/* verbalquiz — tokens and base styles.
   Palette: chalkboard green, chalk white, butter-yellow chalk.
   Type: Atkinson Hyperlegible Next (body, built for legibility at distance),
   Bricolage Grotesque (display). */

:root {
  --board: #123b32;
  --board-deep: #0d2c25;
  --board-line: rgba(246, 243, 234, 0.14);
  --chalk: #f6f3ea;
  --chalk-dim: rgba(246, 243, 234, 0.7);
  /* Text: at least 4.5:1 on the board. Anything dimmer is for rules only. */
  --chalk-faint: rgba(246, 243, 234, 0.56);
  --butter: #f2c14e;
  --butter-ink: #6b4d00;

  --paper: #eef3ef;
  --paper-raised: #ffffff;
  --paper-line: #d3ddd6;
  --ink: #12302a;
  --ink-soft: #4f635c;
  --ink-faint: #5f706a;

  /* The darker of each pair is for words (4.5:1 on its soft background and
     under white text); the brighter is for fills: bars and dots. */
  --good: #266a4c;
  --good-fill: #2f7d5b;
  --good-soft: #dff1e6;
  --partial: #8a5710;
  --partial-fill: #c98a2b;
  --partial-soft: #fbedd0;
  --bad: #9e3c27;
  --bad-fill: #b8472f;
  --bad-soft: #f8e1db;

  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-body);

  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(18, 48, 42, 0.06), 0 8px 24px rgba(18, 48, 42, 0.08);
  --max: 760px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

body[data-surface="board"] {
  background: var(--board);
  color: var(--chalk);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-variation-settings: "opsz" 96;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--butter);
  outline-offset: 3px;
}

/* ---------- shell ---------- */

.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px calc(40px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.wordmark .mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--board);
  display: grid;
  place-items: center;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 500;
}

.nav a[aria-current="page"] {
  background: var(--board);
  color: var(--chalk);
}

@media (max-width: 480px) {
  /* Phones: the bar must never widen the page; wrap instead. */
  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .wordmark {
    font-size: 1.2rem;
  }

  .nav {
    gap: 0;
    margin-left: auto;
  }

  .nav a {
    padding: 6px 10px;
    font-size: 0.95rem;
  }
}

/* Safety net: no page should ever scroll sideways. */
html,
body {
  overflow-x: clip;
}

/* ---------- primitives ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  background: var(--board);
  color: var(--chalk);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

.btn:hover {
  background: var(--board-deep);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  background: var(--paper-line);
  border-color: transparent;
  color: var(--ink-faint);
  cursor: default;
  transform: none;
}

body[data-surface="board"] .btn:disabled,
.on-board .btn:disabled {
  background: rgba(246, 243, 234, 0.12);
  color: var(--chalk-faint);
}

.btn-butter {
  background: var(--butter);
  color: var(--butter-ink);
}

.btn-butter:hover {
  background: #eab73f;
}

.btn-ghost {
  background: transparent;
  border-color: var(--paper-line);
  color: var(--ink);
}

.btn-ghost:hover {
  background: rgba(18, 48, 42, 0.05);
}

.btn-big {
  min-height: 64px;
  padding: 14px 28px;
  font-size: 1.15rem;
}

.btn-small {
  min-height: 44px;
  padding: 6px 16px;
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.field label {
  font-weight: 700;
  font-size: 0.95rem;
}

.field .hint {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.input,
textarea.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--paper-line);
  background: var(--paper-raised);
  min-height: 48px;
}

textarea.input {
  resize: vertical;
  line-height: 1.45;
}

.input:focus {
  border-color: var(--board);
  outline: none;
  box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.45);
}

.card {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--ink-soft);
}

.faint {
  color: var(--ink-faint);
}

.eyebrow {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

body[data-surface="board"] .eyebrow {
  color: var(--chalk-dim);
}

.error {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 500;
}

.notice {
  background: var(--partial-soft);
  color: #6b4d00;
  border-radius: var(--radius);
  padding: 12px 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(18, 48, 42, 0.08);
  color: var(--ink-soft);
}

.chip-correct {
  background: var(--good-soft);
  color: var(--good);
}

.chip-partial {
  background: var(--partial-soft);
  color: var(--partial);
}

.chip-incorrect {
  background: var(--bad-soft);
  color: var(--bad);
}

.chip-skipped {
  background: rgba(18, 48, 42, 0.08);
  color: var(--ink-soft);
}

.chip-building {
  background: var(--partial-soft);
  color: var(--partial);
}

.chip-ready {
  background: var(--good-soft);
  color: var(--good);
}

.chip-failed {
  background: var(--bad-soft);
  color: var(--bad);
}

.chip-active {
  background: var(--partial-soft);
  color: var(--partial);
}

.chip-ended {
  background: var(--good-soft);
  color: var(--good);
}

.chip-abandoned {
  background: rgba(18, 48, 42, 0.08);
  color: var(--ink-soft);
}

.list {
  display: grid;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.list-item:hover {
  background: #fbfdfb;
}

.list-item .title {
  font-weight: 700;
}

.list-item .meta {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.section {
  margin-top: 36px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  /* The note drops under the heading and reads as a note, not as body copy. */
  .section-head {
    display: grid;
    justify-content: start;
    gap: 2px;
  }

  .section-head > :not(h2) {
    font-size: 0.95rem;
  }
}

