:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #4a5468;
  --rule: #d6dae1;
  --band: #172033;
  --band-ink: #f4f6fa;
  --band-muted: #c9d0dc;
  --accent: #0f4c5c;
  --accent-ink: #ffffff;
  --focus: #c2410c;
  --clash: #b42318;
  --eve: #8f5300;
  --season: #1d5fa8;
  --possible: #586273;
  --clear: #1e7a3c;
  --field: #ffffff;
  --soft: #eef1f4;
  --r: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c;
    --surface: #171c25;
    --ink: #e8ebf0;
    --muted: #b3bbc8;
    --rule: #2e3644;
    --band: #1d2533;
    --band-ink: #f4f6fa;
    --band-muted: #c3cad6;
    --accent: #7cc4d6;
    --accent-ink: #0b1418;
    --focus: #fdba74;
    --clash: #ff8a7a;
    --eve: #f2b84b;
    --season: #8ab8f0;
    --possible: #b3bbc8;
    --clear: #6fd08f;
    --field: #0f131a;
    --soft: #1f2632;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --surface: #171c25; --ink: #e8ebf0; --muted: #b3bbc8; --rule: #2e3644; --band: #1d2533;
  --band-ink: #f4f6fa; --band-muted: #c3cad6; --accent: #7cc4d6; --accent-ink: #0b1418; --focus: #fdba74;
  --clash: #ff8a7a; --eve: #f2b84b; --season: #8ab8f0; --possible: #b3bbc8; --clear: #6fd08f; --field: #0f131a; --soft: #1f2632;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 5; }
.skip:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }
.print-only, .print-blank { display: none; }
.frame, .frame > tbody, .frame > tbody > tr, .frame > tbody > tr > td { display: block; }
.frame { width: 100%; border-collapse: collapse; }
.frame > tbody > tr > td { padding: 0; }

/* masthead */
.masthead { background: var(--band); color: var(--band-ink); padding: 22px 0 20px; }
.masthead h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 4.6vw, 2.5rem); line-height: 1.12; letter-spacing: -0.02em; font-weight: 750; max-width: 24ch; }
.lede { margin: 0; color: var(--band-muted); max-width: 62ch; font-size: 1.05rem; }

/* tool */
.tool { display: grid; gap: 24px; padding-top: 20px; padding-bottom: 28px; }
@media (min-width: 960px) {
  .tool { grid-template-columns: minmax(340px, 410px) minmax(0, 1fr); align-items: start; gap: 36px; }
}
.inputs { display: grid; gap: 14px; min-width: 0; }
.block { min-width: 0; }
.h { display: block; font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
textarea, input[type=text], input[type=date], input[type=time], select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field); border: 1px solid #8c95a5; border-radius: var(--r);
  padding: 9px 10px; min-height: 44px; max-width: 100%;
}
textarea { width: 100%; min-height: 150px; resize: vertical; line-height: 1.5; font-variant-numeric: tabular-nums; }
.adder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 7.5em); gap: 8px; margin-top: 8px; }
.adder #add-name { grid-column: 1; min-width: 0; }
.adder #add { grid-column: 2; }
.adder input { width: 100%; min-width: 0; }
@media (min-width: 560px) and (max-width: 959px) {
  .adder { grid-template-columns: 11em 7.5em minmax(0, 1fr) auto; }
  .adder #add-name, .adder #add { grid-column: auto; }
}
.hint { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.btn {
  font: inherit; font-size: 16px; min-height: 44px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: var(--rule); color: var(--muted); }
.btn.danger { background: var(--clash); border-color: var(--clash); color: #fff; }
.btn.small { min-height: 44px; padding: 4px 12px; }
.btn:hover { filter: brightness(1.08); }
.link { font: inherit; font-size: 16px; background: none; border: 0; padding: 10px 0; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 44px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.ask, .confirm, .incoming, .linkbox { background: var(--soft); border-radius: var(--r); padding: 12px 14px; margin-top: 10px; }
.ask p, .confirm p, .incoming p { margin: 0 0 10px; }
.linkbox label { display: block; margin-bottom: 6px; }
.linkbox input { width: 100%; }
.problems { margin: 10px 0 0; padding: 0; list-style: none; color: var(--clash); }
.problems li { margin: 4px 0; overflow-wrap: anywhere; }
.problems .quote { color: var(--muted); }

details > summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--rule); padding-top: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: auto; margin-right: 6px; }
details[open] > summary::after { transform: rotate(-135deg); }
details > summary .h { margin: 0; }
.sum { color: var(--muted); }
.trad-list { display: grid; gap: 2px; margin-top: 6px; }
.trad { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--rule); }
.trad:last-child { border-bottom: 0; }
.tname { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; min-width: 0; }
.tname input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.seg { display: inline-flex; flex: none; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { min-width: 62px; min-height: 44px; display: grid; place-items: center; padding: 0 10px; cursor: pointer; color: var(--muted); font-size: 16px; }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }
.seg input:disabled + label { opacity: .45; cursor: default; }
.opt { display: grid; gap: 4px; margin: 10px 0; }
.opt select { width: 100%; }
.kept ul { list-style: none; padding: 0; margin: 0; }
.kept li { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--rule); padding: 6px 0; overflow-wrap: anywhere; }

