/* Field Day planner — one stylesheet, mobile first. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #171d24;
  --muted: #5d6874;
  --line: #dde2e9;
  --line-strong: #c3cad4;
  --accent: #1d5fa8;
  --accent-text: #ffffff;
  --todo: #94a0ad;
  --progress: #4f46e5;
  --done: #1a7f4b;
  --warn: #a8501c;
  --danger: #b3261e;
  --radius: 8px;
  --tap: 46px;
  --gap: .75rem;
  --topbar-h: 3.3rem;
  --quick-h: 2.9rem;
  --bottomnav-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a;
    --surface: #181d25;
    --surface-2: #212832;
    --text: #e8edf4;
    --muted: #98a4b3;
    --line: #2a323d;
    --line-strong: #3a444f;
    --accent: #63a0e8;
    --accent-text: #0c1016;
    --todo: #77828f;
    --progress: #8b83ff;
    --done: #33b06a;
    --warn: #d99154;
    --danger: #e5715f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 1.5rem 0 .5rem; letter-spacing: .01em; }

.wrap { max-width: 62rem; margin: 0 auto; padding: 1rem .75rem 2.5rem; }
/* For the timeline, which is the one page whose job is width. */
.wrap.wide { max-width: 108rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 1rem 0; list-style: none; }
.page-head {
  display: flex; flex-wrap: wrap; gap: .25rem var(--gap);
  align-items: baseline; justify-content: space-between; margin-bottom: 1rem;
}
.page-head p { margin: 0; }

/* --- Navigation --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  padding: .55rem .75rem; min-height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 600; text-decoration: none; color: var(--text); }
.topnav { display: none; align-items: center; gap: .9rem; }
.topnav > a:not(.button) { text-decoration: none; color: var(--muted); }
.topnav > a:not(.button):hover { color: var(--text); }
.topnav .current { color: var(--text); font-weight: 600; }

.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; color: var(--muted);
  padding: .4rem 0; min-height: var(--tap);
  display: flex; align-items: center; justify-content: center; gap: .15rem;
  white-space: nowrap;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: .85em; }
.menu-panel {
  position: absolute; right: 0; top: 100%; z-index: 40;
  display: grid; min-width: 12rem; padding: .3rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .14);
}
.menu-panel a {
  padding: .6rem .7rem; text-decoration: none; color: var(--text);
  border-radius: 6px; min-height: var(--tap); display: flex; align-items: center;
}
.menu-panel a:hover { background: var(--surface-2); }
.menu.up .menu-panel { top: auto; bottom: 100%; margin-bottom: .3rem; }
.menu-title { display: none; }

/* Tapping anywhere else closes the menu. Without a backdrop the only way out
   is to hit the same small target again. */
.menu[open]::before {
  content: ""; position: fixed; inset: 0; z-index: 1;
  background: rgb(0 0 0 / .45);
}

/* On a phone it is a sheet across the foot of the screen, not a small tray
   hanging off one nav item. */
@media (max-width: 759px) {
  .bottomnav .menu > summary { min-width: 0; padding: 0 .2rem; }
  .bottomnav .menu[open] > summary { color: var(--accent); font-weight: 600; }
  /* Outranks the desktop .menu.up rule, which pins it to the summary. */
  .bottomnav .menu.up .menu-panel {
    position: fixed; left: .5rem; right: .5rem; top: auto;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 2;
    min-width: 0; margin: 0; padding: .35rem;
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 -8px 32px rgb(0 0 0 / .35);
  }
  .menu-title {
    display: block; margin: .1rem .7rem .35rem; padding-bottom: .4rem;
    border-bottom: 1px solid var(--line);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--muted); font-weight: 600;
  }
  .bottomnav .menu.up .menu-panel a { min-height: var(--bottomnav-h); font-size: 1rem; }
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav > a, .bottomnav > .menu {
  flex: 1; text-align: center; font-size: .8rem;
}
.bottomnav > a {
  padding: .7rem .2rem; text-decoration: none; color: var(--muted);
  min-height: var(--bottomnav-h); display: flex; align-items: center; justify-content: center;
}
.bottomnav .current { color: var(--accent); font-weight: 600; }
.bottomnav .menu > summary { font-size: .8rem; }