/* ---------- home: the board you talk to ---------- */

.hero-board {
  margin-top: 8px;
  padding: clamp(22px, 4vw, 36px);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(246, 243, 234, 0.07), transparent 55%), var(--board);
  color: var(--chalk);
  display: grid;
  gap: 22px;
  box-shadow: var(--shadow);
}

.hero-board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Two ways in, side by side where there is room and stacked on a phone. */
.hero-board-actions .btn {
  flex: 1 1 250px;
}

.hero-board .btn-ghost {
  color: var(--chalk);
  border-color: var(--chalk-faint);
}

.hero-board .btn-ghost:hover {
  background: rgba(246, 243, 234, 0.08);
  border-color: var(--chalk);
}

.hero-board-note {
  color: var(--chalk-dim);
  max-width: 56ch;
}

.icon {
  flex: none;
}

/* ---------- small form pieces ---------- */

.pills {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
  min-width: 0;
}

.pills legend {
  padding: 0;
  margin-bottom: 8px;
  font-weight: 700;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  cursor: pointer;
}

.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--paper-line);
  background: var(--paper-raised);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pill input:checked + span {
  background: var(--board);
  border-color: var(--board);
  color: var(--chalk);
}

.pill input:focus-visible + span {
  outline: 3px solid var(--butter);
  outline-offset: 3px;
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-soft);
  border: 1.5px dashed var(--paper-line);
  border-radius: var(--radius-lg);
}

/* ---------- welcome ---------- */

.welcome {
  padding-top: 6vh;
  display: grid;
  gap: 36px;
}

.welcome-pitch {
  display: grid;
  gap: 28px;
  align-content: start;
}

/* The product in three lines: a quiz that talks, on the board it happens on.
   (The selectors name body and figure to outrank the paper-surface transcript
   colours further down.) */
.welcome-board {
  margin: 0;
  padding: clamp(22px, 4vw, 40px);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(246, 243, 234, 0.07), transparent 55%), var(--board);
  color: var(--chalk);
  display: grid;
  gap: 18px;
  align-content: center;
  box-shadow: var(--shadow);
}

body figure.welcome-board .script-line .who {
  color: var(--chalk-faint);
}

body figure.welcome-board .script-line.quiz .who {
  color: var(--butter);
}

body figure.welcome-board .script-line .what {
  color: var(--chalk-dim);
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
}

body figure.welcome-board .script-line.you .what {
  color: var(--chalk);
}

@media (min-width: 1000px) {
  /* Wide screens: the pitch on the left, the board filling the right, in a
     frame wider than the reading column the rest of the app uses. */
  .shell:has(.welcome) {
    max-width: 1140px;
  }

  .welcome {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 56px;
  }

  .welcome-board {
    min-height: 420px;
  }
}

