@font-face {
  font-family: 'Sora';
  src: url('../assets/fonts/sora-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Hanken Grotesk';
  src: url('../assets/fonts/hanken-grotesk-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

/* ============================================================
   ML TRACK — Base design system
   Ported from the Quantro AI navy / gold / cream system.
   Everything shared lives here: tokens, typography, buttons,
   nav, footer, reveal. Page layers (curriculum, lesson, viz)
   load AFTER this file and only add what they need.
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overflow-x: hidden; }
img, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul { list-style: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

/* ---------- Brand-constant tokens ---------- */
:root {
  --gold:        #D3AE6C;
  --gold-bright: #E3C58A;
  --gold-deep:   #B8914F;
  --gold-ink:    #7E5E26;
  --navy-band:   #112251;
  --navy-deep:   #0C1733;
  --cream:       #F5F1EA;

  --font-display: 'Sora', system-ui, sans-serif;
  --font-body:    'Hanken Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --maxw: 1240px;
  --gutter: clamp(20px, 5vw, 64px);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);

  /* Section accents — light theme. One per roadmap section; every module
     inside a section shares it, which is what groups them visually.
     Hues follow the source roadmap, but its neon values (cyan #00e5ff,
     mint #00ff9d) are invisible on cream, so each is darkened here and
     re-brightened for dark theme below. */
  --ac-found:   #0E8FA8;   /* Foundations           */
  --ac-classic: #6D3FC8;   /* Classical ML          */
  --ac-deep:    #C93B7B;   /* Deep Learning         */
  --ac-llm:     #B57A0B;   /* LLMs & RAG            */
  --ac-prod:    #12916A;   /* Production AI         */
  --ac-extra:   #C75B15;   /* Recommended Additions */

  /* Separate ink values keep small accent text accessible on cream. */
  --ac-found-ink:   #0B6F82;
  --ac-classic-ink: #6D3FC8;
  --ac-deep-ink:    #A92F65;
  --ac-llm-ink:     #805400;
  --ac-prod-ink:    #087557;
  --ac-extra-ink:   #9A430C;
}

/* ---------- Light theme (default) ---------- */
:root, [data-theme="light"] {
  --bg:           #F5F1EA;
  --bg-alt:       #FFFFFF;
  --surface:      #FFFFFF;
  --surface-2:    #FBF8F2;
  --text:         #0C1733;
  --text-muted:   rgba(12,23,51,.62);
  --text-subtle:  rgba(12,23,51,.62);
  --text-faint:   rgba(12,23,51,.40);
  --border:       #E5DFD0;
  --border-strong:#D8CDB4;
  --nav-solid:    rgba(255,255,255,.86);
  --halftone:     rgba(211,174,108,.16);
  --grid-line:    rgba(12,23,51,.05);
  --shadow-card:  0 1px 2px rgba(12,23,51,.04), 0 18px 40px -28px rgba(12,23,51,.22);
  --shadow-gold:  0 18px 48px -24px rgba(211,174,108,.55);
  --code-bg:      #0C1733;
  --code-text:    #E8E3D8;

  /* Same red the lesson widgets use for error/residual states — one
     "error" hue for the whole site, not a second invented one. --danger
     is deep enough for white text on a filled button; --danger-ink is
     for text/borders directly on --surface. */
  --danger:     #A63831;
  --danger-ink: #C0453C;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --bg:           #0C1733;
  --bg-alt:       #112251;
  --surface:      #16275A;
  --surface-2:    #14224F;
  --text:         #F5F1EA;
  --text-muted:   rgba(245,241,234,.66);
  --text-subtle:  rgba(245,241,234,.66);
  --text-faint:   rgba(245,241,234,.40);
  --border:       #3C507E;
  --border-strong:#4C619A;
  --nav-solid:    rgba(12,23,51,.80);
  --halftone:     rgba(211,174,108,.13);
  --grid-line:    rgba(245,241,234,.05);
  --shadow-card:  0 1px 2px rgba(0,0,0,.3), 0 22px 50px -28px rgba(0,0,0,.7);
  --shadow-gold:  0 22px 60px -26px rgba(211,174,108,.45);
  --code-bg:      #081025;
  --code-text:    #E8E3D8;

  /* Brighter accents so they don't muddy against navy. */
  --ac-found:   #35D6F0;
  --ac-classic: #A98BF5;
  --ac-deep:    #F0709A;
  --ac-llm:     #F0B23C;
  --ac-prod:    #3ED9A2;
  --ac-extra:   #F59355;
  --ac-found-ink:   #35D6F0;
  --ac-classic-ink: #A98BF5;
  --ac-deep-ink:    #F0709A;
  --ac-llm-ink:     #F0B23C;
  --ac-prod-ink:    #3ED9A2;
  --ac-extra-ink:   #F59355;
  --gold-ink:       #D3AE6C;
  --danger:         #C24A40;
  --danger-ink:     #F0796C;
}

/* ---------- Base ---------- */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.6;
  letter-spacing: -0.005em;
  transition: background .5s var(--ease), color .5s var(--ease);
}

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.025em;
  color: var(--text);
  text-wrap: balance;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-ink);
  display: inline-flex; align-items: center; gap: .6em;
}
[data-theme="dark"] .eyebrow { color: var(--gold); }
.eyebrow::before { content: ""; width: 22px; height: 1px; background: currentColor; opacity: .8; }

