:root {
  --bg: #e9eef1;
  --surface: #ffffff;
  --ink: #16222b;
  --muted: #44525d;
  --line: #b9c4cc;
  --shelf: #2c3a44;
  --accent: #962a20;
  --accent-ink: #ffffff;
  --accent-soft: #f6e4e1;
  --label: #fffdf6;
  --label-ink: #111;
  --ok: #1c6440;
  --ok-bg: #e2f1e8;
  --warn: #7a4300;
  --warn-bg: #fcefd8;
  --focus: #0b62a8;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181d;
    --surface: #1a242b;
    --ink: #e6ecf0;
    --muted: #a8b5bf;
    --line: #3a4954;
    --shelf: #7f93a1;
    --accent: #f0907f;
    --accent-ink: #1a0d0b;
    --accent-soft: #3a2420;
    --label: #f4f1e6;
    --label-ink: #111;
    --ok: #8fd3ad;
    --ok-bg: #173226;
    --warn: #f3c27a;
    --warn-bg: #3a2c14;
    --focus: #7cc0ff;
  }
}
* { 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: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

.top { border-bottom: 6px solid var(--shelf); background: var(--surface); }
.top .wrap { padding-top: 22px; padding-bottom: 16px; }
h1 { font-size: clamp(1.7rem, 4.6vw, 2.5rem); line-height: 1.12; margin: 0 0 8px; font-weight: 800; letter-spacing: -0.015em; }
.lede { margin: 0; max-width: 62ch; color: var(--muted); }

/* tool */
.tool { padding-top: 18px; padding-bottom: 28px; }
input[type="text"], input[type="date"], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 4px; padding: 8px 10px; min-height: 44px; max-width: 100%;
}
textarea { width: 100%; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
label { font-weight: 600; }
.btn {
  font: inherit; font-size: 16px; font-weight: 600; min-height: 44px; padding: 8px 16px; border-radius: 4px;
  border: 1.5px solid var(--shelf); background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: var(--line); }
.btn.small { min-height: 40px; padding: 6px 12px; }
.btn.icon { min-width: 44px; padding: 6px 0; font-size: 18px; line-height: 1; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:hover:not(:disabled) { border-color: var(--accent); }

.cycle { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.cycle > label { display: flex; flex-direction: column; gap: 4px; }
#f-weeks { width: 6.5em; }
.more { flex-basis: 100%; }
.more summary { cursor: pointer; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); }
.more-grid { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 4px 0 6px; }
.more-grid label { display: flex; flex-direction: column; gap: 4px; }
#f-title { width: 18em; }
#f-rate { width: 6.5em; }

.status { margin: 14px 0 12px; padding: 10px 14px; border-left: 0; border-radius: 4px; background: var(--surface); font-weight: 600; }
.status:empty { display: none; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.kept-line { margin: -4px 0 12px; font-weight: 600; }
.replan { margin: 14px 0 0; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--shelf); margin-top: 6px; }
.tabs [role="tab"] {
  font: inherit; font-size: 16px; font-weight: 700; min-height: 46px; padding: 8px 16px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 4px 4px 0 0; white-space: nowrap;
}
.tabs [aria-selected="true"] { background: var(--shelf); color: var(--bg); }
.panel { padding: 14px 0 6px; }

/* rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows > li.empty { color: var(--muted); border: 0; }
.cols { display: flex; gap: 10px; margin: 0; color: var(--muted); font-size: 15px; font-weight: 600; padding-left: 38px; }
.cols span:first-child { flex: 1 1 auto; }
.cols span:last-child { width: 420px; }
.rg { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; }
.rg .pos { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rg .cn { width: 100%; font-family: var(--mono); }
.rg-more { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; width: 420px; }
.rg .n { width: 5.2em; text-align: right; font-variant-numeric: tabular-nums; }
.tw { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 500; white-space: nowrap; }
.tw input { width: 20px; height: 20px; }
.mv { display: inline-flex; gap: 4px; margin-left: auto; }
.row-msg { grid-column: 2 / -1; margin: 2px 0 0; color: var(--warn); font-size: 16px; }
.row-msg.read { color: var(--muted); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 14px 0 0; }
.paste { margin-top: 14px; }
.paste summary { cursor: pointer; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); }
.paste label { display: block; font-weight: 500; margin: 4px 0 6px; }

.pp-top { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.pp-top .nm { flex: 1 1 200px; }
.pp-top .nm input { width: 100%; }
.amt { display: inline-flex; gap: 6px; }
.amt input { width: 4.6em; text-align: right; }
.pp-bot { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 8px; }
.days { display: inline-flex; gap: 3px; }
.day {
  font: inherit; font-size: 15px; font-weight: 600; min-width: 40px; min-height: 44px; padding: 0 4px; border-radius: 4px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
}
.day[aria-pressed="true"] { background: var(--shelf); border-color: var(--shelf); color: var(--bg); }
.off { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.off input { width: 9em; }
.row-sum { margin: 6px 0 0; color: var(--muted); }
.row-sum:empty { display: none; }

/* rota */
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 10px 14px; margin-bottom: 12px; }
.notice p { margin: 4px 0; }
.seg-wrap { border: 0; padding: 0; margin: 0 0 10px; }
.seg-wrap legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--shelf); border-radius: 4px; overflow: hidden; }
.seg label { position: relative; font-weight: 600; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; }
.seg input:checked + span { background: var(--shelf); color: var(--bg); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.rota .empty { color: var(--muted); }
.wk { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.wk h3 { font-size: 1.12rem; margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 0 12px; align-items: baseline; }
.wk .when { color: var(--muted); font-weight: 600; font-size: 16px; }
.tick { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 12px; justify-content: flex-end; }
.done { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 16px; font-weight: 600; }
.done input { width: 20px; height: 20px; }
.again { font-weight: 600; }
.wk .now { font-size: 16px; font-weight: 700; }
.missed { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
.missed h3 { font-size: 1.05rem; margin: 0 0 8px; }
.missed ul { list-style: none; margin: 0; padding: 0; }
.missed li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.missed .m-what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.missed .m-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.out-note { margin: 10px 0 0; }
.wk .sec { margin: 0 0 6px; color: var(--muted); }
.as { list-style: none; margin: 0; padding: 0; }
.as li { display: grid; grid-template-columns: minmax(9em, 14em) minmax(0, 1fr) auto; gap: 4px 14px; padding: 5px 0; align-items: start; }
.who .dd { color: var(--muted); font-size: 16px; }
/* the 44px tap target is centred on the first line of the row, not hanging below it */
.as li > .tick { margin-top: -9px; }
.runs { display: flex; flex-direction: column; gap: 4px; }
.run { overflow-wrap: anywhere; }
.cnl {
  display: inline-block; font-family: var(--mono); font-size: 15.5px; font-weight: 700; background: var(--label); color: var(--label-ink);
  border: 1.5px solid #222; border-radius: 2px; padding: 0 6px; line-height: 1.5; margin-right: 2px;
}
.offw, .none { margin: 6px 0 0; color: var(--muted); }

.out { margin-top: 26px; padding-top: 16px; border-top: 6px solid var(--shelf); }
.out h2 { font-size: 1.3rem; margin: 0 0 10px; }
.out-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 0; }
.kept { margin-top: 20px; }
.kept summary { cursor: pointer; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); }
.kept-list { list-style: none; padding: 0; margin: 6px 0; }
.kept-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kept-list .when, .kept-list .none { color: var(--muted); }
.bar { background: var(--accent-soft); border-radius: 4px; padding: 10px 14px; margin-bottom: 14px; }
.bar p { margin: 0 0 8px; }
.bar .bar-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.note { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px));
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 4px; display: flex; gap: 12px; align-items: center;
  z-index: 20; pointer-events: none; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
