/* ================================================================
   ChawaTech — Stylesheet
   Architecture: Tokens → Base → Layout → Components → Utilities
   Single source of truth: all colours, spacing, type derive from
   custom properties on :root. Components never hardcode values.
   ================================================================ */

/* ----------------------------------------------------------------
   1. DESIGN TOKENS
   ---------------------------------------------------------------- */
:root {
    /* Colour — light theme */
    --bg:           #fafaf7;
    --bg-elev:      #ffffff;
    --bg-subtle:    #f3f3ee;
    --border:       #e6e4dd;
    --border-strong:#c9c6bd;
    --text:         #18181b;
    --text-muted:   #57575c;
    --text-soft:    #8b8b91;
    --accent:       #2d4a3e;        /* deep forest — distinctive without shouting */
    --accent-soft:  #e8efea;
    --accent-text:  #1a2e25;
    --danger:       #991b1b;        /* same red as the .form-status.error banner text */

    --syntax-keyword: #b45309;       /* used for inline tags, accent words */
    --syntax-string:  #2d4a3e;
    --syntax-mute:    #8b8b91;

    /* Type — Inter Tight is unusual enough to feel considered;
       Fraunces gives display warmth; JetBrains Mono is the
       universal "this person codes" mono */
    --font-display: 'Fraunces', 'Times New Roman', serif;
    --font-sans:    'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, monospace;

    --fs-xs:   0.78rem;
    --fs-sm:   0.88rem;
    --fs-base: 1rem;
    --fs-md:   1.125rem;
    --fs-lg:   1.375rem;
    --fs-xl:   2rem;
    --fs-2xl:  3rem;
    --fs-3xl:  clamp(2.5rem, 6vw, 4.75rem);

    /* Spacing — 4px base scale */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --s-8: 4rem;
    --s-9: 6rem;
    --s-10: 8rem;

    /* Layout */
    --max-w:     72rem;
    --max-w-sm:  42rem;
    --radius:    8px;
    --radius-sm: 4px;

    /* Motion */
    --t-fast: 120ms;
    --t-base: 200ms;
    --t-slow: 400ms;
    --ease:   cubic-bezier(0.2, 0, 0, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
    --shadow:    0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
}

/* Dark theme — flip only the colours, everything else inherits */
:root[data-theme="dark"] {
    --bg:           #0e0f10;
    --bg-elev:      #18191b;
    --bg-subtle:    #1f2022;
    --border:       #2a2b2e;
    --border-strong:#3a3b3f;
    --text:         #f4f4f5;
    --text-muted:   #a1a1aa;
    --text-soft:    #71717a;
    --accent:       #7eb89e;
    --accent-soft:  #1a2e25;
    --accent-text:  #c4e0d2;
    --danger:       #fca5a5;

    --syntax-keyword: #f0b66f;
    --syntax-string:  #7eb89e;
    --syntax-mute:    #71717a;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow:    0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.4);
}

/* ----------------------------------------------------------------
   2. RESET + BASE
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

img, svg { display: block; max-width: 100%; }

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

input, textarea {
    font: inherit;
    color: inherit;
}

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* Accessible focus — never remove, only refine */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ----------------------------------------------------------------
   3. LAYOUT PRIMITIVES
   ---------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--s-5);
}
.container-sm { max-width: var(--max-w-sm); }

.section { padding: var(--s-9) 0; }
.section-tight { padding: var(--s-7) 0; }

@media (max-width: 640px) {
    .section { padding: var(--s-7) 0; }
    .container { padding: 0 var(--s-4); }
}

/* ----------------------------------------------------------------
   4. NAV
   ---------------------------------------------------------------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    border-bottom: 1px solid transparent;
    transition: border-color var(--t-base) var(--ease);
}
.nav.scrolled { border-bottom-color: var(--border); }

.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--s-4) var(--s-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    position: relative;
    z-index: 1;
}

.brand {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 500;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.brand-logo {
    display: block;
    height: calc(var(--s-6) + var(--s-1));   /* 36px */
    width: auto;
    flex-shrink: 0;
}
.brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--s-5);
    list-style: none;
}
.nav-links a {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    position: relative;
}
.nav-links a:hover { color: var(--text); }
.nav-links a::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -6px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--t-base) var(--ease);
}
.nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }

.nav-actions { display: flex; gap: var(--s-2); align-items: center; }

.icon-btn {
    width: 36px; height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.kbd {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--bg-elev);
    color: var(--text-muted);
}
.cmd-trigger {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 6px 10px 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--text-soft);
    background: var(--bg-elev);
    transition: border-color var(--t-fast) var(--ease);
}
.cmd-trigger:hover { border-color: var(--border-strong); color: var(--text-muted); }

@media (max-width: 720px) {
    .nav-links { display: none; }
}

/* Mobile menu */
.menu-btn { display: none; }
@media (max-width: 720px) {
    .menu-btn { display: grid; }
}

.mobile-menu {
    position: fixed;
    inset: 72px 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: var(--s-4) var(--s-5);
    z-index: 0;   /* below .nav-inner (z-index 1) so the bar is never covered by the sliding panel */
    transform: translateY(-110%);
    visibility: hidden;   /* closed panel must not paint over the top of the header */
    transition: transform var(--t-base) var(--ease), visibility 0s linear var(--t-base);
}
.mobile-menu.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
/* Scrim + blur over the page while the menu is open. Lives outside .nav on purpose:
   .nav has its own backdrop-filter, which would confine any blur inside it to the nav. */
.menu-scrim {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: color-mix(in srgb, var(--bg) 60%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease);
}
@media (max-width: 720px) {
    body:has(.mobile-menu.open) .menu-scrim { opacity: 1; pointer-events: auto; }
    html:has(.mobile-menu.open) { overflow: hidden; }   /* scroll lock */
}
.mobile-menu ul { list-style: none; display: grid; gap: var(--s-3); }
.mobile-menu a {
    display: block;
    padding: var(--s-3) 0;
    font-size: var(--fs-md);
    border-bottom: 1px solid var(--border);
}

/* ----------------------------------------------------------------
   5. HERO
   ---------------------------------------------------------------- */
.hero {
    padding: var(--s-10) 0 var(--s-9);
    position: relative;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 6px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--s-5);
    font-family: var(--font-mono);
}
.status-pill .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
    50%      { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.06); }
}

.hero h1 {
    font-family: var(--font-display);
    font-size: var(--fs-3xl);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: var(--s-5);
    max-width: 18ch;
}
.hero h1 em {
    font-style: italic;
    color: var(--accent);
    font-feature-settings: "ss01";
}

.hero .lede {
    font-size: var(--fs-md);
    color: var(--text-muted);
    max-width: 50ch;
    margin-bottom: var(--s-6);
    line-height: 1.55;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2) var(--s-5);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
    margin-top: var(--s-6);
}
.hero-meta span strong {
    color: var(--text);
    font-weight: 500;
    margin-left: 4px;
}

/* ----------------------------------------------------------------
   6. SECTION HEADERS
   ---------------------------------------------------------------- */
.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--s-4);
    margin-bottom: var(--s-7);
    flex-wrap: wrap;
}
.section-num {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
    letter-spacing: 0.1em;
}
.section-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 400;
    letter-spacing: -0.02em;
}
.section-rule {
    flex: 1;
    height: 1px;
    background: var(--border);
    margin-bottom: 8px;
}

/* ----------------------------------------------------------------
   7. ABOUT
   ---------------------------------------------------------------- */
.about-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: var(--s-8);
    align-items: start;
}
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; gap: var(--s-6); } }

.about-prose p {
    font-size: var(--fs-md);
    color: var(--text);
    margin-bottom: var(--s-4);
    line-height: 1.7;
}
.about-prose p:last-child { margin-bottom: 0; }

.about-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-5);
    box-shadow: var(--shadow-sm);
}
.about-card h4 {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-soft);
    margin-bottom: var(--s-4);
}
.about-card dl { display: grid; gap: var(--s-3); }
.about-card .row {
    display: grid;
    grid-template-columns: 7em 1fr;
    gap: var(--s-3);
    font-size: var(--fs-sm);
    align-items: baseline;
}
.about-card dt { color: var(--text-muted); font-family: var(--font-mono); font-size: var(--fs-xs); }
.about-card dd { color: var(--text); }
.about-card dd a { border-bottom: 1px solid var(--border-strong); }
.about-card dd a:hover { color: var(--accent); border-color: var(--accent); }

