:root {
  /* Daylight Architectural Studio + Gallery Paper Workspace */
  --bg: #f7f8fa;
  --bg-2: #edf0f5;
  --panel-solid: #f7f8fa;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f4fa;
  --surface-subtle: #edf1f6;
  --line: #d8dfe8;
  --line-strong: #bac4d3;

  /* Ink & contrast (all >= WCAG AA) */
  --text: #101722;
  --muted: #4b5668;
  --faint: #5c687a;

  /* Deliberate Cobalt Editorial Accent */
  --accent: #1d4ed8;
  --accent-hover: #1a44bd;
  --accent-soft: rgba(29, 78, 216, 0.08);
  --accent-border: rgba(29, 78, 216, 0.28);

  /* Semantic feedback colors (reserved for interactive & quiz states) */
  --good: #0d7a53;
  --good-soft: #e7f6ef;
  --good-border: #9edbc1;
  --warn: #9a5b00;
  --warn-soft: #fdf5e4;
  --warn-border: #e9cd88;
  --bad: #c4283e;
  --bad-soft: #fdecef;
  --bad-border: #efb2bc;

  /* Stage cyclorama tokens */
  --stage-top: #d0d8e2;
  --stage-mid: #b3bfc9;
  --stage-bottom: #95a3b2;

  /* Strict 2-font system + 3-size body scale */
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-heading: 1.375rem; /* 22px */
  --text-body: 0.9375rem;   /* 15px */
  --text-sm: 0.8125rem;     /* 13px */

  /* Layout & motion */
  --radius: 12px;
  --radius-sm: 8px;
  --panel-w: 488px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--text-body)/1.52 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); line-height: 1.45; }

/* ── Studio Stage ──────────────────────────────────────────────────────── */

#stage {
  position: fixed;
  inset: 0 var(--panel-w) 0 0;
  overflow: hidden;
  background:
    radial-gradient(64% 52% at 50% 24%, rgba(255, 255, 255, 0.56) 0%, transparent 72%),
    radial-gradient(90% 80% at 50% 42%, var(--stage-top) 0%, var(--stage-mid) 62%, var(--stage-bottom) 100%);
}

#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(48% 12% at 50% 100%, rgba(16, 23, 34, 0.16), transparent 72%),
    radial-gradient(125% 100% at 50% 42%, transparent 64%, rgba(16, 23, 34, 0.14) 100%);
}

#avatar { position: absolute; inset: 0; }
#avatar canvas { display: block; }

#avatar-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: opacity 420ms var(--ease);
}

#avatar-loading.done { opacity: 0; pointer-events: none; }

.ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid rgba(16, 23, 34, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

.ring.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Top Bar & Live HUD ────────────────────────────────────────────────── */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: var(--panel-w);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  z-index: 8;
  pointer-events: none;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}

#topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  color: var(--accent);
  flex: none;
}

.brand-name {
  font: 800 1.4375rem/1 var(--display);
  letter-spacing: -0.03em;
  color: var(--text);
}

.brand-tag {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  padding-left: 10px;
  border-left: 1px solid rgba(16, 23, 34, 0.18);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: none;
}

.signin {
  text-decoration: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(16, 23, 34, 0.16);
}

.signin:hover {
  background: var(--card-hover);
  border-color: var(--accent-border);
}

.signin.pulse { animation: signin-pulse 1s var(--ease) 3; }
@keyframes signin-pulse {
  50% { box-shadow: 0 0 0 5px rgba(29, 78, 216, 0.28); border-color: var(--accent); }
}

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px 0 5px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 23, 34, 0.14);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  font-size: var(--text-sm);
}

.account-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.account-name {
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-out {
  color: var(--muted);
  text-decoration: none;
  padding-left: 6px;
  border-left: 1px solid var(--line);
  transition: color 160ms var(--ease);
}

.account-out:hover { color: var(--text); }

.signin-cta {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  transition: background-color 160ms var(--ease);
}

.signin-cta:hover { background: rgba(29, 78, 216, 0.14); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 23, 34, 0.14);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 140ms var(--ease);
}

