/* Study surfaces: review session, card panel. */

.review-page { max-width: 640px; }
.review-kinds { margin-bottom: var(--s-4); }
.stage { display: grid; gap: var(--s-4); }
.stage__counts { display: flex; align-items: center; gap: var(--s-3); min-height: 28px; margin: 0; }

.flashcard {
  position: relative; display: grid; gap: var(--s-4);
  min-height: 300px; padding: var(--s-6) var(--s-5);
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  background: var(--paper); cursor: pointer; align-content: center;
}
.flashcard[data-revealed="true"] { cursor: default; }
.flashcard__front { display: grid; gap: var(--s-2); justify-items: center; text-align: center; align-content: center; }
.flashcard__front .headword { font-size: clamp(2.25rem, 7vw, 3.25rem); }
.flashcard__meta { justify-content: center; }
.flashcard__hint { font-size: var(--text-sm); color: var(--ink-muted); margin: 0; }
.flashcard__prompt { font-size: var(--text-2xl); font-weight: 600; line-height: 1.3; margin: 0; max-width: 28ch; }
.flashcard__img { width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius); margin-bottom: var(--s-2); }
.flashcard__back {
  display: grid; gap: var(--s-2); justify-items: center; text-align: center;
  padding-top: var(--s-4); border-top: 1px solid var(--rule);
  animation: reveal 260ms var(--ease-out);
}
.flashcard__back p { margin: 0; max-width: 52ch; }
.flashcard__answer { font-size: var(--text-xl); font-weight: 600; }
.flashcard__example { font-style: italic; }
.flashcard__senses { display: grid; gap: 2px; padding-top: var(--s-2); border-top: 1px solid var(--rule); }
.flashcard__senses p { margin: 0; }
.flashcard__senses ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.flashcard__senses li { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.reveal-btn { justify-self: center; align-self: end; gap: var(--s-2); }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ratings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); }
.rating {
  display: grid; justify-items: center; gap: 2px; padding: 10px 6px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer;
  transition: background var(--dur) var(--ease-out), border-color var(--dur);
}
.rating:hover { background: var(--wash); }
.rating[data-rating="1"] { color: var(--danger); }
.rating--good { border-color: var(--accent); color: var(--accent); }
.rating__ivl { font-size: var(--text-xs); font-weight: 500; color: var(--ink-muted); }
.rating kbd { display: none; }
@media (pointer: fine) { .rating kbd { display: inline-block; margin-top: 2px; } }
@media (max-width: 767px) {
  .ratings {
    position: sticky; bottom: calc(var(--tabbar-h) + var(--s-2)); z-index: 5;
    padding: var(--s-2); margin: 0 calc(-1 * var(--s-2)); border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px);
  }
  .rating { min-height: 56px; }
  .flashcard { min-height: 260px; padding: var(--s-5) var(--s-4); }
}
.stage__done { padding: var(--s-6) 0; }

/* ---------- Writing: editor ---------- */
.editor { display: grid; grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.6fr); gap: var(--s-6); align-items: start; }
.editor__prompt { position: sticky; top: calc(var(--topbar-h) + var(--s-3)); display: grid; gap: var(--s-2); }
.prompt-text p { margin-bottom: var(--s-2); }
.prompt-image { border-radius: var(--radius); border: 1px solid var(--rule); }
.editor__main { display: grid; gap: var(--s-2); }
.essay-input {
  width: 100%; min-height: 62vh; padding: var(--s-4) var(--s-5);
  border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink);
  font-family: var(--font-read); font-size: 1.0625rem; line-height: 1.8; resize: vertical;
}
.essay-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.editor__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); font-size: var(--text-sm); }
.editor__bar .icon { display: inline; vertical-align: -2px; }
.editor__bar .ok { color: var(--success); }
@media (max-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .editor__prompt { position: static; }
  .essay-input { min-height: 50vh; padding: var(--s-3); }
  .editor__bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--s-2)); padding: var(--s-2); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); }
}

