/* ============================================================
   UCAT Tutor design system "Vitals" v2
   Fixed-viewport app (no page scrolling) · SVG icons, no emoji
   Neutral surfaces · teal identity · amber = streak/XP only ·
   green/red = correct/incorrect only · section hues as accents
   ============================================================ */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('fonts/BricolageGrotesque-var.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --canvas: #F5F7F8;
  --surface: #FFFFFF;
  --subtle: #EEF2F2;
  --ink: #0E1A1A;
  --muted: #5B6B6B;
  --hairline: #E3E9E8;

  --brand: #0E9384;
  --brand-strong: #0B7166;
  --brand-tint: #D8F1EC;
  --on-brand: #FFFFFF;

  --correct: #17B26A;
  --correct-tint: #E4F7EE;
  --incorrect: #F04438;
  --incorrect-tint: #FDEAE8;
  --amber: #F79009;
  --amber-deep: #FB6514;
  --amber-tint: #FEF0DC;

  --vr: #2E6BE6;
  --dm: #8250DF;
  --qr: #CA8A04;
  --sj: #E0518D;

  --statusbar: #0E1A1A;

  --display: 'Bricolage Grotesque', -apple-system, system-ui, sans-serif;
  --body: 'Inter', -apple-system, system-ui, sans-serif;

  --r-card: 16px;
  --r-btn: 14px;
  --shadow: 0 1px 2px rgba(14,26,26,.05), 0 4px 16px rgba(14,26,26,.06);
  --shadow-lift: 0 2px 6px rgba(14,26,26,.08), 0 12px 32px rgba(14,26,26,.10);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --canvas: #0A1413;
  --surface: #0F1C1B;
  --subtle: #162726;
  --ink: #EAF2F1;
  --muted: #8AA09E;
  --hairline: #22302F;

  --brand: #2DD4BF;
  --brand-strong: #14B8A6;
  --brand-tint: #123430;
  --on-brand: #06211D;

  --correct-tint: #10291E;
  --incorrect-tint: #331715;
  --amber-tint: #2E2110;

  --vr: #4F86F0;
  --dm: #9B72EC;
  --qr: #E0A82E;
  --sj: #EC77A6;

  --statusbar: #0A1413;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.4);
}

/* ---------- reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
a { color: var(--brand); text-decoration: none; }
img, canvas, svg { display: block; max-width: 100%; }
input, select { font: inherit; color: inherit; }

h1, h2, h3, .display { font-family: var(--display); }
.num { font-variant-numeric: tabular-nums; }

.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.22em; flex-shrink: 0; }
.ic-lg { width: 1.6em; height: 1.6em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* iOS status-bar shim (black-translucent draws under the clock) */
.sat-shim { position: fixed; top: 0; left: 0; right: 0; height: var(--sat); background: var(--statusbar); z-index: 80; pointer-events: none; }

/* hidden haptic trigger (iOS switch trick) */
.haptic-hide { position: fixed; left: -200px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- app shell: fixed viewport, no page scroll ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: calc(8px + var(--sat)) 16px calc(12px + var(--sab));
}
.screen { animation: fadeup .22s ease both; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scroll-y { overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 2px 0 10px; flex-shrink: 0;
}
.topbar .wordmark {
  font-family: var(--display); font-weight: 800; font-size: 20px;
  letter-spacing: -0.02em; color: var(--ink);
}
.topbar .wordmark em { font-style: normal; color: var(--brand); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--hairline);
  color: var(--muted); font-size: 17px;
}
.icon-btn:active { transform: scale(.94); }

.back-row { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; flex-shrink: 0; }
.back-btn { color: var(--muted); font-weight: 600; font-size: 15px; padding: 8px 8px 8px 0; display: flex; align-items: center; gap: 2px; }
.screen-title { font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }

/* ---------- buttons: tactile, pressable, game-grade ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 20px;
  border-radius: 16px;
  font-weight: 700; font-size: 16px;
  letter-spacing: .01em;
  transition: transform .06s ease, box-shadow .06s ease, filter .15s ease;
  width: 100%;
}
.btn-primary {
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 4px 0 var(--brand-strong);
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-strong); }
.btn-ghost {
  background: var(--surface); border: 1.5px solid var(--hairline); color: var(--ink);
  box-shadow: 0 3px 0 var(--hairline);
}
.btn-ghost:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--hairline); }
.btn-quiet { background: none; color: var(--muted); min-height: 44px; font-size: 15px; font-weight: 600; }
.btn-quiet:active { transform: scale(.97); }
.btn-danger { background: var(--incorrect-tint); color: var(--incorrect); box-shadow: 0 3px 0 color-mix(in srgb, var(--incorrect) 30%, transparent); }
.btn-danger:active { transform: translateY(2px); box-shadow: none; }
.btn-amber {
  background: linear-gradient(135deg, var(--amber), var(--amber-deep)); color: #fff;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--amber-deep) 70%, #000);
}
.btn-amber:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--amber-deep) 70%, #000); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 10px; }

.mode-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.mode-card:active { transform: scale(.98); }
.mode-card .mc-body { flex: 1; min-width: 0; }
.mode-card h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.mode-card p { font-size: 13px; color: var(--muted); margin-top: 1px; }
.mode-card .mc-visual { flex-shrink: 0; color: var(--brand); }
.mode-card .chev { color: var(--muted); flex-shrink: 0; }

/* ---------- section chips ---------- */
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  border-radius: 12px; padding: 8px 4px; text-align: center;
  background: var(--surface); border: 1px solid var(--hairline);
}
.chip .c-code { font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.chip .c-rating { font-family: var(--display); font-size: 18px; font-weight: 800; }
.chip .c-delta { font-size: 11px; font-weight: 600; }
.chip.vr .c-code { color: var(--vr); } .chip.dm .c-code { color: var(--dm); }
.chip.qr .c-code { color: var(--qr); } .chip.sj .c-code { color: var(--sj); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 99px;
}
.tag-beta { background: var(--amber-tint); color: var(--amber-deep); }
.tag-pro { background: var(--brand-tint); color: var(--brand-strong); }

/* ---------- the monitor: hero zone ---------- */
.hero {
  position: relative;
  background:
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--brand) 7%, transparent) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--brand) 7%, transparent) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--brand) 12%, transparent) 0 1px, transparent 1px 45px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--brand) 12%, transparent) 0 1px, transparent 1px 45px),
    var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 14px 16px 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.hero .hero-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.hero .hero-rating {
  font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums;
  font-size: 58px; line-height: 1.05; letter-spacing: -0.02em; color: var(--ink);
  display: flex; align-items: baseline; gap: 10px;
}
.hero .hero-delta { font-family: var(--body); font-size: 14px; font-weight: 700; }
.hero .hero-ecg { display: block; width: 100%; height: 44px; margin: 2px 0 6px; }
.hero .hero-mascot { position: absolute; top: 12px; right: 10px; }
.hero .hero-mascot .mascot { width: 64px; height: 68px; margin: 0; }
.hero-vitals {
  display: flex; align-items: center; gap: 14px;
  padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--hairline) 60%, transparent);
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.hero-vitals .hv { display: flex; align-items: center; gap: 5px; }
.hero-vitals .hv b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 800; font-family: var(--display); font-size: 15px; }
.hero-vitals .hv .ic { color: var(--muted); }
.hero-vitals .hv:first-child .ic, .hero-vitals .hv:last-child .ic { color: var(--amber); }
.hero-vitals .hv.risk b, .hero-vitals .hv.risk .ic { color: var(--incorrect); animation: pulse 1.6s infinite; }