/* results */
.results { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; min-width: 0; }
.res-head h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.summary { margin: 4px 0 0; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.flt { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; cursor: pointer; }
.flt input { width: 20px; height: 20px; accent-color: var(--accent); }
.actions #clear { margin-left: auto; }
.empty { color: var(--muted); margin: 14px 0 4px; }
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list .row { display: grid; grid-template-columns: 6.6em minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); }
.when { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.25; }
.when .wd, .when .yr, .when .tm { color: var(--muted); font-size: 16px; }
.when .dm { font-size: 1.2rem; font-weight: 700; }
.when .tm { margin-top: 2px; }
.what { min-width: 0; }
.what p { margin: 0; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.status { display: flex; align-items: center; gap: 8px; margin-top: 2px !important; }
.st-clash .status b { color: var(--clash); }
.st-eve .status b { color: var(--eve); }
.st-season .status b { color: var(--season); }
.st-possible .status b { color: var(--possible); }
.st-clear .status b { color: var(--clear); }
.st-unchecked .status b { color: var(--possible); }
.why { margin: 4px 0 0; padding-left: 1.1em; }
.why li { margin: 2px 0; overflow-wrap: anywhere; }
.why .on { font-weight: 600; }
.why .tr, .note { color: var(--muted); }
.why .note { display: block; }
.alt { margin-top: 6px !important; }
.note { font-size: 16px; }
.more { margin-top: 14px; }
.caution { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--muted); }
.saving { color: var(--eve); margin: 10px 0 0; }

/* status marks: shape and colour, so they read without colour too */
.mk { display: inline-block; width: 14px; height: 14px; flex: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mk.clash { background: var(--clash); border-radius: 2px; }
.mk.eve { border: 2px solid var(--eve); border-radius: 50%; background: linear-gradient(90deg, var(--eve) 50%, transparent 50%); }
.mk.season { border: 3px solid var(--season); border-radius: 2px; }
.mk.possible { border: 2px dashed var(--possible); border-radius: 50%; }
.mk.clear { border: 2px solid var(--clear); border-radius: 50%; }
.mk.unchecked { border: 2px dashed var(--possible); border-radius: 2px; }

/* page text */
.prose { padding-bottom: 32px; }
.prose section { max-width: 72ch; }
.prose h2 { font-size: 1.4rem; margin: 32px 0 8px; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.08rem; margin: 20px 0 4px; }
.prose p { margin: 0 0 10px; }
.keys { list-style: none; padding: 0; margin: 0 0 10px; }
.keys li { display: flex; gap: 10px; align-items: baseline; margin: 6px 0; }
.keys .mk { position: relative; top: 2px; }
.sources li { margin: 4px 0; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--band); color: var(--band-ink); padding: 10px 14px; border-radius: var(--r);
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); z-index: 10; pointer-events: none; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.toast .btn { pointer-events: auto; color: var(--band-ink); border-color: var(--band-muted); min-height: 44px; }