/* ---------- Writing: feedback ---------- */
.page__title--sm { font-size: var(--text-2xl); }
.band-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: var(--text-sm); }
.scores { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-5); align-items: start; padding: var(--s-4) 0 var(--s-5); border-bottom: 1px solid var(--rule); }
.scores__overall { display: grid; justify-items: center; gap: 2px; min-width: 96px; }
.scores__band { font-family: var(--font-read); font-size: 3.25rem; font-weight: 600; line-height: 1; color: var(--accent); }
.criteria { margin: 0; display: grid; gap: var(--s-3); }
.criterion dt { display: flex; align-items: baseline; gap: var(--s-2); font-weight: 600; }
.criterion__band { margin-left: auto; font-weight: 700; }
.criterion { max-width: calc(72ch + 4rem); } /* keeps each band score next to its heading */
.criterion dd { margin: 2px 0 0; display: grid; gap: 2px; font-size: var(--text-sm); max-width: 72ch; }
@media (max-width: 640px) { .feedback > .page__head { flex-direction: column; align-items: stretch; } .feedback > .page__head .cluster { justify-content: flex-start; } }
@media (max-width: 640px) { .scores { grid-template-columns: minmax(0, 1fr); } .scores__overall { justify-items: start; } }

.feedback__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: var(--s-6); margin-top: var(--s-5); align-items: start; }
@media (max-width: 900px) { .feedback__grid { grid-template-columns: minmax(0, 1fr); } }
.essay { font-size: 1.0625rem; line-height: 1.85; white-space: normal; }
.essay-mark {
  text-decoration: none; color: inherit; border-bottom: 2px solid var(--warning); background: var(--warning-wash);
  border-radius: 2px; padding: 0 1px;
}
.essay-mark[data-severity="major"] { border-bottom-color: var(--danger); background: var(--danger-wash); }
.essay-mark[data-kind="vocabulary"], .essay-mark[data-kind="collocation"] { border-bottom-style: dashed; }
.essay-mark:hover, .essay-mark:focus-visible { background: var(--accent-wash); }
.annotations { position: sticky; top: calc(var(--topbar-h) + var(--s-3)); max-height: calc(100dvh - var(--topbar-h) - var(--s-6)); overflow: auto; }
@media (max-width: 900px) { .annotations { position: static; max-height: none; } }
.ann-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.ann { padding: var(--s-3); border: 1px solid var(--rule); border-radius: var(--radius); scroll-margin-top: calc(var(--topbar-h) + var(--s-4)); }
.ann:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.ann p { margin: 0 0 4px; }
.ann__foot { margin-top: var(--s-1); gap: 2px; }
.bullets { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-1); }
.grid-2--gap { gap: var(--s-5); }
@media (max-width: 640px) { .grid-2--gap { grid-template-columns: minmax(0, 1fr); } }

/* Mistake notebook */
.mistake-row { align-items: flex-start; }
/* "Select all" above the rows: its checkbox sits in the rows' checkbox column. */
.select-all { display: flex; align-items: center; min-height: 36px; padding: 0 0 6px; margin: var(--s-2) 0 4px; border-bottom: 1px solid var(--rule); }
.select-all__label { display: inline-flex; align-items: center; gap: var(--s-3); font-size: var(--text-sm); color: var(--ink-muted); cursor: pointer; }
.select-all__label .row__check { margin-top: 0; opacity: 1; }
.row__check { margin-top: 6px; width: 16px; height: 16px; accent-color: var(--accent); opacity: 0.35; }
.row:hover .row__check, .row__check:checked, .row__check:focus-visible { opacity: 1; }
@media (pointer: coarse) { .row__check { opacity: 1; } }
.mistake-row .row__main p { margin: 0 0 4px; max-width: 72ch; }
.mistake-detail { margin-top: var(--s-2); display: grid; gap: var(--s-2); }
.flashcard__prompt--sentence { font-size: var(--text-xl); font-weight: 500; font-family: var(--font-read); }

