/* Cladogram Practice: a field guide's plate pages. Lichen-pale paper, moss-green ink and actions, a ruled specimen
   label for each problem, and every tree and table on white like a printed plate, in black line art. */
:root {
  --bg: #eef1e8;
  --paper: #fbfcf8;
  --ink: #18221b;
  --muted: #4f5a51;
  --line: #cdd5c6;
  --edge: #84907f;
  --moss: #2f5d36;
  --moss-ink: #ffffff;
  --moss-soft: #dfe9d8;
  --rule: #18221b;
  --ok: #1d6a37;
  --ok-soft: #dcefe0;
  --bad: #9b2a1d;
  --bad-soft: #f6e0dc;
  --warn: #6f5200;
  --warn-soft: #f3ead2;
  --focus: #1d5fd1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", 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: 2px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121813;
    --paper: #1b231c;
    --ink: #e6ece2;
    --muted: #b0bbad;
    --line: #34402f;
    --edge: #6e7b69;
    --moss: #9fd3a3;
    --moss-ink: #0e1a10;
    --moss-soft: #22352a;
    --rule: #9fb59c;
    --ok: #8fd8a6;
    --ok-soft: #173020;
    --bad: #ff9d90;
    --bad-soft: #3a1d18;
    --warn: #f0c66b;
    --warn-soft: #352b14;
    --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(--moss); 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; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hero { padding: 22px 0 2px; max-width: 760px; }
h1 { font: 700 clamp(1.9rem, 5.4vw, 2.75rem)/1.08 var(--serif); margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--muted); max-width: 62ch; }
h2 { font: 700 1.45rem/1.2 var(--serif); margin: 0 0 10px; }

/* setup */
.setup { margin: 14px 0 4px; display: grid; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; border: 1.5px solid var(--rule); border-radius: var(--r); width: fit-content; max-width: 100%; }
.segb { font: inherit; font-weight: 650; min-height: 44px; padding: 8px 14px; border: 0; background: var(--paper); color: var(--muted); cursor: pointer; flex: 1 1 auto; }
.segb + .segb { border-left: 1.5px solid var(--rule); }
.segb[aria-pressed="true"] { background: var(--moss); color: var(--moss-ink); }
.setrow, .morerow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 650; }
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: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--moss); color: var(--moss-ink); border-color: var(--moss); }
.btn.small { padding: 6px 14px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(0.95); }
.link { font: inherit; background: none; border: 0; padding: 10px 4px; min-height: 44px; color: var(--moss); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.setcode { color: var(--muted); font-size: 0.95rem; }
.setcode b { color: var(--ink); }
.levelnote { margin: 0; color: var(--muted); font-size: 0.95rem; }
.more summary { cursor: pointer; color: var(--moss); font-weight: 650; min-height: 44px; display: flex; align-items: center; width: fit-content; }
.more .morerow { padding: 2px 0 6px; }
[hidden] { display: none !important; }

.note { overflow-wrap: anywhere; margin: 12px 0; padding: 10px 12px; border-left: 5px solid var(--warn); background: var(--warn-soft); }
.note.info { border-left-color: var(--moss); background: var(--moss-soft); }
.note .link { min-height: 0; padding: 0; font-weight: 650; }

/* problems: a specimen label (double rule) heads each plate */
.sets:focus { outline: none; }
.pb { margin: 18px 0 0; background: var(--paper); border-top: 4px double var(--rule); border-bottom: 1px solid var(--line); }
.pb-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; padding: 10px 16px 6px; }
.pb-head h2 { margin: 0; font-size: 1.35rem; }
.pb-head .of { font-weight: 400; color: var(--muted); }
.pb-score { margin: 0; font-size: 0.92rem; color: var(--muted); }
.data { padding: 4px 16px 10px; min-width: 0; }
.svgwrap { background: #fff; border: 1px solid var(--line); padding: 6px; overflow: hidden; }
.svgwrap svg { display: block; max-width: 100%; height: auto; }
.fig { margin: 0; }
.fig figcaption, .figcap { font-size: 0.92rem; color: var(--muted); margin: 6px 0 0; }
.tlegend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 6px 0 0; padding: 0; font-size: 0.93rem; }
.tlegend .tn { font-weight: 700; margin-right: 2px; }

