/* ==========================================================================
   MySATBoost — "Test booklet" design system
   Graph paper, No. 2 pencil, answer bubbles.
   ========================================================================== */

:root {
  /* paper & ink */
  --paper:      #F4F6FA;
  --sheet:      #FFFFFF;
  --grid:       rgba(41, 82, 227, .055);
  --ink:        #14213D;
  --ink-2:      #34405A;
  --muted:      #66718A;
  --line:       #DCE2EC;
  --line-2:     #C7D0DE;

  /* pencil */
  --pencil:      #F5B700;
  --pencil-dark: #D69E00;
  --pencil-wood: #F2D6A2;
  --graphite:    #2B2F38;
  --eraser:      #F0899A;
  --ferrule:     #B9C0CB;

  /* action & feedback */
  --blue:       #2952E3;
  --blue-dark:  #1D3FB8;
  --blue-soft:  #E8EEFF;
  --good:       #138A5B;
  --good-soft:  #E4F5EC;
  --bad:        #CC3535;
  --bad-soft:   #FCE9E9;
  --warn-soft:  #FFF4D1;

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-sheet: 0 1px 0 var(--line), 0 10px 30px -18px rgba(20, 33, 61, .35);
  --focus: 0 0 0 3px #fff, 0 0 0 5px var(--blue);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
}
img, svg { max-width: 100%; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-dark); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.12rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.wrap { max-width: 1120px; margin: 0 auto; padding: 2.25rem 1.25rem 4rem; }
.wrap.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 60ch; }
.crumbs { font-size: .92rem; color: var(--muted); margin-bottom: .75rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.stack > * + * { margin-top: 1rem; }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sheet);
  padding: 1.5rem;
}
.sheet-tight { padding: 1rem 1.25rem; }
.sheet h2:first-child, .sheet h3:first-child { margin-top: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.25rem 0 1rem; }
.section-title h2 { margin: 0; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; height: 64px; display: flex; align-items: center; gap: 1.5rem; }
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand:hover { color: #fff; }
.brand-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.brand-name b { color: var(--pencil); font-weight: 800; }
.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark span { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); }
.brand-mark span:nth-child(3) { background: var(--pencil); border-color: var(--pencil); }
.mainnav { display: flex; align-items: center; gap: .2rem; flex: 1; }
.mainnav > a {
  color: rgba(255,255,255,.72); text-decoration: none; font-weight: 700; font-size: .95rem;
  padding: .45rem .8rem; border-radius: 999px; transition: background .15s, color .15s;
}
.mainnav > a:hover { color: #fff; background: rgba(255,255,255,.08); }
.mainnav > a.is-active { color: var(--ink); background: var(--pencil); }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: .65rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--ink); font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.usermeta { display: flex; flex-direction: column; line-height: 1.15; }
.u-name { font-weight: 700; font-size: .95rem; }
.u-role { font-size: .78rem; color: rgba(255,255,255,.6); }
.u-role.role-admin { color: var(--pencil); }
.link-btn { background: none; border: 0; padding: .3rem .4rem; color: rgba(255,255,255,.7); font: inherit; font-size: .88rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: #fff; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; padding: .5rem; cursor: pointer; }
.nav-toggle .bars, .nav-toggle .bars::before, .nav-toggle .bars::after {
  display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; position: relative; content: '';
}
.nav-toggle .bars::before { position: absolute; top: -7px; }
.nav-toggle .bars::after  { position: absolute; top: 7px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1;
  padding: .8rem 1.25rem; border-radius: var(--r-md); border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 0 var(--blue-dark); }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-pencil { background: var(--pencil); color: var(--ink); box-shadow: 0 2px 0 var(--pencil-dark); }
.btn-pencil:hover { background: #FFC61A; color: var(--ink); }
.btn-ghost { background: var(--sheet); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { background: var(--sheet); color: var(--bad); border-color: #EDBABA; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-sm { padding: .5rem .8rem; font-size: .9rem; border-radius: var(--r-sm); }
.btn-lg { padding: 1rem 1.6rem; font-size: 1.08rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--sheet); color: var(--ink); cursor: pointer; font: inherit; font-size: .95rem;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.btn-row { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label, .label { display: block; font-weight: 700; font-size: .95rem; margin-bottom: .4rem; color: var(--ink); }
.field .hint { font-size: .86rem; color: var(--muted); margin-top: .35rem; }
.input, .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number],
.field input[type=search], .field select, .field textarea, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--sheet);
  border: 1.5px solid var(--line-2); border-radius: var(--r-md); padding: .72rem .85rem;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea, textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.field.has-error input { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .88rem; margin-top: .35rem; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .88rem; }
.check { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.5rem; }
.pw-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); background: none; border: 0; font: inherit; font-size: .88rem; font-weight: 700; color: var(--blue); cursor: pointer; padding: .35rem .5rem; }

/* ── Alerts & toasts ────────────────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: var(--r-md); margin-bottom: 1.1rem; border: 1px solid; }
.alert-error { background: var(--bad-soft); border-color: #F1C2C2; color: #8F1F1F; }
.alert-success { background: var(--good-soft); border-color: #BFE3CF; color: #0D5E3E; }
.alert-info { background: var(--warn-soft); border-color: #F1DE9C; color: #6B5200; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 380px); }
.toast {
  background: var(--ink); color: #fff; padding: .8rem 1rem; border-radius: var(--r-md);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.45); border-left: 5px solid var(--pencil);
  animation: toast-in .25s ease-out, toast-out .3s ease-in 5s forwards;
}
.toast-error { border-left-color: var(--bad); }
.toast-success { border-left-color: #3DDC97; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }

/* ── Badges / pills ─────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; background: #EEF1F6; color: var(--ink-2); white-space: nowrap; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad  { background: var(--bad-soft); color: var(--bad); }
.pill-pencil { background: var(--warn-soft); color: #7A5C00; }
.pill-blue { background: var(--blue-soft); color: var(--blue-dark); }
.score-good { color: var(--good); }
.score-ok   { color: #A06F00; }
.score-low  { color: var(--bad); }

/* ==========================================================================
   SIGNATURE 1 — The pencil progress bar
   eraser · ferrule · yellow body (fill) · sharpened wood tip · graphite point
   ========================================================================== */
.pencil {
  --p: 0;                      /* 0–100, set inline */
  --h: 16px;
  position: relative; height: var(--h); display: flex; align-items: center;
}
.pencil-track {
  position: relative; flex: 1; height: var(--h);
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--line) calc(10% - 1px) 10%), #EDF0F5;
  border-radius: 3px 999px 999px 3px;
}
.pencil-body {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: max(calc(var(--p) * 1%), 22px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.45) 0 22%, transparent 22% 38%, rgba(0,0,0,.07) 38% 62%, transparent 62% 78%, rgba(0,0,0,.12) 78%),
    var(--pencil);
  border-radius: 3px 0 0 3px;
  transition: width 1.1s cubic-bezier(.2,.7,.2,1);
}
/* eraser + ferrule */
.pencil-body::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
  background: linear-gradient(90deg, var(--eraser) 0 55%, var(--ferrule) 55% 100%);
  border-radius: 3px 0 0 3px;
}
/* sharpened tip */
.pencil-body::after {
  content: ''; position: absolute; top: 0; bottom: 0; right: calc(var(--h) * -1.05);
  width: calc(var(--h) * 1.05);
  background: linear-gradient(90deg, var(--pencil-wood) 0 62%, var(--graphite) 62%);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.pencil.is-empty .pencil-body { width: 22px; }
.pencil-label { margin-left: calc(var(--h) * 1.4); font-weight: 700; font-size: .9rem; min-width: 3.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.pencil-lg { --h: 22px; }
.pencil-sm { --h: 11px; }
.pencil-sm .pencil-body::before { width: 9px; }
.pencil.is-done .pencil-track { background: #EAF6EF; }
@media (prefers-reduced-motion: reduce) { .pencil-body { transition: none; } }

/* ==========================================================================
   SIGNATURE 2 — Answer bubbles
   ========================================================================== */
.bubble {
  width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 2px solid var(--ink-2); color: var(--ink-2);
  font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  background: var(--sheet); transition: background .12s, color .12s, border-color .12s, transform .12s;
}
.bubble-sm { width: 1.6rem; height: 1.6rem; font-size: .78rem; border-width: 1.5px; }

/* ── Auth (login / register) ────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side {
  background: var(--ink); color: #fff; padding: 3rem clamp(1.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side .brand { margin-bottom: 2rem; }
.auth-side h1 { color: #fff; font-size: clamp(2.2rem, 4.4vw, 3.4rem); max-width: 12ch; margin-bottom: .6rem; }
.auth-side p.lede { color: rgba(255,255,255,.72); max-width: 40ch; font-size: 1.1rem; }
.answer-sheet { display: grid; gap: .55rem; margin: 2.5rem 0; max-width: 340px; }
.answer-row { display: flex; align-items: center; gap: .55rem; }
.answer-row .n { width: 1.8rem; font-family: var(--font-display); font-weight: 700; color: rgba(255,255,255,.45); font-size: .9rem; text-align: right; font-variant-numeric: tabular-nums; }
.answer-row .bubble { background: transparent; border-color: rgba(255,255,255,.35); color: rgba(255,255,255,.55); width: 2rem; height: 2rem; font-size: .82rem; }
.answer-row .bubble.fill { background: var(--pencil); border-color: var(--pencil); color: var(--ink); animation: fill-in .35s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes fill-in { from { transform: scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .answer-row .bubble.fill { animation: none; } }
.auth-foot { color: rgba(255,255,255,.5); font-size: .88rem; }
.auth-main { display: grid; place-items: center; padding: 2.5rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 2rem; margin-bottom: .3rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1.75rem; }
.auth-switch { margin-top: 1.5rem; text-align: center; color: var(--muted); }

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.hello { margin-bottom: 1.75rem; }
.hello h1 { margin-bottom: .25rem; }
.hello p { color: var(--muted); margin: 0; }
.continue {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: center;
  background: var(--sheet); border: 1px solid var(--line); border-left: 8px solid var(--course, var(--blue));
  border-radius: var(--r-lg); padding: 1.6rem 1.75rem; box-shadow: var(--shadow-sheet);
}
.continue .kicker { font-size: .92rem; color: var(--muted); margin-bottom: .3rem; }
.continue h2 { font-size: 1.6rem; margin-bottom: .9rem; }
.continue .pencil { max-width: 520px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-top: 1.5rem; }
.stat { background: var(--sheet); padding: 1.1rem 1.25rem; }
.stat .v { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; gap: .85rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; padding-top: 0; }
.history .h-main { flex: 1; min-width: 0; }
.history .h-title { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); text-decoration: none; }
.history .h-meta { font-size: .86rem; color: var(--muted); }
.history .h-score { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* ── Course cards ───────────────────────────────────────────────────────── */
.course-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.course-card {
  position: relative; display: flex; flex-direction: column; gap: .9rem;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.4rem 1.5rem 1.3rem; box-shadow: var(--shadow-sheet); text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.course-card::before { content: ''; position: absolute; left: 1.5rem; top: 0; width: 44px; height: 5px; background: var(--course, var(--blue)); border-radius: 0 0 4px 4px; }
.course-card:hover { border-color: var(--course, var(--blue)); color: var(--ink); }
.course-card h3 { font-size: 1.3rem; margin: .2rem 0 0; }
.course-card p { color: var(--muted); font-size: .95rem; margin: 0; flex: 1; }
.course-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); }
.course-card .go { font-weight: 700; color: var(--course, var(--blue)); }

/* ── Course path (ordered quizzes) ──────────────────────────────────────── */
.course-hero {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
  padding: 1.75rem; margin-bottom: 2rem; border-top: 6px solid var(--course, var(--blue));
}
.course-hero h1 { margin-bottom: .4rem; }
.course-hero p { color: var(--muted); max-width: 65ch; }
.course-hero .row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; margin-top: 1.25rem; }
.course-hero .pencil { flex: 1; min-width: 240px; }
.unit { margin-bottom: 2rem; }
.unit-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.unit-head h2 { font-size: 1.15rem; margin: 0; }
.unit-head .unit-n { color: var(--muted); font-weight: 700; font-family: var(--font-display); margin-right: .35rem; }
.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path::before { content: ''; position: absolute; left: 1.15rem; top: 1.2rem; bottom: 1.2rem; width: 2px; background: var(--line-2); }
.step { position: relative; display: flex; align-items: center; gap: 1rem; padding: .55rem 0; }
.step .bubble { position: relative; z-index: 1; }
.step-card {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-width: 0;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-md); padding: .85rem 1.1rem;
  text-decoration: none; color: var(--ink);
}
a.step-card:hover { border-color: var(--ink); color: var(--ink); }
.step-title { font-weight: 700; display: block; }
.step-meta { font-size: .88rem; color: var(--muted); }
.step.is-passed .bubble { background: var(--ink); border-color: var(--ink); color: var(--pencil); }
.step.is-current .bubble { background: var(--pencil); border-color: var(--pencil-dark); color: var(--ink); box-shadow: 0 0 0 5px rgba(245,183,0,.25); }
.step.is-current .step-card { border: 2px solid var(--ink); box-shadow: 0 6px 20px -12px rgba(20,33,61,.5); }
.step.is-locked .bubble { border-style: dashed; border-color: var(--line-2); color: var(--line-2); }
.step.is-locked .step-card { background: transparent; border-style: dashed; color: var(--muted); }
.step.is-locked .step-title { font-weight: 400; }
.lesson-link { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .92rem; }

