/* סיווג במתמטיקה: the proctor's board.
   Board-white ground, aluminium rails, four marker inks (blue, red, green, black) plus orange for flags.
   Assistant does the work; Playpen Sans Hebrew is the marker hand, used only for times, rules, scores and grading. */

:root {
  --board: #F6F7F4;
  --board-2: #FCFCFA;
  --wash: #ECEEE9;
  --ink: #1C1D21;
  --ink-2: #484E55;
  --ink-3: #62686F;
  --rule: #D6D9D4;
  --rule-2: #BCC1BB;
  --frame: #A3A9AE;
  --frame-2: #8A9196;
  --blue: #1E4FD6;
  --blue-2: #173FAD;
  --blue-wash: #E5EBFB;
  --red: #C21F2A;
  --red-wash: #FBE6E5;
  --green: #12733C;
  --green-wash: #E1F1E7;
  --orange: #A85106;
  --on-blue: #FFFFFF;
  --shadow: 0 1px 2px rgba(28, 29, 33, .06), 0 6px 18px -8px rgba(28, 29, 33, .18);
  --ui: "Assistant", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  --hand: "Playpen Sans Hebrew", "Assistant", "Segoe UI", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gutter: 16px;
  --max: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --board: #121416;
    --board-2: #181B1D;
    --wash: #1F2326;
    --ink: #ECEEEA;
    --ink-2: #BFC4BE;
    --ink-3: #9AA09A;
    --rule: #2E3336;
    --rule-2: #454B4F;
    --frame: #50575C;
    --frame-2: #6A7277;
    --blue: #86A6FF;
    --blue-2: #A9C0FF;
    --blue-wash: #1D2742;
    --red: #FF7A72;
    --red-wash: #3A1E1E;
    --green: #5AD08C;
    --green-wash: #183224;
    --orange: #FFA14F;
    --on-blue: #0E1424;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px -10px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --board: #121416;
  --board-2: #181B1D;
  --wash: #1F2326;
  --ink: #ECEEEA;
  --ink-2: #BFC4BE;
  --ink-3: #9AA09A;
  --rule: #2E3336;
  --rule-2: #454B4F;
  --frame: #50575C;
  --frame-2: #6A7277;
  --blue: #86A6FF;
  --blue-2: #A9C0FF;
  --blue-wash: #1D2742;
  --red: #FF7A72;
  --red-wash: #3A1E1E;
  --green: #5AD08C;
  --green-wash: #183224;
  --orange: #FFA14F;
  --on-blue: #0E1424;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

@media (min-width: 720px) { :root { --gutter: 32px; } }
@media (min-width: 1100px) { :root { --gutter: 48px; } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; scrollbar-color: var(--frame) var(--board); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--board);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--ui);
  text-rendering: optimizeLegibility;
}
::selection { background: var(--blue-wash); color: var(--ink); }
input, textarea { caret-color: var(--blue); }
a { color: var(--blue); text-decoration-thickness: 1.5px; text-underline-offset: .22em; }
a:hover { color: var(--blue-2); }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.4rem); font-weight: 800; letter-spacing: -.012em; }
h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.005em; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button, input, select { font: inherit; color: inherit; }
svg { flex: none; }
.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.num, table { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* KaTeX inside right-to-left Hebrew */
.katex { direction: ltr; unicode-bidi: isolate; font-size: 1.08em; }
.katex-display { direction: ltr; overflow-x: auto; overflow-y: hidden; padding-block: 4px; margin: .55em 0; scrollbar-width: thin; }
.katex-display > .katex { font-size: 1.1em; }
mjx-container { direction: ltr; unicode-bidi: isolate; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; }

/* grid and flex children shrink below formula width instead of widening the page */
.home > *, .board > *, .exam-layout > *, .qsheet > *, .rq > *, .pq > *, .steps li > div, .opt .ot,
.prose > *, .flash > *, .daily > *, .stage > *, .feedback > *, .res-head > *, .facts > * { min-width: 0; }

/* ---------- shell ---------- */
.frame-rail { height: 7px; background: var(--frame); box-shadow: inset 0 -1px 0 var(--frame-2); }
.topbar { border-bottom: 1px solid var(--rule); background: var(--board); }
.topbar-inner { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.22rem; letter-spacing: -.01em; }
.brand:hover { color: var(--ink); }
.brand b { color: var(--blue); font-weight: 800; }
.brand-mark { width: 30px; height: 30px; }
.brand-mark .ring { fill: none; stroke: var(--blue); stroke-width: 2.4; stroke-linecap: round; }
.brand-mark .tick { fill: none; stroke: var(--green); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.mainnav { display: flex; gap: 4px 22px; margin-inline-start: auto; }
.mainnav a { position: relative; color: var(--ink-2); text-decoration: none; font-weight: 600; padding-block: 6px; white-space: nowrap; }
.mainnav a:hover { color: var(--ink); }
.mainnav a.active { color: var(--ink); }
.mainnav a .mk.under { bottom: -2px; height: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--rule-2); border-radius: 3px;
  background: var(--board-2); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 719px) {
  .topbar-inner { padding-block: 10px 0; gap: 4px 12px; }
  .brand { font-size: 1.1rem; }
  .mainnav { order: 3; flex-basis: 100%; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); gap: 18px; overflow-x: auto; scrollbar-width: none; }
  .wide-only { display: none; }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav a { padding-block: 10px 12px; }
  .mainnav a .mk.under { bottom: 2px; }
  #theme-toggle { margin-inline-start: auto; }
}