@media (min-width: 760px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 0; }
}

/* --- Controls --- */
button, input, select, textarea { font: inherit; color: inherit; }

.button, button[type="submit"], .statusbar button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--tap); padding: .4rem .85rem;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  text-decoration: none; cursor: pointer; font-weight: 500;
}
.button.small, button.small { min-height: 36px; padding: .25rem .6rem; font-size: .85rem; }
.button.ghost, button.ghost {
  background: transparent; color: var(--text); border-color: var(--line-strong);
}
.button.ok { background: var(--done); color: var(--accent-text); }
.button.danger, button.danger[type="submit"] { background: var(--danger); color: var(--accent-text); }
/* Element-qualified so the shared button fill does not outrank it. */
button.linkish {
  background: none; border: none; color: var(--muted); cursor: pointer;
  min-height: var(--tap); padding: .4rem .2rem;
  text-decoration: underline; font-size: .85rem; font-weight: 400;
}
button.linkish:hover { color: var(--text); }
button.linkish.danger { color: var(--danger); }
.inline { display: inline; }
html.js .js-hide { display: none; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%; padding: .5rem .6rem; min-height: var(--tap); font-size: 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
textarea { min-height: 5rem; }
select { appearance: auto; }

.messages { list-style: none; margin: 0; padding: .5rem .75rem 0; max-width: 62rem; margin-inline: auto; }
.messages li {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--done);
  padding: .55rem .75rem; border-radius: var(--radius); margin-bottom: .4rem;
}

/* --- Filters --- */
.filters {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 1rem;
}
.filters > summary {
  padding: .6rem .75rem; cursor: pointer; min-height: var(--tap);
  display: flex; align-items: center; gap: .4rem; color: var(--muted);
}
.filters .dot-accent { width: .45rem; height: .45rem; border-radius: 50%; background: var(--accent); }
.filter-form { display: grid; gap: .55rem; padding: 0 .75rem .75rem; }
.filter-form label { display: grid; gap: .15rem; font-size: .8rem; color: var(--muted); }
.filter-form label.check { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); }
.filter-form label.check input { width: 1.05rem; height: 1.05rem; min-height: 0; }
.filter-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

@media (min-width: 760px) {
  .filter-form { grid-template-columns: repeat(3, 1fr); align-items: end; }
}

/* --- Quick filters --- */
.quick {
  position: sticky; top: var(--topbar-h); z-index: 20;
  display: flex; gap: .35rem; padding: .45rem 0;
  background: var(--bg); margin: -.25rem 0 .6rem;
  overflow-x: auto; scrollbar-width: none;
}
.quick::-webkit-scrollbar { display: none; }
.quick a {
  flex: 1 0 auto; text-align: center; white-space: nowrap;
  padding: .5rem .9rem; min-height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--muted); text-decoration: none; font-size: .9rem;
}
.quick a.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600;
}

/* --- Schedule --- */
/* A long schedule is a hundred rows, and on a phone most of them are below the
   fold. This lets the browser skip laying out and painting a day until it comes
   into view. contain-intrinsic-size keeps the scrollbar honest in the meantime,
   so the thumb does not jump as days are reached. Nothing is hidden: find in
   page still works, and a browser without the property just does the work. */
.day, .tl-day {
  content-visibility: auto;
  contain-intrinsic-size: auto 20rem;
}
.day-head {
  position: sticky; top: calc(var(--topbar-h) + var(--quick-h)); z-index: 10;
  margin: 1.5rem 0 .4rem; padding: .35rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--muted);
}
.day.is-today .day-head { color: var(--accent); }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.task {
  scroll-margin-top: calc(var(--topbar-h) + var(--quick-h) + 2.5rem);
  display: grid;
  grid-template-columns: auto 3.6rem 1fr;
  grid-template-areas: "check time body" ". . assign";
  gap: .3rem .6rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--todo);
  border-radius: var(--radius); padding: .5rem .65rem;
}
.task.status-in_progress { border-left-color: var(--progress); }
.task.status-done { border-left-color: var(--done); }
/* Past its deadline, or its time came and went with nobody on it. Different
   questions, same answer for the person reading the row: this one is adrift. */
