/* Consumer arithmetic practice: a till receipt on sand paper. Warm paper, dark slate ink, one deep sea-teal accent.
   The page's one motif is the receipt's dashed tear line and its double-underlined total. */
:root {
  --bg: #efe9dc; --paper: #fbf8f1; --ink: #1d2a2a; --muted: #4a5552; --line: #d9d0bd; --line2: #8f8775;
  --accent: #0d6763; --accent-ink: #ffffff; --accent-soft: #dcece9;
  --ok: #1d6b3a; --ok-soft: #e1f1e6; --bad: #a3261b; --bad-soft: #fbe5e2; --warn: #7d5300; --warn-soft: #fbf0d6;
  --head: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 3px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101716; --paper: #172120; --ink: #e8ece6; --muted: #aab6b1; --line: #2c3a38; --line2: #55645f;
    --accent: #6fcfc5; --accent-ink: #0b1514; --accent-soft: #1b3330;
    --ok: #79d39a; --ok-soft: #1c3426; --bad: #ff9a8f; --bad-soft: #3d1f1c; --warn: #f0c46b; --warn-soft: #3a2f16;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hero { padding: 22px 0 4px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 8px; padding-bottom: 10px; border-bottom: 2px dashed var(--ink); display: inline-block; }
.lede { margin: 4px 0 0; max-width: 62ch; color: var(--muted); }
@media (max-width: 600px) {
  .hero { padding-top: 12px; }
  .hero h1 { margin-bottom: 4px; padding-bottom: 6px; }
  .lede { display: none; }
  .cur-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .setup { gap: 8px; margin-top: 8px; }
  .sheet { padding: 12px 12px 14px; }
}

.setup { margin: 12px 0 8px; display: grid; gap: 10px; }
.setup fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips, .steps-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .step { position: relative; }
.chip input, .step input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span, .step span { display: flex; align-items: center; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line2); background: var(--paper); border-radius: var(--r); white-space: nowrap; }
.step b { font-family: var(--mono); margin-right: 6px; color: var(--muted); }
.chip input:checked + span, .step input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }
.step input:checked + span b { color: var(--paper); }
/* with three courses, "Other courses" shows as "Other" on phones so the currency menu stays on the course row */
.chip span.more { display: inline; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; white-space: pre; }
@media (max-width: 440px) { .chip .more { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
.chip input:focus-visible + span, .step input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.setrow { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); }
select { min-height: 44px; padding: 6px 10px; max-width: 100%; }
#topic { max-width: 15em; }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 14px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.note { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: var(--r); }
.note.info { background: var(--accent-soft); }

.sheet { background: var(--paper); border: 1px solid var(--line); border-top: 2px dashed var(--line2); border-radius: 0 0 var(--r) var(--r); padding: 14px 16px 16px; margin: 10px 0 18px; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.qhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; }
.qhead h3 { margin-right: auto; }
.see { font-weight: 600; }
.code { font-family: var(--mono); letter-spacing: 0.08em; color: var(--accent); }
.lvname { font-family: var(--sans); font-size: 1rem; font-weight: 400; color: var(--muted); }
.score { margin: 0; color: var(--muted); }
.rules { margin: 6px 0 2px; }
.rules summary, .work summary, .recent summary, .faq summary { cursor: pointer; min-height: 44px; display: list-item; padding: 10px 0; font-weight: 600; }
.rules ul { margin: 4px 0 8px; padding-left: 20px; max-width: 80ch; }
.rules li { margin: 0 0 4px; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 14px 0 6px; border-top: 1px dashed var(--line2); }
.q:first-child { border-top: 0; }
.q h3 { margin: 4px 0 8px; font-size: 1.12rem; display: flex; gap: 10px; align-items: baseline; }
.qn { font-family: var(--mono); color: var(--accent-ink); background: var(--accent); border-radius: 2px; padding: 0 7px; font-size: 1rem; }
.blk { margin: 0 0 10px; }
.scen { margin: 0 0 8px; max-width: 75ch; }
.tag, .sub { font-family: var(--mono); font-weight: 700; }

.asks { display: grid; gap: 4px; max-width: 760px; }
.ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 14px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.atext { margin: 0; flex: 1 1 22rem; min-width: 0; }
.aval { flex: 0 1 auto; display: inline-flex; max-width: 100%; }

.twrap { overflow-x: auto; max-width: 100%; margin: 4px 0 8px; }
table.dt { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dt th, .dt td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-weight: 400; }
.dt thead th { font-weight: 700; color: var(--muted); border-bottom: 2px solid var(--ink); vertical-align: bottom; }
.dt .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.dt thead th.num { font-family: var(--sans); white-space: normal; }
.dt td.in { padding: 3px 6px; }
.dt tr.r-tot th, .dt tr.r-tot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 4px double var(--ink); }

