/* Titration Results Practice: a white tile under a burette. Warm white ground, graphite ink, a copper(II) sulfate
   blue accent for actions and question numbers, and a burette scale (short ticks, a long one every fifth) running
   down the left edge of each question. Burette close-ups stay white with clear liquid in both themes, as on paper.
   On paper everything is black on white. */
:root {
  --bg: #f6f5f1;
  --paper: #ffffff;
  --ink: #171a21;
  --muted: #4a515e;
  --line: #d6d8dd;
  --edge: #737b88;
  --accent: #1d4fa3;
  --accent-ink: #ffffff;
  --accent-soft: #e3eaf7;
  --info: #1d4fa3;
  --ok: #17663a;
  --ok-soft: #ddefe3;
  --close: #7a5300;
  --close-soft: #f6ecd2;
  --bad: #a3241d;
  --bad-soft: #f8e0dd;
  --focus: #c2185b;
  --panel: #232936;
  --panel-ink: #f3f4f7;
  --panel-muted: #b9c0cc;
  --head: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --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: 3px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --paper: #1c2028;
    --ink: #e6e8ec;
    --muted: #a9b0bc;
    --line: #313744;
    --edge: #6c7584;
    --accent: #8db4f2;
    --accent-ink: #0b1630;
    --accent-soft: #1d2a44;
    --info: #9fc0f5;
    --ok: #8adca6;
    --ok-soft: #14301f;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #f48fb1;
    --panel: #2b3343;
    --panel-ink: #f3f4f7;
    --panel-muted: #b9c0cc;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
a { color: var(--info); text-underline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; font-weight: 700; }
.hero { position: relative; padding: 18px 0 14px 30px; margin: 0; }
/* a burette scale down the left of the title: short ticks, a long one every fifth */
.hero::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 14px; width: 18px; border-right: 2.5px solid var(--accent);
  background: repeating-linear-gradient(to bottom, transparent 0 34px, var(--accent) 34px 36px) right / 16px 100% no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 5px, var(--accent) 5px 7.2px) right / 8px 100% no-repeat; }
.hero h1 { font: 800 clamp(26px, 4.6vw, 40px)/1.1 var(--sans); margin: 0 0 6px; letter-spacing: -0.02em; max-width: 24ch; }
.lede { margin: 0; max-width: 64ch; }

