/**
 * style.css — Mobile-first responsive styles for Quant Reflex Trainer (SPA)
 *
 * Color scheme (light study theme):
 *   background : #f8fafc
 *   card       : #ffffff
 *   accent     : #2563eb
 *   text       : #0f172a
 *   secondary  : #64748b
 */

/* ==================== DESIGN TOKENS ==================== */
:root {
  --qr-card-radius: 1.5rem;        /* 24px — large cards */
  --qr-card-radius-sm: 1.25rem;    /* 20px — small cards / tiles */
  --qr-btn-radius: 1.125rem;       /* 18px — buttons / CTAs */
  --qr-card-padding: 1.25rem;      /* 20px */
  --qr-numpad-h: 15rem;            /* single source for the custom-numpad height reservation (drill card + numpad-active body padding) — ADR-087; FW-W5: was 13.75rem, UNDER the keypad's real 238px (4×50px rows + gaps + padding) — the action bar overlapped the keypad top by ~10px */
  --qr-card-border-light: 1px solid rgba(15,23,42,0.06);
  --qr-card-border-dark: 1px solid rgba(255,255,255,0.08); /* soft hairline on navy */
  --qr-shadow-light: 0 6px 20px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.03);
  --qr-shadow-dark: 0 8px 24px rgba(2,6,23,0.45);          /* soft navy shadow */
  /* ADR-134: the --sp-xs/sm/md/lg t-shirt scale lived here and duplicated --sp-1…12 below. Two
     spacing token systems is one too many, and all four t-shirt tokens were referenced ZERO times.
     --sp-1…12 is canonical. */
  --qr-nav-h: 3.75rem;             /* bottom-nav height — single source of truth (ADR-011) */
  --qr-practice-gap: .6rem;        /* Practice scroll-panel: equal top/bottom inset */
  --qr-bg: #f8fafc;                /* app background (light) — used by sticky surfaces e.g. Learn section nav */
  --qr-accent: #2563eb;            /* canonical brand blue (new code; existing hard-coded #2563eb left as-is) */

  /* ── Semantic design tokens (ADR-086) — seeded from the existing palette (no new hues). The redesigned drill
     journey references THESE, so every theme × mode inherits one structure and expresses only its own colour.
     Light defaults below; dark + playful override the same names. ── */
  --qr-text: #0f172a; --qr-text-dim: #64748b; --qr-text-mut: #64748b;   /* UI Phase 1 §6.3: was #94a3b8 (~2.9:1 on white, sub-AA); #64748b clears 4.5:1 for muted body text */
  --qr-surface: rgba(255,255,255,.88); --qr-surface-solid: #ffffff; --qr-surface-2: #f1f5f9; --qr-surface-3: #e2e8f0;
  /* ADR-132: the grouping-tray step. Near white you need a LARGER absolute delta for the same
     perceived step, so classic light takes --qr-surface-3 (delta 22 vs the page) where dark takes
     --qr-surface (delta 16). Both read as the same tray; the numbers differ because the palettes do. */
  --qr-panel: var(--qr-surface-3);
  --qr-border: #e2e8f0; --qr-border-strong: #cbd5e1;
  --qr-accent-2: #3b82f6; --qr-accent-strong: #1d4ed8; --qr-on-accent: #fff;   /* text on accent fills — invariant (FW-W7e) */
  --qr-success: #16a34a; --qr-success-fg: #15803d; --qr-success-bg: rgba(22,163,74,.12); --qr-success-border: #22c55e;
  --qr-danger: #dc2626; --qr-danger-fg: #991b1b; --qr-danger-bg: rgba(220,38,38,.10); --qr-danger-border: #ef4444;
  --qr-warn: #f59e0b; --qr-info: #8b5cf6; --qr-info-fg: #7c3aed;
  --qr-focus-ring: 0 0 0 3px rgba(37,99,235,.35);
  --qr-dur-fast: .12s; --qr-dur: .2s; --qr-dur-slow: .4s; --qr-ease: cubic-bezier(.2,.7,.2,1);
  --qr-ease-out: cubic-bezier(.25,.46,.45,.94);   /* soft decelerate (the widely-used ease-out) */
  --qr-spring: cubic-bezier(.34,1.56,.64,1);   /* the ONE arrival spring (modal in, countdown pop, new-best) */

  /* ── QR Design Language v2 foundation tokens (UI Phase 1 / blueprint §6) — ADDITIVE. New code uses these;
     legacy names below are kept as aliases. Token DEFINITIONS are custom properties, so they do not count
     against the design-lint census (only literal `border-radius:` / `box-shadow:` / etc. declarations do). ── */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-full: 999px;
  --r-sheet-top: 1.4rem 1.4rem 0 0; --r-sheet: 1.4rem;   /* bottom-sheet top corners / ≥600px centered form (FW-W3) */
  --r-keypad-top: 16px 16px 0 0;   /* numpad docked top corners */
  --r-round-b: 0 0 1.5rem 1.5rem;  /* bottom-rounded band */
  --r-bubble: 1rem 1rem .25rem 1rem;   /* chat bubble (companion user turn) */
  --r-round-r: 0 12px 12px 0;      /* right-rounded rail */
  --el-1: 0 6px 20px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.03);   /* resting card */
  --el-2: 0 12px 28px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.05);  /* raised / hover / sheet */
  --el-3: 0 24px 48px rgba(15,23,42,.16), 0 6px 16px rgba(15,23,42,.08); /* dialog */
  --el-sheet: 0 -8px 40px rgba(2,6,23,.28);                              /* bottom sheet (upward throw) */
  --el-nav: 0 -2px 12px rgba(0,0,0,.06);                                 /* bottom nav (soft up) */
  --el-inset: inset 0 0 0 1px var(--qr-border);                          /* inset hairline */
  --el-key: 0 4px 16px rgba(0,0,0,.04), inset 0 1px 1px rgba(255,255,255,.4);      /* keypad key */
  /* ADR-131: these two used to hardcode rgba(37,99,235,…) — the CLASSIC accent — so the Playful theme
     glowed classic-blue no matter what its palette said. They now read accent-veil tokens, which each
     theme re-declares. A custom-property DEFINITION is not a `box-shadow:` declaration, so per-theme
     glow costs ZERO shadow census (scripts/design-lint.check.js counts declarations only). */
  --qr-glow-accent: 0 4px 12px var(--qr-veil-accent-25);                 /* accent CTA glow */
  --qr-glow-duel: 0 4px 14px rgba(217,119,6,.3);                         /* duel amber glow */
  --qr-ring-ok: 0 0 0 3px rgba(22,163,74,.12);                           /* success feedback ring */
  --qr-ring-danger: 0 0 0 3px rgba(220,38,38,.12);                       /* danger feedback ring */
  --qr-grad-duel: linear-gradient(135deg, #d97706, #f59e0b);             /* the ONE duel/archive identity gradient (FW-W6) */
  /* FW-W7c — the 10-gradient identity set (blueprint §14). Built from color tokens where the
     hue must follow the theme; washes are translucent so they sit on any surface. */
  --qr-grad-a: var(--qr-accent); --qr-grad-b: var(--qr-accent-strong);   /* gradient endpoints — themes re-declare the COLORS, never the gradients */
  --qr-grad-cta: linear-gradient(135deg, var(--qr-grad-a), var(--qr-grad-b));
  --qr-grad-bar: linear-gradient(90deg, var(--qr-accent), var(--qr-accent-2));
  --qr-grad-bar-ok: linear-gradient(90deg, var(--qr-success), var(--qr-success-border));
  --qr-grad-bar-warn: linear-gradient(90deg, var(--qr-warn), #fbbf24);
  --qr-grad-bar-danger: linear-gradient(90deg, var(--qr-danger), var(--qr-danger-border));
  /* ADR-131: the wash/glow stops were hardcoded classic-blue, so every theme washed and haloed in the
     same hue. They now read accent-veil tokens. The gradient LITERAL is unchanged in count — the census
     measures distinct gradient strings, and swapping a colour for a var() leaves exactly one — so the
     10/10 gradient ceiling is untouched while both themes (and the hero) can re-tint by declaring vars. */
  --qr-grad-wash: linear-gradient(135deg, var(--qr-wash-a), var(--qr-wash-b));
  --qr-grad-wash-duel: linear-gradient(135deg, rgba(217,119,6,.12), rgba(245,158,11,.05));
  --qr-grad-glow: radial-gradient(circle, var(--qr-glow-stop), transparent 62%);
  --qr-grad-skel: linear-gradient(90deg, var(--qr-skel-veil) 25%, var(--qr-skel-mid) 37%, var(--qr-skel-veil) 63%);
  --qr-skel-mid: rgba(15,23,42,.11);
  --qr-dur-pulse: 1.2s;                    /* ambient pulse loops (skeletons) */
  /* FW-W7e — recurring translucent veils/hairlines (C3). Theme-INVARIANT value tokens: a white
     veil on dark surfaces and an ink veil on light surfaces are physical layers, not theme hues. */
  --qr-veil-w-4: rgba(255,255,255,.04); --qr-veil-w-5: rgba(255,255,255,.05);
  --qr-veil-w-6: rgba(255,255,255,.06); --qr-veil-w-8: rgba(255,255,255,.08);
  --qr-veil-w-10: rgba(255,255,255,.1); --qr-veil-w-12: rgba(255,255,255,.12);
  --qr-veil-w-14: rgba(255,255,255,.14);
  --qr-veil-ink-3: rgba(15,23,42,.03); --qr-veil-ink-5: rgba(15,23,42,.05);
  --qr-veil-ink-6: rgba(15,23,42,.06); --qr-veil-ink-8: rgba(15,23,42,.08);
  --qr-veil-ink-10: rgba(15,23,42,.1); --qr-veil-ink-14: rgba(15,23,42,.14);
  /* ADR-131 — the accent-veil ladder. THIS is the theme's atmosphere dial: every wash, halo and glow in
     the app resolves through it, so re-declaring these five values under a theme re-tints the whole
     ambience without touching a single gradient or shadow literal. Classic = its slate-blue #2563eb. */
  --qr-veil-accent-8: rgba(37,99,235,.08); --qr-veil-accent-12: rgba(37,99,235,.12);
  --qr-veil-accent-25: rgba(37,99,235,.25);   /* ADR-134: -40 removed with its only consumer, --qr-glow-accent-strong */
  --qr-wash-a: rgba(37,99,235,.12); --qr-wash-b: rgba(37,99,235,.03);   /* app-wide wash stops */
  --qr-glow-stop: rgba(37,99,235,.12);                                   /* radial halo stop */
  --qr-skel-veil: rgba(15,23,42,.05);      /* skeleton row veil */
  /* ADR-133 — three purposeful glass tiers, replacing nine ad-hoc blur radii. Roles, not numbers:
     a scrim dims the page behind a modal, a surface lifts content off the page, chrome is the
     app's own shell. Each tier takes the LOWER end of the cluster it replaces, so consolidating
     reduces total backdrop-filter work rather than adding to it. The material difference between
     the themes comes from their surface colour and alpha, not from the blur radius. */
  /* ADR-133 — press feedback had twelve different scale values (.88 to .995). Two now: large
     surfaces settle subtly, small controls may squeeze a little more, which is what makes a tap
     read as deliberate. Celebratory GROW animations are unrelated and left alone. */
  --qr-press-lg: .98;            /* cards, rows, sheets, mode cards */
  --qr-press-sm: .96;            /* chips, icon buttons, nav items */
  --glass-scrim: blur(6px);      /* page-dimming overlays behind modals and sheets */
  --glass-surface: blur(10px);   /* elevated content on the page: cards, chips, stat panels */
  --glass-chrome: blur(16px);    /* the app's own shells: modal bodies, nav, auth card */
  --z-nav: 100; --z-sticky: 200; --z-sheet: 900; --z-dialog: 1000; --z-toast: 1100; --z-critical: 1200;
  /* FW-W7b: VALUE-PRESERVING z tokens — each keeps its historical value so no stacking order
     can change; consolidation is nominal (census) now, semantic re-layering can come later. */
  --z-above: 1; --z-lift: 2; --z-lift-2: 3; --z-lift-3: 5; --z-lift-4: 6;
  --z-session-bg: 10; --z-session-card: 11; --z-session-actions: 98; --z-session-numpad: 99;
  --z-scrim-250: 250; --z-float-300: 300; --z-pop-500: 500; --z-companion: 600; --z-report: 700;
  --z-boot-hide: 9998; --z-boot-splash: 9999; --z-boot-3: 10000; --z-boot-4: 10001; --z-boot-top: 10010;
  --fs-h1: 1.5rem; --fs-h2: 1.25rem; --fs-h3: 1.125rem; --fs-body: 1rem; --fs-sub: .875rem; --fs-caption: .75rem; --fs-micro: .6875rem;
  --fs-d1: 2rem; --fs-d2: 1.75rem;   /* display: drill answer / results numbers */
  --fs-icon: 2.6rem; --fs-icon-lg: 3.5rem;   /* decorative emoji/glyph display sizes (FW-W7d) */

  /* Legacy token aliases (ADR-091): a handful of older inline styles reference pre-ADR-086 names
     that were never defined (they silently fell back to inherited colors). Alias them ONCE to the
     semantic system — var() resolves at use time, so dark/playful re-declarations of the qr tokens
     flow through automatically. Prefer --qr-* in all new code. */
  --text-primary: var(--qr-text);
  --text-secondary: var(--qr-text-dim);
  --bg-surface: var(--qr-surface-solid);
  --bg-elevated: var(--qr-surface-2);
  --border-color: var(--qr-border);
}
html.dark-mode {
  --qr-bg: #0f172a; --qr-accent: #60a5fa;
  --qr-text: #e2e8f0; --qr-text-dim: #94a3b8; --qr-text-mut: #94a3b8;   /* ADR-095: was #64748b (~3.2:1 on dark surfaces, below AA); #94a3b8 clears 4.5:1 for small tertiary text */
  --qr-surface: rgba(30,41,59,.88); --qr-surface-solid: #1e293b; --qr-surface-2: #0f172a; --qr-surface-3: #334155;
  --qr-panel: var(--qr-surface);          /* byte-identical to the value this theme shipped before */
  --qr-border: #334155; --qr-border-strong: #475569;
  --qr-accent-2: #3b82f6; --qr-accent-strong: #3b82f6;
  --qr-success: #22c55e; --qr-success-fg: #86efac; --qr-success-bg: rgba(22,163,74,.20); --qr-success-border: #22c55e;
  --qr-danger: #f87171; --qr-danger-fg: #fca5a5; --qr-danger-bg: rgba(220,38,38,.22); --qr-danger-border: #ef4444;
  --qr-warn: #fbbf24; --qr-info: #a78bfa; --qr-info-fg: #c4b5fd;
  --qr-focus-ring: 0 0 0 3px rgba(96,165,250,.4);
  /* deeper elevation on navy so cards read against the dark surface */
  --el-1: 0 8px 24px rgba(2,6,23,.45); --el-2: 0 14px 32px rgba(2,6,23,.55); --el-3: 0 24px 48px rgba(2,6,23,.6);
  --qr-skel-veil: rgba(255,255,255,.06);
  --qr-skel-mid: rgba(255,255,255,.1);
}
/* Playful skin — a COMPLETE token identity (ADR-087): warm off-white surfaces, its own confident blue accent, warm
   ink, and matching status/focus tokens. Every token-driven component (start screen, keypad symbols, teaching panel,
   verdict, chips, topics, loading, focus rings) now expresses the Playful palette instead of falling back to the
   default blue — structure/motion stay inherited. All pairs WCAG AA-verified (scripts contrast validator). */
html.theme-playful {
  --qr-bg: #faf9f7;
  --qr-accent: #2a63c6; --qr-accent-2: #4f8ff7; --qr-accent-strong: #3b7de0;
  --qr-grad-a: #4f8ff7; --qr-grad-b: #2dd4bf;   /* CTA endpoints — --qr-grad-cta re-resolves through these (FW-W7c) */
  --qr-shadow-playful: 0 4px 24px rgba(120,100,70,.08), 0 1px 6px rgba(120,100,70,.04);
  --qr-text: #2a2521; --qr-text-dim: #6a6055; --qr-text-mut: #6f6455;
  --qr-surface: #faf9f7; --qr-surface-solid: #faf9f7; --qr-surface-2: #f0eee9; --qr-surface-3: #e8e6e1;
  /* --qr-surface IS Playful's page colour, so the tray must step to warm paper instead */
  --qr-panel: var(--qr-surface-2);
  --qr-border: #e8e6e1; --qr-border-strong: #d9d5cc;
  /* ADR-131: --qr-success{,-bg,-border} and --qr-danger{,-fg,-bg,-border} were re-declared here with
     values byte-identical to :root — 7 of Playful's 28 "overrides" changed nothing. Only the two that
     genuinely differ from Classic are kept. */
  --qr-success-fg: #146a31;
  --qr-danger-fg: #991b1b;
  --qr-warn: #9a4708; --qr-info: #6d28d9; --qr-info-fg: #6d28d9;
  --qr-focus-ring: 0 0 0 3px rgba(42,99,198,.35);

  /* ── ADR-131: Playful's ATMOSPHERE ──────────────────────────────────────────────────────────────
     Before this, Playful re-declared 28 tokens out of 205 — and 7 of those set values identical to
     Classic. It inherited the entire depth layer, so both themes shipped byte-identical shadows and a
     classic-blue glow: a different palette on the same object. Depth, not hue, is what the eye reads as
     "a different app", so Playful now owns its own.

     Classic is crisp and cool: tight slate shadows, an electric blue halo, 24px cards.
     Playful is warm paper: softer and further-thrown shadows in the same warm brown its
     --qr-shadow-playful token already implied, a teal-leaning halo drawn from its own --qr-grad-b,
     and a rounder silhouette.

     All of it is FREE under design-lint: custom-property definitions are not `box-shadow:` /
     `border-radius:` declarations, and the gradients only change which var() they read. */
  --el-1: 0 8px 26px rgba(120,100,70,.10), 0 1px 3px rgba(120,100,70,.05);
  --el-2: 0 16px 36px rgba(120,100,70,.13), 0 3px 8px rgba(120,100,70,.06);
  --el-3: 0 28px 56px rgba(120,100,70,.18), 0 8px 20px rgba(120,100,70,.09);
  --el-nav: 0 -2px 16px rgba(120,100,70,.09);
  --el-key: 0 4px 16px rgba(120,100,70,.06), inset 0 1px 1px rgba(255,255,255,.7);
  --el-sheet: 0 -8px 44px rgba(120,100,70,.22);
  /* teal-leaning ambience (its own --qr-grad-b), so washes/halos/glows stop reading classic-blue */
  --qr-veil-accent-8: rgba(45,212,191,.10); --qr-veil-accent-12: rgba(45,212,191,.15);
  --qr-veil-accent-25: rgba(45,212,191,.28);
  --qr-wash-a: rgba(45,212,191,.14); --qr-wash-b: rgba(79,143,247,.05);
  --qr-glow-stop: rgba(45,212,191,.16);
  /* rounder silhouette — the token is read through border-radius: var(), so this costs no census */
  --qr-card-radius: 1.75rem; --qr-card-radius-sm: 1.5rem; --qr-btn-radius: 1.375rem;
}
html.theme-playful.dark-mode {
  --qr-bg: #0d1117;
  --qr-accent: #58a6ff; --qr-accent-2: #58a6ff; --qr-accent-strong: #4f8ff7;
  --qr-grad-a: #58a6ff; --qr-grad-b: #2dd4bf;
  --qr-shadow-playful: 0 8px 24px rgba(0,0,0,.35);
  --qr-text: #e6edf3; --qr-text-dim: #9aa5b1; --qr-text-mut: #7f8b99;
  --qr-surface: rgba(30,35,48,.9); --qr-surface-solid: #1b2130; --qr-surface-2: #141926; --qr-surface-3: #2a3346;
  --qr-panel: rgba(22,27,45,.88);         /* mirrors .analytics-card, byte-identical to before */
  --qr-border: #2a3346; --qr-border-strong: #3a465e;
  --qr-success: #22c55e; --qr-success-fg: #86efac; --qr-success-bg: rgba(22,163,74,.20); --qr-success-border: #22c55e;
  --qr-danger: #f87171; --qr-danger-fg: #fca5a5; --qr-danger-bg: rgba(220,38,38,.22); --qr-danger-border: #ef4444;
  --qr-warn: #fbbf24; --qr-info: #a78bfa; --qr-info-fg: #c4b5fd;
  --qr-focus-ring: 0 0 0 3px rgba(88,166,255,.4);

  /* ADR-131: Playful DARK was rendering Playful LIGHT's shadows. `html.dark-mode` and
     `html.theme-playful` have equal specificity, so source order decides and the later
     `html.theme-playful` block won — meaning the warm paper ramp (brown at 10% alpha, tuned for an
     off-white surface) was painting on a #0d1117 background, where it is effectively invisible.
     Classic dark has always declared its own; Playful dark now does too. Measured before the fix:
     playful-dark reported byte-identical --el-* and --el-sheet to playful-light. */
  --el-1: 0 8px 26px rgba(0,0,0,.42), 0 1px 3px rgba(0,0,0,.30);
  --el-2: 0 16px 36px rgba(0,0,0,.52), 0 3px 8px rgba(0,0,0,.34);
  --el-3: 0 28px 56px rgba(0,0,0,.60), 0 8px 20px rgba(0,0,0,.38);
  --el-nav: 0 -2px 16px rgba(0,0,0,.44);
  --el-sheet: 0 -8px 44px rgba(0,0,0,.50);
  --el-key: 0 4px 16px rgba(0,0,0,.34), inset 0 1px 1px rgba(255,255,255,.05);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Focus policy (UI Phase 1 §6.6): keyboard focus shows the ONE accent ring via each control's own
   :focus-visible rule; mouse/programmatic focus shows nothing. This removes the browser default outline
   that was flashing (amber/blue) on the tabindex="-1" scroll-anchor headings (results title, quick-ref
   title, revision title) which are focus targets for scroll+SR announcement, not operable controls. */
:focus:not(:focus-visible) { outline: none; }
[tabindex="-1"]:focus { outline: none; box-shadow: none; }

/* Zoom is re-enabled (viewport no longer sets user-scalable=0 — WCAG 1.4.4); this keeps interactive
   controls from firing the 300ms double-tap-to-zoom delay while still allowing pinch-zoom of the page. */
button, a, input, select, textarea, [role="button"], .numpad-btn, .mcq-option, .nav-link, [data-numpad] {
  touch-action: manipulation;
}

/* Disable text selection globally for native app feel */
*, *::before, *::after {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Allow text selection in input fields and textareas */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  height: 100%;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  /* Root background is themed so the pre-paint theme class (added to <html> in the head, before <body>
     parses) paints the correct surface on the very first frame — no white flash for dark/System users. */
  background: var(--qr-bg);
  /* Hide scrollbar cross-browser */
  scrollbar-width: none; /* Firefox */
}
html::-webkit-scrollbar { display: none; } /* Chrome, Edge, Samsung Internet */

/* ==================== LOCALIZATION TYPOGRAPHY (ADR-111) ====================
   Devanagari coverage: Android (Noto), iOS (Kohinoor) and Windows (Nirmala UI) all serve a native
   Devanagari face through the system stack; the bundled Noto Sans Devanagari below is the guaranteed
   fallback for platforms without one (desktop Linux, kiosk browsers). unicode-range keeps it from
   ever downloading on an all-English session; the SW precaches it for offline hi/mr. */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/noto-sans-devanagari.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* Inter (FW-W4, blueprint §5): ONE bundled brand face for Latin UI text — a variable font, so every
   weight the app uses ships in a single 48KB latin-subset file. font-display:swap keeps first paint
   on the system face; unicode-range scopes Inter to Latin so Devanagari sessions still resolve
   through Noto/native faces exactly as before. Numerals get Inter's tabular-friendly forms. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-var-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Devanagari NEVER letter-spaces: positive tracking breaks matra positioning and conjunct/ligature
   shaping. The app's ~60 uppercase micro-labels pair letter-spacing for a small-caps affordance —
   a Latin-only treatment. Under a Devanagari app locale (or inside any hi/mr content container)
   tracking is force-reset; text-transform:uppercase is already a harmless no-op for Devanagari. */
[data-app-locale='hi'] *, [data-app-locale='mr'] *,
[lang='hi'], [lang='hi'] *, [lang='mr'], [lang='mr'] * {
  letter-spacing: normal !important;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif; /* Inter for Latin (FW-W4, latin unicode-range only); native faces + bundled Devanagari fallback behind it (ADR-111) */
  /* UI Phase 1: token-driven so the body element itself themes from the <html>-level token blocks.
     (The theme class moved to <html>; a hardcoded body bg here would stay light in dark/playful.) */
  background: var(--qr-bg);
  color: var(--qr-text);
  height: 100%;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: calc(var(--qr-nav-h) + env(safe-area-inset-bottom, 0px)); /* reserves the fixed nav */
  opacity: 0;
  transition: opacity var(--qr-dur) var(--qr-ease-out);
  overflow: hidden;
}

/* Global scrollbar hiding for all scrollable elements */
*::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }
body.loaded { opacity: 1; }

/* Global scroll lock when modals are open */
body.modal-open {
  overflow: hidden !important;
}

/* Enforce instant tap registration and prevent double-tap zoom on all interactive elements */
button, a, input, select, textarea, .mode-card, .category-btn, .numpad-key, .clear-option-btn {
  touch-action: manipulation;
}

/* ---- Splash Screen ---- */
.app-loader {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--qr-surface-solid);
  z-index: var(--z-boot-splash);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  contain: layout style paint;
}
html.dark-mode .app-loader { background: #0d1117; }

/* Q Logo — gentle idle pulse while waiting for app to initialize */
.splash-logo {
  position: relative;
  z-index: var(--z-lift);
  width: 22vw;
  min-width: 80px;
  max-width: 180px;
  height: auto;
  will-change: transform, opacity;
  animation: splashIdle calc(var(--qr-dur-pulse) * 11 / 6) var(--qr-ease) infinite;
}
@keyframes splashIdle {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); }
}

/* design-lint:content-art-start — splash amoeba blob: organic elliptical radii + liquid gradients are ART, not design-system values */
/* Blob behind Q — irregular border-radius creates an organic, non-circular shape.
   Multi-layer gradient adds a highlight + shadow for liquid depth. */
.splash-blob {
  position: absolute;
  z-index: var(--z-above);
  width: 80px;
  height: 80px;
  border-radius: 42% 58% 55% 45% / 52% 44% 56% 48%;
  background:
    radial-gradient(circle at 35% 35%, rgba(47,139,253,.55), transparent 50%),
    radial-gradient(circle at 65% 60%, rgba(0,63,127,.35), transparent 55%),
    radial-gradient(ellipse at 50% 50%, #2f8bfd, #005fbd 55%, #004494 85%, #003060);
  opacity: 0;
  will-change: transform, opacity;
  pointer-events: none;
}

/* Stage 2 — Q Bounce (replaces idle animation) */
.splash-bounce .splash-logo {
  animation: splashBounce var(--qr-dur-slow) var(--qr-spring) forwards;
}
@keyframes splashBounce {
  0%   { transform: translateY(0); }
  32%  { transform: translateY(-11px); }
  58%  { transform: translateY(2px); }
  78%  { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

/* Stage 3 — Blob Emerge */
.splash-blob-emerge .splash-blob {
  animation: blobEmerge var(--qr-dur-slow) var(--qr-ease-out) forwards;
}
@keyframes blobEmerge {
  0%   { opacity: 0; transform: scale(0.15); border-radius: 42% 58% 55% 45% / 52% 44% 56% 48%; }
  40%  { opacity: .75; }
  100% { opacity: 1; transform: scale(1); border-radius: 38% 62% 50% 50% / 55% 40% 60% 45%; }
}

/* Stage 4 — Amoeba Expansion
   opacity: 1 prevents flash when this overrides blob-emerge (same specificity,
   later source order wins). Seven keyframe stops for organic border-radius wobble. */
.splash-expand .splash-blob {
  opacity: 1;
  animation: blobExpand var(--qr-dur-slow) var(--qr-ease) forwards;
}
@keyframes blobExpand {
  0%   { transform: scale(1);  border-radius: 38% 62% 50% 50% / 55% 40% 60% 45%; }
  12%  { transform: scale(3.5); border-radius: 44% 56% 58% 42% / 46% 54% 50% 50%; }
  28%  { transform: scale(10);  border-radius: 50% 50% 42% 58% / 53% 47% 55% 45%; }
  45%  { transform: scale(19);  border-radius: 46% 54% 55% 45% / 48% 52% 48% 52%; }
  65%  { transform: scale(30);  border-radius: 52% 48% 50% 50% / 50% 50% 52% 48%; }
  82%  { transform: scale(40);  border-radius: 49% 51% 50% 50% / 50% 50% 50% 50%; }
  100% { transform: scale(50);  border-radius: 50%; }
}
/* design-lint:content-art-end */

/* Stage 5 — Full Screen Fill + Q emphasis */
.splash-fill {
  background: #005fbd;
  transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
html.dark-mode .splash-fill {
  background: #005fbd;
}
.splash-fill .splash-logo {
  animation: splashEmphasis var(--qr-dur) var(--qr-spring) forwards;
}
@keyframes splashEmphasis {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Stage 6 — Fade Out (subtle scale-up dissolve, disable pointer events) */
.splash-fadeout {
  opacity: 0;
  transform: scale(1.015);
  transition: opacity var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }

/* ---- SPA View System ---- */
.spa-view {
  display: none;
  touch-action: pan-y;
}
.spa-view-active {
  display: block;
  /* FW-W5: no fill-mode. The `to` state equals the natural state, so `both` only RETAINED the
     animation's transform fill — which made the view a containing block for position:fixed
     descendants forever, silently trapping the drill's fixed layers inside the 720px .container
     in web-mode (the pwa-mode variant below never had a fill). */
  animation: viewSlideIn var(--qr-dur) var(--qr-ease-out);
}
/* Belt-and-braces: a live drill re-pins its layers to the real viewport — never animate the view
   shell underneath it (an active transform animation would re-trap the fixed layers). */
body.drill-session-active .spa-view-active { animation: none; }
@keyframes viewSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
/* Reduced-motion: skip translate, keep opacity fade */
@media (prefers-reduced-motion: reduce) {
  .spa-view-active { animation: viewFadeIn var(--qr-dur-fast) var(--qr-ease-out) both; }
  @keyframes viewFadeIn { from { opacity: 0; } to { opacity: 1; } }
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: 480px;
  /* NO top padding here. The four tab views (Practice / Learn / Stats / Settings) each open with their
     own <header>, which already carries the spacing above the heading — so a container top padding was
     spacing them a second time. Practice never showed it because `body.view-practice-active > .container`
     zeroes this padding (Practice is a fixed-height flex shell that owns its own scrolling, ADR-011),
     which is exactly why its heading sat 20px higher than the other three: 1.25rem, measured.
     The views that have no header of their own — Home's hero and Duel — take the spacing directly
     instead, so their layout is unchanged. */
  padding: 0 1.25rem 1rem; /* bottom padding gives breathing room above nav */
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 1rem; /* prevent last card clipping behind nav */
}

/* App bar (blueprint §7-global): left-aligned neutral title + dimmed leading icon + optional action slot.
   Replaces the old centered-blue emoji headers used by Practice / Learn / Stats / Settings. */
/* The four tab headings (Practice / Learn / Stats / Settings) are centred. Every <header> in this
   document is one of those four and contains only its <h1> — there are no sibling controls to be
   pushed off-centre, and this stylesheet is loaded by main-app alone (ADR-099: separate deploy roots),
   so the bare element selector cannot reach another app's chrome.
   The heading icon lives INSIDE the h1, so icon and title centre together as one unit rather than the
   text drifting off-centre by the icon's width. `justify-content` centres the h1 box; `text-align`
   handles the wrapped case on very narrow screens. Home is deliberately untouched — its greeting hero
   is a different component, not a tab heading. */
header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-align: center;
  padding: 1rem 0 .5rem; /* tighter — reduces Practice tab vertical waste */
}
header h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--qr-text);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  min-width: 0;
}
header h1 .qr-ico { color: var(--qr-text-dim); }
.header-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
  -webkit-text-fill-color: initial;
}
.header-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}
/* Header icons are qr-ico spans now — give the glyph breathing room from the title */
h1 .qr-ico.header-icon { margin-right: .25rem; }

/* ---- Cards ---- */
.card {
  background: rgba(255,255,255,.88);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  border-radius: var(--qr-card-radius);
  padding: var(--qr-card-padding);
  margin-bottom: 1rem;
  box-shadow: var(--qr-shadow-light);
  border: var(--qr-card-border-light);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
  overflow-wrap: break-word;
  word-break: normal;
  -webkit-tap-highlight-color: transparent;
}
.card:active {
  transform: scale(var(--qr-press-lg));
  box-shadow: var(--el-1);
}

.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Sections B & C: comfortable CTA stack — equal, generous vertical spacing
   between stacked action buttons in centered cards (results + quick-drill setup).
   Buttons share a uniform width so the stack reads as one modern CTA group. */
.card.center-content > .btn-primary,
.card.center-content > .btn-secondary {
  width: 100%;
  max-width: 340px;
}
.card.center-content > .btn-primary + .btn-primary,
.card.center-content > .btn-primary + .btn-secondary,
.card.center-content > .btn-secondary + .btn-primary,
.card.center-content > .btn-secondary + .btn-secondary {
  margin-top: 12px;
}
.card.center-content > .speed-benchmark-card + .btn-primary,
.card.center-content > .results-grid + .btn-primary,
.card.center-content > p + .btn-primary {
  margin-top: 16px;
}

/* Prevent 300ms tap delay on interactive elements */
a, button, input, select, textarea, label, .btn, .mode-card, .category-btn,
.table-select-btn,
.bottom-nav a, .collapsible-header {
  touch-action: manipulation;
}

/* ---- Buttons ---- */

/* ---- Inputs ---- */
.input {
  width: 100%;
  max-width: 320px;
  padding: .75rem 1rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--r-md);
  background: var(--qr-surface-solid);
  color: var(--qr-text);
  font-size: var(--fs-h3);
  text-align: center;
  outline: none;
  margin: .75rem 0;
  transition: border-color var(--qr-dur) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out);
}
.input:focus { border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring); }
/* Filled state — instant visual confirmation digit was registered */
.input:not(:placeholder-shown) { border-color: #93c5fd; background: #f0f7ff; }
/* Prevent sticky hover states on touch devices */
@media (pointer: coarse) {
  .btn:hover { background: var(--qr-surface-3); }
  .btn.accent:hover { background: var(--qr-grad-cta); }
  .mode-card:hover { transform: none; }
}


/* ---- Drill / Test UI ---- */
.drill-progress {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  margin-bottom: .25rem;
}

/* Progress bar */
.drill-progress-bar {
  width: 100%;
  max-width: 280px;
  height: .35rem;
  background: var(--qr-surface-3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .75rem;
}
.drill-progress-fill {
  height: 100%;
  background: var(--qr-grad-bar);
  border-radius: 4px;
  transition: width var(--qr-dur-slow) var(--qr-ease-out);
}

/* Timer urgency (ADR-091): calm by default — a permanently red clock is a constant alarm, i.e.
   no signal. Danger color + a gentle opacity pulse only when time actually matters (≤5s per-Q,
   ≤10s total). Tabular numerals keep the digits from jiggling as they count down. The pulse is
   animation-based, so both reduced-motion kill-switches neutralize it automatically. */
.timer {
  font-size: var(--fs-body);
  color: var(--qr-text-dim);
  font-weight: 600;
  margin-bottom: .5rem;
  font-variant-numeric: tabular-nums;
  transition: color var(--qr-dur) var(--qr-ease-out);
}
.timer.timer-low {
  color: var(--qr-danger);
  font-weight: 700;
  animation: timerUrgent calc(var(--qr-dur-slow) * 2.5) var(--qr-ease) infinite;
}
@keyframes timerUrgent {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.question-text {
  font-size: var(--fs-d1);
  font-weight: 700;
  margin-bottom: .75rem;
  letter-spacing: .02em;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: break-word;
  font-variant-numeric: tabular-nums; /* stable digit widths across question swaps */
}
/* UI Phase 1 §6.2: medium-length prompts (53-110 chars) — between the display "24 × 18" and the compact
   sentence tier. Left-aligned + capped width so a multi-line prompt reads as a paragraph, not a headline. */
.question-text-medium {
  font-size: var(--fs-h1);
  line-height: 1.35;
  letter-spacing: 0;
  text-align: left;
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}
@media (max-height: 600px) { .question-text-medium { font-size: 1.3rem; } }

.feedback {
  min-height: 1.75rem;
  font-size: var(--fs-h3);
  font-weight: 700;
  margin-bottom: .25rem;
  border-radius: var(--r-md);
  padding: .25rem .75rem;
  transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
.feedback.correct {
  color: var(--qr-success-fg);
  background: rgba(22,163,74,.1);
  border: 1px solid rgba(22,163,74,.18);
}
.feedback.wrong {
  color: var(--qr-danger);
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.15);
}

/* Drill exit button — 44px target with a visible affordance circle (ADR-091) */
.session-exit,
.drill-exit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: var(--qr-surface-2);
  color: var(--qr-text-dim);
  font-size: var(--fs-h3);
  font-weight: 500;
  line-height: 1.1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: var(--z-session-bg);
  transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.session-exit:active,
.drill-exit-btn:active {
  background: rgba(0,0,0,.12);
  color: var(--qr-text);
}
html.dark-mode .session-exit,
html.dark-mode .drill-exit-btn {
  background: transparent;
  color: #94a3b8;
}
html.dark-mode .session-exit:active,
html.dark-mode .drill-exit-btn:active {
  background: rgba(255,255,255,.15);
  color: #e2e8f0;
}

/* Ensure drillContainer is position relative for exit button */
#drillContainer {
  position: relative;
}

/* Feedback animation */
.feedback-anim {
  animation: feedbackPop var(--qr-dur-slow) var(--qr-spring);
}
@keyframes feedbackPop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- Results Grid ---- */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin: 1rem 0;
  width: 100%;
}
.result-item {
  background: var(--qr-surface-2);
  border-radius: var(--r-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result-value { font-size: var(--fs-h1); font-weight: 700; color: var(--qr-accent); font-variant-numeric: tabular-nums; }
.result-label { font-size: var(--fs-caption); color: var(--qr-text-dim); margin-top: .25rem; }
.results-grid .result-item:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: 60%;
  margin-left: auto;
  margin-right: auto;
}
/* Results screen: drillContainer goes fullscreen with its own scroll.
   This class is added by drill-engine.js finish() and removed on navigation.
   Does NOT depend on body.drill-session-active (which is removed before results render). */
#drillContainer.drill-results-active {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-session-bg);
  background: var(--qr-bg);   /* ADR-087: was four per-theme literals, each == that theme's --qr-bg (pixel-identical) */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
#drillContainer.drill-results-active > .card.center-content {
  position: relative;
  margin: 3rem .75rem 3rem .75rem;
  overflow: visible;
}

/* Performance badge */
.performance-badge {
  display: inline-block;
  padding: .5rem 1.25rem;
  border-radius: var(--r-xl);
  font-size: var(--fs-body);
  font-weight: 700;
  margin-bottom: .75rem;
  letter-spacing: .02em;
}
.badge-excellent { background: #dcfce7; color: var(--qr-success-fg); }
.badge-good      { background: #dbeafe; color: var(--qr-accent-strong); }
.badge-practice  { background: #fef9c3; color: #a16207; }
/* Neutral, honest verdict for <50% sessions — informational slate, not celebration-in-red */
.badge-review    { background: var(--qr-surface-2); color: #475569; }
html.dark-mode .badge-review { background: #1e293b; color: #cbd5e1; }

/* ---- Adaptive Mode Pill (in drill progress line) ---- */
.adaptive-mode-pill {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  border-radius: var(--r-full);
  font-size: var(--fs-caption);
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: .02em;
}
.adaptive-pill-hard   { background: #ede9fe; color: var(--qr-info-fg); }
.adaptive-pill-medium { background: #dbeafe; color: var(--qr-accent-strong); }
.adaptive-pill-easy   { background: #dcfce7; color: var(--qr-success-fg); }

/* ---- Adaptive Toggle Hint ---- */
.adaptive-toggle-section { margin-top: .75rem; }
.adaptive-toggle-hint { margin-top: .5rem; }
.adaptive-hint-text {
  font-size: var(--fs-caption);
  color: var(--qr-info-fg);
  font-style: italic;
  text-align: center;
}.adaptive-lock { font-size: .85em; opacity: .7; pointer-events: none; }

/* ---- Speed Benchmark (premium redesign) ---- */
@keyframes sb-slide-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.speed-benchmark-card {
  width: 100%;
  background: var(--qr-grad-wash);
  border: 1px solid #ddd6fe;
  border-radius: var(--qr-card-radius-sm);
  padding: 20px;
  margin: 16px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--qr-glow-accent);
  animation: sb-slide-up var(--qr-dur-slow) var(--qr-ease-out) both;
}
html.dark-mode .speed-benchmark-card {
  background: var(--qr-grad-wash);
  border-color: #4c1d95;
  box-shadow: var(--el-2);
}
.benchmark-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.benchmark-icon {
  font-size: var(--fs-h3);
  line-height: 1;
}
.benchmark-title {
  font-size: var(--fs-caption);
  font-weight: 700;
  color: #5b21b6;
  letter-spacing: .06em;
  text-transform: uppercase;
}
html.dark-mode .benchmark-title { color: #c4b5fd; }
.benchmark-highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.65);
}
html.dark-mode .benchmark-highlight { background: rgba(0,0,0,.25); }
.benchmark-highlight-pct {
  font-size: var(--fs-sub);
  font-weight: 500;
  color: #374151;
  line-height: 1;
}
html.dark-mode .benchmark-highlight-pct { color: #e2e8f0; }
.benchmark-highlight-pct strong {
  font-size: var(--fs-d1);
  font-weight: 800;
  display: block;
  line-height: 1.1;
  margin-bottom: 4px;
}
.benchmark-band-top    .benchmark-highlight-pct strong { color: var(--qr-success-fg); }
.benchmark-band-mid    .benchmark-highlight-pct strong { color: var(--qr-accent); }
.benchmark-band-bottom .benchmark-highlight-pct strong { color: var(--qr-danger); }
html.dark-mode .benchmark-band-top    .benchmark-highlight-pct strong { color: #4ade80; }
html.dark-mode .benchmark-band-mid    .benchmark-highlight-pct strong { color: #60a5fa; }.benchmark-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.benchmark-stat-block {
  background: rgba(255,255,255,.7);
  border-radius: var(--r-md);
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
html.dark-mode .benchmark-stat-block { background: rgba(0,0,0,.3); }
.benchmark-stat-value {
  font-size: var(--fs-h2);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--qr-info-fg);
  line-height: 1;
}
html.dark-mode .benchmark-stat-value { color: #a78bfa; }
.benchmark-stat-label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--qr-text-dim);
  text-align: center;
  line-height: 1.2;
}
html.dark-mode .benchmark-stat-label { color: #94a3b8; }
.benchmark-ai-section { margin-top: -4px; min-height: 4rem; }
@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}
.benchmark-ai-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.benchmark-level {
  display: inline-block;
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  border-radius: var(--r-full);
  padding: .25rem .75rem;
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .03em;
  align-self: center; /* Section A: status badge centered under metrics row */
  box-shadow: var(--qr-glow-accent);
}
.benchmark-summary {
  font-size: var(--fs-sub);
  color: #374151;
  line-height: 1.55;
  margin: 0;
}
html.dark-mode .benchmark-summary { color: #e2e8f0; }
.benchmark-suggestion {
  font-size: var(--fs-caption);
  color: #4b5563;
  line-height: 1.45;
  margin: 0;
}
html.dark-mode .benchmark-suggestion { color: #c4b5fd; }
.benchmark-tip-label {
  font-weight: 700;
  color: var(--qr-info-fg);
}
html.dark-mode .benchmark-tip-label { color: #a78bfa; }

/* ---- Daily Goal ---- */
.goal-card { position: relative; overflow: hidden; }
.goal-progress-fill.goal-met {
  background: var(--qr-grad-bar-ok);
}

/* ---- Learn Page ---- */
.section-title {
  font-size: var(--fs-h3);
  color: var(--qr-accent);
  margin: 0 0 .75rem;
}
.category-select-title {
  margin-bottom: .5rem;
  text-align: center;
  font-size: var(--fs-body);
}
.mode-icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  vertical-align: text-bottom;
  margin-right: .125rem;
}
.mode-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.mode-icon-custom {
  color: #4f46e5;
}
.custom-practice-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-top: .25rem;
}
.custom-practice-start-btn { margin-top: .75rem; width: 100%; }

/* ---- Learn Search ---- */
.learn-search-container {
  margin-bottom: 1rem;
}
.learn-search-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--qr-btn-radius, .9rem);
  background: var(--qr-surface-solid);
  color: var(--qr-text);
  font-size: var(--fs-body);
  outline: none;
  transition: border-color var(--qr-dur), box-shadow var(--qr-dur), background var(--qr-dur);
}
.learn-search-input:focus { border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring); }

/* ---- Math Tables (monospace, aligned) ---- */
.math-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: .75rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}
.math-table th,
.math-table td {
  padding: .5rem .5rem;
  text-align: left;
  border-bottom: 1px solid var(--qr-border);
  font-size: var(--fs-sub);
}
.math-table th { color: var(--qr-text-dim); font-weight: 600; }

.mono-table td {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  white-space: nowrap;
}

/* ---- Math Grid (squares, cubes) ---- */
.math-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem;
}
.math-grid-item {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: var(--fs-sub);
  padding: .25rem .5rem;
  display: flex;
  align-items: center;
  gap: .25rem;
  background: var(--qr-bg);
  border-radius: var(--r-sm);
}
.math-expr { color: var(--qr-text); font-weight: 600; min-width: 2.5rem; text-align: right; }
.math-eq { color: var(--qr-text-dim); }
.math-val { color: var(--qr-accent); font-weight: 600; }

/* ---- Table Selector (Learn page) ---- */
/* CSS Grid ensures exactly 6 columns × 5 rows regardless of device width */
.table-selector {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .25rem;
  margin-bottom: 1rem;
}
.table-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--r-md);
  background: var(--qr-surface-solid);
  color: var(--qr-text);
  font-size: var(--fs-sub);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--qr-dur), background var(--qr-dur), transform var(--qr-dur-fast);
  padding: 0;
}
.table-select-btn:active,
.table-select-btn.active {
  background: var(--qr-accent);
  border-color: var(--qr-accent);
  color: var(--qr-on-accent);
  transform: scale(var(--qr-press-sm));
}
.table-controls {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  margin-top: .5rem;
  width: 100%;
}
.table-controls button {
  flex: 1;
  width: 50%;
}
.table-controls .btn {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

/* ---- Multiplication Table Cards ---- */
.tables-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
.table-card {
  background: rgba(248,250,252,.85);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  border-radius: var(--r-lg);
  padding: .75rem;
  border: 1px solid rgba(226,232,240,.7);
  min-width: 0;
  overflow: hidden;
  text-align: center;
  box-shadow: var(--el-1);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
}
.table-card:active {
  transform: scale(var(--qr-press-sm));
  box-shadow: var(--el-1);
}
.table-title {
  font-size: var(--fs-sub);
  font-weight: 700;
  color: var(--qr-accent);
  margin-bottom: .5rem;
  padding-bottom: .25rem;
  text-align: center;
  border-bottom: 1px solid var(--qr-border);
}
.table-card .math-table {
  width: auto;
  margin: 0 auto;
  table-layout: auto;
}
.table-card .math-table td {
  font-size: var(--fs-caption);
  padding: .125rem .25rem;
  white-space: nowrap;
  text-align: right;
  border-bottom: none;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 320px) {
  .tables-container {
    grid-template-columns: 1fr;
  }
  .table-card .math-table td {
    font-size: var(--fs-sub);
    padding: .25rem .25rem;
  }
}

/* ---- Offline Banner ---- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fef3c7;
  color: #92400e;
  font-size: var(--fs-caption);
  font-weight: 600;
  text-align: center;
  padding: .5rem .75rem;
  z-index: var(--z-boot-hide);
  animation: offlineSlideDown var(--qr-dur) var(--qr-ease-out);
  box-shadow: var(--el-1);
}
html.dark-mode .offline-banner {
  background: #451a03;
  color: #fbbf24;
}
@keyframes offlineSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---- Streak-at-risk banner ---- */
.streak-risk-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--qr-card-radius-sm);
  background: var(--qr-grad-wash-duel);
  border: 1px solid var(--qr-warn);
  margin-bottom: .75rem;
}
.streak-risk-icon { --qr-ico-size: var(--fs-h1); font-size: var(--fs-h1); }
.streak-risk-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .125rem;
}
.streak-risk-content strong { color: #92400e; font-size: var(--fs-sub); }
.streak-risk-sub { color: #a16207; font-size: var(--fs-caption); }
.streak-risk-btn {
  padding: .5rem .75rem;
  border-radius: var(--r-sm);
  background: var(--qr-warn);
  color: var(--qr-on-accent);
  font-weight: 600;
  font-size: var(--fs-sub);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background var(--qr-dur);
}
.streak-risk-btn:hover { background: #d97706; }

/* ---- Suggested practice card ---- */
.suggested-practice-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--qr-card-radius-sm);
  background: var(--qr-grad-wash);
  border: 1px solid #14b8a6;
  margin-bottom: .75rem;
}
.suggested-icon { --qr-ico-size: var(--fs-h1); font-size: var(--fs-h1); }
.suggested-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .125rem;
}
.suggested-content strong { color: #0f766e; font-size: var(--fs-sub); }
.suggested-sub { color: #0d9488; font-size: var(--fs-caption); }
.suggested-btn {
  padding: .5rem .75rem;
  border-radius: var(--r-sm);
  background: #14b8a6;
  color: var(--qr-on-accent);
  font-weight: 600;
  font-size: var(--fs-sub);
  border: none;
  cursor: pointer;
  transition: background var(--qr-dur);
}
.suggested-btn:hover { background: #0d9488; }

/* ---- Daily quota indicator ---- */
.daily-quota-card {
  padding: .75rem 1rem;
  border-radius: var(--qr-card-radius-sm);
  background: var(--qr-surface-2);
  border: 1px solid var(--qr-border);
  margin-bottom: .75rem;
}
.quota-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}
.quota-label { color: var(--qr-text-dim); font-size: var(--fs-caption); font-weight: 500; }
.quota-count { color: #334155; font-size: var(--fs-sub); font-weight: 700; }
.quota-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--qr-surface-3);
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--qr-grad-bar);
  transition: width var(--qr-dur-slow) var(--qr-ease-out);
}
.quota-fill.quota-full {
  background: var(--qr-grad-bar-danger);
}
/* ADR-151: the two per-day set allowances, shown under the question bar so all three free limits
   are legible in one glance on the Practice tab. */
.quota-sets {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .45rem;
}
.quota-set {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--qr-text-dim);
  background: var(--qr-surface-3);
  border-radius: 999px;
  padding: .1rem .5rem;
}
.quota-set.quota-set-spent {
  color: var(--qr-danger);
  opacity: .85;
}
.quota-warning {
  display: block;
  margin-top: .25rem;
  font-size: var(--fs-caption);
  color: var(--qr-danger);
}
.quota-upgrade-link {
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Dark mode: Batch 3 cards ---- */
html.dark-mode .streak-risk-card {
  background: var(--qr-grad-wash-duel);
  border-color: #b45309;
}
html.dark-mode .streak-risk-content strong { color: #fde68a; }
html.dark-mode .streak-risk-sub { color: #fbbf24; }
html.dark-mode .streak-risk-btn { background: #b45309; }
html.dark-mode .streak-risk-btn:hover { background: #92400e; }

html.dark-mode .suggested-practice-card {
  background: var(--qr-grad-wash);
  border-color: #0d9488;
}
html.dark-mode .suggested-content strong { color: #99f6e4; }
html.dark-mode .suggested-sub { color: #5eead4; }
html.dark-mode .suggested-btn { background: #0d9488; }
html.dark-mode .suggested-btn:hover { background: #0f766e; }

html.dark-mode .daily-quota-card {
  background: #1e293b;
  border-color: #334155;
}
html.dark-mode .quota-label { color: #94a3b8; }
html.dark-mode .quota-count { color: #e2e8f0; }
html.dark-mode .quota-bar { background: #334155; }
html.dark-mode .quota-set { background: #334155; color: #94a3b8; }
html.dark-mode .quota-set.quota-set-spent { color: #fca5a5; }
html.dark-mode .quota-warning { color: #fca5a5; }
html.dark-mode .quota-upgrade-link { color: #60a5fa; }

/* ---- Progress/Stats Page ---- */

/* ---- Bottom Navigation ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--qr-surface-solid);
  border-top: 1px solid var(--qr-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--qr-nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: var(--z-nav);
  box-shadow: var(--el-nav);
  /* Prevent bouncy scroll from affecting navbar */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overscroll-behavior: none;
  will-change: transform;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: #94a3b8;
  padding: .5rem 0;
  flex: 1;
  min-height: 48px;
  justify-content: center;
  text-decoration: none;
  transition: color var(--qr-dur), transform var(--qr-dur-fast);
  cursor: pointer;
  position: relative;
}
.bottom-nav a:active { transform: scale(var(--qr-press-sm)); }
.bottom-nav a .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  aspect-ratio: 1;
  margin-bottom: .25rem;
  line-height: 0;
}
.bottom-nav a .nav-icon .qr-ico {
  display: block;
  font-size: var(--fs-h2);
  line-height: 1;
  transition: transform var(--qr-dur) var(--qr-ease-out), opacity var(--qr-dur);
  opacity: .55;
}
.bottom-nav a.active { color: var(--qr-accent); }
.bottom-nav a.active .nav-icon .qr-ico {
  transform: scale(1.15);
  opacity: 1;
}
.bottom-nav a .nav-icon .qr-ico.tab-pop {
  animation: tab-icon-pop var(--qr-dur) var(--qr-ease-out) both;
}
@keyframes tab-icon-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1.15); }
}
.bottom-nav a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 1.5rem;
  height: 2.5px;
  background: var(--qr-grad-bar);
  border-radius: 0 0 2px 2px;
  transition: transform var(--qr-dur) var(--qr-ease-out);
}
.bottom-nav a.active::after {
  transform: translateX(-50%) scaleX(1);
}

/* ---- Collapsible Sections ---- */
.collapsible-card { padding: 0; overflow: hidden; }
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--qr-dur-fast);
  min-height: 48px;
}
.collapsible-header:active { background: var(--qr-surface-2); }
.collapsible-header:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: inherit; }
.collapsible-header .section-title { margin: 0; }
.collapse-icon {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  transition: transform var(--qr-dur);
}
.collapsible-content {
  padding: 0 1.25rem 1.25rem;
}

/* ---- Mode Cards (Practice page) ---- */
.mode-card {
  background: rgba(255,255,255,.88);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  border-radius: var(--qr-card-radius);
  padding: var(--qr-card-padding);
  margin-bottom: .75rem;
  box-shadow: var(--qr-shadow-light);
  border: var(--qr-card-border-light);
  cursor: pointer;
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out);
  min-height: 48px;
  touch-action: pan-y; /* Improves scroll responsiveness */
  flex-shrink: 0;
}
.mode-card:active { transform: scale(var(--qr-press-lg)); background: rgba(248,250,252,.9); box-shadow: var(--el-1); }
.mode-card h3 {
  font-size: var(--fs-h3);
  color: var(--qr-text);
  margin-bottom: .25rem;
}
.mode-card p {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  line-height: 1.4;
}

/* ---- Category Grid (Practice page) ---- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
  margin-top: .25rem;
}
.category-btn {
  padding: 12px 8px;
  min-height: 44px;                 /* ADR-095: meet the 44px touch-target minimum for this dense picker grid */
  border: 2px solid rgba(0,0,0,.08);/* 2px in BOTH states so selection is a colour change, never a width reflow */
  border-radius: var(--r-md);
  background: var(--qr-surface-solid);
  color: #111827;
  font-size: var(--fs-caption);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background var(--qr-dur), border var(--qr-dur);
}
.category-btn:active {
  background: var(--qr-bg);
  border-color: var(--qr-accent);
}
.category-btn.selected {
  background: rgba(37,99,235,.10);
  border: 2px solid var(--qr-accent);        /* same width as base → no layout shift on select */
  color: var(--qr-accent-strong);
  font-weight: 700;
}
.custom-practice-config {
  display: none;
  margin-top: 1rem;
  padding: 0 12px;
}
#focusStartSection {
  padding: 0 12px;
}
.custom-question-range {
  width: 100%;
  margin-top: .25rem;
}
.custom-mode-error {
  min-height: 1rem;
  color: var(--qr-danger);
  margin: .5rem 0 0;
}

/* Timer selection for Focus & Custom modes */
.timer-select-section {
  margin-top: 1rem;
  padding: .75rem;
  margin-left: 12px;
  margin-right: 12px;
  background: rgba(241,245,249,.65);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  border: 1px solid rgba(226,232,240,.6);
  border-radius: var(--r-lg);
}
html.dark-mode .timer-select-section {
  background: rgba(30,41,59,.5);
  border-color: rgba(51,65,85,.5);
}
.timer-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.timer-toggle-label {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: #374151;
}
html.dark-mode .timer-toggle-label { color: #e2e8f0; }
.timer-config-area {
  margin-top: .75rem;
}
/* Timer pills co-declare with the .qr-segment primitive (FW-W3) — see the design-system block. */
.timer-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .75rem;
}
.timer-seconds-input {
  width: 5.5rem;
  padding: .5rem .5rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--r-sm);
  font-size: var(--fs-body);
  font-weight: 700;
  text-align: center;
  color: var(--qr-text);
  background: var(--qr-surface-solid);
  outline: none;
  transition: border-color var(--qr-dur-fast);
}
.timer-seconds-input:focus {
  border-color: var(--qr-accent);
  box-shadow: var(--qr-focus-ring);
}
html.dark-mode .timer-seconds-input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark-mode .timer-seconds-input:focus { border-color: #3b82f6; }
.timer-unit-label {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  font-weight: 500;
}
html.dark-mode .timer-unit-label { color: #94a3b8; }

/* Daily limit banner */
.daily-limit-banner {
  background: var(--qr-grad-wash-duel);
  border: 1px solid var(--qr-warn);
  border-radius: var(--r-md);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
  font-size: var(--fs-sub);
  color: #92400e;
  font-weight: 500;
}
.daily-limit-banner .btn {
  margin-top: .5rem;
  max-width: 200px;
  min-height: 36px;
  padding: .5rem .75rem;
  font-size: var(--fs-sub);
}
html.dark-mode .daily-limit-banner {
  background: var(--qr-grad-wash-duel);
  border-color: #d97706;
  color: #fef3c7;
}
.settings-group .card {
  margin-bottom: .75rem;
}
.settings-group .card:last-child {
  margin-bottom: 0;
}

/* Settings Sections */
.settings-section {
  margin-bottom: 1.75rem;
}
.settings-section:last-child {
  margin-bottom: 1rem;
}
.settings-section-title {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--qr-text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
  padding-left: .25rem;
}.settings-section-card {
  background: var(--qr-surface-solid);
  border-radius: var(--r-lg);
  /* ADR-135: horizontal padding is fluid so a 320px phone reclaims ~13px of row width. Vertical is
     unchanged; at >=360px this resolves to the original 1rem, so nothing moves on normal phones. */
  padding: .75rem clamp(.5rem, 3vw, 1rem);
  box-shadow: var(--el-1);
  border: 1px solid rgba(226,232,240,.5);
}
html.dark-mode .settings-section-card {
  background: #1e293b;
  box-shadow: var(--el-1);
  border-color: rgba(51,65,85,.5);
}
.settings-row-divider {
  height: 1px;
  background: var(--qr-surface-2);
  margin: .5rem 0;
}
html.dark-mode .settings-row-divider {
  background: #334155;
}
.settings-row-block {
  padding: .5rem 0;
}
.settings-row-block h3 {
  font-size: var(--fs-body);
  color: var(--qr-text);
  margin-bottom: .25rem;
}
html.dark-mode .settings-row-block h3 {
  color: #f1f5f9;
}

/* .settings-row co-declares with the .qr-row primitive (FW-W3) — see the design-system block. */
/* min-width:0 lets the text column shrink below its content width so a long subtitle wraps INSIDE its own
   column instead of shoving the fixed-width control past the card's right padding (the flexbox-overflow fix). */
.settings-label { flex: 1; min-width: 0; }
.settings-label h3 {
  font-size: var(--fs-body);
  color: var(--qr-text);
  margin-bottom: .25rem;
}
.settings-label p {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  line-height: 1.35;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-boot-top);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: .75rem 1rem;
  border-radius: var(--r-lg);
  font-size: var(--fs-sub);
  font-weight: 500;
  box-shadow: var(--el-2);
  opacity: 0;
  transform: translateY(.75rem);
  transition: opacity var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out);
  pointer-events: auto;
  max-width: 90vw;
  text-align: center;
  letter-spacing: .01em;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}
html.dark-mode .toast {
  background: #334155;
  color: #f1f5f9;
}

/* ═══════════════════════════════════════════════════════════════════════════
   QR PRIMITIVES (UI Phase 1 / M3) — the shared component layer. Overlays route
   their lifecycle through QROverlay (js/ui/overlay.js); these are the token-driven
   visual primitives it + the surfaces build on, so one theme switch is correct
   everywhere and there is one implementation of each pattern.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ---- Button ---- */
.qr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px;                 /* comfortable touch target (§6.8) */
  font: inherit; font-weight: 700; font-size: var(--fs-sub);
  padding: .75rem 1.25rem; border: 0; border-radius: var(--r-md);
  cursor: pointer; text-align: center; line-height: 1.15;
  transition: transform var(--qr-dur-fast) var(--qr-ease), background var(--qr-dur) var(--qr-ease), box-shadow var(--qr-dur) var(--qr-ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.qr-btn:active { transform: scale(var(--qr-press-sm)); }
.qr-btn.is-loading { opacity: .65; pointer-events: none; }
.qr-btn:disabled, .qr-btn[disabled] { opacity: .45; pointer-events: none; }
.qr-btn:focus-visible { outline: none; box-shadow: var(--qr-focus-ring); }
.qr-btn-primary { background: var(--qr-grad-cta); color: var(--qr-on-accent); box-shadow: var(--qr-glow-accent); }
.qr-btn-secondary { background: var(--qr-surface-2); color: var(--qr-text); box-shadow: var(--el-inset); }
.qr-btn-danger { background: var(--qr-danger); color: var(--qr-on-accent); }
.qr-btn-ghost { background: transparent; color: var(--qr-accent); }
.qr-btn-tonal { background: color-mix(in srgb, var(--qr-accent) 14%, transparent); color: var(--qr-accent-strong); }
.qr-btn-sm { padding: .5rem .75rem; font-size: var(--fs-caption); }
.qr-btn-lg { padding: 1rem 1.25rem; font-size: var(--fs-body); }
.qr-btn-block { width: 100%; }

/* ============================================================================
   FW-W3 — design-system primitives (token-only). Authored EARLY in the file on
   purpose: component rules further down co-declare onto these (real adopters:
   report + companion sheets, timer pills, settings rows, About TOC chips,
   duel-archive skeleton, inbox cards, modal/goal inputs) and keep only their
   deltas — the cascade lets a component override a primitive simply by coming
   later. New surfaces (W4 Quick Study chips/picker) use the bare .qr-* classes.
   ========================================================================== */

/* ---- Bottom sheet (phone) → centered dialog (≥600px) ---- */
.qr-sheet, .report-sheet-overlay, .companion-overlay, .duel-sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  display: flex; align-items: flex-end; justify-content: center;
  -webkit-backdrop-filter: var(--glass-scrim); backdrop-filter: var(--glass-scrim);
}
.qr-sheet { z-index: var(--z-sheet); }
.qr-sheet-card, .report-sheet, .companion-sheet, .duel-sheet {
  width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh;
  background: var(--qr-surface-solid);
  border-radius: var(--r-sheet-top);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--el-sheet);
}
.qr-sheet-grabber, .report-sheet-grabber, .companion-grabber {
  width: 38px; height: 4px; border-radius: var(--r-full); background: var(--qr-border-strong);
  margin: .5rem auto .125rem; flex-shrink: 0; cursor: grab;
}
@media (min-width: 600px) {
  .qr-sheet, .report-sheet-overlay, .companion-overlay, .duel-sheet-overlay { align-items: center; }
  .qr-sheet-card, .report-sheet, .companion-sheet, .duel-sheet { border-radius: var(--r-sheet); max-height: 84vh; }
  .qr-sheet-grabber, .report-sheet-grabber, .companion-grabber { display: none; }
}

/* ---- Card ---- */
.qr-card {
  background: var(--qr-surface-solid); color: var(--qr-text);
  border: 1px solid var(--qr-border); border-radius: var(--qr-card-radius-sm);
  padding: var(--sp-4);
}

/* ---- Chip (pill-shaped tap target) ---- */
.qr-chip, .info-toc-chip {
  font: inherit; font-weight: 700;
  border: 1px solid var(--qr-border); border-radius: var(--r-full);
  padding: .25rem .5rem; min-height: 2.25rem;   /* 36px minimum touch target (ADR-110) */
  cursor: pointer;
}
.qr-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  background: var(--qr-surface-2); color: var(--qr-text-dim); font-size: var(--fs-caption);
}
.qr-chip:active, .info-toc-chip:active { transform: scale(var(--qr-press-sm)); }
.qr-chip:focus-visible, .info-toc-chip:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }

/* ---- Row (label left, control right; 48px comfortable line) ---- */
.qr-row, .settings-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-4); min-height: 48px; padding: var(--sp-1) 0;
}
/* ADR-135 — Settings rows must never truncate their label. The select was `flex: 0 1 auto` with a hard
   `min-width: 8.5rem`, so it refused to shrink and starved the `flex: 1` label: at 320px the label got
   96px for text needing 147px, and 6 of 17 labels ellipsised. Solving the width budget shows the
   problem reaches every viewport below 371px, so 360px devices were affected too.

   ADR-136 — the ADR-135 repair was fluid (`clamp(7.5rem, 34vw, 8.5rem)`), which fixed truncation but
   bought it with inconsistency: the same control measured 120px on a 320px phone and 136px on a 390px
   one, with the arrow at a different inset on each. The control is now FIXED, so every dropdown is
   pixel-identical on every device.

   That is safe only because ADR-135's real fix was the label rule below — labels wrap instead of
   ellipsising, so the control no longer has to give width back. Worst case, 320px:
   320 − 40 (.container) − 19.2 (.settings-section-card, whose 3vw padding is KEPT and is load-bearing
   here) − 16 (gap) − 136 (select) = 108.8px of label column against a 96px longest single word
   ("Appearance"). Nothing breaks mid-word and nothing clips. */
.settings-row .theme-select {
  /* `width` as well as the flex basis: the base rule is `width: auto; min-width: 8.5rem`, so without
     it a select is as wide as its own longest option and "Playful Professional" would outgrow "Easy".
     Pinning both is what makes all six identical to EACH OTHER, not just across devices. */
  flex: 0 0 8.5rem;
  width: 8.5rem;
  min-width: 0;
  /* The arrow gutter and inset are fixed for the same reason — a chevron sitting 8px from the edge on
     one phone and 13.6px on another is the same control drawn two ways. These restate the base
     `.theme-select` values deliberately, so the fixed contract reads in one place instead of depending
     on the absence of a fluid rule. */
  padding-right: 2.25rem;
  background-position: right .85rem center;
}
/* The label WRAPS rather than ellipsising. It sat in the `.cat-name / .mode-card h3` nowrap+ellipsis
   group, which is right for a single-line card title and wrong here: a Settings label names the control
   beside it and must always be readable in full. Wrapping is also what makes the fixed control width
   above safe: the label gives, so the dropdown never has to. */
.settings-label h3 { white-space: normal; overflow-wrap: break-word; }

/* ---- Input ---- */
.qr-input, .modal-input, .goal-input, .duel-join-input {
  border: 2px solid var(--qr-border); border-radius: var(--r-md);
  outline: none; color: var(--qr-text); background: var(--qr-surface-solid);
  transition: border-color var(--qr-dur);
}
/* ADR-138 — release-certification finding, caught only once the gate learned about bottom sheets.
   This input is the Quick Study picker's search field, and it was 40.2px tall before ADR-133 and 37px
   after: the spacing normalisation snapped its 0.6rem padding to the nearest 4px step (9.6px → 8px),
   which is the transform working exactly as documented — but it took a control that was ALREADY under
   the 44px touch floor and made it worse. The floor is the fix, not the padding: `.theme-select`,
   `.settings-action-btn`, `.qs-pick-row`, `.numpad-btn` and the duel buttons all already carry
   `min-height: 44px`, so the text input was simply the one control the convention had missed. */
.qr-input { width: 100%; box-sizing: border-box; padding: .5rem .75rem; font: inherit; font-size: var(--fs-sub); min-height: 44px; }
.qr-input:focus, .modal-input:focus, .goal-input:focus, .duel-join-input:focus { border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring); }

/* ---- Segment (single-select pill row) ---- */
.qr-segment, .timer-pill-selector { display: flex; background: #e8edf3; border-radius: var(--r-md); padding: 4px; gap: 4px; }
html.dark-mode .qr-segment, html.dark-mode .timer-pill-selector { background: #1e293b; }
.qr-segment-btn, .timer-pill {
  flex: 1; padding: .5rem .5rem; border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--qr-text-dim); font-size: var(--fs-caption); font-weight: 600;
  cursor: pointer; text-align: center;
  transition: background var(--qr-dur) var(--qr-ease-out), color var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out), opacity var(--qr-dur) var(--qr-ease-out);
}
.qr-segment-btn.active, .timer-pill.active { background: var(--qr-surface-solid); color: var(--qr-accent-strong); box-shadow: var(--el-1); }
html.dark-mode .qr-segment-btn.active, html.dark-mode .timer-pill.active { background: #334155; color: #93c5fd; }

/* ---- Skeleton (ambient loading pulse) ---- */
.qr-skel, .ba-skeleton { display: flex; flex-direction: column; gap: .5rem; }
.qr-skel-row, .ba-skel-row {
  height: 3.2rem; border-radius: var(--qr-card-radius-sm);
  background: var(--qr-skel-veil);
  animation: qrSkelPulse var(--qr-dur-pulse) var(--qr-ease) infinite;
}
@keyframes qrSkelPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---- Inbox card adoption (was inline-styled; var(--radius-lg) was undefined → radius silently
   computed to 0. The .qr-card shell fixes that and gives the drawer real theme surfaces.) ---- */
.notification-card { cursor: pointer; }
.notification-card.is-unread { background: var(--qr-surface-2); border-color: var(--qr-danger); }

/* ============================================================================
   Quick Study v2 (FW-W4) — the Home shortcut tray + the categorized picker
   sheet. Built ENTIRELY on existing components (.mode-card + the Practice tray
   on Home; .qr-sheet/.qr-row/.qr-input/.qr-btn in the picker); only
   Quick-Study-specific arrangement lives here.
   ========================================================================== */
/* ---- Home tray (ADR-136) — Practice's smaller sibling ----------------------------------------
   Quick Study used to be a wrapping row of `.qs-chip` pills inside one `.qr-card`: a tag cloud that
   read as metadata rather than as a set of destinations, and that pushed Home arbitrarily long as
   shortcuts were added. It is now the Practice pattern at a smaller scale — the same grouping tray
   (`.practice-container`) around the same cards (`.mode-card`) at the same rhythm
   (`.practice-mode-group`'s 16px column).

   The cards genuinely ARE `.mode-card`s, so every theme rule, the `:active` press scale and the global
   ripple come along automatically and can never drift apart from Practice. Only the arrangement lives
   here: a single line of leading icon, title, trailing chevron. */
.qs-tray {
  display: flex;
  flex-direction: column;
  /* the .practice-container surface, verbatim */
  background: var(--qr-panel);
  border-radius: var(--qr-card-radius);
  padding: 1rem .75rem;
  /* Cap at four cards. The px value is measured and set by home-view.js — at 1–4 cards it equals the
     content height exactly (tight wrap, no dead space, no scrollbar); at 5+ it freezes at the fourth.
     `max-height: none` here is the pre-measurement state, never a rendered one. */
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  /* required: the tray is nested inside the scrolling Home view and must not chain its overscroll */
  overscroll-behavior-y: contain;
}
.qs-tray::-webkit-scrollbar { display: none; }
/* Armed one frame after the first paint, so the tray does not animate open on load — only later
   add/remove of shortcuts animates. */
.qs-tray.is-ready { transition: max-height var(--qr-dur-slow) var(--qr-ease-out); }
/* `flex: 0 0 auto` is defensive: as the tray's only flex item the group must overflow the capped
   height, never shrink to fit it. (`.mode-card` carries the same guard inside Practice.) */
.qs-group { display: flex; flex-direction: column; gap: var(--sp-4); flex: 0 0 auto; }
.qs-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  /* Height is set by the RADIUS, not by the text. `--qr-card-radius` is 24px in Classic and 28px in
     Playful; once the radius approaches half the height the corners meet and the card reads as a
     pill — the exact shape this redesign replaces. Measured at the first pass: 60px gave 24/60 = 0.40
     in Classic and 28/60 = 0.47 in Playful, and the Playful screenshot was unmistakably a pill. 68px
     brings the ratios to 0.35 / 0.41 against Practice's own 24/87 = 0.28, and the card reads as a
     card in all four themes. Horizontal padding matches Practice's 1.25rem exactly. */
  min-height: 68px;
  padding: .75rem 1.25rem;
  margin-bottom: 0;
  font: inherit;
  text-align: left;
}
.qs-card .qr-ico { --qr-ico-size: 1.15rem; flex: 0 0 auto; color: var(--qr-accent); }
.qs-card-label {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--qr-text);
  overflow-wrap: break-word;
}
.qs-card .settings-chevron { font-size: var(--fs-h2); }
.qs-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }

/* Picker sheet — .qs-chip-label is the picker row's title (see `.qs-pick-main .qs-chip-label`), which
   is why it outlived the Home chips it was named for. */
.qs-chip-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.qs-picker-overlay { z-index: var(--z-sheet); animation: modalOverlayFadeIn var(--qr-dur) var(--qr-ease); }
.qs-picker-overlay.closing { animation: modalOverlayFadeOut var(--qr-dur) var(--qr-ease) forwards; }
.qs-picker-overlay.closing .qs-picker { opacity: 0; transform: translateY(12px); transition: opacity var(--qr-dur) var(--qr-ease), transform var(--qr-dur) var(--qr-ease); }
.qs-picker-head { display: flex; align-items: baseline; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4) 0; }
.qs-picker-title { flex: 1; font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); }
.qs-picker-title:focus { outline: none; }
.qs-picker-selcount { flex: 0 0 auto; font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); }
.qs-picker-search { padding: var(--sp-2) var(--sp-4); }
.qs-picker-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--sp-4) var(--sp-2); }
.qs-pick-section { border: 1px solid var(--qr-border); border-radius: var(--r-md); margin-bottom: var(--sp-2); overflow: hidden; background: var(--qr-surface-solid); }
.qs-pick-header {
  width: 100%; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3); border: 0; background: var(--qr-surface-2);
  font: inherit; font-size: var(--fs-sub); font-weight: 800; color: var(--qr-text);
  cursor: pointer; text-align: left;
}
.qs-pick-header:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: -2px; }
.qs-pick-header span:first-child { flex: 1; }
.qs-pick-count { font-size: var(--fs-micro); font-weight: 800; color: var(--qr-accent); }
.qs-pick-caret { color: var(--qr-text-dim); transition: transform var(--qr-dur) var(--qr-ease); }
.qs-pick-section.is-open .qs-pick-caret { transform: rotate(180deg); }
.qs-pick-list { padding: var(--sp-1) var(--sp-3); }
.qs-pick-subhead { font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--qr-text-dim); margin: var(--sp-2) 0 0; }
.qs-pick-row { cursor: pointer; min-height: 44px; }
.qs-pick-row + .qs-pick-row { border-top: 1px solid var(--qr-border); }
.qs-pick-main { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: 1; font-size: var(--fs-sub); color: var(--qr-text); }
.qs-pick-main .qr-ico { --qr-ico-size: 1rem; color: var(--qr-accent); flex: 0 0 auto; }
.qs-pick-main .qs-chip-label { max-width: none; }
.qs-pick-lock { min-height: 0; padding: .125rem .25rem; font-size: var(--fs-micro); gap: 2px; display: inline-flex; align-items: center; color: var(--qr-text-dim); }
.qs-pick-lock .qr-ico { --qr-ico-size: .7rem; color: inherit; }
.qs-pick-row input[type="checkbox"] { accent-color: var(--qr-accent); width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.qs-picker-hint { padding: 0 var(--sp-4); margin: 0 0 var(--sp-1); font-size: var(--fs-caption); }
.qs-picker-empty { text-align: center; padding: var(--sp-4) 0; }
.qs-picker-actions { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--qr-border); }
.qs-picker-actions .qr-btn { flex: 1; }

/* Streak chip — now lives in the Daily Goal card header (FW-W4); ids unchanged for home-view.js */
.home-streak-chip { border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.1); color: var(--qr-text); gap: 4px; cursor: default; }
.home-streak-chip .streak-fire { --qr-ico-size: var(--fs-sub); font-size: var(--fs-sub); line-height: 1; }
.home-streak-chip .streak-count { font-weight: 800; }

/* ---- Dialog (centered, focus-trapped by QROverlay) ---- */
.qr-dialog-overlay {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + var(--sp-4)) var(--sp-4) calc(env(safe-area-inset-bottom, 0px) + var(--sp-4));
  background: rgba(15,23,42,.55);
  -webkit-backdrop-filter: var(--glass-scrim); backdrop-filter: var(--glass-scrim);
  animation: modalOverlayFadeIn var(--qr-dur) var(--qr-ease);
}
.qr-dialog-overlay.closing { animation: modalOverlayFadeOut var(--qr-dur) var(--qr-ease) forwards; }
.qr-dialog-card {
  background: var(--qr-surface-solid); color: var(--qr-text);
  width: 100%; max-width: 24rem; border-radius: var(--r-xl); box-shadow: var(--el-3);
  padding: var(--sp-6); text-align: center;
  max-height: 85vh; overflow-y: auto;
  animation: modalContentScaleIn var(--qr-dur) var(--qr-spring);
}
.qr-dialog-overlay.closing .qr-dialog-card { opacity: 0; transform: scale(.96); transition: opacity var(--qr-dur) var(--qr-ease), transform var(--qr-dur) var(--qr-ease); }
.qr-dialog-icon { display: inline-flex; width: 2.5rem; height: 2.5rem; color: var(--qr-accent); margin-bottom: var(--sp-2); }
.qr-dialog-card.is-danger .qr-dialog-icon { color: var(--qr-danger); }
.qr-dialog-title { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); margin-bottom: var(--sp-2); letter-spacing: -.01em; }
.qr-dialog-title:focus { outline: none; }
.qr-dialog-body { font-size: var(--fs-sub); color: var(--qr-text-dim); line-height: 1.5; margin-bottom: var(--sp-5); }
.qr-dialog-actions { display: flex; gap: var(--sp-3); }
.qr-dialog-actions .qr-btn { flex: 1; }

/* ---- Toast v2 — variants + action (container gets role=status/aria-live in JS) ---- */
.toast.is-success { border-left: 3px solid var(--qr-success-border); }
.toast.is-error { border-left: 3px solid var(--qr-danger-border); }
.toast.is-info { border-left: 3px solid var(--qr-accent); }
.toast-action { margin-left: .5rem; background: none; border: 0; color: var(--qr-accent-2); font-weight: 800; cursor: pointer; font-size: inherit; padding: 0; }

/* ---- PRO badge (unified — the single source of truth for every "PRO"/premium marker) ----
   The legacy per-surface classes (.home-premium-badge, .duel-premium-badge, .info-premium-chip) now
   share this one amber design; their markup/ids/i18n hooks are untouched. Surface-specific layout
   deltas (inline margins) are the only overrides retained below. */
.qr-badge-pro,
.home-premium-badge,
.duel-premium-badge,
.info-premium-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: var(--fs-micro); font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: .125rem .5rem; border-radius: var(--r-full);
  color: #b45309; background: rgba(245,158,11,.16);
  vertical-align: middle; flex-shrink: 0;
}
html.dark-mode .qr-badge-pro,
html.dark-mode .home-premium-badge,
html.dark-mode .duel-premium-badge,
html.dark-mode .info-premium-chip { color: #fcd34d; background: rgba(245,158,11,.22); }
.qr-badge-pro .qr-ico,
.home-premium-badge .qr-ico,
.info-premium-chip .qr-ico { --qr-ico-size: .8rem; color: inherit; }
.home-premium-badge { margin-left: .25rem; }

/* Profile Modal */
.profile-modal {
  max-width: 24rem;
}
.profile-field {
  margin-bottom: 1rem;
}
.profile-field:last-of-type {
  margin-bottom: .5rem;
}
.profile-field-label {
  display: block;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--qr-text-dim);
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}.profile-input {
  width: 100%;
  box-sizing: border-box;
}
.profile-input:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  body,
  body *,
  body *::before,
  body *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .ripple-effect { display: none !important; }
}
body.reduced-motion,
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}
body.reduced-motion .ripple-effect { display: none !important; }
body.reduced-motion .splash-logo { animation: none !important; }
body.reduced-motion .splash-blob { animation: none !important; display: none !important; }
body.reduced-motion .fade-in { animation: none !important; opacity: 1 !important; }
body.reduced-motion .guide-animate-section { opacity: 1 !important; transform: none !important; }

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 3rem;
  height: 1.75rem;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: var(--r-lg);
  transition: background var(--qr-dur);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 1.35rem;
  width: 1.35rem;
  left: .2rem;
  bottom: .2rem;
  background: var(--qr-surface-solid);
  border-radius: 50%;
  transition: transform var(--qr-dur);
}
.toggle input:checked + .toggle-slider { background: var(--qr-accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(1.25rem); }

/* Goal input */
/* Box/border/focus come from the .qr-input primitive (FW-W3); only the size deltas live here. */
.goal-input {
  width: 5rem;
  flex-shrink: 0;
  padding: .5rem;
  font-size: var(--fs-body);
  font-weight: 600;
  text-align: center;
}

/* ---- Settings Info Sections ---- */
.settings-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--qr-dur-fast);
}
.settings-link:active {
  background: rgba(37,99,235,.06);
}
.settings-chevron {
  font-size: var(--fs-h1);
  /* ADR-138 — was a hardcoded #94a3b8, with three per-theme literals overriding it. Those are the
     PRE-TOKEN values the design system already rejected: line 34 records #94a3b8 as "~2.9:1 on white,
     sub-AA" and line 147 records #64748b as "below AA on dark surfaces" — the chevron simply never got
     migrated when `--qr-text-dim` was introduced. Measured on Quick Study cards it sat at 2.50 / 3.08 /
     3.17 / 2.07 : 1 across the four themes, the last well under the 3:1 floor for a UI affordance.
     ADR-136 then multiplied the problem by putting a chevron on every Quick Study card.
     Routing through the token fixes both at once, per theme, and drops four colour literals. The three
     theme overrides below are removed BECAUSE they would defeat the token — that is the mechanism of
     the fix, not opportunistic cleanup. */
  color: var(--qr-text-dim);
  font-weight: 300;
  line-height: 1;
  flex-shrink: 0;
}
html.dark-mode .settings-link:active {
  background: rgba(96,165,250,.08);
}

/* ---- Contact support card (ADR-100 → ADR-102 premium redesign) — a STANDALONE card in the Feedback
   section: mail avatar + address (tap to email) + a copy button (tap to copy). Adopts the About modal's
   .info-block design language (radius, soft dual shadow, hairline border, generous padding, press-scale)
   so it reads as intentional/premium, while keeping its richer avatar + copy affordances. Dark-mode aware. ---- */
.contact-card {
  display: flex; align-items: center; gap: 1rem;
  margin-top: .75rem;
  background: var(--qr-surface-solid);
  border-radius: var(--r-lg);
  padding: 1rem 1rem;
  box-shadow: var(--el-1);
  border: 1px solid rgba(226,232,240,.5);
  transition: box-shadow var(--qr-dur-fast) var(--qr-ease-out);
}
html.dark-mode .contact-card {
  background: #1e293b;
  border-color: rgba(51,65,85,.5);
  box-shadow: var(--el-1);
}
.contact-card-avatar {
  flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: rgba(37,99,235,.1); color: var(--qr-accent); display: flex; align-items: center; justify-content: center; font-size: var(--fs-h3);
}
html.dark-mode .contact-card-avatar { background: rgba(96,165,250,.14); color: #93c5fd; }
.contact-card-body { flex: 1; min-width: 0; }
.contact-card-title { font-size: var(--fs-caption); font-weight: 600; color: var(--qr-text-dim); }
html.dark-mode .contact-card-title { color: #94a3b8; }
.contact-card-email { display: inline-block; margin-top: .125rem; font-size: var(--fs-sub); line-height: 1.6; font-weight: 700; color: var(--qr-accent); text-decoration: none; word-break: break-all; -webkit-tap-highlight-color: transparent; }
.contact-card-email:hover { text-decoration: underline; }
.contact-card-email:active { opacity: .7; }
.contact-card-email:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: 4px; }
html.dark-mode .contact-card-email { color: #93c5fd; }
.contact-card-copy {
  flex: 0 0 auto; width: 2.75rem; height: 2.75rem; border: 1px solid rgba(226,232,240,.9); border-radius: var(--r-md);
  background: var(--qr-surface-solid); color: var(--qr-text-dim); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-h3); transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast), transform var(--qr-dur-fast);
}
.contact-card-copy:hover { background: var(--qr-surface-2); }
.contact-card-copy:active { transform: scale(var(--qr-press-sm)); }
.contact-card-copy:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.contact-card-copy.is-copied { background: rgba(16,163,74,.12); border-color: rgba(16,163,74,.4); color: var(--qr-success); }
html.dark-mode .contact-card-copy { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .contact-card-copy.is-copied { background: rgba(16,163,74,.2); border-color: rgba(16,163,74,.5); color: #4ade80; }

/* ---- Full-screen Info Modals ---- */
.info-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(0,0,0,.45);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  z-index: var(--z-float-300);
  animation: infoModalFadeIn var(--qr-dur) var(--qr-ease-out);
}

body.paywall-open {
  overflow: hidden;
}

.paywall-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, .62);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  z-index: var(--z-pop-500);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: paywallFadeIn var(--qr-dur) var(--qr-ease-out);
}

.paywall-overlay.closing {
  animation: paywallFadeOut var(--qr-dur) var(--qr-ease-out) forwards;
}

.paywall-card {
  width: min(520px, 100%);
  background: var(--qr-bg);
  border-radius: var(--qr-card-radius-sm);
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: var(--el-3);
  text-align: center;
  transform-origin: center;
  animation: paywallScaleIn var(--qr-dur-slow) var(--qr-ease-out);
  position: relative;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.paywall-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -.5rem -.5rem .25rem .5rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(2, 8, 23, .08);
  color: #334155;
  font-size: var(--fs-h2);
  line-height: 1;
  cursor: pointer;
  z-index: var(--z-lift);
  flex-shrink: 0;
}
.stats-insights-locked {
  width: 100%;
  min-height: 164px;
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(37,99,235,.18);
  background:
    var(--qr-grad-wash),
    var(--qr-bg);
  box-shadow: var(--el-inset);
}
.stats-insights-locked::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    var(--qr-grad-glow),
    var(--qr-grad-glow);
  filter: blur(8px);
}
.stats-insights-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
}
.stats-insights-locked-content {
  position: relative;
  z-index: var(--z-above);
  min-height: 164px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  text-align: center;
  padding: 1.25rem;
}
.stats-insights-locked-title {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 700;
  color: #1e3a8a;
}
.stats-insights-locked-cta {
  margin: 0;
  font-size: var(--fs-sub);
  color: var(--qr-accent-strong);
}

html.dark-mode .paywall-card {
  background: #0f172a;
}
html.dark-mode .paywall-close {
  background: rgba(148, 163, 184, .2);
  color: #e2e8f0;
}
html.dark-mode .paywall-plus-toggle-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}
/* Post-session soft upgrade prompt (free users, results screen). ADR-088: authored this base rule — previously ONLY a
   html.dark-mode rule existed, so the banner rendered completely unstyled in Light + Playful. Fully token-driven, so
   every theme (incl. Playful) styles it automatically; the dark rule below still overrides bg/border/text. The CTA text
   uses --qr-surface-solid over --qr-accent: in every theme the surface is the opposite lightness of the accent, so
   on-accent text stays high-contrast (light themes → light text on dark-blue; dark themes → dark text on light-blue). */
.session-upgrade-banner {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: 1rem auto 0; max-width: 24rem; padding: .75rem .75rem;
  border: 1px solid var(--qr-border); border-radius: var(--r-lg);
  background: var(--qr-surface-2);
}
.session-upgrade-text { flex: 1 1 8rem; min-width: 0; font-size: var(--fs-sub); font-weight: 600; color: var(--qr-text); }
.session-upgrade-btn {
  flex: 0 0 auto; font: inherit; font-size: var(--fs-caption); font-weight: 700; cursor: pointer;
  padding: .5rem .75rem; border-radius: var(--r-full); border: none;
  background: var(--qr-accent); color: var(--qr-surface-solid);
}
.session-upgrade-btn:active { transform: scale(var(--qr-press-sm)); }
.session-upgrade-dismiss {
  flex: 0 0 auto; font: inherit; font-size: var(--fs-h2); line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--qr-text-mut); padding: .125rem .25rem;
}
html.dark-mode .session-upgrade-banner {
  background: var(--qr-grad-wash);
  border-color: #334155;
}
html.dark-mode .session-upgrade-text { color: #93c5fd; }
html.dark-mode .session-upgrade-dismiss { color: #94a3b8; }

/* Firm daily-cap pause panel (ADR-107, Phase 5A): a free user hit their 20/day limit mid-session. Rendered into
   the immersive drill container in place of the next question; the session is preserved for a seamless upgrade. */
.quota-reached-card { text-align: center; gap: 1rem; max-width: 26rem; margin: 0 auto; }
.quota-reached-icon { font-size: var(--fs-icon); line-height: 1; }
.quota-reached-title { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); margin: 0; }
.quota-reached-sub { font-size: var(--fs-sub); line-height: 1.5; color: var(--qr-text-mut); margin: 0; max-width: 22rem; }
.quota-reached-actions { display: flex; flex-direction: column; gap: .5rem; width: 100%; max-width: 18rem; margin-top: .25rem; }
.quota-reached-actions .btn-primary,
.quota-reached-actions .btn-secondary { width: 100%; }
.quota-reached-reset { font-size: var(--fs-caption); color: var(--qr-text-mut); margin: .125rem 0 0; opacity: .85; }
html.dark-mode .stats-insights-locked {
  border-color: rgba(96,165,250,.25);
  background:
    var(--qr-grad-wash),
    rgba(15,23,42,.9);
  box-shadow: var(--el-inset);
}
html.dark-mode .stats-insights-locked::before {
  background:
    var(--qr-grad-glow),
    var(--qr-grad-glow);
}
html.dark-mode .stats-insights-locked-title {
  color: #dbeafe;
}
html.dark-mode .stats-insights-locked-cta {
  color: #93c5fd;
}

@keyframes paywallFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes paywallFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes paywallScaleIn {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}
.info-modal-overlay.closing {
  animation: infoModalFadeOut var(--qr-dur) var(--qr-ease-out) forwards;
}
@keyframes infoModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes infoModalFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.info-modal-content {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  margin: auto;
  background: var(--qr-bg);
  border-radius: var(--qr-card-radius);
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  box-shadow: var(--el-3);
  animation: paywallScaleIn var(--qr-dur-slow) var(--qr-ease-out);
  display: flex;
  flex-direction: column;
}
.info-modal-overlay.closing .info-modal-content {
  animation: none;
}
.info-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
}
.info-modal-close {
  /* ADR-110 cert: 2.25rem = 36px minimum touch target (was 2rem/32px). */
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: rgba(0,0,0,.06);
  border-radius: 50%;
  font-size: var(--fs-h3);
  color: var(--qr-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--qr-dur-fast), transform var(--qr-dur-fast);
  line-height: 1;
  flex-shrink: 0;
}
.info-modal-close:active {
  transform: scale(var(--qr-press-sm));
  background: rgba(0,0,0,.1);
}

/* Info modal hero header */
.info-hero {
  position: sticky;
  top: 0;
  z-index: var(--z-session-bg);
  background: var(--qr-bg);
  padding: .75rem 1rem .5rem;
  margin-bottom: .5rem;
}
.info-modal-scroll {
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  padding: 0 1.25rem 2rem;
}
.info-modal-scroll::after {
  display: none;
}
.info-modal-title {
  /* ADR-110: the modal title must outrank the block h4s below it (was 16px/600 — visually inverted hierarchy). */
  font-size: var(--fs-h2);
  font-weight: 800;
  color: var(--qr-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.info-modal-title:focus { outline: none; }   /* programmatic focus target on open (ADR-110 a11y) — no ring on mouse */
.info-modal-subtitle {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  line-height: 1.5;
  margin: .25rem 0 0;
}
/* ADR-110: Guide section navigation — one horizontally scrollable chip row in the sticky hero. */
.info-toc {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: .75rem 0 .125rem;
  padding-bottom: .125rem;
}
.info-toc::-webkit-scrollbar { display: none; }
/* Shell (border/radius/padding/touch-target/:active/:focus) comes from the .qr-chip primitive
   (FW-W3); only the TOC-specific ink/surface deltas live here. */
.info-toc-chip {
  flex: 0 0 auto;
  font-size: var(--fs-caption);
  color: #475569;
  background: var(--qr-surface-2);
}
html.dark-mode .info-toc-chip { color: #cbd5e1; background: #1e293b; }
/* ADR-110: inline Premium marker — replaces the bare 🔒 glyph in prose with a self-explanatory chip. */
/* .info-premium-chip visuals consolidated into the unified .qr-badge-pro rule (see PRO badge block). */

/* Info modal sections */
.info-section {
  margin-bottom: 1.75rem;
}
.info-section:last-child {
  margin-bottom: 0;
}
.info-section-title {
  font-size: var(--fs-caption);
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .75rem;
  padding-left: .125rem;
}

/* Info block cards */
.info-block {
  margin-bottom: .75rem;
  background: var(--qr-surface-solid);
  border-radius: var(--r-lg);
  padding: 1rem 1rem;
  box-shadow: var(--el-1);
  border: 1px solid rgba(226,232,240,.5);
}
.info-block:last-child {
  margin-bottom: 0;
}
.info-block-highlight {
  border-left: 3px solid var(--qr-accent);
}
.info-block h4 {
  font-size: var(--fs-body);
  /* ADR-131 drift census: 650 was one of only three off-scale weights in the app (the title scale is
     400/600/700/800). Snapped to the nearest used step; the 800 .info-modal-title still outranks it,
     which is the hierarchy ADR-110 established. */
  font-weight: 700;
  color: var(--qr-text);
  margin-bottom: .5rem;
}
.info-block p {
  font-size: var(--fs-sub);
  color: #475569;
  line-height: 1.6;
  margin-bottom: .25rem;
}
.info-block p:last-child {
  margin-bottom: 0;
}
.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.info-list li {
  font-size: var(--fs-sub);
  color: #475569;
  line-height: 1.55;
  padding: .25rem 0 .25rem .75rem;
  position: relative;
}
.info-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--qr-accent);
  font-weight: 700;
}
.info-tip {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  margin-top: .5rem;
  padding: .5rem .5rem;
  background: rgba(37,99,235,.05);
  border-radius: var(--r-sm);
  border-left: 2.5px solid var(--qr-accent);
}
.info-version {
  font-size: var(--fs-caption);
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: .25rem;
}
.info-quote {
  border-left: 3px solid var(--qr-accent);
}
.info-quote p {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  line-height: 1.7;
  font-style: italic;
}

/* Dark mode info modals */
html.dark-mode .info-modal-overlay {
  background: rgba(0,0,0,.6);
}
html.dark-mode .info-modal-content {
  background: #0f172a;
  box-shadow: var(--el-3);
}html.dark-mode .info-modal-scroll::after {
  display: none;
}
html.dark-mode .info-modal-close {
  background: var(--qr-veil-w-8);
  color: #94a3b8;
}html.dark-mode .info-modal-subtitle { color: #94a3b8; }
html.dark-mode .info-section-title { color: #64748b; }html.dark-mode .info-block p { color: #94a3b8; }
html.dark-mode .info-block {
  background: #1e293b;
  border-color: rgba(51,65,85,.5);
  box-shadow: var(--el-1);
}
html.dark-mode .info-block-highlight {
  border-left-color: #60a5fa;
}
html.dark-mode .info-list li { color: #94a3b8; }
html.dark-mode .info-list li::before { color: #60a5fa; }
html.dark-mode .info-tip {
  background: rgba(96,165,250,.08);
  border-left-color: #60a5fa;
  color: #94a3b8;
}
html.dark-mode .info-version { color: #64748b; }
html.dark-mode .info-quote { border-left-color: #60a5fa; }
/* Guide section animations */
.guide-animate-section {
  opacity: 0;
  transform: translateY(12px);
  animation: guideCardFadeIn var(--qr-dur-slow) var(--qr-ease-out) forwards;
}
/* ADR-110: tighter stagger — the Guide now has 16 sections; a .88s tail felt slow. First few cards cascade,
   everything below the fold (n+7) shares one late-but-snappy delay. Reduced-motion kill-switch still applies. */
.guide-animate-section:nth-child(2) { animation-delay: calc(var(--qr-dur-fast) * 0.5); }
.guide-animate-section:nth-child(3) { animation-delay: calc(var(--qr-dur-fast) * 1); }
.guide-animate-section:nth-child(4) { animation-delay: calc(var(--qr-dur-fast) * 1.5); }
.guide-animate-section:nth-child(5) { animation-delay: calc(var(--qr-dur-fast) * 2); }
.guide-animate-section:nth-child(6) { animation-delay: calc(var(--qr-dur-fast) * 2.5); }
.guide-animate-section:nth-child(n+7) { animation-delay: calc(var(--qr-dur-fast) * 3); }
@keyframes guideCardFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Info block tap feedback */
.info-block {
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
}
.info-block:active {
  transform: scale(var(--qr-press-lg));
}

/* (ADR-110 cert: the old Guide premium-tier card styles that lived here — .guide-premium-section
   through .guide-tier-cta-note incl. dark/playful variants — were removed; the rewritten Guide
   composes the shared .info-* system instead and nothing referenced them.) */


/* ---- Category Stats (Stats page) ---- */
/* Accuracy bar + strength labels — reused across Stats (subject mastery, exam readiness, study-next) as the ONE
   accuracy-bar language (ADR-080). The old flat category-accuracy LIST rows were removed with the Stats rebuild. */
.cat-bar-container {
  flex: 1;
  height: .45rem;
  background: var(--qr-surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.cat-bar {
  height: 100%;
  border-radius: 4px;
  transition: width var(--qr-dur-slow) var(--qr-ease-out);
}
.cat-bar-high  { background: var(--qr-grad-bar-ok); }
.cat-bar-mid   { background: var(--qr-grad-bar); }
.cat-bar-low   { background: var(--qr-grad-bar-warn); }
.cat-bar-weak  { background: var(--qr-grad-bar-danger); }

/* ---- Formula Text ---- */
.formula-text {
  background: var(--qr-surface-2);
  padding: .5rem .75rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sub);
  margin: .5rem 0 .5rem;
  color: var(--qr-text);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.formula-block {
  padding: .5rem 0 .75rem;
  border-bottom: 1px solid var(--qr-border);
}
.formula-block:last-of-type {
  border-bottom: none;
  padding-bottom: .25rem;
}
.formula-block-title {
  margin: 0 0 .25rem;
  color: var(--qr-text);
  font-size: var(--fs-body);
  font-weight: 700;
}
.formula-label {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--qr-text-dim);
  font-weight: 700;
  margin-top: .25rem;
}
.formula-tip {
  margin: .25rem 0 0;
  color: #475569;
  line-height: 1.5;
  font-size: var(--fs-sub);
}

/* ---- Secondary Text ---- */
.secondary-text {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  line-height: 1.5;
}

/* ---- Text Overflow Protection ---- */
.cat-name,
.mode-card h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Animations ---- */
.fade-in {
  animation: fadeIn var(--qr-dur) var(--qr-ease-out);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Per-question card transition — snappier than generic fade-in */
.question-card-transition {
  animation: questionCardIn var(--qr-dur) var(--qr-ease-out) both;
}
@keyframes questionCardIn {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered fade-in for analytics sections */
.analytics-section:nth-child(1) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) .0s both; }
.analytics-section:nth-child(2) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) calc(var(--qr-dur-fast) * 0.416667) both; }
.analytics-section:nth-child(3) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) calc(var(--qr-dur-fast) * 0.833333) both; }
.analytics-section:nth-child(4) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) calc(var(--qr-dur-fast) * 1.25) both; }
.analytics-section:nth-child(5) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) calc(var(--qr-dur-fast) * 1.66667) both; }
.analytics-section:nth-child(6) { animation: fadeIn var(--qr-dur-slow) var(--qr-ease-out) calc(var(--qr-dur-fast) * 2.08333) both; }

/* ---- Dark Mode ---- */
html.dark-mode {
  background: #0f172a;
  color: #e2e8f0;
}
html.dark-mode header h1 {
  color: var(--qr-text);
}
html.dark-mode .card,
html.dark-mode .mode-card {
  background: rgba(30,41,59,.88);
  border: var(--qr-card-border-dark);
  box-shadow: var(--qr-shadow-dark);
}
html.dark-mode .bottom-nav {
  background: #1e293b;
  border-top-color: #334155;
}
html.dark-mode .bottom-nav a { color: #94a3b8; }
html.dark-mode .bottom-nav a .nav-icon .qr-ico { opacity: .5; }
html.dark-mode .bottom-nav a.active { color: #60a5fa; }
html.dark-mode .bottom-nav a.active .nav-icon .qr-ico { opacity: 1; }
html.dark-mode .bottom-nav a.active::after { background: var(--qr-grad-bar); }
html.dark-mode .input,
html.dark-mode .learn-search-input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark-mode .input:focus,
html.dark-mode .learn-search-input:focus { box-shadow: var(--qr-focus-ring); }
html.dark-mode .shortcut-table th,
html.dark-mode .shortcut-table td,
html.dark-mode .math-table th,
html.dark-mode .math-table td {
  border-bottom-color: #334155;
}
html.dark-mode .shortcut-table th,
html.dark-mode .math-table th { color: #94a3b8; }
html.dark-mode .stat-card,
html.dark-mode .result-item {
  background: #334155;
}
html.dark-mode .stat-card .value,
html.dark-mode .result-value { color: #60a5fa; }
html.dark-mode .stat-card .label,
html.dark-mode .result-label { color: #94a3b8; }
html.dark-mode .mode-card h3,
html.dark-mode .settings-label h3,
html.dark-mode .cat-name { color: #e2e8f0; }
html.dark-mode .mode-card p,
html.dark-mode .settings-label p { color: #94a3b8; }
html.dark-mode .table-card {
  background: rgba(30,41,59,.85);
  border-color: rgba(51,65,85,.7);
}
html.dark-mode .table-card .table-title {
  border-bottom-color: #334155;
}
html.dark-mode .collapsible-header:active { background: #334155; }
html.dark-mode .category-btn {
  background: #0f172a;
  border-color: rgba(148,163,184,.22);
  color: #e2e8f0;
}
html.dark-mode .category-btn:active {
  background: #1e293b;
  border-color: #60a5fa;
}
html.dark-mode .category-btn.selected {
  background: rgba(96,165,250,.10);
  border: 2.5px solid #60a5fa;
  color: #93c5fd;
}
html.dark-mode .formula-text {
  background: #334155;
  color: #e2e8f0;
}
html.dark-mode .formula-block { border-bottom-color: #334155; }
html.dark-mode .formula-block-title { color: #f8fafc; }html.dark-mode .formula-tip { color: #cbd5e1; }html.dark-mode .cat-bar-container { background: #1e293b; }
html.dark-mode .math-grid-item { background: #334155; }html.dark-mode .math-val { color: #60a5fa; }
html.dark-mode .table-select-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark-mode .table-select-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
html.dark-mode .btn {
  background: #334155;
  color: #e2e8f0;
}
html.dark-mode .btn.accent { background: var(--qr-grad-cta); color: #ffffff; }html.dark-mode .feedback.correct { background: rgba(22,163,74,.15); }
html.dark-mode .feedback.wrong   { background: rgba(220,38,38,.15); }

/* ---- Custom Formulas & Topics ---- */
.custom-formula-item {
  border-bottom: 1px solid var(--qr-border);
  padding: .5rem 0;
}
.custom-formula-item:last-child { border-bottom: none; }
.custom-formula-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .25rem;
}
.custom-formula-actions, .custom-topic-actions {
  display: flex;
  gap: .125rem;
  flex-shrink: 0;
}
.formula-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-sub);
  padding: .125rem .25rem;
  border-radius: 4px;
  transition: background var(--qr-dur-fast);
  opacity: .6;
}
.formula-action-btn:hover, .formula-action-btn:active { opacity: 1; background: rgba(0,0,0,.05); }
.formula-action-btn.bookmarked { opacity: 1; }
.custom-topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}
.custom-topic-header .section-title { margin: 0; }
.add-formula-btn {
  font-size: var(--fs-sub);
  padding: .75rem;
  margin-top: .75rem;
  background: var(--qr-veil-w-5);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  color: #3b82f6;
  border: none;
  box-shadow: var(--el-key);
  border-radius: var(--r-lg);
  transition: all var(--qr-dur) var(--qr-spring);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 600;
}
.add-formula-btn:hover { 
  background: var(--qr-veil-w-10); 
  box-shadow: var(--el-key); 
  transform: translateY(-1px);
}

/* ---- Add Topic Button ---- */
.add-topic-btn {
  font-size: var(--fs-body);
  padding: 1rem .75rem;
  margin-top: .75rem;
  margin-bottom: 1rem;
  width: 100%;
  background: var(--qr-veil-w-5);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  color: #3b82f6;
  border: none;
  box-shadow: var(--el-key);
  border-radius: var(--r-lg);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 600;
}
.add-topic-btn:hover { 
  background: var(--qr-veil-w-10); 
  box-shadow: var(--el-key); 
  transform: translateY(-1px);
}

/* ---- Bookmarks Section ---- */

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.48);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-sticky);
  padding: 1rem;
  animation: modalOverlayFadeIn var(--qr-dur-fast) var(--qr-ease-out) both;
}
@keyframes modalOverlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-overlay.closing {
  animation: modalOverlayFadeOut var(--qr-dur-fast) var(--qr-ease-out) both;
}
@keyframes modalOverlayFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.modal-content {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: var(--glass-chrome);
  -webkit-backdrop-filter: var(--glass-chrome);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--qr-card-radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--el-key);
  animation: modalContentScaleIn var(--qr-dur) var(--qr-spring) both;
}
.modal-content::after {
  display: none;
}
@keyframes modalContentScaleIn {
  from { transform: scale(.9) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-title {
  font-size: var(--fs-h3);
  color: var(--qr-accent);
  margin-bottom: 1rem;
}
.modal-label {
  display: block;
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  margin-bottom: .25rem;
  margin-top: .5rem;
}
/* Box/border/focus come from the .qr-input primitive (FW-W3); only the size deltas live here. */
.modal-input {
  width: 100%;
  padding: .5rem .75rem;
  font-size: var(--fs-sub);
}
textarea.modal-input { min-height: 4rem; resize: vertical; font-family: inherit; }
.modal-actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
}
.modal-actions .btn { flex: 1; margin-top: 0; }
.modal-cancel { background: var(--qr-surface-3); }

/* ---- Category Strength ---- */
.category-strength-label {
  font-size: var(--fs-caption);
  font-weight: 600;
  padding: .125rem .25rem;
  border-radius: 4px;
  white-space: nowrap;
}
.strength-strong { background: #dcfce7; color: var(--qr-success-fg); }
.strength-moderate { background: #dbeafe; color: var(--qr-accent-strong); }
.strength-weak { background: #fee2e2; color: var(--qr-danger); }

/* ---- Dark Mode additions ---- */
html.dark-mode .custom-formula-item { border-bottom-color: #334155; }
html.dark-mode .formula-action-btn:hover { background: var(--qr-veil-w-10); }
html.dark-mode .add-formula-btn,
html.dark-mode .add-topic-btn {
  background: rgba(30, 41, 59, 0.4);
  color: #60a5fa;
  border: none;
  box-shadow: var(--el-key);
}
html.dark-mode .add-formula-btn:hover,
html.dark-mode .add-topic-btn:hover {
  background: rgba(30, 41, 59, 0.6);
}
html.dark-mode .modal-content { background: rgba(30, 41, 59, 0.75); border: 1px solid var(--qr-veil-w-8); box-shadow: var(--el-key); }
html.dark-mode .modal-content::after {
  display: none;
}html.dark-mode .modal-cancel { background: #334155; color: #e2e8f0; }

/* ---- Table Expansion Modal ---- */
.table-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-scrim-250);
  padding: 1rem;
  opacity: 0;
  animation: tableModalFadeIn var(--qr-dur) var(--qr-ease-out) forwards;
}
.table-modal-overlay.closing {
  animation: tableModalFadeOut var(--qr-dur) var(--qr-ease-out) forwards;
}
@keyframes tableModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes tableModalFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.table-modal-content {
  background: rgba(255,255,255,.95);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  border-radius: var(--qr-card-radius-sm);
  padding: 1.75rem 1.5rem;
  width: 100%;
  max-width: 340px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--el-3);
  border: 1px solid rgba(226,232,240,.6);
  position: relative;
  transform: scale(.92);
  animation: tableModalScaleIn var(--qr-dur) var(--qr-ease-out) forwards;
}
.table-modal-overlay.closing .table-modal-content {
  animation: tableModalScaleOut var(--qr-dur) var(--qr-ease-out) forwards;
}
@keyframes tableModalScaleIn {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes tableModalScaleOut {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(.92); opacity: 0; }
}
.table-modal-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: rgba(0,0,0,.06);
  border-radius: 50%;
  font-size: var(--fs-body);
  color: var(--qr-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--qr-dur-fast), transform var(--qr-dur-fast);
  line-height: 1;
}
.table-modal-close:active {
  transform: scale(var(--qr-press-sm));
  background: rgba(0,0,0,.1);
}
.table-modal-title {
  font-size: var(--fs-h2);
  font-weight: 700;
  color: var(--qr-accent);
  margin-bottom: .75rem;
  text-align: center;
}
.table-modal-content .math-table {
  width: auto;
  margin: 0 auto;
}
.table-modal-content .math-table td {
  font-size: var(--fs-h3);
  padding: .25rem .5rem;
  white-space: nowrap;
  text-align: right;
  border-bottom: none;
  font-variant-numeric: tabular-nums;
}
html.dark-mode .table-modal-overlay {
  background: rgba(0,0,0,.6);
}
html.dark-mode .table-modal-content {
  background: rgba(30,41,59,.95);
  border-color: rgba(51,65,85,.7);
}
html.dark-mode .table-modal-close {
  background: var(--qr-veil-w-8);
  color: #94a3b8;
}
/* ---- Practice: fixed app shell (ADR-011) ---- */
/* When Practice is active the app-level scroller (.container) yields scroll control to this
   shell, so the fixed header and bottom nav never drift (eliminates the double scroll). */
body.view-practice-active > .container {
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}
#view-practice.spa-view-active {
  display: flex;
  flex-direction: column;
  /* Viewport − fixed nav − bottom safe area; top safe area clears the notch / status bar. */
  height: calc(var(--vh, 1vh) * 100 - var(--qr-nav-h) - env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
}
/* The header is the fixed band — never grows, shrinks, or scrolls. */
#view-practice.spa-view-active > header {
  flex: 0 0 auto;
}

.practice-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  /* The single Practice scroller — isolates scrolling to this panel. */
  flex: 1;
  min-height: 0;
  width: 100%;
  /* Equal top/bottom margin → panel visually centered between header and nav. */
  margin: var(--qr-practice-gap) auto;
  /* Symmetric internal padding → dedicated-panel feel. */
  padding: 1rem .75rem;
  /* ADR-132: the grouping SURFACE, restored. This rule had lost its background, so the panel existed
     only in the two dark themes — which have their own background rules — and the mode cards floated
     directly on the page in both light themes. Three independent traces of the original are still in
     this file: the `:active` rule below cancels `.card`'s tap-scale on an element that no longer
     carries that class, the dark rule's value is EXACTLY dark's --qr-surface, and Playful's rule
     overrode a background that no longer existed. The comment above already called it a glass panel.
     Deliberately background-only: the matching `border: 1px solid` is NOT restored, because adding one
     would make the dark themes render an edge they do not render today.

     The value is a SEMANTIC token, not `--qr-surface`, because "the surface colour" and "a grouping
     tray that reads against this theme's page" are not the same thing in every palette. Measured
     against each theme's page background, max channel delta: classic dark 16 and playful light 14 —
     both clearly readable — but classic light's `--qr-surface` composites to rgb(254,254,255) on a
     rgb(248,250,252) page, a delta of 6. That is invisible: px-diff scored the whole screen as ZERO
     changed pixels. Each theme therefore names its own panel step below. */
  background: var(--qr-panel);
  /* Soft glass-panel corners — same radius as Home cards, so it reads as an intentional
     container rather than a sharp rectangle. (Visual refinement of the ADR-011 panel.) */
  border-radius: var(--qr-card-radius);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}
.practice-container::-webkit-scrollbar { display: none; }
.practice-container:active {
  /* Cancel .card tap-scale on the container itself */
  transform: none;
  box-shadow: var(--el-1);
}
.practice-container .mode-card {
  padding: 1.25rem 1.25rem;
  margin-bottom: .75rem;
}
.practice-container .mode-card h3 {
  font-size: var(--fs-h3);
}
.practice-container .mode-card p {
  font-size: var(--fs-sub);
  line-height: 1.4;
}
.practice-container .mode-card:last-child {
  margin-bottom: 0;
}

#categorySelect {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  padding: 1rem;
}
.training-card {
  background: rgba(255,255,255,.92);
  backdrop-filter: var(--glass-chrome);
  -webkit-backdrop-filter: var(--glass-chrome);
  border-radius: var(--qr-card-radius-sm);
  box-shadow: var(--el-1);
  border: 1px solid rgba(226,232,240,.7);
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html.dark-mode .training-card {
  background: rgba(30,41,59,.94);
  border-color: rgba(51,65,85,.7);
  box-shadow: var(--el-2);
}
.training-card .category-select-title {
  padding: 1.25rem 1.25rem .5rem;
  margin: 0;
  flex-shrink: 0;
}
.training-card-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 .5rem .5rem;
}
.training-card-body::-webkit-scrollbar { display: none; }
.training-card-back {
  flex-shrink: 0;
  display: block;
  width: calc(100% - 2rem);
  margin: .75rem 1rem;
  padding: .75rem .5rem;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--qr-text-dim);
  font-size: var(--fs-sub);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background var(--qr-dur-fast);
}
.training-card-back:active {
  background: rgba(0,0,0,.04);
}
html.dark-mode .training-card-back {
  color: #94a3b8;
  border-color: var(--qr-veil-w-10);
}
html.dark-mode .training-card-back:active {
  background: var(--qr-veil-w-6);
}

body.web-mode #categorySelect {
  position: fixed;
}

/* ---- Stats Grid Improvements ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: .5rem;
}
.stat-grid-2 {
  grid-template-columns: 1fr 1fr;
}
.stat-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.stat-card {
  background: var(--qr-surface-2);
  border-radius: var(--qr-card-radius-sm);
  padding: 1rem .5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 5rem;
  transition: transform var(--qr-dur-fast) var(--qr-ease-out);
}
.stat-card:active {
  transform: scale(var(--qr-press-sm));
}
.stat-card .value {
  font-size: var(--fs-h1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--qr-accent);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -.02em;
}
.stat-grid-3 .stat-card .value {
  font-size: var(--fs-h2);
}
.stat-card .label {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  margin-top: .25rem;
  line-height: 1.3;
  text-align: center;
}
.stat-card .value-sm {
  font-size: var(--fs-caption);
  /* break only when a token genuinely can't fit (long category names), never mid-word on short labels like
     "Strong"/"Faster" — word-break:break-word was splitting those into "Stro ng" (ADR-080). */
  overflow-wrap: break-word;
  hyphens: none;
  max-width: 100%;
  line-height: 1.2;
}
.stat-card.highlight { border-left: 3px solid var(--qr-accent); }
.stat-card-positive { border-left: 3px solid var(--qr-success); }
.stat-card-positive .value { color: var(--qr-success); }
.stat-card-negative { border-left: 3px solid var(--qr-danger); }
.stat-card-negative .value { color: var(--qr-danger); }
.stat-hint {
  font-size: var(--fs-micro);
  color: #94a3b8;
  margin-top: .25rem;
  line-height: 1.3;
  text-align: center;
}

/* ---- Analytics Dashboard Sections ---- */
.analytics-section {
  margin-bottom: 1.75rem;
}
.analytics-section:last-child {
  margin-bottom: 1rem;
}
.analytics-section-title {
  /* ADR-080: identical to .home-section-title (Practice) so Stats and Practice section eyebrows read as one design. */
  font-size: var(--fs-sub);
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
  padding-left: .25rem;
}
html.dark-mode .analytics-section-title {
  color: #94a3b8;
}
.analytics-card {
  background: var(--qr-surface-solid);
  border-radius: var(--r-lg);
  padding: .75rem;
  box-shadow: var(--el-1);
  border: 1px solid rgba(226,232,240,.5);
}
html.dark-mode .analytics-card {
  background: #1e293b;
  box-shadow: var(--el-1);
  border-color: rgba(51,65,85,.5);
}

/* ADR-132: this rule is gone. Its background was byte-identical to dark's --qr-surface, which the base
   rule now reads, so dark renders exactly as before; and its `border-color` was dead, since nothing has
   ever given this element a border-width (measured 0px in all four themes). */

/* ---- Responsive ---- */
@media (max-width: 359px) {
  .stat-grid-3 {
    grid-template-columns: 1fr;
  }
  .stat-grid-3 .stat-card .value {
    font-size: var(--fs-h1);
  }
  .analytics-card {
    padding: .75rem .5rem;
  }
}
@media (min-width: 600px) {
  header h1 { font-size: var(--fs-d1); }
  .question-text { font-size: 2.25rem; }
  .container { max-width: 600px; }
}
@media (min-width: 768px) {
  .container { max-width: 720px; }
  .tables-container {
    grid-template-columns: repeat(3, 1fr);
  }
}
/* Global container ladder (blueprint §6.9): landscape tablets / desktop PWA get more room instead of a
   stretched phone column. Learn keeps its own wider reading ladder below. */
@media (min-width: 960px)  { .container { max-width: 900px; } }
@media (min-width: 1100px) { .container { max-width: 1040px; } }
/* Bottom-nav (blueprint §6.9): keep the bar full-width but centre the 5 tabs in a 640px zone on wide
   screens so they stop scattering across a tablet's full width. */
@media (min-width: 900px) {
  .bottom-nav { padding-left: calc((100% - 640px) / 2); padding-right: calc((100% - 640px) / 2); }
}
.login-field {
  margin-bottom: 1rem;
}

/* ---- Coaching ID Field (always visible) ---- */
.coaching-id-field {
  /* No slide-in animation — field is always present */
}

/* ---- Realtime Field Validation ---- */
.login-field-validation {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--qr-dur) var(--qr-ease-out), opacity var(--qr-dur) var(--qr-ease-out), margin var(--qr-dur) var(--qr-ease-out);
  margin-top: 0;
}
.login-field-validation.active {
  max-height: 8rem;
  opacity: 1;
  margin-top: .5rem;
}
.login-field-validation ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.login-field-validation li {
  font-size: var(--fs-caption);
  line-height: 1.6;
  padding-left: .125rem;
  transition: color var(--qr-dur) var(--qr-ease-out);
}
.login-field-validation li.val-error {
  color: var(--qr-danger);
}
.login-field-validation li.val-error::before {
  content: '✗ ';
  font-weight: 600;
}
.login-field-validation li.val-pass {
  color: var(--qr-success);
}
.login-field-validation li.val-pass::before {
  content: '✓ ';
  font-weight: 600;
}
.login-field-validation.all-valid {
  max-height: 2rem;
}
.login-field-validation .val-summary {
  font-size: var(--fs-caption);
  color: var(--qr-success);
  font-weight: 500;
}
.login-field-validation .val-summary::before {
  content: '✓ ';
  font-weight: 600;
}
/* Optional coaching logo on the join confirmation (ADR-030) — rendered only when coachings.logoUrl is set. */
.login-field-validation .coaching-join-logo {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  vertical-align: -4px;
  margin-right: 4px;
}

/* Validation-aware input border states */
.login-input.input-error {
  border-color: #f87171;
}
.login-input.input-error:focus {
  border-color: var(--qr-danger);
  box-shadow: var(--qr-ring-danger);
}
.login-input.input-valid {
  border-color: #4ade80;
}
.login-input.input-valid:focus {
  border-color: var(--qr-success);
  box-shadow: var(--qr-ring-ok);
}

/* Dark mode: field validation */
html.dark-mode .login-field-validation li.val-error {
  color: #f87171;
}
html.dark-mode .login-field-validation li.val-pass {
  color: #4ade80;
}
html.dark-mode .login-field-validation .val-summary {
  color: #4ade80;
}
html.dark-mode .login-input.input-error {
  border-color: rgba(248,113,113,.6);
}
html.dark-mode .login-input.input-error:focus {
  border-color: #f87171;
  box-shadow: var(--qr-ring-danger);
}
html.dark-mode .login-input.input-valid {
  border-color: rgba(74,222,128,.5);
}
html.dark-mode .login-input.input-valid:focus {
  border-color: #4ade80;
  box-shadow: var(--qr-ring-ok);
}

/* ---- Coaching ID slide-in ---- */
.coaching-id-field.coaching-visible {
  display: block !important;
  animation: slideFieldIn var(--qr-dur-slow) var(--qr-ease-out) forwards;
}
@keyframes slideFieldIn {
  from {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    max-height: 10rem;
    margin-top: inherit;
    transform: translateY(0);
  }
}

/* ---- Clear Data Modal ---- */
.clear-data-modal {
  max-width: 420px;
}
.clear-option-btn {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  width: 100%;
  padding: .75rem;
  border: 1.5px solid var(--qr-border);
  border-radius: var(--r-md);
  background: var(--qr-surface-solid);
  cursor: pointer;
  margin-bottom: .5rem;
  text-align: left;
  transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast);
}
.clear-option-btn:active {
  transform: scale(var(--qr-press-lg));
}
.clear-option-btn:hover {
  border-color: var(--qr-border-strong);
  background: var(--qr-bg);
}
.clear-option-danger {
  border-color: #fecaca;
}
.clear-option-danger:hover {
  border-color: #f87171;
  background: #fef2f2;
}
.clear-option-icon {
  font-size: var(--fs-h2);
  flex-shrink: 0;
  margin-top: .125rem;
}
.clear-option-info {
  display: flex;
  flex-direction: column;
  gap: .125rem;
}
.clear-option-info strong {
  font-size: var(--fs-sub);
  color: var(--qr-text);
}
.clear-option-info span {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  line-height: 1.3;
}

/* Dark mode: clear data modal */
html.dark-mode .clear-option-btn {
  background: #1e293b;
  border-color: #334155;
}
html.dark-mode .clear-option-btn:hover {
  border-color: #475569;
  background: #334155;
}
html.dark-mode .clear-option-danger {
  border-color: rgba(248,113,113,.3);
}
html.dark-mode .clear-option-danger:hover {
  border-color: #f87171;
  background: rgba(220,38,38,.1);
}html.dark-mode .clear-option-info span {
  color: #94a3b8;
}

/* ---- Custom Numpad ---- */
.custom-numpad {
  position: fixed;
  bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  background: var(--qr-surface-2);
  border-top: 1px solid var(--qr-border);
  padding: .5rem;
  z-index: var(--z-session-numpad);
  transform: translateY(100%);
  transition: transform var(--qr-dur) var(--qr-ease-out);
}
.custom-numpad.visible {
  transform: translateY(0);
}
.custom-numpad:not(.visible) {
  visibility: hidden;
  pointer-events: none;
}
.numpad-grid {
  /* ADR-086: a stable 3-column digit pad + a tall submit column on the right. The digit block never moves; only the
     single contextual symbol slot (bottom-left) changes per answer format, so the keypad never reshuffles. */
  display: flex;
  gap: .5rem;
  max-width: 480px;
  margin: 0 auto;
  align-items: stretch;
}
.numpad-pad {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.numpad-btn.numpad-sym { color: var(--qr-accent); font-weight: 700; }
.numpad-blank { visibility: hidden; pointer-events: none; box-shadow: none; }
.numpad-btn {
  min-height: 50px;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--fs-h2);
  font-weight: 600;
  background: var(--qr-surface-solid);
  color: var(--qr-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: var(--el-1);
}
.numpad-btn:active {
  background: #dbeafe;
  transform: scale(var(--qr-press-sm));
}
.numpad-btn.numpad-submit {
  flex: 0 0 23%;
  min-width: 66px;
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  font-size: var(--fs-h1);
  box-shadow: var(--qr-glow-accent);
}
.numpad-btn.numpad-submit:active {
  background: var(--qr-grad-cta);
  box-shadow: none;
}
.numpad-btn.numpad-backspace {
  font-size: var(--fs-h3);
  color: var(--qr-text-dim);
}

/* Dark mode numpad */
html.dark-mode .custom-numpad {
  background: #1e293b;
  border-top-color: #334155;
}
html.dark-mode .numpad-btn {
  background: #334155;
  color: #e2e8f0;
  box-shadow: var(--el-1);
}
html.dark-mode .numpad-btn:active {
  background: #475569;
}
html.dark-mode .numpad-btn.numpad-submit {
  background: var(--qr-grad-cta);
  color: #ffffff;
}

/* When numpad is visible, add bottom padding to body to prevent content overlap */
body.numpad-active {
  padding-bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px) + var(--qr-numpad-h));
}

/* ---- Drill Session: Fixed-Position Layout ----
   Each layer is independently position-fixed so content changes
   (long questions, wrong-answer feedback) never shift the action
   bar or numpad.

   Stack (bottom → top):
     drillContainer  z-index: 10  (background only)
     card            z-index: 11  (fixed viewport, internal scroll)
     drill-actions   z-index: 98  (fixed above numpad)
     custom-numpad   z-index: 99  (fixed bottom — unchanged)
     drill-exit-btn  z-index: 100 (fixed top-right)

   CSS custom properties keep height calculations DRY.
   --drill-numpad-h: 4 rows × 50px + 3 gaps × .4rem + .5rem×2 padding + 1px border ≈ 13.9rem
*/

body.drill-session-active {
  --drill-numpad-h: var(--qr-numpad-h);
  --drill-actions-h: 3.5rem;
  --drill-card-gap: 1.25rem;   /* the LARGER gap between the question card and Submit — creates hierarchy */
  --drill-submit-gap: .5rem;   /* the small gap between Submit and the numpad (Submit lifts off the keypad) */
  --drill-safe-b: env(safe-area-inset-bottom, 0px);
}

body.drill-session-active,
html.drill-session-active {
  overflow: hidden;
}

/* Numpad: fixed bottom (already position:fixed from base rule) */
body.drill-session-active .custom-numpad {
  bottom: var(--drill-safe-b);
}

/* Background layer — fills viewport, provides theme background.
   ADR-087: tokenized to var(--qr-bg). The four per-theme literals it replaced (#f8fafc / #0f172a / #faf9f7 / #0d1117)
   each equal that theme's --qr-bg exactly, so this is pixel-identical while making a future theme's shell automatic. */
body.drill-session-active #drillContainer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-session-bg);
  background: var(--qr-bg);
}

/* Exit button: fixed top-right, above everything.
   ADR-087: matches the pause button's safe-area handling so both top-corner controls sit at the same height and clear
   the notch/status bar on devices with a top inset. */
body.drill-session-active .drill-exit-btn {
  position: fixed;
  top: calc(.75rem + env(safe-area-inset-top, 0px));
  right: .75rem;
  z-index: var(--z-nav);
}

/* Question card: fixed viewport between exit area and action bar */
body.drill-session-active #drillContainer > .card {
  position: fixed;
  top: 3.4rem;
  left: .75rem;
  right: .75rem;
  bottom: calc(var(--drill-numpad-h) + var(--drill-submit-gap) + var(--drill-actions-h) + var(--drill-card-gap) + var(--drill-safe-b));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  z-index: var(--z-session-card);
}
body.drill-session-active #drillContainer > .card:active {
  transform: none;
}
/* ADR-086 — kill the MCQ dead space: when NO numpad is shown (MCQ/LR questions), the card and action bar no longer
   reserve the ~13.75rem keypad band; the question card grows to fill the lower region instead of leaving it blank. */
body.drill-session-active:not(.numpad-active) #drillContainer > .card {
  bottom: calc(var(--drill-actions-h) + var(--drill-card-gap) + var(--drill-safe-b));
}
body.drill-session-active:not(.numpad-active) .drill-actions {
  bottom: calc(var(--drill-safe-b) + .4rem);
}

/* Scrollable question content inside the fixed card */
.drill-question-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 0;
  padding-bottom: .5rem;
}
.drill-question-scroll > * {
  flex-shrink: 0;
}
.drill-question-scroll::before {
  content: '';
  flex: 1 1 0%;
  min-height: 1.5rem;
}
.drill-question-scroll::after {
  content: '';
  flex: 1 1 0%;
  min-height: 0;
}

/* Action bar: fixed, directly above numpad */
body.drill-session-active .drill-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--drill-numpad-h) + var(--drill-submit-gap) + var(--drill-safe-b));
  z-index: var(--z-session-actions);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: .5rem .75rem;
}
body.drill-session-active .drill-actions .btn {
  flex: 1;
  max-width: none;
  margin-top: 0;
  min-width: 0;
  min-height: 2.75rem;
  border-radius: var(--r-md);
  font-size: var(--fs-body);
  padding: 1rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.drill-session-active .drill-actions.has-skip {
  gap: .5rem;
}
/* Unified Skip · Submit layout — ONE design across Practice / Focus / Drills / Tests / Duels: Skip = 1/3 (left,
   clean secondary), Submit = 2/3 (right, primary), equal height. When skip is off, no element + no reserved space. */
body.drill-session-active .drill-actions.has-skip .skip-btn {
  flex: 0 0 33%;
  font-size: var(--fs-body);
  font-weight: 600;
  padding: 1rem 1rem;
  border-radius: var(--r-md);
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f7;
  color: #475569;
  border: none;
}
html.dark-mode.drill-session-active .drill-actions.has-skip .skip-btn { background: #1e293b; color: #94a3b8; }
.skip-btn-disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---- Native App Feel Enhancements ---- */

/* Prevent image dragging throughout the app (decorative images only) */
img {
  -webkit-user-drag: none;
  user-drag: none;
}
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.15);
  transform: scale(0);
  animation: rippleAnim var(--qr-dur-slow) var(--qr-ease-out) forwards;
  pointer-events: none;
  z-index: var(--z-above);
}
html.dark-mode .ripple-effect {
  background: rgba(96, 165, 250, 0.12);
}
@keyframes rippleAnim {
  to {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Enhanced press feedback for buttons */
.btn, .mode-card, .category-btn,
.table-select-btn, .clear-option-btn,
.numpad-btn, .formula-action-btn {
  -webkit-tap-highlight-color: transparent;
}

/* Numpad key press animation */
.numpad-btn.pressed {
  transform: scale(.89);
  background: #bfdbfe;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
}
html.dark-mode .numpad-btn.pressed {
  background: #334155;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
}

/* (The wrong-answer card shake was removed with ADR-091 — sound + the red teaching panel carry
   the verdict; shake on top was punishment, not information.) */

/* Drill progress bar pulse on completion */
.drill-progress-fill.completed {
  animation: progressPulse var(--qr-dur-slow) var(--qr-ease-out);
}
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Next button pulse — draws attention after correct answer without forcing auto-advance */
.btn.next-btn-pulse {
  animation: nextBtnPulse var(--qr-dur-slow) var(--qr-ease-out);
}
@keyframes nextBtnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.45); transform: scale(1); }
  40%  { box-shadow: 0 0 0 8px rgba(37,99,235,.0); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,.0); transform: scale(1); }
}

/* Correct answer card flash — brief green tint on the card surface */
.correct-flash {
  animation: correctFlash var(--qr-dur-slow) var(--qr-ease-out) forwards;
}
@keyframes correctFlash {
  0%   { background: rgba(255,255,255,.88); }
  25%  { background: rgba(22,163,74,.12); }
  100% { background: rgba(255,255,255,.88); }
}
html.dark-mode .correct-flash {
  animation: correctFlashDark var(--qr-dur-slow) var(--qr-ease-out) forwards;
}
@keyframes correctFlashDark {
  0%   { background: rgba(30,41,59,.88); }
  25%  { background: rgba(22,163,74,.18); }
  100% { background: rgba(30,41,59,.88); }
}

/* ---- Compact Screen Adjustments (small Android, short-screen PWA) ---- */
@media (max-height: 600px) {
  /* Reduce question text size to prevent vertical overflow */
  .question-text { font-size: 1.6rem; }
  /* Shrink numpad buttons slightly */
  .numpad-btn { min-height: 44px; font-size: var(--fs-h3); }
  /* Tighten the spacing rhythm + top inset on short screens so the card never overlaps the numpad */
  body.drill-session-active { --drill-card-gap: .7rem; --drill-submit-gap: .35rem; --qr-numpad-h: 13.4rem; }   /* 44px rows */
  body.drill-session-active #drillContainer > .card {
    top: 2.6rem;
  }
  /* Tighter mode cards on small screens */
  .practice-container .mode-card { padding: 1rem 1rem; margin-bottom: .5rem; }
  header { padding: .5rem 0 .25rem; }
}
@media (max-height: 500px) {
  .question-text { font-size: 1.4rem; }
  .numpad-btn { min-height: 40px; }
  body.drill-session-active { --qr-numpad-h: 12.5rem; }   /* 40px rows */
}

/* ---- PWA Standalone Mode ---- */
@media (display-mode: standalone) {
  body {
    overscroll-behavior: none; /* Prevent pull-to-refresh in installed PWA */
  }
}

/* ---- Landscape Compact Mode ---- */
@media (max-height: 400px) and (orientation: landscape) {
  .practice-container .mode-card {
    padding: .75rem 1rem;
    margin-bottom: .5rem;
  }
  .practice-container .mode-card p {
    display: none; /* Hide descriptions to save vertical space */
  }
  header { padding: .25rem 0 .25rem; }
  header h1 { font-size: var(--fs-h3); }
}


/* The two views without a <header> keep the top spacing the container used to provide for everyone. */
#view-home.spa-view-active,
#view-duel.spa-view-active { padding-top: 1.25rem; }

/* Smooth scrolling for content area */
.container {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ==================== Onboarding Overlay ==================== */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  z-index: var(--z-boot-3);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 1;
  transition: opacity var(--qr-dur) var(--qr-ease-out);
}
.onboarding-overlay.onboarding-exit {
  opacity: 0;
}

.onboarding-card {
  width: 100%;
  max-width: 420px;
  background: var(--qr-surface-solid);
  border-radius: var(--qr-card-radius-sm);
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: var(--el-1);
  text-align: center;
  position: relative;
  opacity: 1;
  transform: translateX(0);
  transition: opacity var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out);
  /* Prevent card from being pushed off-screen by virtual keyboard */
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.onboarding-card-exit {
  opacity: 0;
  transform: translateX(-20px);
}
.onboarding-card-enter {
  animation: obSlideIn var(--qr-dur) var(--qr-ease-out);
}
@keyframes obSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Onboarding Visual Area ---- */
.onboarding-visual {
  margin-bottom: 1.25rem;
}

.onboarding-icon-anim {
  position: relative;
  display: inline-block;
  margin: .5rem 0 .25rem;
}
.onboarding-icon-main {
  font-size: var(--fs-icon-lg);
  display: block;
  animation: obBounce calc(var(--qr-dur-pulse) * 5 / 3) var(--qr-ease) infinite;
}
@keyframes obBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.onboarding-icon-sparkle {
  position: absolute;
  font-size: var(--fs-h2);
  animation: obSparkle calc(var(--qr-dur-pulse) * 1.5) var(--qr-ease) infinite;
}
.onboarding-sparkle-1 {
  top: -4px;
  right: -16px;
  animation-delay: 0s;
}
.onboarding-sparkle-2 {
  bottom: 0;
  left: -16px;
  animation-delay: calc(var(--qr-dur-fast) * 5);
}
@keyframes obSparkle {
  0%, 100% { opacity: .4; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ---- Onboarding Split Preview ---- */
.onboarding-split-preview {
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin: .5rem 0;
}
.onboarding-preview-card {
  flex: 1;
  max-width: 120px;
  background: var(--qr-surface-2);
  border-radius: var(--r-md);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  border: 1px solid var(--qr-border);
}
.onboarding-preview-icon {
  font-size: var(--fs-d2);
}
.onboarding-preview-label {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: #475569;
}

/* ---- Onboarding Stats Preview ---- */
.onboarding-stats-preview {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin: .5rem 0;
}
.onboarding-stat-item {
  flex: 1;
  max-width: 90px;
  background: var(--qr-surface-2);
  border-radius: var(--r-md);
  padding: .75rem .5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  border: 1px solid var(--qr-border);
}
.onboarding-stat-val {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--qr-accent);
}
.onboarding-stat-label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--qr-text-dim);
}

/* ---- Onboarding Typography ---- */
.onboarding-title {
  font-size: var(--fs-h1);
  font-weight: 700;
  color: var(--qr-text);
  margin-bottom: .5rem;
  line-height: 1.3;
}
.onboarding-desc {
  font-size: var(--fs-sub);
  color: #475569;
  line-height: 1.55;
  margin-bottom: .5rem;
}
.onboarding-name-field {
  margin: 1rem auto;
  text-align: center;
  max-width: 280px;
}
.onboarding-name-label {
  display: block;
  font-size: var(--fs-sub);
  font-weight: 600;
  color: #475569;
  margin-bottom: .5rem;
}
.onboarding-name-input {
  width: 100%;
  box-sizing: border-box;
  font-size: var(--fs-body);
  text-align: center;
}
html.dark-mode .onboarding-name-label {
  color: #94a3b8;
}
.onboarding-hint {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  background: var(--qr-bg);
  border-radius: var(--r-sm);
  padding: .5rem .75rem;
  margin-top: .25rem;
  border: 1px solid var(--qr-border);
}
.onboarding-note {
  font-size: var(--fs-caption);
  color: #94a3b8;
  margin-top: .5rem;
}

/* ---- Onboarding Buttons ---- */
/* ADR-106 (ONB-1): subtle global Back at the card's top-left — lets a user step back without abandoning the flow. */
.onboarding-back-btn {
  position: absolute;
  top: .85rem;
  left: .9rem;
  background: none;
  border: none;
  padding: .25rem .25rem;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  z-index: var(--z-lift);
  transition: color var(--qr-dur-fast) var(--qr-ease-out);
}
.onboarding-back-btn:hover { color: #475569; }
html.dark-mode .onboarding-back-btn { color: #64748b; }
html.dark-mode .onboarding-back-btn:hover { color: #cbd5e1; }

.onboarding-actions {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
}
.onboarding-next-btn {
  max-width: 260px;
}
.onboarding-skip-btn {
  background: transparent;
  color: #94a3b8;
  font-size: var(--fs-sub);
  font-weight: 500;
  max-width: 260px;
}
.onboarding-skip-btn:hover {
  background: transparent;
  color: var(--qr-text-dim);
}
.onboarding-skip-btn:active {
  background: transparent;
  transform: scale(var(--qr-press-sm));
}

/* ---- Daily Goal Selection ---- */
.onboarding-goal-icon {
  font-size: var(--fs-icon);
  display: block;
  margin: .25rem 0;
}
.onboarding-goal-options {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin: 1rem 0 .25rem;
  align-items: center;
}
.onboarding-goal-btn {
  width: 100%;
  max-width: 240px;
  padding: .75rem 1rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--r-md);
  background: var(--qr-surface-solid);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--qr-text);
  cursor: pointer;
  transition: border-color var(--qr-dur) var(--qr-ease-out), background var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
}
.onboarding-goal-btn:active {
  transform: scale(var(--qr-press-sm));
}
.onboarding-goal-btn.onboarding-goal-active {
  border-color: var(--qr-accent);
  background: var(--qr-veil-accent-8);
  color: var(--qr-accent);
}

/* ---- Target Exam Screen (tier → exam picker) ---- */
.onboarding-exam-list { max-height: 46vh; overflow-y: auto; padding: 2px; }
.onboarding-exam-list .onboarding-goal-btn { max-width: 280px; text-align: left; }
.onboarding-tier-btn { display: flex; flex-direction: column; gap: .125rem; }
.onboarding-tier-label { font-weight: 700; }
.onboarding-tier-blurb { font-size: var(--fs-caption); font-weight: 500; color: var(--qr-text-dim); }
.onboarding-note a { color: var(--qr-accent); font-weight: 600; text-decoration: none; }

/* ---- First Question Screen ---- */
.onboarding-question-screen {
  padding: .5rem 0;
}
.onboarding-q-label {
  font-size: var(--fs-caption);
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}
.onboarding-q-text {
  font-size: var(--fs-d1);
  font-weight: 700;
  color: var(--qr-text);
  margin-bottom: 1rem;
  letter-spacing: .02em;
}
.onboarding-q-input {
  display: block;
  margin: 0 auto;
  font-size: var(--fs-h1);
  font-weight: 600;
  caret-color: var(--qr-accent);
}
.onboarding-q-feedback {
  display: none;
  margin-top: .75rem;
}
.onboarding-success {
  font-size: var(--fs-h3);
  font-weight: 600;
  color: var(--qr-success);
  animation: obSuccessPop var(--qr-dur-slow) var(--qr-spring);
}
.onboarding-retry-msg {
  font-size: var(--fs-body);
  font-weight: 500;
  color: #d97706;
  animation: obSuccessPop var(--qr-dur-slow) var(--qr-spring);
}
@keyframes obSuccessPop {
  0% { opacity: 0; transform: scale(.7); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes obShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* ---- Progress Dots ---- */
.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.5rem;
  padding-top: .75rem;
}
.onboarding-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--qr-surface-3);
  transition: background var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out);
}
.onboarding-dot-active {
  background: var(--qr-accent);
  transform: scale(1.25);
}
.onboarding-dot-completed {
  background: #93c5fd;
}

/* ---- Onboarding Dark Mode ---- */
html.dark-mode .onboarding-overlay {
  background: rgba(2, 6, 23, .7);
}
html.dark-mode .onboarding-card {
  background: #1e293b;
  box-shadow: var(--el-1);
}html.dark-mode .onboarding-desc { color: #94a3b8; }
html.dark-mode .onboarding-hint {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}
html.dark-mode .onboarding-note { color: #64748b; }
html.dark-mode .onboarding-preview-card {
  background: #0f172a;
  border-color: #334155;
}
html.dark-mode .onboarding-preview-label { color: #94a3b8; }
html.dark-mode .onboarding-stat-item {
  background: #0f172a;
  border-color: #334155;
}html.dark-mode .onboarding-stat-label { color: #94a3b8; }
html.dark-mode .onboarding-goal-btn {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark-mode .onboarding-goal-btn.onboarding-goal-active {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, .12);
  color: #60a5fa;
}html.dark-mode .onboarding-q-label { color: #64748b; }html.dark-mode .onboarding-dot-active { background: #60a5fa; }
html.dark-mode .onboarding-dot-completed { background: #1e40af; }
html.dark-mode .onboarding-skip-btn { color: #64748b; }
html.dark-mode .onboarding-skip-btn:hover { color: #94a3b8; }
html.dark-mode .onboarding-retry-msg { color: #fbbf24; }

/* ========================================================
   Theme 2: Playful Professional
   ======================================================== */

/* ---- Smooth Transitions ---- */
html.theme-playful,
html.theme-playful .card,
html.theme-playful .mode-card,
html.theme-playful .bottom-nav,
html.theme-playful .settings-section-card,
html.theme-playful .stat-card,
html.theme-playful .result-item,
html.theme-playful .table-card,
html.theme-playful .analytics-card,
html.theme-playful .btn,
html.theme-playful .input,
html.theme-playful .learn-search-input {
  transition: background var(--qr-dur) var(--qr-ease-out), color var(--qr-dur) var(--qr-ease-out), border-color var(--qr-dur) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out);
}

/* ---- Light Mode ---- */
html.theme-playful {
  background: #faf9f7;
  color: #1a1a2e;
}

html.theme-playful .app-loader { background: #ffffff; }

html.theme-playful header h1 {
  color: #4f8ff7;
}

html.theme-playful .card,
html.theme-playful .training-card {
  background: rgba(255,255,255,.94);
  border-color: rgba(226,222,214,.5);
  box-shadow: var(--qr-shadow-playful);
}
html.theme-playful .mode-card {
  background: rgba(255,255,255,.92);
  border-color: rgba(226,222,214,.5);
  box-shadow: var(--el-1);
}
html.theme-playful .card:hover,
html.theme-playful .mode-card:hover {
  transform: translateY(-1px);
  /* ADR-137: the light variant had the same teal halo on hover (Playful re-declares
     --qr-veil-accent-25 for both variants). Elevation, not hue — matches the dark rule below. */
  box-shadow: var(--el-2);
}

html.theme-playful .mode-card h3 { color: #1a1a2e; }
html.theme-playful .mode-card p { color: #5a6275; }

html.theme-playful .bottom-nav {
  background: #faf9f7;
  border-top-color: rgba(226,222,214,.6);
  box-shadow: var(--el-nav);
}
html.theme-playful .bottom-nav a { color: #8b8fa3; }
html.theme-playful .bottom-nav a .nav-icon .qr-ico { opacity: .6; }
html.theme-playful .bottom-nav a.active { color: var(--qr-grad-b); }
html.theme-playful .bottom-nav a.active .nav-icon .qr-ico {
  opacity: 1;
}
html.theme-playful .bottom-nav a.active::after {
  background: var(--qr-grad-bar);
}

html.theme-playful .input,
html.theme-playful .learn-search-input {
  background: #ffffff;
  border-color: #e2ded6;
  color: #1a1a2e;
}
html.theme-playful .input:focus,
html.theme-playful .learn-search-input:focus {
  border-color: #4f8ff7;
  box-shadow: var(--qr-focus-ring);
}

html.theme-playful .stat-card,
html.theme-playful .result-item {
  background: #f0efec;
}
html.theme-playful .stat-card .value,
html.theme-playful .result-value { color: #4f8ff7; }
html.theme-playful .stat-card .label,
html.theme-playful .result-label { color: #5a6275; }
html.theme-playful .stat-card.highlight { border-left-color: #4f8ff7; }html.theme-playful .stat-card-negative .value { color: #dc2626; }

html.theme-playful .settings-section-title { color: #5a6275; }
html.theme-playful .settings-section-card {
  background: #ffffff;
  border-color: rgba(226,222,214,.5);
  box-shadow: var(--el-1);
}
html.theme-playful .settings-row-divider { background: #f0efec; }
html.theme-playful .settings-label h3 { color: #1a1a2e; }
html.theme-playful .settings-label p { color: #5a6275; }
html.theme-playful .settings-row-block h3 { color: #1a1a2e; }
html.theme-playful .settings-link:active { background: rgba(79,143,247,.06); }

html.theme-playful .btn {
  background: #e8e6e1;
  color: #1a1a2e;
}
html.theme-playful .btn:hover { background: #dad7d0; }
html.theme-playful .btn.accent {
  background: var(--qr-grad-cta);
  color: #ffffff;
}
html.theme-playful .btn.accent:hover {
  background: var(--qr-grad-cta);
}

/* ── ADR-088: complete the Playful drill/results identity ──────────────────────────────────────────────────────────
   These results/feedback/interactive components predate the token system and rendered classic blue/violet/pastel in
   Playful. Re-themed here through Playful tokens (which resolve for both Playful light AND dark), so Playful reads as a
   full identity. Classic + Dark are byte-identical — no base or html.dark-mode rule is touched. WCAG AA-verified. */

/* Primary CTA (drill Submit / Next / Retry) + share button → the Playful blue→teal accent (matches .btn.accent). */
html.theme-playful .btn-primary { background: var(--qr-grad-cta); color: #ffffff; }
html.theme-playful .btn-primary:hover { background: var(--qr-grad-cta); }
html.theme-playful .results-share-btn { background: var(--qr-grad-cta); border-color: var(--qr-accent); }

/* Performance badges + adaptive pills → token-tinted (warm-surface friendly) instead of classic pastels. */
html.theme-playful .badge-excellent,
html.theme-playful .adaptive-pill-easy { background: var(--qr-success-bg); color: var(--qr-success-fg); }
html.theme-playful .badge-good,
html.theme-playful .adaptive-pill-medium { background: var(--qr-surface-3); color: var(--qr-accent); }
html.theme-playful .badge-practice { background: var(--qr-surface-3); color: var(--qr-warn); }
html.theme-playful .badge-review { background: var(--qr-surface-2); color: var(--qr-text-dim); }
html.theme-playful .adaptive-pill-hard { background: var(--qr-surface-3); color: var(--qr-info-fg); }

/* Speed-benchmark card → Playful surface + accent (was fixed lilac/violet, off on warm cream). */
html.theme-playful .speed-benchmark-card { background: var(--qr-surface-2); border-color: var(--qr-border); box-shadow: none; }
html.theme-playful .benchmark-title,
html.theme-playful .benchmark-stat-value { color: var(--qr-accent); }
html.theme-playful .benchmark-highlight-pct,
html.theme-playful .benchmark-highlight-pct strong,
html.theme-playful .benchmark-summary { color: var(--qr-text); }
html.theme-playful .benchmark-stat-label,
html.theme-playful .benchmark-suggestion { color: var(--qr-text-dim); }
html.theme-playful .benchmark-level { background: var(--qr-grad-cta); box-shadow: none; }

/* Insight / auto-explain / wrong-answer / percentile-delta → accent + status tokens. */
html.theme-playful .session-insight-card { color: var(--qr-text); background: var(--qr-surface-2); border-left-color: var(--qr-accent); }
html.theme-playful .auto-explain-tip { color: var(--qr-accent); background: var(--qr-surface-2); border-left-color: var(--qr-accent); }
html.theme-playful .wrong-answer-card { background: var(--qr-danger-bg); border-left-color: var(--qr-danger-border); }
html.theme-playful .percentile-delta.delta-up { color: var(--qr-success-fg); }
html.theme-playful .percentile-delta.delta-down { color: var(--qr-danger-fg); }

/* MCQ options + correct/wrong reveal → surface/border/text + status tokens. */
html.theme-playful .mcq-option { color: var(--qr-text); background: var(--qr-surface-solid); border-color: var(--qr-border); }
html.theme-playful .mcq-option.pressed { background: var(--qr-surface-2); }
html.theme-playful .mcq-option.mcq-correct { background: var(--qr-success-bg); border-color: var(--qr-success-border); color: var(--qr-success-fg); }
html.theme-playful .mcq-option.mcq-wrong { background: var(--qr-danger-bg); border-color: var(--qr-danger-border); color: var(--qr-danger-fg); }

/* Feedback wrapper text · progress label · active-drill skip. */
html.theme-playful .feedback.correct { color: var(--qr-success-fg); }
html.theme-playful .feedback.wrong { color: var(--qr-danger-fg); }
html.theme-playful .drill-progress { color: var(--qr-text-dim); }
html.theme-playful.drill-session-active .drill-actions.has-skip .skip-btn { background: var(--qr-surface-2); color: var(--qr-text-dim); }html.theme-playful .toast {
  background: #1a1a2e;
  color: #f1f5f9;
}

html.theme-playful .profile-field-label { color: #5a6275; }
html.theme-playful .section-title { color: #4f8ff7; }

html.theme-playful .table-card {
  background: rgba(255,255,255,.90);
  border-color: rgba(226,222,214,.6);
}
html.theme-playful .table-card .table-title { border-bottom-color: #e2ded6; }
html.theme-playful .table-title { color: #4f8ff7; }

html.theme-playful .category-btn {
  background: #ffffff;
  border-color: #e2ded6;
  color: #1a1a2e;
}
html.theme-playful .category-btn:active {
  background: #f7f7f9;
  border-color: #4f8ff7;
}
html.theme-playful .category-btn.selected {
  background: rgba(79,143,247,.08);
  border: 2.5px solid #4f8ff7;
  color: #2d6ae0;
}
html.theme-playful .timer-select-section {
  background: rgba(247,247,249,.7);
  border-color: rgba(226,222,214,.5);
}

html.theme-playful .shortcut-table th,
html.theme-playful .shortcut-table td,
html.theme-playful .math-table th,
html.theme-playful .math-table td {
  border-bottom-color: #e2ded6;
}
html.theme-playful .shortcut-table th,
html.theme-playful .math-table th { color: #5a6275; }
html.theme-playful .math-grid-item { background: #f5f4f1; }
html.theme-playful .math-expr { color: #1a1a2e; }
html.theme-playful .math-val { color: #4f8ff7; }

html.theme-playful .table-select-btn {
  background: #ffffff;
  border-color: #e2ded6;
  color: #1a1a2e;
}
html.theme-playful .table-select-btn.active {
  background: #4f8ff7;
  border-color: #4f8ff7;
  color: #ffffff;
}

html.theme-playful .collapsible-header:active { background: #f0efec; }

html.theme-playful .formula-text {
  background: #f0efec;
  color: #1a1a2e;
}
html.theme-playful .formula-block { border-bottom-color: #e2ded6; }
html.theme-playful .formula-block-title { color: #1a1a2e; }
html.theme-playful .formula-label { color: #7a8795; }
html.theme-playful .formula-tip { color: #4b5563; }

html.theme-playful .feedback.correct { background: rgba(22,163,74,.08); }
html.theme-playful .feedback.wrong   { background: rgba(220,38,38,.08); }

html.theme-playful .info-modal-overlay { background: rgba(26,26,46,.4); }
html.theme-playful .info-modal-content {
  background: #faf9f7;
  box-shadow: var(--el-3);
}html.theme-playful .info-modal-close {
  background: rgba(0,0,0,.05);
  color: #5a6275;
}
html.theme-playful .info-modal-scroll::after {
  display: none;
}
html.theme-playful .info-modal-title { color: #1a1a2e; }
html.theme-playful .info-modal-subtitle { color: #5a6275; }
html.theme-playful .info-section-title { color: #8b8fa3; }
html.theme-playful .info-block {
  background: #ffffff;
  border-color: rgba(226,222,214,.5);
}
html.theme-playful .info-block-highlight { border-left-color: #4f8ff7; }
html.theme-playful .info-block h4 { color: #1a1a2e; }
html.theme-playful .info-block p { color: #5a6275; }
html.theme-playful .info-list li { color: #5a6275; }
html.theme-playful .info-list li::before { color: #4f8ff7; }
html.theme-playful .info-tip {
  background: rgba(79,143,247,.06);
  border-left-color: #4f8ff7;
  color: #5a6275;
}
html.theme-playful .info-version { color: #8b8fa3; }
html.theme-playful .info-quote { border-left-color: #4f8ff7; }
html.theme-playful .info-quote p { color: #5a6275; }

html.theme-playful .session-exit,
html.theme-playful .drill-exit-btn {
  background: transparent;
  color: #5a6275;
}
html.theme-playful .session-exit:active,
html.theme-playful .drill-exit-btn:active {
  background: rgba(0,0,0,.10);
  color: #1a1a2e;
}
html.theme-playful .add-formula-btn,
html.theme-playful .add-topic-btn {
  background: rgba(79,143,247,.06);
  color: #4f8ff7;
  border-color: rgba(79,143,247,.3);
}
html.theme-playful .add-formula-btn:hover,
html.theme-playful .add-topic-btn:hover { background: rgba(79,143,247,.12); }

html.theme-playful .custom-formula-item { border-bottom-color: #e2ded6; }
html.theme-playful .formula-action-btn:hover { background: rgba(0,0,0,.04); }

html.theme-playful .modal-content { background: #faf9f7; }
html.theme-playful .modal-content::after {
  display: none;
}
html.theme-playful .modal-title { color: #4f8ff7; }
html.theme-playful .modal-cancel { background: #e8e6e1; }

html.theme-playful .table-modal-overlay { background: rgba(26,26,46,.4); }
html.theme-playful .table-modal-content {
  background: rgba(255,255,255,.95);
  border-color: rgba(226,222,214,.6);
}
html.theme-playful .table-modal-close {
  background: rgba(0,0,0,.05);
  color: #5a6275;
}
html.theme-playful .table-modal-title { color: #4f8ff7; }

html.theme-playful .analytics-section-title { color: #5a6275; }
html.theme-playful .analytics-card {
  background: #ffffff;
  border-color: rgba(226,222,214,.5);
  box-shadow: var(--el-1);
}
/* ADR-132: this rule is gone. It used to force `transparent`, overriding a base background that had
   already been lost — a dead opt-out, and the reason Playful light had no grouping panel either.
   Playful's tray colour now comes from its own --qr-panel token. */
html.theme-playful .login-input.input-error { border-color: #f87171; }
html.theme-playful .login-input.input-error:focus {
  border-color: #dc2626;
  box-shadow: var(--qr-ring-danger);
}
html.theme-playful .login-input.input-valid { border-color: #4ade80; }
html.theme-playful .login-input.input-valid:focus {
  border-color: #16a34a;
  box-shadow: var(--qr-ring-ok);
}


html.theme-playful .clear-option-btn {
  background: #ffffff;
  border-color: #e2ded6;
}
html.theme-playful .clear-option-btn:hover {
  border-color: #dad7d0;
  background: #faf9f7;
}
html.theme-playful .clear-option-danger { border-color: #fecaca; }
html.theme-playful .clear-option-danger:hover {
  border-color: #f87171;
  background: #fef2f2;
}
html.theme-playful .clear-option-info strong { color: #1a1a2e; }
html.theme-playful .clear-option-info span { color: #5a6275; }

html.theme-playful .custom-numpad {
  background: #f0efec;
  border-top-color: #e2ded6;
}
html.theme-playful .numpad-btn {
  background: #ffffff;
  color: #1a1a2e;
  box-shadow: var(--el-1);
}
html.theme-playful .numpad-btn:active { background: #e8e6e1; }
html.theme-playful .numpad-btn.numpad-submit {
  background: var(--qr-grad-cta);
  color: #ffffff;
}
html.theme-playful .numpad-btn.pressed { background: rgba(79,143,247,.12); }
html.theme-playful .ripple-effect { background: rgba(79,143,247,.15); }

html.theme-playful .toggle input:checked + .toggle-slider { background: #4f8ff7; }

html.theme-playful .strength-moderate { background: rgba(79,143,247,.12); color: #3d7de5; }

html.theme-playful .bookmarks-card { border-left-color: #f59e0b; }
html.theme-playful .drill-progress-fill {
  background: var(--qr-grad-bar);
}

html.theme-playful .onboarding-overlay { background: rgba(26,26,46,.55); }
html.theme-playful .onboarding-card {
  background: #ffffff;
  box-shadow: var(--el-1);
}
html.theme-playful .onboarding-title { color: #1a1a2e; }
html.theme-playful .onboarding-desc { color: #5a6275; }
html.theme-playful .onboarding-hint {
  background: #f5f4f1;
  border-color: #e2ded6;
  color: #5a6275;
}
html.theme-playful .onboarding-note { color: #8b8fa3; }
html.theme-playful .onboarding-preview-card {
  background: #f0efec;
  border-color: #e2ded6;
}
html.theme-playful .onboarding-preview-label { color: #5a6275; }
html.theme-playful .onboarding-stat-item {
  background: #f0efec;
  border-color: #e2ded6;
}
html.theme-playful .onboarding-stat-val { color: #4f8ff7; }
html.theme-playful .onboarding-stat-label { color: #5a6275; }
html.theme-playful .onboarding-name-label { color: #5a6275; }
html.theme-playful .onboarding-goal-btn {
  background: #ffffff;
  border-color: #e2ded6;
  color: #1a1a2e;
}
html.theme-playful .onboarding-goal-btn.onboarding-goal-active {
  border-color: #4f8ff7;
  background: rgba(79,143,247,.08);
  color: #4f8ff7;
}
html.theme-playful .onboarding-q-text { color: #1a1a2e; }
html.theme-playful .onboarding-q-label { color: #8b8fa3; }
html.theme-playful .onboarding-dot { background: #e2ded6; }
html.theme-playful .onboarding-dot-active { background: #4f8ff7; }
html.theme-playful .onboarding-dot-completed { background: #a3cdfa; }
html.theme-playful .onboarding-skip-btn { color: #8b8fa3; }
html.theme-playful .onboarding-skip-btn:hover { color: #5a6275; }
html.theme-playful .onboarding-retry-msg { color: #d97706; }

/* ---- Dark Mode (Premium Dark) ---- */
html.theme-playful.dark-mode {
  background: #0d1117;
  color: #e6edf3;
}

html.theme-playful.dark-mode .app-loader { background: #0d1117; }

html.theme-playful.dark-mode header h1 {
  color: #58a6ff;
}

/* ADR-137 — content surfaces get ELEVATION, never a coloured halo.
   These four rules used `--qr-glow-accent`, which inside this block resolves to
   `0 4px 12px rgba(45,212,191,.28)` — a teal glow, because Playful Dark re-declares
   `--qr-veil-accent-25` in its own palette. As the card's ENTIRE box-shadow that reads as neon rather
   than depth, and it was the whole elevation story for `.card` and `.mode-card`: Home, Practice, Learn
   and Quick Study all wore the same halo, because they are all the same component.

   The replacement is not new — it is what this theme's OTHER surfaces already use.
   `html.theme-playful.dark-mode` declares `--el-1: 0 8px 26px rgba(0,0,0,.42), 0 1px 3px rgba(0,0,0,.30)`
   and `.settings-section-card` / `.analytics-card` in this very block already read it. The card was the
   outlier. Swapping to the ladder INCREASES depth — a 26px double-throw against the glow's single 12px —
   so hierarchy strengthens rather than flattens, and glass, borders and surface separation are untouched.

   The durable rule this encodes, asserted by design-lint: a coloured glow belongs to accent ACTIONS
   (CTAs, active pills, primary buttons), never to content SURFACES. */
html.theme-playful.dark-mode .training-card {
  background: rgba(22,27,45,.94);
  border-color: rgba(79,143,247,.12);
  box-shadow: var(--el-1);
}
html.theme-playful.dark-mode .card,
html.theme-playful.dark-mode .mode-card {
  background: rgba(22,27,45,.88);
  border-color: rgba(79,143,247,.12);
  box-shadow: var(--el-1);
}
html.theme-playful.dark-mode .card:hover,
html.theme-playful.dark-mode .mode-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--el-2);        /* one step up the ladder — lift reads as rising, not as lighting up */
}

html.theme-playful.dark-mode .mode-card h3,
html.theme-playful.dark-mode .settings-label h3,
html.theme-playful.dark-mode .cat-name { color: #e6edf3; }
html.theme-playful.dark-mode .mode-card p,
html.theme-playful.dark-mode .settings-label p { color: #8b949e; }

html.theme-playful.dark-mode .bottom-nav {
  background: #0d1117;
  border-top-color: var(--qr-veil-w-6);
  box-shadow: var(--el-nav);
}
html.theme-playful.dark-mode .bottom-nav a { color: #8b949e; }
html.theme-playful.dark-mode .bottom-nav a .nav-icon .qr-ico { opacity: .6; }
html.theme-playful.dark-mode .bottom-nav a.active { color: #58a6ff; }
html.theme-playful.dark-mode .bottom-nav a.active .nav-icon .qr-ico {
  opacity: 1;
}
html.theme-playful.dark-mode .bottom-nav a.active::after {
  background: var(--qr-grad-bar);
}

html.theme-playful.dark-mode .input,
html.theme-playful.dark-mode .learn-search-input {
  background: #161b2d;
  border-color: var(--qr-veil-w-6);
  color: #e6edf3;
}
html.theme-playful.dark-mode .input:focus,
html.theme-playful.dark-mode .learn-search-input:focus {
  border-color: #58a6ff;
  box-shadow: var(--qr-focus-ring);
}

html.theme-playful.dark-mode .shortcut-table th,
html.theme-playful.dark-mode .shortcut-table td,
html.theme-playful.dark-mode .math-table th,
html.theme-playful.dark-mode .math-table td {
  border-bottom-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .shortcut-table th,
html.theme-playful.dark-mode .math-table th { color: #8b949e; }

html.theme-playful.dark-mode .stat-card,
html.theme-playful.dark-mode .result-item {
  background: rgba(22,27,45,.7);
  border: 1px solid rgba(79,143,247,.08);
}
html.theme-playful.dark-mode .stat-card .value,
html.theme-playful.dark-mode .result-value { color: #58a6ff; }
html.theme-playful.dark-mode .stat-card .label,
html.theme-playful.dark-mode .result-label { color: #8b949e; }
html.theme-playful.dark-mode .stat-card.highlight { border-left-color: #58a6ff; }
html.theme-playful.dark-mode .stat-card-positive .value { color: #3fb950; }
html.theme-playful.dark-mode .stat-card-negative .value { color: #f85149; }

html.theme-playful.dark-mode .settings-section-title { color: #8b949e; }
html.theme-playful.dark-mode .settings-section-card {
  background: rgba(22,27,45,.88);
  border-color: rgba(79,143,247,.10);
  box-shadow: var(--el-1);
}
html.theme-playful.dark-mode .settings-row-divider { background: var(--qr-veil-w-6); }
html.theme-playful.dark-mode .settings-row-block h3 { color: #e6edf3; }
html.theme-playful.dark-mode .settings-link:active { background: rgba(88,166,255,.08); }

html.theme-playful.dark-mode .btn {
  background: rgba(22,27,45,.9);
  border: 1px solid var(--qr-veil-w-6);
  color: #e6edf3;
}
html.theme-playful.dark-mode .btn:hover {
  background: rgba(30,35,55,.95);
}
html.theme-playful.dark-mode .btn.accent {
  background: var(--qr-grad-cta);
  border: none;
  color: #ffffff;
}

html.theme-playful.dark-mode .drill-progress-bar { background: rgba(22,27,45,.7); }
html.theme-playful.dark-mode .toast {
  background: rgba(22,27,45,.95);
  color: #e6edf3;
  border: 1px solid rgba(79,143,247,.15);
  box-shadow: var(--el-2);
}

html.theme-playful.dark-mode .profile-field-label { color: #8b949e; }
html.theme-playful.dark-mode .section-title { color: #58a6ff; }

html.theme-playful.dark-mode .table-card {
  background: rgba(22,27,45,.85);
  border-color: rgba(79,143,247,.10);
}
html.theme-playful.dark-mode .table-card .table-title {
  border-bottom-color: var(--qr-veil-w-6);
  color: #58a6ff;
}

html.theme-playful.dark-mode .category-btn {
  background: #161b2d;
  border-color: var(--qr-veil-w-12);
  color: #e6edf3;
}
html.theme-playful.dark-mode .category-btn:active {
  background: var(--qr-veil-w-4);
  border-color: #58a6ff;
}
html.theme-playful.dark-mode .category-btn.selected {
  background: rgba(88,166,255,.08);
  border: 2.5px solid #58a6ff;
  color: #79c0ff;
}
html.theme-playful.dark-mode .timer-select-section {
  background: rgba(22,27,45,.5);
  border-color: var(--qr-veil-w-8);
}

html.theme-playful.dark-mode .cat-bar-container { background: rgba(22,27,45,.7); }

html.theme-playful.dark-mode .math-grid-item {
  background: rgba(22,27,45,.7);
}
html.theme-playful.dark-mode .math-expr { color: #e6edf3; }
html.theme-playful.dark-mode .math-val { color: #58a6ff; }

html.theme-playful.dark-mode .table-select-btn {
  background: #161b2d;
  border-color: var(--qr-veil-w-6);
  color: #e6edf3;
}
html.theme-playful.dark-mode .table-select-btn.active {
  background: #58a6ff;
  border-color: #58a6ff;
  color: #0d1117;
}

html.theme-playful.dark-mode .collapsible-header:active { background: var(--qr-veil-w-4); }

html.theme-playful.dark-mode .formula-text {
  background: rgba(22,27,45,.7);
  color: #e6edf3;
}
html.theme-playful.dark-mode .formula-block { border-bottom-color: var(--qr-veil-w-8); }
html.theme-playful.dark-mode .formula-block-title { color: #f8fafc; }
html.theme-playful.dark-mode .formula-label { color: #9ba7b4; }
html.theme-playful.dark-mode .formula-tip { color: #cbd5e1; }

html.theme-playful.dark-mode .feedback.correct { background: rgba(63,185,80,.12); }
html.theme-playful.dark-mode .feedback.wrong   { background: rgba(248,81,73,.12); }

html.theme-playful.dark-mode .info-modal-overlay { background: rgba(0,0,0,.6); }
html.theme-playful.dark-mode .info-modal-content {
  background: #0d1117;
  box-shadow: var(--el-3);
}
html.theme-playful.dark-mode .info-hero {
  background: #0d1117;
}
html.theme-playful.dark-mode .info-modal-close {
  background: var(--qr-veil-w-6);
  color: #8b949e;
}
html.theme-playful.dark-mode .info-modal-scroll::after {
  display: none;
}
html.theme-playful.dark-mode .info-modal-title { color: #e6edf3; }
html.theme-playful.dark-mode .info-modal-subtitle { color: #8b949e; }
html.theme-playful.dark-mode .info-section-title { color: #484f58; }
html.theme-playful.dark-mode .info-block {
  background: rgba(22,27,45,.8);
  border-color: rgba(79,143,247,.08);
  box-shadow: var(--el-1);
}
html.theme-playful.dark-mode .info-block-highlight { border-left-color: #58a6ff; }
html.theme-playful.dark-mode .info-block h4 { color: #e6edf3; }
html.theme-playful.dark-mode .info-block p { color: #8b949e; }
html.theme-playful.dark-mode .info-list li { color: #8b949e; }
html.theme-playful.dark-mode .info-list li::before { color: #58a6ff; }
html.theme-playful.dark-mode .info-tip {
  background: rgba(88,166,255,.06);
  border-left-color: #58a6ff;
  color: #8b949e;
}
html.theme-playful.dark-mode .info-version { color: #484f58; }
html.theme-playful.dark-mode .info-quote { border-left-color: #58a6ff; }
html.theme-playful.dark-mode .info-quote p { color: #8b949e; }

html.theme-playful.dark-mode .session-exit,
html.theme-playful.dark-mode .drill-exit-btn {
  background: transparent;
  color: #8b949e;
}
html.theme-playful.dark-mode .session-exit:active,
html.theme-playful.dark-mode .drill-exit-btn:active {
  background: var(--qr-veil-w-12);
  color: #e6edf3;
}
html.theme-playful.dark-mode .add-formula-btn,
html.theme-playful.dark-mode .add-topic-btn {
  background: rgba(88,166,255,.08);
  color: #58a6ff;
  border-color: rgba(88,166,255,.20);
}
html.theme-playful.dark-mode .custom-formula-item { border-bottom-color: var(--qr-veil-w-6); }
html.theme-playful.dark-mode .formula-action-btn:hover { background: var(--qr-veil-w-8); }

html.theme-playful.dark-mode .modal-content {
  background: #161b2d;
  border: 1px solid rgba(79,143,247,.10);
}
html.theme-playful.dark-mode .modal-content::after {
  display: none;
}
html.theme-playful.dark-mode .modal-title { color: #58a6ff; }
html.theme-playful.dark-mode .modal-cancel {
  background: var(--qr-veil-w-6);
  color: #e6edf3;
}

html.theme-playful.dark-mode .table-modal-overlay { background: rgba(0,0,0,.65); }
html.theme-playful.dark-mode .table-modal-content {
  background: rgba(22,27,45,.95);
  border-color: rgba(79,143,247,.12);
}
html.theme-playful.dark-mode .table-modal-close {
  background: var(--qr-veil-w-6);
  color: #8b949e;
}
html.theme-playful.dark-mode .table-modal-title { color: #58a6ff; }

html.theme-playful.dark-mode .analytics-section-title { color: #8b949e; }
html.theme-playful.dark-mode .analytics-card {
  background: rgba(22,27,45,.88);
  border-color: rgba(79,143,247,.10);
  box-shadow: var(--el-1);
}
/* ADR-132: this rule is gone too — Playful dark's tray value moved to its --qr-panel token (still
   mirroring .analytics-card, still byte-identical), and its `border-color` was dead, since nothing has
   ever given this element a border-width. */
html.theme-playful.dark-mode .login-input.input-error { border-color: rgba(248,81,73,.5); }
html.theme-playful.dark-mode .login-input.input-valid { border-color: rgba(74,222,128,.4); }
html.theme-playful.dark-mode .login-field-validation li.val-error { color: #f85149; }
html.theme-playful.dark-mode .login-field-validation li.val-pass { color: #3fb950; }
html.theme-playful.dark-mode .login-field-validation .val-summary { color: #3fb950; }


html.theme-playful.dark-mode .clear-option-btn {
  background: #161b2d;
  border-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .clear-option-btn:hover {
  border-color: var(--qr-veil-w-12);
  background: rgba(22,27,45,.95);
}
html.theme-playful.dark-mode .clear-option-danger { border-color: rgba(248,81,73,.25); }
html.theme-playful.dark-mode .clear-option-danger:hover {
  border-color: #f85149;
  background: rgba(248,81,73,.08);
}
html.theme-playful.dark-mode .clear-option-info strong { color: #e6edf3; }
html.theme-playful.dark-mode .clear-option-info span { color: #8b949e; }

html.theme-playful.dark-mode .custom-numpad {
  background: #0d1117;
  border-top-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .numpad-btn {
  background: rgba(22,27,45,.9);
  color: #e6edf3;
  box-shadow: var(--el-1);
  border: 1px solid var(--qr-veil-w-4);
}
html.theme-playful.dark-mode .numpad-btn:active { background: rgba(30,35,55,.95); }
html.theme-playful.dark-mode .numpad-btn.numpad-submit {
  /* ADR-087: match Playful-light's signature blue→teal submit so Playful reads cohesively in dark too (was plain blue). */
  background: var(--qr-grad-cta);
  border: none;
  color: #ffffff;
}
html.theme-playful.dark-mode .numpad-btn.pressed { background: rgba(88,166,255,.15); }
html.theme-playful.dark-mode .ripple-effect { background: rgba(88,166,255,.12); }

html.theme-playful.dark-mode .toggle input:checked + .toggle-slider { background: #58a6ff; }

html.theme-playful.dark-mode .strength-strong { background: rgba(63,185,80,.15); color: #3fb950; }
html.theme-playful.dark-mode .strength-moderate { background: rgba(88,166,255,.15); color: #58a6ff; }
html.theme-playful.dark-mode .strength-weak { background: rgba(248,81,73,.15); color: #f85149; }
html.theme-playful.dark-mode .drill-progress-fill {
  background: var(--qr-grad-bar);
}

html.theme-playful.dark-mode .onboarding-overlay { background: rgba(0,0,0,.7); }
html.theme-playful.dark-mode .onboarding-card {
  background: #161b2d;
  /* ADR-137: a modal panel is a content surface, not an accent action — elevation, not a halo.
     --el-3 rather than --el-1 because it floats above an overlay; the ladder already says so. */
  box-shadow: var(--el-3);
}
html.theme-playful.dark-mode .onboarding-title { color: #e6edf3; }
html.theme-playful.dark-mode .onboarding-desc { color: #8b949e; }
html.theme-playful.dark-mode .onboarding-hint {
  background: #0d1117;
  border-color: var(--qr-veil-w-6);
  color: #8b949e;
}
html.theme-playful.dark-mode .onboarding-note { color: #484f58; }
html.theme-playful.dark-mode .onboarding-preview-card {
  background: #0d1117;
  border-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .onboarding-preview-label { color: #8b949e; }
html.theme-playful.dark-mode .onboarding-stat-item {
  background: #0d1117;
  border-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .onboarding-stat-val { color: #58a6ff; }
html.theme-playful.dark-mode .onboarding-stat-label { color: #8b949e; }
html.theme-playful.dark-mode .onboarding-name-label { color: #8b949e; }
html.theme-playful.dark-mode .onboarding-goal-btn {
  background: #0d1117;
  border-color: var(--qr-veil-w-6);
  color: #e6edf3;
}
html.theme-playful.dark-mode .onboarding-goal-btn.onboarding-goal-active {
  border-color: #58a6ff;
  background: rgba(88,166,255,.12);
  color: #58a6ff;
}
html.theme-playful.dark-mode .onboarding-q-text { color: #e6edf3; }
html.theme-playful.dark-mode .onboarding-q-label { color: #484f58; }
html.theme-playful.dark-mode .onboarding-dot { background: var(--qr-veil-w-6); }
html.theme-playful.dark-mode .onboarding-dot-active { background: #58a6ff; }
html.theme-playful.dark-mode .onboarding-dot-completed { background: #1f4287; }
html.theme-playful.dark-mode .onboarding-skip-btn { color: #484f58; }
html.theme-playful.dark-mode .onboarding-skip-btn:hover { color: #8b949e; }
html.theme-playful.dark-mode .onboarding-retry-msg { color: #e3b341; }

/* ---- Profile Banner Card ---- */
.profile-banner {
  background: var(--qr-grad-cta);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  color: var(--qr-on-accent);
  margin-bottom: 1.25rem;
  text-align: center;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}
html.theme-playful .profile-banner {
  background: var(--qr-grad-cta);
}
html.theme-playful.dark-mode .profile-banner {
  background: var(--qr-grad-wash);
  border: 1px solid rgba(88,166,255,.15);
  color: #e6edf3;
}
.profile-password-wrapper .profile-input {
  padding-right: 2.75rem;
}

/* ---- Theme Selector ---- */
.theme-select {
  width: auto;
  min-width: 8.5rem;
  min-height: 44px;                 /* comfortable touch target (§6.8) */
  padding: .5rem .75rem;
  border: 2px solid var(--qr-border);
  border-radius: var(--r-md);
  background-color: var(--qr-surface);
  color: var(--qr-text);
  font-size: var(--fs-sub);
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.25rem;
  transition: border-color var(--qr-dur) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out);
}
.theme-select:focus {
  border-color: var(--qr-accent);
  box-shadow: var(--qr-focus-ring);
}
html.theme-playful .theme-select {
  border-color: #e2ded6;
  color: #1a1a2e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6275' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
html.theme-playful .theme-select:focus {
  border-color: #4f8ff7;
  box-shadow: var(--qr-focus-ring);
}
html.theme-playful.dark-mode .theme-select {
  background-color: #161b2d;
  border-color: var(--qr-veil-w-6);
  color: #e6edf3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
html.theme-playful.dark-mode .theme-select:focus {
  border-color: #58a6ff;
  box-shadow: var(--qr-focus-ring);
}

/* ---- Default (Classic Blue) dark mode for new components ---- */
html.dark-mode .profile-banner {
  background: var(--qr-grad-wash);
  border: 1px solid rgba(96,165,250,.15);
  color: #e2e8f0;
}
html.dark-mode .theme-select {
  background-color: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
html.dark-mode .theme-select:focus {
  border-color: #60a5fa;
  box-shadow: var(--qr-focus-ring);
}

/* (.nav-emoji rules were folded into the .qr-ico nav rules — the icon markup is unified now) */

/* ---- Skip button in drills ---- */
.skip-btn {
  margin-top: 0;
  background: transparent;
  color: var(--qr-text-dim);
  font-size: var(--fs-sub);
  border: 1px solid var(--qr-border);
  padding: .5rem 1rem;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.skip-btn:active {
  background: var(--qr-surface-2);
}
html.dark-mode .skip-btn {
  color: #94a3b8;
  border-color: #334155;
}
html.dark-mode .skip-btn:active {
  background: #1e293b;
}
html.theme-playful .skip-btn {
  color: #5a6275;
  border-color: #e2ded6;
}
html.theme-playful .skip-btn:active {
  background: #f0efec;
}
html.theme-playful.dark-mode .skip-btn {
  color: #8b949e;
  border-color: var(--qr-veil-w-6);
}
html.theme-playful.dark-mode .skip-btn:active {
  background: var(--qr-veil-w-4);
}

/* ======== UI/UX Polish & Micro-interactions ======== */

/* Task 13: Subtle card tap feedback on analytics cards */
.analytics-card {
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
}
.analytics-card:active {
  transform: scale(var(--qr-press-lg));
}

/* Task 12: Improved scroll behavior */
.spa-view {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Task 13: Settings section card tap feedback */
.settings-section-card {
  transition: transform var(--qr-dur-fast) var(--qr-ease-out);
}
.settings-action-btn {
  width: 100%;
  border: 1px solid var(--qr-veil-ink-14);
  background: transparent;
  color: inherit;
  box-shadow: var(--el-1);
  transition: border-color var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out);
  min-height: 44px;
  padding: .75rem 1rem;
}
.settings-action-btn:hover {
  border-color: rgba(15,23,42,.2);
  box-shadow: var(--el-2);
}
.settings-action-btn:active {
  transform: translateY(1px);
  background: var(--qr-veil-ink-3);
}
.settings-action-danger {
  color: #b91c1c;
  border-color: rgba(185,28,28,.26);
}
html.dark-mode .settings-action-btn {
  border-color: var(--qr-veil-w-12);
  box-shadow: var(--el-1);
}
html.dark-mode .settings-action-btn:hover {
  border-color: rgba(255,255,255,.22);
  box-shadow: var(--el-2);
}
html.dark-mode .settings-action-btn:active {
  background: var(--qr-veil-w-5);
}
html.dark-mode .settings-action-danger {
  color: #fda4af;
  border-color: rgba(244,63,94,.34);
}
.settings-action-with-desc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .125rem;
  padding: .5rem 1rem;
}
.settings-btn-label {
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.3;
}
.settings-btn-desc {
  font-size: var(--fs-micro);
  font-weight: 400;
  opacity: .5;
  line-height: 1.2;
  letter-spacing: .01em;
}
.trial-upgrade-card {
  padding: 1rem;
  border-radius: var(--r-lg);
  box-shadow: var(--el-2);
}
.trial-upgrade-title {
  margin: 0 0 .75rem;
  font-size: var(--fs-h3);
  color: var(--qr-text);
}
.trial-upgrade-list {
  margin: 0 0 1rem;
  padding-left: 1rem;
  color: #334155;
}
.trial-upgrade-list li {
  margin-bottom: .25rem;
  font-size: var(--fs-sub);
}
.trial-upgrade-list li:last-child {
  margin-bottom: 0;
}
.trial-upgrade-btn {
  width: 100%;
}
html.dark-mode .trial-upgrade-card {
  box-shadow: var(--el-2);
}
html.dark-mode .trial-upgrade-title {
  color: #e2e8f0;
}
html.dark-mode .trial-upgrade-list {
  color: #94a3b8;
}
.about-user-status-text {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--qr-text);
}
html.dark-mode .about-user-status-text {
  color: #e2e8f0;
}
.ai-coach-locked .secondary-text {
  margin-bottom: .75rem;
}
.ai-coach-unlock-btn {
  max-width: 280px;
}
.ai-coach-body {
  min-height: 3rem;
}
.ai-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--qr-border);
  border-top-color: var(--qr-accent);
  border-radius: 50%;
  animation: aiSpin calc(var(--qr-dur-slow) * 2) linear infinite;
  flex-shrink: 0;
}
.ai-spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aiSpin calc(var(--qr-dur-slow) * 2) linear infinite;
  vertical-align: middle;
  margin-right: .25rem;
}
@keyframes aiSpin {
  to { transform: rotate(360deg); }
}
html.dark-mode .ai-spinner {
  border-color: #334155;
  border-top-color: #60a5fa;
}

.wrong-answer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  border: none !important;
  border-left: 3px solid var(--qr-danger-border) !important;
  border-radius: var(--r-sm);
  padding: .75rem 1rem !important;
  background: rgba(239,68,68,.05) !important;
  text-align: center;
  width: 100%;
  max-width: 22rem;
  box-sizing: border-box;
  flex-shrink: 0;
  font-size: inherit;
  min-height: auto;
}
html.dark-mode .wrong-answer-card {
  border-left-color: #f87171 !important;
  background: rgba(239,68,68,.1) !important;
}
/* AI Explain button — tokenized to --qr-info (ADR-087). Classic/Dark values equal the previous hardcoded #8b5cf6/
   #a78bfa exactly (pixel-identical); Playful now inherits its own deep-violet info tone automatically. */
.drill-explain-btn {
  display: block;
  margin-top: .75rem;
  padding: .5rem 1.25rem;
  font-size: var(--fs-sub);
  font-weight: 600;
  border: 1.5px solid var(--qr-info);
  border-radius: var(--r-sm);
  background: none;
  color: var(--qr-info);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out);
}
.drill-explain-btn:active {
  background: var(--qr-info);
  color: var(--qr-on-accent);
}
html.dark-mode .drill-explain-btn:active {
  color: #1e1b4b;   /* dark ink on the light-lavender active fill */
}

/* ── Teaching correction panel (ADR-086 P4) — token-driven, one design across all themes ── */
.drill-verdict { font-size: var(--fs-body); font-weight: 800; letter-spacing: .01em; }
.drill-verdict-ok { color: var(--qr-success-fg); }
.drill-verdict-wrong { color: var(--qr-danger); }
/* Timeout is a pacing verdict, not a knowledge verdict — amber, not failure-red (ADR-091) */
.drill-verdict-wrong.drill-verdict-timeout { color: var(--qr-warn); }
/* Quiet in-session momentum chip beside "✓ Correct" from 3-in-a-row */
.drill-streak-chip {
  display: inline-block;
  margin-left: .5rem;
  padding: .125rem .5rem;
  border-radius: var(--r-full);
  background: var(--qr-success-bg);
  color: var(--qr-success-fg);
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .02em;
  vertical-align: middle;
}
.drill-teach {
  display: flex; flex-direction: column; align-items: stretch; gap: .5rem;
  width: 100%; max-width: 24rem; margin: 0 auto; text-align: left;
}
.drill-teach-answer {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .5rem; border-radius: var(--r-md);
  background: var(--qr-success-bg); border: 1px solid var(--qr-success-border);
}
.drill-teach-answer-lbl { font-size: var(--fs-caption); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--qr-text-dim); }
.drill-teach-answer-val { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-success-fg); word-break: break-word; }
.drill-teach-why {
  padding: .5rem .5rem; border-radius: var(--r-md); text-align: left;
  background: var(--qr-surface-2); border-left: 3px solid var(--qr-accent);
}
.drill-teach-why-head { font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--qr-accent); margin-bottom: .25rem; }
.drill-teach-steps { display: flex; flex-direction: column; gap: .25rem; }
.drill-teach-step { font-size: var(--fs-sub); line-height: 1.45; color: var(--qr-text); position: relative; padding-left: .75rem; }
.drill-teach-step::before { content: ''; position: absolute; left: .1rem; top: .55em; width: .35rem; height: .35rem; border-radius: 50%; background: var(--qr-accent); }
.drill-teach-step:only-child { padding-left: 0; }
.drill-teach-step:only-child::before { display: none; }
.drill-teach-concept {
  align-self: flex-start; margin-top: .5rem; font: inherit; font-size: var(--fs-caption); font-weight: 600;
  padding: .25rem .75rem; border-radius: var(--r-full); cursor: pointer;
  color: var(--qr-accent); background: transparent; border: 1px solid var(--qr-border-strong);
}
.drill-teach-concept:active { transform: scale(var(--qr-press-sm)); background: var(--qr-surface-2); }

/* ── Premium start screen (ADR-086 P5) — token-driven, one design across all themes ── */
.drill-start { gap: 0; }
.drill-start-badge {
  width: 4rem; height: 4rem; margin: 0 auto .75rem; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-d1); line-height: 1; border-radius: var(--qr-card-radius-sm);
  background: var(--qr-surface-2); border: 1px solid var(--qr-border);
  box-shadow: var(--el-2);
  animation: drillStartPop var(--qr-dur-slow, var(--qr-dur-slow)) var(--qr-ease) both;
}
.drill-start-title { margin: 0 0 .25rem; font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.01em; color: var(--qr-text); }
.drill-start-sub { margin: 0 auto 1.25rem; max-width: 22rem; font-size: var(--fs-sub); line-height: 1.45; color: var(--qr-text-dim); }
.drill-start-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; max-width: 22rem; margin: 0 auto 1.25rem;
}
.drill-start-stat {
  display: flex; flex-direction: column; align-items: center; gap: .125rem;
  padding: .75rem .5rem; border-radius: var(--r-lg);
  background: var(--qr-surface-2); border: 1px solid var(--qr-border);
}
.drill-start-stat .ds-ico { font-size: var(--fs-h3); line-height: 1; }
.drill-start-stat .ds-val { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); }
.drill-start-stat .ds-lbl { font-size: var(--fs-micro); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--qr-text-mut); }
.drill-start-cta { width: 100%; max-width: 22rem; margin: 0 auto; }
.drill-start-back { width: 100%; max-width: 22rem; margin: .5rem auto 0; }
@keyframes drillStartPop { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }

/* ── Honest loading state (ADR-086 P5) — subtle motion, no fake progress ── */
.drill-loading { gap: 0; }
.drill-loading-orb { display: flex; gap: .5rem; justify-content: center; margin: 0 auto 1rem; }
.drill-loading-orb span {
  width: .8rem; height: .8rem; border-radius: 50%; background: var(--qr-accent);
  animation: drillLoadBounce calc(var(--qr-dur-slow) * 2.75) var(--qr-ease) infinite;
}
.drill-loading-orb span:nth-child(2) { animation-delay: calc(var(--qr-dur-fast) * 1.33333); }
.drill-loading-orb span:nth-child(3) { animation-delay: calc(var(--qr-dur-fast) * 2.66667); }
.drill-loading-title { margin: 0 0 .25rem; font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); }
.drill-loading-sub { margin: 0; font-size: var(--fs-sub); color: var(--qr-text-dim); }
@keyframes drillLoadBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-.5rem); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .drill-start-badge { animation: none; }
  .drill-loading-orb span { animation-duration: calc(var(--qr-dur-pulse) * 11 / 6); }
}

/* ── Completion dashboard (ADR-086 P6) — token-driven, one design across all themes ── */
.drill-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 0 auto 1rem; }
.drill-chip {
  display: inline-flex; align-items: center; font-size: var(--fs-caption); font-weight: 700; line-height: 1;
  padding: .25rem .5rem; border-radius: var(--r-full); border: 1px solid var(--qr-border);
  background: var(--qr-surface-2); color: var(--qr-text);
}
.drill-chip.chip-up { color: var(--qr-success-fg); background: var(--qr-success-bg); border-color: var(--qr-success-border); }
.drill-chip.chip-down { color: var(--qr-danger); background: var(--qr-danger-bg); border-color: var(--qr-danger-border); }
.drill-topics { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; max-width: 24rem; margin: 0 auto 1rem; }
.drill-topic {
  display: flex; align-items: flex-start; gap: .5rem; text-align: left;
  min-height: 5.1rem; padding: .75rem .5rem; border-radius: var(--r-lg);
  border: 1px solid var(--qr-border); background: var(--qr-surface-2);
}
.drill-topic .dt-ico { font-size: var(--fs-h1); line-height: 1.2; flex: 0 0 auto; }
.drill-topic .dt-body { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.drill-topic .dt-lbl { font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--qr-text-mut); }
/* Topic names can be long ("Time, Speed & Distance", "Profit, Loss & Discount"): wrap to two lines and clamp
   rather than clip with an ellipsis, so the full label reads and the card never overflows (ADR-089). */
.drill-topic .dt-name {
  font-size: var(--fs-sub); font-weight: 800; color: var(--qr-text); line-height: 1.2;
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.drill-topic .dt-acc { font-size: var(--fs-caption); font-weight: 600; color: var(--qr-text-dim); }
.drill-topic-strong { border-left: 3px solid var(--qr-success-border); }
.drill-topic-weak { border-left: 3px solid var(--qr-warn); }
/* Very narrow phones (≤360px): a 2-column split leaves each card too tight for a wrapped topic name — stack them. */
@media (max-width: 360px) { .drill-topics { grid-template-columns: 1fr; } }
.drill-next { display: flex; flex-direction: column; gap: .5rem; width: 100%; max-width: 24rem; margin: .25rem auto 0; }
.drill-next-primary { width: 100%; }
.drill-next-secondary { width: 100%; margin: 0; }

/* ── Pause / resume + graceful failure (ADR-086 P7) — token-driven across all themes ── */
/* 44px target with a visible affordance circle (ADR-091) */
.session-pause,
.drill-pause-btn {
  position: absolute; top: 10px; left: 10px; width: 2.75rem; height: 2.75rem;
  border: none; border-radius: 50%; background: var(--qr-surface-2); color: var(--qr-text-dim);
  font-size: var(--fs-h3); line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; z-index: var(--z-session-bg); transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.session-pause:active,
.drill-pause-btn:active { background: rgba(0,0,0,.12); color: var(--qr-text); }
html.dark-mode .session-pause:active,
html.dark-mode .drill-pause-btn:active { background: rgba(255,255,255,.15); color: var(--qr-text); }
body.drill-session-active .drill-pause-btn {
  position: fixed; top: calc(.75rem + env(safe-area-inset-top, 0px)); left: .75rem; z-index: var(--z-nav);
}

/* In-drill "Report" button (ADR-096) — sits just right of Pause, same 44px affordance. */
.session-report,
.drill-report-btn {
  position: absolute; top: 10px; left: calc(10px + 2.75rem + .4rem); width: 2.75rem; height: 2.75rem;
  border: none; border-radius: 50%; background: var(--qr-surface-2); color: var(--qr-text-dim);
  font-size: var(--fs-h3); line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; z-index: var(--z-session-bg); transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.session-report:active,
.drill-report-btn:active { background: rgba(0,0,0,.12); color: var(--qr-text); }
html.dark-mode .session-report:active,
html.dark-mode .drill-report-btn:active { background: rgba(255,255,255,.15); color: var(--qr-text); }
body.drill-session-active .drill-report-btn {
  position: fixed; top: calc(.75rem + env(safe-area-inset-top, 0px)); left: calc(.75rem + 2.75rem + .4rem); z-index: var(--z-nav);
}
/* ADR-158 — while the pause screen is up, the two body-level session surfaces must not paint over it.
   The overlay lives inside #drillContainer, which `body.drill-session-active #drillContainer` makes a stacking
   context (position:fixed + z-index), so the overlay's z-index:200 is confined below the body-level
   #customNumpad (99) and .drill-actions (98) no matter how high it goes. Hiding them is the presentational
   half of the fix; the pointer/keyboard guards in js/ui/numpad.js and drill-engine's submit() are the
   correctness half, and they stand alone if this rule is ever overridden. */
body.drill-paused #customNumpad,
body.drill-paused .drill-actions { display: none; }

.drill-pause-overlay {
  position: fixed; inset: 0; z-index: var(--z-sticky); display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: rgba(15,23,42,.55); backdrop-filter: var(--glass-scrim); -webkit-backdrop-filter: var(--glass-scrim);
  animation: drillFadeIn var(--qr-dur, var(--qr-dur)) var(--qr-ease, var(--qr-ease-out)) both;
}
.drill-pause-card {
  width: 100%; max-width: 20rem; text-align: center; padding: 1.75rem 1.25rem; border-radius: var(--qr-card-radius-sm);
  background: var(--qr-surface-solid); border: 1px solid var(--qr-border); box-shadow: var(--el-3);
}
.drill-pause-icon { font-size: var(--fs-icon); line-height: 1; margin-bottom: .5rem; }
.drill-pause-title { margin: 0 0 .25rem; font-size: var(--fs-h1); font-weight: 800; color: var(--qr-text); }
.drill-pause-sub { margin: 0 0 1.25rem; font-size: var(--fs-sub); color: var(--qr-text-dim); }
.drill-pause-card .btn-primary { width: 100%; margin: 0; }
.drill-error-icon { font-size: var(--fs-icon); line-height: 1; margin-bottom: .5rem; }
@keyframes drillFadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drill-pause-overlay { animation: none; } }

/* .sp-unlock-btn / .sp-open-btn cap the width of the Home study-plan CTA buttons (home-bento-action-btn). */
.sp-unlock-btn,
.sp-open-btn {
  max-width: 280px;
}

/* Task 14: Reduced motion for view transitions */
body.reduced-motion .spa-view-active {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .spa-view-active {
    animation: none !important;
  }
  .guide-animate-section {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---- Auto-explain tip (wrong answer inline) ---- */
.auto-explain-tip {
  font-size: var(--fs-caption);
  font-weight: 500;
  color: var(--qr-accent-strong);
  background: rgba(37,99,235,.07);
  border-left: 3px solid var(--qr-accent);
  border-radius: var(--r-sm);
  padding: .5rem .5rem;
  margin-top: .5rem;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: break-word;
}
.auto-explain-locked {
  color: #6b7280;
  background: rgba(107,114,128,.07);
  border-left-color: #9ca3af;
}
.auto-explain-locked .auto-explain-unlock {
  color: var(--qr-info-fg);
  text-decoration: underline;
  cursor: pointer;
}
html.dark-mode .auto-explain-tip {
  color: #93c5fd;
  background: var(--qr-veil-accent-12);
  border-left-color: #60a5fa;
}
html.dark-mode .auto-explain-locked {
  color: #9ca3af;
  background: rgba(107,114,128,.1);
  border-left-color: #6b7280;
}
html.dark-mode .auto-explain-locked .auto-explain-unlock {
  color: #a78bfa;
}
@keyframes newBestPop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* ---- Percentile delta ---- */
.percentile-delta {
  display: block;
  font-size: var(--fs-caption);
  font-weight: 600;
  margin-top: .25rem;
}
.delta-up   { color: var(--qr-success); }
.delta-down { color: var(--qr-danger); }
html.dark-mode .delta-up   { color: #4ade80; }
/* ---- Share button on results (premium gradient accent) ----
   ADR-087: consolidated from two rules (a base outlined style + a later `!important` gradient override that made the
   base background/color/hover/dark-bg declarations dead-on-arrival) into this single coherent rule — renders identically. */
.results-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  border: 1.5px solid var(--qr-accent);
  border-radius: var(--r-md);
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  font-size: var(--fs-body);
  font-weight: 700;
  box-shadow: var(--qr-glow-accent);
  cursor: pointer;
  transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
.results-share-btn:active { box-shadow: var(--qr-glow-accent); }
html.dark-mode .results-share-btn { border-color: #60a5fa; }

/* ---- Session insight card (results screen) ---- */
.session-insight-card {
  font-size: var(--fs-sub);
  font-weight: 500;
  color: #1e3a5f;
  background: rgba(37,99,235,.07);
  border-left: 3px solid var(--qr-accent);
  border-radius: var(--r-sm);
  padding: .5rem .75rem;
  margin: .5rem auto .75rem;
  width: 100%;
  max-width: 22rem;
  box-sizing: border-box;
  text-align: left;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}
html.dark-mode .session-insight-card {
  color: #bfdbfe;
  background: var(--qr-veil-accent-12);
  border-left-color: #60a5fa;
}

/* ---- 7-day accuracy bar chart — Premium Redesign ---- */
.sparkline-chart-wrap {
  display: flex;
  justify-content: center;
  padding: .25rem 0;
}
.stats-sparkline {
  display: block;
  overflow: visible;
  max-width: 320px;
  width: 100%;
}
.sparkline-bar {
  animation: sparklineGrow var(--qr-dur-slow) var(--qr-spring) both;
  transform-box: fill-box;
  transform-origin: bottom center;
}
@keyframes sparklineGrow {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sparkline-bar { animation: none !important; }
}
body.reduced-motion .sparkline-bar { animation: none !important; }
.stats-sparkline .sparkline-val {
  font-size: 9px;
  font-family: inherit;
  font-weight: 600;
  fill: currentColor;
  opacity: .65;
  letter-spacing: -.01em;
}
.stats-sparkline .sparkline-day {
  font-size: 9px;
  font-family: inherit;
  font-weight: 500;
  fill: currentColor;
  opacity: .45;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sparkline-trend-label {
  font-size: var(--fs-caption);
  text-align: center;
  margin-top: .5rem;
  color: #475569;
  font-weight: 600;
  padding: .25rem .75rem;
  border-radius: var(--r-lg);
  display: inline-block;
  width: auto;
  margin-left: auto;
  margin-right: auto;
  letter-spacing: .02em;
}
/* Center the trend pill */
#statsSparkline { text-align: center; }
.sparkline-trend-positive {
  background: rgba(22,163,74,.08);
  color: var(--qr-success);
}
.sparkline-trend-negative {
  background: rgba(220,38,38,.08);
  color: var(--qr-danger);
}
.sparkline-trend-steady {
  background: rgba(100,116,139,.08);
  color: var(--qr-text-dim);
}
html.dark-mode .sparkline-trend-label { color: #94a3b8; }
html.dark-mode .sparkline-trend-positive {
  background: rgba(52,211,153,.12);
  color: #34d399;
}
html.dark-mode .sparkline-trend-negative {
  background: rgba(248,113,113,.12);
  color: #f87171;
}
html.dark-mode .sparkline-trend-steady {
  background: rgba(148,163,184,.1);
  color: #94a3b8;
}
html.dark-mode .stats-sparkline .sparkline-val,
html.dark-mode .stats-sparkline .sparkline-day {
  fill: #e2e8f0;
}

/* ======== Native-App Immersion Hardening ======== */

/* Prevent overscroll glow/bounce on scroll containers in PWA mode */
html.pwa-mode .spa-view,
html.pwa-mode .container {
  overscroll-behavior-y: contain;
}

/* Smoother view transition for native feel */
@keyframes viewSlideInNative {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
html.pwa-mode .spa-view-active {
  animation: viewSlideInNative var(--qr-dur) var(--qr-ease-out);
}

/* Tighter header density for app-like feel */
html.pwa-mode header {
  padding: 1.25rem 0 .5rem;
}

/* Ensure modal overlays prevent background scroll */
.modal-overlay,
.info-modal-overlay,
.paywall-overlay,
.onboarding-overlay {
  overscroll-behavior: none;
  touch-action: none;
}
.modal-overlay .modal-content,
.info-modal-overlay .info-modal-content,
.paywall-overlay .paywall-card,
.onboarding-overlay .onboarding-card {
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

/* Info modal scrollable area isolation */
.info-modal-scroll {
  overscroll-behavior-y: contain;
}

/* ======== Math Duel V2 — solving header · presence chip · countdown · active card (ADR-033, §10A) ======== */
/* ADR-063: polished multiplayer header — opponent identity LEFT (~2/3, flexes + truncates), Exit compact RIGHT.
   The left zone is a structured avatar+info slot so an avatar/premium/league/streak badge can drop in later. */
.duel-solve-header { display: flex; align-items: center; gap: .75rem; max-width: 520px; margin: 0 auto .25rem; padding: .25rem .25rem; }
.duel-opp { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .5rem; }
.duel-opp-avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #eef2f7; color: #475569; font-size: var(--fs-h3); font-weight: 800; line-height: 1; }
.duel-opp-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.duel-opp-name { font-size: var(--fs-body); font-weight: 700; color: #1e293b; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-opp-status { display: inline-flex; align-items: center; gap: .25rem; font-size: var(--fs-caption); font-weight: 600; color: var(--qr-text-dim); }
.duel-exit-btn { flex: 0 0 auto; min-height: 36px; padding: .5rem .75rem; border: none; border-radius: var(--r-md); cursor: pointer;
  background: var(--qr-surface-2); color: #334155; font-size: var(--fs-sub); font-weight: 700; box-shadow: var(--el-inset);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: background var(--qr-dur-fast) var(--qr-ease-out); }
.duel-exit-btn:active { background: var(--qr-surface-3); box-shadow: var(--el-inset); }
html.dark-mode .duel-opp-avatar { background: rgba(124,58,237,.18); color: #c4b5fd; }
html.dark-mode .duel-opp-name { color: #e2e8f0; }
html.dark-mode .duel-opp-status { color: #94a3b8; }
html.dark-mode .duel-exit-btn { background: rgba(248,113,113,.12); color: #f87171; box-shadow: var(--qr-ring-danger); }
html.dark-mode .duel-exit-btn:active { background: rgba(248,113,113,.2); }
.duel-opp-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.duel-opp-dot.is-solving { background: var(--qr-warn); }   /* amber = solving */
.duel-opp-dot.is-finished { background: #10b981; }  /* green = finished */
.duel-countdown-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2,6,23,.92); z-index: var(--z-dialog); backdrop-filter: var(--glass-scrim); -webkit-backdrop-filter: var(--glass-scrim); }
.duel-countdown-num { font-size: 6rem; font-weight: 900; color: var(--qr-on-accent); animation: duelCountdownPop var(--qr-dur-slow) var(--qr-spring); }
@keyframes duelCountdownPop { 0% { transform: scale(1.9); opacity: 0; } 55% { transform: scale(.95); opacity: 1; } 100% { transform: scale(1); } }

/* Duel solving REUSES the Practice fixed-shell (ADR-011/033). The drill engine renders into #duelActive (the
   duel's visible container — #drillContainer lives in the hidden practice view and a position:fixed child of a
   display:none ancestor won't paint), so mirror ONLY the 6 container-keyed overlay rules here. Every other shell
   rule keys on classes (.drill-actions/.drill-question-scroll/.custom-numpad) and already applies. */
/* ADR-087: tokenized to var(--qr-bg) — collapses the four per-theme literals (each == that theme's --qr-bg). */
body.drill-session-active #duelActive { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: var(--z-session-bg); background: var(--qr-bg); }
body.drill-session-active #duelActive > .card {
  /* top pushed down (was 3rem) so the redesigned header reads as a proper band with breathing room above the
     card — this also trims the card's height-from-top, which felt squeezed against the header (ADR-063 polish). */
  position: fixed; top: 3.9rem; left: .75rem; right: .75rem;
  /* mirror the Practice card bottom EXACTLY (incl. --drill-submit-gap) so the card → Submit → numpad rhythm is
     identical across Practice/Focus/Drills/Tests/Duels (the §10A unified answering screen). */
  bottom: calc(var(--drill-numpad-h) + var(--drill-submit-gap) + var(--drill-actions-h) + var(--drill-card-gap) + var(--drill-safe-b));
  display: flex; flex-direction: column; overflow: hidden; margin: 0; z-index: var(--z-session-card);
}
body.drill-session-active #duelActive > .card:active { transform: none; }
/* Duel multiplayer header: fixed in the top bar (where Practice's exit button sits), above the card. */
body.drill-session-active .duel-solve-header { position: fixed; top: .55rem; left: .75rem; right: .75rem; z-index: var(--z-nav); max-width: none; margin: 0; padding: .25rem .25rem; }

/* (removed dead .mode-card-duel purple block — the Home duel card is .home-bento-duel; setup is now a §10A modal) */

/* ======== Math Duel — Setup Screen (legacy #duelSetup full-screen; setup now renders as a bottom-sheet modal) ======== */

#duelSetup {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  padding: 1rem;
}
.duel-mode-btn.active {
  border-color: var(--qr-info-fg);
  background: rgba(124,58,237,.06);
  color: #6d28d9;
}
html.dark-mode .duel-mode-btn.active {
  border-color: #7c3aed;
  background: rgba(124,58,237,.15);
  color: #a78bfa;
}

/* ======== Math Duel — Waiting Room ======== */

#duelWaiting {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--qr-bg);
  padding: 1.5rem;
}
html.dark-mode #duelWaiting {
  background: #0f172a;
}
.duel-player-slot.filled {
  border-color: var(--qr-info-fg);
  background: rgba(124,58,237,.05);
}
html.dark-mode .duel-player-slot.filled {
  border-color: #7c3aed;
  background: rgba(124,58,237,.12);
}
.duel-player-slot.empty {
  border-style: dashed;
  opacity: .6;
}
.duel-waiting-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--qr-info-fg);
  animation: duelPulse var(--qr-dur-pulse) var(--qr-ease) infinite;
}
.duel-waiting-indicator .dot:nth-child(2) { animation-delay: calc(var(--qr-dur-fast) * 1.66667); }
.duel-waiting-indicator .dot:nth-child(3) { animation-delay: calc(var(--qr-dur-fast) * 3.33333); }

/* Share/invite button */
.duel-share-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.5rem;
  border: none;
  border-radius: var(--r-md);
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  font-size: var(--fs-sub);
  font-weight: 600;
  cursor: pointer;
  margin: .75rem 0;
  transition: transform var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
}
.duel-share-btn:active { transform: scale(var(--qr-press-sm)); }
@keyframes duelStartPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.3); }
  50% { box-shadow: 0 0 0 8px rgba(22,163,74,0); }
}

/* ======== Math Duel — Active Screen ======== */

#duelActive {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  background: var(--qr-bg);
  padding: 0;
}
html.dark-mode #duelActive {
  background: #0f172a;
}

/* ======== Math Duel — Results host ======== */
/* #duelResults is the fixed full-screen container the §10A result card (.duel-result-card) renders INTO. The V1
   inner layout (.duel-results-card / .duel-result-title / .duel-result-comparison / .duel-result-player / celebrate /
   .mode-card-duel) was removed — it was dead (0 JS refs) and its stray `.duel-result-actions { flex-direction:column }`
   was silently stacking the live Share/Finish row. The card's own styling lives in the CENTERED block below. */
#duelResults {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--qr-bg);
  padding: 1.5rem;
  overflow-y: auto;                                  /* tall content (review list) scrolls instead of clipping */
  padding-top: max(1.5rem, env(safe-area-inset-top, 0));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0));
}
html.dark-mode #duelResults { background: #0f172a; }
/* ADR-064: inside the centered results overlay the screen wrapper must NOT stretch full-height or carry the
   bottom-nav padding — that pushed the card high on short devices. Let it size to content + center naturally. */
#duelResults .duel-screen { min-height: 0; padding: 0; margin: auto; width: 100%; }

/* ADR-064: premium finish transition overlay */
.duel-calc-overlay { position: fixed; inset: 0; z-index: var(--z-toast); display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, .92); backdrop-filter: var(--glass-scrim); -webkit-backdrop-filter: var(--glass-scrim); animation: duelCalcIn var(--qr-dur) var(--qr-ease-out); }
.duel-calc-overlay.is-out { animation: duelCalcOut var(--qr-dur) var(--qr-ease-out) forwards; }
@keyframes duelCalcIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes duelCalcOut { from { opacity: 1; } to { opacity: 0; } }
.duel-calc-card { display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--qr-on-accent); padding: 1.5rem; }
.duel-calc-spinner { display: flex; gap: .5rem; }
.duel-calc-spinner > span { width: 12px; height: 12px; border-radius: 50%; background: #60a5fa; animation: duelCalcBounce calc(var(--qr-dur-slow) * 2.5) infinite var(--qr-ease) both; }
.duel-calc-spinner > span:nth-child(1) { animation-delay: -.calc(var(--qr-dur-fast) * 266.667); }
.duel-calc-spinner > span:nth-child(2) { animation-delay: -.calc(var(--qr-dur-fast) * 133.333); }
@keyframes duelCalcBounce { 0%, 80%, 100% { transform: scale(.5); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.duel-calc-text { font-size: var(--fs-h3); font-weight: 700; letter-spacing: .01em; min-height: 1.4em; }
.duel-calc-text.is-swap { animation: duelCalcSwap var(--qr-dur-slow) var(--qr-ease-out); }
@keyframes duelCalcSwap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ADR-064: results reveal entrance */
.duel-reveal { animation: duelReveal var(--qr-dur-slow) var(--qr-spring) both; }
@keyframes duelReveal { 0% { opacity: 0; transform: translateY(14px) scale(.96); } 100% { opacity: 1; transform: translateY(0) scale(1); } }

/* ADR-064: results actions — Review primary-width, Share/Finish in a row */
.duel-result-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.duel-review-btn { width: 100%; }
.duel-actions-row { display: flex; gap: .5rem; }
.duel-actions-row > button { flex: 1 1 0; }

/* ADR-064: post-match review screen */
.duel-review-card { padding: 1rem 1rem 1.25rem; text-align: left; width: 100%; max-width: 480px; }
.duel-review-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.duel-review-back { flex: 0 0 auto; border: none; background: var(--qr-surface-2); color: #334155; font-weight: 700; font-size: var(--fs-sub);
  padding: .5rem .75rem; border-radius: var(--r-md); cursor: pointer; }
html.dark-mode .duel-review-back { background: var(--qr-veil-w-8); color: #e2e8f0; }
.duel-review-titlewrap { flex: 1 1 auto; }
.duel-review-title { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); }
html.dark-mode .duel-review-title { color: #f1f5f9; }
.duel-review-sub { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }
.duel-review-list { display: flex; flex-direction: column; gap: .75rem; }
.duel-review-row { border: 1px solid var(--qr-veil-ink-8); border-left: 4px solid var(--qr-border-strong); border-radius: var(--r-lg); padding: .75rem .75rem; background: var(--qr-surface-solid); }
html.dark-mode .duel-review-row { background: rgba(255, 255, 255, .03); border-color: var(--qr-veil-w-8); }
.duel-review-row.is-correct { border-left-color: #10b981; }
.duel-review-row.is-wrong { border-left-color: var(--qr-danger-border); }
.duel-review-row.is-skipped { border-left-color: var(--qr-warn); }
.drv-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.drv-qn { font-weight: 800; font-size: var(--fs-caption); color: #475569; }
.drv-cat { font-size: var(--fs-caption); color: #94a3b8; font-weight: 600; flex: 1 1 auto; }
.drv-badge { font-size: var(--fs-micro); font-weight: 800; padding: .125rem .5rem; border-radius: var(--r-full); white-space: nowrap; }
.drv-badge.is-ok { color: #047857; background: rgba(16, 185, 129, .14); }
.drv-badge.is-no { color: #b91c1c; background: rgba(239, 68, 68, .12); }
.drv-badge.is-skip { color: #b45309; background: rgba(245, 158, 11, .14); }
.drv-q { font-size: var(--fs-body); color: #1e293b; font-weight: 600; margin-bottom: .5rem; }
html.dark-mode .drv-q { color: #e2e8f0; }
.drv-answers { display: flex; flex-wrap: wrap; gap: .5rem .75rem; margin-bottom: .5rem; }
.drv-yours, .drv-correct { display: flex; flex-direction: column; }
.drv-k { font-size: var(--fs-micro); color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.drv-v { font-size: var(--fs-body); font-weight: 800; color: #334155; }
html.dark-mode .drv-v { color: #e2e8f0; }
.drv-correct .drv-v { color: #047857; }
html.dark-mode .drv-correct .drv-v { color: #34d399; }
.drv-explain { border: none; background: rgba(37, 99, 235, .1); color: var(--qr-accent); font-weight: 700; font-size: var(--fs-sub);
  padding: .5rem .75rem; border-radius: var(--r-md); cursor: pointer; }
html.dark-mode .drv-explain { background: rgba(96, 165, 250, .14); color: #93c5fd; }
.duel-review-loading { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2.5rem 1rem; color: var(--qr-text-dim); }
.duel-review-loading .duel-calc-spinner > span { background: var(--qr-accent); }
.duel-review-empty { color: #94a3b8; text-align: center; padding: 1.5rem; }
/* Small phones: shrink the head-to-head score so it never overflows the card. */
@media (max-width: 340px) {
  .duel-result-score { font-size: var(--fs-h1); }
}
.duel-username-status.loading {
  color: var(--qr-info-fg);
}
.duel-username-status.found {
  color: var(--qr-success);
  font-weight: 600;
}
.duel-username-status.error {
  color: var(--qr-danger);
}
.duel-username-status.warning {
  color: #d97706;
}
html.dark-mode .duel-username-status.found { color: #4ade80; }html.dark-mode .duel-username-status.warning { color: #fbbf24; }
@keyframes spin {
  to { transform: rotate(360deg); }
}
/* .duel-premium-badge visuals consolidated into the unified .qr-badge-pro rule (see PRO badge block). */

/* Premium restriction notice */
.duel-premium-notice {
  text-align: center;
  padding: 1rem;
  border-radius: var(--r-md);
  background: var(--qr-grad-wash);
  border: 1px solid rgba(124,58,237,.15);
}
.duel-player-card.filled {
  border-color: var(--qr-info-fg);
  background: rgba(124,58,237,.04);
}
html.dark-mode .duel-player-card.filled {
  border-color: #7c3aed;
  background: rgba(124,58,237,.1);
}
.duel-player-card.empty {
  border-style: dashed;
  opacity: .55;
}
.duel-player-connection-dot.online { color: var(--qr-success); }
.duel-player-connection-dot.offline { color: #94a3b8; }
html.dark-mode .duel-player-connection-dot.online { color: #4ade80; }
@keyframes dotPulseAnim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.7); }
}
@keyframes duelInviteBorderGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.duel-invite-countdown.urgent {
  color: var(--qr-danger);
  animation: duelPulse calc(var(--qr-dur-slow) * 2.5) var(--qr-ease) infinite;
}
.duel-exit-btn {
  padding: .25rem .5rem;
  border: 1.5px solid #fca5a5;
  border-radius: var(--r-sm);
  background: rgba(220,38,38,.06);
  color: var(--qr-danger);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
.duel-exit-btn:active { background: rgba(220,38,38,.15); }
html.dark-mode .duel-exit-btn {
  border-color: rgba(248,113,113,.3);
  background: rgba(220,38,38,.1);
  color: #f87171;
}

/* ======== Share Preview Modal ======== */

.share-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-boot-top);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: var(--glass-scrim);
  -webkit-backdrop-filter: var(--glass-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity var(--qr-dur) var(--qr-ease-out);
}
.share-preview-overlay.share-preview-visible {
  opacity: 1;
}

.share-preview-modal {
  background: #1e293b;
  border-radius: var(--qr-card-radius-sm);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--el-3);
  border: 1px solid rgba(51, 65, 85, 0.5);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--qr-dur) var(--qr-ease-out);
}
.share-preview-visible .share-preview-modal {
  transform: translateY(0) scale(1);
}
/* FW-W1: QROverlay drives close with a .closing class — mirror the exit transition (defined after
   .share-preview-visible so it wins at equal specificity). */
.share-preview-overlay.closing { opacity: 0; }
.share-preview-overlay.closing .share-preview-modal { transform: translateY(20px) scale(.96); }

.share-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
}

.share-preview-title {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
}

.share-preview-close {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: var(--qr-veil-w-8);
  color: #94a3b8;
  font-size: var(--fs-h2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
}
.share-preview-close:active {
  background: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

.share-preview-canvas-wrap {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: center;
}

.share-preview-img {
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: var(--r-md);
  box-shadow: var(--el-3);
}

.share-preview-actions {
  display: flex;
  gap: .5rem;
  padding: .75rem 1.25rem 1.25rem;
  flex-wrap: wrap;
}

.share-action-btn {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: .75rem .5rem;
  font-size: var(--fs-sub);
  font-weight: 600;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
  background: var(--qr-veil-w-8);
  color: #e2e8f0;
}
.share-action-btn:active {
  transform: scale(var(--qr-press-sm));
}
/* ---- Universal Button System ---- */
.btn-primary, .btn-secondary, .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  padding: 1.25rem 1.25rem;
  border: none;
  border-radius: var(--r-lg);
  font-size: var(--fs-h3);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-spring), box-shadow var(--qr-dur) var(--qr-ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  gap: 0.75rem;
  line-height: 1.2;
}

.btn-primary:active, .btn-secondary:active, .btn:active {
  transform: scale(var(--qr-press-sm));
}

.btn-primary, .btn.accent {
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  box-shadow: var(--qr-glow-accent);
}

.btn-primary:active, .btn.accent:active {
  box-shadow: var(--qr-glow-accent);
}

/* UI Phase 1 §6.3/W4: was hardcoded #f1f5f9/#334155 — theme-blind (a LIGHT button on the dark UI).
   Now token-driven so the flagship secondary adapts across all four themes. */
.btn-secondary, .btn {
  background: var(--qr-surface-2);
  color: var(--qr-text);
  box-shadow: var(--el-inset);
}

.btn-secondary:active, .btn:active {
  background: var(--qr-surface-3);
  box-shadow: var(--el-inset);
}

.share-action-btn.accent:active {
  background: var(--qr-grad-cta);
}
.share-action-regen {
  flex: 0 0 auto;
  min-width: 100px;
}

/* (ADR-087: the premium-gradient .results-share-btn override that lived here was merged into the single base rule
   near the results styles — removed to eliminate the duplicate + its !important.) */

/* ==================== AUTH SCREEN ==================== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: calc(var(--vh, 1vh) * 100);
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--qr-grad-wash);
  z-index: var(--z-boot-4);
  overflow: hidden;
}

html.dark-mode .auth-screen {
  background: #0f172a;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  max-height: calc(var(--vh, 1vh) * 100 - 40px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--r-xl);
  padding: 32px 24px;
  position: relative;
  z-index: var(--z-above);
  backdrop-filter: var(--glass-chrome);
  -webkit-backdrop-filter: var(--glass-chrome);
  box-shadow: var(--el-1);
}

.auth-card::-webkit-scrollbar {
  display: none;
}

html.dark-mode .auth-card {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--qr-veil-w-6);
  box-shadow: var(--el-3);
}

.auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: block;
  object-fit: contain;
}

.auth-title {
  font-size: var(--fs-h1);
  font-weight: 800;
  text-align: center;
  margin-bottom: 2px;
  color: var(--qr-text);
  letter-spacing: -0.02em;
}

html.dark-mode .auth-title {
  color: #f1f5f9;
}

.auth-subtitle {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  text-align: center;
  margin-bottom: 20px;
}

html.dark-mode .auth-subtitle {
  color: #94a3b8;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  background: var(--qr-surface-2);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: 20px;
  box-shadow: var(--el-inset);
}

html.dark-mode .auth-tabs {
  background: rgba(17, 24, 39, 0.6);
  box-shadow: none;
}

.auth-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--qr-text-dim);
  font-weight: 600;
  font-size: var(--fs-caption);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--qr-dur) var(--qr-spring);
  min-height: 40px;
}

html.dark-mode .auth-tab {
  color: #94a3b8;
}

.auth-tab.active {
  background: var(--qr-surface-solid);
  color: var(--qr-text);
  box-shadow: var(--el-1);
}

html.dark-mode .auth-tab.active {
  background: #2563eb;
  color: #fff;
  box-shadow: var(--qr-glow-accent);
}

.auth-field {
  margin-bottom: 12px;
}

.auth-label {
  display: block;
  font-size: var(--fs-micro);
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

html.dark-mode .auth-label {
  color: #94a3b8;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: color var(--qr-dur) var(--qr-ease-out), background var(--qr-dur) var(--qr-ease-out);
  min-height: 36px;
  min-width: 36px;
  touch-action: manipulation;
}

.password-toggle-btn:hover {
  color: var(--qr-text-dim);
  background: rgba(0,0,0,0.04);
}

html.dark-mode .password-toggle-btn:hover {
  color: #cbd5e1;
  background: var(--qr-veil-w-5);
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--qr-surface-solid);
  border: 1px solid var(--qr-border);
  border-radius: var(--r-md);
  color: var(--qr-text);
  font-size: var(--fs-body);
  outline: none;
  transition: all var(--qr-dur) var(--qr-ease);
  min-height: 48px;
  box-shadow: var(--el-1);
}

html.dark-mode .auth-input {
  background: rgba(30, 37, 54, 0.8);
  border-color: var(--qr-veil-w-10);
  color: #f1f5f9;
}

.password-wrapper .auth-input {
  padding-right: 48px;
}

.auth-input:focus {
  border-color: #3b82f6;
  box-shadow: var(--qr-focus-ring);
}

html.dark-mode .auth-input:focus {
  box-shadow: var(--qr-focus-ring);
}

.auth-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

html.dark-mode .auth-input::placeholder {
  color: #475569;
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--qr-danger);
  padding: 16px 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-sub);
  margin-bottom: 20px;
  display: none;
}

html.dark-mode .auth-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.auth-btn {
  width: 100%;
  padding: 16px 12px;
  background: var(--qr-grad-cta);
  border: none;
  border-radius: var(--r-md);
  color: var(--qr-on-accent);
  font-size: var(--fs-body);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--qr-dur) var(--qr-ease);
  min-height: 48px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--qr-glow-accent);
  letter-spacing: 0.02em;
}

/* ---- Google Sign-In ---- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .75rem 0;
  color: var(--qr-text-mut);
  font-size: var(--fs-caption);
  font-weight: 600;
  text-transform: lowercase;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--qr-border);
}
.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  min-height: 48px;
  padding: 12px;
  background: var(--qr-surface-solid);
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--r-md);
  color: var(--qr-text);
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
}
.auth-google-btn:active { transform: scale(var(--qr-press-lg)); }
.auth-google-btn:disabled { opacity: .7; cursor: progress; }
.auth-google-logo { flex-shrink: 0; }
html.dark-mode .auth-google-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }

html.dark-mode .auth-btn {
  background: var(--qr-grad-cta);
}

/* Forgot-password link (ADR-041) */
.auth-forgot-btn {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--qr-accent);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}
.auth-forgot-btn:hover { text-decoration: underline; }
.auth-forgot-btn:disabled { opacity: 0.6; cursor: default; }
html.dark-mode .auth-forgot-btn { color: #60a5fa; }

.auth-btn:active {
  transform: scale(var(--qr-press-sm)) translateY(2px);
  box-shadow: var(--qr-glow-accent);
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-footer {
  text-align: center;
  font-size: var(--fs-micro);
  color: var(--qr-text-dim);
  margin-top: 16px;
  font-weight: 500;
}

html.dark-mode .auth-footer {
  color: #475569;
}

/* Coaching ID field */
.coaching-id-field .auth-input {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.coaching-helper-text {
  font-size: var(--fs-micro);
  color: #94a3b8;
  text-align: center;
  line-height: 1.5;
  margin-top: 8px;
  width: 100%;
  font-weight: 500;
}

html.dark-mode .coaching-helper-text {
  color: #94a3b8;
}

.login-field-validation {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  margin-top: 4px;
  min-height: 1.2em;
}

html.dark-mode .login-field-validation {
  color: #94a3b8;
}

.login-field-validation.error {
  color: var(--qr-danger);
}

html.dark-mode .login-field-validation.error {
  color: #fca5a5;
}

.login-field-validation.success {
  color: var(--qr-success);
}

html.dark-mode .login-field-validation.success {
  color: #6ee7b7;
}

/* ================================================================
   HOME TAB — Premium Redesign
   ================================================================ */

/* Core tokens moved to top of file */

/* ---- Hero Section ---- */
.home-hero {
  position: relative;
  padding: calc(max(env(safe-area-inset-top, 2.5rem), 2.5rem) + 1.5rem) 1.5rem 2rem;
  margin: -1.25rem -1.25rem 1.5rem;
  overflow: hidden;
  text-align: left;
  border-radius: var(--r-round-b);
  box-shadow: var(--qr-glow-accent);
}
.home-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
/* ADR-131 — the hero is a BESPOKE surface again.
   FW-W7c (05d9642, "gradients 64→10") swapped this layer's own 3-stop OPAQUE ramp
   `linear-gradient(145deg, #eff6ff 0%, #dbeafe 60%, #bfdbfe 100%)` for the generic app-wide
   `--qr-grad-wash`, which is a 12%→3% ALPHA wash. Over a white page that renders as almost-white-blue:
   the hero stopped being the centrepiece and became a faint tint. Dark mode fared worse — it lost its
   navy ramp `#0f172a → #1e3a8a → #172554` entirely and the override below was left setting the exact
   same value as the light rule, a no-op duplicate.
   The richness is restored through the hero's own wash STOPS rather than a new gradient literal, so the
   10/10 gradient ceiling is untouched. Each theme/appearance declares its own ramp; the shared
   --qr-grad-wash keeps serving its other consumers unchanged. */
.home-hero-bg-layer1 {
  position: absolute;
  inset: 0;
  background: var(--qr-grad-wash);
}
.home-hero {
  /* The two gradients are RE-DECLARED here, not just their stops. A custom property's `var()`s are
     substituted on the element that DECLARES it, and the resolved string is what inherits — so the
     `:root` copies of these already baked in `:root`'s stops before ever reaching the hero. Overriding
     `--qr-wash-a` on a descendant cannot reach back into them. Declaring the gradients on `.home-hero`
     moves substitution to the element where the hero's own stops live. The literals are byte-identical
     to the `:root` ones, and design-lint counts DISTINCT gradient strings, so the ceiling is untouched. */
  --qr-grad-wash: linear-gradient(135deg, var(--qr-wash-a), var(--qr-wash-b));
  --qr-grad-glow: radial-gradient(circle, var(--qr-glow-stop), transparent 62%);
  --qr-wash-a: #dbeafe;
  --qr-wash-b: #bfdbfe;
  --qr-glow-stop: rgba(59,130,246,.20);   /* the halo was 0.2 before the burn-down flattened it to .12 */
}
html.dark-mode .home-hero {
  --qr-wash-a: #1e3a8a;
  --qr-wash-b: #172554;
  --qr-glow-stop: rgba(96,165,250,.15);
}
html.theme-playful .home-hero {
  --qr-wash-a: #d9f5f0;                    /* Playful's own hero: warm paper washed with its teal */
  --qr-wash-b: #bfe9e2;
  --qr-glow-stop: rgba(45,212,191,.22);
}
html.theme-playful.dark-mode .home-hero {
  --qr-wash-a: #0f3b3a;
  --qr-wash-b: #0b2b33;
  --qr-glow-stop: rgba(45,212,191,.18);
}
/* Restoring the ramp to OPAQUE changes the backdrop the greeting sits on, so its contrast has to be
   re-tuned for the new surface — the same reasoning that set the global --qr-text-dim values (see the
   token block). Measured against each ramp's worst stop: classic light slate-500 on #bfdbfe = 3.35 and
   classic dark slate-400 on #1e3a8a = 4.04, both under AA, so classic gets one step more contrast
   (5.33 and 6.98). Playful already clears AA on its own dims (4.67 / 4.92) and is deliberately left
   alone so it keeps its warm caption. Scoped to the hero only — the global token is untouched. */
html:not(.theme-playful) .home-hero { --qr-text-dim: #475569; }
html:not(.theme-playful).dark-mode .home-hero { --qr-text-dim: #cbd5e1; }
.home-hero-bg-layer2 {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 250px;
  height: 250px;
  background: var(--qr-grad-glow);
  border-radius: 50%;
  animation: slowSpin 25s linear infinite;
  mix-blend-mode: multiply;
}
html.dark-mode .home-hero-bg-layer2 {
  /* ADR-131: the colour now comes from the hero's own --qr-glow-stop (declared per theme/appearance
     above); only the BLEND differs by appearance — multiply darkens on paper, screen lifts on navy. */
  mix-blend-mode: screen;
}
@keyframes slowSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.home-hero-content {
  position: relative;
  z-index: var(--z-above);
}

.hero-header-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.hero-profile-pic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--qr-grad-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--qr-on-accent);
  font-weight: 800;
  font-size: var(--fs-h3);
  box-shadow: var(--qr-glow-accent);
  flex-shrink: 0;
}

.hero-greeting-col {
  flex: 1;
}

.home-hero-greeting {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  font-weight: 600;
  margin: 0 0 .25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
/* ADR-131: the hardcoded dark override that used to live here restated the dark theme's own
   --qr-text-dim, so it was a no-op outside the hero — but inside the hero it beat the scoped
   override above on specificity. Dropping it lets the single `color: var(--qr-text-dim)` declaration
   resolve per theme/appearance, and removes a raw colour. */

.home-hero-title {
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--qr-text);
  margin: 0;
}
html.dark-mode .home-hero-title { color: #f8fafc; }

/* Dashboard Stats inline */
.hero-dashboard-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.65);
  backdrop-filter: var(--glass-surface);
  -webkit-backdrop-filter: var(--glass-surface);
  padding: 1rem 1.25rem;
  border-radius: var(--qr-card-radius);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: var(--qr-shadow-light);
}
html.dark-mode .hero-dashboard-stats {
  background: rgba(30,41,59,0.5);
  border: 1px solid rgba(51,65,85,0.4);
  box-shadow: var(--qr-shadow-dark);
}

.hero-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.hero-stat-val {
  font-size: var(--fs-h1);
  font-weight: 800;
  color: var(--qr-text);
  line-height: 1.1;
}
html.dark-mode .hero-stat-val { color: #f1f5f9; }
.hero-stat-lbl {
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--qr-text-dim);
  margin-top: .25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
html.dark-mode .hero-stat-lbl { color: #94a3b8; }

.hero-stat-divider {
  width: 1px;
  height: 24px;
  background: rgba(226,232,240,0.8);
}
html.dark-mode .hero-stat-divider { background: rgba(71,85,105,0.5); }

/* Streak Badge */
.hero-streak-col {
  flex-shrink: 0;
}
.home-streak-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem 0.75rem;
  border-radius: var(--r-full);
  background: var(--qr-surface-solid);
  border: 1px solid rgba(226,232,240,0.8);
  box-shadow: var(--el-1);
  font-size: var(--fs-sub);
  color: var(--qr-text);
  font-weight: 700;
  transition: all var(--qr-dur) var(--qr-ease-out);
}

/* Target-exam identity chip under the hero name */
.hero-exam-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-top: .25rem;
  padding: .25rem .5rem;
  border-radius: var(--r-full);
  border: 1px solid var(--qr-border);
  background: var(--qr-surface-solid);
  color: var(--qr-accent-strong);
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  touch-action: manipulation;
}
html.dark-mode .hero-exam-chip { background: rgba(30,41,59,.8); color: var(--qr-accent); }

/* One-time target-exam nudge for pre-existing users */
/* Text ABOVE a full-width button, not beside it. As a single centred row the button's `nowrap` claimed
   its width first and the sentence was left to wrap inside whatever remained — on a 390px screen that
   collapsed "Preparing for an exam?" into a four-line column beside the CTA. A column costs nothing at
   any width and removes the competition for horizontal space entirely.
   The dismiss × stays out of the flow (absolutely positioned) so it cannot stretch to full width with
   the button, and so the text keeps the full content width instead of being inset by a third control. */
.exam-nudge-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .75rem;
  padding: .75rem 1rem;
  margin: 0 0 .75rem;
}
.exam-nudge-text {
  font-size: var(--fs-sub); color: var(--qr-text-dim); font-weight: 600;
  padding-right: 1.75rem;   /* clears the dismiss × */
}
/* 44px matches the twin-card CTA and the platform minimum touch target; this control was 40px. */
.exam-nudge-btn { width: 100%; min-height: 44px; padding: .5rem 1rem; font-size: var(--fs-caption); }
.exam-nudge-dismiss {
  position: absolute; top: .25rem; right: .5rem;
  background: none; border: none; color: var(--qr-text-mut);
  font-size: var(--fs-h2); line-height: 1; padding: .5rem .25rem; cursor: pointer;
}
html.dark-mode .home-streak-badge {
  background: rgba(30,41,59,0.8);
  border-color: rgba(51,65,85,0.6);
  color: #f1f5f9;
}
.home-streak-badge.streak-active {
  background: var(--qr-grad-wash-duel);
  border-color: rgba(245,158,11,0.2);
  color: #b45309;
}
html.dark-mode .home-streak-badge.streak-active {
  background: var(--qr-grad-wash-duel);
  border-color: rgba(245,158,11,0.3);
  color: #fbbf24;
}
.streak-fire { --qr-ico-size: var(--fs-body); font-size: var(--fs-body); }
.streak-count { font-weight: 800; }

/* ---- Primary CTA Button ---- */
.home-cta-section {
  margin: 1.5rem 1.25rem;
}
.home-cta-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.25rem;
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--qr-card-radius);
  cursor: pointer;
  box-shadow: var(--qr-glow-accent);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
  animation: ctaPulse calc(var(--qr-dur-pulse) * 2.5) var(--qr-ease) infinite;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.home-cta-btn:active {
  transform: scale(var(--qr-press-sm));
  box-shadow: var(--qr-glow-accent);
  animation: none;
}
@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(37,99,235,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
  50% { box-shadow: 0 12px 32px rgba(37,99,235,0.5), inset 0 1px 0 rgba(255,255,255,0.3); }
}
.home-cta-icon {
  font-size: var(--fs-h1);
  flex-shrink: 0;
}
.home-cta-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  flex: 1;
}
.home-cta-text strong {
  font-size: var(--fs-h3);
  font-weight: 800;
}
.home-cta-text small {
  font-size: var(--fs-caption);
  opacity: 0.85;
  font-weight: 500;
  margin-top: .125rem;
}
.home-cta-arrow {
  font-size: var(--fs-h1);
  font-weight: 700;
  opacity: 0.9;
  flex-shrink: 0;
}

/* ---- Daily Goal Ring Card ---- */
.home-goal-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: var(--qr-card-padding);
  background: var(--qr-surface-solid);
  border-radius: var(--qr-card-radius);
  border: 1px solid rgba(226,232,240,0.6);
  box-shadow: var(--qr-shadow-light);
  margin-bottom: 1.5rem;
}
html.dark-mode .home-goal-card {
  background: rgba(30,41,59,0.7);
  border-color: rgba(51,65,85,0.5);
  box-shadow: var(--qr-shadow-dark);
}
.home-goal-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}
.home-goal-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.home-goal-ring-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 8;
}
html.dark-mode .home-goal-ring-bg { stroke: #334155; }
.home-goal-ring-fill {
  fill: none;
  stroke: var(--qr-accent, var(--qr-accent));   /* theme-aware; JS overrides per progress (ADR-095) */
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset calc(var(--qr-dur-slow) * 2) var(--qr-ease-out);
}
.home-goal-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-goal-pct {
  font-size: var(--fs-body);
  font-weight: 800;
  color: var(--qr-accent);
}
html.dark-mode .home-goal-pct { color: #60a5fa; }
.home-goal-info { flex: 1; }
.home-goal-title {
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--qr-text);
  margin: 0 0 .25rem;
}
html.dark-mode .home-goal-title { color: #f1f5f9; }
.home-goal-detail {
  font-size: var(--fs-caption);
  color: var(--qr-text-dim);
  margin: 0 0 .125rem;
}
html.dark-mode .home-goal-detail { color: #94a3b8; }
.home-goal-status {
  font-size: var(--fs-caption);
  /* ADR-138 — PRE-EXISTING (not an ADR-133+ regression), fixed because it is the same one-line class of
     defect found next to it: another survivor of the hardcoded #94a3b8 that line 34 records as
     "~2.9:1 on white, sub-AA". Measured 2.56:1 classic-light / 2.44:1 playful-light on real caption
     text — a clear AA failure on a line users actually read. The token carries the per-theme values
     chosen to clear the threshold. */
  color: var(--qr-text-dim);
  margin: 0;
}

/* ---- Section Headers ---- */
.home-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.25rem 0 .75rem;
}
.home-section-title {
  font-size: var(--fs-sub);
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0;
}
html.dark-mode .home-section-title { color: #94a3b8; }
.home-section-edit {
  background: none;
  border: none;
  font-size: var(--fs-body);
  cursor: pointer;
  padding: .25rem;
  opacity: .6;
  transition: opacity var(--qr-dur-fast);
}
.home-section-edit:hover { opacity: 1; }
/* ADR-136: the glyph moved into a .qr-ico so Playful paints a line pencil instead of leaving a lone
   colour emoji in a screen of SVG. Sized through the contract, never through width/height.

   The layout gate flagged the swap shrinking the button's visible box 27→26px. The first repair —
   forcing a 44px flex box — was wrong and was reverted: the gate measures the VISIBLE box, but this
   control's touch target is already a real 44×44 via the invisible `::after` added in ADR-133, so the
   44px box bought nothing and cost 17px of Home height, pushing the whole Quick Study section down on
   a screen the brief asks to keep compact. The icon simply keeps the system's default 1.2rem, which
   restores the original 27px box exactly. Don't inflate layout to satisfy a proxy metric. */
.home-section-edit { transition: opacity var(--qr-dur-fast), transform var(--qr-dur-fast) var(--qr-ease-out); }
.home-section-edit .qr-ico { color: var(--qr-text-dim); }
.home-section-edit:active { transform: scale(var(--qr-press-sm)); }

/* ---- Bento Grid ---- */
.home-bento-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 359px) {
  .home-bento-grid {
    grid-template-columns: 1fr;
  }
}
.home-bento-card {
  position: relative;
  background: var(--qr-surface-solid);
  border-radius: var(--qr-card-radius);
  padding: var(--qr-card-padding);
  border: var(--qr-card-border-light);
  box-shadow: var(--qr-shadow-light);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.home-bento-card:active {
  transform: scale(var(--qr-press-lg));
  box-shadow: var(--el-2);
}
html.dark-mode .home-bento-card {
  background: rgba(30,41,59,0.7);
  border: var(--qr-card-border-dark);
  box-shadow: var(--qr-shadow-dark);
}
/* Duel card spans full width */
.home-bento-duel {
  grid-column: 1 / -1;
}
.home-bento-glow {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--qr-grad-glow);
  pointer-events: none;
}
html.dark-mode .home-bento-glow {
  background: var(--qr-grad-glow);
}
.home-bento-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Squircle Icons */
.home-bento-icon-squircle {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-amber { background: rgba(245,158,11,0.15); }
.icon-blue { background: rgba(59,130,246,0.15); }
/* Playful: soft neutral tiles + accent-tinted mask icons — one visual system with the CTAs */
html.theme-playful .home-bento-icon-squircle { background: var(--qr-surface-2); border: 1px solid var(--qr-border); }
html.theme-playful .home-bento-icon.qr-ico { color: var(--qr-accent); }

.home-bento-icon {
  font-size: var(--fs-h2);
}

/* .home-premium-badge visuals consolidated into the unified .qr-badge-pro rule (see PRO badge block);
   only its inline margin-left delta is retained there. */

.home-bento-duel-live {
  position: absolute;
  top: var(--qr-card-padding);
  right: var(--qr-card-padding);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.95);
  padding: 4px 8px;
  border-radius: var(--r-md);
  font-size: var(--fs-caption);
  font-weight: 700;
  color: #10b981;
  box-shadow: var(--el-1);
  border: 1px solid rgba(16,185,129,0.2);
  z-index: var(--z-lift);
}
@keyframes pulseLive {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  70% { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.home-bento-title {
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  font-weight: 800;
  color: var(--qr-text);
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
}
html.dark-mode .home-bento-title { color: #f1f5f9; }
.home-bento-desc {
  font-size: clamp(0.7rem, 2vw, 0.8rem);
  color: var(--qr-text-dim);
  line-height: 1.4;
  margin: 0 0 .75rem;
  flex: 1;
}
html.dark-mode .home-bento-desc { color: #94a3b8; }

/* Duel Arena Buttons */
.home-duel-actions {
  display: flex;
  gap: .5rem;
}
.home-duel-btn {
  flex: 1;
  padding: .5rem .5rem;
  border: none;
  border-radius: var(--qr-btn-radius);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--qr-dur-fast) var(--qr-ease), background var(--qr-dur) var(--qr-ease);
  touch-action: manipulation;
}
.home-duel-btn:active { transform: scale(var(--qr-press-sm)); }
.home-duel-create {
  background: var(--qr-grad-cta);
  color: var(--qr-on-accent);
  box-shadow: var(--qr-glow-accent);
  padding: 0.75rem 1rem;
}
.home-duel-join {
  background: var(--qr-surface-3);
  color: var(--qr-text);
  padding: 0.75rem 1rem;
}
html.dark-mode .home-duel-join {
  background: #334155;
  color: #e2e8f0;
}

/* Bento Action Buttons (locked state) */
.home-bento-action-btn {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid rgba(37,99,235,0.4);
  border-radius: var(--qr-btn-radius);
  background: rgba(37,99,235,0.06);
  color: var(--qr-accent);
  font-size: var(--fs-caption);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--qr-dur-fast) var(--qr-ease-out);
  touch-action: manipulation;
}
.home-bento-action-btn:hover {
  background: rgba(37,99,235,0.14);
  border-color: rgba(37,99,235,0.6);
}
.home-bento-action-btn:active {
  transform: scale(var(--qr-press-lg));
}
html.dark-mode .home-bento-action-btn {
  border-color: rgba(96,165,250,0.5);
  background: rgba(96,165,250,0.12);
  color: #93c5fd;
}
html.dark-mode .home-bento-action-btn:hover {
  background: rgba(96,165,250,0.22);
  border-color: rgba(96,165,250,0.8);
}

/* Override AI Coach card styling when inside bento */
.home-bento-coach .ai-coach-card,
.home-bento-coach .card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.home-bento-coach .ai-coach-card h3,
.home-bento-timetable .card h3 {
  display: none; /* Title already in bento header */
}
.home-bento-coach .ai-coach-locked {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}
.home-bento-coach .ai-coach-unlock-btn {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px dashed rgba(124,58,237,.3);
  border-radius: var(--r-md);
  background: rgba(124,58,237,.05);
  color: var(--qr-info-fg);
  font-size: var(--fs-caption);
  font-weight: 600;
  box-shadow: none;
  margin: 0;
  margin-top: auto;
  max-width: none;
}

#aiCoachContainer, #aiStudyPlanContainer {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: flex-end;
}

/* Section E: Stats premium CTA — dominant, perfectly centered, full-width,
   equal margins, responsive across all device widths. */
#aiInsightsContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
#aiInsightsContainer .stats-premium-note {
  text-align: center;
  width: 100%;
  margin: 0 0 .75rem;
}
#aiInsightsContainer .stats-premium-cta {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  border-radius: var(--r-lg);
  font-size: var(--fs-body);
  font-weight: 800;
}

/* ───────────────────────────────────────────────────────────────────────
   AI Coach + Study Plan = premium feature cards, Math Duel's smaller siblings.
   They inherit .home-bento-card verbatim (same glass, hairline border, navy
   shadow — NO gradient/purple/glow). Compact header (icon+title like Duel) +
   short desc + identical CTA. Twins stay the same height via grid stretch.
   ─────────────────────────────────────────────────────────────────────── */
.home-twin-card { align-items: stretch; }
/* CTA pinned to the bottom; identical box for both twins. */
/* The two CTA containers must GROW, or the twins cannot align. `.ai-coach-body` / `.ai-study-plan-body`
   already declare `flex: 1; justify-content: flex-end` to bottom-align their button — but flex-grow is
   measured against the parent, and these containers were plain auto-height divs, so that instruction had
   nothing to act on and each button simply sat wherever its description left it. Making the containers
   flex columns that fill the remaining card height is what turns the existing rule into the intended
   result: both CTAs land on one baseline no matter how differently the two descriptions wrap. */
.home-twin-card #aiCoachContainer,
.home-twin-card #aiStudyPlanContainer {
  padding-top: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
/* Give the PRO badge its own row in BOTH twins. The title is a wrapping flex row of [text][badge], and
   the two titles are different lengths: "AI Coach" fits beside its badge, "Study Planner" does not, so
   at phone widths one card's badge wrapped to a second line and the other's did not — measured at 390px,
   a 37px title block against a 52px one, which put the two PRO badges and the two descriptions 15px out
   of step. Stacking the badge makes the block [text-row][badge-row] in both cards, so the twins agree by
   construction instead of by coincidence of string length — which also means a longer hi/mr translation
   cannot reintroduce the mismatch the way a fixed min-height would. */
.home-twin-card .home-bento-title {
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
}
/* …and reserve two text lines for the name itself. The icon sits BESIDE the title, leaving it about
   77px on a 390px phone — enough for "AI Coach" on one line but not "Study Planner", which wrapped to
   two. That one-line difference was the whole 37px-vs-52px mismatch. Reserving the taller state for
   both makes the badges and descriptions line up by construction.
   `min-height` in `em` so it follows the title's clamp() size and a longer string still grows rather
   than clips. A translation long enough to need a THIRD line in only one of the two cards would
   reintroduce a smaller version of this — noted rather than over-engineered, since the twins are also
   equal-height overall and their CTAs are pinned to a shared baseline regardless. */
.home-twin-card .home-bento-title > span:first-child { min-height: 2.4em; }

/* EXACT two lines for the name and the description in BOTH twins, rather than "however this particular
   string happens to wrap". Reserving a two-line BOX (above) equalised the geometry, but "AI Coach" still
   rendered as one line of text with an empty line under it while "Study Planner" filled both — so the
   pair measured identical and still read as mismatched.
   `pre-line` honours a newline written into the string itself, so each language chooses its own break
   point instead of depending on the box width, and the result is two lines at every width rather than
   two lines only where the box happens to be narrow enough. Whitespace is still collapsed otherwise, so
   the surrounding markup indentation does not leak into the rendering. */
.home-twin-card .home-bento-title > span:first-child,
.home-twin-card .home-bento-desc { white-space: pre-line; }
/* The description reserves its two lines too, so a future one-line translation cannot pull the CTA up
   in one card and not the other. */
.home-twin-card .home-bento-desc { min-height: 2.8em; }

.home-twin-card .home-bento-action-btn {
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  /* `.sp-open-btn` / `.sp-unlock-btn` carry `max-width: 280px` from the standalone study-plan CTA, and
     the coach's `.ai-insights-btn` does not — so on a tablet, where a twin card is wide enough to pass
     280px, the planner's button stopped growing and the coach's did not: 290px against 280px, measured
     at 768px. Inside a twin the CTA is a full-width element of a paired card, so the cap does not apply
     to either of them. It is cleared here rather than deleted from the base rule, which still governs
     the card's non-twin uses. */
  max-width: none;
  font-size: var(--fs-caption); line-height: 1.2; padding: 0 0.75rem;
}

.ai-coach-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: flex-start;
  gap: 0.5rem;
}

.home-bento-action-btn, .sp-open-btn, .ai-insights-btn {
  margin-top: auto;
}

/* Reduced-motion: disable CTA pulse */
@media (prefers-reduced-motion: reduce) {
  .home-cta-btn { animation: none; }
  .home-goal-ring-fill { transition: none; }
}


/* =========================================================================
   STATS TAB PREMIUM ISOLATION
   ========================================================================= */
/* Stats cards now inherit the unified global card standard (no per-tab override). */

/* Global Empty States (Isolated to Stats after Rollback) */
.qr-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  min-height: 50vh;
  opacity: 0;
  animation: viewSlideIn var(--qr-dur-slow) var(--qr-ease-out) forwards calc(var(--qr-dur-fast) * 0.833333);
}
.qr-empty-state svg {
  width: 120px;
  height: 120px;
  margin-bottom: 1.5rem;
  color: var(--qr-border-strong);
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.05));
}
.qr-empty-state h2 {
  font-size: var(--fs-h1);
  font-weight: 700;
  color: var(--qr-text);
  margin-bottom: 0.5rem;
}
.qr-empty-state p {
  font-size: var(--fs-body);
  color: var(--qr-text-dim);
  max-width: 280px;
  margin-bottom: 2rem;
  line-height: 1.5;
}
html.dark-mode .qr-empty-state h2 { color: #f8fafc; }
html.dark-mode .qr-empty-state svg { color: #334155; }

/* PART 1 - LEARN TAB BUTTON FIX */
.table-controls {
  display: flex;
  gap: 1rem;
  width: 100%;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
}

#showAllTables,
#clearAllTables {
  flex: 1;
  max-width: calc(50% - 0.5rem);
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PART 2 & 3 - AI COACH & STUDY PLAN VISUAL CONSISTENCY */
.home-bento-coach,
.home-bento-timetable {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--qr-card-padding);
  min-height: 180px;
}

.ai-coach-body,
.ai-study-plan-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 50px;
}


/* ════════════════════════════════════════════════════════════════
   PAYWALL v2 — product-grade single-tier (Free vs Premium)
   Markup built in paywall.js (showPaywall). Reuses .paywall-overlay /
   .paywall-card / .paywall-close shell; everything below is .pw-*.
   ════════════════════════════════════════════════════════════════ */

.pw-card {
  max-width: 460px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.25rem 1.25rem;
}
.pw-close { z-index: var(--z-lift-2); }

/* Hero */
.pw-hero { text-align: center; padding: .25rem 0 .5rem; }
.pw-hero-icon {
  font-size: var(--fs-d1); line-height: 1;
  display: inline-block; margin-bottom: .5rem;
  filter: drop-shadow(0 4px 12px rgba(37,99,235,.35));
}
.pw-hero-title {
  margin: 0; font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.02em;
  background: var(--qr-grad-cta);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--qr-accent);
}
.pw-hero-sub { margin: .25rem 0 0; color: var(--qr-text-dim); font-size: var(--fs-body); font-weight: 600; }

/* Context accent */
.pw-context {
  margin: .75rem 0 0; padding: .5rem .75rem;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--r-md);
  color: #1e3a8a; font-size: var(--fs-sub); font-weight: 600; text-align: center;
}

/* (The old value-chips grid was removed with the paywall restructure — the compare table is the
   single benefits presentation now.) */
.pw-footer-dot { color: #cbd5e1; font-weight: 700; }

/* Comparison matrix */
.pw-compare-wrap { margin: 1rem 0 .25rem; border: 1px solid #e8edf3; border-radius: var(--r-lg); overflow: hidden; }
.pw-compare { width: 100%; border-collapse: collapse; font-size: var(--fs-sub); }
.pw-compare thead th {
  background: var(--qr-surface-2); font-weight: 800; color: var(--qr-text);
  padding: .5rem .5rem; text-align: center; border-bottom: 1px solid var(--qr-border);
}
.pw-compare th.pw-compare-feat, .pw-compare td.pw-compare-feat { text-align: left; }
.pw-compare th.pw-compare-prem { color: var(--qr-accent); }
.pw-compare tbody td { padding: .5rem .5rem; text-align: center; border-bottom: 1px solid #f1f5f9; color: #475569; }
.pw-compare tbody tr:last-child td { border-bottom: none; }
.pw-compare td.pw-compare-feat { font-weight: 600; color: #1e293b; }
.pw-compare td.pw-compare-free { color: var(--qr-text-dim); }
.pw-compare td.pw-compare-prem { color: var(--qr-accent-strong); font-weight: 700; background: rgba(37,99,235,.06); }

/* Plan selector */
.pw-plans { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1rem 0 .25rem; }
.pw-plan {
  position: relative; text-align: center; cursor: pointer;
  padding: 1rem .5rem .75rem; border-radius: var(--r-lg);
  border: 2px solid var(--qr-border); background: var(--qr-surface-solid);
  transition: border-color var(--qr-dur) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur) var(--qr-ease-out), background var(--qr-dur) var(--qr-ease-out);
}
.pw-plan:hover { border-color: var(--qr-border-strong); }
.pw-plan--active {
  border-color: var(--qr-accent); background: var(--qr-grad-wash);
  box-shadow: var(--qr-focus-ring); /* brighter border + stronger glow */
  transform: translateY(-3px);
}
html.dark-mode .pw-plan--active {
  background: var(--qr-grad-wash); border-color: #3b82f6;
  box-shadow: var(--qr-focus-ring);
}
.pw-plan-badge {
  position: absolute; top: -.6rem; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-micro); font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--qr-on-accent); background: var(--qr-grad-cta);
  padding: .25rem .5rem; border-radius: var(--r-lg); white-space: nowrap;
}
.pw-plan-label { font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); }
.pw-plan-price { font-size: var(--fs-h1); font-weight: 800; color: var(--qr-text); margin: .125rem 0 0; }
.pw-plan--active .pw-plan-price { color: var(--qr-accent-strong); }
.pw-plan-per { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }
.pw-plan-save { font-size: var(--fs-caption); color: var(--qr-success-fg); font-weight: 800; margin-top: .25rem; min-height: 1em; }
html.dark-mode .pw-plan-per { color: #94a3b8; }
html.dark-mode .pw-plan-save { color: #4ade80; }

/* CTA */
.pw-cta {
  width: 100%; margin: 1rem 0 .25rem; padding: 1rem 1rem;
  border: none; border-radius: var(--qr-btn-radius); cursor: pointer;
  font-size: var(--fs-body); font-weight: 800; color: var(--qr-on-accent);
  background: var(--qr-grad-cta);
  box-shadow: var(--qr-glow-accent);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out), filter var(--qr-dur) var(--qr-ease-out);
}
.pw-cta:hover { filter: brightness(1.05); box-shadow: var(--qr-glow-accent); }
.pw-cta:active { transform: scale(var(--qr-press-lg)); }
.pw-cta--loading { opacity: .85; cursor: progress; }
.pw-cta-note { text-align: center; margin: 0 0 .5rem; color: var(--qr-text-dim); font-size: var(--fs-caption); font-weight: 600; }

/* Trust builders */
.pw-trust { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem .75rem; margin: .75rem 0 .25rem; }
.pw-trust-item { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }

/* Restore (ADR-142, WS3). A quiet secondary action: it must be findable — Play requires a reinstall
   to recover an entitlement without paying again — without competing with the primary CTA. 44px min
   height keeps the ADR-133 touch-target floor; the disabled state is what the in-flight label uses. */
.pw-restore {
  display: block; width: 100%; min-height: 44px; margin: .5rem 0 0;
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim);
  text-decoration: underline; text-underline-offset: 3px;
  transition: color var(--qr-dur-fast) var(--qr-ease-out), opacity var(--qr-dur-fast) var(--qr-ease-out);
}
.pw-restore:hover { color: var(--qr-accent); }
.pw-restore:active { transform: scale(var(--qr-press-sm)); }
.pw-restore:disabled { cursor: default; opacity: .6; text-decoration: none; }
html.dark-mode .pw-restore { color: #94a3b8; }

/* Footer */
.pw-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .5rem 1rem; margin-top: 1rem; padding-top: .75rem; border-top: 1px solid #eef2f7;
}
.pw-footer-link {
  background: none; border: none; cursor: pointer; padding: 0;
  font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); text-decoration: none;
}
.pw-footer-link:hover { color: var(--qr-accent); }

/* Responsive */
@media (max-width: 420px) {
  .pw-hero-title { font-size: var(--fs-h1); }
  .pw-compare { font-size: var(--fs-caption); }
}

/* Dark mode */
html.dark-mode .pw-hero-sub { color: #94a3b8; }
html.dark-mode .pw-context { background: var(--qr-veil-accent-12); border-color: rgba(37,99,235,.35); color: #bfdbfe; }
html.dark-mode .pw-compare-wrap { border-color: #1e293b; }
html.dark-mode .pw-compare thead th { background: #111827; color: #e2e8f0; border-bottom-color: #1e293b; }
html.dark-mode .pw-compare th.pw-compare-prem { color: #60a5fa; }
html.dark-mode .pw-compare tbody td { color: #94a3b8; border-bottom-color: #1e293b; }
html.dark-mode .pw-compare td.pw-compare-feat { color: #e2e8f0; }
html.dark-mode .pw-compare td.pw-compare-prem { color: #93c5fd; background: rgba(37,99,235,.14); }
html.dark-mode .pw-plan { background: #0f172a; border-color: #1e293b; }
html.dark-mode .pw-plan-price { color: #f1f5f9; }
html.dark-mode .pw-plan--active .pw-plan-price { color: #93c5fd; }
html.dark-mode .pw-cta-note, html.dark-mode .pw-trust-item, html.dark-mode .pw-footer-link { color: #94a3b8; }
html.dark-mode .pw-footer { border-top-color: #1e293b; }

/* ───────────────────────────────────────────────────────────────────────
   Practice tab — sectioned hierarchy (Today's Progress / Quick Start /
   Advanced Modes). Brings the screen up to the Home tab's intentional feel.
   ─────────────────────────────────────────────────────────────────────── */
.practice-section { margin-bottom: 32px; }            /* between major sections */
.practice-section:first-child { margin-top: 0; }
.practice-section:last-child { margin-bottom: 0; }
.practice-mode-group { display: flex; flex-direction: column; gap: 16px; } /* between cards */
.practice-mode-group .mode-card { margin-bottom: 0; }  /* gap handles spacing */

/* ADR-080 spacing: the first section heading sits flush to the container's own top padding (the daily-quota div is a
   <div>, so :first-of-type targets the real first <section> regardless of whether the quota box is present). This
   removes the dead band above "Quick Start" without making it cramped. */
.practice-container .practice-section:first-of-type .home-section-header { margin-top: .125rem; }

/* ADR-080 hierarchy: clearer title/subtitle on every mode card. */
.practice-container .mode-card h3 { font-weight: 700; letter-spacing: -.01em; }   /* ADR-131: was 750, off-scale */
.practice-container .mode-card p { color: #475569; }
html.dark-mode .practice-container .mode-card p { color: #94a3b8; }

/* ADR-081: Subject Sets are grouped by the "Subject Sets" section header + typography — no decorative rail/eyebrow
   (removed as visual clutter). The cards are plain .mode-card so every Practice card reads identically. */


/* ═══════════════════════════════════════════════════════════════════════════
   DUEL V2 — redesigned §10A surfaces (one design language with Practice).
   Accent is app blue (#2563eb), NOT indigo. Setup/Join are bottom-sheet modals
   reusing .training-card; lobby/waiting/results are full duel-view screens.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ---- Setup / Join bottom-sheet modal ---- */
/* Shell (scrim/geometry/shadow/>=600px centering) comes from the .qr-sheet primitive (FW-W6);
   only the duel-specific z-order, width and entrance motion live here. .training-card supplies
   the surface identity by cascade, as before. */
.duel-sheet-overlay { z-index: var(--z-critical); }
@keyframes duelSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.duel-sheet { max-width: 480px; animation: duelSheetUp var(--qr-dur) var(--qr-ease); }
.duel-sheet-compact { max-width: 420px; }
.duel-sheet-title { text-align: center; }
.duel-sheet-body { padding: 0 1rem .75rem; }
.duel-sheet-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .75rem 1rem calc(.8rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--qr-border);
}
.duel-sheet-cta { width: 100%; }
.duel-field { margin: 1rem .25rem 0; }
.duel-field:first-child { margin-top: .5rem; }
.duel-field-label {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sub);
  margin: 0 0 .5rem;
  color: var(--qr-text);
}
.duel-field-hint { color: var(--qr-text-dim); font-weight: 400; font-size: var(--fs-caption); }
.duel-skip-hint { margin: .5rem 0 0; color: var(--qr-text-dim); font-size: var(--fs-caption); }
.duel-topic-grid { margin-top: .25rem; }

.duel-join-help { text-align: center; margin: .5rem 0 1rem; }
/* Box/border/focus come from the .qr-input primitive (FW-W6); the code-entry sizing lives here. */
.duel-join-input {
  width: 100%;
  text-align: center;
  letter-spacing: .35em;
  font-size: var(--fs-d2);
  font-weight: 800;
  text-transform: uppercase;
  padding: 1rem .75rem;
}
.duel-join-err { color: var(--qr-danger); font-size: var(--fs-sub); min-height: 1.1rem; margin-top: .5rem; text-align: center; }
.duel-arena-full { text-align: center; padding: 1.5rem 1.25rem .5rem; }
.duel-arena-emoji { font-size: var(--fs-icon); line-height: 1; }
.duel-arena-title { font-size: var(--fs-h2); font-weight: 800; margin: .5rem 0 .5rem; color: var(--qr-text); }

/* ---- Shared duel screens (lobby / waiting / results) ---- */
.duel-screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 1rem calc(1.5rem + var(--qr-nav-h, 3.75rem));
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.duel-card {
  background: var(--qr-surface-solid);
  border: 1px solid var(--qr-veil-ink-8);
  border-radius: var(--qr-card-radius);
  box-shadow: var(--qr-shadow-light, 0 6px 20px var(--qr-veil-ink-6));
  padding: 1.5rem 1.25rem;
}
html.dark-mode .duel-card {
  background: #1e293b;
  border-color: var(--qr-veil-w-8);
  box-shadow: var(--qr-shadow-dark, 0 8px 24px rgba(2, 6, 23, .45));
}
.duel-vs-head {
  text-align: center;
  font-size: var(--fs-h2);
  font-weight: 800;
  color: var(--qr-text);
  margin-bottom: 1rem;
}
html.dark-mode .duel-vs-head { color: #f1f5f9; }

.duel-roomcode-block {
  text-align: center;
  background: var(--qr-surface-2);
  border-radius: var(--qr-card-radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}
html.dark-mode .duel-roomcode-block { background: rgba(15, 23, 42, .55); }
.duel-roomcode-label { font-size: var(--fs-caption); letter-spacing: .08em; text-transform: uppercase; color: var(--qr-text-dim); }
.duel-roomcode { font-size: var(--fs-d1); font-weight: 800; letter-spacing: .25em; color: var(--qr-accent); margin: .125rem 0 .75rem; }
.duel-share-row { display: flex; gap: .5rem; justify-content: center; }
.duel-share-btn {
  padding: .5rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid rgba(37, 99, 235, .35);
  background: var(--qr-veil-accent-8);
  color: var(--qr-accent-strong);
  font-size: var(--fs-sub);
  font-weight: 600;
  cursor: pointer;
}
html.dark-mode .duel-share-btn { color: #93c5fd; background: rgba(37, 99, 235, .14); border-color: rgba(59, 130, 246, .4); }

.duel-slots { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.duel-slot {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .75rem;
  border-radius: var(--qr-card-radius-sm);
  background: var(--qr-bg);
  border: 1px solid var(--qr-veil-ink-6);
}
html.dark-mode .duel-slot { background: rgba(15, 23, 42, .4); border-color: var(--qr-veil-w-6); }
.duel-slot.is-empty { border-style: dashed; opacity: .85; }
.duel-avatar {
  width: 2.2rem;
  height: 2.2rem;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--fs-body);
  color: var(--qr-on-accent);
  background: var(--qr-accent);
}
.duel-avatar.is-empty { background: #cbd5e1; color: var(--qr-text-dim); }
.duel-avatar.lg { width: 3.4rem; height: 3.4rem; font-size: var(--fs-h1); margin-bottom: .25rem; }
.duel-avatar.is-finished { background: var(--qr-success); }
.duel-avatar.is-solving { background: #d97706; }
.duel-avatar.is-stale { background: var(--qr-text-dim); }
.duel-slot-name { font-weight: 600; color: var(--qr-text); }
.duel-slot-status { margin-left: auto; font-size: var(--fs-caption); color: var(--qr-text-dim); display: inline-flex; align-items: center; gap: .25rem; }
.duel-slot-status.is-on { color: var(--qr-success); }

.duel-section-label { font-size: var(--fs-caption); letter-spacing: .06em; text-transform: uppercase; color: var(--qr-text-dim); margin: .25rem 0 .5rem; }
.duel-config-summary {
  text-align: center;
  font-size: var(--fs-sub);
  color: #475569;
  background: var(--qr-surface-2);
  border-radius: var(--qr-card-radius-sm);
  padding: .75rem .75rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}
html.dark-mode .duel-config-summary { background: rgba(15, 23, 42, .5); color: #cbd5e1; }
.duel-cta { width: 100%; }
.duel-cta:disabled { opacity: .55; cursor: not-allowed; }
.duel-leave-link {
  display: block;
  width: 100%;
  margin-top: .75rem;
  padding: .5rem;
  border: none;
  background: transparent;
  color: var(--qr-text-dim);
  font-weight: 600;
  font-size: var(--fs-sub);
  cursor: pointer;
  text-align: center;
}

.duel-joined-badge {
  text-align: center;
  color: var(--qr-success);
  font-weight: 700;
  font-size: var(--fs-body);
  margin-bottom: .5rem;
}
.duel-waiting-host {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: #475569;
  font-weight: 600;
  font-size: var(--fs-sub);
  padding: .5rem;
}
html.dark-mode .duel-waiting-host { color: #cbd5e1; }
.duel-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d97706;
  display: inline-block;
  animation: duelPulse calc(var(--qr-dur-pulse) * 1.0834) var(--qr-ease) infinite;
}
@keyframes duelPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }

/* ---- Waiting screen ---- */
.duel-waiting-card { text-align: center; }
.duel-waiting-title { font-size: var(--fs-h2); font-weight: 800; margin: .5rem 0 .5rem; color: var(--qr-text); }
html.dark-mode .duel-waiting-title { color: #f1f5f9; }
.duel-waiting-sub { color: var(--qr-text-dim); font-size: var(--fs-sub); margin-bottom: 1rem; line-height: 1.5; }
.duel-opp-status {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--qr-surface-2);
  border-radius: var(--r-full);
  padding: .5rem 1rem;
  font-size: var(--fs-sub);
  font-weight: 600;
  color: #334155;
  margin-bottom: 1.25rem;
}
html.dark-mode .duel-opp-status { background: rgba(15, 23, 42, .5); color: #cbd5e1; }
.duel-opp-dot { width: 9px; height: 9px; border-radius: 50%; background: #d97706; }
.duel-opp-dot.is-finished { background: var(--qr-success); }
.duel-opp-dot.is-solving { background: #d97706; animation: duelPulse calc(var(--qr-dur-pulse) * 1.0834) var(--qr-ease) infinite; }
.duel-opp-dot.is-stale { background: var(--qr-text-dim); }

/* ---- Results screen ---- */
.duel-result-banner {
  text-align: center;
  font-size: var(--fs-d2);
  font-weight: 800;
  margin-bottom: 1rem;
}
.duel-result-banner.is-win { color: var(--qr-success); }
.duel-result-banner.is-loss { color: var(--qr-danger); }
.duel-result-banner.is-draw { color: var(--qr-text-dim); }
/* Layout for .duel-result-vs / .duel-result-col / .duel-result-crown lives in the CENTERED block below.
   Here we keep only the visual tokens (colors, name/caption typography) shared by both. */
.duel-vs-sep { display: flex; align-items: center; color: #94a3b8; font-weight: 800; font-size: var(--fs-caption); padding: 0 .5rem; }
.duel-result-name {
  font-size: var(--fs-sub);
  color: var(--qr-text-dim);
  margin-top: .25rem;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.duel-result-score { color: var(--qr-text); }
html.dark-mode .duel-result-score { color: #f1f5f9; }
.duel-result-correct { font-size: var(--fs-caption); color: #94a3b8; }
.duel-result-actions { display: flex; gap: .5rem; }
.duel-result-actions .btn-secondary, .duel-result-actions .btn-primary { flex: 1; }

/* ---- Submit & Leave modal (de-indigo, blue) ---- */
.duel-exit-modal { max-width: 380px; text-align: left; }
.duel-exit-title { font-size: var(--fs-h2); font-weight: 800; margin: 0 0 .5rem; color: var(--qr-text); }
html.dark-mode .duel-exit-title { color: #f1f5f9; }
.duel-exit-body { color: #475569; font-size: var(--fs-sub); line-height: 1.55; margin-bottom: 1rem; }
html.dark-mode .duel-exit-body { color: #cbd5e1; }
.duel-exit-actions { display: flex; flex-direction: column; gap: .5rem; }

/* ---- Release-audit UX fixes: touch targets ≥40-44px, dark-mode contrast, notch safe-area ---- */
.duel-sheet .category-btn { min-height: 44px; }                       /* audit mobile-ux-perf-06 */
.duel-sheet .timer-pill { min-height: 40px; }                         /* audit mobile-ux-perf-09 */
.duel-share-btn { min-height: 40px; }                                 /* audit mobile-ux-perf-10 */
.duel-leave-link { min-height: 40px; }
/* (FW-W6: dark Draw contrast now re-resolves through --qr-text-dim — audit mobile-ux-perf-07 preserved) */
body.drill-session-active .duel-solve-header { top: calc(.55rem + env(safe-area-inset-top, 0px)); }  /* audit mobile-ux-perf-01 (notch) */
/* Landscape: never let the duel question card collapse under the fixed numpad/header (audit mobile-ux-perf-02). */
@media (orientation: landscape) and (max-height: 520px) {
  body.drill-session-active .duel-solve-header { top: .25rem; }
  .duel-countdown-num { font-size: var(--fs-icon-lg); }
}
/* The compact Join sheet sits CENTERED (not as a bottom sheet) so the soft keyboard rising from the bottom doesn't
   hide its footer "Join Duel" button (audit mobile-ux-perf-03). */
.duel-sheet-compact { align-self: center; border-radius: var(--r-sheet); }

/* ---- Result screen: CENTERED composition on a single vertical axis, full data restored ---- */
.duel-result-card { padding: 1.75rem 1.25rem; text-align: center; }
.duel-result-icon { font-size: var(--fs-icon); line-height: 1; margin-bottom: .25rem; }
.duel-result-banner { margin-bottom: 1.25rem; text-align: center; }
/* VS row: a symmetric 3-column grid → the two player columns are EXACTLY equal width regardless of name/score
   length, with "vs" perfectly centered. No left-drift. */
.duel-result-vs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.25rem;
}
.duel-vs-sep { justify-content: center; }
/* Player columns: equal-height (fixed crown slot on both), subtle winner ring, restrained score size. */
.duel-result-col { display: flex; flex-direction: column; align-items: center; padding: .25rem; }
.duel-result-crown { height: 1.6rem; line-height: 1.6rem; font-size: var(--fs-h3); }
.duel-result-score { font-size: var(--fs-d1); font-weight: 800; line-height: 1.1; }
.duel-result-col.is-winner .duel-avatar { box-shadow: var(--qr-focus-ring); }
/* Stats: THREE perfectly equal rows, each its own symmetric 1fr·auto·1fr grid, hairline divider between. */
.duel-result-stats {
  background: var(--qr-surface-2);
  border-radius: var(--qr-card-radius-sm);
  padding: .125rem 1rem;
  margin-bottom: 1.25rem;
}
html.dark-mode .duel-result-stats { background: rgba(15, 23, 42, .5); }
.rs-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 3rem;
  border-bottom: 1px solid var(--qr-veil-ink-6);
}
.rs-row:last-child { border-bottom: none; }
html.dark-mode .rs-row { border-bottom-color: rgba(255, 255, 255, .07); }
.rs-you { text-align: right; font-weight: 700; color: var(--qr-text); }
.rs-opp { text-align: left; font-weight: 700; color: var(--qr-text); }
.rs-label { text-align: center; font-size: var(--fs-caption); letter-spacing: .05em; text-transform: uppercase; color: var(--qr-text-dim); white-space: nowrap; }
.duel-result-why { text-align: center; margin-bottom: 1.25rem; font-size: var(--fs-sub); color: var(--qr-text-dim); letter-spacing: .01em; }
.duel-result-actions .duel-finish-btn { flex: 1.5; font-weight: 700; }


/* ---- PWA install gate (ADR-038) ---- */
.duel-installgate { text-align: center; padding: 1.5rem 1.25rem .5rem; }
.duel-installgate-icon { font-size: var(--fs-icon); line-height: 1; }
.duel-installgate-title { font-size: var(--fs-h2); font-weight: 800; margin: .5rem 0 .5rem; color: var(--qr-text); }

/* ═══════════════════ AI Companion — one design language (ADR-039) ═══════════════════ */
/* Shell comes from the .qr-sheet primitive (FW-W3); companion keeps its z-order, entrance motion,
   its slightly-tinted surface, its softer grabber ink and its 82vh desktop height. */
.companion-overlay { z-index: var(--z-companion); animation: cpnFade var(--qr-dur) var(--qr-ease-out); }
@keyframes cpnFade { from { opacity: 0; } to { opacity: 1; } }
.companion-sheet { background: var(--qr-bg); animation: cpnRise var(--qr-dur) var(--qr-ease); }
@keyframes cpnRise { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 600px) { .companion-sheet { max-height: 82vh; } }
html.dark-mode .companion-sheet { background: #0f172a; }
.companion-grabber { background: rgba(15, 23, 42, .18); }
html.dark-mode .companion-grabber { background: rgba(255, 255, 255, .22); }
.companion-head { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem 1rem; border-bottom: 1px solid rgba(15, 23, 42, .07); touch-action: none; }
html.dark-mode .companion-head { border-bottom-color: rgba(255, 255, 255, .07); }
.companion-badge { font-size: var(--fs-micro); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--qr-accent); background: rgba(37, 99, 235, .1); padding: .25rem .5rem; border-radius: var(--r-full); }
.companion-title { flex: 1; font-weight: 700; color: var(--qr-text); font-size: var(--fs-body); }
html.dark-mode .companion-title { color: #f1f5f9; }
.companion-close { flex: 0 0 auto; width: 2rem; height: 2rem; border: none; background: var(--qr-veil-ink-5); border-radius: var(--r-full); color: var(--qr-text-dim); font-size: var(--fs-sub); cursor: pointer; }
html.dark-mode .companion-close { background: var(--qr-veil-w-8); color: #cbd5e1; }
.companion-refresh { flex: 0 0 auto; width: 2rem; height: 2rem; border: none; background: var(--qr-veil-accent-8); border-radius: var(--r-full); color: var(--qr-accent); font-size: var(--fs-body); line-height: 1; cursor: pointer; transition: transform var(--qr-dur-slow) var(--qr-ease-out); }
.companion-refresh:active { transform: rotate(180deg) scale(var(--qr-press-sm)); }
html.dark-mode .companion-refresh { background: rgba(96, 165, 250, .14); color: #93c5fd; }
.companion-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem 1rem 1.25rem; }

/* turns + conversation */
.companion-turn { margin-bottom: .25rem; }
.companion-turn.is-new { animation: cpnIn var(--qr-dur-fast) var(--qr-ease-out); }
@keyframes cpnIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.companion-userturn { align-self: flex-end; margin: .5rem 0 .5rem auto; max-width: 80%; background: var(--qr-accent); color: var(--qr-on-accent); padding: .5rem .75rem; border-radius: var(--r-bubble); font-size: var(--fs-sub); font-weight: 600; width: fit-content; }
.companion-typing { display: inline-flex; gap: .25rem; padding: .5rem .25rem; }
.companion-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: cpnDot calc(var(--qr-dur-slow) * 2.5) infinite var(--qr-ease); }
.companion-typing i:nth-child(2) { animation-delay: calc(var(--qr-dur-fast) * 1.25); } .companion-typing i:nth-child(3) { animation-delay: calc(var(--qr-dur-fast) * 2.5); }
@keyframes cpnDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* blocks */
.cb-say { font-size: var(--fs-body); line-height: 1.5; color: var(--qr-text); margin: .25rem 0 .75rem; font-weight: 500; }
html.dark-mode .cb-say { color: #e2e8f0; }
.cb-card { display: flex; gap: .5rem; background: var(--qr-surface-solid); border: 1px solid rgba(15, 23, 42, .07); border-left-width: 3px; border-radius: var(--r-lg); padding: .75rem .75rem; margin: .5rem 0; }
html.dark-mode .cb-card { background: var(--qr-veil-w-4); border-color: var(--qr-veil-w-8); }
.cb-card.accent-blue { border-left-color: var(--qr-accent); } .cb-card.accent-green { border-left-color: var(--qr-success); } .cb-card.accent-amber { border-left-color: #d97706; } .cb-card.accent-rose { border-left-color: #e11d48; } .cb-card.accent-slate { border-left-color: #64748b; }
.cb-card-icon { font-size: var(--fs-h3); line-height: 1.4; }
.cb-card-title { font-weight: 700; font-size: var(--fs-caption); color: var(--qr-text); margin-bottom: .125rem; }
html.dark-mode .cb-card-title { color: #f1f5f9; }
.cb-card-body { font-size: var(--fs-sub); color: #475569; line-height: 1.45; }
html.dark-mode .cb-card-body { color: #cbd5e1; }
.cb-metric { display: flex; align-items: center; justify-content: space-between; background: var(--qr-surface-solid); border: 1px solid var(--qr-veil-ink-6); border-radius: var(--r-lg); padding: .5rem .75rem; margin: .25rem 0; }
html.dark-mode .cb-metric { background: var(--qr-veil-w-4); border-color: rgba(255, 255, 255, .07); }
.cb-metric-label { font-size: var(--fs-sub); color: var(--qr-text-dim); font-weight: 600; }
.cb-metric-val { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); }
html.dark-mode .cb-metric-val { color: #f1f5f9; }
.cb-metric-trend.tr-up { color: var(--qr-success); } .cb-metric-trend.tr-down { color: #e11d48; } .cb-metric-trend.tr-flat { color: #94a3b8; }
.cb-metric.is-bad .cb-metric-trend.tr-down { color: #e11d48; }
.cb-progress { margin: .5rem 0; }
.cb-progress-top { display: flex; justify-content: space-between; font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; margin-bottom: .25rem; }
.cb-progress-bar { height: 8px; background: var(--qr-veil-ink-8); border-radius: var(--r-full); overflow: hidden; }
.cb-progress-bar i { display: block; height: 100%; background: var(--qr-accent); border-radius: var(--r-full); transition: width var(--qr-dur-slow) var(--qr-ease-out); }
.cb-progress-cap { font-size: var(--fs-caption); color: #94a3b8; margin-top: .25rem; }
html.dark-mode .cb-progress-bar { background: var(--qr-veil-w-8); }
/* ADR-050: readiness ring block (reuses the planner .pr-ring SVG/CSS). */
.cb-ring { display: flex; align-items: center; gap: 1rem; background: var(--qr-grad-wash); border: 1px solid rgba(37, 99, 235, .14); border-radius: var(--r-lg); padding: .75rem 1rem; margin: .5rem 0; }
.cb-ring .pr-ring { flex: 0 0 auto; }
.cb-ring-meta { min-width: 0; }
.cb-ring-label { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .03em; color: var(--qr-text-dim); font-weight: 700; }
.cb-ring-sub { font-size: var(--fs-body); font-weight: 800; color: var(--qr-text); margin-top: .125rem; line-height: 1.35; }
html.dark-mode .cb-ring { background: var(--qr-grad-wash); border-color: rgba(59, 130, 246, .24); }
html.dark-mode .cb-ring-sub { color: #e2e8f0; }
/* ADR-050: cascade dashboard blocks in (--bi is the block index set in renderEnvelope). */
.cb-stagger { animation: cbStagger var(--qr-dur-slow) var(--qr-ease) both; animation-delay: calc(var(--bi, 0) * calc(var(--qr-dur-fast) * 0.583333)); }
@keyframes cbStagger { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
.cb-steps { background: var(--qr-surface-solid); border: 1px solid var(--qr-veil-ink-6); border-radius: var(--r-lg); padding: .5rem .75rem; margin: .5rem 0; }
html.dark-mode .cb-steps { background: var(--qr-veil-w-4); border-color: rgba(255, 255, 255, .07); }
.cb-steps-title { font-weight: 700; font-size: var(--fs-caption); color: var(--qr-text-dim); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .5rem; }
.cb-steps ol { margin: 0; padding: 0; list-style: none; }
.cb-steps li { display: flex; gap: .5rem; align-items: flex-start; font-size: var(--fs-sub); color: #334155; line-height: 1.5; padding: .25rem 0; }
html.dark-mode .cb-steps li { color: #cbd5e1; }
.cb-step-n { flex: 0 0 auto; width: 1.3rem; height: 1.3rem; background: var(--qr-veil-accent-12); color: var(--qr-accent); border-radius: var(--r-full); font-size: var(--fs-caption); font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: .125rem; }
.cb-mission { display: flex; align-items: center; gap: .75rem; background: var(--qr-grad-wash); border: 1px solid rgba(37, 99, 235, .25); border-radius: var(--r-lg); padding: .75rem .75rem; margin: .5rem 0; cursor: pointer; transition: transform var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out); }
.cb-mission:active { transform: scale(var(--qr-press-lg)); }
html.dark-mode .cb-mission { background: var(--qr-veil-accent-12); }
.cb-mission-main { flex: 1; min-width: 0; }
.cb-mission-title { font-weight: 800; color: var(--qr-text); font-size: var(--fs-body); }
html.dark-mode .cb-mission-title { color: #f1f5f9; }
.cb-mission-why { font-size: var(--fs-caption); color: var(--qr-text-dim); margin-top: .125rem; }
.cb-mission-go { flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: var(--r-full); background: var(--qr-accent); color: var(--qr-on-accent); display: flex; align-items: center; justify-content: center; font-size: var(--fs-caption); }
.cb-timeline { list-style: none; margin: .5rem 0; padding: 0 0 0 .25rem; }
.cb-timeline li { display: flex; gap: .5rem; align-items: flex-start; padding: .25rem 0; position: relative; }
.cb-tl-dot { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; background: #cbd5e1; margin-top: .25rem; border: 2px solid #f8fafc; }
.cb-timeline li.done .cb-tl-dot { background: var(--qr-success); }
.cb-timeline b { font-size: var(--fs-sub); color: var(--qr-text); } html.dark-mode .cb-timeline b { color: #e2e8f0; }
.cb-tl-sub { display: block; font-size: var(--fs-caption); color: #94a3b8; }
.cb-celebrate { background: var(--qr-grad-wash); border-radius: var(--r-lg); padding: .75rem .75rem; margin: .5rem 0; font-weight: 700; color: #166534; font-size: var(--fs-sub); }
html.dark-mode .cb-celebrate { color: #86efac; }
.cb-callout { border-radius: var(--r-lg); padding: .5rem .75rem; margin: .5rem 0; font-size: var(--fs-sub); line-height: 1.45; }
.cb-callout.tone-info { background: var(--qr-veil-accent-8); color: #1e40af; } html.dark-mode .cb-callout.tone-info { color: #93c5fd; }
.cb-callout.tone-warn { background: rgba(217, 119, 6, .1); color: #9a3412; } html.dark-mode .cb-callout.tone-warn { color: #fdba74; }
.cb-callout.tone-success { background: rgba(16, 163, 74, .1); color: #166534; } html.dark-mode .cb-callout.tone-success { color: #86efac; }

/* ADR-103: quiet "N free explanations left" note under a free user's QuanAI explanation. */
.companion-free-note { margin: .5rem 0 .125rem; font-size: var(--fs-caption); opacity: .6; text-align: center; }

/* chips */
.companion-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 .25rem; }
.companion-chip { border: 1px solid var(--qr-veil-ink-14); background: var(--qr-surface-solid); color: #1e293b; border-radius: var(--r-full); padding: .5rem .75rem; font-size: var(--fs-sub); font-weight: 600; cursor: pointer; transition: transform var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast) var(--qr-ease-out); min-height: 38px; }
.companion-chip:active { transform: scale(var(--qr-press-sm)); }
html.dark-mode .companion-chip { background: var(--qr-veil-w-6); color: #e2e8f0; border-color: var(--qr-veil-w-14); }
.companion-chip.kind-deeplink { background: var(--qr-accent); color: var(--qr-on-accent); border-color: var(--qr-accent); }
.companion-chip.kind-drill { background: var(--qr-accent); color: var(--qr-on-accent); border-color: var(--qr-accent); }
.companion-chip.kind-dismiss { background: transparent; color: var(--qr-text-dim); border-color: transparent; }

/* in-place micro-drill (ADR-045) — runs inside the AI modal, never navigates */
.companion-quiz { border: 1px solid rgba(37, 99, 235, .22); background: rgba(37, 99, 235, .05); border-radius: var(--r-lg); padding: 1rem 1rem; }
.cq-head { font-size: var(--fs-caption); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--qr-accent); margin-bottom: .5rem; }
.cq-q { font-size: var(--fs-body); font-weight: 600; color: var(--qr-text); line-height: 1.4; margin-bottom: .75rem; }
html.dark-mode .cq-q { color: #f1f5f9; }
.cq-form { display: flex; gap: .5rem; }
.cq-input { flex: 1; min-width: 0; padding: .5rem .75rem; border: 1px solid rgba(15, 23, 42, .18); border-radius: var(--r-md); font-size: var(--fs-body); font-weight: 600; background: var(--qr-surface-solid); color: var(--qr-text); }
html.dark-mode .cq-input { background: var(--qr-veil-w-6); color: #f1f5f9; border-color: rgba(255, 255, 255, .16); }
.cq-input:disabled { opacity: .7; }
.cq-go { border: none; background: var(--qr-accent); color: var(--qr-on-accent); font-weight: 700; border-radius: var(--r-md); padding: .5rem 1rem; cursor: pointer; }
.cq-go:disabled { opacity: .5; }
.cq-fb { min-height: 1.1rem; margin-top: .5rem; font-size: var(--fs-sub); font-weight: 700; }
.cq-fb.good { color: var(--qr-success); }
.cq-fb.bad { color: var(--qr-danger); }
.cq-result { font-size: var(--fs-body); font-weight: 600; color: var(--qr-text); text-align: center; padding: .25rem 0; }
html.dark-mode .cq-result { color: #f1f5f9; }

/* staged loading skeleton */
.companion-loading { padding: .5rem 0; }
.companion-skel { height: 14px; border-radius: var(--r-sm); background: var(--qr-grad-skel); background-size: 400% 100%; animation: cpnShimmer calc(var(--qr-dur-pulse) * 1.0834) var(--qr-ease-out) infinite; margin: .5rem 0; }
html.dark-mode .companion-skel { background: var(--qr-grad-skel); background-size: 400% 100%; }
.companion-skel.sk1 { width: 90%; } .companion-skel.sk2 { width: 70%; } .companion-skel.sk3 { width: 80%; }
@keyframes cpnShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.companion-loadmsg { font-size: var(--fs-sub); color: #94a3b8; margin-top: .5rem; font-weight: 600; }

/* ---- QuanAI Planner setup wizard (ADR-046) ---- */
.ps-dots { display: flex; gap: .25rem; justify-content: center; margin: .25rem 0 1rem; }
.ps-dots span { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--qr-veil-ink-14); transition: background var(--qr-dur) var(--qr-ease-out), width var(--qr-dur) var(--qr-ease-out); }
.ps-dots span.on { width: 20px; background: var(--qr-accent); }
.ps-dots span.done { background: #93c5fd; }
html.dark-mode .ps-dots span { background: rgba(255, 255, 255, .16); }
.ps-screen .cb-say { margin-bottom: 1rem; }
.ps-sub { font-weight: 500; color: #94a3b8; font-size: var(--fs-sub); }
.ps-search, .ps-custom, .ps-date { width: 100%; box-sizing: border-box; border: 1px solid rgba(15, 23, 42, .16); border-radius: var(--r-md); padding: .75rem .75rem; font-size: var(--fs-body); margin-bottom: .75rem; background: var(--qr-surface-solid); color: var(--qr-text); }
html.dark-mode .ps-search, html.dark-mode .ps-custom, html.dark-mode .ps-date { background: var(--qr-veil-w-6); color: #e2e8f0; border-color: rgba(255, 255, 255, .16); }
.ps-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.ps-opt { text-align: left; border: 1px solid var(--qr-veil-ink-14); background: var(--qr-surface-solid); color: #1e293b; border-radius: var(--r-md); padding: .75rem .75rem; font-size: var(--fs-body); font-weight: 600; cursor: pointer; transition: border-color var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out); }
.ps-opt.big { padding: .75rem; }
.ps-opt.sel { border-color: var(--qr-accent); background: var(--qr-veil-accent-8); color: var(--qr-accent-strong); }
html.dark-mode .ps-opt { background: var(--qr-veil-w-5); color: #e2e8f0; border-color: var(--qr-veil-w-14); }
html.dark-mode .ps-opt.sel { background: rgba(37, 99, 235, .22); color: #bfdbfe; border-color: #3b82f6; }
.ps-stack { display: flex; flex-direction: column; gap: .5rem; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ps-hint { font-size: var(--fs-sub); color: var(--qr-text-dim); font-weight: 600; margin-top: .25rem; text-align: center; }
.ps-bigval { text-align: center; font-size: var(--fs-h1); color: var(--qr-accent); margin: .25rem 0 .75rem; }
html.dark-mode .ps-bigval { color: #60a5fa; }
.ps-range { width: 100%; margin: .25rem 0 1rem; accent-color: var(--qr-accent); }
.ps-presets { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.ps-chip { border: 1px solid var(--qr-veil-ink-14); background: var(--qr-surface-solid); color: #475569; border-radius: var(--r-full); padding: .5rem .75rem; font-size: var(--fs-sub); font-weight: 600; cursor: pointer; }
.ps-chip.sel { background: var(--qr-accent); color: var(--qr-on-accent); border-color: var(--qr-accent); }
html.dark-mode .ps-chip { background: var(--qr-veil-w-6); color: #cbd5e1; border-color: var(--qr-veil-w-14); }
.ps-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; margin-bottom: .5rem; }
.ps-day { aspect-ratio: 1; border: 1px solid var(--qr-veil-ink-14); background: var(--qr-surface-solid); color: #475569; border-radius: var(--r-md); font-weight: 700; font-size: var(--fs-body); cursor: pointer; }
.ps-day.sel { background: var(--qr-accent); color: var(--qr-on-accent); border-color: var(--qr-accent); }
html.dark-mode .ps-day { background: var(--qr-veil-w-6); color: #cbd5e1; border-color: var(--qr-veil-w-14); }
.ps-nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1rem; }
.ps-nav .ps-next { min-width: 110px; }
.ps-nav .companion-chip[disabled] { opacity: .4; cursor: not-allowed; }
.planner-loading { text-align: center; color: #94a3b8; font-weight: 600; padding: 2.5rem 0; }
.planner-empty { text-align: center; padding: 3rem 1rem; }
.planner-empty .pe-emoji { font-size: var(--fs-icon); }
.planner-empty h2 { margin: .5rem 0 .25rem; font-size: var(--fs-h1); color: var(--qr-text); }
html.dark-mode .planner-empty h2 { color: #e2e8f0; }
.planner-empty p { color: var(--qr-text-dim); max-width: 380px; margin: 0 auto 1.25rem; line-height: 1.5; }
.planner-cta, .planner-regen { background: var(--qr-accent); color: var(--qr-on-accent); border: none; border-radius: var(--r-md); padding: .75rem 1.25rem; font-size: var(--fs-body); font-weight: 700; cursor: pointer; }
.planner-regen { width: 100%; margin-top: .5rem; }
.planner-top { display: flex; align-items: center; gap: .75rem; padding: .5rem 0 1rem; }
.planner-adjust { border: 1px solid var(--qr-veil-ink-14); background: var(--qr-surface-solid); color: #1e293b; border-radius: var(--r-md); padding: .5rem .5rem; font-weight: 700; cursor: pointer; }
html.dark-mode .planner-adjust { background: var(--qr-veil-w-6); color: #e2e8f0; border-color: var(--qr-veil-w-14); }
.planner-titles { flex: 1; }
.planner-title { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); }
html.dark-mode .planner-title { color: #e2e8f0; }
.planner-sub { font-size: var(--fs-sub); color: var(--qr-text-dim); font-weight: 600; }
.planner-readiness { display: flex; align-items: center; gap: 1rem; background: var(--qr-grad-wash); border: 1px solid rgba(37, 99, 235, .14); border-radius: var(--r-lg); padding: 1rem; margin-bottom: 1rem; }
.pr-ring .pr-bg { fill: none; stroke: var(--qr-veil-ink-10); stroke-width: 7; }
.pr-ring .pr-fg { fill: none; stroke: var(--qr-accent); stroke-width: 7; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset var(--qr-dur-slow) var(--qr-ease-out); }
.pr-ring .pr-num { fill: var(--qr-accent-strong); font-size: var(--fs-h2); font-weight: 800; text-anchor: middle; }
html.dark-mode .pr-ring .pr-bg { stroke: var(--qr-veil-w-12); }
html.dark-mode .pr-ring .pr-num { fill: #93c5fd; }
.pr-band { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); }
html.dark-mode .pr-band { color: #e2e8f0; }
.pr-label { font-size: var(--fs-caption); color: var(--qr-text-dim); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.pr-forecast { font-size: var(--fs-sub); color: var(--qr-accent-strong); font-weight: 600; margin-top: .25rem; }
.pr-forecast.is-behind { color: #d97706; }
.planner-rationale { font-size: var(--fs-sub); color: #334155; line-height: 1.5; background: var(--qr-veil-ink-3); border-radius: var(--r-md); padding: .75rem .75rem; margin-bottom: 1rem; }
html.dark-mode .planner-rationale { color: #cbd5e1; background: var(--qr-veil-w-4); }
.planner-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; margin-bottom: 1rem; }
.pd-cell { display: flex; flex-direction: column; align-items: center; gap: .125rem; border: 1px solid var(--qr-veil-ink-10); background: var(--qr-surface-solid); border-radius: var(--r-md); padding: .5rem .25rem; cursor: pointer; min-height: 58px; transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast) var(--qr-ease-out); }
.pd-cell:active { transform: scale(var(--qr-press-sm)); }
html.dark-mode .pd-cell { background: var(--qr-veil-w-4); border-color: var(--qr-veil-w-10); }
.pd-dow { font-size: var(--fs-micro); color: #94a3b8; font-weight: 700; text-transform: uppercase; }
.pd-num { font-size: var(--fs-h3); font-weight: 800; color: #1e293b; }
html.dark-mode .pd-num { color: #e2e8f0; }
.pd-tag { font-size: var(--fs-micro); font-weight: 700; color: var(--qr-text-dim); min-height: .8em; }
.pd-cell.k-st { border-top: 3px solid var(--qr-accent); } .pd-cell.k-rv { border-top: 3px solid var(--qr-info-fg); }
.pd-cell.k-mk { border-top: 3px solid #db2777; } .pd-cell.k-bf { border-top: 3px solid #d97706; }
.pd-cell.k-rs { border-top: 3px solid rgba(15, 23, 42, .12); } .pd-cell.k-ms { border-top: 3px solid var(--qr-danger); opacity: .7; }
.pd-cell.is-today { box-shadow: var(--qr-focus-ring); }
.pd-cell.is-sel { border-color: var(--qr-accent); background: var(--qr-veil-accent-8); }
.pd-cell.is-complete .pd-tag { color: var(--qr-success); }
.pday-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.pday-kind { font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: .25rem .5rem; border-radius: var(--r-full); color: var(--qr-on-accent); background: var(--qr-accent); }
.pday-kind.k-rv { background: var(--qr-info-fg); } .pday-kind.k-mk { background: #db2777; } .pday-kind.k-bf { background: #d97706; }
.pday-kind.k-rs { background: #94a3b8; } .pday-kind.k-ms { background: var(--qr-danger); }
.pday-date { font-size: var(--fs-sub); color: var(--qr-text-dim); font-weight: 700; }
.pday-empty { color: #94a3b8; font-style: italic; padding: 1rem 0; text-align: center; }
.pday-tasks { display: flex; flex-direction: column; gap: .5rem; }
.pt-task { display: flex; align-items: flex-start; gap: .75rem; border: 1px solid var(--qr-veil-ink-10); border-radius: var(--r-md); padding: .75rem; background: var(--qr-surface-solid); }
html.dark-mode .pt-task { background: var(--qr-veil-w-4); border-color: var(--qr-veil-w-10); }
.pt-task.is-done { opacity: .62; }
.pt-task.is-done .pt-title { text-decoration: line-through; }
.pt-check { width: 22px; height: 22px; margin-top: .125rem; accent-color: var(--qr-success); flex-shrink: 0; cursor: pointer; }
.pt-main { flex: 1; min-width: 0; }
.pt-title { font-weight: 700; color: var(--qr-text); font-size: var(--fs-body); }
html.dark-mode .pt-title { color: #e2e8f0; }
.pt-meta { font-size: var(--fs-caption); color: var(--qr-text-dim); margin-top: .125rem; display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.pt-dot { color: #cbd5e1; }
.pt-diff { font-weight: 700; text-transform: capitalize; }
.pt-diff.d-easy { color: var(--qr-success); } .pt-diff.d-medium { color: #d97706; } .pt-diff.d-hard { color: var(--qr-danger); }
.pt-reason { font-size: var(--fs-caption); color: #475569; margin-top: .25rem; line-height: 1.4; }
html.dark-mode .pt-reason { color: #94a3b8; }
/* Planner footer — three clear actions: Rebuild (primary), an optional end-of-block hint, and a de-emphasized,
   hairline-separated destructive "Start over" (ADR-070). */
.planner-foot { margin-top: 1.25rem; display: flex; flex-direction: column; align-items: stretch; gap: .5rem; }
.planner-foot .planner-regen { margin-top: 0; }
.planner-foot-hint { font-size: var(--fs-caption); color: var(--qr-text-dim); text-align: center; font-weight: 600; }
html.dark-mode .planner-foot-hint { color: #94a3b8; }
.planner-startover { margin-top: .25rem; padding-top: .75rem; border: none; border-top: 1px solid var(--qr-veil-ink-8); background: none; color: var(--qr-danger); font-weight: 700; font-size: var(--fs-sub); cursor: pointer; text-align: center; }
html.dark-mode .planner-startover { border-top-color: var(--qr-veil-w-10); color: #f87171; }

/* Start-over confirm body (delete/keep lists) — rendered inside the shared .qr-dialog shell (FW-W2);
   the bespoke .qr-confirm shell (overlay/card/title/actions/buttons) was deleted with that migration. */
.qr-confirm-lead { text-align: left; font-size: var(--fs-sub); color: #475569; line-height: 1.5; margin-bottom: .5rem; }
html.dark-mode .qr-confirm-lead { color: #cbd5e1; }
.qr-confirm-list-label { text-align: left; font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--qr-text-dim); margin: .75rem 0 .25rem; }
.qr-confirm-list { list-style: none; margin: 0 0 .25rem; padding: 0; }
.qr-confirm-list li { text-align: left; font-size: var(--fs-sub); line-height: 1.45; padding: .125rem 0 .125rem 1.25rem; position: relative; color: #334155; }
html.dark-mode .qr-confirm-list li { color: #cbd5e1; }
.qr-confirm-list.is-del li::before { content: '\2715'; position: absolute; left: 0; color: var(--qr-danger); font-weight: 800; }
.qr-confirm-list.is-keep li::before { content: '\2713'; position: absolute; left: 0; color: var(--qr-success); font-weight: 800; }
.qr-confirm-note { text-align: left; font-size: var(--fs-caption); color: var(--qr-text-dim); line-height: 1.45; margin: .5rem 0 0; }
html.dark-mode .qr-confirm-note { color: #94a3b8; }

/* ---- ADR-057: the strategy dashboard (readiness → path → focus → triage) ---- */
.pr-projected { font-size: var(--fs-caption); color: #475569; font-weight: 600; margin-top: .25rem; }
html.dark-mode .pr-projected { color: #94a3b8; }
.planner-verdict { font-size: var(--fs-body); line-height: 1.5; color: var(--qr-text); font-weight: 600; background: rgba(37, 99, 235, .06); border-left: 3px solid var(--qr-accent); border-radius: var(--r-round-r); padding: .75rem .75rem; margin-bottom: 1rem; }
html.dark-mode .planner-verdict { color: #e2e8f0; background: rgba(96, 165, 250, .1); }
.planner-recovery { display: flex; align-items: center; gap: .75rem; background: rgba(217, 119, 6, .1); border: 1px solid rgba(217, 119, 6, .28); border-radius: var(--r-md); padding: .75rem .75rem; margin-bottom: 1rem; }
.prc-text { flex: 1; font-size: var(--fs-sub); color: #92400e; line-height: 1.45; }
html.dark-mode .prc-text { color: #fbbf24; }
.planner-section-title { font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--qr-text-dim); margin: 1rem 0 .5rem; }
.planner-sched-title { border-top: 1px solid var(--qr-veil-ink-8); padding-top: 1rem; margin-top: 1.5rem; }
html.dark-mode .planner-sched-title { border-color: var(--qr-veil-w-8); }
.pm { display: flex; gap: .75rem; padding-bottom: 1rem; position: relative; }
.pm::before { content: ''; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--qr-veil-ink-10); }
.pm:last-child::before { display: none; }
html.dark-mode .pm::before { background: var(--qr-veil-w-12); }
.pm.is-done .pm-dot { background: var(--qr-success); box-shadow: var(--qr-ring-ok); }
.pm.is-active .pm-dot { background: var(--qr-accent); box-shadow: var(--qr-focus-ring); }
.pm.is-upcoming .pm-name { color: var(--qr-text-dim); }
.pm-now { font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--qr-on-accent); background: var(--qr-accent); border-radius: var(--r-full); padding: .125rem .25rem; vertical-align: middle; }
.pm-bar { height: 5px; border-radius: var(--r-full); background: var(--qr-veil-ink-8); margin-top: .5rem; overflow: hidden; }
.pm-bar span { display: block; height: 100%; background: var(--qr-accent); border-radius: var(--r-full); transition: width var(--qr-dur-slow) var(--qr-ease-out); }
.pm.is-done .pm-bar span { background: var(--qr-success); }
html.dark-mode .pm-bar { background: var(--qr-veil-w-10); }
.planner-focus { display: flex; flex-direction: column; gap: .5rem; }
.pf { border: 1px solid var(--qr-veil-ink-10); border-radius: var(--r-md); padding: .75rem; background: var(--qr-surface-solid); }
html.dark-mode .pf { background: var(--qr-veil-w-4); border-color: var(--qr-veil-w-10); }
.pf-head { display: flex; align-items: center; gap: .75rem; }
.pf-label { flex: 1; font-weight: 700; color: var(--qr-text); font-size: var(--fs-body); min-width: 0; }
html.dark-mode .pf-label { color: #e2e8f0; }
.pf-why { font-size: var(--fs-sub); color: #475569; line-height: 1.45; margin-top: .25rem; }
html.dark-mode .pf-why { color: #94a3b8; }
.pf-impact { font-size: var(--fs-caption); color: var(--qr-success); font-weight: 700; margin-top: .25rem; }
.planner-triage { font-size: var(--fs-sub); color: var(--qr-text-dim); line-height: 1.5; background: var(--qr-veil-ink-3); border-radius: var(--r-md); padding: .75rem .75rem; margin-top: 1rem; }
html.dark-mode .planner-triage { color: #94a3b8; background: var(--qr-veil-w-4); }
.planner-triage strong { color: #475569; }
html.dark-mode .planner-triage strong { color: #cbd5e1; }


/* ───────── Stats rebuild (ADR-080) — "Am I getting better?" sections. Reuses cat-bar / strength-label / stat-card. ───────── */
.stats-block-cap { font-size: var(--fs-caption); color: var(--qr-text-dim); margin: 0 0 .5rem; line-height: 1.4; }
html.dark-mode .stats-block-cap { color: #94a3b8; }
.stats-block-cap strong { color: var(--qr-accent); }

/* subject split (today + time invested) */
.stats-split { margin-top: 1rem; }
.stats-split-row { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.stats-split-name { flex: 0 0 5.2rem; font-size: var(--fs-caption); font-weight: 600; color: #334155; }
.stats-split-bar { flex: 1; height: .5rem; background: var(--qr-surface-3); border-radius: 4px; overflow: hidden; }
.stats-split-fill { height: 100%; border-radius: 4px; background: var(--qr-grad-bar); }
.stats-split-val { flex: 0 0 auto; min-width: 2.4rem; text-align: right; font-size: var(--fs-caption); font-weight: 700; color: var(--qr-accent); }
html.dark-mode .stats-split-name { color: #cbd5e1; }
html.dark-mode .stats-split-bar { background: #334155; }
html.dark-mode .stats-split-val { color: #93c5fd; }

/* subject mastery rows */
.stats-mastery-row { padding: .75rem 0; border-bottom: 1px solid #f1f5f9; }
.stats-mastery-row:last-child { border-bottom: none; }
html.dark-mode .stats-mastery-row { border-bottom-color: #334155; }
.stats-mastery-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .25rem; }
.stats-mastery-name { font-size: var(--fs-body); font-weight: 700; color: var(--qr-text); }
.stats-mastery-pct { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-accent); }
html.dark-mode .stats-mastery-name { color: #f1f5f9; }
html.dark-mode .stats-mastery-pct { color: #93c5fd; }
.stats-mastery-meta { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.stats-mastery-sub { font-size: var(--fs-caption); color: #94a3b8; }
.stats-mastery-weak { font-size: var(--fs-caption); color: #b45309; margin-top: .25rem; }
html.dark-mode .stats-mastery-weak { color: #fcd34d; }

/* study next */
.stats-weak-row { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; background: none; border: none; cursor: pointer; padding: .5rem 0; border-bottom: 1px solid #f1f5f9; transition: background var(--qr-dur-fast) var(--qr-ease-out); }
.stats-weak-row:last-child { border-bottom: none; }
.stats-weak-row:active { background: rgba(37,99,235,.05); }
html.dark-mode .stats-weak-row { border-bottom-color: #334155; }
.stats-weak-name { flex: 0 0 7rem; font-size: var(--fs-sub); font-weight: 600; color: var(--qr-text); }
html.dark-mode .stats-weak-name { color: #e2e8f0; }
.stats-weak-row .cat-bar-container { flex: 1; }
.stats-weak-go { flex: 0 0 auto; font-size: var(--fs-caption); font-weight: 700; color: var(--qr-accent); }

/* QuanAI recommendation card */
.stats-rec-card { padding: .25rem 0; }
.stats-rec-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.stats-rec-ico { --qr-ico-size: var(--fs-h3); font-size: var(--fs-h3); }
.stats-rec-by { font-size: var(--fs-caption); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--qr-accent); }
.stats-rec-text { margin: 0 0 1rem; font-size: var(--fs-body); line-height: 1.5; color: #334155; }
html.dark-mode .stats-rec-text { color: #cbd5e1; }
.stats-rec-text strong { color: var(--qr-text); font-weight: 800; }
html.dark-mode .stats-rec-text strong { color: #f1f5f9; }
.stats-rec-btn { min-height: 46px; font-size: var(--fs-body); }

/* ---- ADR-062: transparent readiness + clearer labels ---- */
.planner-readiness.is-tappable { cursor: pointer; border-radius: var(--r-lg); transition: background var(--qr-dur-fast); }
.planner-readiness.is-tappable:hover, .planner-readiness.is-expanded { background: rgba(37, 99, 235, .06); }
.pr-sub { font-weight: 600; color: #94a3b8; font-size: var(--fs-caption); }
.pr-why { font-size: var(--fs-caption); color: var(--qr-accent); font-weight: 700; margin-top: .25rem; }
html.dark-mode .pr-why { color: #93c5fd; }
.planner-readiness-detail { margin: .25rem 0 .5rem; padding: .75rem .75rem; border: 1px solid rgba(37, 99, 235, .2); border-radius: var(--r-md); background: rgba(37, 99, 235, .04); }
html.dark-mode .planner-readiness-detail { background: var(--qr-veil-accent-8); border-color: rgba(37, 99, 235, .3); }
.prd-summary { font-size: var(--fs-sub); font-weight: 700; color: #1e293b; margin-bottom: .5rem; }
html.dark-mode .prd-summary { color: #e2e8f0; }
.prd-row { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; }
.prd-flabel { flex: 0 0 9.5rem; font-size: var(--fs-caption); color: #475569; }
html.dark-mode .prd-flabel { color: #cbd5e1; }
.prd-bar { flex: 1; height: 7px; border-radius: 4px; background: var(--qr-veil-ink-10); overflow: hidden; }
html.dark-mode .prd-bar { background: var(--qr-veil-w-12); }
.prd-bar > span { display: block; height: 100%; background: var(--qr-grad-bar); }
.prd-fpct { flex: 0 0 2.6rem; text-align: right; font-size: var(--fs-caption); font-weight: 700; color: #334155; }
html.dark-mode .prd-fpct { color: #cbd5e1; }
.prd-note { font-size: var(--fs-caption); color: #94a3b8; margin-top: .5rem; }
.psec-progresslabel { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; margin-top: .25rem; }
html.dark-mode .psec-progresslabel { color: #94a3b8; }

/* ---- ADR-059: section path + session-typed study blocks ---- */
.planner-sections { display: flex; flex-direction: column; gap: .5rem; }
.psec { border: 1px solid var(--qr-veil-ink-10); border-radius: var(--r-md); overflow: hidden; background: var(--qr-surface-solid); }
html.dark-mode .psec { background: var(--qr-veil-w-4); border-color: var(--qr-veil-w-10); }
.psec.is-active { border-color: rgba(37, 99, 235, .35); box-shadow: var(--qr-glow-accent); }
.psec-head { padding: .75rem .75rem; cursor: pointer; }
.psec-title { font-weight: 800; color: var(--qr-text); font-size: var(--fs-body); }
html.dark-mode .psec-title { color: #e2e8f0; }
.psec.is-upcoming .psec-title { color: var(--qr-text-dim); }
.psec.is-done .psec-title::after { content: ' ✓'; color: var(--qr-success); }
.psec-meta { font-size: var(--fs-caption); color: #94a3b8; font-weight: 600; margin: .125rem 0 .5rem; }
.psec-topics { max-height: 0; overflow: hidden; transition: max-height var(--qr-dur) var(--qr-ease-out); padding: 0 .75rem; }
.psec.is-open .psec-topics, .psec.is-active .psec-topics { max-height: 1200px; padding: 0 .75rem .5rem; }
.psec-topic { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .25rem 0; border-top: 1px dashed var(--qr-veil-ink-8); }
html.dark-mode .psec-topic { border-color: var(--qr-veil-w-8); }
.psec-tlabel { font-size: var(--fs-sub); color: #334155; }
html.dark-mode .psec-tlabel { color: #cbd5e1; }
.psec-tmeta { font-size: var(--fs-caption); color: #94a3b8; font-weight: 600; white-space: nowrap; }
.pf-pri { font-size: var(--fs-caption); font-weight: 800; color: var(--qr-accent); background: rgba(37, 99, 235, .1); border-radius: var(--r-sm); padding: .125rem .25rem; }
.pf-tags { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; margin-top: .25rem; }
.pf-unlocks { font-size: var(--fs-caption); color: var(--qr-info-fg); margin-top: .25rem; }.pf-suggest, .pt-suggest { font-size: var(--fs-caption); color: var(--qr-accent); margin-top: .5rem; }
html.dark-mode .pf-suggest, html.dark-mode .pt-suggest { color: #93c5fd; }
.pt-suggest.pt-ext { color: #94a3b8; }
.pt-unlocks { font-size: var(--fs-caption); color: var(--qr-info-fg); margin-top: .25rem; }.pt-st { font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; border-radius: var(--r-full); padding: .125rem .25rem; vertical-align: middle; }

/* ---- ADR-049 micro-polish: premium calendar feel ---- */
.pd-cell { transition: transform var(--qr-dur-fast) var(--qr-ease), border-color var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out); }
.pd-cell:active { transform: scale(var(--qr-press-sm)); }
.pd-cell.is-sel { transform: translateY(-1px); box-shadow: var(--qr-glow-accent); }
.pd-cell.is-today .pd-num { color: var(--qr-accent); }
html.dark-mode .pd-cell.is-today .pd-num { color: #93c5fd; }
.pd-cell.is-complete { animation: pdPop var(--qr-dur) var(--qr-ease-out); }
@keyframes pdPop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }
.pt-task { transition: opacity var(--qr-dur) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out); }
.pt-check { transition: transform var(--qr-dur-fast) var(--qr-ease-out); } .pt-check:active { transform: scale(1.15); }
.pr-fg { transition: stroke-dashoffset var(--qr-dur-slow) var(--qr-ease); }

/* ---- ADR-049 responsiveness: the week grid + ring on small phones ---- */
@media (max-width: 400px) {
  .planner-readiness { flex-direction: column; align-items: center; text-align: center; gap: .5rem; }
  .pr-ring { width: 60px; height: 60px; }
  .pd-cell { min-height: 52px; padding: .25rem .125rem; }
  .pd-num { font-size: var(--fs-body); }
  .planner-grid { gap: .25rem; }
}
@media (max-width: 340px) {
  .pd-cell { min-height: 48px; }
  .pd-dow { font-size: var(--fs-micro); }
  .pd-tag { font-size: var(--fs-micro); }
}

@media (prefers-reduced-motion: reduce) {
  .companion-overlay, .companion-sheet, .companion-turn.is-new, .companion-typing i, .companion-skel, .cb-mission, .ps-dots span,
  .cb-stagger, .cb-progress-bar i,
  .pd-cell, .pd-cell.is-complete, .pt-task, .pt-check, .pr-fg { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════ Battle Archive (ADR-068) — Premium duel history ═══════════════════════════ */
/* Premium-only, expands INLINE inside #homeDuelCard. Inherits the app's card tokens + the duel design language. */

.ba-section { margin-top: .75rem; border-top: 1px solid rgba(15,23,42,0.07); padding-top: .75rem; }
html.dark-mode .ba-section { border-top-color: var(--qr-veil-w-8); }

/* ---- trigger button on the duel card (opens the modal) ---- */
.ba-open {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  background: var(--qr-grad-wash-duel);
  border: 1px solid rgba(217,119,6,0.22); border-radius: var(--qr-btn-radius);
  padding: .75rem .75rem; cursor: pointer; font: inherit; color: inherit;
  transition: background var(--qr-dur) var(--qr-ease-out), border-color var(--qr-dur) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
}
.ba-open:hover { background: var(--qr-grad-wash-duel); }
.ba-open:active { transform: scale(var(--qr-press-lg)); }
.ba-open:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.ba-open-icon { font-size: var(--fs-h3); }
.ba-open-label { font-weight: 700; font-size: var(--fs-body); flex: 1; text-align: left; letter-spacing: .01em; }
.ba-open-chevron { font-size: var(--fs-h3); opacity: .55; font-weight: 700; }
.ba-count {
  display: inline-block; min-width: 1.3rem; text-align: center; padding: 0 .25rem; margin-left: .25rem;
  font-size: var(--fs-caption); font-weight: 800; line-height: 1.35rem; height: 1.35rem;
  background: #d97706; color: var(--qr-on-accent); border-radius: var(--r-md); vertical-align: middle;
}
html.dark-mode .ba-open { border-color: rgba(245,158,11,0.28); }

/* ---- centered premium modal (reuses the paywall shell's dim / scale-in / fade keyframes) ---- */
.ba-modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(11,18,32,.62); -webkit-backdrop-filter: var(--glass-scrim); backdrop-filter: var(--glass-scrim);
  animation: paywallFadeIn var(--qr-dur) var(--qr-ease-out);
}
.ba-modal-overlay.closing { animation: paywallFadeOut var(--qr-dur) var(--qr-ease-out) forwards; }
.ba-modal-card {
  position: relative; width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  background: var(--qr-bg, var(--qr-bg)); border-radius: var(--qr-card-radius);
  box-shadow: var(--el-3); overflow: hidden;
  animation: paywallScaleIn var(--qr-dur-slow) var(--qr-ease-out);
}
html.dark-mode .ba-modal-card { background: #0f172a; }
.ba-modal-head {
  position: sticky; top: 0; z-index: var(--z-above); display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 1rem 1rem .75rem; border-bottom: var(--qr-card-border-light);
  background: rgba(248,250,252,.82); -webkit-backdrop-filter: var(--glass-scrim); backdrop-filter: var(--glass-scrim);
}
html.dark-mode .ba-modal-head { background: rgba(15,23,42,.82); border-bottom-color: var(--qr-veil-w-8); }
.ba-modal-title { margin: 0; font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); outline: none; }
html.dark-mode .ba-modal-title { color: #f1f5f9; }
.ba-modal-close {
  flex: 0 0 auto; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: none; cursor: pointer;
  background: var(--qr-veil-ink-6); color: inherit; font-size: var(--fs-sub); line-height: 1; transition: background var(--qr-dur-fast), transform var(--qr-dur-fast) var(--qr-ease-out);
}
.ba-modal-close:hover { background: rgba(15,23,42,.12); }
.ba-modal-close:active { transform: scale(var(--qr-press-sm)); }
.ba-modal-close:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
html.dark-mode .ba-modal-close { background: var(--qr-veil-w-10); }
html.dark-mode .ba-modal-close:hover { background: rgba(255,255,255,.16); }
.ba-modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 1rem 1rem 1.25rem; }
@keyframes baReveal { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Practice subject picker (ADR-080) — reuses the Battle-Archives shell; just a narrower card + subject cards ---- */
.ba-modal-card.psm-card-wrap { width: min(460px, 100%); }
.psm-grid { display: flex; flex-direction: column; gap: .5rem; }
.psm-card {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; cursor: pointer;
  padding: .75rem .75rem; border-radius: var(--qr-card-radius-sm);
  border: 1.5px solid var(--qr-veil-ink-8); background: var(--qr-surface-solid);
  transition: transform var(--qr-dur-fast) var(--qr-spring), border-color var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out);
}
.psm-card:hover { border-color: #bfdbfe; box-shadow: var(--el-2); }
.psm-card:active { transform: scale(var(--qr-press-lg)); }
.psm-card.is-last { border-color: #93c5fd; background: rgba(37,99,235,.04); }
.psm-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.psm-ico { flex: 0 0 auto; width: 2.6rem; height: 2.6rem; display: flex; align-items: center; justify-content: center; font-size: var(--fs-h1); border-radius: var(--r-lg); background: var(--qr-veil-accent-8); }
.psm-text { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.psm-title { font-size: var(--fs-body); font-weight: 700; color: var(--qr-text); }   /* ADR-131: was 750, off-scale */
.psm-last-tag { font-size: var(--fs-micro); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--qr-accent); background: var(--qr-veil-accent-12); padding: .125rem .25rem; border-radius: 4px; vertical-align: middle; margin-left: .25rem; }
.psm-desc { font-size: var(--fs-caption); color: #475569; line-height: 1.3; }
.psm-kinds { font-size: var(--fs-caption); color: #94a3b8; line-height: 1.3; }
.psm-dontask { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; font-size: var(--fs-caption); color: var(--qr-text-dim); cursor: pointer; }
.psm-dontask input { width: 1.05rem; height: 1.05rem; accent-color: var(--qr-accent); flex: 0 0 auto; }
html.dark-mode .psm-card { background: #1e293b; border-color: var(--qr-veil-w-8); }
html.dark-mode .psm-card.is-last { background: rgba(37,99,235,.16); border-color: rgba(96,165,250,.45); }
html.dark-mode .psm-title { color: #f1f5f9; }
html.dark-mode .psm-desc { color: #cbd5e1; }
html.dark-mode .psm-kinds { color: #94a3b8; }
html.dark-mode .psm-ico { background: rgba(37,99,235,.22); }
html.dark-mode .psm-dontask { color: #94a3b8; }

/* .ba-skeleton/.ba-skel-row co-declare with the .qr-skel primitive (FW-W3) — veil + pulse come
   from --qr-skel-veil / --qr-dur-pulse; the dark veil re-resolves through the token. */

/* ---- mini stat tile (shared by personal strip + rivalry + card detail) ---- */
.ba-mini { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem; padding: .5rem .25rem; text-align: center; min-width: 0; }
.ba-mini-val { font-weight: 800; font-size: var(--fs-body); color: var(--qr-text); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ba-mini-label { font-size: var(--fs-micro); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--qr-text-dim); }
html.dark-mode .ba-mini-val { color: #e2e8f0; }

/* ---- personal stats strip ---- */
.ba-personal { background: rgba(15,23,42,0.025); border: 1px solid var(--qr-veil-ink-6); border-radius: var(--qr-card-radius-sm); padding: .25rem .25rem; margin-bottom: .75rem; }
html.dark-mode .ba-personal { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.07); }
.ba-personal-row { display: grid; grid-template-columns: repeat(4, 1fr); }
.ba-personal-row + .ba-personal-row { border-top: 1px solid var(--qr-veil-ink-5); }
html.dark-mode .ba-personal-row + .ba-personal-row { border-top-color: var(--qr-veil-w-5); }

/* ---- rivalry banner ---- */
.ba-rivalry { position: relative; background: var(--qr-grad-wash-duel); border: 1px solid rgba(37,99,235,0.18); border-radius: var(--qr-card-radius-sm); padding: .75rem .5rem; margin-bottom: .75rem; }
html.dark-mode .ba-rivalry { border-color: rgba(96,165,250,0.22); }
.ba-rivalry-clear { position: absolute; top: .5rem; right: .5rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: none; background: var(--qr-veil-ink-8); color: inherit; cursor: pointer; font-size: var(--fs-caption); line-height: 1; }
html.dark-mode .ba-rivalry-clear { background: var(--qr-veil-w-12); }
.ba-rivalry-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.ba-rivalry-id { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ba-rivalry-vs { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .05em; color: var(--qr-text-dim); font-weight: 600; }
.ba-rivalry-name { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.dark-mode .ba-rivalry-name { color: #f1f5f9; }
.ba-rivalry-score { display: flex; align-items: center; gap: .25rem; font-weight: 800; font-size: var(--fs-h1); color: var(--qr-text); }
.ba-rivalry-score em { font-size: var(--fs-body); opacity: .5; font-style: normal; }
html.dark-mode .ba-rivalry-score { color: #f1f5f9; }
.ba-rivalry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .125rem; background: rgba(255,255,255,0.5); border-radius: var(--r-md); }
html.dark-mode .ba-rivalry-grid { background: rgba(2,6,23,0.25); }

/* ---- filters ---- */
.ba-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; align-items: center; }
.ba-chips { display: inline-flex; gap: .25rem; background: rgba(15,23,42,0.04); border-radius: var(--r-lg); padding: .25rem; }
html.dark-mode .ba-chips { background: var(--qr-veil-w-5); }
.ba-chip { border: none; background: transparent; color: #475569; font: inherit; font-size: var(--fs-caption); font-weight: 700; padding: .25rem .5rem; border-radius: var(--r-md); cursor: pointer; transition: background var(--qr-dur-fast) var(--qr-ease-out), color var(--qr-dur-fast) var(--qr-ease-out); }
html.dark-mode .ba-chip { color: #94a3b8; }
.ba-chip.is-active { background: var(--qr-surface-solid); color: var(--qr-text); box-shadow: var(--el-1); }
html.dark-mode .ba-chip.is-active { background: #1e293b; color: #f1f5f9; }
.ba-search { flex: 1; min-width: 8rem; border: 1px solid var(--qr-veil-ink-10); border-radius: var(--r-md); padding: .5rem .5rem; font: inherit; font-size: var(--fs-caption); background: var(--qr-surface-solid); color: var(--qr-text); }
html.dark-mode .ba-search { background: var(--qr-veil-w-5); border-color: var(--qr-veil-w-10); color: #f1f5f9; }

/* ---- battle list + cards ---- */
.ba-list { display: flex; flex-direction: column; gap: .5rem; }
.ba-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; background: var(--qr-surface-solid); border: 1px solid rgba(15,23,42,0.07); border-left: 3px solid #94a3b8; border-radius: var(--qr-card-radius-sm); padding: .5rem .5rem; cursor: pointer; transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out); }
.ba-card:hover { box-shadow: var(--el-2); }
.ba-card:active { transform: scale(var(--qr-press-lg)); }
.ba-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
html.dark-mode .ba-card { background: var(--qr-veil-w-4); border-color: rgba(255,255,255,0.07); }
.ba-card.is-win { border-left-color: var(--qr-success); }
.ba-card.is-loss { border-left-color: var(--qr-danger); }
.ba-card.is-draw { border-left-color: var(--qr-text-dim); }
.ba-card.is-nc { border-left-color: #94a3b8; opacity: .8; }
.ba-card-av { width: 2.4rem; height: 2.4rem; font-size: var(--fs-body); }
.ba-card-main { min-width: 0; }
.ba-card-top { display: flex; align-items: center; gap: .5rem; }
.ba-card-opp { font-size: var(--fs-sub); font-weight: 700; color: var(--qr-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.dark-mode .ba-card-opp { color: #f1f5f9; }
.ba-card-sub { font-size: var(--fs-caption); color: var(--qr-text-dim); margin-top: .125rem; }
.ba-badge { font-size: var(--fs-micro); font-weight: 800; letter-spacing: .05em; padding: .125rem .25rem; border-radius: var(--r-sm); }
.ba-badge.is-win { background: rgba(22,163,74,0.14); color: var(--qr-success); }
.ba-badge.is-loss { background: rgba(220,38,38,0.14); color: var(--qr-danger); }
.ba-badge.is-draw { background: rgba(100,116,139,0.16); color: var(--qr-text-dim); }
.ba-badge.is-nc { background: rgba(100,116,139,0.12); color: #94a3b8; }
.ba-card-score { display: flex; align-items: center; gap: .25rem; font-weight: 800; font-size: var(--fs-h3); color: var(--qr-text); }
.ba-card-score em { font-size: var(--fs-caption); opacity: .45; font-style: normal; }
html.dark-mode .ba-card-score { color: #f1f5f9; }

/* ---- card expand-in-place detail ---- */
.ba-card-detail { grid-column: 1 / -1; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--qr-veil-ink-6); animation: baReveal var(--qr-dur) var(--qr-ease-out); }
html.dark-mode .ba-card-detail { border-top-color: rgba(255,255,255,0.07); }
.ba-detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .125rem; }
.ba-detail-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }
.ba-detail-rival { border: none; background: transparent; color: var(--qr-accent); font: inherit; font-size: var(--fs-caption); font-weight: 700; cursor: pointer; padding: 0; }
html.dark-mode .ba-detail-rival { color: #60a5fa; }
@media (max-width: 400px) { .ba-detail-grid { grid-template-columns: repeat(2, 1fr); } .ba-personal-row { grid-template-columns: repeat(2, 1fr); } }

.ba-loadmore { width: 100%; margin-top: .25rem; padding: .5rem; border: 1px dashed rgba(15,23,42,0.18); border-radius: var(--qr-btn-radius); background: transparent; color: #475569; font: inherit; font-weight: 700; font-size: var(--fs-caption); cursor: pointer; }
html.dark-mode .ba-loadmore { border-color: rgba(255,255,255,0.18); color: #94a3b8; }
.ba-loadmore:hover { background: var(--qr-veil-ink-3); }
.ba-noresults { text-align: center; color: var(--qr-text-dim); font-size: var(--fs-sub); padding: 1rem .5rem; }

/* ---- empty state ---- */
.ba-empty { text-align: center; padding: 1.5rem .75rem; }
.ba-empty-art { font-size: var(--fs-icon); margin-bottom: .5rem; filter: drop-shadow(0 4px 10px rgba(217,119,6,0.25)); animation: baFloat calc(var(--qr-dur-pulse) * 2.5) var(--qr-ease) infinite; }
@keyframes baFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.ba-empty-title { font-size: var(--fs-h3); font-weight: 800; margin: 0 0 .25rem; color: var(--qr-text); }
html.dark-mode .ba-empty-title { color: #f1f5f9; }
.ba-empty-sub { font-size: var(--fs-sub); color: var(--qr-text-dim); margin: 0 auto 1rem; max-width: 22rem; line-height: 1.45; }
.ba-empty-cta { background: var(--qr-grad-duel); color: var(--qr-on-accent); border: none; border-radius: var(--qr-btn-radius); padding: .75rem 1rem; font: inherit; font-weight: 800; font-size: var(--fs-sub); cursor: pointer; box-shadow: var(--qr-glow-duel); transition: transform var(--qr-dur-fast) var(--qr-ease-out); }
.ba-empty-cta:active { transform: scale(var(--qr-press-sm)); }

/* ---- achievements ---- */
.ba-ach-wrap { margin-top: .75rem; }
.ba-ach-head { font-size: var(--fs-caption); font-weight: 800; letter-spacing: .02em; color: var(--qr-text); margin-bottom: .5rem; text-transform: uppercase; }
.ba-ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr)); gap: .5rem; }
.ba-ach { display: flex; flex-direction: column; align-items: center; gap: .125rem; text-align: center; padding: .5rem .25rem; border-radius: var(--qr-card-radius-sm); background: rgba(15,23,42,0.035); border: 1px solid var(--qr-veil-ink-6); opacity: .55; filter: grayscale(.85); transition: transform var(--qr-dur-fast) var(--qr-ease-out), opacity var(--qr-dur) var(--qr-ease-out); }
html.dark-mode .ba-ach { background: rgba(255,255,255,0.035); border-color: var(--qr-veil-w-6); }
.ba-ach.is-on { opacity: 1; filter: none; background: var(--qr-grad-wash-duel); border-color: rgba(217,119,6,0.22); }
.ba-ach.is-on:hover { transform: translateY(-2px); }
.ba-ach-icon { font-size: var(--fs-h1); line-height: 1; }
.ba-ach-name { font-size: var(--fs-micro); font-weight: 700; color: var(--qr-text); line-height: 1.15; }
.ba-ach-date { font-size: var(--fs-micro); color: #d97706; font-weight: 700; }
.ba-ach-locked { font-size: var(--fs-micro); color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

@media (prefers-reduced-motion: reduce) {
  .ba-modal-overlay, .ba-modal-card, .ba-card-detail, .ba-empty-art, .ba-skel-row, .ba-ach.is-on:hover { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════ Learn Knowledge Engine (ADR-069) — hub, topic pages, responsive shell ═══════════════════════════ */
/* Reusable responsive primitives, scoped to body.view-learn-active so the rest of the app is untouched. Reuses the
   app's card tokens + .math-table + .formula-block (identity preserved). Phone-first; widens intelligently on
   tablet/desktop. */

/* ---- responsive shell: lift the 480px cap ONLY for Learn ---- */
body.view-learn-active .container { max-width: 560px; }
@media (min-width: 768px)  { body.view-learn-active .container { max-width: 720px; } }
@media (min-width: 960px)  { body.view-learn-active .container { max-width: 900px; } }   /* landscape tablets: room for reading column + side rail */
@media (min-width: 1100px) { body.view-learn-active .container { max-width: 1040px; } }
@media (min-width: 1400px) { body.view-learn-active .container { max-width: 1140px; } }

/* ---- search results dropdown ---- */
.kx-search-results { margin-top: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.kx-search-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem; border: 1px solid var(--qr-veil-ink-8); border-radius: var(--qr-card-radius-sm); background: rgba(255,255,255,.7); cursor: pointer; text-decoration: none; color: inherit; transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast); }
.kx-search-item:hover, .kx-search-item:focus-visible { background: #eff6ff; border-color: #bfdbfe; outline: none; }
.kx-search-ico { font-size: var(--fs-h3); }
.kx-search-title { font-weight: 700; font-size: var(--fs-sub); color: var(--qr-text); }
.kx-search-cat { margin-left: auto; font-size: var(--fs-caption); color: #475569; text-transform: capitalize; }
.kx-search-empty { padding: .75rem .25rem; color: var(--qr-text-dim); font-size: var(--fs-sub); text-align: center; }
html.dark-mode .kx-search-item { background: rgba(30,41,59,.6); border-color: var(--qr-veil-w-8); }
html.dark-mode .kx-search-item:hover, html.dark-mode .kx-search-item:focus-visible { background: #1e293b; border-color: #334155; }
html.dark-mode .kx-search-title { color: #e2e8f0; }
html.dark-mode .kx-search-cat, html.dark-mode .kx-search-empty { color: #94a3b8; }

/* ---- hub: category groups + topic cards ---- */
/* one-time staggered entrance for the (≤5) hub category sections — feels alive on open, plays once per hub build */
.kx-cat { margin-bottom: 1.5rem; animation: kx-rise var(--qr-dur-slow) var(--qr-ease-out) both; }
.kx-cat:nth-child(2) { animation-delay: calc(var(--qr-dur-fast) * 0.375); }
.kx-cat:nth-child(3) { animation-delay: calc(var(--qr-dur-fast) * 0.75); }
.kx-cat:nth-child(4) { animation-delay: calc(var(--qr-dur-fast) * 1.125); }
.kx-cat:nth-child(5) { animation-delay: calc(var(--qr-dur-fast) * 1.5); }
@keyframes kx-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.kx-cat-head { display: flex; align-items: baseline; gap: .5rem; margin: 0 0 .125rem; }
.kx-cat-title { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); margin: 0; }
.kx-cat-count { font-size: var(--fs-caption); font-weight: 700; color: #475569; }
.kx-cat-blurb { font-size: var(--fs-sub); color: #475569; margin: 0 0 .75rem; line-height: 1.45; }
html.dark-mode .kx-cat-title { color: #f1f5f9; }
html.dark-mode .kx-cat-count, html.dark-mode .kx-cat-blurb { color: #94a3b8; }

/* One header language for the Learn hub: a subtle blue accent bar before category + major-section titles, and a calm
   top hairline that lets the major groups (Knowledge categories → Quick Reference → Your Topics) breathe — hierarchy
   through spacing + a single accent, not divider lines everywhere. */
.kx-cat-title::before, .kx-hub-head::before {
  content: ''; display: inline-block; width: 4px; height: .9em; margin-right: .5rem; vertical-align: -1px;
  border-radius: 2px; background: var(--qr-accent);
}
.kx-hub-head { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); margin: 2rem 0 .125rem; padding-top: 1.5rem; border-top: var(--qr-card-border-light); }
html.dark-mode .kx-hub-head { color: #f1f5f9; border-top-color: var(--qr-veil-w-8); }
.kx-topic-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; }
@media (min-width: 560px)  { .kx-topic-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px)  { .kx-topic-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .kx-topic-grid { grid-template-columns: repeat(4, 1fr); } }

.kx-topic-card { display: flex; flex-direction: column; gap: .5rem; text-align: left; width: 100%; padding: 1rem .75rem; border: 1px solid rgba(15,23,42,.07); border-radius: var(--qr-card-radius-sm); background: rgba(255,255,255,.85); box-shadow: var(--qr-shadow-light); cursor: pointer; font: inherit; color: inherit; transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast); }
.kx-topic-card:hover { transform: translateY(-2px); box-shadow: var(--el-2); border-color: #bfdbfe; }
.kx-topic-card:active { transform: scale(var(--qr-press-lg)); }
.kx-topic-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
/* "Coming soon" topics read as planned (not disabled/dimmed): softer dashed surface, full-opacity title, no lift. */
.kx-topic-card.is-scaffold { background: rgba(248,250,252,.6); border-style: dashed; border-color: var(--qr-veil-ink-14); box-shadow: none; }
.kx-topic-card.is-scaffold:hover { transform: none; box-shadow: none; border-color: var(--qr-border-strong); }
html.dark-mode .kx-topic-card { background: rgba(30,41,59,.7); border-color: var(--qr-veil-w-8); box-shadow: var(--qr-shadow-dark); }
html.dark-mode .kx-topic-card:hover { border-color: #3b5573; }
html.dark-mode .kx-topic-card.is-scaffold { background: rgba(30,41,59,.45); border-color: var(--qr-veil-w-14); }
html.dark-mode .kx-topic-card.is-scaffold:hover { border-color: #475569; }
.kx-tc-top { display: flex; align-items: center; gap: .5rem; }
.kx-tc-ico { font-size: var(--fs-h1); line-height: 1; }
.kx-tc-title { font-weight: 800; font-size: var(--fs-body); color: var(--qr-text); }
html.dark-mode .kx-tc-title { color: #f1f5f9; }
.kx-tc-badges { display: flex; flex-wrap: wrap; gap: .25rem; }

/* difficulty + exam-frequency + status badges */
.kx-badge { font-size: var(--fs-micro); font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: .125rem .25rem; border-radius: var(--r-sm); }
.kx-freq { background: rgba(100,116,139,.14); color: #475569; }
.kx-status-scaffold { background: rgba(100,116,139,.14); color: #475569; }
/* ADR-109: Premium-gated Learn topic badge + card affordance. */
.kx-status-premium { background: rgba(37,99,235,.14); color: var(--qr-accent); display: inline-flex; align-items: center; gap: .25rem; font-weight: 700; }
/* ADR-132: was `width/height: .8em`, which broke in BOTH themes for two different reasons. Playful's
   masking rule sets font-size:0, so `.8em` resolved to 0px and the lock was invisible; Classic ignored
   it entirely, because `html:not(.theme-playful) .qr-ico` (0,2,1) outranks this selector (0,2,0), so
   the glyph fell back to the 1.2rem default and rendered 24x19px — roughly 2.5x its authored size.
   The authored intent is kept exactly: --fs-micro is .6875rem (11px), so .8em is precisely .55rem.
   Expressing it as calc() over the token documents the intent and survives a type-scale change, while
   avoiding `em`. Deliberately smaller than the .8rem sibling premium chips — that was the design. */
.kx-status-premium .qr-ico { --qr-ico-size: calc(var(--fs-micro) * .8); }
.kx-topic-card.is-premium .kx-tc-title { opacity: .82; }
html.dark-mode .kx-status-premium { background: rgba(96,165,250,.2); color: #93c5fd; }
/* ADR-109: locked topic page (rendered in place of the chapter for a gated topic the user hasn't unlocked). */
.kx-topic-locked { text-align: center; max-width: 30rem; margin: 1.5rem auto 0; display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 1.5rem 1rem; border: 1px solid var(--qr-border); border-radius: var(--r-lg); background: var(--qr-surface-2); }
.kx-locked-icon { font-size: var(--fs-icon); line-height: 1; color: var(--qr-accent); }
/* ADR-132: same contract violation — the authored 2.2rem box was silently overridden to `auto` in
   Classic by `html:not(.theme-playful) .qr-ico` (0,2,1 beats 0,2,0), leaving the locked-topic glyph at
   the 1.2rem default. Routed through --qr-ico-size so both themes honour the authored size. */
.kx-locked-icon .qr-ico { --qr-ico-size: 2.2rem; }
.kx-locked-title { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); margin: 0; }
.kx-locked-sub { font-size: var(--fs-sub); line-height: 1.5; color: var(--qr-text-mut); margin: 0; }
.kx-locked-cta { width: 100%; max-width: 18rem; margin-top: .25rem; }
html.dark-mode .kx-locked-icon { color: #93c5fd; }
html.dark-mode .kx-freq, html.dark-mode .kx-status-scaffold { background: rgba(148,163,184,.18); color: #cbd5e1; }

/* ---- topic page ---- */
/* ADR-092: one honest back link (topic pages are one level deep — no pretend breadcrumb hierarchy) */
.kx-topic-nav { margin-bottom: .25rem; }

.kx-topic-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.kx-th-ico { font-size: var(--fs-d1); line-height: 1; }
.kx-th-title { font-size: var(--fs-h1); font-weight: 800; color: var(--qr-text); margin: 0; }
html.dark-mode .kx-th-title { color: #f1f5f9; }
.kx-th-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .75rem; }

/* sticky in-page section nav — subtle glass so it blends into the page (the pills are the focus, not a dark strip) */
.kx-section-nav { position: sticky; top: 0; z-index: var(--z-lift-3); display: flex; gap: .5rem; overflow-x: auto; padding: .5rem 0; margin-bottom: .5rem; background: rgba(248,250,252,.72); -webkit-backdrop-filter: var(--glass-surface); backdrop-filter: var(--glass-surface); -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior-x: contain; }
.kx-section-nav::-webkit-scrollbar { display: none; }
html.dark-mode .kx-section-nav { background: rgba(15,23,42,.72); }
/* No backdrop-filter (older Safari/Android) → near-opaque mask so page content doesn't bleed through the sticky nav. */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .kx-section-nav { background: rgba(248,250,252,.97); }
  html.dark-mode .kx-section-nav { background: rgba(15,23,42,.97); }
}
/* Programmatic focus targets (route-change a11y) must not paint a ring for mouse users — they aren't controls. */
/* programmatic a11y focus targets (non-interactive headings) — focus lands for SR without a loud UA ring */
.kx-th-title:focus, #learnHeading:focus, .kx-hub-head:focus { outline: none; }
/* ADR-092: quieter inactive pills — the nav is a map, not a row of buttons competing with the content */
.kx-sec-pill { flex: 0 0 auto; min-height: 2.25rem; border: 1px solid transparent; background: var(--qr-veil-ink-5); color: var(--qr-text-dim); border-radius: var(--r-xl); padding: .5rem .75rem; font-size: var(--fs-caption); font-weight: 700; cursor: pointer; white-space: nowrap; transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast), color var(--qr-dur-fast), transform var(--qr-dur-fast) var(--qr-ease-out); }
.kx-sec-pill:hover { background: #eff6ff; color: var(--qr-accent); }
.kx-sec-pill:active { transform: scale(var(--qr-press-sm)); }
.kx-sec-pill.is-active { background: var(--qr-accent); border-color: var(--qr-accent); color: var(--qr-on-accent); box-shadow: var(--qr-glow-accent); }
.kx-sec-pill:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
html.dark-mode .kx-sec-pill { background: var(--qr-veil-w-6); color: #94a3b8; }
html.dark-mode .kx-sec-pill:hover { background: #1e293b; color: #93c5fd; }
html.dark-mode .kx-sec-pill.is-active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ADR-092: ONE reading column at every width. The old ≥960px right rail split the reader's attention; the chapter
   footer now carries next-up/related at the point of finish. Wide screens keep a comfortable centred measure. */
.kx-topic-body { display: block; }
@media (min-width: 960px) {
  .kx-topic-body { max-width: 720px; margin-left: auto; margin-right: auto; }
}
.kx-topic-main { min-width: 0; animation: kx-fade-in var(--qr-dur) var(--qr-ease-out) both; }
@keyframes kx-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Dark mode has no base body-color flip, so set a light base for the topic page — every un-coloured block (callout/
   example/revision list text + headings) inherits it instead of the light-mode near-black. ADR-069 P1/P2 audit. */
html.dark-mode #learnTopic { color: #e2e8f0; }
/* ADR-081 chapter rhythm: more breathing room between sections + a refined eyebrow so each section reads as a clear
   chapter heading rather than a list item. */
.kx-section { scroll-margin-top: 3.4rem; margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--qr-veil-ink-6); }
.kx-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
html.dark-mode .kx-section { border-bottom-color: var(--qr-veil-w-6); }
.kx-section-label { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; color: var(--qr-accent); font-weight: 800; margin: 0 0 .5rem; }
html.dark-mode .kx-section-label { color: #93c5fd; }

/* block styles */
/* ADR-092 reading typography: the overview is the chapter's lede — a generous opening paragraph, not a quote box */
.kx-overview { font-size: var(--fs-h3); line-height: 1.7; color: #334155; margin: 0; padding: 0; background: none; border: none; }
html.dark-mode .kx-overview { color: #cbd5e1; }
/* concept title doubles as the section heading (no eyebrow above it) — give it heading weight + air */
.kx-concept-title { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); margin: 0 0 .5rem; letter-spacing: -.01em; line-height: 1.3; }
.kx-concept-body { font-size: var(--fs-body); line-height: 1.65; color: #334155; margin: 0 0 .5rem; }
html.dark-mode .kx-concept-title { color: #f1f5f9; }
html.dark-mode .kx-concept-body { color: #cbd5e1; }
.kx-label-warn { color: #b45309 !important; }
.kx-label-trap { color: var(--qr-danger) !important; }
html.dark-mode .kx-label-warn { color: #fbbf24 !important; }
html.dark-mode .kx-label-trap { color: #f87171 !important; }

.kx-callout { border-radius: var(--qr-card-radius-sm); padding: .75rem .75rem; margin: 0 0 .5rem; border: 1px solid transparent; }
.kx-callout-head { font-weight: 800; font-size: var(--fs-sub); margin: 0 0 .25rem; }
.kx-callout-list { margin: 0; padding-left: 1rem; }
.kx-callout-list li { font-size: var(--fs-sub); line-height: 1.5; margin-bottom: .25rem; }
.kx-callout-body { font-size: var(--fs-sub); line-height: 1.5; margin: 0; }
.kx-trick { background: rgba(22,163,74,.07); border-color: rgba(22,163,74,.2); }
.kx-trap  { background: rgba(220,38,38,.06); border-color: rgba(220,38,38,.18); }
.kx-memory { background: rgba(124,58,237,.06); border-color: rgba(124,58,237,.18); }
.kx-exam  { background: rgba(37,99,235,.06); border-color: rgba(37,99,235,.2); }   /* ADR-081 exam-strategy callout */
html.dark-mode .kx-trick { background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.28); }
html.dark-mode .kx-trap { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.28); }
html.dark-mode .kx-memory { background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.28); }
html.dark-mode .kx-exam { background: rgba(59,130,246,.14); border-color: rgba(59,130,246,.3); }

.kx-example { border: 1px solid var(--qr-veil-ink-8); border-radius: var(--qr-card-radius-sm); padding: .75rem .75rem; margin: 0 0 .5rem; background: rgba(255,255,255,.6); }
html.dark-mode .kx-example { background: rgba(30,41,59,.5); border-color: var(--qr-veil-w-8); }
.kx-example-head { font-weight: 800; font-size: var(--fs-sub); margin: 0 0 .25rem; color: var(--qr-accent); }
html.dark-mode .kx-example-head { color: #60a5fa; }
.kx-example-problem { font-size: var(--fs-sub); line-height: 1.55; margin: 0 0 .5rem; color: var(--qr-text); }
html.dark-mode .kx-example-problem { color: #e2e8f0; }
.kx-example-steps { margin: 0 0 .5rem; padding-left: 1rem; }
.kx-example-steps li { font-size: var(--fs-sub); line-height: 1.55; margin-bottom: .25rem; }
.kx-example-answer { font-weight: 800; font-size: var(--fs-sub); color: var(--qr-success); }
html.dark-mode .kx-example-answer { color: #4ade80; }

.kx-revision-list { margin: 0; padding-left: 1rem; }
.kx-revision-list li { font-size: var(--fs-sub); line-height: 1.55; margin-bottom: .25rem; }

.kx-table-wrap { margin: 0 0 .5rem; }
.kx-table-caption { font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); margin-bottom: .25rem; }
html.dark-mode .kx-table-caption { color: #94a3b8; }
.kx-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* end-of-chapter footer labels + related chips (ADR-092: everything onward lives at the end of the chapter) */
.kx-aside-title { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; color: var(--qr-text-dim); font-weight: 800; margin: 0 0 .5rem; }
html.dark-mode .kx-aside-title { color: #94a3b8; }
.kx-related, .kx-related-inline { display: flex; flex-wrap: wrap; gap: .25rem; }
.kx-chip { display: inline-flex; align-items: center; min-height: 2.25rem; padding: .5rem .75rem; border-radius: var(--r-xl); border: 1.5px solid var(--qr-border); background: var(--qr-surface-solid); color: var(--qr-accent); font-size: var(--fs-caption); font-weight: 700; text-decoration: none; cursor: pointer; text-transform: capitalize; transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast); }
.kx-chip:hover { background: #eff6ff; border-color: #bfdbfe; }
.kx-chip:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
html.dark-mode .kx-chip { background: #1e293b; border-color: #334155; color: #60a5fa; }
html.dark-mode .kx-chip:hover { border-color: #3b5573; }
.kx-back { display: inline-flex; align-items: center; gap: .25rem; min-height: 2.25rem; background: none; border: none; color: var(--qr-accent); font: inherit; font-weight: 700; cursor: pointer; padding: .5rem .25rem; margin-bottom: .5rem; }
.kx-back:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: 4px; }
html.dark-mode .kx-back { color: #60a5fa; }

/* end-of-chapter footer (ADR-092): finish actions → next-up card → related → previous */
.kx-chapter-foot { margin-top: 2.25rem; padding-top: 1.5rem; border-top: 2px solid var(--qr-veil-ink-8); }
html.dark-mode .kx-chapter-foot { border-top-color: var(--qr-veil-w-10); }
.kx-foot-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.kx-foot-block { margin-bottom: 1.25rem; }
/* Report-an-issue line (ADR-100): a quiet, full-width affordance that closes the chapter — deliberately
   low-emphasis (never competes with the filled "Practise this" primary), but always discoverable. */
.kx-report-line {
  display: block; width: 100%; margin-top: 1.5rem; padding: .75rem 1rem;
  border: 1px dashed rgba(100,116,139,.35); border-radius: var(--qr-card-radius-sm);
  background: none; font: inherit; font-size: var(--fs-sub); color: var(--qr-text-dim); text-align: center; cursor: pointer;
  transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast), color var(--qr-dur-fast);
}
.kx-report-line:hover { background: rgba(37,99,235,.05); border-color: rgba(37,99,235,.3); color: #475569; }
.kx-report-line:active { transform: scale(var(--qr-press-lg)); }
.kx-report-line:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-report-ico { margin-right: .25rem; opacity: .8; }
.kx-report-cta { color: var(--qr-accent); font-weight: 700; }
html.dark-mode .kx-report-line { border-color: rgba(148,163,184,.3); color: #94a3b8; }
html.dark-mode .kx-report-line:hover { background: rgba(96,165,250,.08); border-color: rgba(96,165,250,.35); color: #cbd5e1; }
html.dark-mode .kx-report-cta { color: #93c5fd; }
@media (prefers-reduced-motion: reduce) { .kx-report-line:active { transform: none; } }
.kx-foot-next { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; padding: .75rem 1rem; border: 1.5px solid var(--qr-border); border-radius: var(--qr-card-radius-sm); background: rgba(255,255,255,.85); cursor: pointer; font: inherit; color: inherit; transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast), background var(--qr-dur-fast); }
.kx-foot-next:hover { border-color: #bfdbfe; background: #eff6ff; transform: translateY(-1px); }
.kx-foot-next:active { transform: scale(var(--qr-press-lg)); }
.kx-foot-next:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-fn-ico { flex: 0 0 auto; font-size: var(--fs-h1); line-height: 1; }
.kx-fn-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kx-fn-title { font-size: var(--fs-body); font-weight: 800; color: var(--qr-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-fn-cat { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }
.kx-fn-arrow { flex: 0 0 auto; font-size: var(--fs-h2); color: var(--qr-accent); font-weight: 700; }
html.dark-mode .kx-foot-next { background: rgba(30,41,59,.7); border-color: #334155; }
html.dark-mode .kx-foot-next:hover { background: #1e293b; border-color: #3b5573; }
html.dark-mode .kx-fn-title { color: #f1f5f9; }
html.dark-mode .kx-fn-cat { color: #94a3b8; }
html.dark-mode .kx-fn-arrow { color: #60a5fa; }
.kx-foot-prev { display: inline-flex; align-items: center; min-height: 2.25rem; background: none; border: none; padding: .25rem .25rem; font: inherit; font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); cursor: pointer; }
.kx-foot-prev:hover { color: var(--qr-accent); }
.kx-foot-prev:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: 4px; }
html.dark-mode .kx-foot-prev { color: #94a3b8; }
html.dark-mode .kx-foot-prev:hover { color: #60a5fa; }

@media (prefers-reduced-motion: reduce) {
  .kx-topic-card, .kx-sec-pill, .kx-chip, .kx-search-item, .kx-foot-next { transition: none !important; }
  .kx-topic-card:hover, .kx-topic-card:active, .kx-sec-pill:active, .kx-foot-next:hover, .kx-foot-next:active { transform: none !important; }
  .kx-topic-main, .kx-cat { animation: none !important; }
}

/* ───────── Phase 4 — integrations: action bar · resume strips · completion · cheat-sheet projection (NO AI) ───────── */

/* topic action bar (Practise this · Quick revision · Mark complete · Save) */
.kx-actionbar { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.kx-action { display: inline-flex; align-items: center; gap: .25rem; min-height: 2.5rem; padding: .5rem .75rem; border-radius: var(--r-xl); border: 1.5px solid var(--qr-border); background: var(--qr-surface-solid); color: #334155; font: inherit; font-size: var(--fs-sub); font-weight: 700; cursor: pointer; transition: background var(--qr-dur-fast), border-color var(--qr-dur-fast), color var(--qr-dur-fast), transform var(--qr-dur-fast) var(--qr-ease-out); }
.kx-action:hover { background: var(--qr-surface-2); }
.kx-action:active { transform: scale(var(--qr-press-sm)); }
.kx-action:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-action-practise { background: var(--qr-accent); border-color: var(--qr-accent); color: var(--qr-on-accent); box-shadow: var(--qr-glow-accent); }
.kx-action-practise:hover { background: var(--qr-accent-strong); border-color: var(--qr-accent-strong); }
/* non-interactive "Practice coming soon" cue (Pipes & Cisterns, until a dedicated bank exists) */
.kx-action-soon { background: rgba(100,116,139,.1); border-style: dashed; border-color: rgba(100,116,139,.4); color: #475569; cursor: default; }
html.dark-mode .kx-action-soon { background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.4); color: #cbd5e1; }
.kx-action-revise.is-on { background: rgba(124,58,237,.12); border-color: var(--qr-info-fg); color: #6d28d9; }
.kx-action-complete.is-on { background: rgba(22,163,74,.12); border-color: var(--qr-success); color: var(--qr-success); }
.kx-action-save.is-on { background: rgba(217,119,6,.12); border-color: #d97706; color: #b45309; }
html.dark-mode .kx-action { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .kx-action:hover { background: #273449; }
html.dark-mode .kx-action-practise { background: #2563eb; border-color: #2563eb; color: #fff; }
html.dark-mode .kx-action-revise.is-on { background: rgba(167,139,250,.18); border-color: #a78bfa; color: #c4b5fd; }
html.dark-mode .kx-action-complete.is-on { background: rgba(22,163,74,.2); border-color: #22c55e; color: #4ade80; }
html.dark-mode .kx-action-save.is-on { background: rgba(217,119,6,.22); border-color: #d97706; color: #fbbf24; }

/* cheat-sheet projection: in revision mode, only revision-type sections + their pills stay visible */
#learnTopic.kx-revision-only .kx-section:not(.is-revision),
#learnTopic.kx-revision-only .kx-sec-pill:not(.is-revision) { display: none; }

/* hub resume strips (Continue learning + Due for revision) */
.kx-resume { margin: 0 0 1.25rem; }
.kx-resume-head { font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #475569; margin: 0 0 .5rem; }
html.dark-mode .kx-resume-head { color: #94a3b8; }
/* horizontal scroller with a soft right edge-fade hinting "more to scroll" (premium, signals scrollability) */
.kx-resume-row { display: flex; gap: .5rem; overflow-x: auto; padding: .125rem .125rem .25rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 1.5rem), transparent 100%); mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 1.5rem), transparent 100%); }
.kx-resume-row::-webkit-scrollbar { display: none; }
.kx-resume-card { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .5rem; max-width: 15rem; min-height: 2.6rem; padding: .5rem .75rem; border: 1px solid var(--qr-veil-ink-8); border-radius: var(--qr-card-radius-sm); background: rgba(255,255,255,.85); box-shadow: var(--qr-shadow-light); cursor: pointer; font: inherit; color: inherit; transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast), box-shadow var(--qr-dur-fast) var(--qr-ease-out); }
.kx-resume-card:hover { transform: translateY(-1px); border-color: #bfdbfe; box-shadow: var(--el-2); }
.kx-resume-card:active { transform: scale(var(--qr-press-lg)); }
.kx-resume-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-rc-ico { font-size: var(--fs-h2); line-height: 1; }
.kx-rc-title { font-weight: 700; font-size: var(--fs-sub); color: var(--qr-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-rc-done { color: var(--qr-success); font-weight: 800; }
.kx-rc-lock { flex: 0 0 auto; font-size: var(--fs-caption); opacity: .85; }   /* ADR-109: premium lock chip on strip cards */
html.dark-mode .kx-resume-card { background: rgba(30,41,59,.7); border-color: var(--qr-veil-w-8); box-shadow: var(--qr-shadow-dark); }
html.dark-mode .kx-rc-title { color: #f1f5f9; }
html.dark-mode .kx-rc-done { color: #4ade80; }

/* ───────── ADR-092 — Learn reimagined: Up-next hero · Revise-today · Needs-practice · revise flow · footer ───────── */

/* grouped search results (Topics / Quick reference) */
.kx-search-group { font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--qr-text-dim); margin: .5rem .125rem .125rem; }
html.dark-mode .kx-search-group { color: #94a3b8; }

/* "Up next" hero — the single recommended next chapter */
.kx-upnext { display: block; width: 100%; text-align: left; margin: 0 0 .75rem; padding: 1rem 1rem; border: 1.5px solid rgba(37,99,235,.25); border-radius: var(--qr-card-radius); background: var(--qr-grad-wash); cursor: pointer; font: inherit; color: inherit; transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast), box-shadow var(--qr-dur-fast) var(--qr-ease-out); }
.kx-upnext:hover { transform: translateY(-1px); border-color: rgba(37,99,235,.45); box-shadow: var(--qr-glow-accent); }
.kx-upnext:active { transform: scale(var(--qr-press-lg)); }
.kx-upnext:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-upnext-eyebrow { display: block; font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--qr-accent); margin-bottom: .25rem; }
.kx-upnext-row { display: flex; align-items: center; gap: .75rem; }
.kx-upnext-ico { flex: 0 0 auto; font-size: var(--fs-d2); line-height: 1; }
.kx-upnext-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kx-upnext-title { font-size: var(--fs-h3); font-weight: 800; color: var(--qr-text); letter-spacing: -.01em; }
.kx-upnext-why { font-size: var(--fs-caption); color: var(--qr-text-dim); font-weight: 600; }
.kx-upnext-arrow { flex: 0 0 auto; font-size: var(--fs-h1); color: var(--qr-accent); font-weight: 700; }
html.dark-mode .kx-upnext { background: var(--qr-grad-wash); border-color: rgba(96,165,250,.3); }
html.dark-mode .kx-upnext-eyebrow, html.dark-mode .kx-upnext-arrow { color: #60a5fa; }
html.dark-mode .kx-upnext-title { color: #f1f5f9; }
html.dark-mode .kx-upnext-why { color: #94a3b8; }

/* "Revise today" — the daily recall entry; visible only when something is due */
.kx-revise-card { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; margin: 0 0 1rem; padding: .75rem 1rem; border: 1.5px solid rgba(217,119,6,.3); border-radius: var(--qr-card-radius); background: rgba(245,158,11,.07); cursor: pointer; font: inherit; color: inherit; transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast); }
.kx-revise-card:hover { transform: translateY(-1px); border-color: rgba(217,119,6,.5); }
.kx-revise-card:active { transform: scale(var(--qr-press-lg)); }
.kx-revise-card:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-revise-ico { flex: 0 0 auto; font-size: var(--fs-h1); line-height: 1; }
.kx-revise-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kx-revise-txt strong { font-size: var(--fs-body); font-weight: 800; color: var(--qr-text); }
.kx-revise-txt small { font-size: var(--fs-caption); color: var(--qr-text-dim); line-height: 1.35; }
.kx-revise-cta { flex: 0 0 auto; padding: .5rem .75rem; border-radius: var(--r-xl); background: #d97706; color: var(--qr-on-accent); font-size: var(--fs-caption); font-weight: 800; }
html.dark-mode .kx-revise-card { background: rgba(245,158,11,.1); border-color: rgba(251,191,36,.3); }
html.dark-mode .kx-revise-txt strong { color: #f1f5f9; }
html.dark-mode .kx-revise-txt small { color: #94a3b8; }

/* Needs-practice strip: small accuracy chip on the card */
.kx-rc-acc { flex: 0 0 auto; font-size: var(--fs-caption); font-weight: 800; color: var(--qr-danger); background: rgba(220,38,38,.09); border-radius: var(--r-xl); padding: .125rem .5rem; }
html.dark-mode .kx-rc-acc { color: #f87171; background: rgba(248,113,113,.14); }

/* My notes sub-heading */
.kx-mynotes-sub { font-size: var(--fs-sub); font-weight: 800; color: #334155; margin: .25rem 0 .5rem; }
html.dark-mode .kx-mynotes-sub { color: #cbd5e1; }

/* guided revision flow (#learn/revise) — same centred reading measure as the topic page on wide screens */
@media (min-width: 960px) {
  #learnRevise { max-width: 720px; margin-left: auto; margin-right: auto; }
}
.kx-rev-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.kx-rev-exit { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border: none; border-radius: 50%; background: var(--qr-veil-ink-6); color: var(--qr-text-dim); font-size: var(--fs-h3); font-weight: 700; cursor: pointer; }
.kx-rev-exit:hover { background: rgba(15,23,42,.12); }
.kx-rev-exit:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-rev-count { font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--qr-text-dim); }
.kx-rev-count:focus { outline: none; }
.kx-rev-bar { height: 4px; border-radius: 2px; background: var(--qr-veil-ink-8); overflow: hidden; margin-bottom: 1rem; }
.kx-rev-fill { height: 100%; border-radius: 2px; background: #d97706; transition: width var(--qr-dur) var(--qr-ease-out); }
.kx-rev-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.kx-rev-ico { font-size: var(--fs-h1); line-height: 1; }
.kx-rev-title { font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); margin: 0; letter-spacing: -.01em; }
.kx-rev-body { margin-bottom: 1.25rem; }
.kx-rev-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--qr-veil-ink-8); }
.kx-rev-full { background: none; border: none; padding: .5rem .25rem; min-height: 2.5rem; font: inherit; font-size: var(--fs-sub); font-weight: 700; color: var(--qr-text-dim); cursor: pointer; }
.kx-rev-full:hover { color: var(--qr-accent); }
.kx-rev-full:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: 4px; }
.kx-rev-next { min-height: 2.75rem; padding: .5rem 1.25rem; border-radius: var(--r-xl); font-weight: 800; }
.kx-rev-done { text-align: center; padding: 2.5rem .75rem; }
.kx-rev-done-ico { font-size: var(--fs-icon); line-height: 1; margin-bottom: .75rem; }
.kx-rev-done-title { font-size: var(--fs-h1); font-weight: 800; color: var(--qr-text); margin: 0 0 .5rem; }
.kx-rev-done-title:focus { outline: none; }
.kx-rev-done-sub { font-size: var(--fs-sub); line-height: 1.6; color: var(--qr-text-dim); max-width: 26rem; margin: 0 auto 1.5rem; }
.kx-rev-home { min-height: 2.75rem; padding: .5rem 1.5rem; border-radius: var(--r-xl); font-weight: 800; }
html.dark-mode #learnRevise { color: #e2e8f0; }
html.dark-mode .kx-rev-exit { background: var(--qr-veil-w-8); color: #94a3b8; }
html.dark-mode .kx-rev-exit:hover { background: var(--qr-veil-w-14); }
html.dark-mode .kx-rev-count { color: #94a3b8; }
html.dark-mode .kx-rev-bar { background: var(--qr-veil-w-10); }
html.dark-mode .kx-rev-title, html.dark-mode .kx-rev-done-title { color: #f1f5f9; }
html.dark-mode .kx-rev-actions { border-top-color: var(--qr-veil-w-10); }
html.dark-mode .kx-rev-full, html.dark-mode .kx-rev-done-sub { color: #94a3b8; }
html.dark-mode .kx-rev-full:hover { color: #60a5fa; }

/* quick-ref card reveal flash (unified search → library) */
@keyframes qrCardFlash { 0% { box-shadow: 0 0 0 3px rgba(37,99,235,.55); } 100% { box-shadow: 0 0 0 3px rgba(37,99,235,0); } }
.qref-card-flash { animation: qrCardFlash calc(var(--qr-dur-pulse) * 1.25) var(--qr-ease-out) both; border-radius: var(--qr-card-radius-sm); }

@media (prefers-reduced-motion: reduce) {
  .kx-upnext, .kx-revise-card, .kx-rev-fill { transition: none !important; }
  .kx-upnext:hover, .kx-upnext:active, .kx-revise-card:hover, .kx-revise-card:active { transform: none !important; }
  .qref-card-flash { animation: none !important; }
}

/* completion tick on the category topic cards */
.kx-topic-card.is-complete { border-color: rgba(22,163,74,.4); }
.kx-topic-card.is-complete .kx-tc-title::after { content: " ✓"; color: var(--qr-success); font-weight: 900; }
html.dark-mode .kx-topic-card.is-complete { border-color: rgba(34,197,94,.45); }
html.dark-mode .kx-topic-card.is-complete .kx-tc-title::after { color: #4ade80; }

@media (prefers-reduced-motion: reduce) {
  .kx-action, .kx-resume-card { transition: none !important; }
  .kx-resume-card:hover, .kx-resume-card:active, .kx-action:active { transform: none !important; }
}

/* ============================================================================
   Data Interpretation — Speed-Aptitude subject (ADR-074, V2 Phase 2)
   Subject group labels in the Practice category picker + the lightweight DI
   chart/table block rendered above the question stem (js/ui/di-charts.js).
   ========================================================================== */

/* Subject group headings in the category picker (Quant / Data Interpretation) */
.category-subject-label {
  margin: 1rem .125rem .5rem; font-size: var(--fs-caption); font-weight: 700; letter-spacing: .02em;
  color: #475569; text-transform: uppercase;
}
.category-grid + .category-subject-label { margin-top: 1rem; }
/* Each subject is now a labelled role="group" (screen-reader grouping); preserve the inter-group rhythm the old
   grid→label sibling rule gave, now that the label is nested inside its group wrapper. */
.category-group + .category-group { margin-top: 1rem; }
html.dark-mode .category-subject-label { color: #cbd5e1; }

/* ADR-084: dynamic category picker — search + collapsible sections. Reuses .category-grid / .category-btn. */
.category-search-wrap { padding: .25rem .125rem .125rem; }
.category-search-input {
  /* ADR-134: vertical padding rounds UP — see .qr-search-input below for the reasoning. */
  width: 100%; box-sizing: border-box; padding: .75rem .75rem; border: 1px solid rgba(0,0,0,.10);
  border-radius: var(--r-md); background: var(--qr-surface-solid); color: #111827; font-size: var(--fs-sub); -webkit-appearance: none; appearance: none;
}
.category-search-input::placeholder { color: #94a3b8; }
.category-search-input:focus { outline: none; border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring); }
.category-section { border: 1px solid rgba(0,0,0,.07); border-radius: var(--r-md); overflow: hidden; margin-top: .5rem; background: var(--qr-surface-solid); }
.category-section-header {
  width: 100%; display: flex; align-items: center; gap: .5rem; padding: .75rem .75rem; background: var(--qr-bg);
  border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--qr-text); transition: background var(--qr-dur);
}
.category-section-header:active { background: #eef2f7; }
.category-section-header:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: -2px; }
.category-section-title { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sub); font-weight: 700; letter-spacing: .01em; }
.category-section-icon { font-size: var(--fs-body); }
.category-section-count { flex: 0 0 auto; font-size: var(--fs-micro); font-weight: 700; color: var(--qr-text-dim); text-transform: uppercase; letter-spacing: .04em; }
.category-section-header .collapse-icon { flex: 0 0 auto; font-size: var(--fs-micro); color: #94a3b8; }
.category-section .category-grid { padding: 12px 8px; margin: 0; animation: catSectionIn var(--qr-dur) var(--qr-ease-out); }
@keyframes catSectionIn { from { opacity: .3; } to { opacity: 1; } }
.category-picker-empty { text-align: center; padding: 1rem .5rem; }
/* pin star + most-asked marker on each category button */
.category-btn { position: relative; }
.cat-star { position: absolute; top: 3px; right: 5px; font-size: var(--fs-caption); line-height: 1; color: #cbd5e1; cursor: pointer; padding: 2px; }
.cat-star.is-pinned { color: var(--qr-warn); }
.cat-star:active { transform: scale(1.2); }
/* "For You" strip — light chip rows */
.category-foryou-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 2px; }
.category-foryou-row .category-btn { flex: 0 1 auto; padding: 8px 12px; }
html.dark-mode .cat-star { color: #475569; }
html.dark-mode .cat-star.is-pinned { color: #fbbf24; }
html.dark-mode .category-search-input { background: #1e293b; color: #e2e8f0; border-color: var(--qr-veil-w-12); }
html.dark-mode .category-search-input::placeholder { color: #64748b; }
html.dark-mode .category-section { background: #0f172a; border-color: var(--qr-veil-w-8); }
html.dark-mode .category-section-header { background: #1e293b; color: #e2e8f0; }
html.dark-mode .category-section-header:active { background: #263449; }
html.dark-mode .category-section-count { color: #94a3b8; }

/* ============================================================================
   Quick-Reference revision library (ADR-084 Batch 3) — #learn/quick-ref
   Reuses .math-table / .math-grid / .collapsible-* / .card; premium entry chip.
   ========================================================================== */
.qr-lib-entry {
  width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: .75rem; text-align: left;
  padding: .75rem 1rem; margin: .25rem 0 .5rem; cursor: pointer; font: inherit;
  border: 1px solid rgba(37,99,235,.20); border-radius: var(--r-lg);
  background: var(--qr-grad-wash); color: var(--qr-text);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur) var(--qr-ease-out), border-color var(--qr-dur) var(--qr-ease-out);
}
.qr-lib-entry:active { transform: scale(var(--qr-press-lg)); }
.qr-lib-entry:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.qr-lib-entry-ico { --qr-ico-size: var(--fs-h1); flex: 0 0 auto; font-size: var(--fs-h1); line-height: 1; }
.qr-lib-entry-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qr-lib-entry-txt strong { font-size: var(--fs-body); font-weight: 700; }
.qr-lib-entry-txt small { font-size: var(--fs-caption); color: var(--qr-text-dim); line-height: 1.3; }
.qr-lib-entry-arrow { flex: 0 0 auto; font-size: var(--fs-h1); color: var(--qr-accent); font-weight: 700; }

.qr-lib-head { margin-bottom: .5rem; }
.qr-lib-back {
  border: 0; background: none; color: var(--qr-accent); font: inherit; font-weight: 600; font-size: var(--fs-sub);
  /* ADR-134: top padding rounds UP (.3rem->.5rem, not .25rem). This is a back button already below
     the touch floor; nearest-rounding shaved another 0.8px off it. The 44px hit area still does the
     real work, but the grid should not make an undersized control smaller. */
  padding: .5rem 0 .5rem; cursor: pointer;
}
.qr-lib-back:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; border-radius: var(--r-sm); }
.qr-search-wrap { margin: .25rem 0 .75rem; }
.qr-search-input {
  /* ADR-134: vertical padding rounds UP here, not to nearest. Nearest took this field from 37.2px to
     34px, and an input is a touch target — the one place the grid must not be allowed to make an
     already-undersized control smaller. Horizontal still floors, so the text keeps its room. */
  width: 100%; box-sizing: border-box; padding: .75rem .75rem; border: 1px solid rgba(0,0,0,.10);
  border-radius: var(--r-md); background: var(--qr-surface-solid); color: #111827; font-size: var(--fs-sub); -webkit-appearance: none; appearance: none;
}
.qr-search-input::placeholder { color: #94a3b8; }
.qr-search-input:focus { outline: none; border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring); }
.qr-sec .section-title { display: flex; align-items: center; gap: .5rem; }
.qr-sec-count {
  font-size: var(--fs-micro); font-weight: 700; color: var(--qr-text-dim); background: rgba(100,116,139,.12);
  border-radius: var(--r-full); padding: 2px 8px; text-transform: uppercase; letter-spacing: .03em;
}
.qref-card { padding: .75rem 0; border-top: 1px solid rgba(0,0,0,.06); }
.qref-card:first-child { border-top: 0; padding-top: .25rem; }
.qref-card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.qref-card-ico { font-size: var(--fs-h3); line-height: 1; }
.qref-card-title { font-size: var(--fs-sub); font-weight: 700; color: var(--qr-text); }
.qr-grid { margin-top: .25rem; }
.qref-card-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.qr-link {
  border: 1px solid rgba(37,99,235,.25); background: #eff6ff; color: var(--qr-accent-strong); font: inherit; font-size: var(--fs-caption);
  font-weight: 600; padding: .25rem .5rem; border-radius: var(--r-full); cursor: pointer; transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
.qr-link:active { transform: scale(var(--qr-press-sm)); }
.qr-link-practice { border-color: rgba(22,163,74,.28); background: #ecfdf5; color: var(--qr-success-fg); }
.qref-empty { text-align: center; padding: 1rem .5rem; }
html.dark-mode .qr-lib-entry { background: var(--qr-grad-wash); border-color: rgba(96,165,250,.28); color: #e2e8f0; }
html.dark-mode .qr-lib-entry-txt small { color: #94a3b8; }
html.dark-mode .qr-lib-entry-arrow, html.dark-mode .qr-lib-back { color: #60a5fa; }
html.dark-mode .qr-search-input { background: #1e293b; color: #e2e8f0; border-color: var(--qr-veil-w-12); }
html.dark-mode .qr-search-input::placeholder { color: #64748b; }
html.dark-mode .qr-sec-count { color: #94a3b8; background: rgba(148,163,184,.16); }
html.dark-mode .qref-card { border-top-color: var(--qr-veil-w-8); }
html.dark-mode .qref-card-title { color: #e2e8f0; }
html.dark-mode .qr-link { background: #1e293b; color: #93c5fd; border-color: rgba(96,165,250,.28); }
html.dark-mode .qr-link-practice { background: #10241b; color: #6ee7b7; border-color: rgba(52,211,153,.3); }

/* ============================================================================
   Multiple-choice answers — Logical Reasoning (ADR-075, V2 Phase 3)
   Rendered in place of the numeric input when a question carries options[].
   ========================================================================== */
.mcq-options { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .25rem 0 .25rem; width: 100%; }
/* On a roomy screen the answer card is wide; cap the option grid so buttons stay a comfortable tap size and the
   two columns read as a tidy pair instead of stretching edge-to-edge (tablet/desktop craftsmanship pass). */
@media (min-width: 640px) { .mcq-options { max-width: 30rem; margin-left: auto; margin-right: auto; gap: .75rem; } }
.mcq-option {
  appearance: none; -webkit-appearance: none; text-align: center; cursor: pointer;
  padding: 1rem .75rem; font-size: var(--fs-body); font-weight: 600; line-height: 1.25;
  color: #1e293b; background: var(--qr-surface-solid); border: 1.5px solid var(--qr-border); border-radius: var(--qr-btn-radius);
  transition: transform var(--qr-dur-fast) var(--qr-ease-out), border-color var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out);
  overflow-wrap: break-word; word-break: break-word; /* long LR statement options never overflow their button */
}
/* paragraph-length options (LR statement/decision distractors) read as prose, not centred labels — left-align and
   relax line-height so a 3–4 line option stays legible. Always full-width (mcq-wide is applied alongside). */
.mcq-option.mcq-para { text-align: left; line-height: 1.4; font-weight: 500; }
.mcq-option:active { transform: scale(var(--qr-press-sm)); }
/* Press-down feedback (parity with the numpad's .pressed key): a tap reads on contact, not just on result. Wired by
   the drill engine on pointerdown/up; toggles only this class — never grades, so it can't affect answer state. */
.mcq-option.pressed { transform: scale(.96); background: #eff6ff; }
html.dark-mode .mcq-option.pressed { background: #243043; }
.mcq-option.selected { border-color: var(--qr-accent); }
.mcq-option:disabled { cursor: default; opacity: 1; }
/* single long option (e.g. "Cannot be determined") spans the row */
.mcq-option.mcq-wide { grid-column: 1 / -1; }
.mcq-option.mcq-correct { background: #dcfce7; border-color: var(--qr-success-border); color: #166534; }
.mcq-option.mcq-wrong { background: #fee2e2; border-color: var(--qr-danger-border); color: var(--qr-danger-fg); }
/* non-colour indicator too (colour-blind a11y) — the result is never signalled by colour alone */
.mcq-option.mcq-correct::after { content: ' ✓'; font-weight: 900; }
.mcq-option.mcq-wrong::after { content: ' ✗'; font-weight: 900; }
html.dark-mode .mcq-option { color: #e2e8f0; background: #1e293b; border-color: #334155; }
html.dark-mode .mcq-option.selected { border-color: var(--qr-accent); }
html.dark-mode .mcq-option.mcq-correct { background: rgba(34,197,94,.18); border-color: #22c55e; color: #86efac; }
html.dark-mode .mcq-option.mcq-wrong { background: rgba(239,68,68,.18); border-color: #ef4444; color: #fca5a5; }
@media (prefers-reduced-motion: reduce) { .mcq-option { transition: none; } .mcq-option:active, .mcq-option.pressed { transform: none; } }

/* ── MCQ as a first-class lower-region interaction (ADR-086 P3) ──
   Anchor the options toward the bottom of the (now full-height) card so they OCCUPY the lower answer region under the
   thumb instead of floating centred with voids; the stem scrolls above. Bigger, comfortable targets fill the space. */
.drill-has-mcq .drill-question-scroll::after { display: none; }
.drill-has-mcq .drill-question-scroll::before { flex: 0 1 auto; min-height: .75rem; }
.drill-has-mcq #mcqOptions { margin-top: auto; padding-top: .5rem; }
.mcq-options { gap: .75rem; margin: .25rem 0 .25rem; }
.mcq-option { padding: 1rem .75rem; font-size: var(--fs-h3); min-height: 3.4rem; display: flex; align-items: center; justify-content: center; }
.mcq-option.mcq-para { justify-content: flex-start; }
@media (min-width: 640px) { .drill-has-mcq #mcqOptions { max-width: 34rem; margin-left: auto; margin-right: auto; } }

/* Stats: the per-subject breakdown sits above the per-category list with a little breathing room (ADR-076) */

/* Learn-hub subject grouping (ADR-073/074): a calm header above each subject's categories */
.kx-subject-group { margin-bottom: .5rem; }
/* ADR-080: let subjects breathe — a generous gap + a soft divider between sections, and a header that carries a blurb
   + topic count + difficulty coverage instead of a bare label. */
.kx-subject-group + .kx-subject-group { margin-top: 2.5rem; padding-top: 1.75rem; border-top: 1px solid var(--qr-veil-ink-8); }
html.dark-mode .kx-subject-group + .kx-subject-group { border-top-color: var(--qr-veil-w-8); }

/* Subject filter (ADR-082): a sticky pill row that toggles which subject group is visible. The pills are the
   motion (active-state transition); content swap is instant — "filtering must be instant, no jarring movement". */
.kx-filter {
  display: flex; flex-wrap: wrap; gap: .5rem;
  position: sticky; top: 0; z-index: var(--z-lift-4);
  padding: .5rem 0 .75rem; margin-bottom: .25rem;
  background: var(--qr-bg);
}
.kx-filter-pill {
  font: inherit; font-size: var(--fs-caption); font-weight: 600; line-height: 1;
  min-height: 38px; padding: .5rem .75rem;
  border: 1.5px solid rgba(15,23,42,.12); border-radius: var(--r-full);
  background: var(--qr-surface-solid); color: #475569; cursor: pointer;
  transition: background var(--qr-dur) var(--qr-ease-out), color var(--qr-dur) var(--qr-ease-out), border-color var(--qr-dur) var(--qr-ease-out);
  -webkit-tap-highlight-color: transparent;
}
.kx-filter-pill:hover { border-color: rgba(15,23,42,.22); }
.kx-filter-pill:focus-visible { outline: 2px solid var(--qr-accent); outline-offset: 2px; }
.kx-filter-pill.is-active { background: var(--qr-accent); border-color: var(--qr-accent); color: var(--qr-on-accent); }
.kx-subject-group.is-hidden { display: none; }
/* when filtering hides the preceding subject, don't paint the divider on the now-leading visible one */
.kx-subject-group.is-hidden + .kx-subject-group { margin-top: 0; padding-top: 0; border-top: none; }
html.dark-mode .kx-filter-pill { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .kx-filter-pill:hover { border-color: #475569; }
html.dark-mode .kx-filter-pill.is-active { background: var(--qr-accent); border-color: var(--qr-accent); color: #0f172a; }
.kx-subject-head-wrap { margin: 0 .125rem 1rem; }
.kx-subject-head {
  font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.01em; text-transform: none;
  color: var(--qr-text); margin: 0;
}
html.dark-mode .kx-subject-head { color: #f1f5f9; }
.kx-subject-blurb { font-size: var(--fs-sub); color: #475569; margin: .25rem 0 0; line-height: 1.45; max-width: 42rem; }
html.dark-mode .kx-subject-blurb { color: #94a3b8; }
.kx-subject-meta { font-size: var(--fs-caption); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--qr-accent); margin-top: .5rem; }
html.dark-mode .kx-subject-meta { color: #93c5fd; }

/* sub-groups within a category (LR) */
.kx-subgroup { margin-bottom: 1rem; }
.kx-subgroup-head {
  display: flex; align-items: center; gap: .5rem;
  font-size: var(--fs-caption); font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: #475569;
  margin: 0 .125rem .5rem;
}
html.dark-mode .kx-subgroup-head { color: #94a3b8; }
.kx-subgroup-count { font-size: var(--fs-micro); font-weight: 800; color: var(--qr-text-dim); background: var(--qr-veil-ink-6); padding: .125rem .25rem; border-radius: 4px; }
html.dark-mode .kx-subgroup-count { color: #cbd5e1; background: var(--qr-veil-w-8); }

/* contextual topic badges (subtle, scarce) */
.kx-badge-rec { background: var(--qr-veil-accent-12); color: var(--qr-accent-strong); }
.kx-badge-asked { background: rgba(217,119,6,.14); color: #b45309; }
html.dark-mode .kx-badge-rec { background: rgba(37,99,235,.24); color: #bfdbfe; }
html.dark-mode .kx-badge-asked { background: rgba(217,119,6,.24); color: #fcd34d; }

/* design-lint:content-art-start di-lr-figures */
/* DI chart + LR figure renderer-coupled ART (FW-W7d): SVG inks and viewBox-scaled px type
   (8/8.5/13/18/56px are chart-geometry units, not UI type) reproduce exam content —
   deliberately outside the design system. Coupled to di-charts.js / lr-figures.js renderers. */
.di-chart {
  margin: 0 auto 1rem; max-width: 420px; width: 100%;
  background: var(--qr-surface-solid); border: 1px solid var(--qr-border); border-radius: var(--r-md); padding: .75rem .5rem .5rem;
}
html.dark-mode .di-chart { background: #1e293b; border-color: #334155; }
.di-chart-title {
  font-size: var(--fs-caption); font-weight: 700; color: #334155; text-align: center;
  margin-bottom: .5rem; line-height: 1.25;
}
html.dark-mode .di-chart-title { color: #e2e8f0; }
.di-chart-svg { display: block; width: 100%; height: auto; }

/* SVG text/lines (fill for text, stroke for axes) */
.di-chart-svg .di-val { font-size: 8.5px; font-weight: 700; fill: #1e293b; }
.di-chart-svg .di-axis-lbl { font-size: 8px; fill: #64748b; }
/* White on-slice % labels get a dark outline (paint-order: stroke) so they stay legible on ANY slice colour
   — incl. light amber/green — without depending on the slice fill (a11y contrast, ADR-074 audit). */
.di-chart-svg .di-pie-pct { font-size: 8.5px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(15, 23, 42, .55); stroke-width: 2.4px; stroke-linejoin: round; }
.di-chart-svg .di-axis { stroke: #cbd5e1; stroke-width: 1; }
html.dark-mode .di-chart-svg .di-val { fill: #f1f5f9; }
html.dark-mode .di-chart-svg .di-axis-lbl { fill: #94a3b8; }
html.dark-mode .di-chart-svg .di-axis { stroke: #475569; }

/* VIS-1/2 (ADR-105): recessive value-axis gridlines + axis titles. Gridlines sit behind the marks. */
.di-chart-svg .di-grid { stroke: #eef2f7; stroke-width: 1; }
html.dark-mode .di-chart-svg .di-grid { stroke: #334155; }
.di-chart-svg .di-tick { font-variant-numeric: tabular-nums; }
.di-chart-svg .di-axis-title { font-size: 8px; font-weight: 600; fill: #64748b; letter-spacing: .01em; }
html.dark-mode .di-chart-svg .di-axis-title { fill: #94a3b8; }

/* VIS-3/4 (ADR-105): ONE categorical series palette, theme-tuned, applied via `currentColor` from these classes so
   the renderer stays theme-unaware. Light hues are the brand set (CVD worst-adjacent ΔE 21.4, relief via on-chart
   value labels); dark steps are lightened to clear ≥3:1 on the dark card (#1e293b). Fixed slot order, never cycled. */
.di-chart-svg { --di-series-0: #2563eb; --di-series-1: #0ea5e9; --di-series-2: #22c55e; --di-series-3: #f59e0b; --di-series-4: #ef4444; --di-series-5: #8b5cf6; }
html.dark-mode .di-chart-svg { --di-series-0: #60a5fa; --di-series-1: #38bdf8; --di-series-2: #4ade80; --di-series-3: #fbbf24; --di-series-4: #f87171; --di-series-5: #a78bfa; }
.di-chart-svg .di-series-0 { color: var(--di-series-0); }
.di-chart-svg .di-series-1 { color: var(--di-series-1); }
.di-chart-svg .di-series-2 { color: var(--di-series-2); }
.di-chart-svg .di-series-3 { color: var(--di-series-3); }
.di-chart-svg .di-series-4 { color: var(--di-series-4); }
.di-chart-svg .di-series-5 { color: var(--di-series-5); }

/* DI Sets (ADR-078): the shared context (chart or caselet) sits persistently above the rotating question block. */
.di-set-context { width: 100%; margin: 0 0 .25rem; }
.di-caselet-context { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: var(--qr-card-radius-sm); padding: .75rem 1rem; font-size: var(--fs-body); line-height: 1.5; color: #1e293b; text-align: left; }
html.dark-mode .di-caselet-context { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.di-set-badge { display: inline-block; font-size: var(--fs-micro); font-weight: 800; letter-spacing: .06em; color: var(--qr-accent); background: rgba(37,99,235,.1); padding: .125rem .25rem; border-radius: var(--r-sm); vertical-align: middle; margin-left: .25rem; }
html.dark-mode .di-set-badge { background: rgba(37,99,235,.22); }

/* DI data table */
.di-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.di-table { width: 100%; border-collapse: collapse; font-size: var(--fs-caption); }
.di-table th, .di-table td { padding: .5rem .5rem; border-bottom: 1px solid #e2e8f0; text-align: left; }
.di-table th { color: #475569; font-weight: 700; background: #f8fafc; }
.di-table td.num, .di-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: 'SF Mono', 'Consolas', monospace; }
.di-table td.row-h { font-weight: 600; }
html.dark-mode .di-table th { color: #cbd5e1; background: #0f172a; }
html.dark-mode .di-table th, html.dark-mode .di-table td { border-color: #334155; }

/* ── LR visual figures (ADR-079): viewBox-vector, DPI-independent, themed via these classes ── */
/* VIS-5 (ADR-105): ONE normalized stroke weight for primary figure outlines (was scattered 2.5–6) + a thinner token
   for interior/secondary lines, so figures shown side-by-side in an option grid read consistently. grid3 renders in a
   300×300 viewBox (3× the 100-unit figures), so its strokes multiply the token by 3 to match at display size. */
.lr-figure { margin: 0 auto .5rem; max-width: 156px; width: 100%; --lr-stroke: 3.5; --lr-stroke-thin: 1.5; }
.lr-figure-svg { width: 100%; height: auto; display: block; }
.lr-fig-glyph { font-size: 56px; font-weight: 800; fill: #1e293b; font-family: 'Inter', system-ui, sans-serif; }
.lr-fig-qmark { fill: #94a3b8; }
.lr-fig-stroke { stroke: #1e293b; stroke-width: var(--lr-stroke); stroke-linecap: round; fill: none; }
.lr-fig-fill { fill: #1e293b; stroke: none; }
.lr-fig-die { fill: #f8fafc; stroke: #1e293b; stroke-width: var(--lr-stroke); }
.lr-fig-cubeface { fill: #dbeafe; stroke: #1e293b; stroke-width: 2.5; }
.lr-fig-cubeface2 { fill: #eff6ff; stroke: #1e293b; stroke-width: 2.5; }
.lr-fig-cubeface3 { fill: #bfdbfe; stroke: #1e293b; stroke-width: 2.5; }
.lr-fig-cubeline { stroke: #64748b; stroke-width: 1; }
html.dark-mode .lr-fig-glyph { fill: #f1f5f9; }
html.dark-mode .lr-fig-stroke { stroke: #f1f5f9; }
html.dark-mode .lr-fig-fill { fill: #f1f5f9; }
html.dark-mode .lr-fig-die { fill: #0f172a; stroke: #f1f5f9; }
html.dark-mode .lr-fig-cubeface { fill: #1e3a5f; stroke: #cbd5e1; }
html.dark-mode .lr-fig-cubeface2 { fill: #25456b; stroke: #cbd5e1; }
html.dark-mode .lr-fig-cubeface3 { fill: #14304f; stroke: #cbd5e1; }

/* ── ADR-093 primitives: shapes, compositions, line figures, paper, nets, matrices ── */
.lr-fig-shape { stroke: #1e293b; stroke-width: var(--lr-stroke); stroke-linejoin: round; fill: none; }
.lr-fig-solidshape { fill: #1e293b; stroke: #1e293b; stroke-width: 2; stroke-linejoin: round; }
.lr-fig-dotfill { fill: #1e293b; }
.lr-fig-dotknock { fill: #fff; stroke: #1e293b; stroke-width: 2.5; }   /* marker on a shaded shape — never vanishes */
.lr-fig-seg { stroke: #1e293b; stroke-width: var(--lr-stroke); stroke-linecap: round; fill: none; }
.lr-fig-paper { fill: #f8fafc; stroke: #1e293b; stroke-width: var(--lr-stroke); }
.lr-fig-fold { stroke: #2563eb; stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.lr-fig-foldarrow { stroke: #2563eb; stroke-width: 2; fill: none; }
.lr-fig-hole { fill: #1e293b; }
.lr-fig-netcell { fill: #eff6ff; stroke: #1e293b; stroke-width: 2; }
.lr-fig-netlbl { font-size: 13px; font-weight: 800; fill: #1e293b; font-family: 'Inter', system-ui, sans-serif; }
.lr-fig-facelbl { font-size: 18px; font-weight: 800; fill: #1e293b; font-family: 'Inter', system-ui, sans-serif; }
.lr-fig-facelbl-top, .lr-fig-facelbl-side { font-size: 13px; }
.lr-fig-gridframe { fill: none; stroke: #1e293b; stroke-width: calc(var(--lr-stroke) * 3); }   /* 300×300 viewBox → ×3 to match 100-unit figures */
.lr-fig-gridline { stroke: #94a3b8; stroke-width: calc(var(--lr-stroke-thin) * 3); }
html.dark-mode .lr-fig-shape { stroke: #f1f5f9; }
html.dark-mode .lr-fig-solidshape { fill: #f1f5f9; stroke: #f1f5f9; }
html.dark-mode .lr-fig-dotfill { fill: #f1f5f9; }
html.dark-mode .lr-fig-dotknock { fill: #1e293b; stroke: #f1f5f9; }
html.dark-mode .lr-fig-seg { stroke: #f1f5f9; }
html.dark-mode .lr-fig-paper { fill: #0f172a; stroke: #f1f5f9; }
html.dark-mode .lr-fig-fold, html.dark-mode .lr-fig-foldarrow { stroke: #60a5fa; }
html.dark-mode .lr-fig-hole { fill: #f1f5f9; }
html.dark-mode .lr-fig-netcell { fill: #1e3a5f; stroke: #cbd5e1; }
html.dark-mode .lr-fig-netlbl, html.dark-mode .lr-fig-facelbl { fill: #f1f5f9; }
html.dark-mode .lr-fig-gridframe { stroke: #f1f5f9; }
html.dark-mode .lr-fig-gridline { stroke: #64748b; }
/* design-lint:content-art-end di-lr-figures */

/* ── ADR-093 presentation stage: the figure is the hero, the stem is an instruction ── */
.question-text-compact { font-size: var(--fs-body); font-weight: 600; letter-spacing: 0; line-height: 1.5; color: #334155; max-width: 34rem; text-align: left; margin-left: auto; margin-right: auto; }
html.dark-mode .question-text-compact { color: #cbd5e1; }
@media (max-height: 600px) { .question-text-compact { font-size: var(--fs-sub); } }
.q-figure-stage { display: flex; justify-content: center; align-items: center; width: 100%; max-width: 420px; margin: 0 auto .75rem; padding: .75rem .5rem; background: var(--qr-surface-solid); border: 1px solid var(--qr-border); border-radius: var(--r-md); }
.q-figure-stage .lr-figure { margin: 0; }
html.dark-mode .q-figure-stage { background: #1e293b; border-color: #334155; }
.lr-figure-grid { max-width: 240px; margin: 0 auto; }
.q-figure-stage .lr-figure-grid { max-width: 230px; }

/* picture-answer grid: each option button shows a lettered figure. VIS-6 (ADR-105): larger caps so figures are
   readable at a glance (was 96/88px, min-height 92). */
.mcq-options-figures { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; width: 100%; max-width: 440px; margin-left: auto; margin-right: auto; }
.mcq-figure-option { position: relative; display: flex; align-items: center; justify-content: center; padding: .5rem .5rem .5rem; min-height: 108px; }
.mcq-figure-option .lr-figure { margin: 0; max-width: 112px; }
.mcq-figure-option .lr-figure-grid { max-width: 104px; }
/* VIS-7 (ADR-105): opaque letter chip (solid plate + hairline + slight shadow) so a wide `row` option figure that
   extends toward the corner can never render under the A/B/C/D badge. */
.mcq-opt-letter { position: absolute; top: .3rem; left: .3rem; z-index: var(--z-above); font-size: var(--fs-micro); font-weight: 800; color: #475569; background: var(--qr-surface-solid); border: 1px solid var(--qr-border); box-shadow: var(--el-1); border-radius: var(--r-sm); padding: .125rem .25rem; line-height: 1.3; }
html.dark-mode .mcq-opt-letter { color: #cbd5e1; background: #1e293b; border-color: #334155; box-shadow: var(--el-1); }
/* LR syllabus tier sub-headings inside the Logical Reasoning category group */
.category-tier-label { margin: .5rem 0 .25rem; font-size: var(--fs-micro); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--qr-text-dim); }
html.dark-mode .category-tier-label { color: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════════════════════
   QR ICON SYSTEM — one markup, all four themes (see qrIco() in app.js)
   The emoji text node inside .qr-ico is unconditionally collapsed (font-size:0)
   in EVERY theme (light/dark/playful/playful-dark); a monochrome SVG mask paints
   in currentColor, so a theme switch needs no JS re-render and icons tint with
   their text. The emoji stays in markup only as a copy/paste-safe fallback.
   Unbound data-ico names degrade to a neutral dot.
   ═══════════════════════════════════════════════════════════════════════════ */
.qr-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--qr-ico-size, 1.2rem);
  height: var(--qr-ico-size, 1.2rem);
  vertical-align: -0.22em;
  color: var(--qr-accent);
  --ico: var(--qri-dot);
}
/* ADR-131: collapsing the emoji text node is PLAYFUL's behaviour, not a universal one — it moved off
   the base rule so Classic can show the glyph without an !important fight. (An `!important` value also
   fails design-lint's pure-var() test, so keeping it off the Classic rule protects the font-size ceiling.) */
html.theme-playful .qr-ico {
  font-size: 0 !important;
  line-height: 0 !important;
  /* The base rule's `-0.22em` is INERT here: `em` resolves against this element's own font-size,
     which the line above sets to 0, so it has always computed to 0px. Playful icons have therefore
     been sitting at plain baseline — an inline-flex box with no baseline-bearing item aligns its
     bottom margin edge to the text baseline, which rides ~2.5px above the label's cap centre.
     Measured by scripts/dev/align-probe.js: -2.42 / -2.79 / -2.39px on the three inline surfaces.
     The correction has to be size-relative rather than `em` to survive the zero font-size. */
  vertical-align: calc(var(--qr-ico-size, 1.2rem) * -0.135);
}
.qr-ico::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}

/* ── ADR-131 — the two themes own two different ICON LANGUAGES ───────────────────────────────────
   P1-final Wave B (b93b0cf) converted chrome emoji to masked SVG for BOTH themes, which is what made
   Classic and Playful read as the same product. It did, however, keep every emoji in the DOM as the
   element's text (all 78 .qr-ico spans in index.html still carry theirs), and hides it with
   `font-size: 0` + the ::before mask above. So Classic's personality is restored purely in CSS.

   Classic  = the original emoji set: warm, playful, instantly recognisable.
   Playful  = the generated monochrome icon system: minimal and modern.
   Neither theme mixes the two. Content emoji (Learn topic icons, Quick-Ref cards, report reasons) are
   authored per-item DATA, not chrome, and stay emoji in both themes — the one documented exception,
   because converting them would mean rewriting translated strings and inventing ~100 new glyphs. */
html:not(.theme-playful) .qr-ico {
  /* pure var() reference on purpose: both `var(--x, fallback)` and a trailing `!important` fail
     design-lint's pure-var() test and would spend a slot off the 12-value font-size ceiling.
     --qr-ico-em carries the fallback, and no !important is needed now that the masking rule above is
     scoped to Playful — this selector is already more specific than `.qr-ico`. */
  --qr-ico-em: var(--qr-ico-size, 1.2rem);
  font-size: var(--qr-ico-em);
  line-height: 1;
  width: auto;
  height: auto;
  color: inherit;
  /* Measured, not guessed (scripts/dev/align-probe.js). `vertical-align` only ever reaches the three
     INLINE surfaces — .settings-label h3, .mode-card h3, .kx-hub-head; every other icon sits in a
     flex parent where align-items does the work and this property is ignored. On those three the
     inherited -0.14em put the glyph 2.24 / 2.25 / 2.80px BELOW the label's cap centre, so it needed
     raising by ~0.134em. That lands on ~0 — which is the point: an emoji at baseline sits where it
     did as a plain text node, before Wave B wrapped it in a box. Residuals: -0.03 / -0.15 / +0.29px. */
  vertical-align: -0.01em;
}
html:not(.theme-playful) .qr-ico::before { content: none; }

/* The About modal's section titles are the fourth (and last) INLINE icon surface, and the only one
   where the icon is far larger than its label — a 1.2rem default icon beside an --fs-caption
   uppercase heading. That size ratio is pre-existing drift and is deliberately left alone here (a
   resize would be a redesign, not a restoration); only the alignment is corrected. Measured at the
   shared constants: -1.88 / -1.89px in Classic and -2.17 / -2.59px in Playful, i.e. riding high in
   both. Residuals after this correction: ±0.01px Classic, ±0.21px Playful. */
html:not(.theme-playful) .info-section-title .qr-ico { vertical-align: -0.108em; }
html.theme-playful .info-section-title .qr-ico { vertical-align: calc(var(--qr-ico-size, 1.2rem) * -0.259); }

/* Context sizing & tinting (playful only) */
.bottom-nav .nav-icon .qr-ico { --qr-ico-size: 1.4rem; }
header h1 .qr-ico { --qr-ico-size: 1.5rem; vertical-align: -0.15em; }
.settings-label h3 .qr-ico { --qr-ico-size: 1.05rem; }
.mode-card h3 .qr-ico { --qr-ico-size: 1.15rem; }
.settings-btn-label .qr-ico,
.settings-action-btn .qr-ico { --qr-ico-size: 1.05rem; color: inherit; }
.clear-option-icon.qr-ico { --qr-ico-size: 1.25rem; }
.home-cta-icon.qr-ico { --qr-ico-size: 1.5rem; color: var(--qr-on-accent); }
.home-bento-icon.qr-ico { --qr-ico-size: 1.45rem; }
.pw-trust-item .qr-ico { --qr-ico-size: 0.95rem; color: inherit; }
html.theme-playful .bottom-nav a.active .nav-icon .qr-ico { color: var(--qr-grad-b, #2dd4bf); }

/* name → glyph bindings */
.qr-ico[data-ico='home'] { --ico: var(--qri-home); }
.qr-ico[data-ico='practice'] { --ico: var(--qri-target); }
.qr-ico[data-ico='learn'] { --ico: var(--qri-book-open); }
.qr-ico[data-ico='stats'] { --ico: var(--qri-chart-bar); }
.qr-ico[data-ico='settings'] { --ico: var(--qri-cog); }
.qr-ico[data-ico='cog'] { --ico: var(--qri-cog); }
.qr-ico[data-ico='zap'] { --ico: var(--qri-zap); }
.qr-ico[data-ico='activity'] { --ico: var(--qri-activity); }
.qr-ico[data-ico='timer'] { --ico: var(--qri-timer); }
.qr-ico[data-ico='chart-bar'] { --ico: var(--qri-chart-bar); }
.qr-ico[data-ico='nodes'] { --ico: var(--qri-nodes); }
.qr-ico[data-ico='target'] { --ico: var(--qri-target); }
.qr-ico[data-ico='shuffle'] { --ico: var(--qri-shuffle); }
.qr-ico[data-ico='rotate'] { --ico: var(--qri-rotate); }
.qr-ico[data-ico='file-text'] { --ico: var(--qri-file-text); }
.qr-ico[data-ico='bot'] { --ico: var(--qri-bot); }
.qr-ico[data-ico='moon'] { --ico: var(--qri-moon); }
.qr-ico[data-ico='palette'] { --ico: var(--qri-palette); }
.qr-ico[data-ico='graduation'] { --ico: var(--qri-graduation); }
.qr-ico[data-ico='gauge'] { --ico: var(--qri-gauge); }
.qr-ico[data-ico='skip'] { --ico: var(--qri-skip); }
.qr-ico[data-ico='sliders'] { --ico: var(--qri-sliders); }
/* ADR-136: the Quick Study "customize" button shipped a bare ✏️ in its text node. It carried
   `data-i18n-attr`, which translates only title/aria-label — but the icon-identity guard's
   translated-string exemption matched the attribute and waved the glyph through, so the single
   colour emoji sat in a screen of line icons in Playful. The guard is tightened alongside this. */
.qr-ico[data-ico='edit'] { --ico: var(--qri-edit); }
.qr-ico[data-ico='volume'] { --ico: var(--qri-volume); }
.qr-ico[data-ico='vibrate'] { --ico: var(--qri-vibrate); }
.qr-ico[data-ico='pause-circle'] { --ico: var(--qri-pause-circle); }
.qr-ico[data-ico='bell'] { --ico: var(--qri-bell); }
.qr-ico[data-ico='book'] { --ico: var(--qri-book); }
.qr-ico[data-ico='info'] { --ico: var(--qri-info); }
.qr-ico[data-ico='user'] { --ico: var(--qri-user); }
.qr-ico[data-ico='log-out'] { --ico: var(--qri-log-out); }
.qr-ico[data-ico='trash'] { --ico: var(--qri-trash); }
.qr-ico[data-ico='download'] { --ico: var(--qri-download); }
.qr-ico[data-ico='layers'] { --ico: var(--qri-layers); }
.qr-ico[data-ico='swords'] { --ico: var(--qri-swords); }
.qr-ico[data-ico='calendar'] { --ico: var(--qri-calendar); }
.qr-ico[data-ico='lock'] { --ico: var(--qri-lock); }
.qr-ico[data-ico='flame'] { --ico: var(--qri-flame); }
.qr-ico[data-ico='alert'] { --ico: var(--qri-alert); }
.qr-ico[data-ico='flag'] { --ico: var(--qri-flag); }
/* Report modal chrome (ADR-099): bind the icons the report sheet uses so Playful paints masks instead of the
   neutral-dot fallback. 'robot' reuses the existing bot glyph. */
.qr-ico[data-ico='close'] { --ico: var(--qri-x); }
.qr-ico[data-ico='back'] { --ico: var(--qri-chevron-left); }
.qr-ico[data-ico='send'] { --ico: var(--qri-send); }
.qr-ico[data-ico='check'] { --ico: var(--qri-check); }
.qr-ico[data-ico='robot'] { --ico: var(--qri-bot); }
/* Contact card (ADR-100) */
.qr-ico[data-ico='mail'] { --ico: var(--qri-mail); }
.qr-ico[data-ico='copy'] { --ico: var(--qri-copy); }
/* Language settings rows (ADR-111) */
.qr-ico[data-ico='globe'] { --ico: var(--qri-globe); }
.qr-ico[data-ico='book-open'] { --ico: var(--qri-book-open); }

/* glyph tokens (URL-encoded monochrome SVG masks) */
:root {
  --qri-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='5' fill='%23000' stroke='none'/%3E%3C/svg%3E");
  --qri-activity: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='22 12 18 12 15 21 9 3 6 12 2 12'/%3E%3C/svg%3E");
  --qri-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Ccircle cx='12' cy='17' r='1' fill='%23000' stroke='none'/%3E%3C/svg%3E");
  --qri-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'/%3E%3C/svg%3E");
  --qri-book: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/%3E%3C/svg%3E");
  --qri-book-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M2 4h7a3 3 0 0 1 3 3v13a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 4h-7a3 3 0 0 0-3 3v13a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E");
  --qri-globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/%3E%3C/svg%3E");
  --qri-bot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='4' y='8' width='16' height='12' rx='2'/%3E%3Cline x1='12' y1='8' x2='12' y2='4'/%3E%3Ccircle cx='12' cy='3' r='1'/%3E%3Ccircle cx='9' cy='13' r='1' fill='%23000' stroke='none'/%3E%3Ccircle cx='15' cy='13' r='1' fill='%23000' stroke='none'/%3E%3Cpath d='M9 17h6'/%3E%3C/svg%3E");
  --qri-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  --qri-chart-bar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cline x1='6' y1='20' x2='6' y2='12'/%3E%3Cline x1='12' y1='20' x2='12' y2='5'/%3E%3Cline x1='18' y1='20' x2='18' y2='9'/%3E%3Cline x1='3' y1='20' x2='21' y2='20'/%3E%3C/svg%3E");
  --qri-cog: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E");
  --qri-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
  --qri-file-text: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3C/svg%3E");
  --qri-flame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M12 22c4.4 0 7-2.9 7-6.7 0-3.5-2.6-5.6-3.8-8.2-1.7 1.6-2.2 2.9-2.2 5-1.2-1.7-2.5-3-2.5-5.9C7.6 9 5 11.6 5 15.3 5 19.1 7.6 22 12 22z'/%3E%3C/svg%3E");
  --qri-flag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z'/%3E%3Cline x1='4' y1='22' x2='4' y2='15'/%3E%3C/svg%3E");
  --qri-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
  --qri-chevron-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E");
  --qri-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E");
  --qri-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  --qri-mail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-10 6L2 7'/%3E%3C/svg%3E");
  --qri-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  --qri-gauge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M12 15l4-5'/%3E%3Cpath d='M3.34 19a10 10 0 1 1 17.32 0z'/%3E%3C/svg%3E");
  --qri-graduation: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M22 10 12 5 2 10l10 5 10-5z'/%3E%3Cpath d='M6 12.5V17c0 1.7 2.7 3 6 3s6-1.3 6-3v-4.5'/%3E%3Cline x1='22' y1='10' x2='22' y2='15'/%3E%3C/svg%3E");
  --qri-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3Cpath d='M9 21v-6h6v6'/%3E%3C/svg%3E");
  --qri-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='11'/%3E%3Ccircle cx='12' cy='8' r='1' fill='%23000' stroke='none'/%3E%3C/svg%3E");
  --qri-layers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolygon points='12 2 2 7 12 12 22 7 12 2'/%3E%3Cpolyline points='2 12 12 17 22 12'/%3E%3Cpolyline points='2 17 12 22 22 17'/%3E%3C/svg%3E");
  --qri-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
  --qri-log-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
  --qri-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E");
  --qri-nodes: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='18' cy='5' r='3'/%3E%3Ccircle cx='6' cy='12' r='3'/%3E%3Ccircle cx='18' cy='19' r='3'/%3E%3Cline x1='8.6' y1='10.6' x2='15.4' y2='6.4'/%3E%3Cline x1='8.6' y1='13.4' x2='15.4' y2='17.6'/%3E%3C/svg%3E");
  --qri-palette: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='13.5' cy='6.5' r='1' fill='%23000' stroke='none'/%3E%3Ccircle cx='17.5' cy='10.5' r='1' fill='%23000' stroke='none'/%3E%3Ccircle cx='8.5' cy='7.5' r='1' fill='%23000' stroke='none'/%3E%3Ccircle cx='6.5' cy='12' r='1' fill='%23000' stroke='none'/%3E%3Cpath d='M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 1.8 1.8 0 0 0 1.3-3.1 1.8 1.8 0 0 1 1.3-3H17a5 5 0 0 0 5-5c0-5-4.5-8.9-10-8.9z'/%3E%3C/svg%3E");
  --qri-pause-circle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='10' y1='15' x2='10' y2='9'/%3E%3Cline x1='14' y1='15' x2='14' y2='9'/%3E%3C/svg%3E");
  --qri-rotate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='23 4 23 10 17 10'/%3E%3Cpath d='M20.49 15a9 9 0 1 1-2.12-9.36L23 10'/%3E%3C/svg%3E");
  --qri-shuffle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='16 3 21 3 21 8'/%3E%3Cline x1='4' y1='20' x2='21' y2='3'/%3E%3Cpolyline points='21 16 21 21 16 21'/%3E%3Cline x1='15' y1='15' x2='21' y2='21'/%3E%3Cline x1='4' y1='4' x2='9' y2='9'/%3E%3C/svg%3E");
  --qri-skip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolygon points='5 4 15 12 5 20 5 4' fill='%23000' stroke='none'/%3E%3Cline x1='19' y1='5' x2='19' y2='19'/%3E%3C/svg%3E");
  --qri-edit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E");
  --qri-sliders: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cline x1='21' y1='6' x2='14' y2='6'/%3E%3Cline x1='10' y1='6' x2='3' y2='6'/%3E%3Cline x1='21' y1='12' x2='12' y2='12'/%3E%3Cline x1='8' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='18' x2='16' y2='18'/%3E%3Cline x1='12' y1='18' x2='3' y2='18'/%3E%3Cline x1='14' y1='4' x2='14' y2='8'/%3E%3Cline x1='8' y1='10' x2='8' y2='14'/%3E%3Cline x1='16' y1='16' x2='16' y2='20'/%3E%3C/svg%3E");
  --qri-swords: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='3 3 6 3 17 14 14 17 3 6 3 3'/%3E%3Cline x1='13' y1='19' x2='19' y2='13'/%3E%3Cline x1='16' y1='16' x2='20' y2='20'/%3E%3Cpolyline points='21 3 18 3 7 14 10 17 21 6 21 3'/%3E%3Cline x1='5' y1='13' x2='8' y2='16'/%3E%3Cline x1='4' y1='20' x2='8' y2='16'/%3E%3C/svg%3E");
  --qri-target: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Ccircle cx='12' cy='12' r='1' fill='%23000'/%3E%3C/svg%3E");
  --qri-timer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='12' cy='13' r='8'/%3E%3Cline x1='12' y1='13' x2='12' y2='9'/%3E%3Cline x1='10' y1='2' x2='14' y2='2'/%3E%3Cline x1='18.4' y1='5.6' x2='17' y2='7'/%3E%3C/svg%3E");
  --qri-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E");
  --qri-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
  --qri-vibrate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='9' y='5' width='6' height='14' rx='1.5'/%3E%3Cpath d='M5 8v8'/%3E%3Cpath d='M2 10v4'/%3E%3Cpath d='M19 8v8'/%3E%3Cpath d='M22 10v4'/%3E%3C/svg%3E");
  --qri-volume: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5' fill='%23000' stroke='none'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M18.5 5.5a9 9 0 0 1 0 13'/%3E%3C/svg%3E");
  --qri-zap: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpolygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2' fill='%23000' stroke='none'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLET DRILL LAYOUT (ADR-091) — at ≥768px the drill was a phone column inside a
   720px container with a full-bleed keypad. Center-constrain the working surfaces
   to a comfortable 640px reading/answer width; give the results grid a third column.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #drillContainer > .card {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
  }
  .custom-numpad {
    max-width: 640px;
    left: 50%;
    right: auto;
    width: 100%;
    transform: translateX(-50%) translateY(100%);
    border-radius: var(--r-keypad-top);
  }
  .custom-numpad.visible {
    transform: translateX(-50%) translateY(0);
  }
  body.drill-session-active .drill-actions {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 640px;
    transform: translateX(-50%);
  }
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  /* 5 tiles → 3 + 2 at three columns; the phone-only odd-last span no longer applies */
  .results-grid .result-item:last-child:nth-child(odd) {
    grid-column: auto;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LANDSCAPE DRILL SPLIT (FW-W5, blueprint §12) — in landscape the stacked phone
   layout starves the question card (card + actions + keypad don't fit a short
   viewport). Because every drill layer is independently position:fixed, landscape
   is pure RE-PINNING — no DOM moves: the question card takes the LEFT pane
   (full height), the keypad + action bar take the RIGHT pane. Same recipe for
   Practice (#drillContainer) and Duels (#duelActive). The action bar keeps its
   calc() off --qr-numpad-h, so one variable re-pins both right-pane layers.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (orientation: landscape) and (min-width: 640px) {
  /* Card owns the left ~58% — full height under the top controls. Covers the numpad,
     no-numpad (MCQ/LR) and duel variants, all of which pin differently in portrait. */
  body.drill-session-active #drillContainer > .card,
  body.drill-session-active:not(.numpad-active) #drillContainer > .card,
  body.drill-session-active #duelActive > .card {
    top: 3.4rem;
    left: .75rem;
    right: calc(42% + .5rem);   /* .5rem gutter between the panes */
    bottom: calc(.75rem + var(--drill-safe-b));
    max-width: none;
  }
  body.drill-session-active #duelActive > .card { top: 3.9rem; }   /* duel header band */
  /* Keypad + actions own the right pane. width:auto + transform reset undo the ≥768px
     phone-column centering (max-width 640 + translateX(-50%)). */
  body.drill-session-active .custom-numpad {
    left: 58%;
    right: .75rem;
    width: auto;
    max-width: none;
    border-radius: var(--r-keypad-top);
    transform: translateY(100%);
  }
  body.drill-session-active .custom-numpad.visible { transform: translateY(0); }
  body.drill-session-active .drill-actions,
  body.drill-session-active:not(.numpad-active) .drill-actions {
    left: 58%;
    right: .75rem;
    width: auto;
    max-width: none;
    transform: none;
    padding-left: 0;
    padding-right: 0;
  }
}
/* Tablet landscape (≥960px): the right pane has room — taller keys for comfortable
   two-handed answering; the reservation var recomputes the card/actions pins for free. */
@media (orientation: landscape) and (min-width: 960px) {
  body.drill-session-active { --qr-numpad-h: 17.5rem; }   /* 60px rows */
  body.drill-session-active .numpad-btn { min-height: 60px; }
}

/* Programmatic focus lands on the results heading for screen readers (ADR-088 A6);
   the loud user-agent ring on a non-interactive heading is visual noise (ADR-091). */
#drillResultsHeading:focus {
  outline: none;
}

/* ============================================================
   REPORTING SYSTEM (ADR-096) — Report a Problem modal
   Reuses .modal-overlay/.modal-content scaffold. Themed via --qr-* tokens
   (dark-mode + playful inherit automatically). No screenshot/file UI.
   ============================================================ */
/* Report affordance in the AI explanation sheet header (mirrors .companion-refresh). */
.companion-report { flex: 0 0 auto; width: 2rem; height: 2rem; border: none; background: var(--qr-veil-accent-8); border-radius: var(--r-full); color: #2563eb; font-size: var(--fs-body); line-height: 1; cursor: pointer; }
.companion-report:active { transform: scale(var(--qr-press-sm)); }
html.dark-mode .companion-report { background: rgba(96, 165, 250, .14); color: #93c5fd; }

/* ============================================================
   ADR-099 — the report experience is a companion-style BOTTOM SHEET (a sibling of the QuanAI explanation
   sheet). Same shell / motion / grabber / drag-to-dismiss, responsive→centred ≥600px, dark + reduced-motion
   + safe-area aware. z-index 700 so an "ai_explain" report opened over the companion sheet (z-index 600)
   renders on top. Tokens: --qr-*. ============================================================ */
/* Shell (position/scrim/geometry/shadow/grabber/≥600px centering) comes from the .qr-sheet
   primitive (FW-W3); only the report-specific z-order + entrance motion live here. */
.report-sheet-overlay { z-index: var(--z-report); animation: rptFade var(--qr-dur) var(--qr-ease-out); }
@keyframes rptFade { from { opacity: 0; } to { opacity: 1; } }
.report-sheet { color: var(--qr-text); animation: rptRise var(--qr-dur) var(--qr-ease); }
@keyframes rptRise { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.report-sheet-head {
  display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem .75rem;
  border-bottom: 1px solid var(--qr-border); touch-action: none; flex-shrink: 0;
}
.report-sheet-title { flex: 1; font-weight: 800; color: var(--qr-text); font-size: var(--fs-h3); }
.report-sheet-back, .report-sheet-close {
  flex: 0 0 auto; width: 2rem; height: 2rem; border: none; border-radius: var(--r-full);
  background: var(--qr-surface-2); color: var(--qr-text-dim); font-size: var(--fs-body); line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background var(--qr-dur-fast) var(--qr-ease-out);
}
.report-sheet-back:active, .report-sheet-close:active { background: var(--qr-surface-3); }
.report-sheet-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 1rem 1rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
}

/* Lead / hint copy */
.report-lead { margin: 0 0 1rem; font-size: var(--fs-sub); color: var(--qr-text-dim); line-height: 1.45; }
.report-note-hint {
  margin: 0 0 1rem; font-size: var(--fs-sub); color: var(--qr-text-dim); line-height: 1.4;
  background: var(--qr-surface-2); border-radius: var(--r-md); padding: .5rem .5rem; display: flex; align-items: flex-start; gap: .5rem;
}

/* Rich reason / group rows (guided; icon + title + one-line helper + chevron) */
.report-reason-list { display: flex; flex-direction: column; gap: .5rem; }
.report-reason {
  display: flex; align-items: center; gap: .75rem; text-align: left; width: 100%;
  padding: .75rem .75rem; border: 1px solid var(--qr-border); border-radius: var(--qr-card-radius-sm);
  background: var(--qr-surface-solid); cursor: pointer; min-height: 3.4rem;
  transition: border-color var(--qr-dur-fast) var(--qr-ease-out), background var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
}
.report-reason:hover { border-color: var(--qr-border-strong); }
.report-reason:active { transform: scale(var(--qr-press-lg)); background: var(--qr-surface-2); }
.report-reason-ico { font-size: var(--fs-h1); line-height: 1; flex-shrink: 0; width: 1.9rem; text-align: center; }
.report-reason-txt { flex: 1; min-width: 0; }
.report-reason-label { display: block; font-size: var(--fs-body); font-weight: 700; color: var(--qr-text); }
.report-reason-help { display: block; font-size: var(--fs-caption); color: var(--qr-text-mut); margin-top: .125rem; line-height: 1.35; }
.report-reason-chev { flex: 0 0 auto; color: var(--qr-text-mut); font-size: var(--fs-h2); line-height: 1; }
.report-escape {
  margin: 1rem 0 .25rem; width: 100%; background: none; border: none; color: var(--qr-accent); font-size: var(--fs-sub);
  font-weight: 600; cursor: pointer; padding: .5rem; display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
}

/* Contextual "which item" header (auto-collected — the user types nothing) */
.report-ctx {
  background: var(--qr-surface-2); border: 1px solid var(--qr-border); border-radius: var(--qr-card-radius-sm);
  padding: .75rem .75rem; margin: 0 0 1rem;
}
.report-ctx-top { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-caption); font-weight: 700; color: var(--qr-text-dim); }
.report-ctx-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; }
.report-ctx-chip {
  font-size: var(--fs-caption); font-weight: 600; color: var(--qr-text-dim); background: var(--qr-surface-solid);
  border: 1px solid var(--qr-border); border-radius: var(--r-full); padding: .25rem .5rem; white-space: nowrap;
}
.report-ctx-q { margin-top: .5rem; font-size: var(--fs-sub); color: var(--qr-text); line-height: 1.4; font-style: italic; }

/* Fields */
.report-field { margin: 1rem 0 0; }
.report-field .modal-label { display: block; font-size: var(--fs-sub); font-weight: 600; color: var(--qr-text); margin-bottom: .25rem; }
.report-sheet .modal-input,
.report-textarea {
  width: 100%; box-sizing: border-box; border: 1px solid var(--qr-border); border-radius: var(--r-lg);
  padding: .75rem .75rem; font-size: var(--fs-sub); background: var(--qr-surface-solid); color: var(--qr-text);
  font-family: inherit; transition: border-color var(--qr-dur-fast) var(--qr-ease-out), box-shadow var(--qr-dur-fast) var(--qr-ease-out);
}
.report-sheet .modal-input:focus,
.report-textarea:focus { outline: none; border-color: var(--qr-accent); box-shadow: var(--qr-focus-ring, 0 0 0 3px rgba(37,99,235,.18)); }
.report-textarea { min-height: 4.5rem; resize: vertical; line-height: 1.45; }
.report-char-count { font-size: var(--fs-caption); color: var(--qr-text-mut); text-align: right; margin-top: .25rem; }

/* Sub-reason chips */
.report-subreason-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.report-chip {
  border: 1px solid var(--qr-border); border-radius: var(--r-xl); padding: .5rem .75rem; font-size: var(--fs-caption);
  background: var(--qr-surface-solid); color: var(--qr-text); cursor: pointer; transition: all var(--qr-dur-fast) var(--qr-ease-out);
}
.report-chip:active { transform: scale(var(--qr-press-sm)); }
.report-chip.selected { background: var(--qr-accent); border-color: var(--qr-accent); color: var(--qr-on-accent); }

/* Rating stars */
.report-rating { display: flex; gap: .25rem; }
.report-star {
  background: none; border: none; font-size: var(--fs-d1); line-height: 1; color: var(--qr-border-strong);
  cursor: pointer; padding: 0 .125rem; transition: color var(--qr-dur-fast) var(--qr-ease-out), transform var(--qr-dur-fast) var(--qr-ease-out);
}
.report-star:active { transform: scale(1.15); }
.report-star.on { color: var(--qr-warn); }

/* Technical details disclosure */
.report-tech { margin: 1rem 0 .25rem; border: 1px solid var(--qr-border); border-radius: var(--r-lg); overflow: hidden; }
.report-tech summary {
  cursor: pointer; padding: .5rem .75rem; font-size: var(--fs-caption); color: var(--qr-text-dim);
  display: flex; align-items: center; gap: .25rem; list-style: none; user-select: none;
}
.report-tech summary::-webkit-details-marker { display: none; }
.report-tech[open] summary { border-bottom: 1px solid var(--qr-border); }
.report-tech-pre {
  margin: 0; padding: .5rem .75rem; font-size: var(--fs-caption); line-height: 1.5; color: var(--qr-text-dim);
  white-space: pre-wrap; word-break: break-word; max-height: 11rem; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--qr-surface-2);
}

/* Actions */
.report-actions { margin-top: 1.25rem; }
.report-actions .btn-primary { width: 100%; margin: 0; }
.report-reassure { margin: .75rem 0 0; font-size: var(--fs-caption); color: var(--qr-text-mut); text-align: center; line-height: 1.4; }

/* Submitting / success states */
.report-state-center { display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; min-height: 15rem; padding: 1rem 0; }
.report-spinner {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 3px solid var(--qr-surface-3);
  border-top-color: var(--qr-accent); animation: reportSpin calc(var(--qr-dur-slow) * 2) linear infinite; margin-bottom: 1rem;
}
@keyframes reportSpin { to { transform: rotate(360deg); } }
.report-state-msg { font-size: var(--fs-body); color: var(--qr-text-dim); }
.report-success-check { font-size: var(--fs-icon); line-height: 1; margin-bottom: .5rem; animation: reportPop var(--qr-dur-slow) var(--qr-spring) both; }
@keyframes reportPop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.report-success-title { margin: 0 0 .25rem; font-size: var(--fs-h2); font-weight: 800; color: var(--qr-text); }
.report-success-msg { margin: 0 0 .5rem; font-size: var(--fs-sub); color: var(--qr-text-dim); line-height: 1.5; max-width: 24rem; }
.report-success-id { font-size: var(--fs-sub); color: var(--qr-text-dim); }
.report-success-id strong { color: var(--qr-text); font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.report-state-center .report-actions { width: 100%; margin-top: 1.25rem; }

/* Touch targets (ADR-099 verification): give the head buttons + chips + stars a comfortable hit area on touch. */
.report-sheet-back, .report-sheet-close { width: 2.5rem; height: 2.5rem; }
.report-chip { min-height: 2.5rem; }
.report-star { padding: .125rem .25rem; }
/* Long topic/version labels can't blow out the context box (ADR-099 verification). */
.report-ctx-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Playful theme accents */
html.theme-playful .report-reason { border-radius: var(--qr-card-radius); }
html.theme-playful .report-spinner { border-top-color: var(--qr-accent); }
/* The success ✅ is a 3rem focal glyph; in Playful it's an SVG mask, so size the mask up (qr-ico defaults to 1.2rem). */
html.theme-playful .report-success-check .qr-ico { --qr-ico-size: 2.75rem; vertical-align: middle; }

/* Reduced-motion: no rise / pop / spin easing beyond a gentle fade */
@media (prefers-reduced-motion: reduce) {
  .report-sheet-overlay, .report-sheet, .report-success-check { animation-duration: .01ms; }
  .report-spinner { animation-duration: var(--qr-dur-pulse); }
}

/* ══════════════════════════════════════════════════════════════════════════════════════════════════
   Translation Pass (ADR-127, replacing the ADR-126 "Language Morph") — the language-switch transition.

   THE SHAPE. A wave of re-typesetting travels down the screen: each visible section of the active view
   dims, holds while the text is swapped, and returns — in on-screen order, finishing on the bottom-nav
   labels. ADR-126 faded the VIEW ROOT, so the whole screen went flat at once, which is the visual
   signature of a page reload. Fading the SECTIONS is what makes the change read as directional.

   WHY PER-SECTION IS SAFE (it was assumed unsafe in ADR-126). No view replaces its own direct children:
   every onShow handler mutates descendants' innerHTML/textContent or a direct child's style.display, and
   the only cloneNode+replaceChild in the app is Settings' rebind(), three levels down on leaf controls.
   Two hazards disappear with the view-root fade: opacity can no longer COMPOUND down the tree (ADR-126
   measured an effective alpha of 0.379 under a nominal 0.45 floor), and no transform is ever applied to
   .spa-view-active, which FW-W5 (style.css:405) forbids because it makes the view a containing block and
   traps the drill's position:fixed layers. The transition is skipped outright while a drill is active.

   Compositor-only by design: opacity + transform ONLY. The commit blocks the main thread for 88 ms (1x
   CPU) to 196 ms (6x), and a compositor-driven animation keeps running through that block — anything
   main-thread-driven, or any layout-affecting property, would visibly stutter instead.

   Motion budget: every timing is calc() on an existing token, which is both the repo's established
   escape hatch for off-scale timings and free against the design-lint census. Easings are pinned at 3/3
   with zero slack — a literal cubic-bezier here would fail the build — so this uses var(--qr-ease)
   (cubic-bezier(.2,.7,.2,1)), whose fast start and long decelerating tail is the right curve for both
   halves: the exit leaves decisively, the return arrives without ever snapping.

   There is deliberately NO total-duration token. JS reads the resolved transition/animation duration and
   delay back off a real unit, so the whole schedule follows these five values and can never drift.
   ══════════════════════════════════════════════════════════════════════════════════════════════════ */
:root {
  --qr-morph-out: calc(var(--qr-dur-fast) * 0.6);        /*  72ms — a section dims                */
  --qr-morph-out-step: calc(var(--qr-dur-fast) * 0.1);   /*  12ms — exit cascade interval (tight) */
  --qr-morph-in: calc(var(--qr-dur) * 0.85);             /* 170ms — a section returns             */
  --qr-morph-step: calc(var(--qr-dur-fast) * 0.22);      /*  26ms — reveal cascade interval (wide)*/
  --qr-morph-floor: 0.45;                                /* never lower: content stays readable   */
}

/* The container is scroll-behavior:smooth, which turned the router's scrollTop=0 into a visible glide
   to the top. Suppressed for the duration so the scroll RESTORE lands instantly. */
html.qr-lang-morphing .container { scroll-behavior: auto; }

/* NOTE: there is deliberately NO `html.qr-lang-morphing .spa-view-active { animation: none }` rule here.
   Suppressing viewSlideIn by class only defers the problem — a CSS animation restarts the instant its
   name becomes non-none again, so removing the suppression at cleanup made the view flash from opacity 0
   at the very END of the transition (measured). The fix is upstream: the transition uses
   Router.refreshCurrentView(), which never re-adds .spa-view-active, so the entry animation is never
   queued in the first place. */

/* EXIT — fast, tight, cascaded by --qr-morph-i (the unit's position in the wave, written by JS). */
.qr-lang-morph-out {
  opacity: var(--qr-morph-floor);
  transition: opacity var(--qr-morph-out) var(--qr-ease);
  transition-delay: calc(var(--qr-morph-i, 0) * var(--qr-morph-out-step));
}

/* RETURN — longer, wider spacing. One animation carrying BOTH properties, with `both` fill so a unit
   holds the floor through its delay instead of snapping to full opacity and then re-dimming. Safe from
   the ADR-126 compounding trap because these units sit inside a view root that is never faded. */
.qr-lang-morph-in {
  animation: qrLangSettle var(--qr-morph-in) var(--qr-ease) both;
  animation-delay: calc(var(--qr-morph-i, 0) * var(--qr-morph-step));
}
@keyframes qrLangSettle {
  from { opacity: var(--qr-morph-floor); transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* Screen-reader-only live region (the announcer). Clipped rather than display:none so it is still
   read; no layout impact. */
.qr-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -2px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion: NO transition at all, not a faster one. The commit still happens, scroll and focus are
   still restored and the change is still announced — only the motion is removed. Written as the repo's
   established pair (OS media query + the body.reduced-motion class that Settings toggles). The JS also
   skips applying these classes entirely, so this is belt-and-braces for a mid-transition preference flip. */
@media (prefers-reduced-motion: reduce) {
  .qr-lang-morph-out { opacity: 1 !important; transition: none !important; }
  .qr-lang-morph-in { animation: none !important; opacity: 1 !important; transform: none !important; }
}
body.reduced-motion .qr-lang-morph-out { opacity: 1 !important; transition: none !important; }
body.reduced-motion .qr-lang-morph-in { animation: none !important; opacity: 1 !important; transform: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════════
   ADR-133 — TOUCH-TARGET FLOOR
   Six isolated icon buttons measured below the 44px usability floor at 390px:
   the paywall close (32px), modal close (36px), Home section edit (27px),
   Quick-Reference back (29px), training card back (34px) and inbox bell (40px).
   Dismissing a paywall with a 32px target is the worst of these.

   The hit area is expanded with an invisible pseudo-element rather than with
   padding, because padding would inflate the PAINTED control and these are
   deliberately small, quiet buttons. The visual result is byte-identical; only
   the region that accepts a finger changes. Only isolated corner/header buttons
   are treated this way — never controls sitting in a row, where an expanded
   target could steal taps from a neighbour.
   ═══════════════════════════════════════════════════════════════════════════ */
.pw-close, .info-modal-close, .home-section-edit,
.qr-lib-back, .training-card-back, .inbox-bell-btn { position: relative; }
/* ADR-134: the bell carried a 24px SVG before it joined the icon system; without this it fell back to
   the 1.2rem default and the button lost 4.8px of height. */
.inbox-bell-btn .qr-ico { --qr-ico-size: 1.5rem; }
.pw-close::after, .info-modal-close::after, .home-section-edit::after,
.qr-lib-back::after, .training-card-back::after, .inbox-bell-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  /* no paint of any kind — this exists purely to be tapped */
}

/* ADR-176: the paywall's third CTA state — readiness not yet answered. Wordless on purpose (no new
   string in three locales); the honest content of that moment is "we don't know yet". */
.pw-cta-pending { display: flex; justify-content: center; align-items: center; min-height: 3rem; }
.pw-cta-spinner { width: 1.25rem; height: 1.25rem; border-radius: 50%;
  border: 2px solid var(--qr-border); border-top-color: var(--qr-primary);
  animation: pw-cta-spin var(--qr-dur-pulse) linear infinite; }
@keyframes pw-cta-spin { to { transform: rotate(360deg); } }
/* Reduced motion: the border-only spinner is already low-amplitude; slow it to the same token the
   rest of the app uses for calm motion rather than inventing a duration. */
@media (prefers-reduced-motion: reduce) { .pw-cta-spinner { animation-duration: var(--qr-dur-pulse); animation-iteration-count: infinite; } }

/* ADR-176: the fourth CTA state — readiness answered no, but a RETRYABLE no. Styled as a secondary
   control, deliberately not as the primary purchase button: it starts a re-check, not a purchase. */
.pw-cta-error { color: var(--qr-text-dim); }
.pw-cta-retry { display: block; width: 100%; margin: 0 0 .5rem; padding: .7rem 1rem;
  border: 1px solid var(--qr-border); border-radius: var(--qr-btn-radius);
  background: var(--qr-surface-2); color: var(--qr-text); font-weight: 700;
  font-size: var(--fs-body); cursor: pointer; }
.pw-cta-retry:active { transform: scale(var(--qr-press-lg)); }
