/* Culinary Math Practice: a prep-station clipboard. Pale sage ground, charcoal ink, white kitchen forms with thin
   rules and tabular numbers, and a tomato-red accent for actions, question numbers and the key's filled-in cells.
   Blanks are drawn as dashed boxes. On paper it is black on white; the key's filled cells stay bold. */
:root {
  --bg: #eef2ec;
  --paper: #ffffff;
  --ink: #1d221e;
  --muted: #4c5850;
  --line: #cfd8cf;
  --rule: #dfe6df;
  --edge: #7d8a80;
  --band: #263029;
  --band-ink: #ffffff;
  --accent: #b2391b;
  --accent-ink: #ffffff;
  --accent-soft: #f8e4dc;
  --info: #1f5f8b;
  --ok: #1d6b3a;
  --ok-soft: #dcefe2;
  --close: #7a5400;
  --close-soft: #f6ecd3;
  --bad: #a3241d;
  --bad-soft: #f8e0dd;
  --focus: #1b5fd0;
  --blank: #fff7f2;
  --liq: #cfe6f5;
  --head: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", system-ui, sans-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: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141814;
    --paper: #1d231e;
    --ink: #e4ebe5;
    --muted: #a6b3a9;
    --line: #2f3a31;
    --rule: #2a332c;
    --edge: #617066;
    --band: #2c3a2f;
    --band-ink: #f2f6f2;
    --accent: #f08a68;
    --accent-ink: #2a0d03;
    --accent-soft: #3a2119;
    --info: #8fc3ee;
    --ok: #8adca6;
    --ok-soft: #14301f;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8ab8ff;
    --blank: #2a2420;
    --liq: #23435a;
  }
}
* { 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: 1120px; 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.12; font-weight: 700; }
.hero { padding: 20px 0 12px; margin: 14px 0 6px; }
.hero h1 { font-size: clamp(32px, 6.4vw, 48px); margin: 0 0 4px; letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 64ch; color: var(--muted); }

/* ---------- controls ---------- */
.tool { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.setup { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 10px; }
.setrow { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.off { opacity: 0.5; }
legend { font: 600 14px var(--sans); color: var(--muted); padding: 0; margin-bottom: 4px; }
.seg { display: grid; border: 1px solid var(--edge); border-radius: var(--r); overflow: hidden; }
.seg6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.seg2 { grid-template-columns: 1fr 1fr; min-width: 170px; }
.sg { position: relative; display: block; min-width: 0; }
.sg + .sg { border-left: 1px solid var(--edge); }
.sg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 4px 6px; font-size: 15px; line-height: 1.15; }
.sg input:checked + span { background: var(--band); color: var(--band-ink); font-weight: 600; }
.sg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.tdet summary, .rules summary { cursor: pointer; font-weight: 600; min-height: 44px; padding: 10px 0; }
.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; }
.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; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: 4px; min-height: 44px; padding: 6px 10px; }
.btn { font: 600 16px var(--sans); min-height: 44px; padding: 8px 16px; border-radius: 4px; 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; }

/* ---------- formulas ---------- */
.rules { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 14px 10px; }
.why { margin: 6px 0 2px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.fl { margin: 8px 0 0; font-weight: 600; font-size: 15px; }
.rl { margin: 4px 0 0; padding-left: 20px; font-size: 15px; 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); border-radius: 4px; font-size: 16px; }
#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: 14.5px; }
.qs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.q { background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--band); border-radius: var(--r); min-width: 0; }
.q h3 { margin: 0; font-size: 22px; padding: 10px 14px 0; display: flex; align-items: center; gap: 10px; }
.qn { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font: 700 16px var(--sans); }
.scen { margin: 6px 14px 8px; max-width: 75ch; }
.figview { padding: 0 14px; min-width: 0; }
.qparts { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 10px 14px 14px; }

