:root {
  --bg: #f4f4f5; --ink: #1c0f45; --mute: #5d5187; --line: #dcd4fb; --card: #fff;
  --accent: #6c2bff; --accent-ink: #fff; --soft: #e6deff; --pop: #ffd60a; --pop-ink: #1c0f45; --pop-soft: #fff3b0;
  --good: #c4f5cf; --ok: #fff0a0; --bad: #ffc7d1; --danger: #c2183c;
  --bar: var(--pop-soft); --bar-ink: var(--ink); --bar-btn: var(--card); --bar-line: var(--line);
  --moon: block; --sun: none;
  color-scheme: light dark;
}
/* Dark: the system setting, unless the toggle (theme.js) chose light. Keep the two dark blocks the same,
   and put every dark value here, so the toggle can switch it.
   --bar*: the dark --pop-soft looks muddy on the full-width banner, so it takes the bright brand yellow.
   Its buttons inherit the navy text, so they drop the dark card background and take a navy border. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #18181b; --ink: #efeaff; --mute: #a9a0d4; --line: #3a3166; --card: #27272a;
    --accent: #a98bff; --accent-ink: #160b3a; --soft: #32276b; --pop: #ffd60a; --pop-ink: #1c0f45; --pop-soft: #5c4d0a;
    --good: #1d4a2c; --ok: #57480f; --bad: #5a2230; --danger: #ff8a9a;
    --bar: var(--pop); --bar-ink: var(--pop-ink); --bar-btn: transparent; --bar-line: currentColor;
    --moon: none; --sun: block;
  }
}
:root[data-theme=dark] {
  --bg: #18181b; --ink: #efeaff; --mute: #a9a0d4; --line: #3a3166; --card: #27272a;
  --accent: #a98bff; --accent-ink: #160b3a; --soft: #32276b; --pop: #ffd60a; --pop-ink: #1c0f45; --pop-soft: #5c4d0a;
  --good: #1d4a2c; --ok: #57480f; --bad: #5a2230; --danger: #ff8a9a;
  --bar: var(--pop); --bar-ink: var(--pop-ink); --bar-btn: transparent; --bar-line: currentColor;
  --moon: none; --sun: block;
  color-scheme: dark;
}
:root[data-theme=light] { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 300 16px/1.5 Lexend, system-ui, sans-serif; }
main { position: relative; max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
/* Top right of the page column, level with the 42px brand line. */
#theme { position: absolute; top: 25px; right: 16px; width: 40px; padding: 0; display: grid; place-items: center; }
#theme .moon { display: var(--moon); }
#theme .sun { display: var(--sun); }
h1 { font-size: 28px; font-weight: 600; margin: 0 0 16px; }
.brand { font-size: 28px; margin: 0 0 16px; font-weight: 600; }
/* Underline the element that holds the text. When a link inherits the underline, WebKit (every iPhone browser) adds a dark line.
   Longhands: iOS 18 WebKit drops the shorthand with a thickness. */