.tablewrap { overflow-x: auto; }
table.traits, table.matrix { border-collapse: collapse; background: #fff; color: #000; font-size: 0.95rem; }
.traits caption, .matrix caption { caption-side: top; text-align: left; font-size: 0.92rem; color: var(--muted); padding: 0 0 6px; }
.traits th, .traits td, .matrix th, .matrix td { border: 1px solid #9aa596; padding: 4px 7px; }
.traits tbody th, .matrix tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.traits td { text-align: center; font: 700 1.05rem var(--mono); width: 2.2em; }
.traits td.n { color: #6b6b6b; font-weight: 400; }
.matrix td { text-align: center; font-variant-numeric: tabular-nums; min-width: 2.3em; }
.matrix td.self { background: repeating-linear-gradient(135deg, #fff 0 4px, #d9ddd5 4px 5px); }
th.v { vertical-align: bottom; padding: 6px 2px; }
th.v span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 600; }
th.corner { text-align: left; vertical-align: bottom; font-weight: 600; }

.qs { list-style: none; counter-reset: q; margin: 0; padding: 0; min-width: 0; }
.q { counter-increment: q; position: relative; padding: 12px 16px 6px 52px; border-top: 1px solid var(--line); }
.q::before { content: counter(q); position: absolute; left: 14px; top: 13px; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink); font: 700 0.85rem/23px var(--sans); text-align: center; }
.q.is-right::before { background: var(--ok); color: var(--paper); border-color: var(--ok); }
.qt { margin: 0 0 8px; max-width: 64ch; }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font: inherit; font-weight: 600; min-height: 44px; padding: 6px 12px; border: 1.5px solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); cursor: pointer; text-align: left; }
.chip.grp { border-style: double; border-width: 3px; }
.chip[aria-pressed="true"] { background: var(--moss); color: var(--moss-ink); border-color: var(--moss); }
.arow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.live { margin-top: 10px; }
.link.small { padding: 10px 6px; }
.place { display: grid; gap: 6px; margin-bottom: 8px; }
.prow { display: grid; grid-template-columns: minmax(8em, 11em) minmax(0, 1fr); align-items: center; gap: 4px 10px; font-weight: 600; }
.prow select { width: 100%; }
.opts { border: 0; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.opt input, .cand input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--moss); flex: none; }
.opt:has(input:checked) { border-color: var(--moss); background: var(--moss-soft); }
.cands { border: 0; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.cand { display: grid; gap: 4px; border: 1px solid var(--line); padding: 6px; cursor: pointer; border-radius: var(--r); }
.cand .cl { display: flex; align-items: center; gap: 8px; font-weight: 650; min-height: 32px; }
.cand .svgwrap { border: 0; padding: 0; }
.cand:has(input:checked) { border-color: var(--moss); outline: 2px solid var(--moss); }
.fbwrap:empty { display: none; }
.fb { margin: 8px 0 0; padding: 7px 10px; border-radius: var(--r); max-width: 66ch; }
.fb.right { background: var(--ok-soft); color: var(--ok); }
.fb.wrong, .fb.unread { background: var(--bad-soft); color: var(--bad); }
.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; width: fit-content; }
.work > summary::-webkit-details-marker { display: none; }
.work > summary::before { content: "+"; margin-right: 6px; font: 700 1rem var(--mono); }
.work[open] > summary::before { content: "\2212"; }
.ans { margin: 8px 0 6px; }
.steps { margin: 0 0 10px; padding-left: 1.3em; font-size: 0.95rem; }
.steps li { margin: 2px 0; }
.why1 { margin: 0 0 10px; font-size: 0.95rem; max-width: 66ch; }
.hint { color: var(--muted); font-size: 0.93rem; }

@media (min-width: 1060px) {
  /* table or drawing beside its questions; it stays in view while the questions scroll */
  .pb-body { display: grid; grid-template-columns: minmax(0, 1.27fr) minmax(0, 1fr); }
  .pb.read .pb-body { grid-template-columns: minmax(0, 1.78fr) minmax(0, 1fr); } /* room for full trait names */
  .data { position: sticky; top: 8px; align-self: start; }
  .qs { border-left: 1px solid var(--line); }
  .q:first-child { border-top: 0; }
}

