/* ============================================================================
   Pure A* Pathway — inner-app theme refresh
   Pushes the premium landing design language into the app pages.
   Loaded AFTER styles.css so it wins the cascade. Palette/type/cards/buttons
   are remapped to the landing system; structure stays intact.
   Palette: Biscotti var(--bg) paper · Olivewood var(--ink) ink · Tuscan var(--accent) accent
            · Slate #565D72 calm/data.  Type: Fraunces (display) + Hanken (body).
   ============================================================================ */

:root {
  --bg: #f1e6d2;
  --surface: #fbf7ef;
  --surface-soft: #f5ecda;
  --ink: #210706;
  --ink-soft: #43291e;
  --muted: #6e5a49;
  --faint: #8a7257;
  --line: #e4d8c2;
  --line-strong: #d8c6a8;
  --accent: #891d1a;
  --accent-strong: #6e1613;
  --warn: #9b6b16;
  --warn-deep: #6c4c12;
  --on-accent: #fbf2e6;
  --plate: #ffffff;
  --accent-wash: rgba(137, 29, 26, 0.07);
  --blue: #565d72;
  --blue-strong: #434a5e;
  --amber: #92671c;
  --danger: #9f2d2d;
  --soft-green: #e9e6da;
  /* --- the reward colour ------------------------------------------------
     The design system originally banned green outright. It's back, but only
     for one job: telling a student they got it RIGHT. A correct answer painted
     in the maroon accent reads as a cross — real students reported the scare.
     Deep ivy, desaturated to sit on cream without turning the page into a
     dashboard. Use ONLY for earned success; never for CTAs or chrome. */
  --good: #2f6b3f;
  --good-strong: #245231;
  --good-wash: rgba(47, 107, 63, 0.09);
  --soft-good: #e4efe4;
  --on-good: #f4faf2;
  --soft-blue: #e7eaf1;
  --soft-amber: #f4e9ce;
  --soft-red: #f3e1dc;
  --shadow: 0 1px 2px rgba(33, 7, 6, 0.05), 0 30px 64px -42px rgba(60, 20, 15, 0.34);
  --shadow-soft: 0 1px 2px rgba(33, 7, 6, 0.04), 0 14px 30px -22px rgba(60, 20, 15, 0.22);
  --radius: 16px;
}

/* ---- base ---------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg) !important;
  color: var(--ink);
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif !important;
  color: var(--ink);
  letter-spacing: -0.018em;
  font-optical-sizing: auto;
}
a { color: var(--accent); }

/* ---- top bar / nav ------------------------------------------------------- */
.topbar {
  position: sticky !important;
  top: 0;
  z-index: 40;
  background: rgba(241, 230, 210, 0.86) !important;
  border-bottom: 1px solid var(--line) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: none !important;
}
.brand strong { font-family: "Fraunces", serif !important; color: var(--ink); letter-spacing: -0.01em; }
.brand small { color: var(--muted); }
.brand-mark {
  background: #821e28 !important;
  color: var(--bg) !important;
  font-family: "Fraunces", serif !important;
  font-weight: 800;
  border-radius: 11px !important;
  box-shadow: var(--shadow-soft);
}
/* nav links match the landing: plain text, no border/background, turn Tuscan on hover */
.topnav a:not(.primary-button),
.topnav .ghost-button {
  color: var(--ink-soft) !important;
  font-weight: 600;
  border: none !important;
  background: transparent !important;
  border-radius: 8px !important;
  padding: 8px 10px !important;
  transition: color 0.2s ease;
}
.topnav a:not(.primary-button):hover,
.topnav .ghost-button:hover {
  color: var(--accent) !important;
}

/* ---- buttons ------------------------------------------------------------- */
.primary-button,
.topnav .primary-button {
  background: var(--accent) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 12px !important;
  font-family: "Fraunces", serif !important;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 12px 26px -14px rgba(137, 29, 26, 0.5);
  transition: transform 0.2s cubic-bezier(0.22, 0.7, 0.3, 1), box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}
/* landing-grade CTA: specular sheen sweep + arrow nudge */
.primary-button::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -135%; width: 55%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-16deg);
  pointer-events: none;
}
.primary-button:hover::after { left: 135%; transition: left 0.9s cubic-bezier(0.22, 0.7, 0.3, 1); }
.primary-button .btn-arrow { display: inline-block; transition: transform 0.2s cubic-bezier(0.22, 0.7, 0.3, 1); }
.primary-button:hover .btn-arrow { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) { .primary-button::after { display: none; } }
.primary-button:hover,
.topnav .primary-button:hover {
  background: var(--accent-strong) !important;
  transform: translateY(-1.5px);
  box-shadow: 0 18px 36px -16px rgba(137, 29, 26, 0.5);
}
.primary-button:active { transform: translateY(0) scale(0.99); }
.secondary-button {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 12px !important;
  font-family: "Fraunces", serif !important;
  font-weight: 600;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.secondary-button:hover { border-color: rgba(33, 7, 6, 0.25) !important; background: #f3ead9 !important; transform: translateY(-1px); }
.ghost-button {
  color: var(--ink-soft) !important;
  border: 1px solid var(--line) !important;
  background: transparent !important;
  border-radius: 10px !important;
  font-weight: 600;
}
.ghost-button:hover { color: var(--accent) !important; border-color: var(--line-strong) !important; }

/* ---- surfaces: panels, cards, tiles -------------------------------------- */
.panel,
.card,
.feedback-item,
.summary-card,
.metric-grid > div,
.upload {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.feedback-item { box-shadow: var(--shadow-soft); }
.feedback-item strong { font-family: "Fraunces", serif; color: var(--ink); }

/* ---- page header + eyebrow ---------------------------------------------- */
.page-header h1 { font-size: clamp(2rem, 1.45rem + 2.3vw, 3.1rem); line-height: 1.05; }
.page-header p { color: var(--muted); }
.eyebrow {
  color: var(--accent) !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
}

/* ---- metric grid (Time / Marks / Questions / Style) --------------------- */
.metric-grid > div { padding: 18px 20px; }
.metric-grid dt { color: var(--muted) !important; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 700; }
.metric-grid dd { font-family: "Fraunces", serif !important; color: var(--ink) !important; font-weight: 700; }

/* ---- forms -------------------------------------------------------------- */
input, textarea, select {
  background: var(--surface) !important;
  border: 1px solid var(--line-strong) !important;
  color: var(--ink) !important;
  border-radius: 10px !important;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(137, 29, 26, 0.5) !important;
  outline-offset: 1px;
  border-color: var(--accent) !important;
}

/* ---- pills / badges / chips that used the green/blue tokens -------------- */
.badge { font-family: "Hanken Grotesk", sans-serif; }

/* ---- loading screen ----------------------------------------------------- */
.loading-screen h1 { font-family: "Fraunces", serif; }
.loading-screen p { color: var(--muted); }

/* ---- confirmation + marking-in-progress state --------------------------- */
.marking-status {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}
.marking-status-copy strong { font-family: "Fraunces", serif; font-size: 1.05rem; color: var(--ink); display: block; }
.marking-status-copy p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.marking-spinner {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: pa-spin 0.8s linear infinite;
}
@keyframes pa-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .marking-spinner { animation-duration: 1.8s; } }
.marking-status.is-done { align-items: center; justify-content: space-between; }
.marking-result .eyebrow { display: block; }
.marking-score { font-family: "Fraunces", serif; font-weight: 800; color: var(--ink); margin: 0.1rem 0 0; line-height: 1; font-size: 2rem; }
.marking-score strong { color: var(--accent); }
.marking-score span { color: var(--faint); font-size: 1.1rem; font-weight: 600; margin-left: 2px; }

/* ---- attempt sidebar: timer + nav + script panels ----------------------- */
.timer-panel {
  background: var(--ink) !important;
  border: 1px solid rgba(33, 7, 6, 0.4) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow) !important;
}
.timer-panel .eyebrow { color: rgba(241, 230, 210, 0.62) !important; }
.timer-panel strong { color: #fff !important; font-family: "Fraunces", serif !important; letter-spacing: -0.01em; }
.timer-panel span, .timer-panel small { color: rgba(241, 230, 210, 0.72) !important; }
.nav-panel, .script-panel { border-radius: 14px !important; }
.diagnostic-jump-list a {
  border-radius: 9px !important;
  font-family: "Fraunces", serif !important;
  font-weight: 700;
}
.diagnostic-jump-list a:hover { border-color: var(--accent) !important; color: var(--accent) !important; }

/* ---- paper attempt page: full-width header, aligned cols, sticky tools --- */
.diagnostic-paper-shell { align-items: start !important; gap: clamp(1.25rem, 2.4vw, 2.4rem) !important; padding-top: clamp(1.5rem, 3vh, 2.5rem) !important; }
.diagnostic-paper-head { grid-column: 1 / -1; margin-bottom: 0.25rem; }
.diagnostic-paper-sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px;
}
.diagnostic-paper-sidebar::-webkit-scrollbar { width: 6px; }
.diagnostic-paper-sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
@media (max-width: 900px) {
  .diagnostic-paper-sidebar { position: static; max-height: none; overflow: visible; }
}

/* ---- paper attempt page: exam-sheet craft ------------------------------- */
.diagnostic-paper-head h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem); line-height: 1.08; margin: 0.45rem 0 0; }
.diagnostic-paper-head p { color: var(--muted); max-width: 44rem; }
/* the questions sit on one cream "paper sheet" */
.diagnostic-paper-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 2.6vw, 44px) !important;
}
.diagnostic-question-card { padding: 1.7rem 0 !important; border-bottom: 1px solid var(--line) !important; margin: 0 !important; }
.diagnostic-paper-surface .diagnostic-question-card:first-child { padding-top: 0 !important; }
.diagnostic-paper-surface .diagnostic-question-card:last-child { padding-bottom: 0 !important; border-bottom: 0 !important; }
.part-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.diagnostic-question-card h2 { font-family: "Fraunces", serif !important; font-size: 1.22rem !important; font-weight: 700 !important; color: var(--ink) !important; margin: 0 !important; }
.diagnostic-question-actions { display: flex; align-items: center; gap: 0.6rem; }
.marks-pill {
  background: var(--soft-blue) !important; color: var(--blue-strong) !important;
  border: 1px solid rgba(86, 93, 114, 0.22) !important; border-radius: 999px !important;
  font-size: 11.5px !important; font-weight: 700 !important; padding: 4px 11px !important;
  letter-spacing: 0;
}
.flag-button {
  background: transparent !important; border: 1px solid var(--line-strong) !important;
  color: var(--muted) !important; border-radius: 999px !important;
  font-size: 12px !important; font-weight: 600 !important; padding: 5px 13px !important;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.flag-button:hover { border-color: var(--accent) !important; color: var(--accent) !important; }
.flag-button.active { background: var(--accent-wash) !important; border-color: rgba(137, 29, 26, 0.32) !important; color: var(--accent) !important; }
.question-text, .root-question {
  font-size: 1.07rem !important; line-height: 1.75 !important; color: var(--ink-soft) !important;
  white-space: pre-line;
}
.root-question { color: var(--ink) !important; font-weight: 500; margin-bottom: 0.5rem !important; }
.submit-button {
  background: var(--accent) !important; color: #fff !important; border: none !important;
  border-radius: 12px !important; font-family: "Fraunces", serif !important; font-weight: 600 !important;
  box-shadow: 0 12px 26px -14px rgba(137, 29, 26, 0.5);
  position: relative; overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.22, 0.7, 0.3, 1), box-shadow 0.2s ease, background 0.2s ease;
}
.submit-button:hover { background: var(--accent-strong) !important; transform: translateY(-1.5px); }
.success-box { background: var(--soft-blue) !important; border: 1px solid rgba(86, 93, 114, 0.25) !important; color: var(--ink) !important; border-radius: 12px !important; }

/* sidebar panel headings stack cleanly (no awkward wrap) */
.diagnostic-paper-sidebar .section-heading.compact { display: flex !important; flex-direction: column !important; align-items: flex-start !important; gap: 2px !important; }
.diagnostic-paper-sidebar .section-heading.compact h2 { font-family: "Fraunces", serif !important; font-size: 1.18rem !important; margin: 0 !important; }
.diagnostic-paper-sidebar .section-heading.compact span { color: var(--muted) !important; font-size: 12.5px !important; }

/* custom upload dropzone (replaces the raw OS file button) */
.upload-dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  text-align: center; margin-top: 12px; padding: 24px 16px;
  border: 1.5px dashed var(--line-strong); border-radius: 14px;
  background: var(--surface-soft); cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.upload-dropzone:hover { border-color: var(--accent); background: var(--accent-wash); }