.gold { color: var(--gold-ink); }
[data-theme="dark"] .gold { color: var(--gold); }

.section { padding-block: clamp(64px, 8vw, 112px); position: relative; }
.section-head { max-width: 680px; margin-bottom: clamp(40px, 5vw, 68px); }
.section-head h2 { font-size: clamp(2rem, 4.2vw, 3.25rem); margin-top: 18px; }
.section-head p { color: var(--text-muted); font-size: clamp(1.05rem, 1.5vw, 1.25rem); margin-top: 18px; max-width: 56ch; }

/* ---------- Sparkle motif ---------- */
.sparkle {
  display: inline-block;
  background: var(--gold);
  clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6em;
  font-family: var(--font-body); font-weight: 600; font-size: 1rem;
  padding: 15px 26px; border-radius: 999px;
  letter-spacing: -0.01em; white-space: nowrap;
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out),
              background .25s, color .25s, border-color .25s;
}
.btn-gold {
  background: var(--gold); color: var(--navy-deep);
  box-shadow: 0 10px 26px -12px rgba(211,174,108,.7);
}
.btn-gold:hover { background: var(--gold-bright); transform: translateY(-2px); box-shadow: 0 18px 40px -14px rgba(211,174,108,.85); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-deep); transform: translateY(-2px); }
[data-theme="dark"] .btn-ghost:hover { color: var(--gold); }
.btn .arrow { transition: transform .35s var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }
.btn-sm { padding: 10px 18px; font-size: .9rem; }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  transition: background .4s var(--ease), backdrop-filter .4s, border-color .4s;
  border-bottom: 1px solid transparent;
}
.nav.solid {
  background: var(--nav-solid);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin-inline: auto;
  padding: 16px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
/* Quantro AI mark: navy on light, cream on navy. A background image rather
   than an <img> so one rule serves every page depth and follows the theme. */
.brand-logo {
  width: 51px; height: 38px; flex: none;
  background: url(../assets/brand/qai-mark-navy.webp) center / contain no-repeat;
}
[data-theme="dark"] .brand-logo { background-image: url(../assets/brand/qai-mark-cream.webp); }
.brand .wordmark {
  font-family: var(--font-display); font-weight: 600; font-size: 1.22rem; letter-spacing: -.02em; white-space: nowrap;
  padding-left: 12px; border-left: 1px solid var(--border-strong); line-height: 1.5;
}
.brand .wordmark b { font-weight: 700; color: var(--gold-deep); }
[data-theme="dark"] .brand .wordmark b { color: var(--gold); }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 9px 14px; border-radius: 10px; font-size: .95rem; font-weight: 500; white-space: nowrap;
  color: var(--text-muted); transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--grid-line); }

.nav-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--border); color: var(--text-muted);
  transition: color .2s, border-color .2s, background .2s, transform .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
.nav-cta { padding: 12px 20px; font-size: .95rem; }
.nav-burger { display: none; }