/* ---------- Exams: editor ---------- */
.wide-form { max-width: 760px; }
.exam-meta { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0 var(--s-3); max-width: 860px; }
@media (max-width: 640px) { .exam-meta { grid-template-columns: minmax(0, 1fr); } }
.exam-section { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--rule); display: grid; gap: var(--s-3); }
.exam-section__head { display: grid; gap: var(--s-2); }
.exam-section__title { font-size: var(--text-xl); }
.passage-preview summary { cursor: pointer; }
.passage-preview .read { max-height: 340px; overflow: auto; padding: var(--s-3); border-radius: var(--radius); background: var(--wash); margin-top: var(--s-2); }
.audio { width: 100%; max-width: 520px; }
.qgroup { display: grid; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--rule); border-radius: var(--radius-lg); }
.qgroup__head p { margin: 0 0 4px; }
.optlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: var(--text-sm); }
.optlist strong { display: inline-block; min-width: 2.2em; }
.gap-context { display: grid; gap: var(--s-3); }
.gap-text { padding: var(--s-3); border-radius: var(--radius); background: var(--wash); line-height: 2.1; }
.gap { display: inline-block; min-width: 4.5em; border-bottom: 1.5px solid var(--ink-muted); text-align: center; text-decoration: none; color: var(--accent); font-weight: 600; font-size: 0.85em; line-height: 1.4; }
/* Table completion: a real table; scrolls sideways on a phone instead of squeezing cells. */
.gap-table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; } /* relative: see .table-wrap */
.gap-table { border-collapse: collapse; width: 100%; line-height: 1.6; }
.gap-table th, .gap-table td { min-width: 9em; padding: 8px 10px; border: 1px solid var(--rule); text-align: left; vertical-align: top; }
.gap-table th { background: var(--wash); font-weight: 650; }
/* A gap you type into, like the line on a paper test. Built as a .q so the runner counts and saves it. */
.q.q--inline { display: inline-flex; align-items: baseline; gap: 4px; margin: 0 1px; padding: 0 2px; vertical-align: baseline; }
.gap-field__num { flex: none; min-width: 1.6em; padding: 0 4px; border-radius: var(--radius-sm); background: var(--wash-strong); font: 700 var(--text-xs)/1.6 var(--font-ui); text-align: center; cursor: text; }
.q--inline[data-answered="1"] .gap-field__num { background: var(--accent); color: var(--accent-ink); }
.gap-field__input, .gap-field__select {
  min-width: 0; max-width: 100%; padding: 0 2px; border: 0; border-bottom: 1.5px solid var(--ink-muted); border-radius: 0;
  background: transparent; color: var(--ink); font: inherit; line-height: 1.5; caret-color: var(--accent);
  transition: border-color var(--dur), background-color var(--dur);
}
.gap-field__input--s { width: 10ch; }
.gap-field__input--m { width: 16ch; }
.gap-field__input--l { width: 22ch; }
/* Table cells are narrower than a line of notes. */
.gap-table .gap-field__input--m { width: 12ch; }
.gap-table .gap-field__input--l { width: 16ch; }
.gap-field__select { width: auto; padding-right: 2px; cursor: pointer; }
.gap-field__input:hover, .gap-field__select:hover { border-bottom-color: var(--ink); }
.gap-field__input:focus, .gap-field__select:focus { outline: none; border-bottom-color: var(--accent); background: var(--accent-wash); }
.gap-text .gap-field__input, .gap-text .gap-field__select { background-color: color-mix(in srgb, var(--paper) 70%, transparent); }
.gap-text .gap-field__input:focus, .gap-text .gap-field__select:focus { background: var(--paper); }
/* A summary from a box of words (wordBank in app.js). The box sticks above its summary while it scrolls. */
.qblock__bank { display: grid; gap: var(--s-2); }
.wordbank {
  position: sticky; top: calc(var(--topbar-h) + var(--head-h)); z-index: 4; display: flex; flex-wrap: wrap; gap: 6px;
  padding: var(--s-2) 0; background: var(--paper);
}
.wordbank__chip {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 32px; padding: 4px 10px;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--paper); color: var(--ink);
  font: inherit; font-size: var(--text-sm); line-height: 1.4; cursor: pointer; user-select: none;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur), opacity var(--dur);
}
.wordbank__chip strong { color: var(--accent); font-weight: 700; }
.wordbank__chip:hover { background: var(--wash); border-color: var(--ink-muted); }
.wordbank__chip:active { transform: translateY(1px); }
.wordbank__chip[data-used] { background: var(--wash); border-color: var(--rule); color: var(--ink-muted); }
.wordbank__chip[data-used] strong { color: var(--ink-muted); }
/* Jumping to a gap lands below the stuck box, not under it (--bank-h: set by wordBank). */
.qblock__bank .q { scroll-margin-top: calc(var(--topbar-h) + var(--head-h) + var(--bank-h, 0px) + var(--s-4)); }
/* A gap is picked: the words are ready to tap. */
.qblock__bank:has(.gap-pick[data-active]) .wordbank__chip:not([data-used]) { border-color: var(--accent); }
.gap-pick__btn {
  display: inline-flex; align-items: baseline; gap: 4px; min-width: 7ch; padding: 0 4px 0 0; border: 0;
  border-bottom: 1.5px solid var(--ink-muted); border-radius: 0; background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--accent); font: inherit; font-weight: 600; line-height: 1.5; text-align: left; cursor: pointer;
  transition: border-color var(--dur), background-color var(--dur);
}
.gap-pick__btn .gap-field__num { cursor: pointer; }
.gap-pick__btn:hover { border-bottom-color: var(--ink); }
.gap-pick__btn:focus-visible { outline: none; border-bottom-color: var(--accent); background: var(--paper); }
.gap-pick[data-active] .gap-pick__btn, .gap-pick[data-drop] .gap-pick__btn { border-bottom: 2px solid var(--accent); background: var(--accent-wash); }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.qitem { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-2); border-radius: var(--radius); }
.qitem:hover { background: var(--wash); }
.qitem:hover .row__actions, .qitem:focus-within .row__actions { opacity: 1; }
.qitem .row__actions { opacity: 0; }
@media (pointer: coarse) { .qitem .row__actions { opacity: 1; } }
.qitem__num { min-width: 2.5em; font-weight: 700; color: var(--accent); }
.qitem__main { flex: 1; min-width: 0; }
.qitem__main p { margin: 0 0 4px; }
.qitem--editing { background: var(--wash); }
.source-text { white-space: pre-wrap; font-family: var(--font-ui); font-size: var(--text-sm); color: var(--ink-muted); max-height: 420px; overflow: auto; }