.upload-dropzone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.upload-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-dropzone-icon { color: var(--accent); display: inline-flex; }
.upload-dropzone-title { font-family: "Fraunces", serif; font-weight: 700; color: var(--ink); font-size: 1.02rem; }
.upload-dropzone-hint { font-size: 11.5px; color: var(--faint); }
.script-panel .small-note { margin-top: 10px; }

/* uploaded pages list */
.script-upload-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.script-upload-list li { display: flex; flex-direction: column; gap: 1px; padding: 8px 11px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; }
.script-upload-list a { font-weight: 600; color: var(--ink) !important; font-size: 13px; text-decoration: none; }
.script-upload-list a:hover { color: var(--accent) !important; }
.script-upload-list span { font-size: 11px; color: var(--faint); }

@media (max-width: 900px) {
  .diagnostic-paper-surface { padding: 18px !important; }
  .diagnostic-question-card h2 { font-size: 1.1rem !important; }
  .question-text, .root-question { font-size: 1rem !important; }
}

/* ---- notices / warnings / pills / notes --------------------------------- */
.notice-box { background: var(--soft-blue); border: 1px solid rgba(86, 93, 114, 0.25); color: var(--ink); border-radius: 12px; }
.warning-box { background: var(--soft-red); border: 1px solid rgba(159, 45, 45, 0.28); color: var(--ink); border-radius: 12px; }
.status-pill { background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; }
.small-note { color: var(--faint); }

/* ---- diagnostic intro: editorial composition, fills the viewport, no scroll */
.diag-intro {
  box-sizing: border-box;
  min-height: calc(100dvh - 78px); /* viewport minus the top bar */
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: clamp(24px, 3vh, 56px) clamp(24px, 5vw, 80px);
}
/* Year 11 "coming from GCSE" taught-first variant: no paper is sat, so the
   screen warms the WHOLE page background to a calmer "lesson" surface. The
   backdrop is a fixed pseudo behind the content (z-index:-1), so it vanishes
   the instant the screen unmounts — no body class to leak onto other routes. */
.diag-intro.is-y11::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(115% 80% at 12% -5%, rgba(137, 29, 26, 0.10), transparent 58%),
    linear-gradient(180deg, #f7eedd 0%, var(--bg) 52%, #efe2cc 100%);
}
.diag-intro.is-y11 .diag-spec li b { color: var(--accent); }
.diag-intro-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1.08fr 0.9fr;
  gap: clamp(44px, 6vw, 104px);
  align-items: center;
}
.diag-pitch { max-width: 37rem; }
.diag-pitch .eyebrow { margin: 0; font-size: 12px; }
.diag-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(2.7rem, 1.6rem + 3.4vw, 4.5rem);
  line-height: 1.0;
  letter-spacing: -0.022em;
  margin: 0.7rem 0 0;
  color: var(--ink);
}
.diag-sub {
  margin: 1.3rem 0 0;
  max-width: 33rem;
  font-size: clamp(1.05rem, 0.98rem + 0.4vw, 1.32rem);
  line-height: 1.55;
  color: var(--ink-soft);
}
.diag-spec { display: flex; flex-wrap: wrap; gap: 0.5rem 0; margin: 2.1rem 0 0; padding: 0; list-style: none; }
.diag-spec li {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 1.4rem; border-left: 1px solid var(--line-strong);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; color: var(--muted);
}
.diag-spec li:first-child { padding-left: 0; border-left: 0; }
.diag-spec li b {
  font-family: "Fraunces", serif; font-weight: 700; font-size: 2.1rem; line-height: 1;
  color: var(--ink); text-transform: none; letter-spacing: -0.01em; margin-bottom: 5px;
}
.diag-actions { display: flex; align-items: center; gap: 1.5rem; margin: 2.5rem 0 0; }
.diag-actions .primary-button { padding: 16px 36px !important; font-size: 1.05rem !important; }
.diag-back { color: var(--muted); font-weight: 600; font-size: 1rem; }
.diag-back:hover { color: var(--accent); }
.diag-microcopy { margin: 1.1rem 0 0; font-size: 13px; color: var(--faint); }
.diag-pitch .form-message { margin-top: 0.6rem; }

.diag-steps { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(26px, 2.6vw, 40px); }
.diag-steps-kicker { margin: 0 0 1.6rem; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.diag-steps ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.65rem; }
.diag-step { display: flex; gap: 1.1rem; align-items: flex-start; }
.diag-step-n {
  flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-family: "Fraunces", serif; font-weight: 800; font-size: 1.25rem;
  background: var(--accent-wash); color: var(--accent); border: 1px solid rgba(137, 29, 26, 0.16);
}
.diag-step strong { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.18rem; color: var(--ink); display: block; }
.diag-step p { margin: 0.3rem 0 0; font-size: 1rem; line-height: 1.5; color: var(--muted); }
.diag-covers { margin: 1.7rem 0 0; padding-top: 1.4rem; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.55; color: var(--faint); }

@media (max-width: 760px) {
  .diag-intro { min-height: calc(100dvh - 72px); align-items: flex-start; padding: 12px 18px 16px; }
  .diag-intro-grid { grid-template-columns: 1fr; gap: 14px; align-items: stretch; }
  .diag-pitch { max-width: none; }
  .diag-title { font-size: clamp(1.8rem, 1.3rem + 3vw, 2.3rem); margin-top: 0.35rem; line-height: 1.04; }
  .diag-sub { margin-top: 0.7rem; font-size: 0.92rem; line-height: 1.42; }
  .diag-spec { margin-top: 0.95rem; }
  .diag-spec li { padding: 0 0.9rem; }
  .diag-spec li b { font-size: 1.25rem; }
  .diag-actions { margin-top: 1.1rem; gap: 1rem; }
  .diag-actions .primary-button { padding: 12px 24px !important; }
  .diag-microcopy { margin-top: 0.55rem; font-size: 12px; }
  .diag-pitch .form-message { margin-top: 0.4rem; }
  .diag-steps { padding: 14px; border-radius: 14px; }
  .diag-steps-kicker { margin-bottom: 0.7rem; }
  .diag-steps ol { gap: 0.6rem; }
  .diag-step { gap: 0.75rem; }
  .diag-step-n { width: 28px; height: 28px; font-size: 0.9rem; border-radius: 9px; }
  .diag-step strong { font-size: 0.95rem; }
  .diag-step p { font-size: 0.83rem; line-height: 1.32; margin-top: 0.15rem; }
  .diag-covers { display: none; }
}

/* ===== Focused exam mode (paper attempt), rebuilt from scratch =========== */
.exam-bar { position: sticky; top: 0; z-index: 50; background: rgba(241, 230, 210, 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.exam-bar-inner { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 0 clamp(16px, 4vw, 36px); height: 62px; }
.exam-brand { display: inline-flex; align-items: center; gap: 0.6rem; justify-self: start; }
.exam-brand .brand-mark { width: 34px; height: 34px; display: grid; place-items: center; font-size: 15px; }
.exam-brand-name { font-family: "Fraunces", serif; font-weight: 700; font-size: 1rem; color: var(--ink); }
.exam-clock { justify-self: center; display: inline-flex; align-items: baseline; gap: 0.55rem; }
.exam-clock-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em; color: var(--faint); }
.exam-clock [data-time-remaining] { font-family: "Fraunces", serif; font-weight: 800; font-size: 1.5rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.exam-bar-cta { justify-self: end; font-family: "Fraunces", serif; font-weight: 600; font-size: 0.95rem; color: var(--accent); }
.exam-bar-cta:hover { color: var(--accent-strong); }
.exam-bar-progress { height: 2px; background: rgba(33, 7, 6, 0.08); }
.exam-bar-progress span { display: block; height: 100%; width: 100%; background: var(--accent); transition: width 1s linear; }
.exam-expired { background: var(--soft-red); color: var(--accent-strong); text-align: center; font-size: 12.5px; font-weight: 600; padding: 7px 16px; }

.exam-bar-meta { justify-self: end; font-size: 12px; font-weight: 600; color: var(--muted); }
/* whole page fits one viewport — no scroll; content distributes to fill the height */
.exam-page { max-width: 1240px; margin: 0 auto; min-height: calc(100dvh - 68px); display: flex; flex-direction: column; box-sizing: border-box; padding: clamp(16px, 2.4vh, 30px) clamp(20px, 5vw, 44px) clamp(16px, 2.4vh, 28px); }
.exam-head { flex: 0 0 auto; margin-bottom: clamp(14px, 2vh, 24px); max-width: 46rem; }
.exam-head .eyebrow { margin: 0; }
.exam-head h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(1.7rem, 1.3rem + 1.3vw, 2.3rem); line-height: 1.02; letter-spacing: -0.02em; margin: 0.4rem 0 0; color: var(--ink); }
.exam-head p { color: var(--muted); margin: 0.55rem 0 0; font-size: 1rem; line-height: 1.5; max-width: 40rem; }

/* two columns fill the remaining height: paper (left) + hand-in panel (right) */
.exam-cols { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: clamp(1.25rem, 2.5vw, 2.25rem); align-items: stretch; }
.exam-aside { min-height: 0; }
.exam-aside-card { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(20px, 2vw, 28px); }
.exam-aside-card .eyebrow { margin: 0; }
.exam-aside-card h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.4rem; margin: 0.35rem 0 0; color: var(--ink); }
.exam-aside-sub { color: var(--muted); margin: 0.55rem 0 0; font-size: 0.95rem; line-height: 1.5; }
.exam-aside-card .script-upload-list { margin-top: 0.8rem; }
.exam-aside-card .form-message { text-align: center; margin: 0.5rem 0 0; }

.exam-sheet { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(6px, 1vh, 16px) clamp(20px, 4vw, 46px); overflow: hidden; }
.qx { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; column-gap: 1.2rem; align-content: center; align-items: start; padding: clamp(10px, 1.4vh, 20px) 0; border-bottom: 1px solid var(--line); }
.qx:last-child { border-bottom: 0; }
.qx-num { grid-column: 1; font-family: "Fraunces", serif; font-weight: 800; font-size: 1.5rem; line-height: 1.1; color: var(--accent); }
.qx-body { grid-column: 2; min-width: 0; }
.qx-text, .qx-root { font-size: 1.12rem; line-height: 1.7; color: var(--ink); white-space: pre-line; }
.qx-root { font-weight: 500; margin-bottom: 0.45rem; }
.qx-marks { grid-column: 3; text-align: right; white-space: nowrap; padding-top: 0.2rem; }
.qx-marks b { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.05rem; color: var(--ink); display: block; line-height: 1; }
.qx-marks span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.qx .diagram-panel { margin-top: 1rem; }
.qx .diagram-panel img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }

.exam-dropzone { flex: 1 1 auto; min-height: 130px; margin: 1.1rem 0 0 !important; padding: 22px 18px !important; }
.exam-submit { width: 100%; justify-content: center; margin-top: 1rem; padding: 14px 24px !important; font-size: 1rem !important; }
.exam-submit:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.exam-submit:disabled::after { display: none; }
.exam-submit-note { font-size: 12px; color: var(--faint); text-align: center; margin: 0.6rem 0 0; }