.cw { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.pre, .u { color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.cw.own-sign .pre { visibility: hidden; }
input.cell { width: calc(var(--w, 10) * 1ch + 18px); max-width: 100%; min-width: 0; min-height: 44px; padding: 6px 8px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
select.cell { min-width: 9em; }
.cell.is-right { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.cell.is-wrong, .cell.is-unread { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.cell.is-close { border-color: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn); }
.mk { flex: none; width: 1.2em; text-align: center; font-weight: 700; font-size: 1.15rem; line-height: 1; }
.mk-right { color: var(--ok); }
.mk-close { color: var(--warn); }
.mk-wrong, .mk-unread { color: var(--bad); }
.dt td.in .cw { display: flex; justify-content: flex-end; }
.kv { font-family: var(--mono); font-weight: 700; }

@media screen {
  .twrap.rows { overflow-x: visible; }
  .twrap.rows table, .twrap.rows tbody { display: block; width: 100%; }
  .twrap.rows thead { display: none; }
  .twrap.rows tr { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .twrap.rows th, .twrap.rows td { border: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 10px; min-width: 0; }
  .twrap.rows th { font-weight: 700; }
  .twrap.rows td::before { content: attr(data-l); font: 600 1rem var(--sans); color: var(--muted); }
  .twrap.rows td.num[data-l=""] { display: none; }
  .twrap.rows td.in .cw { flex: none; margin-left: auto; }
  .twrap.rows tr.r-tot th, .twrap.rows tr.r-tot td { border: 0; }
  .twrap.rows tr.r-tot { border-top: 2px solid var(--ink); border-bottom: 4px double var(--ink); }
}

.fbwrap { margin: 6px 0; }
.fb { margin: 4px 0; padding: 6px 10px; border-radius: var(--r); background: var(--bad-soft); max-width: 75ch; }
.fb.right { background: var(--ok-soft); }
.fb.close { background: var(--warn-soft); }
.fb.empty { background: var(--accent-soft); }
.qfoot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.work { margin: 4px 0 8px; }
.kfig { display: grid; gap: 8px; }
.kans { list-style: none; margin: 0; padding: 0; }
.kans li { margin: 2px 0; }
.steps { margin: 8px 0; padding-left: 20px; font-family: var(--mono); font-size: 1rem; max-width: 80ch; }
.steps li { margin: 3px 0; overflow-wrap: anywhere; }
.steps li.say { font-family: var(--sans); list-style: none; margin-left: -20px; }
.steps li.sh { font-weight: 700; margin-top: 10px; }

.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line2); }
.confirm { flex-basis: 100%; margin: 0; padding: 10px; background: var(--warn-soft); border-radius: var(--r); }
.save-hint { flex-basis: 100%; margin: 0; color: var(--muted); }

.share { margin: 0 0 24px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.print-row label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; flex-wrap: wrap; }
.share-out label { display: grid; gap: 4px; font-weight: 600; }
.share-out input { width: 100%; min-height: 44px; padding: 6px 10px; font-family: var(--mono); }
.recent { margin-top: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 12px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 6px 0; }
.recent small { display: block; color: var(--muted); font-size: 1rem; }
.hint { color: var(--muted); }

.content { max-width: 75ch; padding-bottom: 20px; }
.content h2 { font-size: 1.3rem; margin: 26px 0 8px; }
.slips { padding-left: 20px; }
.slips li { margin: 0 0 6px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq details p { margin: 0 0 12px; }
.sources { color: var(--muted); }
footer { border-top: 2px dashed var(--ink); padding: 18px 0 30px; color: var(--muted); }
.sb-footer p { margin: 6px 0; }
.sb-more a { color: var(--muted); }
.sb-credit a { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); max-width: min(92vw, 520px); z-index: 20; pointer-events: none; transition: transform 0.2s; }
.toast.on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
[hidden] { display: none !important; }
.print-root { display: none; }

@page { margin: 14mm 12mm; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #888; --line2: #444; --paper: #fff; --bg: #fff; --accent: #000; }
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--sans); }
  main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child, .psheet:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { font-size: 10pt; color: #333; padding-bottom: 4px; border-bottom: 0.5pt solid #888; }
  .ph h2 { margin: 4px 0 0; font-size: 15pt; border-bottom: 1.5pt dashed #000; display: inline-block; padding-bottom: 2px; }
  .ph p { margin: 2px 0 6px; font-size: 10pt; }
  .pmeta { display: flex; justify-content: space-between; gap: 10px; margin: 6px 0; }
  .prules { margin: 4px 0 6px; padding-left: 14pt; font-size: 10pt; }
  .prules li { margin: 0 0 2px; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { margin: 0 0 8pt; break-inside: avoid; }
  .pq > li.big { break-inside: auto; }
  .pq > li.big .blk { break-inside: avoid; }
  table.pbig { width: 100%; border-collapse: collapse; }
  .pbig > thead td, .pbig > tbody > tr > td { padding: 0; vertical-align: top; }
  .pbig .pcont { height: 16pt; vertical-align: top; font-size: 10pt; color: #333; }
  .pq .pbig h3 { position: relative; margin-top: -16pt; min-height: 16pt; background: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .pk > li { margin: 0 0 10pt; break-inside: avoid; }
  .pq > li:last-child, .pk > li:last-child { margin-bottom: 0; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 6px 0 2px; break-after: avoid; }
  .blk { margin: 0 0 4pt; }
  .scen { margin: 0 0 4pt; }
  .asks { max-width: none; gap: 0; }
  .ask { border-bottom: 0; padding: 0; min-height: 21pt; align-items: flex-end; flex-wrap: nowrap; }
  .atext { flex: 1 1 auto; }
  .pans { display: inline-flex; align-items: flex-end; gap: 2pt; white-space: nowrap; }
  .pblank { display: inline-block; border-bottom: 0.75pt solid #000; height: 16pt; vertical-align: bottom; }
  .pchoice { letter-spacing: 0.02em; }
  .pchoice::after { content: " (circle one)"; color: #333; font-size: 10pt; }
  .twrap { overflow: visible; break-inside: avoid; margin: 2pt 0 4pt; }
  table.dt { font-size: 10pt; }
  .dt th, .dt td { padding: 2pt 6pt; border-bottom: 0.5pt solid #777; }
  .dt thead th { border-bottom: 1pt solid #000; color: #000; }
  .dt td.pin { height: 21pt; min-width: 8em; border: 0.5pt solid #777; }
  .dt td.pin .pblank { border: 0; }
  .dt tr.r-tot th, .dt tr.r-tot td { border-top: 1pt solid #000; border-bottom: 2.5pt double #000; }
  .pwork { border: 0.5pt dashed #999; margin-top: 4pt; background: linear-gradient(transparent 20.25pt, #bbb 0) 0 16pt / 100% 21pt repeat-y; break-inside: avoid; break-before: avoid; }
  .pwork::before { content: "Working"; font-size: 10pt; color: #444; padding: 1pt 4pt; display: block; background: #fff; height: 15pt; }
  .kfig { display: block; }
  .kans li { margin: 1pt 0; }
  .steps { font-size: 10pt; margin: 4px 0; }
  .steps li { margin: 1pt 0; }
  .steps li.say { font-size: 10pt; }
  .steps li.sh { margin-top: 4pt; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