/* Which part of the test a row is ("Passage 2", "Part 1 + 3"); a full test stands out. */
.exam-scope { display: block; margin-top: 2px; white-space: nowrap; }
.exam-scope--full { color: var(--accent); font-weight: 600; }
/* A part test (Passage 2 of a full test) sits under its full test, indented like a branch. */
.exam-row--part .title-cell { padding-left: var(--s-5); }
.exam-row--part .title-cell a { font-weight: 400; }
.exam-row__branch { display: inline-block; width: 1.2em; margin-left: -1.2em; color: var(--ink-faint); }
/* Test page: links to the part tests of a full test (or the button that makes them). */
.part-tests { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* ---------- Exams: runner ---------- */
/* --head-h: the sticky head's height, measured by examRunner (a guess until then). */
.runner { --head-h: 56px; display: grid; gap: var(--s-3); padding: 0 var(--s-4) calc(var(--s-8) + 40px); max-width: 1400px; margin: 0 auto; }
/* The bar and the part tabs stick together, so the tabs stay in reach while the questions scroll. */
.runner__head {
  position: sticky; top: var(--topbar-h); z-index: 15; display: grid; justify-items: start; gap: var(--s-2);
  padding-bottom: var(--s-2); background: var(--paper); border-bottom: 1px solid var(--rule);
}
.runner__bar { justify-self: stretch; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding-top: var(--s-2); }
.runner__title { font-weight: 600; }
.runner__timer { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: var(--text-lg); }
.runner__panes { display: grid; gap: var(--s-5); }
.runner__panes--split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.runner__passage {
  position: sticky; top: calc(var(--topbar-h) + var(--head-h) + var(--s-3));
  max-height: calc(100dvh - var(--topbar-h) - var(--head-h) - var(--s-3) - 16px); overflow: auto; padding-right: var(--s-3);
}
.runner__audio { position: sticky; top: calc(var(--topbar-h) + var(--head-h)); z-index: 5; padding: var(--s-2) 0; background: var(--paper); }
.runner__audio audio { width: 100%; }
.runner__questions { display: grid; gap: var(--s-5); max-width: 760px; }
.qblock { display: grid; gap: var(--s-2); }
.qblock p { margin: 0; }
.q { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-2); margin: 0 calc(-1 * var(--s-2)); border-radius: var(--radius); scroll-margin-top: calc(var(--topbar-h) + var(--head-h) + var(--s-4)); }
/* The question jumped to from the strip (examRunner.markJump), until you click or focus elsewhere. */
.q[data-jumped] { background: var(--accent-wash); }
.q__num { min-width: 2.4em; height: 26px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--wash-strong); font-weight: 700; font-size: var(--text-sm); }
.q[data-answered="1"] .q__num { background: var(--accent); color: var(--accent-ink); }
.q__body { flex: 1; min-width: 0; display: grid; gap: var(--s-2); }
.q__text { max-width: 320px; }
.choices { border: 0; margin: 0; padding: 0; display: grid; gap: 2px; }
.choice { display: flex; align-items: flex-start; gap: var(--s-2); padding: 6px 8px; border-radius: var(--radius); cursor: pointer; font-size: var(--text-sm); }
.choice:hover { background: var(--wash); }
.choice input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.choice:has(input:checked) { background: var(--accent-wash); }
/* Matching as a grid: a column per heading/option, a row per statement. The statement
   column stays put while a long option row scrolls sideways on a phone. */