main#app { flex: 1; padding-block: 28px 64px; outline: none; }
@media (min-width: 720px) { main#app { padding-block: 40px 80px; } }

.tray { border-top: 1px solid var(--rule); background: var(--wash); color: var(--ink-2); font-size: .92rem; }
.tray::before { content: ""; display: block; height: 6px; background: var(--frame); }
.tray .wrap { padding-block: 18px 26px; }
.tray p { max-width: 75ch; }

.loading, .empty { color: var(--ink-2); padding: 24px 0; }
.empty { border-block: 1px dashed var(--rule-2); padding: 22px 4px; }

/* ---------- buttons and controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 20px; border: 1.5px solid var(--ink); border-radius: 3px;
  background: transparent; color: var(--ink); font-weight: 700; font-size: 1rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--wash); color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-2); border-color: var(--blue-2); color: var(--on-blue); }
.btn.primary:focus-visible { outline-color: var(--ink); }
.btn.ghost { border-color: var(--rule-2); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--ink-3); color: var(--ink); background: transparent; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-wash); color: var(--red); }
.btn.ok { border-color: var(--green); color: var(--green); }
.btn.ok:hover { background: var(--green-wash); color: var(--green); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .95rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 3px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; min-height: 40px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-inline-start: 1.5px solid var(--ink); }
.seg button:hover { color: var(--ink); background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--board); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tg {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--rule-2); border-radius: 3px; background: var(--board-2); color: var(--ink-2); font-weight: 600; cursor: pointer;
}
.tg .num { color: var(--ink-3); font-weight: 600; font-size: .9em; }
.tg:hover { border-color: var(--ink-3); color: var(--ink); }
.tg[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-wash); color: var(--ink); box-shadow: inset 0 0 0 1px var(--blue); }
.tg[aria-pressed="true"] .num { color: var(--blue); }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 2px 0 0; border: 1.5px solid var(--ink); border-radius: 3px;
  background: var(--board-2); display: grid; place-items: center; cursor: pointer; flex: none;
}
.check input:checked { background: var(--blue); border-color: var(--blue); }
.check input:checked::after { content: ""; width: 11px; height: 6px; border: 2.5px solid var(--on-blue); border-top: 0; border-right: 0; transform: translateY(-2px) rotate(-45deg); }

/* ---------- marker strokes (the signature) ---------- */
.mk { position: absolute; pointer-events: none; overflow: visible; }
.mk path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mk.red path { stroke: var(--red); }
.mk.green path { stroke: var(--green); }
.mk.blue path { stroke: var(--blue); }
.mk.under { inset-inline: -3%; bottom: -.34em; width: 106%; height: .5em; }
.mk.ring { inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); }
.mk.tick { width: 30px; height: 26px; }
.mk.pending path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.mk.draw path { stroke-dasharray: 1; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .mk.draw path { animation: draw .6s var(--ease) both; animation-delay: var(--d, .12s); }
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* ---------- the board (home and exam intro) ---------- */
/* phones: the one-line explanation, then the board, then the table; desks: the board beside both */
.home { display: grid; gap: 22px 56px; }
.home > .home-side { margin-top: 18px; }
@media (min-width: 1000px) {
  .home { grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "board intro" "board side"; align-items: start; }
  .home > .board { grid-area: board; }
  .home > .home-intro { grid-area: intro; }
  .home > .home-side { grid-area: side; margin-top: 0; }
}
.board {
  position: relative; background: var(--board-2); border: 1px solid var(--rule-2);
  padding: 24px 20px 28px; box-shadow: var(--shadow); margin-bottom: 11px;
}
.board::after { content: ""; position: absolute; inset-inline: -1px; bottom: -11px; height: 10px; background: var(--frame); box-shadow: inset 0 -2px 0 var(--frame-2); }
@media (min-width: 720px) { .board { padding: 36px 40px 40px; } }
.board-title { font-family: var(--hand); font-weight: 600; color: var(--blue); font-size: clamp(2rem, 1.4rem + 2.6vw, 3.05rem); line-height: 1.15; letter-spacing: 0; }
.bt-sub { display: block; font-size: .52em; font-weight: 500; color: var(--ink-2); margin-top: 4px; }
.board-sub { color: var(--ink-2); margin-top: 10px; max-width: 58ch; }
.rules-line { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-top: 22px; font-family: var(--hand); font-size: clamp(1.15rem, 1rem + .7vw, 1.48rem); color: var(--blue); list-style: none; font-weight: 500; }
.rules-line li { position: relative; }
.rules-line .no-calc { color: var(--red); }
.times { display: flex; flex-wrap: wrap; gap: 14px 40px; margin: 24px 0 0; }
.times div { display: grid; }
.times dt { font-size: .88rem; font-weight: 700; color: var(--ink-3); }
.times dd { margin: 0; font-family: var(--hand); font-weight: 500; font-size: clamp(1.55rem, 1.3rem + 1vw, 2.05rem); line-height: 1.25; color: var(--ink); }
.board .actions { margin-top: 28px; }
/* lengths drawn in marker: the inked part of the stroke is the exact fraction (time left, time used, accuracy) */
.tline { height: 10px; min-width: 64px; }
.tline svg { display: block; width: 100%; height: 100%; overflow: visible; transform: scaleX(-1); }
.tline path { fill: none; stroke-linecap: round; }
.tline .track { stroke: var(--rule); stroke-width: 3; }
.tline .ink { stroke-width: 5; }
.tline.blue .ink { stroke: var(--blue); }
.tline.red .ink { stroke: var(--red); }
.tline.green .ink { stroke: var(--green); }
.tline.ink .ink { stroke: var(--ink-2); }
.timeline { margin-top: 16px; max-width: 560px; height: 12px; }
.timeline-cap { font-size: .86rem; color: var(--ink-3); margin-top: 6px; }

/* topic mix: a stepped rail, each segment as long as its share of the exam */
.mix { margin-top: 26px; }
.mix-cap { font-size: .9rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.mix-rail { display: flex; gap: 3px; height: 30px; }
.mix-rail span {
  display: grid; place-items: center; min-width: 0; background: var(--blue-wash); border-top: 3px solid var(--blue);
  color: var(--blue); font-weight: 800; font-size: .84rem; overflow: hidden;
}
.mix-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 8px; font-size: .88rem; color: var(--ink-2); list-style: none; }
.mix-legend b { color: var(--ink); font-weight: 800; }

/* home side column */
.intro { font-size: 1.12rem; line-height: 1.6; max-width: 46ch; }
.intro strong { font-weight: 800; }
.tally { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 14px; color: var(--ink-2); font-size: .95rem; }
.tally b { color: var(--ink); }
.side-title { margin: 30px 0 4px; }

/* ruled tables */
.ruled { width: 100%; border-collapse: collapse; }
.ruled th { text-align: start; font-size: .84rem; color: var(--ink-3); font-weight: 700; padding: 10px 8px 8px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.ruled td { padding: 12px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ruled th:first-child, .ruled td:first-child { padding-inline-start: 0; }
.ruled th:last-child, .ruled td:last-child { padding-inline-end: 0; }
.ruled td.n { white-space: nowrap; }
.ruled tr.group td { padding-top: 24px; font-weight: 800; color: var(--ink); border-bottom: 2px solid var(--ink); }
.ruled tr.group td span { font-weight: 600; color: var(--ink-3); margin-inline-start: 8px; font-size: .92rem; }
.ex-name { font-weight: 700; }
.ex-name a { color: var(--ink); text-decoration: none; }
.ex-name a:hover { color: var(--blue); text-decoration: underline; }
.ex-sub { display: block; font-size: .86rem; color: var(--ink-3); font-weight: 600; }
.score { font-family: var(--hand); font-weight: 600; font-size: 1.2rem; color: var(--red); white-space: nowrap; }
.score.none { font-family: var(--ui); font-weight: 400; font-size: 1rem; color: var(--ink-3); }
.go { text-align: end; white-space: nowrap; }
.go a { font-weight: 700; text-decoration: none; }
.go a:hover { text-decoration: underline; }
.go .pdf { color: var(--ink-3); margin-inline-start: 14px; font-weight: 600; }
@media (max-width: 560px) {
  .exam-table thead { display: none; }
  .exam-table tbody { display: block; }
  .exam-table tr:not(.group) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .exam-table td { padding: 0; border: 0; }
  .exam-table td.att { display: none; }
  .exam-table td.score-cell { grid-row: 1; grid-column: 2; text-align: end; }
  .exam-table td.go { grid-column: 1 / -1; text-align: start; padding-top: 6px; }
  .exam-table tr.group { display: block; }
  .exam-table tr.group td { display: block; padding: 24px 0 6px; }
}

/* plain link list (more ways to practise) */
.more { margin-top: 64px; }
.link-list { list-style: none; border-top: 2px solid var(--ink); margin-top: 12px; }
.link-list a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 18px; align-items: center;
  padding: 16px 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none;
}
.link-list a:hover .ll-title { color: var(--blue); }
.ll-title { font-weight: 800; font-size: 1.1rem; }
.ll-desc { grid-column: 1; color: var(--ink-2); }
.ll-meta { grid-row: 1 / span 2; grid-column: 2; color: var(--ink-3); font-weight: 600; font-size: .92rem; }
.link-list svg { grid-row: 1 / span 2; grid-column: 3; width: 20px; height: 20px; fill: none; stroke: var(--ink-3); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 480px) { .ll-meta { display: none; } }
.daily { margin-top: 56px; max-width: 820px; }
.daily .muted { margin: 2px 0 18px; }

/* page heads on the other routes */
.page-head { display: grid; gap: 10px; margin-bottom: 26px; }
.page-head .lede { color: var(--ink-2); font-size: 1.08rem; max-width: 64ch; }
.narrow { max-width: 820px; }

/* ---------- questions ---------- */
.qhead { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; }
.qnum { font-family: var(--hand); font-weight: 600; font-size: 1.5rem; color: var(--blue); line-height: 1.2; }
.topic-tag { font-size: .88rem; font-weight: 700; color: var(--ink-2); padding: 2px 9px; border: 1px solid var(--rule-2); border-radius: 3px; }
.src { font-size: .86rem; color: var(--ink-3); }
.qtext { font-size: 1.12rem; line-height: 1.75; }
.qtext p + p { margin-top: .6em; }

.opts { display: grid; gap: 10px; margin-top: 20px; }
@media (min-width: 640px) { .opts { grid-template-columns: 1fr 1fr; } .opts.one { grid-template-columns: 1fr; } }
.opt {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 10px 14px;
  border: 1px solid var(--rule-2); border-radius: 3px; background: var(--board-2); color: var(--ink); text-align: start; cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
button.opt:hover:not(:disabled) { border-color: var(--ink-3); }
.ol {
  position: relative; display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--ink-3); font-weight: 800; font-size: .98rem; color: var(--ink-2); background: var(--board);
}
.opt .ot { flex: 1; font-size: 1.06rem; overflow-wrap: anywhere; padding-block: 2px; }
.opt.sel { border-color: var(--blue); background: var(--blue-wash); box-shadow: inset 0 0 0 1px var(--blue); }
.opt.sel .ol { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.opt:disabled { cursor: default; opacity: 1; }
.opt.right { border-color: var(--green); background: var(--green-wash); box-shadow: inset 0 0 0 1px var(--green); }
.opt.right .ol { border-color: var(--green); color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-wash); }
.opt.wrong .ol { border-color: transparent; color: var(--red); }
.opt .ol .mk.tick { inset-inline-start: 14px; top: -12px; }
.opt-note { margin-inline-start: auto; padding-inline-start: 10px; font-family: var(--hand); font-weight: 600; font-size: .98rem; white-space: nowrap; }
.opt.right .opt-note { color: var(--green); }
.opt.wrong .opt-note { color: var(--red); }

.flag-btn {
  display: inline-flex; align-items: center; gap: 7px; margin-inline-start: auto; min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--rule-2); border-radius: 3px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer;
}
.flag-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.flag-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.flag-btn[aria-pressed="true"] { color: var(--orange); border-color: var(--orange); }
.flag-btn[aria-pressed="true"] svg { fill: currentColor; }

/* hint, feedback, structure */
.qtools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 16px; }
.keys { font-size: .86rem; color: var(--ink-3); }
.kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 3px; font-size: .84em; text-align: center; background: var(--board-2); color: var(--ink-2); }
.hintbox { margin-top: 14px; padding: 12px 16px; background: var(--wash); border-top: 2px solid var(--ink); }
.hintbox b { font-weight: 800; }
.feedback { margin-top: 20px; }
.verdict { position: relative; display: inline-block; font-family: var(--hand); font-weight: 600; font-size: 1.5rem; }
.verdict.ok { color: var(--green); }
.verdict.no { color: var(--red); }
.verdict-sub { color: var(--ink-2); margin-top: 6px; }
.struct { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--ink-2); }
.struct strong { color: var(--ink); font-weight: 800; }
.next-row { margin-top: 18px; }

