/* Design tokens live in /tokens.css (linked before this file in HTML). */

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;  /* PR-1: body text baseline per DESIGN-SPEC.md §5.2 */
  /* v2.4.9 hot patch (council 49-24 L1 UNANIMOUS, council log
     .planning/council-49-24-ux-pivot.log): body cap raised from 540px
     to 960px so desktop no longer renders as a phone column on a 1280+
     viewport. Inner text containers should add `max-width: 65ch` for
     readable line-length (Gemini's 65ch addition, Phase 50 work).
     Mobile <540px unchanged — max-width is a cap, not a floor. */
  max-width: 960px;
  margin: 0 auto;
  /* 2026-05-17 CRIT-06 fix (council-crit06-fix-2026-05-17.log,
     3/3 RATIFY): the prior responsive padding-inline formula
     `max(20px, calc((100vw - var(--app-shell-max-width)) / 2))`
     was mathematically incorrect when combined with
     `max-width: 960px` + `margin: 0 auto`. The `margin: 0 auto`
     already centers the capped body in the viewport, so the
     responsive padding INSIDE the cap compressed inner content
     to 640px at 1280×800 (Gate 8 CRIT-06 regression — 7 violations
     across mode-learn/notebooks/qbank/research/write/tutor/animate).
     At 1920×1080 the prior formula clamped content to ~20px.
     The architectural follow-up (move centering to .app-shell,
     make body a full-width canvas) is council-locked but deferred
     to v2.5 Phase 50.X — requires wrapping 6 mode containers. */
  padding-block: 20px;
  padding-inline: 20px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-heading); }

/* Phase 53.X UX-A11Y-FOLLOWUP (kid_ready_walk Criterion 10 sub-set):
   browser defaults render <code>, <pre>, <kbd>, <samp> at ~13.33px which
   fails the kid-readability floor (font_size_min_16px). Force 1rem so
   inline-code spans inherit the 16px body baseline. Monospace family is
   preserved by user-agent defaults; we only override the size. Closes the
   4+ <code>-tag instances flagged on /learn screen at HEAD a83a600
   (verbatim_text includes '@AcumenTutorBot', '/link <code>'). */
code, pre, kbd, samp { font-size: 1rem; }

/* Phase 53 UX-A11Y-01 (kid_ready_walk Criterion 11):
   Global visible-focus ring on every interactive element.
   Per-element overrides may restyle (border-color shift, glow), but
   MAY NOT remove the affordance entirely — Plan 53-02 audits the
   8 sites that historically set `outline: none` and adds explicit
   box-shadow restoration on each.

   :focus-visible (NOT :focus) so mouse clicks don't show rings
   everywhere; only keyboard navigation triggers the ring. Per WCAG
   2.1 AA (council 49-24 §4 row 11). Color token (--primary) is the
   Learning Blue #2563EB — verified 4.5:1+ contrast against the
   --bg (#F8FAFC) and --card (#FFFFFF) tokens. */
*:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 85vh;
  gap: 16px;
  width: 100%;
}

.center-content h1 {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.login-subtitle,
.choose-subtitle {
  font-size: 17px;  /* PR-1: body baseline */
  color: var(--muted-fg);
  text-align: center;
  font-weight: 400;
}

/* U-09: invite-only hint + login error (17px floor, design-token colour). */
.login-no-code,
.choose-grade {
  font-size: 17px;  /* PR-1: body baseline */
  color: var(--muted-fg);
  text-align: center;
}
.login-error {
  font-size: 17px;  /* PR-1: body baseline */
  color: var(--destructive);
  text-align: center;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
input[type="text"], select {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 17px;
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-clay-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow-clay-sm);
}

input[type="text"]::placeholder {
  color: var(--muted-fg);
  font-weight: 400;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
/* Bug-#16 (BETA-RENDER-01): the original rule applied width:100% to every
   <button>, which stretched icon-style controls (settings gear, theme
   toggle, modal close X) across the whole viewport. Default `button` is
   now reset; primary CTA styling is opt-in via class or via the
   stretched .center-content layout below. Icon buttons style themselves
   with their own dimensions in their dedicated rules. */
button {
  display: inline-block;
  padding: 15px 24px;
  border: 3px solid transparent;
  border-radius: var(--radius-btn);
  font-size: 17px;
  font-family: var(--font-heading);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s var(--ease-spring);
  background: var(--cta);
  color: var(--on-cta);
  box-shadow: var(--shadow-clay);
  letter-spacing: 0.01em;
}

/* CTA buttons in the centered login/choose layout still want full width
   so the touch target remains finger-friendly on mobile. */
.center-content > button {
  display: block;
  width: 100%;
}

button:hover {
  background: var(--cta-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-clay-hover);
}

button:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-pressed);
}

button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border-color: var(--border);
  font-family: var(--font-body);
  font-size: 17px;  /* PR-1: body baseline */
  min-height: 48px;  /* PR-1: touch target floor per DESIGN-SPEC §5.3 */
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--muted);
}

.answer-choices button { display: block; width: 100%; margin-bottom: 8px; }
.answer-choices button[aria-checked="true"] { border-color: var(--primary); background: var(--muted); }
#answer-input[hidden], #touch-keypad[hidden], #answer-choices[hidden] { display: none; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 3px solid var(--border);
  box-shadow: none;
  font-family: var(--font-body);
  font-size: 17px;  /* PR-1: body baseline */
  min-height: 48px;  /* PR-1: touch target floor */
}

.btn-outline:hover {
  border-color: var(--primary);
  background: var(--muted);
  box-shadow: var(--shadow-clay-sm);
}

/* ── Animate button (Gate 8 CRIT-10 contrast fix, 2026-05-20) ──────────────
 * The default `button` rule (web/app.css:193-207) sets
 * `background: var(--cta)` (resolves to #F97316) and
 * `color: var(--on-cta)` (resolves to #FFFFFF),
 * which renders at 2.8:1 contrast — below the WCAG AA 4.5:1 floor.
 * Gate 8 kid_ready_walk axe-core CDN scan flagged this as 1 of 14 TRUE
 * residual violations (deploy/.logs/b1ca62b-kid-ready-harness.log).
 *
 * Fix: surgical override on `.animate-btn` ONLY — bg darkened to
 * #C2410C (deep burnt-orange, same color family as --cta-hover #EA580C
 * but past the 4.5 floor). Contrast with white text = 5.18:1 (PASS,
 * 0.68 above floor). The hover state darkens further to maintain the
 * spring-press affordance.
 *
 * WHY a surgical override rather than redefining --cta globally:
 * blast radius. Every CTA in the app inherits `background: var(--cta)`
 * via the default `button` rule (Send, Create KB, Save, etc.). A global
 * --cta token change would shift every CTA's tone simultaneously — a
 * design-system decision that requires its own council session. The
 * Gate 8 violation only flagged #animate-btn (the only axe-visible
 * default-orange CTA at scan time; other CTAs are inside data-kid1-
 * hidden surfaces or sit on overrides). Surgical fix now; system-wide
 * --cta redesign deferred to v2.6 if/when more CTAs surface as
 * Gate 8 violations after Phase 57 unhides Animate + Research.
 *
 * Council-skip per .planning/council-gate8-kb-animate-skip-justification.log
 * (Fix B rationale; Gate 5 evaluated with explicit operator flag-clause
 * check — Option 1 selected as least palette-disruptive: preserves the
 * established white-on-CTA convention used everywhere else in the app).
 *
 * Note: `.animate-btn` is on the Animate mode which is data-kid1-hidden
 * until Phase 57 UX-MODE-CURATION-01. Fixing now (vs deferring) is
 * mechanical + cheap (operator brief) AND removes the test_a11y_contrast_
 * axe.py harness false-positive against the post-deploy axe scan. */
.animate-btn {
  background: #C2410C;
  color: #FFFFFF;
}

.animate-btn:hover {
  background: #9A3412;
}

/* ── Choose screen ────────────────────────────────────────────────────────── */
.choose-header {
  text-align: center;
  padding: 28px 0 4px;
}

.choose-header h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

/* UX Phase 1 — one big Continue CTA on kid home */
.continue-home {
  margin: 20px 0 8px;
  display: flex;
  justify-content: center;
}
.btn-continue {
  width: 100%;
  max-width: 420px;
  min-height: 72px;
  padding: 18px 24px;
  border: 3px solid var(--cta);
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-clay);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-heading);
  transition: transform 0.15s var(--ease-spring), background 0.15s ease;
}
.btn-continue:hover {
  /* Keep --primary (not --primary-light) so white subtitle stays WCAG AA */
  background: var(--primary);
  filter: brightness(0.92);
  box-shadow: var(--shadow-clay-hover);
  transform: translateY(-1px);
}
.btn-continue:active {
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}
.btn-continue-label {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
}
.btn-continue-sub {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  opacity: 1;
}


/* ── Search box ───────────────────────────────────────────────────────────── */
.search-section { margin: 24px 0 0; }

.search-box {
  display: flex;
  gap: 8px;
}

.search-box input { flex: 1; }

.search-box button {
  width: auto;
  padding: 14px 28px;
  flex-shrink: 0;
  background: var(--primary);
}

.search-box button:hover { background: var(--primary-light); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider-or {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.divider-or::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 2px;
  background: var(--border);
}

.divider-or span {
  position: relative;
  background: var(--bg);
  padding: 0 16px;
  color: var(--muted-fg);
  font-weight: 700;
  font-size: 16px;
  font-family: var(--font-heading);
}

/* ── Drop zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 3px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  background: var(--card);
  box-shadow: var(--shadow-clay-sm);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #EFF6FF;
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-clay-hover);
}

.drop-zone-icon { font-size: 3rem; margin-bottom: 10px; }
.drop-zone-text { font-family: var(--font-heading); font-weight: 700; color: var(--fg); font-size: 16px; }
.drop-zone-sub { color: var(--muted-fg); font-size: 16px; margin-top: 4px; }

#upload-preview-img {
  max-width: 100%;
  border-radius: var(--radius-card);
  margin-top: 14px;
  box-shadow: var(--shadow-clay);
}

/* ── Section label ────────────────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 10px;
}

/* ── Topic cards ──────────────────────────────────────────────────────────── */
.topic-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: var(--shadow-clay-sm);
  transition: all 0.25s var(--ease-spring);
}

.topic-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-clay-hover);
}