.task.overdue, .task.late { border-left-color: var(--warn); }
/* Finished is finished, whatever the deadline said. Last word on the border,
   and it takes the lateness chip down with it, so a row that is ticked off in
   place stops claiming to be adrift without waiting for a page load. */
.task.status-done { border-left-color: var(--done); }
.task.status-done .chip.late { display: none; }
/* Ticked off, and on its way out of a list that does not keep finished work. */
.task.is-leaving {
  transition: opacity .3s ease, transform .3s ease;
  opacity: 0; transform: translateX(1.25rem);
}
@media (prefers-reduced-motion: reduce) {
  .task.is-leaving { transition: none; }
}
/* Ticking a task off is switching it off: the whole row steps back, not just
   the title. What is left on the plan should be what the eye lands on. */
.task.status-done { opacity: .62; }
.task.status-done .task-title { text-decoration: line-through; color: var(--muted); }
.task.status-done .task-time,
.task.status-done .chip,
.task.status-done .task-assign { color: var(--muted); }

.task-check { grid-area: check; }
.task-check .check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-top: 0; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--done);
  font-size: 1.4rem; font-weight: 700; line-height: 1; cursor: pointer;
}
.task-check button.check { min-height: 0; }
.task-check .check.static { cursor: default; }
.status-done .task-check .check {
  border-color: var(--done);
  background: color-mix(in srgb, var(--done) 9%, transparent);
}

.task-time { grid-area: time; font-variant-numeric: tabular-nums; line-height: 1.25; font-size: .85rem; }
.task-time .from { display: block; font-weight: 600; }
.task-time .to { display: block; font-size: .75rem; color: var(--muted); }

.task-body { grid-area: body; min-width: 0; }
.task-title { display: block; font-weight: 500; text-decoration: none; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }

.task-assign { grid-area: assign; }
.task-assign form, .assign-form { display: flex; align-items: center; gap: .4rem; }
.task-assign select {
  min-height: 44px; width: auto; min-width: 7rem; max-width: 11rem;
  padding: .3rem .4rem;
}

@media (min-width: 760px) {
  .quick { top: var(--topbar-h); }
  .task {
    grid-template-columns: auto 3.6rem 1fr 12rem;
    grid-template-areas: "check time body assign";
    align-items: center;
  }
  .task-assign select { max-width: 10rem; }
}

/* --- Chips and dots --- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; padding: .12rem .45rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
/* On the screen a name is not a footnote: it is who has the job. A wall is read
   from across a tent, where a faint tint carries less than it does on a phone,
   so the colour is laid on harder here than in the lists. */