.welcome h1 {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  max-width: 12ch;
}

.welcome h1 em {
  font-style: normal;
  color: var(--good);
}

.welcome .lede {
  max-width: 44ch;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

/* ---------- new quiz ---------- */

.ask {
  position: relative;
}

.ask textarea {
  font-size: 1.25rem;
  min-height: 140px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
}

.ask-details {
  margin-top: 10px;
}

.ask-details summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 6px 0;
}

/* ---------- materials: uploader and library ---------- */

.dropzone {
  border: 2px dashed var(--paper-line);
  border-radius: var(--radius-lg);
  padding: 26px 18px;
  text-align: center;
  background: var(--paper-raised);
  transition:
    border-color 120ms ease,
    background 120ms ease;
}

.dropzone.compact {
  padding: 16px 14px;
}

.dropzone-actions {
  justify-content: center;
  margin-top: 12px;
}

.dropzone.compact .dropzone-actions {
  margin-top: 0;
}

.dropzone.over {
  border-color: var(--board);
  background: var(--good-soft);
}

.dropzone-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
}

.dropzone-hint {
  margin-top: 10px;
  font-size: 0.92rem;
}

@media (hover: none) {
  /* Nothing to drop or paste with on a touch screen. */
  .dropzone-hint {
    display: none;
  }
}

.upload-rows {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.upload-row {
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.upload-row-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
}

.upload-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.upload-error {
  color: var(--bad);
  font-weight: 500;
}

.materials {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.material {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  min-width: 0;
}

.material.selectable {
  cursor: pointer;
}

.material {
  transition: border-color 120ms ease;
}

.material.selected {
  border-color: var(--board);
  box-shadow:
    inset 5px 0 0 var(--butter),
    var(--shadow);
}

.material.failed {
  background: var(--bad-soft);
}

.material-check {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--board);
}

.material-body {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.material-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
}

.material-title {
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.material-title:hover {
  text-decoration: underline;
}

.material-meta,
.material-summary {
  font-size: 0.95rem;
}

.material-summary {
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.material-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--partial);
  font-weight: 500;
  font-size: 0.95rem;
}

.build-pulse.dark {
  background: var(--partial-fill);
  flex: none;
}

.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.action-bar {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--board);
  color: var(--chalk);
  box-shadow: 0 10px 30px rgba(18, 48, 42, 0.3);
}

.action-bar .btn-ghost {
  color: var(--chalk);
  border-color: var(--board-line);
}

.action-bar-note {
  color: var(--chalk-dim);
  font-size: 0.92rem;
}

/* The bar floats over the page; leave room so it never sits on the last card. */
.shell:has(.action-bar) {
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

body[data-surface="board"] .btn-ghost {
  border-color: var(--board-line);
  color: var(--chalk);
}

body[data-surface="board"] .btn-ghost:hover {
  background: rgba(246, 243, 234, 0.08);
}

.outline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

/* Topic on the left, its pages on the right, like a table of contents. */
.outline li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--paper-line);
}

.outline li:first-child {
  border-top: 0;
}

.outline-range {
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (min-width: 1320px) {
  /* Wide screens have an empty margin beside the reading column. The outline
     lives there and stays put, so a ninety-slide deck always has its table of
     contents in view. It floats out of the column rather than taking space. */
  .outline-aside {
    float: left;
    position: sticky;
    top: 24px;
    width: 250px;
    margin: 36px 0 0 -290px;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    font-size: 0.95rem;
  }

  .outline-aside h2 {
    font-size: 1.15rem;
  }

  .outline-aside .outline li {
    padding: 6px 0;
  }
}

.pages {
  display: grid;
  gap: 12px;
}

.page-text {
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  scroll-margin-top: 16px;
  min-width: 0;
}

.page-text header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.page-text pre {
  margin: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-text:target,
.page-text.flash {
  outline: 3px solid var(--butter);
}

.page-text pre.folded {
  max-height: 9.5em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 72%, transparent);
}

/* ---------- build panel (a quiz being written) ---------- */

.build {
  margin-top: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--board);
  color: var(--chalk);
  display: grid;
  gap: 14px;
}