.topic-card[aria-disabled="true"] {
  cursor: not-allowed;
}

.topic-card[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: var(--shadow-clay-sm);
  border-color: var(--border);
}

.topic-card.selected {
  border-color: var(--primary);
  background: #EFF6FF;
  box-shadow: var(--shadow-pressed);
  transform: scale(0.98);
}

#upload-topic-list > .topic-card,
#upload-topic-list > .topic-card:hover {
  cursor: default;
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.topic-card-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
}

.topic-card-detail {
  font-size: 16px;
  color: var(--muted-fg);
  margin-top: 3px;
}

/* ── Question screen ──────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
  margin-bottom: 16px;
  font-size: 16px;
}

#kc-label { font-family: var(--font-heading); font-weight: 700; color: var(--primary); }
#mastery-pct { font-family: var(--font-heading); font-weight: 800; color: var(--success); }
/* No-fall: "Question N this sitting" sits beside the band word. */
.top-bar__status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.sitting-count { font-weight: 600; color: #334155; }
/* D5 review slot chip ("Review time"); hidden unless is_review. */
.review-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 16px;
  font-weight: 700;
}
.review-chip[hidden] { display: none; }

.question-body {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-clay);
  font-size: 18px;
  line-height: 1.7;
}

.answer-area {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.answer-area input { flex: 1; }

.answer-area button {
  width: auto;
  padding: 14px 28px;
  flex-shrink: 0;
  background: var(--primary);
}

.answer-area button:hover { background: var(--primary-light); }

/* ── Feedback ─────────────────────────────────────────────────────────────── */
#feedback-area { min-height: 40px; margin: 14px 0; }

#feedback-text {
  font-size: 16px;
  line-height: 1.7;
  padding: 18px;
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-clay-sm);
}

/* State classes sit ON #feedback-text (setFeedbackState in app.js), so these
   are compound selectors. The old descendant form (state class on an ANCESTOR of
   #feedback-text) never matched — Opus run10 P2. */
#feedback-text.feedback-correct {
  border-left: 5px solid var(--success);
  background: #ECFDF5;
}

#feedback-text.feedback-incorrect {
  border-left: 5px solid var(--destructive);
  background: #FEF2F2;
}

/* Dark theme keeps its light --fg, so the light tints above would be
   unreadable — use translucent tints over the dark card instead. */
[data-theme="dark"] #feedback-text.feedback-correct   { background: rgba(52, 211, 153, 0.14); }
[data-theme="dark"] #feedback-text.feedback-incorrect { background: rgba(248, 113, 113, 0.14); }

#feedback-text.feedback-thinking {
  color: var(--muted-fg);
  font-style: italic;
}

/* ── Hints ─────────────────────────────────────────────────────────────────── */
/* PR-1: replaced #FFFBEB bg with amber-tint token (WCAG AA compliant). */
#hint-area {
  background: var(--amber-tint, #FFF3D6);
  border: 3px solid var(--secondary);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 14px;
}

#hint-text { font-size: 17px; color: var(--amber-text, #6A4100); }  /* PR-1: body baseline + token */

/* ── Progress ─────────────────────────────────────────────────────────────── */
#skill-bars { margin: 16px 0; }

.skill-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 16px;
}

.skill-name { flex: 1; font-weight: 700; color: var(--fg); }

.skill-bar-bg {
  width: 120px; height: 14px;
  background: var(--muted);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.05);
}

.skill-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 7px;
  transition: width 0.6s var(--ease-spring);
}

.skill-pct {
  width: 45px;
  text-align: right;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--primary);
}

/* ------------------------------------------------------------------
   Phase 52 UX-MICROCOPY-02 — per-skill mastery bars on progress screen
   UX-AUDIT.md §Screen 7 BLOCKER — empty #skill-bars div populated with
   kid-friendly bars + qualitative band label. Rules appear after the
   legacy .skill-row block so cascade order wins for the new layout
   (vertical stack of name → bar → caption) without removing the old
   .skill-bar-bg / .skill-bar-fill / .skill-pct rules still referenced
   by other call sites.
   ------------------------------------------------------------------ */

#skill-bars-summary {
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #1a202c);
  margin: 8px 0 16px 0;
}

.skill-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--surface, #ffffff);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.skill-row__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #1a202c);
  line-height: 1.3;
}

.skill-row__bar {
  height: 10px;
  background: var(--bar-track, #e5e7eb);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.skill-row__fill {
  height: 100%;
  background: var(--accent, #2563eb);
  border-radius: 999px;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 0;
}

.skill-row__caption {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Phase 53.X UX-A11Y-FOLLOWUP — was 14px (Plan 52-03 default); raised to
     1rem to satisfy the 16px kid-readability floor (test_a11y_font_size_sweep
     test_no_sub_16px_explicit_declarations + kid_ready_walk CRIT-10). */
  font-size: 1rem;
  color: var(--text-muted, #6b7280);
}

.skill-row__band {
  font-weight: 600;
}

.skill-row__sep {
  opacity: 0.5;
}

.skill-row__attempts {
  color: var(--text-muted, #6b7280);
}

/* 4-level band color modifiers — kid-celebratory palette */
.skill-row__band--warming {
  color: var(--warming, #c2410c);   /* warm orange — "just starting" */
}
.skill-row__band--strong {
  color: var(--strong, #1d4ed8);    /* medium blue — "building" */
}
.skill-row__band--almost {
  color: var(--almost, #047857);    /* deep green — "close to mastery" */
}
.skill-row__band--gotit {
  color: var(--gotit, #6d28d9);     /* celebration purple — "you've got this" */
}

/* Empty-state surface for the progress screen */
.skill-bars-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted, #6b7280);
  font-size: 16px;
}

/* Mobile (375×812) — slightly tighter spacing */
@media (max-width: 480px) {
  .skill-row {
    padding: 10px 12px;
  }
  .skill-row__name {
    /* Phase 53.X UX-A11Y-FOLLOWUP — was 15px; raised to 1rem to satisfy
       the 16px floor at mobile (375×812) viewport. */
    font-size: 1rem;
  }
  .skill-row__caption {
    /* Phase 53.X UX-A11Y-FOLLOWUP — was 13px; raised to 1rem. Caption
       text on a 375px-wide row remains readable at 16px (12-char band
       label fits comfortably). */
    font-size: 1rem;
  }
}

/* ── Upload preview ──────────────────────────────────────────────────────── */
#upload-preview {
  text-align: center;
  margin: 12px 0;
}

#upload-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-card);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-clay-sm);
  object-fit: contain;
}

/* ── Upload status ────────────────────────────────────────────────────────── */
#upload-status {
  background: var(--muted);
  border: 3px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin: 14px 0;
}

#upload-status-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-heading);
}

/* ── Upload progress bar ─────────────────────────────────────────────────── */
.upload-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--cta));
  background-size: 200% 100%;
  border-radius: 8px;
  width: 0%;
  transition: width 0.6s ease;
  animation: upload-shimmer 1.5s ease-in-out infinite;
}

@keyframes upload-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.upload-progress-step {
  font-size: 16px;
  color: var(--muted-fg);
  font-family: var(--font-body);
  margin-top: 6px;
}

/* ── Connection banner ────────────────────────────────────────────────────── */
#connection-banner {
  background: var(--secondary);
  color: var(--on-secondary, #0F172A);
  text-align: center;
  padding: 10px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-heading);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* ── v2.5.5 G1 PWA update banner (Council Gate 4 OPTION-C 3/3) ──────────── */
/* Kid-voice "fresh version is ready" banner. Persistent — only dismissed by */
/* tapping "Refresh now" or by a safe-boundary auto-reload (between-problems,*/
/* login screen, idle 5min). Slightly warmer color than connection-banner so */
/* the kid reads it as informational, not error. */
#sw-update-banner {
  background: #DBEAFE;          /* soft blue — informational */
  color: #1E3A8A;
  text-align: center;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-heading);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
#sw-update-banner[hidden] {
  display: none !important;
}
.sw-update-banner-text {
  flex: 1 1 auto;
  min-width: 0;
}
.sw-update-banner-btn {
  background: #1B3A6B;
  color: #FFFFFF;
  border: none;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-heading);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 48px;             /* PR-1: 48px touch target floor */
}
.sw-update-banner-btn:hover,
.sw-update-banner-btn:focus {
  background: #15305C;
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
}

/* ── Button spacing in question screen ────────────────────────────────────── */
#btn-next, #btn-hint, #btn-progress, #btn-topic { margin-bottom: 10px; }

#btn-next { background: var(--primary); color: var(--on-primary); }
#btn-next:hover, #btn-next:focus-visible { background: var(--primary-light); }

/* PR-1: #D97706 on #FFFBEB fails WCAG AA (2.8:1); retired per DESIGN-SPEC §5.1.
   Hint button: --on-secondary text on --secondary fill (6.39:1 light), hover --amber-text (8.86:1). */
#btn-hint { background: var(--secondary); color: var(--on-secondary, #0F172A); }
#btn-hint:hover { background: var(--amber-text, #6A4100); }

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  body { padding: 14px; }
  .center-content h1 { font-size: 2rem; }
  .choose-header h2 { font-size: 1.6rem; }
  .search-box { flex-direction: column; }
  .search-box button { width: 100%; }
  .answer-area { flex-direction: column; }
  .answer-area button { width: 100%; }
  .question-body { padding: 16px; font-size: 16px; }
}

/* -- Deep Solve ------------------------------------------------------------ */
.solve-header { text-align: center; padding: 28px 0 16px; }
.solve-header h2 { font-size: 2rem; font-weight: 800; color: var(--primary); }
.solve-subtitle { font-size: 16px; color: var(--muted-fg); }

.solve-textarea {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-clay-sm);
  resize: vertical;
  min-height: 100px;
  margin-bottom: 12px;
  outline: none;
}
.solve-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow-clay-sm);
}

/* Phase progress bar */
.solve-phase-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 20px 0;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
}

.solve-phase-dot {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--muted-fg);
  background: var(--muted);
  transition: all 0.3s var(--ease-spring);
  text-align: center;
}
.solve-phase-dot.active {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: var(--shadow-clay);
  transform: scale(1.05);
}
.solve-phase-dot.completed {
  color: var(--on-primary);
  background: var(--success);
}

.solve-phase-connector {
  width: 20px;
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

/* Output area */
#solve-output {
  max-height: 500px;
  overflow-y: auto;
  margin: 16px 0;
}

