/* Flipped Economics design system v1 (Option A, "Workbook").
   One file for every page. Tokens first, then site chrome, then lesson components,
   then the learning layer (quiz, exam practice, review, starters). */

:root {
  --ink: #15233B;          /* text and diagram ink */
  --muted: #51627A;        /* secondary text, 6.1:1 on white */
  --line: #E3E9F1;         /* hairlines */
  --line-strong: #C9D3E2;  /* control borders */
  --panel: #F3F6FA;        /* page wash behind cards */
  --bg: #FFFFFF;
  --accent: #2457D6;       /* the one accent: current step, primary action */
  --accent-ink: #1C46B0;   /* accent on hover */
  --accent-soft: #E8EEFC;
  --good: #116432;         /* "Correct." */
  --good-soft: #EAF6EE;
  --warn: #B42318;         /* "Not quite." and diagram warnings */
  --warn-soft: #FDECEA;
  --player-b: #A84B07;     /* second firm in a payoff matrix */
  --radius: 10px;
  --radius-card: 16px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --font: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: Kalam, "Comic Sans MS", cursive;
}

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

/* ---------- Site chrome ---------- */
.container { max-width: 1160px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) { .container { padding: 0 18px; } }

.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .container { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; text-decoration: none; }
.brand svg { flex-shrink: 0; }
.site-nav { display: flex; gap: 24px; font-weight: 500; font-size: 16px; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--ink); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
@media (max-width: 640px) { .site-header .container { min-height: 60px; padding-top: 10px; padding-bottom: 10px; } .site-nav { gap: 18px; font-size: 15px; } .site-header .btn { display: none; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--radius); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); }
.btn:active { transform: scale(.97); }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); padding: 0 10px; }
.btn-ghost:hover { color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }

.site-footer { border-top: 1px solid var(--line); }
.site-footer .container { padding-top: 32px; padding-bottom: 32px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.site-footer strong { color: var(--ink); font-size: 15px; }
.site-footer nav { display: flex; gap: 24px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

h1, h2, h3 { letter-spacing: -0.02em; text-wrap: balance; }
.lede { font-size: 19px; color: var(--muted); max-width: 54ch; text-wrap: pretty; margin: 0; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.section { padding: 64px 0; }
.section-wash { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.section-head h2 { margin: 0; font-size: 30px; }
.section-head p { margin: 0; font-size: 15px; color: var(--muted); }

/* Lesson list (homepage, course page) */
.lesson-list { list-style: none; margin: 0; padding: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lesson-list + .lesson-list { margin-top: 20px; }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 20px 24px; text-decoration: none; color: var(--ink); }
a.lesson-row:hover { background: #FAFBFD; }
a.lesson-row:hover strong { color: var(--accent); }
.lesson-row .n { font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-row strong { display: block; font-size: 18px; font-weight: 600; transition: color .15s var(--ease); }
.lesson-row .sum { display: block; font-size: 15px; color: var(--muted); margin-top: 2px; }
.lesson-row .meta { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 8px; font-size: 14px; font-weight: 600; background: var(--panel); color: var(--muted); }
.tag-live { background: var(--accent-soft); color: var(--accent); }
.tag-due { background: var(--warn-soft); color: var(--warn); }
.tag-secure { background: var(--good-soft); color: var(--good); }
.module-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 28px 0 10px; }
.module-title:first-child { margin-top: 0; }
@media (max-width: 640px) {
  .lesson-row { grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 16px; }
  .lesson-row .meta { grid-column: 2; }
}

/* ---------- Lesson pages ---------- */
body.lesson { background: var(--panel); }
.lesson-bar { background: var(--bg); border-bottom: 1px solid var(--line); }
.lesson-bar .inner { max-width: 1040px; margin: 0 auto; padding: 0 20px; min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lesson-bar .back { font-size: 15px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; }
.lesson-bar .back:hover { color: var(--ink); }
.lesson-bar .brand { font-size: 17px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 22px 20px 56px; }
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.top h1 { font-size: 24px; line-height: 1.2; font-weight: 700; margin: 0; }
.route { font-size: 14px; color: var(--muted); }

.stages { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.stages span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 14px; font-weight: 500; background: var(--bg); }
.stages span.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.stages span.done { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stages span.done::before { content: ""; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translateY(-2px); }
.stages span.skipped { text-decoration: line-through; opacity: .7; }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card); }
svg.diagram { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.caption { border-top: 1px solid var(--line); padding: 16px 22px; min-height: 76px; }
.caption p { margin: 0; font-size: 17px; line-height: 1.5; max-width: 72ch; }
.fb { margin-top: 10px; font-weight: 600; font-size: 16px; line-height: 1.45; }
.fb:empty { margin: 0; }
.fb.good { color: var(--good); }
.fb.bad { color: var(--warn); }
.fb.good, .fb.bad { background: var(--good-soft); padding: 10px 14px; border-radius: 10px; font-weight: 500; color: var(--ink); }
.fb.bad { background: var(--warn-soft); }
.fb b { font-weight: 700; }
.fb.good b { color: var(--good); } .fb.bad b { color: var(--warn); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
body.lesson button:not(.btn):not(.plain) { font: inherit; font-weight: 600; font-size: 15px; min-height: 44px; padding: 0 18px; background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); }
body.lesson button:not(.btn):not(.plain):hover { border-color: var(--ink); }
body.lesson button:not(.btn):not(.plain):active { transform: scale(.97); }
body.lesson button:not(.btn):not(.plain):disabled { opacity: .45; cursor: default; transform: none; }
body.lesson button.primary:not(.btn):not(.plain) { background: var(--accent); border-color: var(--accent); color: #fff; }
body.lesson button.primary:not(.btn):not(.plain):hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.spacer { flex: 1; }

.panel { padding: 24px 26px 26px; }
.panel h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; font-weight: 700; }
.panel h3 { margin: 18px 0 6px; font-size: 17px; font-weight: 700; }
.panel p { margin: 0 0 12px; line-height: 1.55; font-size: 16px; max-width: 72ch; }
.panel .eyebrow { display: block; margin-bottom: 6px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
body.lesson .choice button:not(.btn):not(.plain) { text-align: left; padding: 16px 18px; min-height: 88px; display: block; font-weight: 500; }
.choice b { display: block; font-size: 16px; margin-bottom: 4px; font-weight: 700; }
.choice small { font-weight: 400; color: var(--muted); font-size: 14px; line-height: 1.45; display: block; }
@media (max-width: 640px) { .choice { grid-template-columns: 1fr; } .panel { padding: 20px 18px; } .caption { padding: 14px 16px; } .top h1 { font-size: 21px; } }

/* options for multiple-choice inside a lesson */
.opts { display: grid; gap: 10px; margin: 14px 0 6px; }
.opts button { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .1s var(--ease); }
.opts button:hover:not(:disabled) { border-color: var(--ink); }
.opts button:active:not(:disabled) { transform: scale(.98); }
.opts button:disabled { cursor: default; }
body.lesson .opts button, .opts button { text-align: left; font-weight: 500; padding: 12px 16px; min-height: 52px; line-height: 1.4; display: flex; align-items: center; gap: 12px; }
.opts .key { flex-shrink: 0; width: 28px; height: 28px; border-radius: 7px; background: var(--panel); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.opts button.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.opts button.right { border-color: var(--good); background: var(--good-soft); }
.opts button.right .key { background: var(--good); color: #fff; }
.opts button.wrong { border-color: var(--warn); background: var(--warn-soft); }
.opts button.wrong .key { background: var(--warn); color: #fff; }

/* spectrum drag task */
.spectrum { position: relative; margin: 46px 6px 24px; height: 120px; }
.track { position: absolute; left: 0; right: 0; top: 40px; height: 3px; background: var(--ink); border-radius: 2px; }
.end { position: absolute; top: 52px; font-size: 14px; font-weight: 600; max-width: 40%; }
.end.l { left: 0; } .end.r { right: 0; text-align: right; }
.chip { position: absolute; top: -36px; padding: 6px 12px; font-size: 14px; font-weight: 600; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; cursor: grab; touch-action: none; white-space: nowrap; box-shadow: 0 1px 2px rgba(21,35,59,.08); }
.chip.placed { top: 20px; transform: translateX(-50%); border-color: var(--accent); }
.tick { position: absolute; top: 28px; width: 2px; height: 28px; background: var(--good); display: none; }

/* marking grid and checklists */
table.grid { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 15px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 10px 10px; text-align: left; vertical-align: top; line-height: 1.45; }
table.grid th { font-weight: 600; color: var(--muted); font-size: 14px; border-bottom-color: var(--line-strong); }
table.grid td:first-child, table.grid th:first-child { width: 40px; text-align: center; color: var(--muted); }
table.grid td:last-child, table.grid th:last-child { width: 72px; text-align: center; }
table.grid input { width: 22px; height: 22px; accent-color: var(--accent); }
.check label { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; font-size: 16px; line-height: 1.45; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
body.lesson textarea, .fe-textarea { width: 100%; min-height: 120px; font: 16px/1.55 var(--font); color: var(--ink); padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); resize: vertical; }
body.lesson textarea:focus, .fe-textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.conf { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
body.lesson .conf button { font-weight: 500; }
body.lesson .conf button:not(.btn):not(.plain).sel { background: var(--accent); border-color: var(--accent); color: #fff; }
body.lesson button.piece:not(.btn):not(.plain) { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; min-width: 86px; min-height: 64px; font-weight: 600; }
button.piece span { font-size: 12px; color: var(--muted); font-weight: 500; }
body.lesson button.piece:not(.btn):not(.plain).sel { opacity: .35; }
.model { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 16px; margin: 12px 0 16px; font-size: 16px; line-height: 1.55; }
.label-tool { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }

/* mastery bar */
.bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 6px; }
.bar div { height: 10px; background: var(--line); border-radius: 5px; }
.bar div.full { background: var(--accent); }
.bar div.half { background: repeating-linear-gradient(45deg, var(--accent) 0 4px, var(--accent-soft) 4px 8px); }
.barlabels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; color: var(--muted); }
table.sum { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 15px; }
table.sum td { border-top: 1px solid var(--line); padding: 9px 4px; vertical-align: top; }
table.sum td:last-child { text-align: right; white-space: nowrap; font-weight: 600; }
.note { margin-top: 24px; font-size: 14px; color: var(--muted); line-height: 1.5; }

/* ---------- Learning layer ---------- */
.after { margin-top: 28px; display: grid; gap: 18px; }
.after-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.after-head h2 { margin: 0; font-size: 22px; }
.after-head p { margin: 0; color: var(--muted); font-size: 15px; }

.quiz-q { font-size: 18px; font-weight: 600; line-height: 1.45; margin: 4px 0 4px; max-width: 70ch; }
.quiz-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.quiz-progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 10px 0 16px; }
.quiz-progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s var(--ease); }
.quiz-done { display: grid; gap: 6px; }
.quiz-score { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.mini-matrix { border-collapse: collapse; margin: 10px 0 4px; font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-matrix th, .mini-matrix td { border: 1px solid var(--line-strong); padding: 6px 12px; text-align: center; }
.mini-matrix th { background: var(--panel); font-weight: 600; }
.pa { color: var(--accent); font-weight: 700; } .pb { color: var(--player-b); font-weight: 700; }

/* exam practice */
.exam-q { font-size: 18px; font-weight: 600; line-height: 1.5; max-width: 70ch; margin: 0 0 4px; }
.exam-q .marks { color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 3px; gap: 3px; background: var(--bg); margin: 12px 0 14px; }
body.lesson .seg button, .seg button { min-height: 38px; border: 0; border-radius: 7px; padding: 0 14px; font: inherit; font-size: 15px; font-weight: 600; background: transparent; color: var(--muted); cursor: pointer; }
body.lesson .seg button.on, .seg button.on { background: var(--accent-soft); color: var(--accent); }
.wordcount { font-size: 14px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.paper { background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 18px 22px 22px 56px; font: 20px/32px var(--hand); color: #1A2A6C; white-space: pre-wrap; word-wrap: break-word; min-height: 200px;
  background-image: linear-gradient(to right, transparent 40px, #F2B8B5 40px, #F2B8B5 41px, transparent 41px), repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #D6E0F0 31px, #D6E0F0 32px); background-position: 0 0, 0 17px; }
.photo-answer { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.mark-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; margin: 14px 0; }
.mark-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 22px; align-items: start; }
@media (min-width: 900px) { .mark-split > div:first-child { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; } }
.ao { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ao h4 { margin: 0 0 2px; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.ao h4 span { color: var(--muted); font-weight: 500; font-size: 14px; }
.ao .what { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.band { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1.45; }
.band:hover { background: var(--panel); }
.band input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.band b { white-space: nowrap; }
.band.picked { background: var(--accent-soft); }
.total-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 16px; padding: 14px 0 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.total-line .big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------- Review and starters ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; background: var(--bg); }
.stat .v { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 14px; color: var(--muted); }
.strength { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.strength .track2 { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.strength .track2 span { display: block; width: 0; height: 100%; background: var(--accent); border-radius: 4px; transition: width .8s var(--ease), background-color .2s var(--ease); }
.strength .track2 span.secure { background: var(--good); } /* secure is green everywhere: the tag, the Keep it segment, the bar */

.starter-stage { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 28px 32px; }
.starter-stage ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 18px; counter-reset: s; }
.starter-stage li { counter-increment: s; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start; font-size: 21px; line-height: 1.4; font-weight: 500; }
.starter-stage li::before { content: counter(s); width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.starter-stage .ans { display: block; font-size: 17px; color: var(--good); font-weight: 600; margin-top: 4px; }
.starter-stage .src { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.starter-stage.fullscreen { position: fixed; inset: 0; z-index: 50; border-radius: 0; overflow: auto; padding: 48px 6vw; }
.starter-stage.fullscreen li { font-size: clamp(22px, 2.6vw, 38px); grid-template-columns: 64px minmax(0,1fr); }
.starter-stage.fullscreen li::before { width: 56px; height: 56px; font-size: 26px; }
.starter-stage.fullscreen .ans { font-size: clamp(18px, 2vw, 30px); }
.topic-pick { columns: 2 280px; column-gap: 28px; }
.topic-pick label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; break-inside: avoid; font-size: 15px; cursor: pointer; }
.topic-pick input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  .starter-stage { border: 0; padding: 0; }
  .starter-stage li { font-size: 16pt; }
}

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0s !important; animation-duration: 0s !important; } }

/* ---------- 1 Nov 2026: writing on paper, glossary, chains, progress ---------- */
/* Typed answers look like handwriting on exam paper as you type */
textarea.paper-input, body.lesson textarea.paper-input { font: 20px/32px var(--hand); color: #1A2A6C; padding: 6px 18px 18px 56px; border: 1px solid var(--line-strong); border-radius: 6px; min-height: 256px; background-color: #fff;
  background-image: linear-gradient(to right, transparent 40px, #F2B8B5 40px, #F2B8B5 41px, transparent 41px), repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #D6E0F0 31px, #D6E0F0 32px); background-attachment: local; background-position: 0 0, 0 6px; }
textarea.paper-input::placeholder { color: #8F9BB3; }
/* glossary terms: tap or hover for the definition */
.term { position: relative; display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: help; text-decoration: underline dotted var(--accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
body.lesson button.term:not(.btn):not(.plain) { min-height: 0; padding: 0; border: 0; background: none; font-weight: inherit; border-radius: 0; }
.term-pop { position: absolute; z-index: 60; max-width: 340px; background: var(--ink); color: #fff; font: 14px/1.5 var(--font); font-weight: 400; padding: 10px 12px; border-radius: 10px; box-shadow: 0 8px 24px rgba(21,35,59,.18); }
.term-pop b { display: block; margin-bottom: 2px; }
/* chains of reasoning */
.chain-ico { display: inline-flex; width: 22px; height: 22px; flex-shrink: 0; color: var(--accent); margin-top: 1px; }
.check.chain label { align-items: flex-start; }
.app { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 400; }
.app b { color: var(--accent) !important; }
/* model answers in short paragraphs */
.model p { margin: 0 0 10px; } .model p:last-child { margin-bottom: 0; }
/* a quiet "you called it" */
.called { display: inline-flex; align-items: center; gap: 10px; color: var(--good); font-weight: 700; }
.called svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw-tick .6s .15s var(--ease) forwards; }
@keyframes draw-tick { to { stroke-dashoffset: 0; } }
/* progress: Keep it is green when secure, and explains fading */
.bar div.full.keep { background: var(--good); }
.bar div.half.keep { background: repeating-linear-gradient(45deg, var(--good) 0 4px, var(--good-soft) 4px 8px); }
details.why-fade { margin-top: 10px; font-size: 14px; color: var(--muted); }
details.why-fade summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.why-fade p { margin: 8px 0 0; max-width: 70ch; line-height: 1.55; }
/* model beside the student's drawing */
.side-model { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.side-model svg { width: 100%; height: auto; display: block; }
.side-model .cap2 { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
/* draw stage: your drawing left, the model right */
#diagCard.split { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; align-items: start; }
#diagCard.split > :not(svg):not(.side-model) { grid-column: 1 / -1; }
#diagCard.split .side-model { margin-top: 0; border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 14px; }
#diagCard.split > svg { grid-column: 1; grid-row: 1; } #diagCard.split > .side-model { grid-column: 2; grid-row: 1; }
@media (max-width: 700px) { #diagCard.split { grid-template-columns: 1fr; } #diagCard.split > .side-model { grid-column: 1; grid-row: 2; } #diagCard.split .side-model { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; } }
.conf-note { font-size: 14px; color: var(--muted); margin: 4px 0 0; max-width: 70ch; }
.ao-key { font-size: 14px; color: var(--muted); margin: 4px 0 10px; }
.similar { font-size: 14px; color: var(--muted); margin: 4px 0 0; }

/* Stage bar: completed stages reopen */
#stages button { min-height: 0 !important; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--accent-soft); background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
#stages button::before { content: ""; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translateY(-2px); }
#stages button:hover { border-color: var(--accent); }
#stages button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Walkthrough text fades in word by word */
.fw { animation: fw-in .32s ease-out both; }
@keyframes fw-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .fw { animation: none; } }
/* Pre-question */
.pq p { margin: 0 0 10px; }
.pq .pq-q { font-weight: 600; color: var(--ink); display: flex; gap: 10px; align-items: baseline; }
.q-badge { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; transform: translateY(-1px); }
.pq-hint { margin: 0 0 6px; color: var(--muted); font-style: italic; font-size: 15px; }
/* Notes in the walkthrough and feedback */
.eval-note { display: block; margin-top: 10px; font-size: 15px; }
.eval-note b { color: var(--ink); }
.teacher-tip { display: block; margin-top: 10px; padding-left: 10px; border-left: 2px solid var(--accent); font-size: 15px; }
.teacher-tip b { color: var(--accent); }
mark.hl { background: none; color: inherit; position: relative; z-index: 0; font-weight: 600; white-space: nowrap; }
mark.hl::before { content: ""; position: absolute; left: -3px; right: -3px; bottom: .08em; height: .55em; background: #FBE3A0; border-radius: 3px; z-index: -1; transform: scaleX(0); transform-origin: left center; animation: hlSweep .55s cubic-bezier(.22,.61,.36,1) var(--hl-delay, 0ms) forwards; }
@keyframes hlSweep { to { transform: scaleX(1); } }
.read-q { margin: 8px 0 4px; font-size: 15px; color: var(--muted); }
.read-q p { margin: 0 0 4px; }
.read-q b { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { mark.hl::before { animation: none; transform: none; } }
.tip-note { margin-top: 14px; padding: 10px 14px; border: 1px dashed var(--line-strong); border-radius: 10px; font-size: 15px; color: var(--muted); }
.tip-note b { color: var(--ink); }
/* Labels on diagrams that explain themselves */
.svg-term { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
/* A chain of reasoning built up during the walkthrough */
.chain-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.chain-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; color: var(--muted); }
.chain-list li.new { color: var(--ink); font-weight: 600; }
.chain-list .chain-ico { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--accent); }
/* a chain link joins up: drawn in when it is new or ticked */
.chain-list li.new .chain-ico path { stroke-dasharray: 1; animation: chain-join .7s var(--ease) .15s both; }
.check.chain .chain-ico { color: var(--line-strong); transition: color .2s; }
.check.chain input:checked ~ .chain-ico { color: var(--accent); }
.check.chain input:checked ~ .chain-ico path { stroke-dasharray: 1; animation: chain-join .55s var(--ease) both; }
@keyframes chain-join { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .chain-list li.new .chain-ico path, .check.chain input:checked ~ .chain-ico path { animation: none; } }
.topic-title { font-size: 17px; font-weight: 700; color: var(--ink); margin: 22px 0 8px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.topic-title span { font-size: 13px; font-weight: 500; color: var(--muted); }
.module-title + .topic-title { margin-top: 6px; }

/* Real-world opener photos (Unsplash) */
.story-img { margin: 4px 0 16px; }
.story-img img { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; object-fit: cover; border-radius: 10px; background: var(--accent-soft); }
.story-img figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.story-img figcaption a { color: inherit; }

/* Explore it: live slider diagrams */
.explore { margin-top: 18px; }
.explore-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 760px) { .explore-grid { grid-template-columns: 1fr; } }
.explore-controls label { display: block; font-weight: 600; margin-bottom: 14px; }
.explore-controls .ends { display: flex; justify-content: space-between; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }
.explore-controls input[type=range] { width: 100%; accent-color: var(--accent); min-height: 0; }
.explore-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.explore-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.explore-table td:last-child { text-align: right; }
.explore-table small { color: var(--muted); }
.explore-table .sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 6px; opacity: .6; }
.explore-verdict { margin: 10px 0 0; font-weight: 600; }

/* Exam-board note: a small outlined chip after a sentence, opening what the student's board looks for. Distinct from the dotted-underline definitions. */
.board-note { display: inline-flex; align-items: center; gap: 4px; vertical-align: 1px; margin: 0 0 0 2px; padding: 1px 8px 1px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: var(--accent); font: 600 12px/1.5 var(--font); letter-spacing: .01em; cursor: pointer; white-space: nowrap; }
.board-note:hover { border-color: var(--accent); background: var(--accent-soft); }
body.lesson button.board-note:not(.btn):not(.plain) { min-height: 0; padding: 1px 8px 1px 6px; font-weight: 600; font-size: 12px; border-radius: 6px; color: var(--accent); border: 1px solid var(--line-strong); background: var(--bg); }
body.lesson button.board-note:not(.btn):not(.plain):hover { border-color: var(--accent); background: var(--accent-soft); }
.board-pop { position: absolute; z-index: 61; background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; font: 14px/1.5 var(--font); box-shadow: 0 8px 24px rgba(21,35,59,.14); }
.board-pop p { margin: 8px 0 0; }
.bp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bp-head select { font: 500 13px var(--font); color: var(--ink); text-transform: none; letter-spacing: 0; border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 6px; background: var(--bg); }
.grid tr.grid-head td { padding-top: 14px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
table.grid tr.grid-head td:last-child { text-align: left; width: auto; }
table.grid td label + .board-note { margin-left: 6px; }

/* Class sign-in and class dashboard */
.class-card { max-width: 820px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field label { font-weight: 600; font-size: 15px; }
.field input:not([type=checkbox]), .field textarea { font: inherit; font-size: 17px; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--ink); max-width: 420px; }
.field textarea { max-width: 100%; min-height: 0; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field input[aria-invalid=true] { border-color: var(--warn); }
.field .check { font-weight: 400; display: flex; gap: 8px; align-items: center; font-size: 15px; }
.hint { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.msg { font-size: 15px; color: var(--muted); }
.muted { color: var(--muted); }
.code { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; font-weight: 600; }
.warn-card { border-color: var(--line-strong); }
.btn-danger { background: var(--bg); color: var(--warn); border-color: var(--warn); }
.btn-danger:hover { background: var(--warn-soft); }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row input { flex: 1 1 280px; font: inherit; font-size: 15px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); color: var(--ink); }
table.data { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 15px; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-size: 13px; font-weight: 600; color: var(--muted); border-bottom-color: var(--line-strong); }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.sub-card { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.class-list { list-style: none; margin: 0 0 8px; padding: 0; }
.class-list li + li { border-top: 1px solid var(--line); }
.class-list a { display: flex; justify-content: space-between; padding: 12px 0; color: var(--ink); text-decoration: none; }
.class-list a:hover strong { color: var(--accent); }
.file-btn { cursor: pointer; }
ol.missed { margin: 8px 0 0; padding-left: 22px; }
ol.missed li { margin: 0 0 10px; line-height: 1.45; }
ol.missed .src, ol.starter-qs .src { display: block; font-size: 13px; color: var(--muted); }
ol.starter-qs { margin: 16px 0 0; padding-left: 22px; font-size: 18px; }
ol.starter-qs li { margin-bottom: 14px; }
ol.starter-qs .ans { display: block; margin-top: 4px; color: var(--accent-ink); font-weight: 600; }
@media (max-width: 640px) { table.data th:nth-child(4), table.data td:nth-child(4) { display: none; } }
@media print { #done .warn-card, #done .controls, #done .copy-row { display: none !important; } }

/* present mode: the lesson on the classroom board */
.present-btn { font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 14px; cursor: pointer; margin-left: auto; }
.present-btn:hover { border-color: var(--ink); }
.present-exit { display: none; }
body.present .lesson-bar, body.present #after, body.present .wrap > .note, body.present .top .route { display: none; }
body.present .present-exit { display: block; position: fixed; top: 12px; right: 14px; z-index: 50; font: inherit; font-size: 14px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; cursor: pointer; opacity: .6; }
body.present .present-exit:hover { opacity: 1; }
body.present .wrap { max-width: min(1500px, 96vw); padding-top: 14px; }
body.present svg.diagram { max-height: 66vh; }
body.present .caption p, body.present .panel p, body.present .quiz-q { font-size: 24px; line-height: 1.45; max-width: 80ch; }
body.present .panel h2 { font-size: 34px; }
body.present .top h1 { font-size: 26px; }
@media print { .present-btn, .present-exit { display: none !important; } }

/* Homepage: what to do today (returning students only) */
.today { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.today .card { padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.today h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.today .v { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.today p { margin: 0; font-size: 15px; color: var(--muted); }
.today .controls { margin-top: auto; padding-top: 10px; }

/* Previous and next lesson at the foot of every lesson */
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.lesson-nav a { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); color: var(--ink); text-decoration: none; transition: border-color .15s var(--ease); }
.lesson-nav a:hover { border-color: var(--line-strong); }
.lesson-nav a:hover strong { color: var(--accent); }
.lesson-nav a.next { text-align: right; }
.lesson-nav .k { font-size: 14px; color: var(--muted); }
.lesson-nav strong { font-size: 16px; font-weight: 600; transition: color .15s var(--ease); }
@media (max-width: 560px) { .lesson-nav { grid-template-columns: 1fr; } .lesson-nav a.next { text-align: left; } }

/* ---------- 3 Nov 2026: readable lesson text before the script runs, exam question pages ---------- */
/* Lesson text written into the HTML for search engines and no-script readers. Hidden once scripts run,
   because the interactive lesson replaces it straight away. */
.js .fe-static { display: none; }
.fe-static { max-width: 760px; padding: 24px 0 40px; }
.fe-static h1 { font-size: 32px; line-height: 1.15; margin: 0 0 12px; }
.fe-static h2 { font-size: 22px; margin: 32px 0 10px; }
.fe-static h3 { font-size: 18px; margin: 20px 0 8px; }
.fe-static li { margin-bottom: 10px; }

/* Exam-style question pages */
.q-page { max-width: 860px; padding-top: 48px; padding-bottom: 64px; }
.q-page h1 { font-size: clamp(30px, 3.6vw, 40px); line-height: 1.1; margin: 8px 0 12px; }
.q-intro { color: var(--muted); font-size: 18px; margin: 0 0 20px; max-width: 680px; }
.q-section { margin-top: 40px; }
.q-section h2 { font-size: 22px; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.q-item { margin: 0 0 26px; break-inside: avoid; }
.q-q { margin: 0 0 8px; font-weight: 500; display: flex; gap: 12px; }
.q-n { font-weight: 700; min-width: 24px; }
.q-marks { margin-left: auto; padding-left: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.q-opts { margin: 0 0 8px 36px; padding-left: 18px; }
.q-opts li { margin-bottom: 4px; }
.q-data { margin: 0 0 22px; }
table.data { border-collapse: collapse; margin: 10px 0; font-variant-numeric: tabular-nums; }
table.data th, table.data td { width: 150px; }
table.data th, table.data td { border: 1px solid var(--ink); padding: 6px 12px; text-align: center; min-width: 90px; }
table.data th { font-weight: 600; }
.q-ans { margin: 4px 0 0 36px; }
.q-ans summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.q-ans ul { margin: 8px 0; padding-left: 20px; }
.q-ans h3 { font-size: 16px; margin: 14px 0 4px; }
.q-lines, .q-draw { display: none; }
@media print {
  body { font-size: 11pt; color: #000; }
  .q-page { padding: 0; max-width: none; }
  .q-intro { color: #000; }
  .q-marks { color: #000; }
  .q-section h2 { border-bottom: 1px solid #000; }
  .q-ans { display: none; }
  .print-answers .q-ans { display: block; margin-left: 36px; }
  .q-ans summary { color: #000; }
  .q-lines { display: block; -webkit-print-color-adjust: exact; print-color-adjust: exact; margin: 6px 0 0 36px; height: calc(var(--n) * 9mm); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(9mm - 1px), #000 calc(9mm - 1px), #000 9mm); }
  .print-answers .q-lines, .print-answers .q-draw { display: none; }
  .q-draw { display: block; margin: 6px 0 0 36px; height: 90mm; border: 1px solid #000; }
  table.data th, table.data td { border-color: #000; }
}