.icon-btn:hover {
  background: #ffffff;
  border-color: rgba(16, 23, 34, 0.28);
}

.icon-btn:active { transform: scale(0.96); }

.icon-btn.subtle {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
}

.icon-btn.subtle:hover {
  background: var(--surface-subtle);
  border-color: transparent;
}

#hud {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(16, 23, 34, 0.12);
  backdrop-filter: blur(12px);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.hud-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  flex: none;
}

.hud-topic {
  font-weight: 600;
  color: var(--text);
  max-width: 210px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-phase="quiz"] .brand-name,
body[data-phase="quiz"] .brand-tag,
body[data-phase="results"] .brand-name,
body[data-phase="results"] .brand-tag { display: none; }

@media (max-width: 1220px) {
  .hud-topic,
  .hud-sep-topic { display: none; }
}

.hud-score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.hud-label {
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 500;
}

#hud-score {
  font: 700 var(--text-body)/1 var(--display);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.hud-streak {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hud-streak .flame {
  color: var(--faint);
  opacity: 0.45;
  transition: transform 200ms var(--ease), color 200ms var(--ease), opacity 200ms var(--ease);
}

.hud-streak[data-level="1"] .flame { color: #d97706; opacity: 1; }
.hud-streak[data-level="2"] .flame { color: #d95d16; opacity: 1; transform: scale(1.12); }
.hud-streak[data-level="3"] .flame { color: var(--bad); opacity: 1; transform: scale(1.22); }

.hud-streak .mult {
  color: var(--muted);
  font-weight: 500;
  font-size: var(--text-sm);
}

/* ── Live Caption ──────────────────────────────────────────────────────── */

.caption {
  position: fixed;
  left: calc((100% - var(--panel-w)) / 2);
  transform: translateX(-50%);
  bottom: 28px;
  width: min(640px, calc(100% - var(--panel-w) - 48px));
  padding: 14px 20px;
  border-radius: var(--radius);
  background: rgba(16, 23, 34, 0.86);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.48;
  text-align: center;
  z-index: 6;
  animation: rise 220ms var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Right Studio Workspace Panel ──────────────────────────────────────── */

#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  overflow-y: auto;
  padding: 32px 32px 44px;
  background: var(--bg);
  border-left: 1px solid var(--line);
  z-index: 7;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.view { animation: fade 220ms var(--ease); }
@keyframes fade {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* ── Lobby Typography & Controls ───────────────────────────────────────── */

.title {
  font: 800 clamp(2.125rem, 3vw, 2.75rem)/0.98 var(--display);
  letter-spacing: -0.035em;
  color: var(--text);
  margin: 0 0 12px;
}

.lead {
  color: var(--muted);
  font-size: var(--text-body);
  line-height: 1.52;
  max-width: 44ch;
  margin: 0 0 22px;
}

.control-block { margin-bottom: 16px; }
.control-head { margin-bottom: 2px; }
.control-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}

/* Connected architectural tab strip for coach selection */
.coach-pick {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.coach-pick::-webkit-scrollbar { display: none; }

.coach-pick button {
  position: relative;
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 10px 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: color 160ms var(--ease);
}

.coach-pick button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 200ms var(--ease);
}

.coach-pick button:hover { color: var(--text); }

.coach-pick button.on {
  color: var(--text);
  font-weight: 700;
}

.coach-pick button.on::after { transform: scaleX(1); }

.topic-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.topic-form input,
.type-form input,
.field input,
select,
.name-field input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-body);
  outline: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.topic-form input::placeholder,
.type-form input::placeholder,
.name-field input::placeholder,
.field input::placeholder { color: var(--faint); }

.topic-form input:focus,
.type-form input:focus,
.field input:focus,
.name-field input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

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

.lobby-options {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

/* Primary & secondary actions */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 140ms var(--ease);
}

.btn:hover {
  background: var(--card-hover);
  border-color: var(--line-strong);
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

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

.btn.ghost:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.btn.small {
  padding: 8px 14px;
  font-size: var(--text-sm);
}

.btn:disabled { opacity: 0.45; cursor: default; }

.link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  font-size: var(--text-sm);
  transition: color 160ms var(--ease);
}

.link:hover { color: var(--accent-hover); text-decoration: underline; }

/* Connected segmented difficulty / period toggle */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
}

.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: background-color 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.seg button:hover { color: var(--text); }

.seg button.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 23, 34, 0.08);
}

