/* Leeds Method worksheet: a ledger sheet with colored group columns. */
:root {
  --bg: #f6f3ec;
  --paper: #fffdf8;
  --ink: #1d2422;
  --muted: #4b5654;
  --line: #d8d2c4;
  --rule: #b9b19f;
  --accent: #155e57;
  --accent-ink: #ffffff;
  --accent-soft: #e2efec;
  --warn-bg: #fbecd9;
  --warn-ink: #6b3a00;
  --danger: #a3271b;
  --focus: #c46a00;
  --head: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 6px;
  /* group colors: light fills that keep dark text readable on screen and on paper */
  --g0: #9cc3ea; --g1: #f5b77a; --g2: #a6d99a; --g3: #f0a3b0; --g4: #f2df7a; --g5: #c9b6e8;
  --g6: #8fd6cf; --g7: #d9bc94; --g8: #cfcfcf; --g9: #d4e86f; --g10: #eab3dc; --g11: #b3e0f2;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14201f;
    --paper: #1b2928;
    --ink: #ebefe9;
    --muted: #b5c1bd;
    --line: #34413f;
    --rule: #4b5a57;
    --accent: #6fd0c3;
    --accent-ink: #0d1716;
    --accent-soft: #203a37;
    --warn-bg: #3a2a12;
    --warn-ink: #f6d7a8;
    --danger: #ff9c8f;
    --focus: #ffb454;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--body); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .grid-wrap:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* masthead: ruled like a ledger */
.mast { border-bottom: 2px solid var(--ink); padding: 18px 0 12px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; }
h1 { font-size: clamp(26px, 6vw, 38px); margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 64ch; color: var(--muted); }

/* tool */
.tool { padding-top: 14px; padding-bottom: 8px; }
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--ink); margin: 0 0 14px; }
.tabs button {
  flex: 1 1 auto; white-space: nowrap; min-height: 46px; font: 600 17px/1.2 var(--body); color: var(--muted); background: transparent;
  border: 0; border-bottom: 4px solid transparent; margin-bottom: -2px; cursor: pointer; padding: 8px 6px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.panel { min-height: 200px; }
.lab { display: block; font-weight: 600; margin: 0 0 6px; }
textarea, input[type="text"], select {
  font: 16px/1.4 var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 9px 10px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 16px; }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.btn {
  font: 600 16px/1.2 var(--body); min-height: 44px; padding: 10px 16px; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.subtle { background: transparent; }
.btn.small { min-height: 40px; padding: 7px 12px; }
.btn.icon { min-width: 44px; padding: 0 10px; font-size: 26px; line-height: 1; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #1b0a08; } }
.out { margin: 4px 0 10px; padding: 8px 12px; background: var(--accent-soft); border-radius: var(--r); }
.note { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r); background: var(--accent-soft); }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.note.ex { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }

.band { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 6px; font-weight: 600; }
.band input { width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.count { color: var(--muted); margin: 4px 0 8px; }
.nw { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.hint { margin: 0 0 8px; overflow-wrap: anywhere; }
.file-note { margin: 0 0 10px; overflow-wrap: anywhere; }
.m .tag[hidden] { display: none; }
.field-msg { margin: 2px 0 8px; color: var(--danger); font-weight: 600; }

/* match list: a ruled sheet; one line per match on wide screens, two on phones */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.m {
  display: grid; grid-template-columns: 6.2em minmax(0, 1fr) 44px; grid-template-areas: "nm nm x" "cm nt nt" "tag tag tag";
  gap: 6px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.m .nm { grid-area: nm; font-weight: 600; }
.m .cm { grid-area: cm; text-align: right; font-variant-numeric: tabular-nums; }
.m .nt { grid-area: nt; }
.m .tag { grid-area: tag; font-size: 16px; color: var(--warn-ink); background: var(--warn-bg); border-radius: 4px; padding: 2px 6px; justify-self: start; white-space: nowrap; }
.m .x { grid-area: x; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; border-radius: var(--r); }
.m .x:hover { color: var(--danger); background: var(--warn-bg); }
.m input { border-color: transparent; background: transparent; padding: 8px 6px; }
.m input:hover { border-color: var(--line); }
.m input:focus { border-color: var(--rule); background: var(--paper); }
@media (min-width: 720px) {
  .m { grid-template-columns: minmax(0, 1.3fr) 6.2em minmax(0, 1fr) 8em 44px; grid-template-areas: "nm cm nt tag x"; padding: 2px 0; }
  .m .tag { justify-self: end; }
}

/* shared matches */
.picker { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 6px; }
.pick-info { color: var(--muted); margin: 8px 0 10px; }
.checks { border: 0; margin: 0; padding: 0; min-width: 0; }
.checks legend { font-family: var(--head); font-weight: 700; font-size: 20px; padding: 0; margin: 0 0 4px; max-width: 100%; overflow-wrap: anywhere; }
#checks { list-style: none; margin: 0; padding: 0; columns: 1; border-top: 1px solid var(--rule); }
@media (min-width: 720px) { #checks { columns: 2; column-gap: 24px; } }
#checks li { break-inside: avoid; border-bottom: 1px solid var(--line); }
#checks label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 2px; cursor: pointer; }
#checks input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
#checks .cn { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#checks .cc { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#checks .sub { font-weight: 700; padding: 14px 0 4px; border-bottom: 1px solid var(--rule); }
#checks .none { color: var(--muted); padding: 10px 0; }
.sh-box { margin: 14px 0 4px; }
.sh-box summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
.sh-box textarea { margin: 4px 0 8px; }
.done span, .pick-info, .out, .note, .toast span, .earlier .what, .summary, .confirm p { overflow-wrap: anywhere; min-width: 0; }
.done { display: flex; gap: 10px; align-items: center; min-height: 44px; margin-top: 10px; font-weight: 600; cursor: pointer; }
.done input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* groups */
.notproof { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); }
.summary { margin: 0 0 10px; font-weight: 600; }
.legend { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .legend { grid-template-columns: 1fr 1fr; } }
.lg { display: flex; gap: 10px; align-items: flex-start; }
.lg-body { flex: 1; min-width: 0; }
.lg-meta { display: block; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.sw {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--r);
  font: 700 18px/1 var(--mono); color: #111;
}
.c0 { background: var(--g0); } .c1 { background: var(--g1); } .c2 { background: var(--g2); } .c3 { background: var(--g3); }
.c4 { background: var(--g4); } .c5 { background: var(--g5); } .c6 { background: var(--g6); } .c7 { background: var(--g7); }
.c8 { background: var(--g8); } .c9 { background: var(--g9); } .c10 { background: var(--g10); } .c11 { background: var(--g11); }
.flags { display: grid; gap: 10px; margin: 0 0 14px; }
@media (min-width: 720px) { .flags { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
.flag h3 { font-size: 19px; margin: 0 0 4px; }
.flag p { margin: 0 0 4px; color: var(--muted); }
.flag ul { margin: 0; padding-left: 20px; }
.flag li { overflow-wrap: anywhere; }
.fc { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 10px; }
.grid-tools label { font-weight: 600; }
.grid-tools select { width: auto; }
.grid-wrap { position: relative; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); }
.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.grid thead th { position: sticky; top: 0; border-bottom: 2px solid var(--ink); font-size: 16px; white-space: nowrap; }
.grid thead th:not(.h-g) { background: var(--paper); }
.grid thead th.h-g { text-align: center; color: #111; min-width: 36px; }
.grid .name { font-weight: 600; min-width: 8em; max-width: 16em; overflow-wrap: anywhere; position: sticky; left: 0; background: var(--paper); }
.grid .cmv { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid td.g { text-align: center; color: #111; font: 700 16px/1 var(--mono); min-width: 36px; padding: 6px 4px; border-left: 1px solid var(--line); }
.grid td.g.seed { box-shadow: inset 0 0 0 3px #111; }
.grid .tg { font: 400 16px/1.2 var(--body); color: var(--muted); white-space: nowrap; }
@media (max-width: 480px) {
  .grid th, .grid td { padding: 6px 4px; }
  .grid .name { min-width: 5.5em; padding-left: 6px; }
  .grid td.g, .grid thead th.h-g { min-width: 30px; }
  .grid .tg { display: block; margin: 2px 0 0; }
}
.grid td.gs { line-height: 2; }
.chip { display: inline-block; min-width: 30px; padding: 3px 5px; border-radius: 4px; text-align: center; color: #111; font: 700 16px/1.2 var(--mono); }
.chip.seed { box-shadow: inset 0 0 0 2px #111; }
.grid tr.sep th { background: var(--bg); font-family: var(--head); font-size: 17px; padding-top: 10px; }

.foot-tools { margin: 18px 0 6px; padding-top: 10px; border-top: 1px dashed var(--rule); }
.earlier summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.earlier ul { list-style: none; margin: 0 0 8px; padding: 0; }
.earlier li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.earlier .row { margin: 0; }
.confirm { padding: 10px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r); }
.confirm p { margin: 0; }
.confirm .also { display: flex; gap: 10px; align-items: center; min-height: 44px; margin-top: 6px; cursor: pointer; }
.confirm .also input { width: 22px; height: 22px; flex: none; accent-color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(560px, calc(100% - 32px));
  display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: var(--r);
  background: var(--ink); color: var(--bg); z-index: 20; pointer-events: none; box-shadow: 0 4px 16px rgb(0 0 0 / .25);
}
.toast button { pointer-events: auto; background: var(--bg); color: var(--ink); border-color: var(--bg); }

/* guide */
.guide { padding-top: 18px; padding-bottom: 24px; }
.guide section { max-width: 72ch; }
.guide h2 { font-size: 26px; margin: 28px 0 8px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.guide h3 { font-size: 20px; margin: 18px 0 4px; }
.guide p { margin: 0 0 10px; }

.site-foot { border-top: 2px solid var(--ink); padding: 18px 0 28px; color: var(--muted); font-size: 16px; }
.sb-more { line-height: 1.8; }
.sb-privacy, .sb-credit { margin: 6px 0; }
.site-foot a { color: var(--accent); }

.print-sheet { display: none; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* ---- paper ---- */
@page { margin: 12mm; }
@media print {
  :root { --ink: #000; }
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--body); }
  body > *, main > *:not(.print-sheet) { display: none !important; }
  main { display: block !important; }
  .print-sheet { display: block; }
  .print-sheet .p-title { font: 700 18pt/1.15 var(--head); margin: 0 0 3pt; }
  .p-meta { margin: 0 0 4pt; font-size: 10pt; }
  .p-not { margin: 0 0 8pt; font-size: 9.5pt; border: .75pt solid #000; padding: 3pt 6pt; }
  .p-steps { margin: 0 0 6pt; padding-left: 14pt; font-size: 10pt; }
  .p-steps li { margin: 0 0 1pt; }
  .print-sheet table { border-collapse: collapse; }
  .print-sheet th, .print-sheet td { border: .75pt solid #555; padding: 2pt 4pt; text-align: left; vertical-align: middle; }
  .print-sheet thead { display: table-header-group; }
  .print-sheet tr { break-inside: avoid; }
  .sw, .c0, .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11 { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-sheet .p-outer > thead > tr.p-run > th { border: 0; padding: 0 0 3pt; font-weight: 400; text-align: left; }
  .p-run .p-t { font: 700 14pt/1.15 var(--head); margin-right: 6pt; }
  .p-run .p-m { font-size: 9.5pt; }
  .print-sheet .p-outer > thead > tr.p-run2 > th { border: .75pt solid #000; padding: 2pt 5pt; font-weight: 400; font-size: 9pt; text-align: left; }
  .print-sheet .p-outer > thead > tr.p-gap > th { height: 6pt; }
  .p-legend, .p-flags { width: calc(100% - 2pt); margin: 0 1pt 8pt; font-size: 10pt; }
  .print-sheet .p-flags .p-sec th { font: 700 11pt/1.2 var(--head); border: 0; border-bottom: .75pt solid #555; padding-top: 5pt; }
  .p-flags .p-sn { font: 400 9pt/1.2 var(--body); margin-left: 4pt; }
  .p-flags .name { font-weight: 600; overflow-wrap: anywhere; }
  .p-flags .cmv { text-align: right; white-space: nowrap; }
  .p-flags { table-layout: fixed; }
  .print-sheet tbody.keep { break-inside: avoid; }
  .print-sheet .p-outer { width: 100%; border-collapse: collapse; }
  .print-sheet .p-outer > tbody > tr > td, .print-sheet .p-outer > thead > tr > th { border: 0; padding: 0; }
  .print-sheet .p-outer > tbody > tr { break-inside: auto; }
  .p-legend .sw { width: 18pt; height: 14pt; font-size: 10pt; border-radius: 2pt; border: .5pt solid #000; }
  .p-legend td:first-child { width: 1%; }
  .p-grid { width: calc(100% - 2pt); margin: 0 1pt; table-layout: fixed; font-size: 10pt; }
  .p-grid th, .p-grid td { overflow-wrap: anywhere; }
  .p-grid thead th { border-bottom: 1.5pt solid #000; font-size: 10pt; }
  .p-grid .h-g, .p-grid td.g { text-align: center; padding: 2pt 1pt; font-family: var(--mono); font-weight: 700; color: #000; }
  .p-grid td.g.seed { outline: 1.5pt solid #000; outline-offset: -2pt; }
  .p-grid .cmv { text-align: right; }
  .p-grid td.gs { line-height: 1.5; }
  .p-grid .chip.seed { box-shadow: none; outline: 1.2pt solid #000; outline-offset: .8pt; }
  .p-grid .chip { min-width: 16pt; padding: 0 2pt; font-size: 8.5pt; border: .5pt solid #000; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .p-grid .note { font-size: 9pt; }
  .p-grid tr.sep th { background: none; font: 700 10.5pt/1.2 var(--head); border-left: 0; border-right: 0; padding-top: 6pt; }
  .p-grid .tg { font-weight: 400; font-size: 8.5pt; color: #000; }
  .p-grid.tight { font-size: 9pt; }
  .p-grid.tight .h-g, .p-grid.tight td.g { font-size: 7.5pt; }
  .p-grid.blank td { height: 22pt; }
  .p-grid.blank th:nth-child(n+3):nth-child(-n+8) { text-align: center; }
  .p-grid.blank .pc-name { width: 30%; }
  .p-grid.blank .pc-cm { width: 8%; }
  .p-grid.blank .pc-g { width: 6%; }
  .p-grid .vh { position: absolute; }
}