.match-grid-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.match-grid { border-collapse: collapse; width: 100%; font-size: var(--text-sm); line-height: 1.45; }
.match-grid th, .match-grid td { padding: 0; border: 1px solid var(--rule); text-align: center; vertical-align: middle; }
.match-grid thead th { padding: 6px 4px; background: var(--wash); font-weight: 650; min-width: 2.75em; white-space: nowrap; }
.match-grid thead th[title] { cursor: help; }
.match-grid .match-grid__stmt {
  position: sticky; left: 0; z-index: 1; min-width: 11em; padding: 6px 10px 6px 6px;
  background: var(--paper); text-align: left; font-weight: 400;
}
.match-grid thead .match-grid__stmt { background: var(--wash); }
.match-grid__row-head { display: flex; gap: var(--s-2); align-items: flex-start; }
.match-grid__row-head .q__num { flex: none; }
.match-grid__prompt { padding-top: 2px; }
/* A row is a .q so the runner counts and saves it; undo the .q flex box. */
.match-grid tr.q { display: table-row; padding: 0; margin: 0; border-radius: 0; }
.match-grid tr.q:hover td, .match-grid tr.q:hover .match-grid__stmt { background-color: var(--wash); }
.match-grid tr.q[data-jumped] td, .match-grid tr.q[data-jumped] .match-grid__stmt { background-color: var(--accent-wash); }
.match-grid__cell { display: grid; place-items: center; min-height: 36px; padding: 6px; cursor: pointer; }
.match-grid__cell input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.match-grid td:has(input:checked) { background-color: var(--accent-wash); }
.match-grid td:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.qstrip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 4px; overflow-x: auto;
  padding: var(--s-2) var(--s-4); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--rule);
}
.qstrip__n { flex: none; min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--rule-strong); font-size: var(--text-xs); font-weight: 600; text-decoration: none; }
.qstrip__n[data-done="1"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (min-width: 768px) { .qstrip { left: var(--sidebar-w); } .shell[data-collapsed="true"] .qstrip { left: 0; } }
@media (max-width: 767px) {
  .qstrip { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .runner { padding: 0 var(--s-3) calc(var(--tabbar-h) + 80px); }
  /* Reading on a phone: the runner fills the screen between the top bar and the question strip.
     The passage sits above the questions; each scrolls on its own, and the handle shares the height. */
  .runner--split {
    --qstrip-h: calc(30px + 2 * var(--s-2) + 1px);
    display: flex; flex-direction: column; gap: var(--s-2);
    height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom));
    padding-bottom: var(--qstrip-h); overflow: hidden;
  }
  /* Positioned, so absolute children (.sr-only labels) stay inside the panes instead of
     stretching the page below the screen. */
  .runner--split, .runner--split .runner__passage, .runner--split .runner__questions { position: relative; }
  /* The runner no longer scrolls with the page, so the bar needs no sticking (and would
     stick 48px low inside the runner's own box). */
  .runner--split > .runner__head { position: static; flex: none; }
  .runner--split .runner__section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .runner__panes--split { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .runner--split .runner__passage {
    flex: 0 0 calc(var(--split, 0.45) * 100%); top: auto; max-height: none;
    overflow: auto; overscroll-behavior: contain; padding: 0 var(--s-2) var(--s-3);
  }
  /* Side padding holds each .q's -8px hover margin, so the pane never scrolls sideways. */
  .runner--split .runner__questions { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: var(--s-3) var(--s-2) var(--s-4); }
  .runner--split .q { scroll-margin-top: var(--s-2); }
  /* The questions pane scrolls on its own: the word box sticks to its top. */
  .runner--split .wordbank { top: 0; }
  .runner--split .qblock__bank .q { scroll-margin-top: calc(var(--bank-h, 0px) + var(--s-2)); }
  .runner__handle {
    flex: none; display: grid; place-items: center; height: 24px; margin: 0 calc(-1 * var(--s-3));
    border-block: 1px solid var(--rule); background: var(--wash);
    cursor: row-resize; touch-action: none; user-select: none;
  }
  .runner__handle::before { content: ""; width: 40px; height: 4px; border-radius: 999px; background: var(--rule-strong); transition: background-color var(--dur) var(--ease-out); }
  .runner__handle:focus-visible { outline-offset: -2px; border-radius: 0; }
  .runner__handle:focus-visible::before, .runner__handle[data-dragging="true"]::before { background: var(--accent); }
}

/* ---------- Exams: results ---------- */
.scores--test { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.result-table tr.is-wrong td:first-child { color: var(--danger); }
.result-table tr.is-right td:first-child { color: var(--success); }
.result-mark { display: inline-flex; vertical-align: -2px; }
.exp-row td { padding-top: 0; border-bottom-style: dashed; }
.exp-row:hover td { background: none; }
.explanation { display: grid; gap: 4px; padding: var(--s-2) var(--s-3); border-radius: var(--radius); background: var(--wash); }
.explanation p { margin: 0; }
.evidence { margin: 0; padding: 0 0 0 var(--s-3); border-left: 2px solid var(--rule-strong); color: var(--ink-muted); font-style: italic; }
.note-inline { display: grid; gap: var(--s-1); max-width: 640px; margin-top: var(--s-4); }

/* ---------- Practice ---------- */
.quiz-new { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 var(--s-3); max-width: 640px; }
.quiz-new fieldset, .quiz-new .form-actions { grid-column: 1 / -1; }
.quiz-score { font-size: var(--text-xl); color: var(--ink-muted); }
.quiz-score strong { color: var(--accent); font-size: var(--text-2xl); }
.quiz { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); counter-reset: quiz; }
.quiz-item { display: grid; gap: var(--s-2); padding: var(--s-4); border: 1px solid var(--rule); border-radius: var(--radius-lg); counter-increment: quiz; }
.quiz-item.is-right { border-color: color-mix(in srgb, var(--success) 50%, var(--rule)); }
.quiz-item.is-wrong { border-color: color-mix(in srgb, var(--danger) 50%, var(--rule)); }
.quiz-item__head { display: flex; align-items: center; gap: 2px; }
.quiz-item__head::before { content: counter(quiz); font-weight: 700; color: var(--ink-muted); margin-right: var(--s-2); font-variant-numeric: tabular-nums; }
.quiz-item__prompt { font-size: var(--text-lg); margin: 0; }
.quiz-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
@media (max-width: 540px) { .quiz-options { grid-template-columns: minmax(0, 1fr); } }
.quiz-opt {
  display: flex; align-items: center; min-height: 44px; padding: 8px 12px; text-align: left;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper); color: var(--ink);
  font-size: var(--text-md); cursor: pointer; transition: background var(--dur) var(--ease-out), border-color var(--dur);
}
button.quiz-opt:hover { background: var(--wash); border-color: var(--accent); }
span.quiz-opt { cursor: default; color: var(--ink-muted); }
.quiz-opt.is-answer { border-color: var(--success); background: var(--success-wash); color: var(--ink); font-weight: 600; }
.quiz-opt.is-picked { border-color: var(--danger); background: var(--danger-wash); color: var(--ink); text-decoration: line-through; }
.quiz-item__foot p { margin: 0; }
.text-success { color: var(--success); }

