:root {
    --bg-app: #111827;
    --bg-panel: #1F2937;
    --bg-input: #374151;
    --bg-hover: #4B5563;

    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;

    --border: #374151;
    --border-focus: #10B981;

    --primary: #10B981;
    --primary-hover: #059669;
    --secondary: #34D399;
    --accent: #6EE7B7;

    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #EF4444;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.glass {
    background: rgba(31, 41, 55, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Navbar */
.navbar {
    height: 64px;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.nav-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn.outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn.outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn.dashed {
    border-style: dashed;
    color: var(--text-muted);
}

.btn.dashed:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.btn.sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn.icon {
    padding: 0.4rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
}

.btn.icon:hover {
    color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
}

.full-width {
    width: 100%;
}

/* Workspace */
.main-workspace {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    padding: 2rem;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.editor-pane,
.export-pane {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.editor-pane {
    flex: 3;
}

.export-pane {
    flex: 2;
}

/* Cards */
.helpers-card,
.kv-card,
.export-card,
.presets-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
}

.kv-card {
    flex-grow: 1;
    min-height: 0;
}

.export-card {
    flex-grow: 1;
    min-height: 0;
}

.presets-card {
    max-height: 40%;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-header.space-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.card-body.no-pad {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Auth Grid */
.auth-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.auth-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
    transform: translateY(-2px);
}

/* Validations */
.header-warnings {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--warning);
    background: var(--warning-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.header-warnings.hidden {
    display: none;
}

/* KV Editor */
.kv-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.kv-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.kv-input-group {
    position: relative;
    flex: 1;
}

.kv-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border 0.2s;
}

.kv-input:focus {
    border-color: var(--primary);
}

.kv-input.error {
    border-color: var(--warning);
    background: var(--warning-bg);
}

/* Export Tabs & Viewer */
.tabs {
    display: flex;
    gap: 0.5rem;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: var(--bg-app);
    background: var(--secondary);
    font-weight: 600;
}

.code-viewer {
    flex-grow: 1;
    padding: 1.5rem;
    margin: 0;
    background: #0D1117;
    color: #E5E7EB;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow: auto;
}

/* Presets List */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-item:hover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.raw-input {
    width: 100%;
    height: 200px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: #E5E7EB;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    resize: none;
    outline: none;
}

.raw-input:focus {
    border-color: var(--primary);
}

.form-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-mono);
}

.form-input:focus {
    border-color: var(--primary);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}