/* solution: numbered steps, computations as display math */
details.sol { margin-top: 16px; border-top: 2px solid var(--ink); }
details.sol > summary { display: flex; align-items: center; gap: 10px; padding: 12px 0; font-weight: 800; cursor: pointer; list-style: none; }
details.sol > summary::-webkit-details-marker { display: none; }
details.sol > summary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
details.sol[open] > summary svg { transform: rotate(-90deg); }
details.sol > summary:hover { color: var(--blue); }
.steps { list-style: none; display: grid; gap: 18px; padding: 4px 0 6px; }
.steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0 14px; }
.step-n { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--blue); border-radius: 50%; color: var(--blue); font-family: var(--hand); font-weight: 600; font-size: 1rem; line-height: 1; }
.step-t { font-size: 1.03rem; font-weight: 800; margin: 3px 0 4px; }
.step-b p + p { margin-top: .4em; }
/* phones: the step body takes the full width under its number and title, so formulas get the whole column */
@media (max-width: 600px) {
  .steps li { align-items: center; row-gap: 6px; }
  .steps li > div { display: contents; }
  .step-t { grid-column: 2; margin: 0; }
  .step-b { grid-column: 1 / -1; min-width: 0; }
  .step-r { padding-inline-start: 0; }
}
/* a formula that still does not fit after shrinking fades at its edge, so the scroll is visible */
.katex-display.fade { -webkit-mask-image: linear-gradient(to right, #000 84%, transparent); mask-image: linear-gradient(to right, #000 84%, transparent); }
.step-r { margin: 14px 0 6px; padding-inline-start: 44px; }
.step-r > span { position: relative; display: inline-block; font-weight: 800; font-size: 1.08rem; }
.step-r > span > .mk.under { bottom: -.42em; }
.sol-legacy { padding-bottom: 8px; }
.sol-legacy p + p { margin-top: .6em; }

/* ---------- exam runner ---------- */
.exam-bar { position: sticky; top: 0; z-index: 20; background: var(--board); border-bottom: 1px solid var(--rule-2); margin: -28px calc(-1 * var(--gutter)) 0; padding-inline: var(--gutter); }
@media (min-width: 720px) { .exam-bar { margin-top: -40px; } }
.eb-inner { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; padding-block: 10px; }
.eb-title { font-weight: 800; }
.eb-progress { color: var(--ink-2); font-size: .95rem; }
.eb-timer { margin-inline-start: auto; font-family: var(--hand); font-weight: 600; font-size: 1.45rem; line-height: 1; color: var(--ink); }
.eb-timer.low { color: var(--red); }
.eb-spacer { margin-inline-start: auto; }
.eb-bar { height: 10px; margin: 0 0 8px; }
@media (max-width: 560px) {
  .eb-title { flex-basis: 100%; font-size: .95rem; }
  .eb-progress { font-size: .9rem; }
}
.confirm { margin-top: 18px; padding: 18px 20px; border: 1.5px solid var(--ink); background: var(--board-2); box-shadow: var(--shadow); display: grid; gap: 12px; }
.exam-layout { display: grid; gap: 36px; margin-top: 26px; }
@media (min-width: 980px) { .exam-layout { grid-template-columns: minmax(0, 1fr) 272px; gap: 48px; align-items: start; } .navpanel { position: sticky; top: 96px; } }
/* the question is written on the board: same panel, rail and tray as the home board */
.qsheet { position: relative; outline: none; background: var(--board-2); border: 1px solid var(--rule-2); box-shadow: var(--shadow); padding: 20px 16px 24px; margin-bottom: 11px; }
.qsheet::after { content: ""; position: absolute; inset-inline: -1px; bottom: -11px; height: 10px; background: var(--frame); box-shadow: inset 0 -2px 0 var(--frame-2); }
@media (min-width: 720px) { .qsheet { padding: 28px 32px 32px; } }
.exam-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--rule); }
.exam-nav .pos { color: var(--ink-3); }
.np-title { font-size: 1rem; margin-bottom: 10px; }
.navgrid { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--ink-3); border-inline-start: 1px solid var(--ink-3); }
.nq {
  position: relative; aspect-ratio: 1; min-height: 44px; border: 0; border-bottom: 1px solid var(--ink-3); border-inline-end: 1px solid var(--ink-3);
  background: var(--board-2); color: var(--ink-2); font-weight: 700; font-size: .98rem; cursor: pointer;
}
.nq:hover { background: var(--wash); color: var(--ink); }
.nq.done { background: var(--blue); color: var(--on-blue); }
.nq.cur { box-shadow: inset 0 0 0 3px var(--ink); color: var(--ink); }
.nq.done.cur { box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 5px var(--board-2); color: var(--on-blue); }
/* flagged: an orange corner at the top of the cell's far edge */
.nq.flag::after, .legend i.flag::after {
  content: ""; position: absolute; top: 0; inset-inline-end: 0; width: 14px; height: 14px;
  background: linear-gradient(135deg, var(--orange) 50%, transparent 50%);
}
.legend { list-style: none; display: grid; gap: 6px; margin-top: 12px; font-size: .88rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { position: relative; width: 16px; height: 16px; border: 1px solid var(--ink-3); background: var(--board-2); overflow: hidden; }
.legend i.done { background: var(--blue); border-color: var(--blue); }
.legend i.flag::after { width: 9px; height: 9px; }
.navpanel .keys { margin-top: 14px; line-height: 2; }
.intro-body { margin-top: 22px; }
.trainer-keys { margin-top: 22px; }
.table-note { margin-top: 8px; }
@media (max-width: 979px) { .navpanel .keys { display: none; } }

/* ---------- results ---------- */
.res-head { display: grid; gap: 22px; padding-bottom: 28px; border-bottom: 2px solid var(--ink); }
@media (min-width: 860px) { .res-head { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 22px 56px; } .res-head h1, .res-head .actions { grid-column: 1 / -1; } }
.grade { position: relative; display: inline-block; justify-self: start; margin: 10px 16px 6px; }
.grade-score { font-family: var(--hand); font-weight: 600; font-size: clamp(3.3rem, 2.6rem + 3vw, 4.6rem); line-height: 1.05; color: var(--red); }
.grade-score small { font-size: .5em; }
.grade .mk.ring { inset: -14px -20px -12px; width: calc(100% + 40px); height: calc(100% + 26px); }
.facts { display: grid; gap: 8px; }
.facts p { color: var(--ink-2); }
.facts b { color: var(--ink); }
.facts .verdict-line { font-weight: 700; color: var(--ink); font-size: 1.1rem; }
.time-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; align-items: center; max-width: 520px; }
.time-row .timeline { margin: 0; }