h1.brand, .brand a { color: var(--ink); text-decoration-line: underline; text-decoration-color: var(--pop); text-decoration-thickness: 6px; text-underline-offset: 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
a { color: var(--accent); }
.note, .mute { color: var(--mute); font-size: 14px; }
.blurb { margin: -6px 0 16px; }
[hidden] { display: none !important; }
/* A full-width bar on the top edge of the window, above the page and the calendar's sticky headers.
   --g lines the text up with main's content column: 728px = 760px max-width minus 2 × 16px padding. */
.banner {
  --g: max(16px, calc((100% - 728px) / 2));
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; margin: 0;
  padding: 12px calc(var(--g) + 40px) 12px var(--g);
  background: var(--bar); color: var(--bar-ink); font-size: 14px; box-shadow: 0 2px 8px rgb(0 0 0 / .15);
}
.banner button:not(.close) { background: var(--bar-btn); border-color: var(--bar-line); }
.banner .close { position: absolute; top: 6px; right: calc(var(--g) - 12px); min-height: 0; padding: 4px 12px; border: 0; background: none; color: inherit; font-size: 20px; line-height: 1; }
/* Schedule text for agents that read the HTML. People see the app that poll.js builds. */
.plain { display: none; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 16px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
input, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select { font-size: 16px; width: 100%; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 40px; }
button { padding: 8px 16px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hp { position: absolute; left: -9999px; }
#msg { min-height: 24px; margin: 8px 0; font-size: 14px; color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 12px 0; }
.row label { flex: 1 1 200px; }

/* create: week calendar */
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.cal-nav .count { margin-left: auto; font-weight: 500; }
.cal { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.cal table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.cal th { font-size: 12px; font-weight: 500; color: var(--mute); }
.cal thead th { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 6px 2px; border-bottom: 1px solid var(--line); }
.cal thead th:first-child { width: 52px; }
.cal thead th span { display: block; }
.cal thead th .wd { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--ink); }
.cal tbody th { width: 52px; text-align: right; padding: 0 6px; vertical-align: top; line-height: 1; white-space: nowrap; }
.cal td { padding: 0; border-left: 1px solid var(--line); }
.cal tr.hour td { border-top: 1px solid var(--line); }
.cal td button { display: block; width: 100%; height: 26px; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; font-size: 12px; font-weight: 500; }
.cal.fine td button { height: 20px; }
.cal.coarse td button { height: 44px; }
/* Touch screens keep :hover on the last tapped cell, so only real pointers get a hover colour. */
@media (hover: hover) { .cal td button:hover:not(:disabled):not(.on) { background: var(--soft); } }
.cal td button.span { background: var(--pop-soft); }
.cal td button.on { background: var(--pop); color: var(--pop-ink); }
.cal td button:disabled { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--line) 4px 5px); opacity: .5; }
.cal td button.taken:disabled { background: var(--soft); color: var(--ink); opacity: 1; }
#adding { margin-bottom: 16px; }
/* Phones: all days in one strip, 3 on screen. A swipe stops at the next day. The time column stays put.
   Keep 600px, 3 and 52px in step with create.js. */
@media (max-width: 600px) {
  .cal { scroll-snap-type: x mandatory; scroll-padding-left: 52px; }
  .cal table { width: calc(52px + (100% - 52px) * var(--days) / 3); }
  /* WebKit (all iPhone browsers) ignores a snap area out of view in the other axis, and it places a sticky
     header at its unstuck spot. Below 8:00 that spot is off screen, so the bottom margin stretches the area down the column. */
  .cal thead th + th { scroll-snap-align: start; scroll-snap-stop: always; scroll-margin-bottom: 9999px; }
  .cal th:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: inset -1px 0 var(--line); }
  .cal thead th:first-child { z-index: 3; }
}

/* schedule: answers table */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
#grid { border-collapse: collapse; width: 100%; font-size: 14px; }
.answers-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 8px; }
.answers-head h2 { margin: 0; }
.answers-head .actions { display: flex; gap: 8px; }
#widen { display: none; }
#widen[aria-pressed=true] { background: var(--soft); }
/* Wide windows: the table can break out of the 760px column to the window edges, minus 16px. */
@media (min-width: 800px) {
  #widen { display: block; }
  .scroll.full { margin-inline: calc(50% - 50vw + 16px); }
}
#grid th, #grid td { padding: 6px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
#grid thead th { font-weight: 500; vertical-align: bottom; }
#grid thead small { display: block; font-size: 12px; font-weight: 300; color: var(--mute); }
#grid thead small .unconfirmed { display: block; color: var(--danger); }
#grid tbody th { text-align: left; font-weight: 400; position: sticky; left: 0; background: var(--card); }
#grid tr.day th { font-weight: 600; background: var(--bg); text-align: left; }
/* The day cell spans the whole row, so it scrolls. Its text sticks to the left edge. 10px = cell padding. */
#grid tr.day span { position: sticky; left: 10px; display: inline-block; }
#grid tr.all th:first-child { box-shadow: inset 4px 0 var(--accent); font-weight: 600; }
#grid td.c0 { background: var(--good); }
#grid td.c1 { background: var(--ok); }
#grid td.c2 { background: var(--bad); }
#grid td.no { color: var(--mute); }
#grid input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
#grid button.x { min-height: 0; padding: 0 6px; font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--mute); margin: 8px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.legend .c0 { background: var(--good); } .legend .c1 { background: var(--ok); } .legend .c2 { background: var(--bad); }
#final { background: var(--pop); color: var(--pop-ink); padding: 12px 16px; border-radius: 8px; font-weight: 600; }
#grid tr.final th:first-child { background: var(--pop); color: var(--pop-ink); font-weight: 600; }
#bestlist { margin: 0; padding-left: 20px; }
#admin { padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
footer { max-width: 728px; margin: 0 auto; padding: 0 16px 24px; font-size: 14px; color: var(--mute); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc th, .doc td { padding: 6px 8px 6px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc li { margin-bottom: 4px; }
.prompt { padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
