/* GMAT Buddy 2027 — design system. Mobile first; desktop gets a side rail. */
:root {
  --navy: #1e2a5a;
  --indigo: #4338ca;
  --indigo-soft: #eef0fe;
  --amber: #d97706;
  --amber-soft: #fff7e6;
  --green: #15803d;
  --green-soft: #e9f8ef;
  --red: #c2410c;
  --red-soft: #fdeee6;
  --blue-soft: #eaf2ff;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #151a2d;
  --text-2: #4a5170;
  --text-3: #7a819c;
  --primary: var(--indigo);
  --primary-ink: #ffffff;
  --focus: #6366f1;

  --chart-1: #4338ca;
  --chart-2: #d97706;
  --chart-3: #0e9f6e;
  --chart-4: #db2777;
  --chart-5: #0284c7;
  --chart-6: #7c3aed;
  --chart-axis: #9aa1b9;
  --chart-grid: #e7e9f1;
  --chart-text: #4a5170;
  --chart-bg: #ffffff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 50, 0.05), 0 8px 24px rgba(20, 26, 50, 0.06);
  --shadow-lg: 0 20px 60px rgba(20, 26, 50, 0.16);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-read: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d1222;
    --surface: #151b30;
    --surface-2: #1c2440;
    --border: #283152;
    --text: #e8ebf7;
    --text-2: #b4bad3;
    --text-3: #858ca9;
    --primary: #818cf8;
    --primary-ink: #0d1222;
    --indigo-soft: #232b55;
    --amber-soft: #3a2a0f;
    --green-soft: #12301f;
    --red-soft: #3a1d10;
    --blue-soft: #16264a;
    --green: #4ade80;
    --red: #fb923c;
    --amber: #fbbf24;
    --chart-1: #818cf8;
    --chart-2: #fbbf24;
    --chart-3: #34d399;
    --chart-4: #f472b6;
    --chart-5: #38bdf8;
    --chart-6: #a78bfa;
    --chart-axis: #5d6688;
    --chart-grid: #232b48;
    --chart-text: #b4bad3;
    --chart-bg: #151b30;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0d1222;
  --surface: #151b30;
  --surface-2: #1c2440;
  --border: #283152;
  --text: #e8ebf7;
  --text-2: #b4bad3;
  --text-3: #858ca9;
  --primary: #818cf8;
  --primary-ink: #0d1222;
  --indigo-soft: #232b55;
  --amber-soft: #3a2a0f;
  --green-soft: #12301f;
  --red-soft: #3a1d10;
  --blue-soft: #16264a;
  --green: #4ade80;
  --red: #fb923c;
  --amber: #fbbf24;
  --chart-1: #818cf8;
  --chart-2: #fbbf24;
  --chart-3: #34d399;
  --chart-4: #f472b6;
  --chart-5: #38bdf8;
  --chart-6: #a78bfa;
  --chart-axis: #5d6688;
  --chart-grid: #232b48;
  --chart-text: #b4bad3;
  --chart-bg: #151b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; text-decoration: none; color: var(--text); }
.topbar .brand img { width: 30px; height: 30px; border-radius: 8px; }
.topbar .spacer { flex: 1; }
.topbar .title { font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

main#view {
  max-width: 760px; margin: 0 auto;
  padding: 8px 16px calc(var(--nav-h) + 32px + var(--safe-b));
  min-height: calc(100vh - var(--top-h));
}
main#view.wide { max-width: 1200px; }
main#view.immersive { padding-bottom: 120px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-3); font-size: 11.5px; font-weight: 600;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--primary); }
.bottomnav a.active svg { stroke-width: 2.2; }
body.focus-mode .bottomnav { display: none; }

@media (min-width: 960px) {
  .bottomnav {
    top: 0; bottom: 0; right: auto; width: 92px; height: auto;
    grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding-top: 72px;
    border-top: 0; border-right: 1px solid var(--border);
  }
  .topbar, main#view, .action-bar { margin-left: 92px; }
  main#view { padding-bottom: 48px; }
  body.focus-mode .topbar, body.focus-mode main#view, body.focus-mode .action-bar { margin-left: 0; }
}

/* ---------- type */
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 8px; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 650; }
p { margin: 0 0 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 14px; }
.small { font-size: 13.5px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
.section-title h2 { margin: 0; }
.section-title a, .section-title button { font-size: 14px; font-weight: 600; }

/* ---------- surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card.flat { box-shadow: none; }
.card.tint { background: var(--indigo-soft); border-color: transparent; box-shadow: none; }
.card.warn { background: var(--amber-soft); border-color: transparent; box-shadow: none; }
.card.good { background: var(--green-soft); border-color: transparent; box-shadow: none; }
.card h3 { margin-bottom: 4px; }
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1e2a5a 0%, #3730a3 60%, #4f46e5 100%);
  color: #fff; border-radius: 22px; padding: 22px 20px; margin: 8px 0 16px; box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 70%);
}
.hero .muted, .hero .faint { color: rgba(255, 255, 255, 0.78); }
.hero h1 { font-size: 24px; margin-bottom: 6px; }
.hero-stats { display: flex; gap: 22px; margin-top: 16px; flex-wrap: wrap; }
.hero-stat .n { font-size: 26px; font-weight: 750; line-height: 1; }
.hero-stat .l { font-size: 12.5px; opacity: 0.8; margin-top: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.stat .n { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.stat .l { font-size: 13px; color: var(--text-2); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 13px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 650; font-size: 15.5px;
  cursor: pointer; text-decoration: none; transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600;
}
.chip.indigo { background: var(--indigo-soft); color: var(--primary); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button.chip { border: 1px solid transparent; cursor: pointer; padding: 7px 12px; font-size: 13.5px; }
button.chip.on { background: var(--primary); color: var(--primary-ink); }

/* ---------- progress */
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width 0.4s ease; }
.bar.green > span { background: var(--green); }
.bar.amber > span { background: var(--amber); }
.ring { --p: 0; --size: 64px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); flex-shrink: 0; }
.ring > span { width: calc(var(--size) - 12px); height: calc(var(--size) - 12px); border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 750; font-size: 15px; }
.hero .ring { background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, 0.2) 0); }
.hero .ring > span { background: #2f2a8f; color: #fff; }

/* ---------- lists / plan items */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.item:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.item:active { transform: scale(0.995); }
.item .ic {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--indigo-soft); color: var(--primary);
}
.item .ic svg { width: 22px; height: 22px; }
.item .ic.amber { background: var(--amber-soft); color: var(--amber); }
.item .ic.green { background: var(--green-soft); color: var(--green); }
.item .ic.red { background: var(--red-soft); color: var(--red); }
.item .ic.blue { background: var(--blue-soft); color: var(--chart-5); }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 650; line-height: 1.3; }
.item .s { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.item .end { color: var(--text-3); font-size: 13px; text-align: right; flex-shrink: 0; }
.item.done { opacity: 0.62; }
.item.done .t { text-decoration: line-through; text-decoration-color: var(--text-3); }
.item.optional { border-style: dashed; background: transparent; }
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0;
  display: grid; place-items: center; background: transparent; cursor: pointer; padding: 0;
}
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.check svg { width: 14px; height: 14px; }