.share { margin: 18px 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: 650; }
.share-out input { width: 100%; }
.recent { margin-top: 12px; border-top: 1px solid var(--line); }
.recent summary { cursor: pointer; padding: 11px 0; font-weight: 650; 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); }
.code { font-family: var(--mono); letter-spacing: 0.06em; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 180%); background: var(--ink); color: var(--paper); 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); }
.toast .link { color: inherit; min-height: 0; padding: 0 4px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* content */
.content { padding: 24px 0 8px; max-width: 800px; }
.content h2 { margin-top: 30px; }
.content p, .method { max-width: 68ch; }
.method { padding-left: 1.3em; }
.method li { margin: 4px 0; }
.ex { display: grid; gap: 10px; }
.ex .svgwrap { max-width: 580px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 11px 0; font-weight: 650; 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: 640px) {
  .hero { padding-top: 14px; }
  .pb { margin-left: -16px; margin-right: -16px; }
  .data { padding: 4px 8px 10px; }
  .q { padding: 12px 10px 6px 44px; }
  .q::before { left: 8px; }
  .segb { padding: 8px 10px; }
  .prow { grid-template-columns: 1fr; }
  .svgwrap { padding: 3px; }
  .cands { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
  .cands { grid-template-columns: 1fr; } /* names in the four small trees stay readable on a phone */
}

/* print: only the worksheet and key, black on white */
.print-root { display: none; }
@page { margin: 0.5in 0.55in; }
@media print {
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  .psec { break-after: page; page-break-after: always; }
  .pkey { break-inside: avoid; page-break-inside: avoid; margin-bottom: 18pt; }
  .print-root > :last-child { break-after: auto; page-break-after: auto; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 12pt; border-bottom: 2pt solid #000; margin-bottom: 6pt; }
  .ph h2 { font: 700 15pt var(--serif); margin: 0; }
  .ph p { margin: 0; font-size: 9.5pt; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 2pt 0 8pt; }
  .pdata { margin: 0 0 8pt; break-inside: avoid; }
  .pdata svg, .kfig svg { display: block; max-width: 100%; height: auto; }
  .kfig svg { max-width: 75%; max-height: 3.4in; }
  table.traits, table.matrix { font-size: 10pt; background: #fff; }
  .traits caption, .matrix caption { color: #000; font-size: 9.5pt; text-align: left; padding-bottom: 3pt; }
  .traits th, .traits td, .matrix th, .matrix td { border: 0.8pt solid #000; padding: 2pt 5pt; }
  .traits td.n { color: #000; }
  .matrix td.self { background: #fff; }
  .tlegend { font-size: 9pt; color: #000; }
  .pq { margin: 0; padding-left: 16pt; }
  .pq > li { break-inside: avoid; page-break-inside: avoid; padding: 3pt 0; }
  .pqt { margin: 0 0 3pt; }
  .drawbox { height: 3.6in; width: calc(100% - 4pt); border: 0.8pt solid #000; }
  .drawbox.short { height: 3.1in; } /* molecular sets have a taller table and more questions: keep them on one Letter page */
  .pcands { display: grid; grid-template-columns: 1fr 1fr; gap: 6pt 14pt; }
  .pcand { break-inside: avoid; }
  .pcand p { margin: 0 0 2pt; font-weight: 700; }
  .pcand svg { display: block; max-width: 100%; height: auto; max-height: 1.6in; }
  .popts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2pt 16pt; }
  .popts li { display: flex; align-items: center; gap: 5pt; }
  .circle { display: inline-block; width: 9pt; height: 9pt; border: 0.8pt solid #000; border-radius: 50%; flex: none; }
  .pnote { font-size: 9pt; font-style: italic; margin: 3pt 0; }
  .pks { margin: 0 0 6pt; padding-left: 14pt; font-size: 9.5pt; }
  .pk { margin: 0; padding-left: 16pt; }
  .pk > li { break-inside: avoid; page-break-inside: avoid; padding: 3pt 0 4pt; border-bottom: 0.6pt solid #999; }
  .pk p { margin: 0; }
  .pkq { font-size: 9pt; }
  .pka { font-weight: 700; margin-top: 1pt !important; }
  .pks1 { font-size: 9pt; line-height: 1.3; }
}