.screen-people .chip { font-size: clamp(.8rem, .95vw, 1.15rem); padding: .18rem .6rem; }
.screen-people .chip.person { background: color-mix(in srgb, var(--chip, var(--muted)) 34%, transparent); }
.screen-people .dot { width: .6em; height: .6em; }
.dot {
  width: .55rem; height: .55rem; border-radius: 50%; flex: none;
  background: var(--chip, var(--muted));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12);
}
.chip.tag { background: color-mix(in srgb, var(--chip, var(--muted)) 18%, transparent); }
.chip.person { background: color-mix(in srgb, var(--chip, var(--muted)) 20%, transparent); }
.chip.blocked { background: color-mix(in srgb, var(--warn) 20%, transparent); }
.chip.prio.p3, .chip.prio.p4 { background: color-mix(in srgb, var(--warn) 26%, transparent); }
.chip.cat { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.chip.cat-next_year { background: color-mix(in srgb, var(--progress) 18%, transparent); }
.chip.cat-remember { background: color-mix(in srgb, var(--warn) 20%, transparent); }
/* Archived work is set aside, not flagged: it should read quieter than the rest. */
.chip.archived { background: color-mix(in srgb, var(--muted) 22%, transparent); color: var(--muted); }
.chip.late { background: color-mix(in srgb, var(--warn) 26%, transparent); font-weight: 600; }

/* --- The document archive --- */
.shelf { margin: .8rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
.shelf > summary {
  padding: .55rem .7rem; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
}
.shelf > summary .tally {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: .05rem .4rem;
}
.shelf > .cards, .shelf-in { padding: 0 .7rem .7rem; }
.shelf-in h3 { font-size: .8rem; color: var(--muted); margin: .5rem 0 .3rem; font-weight: 600; }
.doc-kind { margin-right: .35rem; }
/* What the native field means, in words. Empty until a date is chosen. */
.date-echo { display: block; font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.date-echo:empty { display: none; }
.card-actions { display: flex; gap: .8rem; margin-top: .3rem; }

/* --- Task detail --- */
.crumbs { color: var(--muted); font-size: .8rem; margin: 0 0 .25rem; }
.detail-status { display: grid; gap: .5rem; margin: .9rem 0; }
.detail-status > form:first-child button { width: 100%; min-height: 52px; font-size: 1.05rem; }
.detail-status .assign-form select { flex: 1; }
@media (min-width: 760px) {
  .detail-status { display: flex; flex-wrap: wrap; align-items: center; }
  .detail-status > form:first-child button { width: auto; min-width: 12rem; }
  .detail-status .assign-form select { flex: 0 0 14rem; }
}
.statusbar { display: flex; gap: .3rem; flex-wrap: wrap; }
.statusbar .pill {
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  min-height: 36px; padding: .2rem .7rem; font-size: .85rem; font-weight: 400;
}
.statusbar .pill.active { color: var(--accent-text); border-color: transparent; font-weight: 500; }
.statusbar .pill.active.status-todo { background: var(--muted); }
.statusbar .pill.active.status-in_progress { background: var(--progress); }
.statusbar .pill.active.status-done { background: var(--done); }

.warn {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-left: 3px solid var(--warn);
  padding: .55rem .75rem; border-radius: var(--radius);
}
.meta { display: grid; gap: .4rem; margin: 1rem 0; }
.meta div { display: grid; grid-template-columns: 7rem 1fr; gap: .5rem; align-items: baseline; }
.meta dt { color: var(--muted); font-size: .82rem; }
.meta dd { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.description {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .1rem .75rem;
}
.description a { overflow-wrap: anywhere; }
.block { margin-top: 1.75rem; }
.plain, .checklist, .comments, .activity { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.checklist form { display: flex; align-items: center; gap: .4rem; }
.check-btn {
  background: none; border: none; color: var(--text); font-size: 1.1rem;
  padding: .2rem .3rem; min-height: var(--tap); cursor: pointer;
}
.checklist .done span { text-decoration: line-through; color: var(--muted); }
.comments li, .activity li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem .7rem;
}
.comments p { margin: .15rem 0; }
.comment-meta { font-size: .78rem; color: var(--muted); }
.inline-form { display: flex; gap: .5rem; margin-top: .6rem; align-items: flex-start; }
.inline-form.stacked { display: grid; gap: .4rem; }
.inline-form input, .inline-form textarea { flex: 1; }
.stacked-form { display: grid; gap: .15rem; max-width: 40rem; }
.stacked-form.narrow { max-width: 24rem; }
.stacked-form p { margin: .35rem 0; }
.stacked-form ul { padding-left: 1rem; }
.stacked-form label { font-weight: 500; font-size: .85rem; }
.stacked-form .errorlist { color: var(--danger); list-style: none; padding: 0; font-size: .85rem; }
.stacked-form .helptext { color: var(--muted); font-size: .8rem; }

/* --- Tables --- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.grid { border-collapse: collapse; width: 100%; font-size: .88rem; }
.grid th, .grid td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
.grid th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td .dot { margin-right: .4rem; vertical-align: baseline; display: inline-block; }
/* Somebody off the roster should look off it: weaker than "muted", which is
   what ordinary secondary text already is. Put on the cells rather than the
   row, because colour does not reliably inherit into a cell and opacity on a
   <tr> is not dependable in a border-collapse table. */
.grid tr.is-inactive td { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.grid tr.is-inactive td a { color: inherit; }
.grid tr.is-inactive td .dot { opacity: .35; }
.grid tr.is-inactive td .chip { opacity: .6; }
.grid td.access { white-space: normal; }
.grid td.access .chip { margin: .1rem .15rem .1rem 0; }
.chip.admin { background: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 600; }
.chip.cat.muted-chip { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.grid .num { text-align: right; white-space: nowrap; }

/* --- Cards (documents, attendance, notes) --- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .8rem; display: grid; gap: .4rem;
}
.card-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.card-title { font-weight: 600; text-decoration: none; color: var(--text); }
.card-actions { display: flex; gap: .75rem; align-items: center; }
/* The handle that stands in for the roster until somebody asks for it. */
a.assign {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: var(--tap); padding: .2rem .5rem;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); text-decoration: none; font-size: .8rem; white-space: nowrap;
}
a.assign .assign-name { color: var(--muted); }
a.assign:hover { border-color: var(--line-strong); }
.card p { margin: 0; }

@media (min-width: 760px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards.notes { grid-template-columns: 1fr; }
}

.card.me { border-left: 3px solid var(--line-strong); margin-bottom: .5rem; }
.card.me > form > button, .card.me .check-out > summary {
  width: 100%; min-height: 52px; font-size: 1.05rem;
}
/* Which way the button goes is said twice: by colour, and by which side of the
   card it sits on. Scanning a column of cards for who is still out then needs
   no reading at all. Still 12rem and 52px, so it is a thumb-sized target on a
   phone; full width bought nothing but a wider red rectangle. */
.attendance .card > form,
.attendance .card > .check-out { justify-self: start; }
.attendance .card.present > .check-out { justify-self: end; }
/* Opened, the reason and the note need the whole card, not the right half. */
.attendance .card > .check-out[open] { justify-self: stretch; }
.attendance .card > form > button, .attendance .check-out > summary {
  width: auto; min-width: 12rem; min-height: 52px; font-size: 1.05rem; font-weight: 600;
  justify-content: center;
}
.attendance .check-out[open] > summary { width: 100%; }
@media (min-width: 760px) {
  .card.me > form > button, .card.me .check-out > summary { width: auto; min-width: 12rem; }
}
.card.me.present { border-left-color: var(--done); }
.card.me .who { display: flex; align-items: center; gap: .45rem; font-weight: 600; }
.card.me .hours { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.card.me details > summary { cursor: pointer; width: fit-content; }
.card.me .check-out > summary { display: inline-flex; }

/* Two things carry this page across a tent: whose card it is, and the one
   button on it. Everything else is detail, and detail is off by default. */
.attendance .card { border-left: 4px solid var(--line-strong); }
.attendance .card.present {
  border-left-color: var(--done);
  background: color-mix(in srgb, var(--done) 8%, var(--surface));
}
.attendance .who {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.15rem; line-height: 1.2;
}
.attendance .who .dot { width: .7rem; height: .7rem; }
.attendance .state { margin: 0; }
.attendance details > summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; }
.attendance .check-out > summary { width: fit-content; justify-content: center; }
.attendance .spells ul { margin-top: .35rem; gap: .15rem; }

/* Off unless asked for, by the checkbox above the list. Driven by :has() so
   the toggle works on its own; the script only remembers the choice. */
.attendance-wrap .detail { display: none; }
.attendance-wrap:has(.detail-toggle input:checked) .detail { display: grid; gap: .3rem; }
.detail-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  margin: 0 0 .6rem; color: var(--muted); font-size: .85rem; cursor: pointer;
}

.notes .card.resolved { opacity: .6; }
.notes .card.resolved .note-body { text-decoration: line-through; }
.note-form { margin-bottom: 1.25rem; }

/* --- Statistics and charts --- */
/* Wraps to one per line on a narrow phone and sits in a row on anything wider;
   no breakpoint needed, the numbers decide for themselves. */
.stats {
  display: grid; gap: .5rem; margin: .8rem 0;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .55rem .7rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.stat b { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; color: var(--muted); }

.chart-head { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 1.2rem 0 .4rem; }
.chart { margin: 0 0 1rem; }
.chart svg {
  display: block; width: 100%; height: 7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-area { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: none; }
.chart-bar { fill: color-mix(in srgb, var(--accent) 62%, transparent); }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--muted); padding: .25rem .1rem 0;
}
.chart-axis .chart-peak { font-variant-numeric: tabular-nums; }

/* --- Timeline --- */
.tl-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .3rem 0;
}
.tl-row { display: flex; align-items: stretch; min-height: 2rem; }
.tl-label {
  flex: 0 0 8.5rem; position: sticky; left: 0; z-index: 3;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: .3rem .5rem; font-size: .8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-label a { color: var(--text); text-decoration: none; }
.tl-track { position: relative; flex: 1 0 48rem; margin: .12rem 0; }
.tl-ruler { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); }
.tl-hour {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
  font-size: .7rem; color: var(--muted); padding-left: .2rem;
}
.tl-bar {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bar, var(--todo)) 38%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--bar, var(--todo)) 65%, transparent);
  border-radius: 5px; padding: 0 .3rem; overflow: hidden;
  color: var(--text); text-decoration: none; font-size: .7rem; white-space: nowrap;
}
.tl-bar.status-done { opacity: .5; }
.tl-bar.status-in_progress { box-shadow: inset 0 0 0 2px var(--progress); }
.tl-bar.cut-start { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.tl-bar.cut-end { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); z-index: 2; }