.solve-phase-section {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-clay-sm);
}

.solve-phase-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  font-family: var(--font-heading);
}

.solve-phase-content {
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Tool call/result display */
.solve-tool-call {
  background: #FEF3C7;
  border: 2px solid var(--secondary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 16px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: #92400E;
}

.solve-tool-result {
  background: var(--muted);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 4px 0 10px;
  font-size: 16px;
  font-family: monospace;
  white-space: pre-wrap;
  color: var(--fg);
}

/* Status */
#solve-status {
  text-align: center;
  margin: 10px 0;
}
#solve-status-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
}

/* ── Accessibility (UI audit fix #2) ──────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Quiz Cards (UI audit fix #1) ─────────────────────────── */
.quiz-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-clay);
}
.quiz-q-num {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 8px;
}
.quiz-question {
  font-family: var(--font-body);
  font-size: 16px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.quiz-answer-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.quiz-answer-row input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 16px;
}
.quiz-answer-row button {
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
}
.quiz-correct { color: var(--success); font-weight: 700; }

/* ── Stop + Regenerate buttons (UX-01, UX-02) ────────────────────────────── */
.btn-stop {
  background: var(--destructive);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  padding: 8px 18px;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-clay-sm);
}
.btn-stop:hover { filter: brightness(1.05); }

.btn-regenerate {
  background: var(--card);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-btn);
  padding: 6px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-regenerate:hover { background: var(--muted); }

#btn-solve-stop { margin-top: 12px; }

/* ── Toast notification (UX-03) ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: var(--fg);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  box-shadow: var(--shadow-clay);
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Save-to-notebook button (UX-03) ─────────────────────────────────────── */
.btn-save-note {
  display: inline-block;
  margin-left: 8px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-btn);
  padding: 2px 10px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-save-note:hover { background: var(--muted); }

/* Phase 29 / NOTE-02: source-color left-border accent on save buttons */
.btn-save-note[data-source]                      { border-left: 3px solid var(--source-color-chat); }
.btn-save-note[data-source="research"]           { border-left-color: var(--source-color-research); }
.btn-save-note[data-source="cowriter"]           { border-left-color: var(--source-color-cowriter); }
.btn-save-note[data-source="book"]               { border-left-color: var(--source-color-book); }
.btn-save-note[data-source="journey"]            { border-left-color: var(--source-color-journey); }
.quiz-incorrect { color: var(--destructive); font-weight: 700; }

/* Dark/HC palette tokens: /tokens.css */

/* ── Mode nav (UX-05) ────────────────────────────────────────────────────── */
/* Phase 49 Plan 49-05 (Bug #2 fix) — council Gate 4 Hybrid C, 3/3 unanimous:
 *   - REMOVED `max-width: 540px` cap. The 540px clamp was the root cause —
 *     it forced the 7 pills (Learn, Notebooks, Question Bank, Research, Write,
 *     Tutor, Animate) to overflow at every desktop viewport. Without the cap,
 *     the flex container expands to its parent's content width and all 7 pills
 *     fit on one line at >=1024px viewports.
 *   - REMOVED `scrollbar-width: none` + `::-webkit-scrollbar { display: none }`.
 *     These hid the only affordance the user had to discover off-screen tabs.
 *     At narrow viewports (<1024px-ish) where pills DO still overflow,
 *     overflow-x:auto + the browser-default scrollbar now provides a visible
 *     scroll affordance — pure CSS, no JS, vanilla-PWA-compatible.
 *   - flex-wrap:wrap kept off (pills stay on a single row); see council log
 *     `.planning/council-49-05-mode-nav-fix.log` Q1 §"Final disposition" for
 *     why the no-wrap variant was chosen over multi-row.
 *   - Recurrence-class regression: tests/e2e/test_mode_nav_viewport.py
 *     locks the invariant `scrollWidth <= clientWidth at [1280, 1440, 1920]`.
 */
.mode-nav {
  display: flex;
  gap: 6px;
  padding: 8px 0 16px;
  margin: 0 auto;
  /* Honor parent layout — let viewport (or container) decide width. */
  width: 100%;
  /* When content overflows (narrow viewports), the leading pill must be
   * reachable without scrolling — start at flex-start, let the user scroll
   * right naturally (matches browser tab strip / file manager pattern).
   * On desktop where content fits, the pills group at the left edge of the
   * nav — but the nav itself is `margin: 0 auto` and `max-width` of its
   * parent (.center-content / body), so the cluster still appears centered
   * within the page. */
  justify-content: flex-start;
  /* Allow horizontal scroll ONLY when content overflows (narrow widths);
   * the browser-default scrollbar is the visible affordance. NO scrollbar
   * hide rules — that was the bug. */
  overflow-x: auto;
  /* Prevent vertical scrollbar from creeping in due to scrollbar height
   * pushing the row down on narrow widths. */
  overflow-y: hidden;
  /* Plan 49-21 D8 fix: right-edge fade at ALL viewport widths. iOS Safari
   * + Android Chrome auto-hide scrollbars; without the fade, edge tabs
   * ("Learn" + "Animate") clipped silently at 375px. Originally Plan 49-12
   * gated this to @media (min-width: 1024px) on the assumption mobile
   * always-shows scrollbar — that assumption was wrong on modern mobile. */
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
          mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
}

/* Plan 49-12 FAIL-2 fix: desktop scroll affordance.
 *
 * Plan 49-05's Hybrid C restored the browser-default scrollbar — works on
 * mobile (always-visible) but on Chrome/Windows desktop scrollbars hide
 * until hover, leaving the user with no cue that the nav can scroll. Live
 * harness flagged 21 failures across (1280, 1440, 1920) × 7 tabs
 * (.planning/v2.4-LIVE-HARNESS-FAILURES.md §FAIL-2; harness log 2026-05-11).
 *
 * Fix: layer a right-edge linear-gradient mask onto the nav whenever it
 * scrolls horizontally. The fade signals "more to the right" at every
 * desktop viewport without any JS, without altering Plan 49-05's mobile
 * fix, and without consuming layout space. Council Gate 4 ratified
 * 3/3 unanimous (.planning/council-49-12-fix-design.log §FAIL-2).
 *
 * Recurrence class: tests/e2e/test_mode_nav_viewport.py extension asserts
 * the right-edge fade is detectable when scrollWidth > clientWidth.
 */
@media (min-width: 1024px) {
  /* Desktop-specific: widen the fade strip (32px vs 24px mobile) and
   * force scrollbar visible on hover/focus-within so keyboard users get
   * an explicit affordance. Base mask-image lives on .mode-nav at all
   * widths now (Plan 49-21 D8 fix). */
  .mode-nav {
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
            mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
  }
  .mode-nav:hover,
  .mode-nav:focus-within {
    scrollbar-width: thin;  /* Firefox */
  }
  .mode-nav:hover::-webkit-scrollbar,
  .mode-nav:focus-within::-webkit-scrollbar {
    height: 6px;
    display: block;
  }
}

.mode-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted-fg);
  background: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  /* Prevent the long labels (Question Bank, Notebooks) from wrapping mid-pill. */
  white-space: nowrap;
}
.mode-pill.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.mode-pill:hover { background: var(--primary-light); color: var(--on-primary); }

.mode-container { display: none; }
.mode-container.mode-active { display: block; }
/* v2.4.9 hot patch (UX audit §Screen 12 + §Screen 13 BLOCKER): force-hide
   non-active mode containers. Without this, `.cowriter-root` later in the
   cascade (line ~1609 below) wins display:flex specificity, leaking the
   Write panel into Tutor + Animate modes. !important is justified because
   the active/inactive contract is fundamental to mode isolation — no
   downstream rule should override. Five Whys + RCA:
   .planning/v2.4.9-HOTPATCH-RCA.md Cluster C. */
.mode-container:not(.mode-active) { display: none !important; }

/* Phase 57 UX-MODE-CURATION-01 (productionization of v2.4.9 D3 3A hot patch):
   age-gated mode-pill visibility via body[data-grade-band="..."], derived
   from state.gradeLevel by _setGradeBandBodyAttr() in web/app.js. Council
   49-25 D3 3C SPLIT-but-compatible architectural target ratified 2026-05-14.

   Visibility matrix (grades 9-12 modes):
     9-12     → 6 visible (Learn, Notebooks, Question Bank, Research, Write,
                Animate); Tutor hidden
     K-8      → 3 visible (Learn, Notebooks, Question Bank); Research,
                Write, Animate, Tutor hidden
     teacher  → same as K-8 (kid shell; teachers use teacher.html)
     pre-login / unknown / missing grade → same as K-8 (fail closed)

   Classes:
     .mode-pill-g912-unlock  — Research, Write, Animate. Shown ONLY when
                               body[data-grade-band="9-12"]. Written as a
                               :not() rule because body[data-kid1="true"]
                               is static in index.html and is never removed,
                               so a positive data-kid1 rule would also hide
                               these pills for a logged-in 9-12 student.
     .mode-pill-always-hidden — Tutor. Hidden for every cohort.
     .mode-pill-kid-1-hidden  — legacy class, still on Tutor; rules below
                               kept so cached PWA shells stay fail-closed.
   web/app.js blockedModesForBand() enforces the same matrix on #/hash
   routes — keep the two in sync.

   Deprecation: body[data-kid1="true"] kept as deprecated fail-closed
   alias for pre-login state + back-compat with cached PWA clients that
   haven't loaded the Phase 57 web/app.js yet. Both selectors have EQUAL
   CSS specificity (0,2,1 — attribute + class on the same element); the
   data-grade-band rule wins for cached-PWA overlap because it appears
   LATER in source order (Codex Gate 3 v1 LOW remediation: "more specific"
   wording was incorrect). Removal of data-kid1 is a v2.6 cleanup commit
   after one full beta cycle confirms no regression.

   Reference: .planning/council-49-25-architecture.log §D3. */
body[data-kid1="true"] .mode-pill-kid-1-hidden { display: none; }
body[data-grade-band="K-8"] .mode-pill-kid-1-hidden { display: none; }
body[data-grade-band="9-12"] .mode-pill-kid-1-hidden { display: none; } /* UX Phase 0: all students */
body[data-grade-band="teacher"] .mode-pill-kid-1-hidden { display: none; } /* kid shell; use teacher.html */
body:not([data-grade-band="9-12"]) .mode-pill-g912-unlock { display: none; } /* fail closed: pre-login, K-8, teacher, unknown */
.mode-nav .mode-pill.mode-pill-always-hidden { display: none; } /* Tutor: hidden for all cohorts */