/* ---------- Test figures (diagrams, maps, illustrations) ---------- */
.exam-figure { margin: var(--s-3) 0; display: grid; gap: var(--s-1); justify-items: start; }
.exam-figure__zoom { display: block; max-width: 100%; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; cursor: zoom-in; overflow: hidden; }
.exam-figure__zoom img { display: block; max-width: 100%; max-height: 520px; height: auto; object-fit: contain; }
.exam-figure__zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.exam-figure figcaption { font-size: var(--text-xs); color: var(--ink-muted); font-family: var(--font-ui); }
.qblock .exam-figure { margin: var(--s-2) 0; }
.exam-figures { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-3); }
.exam-figures .exam-figure { margin: 0; }
.exam-figures .exam-figure__zoom img { max-height: 180px; }
dialog.figure-zoom { width: auto; max-width: min(1100px, calc(100vw - 24px)); padding: var(--s-2); background: var(--paper); }
dialog.figure-zoom img { display: block; max-width: 100%; max-height: calc(90dvh - 24px); margin: 0 auto; background: #fff; border-radius: var(--radius); }
dialog.figure-zoom::backdrop { background: rgba(0, 0, 0, 0.6); }
.figure-zoom__close { position: absolute; top: 8px; right: 8px; background: color-mix(in srgb, var(--paper) 85%, transparent); }

.figures-edit { display: grid; gap: var(--s-2); margin: var(--s-3) 0; padding: var(--s-3); border: 1px dashed var(--rule-strong); border-radius: var(--radius-lg); }
.figures-edit p { margin: 0; }
.figures-edit__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.figures-edit__upload { cursor: pointer; }
.figures-edit__upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.figure-row { display: flex; align-items: center; gap: var(--s-2); }
.figure-row__thumb { flex: none; width: 64px; height: 48px; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; cursor: zoom-in; overflow: hidden; }
.figure-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.figure-row__form { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-width: 0; }
.figure-row__form .input { flex: 1; min-width: 160px; }
.figure-row__marker { font-size: var(--text-xs); padding: 2px 6px; border-radius: var(--radius-sm); background: var(--wash); user-select: all; }

/* ---------- Listening ---------- */
.text-warning { color: var(--warning); }
.badge--warn { background: var(--warning-wash); color: var(--warning); }
.row__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius); background: var(--wash); color: var(--ink-muted); flex: none; }
.listen-new { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-4); max-width: 640px; }
.listen-new__kind, .listen-new .form-actions { grid-column: 1 / -1; }
.listen-new .form-actions { flex-wrap: wrap; }
.listen-new .field p { margin: 0; }
@media (max-width: 540px) { .listen-new { grid-template-columns: minmax(0, 1fr); } }