.build-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

/* Three steps on one line at every width: a step that wraps alone to a second
   row stops reading as a sequence. */
.build-stages {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.build-stages li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--chalk-faint);
  border: 1.5px solid var(--board-line);
}

.build-stages li.done {
  color: var(--chalk-dim);
}

.build-stages li.active {
  background: var(--butter);
  border-color: var(--butter);
  color: var(--butter-ink);
}

.build-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--butter-ink);
  animation: breathe 1.6s ease-in-out infinite;
}

.build-clock {
  font-variant-numeric: tabular-nums;
  color: var(--chalk-dim);
  font-size: 0.95rem;
}

.build-progress {
  display: grid;
  gap: 6px;
}

.build-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.build-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  /* Room for a few lines so the panel doesn't jump as they arrive, filled
     from the top so there is never a hole above the first one. */
  min-height: 3.2em;
  align-content: start;
  font-size: 0.98rem;
}

.build-feed li {
  display: grid;
  grid-template-columns: 1.4em 1fr;
  color: var(--chalk-faint);
  overflow-wrap: anywhere;
}

.build-feed li.latest {
  color: var(--chalk);
  animation: rise 300ms ease-out;
}

.build-feed .glyph {
  color: var(--butter);
}

.build-note {
  color: var(--chalk-dim);
  font-size: 0.92rem;
}

@media (max-width: 480px) {
  .build-stages {
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    gap: 4px;
  }

  .build-stages li {
    padding: 4px 9px;
    gap: 6px;
  }
}

/* The same pulse, standing alone on the board beside a sentence. */
.question-big .build-pulse {
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-right: 0.2em;
  vertical-align: middle;
  background: var(--butter);
}

/* ---------- quiz detail ---------- */

/* Out loud is the way in; on screen is the quieter alternative beside it. */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.hero-actions .btn-big {
  flex: 1 1 260px;
}

.question-row {
  padding: 14px 0;
  border-top: 1px solid var(--paper-line);
}

.question-row:first-child {
  border-top: 0;
}

.question-row summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: baseline;
}

/* Says "this opens", and where the question came from before it does. */
.question-row summary::after {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-right: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 140ms ease;
  grid-column: 3;
  grid-row: 1;
}

.question-row[open] summary::after {
  transform: translateY(0.1em) rotate(-135deg);
}

.question-row .from {
  grid-column: 2;
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-weight: 500;
}

.question-row summary::-webkit-details-marker {
  display: none;
}

.question-row .n {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  font-weight: 700;
}

.answer-block {
  margin: 10px 0 0 calc(2ch + 12px);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  display: grid;
  gap: 6px;
}

.answer-block .k {
  font-weight: 700;
}

.sources {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.sources a {
  color: var(--ink-soft);
}

/* ---------- board (voice + screen sessions) ---------- */

.board {
  /* Exactly one screen, never more: the page itself must not scroll, or the
     newest lines and the controls end up below the fold. */
  height: 100vh;
  /* biome-ignore lint/suspicious/noDuplicateProperties: the line above is the
     fallback for browsers without dvh; this is the value that should win. */
  height: 100dvh;
  display: grid;
  /* One column that may shrink: a long quiz title must never widen the page. */
  grid-template-columns: minmax(0, 1fr);
  /* The middle may shrink below its content; that content scrolls instead. */
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: calc(12px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
  max-width: 980px;
  margin: 0 auto;
}

.board-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  color: var(--chalk-dim);
  font-weight: 500;
}

.board-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.board-top-row > .board-title {
  flex: 1 1 0;
}

.board-top-row > .board-status,
.board-top-row > .score {
  flex: none;
}

.board-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-progress {
  display: grid;
  gap: 6px;
}

.board-top .score {
  font-variant-numeric: tabular-nums;
}

.board-main {
  display: grid;
  /* A short board sits in the middle; once it is taller than the screen it
     starts at the top instead, so the first line stays reachable. */
  align-content: safe center;
  gap: 28px;
  padding: 24px 0;
  min-height: 0;
  overflow-y: auto;
  /* The only scroller on the page: flicking it must not drag the page behind. */
  overscroll-behavior: contain;
  /* An absolutely positioned child — a visually hidden legend, say — would
     otherwise be laid out against the viewport and stretch the page. */
  position: relative;
}

.question-big {
  font-size: clamp(1.25rem, 1rem + 2.2vw, 2.9rem);
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: -0.005em;
  max-width: 28ch;
  text-wrap: pretty;
}

/* A forty-word question set in the full size eats a phone screen whole and
   pushes the conversation off it. One step down, still readable across a room. */
.question-big.long {
  font-size: clamp(1.1rem, 0.9rem + 1.8vw, 2.3rem);
  max-width: 34ch;
}

.question-big.entering {
  animation: rise 360ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.board-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--chalk);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--chalk-faint);
}