.seg.small button { padding: 5px 10px; }

.name-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.name-field input {
  width: 148px;
  flex: none;
  padding: 7px 11px;
  font-size: var(--text-sm);
}

.name-field .verified {
  color: var(--good);
  font-weight: 600;
  font-size: var(--text-sm);
}

/* Section rhythm */
.panel-section { margin-top: 26px; }
.section-row { margin-bottom: 12px; }
.section-row .section { margin: 0; }

.section {
  font: 700 var(--text-heading)/1.2 var(--display);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 12px;
}

/* Architectural hairline 2-column topic index */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 15px 15px 16px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
  transition: background-color 160ms var(--ease);
}

.card:hover { background: var(--card-hover); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }

.card .emoji {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 4px;
}

.card b {
  font: 600 var(--text-body)/1.3 var(--body);
  color: var(--text);
}

.card span {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.card .plays {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: var(--text-sm);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ── Editorial Leaderboard Table ───────────────────────────────────────── */

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.board li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  transition: background-color 160ms var(--ease);
}

.board li.me {
  background: var(--accent-soft);
  padding-inline: 10px;
  border-radius: var(--radius-sm);
  border-bottom-color: transparent;
}

.board .pos {
  font: 700 var(--text-body)/1 var(--display);
  color: var(--faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.board li:nth-child(1) .pos { color: var(--accent); }
.board li:nth-child(2) .pos { color: var(--text); }
.board li:nth-child(3) .pos { color: var(--muted); }

.board .who { min-width: 0; }

.board .who b {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board .who > span {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board .pts {
  font: 700 var(--text-body)/1 var(--display);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.board .empty {
  grid-template-columns: 1fr;
  color: var(--muted);
  text-align: center;
  padding: 18px 8px;
  font-size: var(--text-sm);
}

.board.compact li { padding: 9px 4px; }

.check {
  display: inline;
  color: var(--good);
  font-size: var(--text-sm);
  font-weight: 700;
  flex: none;
}

/* ── Research View ─────────────────────────────────────────────────────── */

.research-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.research-emoji {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--surface-subtle);
  flex: none;
}

.research-meta { min-width: 0; }

.research-title {
  font: 700 var(--text-heading)/1.2 var(--display);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}

.view-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: var(--text-body);
}

.steps li::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex: none;
}

.steps li.active {
  color: var(--text);
  font-weight: 600;
}

.steps li.active::before {
  border-color: var(--line);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

.steps li.done { color: var(--muted); }

.steps li.done::before {
  content: "✓";
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  border: 0;
  background: var(--good);
  color: #ffffff;
}

.sources {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  margin-bottom: 20px;
}

.sources:empty { display: none; }

.source {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  animation: fade 220ms var(--ease);
  transition: color 160ms var(--ease);
}

.source:hover { color: var(--accent); }

.source b {
  color: var(--text);
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source:hover b { color: var(--accent); }
.source span { flex: none; color: var(--faint); }

.voice-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 8px;
}

.voice-line .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.voice-line.ok .dot { background: var(--good); }
.voice-line.bad .dot { background: var(--bad); }

.research-tip { margin: 0 0 20px; }
.research-actions { margin-top: 8px; }

/* ── Active Quiz View ──────────────────────────────────────────────────── */

.q-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.dots { display: flex; gap: 6px; }

.dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background-color 200ms var(--ease), transform 200ms var(--ease);
}

.dots i.current {
  background: transparent;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  transform: scale(1.15);
}

.dots i.correct { background: var(--good); }
.dots i.partial { background: var(--warn); }
.dots i.incorrect,
.dots i.skipped { background: var(--bad); }

/* Question stands open with typographic hierarchy (no nested card cage) */
.q-card {
  padding-left: 16px;
  border-left: 3px solid var(--accent);
  animation: fade 220ms var(--ease);
}

.q-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Plain typographic metadata separated by subtle middots, never decorative pills */
.pill {
  display: inline;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.pill + .pill:not([hidden])::before {
  content: "·";
  margin: 0 8px;
  color: var(--line-strong);
  font-weight: 400;
}

.pill.gold { color: var(--accent); }
.pill.easy { color: var(--good); }
.pill.hard { color: var(--bad); }

.q-text {
  font: 700 var(--text-heading)/1.28 var(--display);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}

.answer-box {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-subtle);
  border-left: 3px solid transparent;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease);
}

.answer-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.answer-text {
  margin: 0;
  font-size: var(--text-body);
  color: var(--text);
  min-height: 1.5em;
}

.answer-text .partial { color: var(--muted); }

.answer-box.grading {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.answer-box.grading .answer-label::after {
  content: " · Grading…";
  color: var(--accent);
}

.verdict {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  animation: fade 220ms var(--ease);
}

.verdict[data-v="correct"] {
  border-color: var(--good-border);
  border-left-color: var(--good);
  background: var(--good-soft);
}

.verdict[data-v="partial"] {
  border-color: var(--warn-border);
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.verdict[data-v="incorrect"],
.verdict[data-v="skipped"] {
  border-color: var(--bad-border);
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.verdict[data-v="clue"] {
  border-color: var(--accent-border);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.verdict.previous { opacity: 0.78; }

.verdict.previous::before {
  content: attr(data-label);
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

.verdict-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.verdict-chip {
  font: 700 var(--text-body)/1.3 var(--display);
  color: var(--text);
}

.verdict[data-v="correct"] .verdict-chip { color: var(--good); }
.verdict[data-v="partial"] .verdict-chip { color: var(--warn); }
.verdict[data-v="incorrect"] .verdict-chip,
.verdict[data-v="skipped"] .verdict-chip { color: var(--bad); }
.verdict[data-v="clue"] .verdict-chip { color: var(--accent); }

.verdict-points {
  font: 700 var(--text-body)/1 var(--display);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.verdict[data-v="clue"] .verdict-points {
  font: 600 var(--text-sm)/1 var(--body);
  color: var(--muted);
}

.clue {
  margin: 8px 0 0;
  font-size: var(--text-body);
  line-height: 1.48;
  color: var(--text);
}

.reveal {
  margin-top: 10px;
  font-size: var(--text-body);
}

.reveal-answer {
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.48;
}

.keypoints {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.keypoints li {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: var(--text-body);
  line-height: 1.45;
}

.keypoints li::before { content: "○"; color: var(--faint); flex: none; }
.keypoints li.hit { color: var(--text); }
.keypoints li.hit::before { content: "✓"; color: var(--good); font-weight: 700; }

.keypoints li.kp-head {
  margin-top: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.keypoints li.kp-head::before { content: none; }
.keypoints li.extra::before { content: "+"; color: var(--faint); }

/* Voice & input dock */
.mic-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.mic {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  cursor: default;
  background: var(--surface);
  color: var(--muted);
  transition: background-color 200ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease);
}

.mic-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2.5px solid var(--good);
  opacity: 0;
  transform: scale(var(--lvl, 0.85));
  transition: transform 80ms linear, opacity 180ms var(--ease);
}

.mic[data-state="listening"] {
  background: var(--good-soft);
  border-color: var(--good-border);
  color: var(--good);
}

.mic[data-state="listening"] .mic-ring { opacity: 0.9; }

.mic[data-state="hearing"] {
  background: var(--good);
  border-color: var(--good);
  color: #ffffff;
}

.mic[data-state="hearing"] .mic-ring { opacity: 1; }

.mic[data-state="speaking"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.mic[data-state="thinking"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.mic[data-state="off"] { color: var(--faint); background: var(--surface-subtle); }

@keyframes pulse {
  50% { box-shadow: 0 0 0 8px rgba(29, 78, 216, 0), 0 0 0 3px rgba(29, 78, 216, 0.22); }
}

.mic-status { display: flex; flex-direction: column; gap: 2px; }
.mic-status b { font-size: var(--text-body); font-weight: 600; color: var(--text); }
.mic-status span { color: var(--muted); font-size: var(--text-sm); }

.type-form { display: flex; gap: 8px; }
.type-form input { padding: 10px 13px; }

/* Clean borderless inline utility toolbar (no button wall) */
.q-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.action-link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: color 160ms var(--ease);
}

.action-link:hover { color: var(--text); }
.action-link:disabled { opacity: 0.4; cursor: default; }
.action-link.danger { color: var(--bad); margin-left: auto; }
.action-link.danger:hover { text-decoration: underline; }

/* ── Results View ──────────────────────────────────────────────────────── */

.result-hero { padding-bottom: 18px; }

.result-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.rank-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.result-heading { min-width: 0; }

.rank-title {
  font: 800 var(--text-heading)/1.1 var(--display);
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0;
}

.result-topic {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.big-score {
  text-align: right;
  font: 800 var(--text-heading)/1 var(--display);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.score-unit {
  font: 600 var(--text-sm)/1 var(--body);
  color: var(--muted);
  margin-left: 4px;
}

/* Single horizontal metric bar separated by hairline dividers (no mini-cards) */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: 0 0 14px;
}

.stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.stats div:first-child { padding-left: 0; }
.stats div + div { border-left: 1px solid var(--line); }

.stats b {
  font: 700 var(--text-heading)/1.1 var(--display);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stats span {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Plain typographic honor roll (no decorative pill chips) */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
}

.badges:empty { display: none; }

.badge {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.placement {
  margin-top: 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}

.coach-report {
  margin: 18px 0 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}

.coach-report h4 {
  margin: 0 0 10px;
  font: 700 var(--text-body)/1.35 var(--display);
  color: var(--text);
}

.coach-report ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: var(--text-body);
  line-height: 1.5;
}

.coach-report .label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.report-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.call-ended { margin: 12px 0 0; }

/* Promote Play again to primary button when Drill my mistakes is hidden */
#btn-drill[hidden] + #btn-again {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: var(--text-body);
  font-weight: 600;
}

#btn-drill[hidden] + #btn-again:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.review {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.review li {
  padding: 14px 0 14px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  font-size: var(--text-body);
}

.review li.correct { border-left-color: var(--good); }
.review li.partial { border-left-color: var(--warn); }
.review li.incorrect,
.review li.skipped,
.review li.pending { border-left-color: var(--bad); }

.review .rq { font-weight: 600; color: var(--text); line-height: 1.4; }
.review .ra { color: var(--muted); margin-top: 5px; line-height: 1.48; }
.review .ry { color: var(--faint); margin-top: 5px; font-style: italic; font-size: var(--text-sm); }

.review .rp {
  float: right;
  font: 700 var(--text-body)/1.3 var(--display);
  color: var(--accent);
  margin-left: 10px;
  font-variant-numeric: tabular-nums;
}

/* ── Floating Points Pop & Confetti ────────────────────────────────────── */

#pop-layer { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

.pop {
  position: absolute;
  left: calc((100% - var(--panel-w)) / 2);
  top: 96px;
  transform: translateX(-50%);
  font: 800 2.25rem/1 var(--display);
  color: var(--accent);
  text-shadow: 0 2px 16px rgba(255, 255, 255, 0.8);
  animation: floatup 1.3s var(--ease) forwards;
}

.pop.good { color: var(--good); }
.pop small {
  display: block;
  margin-top: 4px;
  font-size: var(--text-sm);
  font-family: var(--body);
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

@keyframes floatup {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(0.8); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -44px) scale(1); }
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 19; }

/* ── Modals & Toast ────────────────────────────────────────────────────── */

.sheet {
  width: min(520px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(16, 23, 34, 0.18);
}

.sheet::backdrop {
  background: rgba(16, 23, 34, 0.36);
  backdrop-filter: blur(4px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-head h2 {
  margin: 0;
  font: 700 var(--text-heading)/1.2 var(--display);
  letter-spacing: -0.02em;
}

.dialog-controls {
  margin-bottom: 14px;
  flex-wrap: nowrap;
}

.sheet select {
  flex: 1 1 auto;
  max-width: 240px;
  padding: 7px 11px;
  font-size: var(--text-sm);
  background-color: var(--surface);
}

.switch-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.switch-row input {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  flex: none;
}

.switch-row span { display: flex; flex-direction: column; gap: 3px; }
.switch-row b { font-size: var(--text-body); font-weight: 600; }
.switch-row small, .field small { color: var(--muted); font-size: var(--text-sm); line-height: 1.45; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.field > span { font-size: var(--text-sm); font-weight: 600; }

code {
  font-family: var(--body);
  font-weight: 600;
  font-size: var(--text-sm);
  background: var(--surface-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.settings-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: calc((100% - var(--panel-w)) / 2);
  top: 74px;
  transform: translateX(-50%);
  max-width: min(500px, calc(100% - var(--panel-w) - 32px));
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid var(--bad-border);
  box-shadow: 0 10px 28px rgba(16, 23, 34, 0.12);
  z-index: 30;
  font-size: var(--text-sm);
  font-weight: 500;
  animation: rise 200ms var(--ease);
}

.toast.info {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

/* ── Mobile Layout (<= 860px) ──────────────────────────────────────────── */

@media (max-width: 860px) {
  :root { --panel-w: 0px; }
  html, body { height: auto; min-height: 100%; overflow: visible; }

  #stage {
    position: fixed;
    inset: 0 0 auto 0;
    height: 44vh;
    height: 44svh;
  }

  #topbar {
    right: 0;
    padding: 12px 16px;
    border-bottom: 1px solid transparent;
  }

  body.scrolled #topbar {
    background: var(--bg);
    border-bottom-color: var(--line);
  }

  .brand-tag { display: none; }

  #hud {
    position: static;
    transform: none;
    margin: 0 auto;
    height: 36px;
    padding: 0 10px;
    gap: 8px;
  }

  .hud-topic,
  .hud-sep-topic { display: none; }
  .dialog-controls { flex-wrap: wrap; }
  .sheet select { max-width: none; width: 100%; }

  #panel {
    position: relative;
    inset: auto;
    width: 100%;
    margin-top: 42vh;
    margin-top: 42svh;
    min-height: 58vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    padding: 24px 18px 44px;
    box-shadow: 0 -10px 30px rgba(16, 23, 34, 0.08);
  }

  .caption {
    left: 50%;
    bottom: auto;
    top: calc(44svh - 84px);
    width: calc(100% - 28px);
    padding: 10px 14px;
    font-size: var(--text-sm);
  }

  .pop { left: 50%; top: 72px; }
  .toast { left: 50%; max-width: calc(100% - 32px); }
  .title { font-size: 2.125rem; }
  .cards { grid-template-columns: 1fr; }
  .name-field input { width: 132px; }
  .account-name { display: none; }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
