/* ============================================
   Terminal Color Scheme Designer — Design System
   ============================================ */
:root {
    --bg-primary: #0F1219;
    --bg-secondary: #1A1F2E;
    --bg-card: rgba(26, 31, 46, 0.85);
    --bg-glass: rgba(26, 31, 46, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #38BDF8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Courier New', monospace;
}

[data-theme="light"] {
    --bg-primary: #F1F5F9;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 600px 400px at 25% 25%, rgba(56, 189, 248, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.header {
    padding: 16px 0 12px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.5rem;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #818CF8);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
}

.tagline {
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--accent);
}

.icon {
    width: 18px;
    height: 18px;
}

.moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #818CF8);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

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

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.76rem;
}

.section {
    margin-bottom: 20px;
}

.section h2 {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.section h3 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 10px 0 6px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Presets */
.presets-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    border-radius: 999px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.preset-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Palette Grid */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.color-cell {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.color-cell:hover {
    transform: scale(1.08);
    border-color: var(--accent);
    z-index: 2;
}

.color-cell .c-label {
    font-size: 0.52rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.color-cell input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
}

.special-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.special-cell {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
    position: relative;
}

.special-cell:hover {
    border-color: var(--accent);
}

.special-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
}

.special-cell .s-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.special-cell input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Terminal Preview */
.terminal {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-md);
}

.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-red {
    background: #FF5F56;
}

.dot-yellow {
    background: #FFBD2E;
}

.dot-green {
    background: #27C93F;
}

.terminal-title {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.terminal-body {
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.5;
    min-height: 200px;
}

/* Contrast */
.contrast-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.contrast-good {
    color: #4ADE80;
}

.contrast-bad {
    color: #F87171;
}

/* Export */
.format-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 0;
}

.format-tab {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.format-tab:hover {
    color: var(--text-secondary);
}

.format-tab.active {
    background: var(--accent);
    color: #fff;
}

.export-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.export-code {
    padding: 14px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--accent);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}

.export-actions {
    display: flex;
    gap: 6px;
    padding: 8px 14px;
    border-top: 1px solid var(--border-glass);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.82rem;
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    .palette-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .special-grid {
        grid-template-columns: 1fr;
    }
}