/* The platform layer of the token cascade (specs/design-system.md § 4–5), at
   the adult values. theme.ts merges the audience preset, the institution
   (tenants.theme), the course (circuits.theme) and the learner's own
   accessibility policy over these into one :root block in a <style> element,
   so everything below reads var(--token) and repaints on a theme change.
   Hairlines (1px) and hit targets (44px) are NOT tokens: they never vary. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e2e2df;
  --accent: #1f5f4f;
  --accent-ink: #ffffff;
  --partial: #9dbfb4;
  --soft: #f3f8f6;
  --tag: #ececea;
  --radius: 6px;
  --base: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Derived, not themeable on their own. */
  --focus: #2b6cb0;
  --danger: #8a2d2d;
  /* The verdict's semantic hues (D-026): what a band MEANS, never the brand
     accent, so a course theme cannot turn a fail green. */
  --pass: #1f6f3f;
  --borderline: #9a6200;
  --fail: var(--danger);
  --hero-line: var(--partial);
  --max-width: 44rem;
  --target: 44px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* The type scale and spacing derive from --base in rem: the child preset
     scales everything by changing one token. Media queries below are in rem
     too, and rem in a media query is the browser default, not --base, so the
     breakpoints hold still while the content scales. */
  font-size: var(--base);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 var(--font);
}

#app {
  display: block;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
}

/* --- The Workspace shell (specs/design-system.md § 1) -----------------------
   Three breakpoints, in rem (16px root): desktop ≥ 75rem (1200px) has the
   256px sidebar; tablet 56.25–74.99rem (900–1199px) collapses it to a 72px
   icon rail and the top bar carries the context switcher; phone < 56.25rem
   makes it a drawer behind a 44px menu target. */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "side top"
    "side main";
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-height: 3.5rem;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.05rem;
  padding: 0 0.25rem;
  min-height: var(--target);
  white-space: nowrap;
  flex-shrink: 0;
}
.page-title {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.5rem;
}
.who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 0;
  flex-shrink: 0;
}
.who .btn {
  white-space: nowrap;
}
.who-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}
.menu {
  display: none;
  width: var(--target);
  height: var(--target);
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.topbar-context {
  display: none;
  min-width: 0;
  flex: 0 1 18rem;
}
.topbar-context .context-switcher {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.topbar-context .context-note {
  margin: 0;
}
.topbar-context .context-logo {
  display: none;
}

/* The sidebar is the navigator: context → course → module. */
.sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 0.75rem 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.sidebar li {
  min-width: 0;
}
.nav-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
  padding: 0 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-empty {
  font-size: 0.85rem;
  margin: 0;
  padding: 0 0.75rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--target);
  padding: 0 0.75rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  min-width: 0;
}
.nav-link .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-link .icon {
  flex-shrink: 0;
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg);
}
.nav-link[aria-current="page"] {
  color: var(--text);
  background: var(--soft);
}
.course-list .nav-link {
  font-weight: 500;
  font-size: 0.95rem;
}
.modules {
  margin-left: 1.5rem;
}
.nav-sub {
  font-weight: 500;
  font-size: 0.9rem;
}
.context-switcher {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.context-logo {
  display: block;
  max-height: 2.5rem;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  align-self: flex-start;
}
select.context {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  font-weight: 600;
}
.context-note {
  font-size: 0.8rem;
  margin: 0;
}
.context-note:empty {
  display: none;
}

.content {
  grid-area: main;
  min-width: 0;
}
.content > .wrap {
  padding: 1rem 1.5rem 3rem;
}
.backdrop {
  display: none;
}

/* Tablet: the icon rail. Labels, headings and the course tree are hidden;
   every link keeps its accessible name (aria-label), so the rail is icons to
   the eye and words to a screen reader. The switcher moves to the top bar. */
@media (min-width: 56.25rem) and (max-width: 74.99rem) {
  .shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .sidebar {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .sidebar .nav-label,
  .sidebar .courses,
  .sidebar .sidebar-context {
    display: none;
  }
  .sidebar .nav-link {
    justify-content: center;
    padding: 0;
    width: var(--target);
    margin: 0 auto;
  }
  .topbar-context {
    display: block;
  }
}

/* Phone: the drawer. */
@media (max-width: 56.24rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "main";
  }
  .menu {
    display: inline-flex;
  }
  .topbar {
    padding: 0.4rem 0.6rem;
    gap: 0.35rem;
  }
  .brand {
    font-size: 1rem;
  }
  .page-title,
  .who-email {
    display: none;
  }
  .topbar-context {
    display: block;
    flex: 1 1 4rem;
    min-width: 4rem;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(20rem, 85vw);
    height: 100vh;
    z-index: 20;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: none;
  }
  .drawer-open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, 0.18);
  }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
  }
  .backdrop[hidden] {
    display: none;
  }
  .content > .wrap {
    padding: 1rem;
  }
}