/* slim monitor ticker (replaces boxed banners for status lines) */
.ticker {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand); padding: 8px 4px 0; flex-shrink: 0;
  width: 100%; text-align: center;
}
.ticker.warn { color: var(--incorrect); }
.ticker.amber { color: var(--amber-deep); }

/* big daily launcher */
.launch {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--brand); color: var(--on-brand);
  border-radius: 18px; padding: 14px 18px;
  box-shadow: 0 5px 0 var(--brand-strong);
  transition: transform .06s ease, box-shadow .06s ease;
}
.launch:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--brand-strong); }
.launch .l-body { flex: 1; min-width: 0; }
.launch h3 { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.launch p { font-size: 12.5px; opacity: .85; margin-top: 1px; font-weight: 600; }
.launch .ring .ring-label { color: var(--on-brand); }
.launch .chev { flex-shrink: 0; opacity: .9; }

/* pathway strip */
.strip {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--surface); border: 1.5px solid var(--hairline);
  border-radius: 16px; padding: 11px 16px;
  box-shadow: 0 3px 0 var(--hairline);
  transition: transform .06s ease, box-shadow .06s ease;
}
.strip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--hairline); }
.strip .s-ic { color: var(--brand); flex-shrink: 0; }
.strip .s-body { flex: 1; min-width: 0; }
.strip h3 { font-size: 15.5px; font-weight: 800; }
.strip p { font-size: 12px; color: var(--muted); font-weight: 600; }
.strip .chev { color: var(--muted); flex-shrink: 0; }

/* four monitor channels */
.chans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex-shrink: 0; }
.chan {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 8px 8px 6px; text-align: left;
  overflow: hidden;
}
.chan .ch-head { display: flex; align-items: baseline; justify-content: space-between; }
.chan .ch-code { font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.chan .ch-delta { font-size: 10px; font-weight: 700; }
.chan .ch-rating { font-family: var(--display); font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.chan .ch-spark { display: block; width: 100%; height: 14px; margin-top: 3px; opacity: .9; }
.chan.vr .ch-code { color: var(--vr); } .chan.dm .ch-code { color: var(--dm); }
.chan.qr .ch-code { color: var(--qr); } .chan.sj .ch-code { color: var(--sj); }

/* soft banners (kept only where a button is needed); rimless */
.banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 14px; padding: 10px 14px; font-size: 13.5px; line-height: 1.4;
  background: var(--amber-tint); color: var(--ink);
  flex-shrink: 0;
}
.banner.info { background: var(--brand-tint); }
.banner .b-ic { color: var(--amber-deep); flex-shrink: 0; }
.banner.info .b-ic { color: var(--brand-strong); }
.banner .b-close { margin-left: auto; color: var(--muted); padding: 4px; flex-shrink: 0; font-weight: 700; }

/* ---------- goal ring ---------- */
.ring { position: relative; width: 48px; height: 48px; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink);
}

/* ---------- question runner ---------- */
.run-top { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; flex-shrink: 0; }
.run-progress { flex: 1; height: 8px; background: var(--subtle); border-radius: 99px; overflow: hidden; }
.run-progress .rp-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s ease; }
.run-quit { color: var(--muted); padding: 6px; line-height: 1; }
.run-calc { color: var(--muted); padding: 6px; line-height: 1; }