/* v2.5.3 C4 fix — topic cards on the choose screen that expose
   adult-vocab destinations ("Knowledge Base", "Deep Solve", "Teacher
   Dashboard"). Council audit flagged these as 9yo dead-end risk.
   Same cohort-gating contract as .mode-pill-kid-1-hidden above.
   Reference: .planning/council-v2.5.2-feature-audit.log §C4. */
body[data-kid1="true"] .topic-card-kid-1-hidden { display: none; }
body[data-grade-band="K-8"] .topic-card-kid-1-hidden { display: none; }
body[data-grade-band="9-12"] .topic-card-kid-1-hidden { display: none; } /* UX Phase 0: all students */
body[data-grade-band="teacher"] .topic-card-kid-1-hidden { display: none; } /* kid shell; use teacher.html */

/* UX Phase 0 — the choose-screen "or" divider that precedes the
   kid-1-hidden topic cards. Same cohort-gating contract as above. */
body[data-kid1="true"] .divider-kid-1-hidden { display: none; }
body[data-grade-band="K-8"] .divider-kid-1-hidden { display: none; }
body[data-grade-band="9-12"] .divider-kid-1-hidden { display: none; } /* UX Phase 0: all students */
body[data-grade-band="teacher"] .divider-kid-1-hidden { display: none; }

.mode-placeholder {
  background: var(--card);
  color: var(--card-fg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 32px;
  text-align: center;
  margin: 24px auto;
  max-width: 540px;
}
.mode-placeholder h2 { color: var(--primary); margin-bottom: 8px; }
.mode-placeholder p  { color: var(--muted-fg); }

/* ── Theme toggle button (UX-04) ─────────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-clay-sm);
}
.theme-toggle:hover { background: var(--muted); }

/* Phase 17 — Visualization containers (VIZ-01..04) */
.viz-container {
  margin: 12px 0;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 60px;
  overflow-x: auto;
  color: var(--fg);
}
.viz-container svg,
.viz-container canvas,
.viz-container video {
  max-width: 100%;
  height: auto;
}
.viz-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px;
}
.viz-gallery-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}
.viz-gallery-item h4 { margin: 0 0 6px 0; font-size: 16px; }
/* Phase 53 A11Y exception — manim viz-gallery captions sit inside the
   `Animate` mode-pill which is kid-1-hidden via `data-kid1` until
   Phase 57 UX-MODE-CURATION-01 grade-level unhide. Preserving the 12px
   caption metric until that unhide lands. See
   .planning/phases/53-a11y-typography-v2-5/53-CONTEXT.md <edge_cases>. */
.viz-gallery-item p  { margin: 0; font-size: 12px; color: var(--muted-foreground); }

/* Phase 18 — Guided Learning Journey UI (GUIDE-01..05) */
.journey-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.journey-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
  font: inherit;
}
.journey-card:hover { background: var(--muted); }
.journey-scaffold-badge {
  display: inline-block;
  font-size: 16px;
  padding: 2px 8px;
  background: var(--muted);
  border-radius: 999px;
  margin-bottom: 8px;
  color: var(--muted-foreground);
}
.journey-content { line-height: 1.6; margin: 12px 0; }
.journey-content p { margin: 8px 0; }
.journey-checkpoint {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}
.journey-checkpoint h4 { margin: 0 0 8px 0; }
.journey-mcq-option {
  display: block;
  width: 100%;
  text-align: left;
  margin: 4px 0;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--fg);
  font: inherit;
}
.journey-mcq-option:hover { background: var(--muted); }
.journey-sa-input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; }
.journey-feedback { margin-top: 8px; font-size: 16px; color: var(--muted-foreground); }
.journey-chat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}
.journey-chat-log { max-height: 200px; overflow-y: auto; margin: 8px 0; font-size: 16px; }
.journey-chat-user { color: var(--primary); margin: 4px 0; }
.journey-chat-bot { color: var(--fg); margin: 4px 0; }
.journey-next-btn { margin-top: 16px; }

/* ── Phase 19: TutorBot persona switcher ─────────────────────────────────── */
/* Bug-#18 (BETA-RENDER-03): the three top-right controls (theme-toggle,
   settings-toggle, bot-switcher) all used position:fixed top:12px with
   `right:` offsets that hadn't accounted for bot-switcher growing once
   a persona name was loaded into the dropdown ("Drill Sergeant" etc).
   The 212px-wide bot-switcher overlapped the 35px settings gear and
   the 95px theme button, leaving "eme: light" visible on the right
   edge with the rest hidden behind the gear.

   New right-stops (right-to-left, gap 8px between each):
     theme-toggle:    right: 12px              (~95px wide → ends at 107)
     settings-toggle: right: 115px             (~35px wide → ends at 150)
     bot-switcher:    right: 158px             (~212px wide → ends at 370)
*/
.bot-switcher {
  position: fixed;
  top: 12px;
  right: 158px; /* clear of settings-toggle (right:115 + 35 width + 8 gap) */
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 100;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  box-shadow: var(--shadow-clay-sm);
}

.bot-switcher-label {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--muted-fg);
  white-space: nowrap;
}

.bot-switcher-select {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.bot-switcher-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* Dark + HC theme overrides */
[data-theme="dark"] .bot-switcher,
[data-theme="hc"] .bot-switcher {
  background: var(--card);
  border-color: var(--border);
}

[data-theme="dark"] .bot-switcher-select,
[data-theme="hc"] .bot-switcher-select {
  background: var(--card);
  color: var(--fg);
  border-color: var(--border);
}

/* Responsive: hide label on very small screens */
@media (max-width: 480px) {
  .bot-switcher {
    right: 80px;
    padding: 4px 6px;
  }
  .bot-switcher-label {
    display: none;
  }
}

/* ── Phase 58 UX-RENDER-01: collapse chrome controls into settings modal ──
   Council 2/3 unanimous A (.planning/council-phase-58.log Q1) — eliminate
   the position:fixed bug class entirely by hiding #theme-toggle and
   #bot-switcher at ALL viewports. Controls remain in DOM so existing JS
   state writes (initTheme, loadBotSwitcher) work unchanged, but the
   user-facing UX lives in #settings-modal Display + Tutor Style sections.
   Closes the Phase 19 BETA-RENDER-03 regression class triggered when
   "Patient Explainer" + "Socratic Mentor" personas widened the dropdown
   past the Phase 19 width assumption. */
#theme-toggle,
#bot-switcher {
  display: none !important;
}

/* Settings modal Display + Tutor Style controls */
.settings-label {
  display: block;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--muted-fg);
  margin: 8px 0 4px 0;
}
.settings-select {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.settings-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* ── Phase 58 UX-RENDER-02: global back-nav primitive ──
   Council 2/3 unanimous A (.planning/council-phase-58.log Q2 + Q3) —
   #nav-back lives INSIDE the body flow (not position:fixed) and routes
   deterministically to screen-choose. Visibility is gated by
   body[data-active-screen] which showScreen() sets at app.js. Closes
   the "no uniform way back from detail screens" finding from Phase 4D.

   Default hidden; revealed for any active screen that is NOT login
   or choose (the two mode-root surfaces that have no "back" semantic). */
.nav-back {
  display: none;
  margin: 8px 16px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-clay-sm);
  min-height: 48px;  /* PR-1: touch target floor per DESIGN-SPEC §5.3 */
  min-width: 48px;   /* PR-1: touch target floor */
}
.nav-back:hover {
  background: var(--muted);
}
.nav-back:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}
body:not([data-active-screen=""]):not([data-active-screen="screen-login"]):not([data-active-screen="screen-choose"]) #nav-back {
  display: inline-block;
}

/* =====================================================   Phase 20 — Research mode styles
   ============================================================ */

.research-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.research-subtitle {
  color: var(--muted-fg);
  font-size: 16px;
  margin: 0;
}