.dict-progress { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: var(--s-3) 0 0; padding: 0; }
.dict-progress li { width: 22px; height: 6px; border-radius: 999px; background: var(--wash-strong); }
.dict-progress li.is-current { background: var(--accent); }
.dict-progress li.is-right { background: var(--success); }
.dict-progress li.is-wrong { background: var(--warning); }
.dict { display: grid; gap: var(--s-4); max-width: 680px; }
.dict__controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.dict__input { width: 100%; min-height: 96px; font: 400 var(--text-lg)/1.6 var(--font-read); }
.dict__result { display: grid; gap: var(--s-3); }
.dict__result p { margin: 0; }
.dict__score { display: flex; align-items: baseline; gap: var(--s-2); margin: 0; }
.dict__score strong { font-size: var(--text-xl); }
.dict__score--big strong { font-size: var(--text-2xl); color: var(--accent); }
.dict__original { font-family: var(--font-read); color: var(--ink); }

.dict-diff { margin: 0; font-size: var(--text-lg); line-height: 2; }
.dw { white-space: nowrap; }
.dw s, .dw ins { text-decoration-thickness: 2px; text-underline-offset: 4px; }
.dw--wrong s { color: var(--danger); }
.dw--wrong ins { color: var(--success); text-decoration: none; font-weight: 600; }
.dw--spelling { padding: 1px 4px; border-radius: var(--radius-sm); background: var(--warning-wash); }
.dw--spelling s { color: var(--warning); }
.dw--spelling ins { color: var(--ink); text-decoration: none; font-weight: 600; }
.dw--missing ins { color: var(--success); font-weight: 600; text-decoration: underline dashed; }
.dw--extra s { color: var(--ink-muted); }
.dict-legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin: 0; padding: 0; }
.dict-legend .dw { font-size: var(--text-sm); }