.strip { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 26px; max-width: 1180px; border-top: 1px solid var(--ink-3); border-inline-start: 1px solid var(--ink-3); }
.strip button {
  position: relative; display: grid; place-items: center; height: 46px; border: 0; border-bottom: 1px solid var(--ink-3); border-inline-end: 1px solid var(--ink-3);
  color: var(--ink-2); font-weight: 700; background: var(--board-2); cursor: pointer;
}
.strip button.right { background: var(--green-wash); color: var(--green); }
.strip button.wrong, .strip button.blank { background: var(--red-wash); color: var(--red); }
.strip button.blank::after { content: ""; position: absolute; inset-inline: 8px; top: 50%; height: 2px; background: var(--red); transform: rotate(-14deg); }
.strip button:hover { box-shadow: inset 0 0 0 2px var(--ink); }
@media (min-width: 900px) { .strip { grid-template-columns: repeat(25, 1fr); } }
.strip-key { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; font-size: .88rem; color: var(--ink-2); list-style: none; }
.strip-key i { position: relative; display: inline-block; width: 13px; height: 13px; margin-inline-end: 6px; vertical-align: -2px; border: 1px solid var(--ink-3); }
.strip-key i.right { background: var(--green-wash); border-color: var(--green); }
.strip-key i.wrong { background: var(--red-wash); border-color: var(--red); }
.strip-key i.blank { background: var(--red-wash); border-color: var(--red); }
.strip-key i.blank::after { content: ""; position: absolute; inset-inline: 1px; top: 5px; height: 1.5px; background: var(--red); transform: rotate(-14deg); }