/* ---------- controls: one dark strip of selects, the extras folded under it ---------- */
.tool { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.setup { background: var(--panel); color: var(--panel-ink); padding: 10px 12px 2px; border-radius: var(--r); }
.ctl { display: grid; gap: 8px 10px; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) auto; grid-template-areas: "board level count new"; align-items: end; }
.f-board { grid-area: board; } .f-level { grid-area: level; } .f-count { grid-area: count; } .f-new { grid-area: new; }
.fld { display: grid; gap: 2px; min-width: 0; }
.fld span { font: 600 13.5px var(--sans); color: var(--panel-muted); }
.fld select { width: 100%; }
.more { display: flex; flex-wrap: wrap; gap: 0 22px; }
.more details[open] { flex-basis: 100%; }
.setup summary { color: var(--panel-ink); }
.setup .tsum { color: var(--panel-muted); }
.more details > fieldset, .more details > div { background: var(--paper); color: var(--ink); padding: 8px 10px; margin: 0 0 10px; border-radius: var(--r); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font: 600 15px var(--sans); color: var(--muted); padding: 0; margin-bottom: 4px; }
.tdet summary, .rules summary { cursor: pointer; font-weight: 600; min-height: 44px; padding: 10px 0; display: list-item; }
.tsum { font-weight: 400; color: var(--muted); font-size: 15px; }
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; padding-top: 4px; }
.tg { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; min-height: 44px; background: var(--paper); }
.tg input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.tg b { display: block; font-weight: 600; font-size: 15.5px; }
.tg small { display: block; color: var(--muted); font-size: 14px; line-height: 1.3; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
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; max-width: 100%; }
.btn { font: 600 16px var(--sans); min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.link { font: inherit; background: none; border: 0; color: var(--info); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 44px; padding: 0 4px; }

/* ---------- rules ---------- */
.rl { margin: 4px 0 0; padding-left: 20px; font-size: 15.5px; line-height: 1.45; }
.rl li { margin: 0 0 4px; }

/* ---------- the sheet ---------- */
.note { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--bad); background: var(--bad-soft); font-size: 16px; border-radius: var(--r); }
#store-note { overflow-wrap: anywhere; }
.note.info { border-color: var(--info); background: var(--paper); }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; }
.sheet-head h2 { font-size: 28px; margin: 6px 0 0; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.score { margin: 0; color: var(--muted); font-size: 15px; }
.sline { margin: 2px 0 10px; color: var(--muted); font-size: 15px; }
.qs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
/* each question hangs on a burette scale: short ticks every 8 px, a long one every 40 px */
.q { position: relative; background: var(--paper); border: 1px solid var(--line); padding-left: 16px; min-width: 0; }
.q::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 13px; border-right: 2px solid var(--accent);
  background: repeating-linear-gradient(to bottom, transparent 0 39px, var(--accent) 39px 41px) right / 12px 100% no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 7px, var(--accent) 7px 8.5px) right / 6px 100% no-repeat; opacity: 0.85; }
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 0 10px; }
.q h3 { margin: 0; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.qn { font: 700 15px var(--mono); color: var(--accent); min-width: 2ch; }
.scen { margin: 6px 14px 8px 10px; max-width: 75ch; }
.figview { padding: 0 14px 0 10px; min-width: 0; }
.qparts { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 10px 14px 14px 10px; }
.zoom { display: none; min-height: 40px; padding: 4px 12px; white-space: nowrap; }

/* ---------- drawings and tables: white like paper in both themes ---------- */
.docwrap { display: grid; gap: 10px; justify-items: start; color: #171a21; max-width: 100%; }
.figs { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.bf { margin: 0; width: 150px; max-width: calc(50% - 7px); }
.figs.n1 .bf { width: 170px; max-width: 60%; }
.bf figcaption { font: 600 14.5px var(--sans); color: var(--muted); margin-top: 3px; }
.bf .kv { color: #b0124f; font-family: var(--mono); }
svg.doc { display: block; width: 100%; height: auto; background: #fff; }
.frame { fill: #fff; stroke: #9aa1ab; stroke-width: 1; }
.glass { fill: #f3f6f9; }
.liq { fill: #d7e6f6; }
.wall { stroke: #39404b; stroke-width: 2.4; }
.bt { stroke: #111; stroke-width: 1.5; }
.bn { fill: #111; font: 700 17px "Helvetica Neue", Arial, sans-serif; }
.men { fill: none; stroke: #1d4fa3; stroke-width: 1.8; }
.kline { stroke: #b0124f; stroke-width: 1.8; stroke-dasharray: 5 3; }
.eqn { margin: 0; font-family: var(--sans); font-size: 16px; background: #fff; color: #171a21; border: 1px solid #c9ccd2; padding: 6px 10px; }
.tw { max-width: 100%; overflow-x: auto; }
table.doc { border-collapse: collapse; background: #fff; color: #171a21; font-size: 15px; font-variant-numeric: tabular-nums; border: 1.5px solid #171a21; }
table.doc th, table.doc td { border: 1px solid #b9bec7; padding: 6px 9px; text-align: right; vertical-align: middle; }
table.doc th { font-weight: 600; text-align: left; }
table.doc thead th { background: #eef0f3; font-size: 14px; text-align: center; }
table.doc thead th:first-child { text-align: left; }
table.doc td { font-family: var(--mono); font-size: 15px; white-space: nowrap; min-width: 64px; }
table.doc.rows thead th { white-space: normal; max-width: 9em; }
td.blank { background: #f2f6ff; outline: 1.5px dashed #1d4fa3; outline-offset: -5px; }
td.fill { color: #b0124f; font-weight: 700; background: #fbeef4; }

/* answer boxes */
.part { border: 0; margin: 0; padding: 0; min-width: 0; }
.part .prompt, .part legend { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; margin-bottom: 4px; color: var(--ink); }
.ain { display: flex; align-items: center; gap: 8px; }
.ain input { width: 9em; max-width: 100%; font-variant-numeric: tabular-nums; }
.ain .unit { color: var(--muted); }
.opts { display: grid; gap: 4px; }
.opt, .tick { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.opt input, .tick input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.ticks { display: flex; flex-wrap: wrap; gap: 6px; }
.tick { align-items: center; min-width: 64px; font-weight: 600; padding: 8px; }
.part.is-right input:not([type]), .part.is-right input[inputmode] { border-color: var(--ok); background: var(--ok-soft); }
.part.is-wrong input[inputmode] { border-color: var(--bad); background: var(--bad-soft); }
.part.is-close input[inputmode], .part.is-unread input[inputmode] { border-color: var(--close); background: var(--close-soft); }
.part.is-right .ticks, .part.is-right .opts { outline: 2px solid var(--ok); outline-offset: 2px; }
.part.is-wrong .ticks, .part.is-wrong .opts { outline: 2px solid var(--bad); outline-offset: 2px; }
.part.is-close .ticks { outline: 2px solid var(--close); outline-offset: 2px; }
.fb { margin: 4px 0 0; font-size: 15px; line-height: 1.4; padding: 4px 8px; }
.fb.right { color: var(--ok); background: var(--ok-soft); }
.fb.wrong { color: var(--bad); background: var(--bad-soft); }
.fb.close, .fb.unread { color: var(--close); background: var(--close-soft); }
.qfoot { display: flex; gap: 10px; align-items: center; }
details.work { margin-top: 2px; border-top: 1px dashed var(--line); padding-top: 4px; }
details.work summary { cursor: pointer; color: var(--info); min-height: 44px; display: flex; align-items: center; font-weight: 600; }
details.work .figview { padding: 0; margin: 6px 0 8px; }
.ans { margin: 8px 0 2px; }
.steps { margin: 0 0 4px; padding-left: 20px; color: var(--muted); font-size: 15.5px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 14px 0 6px; }
.ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: var(--accent-soft); padding: 6px 10px; }
.share { margin: 16px 0 6px; }
.print-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.print-row label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; max-width: 100%; }
.print-row select { max-width: 100%; min-width: 0; }
.share-out label { display: grid; gap: 4px; font-weight: 600; margin-top: 8px; }
.share-out input { width: 100%; }
.recent { margin-top: 12px; background: var(--paper); border: 1px solid var(--line); padding: 4px 12px; }
.recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.recent small { display: block; color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 15px; margin: 0; }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--paper); padding: 10px 16px; max-width: min(92vw, 520px); font-size: 15.5px; transition: transform 0.2s; z-index: 20; }
.toast.on { transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- content ---------- */
.content { max-width: 72ch; padding: 26px 0 20px; }
.content h2 { font-size: 27px; margin: 26px 0 6px; }
.faq details { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { font-size: 15px; color: var(--muted); }
footer { border-top: 1px solid var(--line); padding: 16px 0 28px; font-size: 15px; color: var(--muted); }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.print-root { display: none; }

@media (min-width: 900px) {
  .qparts { grid-template-columns: 1fr 1fr; gap: 12px 22px; }
  .qparts .qfoot, .qparts details.work, .qparts .part.wide { grid-column: 1 / -1; }
  .bf { width: 170px; }
  .figs.n1 .bf { width: 190px; }
}
@media (max-width: 700px) {
  .ctl { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "board board" "level level" "count new"; }
}
@media (max-width: 640px) {
  .zoom { display: inline-block; }
  .zoomed .figs { display: grid; grid-template-columns: 1fr; }
  .zoomed .bf, .zoomed .figs.n1 .bf { width: 230px; max-width: 100%; }
}
@media (max-width: 480px) {
  .hero { padding-top: 8px; padding-bottom: 10px; padding-left: 24px; }
  .hero::before { top: 10px; bottom: 10px; width: 14px; }
  .hero h1 { font-size: 25px; }
  .lede { font-size: 15.5px; line-height: 1.45; }
  .q h3 { font-size: 20px; }
  .qhead { padding: 8px 8px 0 8px; }
  .scen { margin: 6px 8px 6px 8px; }
  .figview { padding: 0 8px; }
  .qparts { padding: 8px 8px 12px 8px; }
  table.doc { font-size: 13.5px; }
  table.doc th, table.doc td { padding: 4px 5px; }
  table.doc td { font-size: 14px; min-width: 50px; }
  table.doc thead th { font-size: 13px; }
  table.doc tbody th { font-size: 13px; max-width: 8.5em; white-space: normal; line-height: 1.25; }
  .tdet summary, .rules summary { min-height: 40px; padding: 8px 0; }
}
@media (max-width: 360px) {
  table.doc th, table.doc td { padding: 3px 3px; }
  table.doc td { font-size: 13px; min-width: 44px; }
}

/* ---------- print ---------- */
@media print {
  :root { --ink: #000; --muted: #333; --line: #999; --paper: #fff; --edge: #555; }
  @page { margin: 12mm 12mm; }
  body { background: #fff; color: #000; font: 10.5pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  svg, table.doc, td.blank, td.fill, thead th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  table.pt { width: 100%; border-collapse: collapse; }
  table.pt > tbody > tr > td, table.pt > thead > tr > td { padding: 0; }
  .prun { font: 8.5pt var(--sans); color: #444; padding-bottom: 5pt !important; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 10pt; border-bottom: 2pt solid #000; margin-bottom: 4pt; }
  .ph h2 { font: 700 17pt var(--head); margin: 0; white-space: nowrap; }
  .ph p { margin: 0; font-size: 9pt; text-align: right; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 4pt 0 4pt; }
  .pround { margin: 0 0 4pt; font-size: 8.4pt; line-height: 1.3; border: 0.8pt solid #000; padding: 3pt 6pt; }
  .pround ul { margin: 0; padding-left: 11pt; columns: 2; column-gap: 8mm; }
  .pround li { break-inside: avoid; margin: 0 0 1pt; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; orphans: 1; widows: 1; }
  .pq > li, .pk > li { padding: 6pt 0 7pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pq > li.half { display: inline-block; vertical-align: top; width: calc(50% - 3mm); margin-right: 5mm; }
  .pq > li.half + li.half { margin-right: 0; }
  .pq > li.half .pbody { column-gap: 4mm; }
  .pkfig .bf, .pkfig .figs.n1 .bf { width: 24mm; }
  .pq h3 { font: 700 12.5pt var(--head); margin: 0 0 2pt; }
  .pscen { margin: 0 0 4pt; font-size: 10.2pt; }
  .pbody { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 7mm; align-items: start; }
  .pbody.stack { grid-template-columns: minmax(0, 1fr); }
  .docwrap { gap: 3mm; }
  /* a results table and its two drawings side by side */
  .docwrap:has(.tw):has(.figs) { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 6mm; }
  .docwrap .eqn + .tw { margin-top: 0; }
  .docwrap:has(.eqn) { display: grid; }
  .figs { gap: 3mm 5mm; flex-wrap: nowrap; }
  .bf, .figs.n1 .bf { width: 31mm; max-width: none; }
  .bf figcaption { font-size: 8.8pt; color: #000; }
  .bf .kv { color: #000; }
  .liq { fill: #e6eef8; }
  .men { stroke: #000; stroke-width: 1.6; }
  .kline { stroke: #000; }
  .eqn { font-size: 9.6pt; padding: 2pt 6pt; border-color: #000; }
  .tw { overflow: visible; }
  table.doc { font-size: 9.4pt; border-width: 1pt; }
  table.doc th, table.doc td { padding: 2pt 6pt; border-color: #777; }
  table.doc td { font-size: 9.6pt; min-width: 15mm; }
  table.doc thead th { font-size: 8.8pt; background: #eee; }
  td.blank { background: #fff; outline: none; }
  td.fill { color: #000; background: #e6e6e6; }
  .pparts { display: grid; grid-template-columns: 1fr; gap: 3pt; font-size: 9.8pt; }
  .pparts .pp { break-inside: avoid; }
  .pparts .pp p { margin: 0; }
  .pparts .pp.wide { grid-column: 1 / -1; }
  .pk > li.half { display: inline-block; vertical-align: top; width: calc(50% - 3mm); margin-right: 5mm; }
  .pk > li.half + li.half { margin-right: 0; }
  .pk > li.half table.pkt td.pkq { width: 40%; }
  .pk > li.half table.pkt td.pka { width: 25%; }
  .pline { margin: 6pt 0 2pt !important; }
  .uline { display: inline-block; width: 34mm; border-bottom: 0.8pt solid #000; }
  .popts { display: grid; gap: 1pt; margin: 2pt 0 0 !important; }
  .pbody.stack .pparts { grid-template-columns: 1fr 1fr; column-gap: 8mm; }
  .pbody.stack.many .pparts { grid-template-columns: 1fr 1fr 1fr; column-gap: 6mm; }
  .pbody.stack.many .uline { width: 30mm; }
  .pq > li.half .pbody.stack .pparts { grid-template-columns: 1fr; }
  .pq > li.half table.doc td { min-width: 11mm; }
  .pq > li.half table.doc th, .pq > li.half table.doc td { padding: 2pt 4pt; }
  .pkey { break-before: page; page-break-before: always; }
  .psheet + .psheet { break-before: page; page-break-before: always; }
  .pkey + .pkey { break-before: page; page-break-before: always; }
  .pk h3 { font: 700 11.5pt var(--head); margin: 0 0 3pt; }
  .pkbody { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 6mm; align-items: start; }
  .pkbody.stack { grid-template-columns: minmax(0, 1fr); }
  table.pkt { width: 100%; border-collapse: collapse; font-size: 9pt; table-layout: fixed; }
  table.pkt td { border-top: 0.5pt solid #bbb; padding: 2pt 4pt; vertical-align: top; }
  table.pkt td.pkq { width: 32%; }
  table.pkt td.pka { width: 22%; font-weight: 700; }
}
