/* Layout: Program Book admin. Masthead bar, left contents column, ruled forms and tables on paper. */
:root {
  --paper: #F6F1E8; --panel: #FFFDF9; --tint: #EDE6DA;
  --ink: #1B1815; --ink-2: #4A443D; --gray: #6A625A; --rule: #BDB3A5;
  --red: #A8102A; --red-ink: #8C0D22; --red-tint: #F3E1DF;
  --ok: #1F6B43; --ok-tint: #E2F0E7; --warn: #7A4E00; --warn-tint: #FBEFD0;
  --on-red: #FFFFFF;
  --display: "Zilla Slab", Rockwell, Georgia, serif;
  --body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #16130F; --panel: #201C17; --tint: #2A251F; --ink: #F1EBE0; --ink-2: #CFC6B8; --gray: #A79E91; --rule: #4A433A;
  --red: #E0566B; --red-ink: #F08A9A; --red-tint: #3A1A1F; --ok: #7FD1A0; --ok-tint: #18301F; --warn: #F0C46A; --warn-tint: #352910; --on-red: #16130F; color-scheme: dark } }
:root[data-theme="dark"] {
  --paper: #16130F; --panel: #201C17; --tint: #2A251F; --ink: #F1EBE0; --ink-2: #CFC6B8; --gray: #A79E91; --rule: #4A433A;
  --red: #E0566B; --red-ink: #F08A9A; --red-tint: #3A1A1F; --ok: #7FD1A0; --ok-tint: #18301F; --warn: #F0C46A; --warn-tint: #352910; --on-red: #16130F; color-scheme: dark }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1rem/1.55 var(--body); font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom, 0px); }
a { color: var(--red-ink); text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }

.bar { background: var(--panel); border-bottom: 1px solid var(--ink); padding-top: env(safe-area-inset-top, 0px); }
.bar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-height: 60px; padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.mark { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.mark b { font: 700 1.6rem/1 var(--display); color: var(--red); }
.mark span { font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.mock-flag { font-size: .8125rem; font-weight: 700; color: var(--warn); background: var(--warn-tint); padding: 3px 8px; border-radius: 2px; }
.who { margin-left: auto; font-size: .875rem; color: var(--ink-2); }

.layout { display: grid; gap: 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1320px; margin: 0 auto; }
.side { padding-block: 16px 8px; border-bottom: 1px solid var(--rule); }
.side ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.side-h { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gray); margin-bottom: 6px; }
.side a { display: block; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 2px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9375rem; background: var(--panel); }
.side a:hover { border-color: var(--ink); }
.side a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.built span { display: block; padding: 6px 10px; font-size: .875rem; color: var(--gray); border: 1px dashed var(--rule); border-radius: 2px; }
main { padding-block: 22px 64px; min-width: 0; outline: none; }
@media (min-width: 960px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); gap: 36px; }
  .side { border-bottom: 0; border-right: 1px solid var(--rule); padding-right: 20px; position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding-block: 22px; }
  .side ul { display: grid; gap: 4px; }
  .side a { border-color: transparent; background: none; }
  .side a:hover { border-color: var(--rule); }
}

/* Page head */
.head { border-top: 4px double var(--ink); padding-top: 12px; margin-bottom: 18px; display: grid; gap: 8px; }
.head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.head p { color: var(--ink-2); max-width: 62ch; }
.where { font-size: .875rem; color: var(--gray); }
.where b { color: var(--ink-2); }
section.blk { margin-top: 28px; display: grid; gap: 12px; }
section.blk > h2 { font-size: 1.375rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
section.blk > h2 small { font: 400 .875rem var(--body); color: var(--gray); }
.why { background: var(--tint); border-left: 3px solid var(--red); padding: 10px 14px; font-size: .9375rem; color: var(--ink-2); max-width: 75ch; }
.why b { color: var(--ink); }

/* Tables */
.tw { overflow-x: auto; border: 1px solid var(--rule); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--rule); }
thead th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); background: var(--tint); white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
tr.grp th { background: var(--tint); font: 700 1.05rem var(--display); color: var(--ink); text-transform: none; letter-spacing: 0; }
td.num { text-align: right; white-space: nowrap; }
td input, td select, td textarea { width: 100%; min-width: 7em; }
td.tight input { min-width: 5em; }