/* ----------------------------------------------------------------
   8. STACK
   ---------------------------------------------------------------- */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--s-5);
}

.stack-group {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-5);
    transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.stack-group:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}
.stack-group h4 {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: var(--s-3);
}
.stack-group ul { list-style: none; display: grid; gap: var(--s-2); }
.stack-group li {
    font-size: var(--fs-sm);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.stack-group li::before {
    content: '';
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--text-soft);
    flex-shrink: 0;
}
.stack-group li.primary { color: var(--text); font-weight: 500; }
.stack-group li.primary::before { background: var(--accent); width: 6px; height: 6px; }
.stack-group .meta {
    font-size: var(--fs-xs);
    color: var(--text-soft);
    font-family: var(--font-mono);
    margin-left: auto;
}

/* ----------------------------------------------------------------
   9. WORK / PROJECTS
   ---------------------------------------------------------------- */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Work cards */
.work-list { display: grid; gap: var(--s-3); }
.work-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-5);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--s-5);
    align-items: start;
    transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.work-item:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
@media (max-width: 700px) {
    .work-item { grid-template-columns: 1fr; gap: var(--s-3); }
}

.work-num {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
    padding-top: 4px;
    min-width: 3em;
}

.work-body h3 {
    font-size: var(--fs-md);
    font-weight: 500;
    margin-bottom: var(--s-2);
    letter-spacing: -0.01em;
}
.work-body .work-desc {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-bottom: var(--s-3);
    line-height: 1.6;
}
.work-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.work-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 2px 8px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}
.work-tag.is-primary {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    color: var(--accent-text);
}

.work-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-2);
}
@media (max-width: 700px) { .work-meta { justify-content: flex-start; } }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-5);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text-muted);
    white-space: nowrap;
    transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.btn-outline:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg-subtle); }
.btn-outline svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------------
   10. EDUCATION
   ---------------------------------------------------------------- */
.qual {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-5) var(--s-6);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--s-6);
    align-items: center;
}
@media (max-width: 600px) { .qual { grid-template-columns: 1fr; gap: var(--s-3); padding: var(--s-5); } }
.qual-year {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    color: var(--accent);
}
.qual-body h3 { font-size: var(--fs-md); font-weight: 500; margin-bottom: 4px; }
.qual-body p { color: var(--text-muted); font-size: var(--fs-sm); }
.qual-school {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
}

/* ----------------------------------------------------------------
   11. CONTACT
   ---------------------------------------------------------------- */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-7);
}
@media (max-width: 800px) { .contact-grid { grid-template-columns: 1fr; gap: var(--s-6); } }

.contact-intro h2 {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.025em;
    margin-bottom: var(--s-4);
}
.contact-intro p {
    color: var(--text-muted);
    margin-bottom: var(--s-5);
    font-size: var(--fs-md);
    line-height: 1.6;
}
.contact-direct {
    border-top: 1px solid var(--border);
    padding-top: var(--s-5);
    display: grid;
    gap: var(--s-3);
}
.contact-direct .row {
    display: grid;
    grid-template-columns: 5em 1fr;
    gap: var(--s-3);
    font-size: var(--fs-sm);
}
.contact-direct dt {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-soft);
    align-self: center;
}
.contact-direct dd a { border-bottom: 1px solid var(--border-strong); }
.contact-direct dd a:hover { color: var(--accent); border-color: var(--accent); }

.contact-form { display: grid; gap: var(--s-4); }
.field { display: grid; gap: var(--s-2); }
.field label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--s-3) var(--s-4);
    font-size: var(--fs-base);
    color: var(--text);
    transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}