@media (min-width: 760px) {
  .tl-label { flex-basis: 15rem; }
  .tl-track { flex-basis: 60rem; }
}
/* Given a desktop, spend it: the track stops insisting on 60rem and takes
   whatever is there, so a whole day fits and the sideways scroll goes away.
   Below this the fixed basis stays, because scrolling a day on a phone is the
   right answer and squeezing seventeen hours into 380px is not. */
@media (min-width: 1180px) {
  .tl-track { flex: 1 1 auto; min-width: 0; }
  .tl-row { min-height: 2.3rem; }
  .tl-bar { font-size: .75rem; }
  .tl-hour { font-size: .75rem; }
}

/* --- The dish, in the corner of the screen --- */
.dish {
  position: fixed; right: clamp(.75rem, 1.4vw, 1.6rem); bottom: clamp(.75rem, 1.4vw, 1.6rem);
  z-index: 15; display: grid; gap: .15rem;
  /* Normally the width of the narrow column. A terminal reporting three
     figures is rare, but it must widen rather than cut the numbers off. */
  width: max-content; min-width: min(23rem, 20vw); max-width: min(28rem, 24vw);
  padding: .5rem clamp(.7rem, .9vw, 1rem);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--done); border-radius: var(--pane-radius);
  font-variant-numeric: tabular-nums; line-height: 1.35;
}
.dish[hidden] { display: none; }
@media (max-width: 1099px), (orientation: portrait) {
  .dish { position: static; width: auto; margin: .6rem clamp(.75rem, 1.4vw, 1.6rem); }
}
.dish.warn { border-left-color: var(--warn); }
.dish.down { border-left-color: var(--danger); }
.dish-body { display: block; }
.dish-lines { display: grid; gap: .2rem; min-width: 0; }
.dish .dish-usage { font-size: clamp(.82rem, .95vw, 1.1rem); color: var(--muted); }
.dish .dish-usage b { color: var(--text); font-weight: 600; }
.dish h2 {
  display: flex; align-items: baseline; gap: .5rem; margin: 0 0 .1rem;
  font-size: clamp(.78rem, .9vw, 1.05rem); text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); font-weight: 600;
}
.dish .dish-state { letter-spacing: 0; text-transform: none; color: var(--text); font-weight: 600; font-size: 1.15em; }
.dish p { margin: 0; display: flex; flex-wrap: wrap; gap: .15rem .8rem; }
.dish .dish-rates {
  font-size: clamp(.9rem, 1.1vw, 1.35rem); font-weight: 500;
  flex-wrap: nowrap; white-space: nowrap; gap: .85rem;
}
.dish .dish-quality { font-size: clamp(.82rem, .95vw, 1.1rem); color: var(--muted); }
.dish .dish-alerts { font-size: clamp(.9rem, 1vw, 1.2rem); color: var(--warn); }
.dish .dish-alerts:empty { display: none; }
/* Made-up numbers have to say so, right above the numbers themselves. */
.dish .dish-demo {
  margin: 0 0 .15rem; padding-bottom: .2rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(.85rem, .95vw, 1.15rem); color: var(--warn);
}
.dish .dish-demo[hidden] { display: none; }
.dish.is-demo { border-left-color: var(--muted); }