.dot.listening {
  background: var(--butter);
  animation: breathe 2.4s ease-in-out infinite;
}

.dot.speaking {
  background: var(--chalk);
}

.dot.busy {
  background: var(--butter);
  animation: blink 900ms steps(2, end) infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* The transcript reads like a script: speaker in the margin, line beside it. */
.script {
  display: grid;
  gap: 10px;
  max-height: 34dvh;
  overflow-y: auto;
  padding-right: 6px;
  mask-image: linear-gradient(to bottom, transparent, black 24px);
}

.script-line {
  display: grid;
  grid-template-columns: 4.5ch 1fr;
  gap: 14px;
  align-items: baseline;
  font-size: 1.1rem;
}

/* On the board the middle is the scroller, so the transcript is not one too:
   a box of its own would hide the newest lines inside a second scrollbar. */
.board .script {
  max-height: none;
  overflow: visible;
  padding-right: 0;
  mask-image: none;
}

.script-line .who {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-faint);
}

.script-line.quiz .who {
  color: var(--butter);
}

.script-line .what {
  color: var(--chalk-dim);
}

.script-line.you .what {
  color: var(--chalk);
}

.script-line.pending .what {
  opacity: 0.6;
}

.script-line.sys .what {
  font-style: italic;
  color: var(--chalk-faint);
}

.board-bottom {
  display: grid;
  gap: 12px;
  justify-items: start;
  /* The anchor for the "Latest" button floating above it. */
  position: relative;
}

.board-heard,
.board-pause,
.board-actions,
.board-type {
  width: 100%;
}

/* What the microphone is picking up: a line of the script, pinned to the
   bottom row, where no amount of question or transcript above it can push it
   off the screen. */
.board-heard {
  align-items: end;
  min-height: 2.4em;
  padding-top: 10px;
  border-top: 1px solid var(--board-line);
}

/* Three lines at most, clipped at the TOP: the words that just arrived are the
   ones worth seeing, so the box holds its content against its own bottom edge. */
.board-heard .heard {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  max-height: 4.05em;
  overflow: hidden;
  line-height: 1.35;
  color: var(--chalk);
  overflow-wrap: anywhere;
}

.board-heard .heard.settled {
  color: var(--chalk-dim);
}

.board-heard .heard.hint {
  color: var(--chalk-faint);
  font-style: italic;
}

/* Offered only when the student has scrolled up to read. It floats over the
   foot of the conversation, so nothing shifts when it comes and goes. */
.board-latest {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 1;
  background: var(--board-deep);
  border-color: var(--chalk-faint);
  box-shadow: 0 4px 16px rgba(13, 44, 37, 0.5);
}

.board-actions {
  display: flex;
  gap: 12px;
}

/* A field on the board is chalk on green, enabled or not: the paper-white
   default would hide chalk-coloured text. */
.board .input.board-input,
.board .input.board-input:disabled {
  flex: 1;
  min-width: 140px;
  background: rgba(246, 243, 234, 0.06);
  border-color: var(--chalk-faint);
  color: var(--chalk);
  -webkit-text-fill-color: var(--chalk);
  opacity: 1;
}