/* "My learning" entry with the review due-count badge (js/app.js). */
.nav-study {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  color: var(--text-muted); font-size: .92rem; font-weight: 600; white-space: nowrap;
  transition: color .2s, border-color .2s, transform .2s;
}
.nav-study:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.nav-study svg { width: 19px; height: 19px; flex: none; }
.nav-study-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--gold); color: var(--navy-deep);
  font: 700 .68rem/20px var(--font-mono); text-align: center;
}
.nav-study-badge[hidden] { display: none; }

/* mobile menu panel */
.mobile-menu {
  display: none; flex-direction: column; gap: 4px;
  padding: 8px var(--gutter) 22px; border-top: 1px solid var(--border);
  max-height: calc(100vh - 76px); overflow-y: auto;
}
.mobile-menu a, .mobile-menu button:not(.btn) {
  min-height: 44px; width: 100%; text-align: left;
  padding: 11px 6px; font-size: 1.05rem; font-weight: 500;
  color: var(--text); border-bottom: 1px solid var(--border);
}
.mobile-menu .btn { margin-top: 16px; }

/* ============================================================
   HERO shell (shared background treatment)
   ============================================================ */
.hero {
  position: relative; padding-top: 132px;
  padding-bottom: clamp(64px, 8vw, 112px);
  overflow: hidden; background: var(--bg);
  transition: background .5s var(--ease);
}
.hero-halftone {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(var(--halftone) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(120% 90% at 78% 18%, #000 0%, transparent 62%);
          mask-image: radial-gradient(120% 90% at 78% 18%, #000 0%, transparent 62%);
}
.hero-glow {
  position: absolute; z-index: 0; top: -10%; right: -6%;
  width: 60vw; height: 60vw; max-width: 760px; max-height: 760px;
  background: radial-gradient(circle, rgba(211,174,108,.20), transparent 62%);
  pointer-events: none; filter: blur(8px);
}
.hero .wrap { position: relative; z-index: 2; }
.hero h1 { font-size: clamp(2.7rem, 6vw, 5.1rem); letter-spacing: -0.035em; }
.hero h1, .hero-sub { overflow-wrap: anywhere; }
.hero-sub { margin-top: 28px; font-size: clamp(1.12rem, 1.5vw, 1.36rem); color: var(--text-muted); max-width: 52ch; line-height: 1.55; }
.hero-cta { margin-top: 38px; display: flex; flex-wrap: wrap; gap: 14px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: clamp(48px, 7vw, 96px);
  align-items: center;
}
.hero-copy { min-width: 0; }
.hero-panel {
  position: relative;
  padding: clamp(24px, 3vw, 34px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}

/* Shared inline icon treatment. */
.module-icon { display: inline-grid; place-items: center; color: var(--accent, var(--gold-ink)); }
.module-icon svg { width: 1em; height: 1em; stroke: currentColor; }

/* ============================================================
   FOOTER — navy in both themes
   ============================================================ */
.footer { background: var(--navy-deep); color: var(--cream); margin-top: auto; }
.footer .wrap { padding-block: clamp(56px, 7vw, 84px) 0; }
.footer-top {
  display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr; gap: 40px;
  padding-bottom: 48px; border-bottom: 1px solid rgba(245,241,234,.12);
}
.footer-lockup { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 22px; }
.footer-mark { width: 80px; height: 60px; flex: none; }
.footer-tagline {
  font-family: var(--font-display); font-size: .82rem; font-weight: 500; line-height: 1.3;
  letter-spacing: .01em; color: rgba(245,241,234,.78);
}
/* Pages with the slim footer carry the mark beside the copyright line. */
.footer-bottom .copy::before {
  content: ""; display: inline-block; vertical-align: middle;
  width: 35px; height: 26px; margin: -4px 12px 0 0;
  background: url(../assets/brand/qai-mark-cream.webp) center / contain no-repeat;
}
.footer-top + .footer-bottom .copy::before { content: none; }
.footer-brand .wordmark { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; color: var(--cream); }
.footer-brand .wordmark b { color: var(--gold-bright); }
.footer-brand p { color: rgba(245,241,234,.6); max-width: 36ch; font-size: 1rem; margin-top: 12px; }
.footer-col h4 {
  font-family: var(--font-body); font-size: .78rem; letter-spacing: .16em;
  text-transform: uppercase; color: rgba(245,241,234,.45); font-weight: 600; margin-bottom: 18px;
}
.footer-col a { display: block; color: rgba(245,241,234,.72); padding: 7px 0; font-size: .98rem; transition: color .2s; }
.footer-col a:hover { color: var(--gold); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding-block: 26px; flex-wrap: wrap;
}
.footer-bottom .copy { color: rgba(245,241,234,.5); font-size: .9rem; }
.footer-reset {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .04em;
  color: rgba(245,241,234,.5); border: 1px solid rgba(245,241,234,.18);
  border-radius: 9px; padding: 8px 14px; transition: .25s;
}
.footer-reset:hover { color: var(--gold); border-color: var(--gold); }

/* ============================================================
   SCROLL REVEAL
   ============================================================ */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.reveal[data-d="1"] { transition-delay: .08s; }
.reveal[data-d="2"] { transition-delay: .16s; }
.reveal[data-d="3"] { transition-delay: .24s; }
.reveal[data-d="4"] { transition-delay: .32s; }
.reveal[data-d="5"] { transition-delay: .40s; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -60px; left: var(--gutter); z-index: 200;
  background: var(--gold); color: var(--navy-deep); padding: 12px 20px;
  border-radius: 0 0 10px 10px; font-weight: 600; transition: top .2s;
}
.skip-link:focus { top: 0; }

/* ============================================================
   GLOBAL SEARCH, FEEDBACK AND DIALOGS
   ============================================================ */
.nav-search-label { display: none; }
.search-dialog, .confirm-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0; border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); color: var(--text); background: var(--surface);
  box-shadow: 0 32px 90px -28px rgba(12,23,51,.48);
}
.search-dialog::backdrop, .confirm-dialog::backdrop {
  background: rgba(7,14,32,.58); backdrop-filter: blur(6px);
}
.search-shell { display: flex; flex-direction: column; max-height: inherit; }
.search-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.search-head svg { width: 20px; height: 20px; color: var(--text-subtle); }
.search-input {
  min-width: 0; width: 100%; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 500 1.08rem/1.4 var(--font-body);
}
.search-input::placeholder { color: var(--text-subtle); }
.search-close { width: 40px; height: 40px; }
.search-status {
  padding: 12px 20px 6px; color: var(--text-subtle);
  font: 600 .7rem/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
}
.search-results { overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.search-result {
  --accent-ink: var(--gold-ink);
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px;
  align-items: center; padding: 12px; border-radius: 14px; border: 1px solid transparent;
}
.search-result:hover, .search-result[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent, var(--gold)) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--accent, var(--gold)) 28%, var(--border));
}
.search-result-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: color-mix(in srgb, var(--accent, var(--gold)) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent, var(--gold)) 28%, var(--border));
  font-size: 19px;
}
.search-result strong { display: block; font: 600 .98rem/1.35 var(--font-display); }
.search-result small { display: block; color: var(--text-muted); font-size: .85rem; line-height: 1.4; margin-top: 2px; }
.search-result-state {
  color: var(--accent-ink); font: 600 .64rem/1.2 var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.search-empty { padding: 44px 24px 54px; text-align: center; color: var(--text-muted); }
.search-empty strong { display: block; color: var(--text); font-family: var(--font-display); margin-bottom: 6px; }
.search-foot {
  display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 20px;
  border-top: 1px solid var(--border); color: var(--text-subtle); font-size: .78rem;
}
.search-foot kbd {
  font: 600 .68rem var(--font-mono); border: 1px solid var(--border-strong);
  background: var(--surface-2); border-radius: 5px; padding: 2px 6px;
}

.toast-region {
  position: fixed; inset: auto max(16px, var(--gutter)) 20px auto; z-index: 300;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px;
  border-radius: 12px; color: var(--cream); background: var(--navy-deep);
  border: 1px solid rgba(255,255,255,.14); box-shadow: 0 16px 44px -20px rgba(0,0,0,.62);
  font-size: .92rem; line-height: 1.4; animation: toast-in .28s var(--ease-out) both;
}
.toast.is-error { border-color: rgba(238,123,114,.68); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.confirm-form { padding: 28px; }
.confirm-form h2 { font-size: 1.45rem; }
.confirm-form p { color: var(--text-muted); margin-top: 10px; max-width: 48ch; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 84%, black); transform: translateY(-1px); }

.inline-state, .noscript-state, .noscript-note {
  margin: 24px auto; padding: 20px 22px; max-width: 680px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-muted);
}
.inline-state strong, .noscript-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px) {
  .footer-top { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .nav-links { display: none; }
  .nav-burger { display: grid; }
  .nav-cta.desktop { display: none; }
  .nav.menu-open { background: var(--nav-solid); backdrop-filter: blur(16px); }
  .nav.menu-open .mobile-menu { display: flex; }
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-panel { max-width: 680px; }
}
@media (min-width: 1001px) { .mobile-menu { display: none !important; } }
/* Between the burger breakpoint and full desktop width there is only room
   for the three primary links; secondary ones (a lesson's module, on-page
   anchors) return at 1280px and are always in the mobile menu. */
@media (min-width: 1001px) and (max-width: 1279px) {
  .nav-links a:nth-child(n+4) { display: none; }
}
/* Below full desktop width — or whenever app.js finds the nav too
   crowded (.is-compact) — "My learning" folds to its icon; the badge
   rides on the corner so the due count stays visible. */
.nav-study.is-compact { width: 44px; padding: 0; justify-content: center; }
.nav-study.is-compact .nav-study-label { display: none; }
.nav-study.is-compact .nav-study-badge { position: absolute; top: -7px; right: -7px; box-shadow: 0 0 0 2px var(--bg); }
@media (max-width: 1279px) {
  .nav-study { width: 44px; padding: 0; justify-content: center; }
  .nav-study-label { display: none; }
  .nav-study-badge { position: absolute; top: -7px; right: -7px; box-shadow: 0 0 0 2px var(--bg); }
}
/* On the narrowest phones the account link moves into the menu only, so
   the header keeps search, My learning and the menu button on one line. */
@media (max-width: 420px) {
  .nav-actions > [data-account-link] { display: none; }
}
@media (max-width: 720px) {
  .footer-top { grid-template-columns: 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .hero { padding-top: 104px; }
  .hero h1 { font-size: clamp(1.9rem, 8vw, 2.4rem); }
  .section-head h2 { font-size: clamp(1.45rem, 6vw, 1.9rem); }
  .hero-sub { font-size: .98rem; margin-top: 18px; }
  .section-head p { font-size: .95rem; }
  .btn { padding: 12px 19px; font-size: .92rem; }
  .section { padding-block: clamp(40px, 10vw, 60px); }
  .section-head { margin-bottom: 26px; }
  .hero-cta { margin-top: 26px; }
  .hero-cta .btn { width: 100%; white-space: normal; }
  .nav-inner { padding-block: 12px; gap: 12px; }
  .nav-actions { gap: 6px; }
  .nav-actions > [data-theme-toggle] { display: none; }
  .brand { gap: 10px; }
  .brand-logo { width: 46px; height: 34px; }
  .brand .wordmark { font-size: 1.12rem; padding-left: 10px; }
  .hero-grid { gap: 30px; }
  .hero-panel { padding: 20px; }
  .search-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .search-result { grid-template-columns: 36px minmax(0, 1fr); }
  .search-result-state { grid-column: 2; }
  .search-foot { display: none; }
  .toast-region { inset-inline: 16px; align-items: stretch; }
}

/* The narrowest phones (320px) need a few more pixels for the nav actions. */
@media (max-width: 360px) {
  .brand { gap: 8px; }
  .brand-logo { width: 40px; height: 30px; }
  .brand .wordmark { font-size: 1.05rem; padding-left: 8px; }
}

@media (forced-colors: active) {
  .btn, .icon-btn, .mod-card, .lesson-row, .viz, .rm-module { border: 1px solid ButtonText; }
  .sparkle { background: ButtonText; }
}
@media (forced-colors: active) and (prefers-color-scheme: dark) {
  .brand-logo { background-image: url(../assets/brand/qai-mark-cream.webp); }
}

/* ============================================================
   REDUCED MOTION — collapse everything decorative
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Theme wipe: don't cross-fade the whole page during a View Transition,
   the circular clip-path in app.js does the work. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