.dict-summary { display: grid; gap: var(--s-2); max-width: 720px; }
.dict-missed { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; padding: 0; }
.dict-missed li { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 10px; border: 1px solid var(--rule); border-radius: var(--radius); font-weight: 500; }
.dict-review { list-style: none; display: grid; gap: var(--s-3); margin: 0; padding: 0; }
.dict-review__item { display: grid; gap: var(--s-1); padding-bottom: var(--s-3); border-bottom: 1px solid var(--rule); }
.dict-review__head { display: flex; align-items: center; gap: var(--s-1); }

/* Card panel on item pages */
.srs-panel { display: grid; gap: var(--s-3); }
.srs-card { display: grid; gap: var(--s-1); padding: var(--s-3); border: 1px solid var(--rule); border-radius: var(--radius); }
.srs-card__head { display: flex; align-items: center; gap: var(--s-2); }
.srs-card__dir { font-weight: 600; font-size: var(--text-sm); }
.srs-card p { margin: 0; }
.qgroup > .btn, .exam-section > .btn { justify-self: start; }

/* ---------- Writing prompt image: in the test editor and the prompt form ---------- */
.writing-image { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-3); margin-top: var(--s-2); }
.writing-image__thumb, .image-field__preview { display: block; padding: 4px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; cursor: zoom-in; }
.writing-image__thumb:hover, .image-field__preview:hover { border-color: var(--rule-strong); }
.writing-image__thumb img { display: block; height: 160px; max-width: 100%; object-fit: contain; }
.writing-image__desc { flex: 1 1 220px; margin: 0; }
.image-field__shown { display: grid; justify-items: start; gap: var(--s-2); margin-bottom: var(--s-2); transition: opacity var(--dur); }
.image-field__shown.is-cleared .image-field__preview { opacity: 0.35; }
.image-field__preview img { display: block; max-height: 240px; max-width: 100%; object-fit: contain; }
.image-field__name { max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