/* Validation failure: red border until the user edits the field */
.field input.invalid,
.field input.invalid:focus,
.field select.invalid,
.field select.invalid:focus,
.field textarea.invalid,
.field textarea.invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 1px var(--danger);
}
.field textarea { min-height: 130px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 500px) { .field-row { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    background: var(--text);
    color: var(--bg);
    padding: var(--s-3) var(--s-5);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    justify-self: start;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn svg { width: 14px; height: 14px; transition: transform var(--t-fast) var(--ease); }
.btn:hover svg { transform: translateX(2px); }

/* Off-screen field */
.field-aux {
    position: absolute !important;
    left: -10000px !important;
    width: 1px; height: 1px;
    overflow: hidden;
}

.form-status {
    display: none;
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-4);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    border: 1px solid;
}
.form-status.show { display: block; }
.form-status.success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.form-status.error   { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
:root[data-theme="dark"] .form-status.success { color: #86efac; background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.3); }
:root[data-theme="dark"] .form-status.error   { color: #fca5a5; background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); }

/* ----------------------------------------------------------------
   12. FOOTER
   ---------------------------------------------------------------- */
.footer {
    border-top: 1px solid var(--border);
    padding: var(--s-6) 0;
    margin-top: var(--s-8);
}
.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--s-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s-4);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }
.footer ul { list-style: none; display: flex; gap: var(--s-4); }

/* ----------------------------------------------------------------
   13. COMMAND PALETTE (⌘K)
   ---------------------------------------------------------------- */
.cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.cmd-overlay.open { display: flex; animation: fade-in var(--t-fast) var(--ease); }

.cmd-panel {
    width: 100%;
    max-width: 540px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.cmd-search {
    width: 100%;
    padding: var(--s-4) var(--s-5);
    font-size: var(--fs-md);
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}
.cmd-search:focus { outline: none; }
.cmd-list { max-height: 50vh; overflow-y: auto; padding: var(--s-2); }
.cmd-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text);
}
.cmd-item .cmd-label-wrap { flex: 1; }
.cmd-item .cmd-hint {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-soft);
}
.cmd-item.active { background: var(--bg-subtle); }
.cmd-item .cmd-icon {
    width: 16px; height: 16px;
    color: var(--text-soft);
}
.cmd-empty {
    padding: var(--s-5);
    text-align: center;
    color: var(--text-soft);
    font-size: var(--fs-sm);
}
.cmd-foot {
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--s-4);
    font-size: var(--fs-xs);
    color: var(--text-soft);
    font-family: var(--font-mono);
}

/* ----------------------------------------------------------------
   14. UTILITIES + REVEAL ANIMATIONS
   ---------------------------------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------------
   15. DOWNLOADS
   ---------------------------------------------------------------- */
.dl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--s-5);
    margin-top: var(--s-6);
}
.dl-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-5);
    transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}
.dl-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.dl-cover {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--s-5);
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 10;
}
.dl-cover img { width: 100%; height: 100%; object-fit: contain; }
.dl-card h3 { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 500; letter-spacing: -0.01em; }
.dl-card p { color: var(--text-muted); font-size: var(--fs-sm); }
.dl-meta {
    display: flex; gap: var(--s-2); flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-soft);
}
.dl-meta span { padding: 2px 8px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 4px; }
.dl-actions { margin-top: auto; }

/* #downloads is a hash-based exclusive view, not part of the normal scroll
   flow — see initDownloadsView() in app.js. Hidden by default; showing it
   swaps out every other top-level section in <main> instead of scrolling. */
#downloads { display: none; }
html.downloads-view .hero,
html.downloads-view main > .section:not(#downloads) {
    display: none;
}
html.downloads-view #downloads {
    display: block;
}

/* ----------------------------------------------------------------
   16. BACK TO TOP
   ---------------------------------------------------------------- */
.to-top {
    position: fixed;
    right: var(--s-5);
    bottom: var(--s-5);
    z-index: 40;   /* under the menu scrim (45), nav (50) and command palette (200) */
    width: 40px; height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    color: var(--text-muted);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(var(--s-2));
    transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease),
                visibility var(--t-base) var(--ease), color var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease);
}
.to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { color: var(--text); border-color: var(--border-strong); }
.to-top svg { width: 18px; height: 18px; }
