:root {
  --ink: #1b1b1b;
  --muted: #5b6170;
  --line: #d5d8de;
  --line-strong: #9aa0aa;
  --paper: #ffffff;
  --page: #f5f6f8;
  --accent: #003262;      /* Berkeley blue */
  --accent-2: #fdb515;    /* California gold */
  --accent-soft: #e8eef6;
  --good: #1d7a3a;
  --good-soft: #e6f4ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn-soft: #fff6dc;
  --code-bg: #f7f7f9;
  --serif: "CMU Serif", "Latin Modern Roman", "Computer Modern", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: "CMU Typewriter Text", "Latin Modern Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

code, .mono { font-family: var(--mono); font-size: 0.93em; }
p code, li code, .rich code { background: var(--code-bg); padding: 0 3px; border-radius: 3px; }

/* ─────────── Buttons ─────────── */
.btn { border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0b4a85; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-home { display: inline-flex; align-items: center; gap: 6px; }
.btn-home svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.btn-sm.btn-home svg { width: 14px; height: 14px; }

/* ─────────── Home ─────────── */
.home { max-width: 1080px; margin: 0 auto; padding: 32px 20px 64px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.home h1 { font-family: var(--serif); font-size: 34px; line-height: 1.2; margin: 0; color: var(--accent); }
.home .tagline { color: var(--muted); margin: 4px 0 0; }
.feedback-row { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.feedback-row + .notice { margin-top: 10px; }
.btn-feedback { background: var(--accent-2); border-color: #d99a00; color: var(--ink); text-decoration: none; }
.btn-feedback:hover:not(:disabled) { background: #f5a800; }
.feedback-note { font-size: 13px; color: var(--accent); font-weight: 600; }
.notice { font-size: 13px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 18px 0; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); border: 1px solid #f0d27a; border-radius: 10px; padding: 14px 16px; margin: 18px 0; }
.resume strong { display: block; }
.resume .actions { display: flex; gap: 8px; }

.home-brand { background: none; border: 0; padding: 0; text-align: left; }
.home-brand:hover h1 { text-decoration: underline; text-decoration-thickness: 2px; }
.link { color: var(--accent); background: none; border: 0; padding: 0; text-decoration: underline; font-size: 13px; }

/* Setup card with dropdown menus */
.setup-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 20px 0; box-shadow: 0 4px 18px rgba(0,0,0,.05); }
.dd-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dd { position: relative; }
.dd-btn { width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left; background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; column-gap: 8px; }
.dd-btn:hover { border-color: var(--accent); }
.dd.open .dd-btn { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.dd-label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.dd-val { grid-row: 2; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-caret { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--muted); transition: transform .15s; }
.dd.open .dd-caret { transform: rotate(180deg); }
.dd-num { cursor: text; }
.dd-num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.dd-num-input { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; -moz-appearance: textfield; appearance: textfield; }
.dd-num-input::-webkit-outer-spin-button, .dd-num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dd-num-input:focus, .dd-num-input:focus-visible { outline: none; }
.dd-num-unit { font-weight: 600; }
.dd-step { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.dd-step-btn { border: 0; background: none; color: var(--muted); font-size: 10px; line-height: 1; padding: 2px 5px; border-radius: 4px; cursor: pointer; }
.dd-step-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.dd-step-btn:disabled { opacity: .35; cursor: default; }
.dd-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 100%; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.16);
  max-height: min(420px, 62vh); overflow-y: auto; overscroll-behavior: contain; } /* long lists (more past exams) scroll inside the menu */
.dd-sub { display: flex; align-items: baseline; gap: 12px; padding: 8px 6px 4px; margin-top: 4px; border-top: 1px solid var(--line); }
.dd-sub:first-child, .dd-group + .dd-sub { border-top: 0; margin-top: 0; }
.dd-sub-name { flex: 1; font-size: 12.5px; font-weight: 700; }
.dd-sub-tools { display: flex; gap: 12px; font-size: 12.5px; }
.dd.wide .dd-panel { width: min(520px, 92vw); }
.dd-tools { display: flex; gap: 14px; padding: 0 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-list { display: grid; gap: 2px; }
.dd-list.cols { grid-template-columns: 1fr 1fr; column-gap: 8px; }
.dd-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.dd-opt:hover { background: var(--accent-soft); }
.dd-opt.disabled { opacity: .45; cursor: not-allowed; }
.dd-opt input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.dd-txt { flex: 1; }
.dd-extra { font-size: 12px; color: var(--accent); font-weight: 700; background: var(--accent-soft); border-radius: 999px; padding: 0 8px; }
.dd-panel .hint { margin: 8px 6px 0; }
.timer-config { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 6px; }
.timer-config input[type=number] { width: 72px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; font: inherit; }
.timer-config label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.err { color: var(--bad); font-size: 12.5px; margin: 6px 6px 0; }
.start-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.start-row .summary { color: var(--muted); font-size: 14px; }
.start-row .summary b { color: var(--ink); }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* Landing (home image) */
.landing { position: relative; height: 100vh; overflow: hidden; background: #3d8be0; }
.landing-hit { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; }
.landing-hit img { width: 100%; height: 100%; object-fit: cover; object-position: 18% center; display: block; user-select: none; }
.landing-hit:hover img { filter: brightness(1.04); }
.landing-hit:focus-visible { outline: 4px solid var(--accent-2); outline-offset: -4px; }
.landing-foot { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.landing-foot > * { pointer-events: auto; }
.landing-hint { background: rgba(0,50,98,.72); color: #fff; font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 999px; animation: pulse 2.4s ease-in-out infinite; }
.landing-resume { background: var(--accent-2); color: var(--ink); border: 0; border-radius: 999px; padding: 8px 18px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
@keyframes pulse { 50% { opacity: .55; } }
@font-face { font-family: "Patrick Hand"; src: url("assets/patrick-hand.woff2") format("woff2"); font-display: swap; }
.landing-privacy { font-size: 12px; color: #fff; text-shadow: 0 1px 3px rgba(0,30,70,.85); text-align: center; padding: 0 12px; }
.landing-privacy a { color: #fff; text-decoration: underline; font-weight: 600; }
.landing-byline { font-family: "Patrick Hand", "Comic Sans MS", cursive; font-size: 17px; color: #fff; text-shadow: 0 1px 3px rgba(0,30,70,.75); letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) { .landing-hint { animation: none; } }

/* ─────────── Practice shell ─────────── */
.practice { height: 100vh; display: grid; grid-template-rows: auto auto auto 1fr auto; background: var(--paper); }
.p-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 24px; gap: 12px; }
.p-header .brand { font-weight: 800; color: var(--accent); white-space: nowrap; }
.p-header .brand-row { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.p-header .set-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-header .left { min-width: 0; }
.p-header .center { display: flex; flex-direction: column; align-items: center; }
.tool-key { list-style: none; margin: 0 0 12px; padding: 0; font-family: var(--sans); font-size: 13.5px; }
.tool-key li { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; }
.tool-key-icon { flex: none; display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.tool-key-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.directions-btn { background: none; border: 0; padding: 0; font-weight: 600; font-size: 13px; color: var(--ink); }
.directions { position: absolute; top: 64px; left: 24px; z-index: 30; max-width: 440px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.15); font-family: var(--serif); font-size: 15px; }
.p-header .progress { font-weight: 700; font-size: 14px; }
.timer { justify-self: end; display: flex; align-items: center; gap: 8px; }
.timer .clock { font-family: var(--mono); font-size: 22px; font-weight: 700; min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.timer .clock.low { color: var(--bad); }
.timer .clock.hidden-clock { color: transparent; text-shadow: 0 0 8px rgba(0,0,0,.35); }
.timer .tctl { display: flex; gap: 4px; }
.rule { height: 3px; background: repeating-linear-gradient(90deg, var(--accent) 0 30px, transparent 30px 34px, var(--accent-2) 34px 52px, transparent 52px 56px); opacity: .9; }

.expired-banner { background: var(--bad-soft); color: var(--bad); border-bottom: 1px solid #f1c3bd; padding: 8px 24px; font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.p-main { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; position: relative; }
.pane { overflow-y: auto; padding: 24px 36px 40px; min-height: 0; }
.pane-left { padding-top: 0; }
.pane-left { border-right: 3px solid var(--line); }

/* Left pane: exam-style problem context */
.problem { font-family: var(--serif); font-size: 16px; line-height: 1.55; max-width: 720px; position: relative; }

/* Annotation toolbar + layers */
.annot-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 2px; background: var(--paper); padding: 8px 0; margin-bottom: 6px; border-bottom: 1px solid var(--line); max-width: 720px; }
.ann-btn { width: 32px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: none; border-radius: 6px; color: var(--ink); padding: 0; }
.ann-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ann-btn:hover:not(:disabled) { background: #f0f1f3; }
.ann-btn:disabled { opacity: .35; cursor: default; }
.ann-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ann-btn[data-ann="pen"] { color: #c62828; }
.ann-btn[data-ann="pen"][aria-pressed="true"] { color: #c62828; border-color: #c62828; background: #fdecea; }
.ann-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.annot-hint { font-family: var(--sans); font-size: 12px; color: var(--muted); margin-left: 8px; }
mark.hl { background: #fff176; color: inherit; border-radius: 2px; padding: 0; }
.annot-layer { position: absolute; left: 0; top: 0; z-index: 10; pointer-events: none; overflow: visible; }
.annot-layer path { fill: none; stroke: #d62828; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.problem[data-mode="pen"] .annot-layer { pointer-events: auto; cursor: crosshair; touch-action: none; }
.problem[data-mode="eraser"] .annot-layer { pointer-events: auto; cursor: cell; touch-action: none; }
/* iPad exams: Apple Pencil draws on both panes (app.js, pencilInk), so the overlay never catches fingers and
   the right pane carries its own ink layer. Fingers scroll and tap as usual. */
.ipad .pane-right { position: relative; }
.pencil-ink .problem .annot-layer { pointer-events: none; }
.p-main.pencil-ink:has(.problem[data-mode="pen"], .problem[data-mode="eraser"]) .pane { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.p-main.pencil-ink .pane :is(input, textarea, .CodeMirror) { -webkit-user-select: text; user-select: text; } /* still typeable */
/* iPad exams: the environment diagram is paper. Its own toolkit and frame / binding editing are off; the main pen
   draws over it. It is laid out at full size so the ink (in the pane's coordinates) stays on it. */
.p-main.pencil-ink .dg-bar { display: none; }
.p-main.pencil-ink .dg-canvas, .p-main.pencil-ink .dg-canvas * { pointer-events: none !important; }
.p-main.pencil-ink .dg-scroll { max-height: none; overflow: visible; }
/* iPad exams: the annotation toolbar leaves the top of the left pane and becomes a column on the divider between
   the panes, over their padding only, so it is in reach from both sides and covers no content. (Its containing
   block is .p-main, outside the scrolling pane, so it stays put while either pane scrolls.) */
.p-main.pencil-ink #annot-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); flex-direction: column; gap: 1px; max-width: none; margin: 0; padding: 4px 3px; border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: 0 4px 14px rgba(0, 0, 0, .14); z-index: 20; }
.p-main.pencil-ink #annot-bar .ann-btn { width: 34px; height: 32px; }
.p-main.pencil-ink .pane-left { padding-top: 24px; } /* the toolbar no longer sits at the top */
.p-main:not(.pencil-ink) .pen-color-wrap { display: none; } /* e.g. once time runs out */
.p-main.pencil-ink #annot-bar .ann-sep { width: 20px; height: 1px; margin: 3px 0; }
.p-main.pencil-ink #annot-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; } /* still read out */
.p-main.pencil-ink #annot-bar .ann-btn[data-ann="pen"], .p-main.pencil-ink #annot-bar .ann-btn[data-ann="pen"][aria-pressed="true"] { color: var(--pen, #c62828); border-color: currentColor; }
.p-main.pencil-ink #annot-bar .ann-btn[data-ann="pen"][aria-pressed="false"] { border-color: transparent; }
.p-main.pencil-ink #annot-bar .exam-settings { top: 0; left: calc(100% + 8px); }
/* Pen colour: a dot under the Pen opens Red / Blue / Black */
.pen-color-wrap { position: relative; display: inline-flex; }
.p-main.pencil-ink #annot-bar .pen-color-btn { height: 20px; margin-top: -2px; }
.pc-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--pen, #d62828)); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px rgba(0, 0, 0, .25); }
.pen-colors { position: absolute; left: calc(100% + 8px); top: -8px; z-index: 40; display: flex; flex-direction: column; gap: 2px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .14); font-family: var(--sans); font-size: 14px; }
.pen-colors[hidden] { display: none; }
.pc-item { display: flex; align-items: center; gap: 10px; min-width: 104px; height: 38px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink); text-align: left; }
.pc-item[aria-checked="true"] { border-color: var(--c); font-weight: 700; }
@media (max-width: 820px) { /* one column of panes: a row in the bottom-right corner, just above the bottom bar */
  .p-main.pencil-ink #annot-bar { position: fixed; flex-direction: row; left: auto; top: auto; right: 12px; bottom: calc(var(--fh, 64px) + 10px); transform: none; padding: 3px 4px; }
  .p-main.pencil-ink #annot-bar .ann-sep { width: 1px; height: 20px; margin: 0 3px; }
  .p-main.pencil-ink #annot-bar .pen-color-btn { width: 22px; height: 32px; margin: 0 0 0 -3px; }
  .p-main.pencil-ink #annot-bar .exam-settings, .p-main.pencil-ink .pen-colors { top: auto; bottom: calc(100% + 8px); left: auto; right: 0; }
  .p-main.pencil-ink #annot-bar .exam-settings { right: -4px; }
}

/* Sticky notes: a layer over both panes. Only its notes take clicks. */
.note-layer { position: absolute; inset: 0; z-index: 15; overflow: hidden; pointer-events: none; font-family: var(--sans); }
.snote { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; background: #fffbd9; border: 1px solid #ebdf9f; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .16); pointer-events: auto; }
.snote.dragging { box-shadow: 0 12px 28px rgba(0, 0, 0, .24); }
.snote-bar { flex: none; display: flex; align-items: center; justify-content: space-between; height: 24px; padding: 0 3px 0 9px; background: #f8efbd; border-bottom: 1px solid #ebdf9f; border-radius: 5px 5px 0 0; cursor: grab; touch-action: none; user-select: none; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #7a6a24; }
.snote.dragging .snote-bar { cursor: grabbing; }
.snote-btns { display: flex; gap: 1px; }
.snote-hbtn { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: none; color: #7a6a24; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.snote-hbtn:hover { background: rgba(0, 0, 0, .08); }
/* Each note has its own toolbar */
.snote-tools { flex: none; display: flex; align-items: center; gap: 1px; padding: 2px 4px; background: #fffde8; border-bottom: 1px solid #f1e8bd; }
.snote-tools .ann-btn { width: 22px; height: 22px; border-radius: 4px; }
.snote-tools .ann-btn svg { width: 15px; height: 15px; }
.snote-tools .ann-btn:hover:not(:disabled) { background: rgba(0, 0, 0, .06); }
.snote-tools .ann-btn[aria-pressed="true"] { background: var(--accent-soft); }
.snote-tools [data-nt="pen"] { color: #c62828; }
.snote-tools .ann-sep { height: 14px; margin: 0 3px; }
/* The body: items are placed from the top-left corner of .snote-canvas, so resizing only adds or removes space */
.snote-body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.snote-canvas { position: absolute; left: 8px; top: 8px; }
.snote-empty { position: absolute; left: 10px; right: 10px; top: 10px; margin: 0; font-size: 13px; color: #9a8b4a; pointer-events: none; }
.nitem { position: absolute; box-sizing: border-box; padding-top: 12px; border-radius: 4px; }
.nitem-grip { position: absolute; left: 0; top: 1px; width: 28px; height: 9px; border-radius: 3px; cursor: grab; touch-action: none; opacity: 0; transition: opacity .1s;
  background: radial-gradient(circle, #c2b26a 1.1px, transparent 1.5px) 1px 0 / 5px 4.5px; }
.nitem:hover .nitem-grip, .nitem.sel .nitem-grip, .nitem:focus-within .nitem-grip { opacity: 1; }
.nitem.sel { outline: 1px dashed #d4c47a; outline-offset: 2px; }
.nitem.dragging { opacity: .9; }
.nitem.dragging .nitem-grip { cursor: grabbing; }
.nitem.clash { outline: 2px solid #d62828; }
.snote[data-tool="select"] .tree-canvas { cursor: grab; }
.snote[data-tool="select"] .tnode { cursor: auto; }
/* A text box is as wide as its text (up to the max-width set by fitTexts, then it wraps): the mirror of the text sets
   the size and draws the highlights; the transparent text box sits exactly on top of it. Same font and padding. */
.nitem-text { width: max-content; min-width: 60px; }
.snote-textwrap { position: relative; }
.snote-mirror, .snote-text { box-sizing: border-box; padding: 2px 4px; font: 14px/1.45 var(--sans); white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.snote-mirror { position: relative; padding-right: 8px; color: transparent; pointer-events: none; }
.snote-mirror mark { background: #a6dcff; color: transparent; border-radius: 2px; }
.snote-text { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; overflow: hidden; resize: none; border: 0; border-radius: 3px; outline: none; background: transparent; color: var(--ink); }
.snote-text:focus { box-shadow: inset 0 0 0 1px #e3d58f; }
.snote-ink { position: absolute; left: 0; top: 0; z-index: 2; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.snote-ink path { fill: none; stroke: #d62828; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
/* Tools: pen and eraser draw on the note, the tree tool places a tree, the highlighter selects in blue */
.snote[data-tool="select"] .snote-body { cursor: text; }
.snote[data-tool="pen"] .snote-body, .snote[data-tool="eraser"] .snote-body { cursor: crosshair; touch-action: none; }
.snote[data-tool="eraser"] .snote-body { cursor: cell; }
.snote[data-tool="pen"] .snote-body *, .snote[data-tool="eraser"] .snote-body * { pointer-events: none; }
.snote[data-tool="tree"] .snote-body { cursor: copy; }
.snote[data-tool="hl"] .snote-text::selection { background: #a6dcff; }
.snote[data-tool="hl"] .tnode-input { cursor: pointer; }
.snote[data-tool="eraser"] .snote-mirror mark, .snote[data-tool="eraser"] .tnode-input.hl { outline: 1px dashed #b3261e; }
.snote-size { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; border-radius: 0 0 5px 0;
  background: linear-gradient(135deg, transparent 52%, #d4c47a 52%, #d4c47a 60%, transparent 60%, transparent 72%, #d4c47a 72%, #d4c47a 80%, transparent 80%); }
.tree-canvas { position: relative; }
.tree-edges { position: absolute; left: 0; top: 0; overflow: visible; }
.tree-edges line { stroke: #333; stroke-width: 1.4; }
.tree-edges marker path { fill: #333; }
.tnode { position: absolute; width: 34px; height: 34px; }
.tnode-input { box-sizing: border-box; width: 34px; height: 34px; padding: 0 3px; border: 1.5px solid #333; border-radius: 50%; background: #fff; color: var(--ink); text-align: center; font: 13px var(--mono); outline: none; }
.tnode-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tnode-input.hl { background: #a6dcff; }
.tnode-btn { position: absolute; right: -13px; width: 17px; height: 17px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; font-size: 13px; line-height: 14px; cursor: pointer; opacity: 0; transition: opacity .1s; }
.tnode-add { bottom: -5px; color: var(--accent); font-weight: 700; }
.tnode-del { top: -5px; color: #b3261e; }
.tnode:hover .tnode-btn, .tnode:focus-within .tnode-btn, .tnode-btn:focus { opacity: 1; }
.tnode-btn:hover { background: var(--accent-soft); }
/* Minimized notes: numbered icons in the bottom-left corner. The ghost is the note being pulled into its icon. */
.snote-ghost { pointer-events: none; z-index: 60; font-family: var(--sans); }
.p-footer .left { display: flex; align-items: center; min-width: 0; }
.note-dock { display: flex; gap: 8px; margin: 0 auto; padding: 0 12px; overflow-x: auto; }
.note-dock:empty { display: none; }
.dock-note { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; flex: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .2)); }
.dock-note svg { position: absolute; inset: 0; width: 36px; height: 36px; fill: #fffbd9; stroke: #d4c47a; stroke-width: 1.4; stroke-linejoin: round; }
.dock-note svg path + path { fill: #f8efbd; }
.dock-num { position: relative; margin: -4px 3px 0 0; font: 700 13px/1 var(--sans); color: #7a6a24; }
.dock-note:hover svg { fill: #fff6c4; stroke: #b8a65a; }
.dock-note:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.problem[data-mode="eraser"] mark.hl, .problem[data-mode="eraser"] .cm-hl { outline: 1px dashed #b3261e; }
.problem[data-mode="hl"] .annot-text, .problem[data-mode="hl"] .CodeMirror-lines { cursor: text; }
.problem[data-mode="hl"] ::selection { background: #fff59d; }
.problem .src { font-family: var(--sans); font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.tag { font-family: var(--sans); font-size: 11.5px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; color: var(--muted); background: var(--paper); }
.tag.diff-easy { border-color: #9cd3ad; color: var(--good); }
.tag.diff-medium { border-color: #f0c96b; color: #8a6100; }
.tag.diff-hard { border-color: #eba59d; color: var(--bad); }
.problem h2 { font-size: 18px; margin: 0 0 8px; font-weight: 700; }
.problem h2 .pts { font-weight: 700; margin-right: 14px; }
.problem p { margin: 0 0 10px; }

/* Diagram workspace (right pane) */
.dg { margin-bottom: 18px; font-family: var(--sans); }
.dg summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 2px 0 6px; }
.dg-note { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.dg-bar { flex-wrap: wrap; max-width: none; }
.dg-bar .annot-hint { flex-basis: 100%; margin: 2px 0 0; min-height: 16px; }
.ann-btn[data-dg="pen"] { color: #c62828; }
.dg-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.dg-canvas { position: relative; user-select: none; }
.rich-pre { font-family: var(--mono); font-size: 13px; line-height: 1.45; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin: 8px 0; overflow-x: auto; white-space: pre; }
.exam-figure { margin: 10px 0 12px; }
.exam-figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.exam-figure figcaption { font-family: var(--sans); font-size: 12px; color: var(--muted); margin-top: 4px; }
.dg-canvas img { position: absolute; left: 0; top: 0; display: block; max-width: none; }
.dg-layer { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }
.dg-layer path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dg-pen { stroke: #d62828; stroke-width: 2.2; opacity: .9; }
.dg-arrow { stroke: var(--accent); stroke-width: 1.8; }
.dg-dot { fill: var(--accent); }
.dg-handle { fill: #fff; stroke: var(--accent); stroke-width: 1.5; }
.dg-text { position: absolute; font-family: var(--mono); font-size: 13px; line-height: 20px; height: 22px; min-width: 3ch; padding: 0 2px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--accent); outline: none; cursor: grab; touch-action: none; }
.dg-text:hover { border-color: var(--line-strong); }
.dg-text.selected, .dg-text:focus { border-color: var(--accent); background: #fff; }
.dg-text:focus { cursor: text; }
.dg-slot { cursor: text; background: rgba(0, 50, 98, .06); }
.dg-canvas:not([data-mode="select"]) .dg-slot:not(:focus) { background: transparent; border-color: transparent; } /* drawing: only typed text shows */
.dg-list { position: absolute; font-family: var(--mono); font-size: 13px; cursor: grab; touch-action: none; }
.dg-grip { font-family: var(--sans); font-size: 11px; color: var(--muted); line-height: 14px; padding-left: 1px; }
.dg-list.selected .dg-grip { color: var(--accent); font-weight: 600; }
.dg-cells { display: flex; align-items: center; }
.dg-cell { display: flex; flex-direction: column; background: #ffffc6; border: 1px solid #66625a; border-left-width: 0; padding: 0 1px; }
.dg-cell:first-child { border-left-width: 1px; }
.dg-index { font-family: var(--sans); font-size: 10px; line-height: 11px; color: #77736a; padding-left: 2px; }
.dg-cell-input { font: inherit; line-height: 18px; height: 20px; padding: 0 2px; border: 0; background: transparent; color: var(--ink); outline: none; text-align: center; }
.dg-cell-input:focus { background: #fff; }
.dg-list-btns { display: inline-flex; margin-left: 4px; gap: 2px; }
.dg-list-btn { width: 18px; height: 18px; padding: 0; line-height: 16px; font-size: 14px; color: var(--accent); background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; }
.dg-list-btn:hover:not(:disabled) { background: var(--accent-soft); }
.dg-list-btn:disabled { opacity: .35; cursor: default; }
.dg-snap { outline: 2px solid var(--accent); outline-offset: 1px; }
.dg-canvas[data-mode="pen"] .dg-list-btns, .dg-canvas[data-mode="eraser"] .dg-list-btns { display: none; }
.dg-canvas[data-mode="list"] .dg-list-btn, .dg-canvas[data-mode="arrow"] .dg-list-btn { pointer-events: auto; } /* + and − work with these tools too */
.dg-canvas:not([data-mode="select"]) .dg-list { pointer-events: none; }
.dg-canvas[data-mode="pen"], .dg-canvas[data-mode="arrow"], .dg-canvas[data-mode="list"] { cursor: crosshair; touch-action: none; }
.dg-canvas[data-mode="eraser"] { cursor: cell; touch-action: none; }
.dg-canvas[data-mode="select"] { cursor: text; }
.dg-canvas:not([data-mode="select"]) .dg-text { pointer-events: none; }

/* Scratch code editor (CodeMirror, dark like PrairieLearn) */
.editor { border: 1px solid #1e1f1c; border-radius: 8px; overflow: hidden; margin: 10px 0 6px; font-family: var(--sans); }
.editor-head { display: flex; align-items: center; gap: 10px; background: #f1f2f4; border-bottom: 1px solid #1e1f1c; padding: 7px 10px 7px 14px; }
.editor-file { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--ink); }
.editor-status { font-size: 12px; color: var(--muted); }
.editor-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ed-confirm { font-size: 12.5px; color: var(--bad); font-weight: 600; }
.editor .CodeMirror { height: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; }
.editor .CodeMirror-scroll { min-height: 120px; }
.editor .CodeMirror-gutters { border-right: 1px solid #3a3b35; }
.editor .CodeMirror-lines { padding: 6px 0; }
/* Code blanks: display derived from the student's answers (template text is never rewritten) */
.cm-slot { white-space: pre; display: inline-block; vertical-align: top; border-radius: 3px; cursor: pointer; padding: 0 1px; }
.cm-slot.empty { color: #b9b59a; background: rgba(253,181,21,.12); border-bottom: 1px dashed #fdb515; }
.cm-slot.filled-mc { color: #9ee8ff; background: rgba(102,217,239,.16); border-bottom: 2px solid #66d9ef; }
.cm-slot.filled-typed { color: #c3f08a; background: rgba(166,226,46,.13); border-bottom: 2px dashed #a6e22e; }
.cm-slot.current { outline: 2px solid #fdb515; outline-offset: 1px; }
/* a select-all blank shows its first checked option; the tag counts the others (Run Code tests each one) */
.cm-slot[data-more]::after { content: attr(data-more); margin-left: 6px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-family: var(--sans); color: #1b1b1b; background: #9ee8ff; vertical-align: 1px; }
.run-option { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.run-option-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.run-option-head code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.run-option-sum { font-weight: 700; }
.run-option-sum.tests-all { color: var(--good); }
.run-option-sum.tests-some { color: var(--bad); }
.cm-slot:hover { filter: brightness(1.25); }
.cm-hl { background: rgba(255,235,59,.38); }
.key-fill { font-family: var(--mono); font-size: 11.5px; padding: 0 5px; border-radius: 3px; background: #272822; white-space: nowrap; }
.key-fill.key-mc { color: #9ee8ff; border-bottom: 2px solid #66d9ef; }
.key-fill.key-typed { color: #c3f08a; border-bottom: 2px dashed #a6e22e; }
.editor-fallback { display: block; width: 100%; min-height: 320px; border: 0; padding: 10px 12px; font-family: var(--mono); font-size: 13.5px; background: #272822; color: #f8f8f2; resize: vertical; }
/* Run Code (Phase 6A): run bar + Console Output under the scratch editor */
.run-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f1f2f4; border-top: 1px solid #1e1f1c; padding: 6px 10px; }
.btn-run { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-run:hover:not(:disabled) { background: #0b4a85; }
.btn-run[aria-busy="true"] { cursor: progress; }
#tutor-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
#tutor-btn[aria-disabled="true"]:hover { background: var(--paper); }
.tutor-msg { font-size: 13px; font-weight: 600; color: var(--bad); }
.run-status { font-size: 12.5px; color: var(--muted); }
.run-status.st-ok { color: var(--good); font-weight: 600; }
.run-status.st-error, .run-status.st-timeout, .run-status.st-load-error, .run-status.st-crash { color: var(--bad); font-weight: 600; }
.run-console { border-top: 1px solid var(--line); background: var(--paper); padding: 8px 10px 10px; font-size: 13px; }
.run-label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.run-out, .run-err { font-family: var(--mono); font-size: 13px; margin: 0 0 6px; padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.run-out { background: var(--code-bg); border: 1px solid var(--line); color: var(--ink); }
.run-err { background: var(--bad-soft); border: 1px solid #f1c3bd; color: #7a1610; }
.run-empty { margin: 0 0 6px; color: var(--muted); font-style: italic; }
.run-msg { margin: 0 0 6px; }
.run-suite { font-size: 12.5px; color: var(--muted); }
.run-tests { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.tests-summary { margin: 0 0 8px; font-weight: 700; font-size: 14px; }
.tests-summary.tests-all { color: var(--good); }
.tests-summary.tests-some { color: var(--ink); }
.cases { display: grid; gap: 6px; }
.case { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.case > summary { cursor: pointer; padding: 6px 10px; display: flex; align-items: center; gap: 8px; }
.case > summary:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.case-mark { font-weight: 700; width: 1em; text-align: center; }
.case-state { margin-left: auto; font-size: 12.5px; font-weight: 600; }
.tests-note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.case-origin { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.st-case-passed .case-mark, .st-case-passed .case-state { color: var(--good); }
.st-case-failed .case-mark, .st-case-failed .case-state, .st-case-error .case-mark, .st-case-error .case-state,
.st-case-timeout .case-mark, .st-case-timeout .case-state { color: var(--bad); }
.st-case-not-run .case-mark, .st-case-not-run .case-state { color: var(--muted); }
.case-body { padding: 4px 10px 8px; border-top: 1px solid var(--line); }
.case-ex + .case-ex { margin-top: 8px; padding-top: 8px; border-top: 1px dotted var(--line); }
.case-k { font-size: 11.5px; font-weight: 700; color: var(--muted); margin: 4px 0 2px; }
.case-v { font-family: var(--mono); font-size: 13px; margin: 0; padding: 6px 8px; border-radius: 4px; background: var(--code-bg); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.case-v.case-bad { border-color: var(--bad); }
.editor-hint { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin: 4px 0 14px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--paper); }

/* Right pane: question */
.q-bar { display: flex; align-items: center; gap: 12px; background: #f0f1f3; border-bottom: 2px dashed var(--line-strong); margin-bottom: 16px; }
.q-num { background: var(--ink); color: #fff; font-weight: 800; padding: 6px 12px; font-size: 16px; }
.mark-btn { background: none; border: 0; display: inline-flex; align-items: center; gap: 6px; padding: 6px 4px; font-weight: 500; }
.mark-btn svg { width: 16px; height: 18px; }
.mark-btn[aria-pressed="true"] { color: #b3261e; font-weight: 700; }
.mark-btn[aria-pressed="true"] svg path { fill: #b3261e; stroke: #b3261e; }
.q-bar .qtype { margin-left: auto; margin-right: 10px; font-size: 12px; color: var(--muted); }

.question { font-family: var(--serif); font-size: 16px; line-height: 1.55; max-width: 680px; }
.part { border-left: 3px solid transparent; padding: 6px 0 8px 12px; margin-left: -15px; border-radius: 2px; transition: border-color .15s, background .15s; }
.part.active { border-left-color: var(--accent-2); background: #fffdf4; }
.part-sep { border: 0; border-top: 1px dashed var(--line-strong); margin: 18px 0; }
.part-meta { display: block; font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.part-meta .diff-easy { color: var(--good); } .part-meta .diff-medium { color: #8a6100; } .part-meta .diff-hard { color: var(--bad); }
.question .q-head { margin: 0 0 12px; }
.question .q-head .lbl { font-weight: 700; margin-right: 6px; }
.question .q-head .pts { font-weight: 700; margin-right: 6px; }

/* Exam-style choices: plain vertical list with circular bubbles / square boxes, no letters */
.choices { list-style: none; margin: 4px 0 18px; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: 2px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 3px 8px; border-radius: 4px; cursor: pointer; position: relative; }
.choice:hover { background: #f3f5f8; }
.choice input { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 15px; height: 15px; margin: 4px 0 0; border: 1px solid #555; background: var(--paper); cursor: pointer; }
.choice input[type=radio] { border-radius: 50%; }
.choice input[type=checkbox] { border-radius: 1px; width: 14px; height: 14px; }
.choice input[type=radio]:checked { box-shadow: inset 0 0 0 3px var(--paper); background: var(--ink); }
.choice input[type=checkbox]:checked { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.choice input:disabled { cursor: default; }
.choice .txt { white-space: pre-wrap; }
.choices.mono .txt { font-family: var(--mono); font-size: 14px; }
.choice.correct { background: var(--good-soft); }
.choice.correct .txt::after { content: "  ✓ Correct"; font-family: var(--sans); font-size: 12px; color: var(--good); font-weight: 700; white-space: nowrap; }
.choice.wrong { background: var(--bad-soft); }
.choice.wrong .txt::after { content: "  ✗ Your choice"; font-family: var(--sans); font-size: 12px; color: var(--bad); font-weight: 700; white-space: nowrap; }
.choice.missed .txt::after { content: "  ← Also correct"; font-family: var(--sans); font-size: 12px; color: var(--good); font-weight: 700; }

/* Answer elimination (Digital SAT style): struck-through letter bubble on the right; "Undo" once eliminated */
.choices li { display: flex; align-items: flex-start; gap: 8px; }
.choices li .choice { flex: 1; min-width: 0; }
.elim-btn { flex: 0 0 auto; min-width: 44px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; padding: 0 4px; border-radius: 4px; color: var(--ink); font-family: var(--sans); }
.elim-mark { position: relative; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid currentColor; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; }
.elim-mark::after { content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: 1.5px; margin-top: -0.75px; background: currentColor; }
.elim-btn:hover { background: #f0f1f3; }
.elim-btn:hover .elim-mark { background: var(--paper); }
.elim-btn.undo { font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.elim-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 1px; }
.choice.eliminated .txt { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--line-strong); }
.choice.eliminated input { border-color: var(--line-strong); }
.choice.eliminated .txt::after { display: inline-block; white-space: pre; text-decoration: none; } /* keep grading tags readable */

/* Exam-style answer box */
.answer-box { border: 1px solid #777; background: var(--paper); margin: 4px 0 18px 22px; }
.answer-box textarea { display: block; width: 100%; min-height: 64px; border: 0; resize: vertical; padding: 10px 12px; font-family: var(--mono); font-size: 14px; background: transparent; }
.answer-box textarea:focus { outline: none; }
.answer-box:focus-within { box-shadow: 0 0 0 3px var(--accent-2); }
.answer-box.code textarea { min-height: 120px; }
.selfcheck-note { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin: -10px 0 14px 22px; }

.q-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: 22px; font-family: var(--sans); }
.feedback { font-family: var(--sans); margin: 16px 0 0 22px; border-radius: 8px; padding: 12px 14px; font-size: 14px; border: 1px solid var(--line); }
.feedback.good { background: var(--good-soft); border-color: #b5dcc1; }
.feedback.bad { background: var(--bad-soft); border-color: #f1c3bd; }
.feedback.info { background: var(--accent-soft); border-color: #c4d3e6; }
.feedback .title { font-weight: 700; margin-bottom: 4px; }
.feedback pre { font-family: var(--mono); background: var(--paper); border: 1px solid var(--line); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; margin: 6px 0; font-size: 13.5px; }
.feedback .alts { font-size: 12.5px; color: var(--muted); }
.feedback .selfgrade { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.feedback .selfgrade .chosen { outline: 2px solid var(--accent); }

/* Footer */
.p-footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 24px; border-top: 3px solid var(--line); position: relative; }
.p-footer .right { justify-self: end; display: flex; gap: 8px; }
.nav-toggle { background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 700; }
.nav-toggle:hover { background: #33363d; }
.nav-toggle:focus-visible { outline-offset: 3px; }
.navigator { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 40; width: min(560px, 94vw); max-height: min(520px, calc(100vh - 150px)); overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px 18px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.nav-head { position: sticky; top: -14px; z-index: 1; display: flex; align-items: center; justify-content: center; background: var(--paper); margin: -14px -18px 0; padding: 12px 44px 2px; }
.navigator h4 { margin: 0; text-align: center; font-size: 16px; }
.nav-close { position: absolute; right: 10px; top: 8px; width: 32px; height: 32px; border: 0; background: none; border-radius: 6px; font-size: 16px; color: var(--muted); }
.nav-close:hover { background: #f0f1f3; color: var(--ink); }
.nav-sub { margin: 0 0 8px; text-align: center; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { display: flex; justify-content: center; gap: 6px 18px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px; }
.nav-cell { height: 40px; border: 1.5px dashed var(--line-strong); background: var(--paper); font-weight: 700; color: var(--accent); position: relative; border-radius: 3px; }
.nav-cell.answered { border-style: solid; background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-cell.partial { border-style: solid; border-color: var(--accent); background: linear-gradient(135deg, var(--accent) 0 50%, var(--accent-soft) 50%); color: #fff; text-shadow: 0 0 3px var(--accent); }
.nav-cell:hover { border-style: solid; border-color: var(--accent); }
.nav-cell.answered:hover { background: #0b4a85; }
/* Current = double ring via box-shadow, so the keyboard focus outline can show on top of it. */
.nav-cell.current { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.nav-cell:focus-visible { outline-offset: 5px; }
.nav-cell.marked::after { content: ""; position: absolute; top: -6px; right: -4px; width: 9px; height: 12px; background: #b3261e; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.nav-cell.good::before, .nav-cell.bad::before { position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%); font-size: 10px; }
.nav-cell.good::before { content: "✓"; color: #9ef0b8; }
.nav-cell.bad::before { content: "✗"; color: #ffb4a8; }
.legend .sw { width: 12px; height: 12px; display: inline-block; border: 1.5px dashed var(--line-strong); }
.legend .sw.cur { border: 1.5px solid var(--line-strong); box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 3px var(--ink); }
.legend .sw.ans { background: var(--accent); border: 1.5px solid var(--accent); }
.legend .sw.part { border: 1.5px solid var(--accent); background: linear-gradient(135deg, var(--accent) 0 50%, var(--accent-soft) 50%); }
.legend .sw.mk { background: #b3261e; border: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.navigator .go-review { display: flex; justify-content: center; margin-top: 14px; }

/* ─────────── Mode switch & exam setup (home) ─────────── */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 0; }
.mode-opt { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 16px; color: var(--ink); }
.mode-opt b { font-size: 16px; }
.mode-opt span { font-size: 13px; color: var(--muted); }
.mode-opt:hover { border-color: var(--accent); }
.mode-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: var(--accent-soft); }
.mode-opt[aria-pressed="true"] b { color: var(--accent); }
/* Practice setup: Language (Python / Gleam / SQL coming soon), above the filters */
.lang-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.lang-label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.lang-opt { display: inline-flex; align-items: baseline; gap: 6px; background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 999px; padding: 6px 16px; font-weight: 600; font-size: 14px; color: var(--ink); }
.lang-opt:hover:not(:disabled) { border-color: var(--accent); }
.lang-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent) inset; background: var(--accent-soft); color: var(--accent); }
.lang-opt.soon { border-style: dashed; color: var(--muted); cursor: not-allowed; opacity: .75; }
.lang-opt small { font-size: 11.5px; font-weight: 600; }
/* With Language: All, the Topics and Sources menus list each language under a heading */
.dd-group { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }
.dd-group:first-of-type { margin-top: 2px; }
.exam-setup .step { padding: 4px 0 14px; }
.exam-setup .step + .step { border-top: 1px solid var(--line); padding-top: 14px; }
.exam-setup h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; }
.kind-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-list { display: grid; gap: 8px; }
.exam-kind-row { margin-bottom: 12px; }
.kind-note { font-size: 13px; line-height: 1.45; color: var(--ink); background: var(--warn-soft); border: 1px solid #f0d27a; border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.dd-sub-name { color: var(--ink); }
.kind-opt { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.kind-opt:hover { border-color: var(--line-strong); background: #fafbfc; }
.kind-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.kind-opt input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
.kind-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kind-txt small { color: var(--muted); font-size: 12.5px; }
.tag.tag-ok { border-color: #9cd3ad; color: var(--good); background: var(--good-soft); }
.tag.tag-warn { border-color: #f0c96b; color: #8a6100; background: var(--warn-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip { border: 1px solid var(--line-strong); background: var(--paper); border-radius: 999px; padding: 3px 11px; font-size: 13px; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.pick-search { width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; margin-bottom: 10px; }
.pick-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.pick-list { border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow-y: auto; padding: 4px; }
.pick-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.pick-row:hover { background: #f3f5f8; }
.pick-row.on { background: var(--accent-soft); }
.pick-row input { accent-color: var(--accent); width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto; }
.pick-txt { min-width: 0; display: flex; flex-direction: column; }
.pick-name { font-size: 14px; overflow-wrap: anywhere; }
.pick-meta { font-size: 12px; color: var(--muted); }
.pick-empty { padding: 8px 10px; margin: 0; }
.picked { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbfc; align-self: start; }
.picked-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; margin-bottom: 6px; }
.picked .hint { margin: 0; }
.picked-list { margin: 0; padding-left: 22px; font-size: 14px; }
.picked-list li { padding: 3px 0; }
.picked-list li span { display: inline; }
.picked-list small { color: var(--muted); white-space: nowrap; }
.unpick { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 0 4px; margin-left: 4px; border-radius: 4px; }
.unpick:hover { color: var(--bad); background: var(--bad-soft); }
.history h2 { font-family: var(--serif); color: var(--accent); font-size: 22px; margin: 26px 0 10px; }
.result-row.hist-row { grid-template-columns: minmax(0, 1fr) auto; }
/* Practice history: a row is the set (opens it) plus a Delete button */
.hist-item { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.hist-item:first-child { border-top: 0; }
.hist-item .result-row { flex: 1; min-width: 0; border-top: 0; }
.hist-del { flex: 0 0 auto; width: 44px; border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.hist-del:hover { background: var(--bad-soft); color: var(--bad); }
.badge.set-done { background: var(--good-soft); color: var(--good); }
.badge.set-open { background: var(--bad-soft); color: var(--bad); }
/* ─────────── My Progress ─────────── */
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-progress { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-progress:hover:not(:disabled) { background: #00264a; }
.mp-top { margin-bottom: 4px; }
/* Home: the My Progress card above Practice Mode / Exam Mode (the whole card is one button) */
.mp-teaser { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 14px; padding: 16px 22px; margin: 18px 0 14px; box-shadow: 0 4px 18px rgba(0,0,0,.05); transition: border-color .12s, box-shadow .12s; }
.mp-teaser:hover { border-color: var(--accent); box-shadow: 0 6px 22px rgba(0,50,98,.12); }
.mp-teaser-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mp-teaser-h { display: inline-flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--accent); }
.mp-teaser-h svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.mp-teaser-sub { font-size: 14px; color: var(--muted); }
.mp-teaser-go { font-size: 14px; font-weight: 700; color: var(--accent); margin-top: 4px; }
.mp-teaser-rings { display: flex; gap: 22px; flex: 0 0 auto; }
.mp-teaser .ring, .mp-teaser .ring svg { width: 96px; }
.mp-teaser .ring svg, .mp-teaser .ring-mid { height: 96px; }
.mp-teaser .ring-mid b { font-size: 21px; }
.mp-teaser .ring figcaption { font-size: 12px; margin-top: 4px; }
.mp-teaser .ring figcaption b { color: var(--ink); }
.band-done .ring-arc { stroke: var(--accent); }
@media (max-width: 560px) {
  .mp-teaser { flex-direction: column; align-items: flex-start; }
  .mp-teaser-rings { align-self: center; }
}
.mp-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 16px 0; box-shadow: 0 4px 18px rgba(0,0,0,.05); }
.mp-card h2 { font-family: var(--serif); color: var(--accent); font-size: 22px; margin: 0; }
.progress .mp-h1 { font-size: 30px; }
.mp-sub { margin: 6px 0 12px; font-size: 13.5px; }
.mp-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 8px 0 4px; }
.mp-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.mp-stat b { font-size: 30px; line-height: 1.1; color: var(--ink); }
.mp-stat b small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.mp-stat span { font-size: 13px; color: var(--muted); }
.mp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mh-filter { position: relative; }
.mh-filter .dd-panel { left: auto; right: 0; min-width: 240px; }
.mh-filter-btn { white-space: nowrap; }
.mh-list, .mp-topics { list-style: none; margin: 0; padding: 0; }
.mh-card { position: relative; margin-top: 10px; }
/* the whole card is one button that opens the set; Delete sits on top of it, right of the status label */
.mh-open { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; font: inherit; color: inherit; background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 52px 12px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.mh-open:hover { border-color: var(--accent); background: #f6f8fb; }
.mh-main { min-width: 0; display: flex; flex-direction: column; }
.mh-title { font-size: 16.5px; font-weight: 700; overflow-wrap: anywhere; }
.mh-del { position: absolute; top: 12px; right: 14px; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px;
  background: var(--paper); color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer; }
.mh-del:hover { background: var(--bad-soft); color: var(--bad); border-color: #f0b8b2; }
.mh-auto { display: inline-block; vertical-align: 2px; font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--accent); background: #e8eef6; border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.mh-meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.mh-status { flex: 0 0 auto; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.mh-status.st-completed { background: var(--good-soft); color: var(--good); }
.mh-status.st-incomplete { background: var(--bad-soft); color: var(--bad); }
.mh-status.st-progress { background: var(--warn-soft); color: #7a5600; }
.mp-topic { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mp-topic:first-child { border-top: 0; }
.mp-topic-name { font-size: 15.5px; }
.mp-topic-n { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
/* Topics to Review: bars + rings on the left, topic picker + list on the right */
.tr-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; margin-top: 10px; align-items: start; }
.tr-charts { min-width: 0; }
/* bars: All (one per language); Python, Gleam and SQL (one per topic) */
.tr-chart-bars { padding: 6px 0 4px; }
.tr-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.tr-bar { width: 100%; display: grid; grid-template-columns: 128px minmax(0, 1fr) 46px; align-items: center; gap: 12px; font: inherit; color: inherit; text-align: left; background: none; border: 0; padding: 6px 4px; border-radius: 10px; }
button.tr-bar { cursor: pointer; }
button.tr-bar:hover { background: #f3f5f8; }
.tr-bar-name { font-weight: 600; font-size: 15px; }
.tr-bar.none .tr-bar-name, .tr-bar.none .tr-bar-val { color: var(--line-strong); }
.tr-bar-track { height: 18px; background: #edf0f3; border-radius: 999px; overflow: hidden; }
.tr-bar-fill { display: block; height: 100%; width: var(--w); border-radius: 999px; background: var(--line-strong); transition: width 1s cubic-bezier(.33, 1, .68, 1); }
.tr-bar-fill.band-good { background: #2e9e57; }
.tr-bar-fill.band-mid { background: #e3a400; }
.tr-bar-fill.band-bad { background: #d2402f; }
.tr-bar-val { font-weight: 700; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.tr-charts.anim .tr-bar-fill { width: 0; }
.tr-langs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tr-rings { display: flex; justify-content: center; gap: 28px; margin-top: 8px; }
.ring { position: relative; margin: 0; width: 132px; text-align: center; }
.ring svg { display: block; width: 132px; height: 132px; }
.ring-track { fill: none; stroke: #edf0f3; stroke-width: 11; }
.ring-arc { fill: none; stroke: var(--line-strong); stroke-width: 11; stroke-linecap: round; stroke-dashoffset: var(--off); transition: stroke-dashoffset 1s cubic-bezier(.33, 1, .68, 1); }
.band-none .ring-arc { stroke: transparent; }
.band-good .ring-arc { stroke: #2e9e57; }
.band-mid .ring-arc { stroke: #e3a400; }
.band-bad .ring-arc { stroke: #d2402f; }
.ring-mid { position: absolute; left: 0; right: 0; top: 0; height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.ring-mid b { font-size: 28px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.ring-num { display: inline-flex; align-items: baseline; }
.ring-num i { font-style: normal; font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.ring-mid small { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.ring figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
/* before the charts scroll into view: the bars and rings empty */
.tr-charts.anim .ring-arc { stroke-dashoffset: var(--c); }
@media (prefers-reduced-motion: reduce) {
  .ring-arc, .tr-bar-fill { transition: none; }
}
.tr-side { min-width: 0; }
.tr-pick { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tr-pick span { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tr-pick select { flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 8px 10px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--ink); }
.tr-up { display: inline-block; font-size: 12px; font-weight: 700; color: var(--good); background: var(--good-soft); border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: 1px; }
.tr-side .mp-topic { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
.tr-side .mp-topic-go { grid-column: 2; grid-row: 1 / span 2; }
.tr-side .mp-topic-n { grid-column: 1; }
@media (max-width: 760px) {
  .tr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .tr-rings { gap: 14px; }
  .ring, .ring svg { width: 118px; }
  .ring svg, .ring-mid { height: 118px; }
}
.mp-empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
@media (max-width: 640px) {
  .mp-stats { grid-template-columns: 1fr; }
  .mh-open { flex-direction: column; gap: 8px; padding-right: 14px; }
  .mh-del { top: auto; bottom: 12px; }
  .mp-topic { grid-template-columns: minmax(0, 1fr) auto; }
  .mp-topic-go { grid-column: 1 / -1; justify-self: start; }
}
.storage-warn { font-size: 14px; line-height: 1.45; background: var(--bad-soft); border: 1px solid #f0b8b2; color: var(--ink); border-radius: 10px; padding: 12px 16px; margin: 18px 0; }

/* ─────────── Exam taking & review ─────────── */
.mode-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: var(--accent); color: #fff; border-radius: 4px; padding: 0 6px; }
.btn-submit { background: var(--accent-2); border-color: #d99a00; color: var(--ink); }
.btn-submit:hover:not(:disabled) { background: #f5a800; }
.banner-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.stale-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20, 24, 33, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.stale-card { background: var(--paper); border-radius: 14px; padding: 22px 24px; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.stale-card h2 { margin: 0 0 8px; font-family: var(--serif); color: var(--accent); font-size: 22px; }
.stale-card p { margin: 0 0 16px; }

/* ─────────── First-visit tour (tour.js) ─────────── */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-dim { position: absolute; inset: 0; width: 100%; height: 100%; }
.tour-dim path { fill: rgba(20, 24, 33, .55); }
.tour-ring { position: absolute; border: 3px solid var(--accent-2); border-radius: 10px; pointer-events: none; }
.tour-card { position: absolute; width: min(360px, calc(100vw - 32px)); background: var(--paper); border-radius: 14px; padding: 16px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); font-size: 14.5px; }
.tour-welcome .tour-card { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); padding: 22px 24px; }
.tour-card h2 { margin: 0 0 8px; font-family: var(--serif); color: var(--accent); font-size: 20px; }
.tour-welcome .tour-card h2 { font-size: 22px; }
.tour-card p { margin: 0 0 10px; }
.tour-card ul { margin: 0 0 10px; padding-left: 18px; }
.tour-card li + li { margin-top: 4px; }
.tour-kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 2px !important; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.tour-end { margin-right: auto; }
.tour-card .tool-key { margin-bottom: 4px; }
/* Diagram demos: a small looping animation inside the tip card */
.tour-demo { position: relative; height: 150px; margin: 4px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; font-family: var(--mono); font-size: 12px; color: var(--ink); }
.tour-demo > * { position: absolute; }
.td-ink { left: 0; top: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.td-ink line { stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: 4 3; }
.td-ink line.done { stroke-dasharray: none; marker-end: url(#td-head); }
.td-ink marker path { fill: var(--accent); }
.td-cursor { left: 0; top: 0; width: 16px; height: 22px; z-index: 3; }
.td-cursor svg { display: block; width: 16px; height: 22px; transform-origin: 1px 1px; }
.td-cursor path { fill: #111; stroke: #fff; stroke-width: 1.2; }
.td-cursor.click svg { animation: td-click .2s ease; }
@keyframes td-click { 45% { transform: scale(.7); } }
.td-bar { display: flex; gap: 4px; }
.td-tool { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.td-tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.td-tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.td-frame { width: 130px; height: 56px; border: 1px solid #333; }
.td-label { position: absolute; left: 6px; top: 3px; }
.td-var { position: absolute; left: 46px; top: 28px; }
.td-slot { width: 40px; height: 18px; line-height: 18px; padding-left: 4px; border-bottom: 1px solid #333; background: var(--accent-soft); }
.td-box { min-width: 12px; height: 20px; line-height: 18px; padding: 0 4px; border: 1px dashed var(--accent); }
.td-list { display: flex; align-items: center; gap: 4px; }
.td-cells { display: flex; }
.td-cell { width: 24px; height: 22px; line-height: 20px; text-align: center; border: 1px solid #333; margin-left: -1px; background: #fff; }
.td-btns span { display: inline-block; width: 16px; height: 16px; line-height: 14px; margin-left: 2px; text-align: center; color: var(--accent); border: 1px solid var(--line-strong); border-radius: 4px; font-family: var(--sans); }
.td-slot.typing::after, .td-box.typing::after, .td-cell.typing::after, .td-lbl.typing::after { content: ''; display: inline-block; width: 1px; height: 13px; margin-left: 1px; vertical-align: -2px; background: var(--ink); animation: td-caret 1s steps(1) infinite; }
.td-cell.active { outline: 2px solid var(--accent-2); }
/* Sticky note demo: two halves (problem | answers), the chooser, a tree note that is dragged across and resized. */
.tour-demo[data-demo="note"] { height: 214px; }
.td-foot { left: 0; right: 0; height: 28px; border-top: 2px solid var(--line); background: var(--paper); font-family: var(--sans); font-size: 10px; }
.td-exit { position: absolute; left: 8px; top: 7px; }
.td-qbtn { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); padding: 2px 7px; border-radius: 4px; background: var(--ink); color: #fff; font-weight: 700; }
.td-divider { width: 0; height: 160px; border-left: 3px solid var(--line); }
.td-pane-label { font-family: var(--sans); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.td-nmin { right: 5px; top: 0; font-family: var(--sans); font-size: 11px; font-weight: 700; line-height: 15px; color: #6b5a00; }
.td-ntools { left: 0; right: 0; top: 15px; height: 17px; display: flex; gap: 2px; padding-left: 3px; background: #fffde8; border-bottom: 1px solid #f1e8bd; }
.td-ntools span { display: inline-flex; width: 14px; height: 14px; margin-top: 1px; border: 1px solid transparent; border-radius: 2px; }
.td-ntools span.on { background: var(--accent-soft); border-color: var(--accent); }
.td-ntools svg { width: 12px; height: 12px; margin: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.td-ntext { left: 9px; top: 40px; font-family: var(--sans); font-size: 12px; white-space: nowrap; }
.td-ntext.typing::after { content: ''; display: inline-block; width: 1px; height: 11px; margin-left: 1px; vertical-align: -2px; background: var(--ink); animation: td-caret 1s steps(1) infinite; }
.td-dock { z-index: 2; width: 22px; height: 22px; box-sizing: border-box; border: 1px solid #d4c47a; border-radius: 3px 3px 8px 3px; background: #fffbd9; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); font-family: var(--sans); font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; color: #6b5a00; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .2s; }
.td-dock.show { opacity: 1; transform: none; }
.td-note { z-index: 1; box-sizing: border-box; background: #fffbd9; border: 1px solid #ebdf9f; border-radius: 5px; box-shadow: 0 4px 12px rgba(0, 0, 0, .14); }
.td-note > * { position: absolute; }
.td-note-bar { left: 0; right: 0; top: 0; height: 15px; padding-left: 6px; background: #f8efbd; border-bottom: 1px solid #ebdf9f; border-radius: 4px 4px 0 0; font-family: var(--sans); font-size: 8.5px; font-weight: 700; line-height: 15px; letter-spacing: .05em; text-transform: uppercase; color: #6b5a00; }
.td-note-ink { left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.td-note-ink line { stroke: #333; stroke-width: 1.2; marker-end: url(#td-head-n); }
.td-note-ink marker path { fill: #333; }
.td-node { width: 22px; height: 22px; box-sizing: border-box; border: 1.3px solid #333; border-radius: 50%; background: #fff; text-align: center; line-height: 20px; font-size: 12px; }
.td-plus { position: absolute; right: -11px; bottom: -4px; width: 11px; height: 11px; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; color: var(--accent); font-family: var(--sans); font-size: 9px; font-weight: 700; line-height: 9px; text-align: center; opacity: 0; transition: opacity .15s; }
.td-node.show .td-plus { opacity: 1; }
.td-grip { right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 0 0 4px 0; background: linear-gradient(135deg, transparent 50%, #c9ad2c 50%, #c9ad2c 62%, transparent 62%, transparent 76%, #c9ad2c 76%, #c9ad2c 88%, transparent 88%); }
@keyframes td-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .td-cursor.click svg, .td-slot.typing::after, .td-box.typing::after, .td-cell.typing::after { animation: none; } }
.review-banner { background: var(--accent-soft); color: var(--accent); border-bottom: 1px solid #c4d3e6; padding: 8px 24px; font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mark-btn.static { color: #b3261e; font-weight: 600; cursor: default; }
.feedback .verdict { font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.feedback.good .verdict { color: var(--good); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .staff-note { margin: -2px 0 10px; }

/* ─────────── Review workspace (submitted exam) ─────────── */
.review-work { max-width: 720px; margin-top: 18px; padding-top: 14px; border-top: 3px solid var(--accent-2); font-family: var(--serif); font-size: 16px; line-height: 1.55; }
.rw-head h3 { font-family: var(--sans); font-size: 15px; margin: 0; color: var(--accent); }
.rw-head .hint { font-family: var(--sans); margin: 2px 0 12px; }
.review-work .part { margin-left: 0; padding-left: 10px; }
.rv-title { font-weight: 700; font-size: 14px; }
.rv-part .q-head { margin: 0 0 8px; }
.rv-part .part-meta .badge { margin-left: 4px; }
.rv-block { font-family: var(--sans); font-size: 14px; margin: 0 0 10px 22px; }
.rv-k { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.rv-k span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.rv-pre { font-family: var(--mono); font-size: 13.5px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rv-none, .rv-same { font-family: var(--sans); font-size: 13px; color: var(--muted); margin: 0 0 10px 22px; }
.rv-block .rv-none { margin-left: 0; }
.rv-current { border-left: 3px solid var(--accent-2); padding-left: 10px; }
.choices.static { padding-left: 0; margin: 0 0 4px; }
.choices.static .choice { cursor: default; }
.choices.static .choice:hover { background: none; }
.choices.static .choice.correct:hover { background: var(--good-soft); }
.choices.static .choice.wrong:hover { background: var(--bad-soft); }
.bubble { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 4px; border: 1px solid #555; border-radius: 50%; background: var(--paper); }
.bubble.box { border-radius: 1px; width: 14px; height: 14px; }
.bubble.on { background: var(--ink); box-shadow: inset 0 0 0 3px var(--paper); }
.bubble.box.on { box-shadow: inset 0 0 0 2px var(--paper); }
.expl-label { font-weight: 700; margin-top: 8px; }
.expl-label span { font-weight: 500; font-size: 12px; color: var(--muted); }

/* ─────────── Results ─────────── */
.results { max-width: 900px; margin: 0 auto; padding: 32px 20px 64px; }
.results h1 { font-family: var(--serif); color: var(--accent); margin: 0 0 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat.good .v { color: var(--good); }
.stat.bad .v { color: var(--bad); }
.result-list { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.result-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; }
.result-row:first-child { border-top: 0; }
.result-row:hover { background: #f7f8fa; }
.result-row .n { font-weight: 800; color: var(--accent); }
.result-row .n small { display: block; font-weight: 600; font-size: 11px; color: var(--muted); }
.result-row .t { min-width: 0; }
.result-row .t small { display: block; color: var(--muted); }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.badge.correct { background: var(--good-soft); color: var(--good); }
.badge.incorrect { background: var(--bad-soft); color: var(--bad); }
.badge.ungraded { background: var(--accent-soft); color: var(--accent); }
.badge.skipped { background: #eee; color: #555; }
.results .actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 2px; }
.score-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 18px 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 18px; align-items: start; box-shadow: 0 4px 18px rgba(0,0,0,.05); }
.score-main .k { font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.score-main .v { font-family: var(--serif); font-size: 48px; font-weight: 700; color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-main .v span { font-size: 26px; color: var(--muted); }
.score-card .stats { margin: 0; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.table-wrap { position: relative; /* keeps the .sr-only header inside the scroll box */ overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-table th, .result-table td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.result-table thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; white-space: nowrap; }
.result-table tbody th { font-weight: 800; color: var(--accent); white-space: nowrap; }
.result-table .sub { font-weight: 600; color: var(--muted); }
.result-table td small { display: block; color: var(--muted); }
.result-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.score-main .v.none { font-family: var(--sans); font-size: 20px; color: var(--ink); }
.disclaimer-strong { font-size: 13px; color: var(--ink); background: var(--warn-soft); border: 1px solid #f0d27a; border-radius: 8px; padding: 8px 12px; margin: 0 0 14px; }
.rq-h, .insights h2 { font-family: var(--serif); color: var(--accent); font-size: 22px; margin: 26px 0 4px; }
.rq-list { display: grid; gap: 8px; margin-top: 10px; }
.rq-group { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.rq-group > summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.rq-group > summary::-webkit-details-marker { display: none; }
.rq-group > summary:hover { background: #f7f8fa; border-radius: 10px; }
.rq-n { font-weight: 800; color: var(--accent); min-width: 22px; }
.rq-n::before { content: "▸ "; color: var(--muted); font-weight: 400; }
.rq-group[open] .rq-n::before { content: "▾ "; }
.rq-title { min-width: 0; font-weight: 600; }
.rq-title small { display: block; font-weight: 400; color: var(--muted); }
.rq-sum { font-size: 12.5px; color: var(--muted); text-align: right; }
.part-rows { list-style: none; margin: 0; padding: 0 14px 10px; }
.part-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pr-lbl { font-weight: 700; }
.pr-topics { color: var(--muted); font-size: 13px; }
.pr-pts { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
.insights { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 6px 18px 16px; margin: 26px 0 16px; }
.insights:focus { outline: none; }
.insights:focus-visible { outline: 3px solid var(--accent-2); }
.insights h2 { margin-top: 12px; }
.insights h3 { font-size: 15px; margin: 18px 0 6px; }
.insight-empty { font-size: 15px; }
.topic-list { margin: 4px 0 0; padding-left: 20px; }
.topic-list li { padding: 2px 0; }
.topic-list .hint { margin: 0; }
.guide { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
.guide > summary { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; cursor: pointer; font-weight: 600; }
.guide > summary .g-meta { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.guide[open] > summary { border-bottom: 1px solid var(--line); }
.guide-body { padding: 4px 14px 10px; }
.concept { padding: 8px 0; }
.concept + .concept { border-top: 1px dashed var(--line); }
.concept h5 { font-size: 14.5px; margin: 0 0 4px; color: var(--accent); }
.concept p { margin: 0 0 6px; font-size: 14px; }
.concept-code { font-family: var(--mono); font-size: 13px; background: #272822; color: #f8f8f2; border-radius: 6px; padding: 8px 10px; overflow-x: auto; margin: 6px 0; }
.pitfall { background: var(--warn-soft); border-radius: 6px; padding: 6px 10px; }
.rec-topic h5 { font-size: 14px; margin: 12px 0 4px; }
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rec-txt { min-width: 0; }
.rec-txt .hint { display: block; margin: 0; }

@media (max-width: 1000px) and (min-width: 821px) { .dd-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ─────────── Mobile ─────────── */
/* Walkthrough videos (YouTube playlists): Exam Results heading / group headers, Practice Summary section */
.btn-walk { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; background: #fff; color: #17458a; border: 1.5px solid #17458a; border-radius: 999px; font-weight: 600; min-height: 30px; transition: background-color .15s ease; }
.btn-walk:hover { background: #eaf2ff; }
.btn-walk:focus-visible { outline: 2px solid #17458a; outline-offset: 2px; }
.btn-walk svg { width: 17px; height: 17px; flex: 0 0 auto; display: block; }
.btn-walk .yt-box { fill: currentColor; }
.btn-walk .yt-tri { fill: #fff; }
@media (prefers-reduced-motion: reduce) { .btn-walk { transition: none; } }
.rq-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; }
.rq-head .rq-h { margin-bottom: 4px; }
.rq-head .btn-walk { margin-bottom: 4px; }
.rq-group.has-walk > summary { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.rq-walk { display: inline-flex; }
.walk-sec { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin: 0 0 16px; }
.walk-h { margin: 0; font-size: inherit; }
.walk-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: none; border: 0; border-radius: 10px; text-align: left; font-family: var(--sans); font-size: 14.5px; font-weight: 700; color: var(--accent); cursor: pointer; }
.walk-toggle:hover { background: #f7f8fa; }
.walk-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.walk-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.walk-title { flex: 1; }
.walk-chev { color: var(--muted); transition: transform .15s; }
.walk-sec.collapsed .walk-chev { transform: rotate(-90deg); }
.walk-body { border-top: 1px solid var(--line); padding: 2px 14px 4px; }
.walk-desc { margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); }
.walk-list { list-style: none; margin: 0; padding: 0; }
.walk-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.walk-row:first-child { border-top: 0; }
.walk-ex { min-width: 0; font-size: 14px; font-weight: 600; }
.walk-ex small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .walk-chev { transition: none; } }

@media (max-width: 820px) {
  .practice { height: auto; min-height: 100vh; grid-template-columns: minmax(0, 1fr); }
  .p-header { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .p-header .center { display: none; }
  .p-main { grid-template-columns: minmax(0, 1fr); } /* long code lines scroll inside the editor, not the page */
  .pane { overflow: visible; padding: 18px 16px 24px; }
  .pane-left { border-right: 0; border-bottom: 3px solid var(--line); }
  .p-footer { position: sticky; bottom: 0; background: var(--paper); grid-template-columns: auto 1fr; padding: 10px 16px; }
  /* Practice hides Exit on a phone, so the minimized-note icons float just above the bar instead */
  .p-footer:not(.exam) .left { position: absolute; left: 12px; bottom: calc(100% + 8px); }
  .p-footer:not(.exam) .left > :not(.note-dock) { display: none; }
  .note-dock { padding: 0 8px; }
  .p-footer.exam { display: flex; flex-wrap: wrap; justify-content: space-between; row-gap: 8px; }
  .p-footer.exam .left { display: flex; }
  .p-footer.exam .navigator { bottom: 116px; max-height: calc(100vh - 190px); }
  .mode-switch, .kind-row, .pick-cols, .score-card { grid-template-columns: minmax(0, 1fr); }
  .review-banner { padding: 8px 16px; }
  .rq-group > summary { grid-template-columns: auto minmax(0, 1fr); }
  .rq-sum { grid-column: 2; text-align: left; }
  .rq-group.has-walk > summary { grid-template-columns: auto minmax(0, 1fr); }
  .rq-walk { grid-column: 2; }
  .part-row { display: flex; flex-wrap: wrap; gap: 6px 10px; }
  .pr-topics { flex-basis: 100%; order: 5; }
  .rv-block, .rv-none, .rv-same { margin-left: 0; }
  .p-footer .center { justify-self: start; }
  .timer .clock { font-size: 18px; min-width: 60px; }
  .timer .tctl .opt { display: none; }
  .navigator { position: fixed; bottom: 68px; max-height: calc(100vh - 140px); padding: 14px 14px 16px; }
  .nav-head { margin: -14px -14px 0; }
  .nav-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 10px; }
  .nav-cell { height: 44px; }
  .choices, .answer-box, .q-actions, .feedback, .selfcheck-note { margin-left: 0; padding-left: 0; }
  .dd-row { grid-template-columns: 1fr; }
  .dd-list.cols { grid-template-columns: 1fr; }
  .editor .CodeMirror { font-size: 12.5px; }
}

/* Exam Settings (⋮ after the trash icon; an exam in progress only) */
.exam-settings-wrap { position: relative; display: inline-flex; }
.exam-settings { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 270px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .14); padding: 10px 12px; font-family: var(--sans); }
.exam-settings[hidden] { display: none; }
.exam-settings-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.exam-setting { display: flex; align-items: center; gap: 12px; }
.exam-setting-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.exam-setting-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.exam-setting-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.switch { position: relative; flex: none; width: 40px; height: 22px; border-radius: 11px; border: none; padding: 0; background: #c3c7cf; cursor: pointer; transition: background .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Scope note (data/in_scope.js): what part of a past-exam question is no longer taught. */
.scope-note { flex-basis: 100%; font-family: var(--sans); font-size: 12.5px; line-height: 1.45; color: var(--ink); background: var(--warn-soft); border: 1px solid #f0d27a; border-radius: 8px; padding: 7px 10px; margin: 2px 0 8px; }
.scope-note b { font-weight: 700; }
.scope-note code { background: #fff; border: 1px solid #e5cf86; border-radius: 4px; padding: 0 4px; }

/* Privacy Policy page (privacy.html) */
.policy { max-width: 760px; margin: 0 auto; padding: 28px 20px 64px; }
.policy h1 { font-family: var(--serif); color: var(--accent); margin: 8px 0 2px; }
.policy h2 { font-family: var(--serif); color: var(--accent); font-size: 21px; margin: 28px 0 6px; }
.policy-meta { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.policy-back { margin: 0; font-size: 14px; }
.policy-back:last-child { margin-top: 32px; }
.policy a { color: var(--accent); }
.policy ul { padding-left: 22px; }
.policy li { margin: 4px 0; }
.policy-summary { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 4px 18px 8px; margin: 18px 0; }
.policy-summary h2 { font-size: 18px; margin-top: 14px; }

/* Review: the original handwriting over a read-only copy of the exam's answer pane (iPad Phase 2D-2). The copy
   rebuilds the exam pane exactly (same width, the iPad exam's CSS, the body's font), then is scaled to fit. */
.orig-ctx { display: block; position: absolute; left: 0; top: 0; transform-origin: 0 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper); text-align: left; pointer-events: none; }
.orig-measure { position: absolute; left: -100000px; top: 0; visibility: hidden; }
.orig-ctx .orig-pane { position: relative; overflow: visible; min-height: 0; padding: 24px 36px 40px; border: 0; }
.orig-ctx .question .q-head { margin: 0 0 12px; } /* not the review panel's tighter heading */
.orig-ctx :is(.choices, .answer-box, .q-actions, .feedback, .selfcheck-note) { margin-left: 22px; }
.orig-ctx .choices { padding-left: 22px; margin-left: 0; }
.orig-ctx.orig-narrow .orig-pane { padding: 18px 16px 24px; } /* the exam was one column of panes */
.orig-ctx.orig-narrow :is(.choices, .answer-box, .q-actions, .feedback, .selfcheck-note) { margin-left: 0; padding-left: 0; }
.orig-svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 1; }
.orig-svg path { fill: none; stroke: #d62828; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.orig-slot:empty { display: block; height: 0; }
.orig-ink { margin: 8px 0 4px; padding: 0; border: 1px dashed #9aa3ad; border-radius: 6px; background: #f7f7f4; overflow: hidden; }
.orig-tag { font: 600 11px/1.4 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: #5d6670; padding: 4px 8px; border-bottom: 1px dashed #c9ced4; background: #eef0f2; }
.orig-clip { position: relative; overflow: hidden; }
.orig-h { font: 700 13px/1.4 var(--sans); margin: 14px 0 4px; color: var(--ink); }
.orig-note { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.review-work #diagram-slot { margin: 6px 0 14px; } /* Review: the editable (blank) diagram above part (a) */
.q-bar .hw-q { margin-left: 4px; }
.rv-block .rv-note { font-size: 13px; color: var(--muted); margin: 6px 0 0; } /* Review: the grade's note, with the submitted answer */