/* uploaded pages: full-width previews you can view + remove */
.exam-uploads { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 1rem 0 0; display: flex; flex-direction: column; gap: 0.8rem; padding-right: 4px; }
.exam-upload { position: relative; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-soft); }
.exam-upload-view { display: block; }
.exam-upload-view img { display: block; width: 100%; height: auto; max-height: 440px; object-fit: contain; background: #fff; }
.exam-upload-pdf { display: flex; align-items: center; gap: 0.5rem; padding: 16px 14px; font-weight: 600; color: var(--ink); font-size: 13px; text-decoration: none; }
.exam-upload-remove { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(33, 7, 6, 0.62); color: #fff; font-size: 19px; line-height: 1; cursor: pointer; display: grid; place-items: center; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: background 0.15s ease; }
.exam-upload-remove:hover { background: var(--accent); }
.exam-upload figcaption { padding: 7px 12px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); background: var(--surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-dropzone-mini { flex: 0 0 auto; margin: 0.8rem 0 0 !important; padding: 12px !important; min-height: 0 !important; }
.exam-dropzone-mini .upload-dropzone-title { font-size: 0.9rem; color: var(--accent); }

/* large screens: scale the whole composition up so it fills the width */
@media (min-width: 1600px) {
  .exam-bar-inner { max-width: 1560px; }
  .exam-page { max-width: 1560px; }
  .exam-cols { grid-template-columns: minmax(0, 1fr) 400px; gap: 2.5rem; }
  .exam-head h1 { font-size: 2.5rem; }
  .exam-head p { font-size: 1.1rem; }
  .qx-num { font-size: 1.75rem; }
  .qx-text, .qx-root { font-size: 1.22rem; line-height: 1.66; }
  .qx-marks b { font-size: 1.15rem; }
  .exam-aside-card h2 { font-size: 1.55rem; }
}
@media (min-width: 2000px) {
  .exam-bar-inner { max-width: 1880px; }
  .exam-page { max-width: 1880px; }
  .exam-cols { grid-template-columns: minmax(0, 1fr) 460px; gap: 3rem; }
  .exam-head h1 { font-size: 2.9rem; }
  .exam-head p { font-size: 1.22rem; }
  .qx-num { font-size: 2rem; }
  .qx-text, .qx-root { font-size: 1.36rem; line-height: 1.62; }
  .qx-marks b { font-size: 1.25rem; }
  .exam-clock [data-time-remaining] { font-size: 1.7rem; }
  .exam-aside-card h2 { font-size: 1.7rem; }
  .exam-upload-view img { max-height: 520px; }
}

/* stack to one column + natural scrolling height on narrower screens */
@media (max-width: 880px) {
  .exam-page { min-height: 0; display: block; padding-bottom: 56px; }
  .exam-cols { display: block; }
  .exam-aside { margin-top: 1.4rem; }
  .exam-sheet { height: auto; display: block; overflow: visible; padding: 0 clamp(18px, 4vw, 30px); }
  .qx { flex: none; align-content: start; padding: clamp(20px, 4vw, 28px) 0; }
  .exam-aside-card { height: auto; }
  .exam-dropzone { flex: none; min-height: 0; padding: 26px 18px !important; }
}

@media (max-width: 560px) {
  .exam-bar-inner { grid-template-columns: auto 1fr; gap: 0.7rem; padding: 0 14px; height: 56px; }
  .exam-brand-name { display: none; }
  .exam-clock-label { display: none; }
  .exam-clock { justify-self: end; }
  .exam-clock [data-time-remaining] { font-size: 1.3rem; }
  .exam-bar-meta { display: none; }
  .exam-sheet { padding: 0 18px; }
  .qx { grid-template-columns: 1.9rem minmax(0, 1fr); column-gap: 0.9rem; padding: 22px 0; }
  .qx-num { font-size: 1.3rem; }
  .qx-text, .qx-root { font-size: 1.05rem; }
  .qx-marks { grid-column: 2; grid-row: 2; text-align: left; justify-self: start; margin-top: 0.7rem; display: inline-flex; align-items: baseline; gap: 0.3rem; padding-top: 0; }
  .qx-marks b, .qx-marks span { display: inline; }
}

/* ===== Marking-in-progress (post-submit anticipation) =================== */
.mark-wait { max-width: 600px; margin: 0 auto; min-height: calc(100dvh - 68px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: clamp(32px, 6vh, 72px) 24px; }
.mark-wait .eyebrow { margin: 0; }
.mark-live { display: inline-flex; align-items: center; gap: 0.5rem; }
.mark-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: mark-pulse 1.4s ease-in-out infinite; }
@keyframes mark-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
.mark-wait h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(2.1rem, 1.6rem + 1.8vw, 3rem); line-height: 1.04; letter-spacing: -0.02em; margin: 0.6rem 0 0; color: var(--ink); }
.mark-ring { position: relative; width: clamp(184px, 22vw, 232px); aspect-ratio: 1; margin: clamp(30px, 5vh, 52px) 0 clamp(26px, 4vh, 42px); display: grid; place-items: center; }
.mark-ring svg { width: 100%; height: 100%; display: block; }
.mark-ring-track { stroke: var(--line); stroke-width: 5; }
.mark-ring-fill { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 553; stroke-dashoffset: 553; transform: rotate(-90deg); transform-origin: 50% 50%; animation: mark-ring-fill 45s cubic-bezier(0.16, 0.6, 0.28, 1) forwards; }
@keyframes mark-ring-fill { to { stroke-dashoffset: 66; } }
.mark-ring-mark { position: absolute; width: 30%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; white-space: nowrap; line-height: 1; background: var(--ink); color: var(--bg); border-radius: 28%; font-family: "Fraunces", serif; font-weight: 800; font-size: clamp(1.4rem, 3vw, 1.95rem); box-shadow: var(--shadow-soft); animation: mark-breathe 2.8s ease-in-out infinite; }
.mark-ring-mark .star-sup { font-size: 0.62em; }
@keyframes mark-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
.mark-phase { font-family: "Fraunces", serif; font-weight: 500; font-size: 1.18rem; color: var(--ink); margin: 0; min-height: 1.5em; transition: opacity 0.3s ease; }
.mark-note { color: var(--muted); font-size: 0.95rem; line-height: 1.55; margin: 1rem 0 0; max-width: 30rem; }
.mark-wait .form-message { margin-top: 0.8rem; }

.mark-result { max-width: 640px; margin: 0 auto; min-height: calc(100dvh - 68px); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: clamp(32px, 6vh, 72px) clamp(20px, 5vw, 32px); }
.mark-result .eyebrow { margin: 0; }
.mark-result h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(2.2rem, 1.6rem + 2vw, 3.2rem); line-height: 1.04; letter-spacing: -0.02em; margin: 0.5rem 0 0; color: var(--ink); }
.mark-result-score { color: var(--accent); white-space: nowrap; }
.mark-result-sub { color: var(--muted); font-size: 1.1rem; line-height: 1.6; margin: 1rem 0 0; max-width: 30rem; }
.mark-result-cta { margin-top: 1.6rem; padding: 15px 32px !important; font-size: 1.05rem !important; }

@media (prefers-reduced-motion: reduce) {
  .mark-ring-fill { animation: none; stroke-dashoffset: 210; }
  .mark-ring-mark, .mark-live::before { animation: none; }
  .mark-phase { transition: none; }
}
@media (max-width: 820px) {
  .mark-wait { min-height: calc(100dvh - 60px); padding: 28px 22px; }
  .mark-wait h1 { font-size: clamp(2rem, 1.5rem + 3vw, 2.5rem); }
  .mark-phase { font-size: 1.08rem; }
}

/* ===== Marked results — satisfaction tick, then push to the repair ======= */
.marked { max-width: 880px; margin: 0 auto; min-height: calc(100dvh - 68px); display: flex; flex-direction: column; justify-content: center; gap: clamp(24px, 4vh, 40px); padding: clamp(32px, 6vh, 72px) clamp(20px, 5vw, 40px); }
.marked-head .eyebrow { margin: 0; }
.marked-score { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(3rem, 2rem + 4vw, 5rem); line-height: 1; letter-spacing: -0.025em; margin: 0.4rem 0 0; color: var(--ink); display: flex; align-items: baseline; gap: 0.35rem; }
.marked-score i { font-style: normal; font-size: 0.46em; font-weight: 600; color: var(--faint); }
.marked-sub { color: var(--muted); font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem); line-height: 1.55; margin: 1rem 0 0; max-width: 38rem; }