/* Form controls */
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: 2px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: 2px solid color-mix(in srgb, var(--red) 30%, transparent); }
textarea { resize: vertical; min-height: 2.6em; }
.money { display: flex; align-items: center; gap: 4px; }
.money input { text-align: right; width: 6em; min-width: 0; }
.fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); background: var(--panel); border: 1px solid var(--rule); padding: 16px; }
.fields label { display: grid; gap: 4px; font-weight: 600; font-size: .875rem; min-width: 0; }
.fields label.wide { grid-column: 1 / -1; }
.fields .hint { font-weight: 400; color: var(--gray); font-size: .8125rem; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .875rem; white-space: nowrap; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }

.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; font: 700 .9375rem var(--body); border: 2px solid var(--red); background: var(--red); color: var(--on-red); border-radius: 2px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.line { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.line:hover { background: var(--ink); color: var(--paper); }
.btn.sm { min-height: 32px; padding: 3px 10px; font-size: .8125rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.x { background: none; border: 0; color: var(--gray); cursor: pointer; font-size: 1.2rem; padding: 2px 6px; }
.x:hover { color: var(--red); }

/* Status pills */
.pill { display: inline-block; font: 700 .75rem/1 var(--body); padding: 4px 7px; border-radius: 2px; border: 1.5px solid currentColor; white-space: nowrap; }
.pill.new { color: var(--red-ink); }
.pill.hard { color: var(--warn); background: var(--warn-tint); border-color: transparent; }
.pill.built { color: var(--ok); background: var(--ok-tint); border-color: transparent; }
.pill.ask { color: var(--warn); }
.pill.auto { color: var(--ok); }
.pill.ex { color: var(--gray); }

/* Overview cards */
.sum { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.sum a { display: grid; gap: 4px; padding: 14px; background: var(--panel); border: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.sum a:hover { border-color: var(--ink); }
.sum b { font: 700 1.125rem var(--display); }
.sum span { font-size: .875rem; color: var(--ink-2); }
.qs { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; max-width: 75ch; }

/* Up next: editor + live preview */
.split { display: grid; gap: 20px; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } .split .pv { position: sticky; top: 16px; } }
.pv-label { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gray); margin-bottom: 6px; }
.openbox { background: var(--panel); border: 2px solid var(--ink); padding: 16px; display: grid; gap: 10px; }
.openbox h3 { font-size: 1.4rem; border-bottom: 2px solid var(--red); padding-bottom: 8px; }
.openbox dl { margin: 0; display: grid; gap: 10px; }
.openbox dt { font: 700 1.05rem/1.25 var(--display); }
.openbox dd { margin: 2px 0 0; color: var(--ink-2); font-size: .9375rem; }
.st { display: inline-block; font: 700 .75rem/1 var(--body); padding: 3px 6px; border: 1.5px solid currentColor; border-radius: 2px; margin-right: 6px; vertical-align: 2px; }
.st.open { color: var(--ok); } .st.soon { color: var(--red-ink); } .st.off { color: var(--gray); } .st.game { color: var(--ink); }
.today { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .875rem; color: var(--ink-2); }
.today input { width: auto; }

/* Year grid */
.months { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mo { background: var(--panel); border: 1px solid var(--rule); padding: 12px; display: grid; gap: 8px; align-content: start; }
.mo h3 { font-size: 1.05rem; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.item { display: grid; gap: 6px; padding: 8px; background: var(--tint); }
.item .row { display: flex; gap: 8px; align-items: center; }
.item .row input { flex: 1; min-width: 0; }

/* Sponsors */
.logo { width: 64px; height: 40px; display: grid; place-items: center; border: 1px dashed var(--rule); font-size: .6875rem; color: var(--gray); text-align: center; line-height: 1.1; background: var(--paper); }
.logo.has { border-style: solid; font: 700 .7rem var(--display); color: var(--ink); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-weight: 600; font-size: .9375rem; border-radius: 2px; z-index: 20; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: no-preference) { #toast { transition: opacity .2s; } }

/* Add / edit / delete window */
dialog { border: 2px solid var(--ink); border-radius: 2px; padding: 0; background: var(--panel); color: var(--ink); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(27, 24, 21, .55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 2px solid var(--red); }
.dlg-head h2 { font-size: 1.375rem; }
.dlg-body { padding: 16px; overflow-y: auto; display: grid; gap: 10px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--rule); }
.btn.danger { background: var(--red); border-color: var(--red); }
td .actions .btn { white-space: nowrap; }

/* ---- v3: nested navigation and working pages ---- */
.who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.side { display: grid; gap: 4px; align-content: start; }
.side .top-link a, .side .grp-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grp-nav { border-top: 1px solid var(--rule); padding-top: 4px; }
.grp-nav summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; min-height: 40px;
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.grp-nav summary::-webkit-details-marker { display: none; }
.grp-nav summary::after { content: "+"; font-size: 1rem; color: var(--gray); }
.grp-nav[open] summary::after { content: "–"; }
.grp-nav ul { list-style: none; margin: 0 0 8px; padding: 0 0 0 8px; display: grid; gap: 2px; border-left: 2px solid var(--rule); }
.side ul { flex-wrap: nowrap; }
.tag { font: 700 .625rem/1 var(--body); letter-spacing: .05em; text-transform: uppercase; color: var(--red-ink); border: 1px solid currentColor; padding: 2px 4px; border-radius: 2px; }
.side a[aria-current="page"] .tag { color: var(--paper); }
@media (max-width: 959px) {
  .side { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; }
  .side .top-link { grid-column: 1 / -1; }
}
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { display: grid; gap: 2px; padding: 14px; background: var(--panel); border: 1px solid var(--rule); border-top: 3px solid var(--ink); text-decoration: none; color: var(--ink); }
.tile:hover { border-color: var(--ink); }
.tile span { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.tile b { font: 700 1.75rem/1.1 var(--display); }
.tile small { font-size: .875rem; color: var(--ink-2); }
.flow { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; max-width: 75ch; }
.filterbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 20px; margin-bottom: 8px; }
.filterbar label { display: grid; gap: 4px; font-weight: 600; font-size: .875rem; }
.stats { font-size: .9375rem; color: var(--ink-2); }
.stats b { color: var(--ink); }
.facts { margin: 0 0 6px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; }
.facts dt { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--gray); }
.facts dd { margin: 0; }
.fields.bare { border: 0; padding: 0; background: none; }
.req { color: var(--red); }
.invalid { border-color: var(--red) !important; background: var(--red-tint) !important; }
.nowrap { flex-wrap: nowrap; }
.gap { height: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grp-in { display: flex; flex-wrap: wrap; gap: 8px; }
.grp-in .grp-name { font: 700 1.05rem var(--display); min-width: 14em; flex: 1 1 14em; }
.grp-in .grp-sub { font: 400 .875rem var(--body); min-width: 18em; flex: 2 1 18em; }
.savebar { margin-top: 18px; }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
td select { min-width: 9em; }

/* ---- design coach pass (2026-11-30) ---- */
.tw { position: relative; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--red) 45%, transparent); outline-offset: 1px; }
.menu-btn { display: none; }
@media (max-width: 959px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: block; padding-block: 10px; }
  .menu-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--ink); border-radius: 2px; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
  .menu-btn span { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
  .menu-btn b { flex: 1; }
  .menu-btn i { font-style: normal; font-size: 1.2rem; color: var(--gray); }
  .side-list { display: none; margin-top: 8px; }
  .side-list[data-open] { display: grid; gap: 4px; }
}
/* Tables turn into stacked cards on phones */
@media (max-width: 699px) {
  .tw.cards { border: 0; background: none; overflow: visible; }
  .tw.cards table, .tw.cards tbody, .tw.cards tr, .tw.cards td, .tw.cards th { display: block; width: 100%; }
  .tw.cards thead { display: none; }
  .tw.cards tr { background: var(--panel); border: 1px solid var(--rule); border-top: 2px solid var(--ink); margin-bottom: 10px; padding: 6px 0; }
  .tw.cards tr.grp { border: 0; background: none; padding: 12px 0 4px; margin: 0; }
  .tw.cards tr.grp th { padding: 0; background: none; }
  .tw.cards td { border: 0; padding: 5px 12px; display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; align-items: start; }
  .tw.cards td::before { content: attr(data-label); font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--gray); padding-top: 3px; }
  .tw.cards td.act, .tw.cards td.empty { display: block; }
  .tw.cards td.act::before, .tw.cards td.empty::before { content: none; }
  .tw.cards td.act { padding-top: 8px; border-top: 1px solid var(--rule); margin-top: 4px; }
  .tw.cards td input, .tw.cards td select, .tw.cards td textarea { min-width: 0 !important; width: 100%; }
  .tw.cards tr.just-added { outline: 3px solid var(--warn); }
}
/* Touch targets and destructive actions */
@media (pointer: coarse) { .btn.sm, .chip { min-height: 44px; } .x { min-width: 44px; min-height: 44px; } }
.dlg-head .x { min-width: 44px; min-height: 44px; font-size: 1.6rem; }
.btn.del { background: transparent; border-color: transparent; color: var(--red-ink); text-decoration: underline; text-underline-offset: .2em; margin-left: 8px; }
.btn.del:hover { background: var(--red-tint); color: var(--red-ink); border-color: transparent; }
.btn.danger { background: var(--red); border-color: var(--red); }
.danger-zone { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 4px; }
.danger-zone .btn.del { margin-left: 0; }
/* Inline errors */
.err { color: var(--red-ink); font-size: .8125rem; font-weight: 700; }
.invalid { border-width: 2px !important; }
/* Window fits above the phone keyboard */
dialog { max-height: calc(100dvh - 32px); }
dialog #toast { position: sticky; bottom: 8px; left: auto; transform: none; margin: 0 16px 12px; display: block; }
/* Overview: needs attention */
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo a { display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 56px; background: var(--panel); border: 1px solid var(--rule); border-left: 4px solid var(--red); text-decoration: none; color: var(--ink); }
.todo a:hover { border-color: var(--ink); border-left-color: var(--red); }
.todo b { font: 700 1.6rem/1 var(--display); min-width: 1.6em; color: var(--red-ink); }
.todo span { flex: 1; font-weight: 600; }
.todo i { font-style: normal; color: var(--gray); }
details.help { background: var(--panel); border: 1px solid var(--rule); padding: 10px 14px; }
details.help summary { cursor: pointer; font: 700 1.05rem var(--display); min-height: 32px; }
details.help .flow { margin-top: 10px; }
details.past { margin-top: 14px; }
details.past summary { cursor: pointer; font-weight: 700; color: var(--ink-2); padding: 8px 0; }
/* Registrations filters and payment */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); border-radius: 999px; font: 600 .875rem var(--body); cursor: pointer; }
.chip span { font-weight: 700; color: var(--ink-2); }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] span, .chip.on span { color: var(--paper); }
select.pay { font-weight: 700; }
select.pay-unpaid { border-color: var(--red); color: var(--red-ink); }
select.pay-paid { border-color: var(--ok); color: var(--ok); }
select.pay-scholarship { border-color: var(--warn); color: var(--warn); }
select.pay-asked { border-color: var(--warn); color: var(--warn); border-style: dashed; }
ul.plain { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
a.tel { white-space: nowrap; }
tr.just-added > td { background: var(--warn-tint); }
@media (max-width: 699px) {
  .tw.cards td { display: block; position: relative; padding-left: calc(12px + 6.5em + 10px); min-height: 2em; }
  .tw.cards td::before { position: absolute; left: 12px; top: 8px; width: 6.5em; }
  .tw.cards td.act, .tw.cards td.empty { padding-left: 12px; }
}
details.help { margin-top: 28px; }