/* ---------- prose (lessons, explanations) */
.prose { font-size: 16.5px; line-height: 1.68; }
.prose.read { font-family: var(--font-read); font-size: 18px; line-height: 1.7; }
.prose.read h1, .prose.read h2, .prose.read h3 { font-family: var(--font); }
.prose h1 { font-size: 28px; margin: 4px 0 14px; }
.prose h2 { font-size: 21px; margin: 32px 0 10px; padding-top: 6px; }
.prose h3 { font-size: 18px; margin: 24px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.prose blockquote { margin: 0 0 14px; padding: 8px 14px; border-left: 3px solid var(--border); color: var(--text-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.prose strong { font-weight: 700; }
.prose a.ext::after { content: ' ↗'; font-size: 0.8em; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; }
.prose table, .data-table { border-collapse: collapse; width: 100%; font-family: var(--font); font-size: 14.5px; }
.prose th, .prose td, .data-table th, .data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
/* Lesson tables hold sentences: let them wrap instead of clipping inside the scroller. */
.prose th, .prose td { white-space: normal; min-width: 96px; vertical-align: top; }
.prose th, .data-table th { background: var(--surface-2); font-weight: 650; }
.prose tr:last-child td, .data-table tr:last-child td { border-bottom: 0; }
.data-table td { font-variant-numeric: tabular-nums; }
.sort-btn { background: none; border: 0; font-weight: 650; cursor: pointer; padding: 0; text-align: left; }
.hint { font-size: 13px; color: var(--text-3); margin: -8px 0 12px; }

.callout { border-radius: 14px; padding: 12px 16px; margin: 0 0 16px; border: 1px solid transparent; font-family: var(--font); font-size: 15.5px; line-height: 1.6; }
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 750; font-size: 12.5px; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 4px; }
.callout-tip, .callout-shortcut { background: var(--indigo-soft); }
.callout-tip .callout-title, .callout-shortcut .callout-title { color: var(--primary); }
.callout-trap { background: var(--red-soft); }
.callout-trap .callout-title { color: var(--red); }
.callout-remember { background: var(--amber-soft); }
.callout-remember .callout-title { color: var(--amber); }
.callout-note, .callout-example { background: var(--surface-2); }
.callout-note .callout-title, .callout-example .callout-title { color: var(--text-2); }

details.reveal, .prose details {
  border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin: 0 0 16px; background: var(--surface);
  font-family: var(--font); font-size: 15.5px;
}
details.reveal > summary, .prose details > summary {
  cursor: pointer; padding: 12px 0; font-weight: 650; color: var(--primary); list-style: none;
}
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::before { content: '▸ '; }
details.reveal[open] > summary::before { content: '▾ '; }
details.reveal[open] { padding-bottom: 6px; }

/* ---------- lesson page */
.lesson-head { margin: 10px 0 18px; }
.lesson-head .chips { margin-bottom: 10px; }
.lesson-progress { position: sticky; top: var(--top-h); height: 3px; z-index: 15; background: transparent; margin: 0 -16px; }
.lesson-progress span { display: block; height: 100%; background: var(--primary); width: 0; transition: width 0.1s linear; }
.toc { margin: 0 0 18px; }
.toc summary { cursor: pointer; font-weight: 650; color: var(--text-2); }
.toc ol { margin: 8px 0 0; padding-left: 20px; color: var(--text-2); font-size: 15px; }
.toc a { color: inherit; text-decoration: none; }
.lesson-end { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
textarea, input[type='text'], input[type='number'], input[type='date'], select, input[type='search'] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--text-2); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; min-height: 40px; font-weight: 650; font-size: 14px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch input { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: var(--border); border-radius: 99px; position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }
.daypick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.daypick button { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; min-height: 42px; font-weight: 650; font-size: 13px; cursor: pointer; }
.daypick button.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }

/* ---------- question player */
.player-top {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.player-top .ptitle { font-weight: 650; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-top .count { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; padding: 5px 10px; border-radius: 10px; background: var(--surface-2); cursor: pointer; border: 0; }
.timer.warn { background: var(--amber-soft); color: var(--amber); }
.timer.over { background: var(--red-soft); color: var(--red); }
.player-progress { height: 3px; background: var(--surface-2); }
.player-progress span { display: block; height: 100%; background: var(--primary); transition: width 0.3s ease; }

.question { margin: 16px 0; }
.question.split { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 960px) {
  .question.split { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .question.split .stimulus { position: sticky; top: 76px; }
  .question.split .stim-scroll { max-height: calc(100vh - 150px); }
}
.stimulus { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stim-toggle { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: var(--surface-2); font-weight: 650; font-size: 13.5px; color: var(--text-2); }
.stim-scroll { padding: 14px 16px 6px; max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.stimulus.collapsed .stim-scroll { display: none; }
.stim-title { font-size: 16px; }
.stim-body { font-family: var(--font-read); font-size: 17px; line-height: 1.7; }
.stim-intro { font-size: 15px; color: var(--text-2); }
.chart-fig { margin: 0 0 12px; }
.chart { display: block; width: 100%; height: auto; }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; overflow-x: auto; }
.tab { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 12px; font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--primary); color: var(--primary-ink); border-color: transparent; }

.q-main { min-width: 0; }
.q-meta { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.prompt { margin-bottom: 14px; font-size: 17px; }
.prompt p:last-child { margin-bottom: 0; }
.ds-statements { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.ds-stmt { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 550; }
.ds-dir { margin-bottom: 12px; font-size: 14px; color: var(--text-2); }
.ds-dir summary { cursor: pointer; font-weight: 600; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; padding: 13px 14px;
  border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: 16px; line-height: 1.45; transition: border-color 0.12s ease, background 0.12s ease;
}
.choice:hover:not([disabled]) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.choice .letter {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  border: 1.5px solid var(--border); font-weight: 700; font-size: 13.5px; color: var(--text-2);
}
.choice.selected { border-color: var(--primary); background: var(--indigo-soft); }
.choice.selected .letter { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.choice.correct { border-color: var(--green); background: var(--green-soft); }
.choice.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.choice.wrong { border-color: var(--red); background: var(--red-soft); }
.choice.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.choice[disabled] { cursor: default; }
.choice-text p { margin: 0; }
.yn-table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
.yn-table th { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 8px 6px; text-align: center; background: var(--surface-2); }
.yn-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.yn-table td.yn-text { padding-left: 10px; white-space: normal; min-width: 180px; }
.yn-table .yn-cell { text-align: center; width: 64px; }
.yn-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; padding: 0; }
.yn-btn .dot { width: 12px; height: 12px; border-radius: 50%; background: transparent; }
.yn-btn.selected { border-color: var(--primary); }
.yn-btn.selected .dot { background: var(--primary); }
.yn-cell.correct { background: var(--green-soft); }
.yn-cell.wrong { background: var(--red-soft); }
.dd-select { display: inline-block; width: auto; min-width: 120px; max-width: 100%; min-height: 40px; padding: 6px 10px; margin: 2px 4px; font-weight: 600; vertical-align: middle; }
.dd-select.correct { border-color: var(--green); background: var(--green-soft); }
.dd-select.wrong { border-color: var(--red); background: var(--red-soft); }
.dd-correct { font-size: 13px; color: var(--green); font-weight: 650; margin-right: 6px; }

.explanation { margin-top: 18px; animation: rise 0.25s ease; }
.verdict { font-weight: 750; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.verdict.right { background: var(--green-soft); color: var(--green); }
.verdict.wrong { background: var(--red-soft); color: var(--red); }
.verdict.skipped { background: var(--amber-soft); color: var(--amber); }
.reason-pick { margin: 14px 0; }
.reason-pick .chips { margin-top: 8px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 26;
  padding: 12px 16px calc(12px + var(--safe-b)); display: flex; gap: 10px; align-items: center;
  background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.action-bar .btn { flex: 1; }
.action-bar .btn.icon-only { flex: 0 0 52px; padding: 0; }
.action-bar .btn.bookmarked { color: var(--amber); border-color: var(--amber); }

.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.review-grid button { min-height: 52px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; position: relative; }
.review-grid button.bm { border-color: var(--amber); }
.review-grid button.bm::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.review-grid button.edited { background: var(--indigo-soft); }
.review-grid button.right { background: var(--green-soft); border-color: var(--green); }
.review-grid button.wrongq { background: var(--red-soft); border-color: var(--red); }

/* ---------- flashcards */
.flash {
  perspective: 1200px; margin: 16px 0; min-height: 280px; cursor: pointer; user-select: none;
}
.flash-inner { position: relative; min-height: 280px; transition: transform 0.45s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
  padding: 26px 22px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 19px; line-height: 1.5;
}
.flash-face.back { transform: rotateY(180deg); background: var(--indigo-soft); font-size: 17px; }
.flash-face .deck { position: absolute; top: 14px; left: 18px; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade-row .btn { flex-direction: column; gap: 0; min-height: 56px; font-size: 14px; }
.grade-row .btn small { font-weight: 500; color: var(--text-3); font-size: 12px; }

/* ---------- calendar / heat map */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); display: block; }
.heat i.l1 { background: color-mix(in srgb, var(--primary) 30%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--primary) 55%, var(--surface-2)); }
.heat i.l3 { background: color-mix(in srgb, var(--primary) 80%, var(--surface-2)); }
.heat i.l4 { background: var(--primary); }
.heat i.today { outline: 2px solid var(--amber); outline-offset: 1px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0 4px; }
.week .d { text-align: center; padding: 8px 0; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-3); cursor: pointer; }
.week .d b { display: block; font-size: 16px; color: var(--text); margin-top: 2px; }
.week .d.sel { background: var(--primary); border-color: transparent; color: rgba(255,255,255,.8); }
.week .d.sel b { color: #fff; }
.week .d.rest { opacity: 0.55; }
.week .d .dots { height: 6px; display: flex; justify-content: center; gap: 2px; margin-top: 3px; }
.week .d .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); display: block; }
.week .d.sel .dots i { background: #fff; }
.week .d.complete .dots i { background: var(--green); }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl { position: relative; margin-bottom: 16px; }
.tl::before { content: ''; position: absolute; left: -20px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); }
.tl.now::before { border-color: var(--primary); background: var(--primary); box-shadow: 0 0 0 4px var(--indigo-soft); }
.tl.past::before { background: var(--green); border-color: var(--green); }
.tl .when { font-size: 12.5px; color: var(--text-3); font-weight: 650; }

/* ---------- modal sheet, toast, empty */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 30, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); box-shadow: var(--shadow-lg); animation: up .25s cubic-bezier(.2,.7,.2,1); }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: -6px auto 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + var(--safe-b)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast { background: #151a2d; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 550; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: all .25s ease; }
.toast.show { opacity: 1; transform: none; }
.toast-good { background: #15803d; }
.toast-warn { background: #b45309; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty svg { width: 48px; height: 48px; color: var(--text-3); margin-bottom: 8px; }
.loading { display: grid; place-items: center; min-height: 40vh; color: var(--text-3); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 12px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.badge .medal { width: 40px; height: 40px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); }
.badge.locked { opacity: 0.4; filter: grayscale(1); }
.kbd { font-family: ui-monospace, monospace; font-size: 12px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .bottomnav, .topbar, .action-bar { display: none; } main#view { padding: 0; margin: 0; } }

.item .move-btn { width: 36px; height: 36px; color: var(--text-3); flex-shrink: 0; }
.item .move-btn svg { width: 19px; height: 19px; }
.daypace { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.daypace .lbl { font-size: 13.5px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.daypace .seg { flex: 1; }
.daypace .seg button { min-height: 36px; font-size: 13px; }

/* ---- secondary views ---- */
.switch input[type='checkbox'] { margin: 0; }
.flash-face .prose p { margin: 0 0 8px; }
.flash-face .prose p:last-child { margin: 0; }
select { appearance: auto; }
@media print {
  #topbar, #nav, .seg, #print-btn, .toasts { display: none !important; }
  details.reveal { break-inside: avoid; box-shadow: none; border: 0; }
}

/* ---------- diagrams & figures */
figure.diagram { margin: 6px 0 20px; padding: 14px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; text-align: center; }
figure.diagram svg { max-width: 100%; height: auto; }
.diagram-loading { color: var(--text-3); font-size: 14px; padding: 20px; font-family: var(--font); }
.diagram-fallback { text-align: left; font-size: 13px; white-space: pre-wrap; color: var(--text-2); margin: 0; }
.prose img, figure.visual img { width: 100%; height: auto; border-radius: 14px; display: block; border: 1px solid var(--border); }
figure.visual { margin: 6px 0 20px; }
figure.visual figcaption { font-size: 13px; color: var(--text-3); margin-top: 6px; text-align: center; font-family: var(--font); }
.cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 18px; display: block; margin: 6px 0 14px; background: var(--surface-2); }
.cover.slim { aspect-ratio: 21 / 8; }

/* compact hero on phones */
.hero h1 { font-size: clamp(19px, 5.2vw, 24px); }
@media (max-width: 520px) {
  .hero { padding: 18px 18px; border-radius: 20px; }
  .hero-stats { gap: 18px; margin-top: 12px; }
  .hero-stat .n { font-size: 21px; }
  .hero .ring { --size: 58px !important; }
}

/* Screens with their own action bar (lessons, players, setup) hide the tab bar; the top back arrow exits. */
body:has(.action-bar) .bottomnav { display: none; }
body:has(.action-bar) main#view { padding-bottom: calc(96px + var(--safe-b)); }
body:has(.action-bar) #toasts { bottom: calc(90px + var(--safe-b)); }
@media (min-width: 960px) {
  body:has(.action-bar) .topbar, body:has(.action-bar) main#view, body:has(.action-bar) .action-bar { margin-left: 0; }
  .action-bar { justify-content: center; }
  .action-bar .btn { max-width: 340px; }
}

.up-next { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--border); }
@media (max-width: 600px) {
  .prose table th, .prose table td { white-space: normal; min-width: 90px; }
  .data-table th, .data-table td { padding: 7px 9px; font-size: 13.5px; }
}

.ds-stmt { font-weight: 500; }
@media (max-width: 600px) {
  .choice { padding: 11px 12px; font-size: 15px; gap: 10px; }
  .choice .letter { width: 26px; height: 26px; font-size: 13px; }
  .question.single .choices.ds, .choices[data-ds] .choice { font-size: 14px; }
  .prompt { font-size: 16px; }
  .q-meta { margin-bottom: 6px; }
}

figure.diagram { cursor: zoom-in; }
figure.diagram.wide { text-align: left; }
.diagram-hint { font-size: 12px; color: var(--text-3); margin: -4px 0 8px; font-family: var(--font); position: sticky; left: 0; }
.diagram-overlay { position: fixed; inset: 0; z-index: 70; background: var(--bg); overflow: auto; -webkit-overflow-scrolling: touch; animation: fade .2s ease; }
.diagram-full { padding: 60px 16px 40px; }
.diagram-close { position: fixed; top: 10px; right: 10px; z-index: 71; background: var(--surface); border: 1px solid var(--border); font-size: 18px; }

/* ===================== DESKTOP LAYOUT (≥ 1100px) ===================== */
.layout { display: block; }
.side-col > * + * { margin-top: 0; }
.nav-brand { display: none; }
@media (min-width: 1100px) {
  :root { --rail: 236px; }
  .bottomnav {
    width: var(--rail); grid-auto-rows: 48px; padding: 18px 14px; gap: 4px; align-content: start;
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 750; font-size: 17px; color: var(--text); text-decoration: none; }
  .nav-brand img { width: 32px; height: 32px; border-radius: 9px; }
  .bottomnav a:not(.nav-brand) { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 12px; font-size: 15px; font-weight: 600; }
  .bottomnav a:not(.nav-brand):hover { background: var(--surface-2); }
  .bottomnav a.active { background: var(--indigo-soft); }
  .bottomnav a svg { width: 21px; height: 21px; }
  .topbar, main#view, .action-bar { margin-left: var(--rail); }
  .topbar .brand { display: none; }
  main#view { max-width: none; padding: 12px 40px 56px; }
  main#view > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
  main#view.reading > * { max-width: 1080px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
  .layout.even { grid-template-columns: 1fr 1fr; }
  .side-col { position: sticky; top: calc(var(--top-h) + 12px); }
  .grid2.tiles { grid-template-columns: repeat(4, 1fr); }
  .lesson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .lesson-grid .item { height: 100%; }
  .cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .cards-grid > .card, .cards-grid > details { margin: 0; }
  .hero { padding: 28px 30px; }
  .hero h1 { font-size: 28px; }
  h1 { font-size: 30px; }
  .lesson-layout { display: grid; grid-template-columns: minmax(0, 760px) 260px; gap: 40px; justify-content: center; }
  .lesson-toc { position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - 120px); overflow-y: auto; }
  .lesson-toc ol { list-style: none; padding: 0; margin: 8px 0 0; }
  .lesson-toc li button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; cursor: pointer; line-height: 1.35; }
  .lesson-toc li button:hover { background: var(--surface-2); }
  .lesson-toc li.on button { background: var(--indigo-soft); color: var(--primary); font-weight: 650; }
  .lesson-toc li.done button { color: var(--text-3); }
  body:has(.action-bar) .topbar, body:has(.action-bar) main#view { margin-left: var(--rail); }
  body:has(.action-bar) .bottomnav { display: grid; }
  body:has(.action-bar) .action-bar { margin-left: var(--rail); }
  body.focus-mode .bottomnav { display: none; }
  body.focus-mode .topbar, body.focus-mode main#view, body.focus-mode .action-bar { margin-left: 0; }
}
@media (max-width: 1099px) { .lesson-toc { display: none; } .side-only { display: none; } }
@media (min-width: 1100px) { .mobile-only { display: none !important; } }
@media (min-width: 1100px) {
  .bottomnav a.nav-brand { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 17px; font-weight: 750; color: var(--text); padding: 4px 10px 22px; height: auto; }
  .topbar:has(> .brand) { display: none; }
  main#view { padding-top: 28px; }
}

.card > .cover:first-child { margin: -4px 0 14px; }
/* desktop dashboard pieces */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 26px 28px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.tint { background: var(--indigo-soft); border-color: transparent; }
.panel.good { background: var(--green-soft); border-color: transparent; }
.next-panel { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.next-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.next-title { font-size: 26px; margin: 6px 0 0; }
ol.outline { margin: 0 0 18px; padding-left: 20px; color: var(--text-2); columns: 2; column-gap: 28px; font-size: 14.5px; }
ol.outline li { margin: 3px 0; break-inside: avoid; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 18px; }
.dash-stats { display: flex; align-items: center; gap: 22px; }
.dstat { text-align: right; }
.dstat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.dstat span { font-size: 12.5px; color: var(--text-3); }
.phase-track { display: flex; gap: 4px; margin: 0 0 22px; }
.phase-seg { height: 30px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: center; padding: 0 10px; min-width: 0; font-size: 12px; font-weight: 650; color: var(--text-3); overflow: hidden; }
.phase-seg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-seg.past { background: color-mix(in srgb, var(--green) 25%, var(--surface-2)); color: var(--text-2); }
.phase-seg.now { background: var(--primary); color: var(--primary-ink); }
.phase-seg.test { background: var(--amber-soft); color: var(--amber); }
.pace-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.pace-row .daypace { flex: 1; margin: 0; }
.list.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.learn-desk { display: grid; grid-template-columns: 210px minmax(300px, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
.unit-nav, .lesson-col, .detail-col { position: sticky; top: 28px; }
.lesson-col { max-height: calc(100vh - 56px); overflow-y: auto; padding-right: 4px; }
.unit-btn { display: flex; justify-content: space-between; width: 100%; border: 0; background: transparent; padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 14.5px; cursor: pointer; color: var(--text-2); text-align: left; }
.unit-btn:hover { background: var(--surface-2); }
.unit-btn.on { background: var(--indigo-soft); color: var(--primary); }
.compact-list { gap: 6px; }
.compact-list .item { padding: 10px 12px; gap: 12px; }
.compact-list .item .t { font-size: 14.5px; font-weight: 600; }
.item.picked { border-color: var(--primary); background: var(--indigo-soft); }
.detail-col .panel { padding: 22px 24px; }
@media (min-width: 1100px) {
  .lesson-layout { display: grid; grid-template-columns: minmax(0, 760px) 290px; gap: 40px; justify-content: center; align-items: start; }
  .lesson-main { min-width: 0; }
  .lesson-toc { display: block; position: sticky; top: calc(var(--top-h) + 16px); }
  .lesson-toc .panel { margin-bottom: 14px; }
  body:has(.lesson-layout) .action-bar { justify-content: center; padding-right: 330px; }
}
.action-bar.inline-bar { position: static; margin: 28px 0 0 !important; padding: 18px 0 0; background: none; border-top: 1px solid var(--border); backdrop-filter: none; -webkit-backdrop-filter: none; justify-content: flex-end; }
.action-bar.inline-bar .btn { flex: 0 0 auto; min-width: 140px; }
body:has(.inline-bar) main#view { padding-bottom: 56px; }
@media (min-width: 1100px) {
  .qx-grid { max-width: 820px; margin: 0 auto; transition: max-width .2s ease; }
  .qx-grid.has-ex { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .qx-grid.has-ex #exhost { position: sticky; top: 76px; max-height: calc(100vh - 170px); overflow-y: auto; padding-right: 6px; }
  .qx-grid.has-ex #exhost .explanation { margin-top: 16px; }
  .keys-hint { text-align: center; margin-top: 14px; }
  .player-top { padding: 12px 28px; }
  body.focus-mode main#view { padding-left: 32px; padding-right: 32px; }
  body.focus-mode .action-bar { justify-content: flex-end; padding-right: 32px; }
  body.focus-mode .action-bar .btn { flex: 0 0 auto; min-width: 160px; }
  body.focus-mode .action-bar .btn.icon-only { min-width: 52px; margin-right: auto; }
}
/* Focus mode (practice, mocks, setup): full width, no sidebar offsets, centred content. */
@media (min-width: 1100px) {
  body.focus-mode .topbar, body.focus-mode main#view, body.focus-mode .action-bar { margin-left: 0 !important; }
  body.focus-mode main#view > * { max-width: 1280px; }
  body.focus-mode main#view > .player-top, body.focus-mode main#view > .player-progress { max-width: none; margin: 0 -32px !important; }
  main#view > .qx-grid { max-width: 820px; }
  main#view > .qx-grid.has-ex { max-width: 1280px; }
  body.focus-mode .action-bar { padding-left: 32px; }
}
/* Mock exam chrome: modelled on the real test interface. */
body.exam-mode main#view .player-top { background: #1e2a5a; color: #fff; border-bottom: 0; }
body.exam-mode main#view .player-top .count { color: rgba(255,255,255,.8); }
body.exam-mode main#view .player-top .timer { background: rgba(255,255,255,.12); color: #fff; }
body.exam-mode main#view .player-top .timer.warn { background: #b45309; }
body.exam-mode main#view .player-top .timer.over { background: #c2410c; }
body.exam-mode .player-progress span { background: var(--amber); }
body.exam-mode .action-bar { background: #1e2a5a; border-top: 0; }
body.exam-mode .action-bar .btn { background: #fff; color: #1e2a5a; border-color: transparent; }
body.exam-mode .action-bar .btn.primary { background: var(--amber); color: #fff; }
body.exam-mode .action-bar .btn.bookmarked { background: #fff7e6; color: #b45309; }
@media (min-width: 1100px) {
  body.exam-mode .question.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
  body.exam-mode .question.split .stimulus { border: 0; border-right: 1px solid var(--border); border-radius: 0; position: static; }
  body.exam-mode .question.split .stim-scroll { max-height: calc(100vh - 190px); }
  body.exam-mode .question.split .q-main { padding: 20px 24px; max-height: calc(100vh - 190px); overflow-y: auto; }
  body.exam-mode .question.single { max-width: 860px; margin: 24px auto; }
  body.exam-mode .stim-toggle .stim-collapse { display: none; }
}
/* desktop month calendar */
.plan-desk { grid-template-columns: minmax(0, 1fr) 380px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.cal-h { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px 2px; }
.cal-d { min-height: 104px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.cal-d:hover:not([disabled]) { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.cal-d.sel { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.cal-d.today .cal-n { background: var(--primary); color: var(--primary-ink); border-radius: 99px; padding: 0 7px; }
.cal-d.rest { background: var(--surface-2); }
.cal-d.past { opacity: .45; cursor: default; }
.cal-d.ph-mocks { border-top: 3px solid var(--amber); }
.cal-d.ph-taper, .cal-d.ph-test { border-top: 3px solid var(--green); }
.cal-top { display: flex; justify-content: space-between; align-items: center; }
.cal-n { font-weight: 750; font-size: 14px; }
.cal-n small { font-weight: 600; color: var(--text-3); }
.cal-m { font-size: 11px; color: var(--text-3); }
.cal-i { font-size: 12px; line-height: 1.3; padding: 3px 6px; border-radius: 6px; background: var(--indigo-soft); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-i.k-mock, .cal-i.k-official, .cal-i.k-checkpoint, .cal-i.k-section-test { background: var(--amber-soft); }
.cal-i.k-admissions { background: var(--blue-soft); }
.cal-i.k-test { background: var(--green-soft); font-weight: 700; }
.cal-more { font-size: 11px; color: var(--text-3); padding-left: 6px; }
.cal-i { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal-light { font-size: 11.5px; color: var(--text-3); padding: 2px 6px; }
@media (min-width: 1100px) {
  .practice-desk { grid-template-columns: minmax(0, 1fr) 380px; }
  .practice-desk .grid2.tiles { grid-template-columns: repeat(2, 1fr); }
  .practice-desk .builder > div { margin-top: 0 !important; }
}
.nav-group { display: none; }
@media (min-width: 1100px) {
  .bottomnav { grid-auto-rows: auto; gap: 2px; overflow-y: auto; }
  .bottomnav a:not(.nav-brand) { min-height: 42px; }
  .nav-group { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 16px 14px 6px; }
}
/* Icons default to text size unless a component sizes them. */
svg.i { width: 1.25em; height: 1.25em; flex-shrink: 0; }
.item > svg.i { width: 20px; height: 20px; color: var(--text-3); }

/* ===================== UX pass (2026-10-20) ===================== */
@media (min-width: 1100px) {
  /* Wide views (players, mocks) must not keep the 1200px phone-era cap; children centre themselves. */
  main#view.wide { max-width: none; }
  /* Fixed action bars are children of #view: exempt them from the centred max-width rule and span the content area. */
  main#view > .action-bar:not(.inline-bar) { max-width: none; margin-left: var(--rail); margin-right: 0; }
  body.focus-mode main#view > .action-bar:not(.inline-bar) { margin-left: 0 !important; }
}
@media (min-width: 1100px) {
  /* Single question before feedback: keep a comfortable reading measure (focus-mode's 1280px rule outranks .qx-grid). */
  body.focus-mode main#view > .qx-grid:not(.has-ex), body.focus-mode main#view > .keys-hint { max-width: 820px; }
}
/* Data tables: long headings wrap so every column fits; numbers stay on one line. */
.data-table th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
/* Auto-scrolled feedback must land below the sticky player bar, not under it. */
.explanation, #exhost, #qdetail { scroll-margin-top: calc(var(--top-h) + 24px); }
@media (min-width: 1100px) {
  /* Players and mocks: the sticky question bar sits flush with the top of the window. */
  body.focus-mode main#view { padding-top: 0; }
}
/* Mock Review & Edit: centred, with a legend; even rows on desktop. */
.review-wrap { max-width: 720px; margin: 0 auto; }
.review-legend { display: flex; gap: 18px; font-size: 13px; color: var(--text-2); margin: -4px 0 14px; }
.review-legend span { display: inline-flex; align-items: center; gap: 6px; }
.review-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1.5px solid var(--border); }
.review-legend .lg-bm { border-color: var(--amber); }
.review-legend .lg-ed { background: var(--indigo-soft); }
@media (min-width: 1100px) { .review-wrap .review-grid { grid-template-columns: repeat(7, 1fr); } }
/* Mock: between-sections / break screen, centred in the window. */
.break-screen { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 24px 0; }
.break-card { max-width: 560px; width: 100%; text-align: center; padding: 32px 28px; }
.break-card .btn-row { justify-content: center; }
.sec-track { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.sec-track span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 650; background: var(--surface-2); color: var(--text-3); }
.sec-track span.done { background: var(--green-soft); color: var(--green); }
.sec-track span.next { background: var(--indigo-soft); color: var(--primary); }
.sec-track svg { width: 14px; height: 14px; }
@media (max-width: 520px) { .break-card { padding: 24px 18px; } .break-card .btn-row .btn { width: 100%; } }
/* Progress: folded long topic list. */
.more-topics > summary { list-style: none; display: inline-block; margin-top: 4px; min-height: 44px; line-height: 36px; }
.more-topics > summary::-webkit-details-marker { display: none; }
.more-topics[open] > summary { display: none; }
@media (min-width: 1100px) { .side-col .seg { margin-top: 16px !important; } .side-col .chips { margin-top: 4px; } }
/* Today: phase labels never clip (segments grow from their label width); short heat maps keep square cells. */
.phase-seg { min-width: max-content; }
.heat { justify-content: start; grid-auto-columns: 12px; }
.side-col .heat { grid-template-rows: repeat(7, 16px); grid-auto-columns: 16px; gap: 4px; }
.side-col .heat i { width: 16px; height: 16px; border-radius: 4px; }
@media (min-width: 1100px) {
  /* Inline vertical margins on top-level blocks must not cancel desktop centring (caused blocks to jut left). */
  main#view > *:not(.action-bar):not(.player-top):not(.player-progress) { margin-left: auto !important; margin-right: auto !important; }
}
.page-h1 { margin: 0 0 18px; }
/* Library on desktop: tabs at a sensible width, content in two columns. */
@media (min-width: 1100px) {
  .lib-tabs { max-width: 520px; }
  .lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
  .lib-grid > .card { margin: 0; }
  .formula-grid > details { margin: 0 !important; }
  #gl-q { max-width: 520px; }
}
/* recaps & quick-fire */
.recall-wrap { max-width: 680px; margin: 0 auto; }
.recall-q { font-size: 20px; line-height: 1.4; margin-bottom: 16px; }
ul.tldr { list-style: none; padding: 0; margin: 16px 0; }
ul.tldr li { position: relative; padding: 12px 14px 12px 40px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-size: 16.5px; line-height: 1.5; }
ul.tldr li::before { content: '✓'; position: absolute; left: 14px; top: 11px; color: var(--green); font-weight: 800; }
.btn.tf-right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.btn.tf-wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
/* Settings on desktop: section cards in two columns. */
@media (min-width: 1100px) {
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-items: start; }
  .settings-grid .set-sec > .section-title { margin-top: 8px; }
}
@media (min-width: 1100px) {
  .more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-items: start; }
  .more-grid .section-title { margin-top: 8px; }
}
/* tools & train */
.tool-wrap { max-width: 640px; margin: 8px auto 0; }
.tool-wrap.wide-tool { max-width: 1000px; }
.big-num { font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.tool-split { display: grid; grid-template-columns: 1fr; gap: 20px; }
.train-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tips-grid .tip-card { margin-bottom: 10px; }
.data-table.compare th { width: 160px; white-space: normal; }
.data-table.compare td { white-space: normal; min-width: 180px; vertical-align: top; }
.sprint-q { font-size: 48px; font-weight: 800; margin: 26px 0 18px; font-variant-numeric: tabular-nums; }
.sprint-in { font-size: 28px; text-align: center; max-width: 260px; margin: 0 auto; display: block; }
.sprint-top { display: flex; justify-content: center; gap: 12px; }
.qf-prompt { font-size: 16.5px; margin-bottom: 14px; }
@media (min-width: 1100px) {
  .tool-split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
  .tool-split > aside { position: sticky; top: 28px; }
  .train-grid { grid-template-columns: repeat(3, 1fr); }
  .tips-grid { columns: 2; column-gap: 14px; }
  .tips-grid .tip-card { break-inside: avoid; }
}
@media print { .cheatsheet { font-size: 12px; } .seg, .btn-row { display: none !important; } }
/* Exam chrome: a disabled Next reads as clearly unavailable, not muddy amber. */
body.exam-mode .action-bar .btn.primary[disabled] { background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.6); opacity: 1; }

/* ---------- Phone & tablet tap targets (>= 44px). Desktop keeps its denser controls. */
@media (max-width: 1099px) {
  .icon-btn { width: 44px; height: 44px; }
  .topbar .brand { min-height: 44px; }
  .seg button, .daypace .seg button { min-height: 44px; }
  .daypick button { min-height: 44px; }
  .btn.sm { min-height: 44px; }
  button.chip { min-height: 44px; }
  .link-btn { min-height: 44px; padding: 4px 8px; }
  .tab { min-height: 44px; }
  /* Summaries become 44px flex rows; the native triangle (lost with flex) is redrawn only where it used to show. */
  details > summary { min-height: 44px; display: flex; align-items: center; gap: 6px; }
  details > summary::-webkit-details-marker { display: none; }
  details:not(.reveal):not(.more-topics) > summary:not([style*='list-style']):not(.link-btn)::before { content: '▸'; color: var(--text-3); font-size: 0.9em; }
  details:not(.reveal):not(.more-topics)[open] > summary:not([style*='list-style']):not(.link-btn)::before { content: '▾'; }
  /* Small round controls keep their look; an invisible ring makes them 44px to the finger. */
  .check, .yn-btn, .switch input { position: relative; }
  .check::after, .yn-btn::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }
  .yn-btn::after { inset: -7px; }
  .item .move-btn { width: 44px; height: 44px; }
}
/* ---------- guided hand-holding */
.buddy-note { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: 16px; padding: 14px 16px; margin: 6px 0 16px; box-shadow: var(--shadow); animation: rise .3s ease; }
.buddy-face { width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #1e2a5a, #4f46e5); }
.buddy-text { flex: 1; min-width: 0; }
.buddy-text p { margin: 2px 0 0; color: var(--text-2); font-size: 14.5px; line-height: 1.5; }
.buddy-note .link-btn { flex-shrink: 0; align-self: center; }
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(10, 14, 30, 0.62); transition: all .25s ease; pointer-events: none; }
.tour-tip { position: fixed; width: min(320px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-lg); animation: rise .25s ease; }
.tour-tip h3 { margin: 4px 0 6px; }
.tour-tip p { color: var(--text-2); font-size: 15px; }
.tour-tip .btn-row { justify-content: flex-end; }
ul.tight { margin: 0; padding-left: 18px; }
ul.tight li { margin: 4px 0; }
.help-btn { font-weight: 800; font-size: 16px; }
.topic-row { padding: 7px 0; margin: 2px 0; border-radius: 8px; }
.topic-row:hover .bar { filter: brightness(1.05); }
@media (max-width: 1099px) {
  button.chip { min-width: 44px; justify-content: center; flex-shrink: 0; }
  .item a.small { display: inline-flex; align-items: center; min-height: 44px; }
}
.help-fab { position: fixed; top: 16px; right: 20px; z-index: 22; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
main#view > .help-fab { max-width: none; margin: 0; }
/* Phone tab bar: the sidebar brand tile must never take a tab slot (it pushed "More" off the bar). */
@media (max-width: 1099px) { .bottomnav a.nav-brand { display: none; } }
/* While the spotlight tour is open the page must not scroll under it (the hole would drift off its target). */
body:has(.tour) { overflow: hidden; }
/* Phone players too: the sticky question bar starts at the very top. */
body.focus-mode main#view.immersive { padding-top: 0; }
body.focus-mode main#view.immersive > .player-top:first-child { margin-top: 0; }
/* Short labels where space is tight (exam bar on phones). */
.short-only { display: none; }
@media (max-width: 520px) { .long-only { display: none; } .short-only { display: inline; } }
/* Three small stats stay on one row on phones instead of a lonely third tile. */
.grid3.keep3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid3.keep3 .stat { padding: 12px 10px; }
.grid3.keep3 .stat .l { font-size: 12.5px; line-height: 1.35; }
/* Keyboard hints only where there is a keyboard. */
@media (pointer: coarse), (max-width: 1099px) { .keys-hint { display: none; } }
/* Collapsed disclosure cards on phones: a compact bar, roomy only once open. */
@media (max-width: 1099px) {
  details.card { padding-top: 6px; padding-bottom: 6px; }
  details.card[open] { padding-bottom: 16px; }
}
/* Lists of cards: the list gap does the spacing (no doubled card margins). */
.list > .card { margin-bottom: 0; }

/* Onboarding on desktop: two panels in a centred frame. */
.ob-desk { display: grid; grid-template-columns: 380px minmax(0, 1fr); max-width: 1120px; margin: 48px auto; min-height: calc(100vh - 96px); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg); overflow: hidden; }
.ob-side { background: linear-gradient(160deg, #1e2a5a 0%, #3730a3 70%, #4f46e5 100%); color: #fff; padding: 36px 32px; display: flex; flex-direction: column; gap: 28px; }
.ob-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; }
.ob-brand img { width: 34px; height: 34px; border-radius: 9px; }
.ob-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ob-steps li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: rgba(255, 255, 255, 0.7); font-weight: 600; font-size: 15px; }
.ob-steps li.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.ob-steps li.done { color: rgba(255, 255, 255, 0.85); }
.ob-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 750; border: 1.5px solid rgba(255, 255, 255, 0.45); flex-shrink: 0; }
.ob-steps li.on .ob-dot { background: #fff; color: #3730a3; border-color: #fff; }
.ob-steps li.done .ob-dot { background: rgba(255, 255, 255, 0.2); border-color: transparent; }
.ob-dot svg { width: 14px; height: 14px; }
.ob-art { margin-top: auto; width: 100%; height: auto; border-radius: 16px; display: block; background: #fff; }
.ob-main { padding: 56px 64px 40px; display: flex; flex-direction: column; max-width: 720px; }
.ob-main .cover { display: none; }
.ob-main h1 { font-size: 32px; }
.ob-main .action-bar.inline-bar { margin-top: auto !important; padding-top: 24px; }
.ob-main .action-bar.inline-bar .btn.primary { min-width: 180px; }
/* guided problems */
.guided-done { font-size: 14.5px; color: var(--text-2); margin: 6px 0; line-height: 1.5; }
.guided-done .chip { margin-right: 6px; }
.num-row { display: flex; gap: 10px; }
.num-row input { flex: 1; font-size: 20px; }
/* argument builder */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.role-chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.argue { display: flex; flex-direction: column; gap: 10px; }
.argue-s { text-align: left; border: 1.5px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px 14px; font-size: 16px; line-height: 1.5; cursor: pointer; min-height: 56px; }
.argue-role { display: block; font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.r-premise { border-color: var(--chart-5) !important; } .role-chip.r-premise, .argue-s.r-premise .argue-role { color: var(--chart-5); }
.r-conclusion { border-color: var(--primary) !important; background: var(--indigo-soft); } .role-chip.r-conclusion, .argue-s.r-conclusion .argue-role { color: var(--primary); }
.r-intermediate { border-color: var(--chart-6) !important; } .role-chip.r-intermediate, .argue-s.r-intermediate .argue-role { color: var(--chart-6); }
.r-background { border-style: dashed !important; } .role-chip.r-background { color: var(--text-2); }
.r-counter { border-color: var(--amber) !important; } .role-chip.r-counter, .argue-s.r-counter .argue-role { color: var(--amber); }
.argue-s.ok { box-shadow: 0 0 0 2px var(--green); }
.argue-s.bad { box-shadow: 0 0 0 2px var(--red); }
.argue-s.bad .argue-role { color: var(--red) !important; }
/* skill map */
.skill-sec { margin-bottom: 14px; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 6px; }
.skill-tile { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 64px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--text); border: 1px solid var(--border); background: var(--surface); }
.skill-name { font-size: 13.5px; font-weight: 650; line-height: 1.3; }
.skill-lv { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.skill-tile.lv1 { background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
.skill-tile.lv2 { background: color-mix(in srgb, var(--amber) 14%, var(--surface)); }
.skill-tile.lv3 { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.skill-tile.lv4 { background: color-mix(in srgb, var(--primary) 24%, var(--surface)); }
.skill-tile.lv5 { background: color-mix(in srgb, var(--green) 26%, var(--surface)); }
.skill-tile.lv5 .skill-lv { color: var(--green); }
/* ---------- UX round 2 (2026-10-20): train, recaps, tools, help, tour, calculator */
.sprint-top { position: relative; align-items: center; min-height: 44px; }
.sprint-top .icon-btn { position: absolute; left: 0; top: 0; }
.recall-wrap .callout { scroll-margin-bottom: 120px; margin-top: 12px; }
.next-steps .item { align-items: center; }
.next-steps .item.static { background: none; border-color: transparent; box-shadow: none; padding-left: 0; padding-right: 0; cursor: default; }
.next-steps .next-go { font-size: 22px; color: var(--text-3); padding-left: 8px; }
.data-table.compare th { vertical-align: top; }
div.field { margin-bottom: 14px; } /* a chip group laid out like a labelled field */
/* "?" on desktop: anchored to the page top, so it scrolls away instead of floating over cards. */
.help-fab { position: absolute; }
@media (max-width: 1099px) {
  input[type='range'] { height: 44px; }
  .player-top .timer { min-height: 44px; min-width: 56px; }
  .sort-btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; }
  .daypick { gap: 3px; }
  .daypick button { padding: 0; min-width: 0; }
  .week { gap: 3px; }
  select.dd-select { min-height: 44px; }
  .topbar .icon-btn { flex-shrink: 0; }
  /* Help playbooks: title over its one-line summary, not squeezed side by side. */
  details.playbook > summary { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; }
  details.playbook > summary > .faint { grid-column: 2; }
}
/* Print (cheat sheets): always light ink on white, whatever the theme, and no app chrome. */
@media print {
  :root, :root[data-theme='dark'], :root:not([data-theme='light']) {
    --bg: #fff !important; --surface: #fff !important; --surface-2: #f4f5f9 !important; --border: #d9dce6 !important;
    --text: #111 !important; --text-2: #333 !important; --text-3: #555 !important; --primary: #3730a3 !important;
    --indigo-soft: #eef0fe !important; --amber-soft: #fff7e6 !important; --green-soft: #e9f8ef !important; --red-soft: #fdeee6 !important; --blue-soft: #eaf2ff !important;
    color-scheme: light;
  }
  body { background: #fff !important; color: #111 !important; }
  .buddy-note, .help-btn, .calc, .tour { display: none !important; }
}
/* Reading measures win over the generic desktop caps (main#view > * and focus mode's 1280px). */
main#view > .recall-wrap, body.focus-mode main#view > .recall-wrap { max-width: 720px; }
main#view > .tool-wrap { max-width: 680px; }
main#view > .tool-wrap.wide-tool { max-width: 1040px; }
/* Answered true/false: the verdict colours stay at full strength (they are results, not unavailable buttons). */
.btn.tf-right[disabled], .btn.tf-wrong[disabled] { opacity: 1; cursor: default; border-width: 2px; }
.train-grid > details.playbook { align-self: start; } /* opening one playbook must not stretch its neighbours */
.seg[data-sheet] button { white-space: nowrap; padding-left: 4px; padding-right: 4px; }
@media (max-width: 400px) {
  /* Seven 44px day buttons need ~326px: let the picker use the card's side padding on narrow phones. */
  .card .daypick { margin-left: -16px; margin-right: -16px; gap: 2px; }
}
/* ---------- trophy celebration */
.celebrate { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 30, 0.62); overflow: hidden; animation: fade .2s ease; }
.celebrate.out { opacity: 0; transition: opacity .18s ease; }
.celebrate-card { position: relative; width: min(420px, 100%); text-align: center; background: var(--surface); border-radius: 26px; padding: 30px 24px 24px; box-shadow: var(--shadow-lg); animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
.celebrate-card h2 { font-size: 26px; margin: 8px 0 6px; }
.celebrate-glow { position: absolute; inset: -40px -40px auto; height: 220px; background: radial-gradient(circle at 50% 40%, rgba(250, 204, 21, .35), transparent 65%); pointer-events: none; }
.celebrate-medal { position: relative; width: 96px; height: 96px; margin: 10px auto 6px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #f59e0b, #d97706 55%, #b45309); box-shadow: 0 10px 30px rgba(217, 119, 6, .45), inset 0 -6px 0 rgba(0,0,0,.12); animation: medal 1s ease .15s both; }
.celebrate-medal svg { width: 46px; height: 46px; stroke-width: 2; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: .95; animation: confetti linear forwards; pointer-events: none; }
@keyframes confetti { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: .9; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes medal { 0% { transform: scale(.3) rotate(-20deg); } 60% { transform: scale(1.12) rotate(6deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .celebrate-card, .celebrate-medal { animation: none; } }
/* trophy case */
.trophy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.trophy { text-align: center; padding: 16px 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.trophy .medal { width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #f59e0b, #b45309); box-shadow: 0 6px 16px rgba(217, 119, 6, .3); }
.trophy .medal svg { width: 24px; height: 24px; }
.trophy .tn { font-weight: 750; font-size: 14.5px; line-height: 1.3; }
.trophy .td { font-size: 12.5px; color: var(--text-2); margin-top: 4px; line-height: 1.4; }
.trophy .tdate { font-size: 11.5px; color: var(--green); font-weight: 700; margin-top: 6px; }
.trophy.locked .medal { background: var(--surface-2); color: var(--text-3); box-shadow: none; }
.trophy.locked .tn { color: var(--text-2); }
/* Three train cards per row only when each card gets ~300px; small desktops keep two. The count badge sits under the text there. */
@media (min-width: 1100px) and (max-width: 1299px) {
  .train-grid { grid-template-columns: repeat(2, 1fr); }
}
.celebrate-list { list-style: none; padding: 0; margin: 12px 0; text-align: left; max-height: 40vh; overflow-y: auto; }
.celebrate-list li { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 14.5px; line-height: 1.35; }
.mini-medal { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #f59e0b, #b45309); }
.mini-medal svg { width: 17px; height: 17px; }

/* ---------- Refreshers (back to basics) ---------- */
.rf-wrap { max-width: 1180px; margin: 0 auto; }
.rf-narrow { max-width: 760px; }
.rf-hero { display: grid; gap: 18px; margin: 8px 0 8px; }
.rf-hero h1 { margin: 6px 0 8px; }
.rf-overall { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.rf-overall .bar { flex: 1; max-width: 420px; }
.rf-next h2 { font-size: 20px; }
.rf-how { list-style: none; padding: 0; margin: 22px 0 6px; display: grid; gap: 10px; }
.rf-how li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.rf-how p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.rf-how strong { display: inline-flex; gap: 6px; align-items: center; }
.rf-how strong svg { width: 17px; height: 17px; color: var(--primary); }
.rf-how-n { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--indigo-soft); color: var(--primary); display: grid; place-items: center; font-weight: 750; font-size: 13px; }
.rf-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.rf-track { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.rf-track:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.rf-track h3 { margin: 4px 0 0; font-size: 17px; }
.rf-track p { margin: 0; font-size: 14px; line-height: 1.45; flex: 1; }
.rf-track-top { display: flex; justify-content: space-between; align-items: flex-start; }
.rf-track .ic, .rf-track-head .ic, .rf-banner .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--indigo-soft); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.rf-track .ic svg, .rf-banner .ic svg { width: 22px; height: 22px; }
.rf-track-head .ic.big { width: 56px; height: 56px; border-radius: 16px; }
.rf-track-head .ic.big svg { width: 28px; height: 28px; }
.rf-track-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.rf-track-head { display: flex; gap: 16px; align-items: flex-start; margin: 8px 0 18px; }
.rf-track-head h1 { margin: 2px 0 6px; }
.rf-actions { display: grid; gap: 12px; }
.rf-action { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0; }
.rf-action > div { flex: 1; min-width: 220px; }
.rf-action p { margin: 4px 0 0; font-size: 14px; }
.rf-action strong { display: inline-flex; align-items: center; gap: 6px; }
.rf-action strong svg { width: 18px; height: 18px; color: var(--primary); }
.rf-finished .t { color: var(--text-2); }
.rf-main { max-width: 760px; }
.rf-main h1 { margin-bottom: 8px; }
.rf-main .lead { font-size: 17px; color: var(--text-2); line-height: 1.55; }
.rf-learn { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.rf-learn li { display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.rf-learn svg { width: 17px; height: 17px; color: var(--green); flex-shrink: 0; margin-top: 3px; }
.rf-visual { width: 100%; border-radius: 16px; display: block; margin: 12px 0 16px; border: 1px solid var(--border); background: var(--surface-2); }
.rf-q { margin-top: 6px; }
.rf-prompt { margin-bottom: 12px; }
.rf-prompt > :first-child { margin-top: 0; }
.rf-prompt table { font-size: 15px; }
.rf-q .choice.picked { border-color: var(--primary); background: var(--indigo-soft); }
.rf-score { display: flex; gap: 18px; align-items: center; margin: 10px 0 18px; }
.rf-score .ring { --size: 84px; flex-shrink: 0; }
.rf-review { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.rf-review .prose > :first-child { margin-top: 4px; }
.rf-banner { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; margin: 8px 0 14px; padding: 14px 16px; }
.rf-banner > div:nth-child(2) { flex: 1; }
.rf-banner > svg { width: 18px; height: 18px; color: var(--text-3); }
.rf-entry { margin-bottom: 10px; background: var(--green-soft); color: var(--green); text-decoration: none; }
.rf-entry span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.rf-entry svg { width: 17px; height: 17px; }
@media (min-width: 700px) {
  .rf-grid { grid-template-columns: repeat(2, 1fr); }
  .rf-how { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .rf-hero { grid-template-columns: 1.25fr 1fr; align-items: center; gap: 40px; margin-top: 16px; }
  .rf-hero h1 { font-size: 34px; letter-spacing: -0.02em; }
  .rf-how { grid-template-columns: repeat(4, 1fr); }
  .rf-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .rf-track { padding: 24px; }
  .rf-actions { grid-template-columns: 1fr 1fr; }
}
