/* Chi-Square Practice: a genetics field notebook. Warm paper, husk-olive accent, purple and gold corn kernels,
   serif headings, ledger tables with figures in a mono face, and a critical-value card that stays beside the
   questions on wide screens. Black-on-white tables and a grey-and-white ear on paper. */
:root {
  --bg: #f3f1e7;
  --paper: #fffdf6;
  --ink: #1d2117;
  --muted: #4f5546;
  --line: #d9d5c3;
  --edge: #8c8f7c;
  --accent: #4b5d16;
  --accent-ink: #ffffff;
  --accent-soft: #e5ebcd;
  --info: #23566b;
  --ok: #1f6a35;
  --ok-soft: #dcefe0;
  --close: #7a5300;
  --close-soft: #f6ead0;
  --bad: #a3271f;
  --bad-soft: #f8e1dd;
  --focus: #1b5fd0;
  --cob: #ecdcab;
  --cob-edge: #b49d5e;
  --husk: #8a9b46;
  --husk-edge: #5d6b25;
  --kp: #5b2a6e;
  --kp-edge: #3a1648;
  --ky: #efbf36;
  --ky-edge: #a97c0c;
  --crease-p: #d9b8e6;
  --crease-y: #6b4a00;
  --head: Charter, "Bitstream Charter", "Sitka Text", Cambria, 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: #16180f;
    --paper: #1f2217;
    --ink: #e7e9dc;
    --muted: #b0b5a1;
    --line: #34382a;
    --edge: #6d725e;
    --accent: #b9cc6b;
    --accent-ink: #1a1f08;
    --accent-soft: #2c3317;
    --info: #86c6e0;
    --ok: #8fd8a3;
    --ok-soft: #15301d;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8ab8ff;
    --cob: #cdb97c;
    --cob-edge: #8f7d45;
    --husk: #7d8f3c;
    --husk-edge: #a9bb63;
  }
}
* { 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: 1140px; 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; }
sup { font-size: 0.72em; line-height: 0; }