.marked-repair { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: clamp(26px, 3.5vw, 46px); }
.marked-repair::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
.marked-repair .eyebrow { margin: 0; }
.marked-repair h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.3rem); line-height: 1.05; letter-spacing: -0.015em; margin: 0.5rem 0 0; color: var(--ink); }
.marked-repair-why { color: var(--ink-soft); font-size: 1.08rem; line-height: 1.6; margin: 0.9rem 0 0; max-width: 42rem; }
.marked-repair-stats { display: flex; flex-wrap: wrap; gap: 0.6rem 0; margin: 1.6rem 0 0; }
.marked-repair-stats > div { display: flex; flex-direction: column; padding: 0 1.5rem; border-left: 1px solid var(--line-strong); }
.marked-repair-stats > div:first-child { padding-left: 0; border-left: 0; }
.marked-repair-stats b { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.75rem; line-height: 1; color: var(--ink); }
.marked-repair-stats b.is-free { color: var(--accent); }
.marked-repair-stats span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin-top: 6px; }
.marked-actions { display: flex; align-items: center; gap: 1.5rem; margin: 1.9rem 0 0; flex-wrap: wrap; }
.marked-cta { padding: 16px 38px !important; font-size: 1.1rem !important; }
.marked-viewscript { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.marked-viewscript:hover { color: var(--accent); }
.marked-guestnote { color: var(--faint); font-size: 12.5px; margin: 1.1rem 0 0; }
@media (min-width: 1600px) {
  .marked { max-width: 1000px; }
  .marked-score { font-size: clamp(4rem, 2rem + 4vw, 5.5rem); }
}
@media (max-width: 620px) {
  .marked { min-height: calc(100dvh - 60px); justify-content: flex-start; padding-top: 40px; }
  .marked-repair-stats { gap: 0.9rem 1.8rem; }
  .marked-repair-stats > div { padding: 0 !important; border-left: 0 !important; }
  .marked-repair-stats b { font-size: 1.5rem; }
  .marked-actions { gap: 1rem; }
  .marked-cta { width: 100%; justify-content: center; }
}

/* ===== Marked results v2 — the returned-paper flip-through =============== */
.mkd { max-width: 880px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px) clamp(64px, 10vh, 120px); }
.mkd-verdict { min-height: calc(100dvh - 68px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 350px); gap: clamp(2rem, 6vw, 6rem); align-items: center; padding: clamp(28px, 5vh, 56px) 0; }
.mkd-verdict-left { min-width: 0; }
.mkd-verdict .eyebrow { margin: 0; }
/* the front-cover scorecard — curiosity hit at a glance */
.mkd-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: clamp(20px, 2vw, 28px); }
.mkd-card-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 0.5rem; }
.mkd-card-rows { list-style: none; margin: 0; padding: 0; }
.mkd-card-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.66rem 0; border-bottom: 1px solid var(--line); }
.mkd-card-row:last-child { border-bottom: 0; }
.mkd-card-q { font-family: "Fraunces", serif; font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.mkd-card-mk { display: inline-flex; align-items: center; gap: 0.55rem; }
.mkd-card-s { font-family: "Fraunces", serif; color: var(--muted); font-size: 0.9rem; }
.mkd-card-s b { font-size: 1.15rem; color: var(--ink); }
.mkd-card-row.is-zero .mkd-card-s b { color: var(--accent); }
.mkd-tick, .mkd-cross { flex: none; }
.mkd-tick { width: 22px; height: 16px; }
.mkd-cross { width: 17px; height: 17px; }
.mkd-tick path, .mkd-cross path { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mkd-card-cue { display: inline-block; margin-top: 1rem; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.mkd-card-cue:hover { color: var(--accent-strong); }
#mkd-paper { scroll-margin-top: 80px; }
@media (max-width: 820px) {
  .mkd-verdict { grid-template-columns: 1fr; gap: clamp(1.6rem, 4vh, 2.6rem); min-height: 0; padding: clamp(32px, 8vh, 64px) 0 clamp(20px, 4vh, 36px); }
  .mkd-card { max-width: 26rem; }
}
.mkd-score { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(3.4rem, 2rem + 6vw, 6rem); line-height: 1; letter-spacing: -0.03em; margin: 0.4rem 0 0; display: flex; align-items: baseline; gap: 0.35rem; color: var(--ink); }
.mkd-score i { font-style: normal; font-size: 0.38em; font-weight: 600; color: var(--faint); }
.mkd-real { font-family: "Fraunces", serif; font-weight: 500; font-size: clamp(1.3rem, 1rem + 1vw, 1.75rem); line-height: 1.28; letter-spacing: -0.01em; margin: 1.2rem 0 0; max-width: 28rem; color: var(--ink); }
.mkd-aside { color: var(--muted); font-size: 1rem; line-height: 1.62; margin: 1.4rem 0 0; max-width: 34rem; }
.mkd-aside b { color: var(--accent); font-weight: 600; }
.mkd-cue { display: inline-block; color: var(--accent); font-weight: 700; animation: mkd-bob 1.8s ease-in-out infinite; }
@keyframes mkd-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

.mkd-paper { margin-top: clamp(8px, 2vh, 24px); }
.mkd-paper-kicker { margin: 0 0 0.9rem; }
.mkd-qs { list-style: none; margin: 0; padding: 0 clamp(18px, 3vw, 38px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.mk-q { display: grid; grid-template-columns: 1.8rem minmax(0, 1fr) auto; column-gap: clamp(0.8rem, 2vw, 1.4rem); align-items: start; padding: clamp(18px, 2.6vw, 28px) 0; border-bottom: 1px solid var(--line); }
.mk-q:last-child { border-bottom: 0; }
.mk-q-label { font-family: "Fraunces", serif; font-weight: 800; font-size: 1.15rem; color: var(--ink); line-height: 1.4; }
.mk-q-text { font-size: 1.02rem; line-height: 1.6; color: var(--ink); margin: 0; white-space: pre-line; }
.mk-q-note { font-family: "Fraunces", serif; font-style: italic; font-size: 0.96rem; line-height: 1.45; color: var(--accent); margin: 0.55rem 0 0; opacity: 0; transform: translateY(5px); transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s; }
.is-revealed .mk-q-note { opacity: 0.9; transform: none; }
.mk-q-mark { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; min-width: 3.4rem; }
.mk-ink { width: 34px; height: 26px; flex: none; }
.mk-ink.is-cross { width: 26px; height: 26px; }
.mk-ink path { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.is-revealed .mk-ink path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.6s cubic-bezier(0.6, 0, 0.3, 1) 0.1s; }
.is-revealed .mk-ink path:nth-child(2) { transition-delay: 0.34s; }
.mk-q-score { font-family: "Fraunces", serif; font-weight: 600; font-size: 1rem; color: var(--muted); white-space: nowrap; opacity: 0; transition: opacity 0.4s ease 0.35s; }
.is-revealed .mk-q-score { opacity: 1; }
.mk-q-score b { font-size: 1.3rem; color: var(--ink); }
.mk-zero .mk-q-score b { color: var(--accent); }
.mkd-viewscript { display: inline-block; margin-top: 1.1rem; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.mkd-viewscript:hover { color: var(--accent); }
.mkd .marked-repair { margin-top: clamp(40px, 7vh, 80px); }

@media (prefers-reduced-motion: reduce) {
  .mkd-cue { animation: none; }
  .is-revealed .mk-ink path, .is-revealed .mk-q-note, .is-revealed .mk-q-score { transition: none; }
}
@media (max-width: 620px) {
  .mkd-verdict { min-height: calc(100dvh - 60px); }
  .mk-q { grid-template-columns: 1.5rem minmax(0, 1fr) auto; column-gap: 0.8rem; }
  .mk-q-text { font-size: 0.98rem; }
  .mk-q-mark { min-width: 2.8rem; }
}

/* ---- mobile: keep the top bar tidy, denser metric grid ------------------ */
@media (max-width: 640px) {
  .brand small { display: none; }
  .topnav { gap: 8px; }
  .topnav a:not(.primary-button) { display: none; } /* hide 'Landing' text link; brand still links home */
  .topnav .primary-button { padding: 8px 14px; }
  .topnav .ghost-button { padding: 8px 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr !important; }
  .page-header h1 { font-size: clamp(1.5rem, 1.1rem + 3vw, 2rem); }
}

/* ---- board + year micro-onboarding (diagnostic intro + account) ----------
   Two compact segmented pickers in the Marked Script language: cream paper,
   ink text, the one Tuscan-red accent for the selected state. Buttons (not
   radios) with aria-pressed — fully keyboard accessible, AA contrast. */
.diag-setup { margin: 2rem 0 0; }
.study-loading { margin: 0; font-size: 13px; color: var(--faint); }
.study-fields { display: flex; flex-direction: column; gap: 0.85rem; }
.study-field { display: flex; flex-direction: column; gap: 0.45rem; }
.study-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted);
}
.study-seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.study-opt {
  appearance: none; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  padding: 8px 16px; font: inherit; font-size: 0.95rem; font-weight: 600;
  line-height: 1.15; min-height: 44px;
  transition: border-color 150ms ease-out, background-color 150ms ease-out, transform 150ms ease-out;
}
.study-opt small {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase;
}
.study-opt:hover { border-color: var(--accent); }
.study-opt:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.study-opt.is-on {
  background: var(--accent-wash); border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.study-opt.is-on small { color: var(--accent-strong); }
.study-note {
  margin: 0.15rem 0 0; max-width: 33rem;
  font-size: 13px; line-height: 1.5; color: var(--muted);
}
.study-note b { color: var(--ink); }
.study-nudge { margin: 0.9rem 0 0; font-size: 13.5px; font-weight: 600; color: var(--accent-strong); }
.study-nudge.is-pulse { animation: study-nudge-in 320ms ease-out; }
@keyframes study-nudge-in {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}
.study-attention .study-seg .study-opt:not(.is-on) { border-color: rgba(137, 29, 26, 0.45); }
.diag-actions .primary-button.is-locked { opacity: 0.55; cursor: not-allowed; }

/* returning student: one-line summary + change affordance */
.study-current { display: flex; align-items: baseline; gap: 0.7rem; margin: 0; flex-wrap: wrap; }
.study-current-line {
  font-family: "Fraunces", serif; font-weight: 700; font-size: 1.25rem;
  letter-spacing: -0.01em; color: var(--ink);
}
.study-change {
  appearance: none; background: none; border: 0; padding: 2px 2px; cursor: pointer;
  font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.study-change:hover { color: var(--accent); }
.study-change:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* ---- sentence-form setup (diagnostic intro): "I'm in [year] doing [board]" --
   Setup reads as one quiet line, not a form — two inline selects styled as
   underlined Fraunces fields so they look chosen, not defaulted. */
/* One line, always: "I'm in [year] doing [board]" as a flex row that doesn't
   wrap on desktop. Lead words in the body face (Hanken), the dropdowns in the
   display face (Fraunces) — the paired display+body the design system runs on. */
.study-sentence {
  margin: 0; display: flex; align-items: center; gap: 0.55rem; flex-wrap: nowrap;
  font-size: 1.12rem; color: var(--muted); font-weight: 500;
}
.study-sentence-lead { white-space: nowrap; }
/* Custom dropdown — designed for us, not the OS default. The trigger is a
   chosen-looking field (Fraunces, comfortable padding, label centred between
   its padding and the chevron); the menu is a Marked Script card. */
/* flex:0 0 auto so a long label (e.g. "Year 11 (coming from GCSE)") is never
   squeezed by the sibling board dropdown — squeezing made it wrap to two lines
   until a (shorter) board was picked. */
.study-dd { position: relative; display: inline-block; vertical-align: baseline; flex: 0 0 auto; }
.study-dd-trigger {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.6rem;
  background: var(--surface, #fbf4e4); color: var(--ink);
  border: 1.5px solid var(--line-strong, #c9bfa6); border-radius: 10px;
  padding: 0.42rem 0.85rem 0.46rem 1rem; margin: 0 0.15rem;
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.08rem;
  line-height: 1.2; min-height: 42px; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(23,32,31,0.04);
  transition: border-color 140ms ease-out, box-shadow 140ms ease-out;
}
.study-dd-trigger .study-dd-value { display: inline-block; }
.study-dd-trigger.is-placeholder { color: var(--muted); font-style: italic; font-weight: 500; }
.study-dd-chev { color: var(--accent); transition: transform 160ms ease-out; }
.study-dd-trigger[aria-expanded="true"] .study-dd-chev { transform: rotate(180deg); }
.study-dd-trigger:hover { border-color: var(--accent); box-shadow: 0 2px 8px -4px rgba(137,29,26,0.35); }
.study-dd-trigger:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.study-dd-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.study-dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; margin: 0; padding: 0.35rem;
  min-width: 100%; width: max-content; max-width: 18rem; list-style: none;
  max-height: min(332px, 56vh); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface, #fbf4e4); border: 1px solid var(--line-strong, #c9bfa6); border-radius: 12px;
  box-shadow: 0 18px 40px -22px rgba(23,32,31,0.5), 0 2px 8px -4px rgba(23,32,31,0.2);
  animation: study-dd-in 130ms ease-out;
}
/* Flip above the trigger when there's no room below. */
.study-dd.study-dd-up .study-dd-menu { top: auto; bottom: calc(100% + 6px); }
.study-dd-menu::-webkit-scrollbar { width: 7px; }
.study-dd-menu::-webkit-scrollbar-thumb { background: var(--line-strong, #c9bfa6); border-radius: 7px; }
@keyframes study-dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .study-dd-menu { animation: none; } .study-dd-chev { transition: none; } }
.study-dd-opt {
  appearance: none; cursor: pointer; display: block; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 8px;
  padding: 0.5rem 0.75rem; font: inherit; font-size: 0.98rem; font-weight: 500; color: var(--ink);
  white-space: nowrap;
}
.study-dd-opt:hover { background: var(--accent-wash, #f5e9e6); }
.study-dd-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.study-dd-opt.is-on { color: var(--accent-strong, #6f1a16); font-weight: 700; }
.study-dd-opt.is-on::after { content: "✓"; float: right; margin-left: 0.8rem; color: var(--accent); }

.study-note-min {
  margin: 1.1rem 0 0; max-width: 38rem;
  font-size: 13px; line-height: 1.5; color: var(--muted);
}
.study-note-min b { color: var(--ink); }
.study-attention .study-dd-trigger.is-placeholder { border-color: rgba(137, 29, 26, 0.55); }
@media (max-width: 640px) { .study-sentence { font-size: 1.06rem; } .study-dd-menu { max-width: 14rem; } }
/* Phones: one line won't fit two dropdowns — wrap deliberately, row by row. */
@media (max-width: 520px) { .study-sentence { flex-wrap: wrap; row-gap: 0.6rem; } }

/* account screen: same pickers inside a standard panel */
.study-panel { margin-top: 1.4rem; }
.study-panel h2 { margin-top: 0; }
.study-panel-sub { margin: 0.4rem 0 1.1rem; color: var(--muted); font-size: 0.97rem; }
.study-panel .form-message.is-error { color: var(--danger); }
.study-panel .small-note { margin-top: 1.1rem; line-height: 1.55; }

/* Email preferences panel + a proper settings toggle. */
.email-prefs-panel { margin-top: 1.4rem; }
.email-prefs-panel h2 { margin-top: 0; }
.email-prefs-panel .form-message.is-error { color: var(--danger); }
.email-prefs-panel .small-note { margin-top: 1.1rem; line-height: 1.55; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding: 0.95rem 1.1rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface, #fbf4e4);
}
.settings-row-text strong { display: block; font-size: 1rem; color: var(--ink); }
.settings-row-text span { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.9rem; line-height: 1.5; max-width: 44ch; }
/* Toggle switch */
.toggle { position: relative; display: inline-flex; flex: 0 0 auto; cursor: pointer; }
.toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.toggle-track {
  width: 48px; height: 28px; border-radius: 999px; background: var(--line-strong, #c9bfa6);
  transition: background-color 0.18s ease; position: relative; flex: 0 0 auto;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(23,32,31,0.3); transition: transform 0.18s ease;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--blue); outline-offset: 2px; }
.toggle input:disabled + .toggle-track { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) {
  .toggle-track, .toggle-thumb { transition: none; }
}
@media (max-width: 560px) {
  .settings-row-text span { font-size: 0.86rem; }
}

/* ---- Settings / Account page (tabbed, flat editorial) -------------------- */
.account-page { max-width: 1040px; margin: 0 auto; padding: 0 0 4rem; }

/* Masthead */
.account-masthead { margin: 0 0 1.9rem; padding: 1.5rem 0 0; }
.account-eyebrow { margin: 0 0 0.3rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent); }
.account-title { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: clamp(2rem, 4.5vw, 2.9rem); letter-spacing: -0.018em; line-height: 1.05; color: var(--ink); }
.account-title-rule { margin: 0.5rem 0 0; width: min(7rem, 38%); height: 2px; background: linear-gradient(to right, var(--accent), transparent); border-radius: 1px; }

/* Desk: sticky rail + panels */
.account-desk { display: grid; grid-template-columns: 1fr; gap: 1.8rem; align-items: start; }
@media (min-width: 880px) {
  .account-desk { grid-template-columns: 14rem 1fr; gap: clamp(2rem, 4vw, 3.5rem); }
  .account-rail { position: sticky; top: 88px; }
}

/* Rail */
.account-rail { display: flex; flex-direction: column; gap: 0; }

/* Membership card */
.account-id-card {
  position: relative; overflow: hidden; text-align: center;
  background: linear-gradient(158deg, var(--surface), var(--surface-soft));
  border: 1px solid var(--line-strong); border-radius: 17px;
  padding: 1.2rem 1rem 1rem; margin-bottom: 0.7rem; box-shadow: var(--shadow-soft);
}
.account-avatar {
  display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--accent); color: #fff; font-family: "Fraunces", Georgia, serif; font-weight: 700;
  font-size: 1.4rem; line-height: 1; margin: 0 auto 0.65rem; box-shadow: 0 9px 20px -8px rgba(137, 29, 26, 0.6);
}
.account-email { margin: 0; font-weight: 600; color: var(--ink); word-break: break-word; font-size: 0.86rem; line-height: 1.35; }
.account-id-meta { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line-strong); }
.account-plan-badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.62rem; border-radius: 999px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line-strong);
}
.account-plan-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.account-plan-badge.is-paid { color: var(--accent); background: var(--soft-red); border-color: rgba(137, 29, 26, 0.2); }
.account-id-course { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.account-id-course:empty { display: none; }

/* Tabs */
.account-tabs { display: flex; flex-direction: column; gap: 2px; }
.account-tab {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; cursor: pointer;
  appearance: none; border: 0; background: none; border-radius: 9px; padding: 0.55rem 0.7rem;
  font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.account-tab svg { flex: none; }
.account-tab:hover { background: var(--surface-soft); color: var(--ink); }
.account-tab.is-on { background: var(--ink); color: var(--bg); }
.account-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-logout {
  margin-top: 0.5rem; appearance: none; background: none; border: 0; padding: 0.55rem 0.7rem; cursor: pointer; font: inherit;
  font-size: 0.86rem; font-weight: 600; color: var(--faint); text-align: left; border-radius: 9px; transition: color 0.15s ease;
}
.account-logout:hover { color: var(--accent); }
.account-logout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Panels */
.account-panels { min-width: 0; }
.account-panel { display: none; }
.account-panel.is-on { display: block; animation: acct-fade 0.26s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes acct-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Groups */
.acct-grp + .acct-grp { border-top: 1px solid var(--line); padding-top: 1.7rem; margin-top: 1.7rem; }
.acct-eyb { margin: 0; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent); }
.acct-h { margin: 0.1rem 0 0; font-family: "Fraunces", Georgia, serif; font-size: 1.4rem; font-weight: 600; letter-spacing: -0.015em; color: var(--ink); }
.acct-uline { display: block; width: 7rem; height: 7px; margin: 0.1rem 0 0; color: var(--accent); }
.acct-sub { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; max-width: 52ch; }
.acct-sub strong { color: var(--ink); }
.acct-foot { margin: 0.85rem 0 0; color: var(--faint); font-size: 0.8rem; line-height: 1.55; max-width: 56ch; }
.account-panel [data-study-setup] { margin-top: 1rem; }
.acct-grp .settings-row { margin-top: 1rem; }
.account-panel .form-message.is-error { color: var(--danger); }

/* Referral */
.acct-refvalue { margin: 0.85rem 0 0; font-family: "Fraunces", Georgia, serif; font-size: 1.1rem; font-weight: 500; line-height: 1.42; letter-spacing: -0.01em; color: var(--ink); max-width: 44ch; }
.acct-refvalue b { color: var(--accent); font-weight: 600; }
.referral-linkrow { display: flex; gap: 0.55rem; align-items: center; margin-top: 1rem; max-width: 30rem; flex-wrap: wrap; }
.referral-input {
  flex: 1; min-width: 12rem; padding: 0.7rem 0.85rem; border: 1.5px solid var(--line-strong);
  border-radius: 10px; background: var(--surface); font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); outline: none;
}
.referral-input:focus { border-color: var(--accent); }
.acct-share { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.7rem; flex-wrap: wrap; }
.acct-share-l { font-size: 0.72rem; font-weight: 600; color: var(--faint); }
.acct-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.75rem; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: 0.76rem; font-weight: 600; color: var(--ink-soft); text-decoration: none; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.acct-chip:hover { border-color: var(--accent); color: var(--accent); }
.acct-reffoot { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; max-width: 54ch; }
.acct-earned { display: flex; align-items: center; gap: 0.55rem; margin: 1.1rem 0 0; padding-top: 0.95rem; border-top: 1px solid var(--line); font-size: 0.9rem; color: var(--ink); }
.acct-earned:empty { display: none; }
.acct-earned-star { color: var(--amber); font-family: "Fraunces", Georgia, serif; font-weight: 800; }
.acct-earned b { font-family: "Fraunces", Georgia, serif; color: var(--amber); }
.acct-earned-dim { color: var(--muted); font-size: 0.84rem; }

/* Feedback head */
.acct-fbhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; }
.acct-fbhead .ghost-button { white-space: nowrap; }
.account-panel [data-my-feedback] { margin-top: 1.1rem; }

/* Billing — free chooser (3 plans) */
.bill-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-top: 1.2rem; align-items: stretch; }
.bill-card { display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: 15px; padding: 1.1rem 1rem 1rem; background: var(--surface); position: relative; }
.bill-card-cur { background: var(--surface-soft); }
.bill-card-feat { border: 1.5px solid var(--accent); box-shadow: var(--shadow-soft); }
.bill-tag { position: absolute; top: -0.6rem; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 0.2rem 0.7rem; border-radius: 999px; white-space: nowrap; }
.bill-pn { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.15rem; font-weight: 600; }
.bill-cyc { margin: 0.2rem 0 0; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); }
.bill-price { margin: 0.55rem 0 0; font-family: "Fraunces", Georgia, serif; font-size: 1.9rem; font-weight: 600; line-height: 1; letter-spacing: -0.01em; color: var(--ink); }
.bill-u { font-family: "Hanken Grotesk", sans-serif; font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.bill-billed { margin: 0.35rem 0 0; font-size: 0.72rem; color: var(--muted); min-height: 1rem; }
.bill-have, .bill-feat { list-style: none; padding: 0; margin: 0.85rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.bill-have li { font-size: 0.8rem; color: var(--muted); display: flex; gap: 0.5rem; align-items: flex-start; line-height: 1.4; }
.bill-have li::before { content: "✓"; color: var(--muted); font-weight: 800; flex: none; }
.bill-feat li { font-size: 0.8rem; color: var(--ink-soft); display: flex; gap: 0.5rem; align-items: flex-start; line-height: 1.4; }
.bill-feat li::before { content: "✓"; color: var(--accent); font-weight: 800; flex: none; }
.bill-feat-head { color: var(--muted) !important; font-weight: 600; }
.bill-feat-head::before { content: "" !important; }
.bill-cta { width: 100%; margin-top: 1rem; }
.bill-curtag { margin: 1rem 0 0; text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.bill-curtag::before { content: "✓ "; color: var(--accent); font-weight: 800; }
.bill-managed { display: flex; align-items: center; gap: 0.45rem; margin: 1.1rem 0 0; font-size: 0.72rem; color: var(--faint); }
.bill-managed svg { flex: none; }

/* Billing — subscribed */
.bill-cur { margin-top: 1.2rem; border: 1.5px solid var(--accent); border-radius: 15px; padding: 1.1rem 1.15rem 1rem; background: var(--surface); box-shadow: var(--shadow-soft); }
.bill-cur-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.bill-cur-name { font-family: "Fraunces", Georgia, serif; font-size: 1.3rem; font-weight: 600; }
.bill-cur-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 0.2rem 0.6rem; border-radius: 999px; color: var(--accent); background: var(--soft-red); border: 1px solid rgba(137, 29, 26, 0.2); white-space: nowrap; }
.bill-cur-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.bill-cur-until { margin: 0.7rem 0 0; font-size: 0.92rem; color: var(--ink-soft); }
.bill-cur-until b { font-family: "Fraunces", Georgia, serif; }
.bill-cur-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; align-items: center; }
.bill-cur .acct-foot { margin-top: 0.9rem; }

/* Responsive — account */
@media (max-width: 879px) {
  .account-tabs { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
  .account-tab { flex: 0 0 auto; }
  .account-logout { align-self: flex-start; }
}
@media (max-width: 760px) {
  .account-masthead { padding-top: 1rem; }
  .acct-grp + .acct-grp { padding-top: 1.4rem; margin-top: 1.4rem; }
}
@media (max-width: 600px) {
  .bill-grid { grid-template-columns: 1fr; gap: 0.9rem; }
}

/* Study / diagnostic responsive (global across pages) */
@media (max-width: 760px) {
  .diag-setup { margin-top: 1.1rem; }
  .study-fields { gap: 0.6rem; }
  .study-opt { padding: 7px 13px; font-size: 0.9rem; min-height: 40px; }
  .study-current-line { font-size: 1.1rem; }
  .study-nudge { margin-top: 0.6rem; font-size: 12.5px; }
  .study-note { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .study-opt { transition: none; }
  .study-nudge.is-pulse { animation: none; }
}

/* ---- verification / claim modal — Marked Script, not a default dialog ----- */
.launch-modal-backdrop { background: rgba(23, 20, 16, 0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.launch-modal {
  width: min(440px, 100%);
  padding: clamp(1.6rem, 3.5vw, 2.1rem);
  border: 1px solid rgba(23,32,31,0.14); border-radius: 18px;
  background: #FBF4E4;
  box-shadow: 0 30px 70px -28px rgba(23,32,31,0.6), 0 2px 8px -4px rgba(23,32,31,0.2);
}
.launch-modal form { gap: 0.95rem; }
.launch-modal h2 { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: clamp(1.55rem, 3vw, 2rem); margin: 0; color: var(--ink); letter-spacing: -0.01em; }
.launch-modal form > p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 1rem; }
.launch-modal label { display: grid; gap: 0.4rem; font-weight: 600; color: var(--ink); }
.launch-modal input[type="email"], .launch-modal input[type="text"], .launch-modal input[type="password"] {
  width: 100%; padding: 0.7rem 0.85rem; font: inherit; color: var(--ink);
  background: #FBF7EC; border: 1.5px solid var(--line-strong, #c9bfa6); border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.launch-modal input[type="email"]:focus, .launch-modal input[type="text"]:focus, .launch-modal input[type="password"]:focus {
  outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
}
.launch-modal .checkbox-row { font-weight: 500; color: var(--ink-soft, var(--ink)); font-size: 0.95rem; }

/* OTP cells: warm paper, Fraunces digits, examiner-red focus + filled state. */
.code-box-row { gap: clamp(0.4rem, 1.5vw, 0.65rem); margin: 0.1rem 0; }
.code-box-row input {
  min-width: 0; aspect-ratio: 3 / 4; min-height: 58px; padding: 0; text-align: center;
  font-family: "Fraunces", Georgia, serif; font-size: 1.7rem; font-weight: 600; color: var(--ink);
  background: #FBF7EC; border: 1.5px solid var(--line-strong, #c9bfa6); border-radius: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.code-box-row input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), 0 3px 12px -5px rgba(137,29,26,0.45);
  background: #fff;
}
.code-box-row input:not(:placeholder-shown) { border-color: var(--accent); color: var(--accent-strong, #6f1a16); }

.launch-modal .primary-button { width: 100%; }
/* Resend / Change email are quiet text links, not bordered buttons — minimal,
   uncluttered, secondary to the one red action. */
.launch-modal .button-row { display: flex; gap: 1.2rem; justify-content: space-between; margin-top: -0.2rem; }
.launch-modal .button-row .secondary-button {
  flex: 0 0 auto; background: none !important; border: 0 !important; border-radius: 0 !important;
  padding: 0 !important; min-height: 0; transform: none !important;
  font-size: 0.92rem; font-weight: 600; color: var(--muted) !important; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong, #c9bfa6);
  transition: color 0.15s ease;
}
.launch-modal .button-row .secondary-button:hover:not(:disabled) { color: var(--accent) !important; background: none !important; transform: none !important; text-decoration-color: var(--accent); }
.launch-modal .button-row .secondary-button:disabled { color: var(--faint, #8a8173) !important; text-decoration: none; cursor: default; }
.launch-modal .button-row .secondary-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.launch-modal .small-note { margin: 0; color: var(--muted); font-size: 0.86rem; }
.launch-modal .form-message { margin: 0; }
@media (max-width: 640px) {
  .launch-modal { background: #FBF4E4; border-radius: 18px 18px 0 0; }
  .code-box-row input { min-height: 52px; font-size: 1.5rem; }
}

/* ---- auth panel spacing: collapse the empty status line so the panel hugs
   its content instead of leaving a tall dead zone at the bottom ------------ */
.auth-panel #authMessage:empty { min-height: 0; margin: 0; }
.auth-panel #authMessage { margin: 0.6rem 0 0; }
.auth-form .small-note { margin: 0.15rem 0 0; }
.auth-panel { padding: 1.25rem 1.3rem 1.35rem; }
.auth-reset-step2 { display: grid; gap: 0.9rem; margin: 0; }

/* ---- My feedback list (account settings page) ----------------------------- */
.my-fb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.my-fb-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line, #e8dece);
}
.my-fb-item:first-child { padding-top: 0; }
.my-fb-item:last-child { border-bottom: none; padding-bottom: 0; }
.my-fb-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.my-fb-signal {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1rem;
  font-weight: 800;
  flex: none;
  width: 1.2rem;
  text-align: center;
}
.my-fb-signal.my-fb-signal-loved    { color: var(--accent); }
.my-fb-signal.my-fb-signal-confused { color: var(--amber, #92671c); }
.my-fb-signal.my-fb-signal-broken   { color: var(--ink); }
.my-fb-signal.my-fb-signal-idea     { color: var(--blue, #565d72); }
.my-fb-body {
  flex: 1;
  min-width: 0;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.my-fb-no-body { color: var(--muted); font-style: normal; }
.my-fb-status {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  flex: none;
  white-space: nowrap;
}
.my-fb-status.my-fb-status-new          { background: var(--soft-amber, #f4e9ce); color: var(--amber, #92671c); }
.my-fb-status.my-fb-status-acknowledged { background: var(--soft-blue, #e7eaf1); color: var(--blue-strong, #434a5e); }
.my-fb-status.my-fb-status-resolved     { background: var(--bg); color: var(--muted); border: 1px solid var(--line-strong); }
.my-fb-meta {
  margin: 0.25rem 0 0 1.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}


/* ============================================================================
   Dark mode — "the night desk". Applied via html[data-theme="dark"], set by
   /theme-boot.js (saved choice, else the device's prefers-color-scheme).
   Same Marked Script identity, lamplight edition: warm near-black grounds,
   cream ink, the examiner's maroon lifted to brick so text passes AA on dark.
   Diagrams keep their white plate (--plate) — 600+ authored SVGs stay legible.
   ============================================================================ */
html[data-theme="dark"] {
  color-scheme: dark;
  /* deep espresso, not mud: a near-black ground with only a whisper of warmth,
     then two clean elevation steps. Lines are crisp, not brown sludge. */
  --bg: #100d0b;
  --surface: #1a1613;
  --surface-soft: #241e1a;
  --ink: #f6efe3;
  --ink-soft: #dccdb9;
  --muted: #a1917f;
  --line: #2c2622;
  --line-strong: #433a33;
  /* the examiner's maroon, warmed to a clean brick that glows on near-black */
  --accent: #e0736a;
  --accent-strong: #ec8c84;
  --accent-wash: rgba(224, 115, 106, 0.12);
  --warn: #e0ad55;
  --warn-deep: #d7a24a;
  --on-accent: #1a0d0c;
  /* reward green, lifted so it glows on near-black instead of muddying */
  --good: #7cc78f;
  --good-strong: #98d9a7;
  --good-wash: rgba(124, 199, 143, 0.14);
  --soft-good: #1d2b21;
  --on-good: #10240f;
}


/* Appearance switch (Settings): a wider sun/moon toggle. The bright knob
   carries the active glyph and slides on flip; the track goes warm-amber for
   day, brick for night — clearly visible, on-brand, never a dim blue. */
.theme-switch .toggle-track { width: 58px; height: 30px;
  background: linear-gradient(180deg, #f6e6c2, #eed9ac); border: 1px solid var(--line-strong); }
.theme-switch .toggle-thumb { top: 3px; left: 3px; width: 24px; height: 24px;
  background: #fffdf8; box-shadow: 0 2px 5px rgba(23,15,8,0.28);
  display: flex; align-items: center; justify-content: center; }
.theme-switch .ts-ico { position: absolute; transition: opacity 0.18s ease; }
.theme-switch .ts-sun { color: #c98a12; opacity: 1; }        /* bright gold sun */
.theme-switch .ts-moon { color: #7a2a26; opacity: 0; }        /* deep brick moon */
.theme-switch input:checked + .toggle-track {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent)); border-color: var(--accent); }
.theme-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(28px); background: #fdf3ec; }
.theme-switch input:checked + .toggle-track .ts-sun { opacity: 0; }
.theme-switch input:checked + .toggle-track .ts-moon { opacity: 1; }
.theme-switch input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 3px; }

/* theme crossfade: a transient class on <html> during a switch eases the whole
   app between palettes instead of a hard cut. Removed after ~360ms so it never
   affects other interactions. */
html.theme-anim, html.theme-anim body, html.theme-anim *:not(.toggle-thumb):not(.ts-ico) {
  transition: background-color 0.34s ease, color 0.34s ease, border-color 0.34s ease,
    fill 0.34s ease, stroke 0.34s ease !important;
}
@media (prefers-reduced-motion: reduce) { html.theme-anim, html.theme-anim * { transition: none !important; } }

/* dark-mode specifics the tokens can't reach ------------------------------ */
/* the examiner's pen stroke is a data-URI (no var() inside) — brick variant */
html[data-theme="dark"] .loop-move-headline em,
html[data-theme="dark"] .hxs-title em {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M3 9 C 30 4 80 3.5 117 6.5' fill='none' stroke='%23d0655d' stroke-width='2.4' stroke-linecap='round' opacity='0.85'/%3E%3C/svg%3E");
}
/* domain chips: same hues, lifted for dark ground */
html[data-theme="dark"] .loop-chip { color: #b9c1d6; background: rgba(150, 160, 190, 0.13); border-color: rgba(150, 160, 190, 0.32); }
html[data-theme="dark"] .loop-chip-pure       { color: #e39aa2; background: rgba(206, 96, 108, 0.14); border-color: rgba(206, 96, 108, 0.36); }
html[data-theme="dark"] .loop-chip-mechanics  { color: #94bfe4; background: rgba(90, 150, 205, 0.15); border-color: rgba(90, 150, 205, 0.36); }
html[data-theme="dark"] .loop-chip-statistics { color: #dfb26b; background: rgba(200, 150, 60, 0.15); border-color: rgba(200, 150, 60, 0.36); }
html[data-theme="dark"] .loop-chip-mixed      { color: #c9cfc4; background: rgba(190, 195, 185, 0.12); border-color: rgba(190, 195, 185, 0.30); }


/* dark: the chrome the tokens can't reach ---------------------------------- */
/* topbar glass: cream glass -> warm-black glass */
html[data-theme="dark"] .topbar { background: rgba(22, 16, 10, 0.88) !important; }

/* filled elements: the lifted brick (--accent) is for TEXT on dark; fills
   need a deeper brick with cream ink or they wash out to salmon */
html[data-theme="dark"] .primary-button,
html[data-theme="dark"] .topnav .primary-button,
html[data-theme="dark"] .hxq-redo,
html[data-theme="dark"] .y11-drawer-handle {
  background: #b0433b !important; color: #fdf3ec !important;
}
html[data-theme="dark"] .primary-button:hover,
html[data-theme="dark"] .topnav .primary-button:hover,
html[data-theme="dark"] .hxq-redo:hover,
html[data-theme="dark"] .y11-drawer-handle:hover {
  background: #c25148 !important;
}
html[data-theme="dark"] .y11-drawer-handle-label { color: #fdf3ec; }
html[data-theme="dark"] .brand-mark { background: #b0433b !important; color: #fdf3ec !important; }


/* dark: light-paper surfaces that carried bare hexes. In dark the paper
   darkens with the room — text tokens already flipped, so any surface left
   cream would show cream-on-cream. (Photos, QR codes and diagram plates are
   the deliberate exceptions — they stay white via --plate.) */
html[data-theme="dark"] .loop-paper-sheet,
html[data-theme="dark"] .loop-byte-card,
html[data-theme="dark"] .loop-pause-card,
html[data-theme="dark"] .loop-confirm-card,
html[data-theme="dark"] .launch-modal { background: var(--surface) !important; }
html[data-theme="dark"] .loop-byte-opt-key,
html[data-theme="dark"] .loop-byte-prove-note,
html[data-theme="dark"] .loop-byte-explain-q,
html[data-theme="dark"] .loop-byte-gate-tick,
html[data-theme="dark"] .loop-onboard-num,
html[data-theme="dark"] .account-avatar,
html[data-theme="dark"] .secondary-button:hover { background: var(--surface-soft) !important; }
html[data-theme="dark"] .submit-button { background: var(--surface) !important; }
html[data-theme="dark"] .launch-modal input[type="email"],
html[data-theme="dark"] .launch-modal input[type="text"],
html[data-theme="dark"] .code-box-row input { background: var(--surface-soft) !important; color: var(--ink) !important; }
html[data-theme="dark"] .code-box-row input:focus { background: var(--surface) !important; }
html[data-theme="dark"] .loop-curio-bar-track { background: var(--line) !important; }
html[data-theme="dark"] .diag-intro.is-y11::before { background: none !important; }

/* the exam paper's per-domain question rings: same lift as the chips */
html[data-theme="dark"] .loop-q-pure .loop-q-ring, html[data-theme="dark"] .loop-q-pure .loop-q-number { color: #e39aa2; }
html[data-theme="dark"] .loop-q-mechanics .loop-q-ring, html[data-theme="dark"] .loop-q-mechanics .loop-q-number { color: #94bfe4; }
html[data-theme="dark"] .loop-q-statistics .loop-q-ring, html[data-theme="dark"] .loop-q-statistics .loop-q-number { color: #dfb26b; }
html[data-theme="dark"] .loop-q-mixed .loop-q-ring, html[data-theme="dark"] .loop-q-mixed .loop-q-number { color: #c9cfc4; }

/* dark: selected account tab joins the filled-element language (the light
   theme's ink-chip inversion would render as a loud cream slab) */
html[data-theme="dark"] .account-tab.is-on { background: #b0433b; color: #fdf3ec; }


/* the OFF (light-selected) switch track, viewed in dark mode, dims its day-gold */
html[data-theme="dark"] .theme-switch input:not(:checked) + .toggle-track { background: linear-gradient(180deg, #4a3f2c, #3a3120); border-color: var(--line-strong); }
html[data-theme="dark"] .theme-switch .toggle-thumb { background: #efe6d8; }
/* ON state stays the bright brick in dark mode too (belt-and-braces vs order) */
html[data-theme="dark"] .theme-switch input:checked + .toggle-track {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent)); border-color: var(--accent); }

/* =====================================================================
   2026-08-15 — LEAN NAV + LESSON FOCUS (Raghu: "match the preview + nav bar")
   Slim glass bar, real logo mark, quiet text links, no filled button.
   Lesson pages: nav + lesson only — no page header, rail, or floating chips.
   ===================================================================== */
/* Not a bar: the header floats on the page's own colour — no band, no line, no
   blur, not sticky (ref: PRØDUX). Logo left, tracked uppercase links right, air
   above and below. */
.topbar {
  /* sticky like the reference: the announcement bar scrolls away, the nav pins (2026-08-26) */
  position: sticky !important;
  top: 0;
  z-index: 40;
  min-height: 0 !important;
  padding: 1.1rem max(1.5rem, calc((100vw - 1120px) / 2)) 0.9rem !important;
  background: var(--bg) !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-theme="dark"] .topbar { background: var(--bg) !important; border-bottom: 0 !important; }
.brand { gap: 0 !important; }
/* the logotype (Raghu's file, 2026-08-15): white on dark, ink on light — swapped
   by CSS content so both themes get the right variant from one <img>. */
/* v2 logotype (tracked sans), tinted to the accent (= the Register tab colour). */
.brand-logotype { height: 28px; width: auto; display: block; }
html:not([data-theme="dark"]) .brand-logotype { content: url("/logotype-mark-light.png"); }
html[data-theme="dark"] .brand-logotype { content: url("/logotype-mark-dark.png"); }
.brand strong, .brand small { display: none !important; }
@media (max-width: 720px) { .brand-logotype { height: 20px; } .topbar { padding-top: 0.9rem !important; } }
/* Hierarchy pass (Raghu 2026-08-15: "doesn't read like a logotype"): the wordmark
   is the ONLY tracked-caps element on the line and the biggest thing on it; nav
   links go quiet — sentence case, regular weight, muted, no tracking. */
.topnav { gap: 1.9rem !important; }
.topnav a:not(.primary-button),
.topnav .ghost-button,
.topnav .topnav-gear {
  font-family: "Archivo", "Inter", system-ui, sans-serif !important;
  font-size: 0.92rem !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--muted) !important;
  padding: 0 !important;
  min-height: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  transition: color 0.2s ease;
}
.topnav a:not(.primary-button):hover,
.topnav .ghost-button:hover,
.topnav .topnav-gear:hover { color: var(--ink) !important; background: transparent !important; }
.topnav .topnav-gear { display: inline-flex; align-items: center; opacity: 0.8; }
.topnav .topnav-gear svg { width: 17px; height: 17px; }
.topnav .topnav-history-ic { display: none !important; }
.topnav .primary-button { padding: 8px 16px !important; border-radius: 10px !important; font-size: 0.9rem !important; letter-spacing: 0; text-transform: none; }
@media (max-width: 720px) { .topnav { gap: 1.2rem !important; } .topbar { padding-top: 1.3rem !important; } }

/* lesson focus: the page is the lesson */
/* the lesson page = contents rail | lesson (Raghu's three, 2026-08-15) */
.loop-lesson-only {
  display: grid; grid-template-columns: 236px minmax(0, 720px); gap: 2.4rem;
  justify-content: center; max-width: 1120px; margin: 0 auto;
  padding: 1.6rem 1.25rem 4rem !important; align-items: start;
}
.loop-lesson-only.no-rail { grid-template-columns: minmax(0, 720px); }
.loop-lesson-only.rail-collapsed { grid-template-columns: 44px minmax(0, 720px); }
.loop-lesson-only .loop-work { max-width: none; margin: 0; min-width: 0; }

.lesson-rail { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; padding-right: 6px; scrollbar-width: thin; }
.lesson-rail-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 0.6rem; }
.lesson-rail-kicker { font-family: "Archivo", system-ui, sans-serif; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.lesson-rail-toggle { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 6px; cursor: pointer; border-radius: 6px; }
.lesson-rail-toggle:hover { color: var(--ink); background: var(--accent-wash); }
.lesson-rail-domh { display: flex; justify-content: space-between; align-items: baseline; margin: 0.9rem 0 0.35rem; font-family: "Archivo", system-ui, sans-serif; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.lesson-rail-domh:first-child { margin-top: 0; }
.lesson-rail-count { font-variant-numeric: tabular-nums; }
.lesson-rail-item { display: flex; align-items: center; gap: 9px; padding: 5px 7px; border-radius: 7px; color: var(--muted); font-size: 13px; line-height: 1.25; text-decoration: none; }
.lesson-rail-item:hover { color: var(--ink); background: var(--accent-wash); }
.lesson-rail-item.is-here { color: var(--ink); background: var(--accent-wash); }
.lesson-rail-item.is-next { color: var(--ink-soft); }
.lesson-rail-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-strong); flex: 0 0 8px; }
.lesson-rail-item.is-here .lesson-rail-dot { background: var(--accent); border-color: var(--accent); }
.lesson-rail-item.is-held .lesson-rail-dot { background: var(--ink-soft); border-color: var(--ink-soft); }
.lesson-rail-item.is-next .lesson-rail-dot { border-color: var(--accent); }
.lesson-rail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-collapsed .lesson-rail-kicker, .rail-collapsed .lesson-rail-domh, .rail-collapsed .lesson-rail-label { display: none; }
.rail-collapsed .lesson-rail-item { padding: 5px 0; justify-content: center; }
.rail-collapsed .lesson-rail-head { justify-content: center; }

.lesson-back { display: inline-block; font-size: 12.5px; color: var(--muted); text-decoration: none; margin: 0 0 0.9rem; }
.lesson-back:hover { color: var(--accent); }

.lesson-video {
  aspect-ratio: 16 / 9; width: 100%; max-width: 640px; margin: 0.9rem 0 1.1rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); text-align: center; padding: 1rem;
}
.lesson-video-play { color: var(--accent); display: inline-flex; }
.lesson-video-title { font-size: 13.5px; color: var(--ink-soft); }
.lesson-video-note { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
/* real player (ARU has rendered byte videos): the box hugs the video, caption sits under it */
.lesson-video.has-video { aspect-ratio: auto; padding: 0; gap: 0; overflow: hidden; align-items: stretch; background: #1a0d0d; }
.lesson-video.has-video video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #1a0d0d; }
.lesson-video.has-video .lesson-video-play, .lesson-video.has-video .lesson-video-note { display: none; }
.lesson-video.has-video .lesson-video-title { display: block; padding: 6px 10px 7px; font-size: 12px; text-align: left; background: var(--surface); color: var(--muted); border-top: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1040px) {
  .loop-lesson-only, .loop-lesson-only.rail-collapsed { grid-template-columns: minmax(0, 1fr); }
  .lesson-rail { position: static; max-height: none; border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; margin-bottom: 0.4rem; }
  .rail-collapsed .lesson-rail-body { display: none; }
  .rail-collapsed .lesson-rail-kicker { display: inline; }
  .rail-collapsed .lesson-rail-domh, .rail-collapsed .lesson-rail-label { display: flex; }
  .rail-collapsed .lesson-rail-item { padding: 5px 7px; justify-content: flex-start; }
  .rail-collapsed .lesson-rail-head { justify-content: space-between; }
  .lesson-video { aspect-ratio: auto; flex-direction: row; justify-content: flex-start; padding: 0.55rem 0.8rem; gap: 10px; }
  .lesson-video-title { display: none; }
  .lesson-video.has-video { flex-direction: column; padding: 0; gap: 0; }
}
body.lesson-focus .fbw-pill,
body.lesson-focus .fbw-dot,
body.lesson-focus .va-preview-fab,
body.lesson-focus .beta-notice { display: none !important; }

/* admin header zone: the accent belongs to the logotype now — the active door /
   tab yields to ink so the brand is the one warm thing on the line (2026-08-15) */
.apx-door.is-on, .apx-navtab.is-on { color: var(--ink) !important; border-bottom-color: var(--ink) !important; }

/* ---- text logotype (2026-08-15, replaces the PNG): Fraunces serif caps, brick
   four-point star as the superscript. Crisp at any size, selectable, theme-native. */
.brand-logotype { display: none !important; }
.brand-word {
  display: inline-flex; align-items: baseline; line-height: 1;
  font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 25px;
  letter-spacing: 0.02em; color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 0;
}
.brand-a { letter-spacing: 0; }
.brand-star {
  width: 0.46em; height: 0.46em; fill: var(--accent);
  align-self: flex-start; margin: 0.02em 0.06em 0 0.02em;
}
.brand-coach { letter-spacing: 0.02em; }
@media (max-width: 720px) { .brand-word { font-size: 21px; } }

/* rail chapters (textbook grain, 2026-08-15) */
.lesson-rail-ch { margin: 0 0 2px; }
.lesson-rail-chs { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 7px; border-radius: 7px; cursor: pointer; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.lesson-rail-chs::-webkit-details-marker { display: none; }
.lesson-rail-chs::before { content: "\203A"; display: inline-block; width: 10px; color: var(--muted); transition: transform 0.15s ease; }
.lesson-rail-ch[open] > .lesson-rail-chs::before { transform: rotate(90deg); }
.lesson-rail-chs:hover { background: var(--accent-wash); color: var(--ink); }
.lesson-rail-chs.is-here { color: var(--ink); }
.lesson-rail-chn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-rail-chc { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-rail-ch .lesson-rail-item { padding-left: 24px; }
.rail-collapsed .lesson-rail-chs { display: none; }
.rail-collapsed .lesson-rail-ch { display: block; }
.rail-collapsed .lesson-rail-ch:not([open]) .lesson-rail-item { display: none; }

/* proportion pass vs the approved mock (2026-08-15) */
.loop-lesson-only { grid-template-columns: 256px minmax(0, 660px) !important; gap: 2.75rem !important; padding-top: 1.4rem !important; }
.loop-lesson-only.rail-collapsed { grid-template-columns: 44px minmax(0, 660px) !important; }
.loop-lesson-only .loop-bytes-intro { display: none; }                 /* the mock has no intro line */
.loop-lesson-only .loop-bytes-kicker {
  font-family: "Archivo", system-ui, sans-serif !important; font-size: 12px !important; font-weight: 500 !important;
  letter-spacing: 0.13em !important; text-transform: uppercase; color: var(--muted) !important; margin: 0 0 0.75rem !important;
}
.lesson-back { margin: 0 0 1.1rem !important; font-size: 13px !important; }
.lesson-video { max-width: none !important; width: 100%; margin: 0 0 1rem !important; }   /* edge-aligned with the card */
.loop-lesson-only .loop-bytes-progress { margin-top: 0 !important; }
.lesson-rail-item { font-size: 13.5px !important; padding: 5px 8px !important; }
.lesson-rail-chs { font-size: 14px !important; padding: 7px 8px !important; }
.lesson-rail-domh { margin-top: 1.1rem !important; }
.lesson-rail-kicker { font-size: 11px !important; }

/* rail flush-left (aligned with the logo), lesson centred in the remainder; three
   collapsible tiers: domain > chapter > lesson (2026-08-15) */
.loop-lesson-only {
  grid-template-columns: 272px minmax(0, 1fr) !important; gap: 0 !important; justify-content: stretch !important;
  max-width: none !important; margin: 0 !important;
  padding-left: max(1.5rem, calc((100vw - 1120px) / 2)) !important; padding-right: 1.5rem !important;
}
.loop-lesson-only.rail-collapsed { grid-template-columns: 56px minmax(0, 1fr) !important; }
.loop-lesson-only .loop-work { max-width: 660px; margin: 0 auto !important; padding: 0 1rem; }
.lesson-rail { padding-right: 1.25rem; border-right: 1px solid var(--line); }
.lesson-rail-dom { margin: 0 0 4px; }
.lesson-rail-domh { list-style: none; cursor: pointer; padding: 8px 8px; border-radius: 8px; margin: 0.4rem 0 0.2rem !important; font-size: 11px !important; letter-spacing: 0.14em; }
.lesson-rail-domh::-webkit-details-marker { display: none; }
.lesson-rail-domh:hover { color: var(--ink); background: var(--accent-wash); }
.lesson-rail-domh.is-here { color: var(--ink); }
.lesson-rail-domh > span:first-child::before { content: "\203A"; display: inline-block; width: 12px; color: var(--muted); transition: transform 0.15s ease; font-size: 14px; line-height: 0; }
.lesson-rail-dom[open] > .lesson-rail-domh > span:first-child::before { transform: rotate(90deg); }
.lesson-rail-dom .lesson-rail-ch { margin-left: 8px; }
.lesson-rail-dom .lesson-rail-item { padding-left: 30px !important; }
.rail-collapsed .lesson-rail-domh { display: none; }
@media (max-width: 1040px) { .loop-lesson-only, .loop-lesson-only.rail-collapsed { grid-template-columns: minmax(0, 1fr) !important; } .lesson-rail { border-right: 0; padding-right: 0; } }

/* hug the viewport's left edge; 4-tier rail (2026-08-15) */
.loop-lesson-only { padding-left: 1rem !important; grid-template-columns: 300px minmax(0, 1fr) !important; }
.loop-lesson-only.rail-collapsed { grid-template-columns: 56px minmax(0, 1fr) !important; }
.lesson-rail-tp { margin: 0; }
.lesson-rail-tps { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px 5px 26px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; }
.lesson-rail-tps::-webkit-details-marker { display: none; }
.lesson-rail-tps::before { content: "\203A"; display: inline-block; width: 10px; margin-left: -14px; color: var(--muted); transition: transform 0.15s ease; }
.lesson-rail-tp[open] > .lesson-rail-tps::before { transform: rotate(90deg); }
.lesson-rail-tps:hover { color: var(--ink); background: var(--accent-wash); }
.lesson-rail-tps.is-here { color: var(--ink-soft); }
.lesson-rail-dom .lesson-rail-tp .lesson-rail-item { padding-left: 44px !important; }
.lesson-rail-chc { white-space: nowrap; }
.rail-collapsed .lesson-rail-tps { display: none; }
.rail-collapsed .lesson-rail-tp:not([open]) .lesson-rail-item { display: none; }

/* =====================================================================
   COURSE CONTENTS RAIL v2 (2026-08-15) — subject › chapter card › group › lesson tree
   Separation by tier: subject = tracked caps header · chapter = bordered card
   with subtitle + round chevron button · group = ring row inside the card ·
   lesson = connector-line tree with state dots. Chevrons are flex-centred.
   ===================================================================== */
.loop-lesson-only { grid-template-columns: 316px minmax(0, 1fr) !important; }
.loop-lesson-only.rail-collapsed { grid-template-columns: 56px minmax(0, 1fr) !important; }
.lesson-rail { border-right: 0; padding-right: 0.9rem; }
.lesson-rail-head { padding: 2px 4px; margin-bottom: 0.9rem; }
.lr-chev { flex: 0 0 auto; transition: transform 160ms ease; color: var(--muted); }
details[open] > summary > .lr-chev, details[open] > summary > .lr-btn > .lr-chev { transform: rotate(90deg); }
summary::-webkit-details-marker { display: none; }
.lr-subject-h, .lr-chapter-h, .lr-group-h { list-style: none; cursor: pointer; display: flex; align-items: center; user-select: none; }

/* tier 1 — subject */
.lr-subject { margin: 0 0 6px; }
.lr-subject-h { gap: 10px; min-height: 40px; padding: 6px 8px 6px 4px; border-radius: 8px;
  font-family: "Archivo", system-ui, sans-serif; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.lr-subject-h:hover { color: var(--ink); }
.lr-subject-h.is-here { color: var(--ink); }
.lr-subject-name { flex: 1; font-weight: 600; }
.lr-subject-meta { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.lr-chapters { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 10px; }

/* tier 2 — chapter card (the SaveMyExams row) */
.lr-chapter { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color 160ms ease; }
.lr-chapter:hover { border-color: var(--line-strong); }
.lr-chapter[open] { border-color: var(--line-strong); }
.lr-chapter-h { gap: 10px; padding: 11px 10px 11px 14px; min-height: 56px; }
.lr-chapter-h:hover .lr-btn { border-color: var(--line-strong); color: var(--ink); }
.lr-chapter-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lr-chapter-name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-chapter-h.is-here .lr-chapter-name { color: var(--accent); }
.lr-chapter-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lr-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: 0 0 32px; transition: border-color 160ms ease, color 160ms ease, background 160ms ease; }
.lr-chapter[open] > .lr-chapter-h .lr-btn { background: var(--accent-wash); border-color: transparent; color: var(--accent); }
.lr-chapter-body { border-top: 1px solid var(--line); padding: 4px 6px 8px; }

/* tier 3 — group row */
.lr-group-h { gap: 10px; min-height: 40px; padding: 6px 8px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); }
.lr-group-h:hover { background: var(--accent-wash); color: var(--ink); }
.lr-group-h.is-here { color: var(--ink); }
.lr-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-group-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lr-ring { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: 0 0 14px; }
.lr-ring.is-part { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.lr-ring.is-done { border-color: var(--accent); background: var(--accent); }

/* tier 4 — lesson tree */
.lr-tree { position: relative; margin: 2px 0 6px 15px; padding-left: 14px; }
.lr-tree::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: var(--line-strong); }
.lr-lesson { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 5px 8px 5px 10px; border-radius: 8px; color: var(--muted); font-size: 13.5px; line-height: 1.3; text-decoration: none; transition: background 140ms ease, color 140ms ease; }
.lr-lesson:hover { color: var(--ink); background: var(--accent-wash); }
.lr-lesson.is-here { color: var(--ink); background: var(--accent-wash); font-weight: 500; }
.lr-lesson.is-next { color: var(--ink-soft); }
.lr-dot { position: absolute; left: -18.5px; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); flex: 0 0 8px; }
.lr-lesson.is-here .lr-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.lr-lesson.is-held .lr-dot { background: var(--ink-soft); border-color: var(--ink-soft); }
.lr-lesson.is-next .lr-dot { border-color: var(--accent); }
.lr-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* collapsed rail: chapters fold to their chevron buttons only */
.rail-collapsed .lr-subject-h, .rail-collapsed .lr-chapter-text, .rail-collapsed .lr-group-h, .rail-collapsed .lr-label { display: none; }
.rail-collapsed .lr-chapter { border: 0; background: transparent; }
.rail-collapsed .lr-chapter-h { padding: 4px 0; justify-content: center; min-height: 0; }
.rail-collapsed .lr-chapter-body { display: none; }
@media (max-width: 1040px) { .loop-lesson-only, .loop-lesson-only.rail-collapsed { grid-template-columns: minmax(0, 1fr) !important; } }
@media (prefers-reduced-motion: reduce) { .lr-chev, .lr-btn, .lr-lesson, .lr-chapter { transition: none; } }

/* rail v2.1: wider, connector line centred on the dots, site-native scrollbars */
.loop-lesson-only { grid-template-columns: 352px minmax(0, 1fr) !important; }
.lesson-rail { padding-right: 0.75rem; }
.lr-tree { margin: 4px 0 8px 10px; padding-left: 0; }
.lr-tree::before { left: 15.5px; top: 12px; bottom: 12px; }         /* dot centre = 12px pad + 8px/2 − 0.5 */
.lr-lesson { padding: 6px 8px 6px 12px; }
.lr-dot { position: static; margin: 0; }
.lr-lesson.is-here .lr-dot { box-shadow: 0 0 0 4px var(--accent-wash); }
.lr-label { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
.lr-chapter-name, .lr-group-name { white-space: normal; overflow: visible; text-overflow: clip; }

/* scrollbars: thin, brand-toned, no arrows — the rail and the page */
.lesson-rail, html { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.lesson-rail::-webkit-scrollbar, html::-webkit-scrollbar { width: 6px; height: 6px; }
.lesson-rail::-webkit-scrollbar-track, html::-webkit-scrollbar-track { background: transparent; }
.lesson-rail::-webkit-scrollbar-thumb, html::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.lesson-rail::-webkit-scrollbar-thumb:hover, html::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.lesson-rail::-webkit-scrollbar-button, html::-webkit-scrollbar-button { display: none; height: 0; }

/* =====================================================================
   LESSON PAGE LAYOUT v3 (2026-08-15): the lesson is centred on the VIEWPORT
   no matter what; the contents rail is a fixed left column (56px when
   collapsed — just the expand button); the video is a fixed, sticky right
   column. Rail scrollbar shows only on hover. Logotype in Newsreader (the
   Times-family serif of the approved mock).
   ===================================================================== */
.brand-word { font-family: "Newsreader", "Tiempos Headline", Georgia, "Times New Roman", serif !important; font-size: 27px !important; letter-spacing: 0.005em !important; font-weight: 700 !important; }
.brand-a { letter-spacing: 0 !important; }
.brand-star { width: 0.44em; height: 0.44em; margin: 0.06em 0.06em 0 0.02em; }

.loop-lesson-only { display: block !important; padding: 1.4rem 0 4rem !important; margin: 0 !important; max-width: none !important; }
.loop-lesson-only .loop-work { max-width: 660px; margin: 0 auto !important; padding: 0 1rem; }

/* rail: fixed left, own scroll, scrollbar only on hover */
.lesson-rail {
  position: fixed !important; left: 0; top: 78px; bottom: 0; width: 352px;
  padding: 0.5rem 0.75rem 3rem 1rem; overflow-y: auto; overflow-x: hidden;
  border-right: 0; background: transparent; z-index: 5;
  scrollbar-width: none; scrollbar-color: var(--line-strong) transparent;
}
.lesson-rail:hover { scrollbar-width: thin; }
.lesson-rail::-webkit-scrollbar { width: 5px; }
.lesson-rail::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.lesson-rail:hover::-webkit-scrollbar-thumb { background: var(--line-strong); }
.lesson-rail::-webkit-scrollbar-track { background: transparent; }
.lesson-rail-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 4px 4px 8px; margin: 0; }

/* collapsed: only the expand button remains */
.rail-collapsed .lesson-rail { width: 56px; padding: 0.5rem 0 0 0; overflow: hidden; }
.rail-collapsed .lesson-rail-head { justify-content: center; }
.rail-collapsed .lesson-rail-kicker { display: none; }
.rail-collapsed .lesson-rail-body { display: none; }
.lesson-rail-toggle { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 22px; }

/* video: fixed right column, sticky by construction */
.lesson-video { position: fixed !important; right: 24px; top: 96px; width: 340px !important; max-width: 340px !important; aspect-ratio: 16 / 9; margin: 0 !important; z-index: 5; }
.loop-lesson-only .loop-bytes-progress { margin-top: 0.4rem !important; }

/* keep the lesson clear of the rail when the viewport can't fit three columns */
@media (max-width: 1440px) {
  .lesson-video { position: static !important; width: 100% !important; max-width: none !important; margin: 0 0 1rem !important; }
}
@media (min-width: 1041px) and (max-width: 1400px) {
  .loop-lesson-only .loop-work { margin-left: calc(352px + 2rem) !important; margin-right: auto !important; }
  .rail-collapsed .loop-work { margin-left: auto !important; }
}
@media (max-width: 1040px) {
  .lesson-rail { position: static !important; width: auto; height: auto; padding: 0 1rem; margin-bottom: 0.5rem; }
  .rail-collapsed .lesson-rail { width: auto; }
}

/* v3.1: centre on the VIEWPORT (the .page cap was 1280px); rail head flush */
.loop-lesson-only { width: 100% !important; max-width: none !important; margin: 0 !important; }
.lesson-rail { padding-top: 0 !important; }
.lesson-rail-head { padding-top: 0.6rem !important; }

/* v3.2: scrollbar always reserved (no layout jump), thumb visible on hover only;
   the rail toggle is a real button — sidebar glyph, bordered, arrow flips */
.lesson-rail { scrollbar-width: thin !important; scrollbar-color: transparent transparent; scrollbar-gutter: stable; }
.lesson-rail:hover { scrollbar-color: var(--line-strong) transparent; }
.lesson-rail::-webkit-scrollbar { width: 6px; }
.lesson-rail::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.lesson-rail:hover::-webkit-scrollbar-thumb { background: var(--line-strong); }
.lesson-rail-toggle {
  width: 36px !important; height: 36px !important; padding: 0 !important; border-radius: 9px !important;
  border: 1px solid var(--line) !important; background: var(--surface) !important; color: var(--ink-soft) !important;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.lesson-rail-toggle:hover { border-color: var(--line-strong) !important; color: var(--ink) !important; background: var(--accent-wash) !important; }
.lr-toggle-ic path:last-child { transition: transform 160ms ease; transform-origin: 10px 10px; }
.lesson-rail-toggle.is-collapsed .lr-toggle-ic path:last-child { transform: scaleX(-1); }
.rail-collapsed .lesson-rail { width: 64px; padding: 0 !important; overflow: hidden !important; }
.rail-collapsed .lesson-rail-head { padding: 0.6rem 0 0 14px !important; justify-content: flex-start; }

/* ONE dashboard (2026-08-17): the hub lives in the SAME contents-rail | content shell as
   the lesson page (.loop-lesson-only). Inside the 720px content column the hub's
   two-column hero/aside split becomes a single flow; the shell's max-width wins. */
.loop-lesson-only.y11-page { max-width: 1120px; }
.loop-lesson-only .loop-hub-work .y11-grid { grid-template-columns: 1fr !important; }
.loop-lesson-only .loop-hub-work .y11-col-aside .y11-progress-strip { margin-top: 0 !important; }
.loop-lesson-only .loop-hub-work .y11-hero { margin-top: 0; }

/* ---- bytes lesson on mobile (2026-08-18): the contents rail is a full-screen overlay; the lesson owns the page ---- */
.lesson-mobile-bar { display: contents; }               /* desktop: only the back link renders, as before */
.lesson-contents-btn { display: none; }
@media (max-width: 1040px) {
  .loop-repair-bytes.loop-lesson-only { padding: 0.55rem 0.9rem 3rem !important; gap: 0 !important; }
  .loop-repair-bytes .lesson-mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 0.7rem; }
  .loop-repair-bytes .lesson-contents-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font: 500 12.5px/1 "Archivo", system-ui, sans-serif; letter-spacing: 0.04em; padding: 7px 11px; border-radius: 999px; cursor: pointer; }
  .loop-repair-bytes .lesson-contents-btn:active { background: var(--accent-wash); }
  .loop-repair-bytes .lesson-back { margin: 0 !important; font-size: 12.5px !important; }
  .loop-repair-bytes .loop-bytes-kicker { margin: 0 0 0.5rem !important; }
  /* the rail: hidden until opened; then a full-screen sheet with the × in its head */
  .loop-repair-bytes .lesson-rail { display: none; position: fixed; inset: 0; z-index: 80; margin: 0; border: 0; padding: 0.4rem 1.1rem 2.5rem; background: var(--bg); overflow: auto; -webkit-overflow-scrolling: touch; max-height: none; }
  .loop-repair-bytes .lesson-rail.is-open { display: block; }
  .loop-repair-bytes .lesson-rail-head { position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 0.6rem 0 0.7rem; margin: 0 0 0.4rem; border-bottom: 1px solid var(--line); justify-content: space-between !important; }
  .loop-repair-bytes .lesson-rail-kicker { display: inline !important; font-size: 12px; }
  .loop-repair-bytes .lesson-rail-toggle { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
  .loop-repair-bytes .lesson-rail-toggle .lr-toggle-ic { display: none; }
  .loop-repair-bytes .lesson-rail-toggle::before { content: "\00d7"; font-size: 26px; line-height: 1; }
  .loop-repair-bytes .lesson-rail-body { display: block !important; }
  .loop-repair-bytes .lesson-rail-domh, .loop-repair-bytes .lesson-rail-label { display: flex !important; }
  .loop-repair-bytes .lesson-rail-item { padding: 9px 8px !important; font-size: 15px !important; }
  .loop-repair-bytes .lesson-rail-chs { font-size: 15px !important; padding: 9px 8px !important; }
  body.lesson-rail-modal { overflow: hidden; }
}