/* footer */
.site-foot { border-top: 1px solid var(--rule); padding: 18px 0 28px; color: var(--muted); }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-credit a, .sb-more a, .sb-privacy a { color: var(--accent); }

.notfound { padding: 28px 0 40px; }

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

@media (max-width: 559px) {
  .masthead { padding: 16px 0 14px; }
  .lede { font-size: 1rem; }
  textarea { min-height: 0; height: 112px; }
  .hint { display: none; }
  .tool { padding-top: 14px; gap: 18px; }
  .results { padding: 12px; }
  .actions .btn { padding: 8px 10px; }
}
@media (max-width: 380px) {
  .masthead { padding: 12px 0 10px; }
  .masthead h1 { font-size: 1.4rem; margin: 0; }
  .lede { display: none; }
  .res-head h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .summary { margin-top: 0; }
  .tool { padding-top: 10px; gap: 12px; }
  .actions { gap: 6px; margin-top: 10px; }
  .actions .btn { padding: 8px; }
  .list .row { grid-template-columns: 5.6em minmax(0, 1fr); gap: 10px; }
  .seg label { min-width: 52px; padding: 0 8px; }
}

/* print */
@page { margin: 14mm 13mm; }
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --rule: #999; --clash: #a1150b; --eve: #7a4600; --season: #164f8f; --possible: #444; --clear: #17612f; }
  body { font-size: 10.5pt; line-height: 1.4; background: #fff; color: #000; }
  .skip, .inputs, .prose, .site-foot, .actions, .toast, .confirm, .linkbox, .incoming, .empty, .saving, #announce, .lede, .more, .ask { display: none !important; }
  .masthead { background: none; color: #000; padding: 0 0 4pt; }
  .masthead h1 { font-size: 16pt; max-width: none; }
  .wrap { max-width: none; padding: 0; }
  .tool { display: block; padding: 0; }
  .results { border: 0; padding: 0; }
  .res-head h2 { font-size: 12.5pt; }
  .print-only { display: block; }
  .frame { display: table; width: 100%; }
  .frame > thead { display: table-header-group; }
  .frame > tbody { display: table-row-group; }
  .frame > thead > tr, .frame > tbody > tr { display: table-row; }
  .frame > thead > tr > td, .frame > tbody > tr > td { display: table-cell; padding: 0; }
  .run-head { margin: 0 0 6pt; padding-bottom: 4pt; border-bottom: 1px solid #999; font-size: 9.5pt; color: #222; }
  .print-sources { margin: 8pt 0 0; color: #333; font-size: 9.5pt; }
  .list .row { grid-template-columns: 9em minmax(0, 1fr); padding: 6pt 0; break-inside: avoid; page-break-inside: avoid; }
  .list .row.long { break-inside: auto; page-break-inside: auto; }
  .why li, .what .name, .what .status { break-inside: avoid; }
  .what .name, .what .status { break-after: avoid; }
  .when .dm { font-size: 11.5pt; }
  .when .wd, .when .yr, .when .tm, .note { font-size: 10pt; }
  .caution { color: #000; font-size: 10pt; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  body.is-empty .print-blank { display: block; }
  body.is-empty .list, body.is-empty .summary { display: none; }
  .print-blank table { width: calc(100% - 2px); margin: 6pt 1px 0; border-collapse: collapse; table-layout: fixed; }
  .print-blank th, .print-blank td { border: 1px solid #555; padding: 0 6pt; height: 26pt; text-align: left; font-size: 10pt; }
  .print-blank th { height: auto; padding: 4pt 6pt; }
  .print-blank th:nth-child(1) { width: 22%; }
  .print-blank th:nth-child(3) { width: 38%; }
}
