:root {
  color-scheme: light;
  --surface-0: #f3f2ee;
  --surface-1: #fcfcfb;
  --border: #e2e0d9;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6f6e69;
  --series-1: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --level-0: #86b6ef;
  --level-1: #3987e5;
  --level-2: #1c5cab;
  --level-3: #0d366b;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --series-1: #3987e5;
    --danger: #f97066;
    --level-0: #184f95;
    --level-1: #2a78d6;
    --level-2: #6da7ec;
    --level-3: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #2e2e2c;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --series-1: #3987e5;
  --danger: #f97066;
  --level-0: #184f95;
  --level-1: #2a78d6;
  --level-2: #6da7ec;
  --level-3: #b7d3f6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.45;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.25;
  text-wrap: balance;
}

h2 {
  margin: 32px 0 12px;
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Voting buttons */
.choices { display: grid; gap: 10px; }

.choice {
  width: 100%;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.choice:hover:not(:disabled) { border-color: var(--series-1); }
.choice[aria-pressed="true"],
.choice[aria-checked="true"] {
  border-color: var(--series-1);
  background: var(--series-1);
  color: var(--accent-ink);
  font-weight: 600;
}
.choice:disabled { cursor: not-allowed; opacity: 0.6; }
.choice:focus-visible { outline: 3px solid var(--series-1); outline-offset: 2px; }

.note { min-height: 1.5em; margin: 14px 0 0; color: var(--text-secondary); }
.note.error { color: var(--danger); }

.status { margin-top: 32px; color: var(--text-muted); font-size: 0.8rem; }
.status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status.live::before { background: var(--series-1); }

/* Results: one horizontal bar per option, anchored at a shared baseline */
.results { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.result-label { display: block; margin-bottom: 4px; color: var(--text-primary); }
.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--border);
}
.result-bar {
  display: block;
  height: var(--bar, 20px);
  flex: none;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
  transition: width 300ms ease-out;
}
.result-bar.empty { min-width: 0; }
.result-value {
  flex: none;
  white-space: nowrap;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .result-bar, .choice { transition: none; }
}

/* Instructor view, sized for a projector */
.host main { max-width: 1200px; padding-top: 40px; }
.host h1 { font-size: clamp(1.6rem, 3.2vw, 2.6rem); margin-bottom: 8px; }
.host .meta { margin: 0 0 32px; color: var(--text-secondary); font-size: 1.1rem; }
.host .results { gap: 22px; --bar: 36px; font-size: 1.25rem; }
.host-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 48px;
  align-items: start;
}
.join { text-align: center; }
.join .qr {
  display: inline-block;
  padding: 14px;
  border-radius: var(--radius);
  background: #ffffff;
}
.join .qr img, .join .qr canvas { display: block; }
.join p { margin: 12px 0 0; color: var(--text-secondary); }
.join .join-url { color: var(--text-primary); font-weight: 600; font-size: 1.1rem; word-break: break-all; }

.controls {
  margin-top: 48px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}
.controls summary { cursor: pointer; color: var(--text-secondary); font-weight: 600; }
.controls label { display: block; margin-top: 16px; color: var(--text-secondary); font-size: 0.9rem; }
.controls input, .controls textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-0);
  color: var(--text-primary);
  font: inherit;
}
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.buttons button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-0);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}
.buttons button.primary { border-color: var(--series-1); background: var(--series-1); color: var(--accent-ink); }

@media (max-width: 800px) {
  .host-grid { grid-template-columns: 1fr; }
  .join { order: -1; }
}

/* Shared buttons and links */
.button {
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.button.primary { border-color: var(--series-1); background: var(--series-1); color: var(--accent-ink); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button:focus-visible, .buttons button:focus-visible { outline: 3px solid var(--series-1); outline-offset: 2px; }

.choice.link { display: block; font-weight: 600; text-decoration: none; }
.choice.link span { display: block; margin-top: 2px; color: var(--text-secondary); font-size: 0.9rem; font-weight: 400; }

/* Survey */
.field { display: block; margin-top: 18px; color: var(--text-secondary); font-size: 0.9rem; font-weight: 600; }
.field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-weight: 400;
}
.field input:focus-visible { outline: 3px solid var(--series-1); outline-offset: 2px; }
.fine-print { margin: 16px 0 0; color: var(--text-muted); font-size: 0.85rem; }
.lead { color: var(--text-secondary); font-size: 1.05rem; }
.hint { margin: -14px 0 18px; color: var(--text-muted); font-size: 0.9rem; }
.options { display: grid; gap: 10px; }
.choice.radio, .choice.check { display: flex; align-items: flex-start; gap: 12px; }
.choice.radio::before, .choice.check::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid var(--text-muted);
  background: var(--surface-1);
}
.choice.radio::before { border-radius: 50%; }
.choice.check::before { border-radius: 4px; }
.choice[aria-checked="true"]::before {
  border-color: var(--accent-ink);
  background: var(--accent-ink);
  box-shadow: inset 0 0 0 3px var(--series-1);
}
.options.segmented { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.options.segmented .choice { display: block; padding: 10px 4px; font-size: 0.82rem; line-height: 1.2; text-align: center; }
.options.segmented .choice::before { display: none; }
.grid-question { display: grid; gap: 18px; }
.grid-label { margin: 0 0 6px; font-weight: 600; }
.follow-up { margin-top: 28px; }
.follow-up h2 { margin: 0 0 18px; color: var(--text-primary); font-size: 1.15rem; }
.survey textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  resize: vertical;
}
.survey textarea:focus-visible { outline: 3px solid var(--series-1); outline-offset: 2px; }
.progress { margin: 0 0 20px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 3px; background: var(--border); }
.progress-fill { width: 0; height: 100%; background: var(--series-1); transition: width 200ms; }
.progress-label { margin: 6px 0 0; color: var(--text-muted); font-size: 0.8rem; }
.survey-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface-0);
}
.survey-nav .primary { min-width: 8em; margin-left: auto; }