/* --- Live update offer --- */
.live {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .6rem);
  display: flex; justify-content: center; pointer-events: none;
}
.live[hidden] { display: none; }
.live button { pointer-events: auto; box-shadow: 0 6px 20px rgb(0 0 0 / .3); }

@media (min-width: 760px) {
  .live { bottom: 1rem; }
}

/* --- Screen view: a television in the tent, and a phone in a pocket --- */
/* The screen is dark whatever the viewer's own theme is, so it pins the whole
   palette rather than only the neutrals. */
body.screen {
  --bg: #0b0e13; --surface: #151a21; --surface-2: #1e242d;
  --text: #f3f6fa; --muted: #93a0b0; --line: #29313b; --line-strong: #3a444f;
  --accent: #63a0e8; --accent-text: #0c1016;
  --todo: #77828f; --progress: #8b83ff; --done: #33b06a;
  --warn: #d99154; --danger: #e5715f;
  --pane-radius: 14px;
  background: var(--bg); color: var(--text); padding-bottom: 0;
}

/* The wrap fills the display; on a television it must never scroll, because
   there is nothing to scroll it with. */
.screen-wrap {
  max-width: none; margin: 0;
  padding: clamp(.75rem, 1.4vw, 1.6rem);
  display: flex; flex-direction: column;
  gap: clamp(.6rem, 1.4vh, 1.2rem);
  min-height: 100vh; min-height: 100dvh;
}