.toast[hidden] { display: none; }
.toast .btn { pointer-events: auto; background: var(--bg); color: var(--ink); border-color: var(--bg); }

/* reading */
.prose { padding-top: 10px; padding-bottom: 30px; }
.prose h2 { font-size: 1.45rem; margin: 30px 0 8px; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.1rem; margin: 18px 0 4px; }
.prose p { max-width: 70ch; margin: 0 0 10px; }
.sources { color: var(--muted); font-size: 16px; }
.site-foot { border-top: 1px solid var(--line); padding: 20px 0 30px; color: var(--muted); }
.sb-footer p { margin: 0 0 8px; max-width: 80ch; font-size: 16px; }
.sb-more { overflow-wrap: anywhere; }
.sb-footer a { color: var(--muted); }

.print-root { display: none; }

@media (max-width: 700px) {
  .cols { display: none; }
  .rg { grid-template-columns: 24px minmax(0, 1fr); }
  .rg-more { grid-column: 2; width: auto; }
  .rg .n::placeholder { color: transparent; }
  .as li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tick { justify-content: flex-start; }
  .as li > .tick { margin: 0; }
  .tabs [role="tab"] { padding: 8px 10px; flex: 1 1 auto; }
}
@media (max-width: 380px) {
  .day { min-width: 36px; font-size: 14px; }
  .btn.icon { min-width: 42px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

.dlg { max-width: min(92vw, 30rem); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; background: var(--surface); color: var(--ink); }
.dlg::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg h2 { margin: 0 0 8px; font-size: 1.2rem; }
.dlg-f { display: block; font-weight: 600; margin: 12px 0 6px; }
.dlg select, .dlg input { width: 100%; min-height: 44px; font-size: 16px; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; font-family: var(--sans); }
  body > *:not(#print) { display: none !important; }
  .print-root { display: block !important; }
  .p-head { margin-bottom: 4mm; }
  .p-title { font-size: 17pt; font-weight: 800; margin: 0 0 1.5mm; line-height: 1.15; }
  .p-sub { margin: 0; font-size: 10.5pt; }
  .p-break { break-before: page; }
  .p-warn { border: 1.2pt solid #000; padding: 2mm 3mm; margin: 0 0 4mm; }
  .p-warn p { margin: 0.5mm 0; }
  .p-kept { margin: 0 0 4mm; font-weight: 700; }
  .p-table { width: calc(100% - 2px); margin: 0 1px 5mm; border-collapse: collapse; table-layout: fixed; font-size: 10pt; }
  .p-table th, .p-table td { border: 0.75pt solid #444; padding: 1.4mm 2mm; text-align: left; vertical-align: top; overflow-wrap: break-word; }
  .p-table thead th { background: #e6e6e6; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-table tr { break-inside: avoid; }
  .p-table tbody { break-inside: avoid; }
  /* the blank rows, key and spot-check line never start a page alone: the last week comes with them */
  .p-log tbody.p-end { break-before: avoid; }
  .p-dd { font-size: 9pt; }
  .p-secs .c-who { width: 22%; } .p-secs .c-sec { width: 48%; } .p-secs .c-n { width: 15%; } .p-secs .c-wk { width: 15%; }
  .p-weeks .c-w { width: 16%; } .p-weeks .c-who { width: 20%; } .p-weeks .c-runs { width: 52%; } .p-weeks .c-done { width: 12%; }
  .p-weeks tbody { border-top: 1.5pt solid #000; }
  .p-log .l-wk { width: 9%; } .p-log .l-sh { width: 31%; } .p-log .l-cn { width: 11%; } .p-log .l-dt { width: 9%; } .p-log .l-mn { width: 7%; } .p-log .l-in { width: 10%; } .p-log .l-pr { width: 12%; }
  .p-log td { height: 12mm; }
  .p-log tbody + tbody { border-top: 0; }
  .p-log tr.p-run th { background: #fff; border: 0; padding: 0 0 1.5mm; font-size: 9pt; font-weight: 400; color: #333; }
  .p-log tr.p-endrow td { border: 0; height: auto; padding: 3mm 0 0; }
  .p-key { font-size: 9.5pt; margin: 0 0 3mm; }
  .p-sign, .p-fields { margin: 3mm 0 4mm; font-size: 10.5pt; display: flex; align-items: baseline; gap: 2mm; }
  .p-line { flex: 1 1 auto; border-bottom: 0.75pt solid #000; height: 5mm; }
  .p-line.short { flex: 0 0 35mm; }
}