/* ── Quiz player ────────────────────────────────────────────────────────── */
.player { max-width: 820px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.player-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.player-top .exit { flex-shrink: 0; }
.player-top .pencil { flex: 1; }
.player-title { font-size: 1rem; color: var(--muted); margin: 0 0 .25rem; font-family: var(--font-body); font-weight: 700; }
.qsheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); overflow: hidden; }
.qsheet-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; border-bottom: 1px dashed var(--line-2); }
.qnum { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
.qnum span { color: var(--muted); font-weight: 500; }
.qtext { padding: 1.5rem 1.5rem .5rem; font-size: 1.15rem; line-height: 1.65; overflow-x: auto; }
.qtext img { height: auto; border-radius: var(--r-sm); }
.qtext table { border-collapse: collapse; margin: .5rem 0; }
.qtext td, .qtext th { border: 1px solid var(--line-2); padding: .35rem .6rem; }
.choices { list-style: none; margin: 0; padding: 1rem 1.5rem 1.5rem; display: grid; gap: .6rem; }
.choice {
  display: flex; align-items: center; gap: 1rem; width: 100%; text-align: left;
  background: var(--sheet); border: 1.5px solid var(--line-2); border-radius: var(--r-md);
  padding: .75rem 1rem; font: inherit; font-size: 1.05rem; color: var(--ink); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--ink); }