.screen-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: .4rem 1rem; padding: clamp(.45rem, .7vw, .9rem) clamp(.7rem, 1vw, 1.25rem);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--pane-radius);
}
.clock-zone {
  margin-left: .3em; font-size: .42em; font-weight: 600;
  letter-spacing: .08em; color: var(--muted); vertical-align: .5em;
}
.screen-head h1 { font-size: clamp(1.25rem, 2.1vw, 2.4rem); }
/* Clickable, but it stays a heading: the screen is furniture, not a web page. */
.screen-head h1 a { color: inherit; text-decoration: none; }
.clock { display: flex; align-items: baseline; gap: .6rem; margin: 0; }
.clock-time {
  font-size: clamp(1.4rem, 2.6vw, 3rem); font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.clock-date { font-size: clamp(.85rem, 1.2vw, 1.5rem); color: var(--muted); }

.screen-grid, .screen-side, .screen-col { display: grid; gap: clamp(.6rem, 1.1vw, 1.4rem); }
.screen-side { align-content: start; }
.screen-block {
  min-width: 0; display: flex; flex-direction: column;
  padding: clamp(.45rem, .65vw, .85rem);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--pane-radius);
}
.screen-block h2 {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 .45rem; padding: .1rem .25rem .4rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(.78rem, 1vw, 1.15rem); text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); font-weight: 600;
}
.screen-block h2 .tally {
  font-size: .95em; letter-spacing: 0; color: var(--text);
  background: var(--surface-2); border-radius: 999px; padding: .05em .55em;
}