.hero { padding: 20px 0 4px; max-width: 780px; }
h1 { font: 700 clamp(1.75rem, 5vw, 2.6rem)/1.08 var(--head); margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { margin: 0 0 4px; color: var(--muted); max-width: 64ch; }
h2 { font: 700 1.35rem/1.2 var(--head); margin: 0 0 10px; }

/* layout: phones stack settings, questions, then the critical values; wide screens keep the critical values in a
   card that stays beside the questions while you scroll */
.tool { display: flex; flex-direction: column; }
.setup { order: 1; margin: 14px 0 4px; }
.work-area { order: 2; min-width: 0; }
.crit { order: 3; }
@media (min-width: 1020px) {
  .tool { display: grid; grid-template-columns: minmax(0, 1fr) 250px; column-gap: 36px; align-items: start; }
  .setup { grid-column: 1; grid-row: 1; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 24px; margin-top: 16px; }
  .setup .topics { flex: 1 1 100%; }
  .setup .levels { flex: 0 0 420px; margin: 0; }
  .setup .check { margin: 0; }
  .work-area { grid-column: 1; grid-row: 2; }
  .crit { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 14px; margin-top: 18px; }
}
fieldset { border: 0; padding: 0; margin: 0 0 10px; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.toggles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tg { position: relative; display: block; cursor: pointer; }
.tg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tg span { display: flex; flex-direction: column; justify-content: center; min-height: 44px; height: 100%; padding: 5px 10px; border: 1px solid var(--edge); border-radius: var(--r); background: var(--paper); color: var(--muted); line-height: 1.2; }
.tg b { font-size: 0.95rem; font-weight: 650; }
.tg small { display: none; font-size: 0.83rem; }
@media (min-width: 1020px) { .tg small { display: block; } }
.tg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tg input:checked + span small { color: inherit; opacity: 0.88; }
.tg .short { display: none; }
@media (max-width: 600px) {
  .tg .long { display: none; }
  .tg .short { display: block; }
  .tg span { padding: 5px 2px; text-align: center; align-items: center; font-size: 0.9rem; }
}
.tg input:focus-visible + span, .sg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--edge); border-radius: var(--r); overflow: hidden; }
.sg { position: relative; display: block; cursor: pointer; }
.sg + .sg { border-left: 1px solid var(--edge); }
.sg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sg .nw { white-space: nowrap; }
.sg > span { display: flex; align-items: center; justify-content: center; min-height: 44px; height: 100%; padding: 4px 4px; text-align: center; font-size: 0.9rem; font-weight: 600; background: var(--paper); line-height: 1.15; }
.sg input:checked + span { background: var(--ink); color: var(--bg); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0 0 8px; cursor: pointer; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.setrow { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
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; }

/* phones: a closed copy of the critical values above the set */
.crit-m { margin: 10px 0 0; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); background: var(--paper); }
.crit-m > summary { cursor: pointer; font-weight: 650; padding: 10px 12px; min-height: 44px; }
.crit-m > div { padding: 0 12px 10px; font-size: 0.93rem; }
.crit-m table { border-collapse: collapse; width: 100%; max-width: 360px; font-family: var(--mono); font-size: 0.92rem; }
.crit-m th, .crit-m td { text-align: right; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.crit-m th { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.crit-m th:first-child, .crit-m td:first-child { text-align: left; }
.crit-m td:nth-child(2) { font-weight: 700; }
.crit-m p { margin: 8px 0 0; color: var(--muted); }
@media (min-width: 1020px) { .crit-m { display: none; } }
/* the critical-value card */
.crit { margin: 18px 0 6px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: var(--r); font-size: 0.93rem; max-width: 420px; }
.crit h2 { font-size: 1.1rem; margin: 0 0 6px; }
.crit table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 0.92rem; }
.crit th, .crit td { text-align: right; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.crit th { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.crit th:first-child, .crit td:first-child { text-align: left; }
.crit td:nth-child(2) { font-weight: 700; }
.crit p { margin: 8px 0 0; color: var(--muted); }

.note { margin: 12px 0; padding: 10px 12px; border-left: 5px solid var(--close); background: var(--close-soft); }
.note.info { border-left-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: 2px solid var(--ink); padding-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.code { font-family: var(--mono); letter-spacing: 0.08em; color: var(--accent); }
.score { margin: 0; font-size: 0.95rem; color: var(--muted); }
.practice { margin: 6px 0 0; font-size: 0.93rem; 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: 700 1.2rem/1.25 var(--head); margin: 0 0 4px; }
.q h3 .qn { color: var(--accent); margin-right: 6px; }
.q .scen { margin: 0 0 12px; max-width: 70ch; }

/* data tables: a ledger, figures right-aligned in mono */
.fig { margin: 0 0 12px; }
.dt { border-collapse: collapse; min-width: min(100%, 360px); max-width: 100%; background: var(--paper); }
.dt th, .dt td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.dt thead th { font-size: 0.84rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--ink); }
.dt td { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.dt thead th + th { text-align: right; }
.dt tbody th { font-weight: 500; }
.dt tfoot th, .dt tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--edge); }
.dt td input.cell { width: 6.2em; text-align: right; font-family: var(--mono); padding: 6px 8px; }
.dt input.cell.is-right { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.dt input.cell.is-wrong, .dt input.cell.is-unread { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.dt input.cell.is-close { border-color: var(--close); box-shadow: inset 0 0 0 1px var(--close); }
.dt.three td:nth-child(2) { font-family: var(--sans); text-align: left; color: var(--muted); font-size: 0.92rem; }
.dt.three .geno { font-family: var(--mono); white-space: nowrap; }
.dt.three thead th:nth-child(2) { text-align: left; }
.cellfb { max-width: 70ch; margin: -4px 0 10px; }

/* the corn ear */
.efig { display: grid; gap: 10px; }
.ef { margin: 0; max-width: 640px; }
.zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--r); }
svg.ear { display: block; width: 100%; height: auto; }
.ear .cob { fill: var(--cob); stroke: var(--cob-edge); stroke-width: 0.6; }
.ear .husk { fill: var(--husk); stroke: var(--husk-edge); stroke-width: 0.5; }
.ear .guide { fill: none; stroke: var(--cob-edge); stroke-width: 0.35; stroke-dasharray: 1.2 1.2; }
.ear .rn { font: 600 4.6px var(--sans); fill: var(--muted); text-anchor: middle; }
.k.p, .lk.p { fill: var(--kp); stroke: var(--kp-edge); stroke-width: 0.45; }
.k.y, .lk.y { fill: var(--ky); stroke: var(--ky-edge); stroke-width: 0.45; }
.cr { fill: none; stroke-width: 0.7; stroke-linecap: round; stroke-linejoin: round; }
.cr.p { stroke: var(--crease-p); }
.cr.y { stroke: var(--crease-y); }
.ef figcaption { margin-top: 4px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.92rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.lk-ic { width: 20px; height: 20px; }

/* questions */
.qparts { max-width: 740px; }
.part { margin: 0 0 14px; min-width: 0; }
.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 input { width: 9em; 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: 70ch; }
.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); }
.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; }
.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: "−"; }
.work .ans { margin: 0 0 2px; }
.steps { list-style: disc; margin: 2px 0 10px; padding-left: 1.4em; font-size: 0.94rem; overflow-wrap: anywhere; }
.wt { border-collapse: collapse; margin: 2px 0 10px; font-size: 0.92rem; max-width: 100%; }
.wt th, .wt td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.wt td { font-family: var(--mono); text-align: right; }
.wt thead th + th { text-align: right; }
.wt thead th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.wt tbody th { font-weight: 500; }
.wt tfoot th, .wt tfoot td { font-weight: 700; border-bottom: 0; }
.sheet-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; }