/* ---------- documents: always white forms, like paper on a clipboard ---------- */
.docwrap { display: inline-block; max-width: 100%; vertical-align: top; }
table.doc { border-collapse: collapse; background: #fff; color: #1d221e; font-size: 15px; font-variant-numeric: tabular-nums; border: 1.5px solid #1d221e; min-width: 260px; }
table.doc caption { caption-side: top; text-align: left; background: #1d221e; color: #fff; padding: 6px 10px; display: table-caption; }
table.doc caption .dn { display: block; font: 700 15px var(--sans); letter-spacing: 0.02em; }
table.doc caption .dy { display: block; font-size: 13.5px; color: #e4ebe5; }
table.doc th, table.doc td { border-bottom: 1px solid #cfd8cf; padding: 5px 10px; text-align: left; vertical-align: middle; }
table.doc td { font-family: var(--mono); font-size: 14.5px; white-space: nowrap; text-align: right; }
table.doc thead th { font-size: 13px; font-weight: 600; color: #4c5850; background: #f2f5f1; text-transform: none; }
table.doc tbody th { font-weight: 500; }
table.doc tfoot th, table.doc tfoot td, table.doc .bf th, table.doc .bf td, table.doc .bh th, table.doc .bh td { background: #f7f9f6; }
table.doc tfoot th, table.doc .bf th { font-weight: 600; }
table.doc .bparts tr:first-child th { font-size: 13px; color: #4c5850; background: #f2f5f1; }
td.blank { background: #fff7f2; outline: 1.5px dashed #b2391b; outline-offset: -4px; min-width: 96px; }
td.fill { color: #8e2a10; font-weight: 700; background: #fdeee7; }
table.doc.lines td.la { font-weight: 700; text-align: left; }
table.doc.lines td { text-align: left; font-family: var(--sans); }
table.doc.lines tbody th { width: 2.2em; color: #4c5850; }
table.doc.recipe td, table.doc.ycard td, table.doc.period td { min-width: 110px; }
.dots { color: #b2391b; font-weight: 700; }
svg.doc { display: block; max-width: 100%; height: auto; background: #fff; border: 1.5px solid #1d221e; border-radius: 2px; }
.glass { fill: #f6fafc; stroke: #1d221e; stroke-width: 2.2; }
.handle { fill: none; stroke: #1d221e; stroke-width: 6; stroke-linecap: round; }
.liq { fill: #cfe6f5; }
.liqtop { stroke: #1f5f8b; stroke-width: 2.4; }
.ct, .ot { stroke: #1d221e; stroke-width: 1.6; }
.cl, .ol { fill: #1d221e; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 12.5px; }
.cl.in { font-size: 11.5px; paint-order: stroke; stroke: #f6fafc; stroke-width: 3px; stroke-linejoin: round; }
.side { fill: #4c5850; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 11px; letter-spacing: 0.06em; }
.kline { stroke: #b2391b; stroke-width: 2; stroke-dasharray: 5 3; }
.tool { fill: #e8ece8; stroke: #1d221e; stroke-width: 1.8; }
.tn { fill: #1d221e; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 14px; }
.tc { fill: #b2391b; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 15px; }

/* 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: 9.5em; max-width: 100%; font-variant-numeric: tabular-nums; }
.part.wide .ain input { width: 17em; }
.unit, .cur { color: var(--muted); }
.opts { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.opt { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.opt input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.part.is-right input:not([type="radio"]) { border-color: var(--ok); background: var(--ok-soft); }
.part.is-wrong input:not([type="radio"]) { border-color: var(--bad); background: var(--bad-soft); }
.part.is-close input:not([type="radio"]), .part.is-unread input:not([type="radio"]) { border-color: var(--close); background: var(--close-soft); }
.fb { margin: 4px 0 0; font-size: 15px; line-height: 1.4; padding: 4px 8px; border-radius: 4px; }
.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; border-radius: 4px; }
.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; }
.print-row select { max-width: 100%; }
.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); border-radius: var(--r); 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: 14.5px; margin: 0; }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px; 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: 75ch; 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: 14.5px; color: var(--muted); }
footer { border-top: 1px solid var(--line); padding: 16px 0 28px; font-size: 14.5px; 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) {
  .tool { grid-template-columns: minmax(0, 1fr) 340px; }
  .setup { grid-column: 1; }
  .rules { grid-column: 2; grid-row: 1 / span 2; }
  .work-area { grid-column: 1 / -1; }
  .qparts { grid-template-columns: 1fr 1fr; gap: 12px 22px; }
  .qparts .qfoot, .qparts details.work, .qparts .part.wide { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .seg6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg6 .sg:nth-child(4) { border-left: 0; }
  .seg6 .sg:nth-child(n+4) { border-top: 1px solid var(--edge); }
}
@media (max-width: 480px) {
  .sg span { font-size: 14px; padding: 4px 2px; }
  .hero { padding-top: 8px; margin-top: 10px; }
  .lede { font-size: 16px; }
  .q h3 { font-size: 20px; padding: 8px 10px 0; }
  .scen { margin: 6px 10px 6px; }
  .figview { padding: 0 10px; }
  .qparts { padding: 8px 10px 12px; }
  table.doc { font-size: 14px; min-width: 0; }
  table.doc th, table.doc td { padding: 4px 6px; }
  table.doc td { font-size: 13.5px; }
  table.doc.costcard td, table.doc.costcard th { padding: 4px 4px; font-size: 12.5px; }
  .part.wide .ain input { width: 100%; }
}

/* the four-column butcher's test form is 6 px too wide at 320 px with metric weights (QA 2026-10-26) */
@media (max-width: 360px) {
  table.doc.btest th, table.doc.btest td { padding: 4px 3px; }
  table.doc.btest td { font-size: 12.5px; }
}
/* the cost card stacks on narrow screens: one block per ingredient, each value labeled */
@media (max-width: 600px) {
  table.doc.costcard, table.doc.costcard tbody, table.doc.costcard tfoot, table.doc.costcard tr { display: block; }
  table.doc.costcard caption { display: block; }
  table.doc.costcard thead { display: none; }
  table.doc.costcard tbody tr { border-bottom: 2px solid #1d221e; }
  table.doc.costcard tbody th { display: block; font-weight: 700; border-bottom: 0; padding-bottom: 0; }
  table.doc.costcard tbody td { display: flex; justify-content: space-between; gap: 12px; min-height: 30px; align-items: center; }
  table.doc.costcard tbody td::before { content: attr(data-l); font-family: var(--sans); color: #4c5850; font-size: 13.5px; }
  table.doc.costcard tfoot tr { display: flex; justify-content: space-between; }
  table.doc.costcard tfoot td { min-width: 96px; }
}
@media (max-width: 480px) {
  .hero { margin-top: 6px; padding-top: 2px; padding-bottom: 6px; }
  .hero h1 { font-size: 30px; }
  .lede { font-size: 15.5px; line-height: 1.4; }
  .setup { padding: 8px 10px; gap: 6px; }
  .tdet summary, .rules summary { min-height: 40px; padding: 8px 0; }
}

/* ---------- 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, table.doc caption, td.blank, td.fill { 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; text-align: right; 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 6pt; font-size: 8.8pt; border: 0.8pt solid #000; padding: 3pt 6pt; }
  .pq { list-style: none; margin: 0; padding: 0; }
  .pq > li { padding: 6pt 0 7pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pq h3 { font: 700 12.5pt var(--head); margin: 0 0 2pt; }
  .pscen { margin: 0 0 4pt; font-size: 10.2pt; }
  .pfig, .pkfig { margin: 0 0 4pt; }
  .pfig .docwrap, .pkfig .docwrap { display: block; }
  table.doc { font-size: 9.6pt; min-width: 0; border-width: 1pt; }
  table.doc caption { padding: 2pt 6pt; }
  table.doc caption .dn { font-size: 9.8pt; }
  table.doc caption .dy { font-size: 8.8pt; }
  table.doc th, table.doc td { padding: 0.5pt 5pt; line-height: 1.22; }
  table.doc td { font-size: 9pt; }
  table.doc { font-size: 9.2pt; }
  table.doc thead th, table.doc .bparts tr:first-child th { font-size: 8.4pt; }
  td.blank { min-width: 60pt; }
  svg.doc.cup { width: 66mm; height: auto; }
  .pkfig svg.doc.cup { width: 46mm; }
  svg.doc.tools { max-width: 100%; height: auto; max-height: 30mm; width: auto; }
  .pparts { display: grid; grid-template-columns: 1fr 1fr; gap: 2pt 8mm; font-size: 9.8pt; margin-top: 3pt; }
  .pparts .pp { break-inside: avoid; }
  .pparts .pp.wide { grid-column: 1 / -1; }
  .pparts .pp p { margin: 0; }
  .pline { margin: 7pt 0 3pt !important; }
  .uline { display: inline-block; width: 38mm; border-bottom: 0.8pt solid #000; }
  .pp.wide .uline { width: 70mm; }
  .popts span { margin-right: 12pt; display: inline-block; }
  .pq > li.side { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 7mm; align-items: start; }
  .pq > li.side > h3, .pq > li.side > .pscen { grid-column: 1 / -1; }
  .pq > li.side .pparts { grid-template-columns: 1fr; margin-top: 0; }
  .pk > li.side { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 6mm; align-items: start; }
  .pk > li.side > h3 { grid-column: 1 / -1; }
  .pk > li.side table.pkt { margin-top: 0; }
  .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 { list-style: none; margin: 0; padding: 0; }
  .pk > li { padding: 5pt 0 7pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  /* keep the last answer of a key with the one before it, so it never sits alone on a page (only the last: not chained) */
  .pk > li:last-child { break-before: avoid; page-break-before: avoid; }
  .pk h3 { font: 700 11.5pt var(--head); margin: 0 0 3pt; }
  td.fill { color: #000; background: #eee; }
  .kline { stroke: #000; }
  table.pkt { width: 100%; border-collapse: collapse; font-size: 9pt; margin-top: 3pt; 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: 18%; font-weight: 700; }
}