/* Survey results */
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px 48px; align-items: flex-start; }
.results-head .buttons { margin-top: 0; }
.results-page .meta { margin-bottom: 16px; }
.cards { display: grid; gap: 24px; margin-top: 32px; }
.card { padding: 24px 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.card h2 { margin: 0 0 4px; color: var(--text-primary); font-size: 1.25rem; }
.card h3 { margin: 24px 0 4px; font-size: 1rem; }
.card-meta { margin: 0 0 16px; color: var(--text-muted); font-size: 0.85rem; }
.results-page .results { --bar: 22px; gap: 12px; font-size: 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 14px; color: var(--text-secondary); font-size: 0.9rem; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.stacks { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; --bar: 22px; }
.stack-row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex: none; gap: 2px; width: calc(100% - 4.5em); height: var(--bar); }
.segment { flex-basis: 0; min-width: 2px; }
.segment:last-child { border-radius: 0 4px 4px 0; }
.level-0 { background: var(--level-0); }
.level-1 { background: var(--level-1); }
.level-2 { background: var(--level-2); }
.level-3 { background: var(--level-3); }
details summary { margin-top: 14px; color: var(--text-secondary); cursor: pointer; }
.data-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table td { color: var(--text-secondary); }
.texts { display: grid; gap: 8px; margin: 12px 0 0; padding-left: 20px; }

/* Wide screens: label beside each bar, so long questions fit on one projector screen */
@media (min-width: 900px) {
  .results-page .results li, .results-page .stacks li {
    display: grid;
    grid-template-columns: minmax(12em, 22em) minmax(0, 1fr);
    gap: 20px;
    align-items: center;
  }
  .results-page .result-label { margin-bottom: 0; }
}

.presenting .results-head, .presenting .gate { display: none; }
.presenting .cards { margin-top: 0; }
.presenting .card { padding: 0; border: none; background: none; }
.presenting .card h2 { margin-bottom: 8px; font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.25; }
.presenting .card-meta { font-size: 1rem; }
.presenting .results { --bar: 26px; gap: 10px; font-size: 1.1rem; }
.presenting .stacks { --bar: 26px; gap: 10px; font-size: 1.1rem; }
.presenting .card h3 { margin-top: 18px; font-size: 1.15rem; }
.presenting .legend { font-size: 1.05rem; }
.present-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
}
.present-bar button { padding: 4px 10px; border: none; background: none; color: var(--text-primary); font: inherit; font-size: 1.05rem; cursor: pointer; }

a.button { display: inline-block; text-decoration: none; }
.buttons { align-items: center; }
.button-link { color: var(--text-secondary); font-size: 0.95rem; }

/* Week landing pages */
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.session-meta { margin: -12px 0 28px; color: var(--text-secondary); }
.cta {
  display: block;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--series-1);
  color: var(--accent-ink);
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
}
.cta span { display: block; margin-top: 4px; font-size: 0.9rem; font-weight: 400; opacity: 0.9; }
.cta:focus-visible { outline: 3px solid var(--series-1); outline-offset: 3px; }
.live-count { min-height: 1.4em; margin: 10px 0 28px; color: var(--text-secondary); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.agenda { display: grid; gap: 10px; margin: 0; padding-left: 22px; color: var(--text-secondary); }
.agenda strong { color: var(--text-primary); }

/* Homework page */
.week .lead a, .agenda a { color: var(--series-1); }
.prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}
.prompt code { flex: 1 1 16em; color: var(--text-primary); font-size: 0.95rem; overflow-wrap: anywhere; }
.prompt .button { padding: 6px 14px; font-size: 0.9rem; }
.agenda li + li { margin-top: 2px; }
ul.agenda { padding-left: 20px; }
.choices.spaced { margin-top: 32px; }