.research-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.research-textarea {
  width: 100%;
  min-height: 90px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

/* Plan 53-02 UX-A11Y-01 — CRIT-11 fix site.
   This is the CRIT-11 violation site flagged by Step F harness on
   2026-05-16 (deploy/.logs/2026-05-16-post-F-pre-deploy-kid-ready.log
   line ~800: "outlineStyle: 'none', boxShadow: 'none', tag: 'textarea'").
   The box-shadow below restores visible focus per WCAG 2.1 AA. */
.research-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.research-submit-btn {
  align-self: flex-start;
  min-width: 120px;
}

.research-hint {
  font-size: 16px;
  color: var(--muted-fg);
  margin: 0;
}

/* Status strip */
.research-status {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 16px;
}

.research-status-info {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

.research-status-success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
}

.research-status-error {
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  color: var(--destructive);
  border: 1px solid color-mix(in srgb, var(--destructive) 30%, transparent);
}

/* Report card */
.research-report {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-outer);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.research-query-echo {
  font-size: 16px;
  color: var(--muted-fg);
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Source badges */
.research-sources-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.research-source-badge {
  font-size: 16px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.research-source-rag {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.research-source-web {
  background: color-mix(in srgb, var(--secondary) 20%, transparent);
  color: #92400e;
}

.research-source-academic {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

/* Report body typography */
.research-report-body {
  line-height: 1.7;
  font-size: 16px;
  color: var(--fg);
}

.research-report-body p {
  margin: 0 0 12px;
}

.research-heading {
  font-family: var(--font-display, inherit);
  font-weight: 700;
  color: var(--fg);
  margin: 20px 0 8px;
}

.research-report-body h2.research-heading { font-size: 20px; }
.research-report-body h3.research-heading { font-size: 17px; }
.research-report-body h4.research-heading { font-size: 16px; }

.research-blockquote {
  border-left: 3px solid var(--primary);
  margin: 0 0 12px;
  padding: 6px 14px;
  color: var(--muted-fg);
  font-style: italic;
}

.research-blockquote p {
  margin: 0;
}

.research-list {
  margin: 0 0 12px;
  padding-left: 24px;
}

.research-list li {
  margin-bottom: 6px;
}

/* Phase 53 A11Y exception — inline citation superscript inside
   `Research` mode-pill, kid-1-hidden via `data-kid1` until Phase 57
   UX-MODE-CURATION-01 grade-level unhide. Superscript convention
   requires sub-baseline metrics; the 11px size is load-bearing for
   the visual pattern. See
   .planning/phases/53-a11y-typography-v2-5/53-CONTEXT.md <edge_cases>. */
/* Inline citation superscript */
.research-citation {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  padding: 0 1px;
}

.research-citation:hover {
  text-decoration: underline;
}

/* Citations section */
.research-citations-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin: 16px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.research-citation-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.research-citation-item {
  display: flex;
  gap: 10px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted-fg);
}

.research-citation-number {
  font-weight: 700;
  color: var(--primary);
  min-width: 28px;
  flex-shrink: 0;
}

.research-citation-content {
  flex: 1;
}

.research-citation-link {
  color: var(--primary);
  word-break: break-all;
}

.research-citation-link:hover {
  text-decoration: underline;
}

/* Dark theme overrides */
[data-theme="dark"] .research-textarea {
  background: var(--card);
  color: var(--fg);
  border-color: var(--border);
}

[data-theme="dark"] .research-source-web {
  color: #fcd34d;
}

@media (max-width: 600px) {
  .research-container {
    padding: 16px 12px;
  }
  .research-report {
    padding: 16px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Phase 21 — Engagement: Streak Badge + Notification Banner
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Streak badge ──────────────────────────────────────────────────────────── */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--secondary, #F59E0B);
  color: var(--on-secondary, #fff);  /* PR-1: AA in light (6.39:1), dark (9.04:1) and hc */
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-clay-sm);
  white-space: nowrap;
  transition: transform 0.15s var(--ease-spring, ease);
}

.streak-badge:hover {
  transform: scale(1.05);
}

/* PR-1: no dark override - base .streak-badge uses --secondary / --on-secondary
   (dark: #0F172A on #FFA500, 9.04:1). */

/* ── Notification banner ───────────────────────────────────────────────────── */
.notification-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: var(--primary, #2563EB);
  color: #fff;
  font-family: var(--font-body);
  font-size: 1rem;
  position: relative;
  z-index: 1000;
  box-sizing: border-box;
  animation: bannerSlideDown 0.3s var(--ease-spring, ease) both;
}

@keyframes bannerSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.notification-banner--check_in {
  background: linear-gradient(90deg, var(--primary, #2563EB), #7c3aed);
}

.notification-banner--streak_reminder {
  background: linear-gradient(90deg, var(--secondary), var(--cta));
  color: var(--on-secondary);
}

.notification-banner--review_due {
  background: linear-gradient(90deg, #0891b2, #0e7490);
}

.notification-banner__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.notification-banner__text {
  flex: 1;
  min-width: 0;
}

.notification-banner__title {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.notification-banner__body {
  margin: 2px 0 0;
  opacity: 0.92;
  font-size: 1rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-banner__cta {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-btn, 20px);
  padding: 6px 16px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s var(--ease-spring, ease);
}

.notification-banner__cta:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.04);
}

.notification-banner__dismiss {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s, transform 0.15s;
}

.notification-banner__dismiss:hover {
  color: #fff;
  transform: scale(1.2);
}

@media (max-width: 600px) {
  .notification-banner {
    flex-wrap: wrap;
    padding: 10px 14px;
  }
  .notification-banner__body {
    white-space: normal;
  }
  .notification-banner__cta {
    order: 3;
    width: 100%;
    text-align: center;
    margin-top: 4px;
  }
  .streak-badge span,
  .streak-badge .label {
    display: none; /* hide "day streak" text on small screens, keep icon+number */
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Phase 22 — Co-Writer layout
   Sidebar (doc list) + main editor/preview pane, action menu, autonomy modal
   ══════════════════════════════════════════════════════════════════════════ */

/* Root layout: sidebar + main side-by-side */
.cowriter-root {
  display: flex;
  gap: 0;
  height: calc(100vh - 140px);
  min-height: 400px;
  overflow: hidden;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay);
  background: var(--card);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.cw-sidebar {
  width: 220px;
  min-width: 180px;
  max-width: 260px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--muted);
  border-radius: var(--radius-card) 0 0 var(--radius-card);
  overflow: hidden;
}

.cw-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.cw-sidebar-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin: 0;
}

.cw-btn-new {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-btn);
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.cw-btn-new:hover { background: var(--primary-light); }

.cw-doc-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

.cw-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 2px 6px;
  transition: background 0.15s;
}
.cw-doc-item:hover { background: var(--border); }
.cw-doc-item.active {
  background: var(--primary);
  color: var(--on-primary);
}
.cw-doc-item.active .cw-doc-name { color: var(--on-primary); }
.cw-doc-item.active .cw-doc-delete { color: rgba(255,255,255,0.7); }

.cw-doc-name {
  font-size: 16px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
}

.cw-doc-delete {
  background: none;
  border: none;
  color: var(--muted-fg);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.1s;
}
.cw-doc-delete:hover { color: var(--destructive); }

.cw-doc-empty {
  padding: 12px 14px;
  font-size: 16px;
  color: var(--muted-fg);
  font-style: italic;
}

/* ── Main editor area ────────────────────────────────────────────────────── */

.cw-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.cw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  gap: 12px;
  flex-shrink: 0;
}

.cw-doc-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cw-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cw-save-status {
  font-size: 16px;
  color: var(--muted-fg);
  min-width: 80px;
  text-align: right;
}

.cw-btn-toggle {
  background: var(--muted);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.cw-btn-toggle:hover { background: var(--border); }

/* ── Editor pane ─────────────────────────────────────────────────────────── */

.cw-editor-pane {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.cw-editor {
  flex: 1;
  padding: 20px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--card);
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Plan 53-02 UX-A11Y-01 — Council R2 missed-site catch.
   .cw-editor base block sets outline:none (~L1866); without a paired
   :focus rule, keyboard users lose all visible affordance on the
   cowriter editor. Restore via box-shadow glow on focus. */
.cw-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* Placeholder via ::before when empty */
.cw-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-fg);
  pointer-events: none;
}

.cw-preview {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--card);
}

/* Markdown preview typography */
.cw-preview h1, .cw-preview h2, .cw-preview h3 {
  font-family: var(--font-heading);
  margin: 1em 0 0.5em;
}
.cw-preview p { margin: 0.5em 0; }
.cw-preview ul, .cw-preview ol { padding-left: 1.5em; margin: 0.5em 0; }
.cw-preview code {
  background: var(--muted);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 16px;
}
.cw-preview pre {
  background: var(--muted);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
}
.cw-preview blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  color: var(--muted-fg);
  margin: 0.5em 0;
}

/* ── Selection action menu ───────────────────────────────────────────────── */

.cw-action-menu {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  z-index: 10;
}

.cw-action-btn {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-btn);
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s var(--ease-spring);
}
.cw-action-btn:hover { background: var(--primary-light); transform: scale(1.04); }
.cw-action-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Autonomy modal ──────────────────────────────────────────────────────── */

.cw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.cw-modal {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-hover);
  padding: 28px 24px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cw-modal h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--fg);
  margin: 0;
}