.section { margin-top: 44px; }
.section > h2 { margin-bottom: 10px; }
.bar-cell { width: 42%; }

.review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 52px 0 6px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.rq { padding: 30px 0 32px; border-bottom: 1px solid var(--rule-2); scroll-margin-top: 24px; }
.rq-mark { position: relative; font-family: var(--hand); font-weight: 600; font-size: 1.2rem; }
.rq.is-right .rq-mark { color: var(--green); }
.rq.is-wrong .rq-mark, .rq.is-blank .rq-mark { color: var(--red); }
.rq-mark .sub { font-family: var(--ui); font-size: .88rem; font-weight: 700; margin-inline-start: 8px; }
.rq.is-blank .opts { outline: 2px dashed var(--red); outline-offset: 7px; }

/* ---------- practice ---------- */
.filters { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.filters > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 14px 0; cursor: pointer; list-style: none; font-weight: 800; }
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary .sum { font-weight: 600; color: var(--ink-2); }
.filters > summary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; margin-inline-start: auto; transition: transform .2s var(--ease); }
.filters[open] > summary svg { transform: rotate(180deg); }
.filter-body { display: grid; gap: 14px; padding: 4px 0 20px; }
.flabel { font-size: .86rem; font-weight: 800; color: var(--ink-3); margin-bottom: -6px; }
.session { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; color: var(--ink-2); }
.session b { color: var(--ink); }
.stage { margin-top: 26px; }
.sess-line { margin-top: 14px; color: var(--ink-2); min-height: 1.6em; }
.sess-line b { color: var(--ink); }