/* Buttons. Every interactive element is at least 44px tall — and a button at
   least 44px wide — at every breakpoint (design-system § 4). The target is
   not a token; a brand cannot shrink it. */
button {
  font: inherit;
}
button,
select,
input,
textarea {
  min-height: var(--target);
}
button {
  min-width: var(--target);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
}
.btn:hover {
  filter: brightness(1.06);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn-ghost {
  background: none;
  color: var(--accent);
}
.btn-link {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 0;
  color: var(--focus);
  cursor: pointer;
  padding: 0 0.25rem;
  font-weight: 600;
  text-align: left;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Landing */
.landing {
  text-align: center;
  padding: 3.5rem 1rem;
}
.landing h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}
.landing p {
  color: var(--muted);
  margin: 0 auto 1.75rem;
  max-width: 28rem;
}

/* Unit list */
.list-title {
  font-size: 1.25rem;
  margin: 0.5rem 0 1rem;
}
.units {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.unit-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
}
.unit-card:hover {
  border-color: var(--accent);
}
.unit-card .t {
  font-weight: 600;
}
.tags {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tag {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--tag);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

/* Assigned courses, above the open catalogue on the landing view. Set apart so
   "this was set for me" is legible at a glance rather than inferred from
   position — and absent entirely when nothing is assigned. */
.assigned {
  border-left: 3px solid var(--accent);
}
.assigned .units {
  margin-top: 0.75rem;
}

/* The learner's course page (VIVA-39): modules, each an ordered list of items
   by kind. A row has the shape of a station row; only the kind label and the
   state are new. The current module (opened from the navigator) is marked. */
.module[aria-current="true"] {
  border-color: var(--accent);
}
.module-coverage {
  font-size: 0.85rem;
}
.items {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: grid;
  gap: 0.5rem;
}
.item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  min-height: var(--target);
}
.item-kind {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--tag);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}
.item-title {
  flex: 1 1 auto;
  font-weight: 600;
  min-width: 0;
  text-align: left;
}
.item-state {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.item-state.done {
  color: var(--accent);
}

/* Unit detail / attempt */
.unit-head h1 {
  font-size: 1.5rem;
  margin: 0.25rem 0 0.75rem;
}
.brief {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The questions themselves — the brief sets the scene, these are what is asked,
   so they read heavier than the brief, not lighter. */
.prompts-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}
.stimulus-figure {
  margin: 1rem 0 0;
}
.stimulus {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
/* Shown in place of a stimulus image that failed to load. Deliberately quiet —
   it is information, not an alarm — but it must be visible: silently removing
   the image left a station saying "look at the image" rendering nothing. */
.stimulus-failed {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.answer-label {
  display: block;
  font-weight: 600;
  margin: 1.5rem 0 0.4rem;
}
textarea {
  width: 100%;
  min-height: 9rem;
  resize: vertical;
  font: inherit;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Confidence capture (VIVA-31) — asked before the answer is sent. A row of three
   options, each a real button so it carries the same 44px hit target as every
   other control (--target); the selected one is filled like a primary button. */
.confidence-label {
  display: block;
  font-weight: 600;
  margin: 1.5rem 0 0.4rem;
}
.confidence-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.confidence-option {
  min-height: var(--target);
  min-width: var(--target);
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.confidence-option:hover {
  filter: brightness(1.06);
}
.confidence-option.selected {
  background: var(--accent);
  color: var(--accent-ink);
}
.confidence-option:disabled {
  opacity: 0.55;
  cursor: default;
}

/* The chat (VIVA-72, D-023): the examiner's turn, then the candidate's, then
   the next. Examiner turns sit left on the page surface, the candidate's own
   words right on the soft tint — two speakers, told apart by position and
   tone, never by colour alone (the speaker label is always there). Text is
   pre-wrap so a typed line break stays a line break, and wraps anywhere so a
   long unbroken token cannot widen the page at phone width. */
.chat {
  margin-top: 0.25rem;
}
.turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.turn {
  max-width: 44rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
  /* Room above a turn scrolled to the top of the view (VIVA-84). */
  scroll-margin-top: 0.75rem;
}
.turn-examiner {
  align-self: flex-start;
  background: var(--surface);
}
.turn-candidate {
  align-self: flex-end;
  background: var(--soft);
}
.speaker {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.turn-text {
  margin: 0;
  white-space: pre-wrap;
}
.turn-progress,
.chat-note {
  margin: 1rem 0 0;
}

/* The Begin gate (VIVA-97): on a fresh voice-on unit the one thing to do is
   Begin, so it is the crown-jewel control — a hero button straight under the
   opener, filled with the accent at the mic bar's weight, with the helper
   line beneath it, subordinate. Same width as a turn, so it reads as the
   next thing in the conversation. */
.begin-gate {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  max-width: 44rem;
  margin-top: 0.75rem;
}
.begin-gate > [role="status"]:empty {
  display: none;
}
.btn-hero {
  min-height: 3.5rem;
  padding: 0.9rem 1.75rem;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, filter 0.2s ease;
}
.btn-hero .icon {
  font-size: 0.85em;
}
.btn-hero:active {
  transform: scale(0.98);
}
.begin-help {
  margin: 0;
  font-size: 0.95rem;
}

/* The difficulty level select (D-039): a three-stop segmented control on the
   Begin gate — how much the examiner helps. Guided → Practice → Exam, left to
   right, hardest on the right. Deliberately plain; the game-like visual is a
   later polish. */
.difficulty-heading {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.difficulty-picker {
  display: flex;
  gap: 0.4rem;
}
.difficulty-option {
  flex: 1 1 0;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text, inherit);
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #cbd5e1);
  border-radius: var(--radius, 8px);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.difficulty-option:hover {
  border-color: var(--accent, #2563eb);
}
.difficulty-option.is-selected {
  color: #fff;
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
}
.difficulty-help {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.9rem;
}

/* The level stamp on a result (D-039): a coloured badge + a note, so a guided or
   practice score is never read as an exam-standard mark. */
.difficulty-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.7rem;
  margin: 0 0 0.75rem;
}
.difficulty-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  color: #fff;
  background: var(--accent, #2563eb);
}
.difficulty-badge.difficulty-guided {
  background: #0d9488;
}
.difficulty-badge.difficulty-exam {
  background: #b91c1c;
}
.difficulty-note-text {
  font-size: 0.9rem;
}

/* The bar above the turns (VIVA-80): the resume note and, while there is an
   in-progress attempt to leave, the Start over control — a quiet, secondary
   action beside the note, never in the composer with Send. */
.chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.chat-bar:empty {
  display: none;
}
.chat-bar .start-over {
  margin: 1rem 0 0 auto;
  min-height: var(--target);
}

/* Jump to latest (VIVA-84, D-028): offered when a turn lands while the
   learner has scrolled up to read. Sticky at the foot of the chat, so it
   floats at the bottom of whatever scrolls the chat (the page today, a
   bounded transcript later) while there is chat below the fold, and is out
   of the way — hidden — the moment they are at the newest turn. */
.jump-latest {
  position: sticky;
  bottom: 1rem;
  z-index: 5;
  display: flex;
  width: max-content;
  margin: 0.75rem auto 0;
  min-height: var(--target);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.jump-latest[hidden] {
  display: none;
}

/* Examiner voice-out controls (VIVA-73): play / replay + pause on a spoken
   examiner turn. A quiet, secondary control cluster under the prompt text.
   The candidate's record-in-takes control (VIVA-74/79) shares the look: the
   same quiet cluster, under the answer box. */
.voice-controls,
.mic-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.voice-btn,
.mic-btn {
  min-height: var(--target);
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.voice-btn:hover,
.mic-btn:hover {
  background: var(--soft);
}
.voice-btn:disabled,
.mic-btn:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.6;
}

/* The voice-first composer (VIVA-81, D-025 amendment). With the examiner's
   voice on the turn reads as a spoken viva, not a form: the pending question
   is the "now speaking" card, the mic is the fixed bar at the foot of the
   viewport (VIVA-87), the draft segments are dashed candidate bubbles, and
   Send is a pill in the composer. Same tokens as everything else; the
   recording colour is the existing state colour (--danger), not a new
   accent. Every control keeps the 44px --target. */

/* The now-speaking card: the question being answered, set apart from the
   quiet history above it. The speaking indicator is driven off the card's
   own Pause control — enabled and reading "Pause playback" exactly while
   audio plays — so no script has to mirror the playback state. */
.turn-now {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.turn-now .speaker {
  display: inline-block;
}
.now-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  vertical-align: top;
}
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.8rem;
}
.eq i {
  display: block;
  width: 3px;
  height: 0.3rem;
  border-radius: 1px;
  background: currentColor;
}
.now-live {
  display: none;
}
.turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .now-live {
  display: inline;
}
.turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .now-idle {
  display: none;
}
.turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .eq i {
  animation: eq 0.8s ease-in-out infinite alternate;
}
.turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .eq i:nth-child(2) {
  animation-delay: 0.2s;
}
.turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .eq i:nth-child(3) {
  animation-delay: 0.4s;
}

/* The fixed mic bar (VIVA-87, D-029): the one recording surface, pinned to
   the foot of the viewport so it stays put while the candidate scrolls the
   data and the turns above it — tap to record, inspect anything, tap to
   stop. It lives inside the chat section (gone with the chat), drawn over
   the page on the page surface with a top rule and the phone's home-bar
   inset respected. The chat carrying it pads its own foot so nothing ends
   up beneath it. Recording turns the button the state colour with a pulse
   ring and a timer; transcribing dims it. */
.mic-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
}
.mic-bar[hidden] {
  display: none;
}
.mic-bar-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 3.75rem;
  height: 3.75rem;
  min-width: var(--target);
  min-height: var(--target);
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, background-color 0.2s ease;
}
.mic-bar-btn .icon {
  width: 1.6rem;
  height: 1.6rem;
}
.mic-bar-btn:hover {
  filter: brightness(1.06);
}
.mic-bar-btn:active {
  transform: scale(0.97);
}
.mic-bar-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.mic-bar-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.mic-bar-text {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}
.mic-ring {
  position: absolute;
  inset: -6px;
  border: 3px solid var(--danger);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.is-recording .mic-bar-btn {
  background: var(--danger);
}
.is-recording .mic-ring {
  opacity: 1;
  animation: mic-pulse 1.4s ease-out infinite;
}
.is-recording .mic-caption {
  color: var(--danger);
  font-weight: 600;
}
.mic-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--danger);
}
.mic-timer:empty {
  display: none;
}
.mic-caption {
  margin: 0;
  font-size: 0.95rem;
}
@keyframes mic-pulse {
  from {
    transform: scale(1);
    opacity: 0.9;
  }
  to {
    transform: scale(1.35);
    opacity: 0;
  }
}
@keyframes eq {
  from {
    height: 0.25rem;
  }
  to {
    height: 0.8rem;
  }
}

/* The draft segments: the answer so far, as candidate bubbles under the
   question — dashed and labelled "not sent yet" so they never read as sent
   turns. Each carries Edit and ✕; open for editing, its text is a field. */
.segments {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.segments[hidden] {
  display: none;
}
.segment {
  border-style: dashed;
  border-color: var(--partial);
}
.segment .turn-text {
  cursor: text;
}
/* Open for editing the bubble takes the row, so the field is not squeezed
   to the width of a short transcript. */
.segment.is-editing {
  align-self: stretch;
}
.segment-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
}
.segment-actions .voice-btn {
  margin-top: 0;
}
.segment-delete {
  color: var(--muted);
}
.segment-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}
.segment-edit {
  min-height: 4.5rem;
  margin-top: 0.25rem;
}

/* Send as a pill, styled like the voice controls — filled accent, icon,
   lift — centred under the mic, with "or type instead" beneath it. */
.voice-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  text-align: center;
}
.voice-actions .actions {
  margin-top: 0;
  justify-content: center;
}
.send-pill {
  gap: 0.5rem;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-size: 1.05rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.send-pill:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}
.send-pill .icon {
  width: 1.2rem;
  height: 1.2rem;
}
.type-instead {
  min-height: var(--target);
  color: var(--muted);
  font-weight: 500;
}
.type-instead:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Marking */
.marking {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
  .is-recording .mic-ring {
    animation: none;
  }
  .live-dot {
    animation: none;
  }
  .turn-now:has(.voice-pause:not(:disabled)[aria-label="Pause playback"]) .eq i {
    animation: none;
  }
  .mic-bar-btn {
    transition: none;
  }
}

/* Feedback — the results page (D-026, §15). The verdict banner is tinted by
   the band's meaning; the tint is mixed over --surface so it holds on a dark
   institution palette as well as the light default. The sections below it
   are the same learner-safe content the CLI flattens to text, as components:
   gap cards, marker rows, a callout. No motion anywhere on this page. */
.feedback-unit {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0.25rem;
}
.verdict {
  --tone: var(--muted);
  background: color-mix(in srgb, var(--tone) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--line));
  border-left: 4px solid var(--tone);
  border-radius: var(--radius);
  padding: 1.1rem 1.35rem;
  margin: 0 0 1.25rem;
}
.verdict-pass {
  --tone: var(--pass);
}
.verdict-borderline {
  --tone: var(--borderline);
}
.verdict-fail {
  --tone: var(--fail);
}
.verdict-label {
  color: var(--tone);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.2rem;
}
.verdict .band {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.verdict .score {
  color: var(--muted);
  font-size: 1rem;
  margin: 0.35rem 0 0;
}
.fb-summary {
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 1.5rem;
}
.fb-section {
  margin: 0 0 1.75rem;
}
.fb-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
}
.gap-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 0.6rem;
}
.gap-area {
  display: inline-block;
  background: var(--tag);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0 0 0.45rem;
}
.gap-headline {
  margin: 0;
  font-weight: 400;
}
.gap-why {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0.35rem 0 0;
}
.gap-why-label {
  font-weight: 600;
}
.fb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.fb-row {
  position: relative;
  padding: 0.35rem 0 0.35rem 1.6rem;
  margin: 0;
}
.fb-row::before {
  position: absolute;
  left: 0;
  top: 0.35rem;
  width: 1.1rem;
  text-align: center;
  font-weight: 700;
}
.fb-row-check::before {
  content: "✓" / "";
  color: var(--pass);
}
.fb-row-arrow::before {
  content: "→" / "";
  color: var(--accent);
}
.fb-row-critical::before {
  content: "!" / "";
  color: var(--fail);
}
/* Critical — sharper: the section is ruled in the fail hue and its rows sit
   on a faint tint of it, so a must-not-miss is never read as one more gap. */