.board .input.board-input::placeholder {
  color: var(--chalk-faint);
  -webkit-text-fill-color: var(--chalk-faint);
}

.board .input.board-input:focus {
  border-color: var(--butter);
  box-shadow: none;
}

/* A chip on the board: chalk outline, not a paper-coloured pill. */
.chip-on-board {
  justify-self: start;
  background: transparent;
  border: 1.5px solid var(--butter);
  color: var(--butter);
}

/* An error on the board is outlined, so it informs without outshining the
   one button that matters. */
body[data-surface="board"] .error {
  background: rgba(184, 71, 47, 0.2);
  border: 1.5px solid rgba(246, 201, 189, 0.55);
  color: #f9d9d0;
}

body[data-surface="board"] .notice {
  background: rgba(242, 193, 78, 0.14);
  border: 1.5px solid rgba(242, 193, 78, 0.5);
  color: var(--chalk);
}

/* Nothing on a session screen is a small target, whatever it was elsewhere. */
.board .btn-small {
  min-height: 48px;
  padding: 8px 18px;
  font-size: 1rem;
}

.board-actions .btn {
  flex: 1;
}

/* A phone screen is one screenful of room for everything at once: the board
   spends less of it on air and more on the conversation. */
@media (max-width: 520px) {
  .board {
    padding-left: 16px;
    padding-right: 16px;
  }

  .board-main {
    gap: 16px;
    padding: 14px 0;
  }

  .board .script {
    gap: 8px;
  }

  .board .script-line {
    grid-template-columns: 4ch 1fr;
    gap: 10px;
    font-size: 1rem;
  }
}

/* light-surface versions for the screen session and review */
body:not([data-surface="board"]) .script-line .who {
  color: var(--ink-faint);
}

body:not([data-surface="board"]) .script-line.quiz .who {
  color: var(--partial);
}

body:not([data-surface="board"]) .script-line .what {
  color: var(--ink-soft);
}

body:not([data-surface="board"]) .script-line.you .what {
  color: var(--ink);
}

/* ---------- covered answer (screen mode) ---------- */

/* On the board the answer is the one sheet of paper: face down until asked
   for, then the only bright thing on the screen. */
.covered {
  display: grid;
  gap: 12px;
}

.cover {
  width: 100%;
  min-height: 132px;
  border: 2px dashed var(--chalk-faint);
  border-radius: var(--radius-lg);
  background: rgba(246, 243, 234, 0.04);
  color: var(--chalk);
  font-weight: 700;
  font-size: 1.35rem;
  cursor: pointer;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 20px;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.cover:hover {
  border-color: var(--butter);
  background: rgba(246, 243, 234, 0.07);
}

.cover span {
  font-size: 1rem;
  color: var(--chalk-dim);
  font-weight: 500;
}

.answer-reveal:not([hidden]) {
  display: grid;
  gap: 10px;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  animation: rise 240ms ease-out;
}

.answer-reveal .k {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
}

.answer-reveal .why {
  color: var(--ink-soft);
}

.answer-toggle {
  justify-self: start;
}

.board-answer {
  width: 100%;
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.grade-row .btn {
  min-height: 76px;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
  font-size: 1.15rem;
}

.grade-row .btn small {
  font-weight: 500;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.86);
}

@media (max-width: 520px) {
  /* Phones: one thumb-sized button per row, with the note beside the label. */
  .grade-row {
    grid-template-columns: 1fr;
  }

  .grade-row .btn {
    flex-direction: row;
    gap: 8px;
    min-height: 60px;
  }

  .grade-row .btn small::before {
    content: "· ";
  }
}

.one-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.btn-good {
  background: var(--good);
  color: white;
}

.btn-partial {
  background: var(--partial);
  color: white;
}

.btn-bad {
  background: var(--bad);
  color: white;
}

/* ---------- progress ---------- */

.topic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--paper-line);
}

.topic-row:first-child {
  border-top: 0;
}

.bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: rgba(18, 48, 42, 0.08);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--good-fill);
}