/* ---------- recognition trainer ---------- */
.flash { position: relative; background: var(--board-2); border: 1px solid var(--rule-2); box-shadow: var(--shadow); padding: 24px 20px 28px; margin-bottom: 11px; outline: none; }
.flash::after { content: ""; position: absolute; inset-inline: -1px; bottom: -11px; height: 10px; background: var(--frame); box-shadow: inset 0 -2px 0 var(--frame-2); }
@media (min-width: 720px) { .flash { padding: 34px 40px 36px; } }
.flash .ask { font-family: var(--hand); font-weight: 600; font-size: 1.3rem; color: var(--blue); }
.flash .front { font-size: 1.2rem; margin: 10px 0 6px; }
.flash .back { border-top: 1px solid var(--rule); margin-top: 16px; padding-top: 18px; }
.flash .reveal-val { position: relative; display: inline-block; font-size: 1.15rem; }
.flash .note { color: var(--ink-2); margin-top: 14px; }
.flash .actions { margin-top: 22px; }
.mastery { display: grid; gap: 8px; max-width: 560px; margin-top: 14px; }
.mastery-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 40px; gap: 12px; align-items: center; font-size: .92rem; color: var(--ink-2); }
.mastery-row .num { text-align: end; color: var(--ink); font-weight: 700; }