.fb-critical {
  border-left: 3px solid var(--fail);
  padding: 0.25rem 0 0.25rem 0.9rem;
}
.fb-critical .fb-title {
  color: var(--fail);
}
.fb-critical .fb-row {
  background: color-mix(in srgb, var(--fail) 6%, var(--surface));
  border-radius: var(--radius);
  padding-left: 1.9rem;
  margin: 0 0 0.35rem;
}
.fb-critical .fb-row::before {
  left: 0.4rem;
}
.fb-callout {
  background: var(--soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0;
}

/* Progress — the profiling switch, the signals, the history */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 0 0 1.75rem;
}
.panel-title {
  font-size: 1rem;
  margin: 0 0 0.6rem;
}
.panel p {
  margin: 0 0 0.6rem;
}
.toggle-status {
  font-size: 0.85rem;
}
.section-title {
  font-size: 1.05rem;
  margin: 1.75rem 0 0.5rem;
}

.concepts,
.history,
.evidence {
  list-style: none;
  margin: 0;
  padding: 0;
}
.concepts {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.concept-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.concept-name {
  font-weight: 700;
  font-size: 1.05rem;
}
.concept-claim {
  margin: 0.3rem 0 0;
}
.concept-pattern {
  margin: 0.3rem 0 0;
  color: var(--muted);
}
/* The calibration signal (VIVA-31) — confidence against outcome, per concept. */
.concept-calibration {
  margin: 0.3rem 0 0;
}
.concept-evidence-label {
  margin: 0.8rem 0 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.evidence li {
  font-size: 0.9rem;
  padding: 0.15rem 0;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
}
.evidence-link {
  font-size: 0.8rem;
  white-space: nowrap;
}

.history {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.history-row {
  display: flex;
  width: 100%;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  cursor: pointer;
  color: inherit;
}
.history-row:hover {
  border-color: var(--accent);
}
.h-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.h-meta {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* Notices */
.notice {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.notice.error {
  color: var(--danger);
  border-color: #e3c9c9;
  background: #fbf3f3;
}
.muted {
  color: var(--muted);
}
.back {
  margin: 1.25rem 0 0;
}

/* Authoring preview (VIVA-2, faculty only) */
.author-output {
  margin-top: 1.5rem;
}
.author-preview {
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.author-preview h2 {
  margin: 0 0 0.5rem;
}
.author-preview h3 {
  margin: 1.25rem 0 0.4rem;
}
.rubric-section {
  padding: 0.75rem 0.95rem;
  margin: 0.5rem 0;
  border-left: 3px solid var(--line);
}
.rubric-section h4 {
  margin: 0 0 0.25rem;
}

/* Courses (VIVA-3) — the faculty course editor. The email input the cohort
   roster (VIVA-4) enrols with is the same control and shares these rules;
   type="email" gets the phone keyboard and the browser's own format hint. */
input[type="text"],
input[type="email"],
select {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  min-width: 0;
  flex: 1 1 16rem;
}
.stations,
.roster {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 0.5rem;
}
.station-row,
.roster-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}
.station-pos {
  color: var(--muted);
  min-width: 1.5rem;
  text-align: right;
}
.station-title,
.roster-who {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
  min-width: 0;
}
.station-actions,
.roster-actions {
  display: flex;
  gap: 0.6rem;
  white-space: nowrap;
}
.station-actions .btn-link:disabled,
.roster-actions .btn-link:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn.danger {
  color: var(--danger);
}

/* Cohorts (VIVA-4 / VIVA-5) — the faculty roster, assignment and results views.
   A roster row and an assigned-course row have exactly the shape of a station
   row, so they share those rules above rather than restating them; only what is
   genuinely new to this surface is declared here. */
.roster-meta {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}
.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.result-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.result-row:first-child {
  border-top: 0;
  padding-top: 0;
}
.result-unit {
  font-weight: 600;
  flex: 1 1 12rem;
  min-width: 0;
}
.result-meta {
  color: var(--muted);
  font-size: 0.82rem;
}
.result-score {
  font-variant-numeric: tabular-nums;
}

/* --- The stimulus DATA (unit detail) ---------------------------------------
   Rendered between the brief and the questions: for a data-interpretation
   station the data IS the question, so it reads as substance and not as an
   aside. Two shapes share the card — a table of measurements, and labelled
   blocks of prose — because the corpus stores them as two shapes. */
.data-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.15rem 1.1rem;
  margin: 0 0 0.75rem;
}
.panel-data-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}
.panel-clinical,
.panel-text {
  margin: 0 0 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.panel-text:last-child,
.panel-clinical:last-child {
  margin-bottom: 0;
}
/* The table scrolls inside its own box; the page never scrolls sideways. */
.panel-scroll {
  overflow-x: auto;
}
.panel-values {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}
.panel-values th,
.panel-values td {
  text-align: left;
  padding: 0.35rem 0.7rem 0.35rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}
.panel-values thead th {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-values tbody tr:last-child th,
.panel-values tbody tr:last-child td {
  border-bottom: 0;
}
.panel-label {
  font-weight: 600;
}
/* The institutions table (VIVA-115): name over slug in the row header. */
.tenants .tenant-name,
.tenants .tenant-slug {
  display: block;
}
.tenants .tenant-slug {
  font-weight: 400;
  font-size: 0.85rem;
}
.tenants td {
  white-space: nowrap;
}
.panel-value .v {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.panel-value .u,
.panel-normal {
  color: var(--muted);
  white-space: nowrap;
}
/* The flag is a WORD first. Colour is a second channel over a label that
   already reads on its own, so the row stays interpretable without it — the
   value and the reference range are never styled away. */
.flag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.flag-high,
.flag-low {
  border-color: var(--danger);
  color: var(--danger);
}
.flag-normal,
.flag-other {
  color: var(--muted);
}

/* The authoring preview's two projections (VIVA-20): the learner's view and the
   judge's view of one compiled package, side by side where there is room. */
.preview-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}
@media (max-width: 760px) {
  .preview-columns {
    grid-template-columns: 1fr;
  }
}
.preview-column {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.preview-column > h3:first-child {
  margin-top: 0;
}

/* The lesson player (VIVA-67): sections in reading order, a section nav, the
   worked example and self-check as panels, and the ONE place Markdown-derived
   structure appears (.md). Images are first-party and never wider than the
   column. */
.lesson-meta {
  margin-top: -0.25rem;
}
.lesson-nav ol {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}
.lesson-nav li {
  margin: 0.15rem 0;
}
.lesson-nav-link[aria-current="true"] {
  font-weight: 700;
}
.lesson-section {
  margin-top: 1.75rem;
  scroll-margin-top: 4.5rem;
}
.lesson-section[aria-current="true"] > .lesson-heading {
  border-left: 3px solid var(--accent);
  padding-left: 0.6rem;
}
.lesson-heading {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}
.md p {
  margin: 0.5rem 0;
}
.md-heading {
  margin: 1rem 0 0.35rem;
}
.md-list {
  margin: 0.5rem 0;
  padding-left: 1.4rem;
}
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--tag);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}
.md-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.75rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.worked-example,
.self-check {
  margin-top: 0.75rem;
  background: var(--soft);
}
.check-question {
  font-weight: 600;
}
.check-answer {
  margin-top: 0.5rem;
}
.completion {
  margin-top: 1.5rem;
  border-left: 3px solid var(--accent);
}
.completion .item-state {
  font-size: 1rem;
  font-weight: 700;
}

/* Next-for-you on the home page: the prescription, with "Why this?" as a
   plain sentence under each item rather than behind a control. */
.next-for-you {
  border-left: 3px solid var(--accent);
}
.recommendations {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: grid;
  gap: 0.6rem;
}
.recommendation {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  min-height: var(--target);
}
.recommendation .item-kind {
  margin-top: 0.55rem;
}
.recommendation-body {
  flex: 1 1 auto;
  min-width: 0;
}
.why-this {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
}

/* Challenge and review (VIVA-27) — the learner's challenge panel, the faculty
   row controls, and the reviewer's per-criterion correction form. */
.challenge-panel {
  margin-top: 1.25rem;
}
.challenge-row {
  margin: 0.4rem 0 0.1rem;
}
.challenge-reason {
  white-space: pre-wrap;
  margin: 0 0 0.6rem;
}
.result-actions {
  display: inline-flex;
  gap: 0.6rem;
  align-items: baseline;
}
.review-slot {
  flex: 1 0 100%;
}
.review-slot:empty {
  display: none;
}
.review-form {
  padding: 0.6rem 0 0.2rem;
}
.review-criterion {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
  padding: 0.3rem 0;
}
.review-criterion input[type="number"] {
  width: 5rem;
}
.review-criterion input[type="text"] {
  flex: 1 1 12rem;
}
.review-label {
  flex: 1 1 10rem;
  font-weight: 600;
}

/* --- The viva page frame (VIVA-88, D-029 part 2) ---------------------------
   The data and the conversation each with their own space. Wide (tablet and
   desktop — the shell's own breakpoint, so the three columns are the
   existing nav rail · Data · Chat): the shell fills the viewport and the two
   panels scroll on their own; the transcript is a bounded region above the
   composer and the mic bar stands at the foot of the Chat column. Phone:
   two tabs over the same DOM (a tab switch hides, never rebuilds, so a
   recording never notices), the one mic bar fixed under both, the page
   scrolling as before. Everything reads var(--token): both presets hold. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.viva {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.viva-panel {
  min-width: 0;
}
.viva-panel > .prompts-title:first-child {
  margin-top: 0.75rem;
}
.viva-data > .brief {
  margin-top: 0.25rem;
}
/* The tab strip: phone only. */
.viva-tabs {
  display: none;
}
.viva-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--target);
  padding: 0 0.75rem;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.viva-tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.viva-tab:hover {
  color: var(--text);
}
/* The live indicator on the Data tab: drawn off the mic bar's own recording
   state — the bar is the truth, nothing polls. Hidden text says the word. */
.tab-live {
  display: none;
  align-items: center;
}
.viva:has(> .mic-bar.is-recording) .tab-live {
  display: inline-flex;
}
.live-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--danger);
  animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse {
  50% {
    opacity: 0.35;
  }
}
/* Enlarge: a quiet link-button on each panel head and under the image, at
   the hit target every control keeps. */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
}
.panel-head .panel-data-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.enlarge-btn {
  min-height: var(--target);
  font-size: 0.9rem;
  flex: none;
}
.stimulus-figure .enlarge-btn {
  margin-top: 0.25rem;
}
/* Wide: the frame fills the viewport; each panel scrolls on its own. */
@media (min-width: 56.25rem) {
  .shell:has(.viva) {
    height: 100vh;
    height: 100dvh;
  }
  .content:has(.viva) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .content > .wrap:has(> .viva) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 90rem;
    width: 100%;
    padding-bottom: 1rem;
  }
  .viva {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head head"
      "data chat"
      ". mic";
    column-gap: 1.5rem;
  }
  .viva > .unit-head {
    grid-area: head;
  }
  .viva-data {
    grid-area: data;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
  }
  .viva-chat {
    grid-area: chat;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .viva-chat > .prompts-title {
    flex: none;
  }
  .viva-chat > .chat {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .viva-chat .chat-bar {
    flex: none;
  }
  /* The transcript: what scrolls. The composer beneath keeps its own height
     and scrolls itself only when the transcript is down to its minimum. */
  .viva-chat .transcript {
    flex: 1 1 0;
    min-height: 6rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 0.5rem 0;
  }
  .viva-chat .composer {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  /* While the Begin gate stands (VIVA-97) the transcript holds the opener
     alone: it keeps to its content so the gate follows straight under the
     question instead of sitting at the foot of the column. */
  .viva-chat .chat:has(> .composer > .begin-gate) .transcript {
    flex: 0 0 auto;
  }
  /* The mic bar at the foot of the Chat column: in the flow, not fixed —
     the column is already the height of the viewport. Positioned so it
     paints above the larger view and stays reachable. */
  .viva > .mic-bar {
    grid-area: mic;
    position: relative;
    z-index: 15;
    box-shadow: none;
    padding-bottom: 0.6rem;
    border-radius: var(--radius);
  }
}
/* Phone: the tabs. */
@media (max-width: 56.24rem) {
  .viva-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0.5rem 0 0.75rem;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
  }
  .viva[data-tab="data"] > .viva-chat,
  .viva[data-tab="chat"] > .viva-data {
    display: none;
  }
  /* The fixed bar covers the foot of whichever tab shows: both pad for it. */
  .viva:has(> .mic-bar:not([hidden])) > .viva-panel {
    padding-bottom: 6rem;
  }
  .viva:has(> .mic-bar:not([hidden])) .enlarged {
    padding-bottom: 6.5rem;
  }
}
/* The larger view (VIVA-88): over the page, under the mic bar (z 15). Not
   modal — the bar stays reachable. Its body scrolls; an image fits by
   default and at actual size overflows to scroll around. */
.enlarged {
  position: fixed;
  inset: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
}
.enlarged[hidden] {
  display: none;
}
.enlarged-panel {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.enlarged-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  border-bottom: 1px solid var(--line);
}
.enlarged-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.enlarged-zoom[hidden] {
  display: none;
}
.enlarged-close {
  width: var(--target);
  padding: 0;
  border-color: transparent;
}
.enlarged-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}
.enlarged-body > .stimulus {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}
.enlarged-body.is-actual > .stimulus {
  max-width: none;
  max-height: none;
  margin: 0;
}
.enlarged-body > .data-panel {
  margin: 0;
  border: 0;
  padding: 0;
}