.choice:hover .bubble { border-color: var(--ink); color: var(--ink); }
.choice[aria-checked="true"] { border-color: var(--ink); background: #F7F8FB; }
.choice[aria-checked="true"] .bubble { background: var(--ink); border-color: var(--ink); color: #fff; transform: scale(1.06); }
.choice-text { flex: 1; min-width: 0; overflow-x: auto; }
.choice kbd { font-family: var(--font-body); font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; }
.player-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }
.dots { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; flex: 1; }
.dot {
  width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--sheet);
  font: inherit; font-size: .78rem; font-weight: 700; color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.dot.is-answered { background: var(--ink); border-color: var(--ink); color: #fff; }
.dot.is-here { box-shadow: 0 0 0 3px var(--pencil); border-color: var(--ink); color: var(--ink); }
.dot.is-answered.is-here { color: var(--pencil); }
.shortcut-hint { text-align: center; font-size: .86rem; color: var(--muted); margin-top: 1rem; }
.confirm-panel { margin-top: 1rem; }

/* ── Results ────────────────────────────────────────────────────────────── */
.result-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2rem; align-items: center; }
.score-ring { --p: 0; --c: var(--good); width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #EDF0F5 0); }
.score-ring::before { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: var(--sheet); }
.score-ring .in { position: relative; text-align: center; }
.score-ring .big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score-ring .of { color: var(--muted); font-size: .9rem; }
.verdict { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: .4rem; }
.review { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.review-item { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.review-item.is-wrong { border-left: 5px solid var(--bad); }
.review-item.is-right { border-left: 5px solid var(--good); }
.review-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1.25rem; border-bottom: 1px dashed var(--line); }
.review-q { padding: 1rem 1.25rem .25rem; overflow-x: auto; }
.review-choices { list-style: none; margin: 0; padding: .5rem 1.25rem 1rem; display: grid; gap: .4rem; }
.review-choices li { display: flex; align-items: center; gap: .75rem; padding: .45rem .65rem; border-radius: var(--r-sm); }
.review-choices li.correct { background: var(--good-soft); }
.review-choices li.correct .bubble { background: var(--good); border-color: var(--good); color: #fff; }
.review-choices li.chosen-wrong { background: var(--bad-soft); }
.review-choices li.chosen-wrong .bubble { background: var(--bad); border-color: var(--bad); color: #fff; }
.review-choices .tag { margin-left: auto; font-size: .8rem; font-weight: 700; }
.explain { margin: 0 1.25rem 1.1rem; padding: .85rem 1rem; background: #F6F8FC; border-radius: var(--r-md); border: 1px solid var(--line); }
.explain summary { cursor: pointer; font-weight: 700; color: var(--blue); }
.explain-body { margin-top: .6rem; overflow-x: auto; }
.filter-tabs { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--sheet); }
.filter-tabs button { border: 0; background: none; font: inherit; font-weight: 700; font-size: .9rem; padding: .4rem .9rem; border-radius: 999px; cursor: pointer; color: var(--muted); }
.filter-tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ── Lesson ─────────────────────────────────────────────────────────────── */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden; background: #000; margin-bottom: 1.5rem; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-body { overflow-x: auto; }
.lesson-body img { height: auto; }

/* ── Empty states ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; background: var(--sheet); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); }
.empty-state h1, .empty-state h2 { margin-bottom: .5rem; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 auto 1.25rem; }

/* ── Admin tables & toolbars ────────────────────────────────────────────── */
.toolbar { display: flex; gap: .65rem; flex-wrap: wrap; align-items: end; margin-bottom: 1.25rem; }
.toolbar .field { margin: 0; }
.toolbar .grow { flex: 1; min-width: 200px; }
.table-wrap { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; box-shadow: var(--shadow-sheet); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 700; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #FAFBFD; }
table.data .q-snip { max-width: 520px; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 2.3rem; height: 2.3rem; display: grid; place-items: center; padding: 0 .6rem; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--sheet); text-decoration: none; color: var(--ink); font-weight: 700; font-size: .9rem; }
.pagination .is-here { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .gap { border: 0; background: none; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.admin-stats .stat { border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); }
.sortable-row { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--sheet); margin-bottom: .5rem; }
.sortable-row .grow { flex: 1; min-width: 0; }
.sortable-row .title { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sortable-row .sub { font-size: .86rem; color: var(--muted); }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:focus-visible + span { box-shadow: var(--focus); }
.preview-box { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; }
.preview-box .qtext { padding: 0 0 .75rem; }
.preview-box .choices { padding: 0; }
.picker-list { max-height: 520px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--sheet); }
.picker-item { display: flex; gap: .75rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); align-items: flex-start; }
.picker-item:last-child { border-bottom: 0; }
.picker-item .grow { flex: 1; min-width: 0; font-size: .93rem; }
.picker-item .grow .muted { font-size: .82rem; }
.danger-zone { border: 1px solid #EDBABA; border-radius: var(--r-lg); padding: 1.25rem; background: #FFFBFB; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .mainnav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--ink);
    flex-direction: column; align-items: stretch; padding: .75rem 1.25rem 1.25rem; gap: .25rem;
    box-shadow: 0 16px 30px -12px rgba(0,0,0,.5);
  }
  .mainnav.is-open { display: flex; }
  .mainnav > a { border-radius: var(--r-sm); padding: .7rem .8rem; }
  .usermenu { margin: .75rem 0 0; padding-top: .9rem; border-top: 1px solid rgba(255,255,255,.12); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 2rem 1.25rem; }
  .auth-side .answer-sheet, .auth-foot { display: none; }
  .auth-side h1 { font-size: 2rem; }
}
@media (max-width: 640px) {
  body { font-size: 1rem; }
  .wrap { padding: 1.5rem 1rem 3rem; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .continue { grid-template-columns: 1fr; padding: 1.25rem; }
  .result-hero { grid-template-columns: 1fr; justify-items: start; }
  .form-grid { grid-template-columns: 1fr; }
  .qtext { padding: 1.1rem 1.1rem .25rem; font-size: 1.05rem; }
  .choices { padding: .75rem 1.1rem 1.1rem; }
  .qsheet-head { padding: .75rem 1.1rem; }
  .choice kbd { display: none; }
  .player-nav .dots { order: -1; flex-basis: 100%; }
  .player-nav > .btn { flex: 1; }
  .shortcut-hint { display: none; }
  .player-top { align-items: flex-start; }
  .course-list { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  table.data .hide-sm { display: none; }
}

/* ── Print (worksheets) ─────────────────────────────────────────────────── */
@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .no-print, .toasts, .skip-link { display: none !important; }
  .wrap { padding: 0; max-width: none; }
}

/* Correct-answer picker in the question editor: the bubble is the radio */
.pick { position: relative; cursor: pointer; flex-shrink: 0; }
.pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick:hover .bubble { border-color: var(--good); color: var(--good); }
.pick input:checked + .bubble { background: var(--good); border-color: var(--good); color: #fff; }
.pick input:focus-visible + .bubble { box-shadow: var(--focus); }

/* ── Email login (magic links) ──────────────────────────────────────────── */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.label-row label { margin-bottom: .4rem; }
.text-btn { background: none; border: 0; padding: 0; font: inherit; font-size: .9rem; font-weight: 700; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--blue-dark); }
.or { display: flex; align-items: center; gap: .9rem; margin: 1.25rem 0; color: var(--muted); font-size: .9rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.hint.center, .center { text-align: center; }
.auth-card .hint.center { margin-top: .6rem; font-size: .88rem; color: var(--muted); }
.tips { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--ink-2); }
.tips li { margin-bottom: .45rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; background: var(--ink); color: var(--pencil); margin-bottom: 1.1rem; }
/* envelope with a yellow answer-bubble seal */
.envelope { position: relative; width: 76px; height: 54px; margin-bottom: 1.4rem; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--sheet); overflow: hidden; }
.envelope::before { content: ''; position: absolute; left: 50%; top: -38px; width: 60px; height: 60px; border: 2.5px solid var(--ink); background: var(--paper); transform: translateX(-50%) rotate(45deg); }
.envelope span { position: absolute; z-index: 1; left: 50%; top: 13px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: var(--pencil); border: 2px solid var(--ink); animation: fill-in .4s cubic-bezier(.3,1.6,.5,1) .2s both; }
@media (prefers-reduced-motion: reduce) { .envelope span { animation: none; } }

/* ==========================================================================
   Quiz modal — +5 / −5 points to 100
   ========================================================================== */
html.modal-open { overflow: hidden; }
.quiz-modal {
  width: min(860px, calc(100vw - 2rem)); max-width: none; max-height: calc(100vh - 2rem);
  padding: 0; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(10, 18, 40, .6); overflow: hidden;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.quiz-modal::backdrop { background: rgba(20, 33, 61, .72); backdrop-filter: blur(3px); }
.quiz-modal[open] { animation: qm-in .28s cubic-bezier(.2,.8,.2,1); }
@keyframes qm-in { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.qm-shell { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.qm-top { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.5rem .75rem; background: var(--ink); color: #fff; border-top: 6px solid var(--course, var(--pencil)); }
.qm-titles { flex: 1; min-width: 0; }
.qm-kicker { margin: 0; font-size: .85rem; color: rgba(255,255,255,.62); }
.qm-title { margin: .1rem 0 0; font-size: 1.15rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qm-score { display: flex; align-items: baseline; gap: .3rem; flex-shrink: 0; }
.qm-points { font-family: var(--font-display); font-size: 2.1rem; font-weight: 800; color: var(--pencil); line-height: 1; display: inline-block; }
.qm-target { color: rgba(255,255,255,.6); font-size: .9rem; }
.qm-points.bump-up { animation: bump-up .5s ease-out; }
.qm-points.bump-down { animation: bump-down .5s ease-out; }
@keyframes bump-up { 30% { transform: scale(1.35); color: #5BE3A8; } }
@keyframes bump-down { 30% { transform: translateY(4px) scale(.9); color: #FF8A8A; } 60% { transform: translateX(-3px); } }
.qm-close { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff; font-size: 1rem; cursor: pointer; }
.qm-close:hover { background: rgba(255,255,255,.1); }
.qm-pencil { padding: 0 1.5rem; margin: 0; background: var(--ink); padding-bottom: 1rem; }
.qm-pencil .pencil-track { background: rgba(255,255,255,.12); }
.qm-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.qm-question { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); overflow: hidden; }
.qm-question.slide-in { animation: slide-in .32s cubic-bezier(.2,.8,.2,1); }
@keyframes slide-in { from { opacity: 0; transform: translateX(28px); } }
.qm-qmeta { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; border-bottom: 1px dashed var(--line-2); font-family: var(--font-display); font-weight: 800; }
.qm-qmeta span:last-child { font-family: var(--font-body); font-weight: 400; font-size: .86rem; color: var(--muted); }
.choice:disabled { cursor: default; }
.choice.is-correct { border-color: var(--good); background: var(--good-soft); }
.choice.is-correct .bubble { background: var(--good); border-color: var(--good); color: #fff; }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.is-wrong .bubble { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.is-dim { opacity: .5; }
.choice:disabled:hover { border-color: inherit; }
.qm-feedback { margin: 0 1.5rem 1.5rem; padding: 1rem 1.15rem; border-radius: var(--r-md); animation: fade-up .25s ease-out; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
.qm-feedback.is-correct { background: var(--good-soft); border: 1px solid #BFE3CF; color: #0D5E3E; }
.qm-feedback.is-wrong { background: #FFF7F7; border: 1px solid #F1C2C2; color: #7A1D1D; }
.qm-verdict { font-size: 1.05rem; }
.qm-badge { display: inline-block; min-width: 2.6rem; text-align: center; font-family: var(--font-display); font-weight: 800; padding: .1rem .5rem; border-radius: 999px; margin-right: .35rem; color: #fff; }
.is-correct .qm-badge { background: var(--good); }
.is-wrong .qm-badge { background: var(--bad); }
.qm-explain { margin-top: .85rem; padding-top: .85rem; border-top: 1px dashed #EDBABA; color: var(--ink); }
.qm-explain .explain-body { margin-top: .4rem; overflow-x: auto; }
.qm-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }
.qm-help { margin: 0; padding: .6rem 1.5rem .9rem; text-align: center; font-size: .82rem; color: var(--muted); }
.qm-message { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.qm-message .btn { margin-left: .5rem; }
/* centre toast */
.qm-toast {
  position: absolute; left: 50%; top: 92px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  padding: .55rem 1.1rem; border-radius: 999px; font-weight: 700; font-family: var(--font-display); font-size: 1.05rem;
  background: var(--ink); color: #fff; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); transition: opacity .2s, transform .2s; white-space: nowrap;
}
.qm-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.qm-toast.good { background: var(--good); }
.qm-toast.bad { background: var(--bad); }
/* finish */
.qm-finish { text-align: center; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); padding: 2.25rem 1.5rem; }
.qm-finish.pop { animation: qm-in .4s cubic-bezier(.3,1.4,.5,1); }
.qm-finish h2 { font-size: 2rem; margin: 1rem 0 .3rem; }
.qm-trophy { width: 108px; height: 108px; margin: 0 auto; border-radius: 50%; background: var(--pencil); border: 4px solid var(--ink); display: grid; place-items: center; box-shadow: 0 0 0 8px rgba(245,183,0,.25); }
.qm-trophy span { font-family: var(--font-display); font-weight: 800; font-size: 2rem; color: var(--ink); }
.qm-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin: 1.5rem auto; max-width: 460px; }
.qm-stats div { background: var(--sheet); padding: .85rem .5rem; display: flex; flex-direction: column; }
.qm-stats .v { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }
.qm-stats .k { font-size: .82rem; color: var(--muted); }
.qm-finish-actions { justify-content: center; }
@media (max-width: 640px) {
  .quiz-modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .qm-shell { max-height: 100dvh; height: 100%; }
  .qm-top { padding: .9rem 1rem .6rem; }
  .qm-pencil { padding: 0 1rem .85rem; }
  .qm-body { padding: 1rem; }
  .qm-qmeta { padding: .75rem 1.1rem; }
  .qm-feedback { margin: 0 1.1rem 1.1rem; }
  .qm-actions .btn { width: 100%; }
  .qm-help { display: none; }
  .qm-points { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .quiz-modal[open], .qm-question.slide-in, .qm-finish.pop, .qm-feedback { animation: none; }
}