/* The other progress bar: chalk, on the board and in the build panel. Both
   bars live here, plain rules first and modifiers after, so neither depends
   on where in the file it happens to sit. */
.build-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(246, 243, 234, 0.12);
  overflow: hidden;
}

.build-bar > i {
  display: block;
  height: 100%;
  min-width: 10px;
  border-radius: 999px;
  background: var(--butter);
  transition: width 500ms ease;
}

.bar[data-level="low"] > i {
  background: var(--bad-fill);
}

.bar[data-level="mid"] > i {
  background: var(--partial-fill);
}

.build-bar.light {
  background: rgba(18, 48, 42, 0.1);
}

.build-bar.light > i {
  background: var(--board);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1;
}

.stat span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- admin lists: cards at every width, never a sideways scroll ---------- */

.admin-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.admin-item {
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.admin-break {
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .admin-actions .btn {
    flex: 1 1 140px;
    min-height: 44px;
  }
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em;
  background: rgba(18, 48, 42, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ---------- loading, and asking before something is deleted ---------- */

.skeleton {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.skeleton-title,
.skeleton-line {
  height: 18px;
  border-radius: 999px;
  background: rgba(18, 48, 42, 0.09);
  animation: pulse 1.6s ease-in-out infinite;
}

.skeleton-title {
  height: 38px;
  width: min(60%, 340px);
}

.skeleton-line.long {
  width: 92%;
}

.skeleton-line.medium {
  width: 78%;
}

.skeleton-line.short {
  width: 60%;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

body[data-surface="board"] .skeleton-title,
body[data-surface="board"] .skeleton-line {
  background: rgba(246, 243, 234, 0.12);
}

.confirm {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(18, 48, 42, 0.3);
}

.confirm::backdrop {
  background: rgba(13, 44, 37, 0.55);
}

.confirm h2 {
  margin-bottom: 8px;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.confirm-actions .btn {
  flex: 1 1 140px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    /* biome-ignore lint/complexity/noImportantStyles: a motion reset has to beat
       every animation rule above it, and several of those are more specific
       than this one. */
    animation: none !important;
    /* biome-ignore lint/complexity/noImportantStyles: same reason. */
    transition: none !important;
  }
}

@media (max-width: 520px) {
  /* A long answer key shouldn't shout on a narrow screen. */
  .answer-reveal .k {
    font-size: 1.15rem;
  }

  .answer-reveal:not([hidden]) {
    padding: 18px;
  }

  /* Three controls on one row, each label on one line. */
  .board-actions {
    gap: 8px;
  }

  .board-actions .btn {
    padding: 8px 6px;
    font-size: 0.95rem;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  /* On a phone the bar is a slim strip: what will be written, and the button.
     The reassurance about timing is on the quiz page a moment later. */
  .action-bar {
    padding: 10px 12px;
    gap: 8px;
  }

  .action-bar-note {
    display: none;
  }

  .action-bar > .btn,
  .action-bar > .row {
    flex: 1 1 100%;
  }

  .action-bar > .row > .btn-butter {
    flex: 1;
  }
}

/* The end of the questions: up to three choices, side by side where they fit. */
.finish-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.finish-choices .btn {
  min-height: 56px;
}


/* ---------- NeuralColumn settings, runner & notices ---------- */

.notice {
  background: var(--partial-soft);
  color: var(--ink);
  border: 1px solid rgba(138, 87, 16, 0.22);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.95rem;
}

.on-board-ghost {
  color: var(--chalk);
  border-color: var(--board-line);
}

.on-board-ghost:hover {
  background: rgba(246, 243, 234, 0.1);
}

.chip-ok {
  background: var(--good-soft);
  color: var(--good);
}

.chip-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.provider-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--paper-line);
}

.job-card {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--paper-line);
}

.job-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.microbox-host {
  min-width: 0;
}

.microbox-host.ncm-pane:not(.ncm-collapsed) {
  margin-top: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--paper-line);
  overflow: hidden;
  min-height: 360px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--board);
}