/* ---------- exam calculator ---------- */
#calc-root:empty { display: none; }
.calc {
  position: fixed; right: 14px; bottom: calc(96px + var(--sab)); z-index: 38;
  width: 232px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 10px;
  box-shadow: var(--shadow-lift);
}
.calc-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 0 2px 8px;
}
.calc-head .ck-close { color: var(--muted); padding: 2px; }
.calc-disp {
  background: var(--subtle); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 8px;
  font-family: var(--display); font-weight: 800; font-size: 22px;
  text-align: right; overflow: hidden; white-space: nowrap;
  min-height: 42px;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc .ck {
  min-height: 38px; border-radius: 9px;
  background: var(--subtle); font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 0 var(--hairline);
}
.calc .ck:active { transform: translateY(2px); box-shadow: none; }
.calc .ck.fn { font-size: 12px; color: var(--muted); }
.calc .ck.op { background: var(--brand-tint); color: var(--brand-strong); }
.calc .ck.eq { background: var(--brand); color: var(--on-brand); box-shadow: 0 2px 0 var(--brand-strong); }

.timerbar { height: 4px; background: var(--subtle); border-radius: 99px; overflow: hidden; margin-bottom: 10px; flex-shrink: 0; }
.timerbar .tb-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.timerbar.over .tb-fill { background: var(--amber); }

.run-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.passage {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); padding: 14px;
  font-size: 15px; line-height: 1.55;
  flex: 0 1 auto; max-height: 34dvh; overflow-y: auto;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.passage p + p { margin-top: 10px; }
.passage table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.passage th, .passage td { border: 1px solid var(--hairline); padding: 4px 7px; text-align: left; }
.passage th { background: var(--subtle); font-weight: 600; }

.stem-wrap { flex: 0 1 auto; overflow-y: auto; max-height: 30dvh; margin-bottom: 12px; overscroll-behavior: contain; }
.stem { font-size: 16.5px; font-weight: 600; line-height: 1.45; }
.sec-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-label .sec-name { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.sec-label.vr .sec-name { color: var(--vr); } .sec-label.dm .sec-name { color: var(--dm); }
.sec-label.qr .sec-name { color: var(--qr); } .sec-label.sj .sec-name { color: var(--sj); }

.opts { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.opt {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 11px 14px; min-height: 46px;
  background: var(--surface); border: 1.5px solid var(--hairline);
  border-radius: var(--r-btn); font-size: 15px; line-height: 1.35;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.opt:active { transform: scale(.985); }
.opt .o-key {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--subtle); color: var(--muted);
  font-size: 12px; font-weight: 700;
}
.opt.selected { border-color: var(--brand); background: var(--brand-tint); }
.opt.selected .o-key { background: var(--brand); color: var(--on-brand); }
.opt.correct { border-color: var(--correct); background: var(--correct-tint); }
.opt.correct .o-key { background: var(--correct); color: #fff; }
.opt.wrong { border-color: var(--incorrect); background: var(--incorrect-tint); }
.opt.wrong .o-key { background: var(--incorrect); color: #fff; }
.opt.dim { opacity: .55; }
.opt[disabled] { cursor: default; }

.run-actions { margin-top: auto; padding-top: 12px; flex-shrink: 0; }

/* ---------- feedback bottom sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 39; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 640px; margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .22);
  padding: 16px 20px calc(14px + var(--sab));
  animation: slideup .26s cubic-bezier(.3, 1.2, .4, 1) both;
}
/* verdict is carried by the mascot, kicker and glow; no colored rims */
.sheet.good .sheet-coach::before, .sheet.bad .sheet-coach::before {
  content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%;
  left: -18px; top: -14px; pointer-events: none;
  background: radial-gradient(closest-side, var(--correct) 0%, transparent 70%);
  opacity: .14;
}
.sheet.bad .sheet-coach::before { background: radial-gradient(closest-side, var(--incorrect) 0%, transparent 70%); }
.sheet-coach { position: relative; }
.verdict { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.verdict.good { color: var(--correct); }
.verdict.bad { color: var(--incorrect); }
.verdict .v-delta { margin-left: auto; font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--muted); }
.sheet-scroll { max-height: 34dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* mascot + speech-bubble feedback inside the sheet */
.sheet-coach { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.sheet-coach .mascot { width: 70px; height: 70px; margin: 10px 0 0; animation: none; }
.sheet-coach .mascot.pm-shake { animation: pmShake .45s ease 1; }
.bubble-h {
  position: relative; flex: 1; min-width: 0;
  background: var(--subtle); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 12px 14px;
  font-size: 14.5px; line-height: 1.5;
}
.bubble-h::before {
  content: ''; position: absolute; left: -7.5px; top: 26px;
  width: 13px; height: 13px; background: var(--subtle);
  border-left: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  transform: rotate(45deg);
}
.bubble-h .kicker {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--display); font-weight: 800; font-size: 16px;
  margin-bottom: 6px;
}
.bubble-h .kicker.good { color: var(--correct); }
.bubble-h .kicker.bad { color: var(--incorrect); }
.bubble-h .kicker .v-delta { margin-left: auto; font-family: var(--body); font-size: 12px; font-weight: 600; color: var(--muted); }

/* mascot in modals + chart empty state */
.modal .mascot, .chart-empty .mascot { margin: 0 auto 8px; }
.chart-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 14px; padding: 12px; }
.explain { font-size: 14.5px; line-height: 1.5; }
.explain h4 { font-family: var(--body); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.explain .why-wrong { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.explain .why-wrong h4 { color: var(--incorrect); }

/* ---------- mascot & lesson slides ---------- */
.mascot-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 4px 2px; overflow: hidden; }
.bubble {
  position: relative;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 15px 17px;
  font-size: 16px; line-height: 1.5;
  box-shadow: var(--shadow);
  animation: fadeup .2s ease both;
}
.bubble::after {
  content: ''; position: absolute; bottom: -8.5px; left: 40px;
  width: 15px; height: 15px; background: var(--surface);
  border-right: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  transform: rotate(45deg);
}
.bubble .kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--brand); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.bubble.warn .kicker { color: var(--amber-deep); }
.bubble .b-title { font-family: var(--display); font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.bubble .b-scroll { max-height: 26dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.bubble .b-scroll p + p { margin-top: 8px; }
.mascot { width: 104px; height: 104px; margin: 16px 0 0 14px; flex-shrink: 0; animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
.mascot.cheer { animation: hop .5s ease; }
@keyframes hop { 0%, 100% { transform: translateY(0) } 40% { transform: translateY(-12px) } }
.mascot-sm { width: 76px; height: 76px; }
.mascot-xs { width: 34px; height: 34px; margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  /* idle blink on the open-eye moods */
  .mascot .pm-eyes { animation: pmBlink 5.6s infinite both; transform-box: fill-box; transform-origin: center 45%; }
  @keyframes pmBlink { 0%, 92%, 100% { transform: scaleY(1) } 96% { transform: scaleY(0.1) } }
  /* one-shot wave on greeting, then settle into bob */
  .mascot.pm-wave { transform-box: fill-box; transform-origin: bottom center; animation: pmWave 1.4s ease 1, bob 3.4s ease-in-out 1.4s infinite; }
  @keyframes pmWave { 0%, 100% { transform: rotate(0) } 15% { transform: rotate(-7deg) } 32% { transform: rotate(5deg) } 50% { transform: rotate(-5deg) } 68% { transform: rotate(3deg) } }
  /* one-shot shake on a wrong answer */
  .mascot.pm-shake { animation: pmShake .45s ease 1; }
  @keyframes pmShake { 0%, 100% { transform: translateX(0) } 20% { transform: translateX(-5px) } 45% { transform: translateX(5px) } 70% { transform: translateX(-3px) } 88% { transform: translateX(3px) } }
}

/* lesson figures */
.fig-box {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 12px 10px;
  margin-top: 12px;
  display: flex; justify-content: center;
  animation: fadeup .25s ease both;
}
.fig-box svg { width: 100%; max-width: 330px; height: auto; }
.fig-box text { font-family: var(--body); }

/* evidence highlighting in lessons */
mark.hl {
  background: color-mix(in srgb, var(--brand) 28%, transparent);
  color: inherit; border-radius: 4px; padding: 0 3px;
  font-weight: 600;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
mark.hl-warn { background: color-mix(in srgb, var(--amber) 30%, transparent); }
.evidence-box {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 12px 14px;
  font-size: 14.5px; line-height: 1.6;
  max-height: 30dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  margin-top: 12px;
}
.evidence-box p + p { margin-top: 8px; }
.evidence-box .ev-q { font-weight: 700; margin-top: 10px; }
.evidence-box .ev-a { margin-top: 8px; font-weight: 600; color: var(--brand-strong); }

.try-card { margin-top: 12px; }
.try-card .passage { max-height: 24dvh; }
.lesson-dots { display: flex; gap: 5px; justify-content: center; padding: 8px 0 2px; flex-shrink: 0; }
.lesson-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--hairline); }
.lesson-dots i.on { background: var(--brand); }

/* ---------- summary ---------- */
.summary-hero { text-align: center; padding: 14px 0 6px; flex-shrink: 0; }
.summary-hero .s-big { font-family: var(--display); font-size: 42px; font-weight: 800; letter-spacing: -0.02em; }
.summary-hero .s-sub { color: var(--muted); font-size: 14.5px; }
.delta-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: 14.5px; }
.delta-row:last-child { border-bottom: none; }
.delta-up { color: var(--correct); font-weight: 700; }
.delta-down { color: var(--incorrect); font-weight: 700; }
.delta-flat { color: var(--muted); font-weight: 600; }
.xp-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--amber-tint); color: var(--amber-deep);
  font-weight: 700; padding: 6px 14px; border-radius: 99px; font-size: 14px;
}

/* ---------- pathway ---------- */
.unit { margin-bottom: 18px; }
.unit-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border-radius: var(--r-card);
  color: #fff; font-family: var(--display); font-weight: 800; font-size: 16px;
  margin-bottom: 4px;
}
.unit-head .u-rating { margin-left: auto; font-size: 14px; opacity: .95; }
.unit-head .tag-beta { background: rgba(255,255,255,.22); color: #fff; }
.unit-head.tk { background: linear-gradient(135deg, var(--brand), var(--brand-strong)); }
.unit-head.vr { background: linear-gradient(135deg, var(--vr), color-mix(in srgb, var(--vr) 70%, #000)); }
.unit-head.dm { background: linear-gradient(135deg, var(--dm), color-mix(in srgb, var(--dm) 70%, #000)); }
.unit-head.qr { background: linear-gradient(135deg, var(--qr), color-mix(in srgb, var(--qr) 70%, #000)); }
.unit-head.sj { background: linear-gradient(135deg, var(--sj), color-mix(in srgb, var(--sj) 70%, #000)); }

/* ---------- winding pathway ---------- */
.vpath { position: relative; }
.vpath .vtrail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.vnode {
  position: absolute; transform: translateX(-50%);
  width: 84px; text-align: center;
}
.vnode .vn-dot {
  width: 62px; height: 62px; border-radius: 50%;
  margin: 0 auto;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface); border: 2.5px solid var(--hairline);
  color: var(--muted);
  box-shadow: 0 4px 0 var(--hairline);
  transition: transform .06s ease, box-shadow .06s ease;
}
.vnode:active .vn-dot { transform: translateY(3px); box-shadow: 0 1px 0 var(--hairline); }
.vnode.done .vn-dot { background: var(--brand); border-color: var(--brand-strong); color: var(--on-brand); box-shadow: 0 4px 0 var(--brand-strong); }
.vnode.open .vn-dot {
  border-color: var(--brand); color: var(--brand);
  box-shadow: 0 4px 0 var(--brand-strong), 0 0 0 5px var(--brand-tint);
}
.vnode.locked .vn-dot { opacity: .5; }
.vnode.locked { pointer-events: auto; } /* still tappable: explains why locked */
.vnode.mastery .vn-dot { width: 70px; height: 70px; font-size: 26px; }
.vnode .vn-label {
  margin-top: 5px; font-size: 10.5px; font-weight: 700; line-height: 1.25;
  color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vnode.done .vn-label, .vnode.open .vn-label { color: var(--ink); }
.vnode .vn-chip {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--canvas);
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.vnode .vn-tag { position: absolute; top: 46px; right: 2px; }
.vpath .vmascot { position: absolute; width: 58px; pointer-events: none; }
.vpath .vmascot .mascot { width: 58px; height: 62px; margin: 0; }

/* pathway section selector: pick one unit, its winding path shows below */
.pathtabs { display: flex; gap: 7px; padding: 2px 0 12px; flex-shrink: 0; }
.pathtab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 7px;
  background: var(--surface); border: 1.5px solid var(--hairline); border-radius: 12px;
  transition: border-color .12s ease, background .12s ease;
}
.pathtab.on { border-color: var(--brand); background: var(--brand-tint); }
.pathtab:active { transform: scale(.97); }
.pathtab .pt-code { font-family: var(--display); font-size: 14px; font-weight: 800; position: relative; display: inline-flex; align-items: center; line-height: 1; }
.pathtab .pt-code .ic { width: 17px; height: 17px; }
.pathtab .pt-dot { position: absolute; top: -3px; right: -8px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.pathtab .pt-sub { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.pathtab.on .pt-sub { color: var(--brand-strong); }
.pathtab .pt-bar { width: 100%; height: 3px; background: var(--subtle); border-radius: 99px; overflow: hidden; margin-top: 1px; }
.pathtab .pt-bar i { display: block; height: 100%; border-radius: 99px; }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex-shrink: 0; }
.stat-box { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 9px 4px; text-align: center; }
.stat-box .sb-val { font-family: var(--display); font-size: 19px; font-weight: 800; }
.stat-box .sb-label { font-size: 10px; color: var(--muted); font-weight: 600; }

.pchips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; flex-shrink: 0; }
.pchip {
  padding: 6px 11px; border-radius: 99px;
  border: 1.5px solid var(--hairline); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.pchip.on { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint); }

.seg { display: flex; background: var(--subtle); border-radius: 11px; padding: 3px; margin: 12px 0 10px; flex-shrink: 0; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12.5px; }
.bar-row .br-label { width: 116px; flex-shrink: 0; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .br-track { flex: 1; height: 8px; background: var(--subtle); border-radius: 99px; overflow: hidden; }
.bar-row .br-fill { height: 100%; border-radius: 99px; background: var(--brand); }
.bar-row .br-val { width: 40px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.heatmap { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; gap: 3px; }
.heatmap .hm-cell { width: 100%; aspect-ratio: 1; border-radius: 3px; background: var(--subtle); }
.heatmap .hm-1 { background: color-mix(in srgb, var(--brand) 30%, var(--subtle)); }
.heatmap .hm-2 { background: color-mix(in srgb, var(--brand) 55%, var(--subtle)); }
.heatmap .hm-3 { background: var(--brand); }

/* ---------- onboarding ---------- */
.ob { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 8px 4px; overflow: hidden; }
.ob h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 10px; }
.ob .ob-sub { color: var(--muted); font-size: 15.5px; margin-bottom: 22px; }
.ob .ob-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.ob .ob-fineprint { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.45; }
.ob .mascot { margin: 0 auto 14px; align-self: center; }
.ob-dots { display: flex; gap: 6px; justify-content: center; padding: 14px 0 0; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--hairline); }
.ob-dots i.on { background: var(--brand); }

.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; background: var(--surface); border: 1.5px solid var(--hairline);
  border-radius: var(--r-btn); font-size: 16px;
}
.choice.selected { border-color: var(--brand); background: var(--brand-tint); }
.choice .ch-title { font-weight: 700; }
.choice .ch-sub { font-size: 13px; color: var(--muted); }

input[type="date"], input[type="text"], input[type="email"] {
  width: 100%; padding: 13px 16px; min-height: 50px;
  background: var(--surface); border: 1.5px solid var(--hairline);
  border-radius: var(--r-btn); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
input:focus { outline: none; border-color: var(--brand); }

/* ---------- settings ---------- */
.set-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 16px 4px 6px;
}
.data-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--brand-tint); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: var(--r-card); padding: 12px 14px;
  font-size: 13.5px; line-height: 1.45; color: var(--ink);
}
.data-card .mascot { flex-shrink: 0; animation: none; }
.set-row .sr-ic {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 15px;
  background: var(--brand-tint); color: var(--brand-strong);
}
.set-row .sr-ic.danger { background: var(--incorrect-tint); color: var(--incorrect); }
.set-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 2px; border-bottom: 1px solid var(--hairline); font-size: 15px;
}
.set-row:last-child { border-bottom: none; }
.set-row .sr-label { flex: 1; font-weight: 500; }
.set-row .sr-val { color: var(--muted); font-size: 14px; }
.set-row .chev { color: var(--muted); }

.switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; z-index: 2; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--hairline); border-radius: 99px; transition: background .15s; }
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- paywall ---------- */
.pay-hero { text-align: center; padding: 0 0 10px; flex-shrink: 0; }
.pay-hero .mascot { margin: 0 auto 2px; }
.pay-hero .price { font-family: var(--display); font-size: 32px; font-weight: 800; }
.pay-hero .price small { display: block; font-family: var(--body); font-size: 13.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.compare { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.compare th { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 6px 4px; text-align: center; }
.compare th:first-child { text-align: left; }
.compare td { padding: 8px 4px; border-top: 1px solid var(--hairline); text-align: center; color: var(--muted); }
.compare td:first-child { text-align: left; color: var(--ink); font-weight: 500; }
.compare .yes { color: var(--correct); }
.compare .no { color: var(--muted); opacity: .6; }
.compare .pro-col { color: var(--brand-strong); font-weight: 600; }

/* ---------- modal & toast ---------- */
#modal-root:empty, #toast-root:empty { display: none; }
.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,20,19,.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0 } }
.modal {
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--sab));
  animation: slideup .24s cubic-bezier(.3, 1.2, .4, 1) both;
}
@keyframes slideup { from { transform: translateY(48px); opacity: .5 } to { transform: none; opacity: 1 } }
.modal h3 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.modal .m-body { font-size: 15px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }

#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(24px + var(--sab));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--ink); color: var(--canvas);
  padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lift); max-width: 92%;
  animation: toastin .25s ease both;
}
@keyframes toastin { from { transform: translateY(16px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.out { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(10px); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.footer-links {
  padding: 10px 4px 0; font-size: 11.5px; color: var(--muted); text-align: center; flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.footer-links a, .footer-links button { color: var(--muted); text-decoration: underline; font-size: 11.5px; }

.share-preview { border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow-lift); }
.share-preview img { width: 100%; max-height: 46dvh; object-fit: contain; background: #0A1413; }

.explain .qid { text-align: right; font-size: 10.5px; color: var(--muted); opacity: .7; margin-top: 8px; }

/* very short viewports (landscape phones): allow the screen to scroll rather than clip */
@media (max-height: 480px) {
  .screen { overflow-y: auto; }
}

/* exam chrome: hidden on mobile, the real thing on desktop */
.exam-bar, .exam-tools, .exam-footer { display: none; }

/* wide screens: passage beside question */
@media (min-width: 900px) {
  .app { max-width: 720px; }
  .app.wide-run { max-width: 1080px; }
  .run-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; min-height: 0; flex: 1; }
  .run-split .passage { max-height: none; height: 100%; }
  .run-split .run-col { display: flex; flex-direction: column; min-height: 0; height: 100%; }

  /* ---------- desktop exam replica ---------- */
  /* The test centre screen is white with a navy toolbar; muscle memory transfers. */
  .exam-skin {
    --canvas: #FFFFFF; --surface: #FFFFFF; --subtle: #F1F1F1;
    --ink: #111111; --muted: #4b4b4b; --hairline: #C9C9C9;
    color: var(--ink); /* re-anchor inheritance: body carries the app theme's ink */
    background: #fff; border: 1px solid #C9C9C9; border-radius: 6px; overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
    animation: none;
  }
  .exam-skin .run-top, .exam-skin .timerbar, .exam-skin .run-actions { display: none; }
  .exam-skin .run-body { padding: 22px 26px; }
  .exam-skin .stem { font-weight: 500; font-family: inherit; }
  .exam-skin .sec-label .sec-name { color: var(--muted) !important; }
  .exam-skin .passage { box-shadow: none; border-color: #C9C9C9; }

  .exam-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: #17497F; color: #fff;
    padding: 10px 18px; font-size: 14px; font-weight: 700;
    flex-shrink: 0;
  }
  .exam-bar .eb-right { display: flex; align-items: center; gap: 10px; font-weight: 600; }
  .exam-bar .eb-sep { width: 1px; height: 14px; background: rgba(255,255,255,.4); }
  .exam-bar #exam-clock { font-variant-numeric: tabular-nums; font-weight: 800; }
  .exam-bar #exam-clock.over { color: #FFB74D; }

  .exam-tools {
    display: flex; align-items: center; justify-content: space-between;
    background: #2E6CB3; padding: 6px 14px; flex-shrink: 0;
  }
  .exam-tools button {
    display: flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,.12); color: #fff;
    border: 1px solid rgba(255,255,255,.35); border-radius: 4px;
    padding: 6px 14px; font-size: 13px; font-weight: 600;
  }
  .exam-tools button:hover { background: rgba(255,255,255,.22); }
  .exam-tools button.on { background: #F79009; border-color: #F79009; color: #1a1a1a; }

  .exam-footer {
    display: flex; align-items: center; justify-content: space-between;
    background: #17497F; padding: 10px 18px; flex-shrink: 0;
    margin-top: auto;
  }
  .exam-footer button {
    display: flex; align-items: center; gap: 6px;
    color: #fff; font-size: 14px; font-weight: 700;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35);
    border-radius: 4px; padding: 8px 20px;
  }
  .exam-footer button:hover { background: rgba(255,255,255,.22); }
  .exam-footer #ex-quit { background: none; border: none; opacity: .75; font-weight: 600; }

  /* exam options read as radio rows */
  .exam-skin .opt { border-radius: 4px; box-shadow: none; }
  .exam-skin .opt .o-key {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid #555; background: #fff; color: transparent;
    font-size: 0;
  }
  .exam-skin .opt.selected { background: #EAF1FA; border-color: #17497F; }
  .exam-skin .opt.selected .o-key { border-color: #17497F; background: radial-gradient(circle, #17497F 0 44%, #fff 48%); }
  .exam-skin .opt.correct .o-key { border-color: var(--correct); background: radial-gradient(circle, var(--correct) 0 44%, #fff 48%); }
  .exam-skin .opt.wrong .o-key { border-color: var(--incorrect); background: radial-gradient(circle, var(--incorrect) 0 44%, #fff 48%); }
}

/* the desktop nav rail is invisible until the desktop frame turns on */
.dsidebar { display: none; }
/* desktop-only elements stay out of the phone layout entirely */
.d-only { display: none; }
/* these wrappers are transparent to the phone's flex layout;
   the desktop frame turns them into real grid/flex boxes */
.home-status { display: contents; }
.bank-pickers { display: contents; }

/* ============================================================
   DESKTOP FRAME (>=1024px): persistent nav rail + wide dashboard.
   Everything below lives inside this query, so phones/tablets and
   the whole iOS-native feel are byte-for-byte unchanged.
   ============================================================ */
@media (min-width: 1024px) {
  #shell { display: flex; align-items: stretch; height: 100dvh; }

  /* ---------- the nav rail ---------- */
  .dsidebar {
    display: flex; flex-direction: column;
    width: 224px; flex-shrink: 0; height: 100dvh;
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    padding: calc(20px + var(--sat)) 14px calc(16px + var(--sab));
    gap: 3px;
  }
  #shell.immersive .dsidebar { display: none; }

  .ds-brand {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 8px 16px; width: 100%; text-align: left;
  }
  .ds-brand .mascot { width: 30px; height: 30px; margin: 0; animation: none; }
  .ds-brand .wordmark { font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; color: var(--ink); }
  .ds-brand .wordmark em { font-style: normal; color: var(--brand); }

  .ds-nav { display: flex; flex-direction: column; gap: 2px; }
  .ds-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 11px;
    font-size: 14.5px; font-weight: 700; color: var(--muted);
    width: 100%; text-align: left;
    transition: background .12s ease, color .12s ease;
  }
  .ds-item:hover { background: var(--subtle); color: var(--ink); }
  .ds-item.on { background: var(--brand-tint); color: var(--brand-strong); }
  .ds-item .ds-ic { display: grid; place-items: center; width: 22px; flex-shrink: 0; }
  .ds-item .ds-ic .ic { width: 20px; height: 20px; }
  .ds-item .ds-lab { flex: 1; }

  .ds-spacer { flex: 1; min-height: 14px; }

  .ds-foot { margin-top: 8px; }
  .ds-foot .ds-item { color: var(--muted); }
  .ds-legal { font-size: 10.5px; color: var(--muted); line-height: 1.5; padding: 6px 12px 0; }

  /* ---------- content area fills the rest ---------- */
  .app { max-width: none; margin: 0; flex: 1; min-width: 0; padding: calc(22px + var(--sat)) 34px calc(20px + var(--sab)); }
  .screen { max-width: 780px; width: 100%; margin: 0 auto; }
  .screen.home { max-width: 1180px; }
  .screen.bank-screen { max-width: 1000px; }

  /* run + lesson + onboarding stay full-focus (rail already hidden) */
  .app.wide-run .screen { max-width: none; margin: 0; }

  /* desktop-only elements come back; specific shapes below override */
  .d-only { display: block; }

  /* ---------- home: "The Coach's Bench" ----------
     Left column: Pulse the coach (focus card -> CTA+up-next -> review).
     Right column: a graph-paper instrument bank (section vitals matched
     to the focus card, question-bank completion, course). Every box edge
     lands on a shared grid line so the whole panel reads level. */
  .screen.home {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr);
    grid-template-areas:
      "status    status"
      "focus     vitals"
      "focus     vitals"
      "prescribe bank"
      "queue     course"
      "foot      foot";
    column-gap: 22px; row-gap: 14px;
    align-content: start;
    overflow-y: auto; overscroll-behavior: contain;
  }
  .screen.home > .topbar,
  .screen.home > .spacer,
  .screen.home > .btn-row { display: none; }
  .screen.home > .hero { grid-area: focus; margin: 0; align-self: stretch; }
  .screen.home > .home-status { grid-area: status; display: flex; flex-direction: column; gap: 10px; }
  .screen.home > .home-status:empty { display: none; }
  .screen.home > .stack { grid-area: prescribe; margin: 0; align-self: stretch; display: flex; flex-direction: column; gap: 12px; }
  .screen.home > .chans { grid-area: vitals; margin: 0; align-self: stretch; }
  .screen.home > .dbank { grid-area: bank; align-self: stretch; }
  .screen.home > .dcourse { grid-area: course; align-self: stretch; }
  .screen.home > .dqueue { grid-area: queue; align-self: stretch; }
  .screen.home > .footer-links { grid-area: foot; margin-top: 2px; text-align: left; }

  /* nav duplicates leave the dashboard: the sidebar already owns them */
  .screen.home #btn-path,
  .screen.home #btn-bank,
  .screen.home #btn-stats { display: none; }

  /* the graph-paper panel mounted behind the right instrument bank */
  .bank-bezel {
    grid-column: 2 / 3; grid-row: 2 / 6;
    margin: -12px -14px; z-index: 0;
    border: 1px solid var(--hairline); border-radius: 20px;
    background:
      repeating-linear-gradient(0deg, color-mix(in srgb, var(--brand) 6%, transparent) 0 1px, transparent 1px 9px),
      repeating-linear-gradient(90deg, color-mix(in srgb, var(--brand) 6%, transparent) 0 1px, transparent 1px 9px),
      repeating-linear-gradient(0deg, color-mix(in srgb, var(--brand) 10%, transparent) 0 1px, transparent 1px 45px),
      repeating-linear-gradient(90deg, color-mix(in srgb, var(--brand) 10%, transparent) 0 1px, transparent 1px 45px),
      var(--canvas);
  }
  .screen.home > .chans, .screen.home > .dbank,
  .screen.home > .dcourse { position: relative; z-index: 1; }

  /* the Focus Card: monitor + coaching prose */
  .screen.home .hero { padding: 18px 22px 15px; border-radius: 22px; display: flex; flex-direction: column; }
  .screen.home .hero .hero-rating { font-size: 58px; }
  .screen.home .hero .hero-ecg { height: 50px; margin: 2px 0 6px; }
  .screen.home .hero .hero-mascot { top: 15px; right: 15px; }
  .screen.home .hero .hero-mascot .mascot { width: 78px; height: 82px; }
  .screen.home .hero .hero-vitals { font-size: 13px; gap: 20px; padding-top: 10px; }
  .hero-focus { margin-top: 13px; padding-top: 13px; border-top: 1px solid color-mix(in srgb, var(--hairline) 55%, transparent); }
  .hero-focus .zlabel { color: var(--brand-strong); margin-bottom: 5px; }
  .hero-focus p { font-size: 14.5px; line-height: 1.5; color: var(--ink); max-width: 50ch; }

  /* the CTA + up-next, joined under the coaching prose */
  .screen.home .stack .launch { padding: 17px 18px; }
  .screen.home .stack .launch h3 { font-size: 19px; }
  .screen.home .stack .launch p { font-size: 13px; }
  .screen.home .upnext { display: flex; padding: 13px 15px; flex: 1; align-items: center; }
  .screen.home .upnext h3 { font-size: 16px; }
  .screen.home .upnext .s-body > p:last-child { font-size: 12.5px; }
  .up-kicker, .zlabel {
    font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted);
  }
  .up-kicker { margin-bottom: 2px; }

  /* section vitals: 2x2 grid stretched to the full height of the rating box */
  .screen.home .chans { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; height: 100%; }
  .screen.home .chan { padding: 13px 15px 11px; border-radius: 15px; display: flex; flex-direction: column; }
  .screen.home .chan .ch-code { font-size: 11px; }
  .screen.home .chan .ch-rating { font-size: 26px; line-height: 1.1; }
  .screen.home .chan .ch-meta { font-size: 12px; line-height: 1.4; color: var(--muted); font-weight: 600; margin-top: 5px; }
  .screen.home .chan .ch-spark { flex: 1 1 auto; min-height: 34px; height: auto; margin-top: 8px; align-self: stretch; }

  /* shared instrument-card shell */
  .dcard {
    background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 15px; padding: 14px 16px;
  }
  .dcard-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
  .dcard-sub { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 6px; }

  /* question-bank completion panel */
  .dbank { display: flex; flex-direction: column; text-align: left; box-shadow: 0 3px 0 var(--hairline); transition: transform .06s ease, box-shadow .06s ease; }
  .dbank:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--hairline); }
  .dbank .dcard-head { margin-bottom: 2px; }
  .dbank-pct { font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--brand-strong); }
  .dbank-sub { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
  .dbank-bars { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
  .dbank-row { display: flex; align-items: center; gap: 11px; }
  .dbank-code { font-size: 11px; font-weight: 800; letter-spacing: .05em; width: 24px; flex-shrink: 0; }
  .dbank-track { flex: 1; height: 7px; background: var(--subtle); border-radius: 99px; overflow: hidden; }
  .dbank-fill { height: 100%; border-radius: 99px; }
  .dbank-n { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; width: 56px; text-align: right; flex-shrink: 0; }

  /* course completion (pathway) */
  .dcourse { display: flex; flex-direction: column; justify-content: center; }
  .dcourse-pct { font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--brand-strong); }
  .dcourse-track { height: 9px; background: var(--subtle); border-radius: 99px; overflow: hidden; }
  .dcourse-fill { height: 100%; background: var(--brand); border-radius: 99px; }

  /* review queue (pressable) */
  .dqueue { display: flex; flex-direction: column; justify-content: center; text-align: left; padding: 13px 16px; box-shadow: 0 3px 0 var(--hairline); transition: transform .06s ease, box-shadow .06s ease; }
  .dqueue:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--hairline); }
  .dqueue .dcard-head { margin-bottom: 6px; }
  .dqueue .chev { color: var(--muted); }
  .dq-row { display: flex; align-items: baseline; gap: 9px; }
  .dq-big { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; }
  .dq-check { color: var(--correct); display: inline-flex; }
  .dq-check .ic { width: 24px; height: 24px; }
  .dq-sub { font-size: 14px; font-weight: 700; }

  /* ---------- pathway: one section, centered under the selector ---------- */
  .screen.path-screen { max-width: 560px; }
  .path-screen .pathtabs { max-width: 560px; }
  .path-screen #path-scroll { padding-bottom: 24px; }
  .path-screen .unit { margin: 0 auto; }

  /* ---------- progress: all three panels at once, no tabs ---------- */
  .screen.stats-screen { max-width: 1080px; }
  .stats-desk {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "chart types" "act types";
    gap: 14px; margin-top: 12px;
  }
  .sd-chart { grid-area: chart; display: flex; flex-direction: column; min-height: 260px; }
  .sd-chart canvas { flex: 1; min-height: 0; width: 100%; }
  .sd-types { grid-area: types; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
  .sd-types .scroll-y { flex: 1; min-height: 0; }
  .sd-act { grid-area: act; }
  .sd-act .heatmap { grid-auto-columns: 18px; gap: 4px; justify-content: start; }
  .sd-h {
    font-family: var(--body); font-size: 11px; font-weight: 700;
    letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
    margin-bottom: 10px;
  }
  .stats-screen .st-share-row { display: none; }
  .tb-share {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 4px;
  }
  .tb-share:hover { color: var(--ink); }

  /* ---------- question bank: completion left, launcher right ---------- */
  .screen.bank-screen {
    max-width: 1020px;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "back back" "stats picks";
    column-gap: 26px; row-gap: 4px;
    align-content: start;
  }
  .bank-screen .back-row { grid-area: back; }
  .bank-screen .bank-stats {
    grid-area: stats; align-self: start;
    flex-direction: column !important; align-items: stretch !important;
    gap: 14px !important; padding: 22px 20px !important;
    text-align: center;
  }
  .bank-screen .bank-stats .bar-row { text-align: left; }
  .bank-screen .bk-ring { margin: 0 auto; width: 92px !important; height: 92px !important; }
  .bank-screen .bk-ring svg { width: 100%; height: 100%; }
  .bank-screen .bank-pickers { display: flex; flex-direction: column; min-height: 0; grid-area: picks; }
  .bank-screen .bank-pickers .seg:first-child { margin-top: 0; }
  .bank-screen .bank-pickers .spacer { display: none; }
  .bank-screen .bank-pickers .run-actions { margin-top: 16px; padding-top: 0; }

  /* ---------- settings: groups flow into two columns ---------- */
  .screen:has(.set-list) { max-width: 900px; }
  .set-list { column-count: 2; column-gap: 26px; }
  .set-group { break-inside: avoid; }
  .set-list .set-title:first-child { margin-top: 4px; }

  /* ---------- paywall: pitch left, comparison right ---------- */
  .screen.pay-screen {
    max-width: 880px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "back back" "hero table" "cta table" "fine table";
    column-gap: 30px; row-gap: 8px;
    align-content: start;
  }
  .pay-screen .back-row { grid-area: back; }
  .pay-screen .pay-hero { grid-area: hero; padding-top: 16px; }
  .pay-screen .pay-table { grid-area: table; align-self: start; }
  .pay-screen .run-actions { grid-area: cta; margin-top: 0; padding-top: 4px; align-self: start; }
  .pay-screen .pay-fine { grid-area: fine; align-self: start; }
  .pay-screen > .spacer { display: none; }
}