.screen-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(.25rem, .55vh, .5rem); align-content: start; min-height: 0; }
.screen-list li {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: .15rem .8rem; align-items: baseline;
  background: var(--surface-2); border-radius: var(--radius);
  padding: clamp(.4rem, .8vh, .75rem) clamp(.6rem, .8vw, 1rem);
  font-size: clamp(1rem, 1.2vw, 1.45rem);
}
.screen-time { color: var(--muted); font-variant-numeric: tabular-nums; text-transform: uppercase; white-space: nowrap; }
.screen-title { min-width: 0; overflow-wrap: break-word; }
.screen-people { grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem; }
.screen-people:empty { display: none; }
.screen-list.big li { font-size: clamp(1.05rem, 1.55vw, 1.9rem); border-left: 4px solid var(--progress); }
.screen-block.late .screen-list li { border-left: 4px solid var(--warn); }
/* How long it has been sitting there, under the time it should have happened. */
.screen-late {
  display: block; color: var(--warn); font-weight: 600;
  font-size: clamp(.72rem, .82vw, .95rem); text-transform: none;
}
.screen-late:empty { display: none; }

/* One name per line, in callsign order, so the same person is always in the
   same place on the wall. */
.screen-roster { display: grid; gap: .3rem; justify-items: start; padding: .1rem .25rem; }
.screen-roster .chip { font-size: clamp(.85rem, 1.05vw, 1.3rem); padding: .25rem .7rem; }
.screen-empty { color: var(--muted); margin: 0; font-size: clamp(.95rem, 1.15vw, 1.35rem); }
.screen-rest { margin: .4rem 0 0; padding: 0 .25rem; color: var(--muted); font-size: clamp(.8rem, .95vw, 1.1rem); }

/* A phone that opens the screen has no navigation otherwise. */
.screen-back {
  align-self: flex-start; margin-top: auto;
  display: inline-flex; align-items: center; min-height: var(--tap);
  color: var(--muted); text-decoration: none; font-size: .9rem;
}

/* A phone is too narrow for a time column beside the title. */
@media (max-width: 560px) {
  .screen-list li { grid-template-columns: 1fr; gap: .1rem; }
  .screen-time { font-size: .85em; }
  .screen-people { grid-column: auto; }
}

/* A television: three columns, everything on one page, no scrollbar. */
@media (min-width: 1100px) and (orientation: landscape) {
  .screen-wrap { height: 100vh; overflow: hidden; }
  .screen-grid {
    flex: 1; min-height: 0;
    grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr);  /* 40/40/20 */
    /* Without this the row sizes itself to the longest list and the columns
       run off the bottom of the screen instead of being cut off inside. */
    grid-template-rows: minmax(0, 1fr);
  }
  /* What is running takes the room it needs; what is overdue gets the rest, so
     its list ends at the bottom edge rather than mid-column. */
  .screen-col.attention { grid-template-rows: auto minmax(0, 1fr); align-content: stretch; }
  .screen-col { min-height: 0; }
  .screen-block, .screen-list { min-height: 0; overflow: hidden; }
  /* The list fills its column, so a row cut off at the bottom edge fades out
     instead of ending in a hard slice. */
  .screen-list {
    flex: 1;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.75rem), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 1.75rem), transparent);
  }
  .screen-list li { grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: center; }
  .screen-people { grid-column: auto; justify-content: flex-end; }
  /* The narrow column has no room for a third column of names. */
  .screen-side .screen-list li { grid-template-columns: max-content minmax(0, 1fr); }
  .screen-side .screen-people { grid-column: 2; justify-content: flex-start; }
  /* The corner panel floats over this column, so the column stops above it. */
  .screen-side { padding-bottom: var(--dish-space, 0px); }
  /* A long title must not push the rows below it off the bottom edge. */
  .screen-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .screen-back { display: none; }
}