/* ---------- progress ---------- */
.summary { display: flex; flex-wrap: wrap; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); margin: 6px 0 0; }
.summary div { flex: 1 1 150px; padding: 14px 16px 16px 0; }
.summary div + div { border-inline-start: 1px solid var(--rule); padding-inline-start: 16px; }
.summary dt { font-size: .86rem; font-weight: 700; color: var(--ink-3); }
.summary dd { margin: 2px 0 0; font-size: 1.45rem; font-weight: 800; }
.summary dd small { font-size: .62em; color: var(--ink-3); font-weight: 700; }
@media (max-width: 560px) {
  .summary div { flex-basis: 50%; }
  .summary div + div { border-inline-start: 0; padding-inline-start: 0; }
  .summary div:nth-child(even) { border-inline-start: 1px solid var(--rule); padding-inline-start: 16px; }
}
.callout { margin-top: 28px; padding: 18px 20px; background: var(--board-2); border: 1px solid var(--rule-2); box-shadow: var(--shadow); display: grid; gap: 12px; }
.tbl { overflow-x: auto; }
.time-cell { min-width: 110px; }
.danger-zone { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); display: grid; gap: 12px; color: var(--ink-2); }

/* ---------- about ---------- */
.prose { max-width: 68ch; }
.prose h1 { margin-bottom: 18px; }
.prose h2 { margin: 34px 0 10px; }
.prose p + p { margin-top: .8em; }
.prose ul { padding-inline-start: 1.2em; display: grid; gap: 8px; margin-top: 8px; }
.prose li::marker { color: var(--blue); }

/* ---------- print: solutions open, no chrome ---------- */
@media print {
  :root, :root[data-theme="dark"] { --board: #fff; --board-2: #fff; --wash: #f2f2f2; --ink: #000; --ink-2: #222; --ink-3: #444; --rule: #bbb; --rule-2: #999; --shadow: none; color-scheme: light; }
  .frame-rail, .topbar, .tray, .exam-bar, .navpanel, .exam-nav, .actions, .seg, .filters, .qtools, .icon-btn, .board::after, .flash::after, .strip, .strip-key { display: none !important; }
  body { font-size: 11.5pt; }
  main#app { padding: 0; }
  .rq { break-inside: avoid; }
  details.sol > summary svg { display: none; }
  .mk path { stroke-dashoffset: 0 !important; animation: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