.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; }

/* the large view of the ear */
.zoom-dlg { width: min(96vw, 980px); max-height: 94vh; padding: 12px; border: 1px solid var(--edge); border-radius: var(--r); background: var(--paper); color: var(--ink); }
.zoom-dlg::backdrop { background: rgba(10, 12, 6, 0.6); }
.zoom-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.zoom-top p { margin: 0; font-size: 0.95rem; }
.zoom-body svg { display: block; width: 100%; height: auto; margin: 6px auto 0; }
.zoom-body .half { margin: 10px 0 0; font-size: 0.9rem; font-weight: 600; color: var(--muted); }

.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.92rem; 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: 8px; }
  .dt th, .dt td { padding: 6px 6px; }
  .dt td input.cell { width: 5.4em; }
  .q .scen { font-size: 0.97rem; }
}

/* print: worksheet and key only, black on white */
.print-root { display: none; }
@page { margin: 0.45in 0.5in; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #999; --paper: #fff; --edge: #555; }
  body { background: #fff; color: #000; font: 10.5pt/1.38 var(--sans); }
  main, footer, .toast, .skip, .zoom-dlg { display: none !important; }
  .print-root { display: block; }
  svg { 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: 6pt !important; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2pt solid #000; margin-bottom: 6pt; }
  .ph h2 { font: 700 15pt var(--head); margin: 0; }
  .ph p { margin: 0; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 4pt 0 6pt; }
  .plabel { margin: 0 0 6pt; font-size: 9pt; font-style: italic; }
  .pq { list-style: none; margin: 0; padding: 0; }
  .pq > li { padding: 7pt 0 5pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pqh { break-after: avoid; page-break-after: avoid; }
  .pq h3 { font: 700 11.5pt var(--head); margin: 0 0 2pt; }
  .pq .pscen { margin: 0 0 5pt; }
  .pq .fig { margin: 0 0 6pt; break-inside: avoid; page-break-inside: avoid; }
  .dt { min-width: 0; background: #fff; font-size: 9.5pt; }
  .dt th, .dt td { padding: 3pt 6pt; border: 0.75pt solid #555; }
  .dt thead th { color: #000; border-bottom: 1.2pt solid #000; font-size: 8.5pt; }
  .pdt.wide { width: 100%; table-layout: fixed; }
  .pdt.wide th:first-child { width: 30%; }
  .pdt td { height: 17pt; }
  .dt.three { font-size: 9pt; }
  .dt.three td { height: auto; }
  .pq .efig { display: block; }
  .pq .ef { max-width: none; width: 118mm; margin: 0 0 4pt; }
  .ear .cob { fill: #fff; stroke: #000; stroke-width: 0.5; }
  .ear .husk { fill: #fff; stroke: #000; stroke-width: 0.45; }
  .ear .guide { stroke: #888; stroke-width: 0.3; }
  .ear .rn { fill: #000; }
  .k.p, .lk.p { fill: #4a4a4a; stroke: #000; stroke-width: 0.35; }
  .k.y, .lk.y { fill: #fff; stroke: #000; stroke-width: 0.45; }
  .cr.p { stroke: #fff; stroke-width: 0.75; }
  .cr.y { stroke: #000; stroke-width: 0.65; }
  .legend { font-size: 9pt; color: #000; gap: 2pt 14pt; }
  .lk-ic { width: 12pt; height: 12pt; }
  .pparts { columns: 2; column-gap: 8mm; }
  .pparts .pp { margin: 0 0 7pt; break-inside: avoid; page-break-inside: avoid; }
  .pparts .pp p { margin: 0 0 2pt; }
  .pparts ol.popts { margin: 0; padding-left: 14pt; list-style: upper-alpha; font-size: 9.5pt; }
  .pparts ol.popts li { margin: 0 0 1.5pt; }
  .pparts .pline { margin-top: 10pt !important; }
  .pkey { break-before: page; page-break-before: always; }
  .pk { margin: 0; padding-left: 18pt; }
  .pk > li { padding: 3pt 0 3pt; border-bottom: 0.75pt solid #bbb; }
  .pk .wt, .pk .steps { break-inside: avoid; page-break-inside: avoid; }
  .pk .ans { break-after: avoid; page-break-after: avoid; }
  .pk h3 { font: 700 10.5pt var(--head); margin: 0 0 2pt; break-after: avoid; page-break-after: avoid; }
  .pk .ans { margin: 0.5pt 0 0; font-weight: 600; font-size: 10pt; line-height: 1.3; }
  .pk .ans b { font-weight: 700; }
  .pk .steps { margin: 0 0 1pt; padding-left: 13pt; font-size: 8.8pt; line-height: 1.28; }
  .wt { font-size: 8.8pt; margin: 2pt 0 3pt; }
  .wt th, .wt td { padding: 1pt 5pt; border-bottom: 0.5pt solid #999; }
  .wt thead th { color: #000; }
}