.cw-modal-question {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

/* PR #38: AI-help transparency line + neutral flagged-assist note. */
.cw-ai-disclosure,
.cw-modal-review-note {
  font-size: 16px;
  color: var(--muted-fg);
  margin: 8px 0 0;
}

.cw-modal-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.cw-modal-suggested {
  background: var(--muted);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.cw-modal-rationale {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 16px;
  resize: vertical;
  color: var(--fg);
  background: var(--card);
  outline: none;
}
.cw-modal-rationale:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.cw-modal-btns {
  display: flex;
  gap: 10px;
}

.cw-btn-accept {
  flex: 1;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-btn);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.cw-btn-accept:hover { background: var(--primary-light); }

.cw-btn-discard {
  flex: 1;
  background: var(--muted);
  color: var(--muted-fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.cw-btn-discard:hover { background: var(--border); }

/* ── Responsive: collapse sidebar on small screens ───────────────────────── */

@media (max-width: 600px) {
  .cowriter-root { flex-direction: column; height: auto; min-height: 0; }
  .cw-sidebar { width: 100%; max-width: 100%; border-right: none; border-bottom: 1px solid var(--border); border-radius: var(--radius-card) var(--radius-card) 0 0; max-height: 180px; }
  .cw-doc-list { display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 6px; padding: 6px; }
  .cw-doc-item { min-width: 120px; flex-shrink: 0; }
  .cw-editor-pane { min-height: 300px; }
  .cw-editor, .cw-preview { min-height: 300px; }
}

/* ===================================================================   Phase 23 — Book Engine Reader Styles
   Theme-aware via CSS custom properties (Phase 16 light/dark/hc support)
   ========================================================================== */

/* Book list */
.book-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.book-list-title { margin: 0; font-size: 22px; }
.book-create-btn { margin-left: auto; }
.book-list { display: flex; flex-direction: column; gap: 12px; }
.book-list-empty { color: var(--text-muted, #888); font-style: italic; }

/* Book card */
.book-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: var(--radius-card, 8px);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.book-card-topic { flex: 1; font-weight: 600; font-size: 16px; min-width: 120px; }
.book-card-meta { display: flex; align-items: center; gap: 8px; }
.book-card-pages { font-size: 16px; color: var(--text-muted, #888); }
.book-card-progress { font-size: 16px; color: var(--accent, #4a90e2); }
.book-card-failed { font-size: 16px; color: var(--destructive); }

/* Status badge */
.book-status-badge {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.book-status-done    { background: #e8f5e9; color: #2e7d32; }
.book-status-failed  { background: #ffebee; color: #c62828; }
.book-status-pending,
.book-status-ideating,
.book-status-sourcing,
.book-status-spinning,
.book-status-planning,
.book-status-compiling {
  background: #fff3e0; color: #e65100;
}
[data-theme="dark"] .book-status-done    { background: #1b5e20; color: #a5d6a7; }
[data-theme="dark"] .book-status-failed  { background: #b71c1c; color: #ef9a9a; }
[data-theme="dark"] .book-status-pending,
[data-theme="dark"] .book-status-ideating,
[data-theme="dark"] .book-status-sourcing,
[data-theme="dark"] .book-status-spinning,
[data-theme="dark"] .book-status-planning,
[data-theme="dark"] .book-status-compiling {
  background: #e65100; color: #ffe0b2;
}

/* Create form */
.book-create-form { max-width: 560px; display: flex; flex-direction: column; gap: 10px; }
.book-form-label   { font-weight: 600; font-size: 16px; }
.book-form-input,
.book-form-select  {
  padding: 8px 12px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: var(--radius-card, 8px);
  background: var(--surface, #fff);
  color: var(--text, #111);
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;
}
.book-form-error { color: var(--destructive); font-size: 16px; }
.book-form-error.book-form-info {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
/* U-03a C17: self-harm support copy shown on the page as info (Cowriter,
   Journey create) when the native alert cannot hold a read-aloud button. */
.kid-support-status {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  font-size: 16px;
}
.book-back-btn { padding: 4px 0; font-size: 16px; color: var(--accent, #4a90e2); }

/* Generation progress */
.book-gen-progress { max-width: 560px; }
.book-gen-title    { margin-bottom: 8px; font-size: 18px; }
.book-gen-stage    { font-size: 16px; color: var(--text-muted, #888); margin-bottom: 8px; }
.book-gen-bar      { height: 8px; background: var(--border, #e0e0e0); border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.book-gen-bar-fill { height: 100%; background: var(--accent, #4a90e2); border-radius: 4px; transition: width 0.4s ease; }
.book-gen-pages    { list-style: none; padding: 0; margin: 0; font-size: 16px; color: var(--text-muted, #888); }
.book-gen-pages li::before { content: '✓ '; color: #4caf50; }

/* Reader */
.book-reader { display: flex; flex-direction: column; gap: 0; }
.book-reader-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg, #f5f5f5);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border, #e0e0e0);
  margin-bottom: 16px;
}
.book-reader-title  { margin: 4px 0 8px; font-size: 20px; }
.book-progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.book-progress-bar  { flex: 1; height: 6px; background: var(--border, #e0e0e0); border-radius: 3px; overflow: hidden; }
.book-progress-fill { height: 100%; background: var(--accent, #4a90e2); border-radius: 3px; transition: width 0.3s; }
.book-page-counter  { font-size: 16px; color: var(--text-muted, #888); white-space: nowrap; }

.book-page-content  { min-height: 300px; padding: 0 0 24px; }
.book-reader-nav    { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border, #e0e0e0); }

/* Block base */
.book-block { margin-bottom: 20px; }

/* TextBlock */
.book-block-text p   { line-height: 1.7; margin: 0 0 14px; }
.book-block-text ul  { padding-left: 20px; }
.book-block-text li  { margin-bottom: 6px; line-height: 1.6; }

/* SectionBlock */
.book-block-section.book-section-h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent, #4a90e2);
}
.book-block-section.book-section-h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 20px 0 10px;
}

/* CalloutBlock */
.book-block-callout {
  border-left: 4px solid var(--accent, #4a90e2);
  background: var(--surface, #f9f9f9);
  border-radius: 0 var(--radius-card, 8px) var(--radius-card, 8px) 0;
  padding: 12px 16px;
}
.book-callout-note    { border-left-color: #2196f3; background: #e3f2fd; }
.book-callout-warning { border-left-color: #ff9800; background: #fff3e0; }
.book-callout-tip     { border-left-color: #4caf50; background: #e8f5e9; }
.book-callout-example { border-left-color: #9c27b0; background: #f3e5f5; }
[data-theme="dark"] .book-callout-note    { background: #1a3a5c; }
[data-theme="dark"] .book-callout-warning { background: #3e2000; }
[data-theme="dark"] .book-callout-tip     { background: #1b3a1f; }
[data-theme="dark"] .book-callout-example { background: #2d1540; }
.book-callout-header  { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.book-callout-icon    { font-size: 16px; }
.book-callout-title   { font-weight: 700; font-size: 16px; }
.book-callout-body p  { margin: 0; line-height: 1.6; }

/* CodeBlock */
.book-block-code {
  position: relative;
  background: var(--code-bg, #1e1e1e);
  border-radius: var(--radius-card, 8px);
  overflow: hidden;
}
/* Phase 53 A11Y exception — language tag (e.g. "python", "js")
   is decorative chrome on a code block. Adult-operator surface
   inside grade-10+ textbook content (kid-1 hidden). The 11px
   metric sits flush against the 14px monospace body; bumping
   creates oversized chrome. See
   .planning/phases/53-a11y-typography-v2-5/53-CONTEXT.md <edge_cases>. */
.book-code-lang {
  background: rgba(255,255,255,0.1);
  color: #ccc;
  font-size: 11px;
  padding: 4px 10px;
  font-family: monospace;
}
.book-block-code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
}
.book-block-code code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 16px;
  color: var(--code-text, #d4d4d4);
  white-space: pre;
}
/* Phase 53 A11Y exception — copy-to-clipboard button is decorative
   code-block chrome inside `.book-block-code`, a grade-10+ textbook
   surface kid-1 never sees (mode-pill curation hides it). The 12px
   chrome metric sits flush against the 14px monospace `<code>` body;
   bumping to 16px breaks the visual hierarchy. See
   .planning/phases/53-a11y-typography-v2-5/53-CONTEXT.md <edge_cases>. */
.book-code-copy {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #ccc;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.book-code-copy:hover { background: rgba(255,255,255,0.25); }

/* QuizBlock */
.book-block-quiz {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: var(--radius-card, 8px);
  padding: 16px;
}
.book-quiz-question { font-weight: 600; margin-bottom: 12px; line-height: 1.5; }
.book-quiz-choices  { display: flex; flex-direction: column; gap: 8px; }
.book-quiz-choice   {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.book-quiz-choice:hover { background: var(--hover-bg, #f0f4ff); }
.book-quiz-choice input[type=radio] { margin: 0; }
.book-quiz-choice-text  { font-size: 16px; }
.book-quiz-choice-correct { border-color: #4caf50; background: #e8f5e9; }
.book-quiz-choice-wrong   { border-color: #f44336; background: #ffebee; }
.book-quiz-feedback {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 16px;
}
.book-quiz-correct   { background: #e8f5e9; color: #2e7d32; border: 1px solid #4caf50; }
.book-quiz-incorrect { background: #ffebee; color: #c62828; border: 1px solid #f44336; }

/* PlaceholderBlock */
.book-block-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface, #fafafa);
  border: 1px dashed var(--border, #e0e0e0);
  border-radius: var(--radius-card, 8px);
  color: var(--text-muted, #888);
  font-size: 16px;
}
.book-placeholder-spinner { font-size: 20px; }

/* Recompile notice */
.book-recompile-notice {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 16px;
  color: #795548;
  margin-bottom: 12px;
}
[data-theme="dark"] .book-recompile-notice { background: #3e2c00; border-color: #8d6e00; color: #ffcc80; }

/* Math */
.book-math-display { display: block; text-align: center; margin: 16px 0; overflow-x: auto; }
.book-math-inline  { display: inline; }

/* Loading state */
.book-loading { padding: 24px; color: var(--text-muted, #888); }
.book-empty-msg { color: var(--text-muted, #888); font-style: italic; }

/* Mobile responsive */
@media (max-width: 600px) {
  .book-list-header  { flex-direction: column; align-items: flex-start; gap: 8px; }
  .book-reader-nav   { flex-direction: column; gap: 8px; }
  .book-reader-nav button { width: 100%; }
  /* Phase 53 A11Y exception — monospace metrics (12px monospace
     renders larger than 12px Comic Neue due to glyph width).
     Bumping to 16px is a Phase 58 UX-RENDER-FIX-01 concern, not
     Phase 53 typography sweep scope. `.book-block-code` is inside
     grade-10+ textbook content (kid-1 hidden via mode curation).
     See .planning/phases/53-a11y-typography-v2-5/53-CONTEXT.md
     <edge_cases>. */
  .book-block-code pre { font-size: 12px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Phase 24 — Notebooks UI
   ══════════════════════════════════════════════════════════════════════════ */

.nb-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.nb-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
}

.nb-search-wrap {
  display: flex;
  gap: 8px;
}

.nb-search-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--card);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  transition: border-color 0.15s;
}
.nb-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.nb-search-btn {
  padding: 10px 18px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.nb-search-btn:hover { background: var(--primary-light); }

/* Tag filter chips */
.nb-tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  min-height: 0;
}

.nb-tag-chip {
  padding: 5px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  color: var(--muted-fg);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.nb-tag-chip:hover { border-color: var(--primary); color: var(--primary); }
.nb-tag-chip--active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* Notebook list */
.nb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nb-empty {
  color: var(--muted-fg);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

/* Notebook card */
.nb-card {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
  overflow: hidden;
  transition: box-shadow 0.15s;
  position: relative;
}
.nb-card:hover { box-shadow: var(--shadow-clay-hover); }

.nb-card-accent {
  width: 6px;
  flex-shrink: 0;
  border-radius: var(--radius-card) 0 0 var(--radius-card);
}

.nb-card-body {
  flex: 1;
  padding: 14px 12px;
  min-width: 0;
}

.nb-card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.nb-source-badge {
  font-size: 16px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nb-card-date {
  font-size: 16px;
  color: var(--muted-fg);
}

.nb-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.nb-card-tag {
  font-size: 16px;
  padding: 2px 8px;
  background: var(--muted);
  color: var(--muted-fg);
  border-radius: 10px;
}

.nb-card-del {
  align-self: center;
  margin-right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted-fg);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.nb-card-del:hover {
  background: var(--destructive);
  color: #fff;
}

/* Delete confirmation modal */
.nb-confirm-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100%);
  background: var(--card);
  border-top: 3px solid var(--destructive);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  padding: 20px 24px;
  z-index: 100;
  animation: nb-slide-up 0.2s var(--ease-spring);
}

@keyframes nb-slide-up {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

.nb-confirm-msg {
  font-size: 16px;
  color: var(--fg);
  margin-bottom: 16px;
}

.nb-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.nb-confirm-delete {
  padding: 9px 22px;
  background: var(--destructive);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.nb-confirm-delete:hover { opacity: 0.88; }

.nb-confirm-cancel {
  padding: 9px 22px;
  background: var(--muted);
  color: var(--muted-fg);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
}
.nb-confirm-cancel:hover { background: var(--border); }

/* Dark theme overrides */
[data-theme="dark"] .nb-card { background: #1e2535; }
[data-theme="dark"] .nb-search-input { background: #1e2535; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .nb-tag-chip { background: #1e2535; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .nb-confirm-modal { background: #1e2535; }

/* ══════════════════════════════════════════════════════════════════════════
   Phase 24 — Question Bank UI
   ══════════════════════════════════════════════════════════════════════════ */

.qb-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.qb-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
}

.qb-teacher-row,
.qb-mode-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.qb-btn-create, .qb-btn-assign {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.qb-btn-create  { background: var(--primary); color: var(--on-primary); }
.qb-btn-assign  { background: var(--cta);     color: var(--on-cta); }
.qb-btn-create:hover, .qb-btn-assign:hover { opacity: 0.88; }

/* Filter bar */
.qb-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--muted);
  border-radius: var(--radius-card);
}

.qb-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qb-filter-label {
  font-size: 16px;
  color: var(--muted-fg);
  font-weight: 600;
}

.qb-filter-select {
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--card);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
}
.qb-filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.qb-bm-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--muted-fg);
  cursor: pointer;
}

.qb-bm-check { cursor: pointer; }

/* Question list */
.qb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qb-empty {
  color: var(--muted-fg);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

/* Question card */
.qb-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
  padding: 10px 14px;
  transition: box-shadow 0.15s;
}
.qb-card:hover { box-shadow: var(--shadow-clay-hover); }

.qb-card-check { flex-shrink: 0; cursor: pointer; width: 18px; height: 18px; }

.qb-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0;
  min-width: 0;
}

.qb-card-subject {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.qb-card-kind {
  font-size: 16px;
  color: var(--muted-fg);
  margin-left: 8px;
}

.qb-card-kc {
  font-size: 16px;
  color: var(--muted-fg);
  margin-left: 8px;
  font-style: italic;
}

.qb-card-preview {
  font-size: 16px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.qb-bm-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted-fg);
  transition: color 0.15s, transform 0.15s var(--ease-spring);
  padding: 4px;
  border-radius: 50%;
}
.qb-bm-btn:hover { color: var(--secondary); transform: scale(1.15); }
.qb-bm-btn--active { color: var(--secondary); }

/* Modal shared styles */
.qb-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 95vw);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius-outer);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  padding: 24px 20px 20px;
  z-index: 200;
  animation: qb-pop-in 0.2s var(--ease-spring);
}

@keyframes qb-pop-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.qb-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted-fg);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background 0.15s;
}
.qb-modal-close:hover { background: var(--muted); }

.qb-modal-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 16px;
  padding-right: 32px;
}

.qb-detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 16px;
}
.qb-detail-label { font-weight: 700; color: var(--muted-fg); min-width: 60px; }
.qb-detail-value { color: var(--fg); }

.qb-detail-question {
  font-size: 16px;
  color: var(--fg);
  line-height: 1.5;
  margin: 14px 0;
  padding: 12px;
  background: var(--muted);
  border-radius: var(--radius-sm);
}

.qb-detail-hint-title { font-weight: 700; font-size: 16px; color: var(--muted-fg); margin-bottom: 6px; }
.qb-detail-hint {
  font-size: 16px;
  color: var(--fg);
  padding: 6px 10px;
  background: var(--muted);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.qb-mention-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--muted);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.qb-mention-label { font-size: 16px; color: var(--muted-fg); }
.qb-mention-code  { font-size: 16px; font-family: monospace; color: var(--primary); background: var(--card); padding: 2px 8px; border-radius: 6px; }
.qb-mention-copy  { padding: 4px 12px; background: var(--primary); color: var(--on-primary); border: none; border-radius: var(--radius-btn); font-size: 16px; cursor: pointer; }
.qb-mention-copy:hover { opacity: 0.88; }

/* Form fields shared */
.qb-field-wrap  { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.qb-field-label { font-size: 16px; font-weight: 600; color: var(--muted-fg); }
.qb-field-input, .qb-field-textarea {
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--card);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.qb-field-input:focus, .qb-field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}
.qb-field-textarea { resize: vertical; }

.qb-create-err { color: var(--destructive); font-size: 16px; margin-bottom: 8px; }

.qb-btn-create-submit {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.qb-btn-create-submit:hover { opacity: 0.88; }
.qb-btn-create-submit:disabled { opacity: 0.55; cursor: not-allowed; }

/* Dark theme */
[data-theme="dark"] .qb-card      { background: #1e2535; }
[data-theme="dark"] .qb-filter-bar { background: #263045; }
[data-theme="dark"] .qb-filter-select { background: #1e2535; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .qb-modal     { background: #1e2535; }
[data-theme="dark"] .qb-field-input,
[data-theme="dark"] .qb-field-textarea { background: #263045; border-color: #334155; color: #e2e8f0; }

/* Mobile */
@media (max-width: 600px) {
  .qb-filter-bar { flex-direction: column; align-items: flex-start; }
  .nb-confirm-modal { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Phase 24 — @q: mention preview chips (shown in answer input area)
   ══════════════════════════════════════════════════════════════════════════ */

.at-mention-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.at-mention-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 12px;
  font-size: 16px;
  font-family: monospace;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-clay-sm);
}

[data-theme="dark"] .at-mention-chip { background: var(--primary-light); }

/* Source-color tokens: /tokens.css */

/* ── Settings modal — Phase 29 / CHAN-01 ──────────────────────────────────── */

/* Keep the gear in its own row so its hit area never covers a mode tab. */
.settings-toggle {
  position: relative;
  display: block;
  margin: 0 0 8px auto;
  width: 48px;  /* PR-1: touch target floor per DESIGN-SPEC §5.3 */
  z-index: 100;
  background: var(--card, var(--bg));
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  min-width: 48px;   /* PR-1: touch target floor */
  min-height: 48px;  /* PR-1: touch target floor */
  font-family: var(--font-body);
  font-size: 17px;  /* PR-1: body baseline */
  cursor: pointer;
  box-shadow: var(--shadow-clay-sm, none);
}
.settings-toggle:hover { background: var(--muted); }

/* Modal overlay — full-screen semi-transparent backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

/* Modal dialog — centered card */
.modal-dialog {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

/* X close button — top-right of dialog */
/* PR-1: 48px touch target floor per DESIGN-SPEC §5.3 */
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  color: var(--fg);
  border: none;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  min-width: 48px;   /* PR-1: touch target floor */
  min-height: 48px;  /* PR-1: touch target floor */
}
.modal-close:hover { background: var(--muted); border-radius: 4px; }

/* Link code monospace display */
.link-code-mono {
  display: inline-block;
  font-family: monospace;
  font-size: 28px;
  letter-spacing: 4px;
  padding: 8px 12px;
  margin: 8px 0;
  background: var(--muted);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  user-select: all;
}

/* Platform instruction list */
.platform-instructions {
  list-style: none;
  padding-left: 0;
  margin-top: 12px;
}
.platform-instructions li { margin-bottom: 8px; }

/* Helper / caption text */
.settings-help {
  color: var(--muted-fg, var(--fg));
  font-size: 1em;
  display: block;
  margin-top: 4px;
}

/* Error message inside modal */
.settings-error {
  color: var(--destructive);  /* kid shell: amber-ink; adult shells: red */
  font-size: 1em;
  margin: 6px 0;
  min-height: 1em;
}

/* Settings section spacing */
.settings-section { margin-top: 16px; }
.settings-section h3 { margin-bottom: 8px; }

/* ── Responsive: mobile full-screen modal ─────────────────────── */
@media (max-width: 600px) {
  .modal-dialog {
    max-width: none;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .modal-overlay { align-items: stretch; }
}

/* ── Theme: dark ─────────────────────────────────────────────── */
[data-theme="dark"] .modal-dialog {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}

/* Bug-#17 (BETA-RENDER-02): in-app chrome (mode-nav, theme toggle,
   settings gear, bot-switcher) must NOT show on the login screen.
   They're gated behind body.logged-in, which app.js manages in three
   places: rehydrateIdentity, goToChoosePath (success), switchStudent.
   Pre-login the user only sees the centered login card. */
body:not(.logged-in) .mode-nav,
body:not(.logged-in) #settings-toggle,
body:not(.logged-in) #theme-toggle,
body:not(.logged-in) #bot-switcher,
body:not(.logged-in) #connection-banner {
  display: none !important;
}

body:not(.logged-in) #nav-back,
body[data-active-screen="screen-login"] #nav-back {
  display: none !important;
}

/* ── Theme: high-contrast ────────────────────────────────────── */
[data-theme="hc"] .modal-dialog {
  border-width: 2px;
}

/* ── OATutor figures (Bug-#10) ─────────────────────────────────
   Inline images injected into stepBody / hint text via the
   ##figureN.gif## → <img> placeholder rewrite in main.py.
   Keeps captures readable on mobile without overflowing the
   question card. */
.problem-figure {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px auto;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}
[data-theme="dark"] .problem-figure {
  background: #ffffff;
}

/* BETA-MONITOR-04 — Beta feedback footer (Phase 46) */
.beta-footer {
  font-size: 1rem;
  text-align: center;
  padding: 0.75rem 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted-fg);
  background: var(--bg);
}

.beta-footer a {
  color: var(--primary);
  text-decoration: underline;
}

.beta-footer a:hover,
.beta-footer a:focus {
  text-decoration: none;
}

/* CC BY 4.0 problem credit (web/app.js renderProblemCredit). Quiet by
   colour + placement, not size: 16px holds the Gate 8 font floor and
   --muted-fg clears 4.5:1 on --card in every theme. */
.problem-credit {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted-fg);
  overflow-wrap: anywhere; /* long plain-text source URLs */
}

.problem-credit a {
  color: var(--muted-fg);
  text-decoration: underline;
}

.problem-credit a:hover,
.problem-credit a:focus-visible {
  color: var(--primary);
}

/* ──────────────────────────────────────────────────────────────────
   Plan 49-07 (STAB-FIX-06) — Topic-search empty-state diagnostic.
   Council Gate 4 Q2 = B (diagnostic empty-state); side question
   convergence (friendly UI + structured operator log). NEVER silent
   blank screen for Bug #8 (calculus invisibility). XSS-safe — CSS
   targets DOM nodes built via createElement + textContent only.
   ────────────────────────────────────────────────────────────────── */
.empty-state {
  padding: 1.25rem 1rem;
  margin: 1rem 0;
  border: 1px dashed var(--border, #ccc);
  border-radius: 0.75rem;
  background: var(--bg-soft, #f7f7f9);
  color: var(--text-muted, #666);
  font-size: 1rem;
  line-height: 1.5;
}

.empty-state-headline {
  font-weight: 600;
  color: var(--fg, #222);
  margin-bottom: 0.5rem;
}

.empty-state-diagnostic {
  font-size: 1rem;
  color: var(--text-muted, #888);
  margin-bottom: 0.5rem;
  font-family: var(--mono, ui-monospace, monospace);
}

.empty-state-message {
  margin-bottom: 0.5rem;
}

.empty-state-hint {
  font-size: 1rem;
  color: var(--text-muted, #999);
  font-style: italic;
}

/* ── Animate gallery topic chips (Plan 49-08, Bug #6) ─────────────────────
 * Manim gallery cards in animate.js render `entry.topics` as a flat list of
 * <span class="animate-topic-badge"> children inside a <div class="animate-
 * gallery-topics"> wrapper. Without explicit chip styling the spans render
 * inline with zero gap and concatenate visually as
 * "derivativetrigonometrycalculus" (Bug #6 in v2.4-LIVE-BUG-TRIAGE.md).
 *
 * Mirrors the .nb-card-tags / .nb-card-tag chip pattern at app.css:2365 so
 * future readers find both surfaces with a single grep on `gap: 6px`. The
 * recurrence-class lesson: name a class in JS → add a CSS rule for that
 * class. Plan 49-08 `tests/test_tag_render_separator.py` enumerates the
 * .join() variant; runtime catch is via Student-Walk Step 10.
 * ─────────────────────────────────────────────────────────────────────── */
.animate-gallery-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.animate-topic-badge {
  font-size: 16px;
  padding: 2px 8px;
  background: var(--surface-2, #eef2ff);
  color: var(--fg, #222);
  border: 1px solid var(--border, #d1d5db);
  border-radius: 10px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════════
   Phase 50 — Layout Foundation (v2.5)

   Council 49-24 L1 UNANIMOUS ratified the body-cap + 65ch/75ch reading
   column architecture. Phase 50 productionizes the v2.4.9 hot patch
   (commit 29b5b41 — Cluster B in .planning/v2.4.9-HOTPATCH-RCA.md) into
   reusable building blocks that downstream phases (51 kid copy, 52
   microcopy + mastery bars, 53 a11y, 58 mode-iso cleanup) can layer
   content into without re-deriving the layout.

   Tokens at :root: --app-shell-max-width (default 960px) +
   --prose-measure (default 75ch). Overrides per-screen via
   `.app-shell { --app-shell-max-width: 1280px }` etc.

   Requirements: UX-LAYOUT-01 (.app-shell), UX-LAYOUT-02 (.prose +
   body padding-inline formula above).
   ══════════════════════════════════════════════════════════════════════════ */

.app-shell {
  /* Inherit the :root token; per-screen override via `.app-shell.app-shell-wide`
     (1280px) or `.app-shell.app-shell-narrow` (540px) — modifiers ship
     only when a screen needs them (YAGNI; CONTEXT <decisions> Claude's-
     discretion: ship base only). */
  max-width: var(--app-shell-max-width);
  margin-inline: auto;
  /* Inner content does NOT add outer padding — body handles outer space
     via padding-inline. Inner spacing remains the responsibility of the
     contained components. */
  padding-inline: 0;
}

.prose {
  /* Readable text column. Caps prose at 75ch so kid (9-13yo) eyes
     don't sweep across a 960px line. Mobile <375px naturally flows
     narrower since `max-width: 75ch` is a cap, not a floor. */
  max-width: var(--prose-measure);
  /* Inherit alignment from parent; do NOT auto-center prose blocks —
     downstream phases (51, 52) decide alignment per-context. */
}

/* Phase 66 FEEDBACK-01 — thumbs-down + 3-button category selector.
 * Council 66 locks: D-66-A1 placement (inline below #hint-text inside
 * #hint-area), D-66-A3 5s disable + visible disabled state, Gate 8
 * floors (font ≥16px, contrast ≥4.5:1, tap target ≥44px, visible focus
 * ring). Mobile (≤480px) stacks vertically per CONTEXT.md layout sketch.
 * PR-1: updated to 48px target + 17px font per DESIGN-SPEC §5.3. */
.feedback-prompt {
  font-size: 1rem;
  color: var(--text-muted, #555);
  margin: 0.5rem 0 0.25rem 0;
}
#feedback-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.feedback-btn {
  min-height: 48px;  /* PR-1: touch target floor */
  min-width: 88px;
  padding: 0.5rem 1rem;
  font-size: 17px;  /* PR-1: body baseline */
  cursor: pointer;
  border: 1px solid var(--button-border, #888);
  background: var(--button-bg, #fff);
  color: var(--text, #111);
  border-radius: 4px;
}
.feedback-btn:hover:not(:disabled) {
  background: var(--button-hover-bg, #f0f0f0);
}
.feedback-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.feedback-btn:focus-visible {
  outline: 3px solid var(--focus-ring, #0070f3);
  outline-offset: 2px;
}
@media (max-width: 480px) {
  #feedback-buttons { flex-direction: column; }
  .feedback-btn    { width: 100%; }
}

/* Step 3 quick check banner + "Was this helpful?" yes/no row */
.check-banner {
  margin: 0 0 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--muted, #f4f4f5);
  color: var(--text, #111);
  font-size: 1rem;
}
#btn-check-skip { margin-top: 0.5rem; }
.helpful-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.helpful-prompt {
  font-size: 1rem;
  color: var(--text, #111);
  margin: 0;
}
.helpful-btn {
  min-height: 48px;
  min-width: 72px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid var(--button-border, #888);
  background: var(--button-bg, #fff);
  color: var(--text, #111);
}
.helpful-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.helpful-btn:focus-visible {
  outline: 3px solid var(--focus-ring, #0070f3);
  outline-offset: 2px;
}

/* WCAG AA >= 4.5:1 contrast overrides */
#screen-login button {
  background: #C2410C;
  color: #FFFFFF;
}
#screen-login button:hover {
  background: #9A3412;
}
body[data-active-screen="screen-choose"] {
  --muted-foreground: #4b5563;
}

.choose-subtitle,
.drop-zone-sub,
.topic-card-detail {
  color: #334155 !important;
}
#btn-search-main,
#btn-switch-choose,
button.btn-secondary#btn-switch-choose {
  background: #1e3a8a !important;
  color: #ffffff !important;
}
#btn-search-main:hover,
#btn-switch-choose:hover {
  background: #1e40af !important;
}
#mastery-pct {
  color: #065f46 !important;
}
#btn-submit {
  background: var(--cta);
  color: var(--on-cta);
}
#btn-submit:hover {
  background: var(--cta-hover);
}
#kc-label {
  color: #1e3a8a !important;
}
#btn-topic,
#btn-topic.btn-outline,
button#btn-topic,
.btn-outline#btn-topic,
#btn-progress,
#btn-progress.btn-secondary,
button#btn-progress {
  color: #1e3a8a !important;
  border-color: #1e3a8a !important;
  background: #ffffff !important;
}
a.teacher-link,
a[href$="teacher.html"],
a[href$="kb.html"],
.top-bar a,
.top-bar button {
  color: #1e3a8a !important;
}
#drop-zone-main,
.drop-zone,
button[onclick*="homework"],
button[onclick*="upload"] {
  color: #1e3a8a !important;
  border-color: #1e3a8a !important;
}


/* UK ICO Children's Code — parent visibility notice (Phase 2 parent UI) */
.kid-parent-notice {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0 16px;
  font-size: 16px;
  color: var(--fg);
}
.kid-parent-notice-why { margin: 8px 0 0; color: var(--muted-fg); font-size: 16px; }
.kid-parent-notice .linkish,
button.linkish {
  background: none; border: none; color: var(--primary); text-decoration: underline;
  cursor: pointer; font: inherit; padding: 4px 6px; min-height: 48px;
}
.login-parent-link { margin: 12px 0; font-size: 16px; }
.login-parent-link a { color: var(--primary); }

/* The clickable boxes, including the checkbox's containing label. */
#kid-parent-notice-dismiss, .qb-bm-label {
  min-width: 48px;
  min-height: 48px;
}
.qb-bm-label { display: inline-flex; align-items: center; padding: 8px; cursor: pointer; }
.login-parent-link a, .beta-footer a {
  display: inline-flex;
  align-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 4px;
}
/* Inline anchors ignore min-height; make the Settings Credits link a real box. */
#settings-about-section a.btn-secondary {
  display: inline-flex;
  align-items: center;
}

/* Give wide equations a local scrollport; preserve all of the equation. */
.mode-container, .screen, .question-body, #hint-area, #feedback-area,
#question-text, #hint-text, #feedback-text, .journey-chat-log {
  min-width: 0;
  max-width: 100%;
}
#question-text, #hint-text, #feedback-text, .journey-chat-log {
  overflow-wrap: anywhere;
}
.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.25em;
}
.katex-display > .katex { width: max-content; min-width: 100%; }

/* Keep sizing in CSS so body[data-age-band="k2"] supplies 56px / 18px,
   including when the student persona changes after a widget is created. */
.manipulative-btn {
  min-width: var(--target-min);
  min-height: var(--target-min);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  touch-action: manipulation;
}

/* Shared nonmodal prompts on kid and parent pages, including fallback helpers. */
.inline-prompt {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 100%;
  margin-block: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: max(16px, var(--body-font-size, 1rem));
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.inline-prompt > p,
.inline-prompt > label,
.inline-prompt > input {
  flex-basis: 100%;
  min-width: 0;
  margin: 0;
}
.inline-prompt > label { font-weight: 700; }
.inline-prompt > p { white-space: pre-line; }
.inline-prompt > input,
.inline-prompt > button,
body[data-age-band] .inline-prompt > button {
  min-height: max(48px, var(--tap-target-size, 48px));
  min-width: max(48px, var(--tap-target-size, 48px));
}
.inline-prompt > input,
.inline-prompt > button {
  padding: 12px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
}
.inline-prompt > input {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
}
.inline-prompt > button {
  flex: 1 1 8rem;
  border-color: var(--blue);
  background: var(--blue);
  color: var(--on-primary);
  font-weight: 700;
  box-shadow: none;
  transform: none;
  transition: none;
  touch-action: manipulation;
}
.inline-prompt > button:hover { background: var(--blue-strong); }
.inline-prompt > button:last-child {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.inline-prompt > button:last-child:hover { background: var(--surface-2); }
.inline-prompt > :is(input, button):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
