/* Inventory Valuation Practice: a bookkeeper's ruled card. Pale sage ledger paper, a deep ledger-green accent, the
   red double rule under the column heads and between Receipts, Issues and Balance, figures in a mono face. A heavy
   grotesque for headings. On paper: black rules on white, the card at full width, every problem kept whole. */
:root {
  --bg: #edf1e8;
  --paper: #fbfcf8;
  --ink: #17201b;
  --muted: #47534c;
  --line: #cfd8cc;
  --edge: #7d8a82;
  --accent: #1e5a45;
  --accent-ink: #ffffff;
  --accent-soft: #dbe9e0;
  --rule: #b4372d;
  --given: #f1f4ec;
  --info: #23566b;
  --ok: #1d6a37;
  --ok-soft: #dcefe0;
  --close: #7a5300;
  --close-soft: #f6ead0;
  --bad: #a3271f;
  --bad-soft: #f8e1dd;
  --focus: #1b5fd0;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --r: 2px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a16;
    --paper: #18221d;
    --ink: #e3ebe5;
    --muted: #a9b7af;
    --line: #2f3c35;
    --edge: #66766d;
    --accent: #84cfad;
    --accent-ink: #0f1f18;
    --accent-soft: #1e3329;
    --rule: #e0847a;
    --given: #1d2a24;
    --info: #86c6e0;
    --ok: #8fd8a3;
    --ok-soft: #15301d;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8ab8ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-underline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.92em; white-space: nowrap; }
.rules .mono { font-size: 1em; }

.hero { padding: 22px 0 2px; max-width: 800px; margin-top: 10px; }
h1 { font: 800 clamp(1.7rem, 4.6vw, 2.5rem)/1.08 var(--sans); margin: 0 0 8px; letter-spacing: -0.02em; }
.lede { margin: 0 0 4px; color: var(--muted); max-width: 64ch; }
h2 { font: 750 1.3rem/1.2 var(--sans); margin: 0 0 10px; letter-spacing: -0.01em; }

/* layout: settings, then the sheet at full width (a ledger card needs every column) */
.setup { margin: 14px 0 4px; }
.work-area { min-width: 0; }
@media (min-width: 1000px) {
  .setup { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 22px; }
  .setup .levels-f { flex: 1 1 560px; margin: 0; }
  .setup .units-f { flex: 0 0 230px; margin: 0; }
  .setup .lifo-note, .setup .aat-note { flex: 1 1 100%; margin: 0; }
}
fieldset { border: 0; padding: 0; margin: 0 0 10px; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--edge); border-radius: var(--r); overflow: hidden; max-width: 420px; }
.sg, .lg { position: relative; display: block; cursor: pointer; }
.sg + .sg { border-left: 1px solid var(--edge); }
.sg input, .lg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sg > span { display: flex; align-items: center; justify-content: center; min-height: 44px; height: 100%; padding: 4px 6px; text-align: center; font-size: 0.95rem; font-weight: 650; background: var(--paper); }
.sg input:checked + span { background: var(--ink); color: var(--bg); }
.lseg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.lseg[data-n="7"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 700px) { .lseg { grid-template-columns: repeat(6, minmax(0, 1fr)); } .lseg[data-n="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.lg > span { display: flex; flex-direction: column; justify-content: center; min-height: 48px; height: 100%; padding: 4px 8px; border: 1px solid var(--edge); border-radius: var(--r); background: var(--paper); font-size: 0.9rem; font-weight: 600; line-height: 1.15; }
.lg b { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.lg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lg input:checked + span b { color: inherit; opacity: 0.85; }
.sg input:focus-visible + span, .lg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.lifo-note { font-size: 0.9rem; color: var(--muted); margin: 0 0 8px; }
.lifo-note[hidden], .aat-note[hidden] { display: none; }
.aat-note { font-size: 1rem; margin: 0 0 8px; padding: 6px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); }
.lnote { margin: 2px 0 0; flex: 1 1 100%; font-size: 0.85rem; font-weight: 650; color: var(--rule); }
.setrow { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
@media (min-width: 1060px) { .setrow { flex: 0 0 auto; } }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: var(--r); min-height: 44px; padding: 6px 10px; }
select { max-width: 100%; }
.btn { font: inherit; font-weight: 650; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 6px 14px; }
.btn:hover { filter: brightness(0.95); }
.link { font: inherit; background: none; border: 0; padding: 10px 0; min-height: 44px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* the marking rules, closed above the sheet */
.rules { margin: 12px 0 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); font-size: 1rem; }
.rules > summary { cursor: pointer; font-weight: 650; padding: 10px 12px; min-height: 44px; }
.rules ul { margin: 0; padding: 0 12px 10px 30px; color: var(--muted); max-width: 80ch; }
.rules li { margin: 0 0 6px; }

.note { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--close); background: var(--close-soft); overflow-wrap: anywhere; border-radius: var(--r); }
.note.info { border-color: var(--info); background: var(--paper); }
.note .link { min-height: 0; padding: 0; font-weight: 600; }

/* the sheet */
.sheet { margin: 12px 0 0; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; border-bottom: 3px double var(--rule); padding-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
.code { font-family: var(--mono); letter-spacing: 0.08em; color: var(--accent); }
.lvname { font-size: 0.9rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.score { margin: 0; font-size: 0.95rem; color: var(--muted); }
.practice { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.qs { list-style: none; margin: 0; padding: 0; }
.q { border-bottom: 1px solid var(--line); padding: 22px 0 10px; }
.q h3 { font: 750 1.15rem/1.25 var(--sans); margin: 0 0 4px; }
.q h3 .qn { color: var(--accent); margin-right: 6px; font-family: var(--mono); }
.q .scen { margin: 0 0 8px; max-width: 72ch; }
.qhint { margin: 0 0 10px; font-size: 0.9rem; color: var(--muted); max-width: 72ch; }

/* the ruled card */
.fig { margin: 0 0 12px; }
.ledger-doc { background: var(--paper); border: 1px solid var(--edge); border-radius: var(--r); max-width: 100%; }
.lhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 18px; padding: 8px 10px 6px; border-bottom: 1px solid var(--line); }
.ltitle { margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.82rem; color: var(--accent); flex: 1 1 100%; }
.lmeta { margin: 0; font-size: 0.9rem; }
.lmeta span { color: var(--muted); }
.lwrap { overflow-x: auto; max-width: 100%; }
.lwrap:focus-visible { outline-offset: -3px; }
table.ledger { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.ledger th, .ledger td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.ledger.key td, .key .ledger td { vertical-align: top; }
.ledger thead th { font-size: 0.78rem; font-weight: 650; color: var(--muted); text-align: center; vertical-align: bottom; }
.ledger thead tr:last-child th { border-bottom: 3px double var(--rule); }
.ledger thead th.grp { color: var(--ink); font-size: 0.85rem; border-bottom: 1px solid var(--line); border-left: 2px solid var(--rule); }
.ledger thead th[rowspan] { border-bottom: 3px double var(--rule); text-align: left; }
.ledger .gs { border-left: 2px solid var(--rule); }
.ledger td.num { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.ledger td.txt { font-size: 0.88rem; }
.ledger td.c-x { white-space: normal; min-width: 6.5em; max-width: 10em; }
.ledger .c-d { position: sticky; left: 0; background: var(--paper); z-index: 1; box-shadow: 1px 0 0 var(--line); font-size: 0.88rem; }
.ledger thead .c-d { z-index: 2; }
.ledger td.num:not(.in) { background: var(--given); }
.ledger td.in { padding: 3px 3px; background: transparent; }
.ledger .ln { display: block; }
.ledger .ln.tot { border-top: 1px solid var(--ink); font-weight: 700; }
.ledger tr.r-open td { border-bottom: 1px solid var(--edge); }
input.cell { font-family: var(--mono); text-align: right; padding: 5px 5px; min-height: 40px; width: 5.4em; }
input.cell.t-qty { width: 3.6em; }
input.cell.t-batches { width: 11.6em; text-align: left; }
input.cell.is-right { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); background: var(--ok-soft); }
input.cell.is-wrong, input.cell.is-unread { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); background: var(--bad-soft); }
input.cell.is-close { border-color: var(--close); box-shadow: inset 0 0 0 1px var(--close); background: var(--close-soft); }
.key .ledger td.num { background: transparent; }
.cellfb { max-width: 72ch; margin: -4px 0 10px; }

/* plain data tables */
.twrap { overflow-x: auto; max-width: 100%; }
.tpair { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-start; }
.dt { border-collapse: collapse; background: var(--paper); font-size: 0.93rem; }
.tcap { margin: 0 0 3px; font-weight: 650; font-size: 0.88rem; color: var(--muted); }
.dt th, .dt td { padding: 5px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.dt thead th { font-size: 0.8rem; color: var(--muted); font-weight: 650; border-bottom: 3px double var(--rule); vertical-align: bottom; }
.dt .num { text-align: right; }
.dt td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dt tbody th { font-weight: 500; white-space: nowrap; }
.dt tfoot th, .dt tfoot td { font-weight: 700; border-top: 1px solid var(--edge); border-bottom: 0; }
.dt td.in { padding: 3px 4px; }
.nrvt th.c-cs, .nrvt th.c-sp, .nrvt th.c-val, .nrvt th.c-nrv, .nrvt th.c-c { min-width: 6.5em; }
.nrvt td.c-note { font-size: 0.85rem; color: var(--muted); min-width: 8em; }

/* questions */
.qparts { max-width: 760px; min-width: 0; }
.work[open] { max-width: none; }
.part { margin: 0 0 14px; min-width: 0; }
/* Compare on wide screens: one row per figure, one column per method (coordinator decision 2026-10-26) */
@media (min-width: 900px) {
  .cmpgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 20px; max-width: 980px; }
  .cmpgrid.m2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 680px; }
  .cmpgrid > .part:first-child, .cmpgrid > fieldset, .cmpgrid > .qfoot { grid-column: 1 / -1; }
  .cmpgrid .ain input { width: 100%; max-width: 11em; }
  .cmpgrid > .part { display: flex; flex-direction: column; }
  .cmpgrid > .part > .prompt { flex: 1 0 auto; }
}
.part > .prompt, .part legend { display: block; font-weight: 600; margin: 0 0 6px; }
.opts { display: grid; gap: 4px; }
.opt { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); cursor: pointer; }
.opt input { margin: 3px 0 0; min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.opt .ot { min-width: 0; }
.opt:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.ain { display: flex; align-items: center; gap: 4px; }
.ain .pre { font-family: var(--mono); color: var(--muted); }
.ain input { width: 10em; font-family: var(--mono); }
.qfoot { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; }
.qfoot .fb { margin: 0; }
.fbwrap:empty { display: none; }
.fb { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--r); max-width: 72ch; }
.fb.right { background: var(--ok-soft); color: var(--ok); }
.fb.close { background: var(--close-soft); color: var(--close); }
.fb.wrong, .fb.unread { background: var(--bad-soft); color: var(--bad); }
.fb.more { color: var(--muted); padding: 2px 10px; }
.part.is-right .ain input { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.part.is-wrong .ain input, .part.is-unread .ain input { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.part.is-close .ain input { border-color: var(--close); box-shadow: inset 0 0 0 1px var(--close); }
.work { margin-top: 4px; min-width: 0; }
.work .steps, .work .ans { max-width: 80ch; }
.work > summary { cursor: pointer; color: var(--muted); font-size: 0.93rem; padding: 10px 0; min-height: 44px; display: flex; align-items: center; list-style: none; }
.work > summary::-webkit-details-marker { display: none; }
.work > summary::before { content: "+"; margin-right: 6px; font-weight: 700; font-family: var(--mono); }
.work[open] > summary::before { content: "−"; }
.keyfig { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 10px; }
.work .ans { margin: 0 0 2px; }
.steps { list-style: disc; margin: 2px 0 10px; padding-left: 1.4em; font-size: 0.93rem; overflow-wrap: anywhere; }
.ksteps > summary { cursor: pointer; font-size: 0.93rem; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.sheet-foot { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 0; }
.confirm { flex: 1 1 100%; margin: 0; padding: 10px 12px; border: 1px solid var(--close); border-radius: var(--r); background: var(--close-soft); }
.confirm[hidden] { display: none; }

.share { margin: 10px 0 8px; }
.print-row { display: flex; align-items: flex-end; gap: 8px 10px; flex-wrap: wrap; }
.print-row label, .share-out label { display: flex; flex-direction: column; gap: 3px; font-size: 0.9rem; font-weight: 600; }
.share-out input { width: 100%; }
.recent { margin-top: 12px; border-top: 1px solid var(--line); }
.recent summary { cursor: pointer; padding: 11px 0; font-weight: 600; min-height: 44px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 4px 0; }
.recent small { display: block; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 8px 0 10px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 160%); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); max-width: calc(100% - 32px); transition: transform 0.2s; z-index: 20; }
.toast.on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* content */
.content { padding: 22px 0 8px; max-width: 800px; }
.content h2 { margin-top: 30px; }
.content p { max-width: 68ch; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 11px 0; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0 0 12px; }
.sources { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; margin-top: 22px; }

footer { border-top: 1px solid var(--line); margin-top: 20px; padding: 16px 0 28px; color: var(--muted); font-size: 0.92rem; }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-footer a { color: var(--ink); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 600px) {
  .hero { padding-top: 6px; margin-top: 8px; }
  .q .scen { font-size: 0.97rem; }
  .ledger th, .ledger td { padding: 3px 4px; }
  input.cell { width: 5.8em; }
  input.cell.t-batches { width: 10.5em; }
}

/* print: worksheet and key only, black on white */
.print-root { display: none; }
@page { margin: 0.45in 0.45in; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #888; --paper: #fff; --edge: #444; --rule: #000; --given: #fff; --accent: #000; }
  body { background: #fff; color: #000; font: 10pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  table.pt { width: 100%; border-collapse: collapse; }
  table.pt > tbody > tr > td, table.pt > thead > tr > td { padding: 0; }
  .prun { font: 8pt var(--sans); color: #444; text-align: right; padding-bottom: 5pt !important; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2pt solid #000; margin-bottom: 6pt; }
  .ph h2 { font: 800 14pt var(--sans); margin: 0; }
  .ph p { margin: 0; font-size: 9pt; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 4pt 0 6pt; }
  .plabel { margin: 0 0 6pt; font-size: 8.5pt; font-style: italic; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { padding: 5pt 0 4pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pqh { break-after: avoid; page-break-after: avoid; }
  /* QA 2026-10-26: the tallest returns cards (9 lines, 4 batches) do not fit under the sheet header on Letter, which left
     page 1 holding only the header; the first problem may run on to page 2 instead (the card's column heads repeat). */
  .pq > li:first-child { break-inside: auto; page-break-inside: auto; }
  .pq h3, .pk h3 { font: 750 11pt var(--sans); margin: 0 0 2pt; }
  .pq .pscen { margin: 0 0 5pt; }
  .fig { margin: 0 0 6pt; }
  .ledger-doc { border: 0.9pt solid #000; border-radius: 0; }
  .lhead { padding: 3pt 5pt; border-bottom: 0.6pt solid #000; gap: 1pt 14pt; }
  .ltitle { font-size: 8pt; color: #000; flex: 0 0 auto; }
  .lmeta { font-size: 8.5pt; }
  .lnote { color: #000; font-size: 8.5pt; font-style: italic; }
  .lmeta span { color: #333; }
  .lwrap { overflow: visible; }
  table.ledger { font-size: 8.3pt; table-layout: fixed; }
  .ledger col.k-d { width: 7.5%; } .ledger col.k-x { width: 13.5%; }
  .ledger td.c-d { white-space: nowrap; font-size: 7.8pt; }
  .ledger thead th.c-d, .ledger thead th.c-x { font-size: 7.3pt; }
  .ledger col.k-rq, .ledger col.k-iq, .ledger col.k-bq { width: 6%; }
  .ledger col.k-rc, .ledger col.k-ic, .ledger col.k-bc { width: 9.5%; }
  .ledger col.k-rv, .ledger col.k-iv, .ledger col.k-bv { width: 9.5%; }
  .ledger.us col.k-x { width: 14%; }
  .ledger th, .ledger td { padding: 2pt 3pt; border: 0.5pt solid #777; white-space: normal; overflow-wrap: anywhere; }
  .ledger td.c-x { min-width: 0; max-width: none; font-size: 7.6pt; }
  .ledger thead th { font-size: 7.3pt; color: #000; }
  .ledger thead tr:last-child th, .ledger thead th[rowspan] { border-bottom: 2.2pt double #000; }
  .ledger .gs, .ledger thead th.grp { border-left: 1.4pt solid #000; }
  .ledger .c-d { position: static; box-shadow: none; }
  .ledger td.num { white-space: nowrap; }
  table.ledger tr { break-inside: avoid; page-break-inside: avoid; }
  /* about 13 pt per handwritten line (ROW_PT in draw.js) */
  table.ledger.l2 tbody tr:not(.r-open) td { height: 28pt; }
  table.ledger.l3 tbody tr:not(.r-open) td { height: 41pt; }
  table.ledger.l4 tbody tr:not(.r-open) td { height: 54pt; }
  table.ledger.l5 tbody tr:not(.r-open) td { height: 67pt; }
  .pq .ledger-doc { break-inside: avoid; page-break-inside: avoid; }
  .wlines { margin: 3pt 0 0; }
  .wlines span { display: block; height: 15pt; border-bottom: 0.5pt solid #999; }
  table.ledger tbody td { height: 17pt; }
  .dt { font-size: 9pt; background: #fff; }
  .tcap { color: #000; font-size: 8.5pt; margin: 0 0 2pt; }
  .dt th, .dt td { padding: 2pt 5pt; border: 0.6pt solid #777; }
  .dt thead th { color: #000; border-bottom: 2pt double #000; font-size: 8pt; }
  .nrvt { width: 100%; table-layout: fixed; }
  .nrvt td { height: 17pt; }
  /* QA 2026-10-26: equal fixed columns made long line names ("Camping lanterns") run into the Note column */
  .nrvt th.c-n { width: 19%; } .nrvt th.c-note { width: 15%; } .nrvt th.c-q { width: 7%; }
  .nrvt th.c-c, .nrvt th.c-sp, .nrvt th.c-cs, .nrvt th.c-nrv, .nrvt th.c-val { width: 11.8%; }
  .nrvt th.c-cs, .nrvt th.c-sp, .nrvt th.c-val, .nrvt th.c-nrv, .nrvt th.c-c { min-width: 0; }
  .nrvt td.c-note { min-width: 0; color: #000; font-size: 8pt; }
  .twrap { overflow: visible; }
  .tpair { gap: 6pt 18pt; }
  .pparts { columns: 2; column-gap: 8mm; margin-top: 4pt; }
  .pparts .pp { margin: 0 0 6pt; break-inside: avoid; page-break-inside: avoid; }
  .pparts .pp p { margin: 0 0 1pt; }
  .pparts ol.popts { margin: 0; padding-left: 14pt; list-style: upper-alpha; font-size: 9pt; }
  .pparts .pline { margin-top: 8pt !important; }
  .pkey { break-before: page; page-break-before: always; }
  .pk > li { padding: 4pt 0 5pt; border-bottom: 0.75pt solid #bbb; }
  .pk .keyfig { margin: 2pt 0 4pt; gap: 6pt; }
  .pk .ledger-doc, .pk .twrap { break-inside: avoid; page-break-inside: avoid; }
  .pk h3 { break-after: avoid; page-break-after: avoid; }
  .pk .ans { margin: 1pt 0 0; font-weight: 600; font-size: 9.5pt; break-after: avoid; page-break-after: avoid; }
  /* QA 2026-10-26: a key ending in an answer (the compare choice) chained break-after: avoid into the next problem's
     heading and card, so Chrome split the next card across pages instead; the last answer may break after. */
  .pkw > .ans:last-child { break-after: auto; page-break-after: auto; }
  .pk .steps { margin: 0 0 2pt; padding-left: 13pt; font-size: 8.4pt; line-height: 1.28; }
  .pk .steps li { break-inside: avoid; page-break-inside: avoid; }
  .pk .kst { margin: 3pt 0 0; font-weight: 650; font-size: 9pt; }
}
@media screen and (max-width: 360px) {
  .lg > span { padding: 4px 4px; font-size: 0.82rem; }
}
