/* M3 Prüfungssimulation
   Visual idea: ECG paper. A fine red millimetre grid and one trace appear in
   the header; everything else stays quiet. Green marks practice, wine red
   marks strict exams. The exam itself (protocol, debrief) is set in a serif. */

:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #18212b;
  --muted: #5e6873;
  --line: #dde2df;
  --grid: #f0d6d6;
  --grid-major: #e6b9b9;
  --trace: #18212b;
  --scrubs: #0e6b63;
  --scrubs-soft: #e3f0ed;
  --wine: #8c2f3d;
  --wine-soft: #f6e6e8;
  --focus: #2e6fd8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d8;
  --on-accent: #ffffff;

  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 0 rgba(24, 33, 43, 0.04), 0 8px 24px -12px rgba(24, 33, 43, 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111518;
    --surface: #182024;
    --ink: #e7ebe9;
    --muted: #98a2a8;
    --line: #2a3338;
    --grid: rgba(220, 110, 110, 0.12);
    --grid-major: rgba(220, 110, 110, 0.22);
    --trace: #e7ebe9;
    --scrubs: #52b9ab;
    --scrubs-soft: #15302c;
    --wine: #e38d9a;
    --wine-soft: #3a1f25;
    --focus: #7aa7f0;
    --warn: #e5bb6a;
    --warn-soft: #33291a;
    --on-accent: #0d1214;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--scrubs); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.95rem; }
.warning { background: var(--warn-soft); color: var(--warn); padding: 0.75rem 1rem; border-radius: var(--r-md); margin: 1rem 0 0; }

kbd {
  font: 600 0.8em var(--sans);
  padding: 0.1em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

/* ECG paper: 1 mm and 5 mm lines */
.ecg-paper,
.hero,
.login {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
  background-position: -1px -1px;
}

/* ---------- buttons and fields ---------- */

.btn {
  font: 600 0.95rem var(--sans);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--scrubs); border-color: var(--scrubs); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 0.8rem 1.5rem; font-size: 1rem; }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn.danger { color: var(--wine); }
.btn.danger.pulse { border-color: var(--wine); animation: pulse-border 1.6s ease-in-out infinite; }
.btn:disabled { opacity: 0.5; cursor: default; }
a.btn { display: inline-block; text-decoration: none; }
@keyframes pulse-border { 50% { box-shadow: 0 0 0 4px var(--wine-soft); } }

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.875rem; font-weight: 500; color: var(--muted); }
input, select {
  font: 400 1rem var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.6rem 0.75rem;
}
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 18px; fill: none; stroke: var(--wine); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.exam-title { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-title::before { content: "/"; margin-right: 1rem; color: var(--line); }
.topbar nav { margin-left: auto; display: flex; gap: 1.25rem; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.topbar nav a:hover { color: var(--ink); }
.exam-controls { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.timer.over { color: var(--wine); }

main { padding: 0 0 2rem; }
#exam, #feedback, .setup-body { width: min(1080px, 100% - 2rem); margin: 0 auto; }

/* ---------- hero ---------- */

.hero { position: relative; border-bottom: 1px solid var(--line); overflow: hidden; }
.hero-inner {
  width: min(1080px, 100% - 2rem);
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 4.5rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.hero h1 { font-size: clamp(2.2rem, 5.2vw, 3.6rem); font-weight: 800; letter-spacing: -0.03em; max-width: 14ch; }
.lead { margin: 1rem 0 0; max-width: 46ch; font-size: 1.15rem; color: var(--muted); }
.countdown {
  margin: 0;
  padding: 0.9rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  font-weight: 500;
  color: var(--muted);
}
.countdown strong { display: block; font-size: 2.4rem; line-height: 1; color: var(--ink); font-weight: 800; letter-spacing: -0.03em; }
.hero-trace {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 60px;
  fill: none;
  stroke: var(--trace);
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: draw 1.8s cubic-bezier(0.6, 0, 0.3, 1) 0.2s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- exam plan ---------- */

.setup-body { padding-top: 2.5rem; padding-bottom: 2rem; }
.exam-group + .exam-group { margin-top: 2.5rem; }
.group-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.group-head h2 { font-size: 1.45rem; }
.group-head h2::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--group);
  vertical-align: 0.12em;
}
.group-head p { margin: 0; color: var(--muted); }
.exam-group.practice { --group: var(--scrubs); --group-soft: var(--scrubs-soft); }
.exam-group.strict { --group: var(--wine); --group-soft: var(--wine-soft); }

.exam-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, 1fr); }

.exam-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1.25rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.exam-tile:hover { border-color: color-mix(in srgb, var(--group) 45%, var(--line)); }
.exam-tile input { position: absolute; opacity: 0; pointer-events: none; }
.exam-tile:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.exam-tile:has(input:checked) {
  border-color: var(--group);
  box-shadow: 0 0 0 1px var(--group), var(--shadow);
  background: linear-gradient(var(--group-soft), var(--surface) 70%);
}
.tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.step {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1.5px solid var(--group);
  color: var(--group);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.exam-tile:has(input:checked) .step { background: var(--group); color: var(--on-accent); }
.duration { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.tile-kicker { color: var(--group); font-size: 0.9rem; font-weight: 600; }
.tile-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.tile-desc { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.6rem; }
/* Finished exams (remembered in the browser): greyed out, with a check mark instead of the number. */
.exam-tile.done { background: var(--paper); }
.exam-tile.done .tile-kicker,
.exam-tile.done .tile-title,
.exam-tile.done .tile-desc { color: var(--muted); }
.exam-tile.done .step { border-color: var(--line); background: var(--line); color: var(--muted); }
.done-note { margin-left: auto; padding-left: 0.75rem; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
/* Filters above the exams: subject buttons, length, and hiding finished exams. */
.filter-bar { display: flex; flex-direction: column; gap: 0.9rem; margin-bottom: 2.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  position: relative;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--muted); }
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-count { color: var(--muted); font-weight: 500; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.chip:has(input:checked) .chip-count { color: color-mix(in srgb, var(--surface) 65%, var(--ink)); }
.filter-options { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.75rem; color: var(--muted); font-size: 0.95rem; }
.filter-options .inline { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.95rem; cursor: pointer; }
.filter-options select { padding: 0.35rem 0.6rem; font-size: 0.95rem; }
.filter-options input[type="checkbox"] { width: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--scrubs); }
.done-count { margin-left: auto; }
.no-match { color: var(--muted); margin: 0 0 2rem; }
.link-btn { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--ink); }
.board { display: flex; align-items: center; margin-top: auto; padding-top: 0.6rem; border-top: 1px dashed var(--line); }
.board .avatar + .avatar { margin-left: -0.45rem; }
.board-label { margin-left: 0.6rem; color: var(--muted); font-size: 0.85rem; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---------- free exam ---------- */

/* The candidate's settings and the choice of what to practise. */
.block + .block { margin-top: 2.75rem; }
.block + #examsBox:not([hidden]) { margin-top: 2.75rem; }
.block-head { display: flex; align-items: baseline; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.block-head h2 { font-size: 1.45rem; }
.block-head p { margin: 0; color: var(--muted); }
.profile {
  display: grid;
  grid-template-columns: 1fr 1fr 1.7fr 1fr;
  gap: 1rem 1.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.profile select, .profile input, .options select, .options input { width: 100%; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.field legend { margin-bottom: 0.35rem; padding: 0; color: var(--muted); font-size: 0.875rem; font-weight: 500; }
.segmented { display: flex; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented label {
  position: relative;
  flex: 1;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 0.62rem 0.4rem;
  color: var(--ink);
  font-size: 0.9rem;
  white-space: nowrap;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
}
.segmented label + label { border-left: 1px solid var(--line); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { background: var(--paper); }
.segmented label:has(input:checked) { background: var(--ink); color: var(--surface); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.hint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.875rem; }

.mode-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, 1fr); margin-bottom: 1.25rem; }
.mode-card {
  position: relative;
  display: block;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card strong { display: block; margin-bottom: 0.3rem; font-size: 1.2rem; letter-spacing: -0.01em; }
.mode-card span { color: var(--muted); font-size: 0.95rem; }
.mode-card:hover { border-color: color-mix(in srgb, var(--scrubs) 45%, var(--line)); }
.mode-card:has(input:checked) {
  border-color: var(--scrubs);
  box-shadow: 0 0 0 1px var(--scrubs), var(--shadow);
  background: linear-gradient(var(--scrubs-soft), var(--surface) 75%);
}
.mode-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.options {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.4fr;
  gap: 1rem 1.25rem;
  align-items: start;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* ---------- start bar ---------- */

.start-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.start-bar-inner {
  width: min(1080px, 100% - 2rem);
  margin: 0 auto;
  padding: 0.85rem 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.selection { display: flex; flex-direction: column; min-width: 0; }
.selection-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection-facts { color: var(--muted); font-size: 0.9rem; }
.how { margin: 0 0 0 auto; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

/* ---------- login ---------- */

.login { min-height: calc(100vh - 57px); display: grid; place-items: center; padding: 2rem 1rem; }
.login-card {
  width: min(420px, 100%);
  padding: 2rem 2rem 2.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.login-trace { width: 100%; height: 40px; fill: none; stroke: var(--wine); stroke-width: 2; stroke-linejoin: round; margin-bottom: 1.25rem; }
.login h1 { font-size: 1.6rem; }
.login p { color: var(--muted); margin: 0.5rem 0 1.5rem; }
.login form { display: flex; flex-direction: column; gap: 0.5rem; }
.login form .btn { margin-top: 1rem; }

/* ---------- exam: the board ---------- */

#exam { padding-top: 2rem; }
.panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.75rem; margin-bottom: 2rem; }
.seat {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.seat .avatar { width: 2.6rem; height: 2.6rem; font-size: 0.85rem; flex: none; }
.seat-text { min-width: 0; display: flex; flex-direction: column; }
.seat .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .subject { color: var(--muted); font-size: 0.85rem; }
.seat.extra { background: transparent; border-style: dashed; }
.seat.speaking { border-color: var(--scrubs); box-shadow: 0 0 0 1px var(--scrubs); }
.seat.speaking .avatar { background: var(--scrubs); color: var(--on-accent); box-shadow: 0 0 0 3px var(--scrubs-soft); }
.wave { display: block; width: 46px; height: 14px; margin-top: 0.25rem; visibility: hidden; }
.wave path { fill: none; stroke: var(--scrubs); stroke-width: 1.6; stroke-linejoin: round; stroke-dasharray: 60; animation: wave 1.1s linear infinite; }
.seat.speaking .wave { visibility: visible; }
@keyframes wave { from { stroke-dashoffset: 120; } to { stroke-dashoffset: 0; } }

/* ---------- exam: talk ---------- */

.stage { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin: 0.5rem 0 2rem; }
.talk {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--scrubs);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--line), 0 0 0 10px var(--paper), 0 0 0 11px var(--line), var(--shadow);
  touch-action: none;
  user-select: none;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}
.talk svg { width: 44px; height: 44px; }
.talk:hover { color: var(--ink); }
.talk.waiting { opacity: 0.6; }
.talk.recording { background: var(--wine); color: #fff; opacity: 1; box-shadow: 0 0 0 10px var(--wine-soft), var(--shadow); }
/* While recording, a ring around the button empties as the time for the answer runs out. */
.talk .talk-time {
  display: none;
  position: absolute;
  inset: -16px;
  width: calc(100% + 32px);
  height: calc(100% + 32px);
  transform: rotate(-90deg) scaleY(-1);
  pointer-events: none;
}
.talk.recording .talk-time { display: block; }
.talk-time circle { fill: none; stroke: var(--line); stroke-width: 3; }
.talk-time circle + circle { stroke: var(--wine); stroke-linecap: round; transition: stroke-dasharray 0.25s linear, stroke 0.3s; }
.talk.soon .talk-time circle + circle { stroke: var(--warn); }
.status.soon { color: var(--warn); font-weight: 600; }
.exam-notice { max-width: 640px; margin: 1rem auto 0; text-align: center; }
.over-time { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.status { min-height: 1.6em; font-size: 1.05rem; text-align: center; color: var(--muted); }
.status.yours { color: var(--ink); font-weight: 600; }
.text-form { width: min(560px, 100%); }
.text-form input { width: 100%; }

/* ---------- exam: protocol ---------- */

.transcript-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0.25rem 1.5rem; }
.transcript-box summary { cursor: pointer; padding: 0.85rem 0; color: var(--muted); font-weight: 600; }
.transcript { max-height: 46vh; overflow-y: auto; padding-bottom: 1rem; }
.line { margin: 0 0 1rem; font: 400 1.075rem/1.6 var(--serif); max-width: 72ch; }
.line .who { display: block; font: 600 0.82rem/1.4 var(--sans); color: var(--muted); margin-bottom: 0.1rem; }
.line.candidate { padding-left: 0.9rem; border-left: 2px solid var(--scrubs); }
.line.candidate .who { color: var(--scrubs); }
.exhibit-line .linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--scrubs);
  font: 500 0.95rem var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- exam: images and lab tables ---------- */

.exhibit { margin: 0 0 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.exhibit figcaption { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); font-weight: 700; }
.exhibit-actions { display: flex; gap: 0.5rem; }
.exhibit-body { padding: 0.75rem; display: flex; justify-content: center; }
.exhibit-body img { display: block; max-width: 100%; max-height: 62vh; object-fit: contain; cursor: zoom-in; border-radius: var(--r-sm); background: #fff; }
.exhibit-body table { border-collapse: collapse; width: 100%; max-width: 640px; font-variant-numeric: tabular-nums; }
.exhibit-body th, .exhibit-body td { text-align: left; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); }
.exhibit-body th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.exhibit-body td:nth-child(2) { font-weight: 700; }
.exhibit-body td:nth-child(3) { color: var(--muted); }
.exhibit-credit { margin: 0; padding: 0 1rem 0.7rem; font-size: 0.78rem; color: var(--muted); text-align: center; }
.exhibit-credit a { color: inherit; }

.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; background: rgba(10, 12, 16, 0.88); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: var(--r-sm); }

/* ---------- debrief ---------- */

#feedback { padding-top: 2.5rem; }
.deliberating { display: grid; justify-items: center; gap: 0.25rem; padding: 5rem 0; text-align: center; font-size: 1.1rem; }
.deliberating p { margin: 0; }
.deliberating-trace {
  width: 240px;
  height: 40px;
  margin-bottom: 1rem;
  fill: none;
  stroke: var(--wine);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-dasharray: 340;
  animation: think 2s linear infinite;
}
@keyframes think { from { stroke-dashoffset: 680; } to { stroke-dashoffset: 0; } }

.feedback-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.feedback-head h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -0.03em; }
.feedback-head p { margin: 0.35rem 0 0; }
.feedback-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.feedback-actions .muted { font-size: 0.9rem; }

.feedback-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1.25rem, 5vw, 3.25rem);
  margin-bottom: 1.25rem;
  font: 400 1.1rem/1.65 var(--serif);
}
.feedback-body > * { max-width: 70ch; }
.feedback-body h1, .feedback-body h2, .feedback-body h3 { font-family: var(--sans); }
.feedback-body h1 { font-size: 1.5rem; margin: 0 0 1rem; }
.feedback-body h2 { font-size: 1.35rem; margin: 2.25rem 0 0.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.feedback-body h2:first-child, .feedback-body h1 + h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.feedback-body h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.feedback-body li { margin-bottom: 0.4rem; }
.feedback-body strong { font-weight: 600; }
.feedback-body table { border-collapse: collapse; width: 100%; font: 400 0.95rem/1.45 var(--sans); margin: 0.75rem 0; }
.feedback-body th, .feedback-body td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.feedback-body th { color: var(--muted); font-weight: 600; }
#feedback > .transcript-box { margin-bottom: 2rem; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  max-width: min(640px, calc(100% - 2rem));
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.1rem;
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: 40;
}

/* ---------- voices page ---------- */

.voices-page { width: min(1080px, 100% - 2rem); margin: 0 auto; padding: 2.5rem 0 3rem; }
.voices-page h1 { font-size: 2rem; margin-bottom: 0.75rem; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.6rem; margin: 1.5rem 0 2rem; }
.role {
  text-align: left;
  font: inherit;
  color: var(--ink);
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
}
.role .r-name { font-weight: 700; }
.role .r-voice { color: var(--muted); font-size: 0.875rem; }
.role.active { border-color: var(--scrubs); box-shadow: 0 0 0 1px var(--scrubs); }
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.tabs .btn.active { border-color: var(--ink); }
.voice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.voice { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.voice .v-name { font-weight: 700; }
.voice .v-meta { color: var(--muted); font-size: 0.8rem; }
.voice .v-desc { font-size: 0.85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.voice .v-actions { display: flex; gap: 0.4rem; margin-top: auto; flex-wrap: wrap; }
.sample { display: flex; gap: 0.75rem; align-items: end; margin-bottom: 1.25rem; flex-wrap: wrap; }
.sample label { flex: 1; min-width: 260px; }

/* ---------- small screens and reduced motion ---------- */

@media (max-width: 900px) {
  .exam-grid { grid-template-columns: repeat(2, 1fr); }
  .profile, .options { grid-template-columns: 1fr 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .how { display: none; }
  .selection { margin-right: auto; }
}
@media (max-width: 600px) {
  .exam-grid, .practice .exam-grid { grid-template-columns: 1fr; }
  .profile, .options { grid-template-columns: 1fr; padding: 1rem; }
  .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .exam-title { display: none; }
  .start-bar-inner { gap: 1rem; }
  .selection-facts { display: none; }
  .transcript-box { padding: 0.25rem 1rem; }
}
/* Printing the debrief (or saving it as PDF): just the debrief and the protocol. */
@media print {
  .topbar, .feedback-actions, .start-bar, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .feedback-body, .transcript-box { border: 0; box-shadow: none; padding: 0; }
  #feedback > .transcript-box[open] .transcript, #feedback > .transcript-box .transcript { max-height: none; overflow: visible; }
  #feedback > .transcript-box:not([open]) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-trace { animation: none; stroke-dashoffset: 0; }
  .wave path, .deliberating-trace, .btn.danger.pulse { animation: none; }
  .talk-time circle + circle { transition: none; }
}

/* ---------- access codes and balance ---------- */

.balance-btn { font-variant-numeric: tabular-nums; }
.balance-btn.low { border-color: var(--warn); color: var(--warn); }
.wallet-panel {
  position: fixed;
  top: 4rem;
  right: max(1rem, (100vw - 1080px) / 2);
  z-index: 20;
  width: min(380px, 100vw - 2rem);
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.wallet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.wallet-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.wallet-list li { display: flex; flex-direction: column; padding: 0.55rem 0.7rem; background: var(--paper); border-radius: var(--r-md); }
.w-code { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.wallet-form { margin-bottom: 1rem; }
.wallet-row { display: flex; gap: 0.5rem; }
.wallet-row input { flex: 1; min-width: 0; }
.wallet-panel > .btn { display: block; text-align: center; text-decoration: none; }
.login-alt { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.95rem; }
#examNotice a { color: inherit; font-weight: 600; }

/* ---------- legal links under every view ---------- */

/* The bottom padding keeps the links clear of the fixed start bar. */
.app-foot { width: min(1080px, 100% - 2rem); margin: 0 auto; padding: 1.25rem 0 6.5rem; border-top: 1px solid var(--line); font-size: 0.85rem; }
.app-foot nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.app-foot a { color: var(--muted); }
