/* FourFaced — one clip, four voices, every caption backed by evidence. */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("fonts/big-shoulders-display-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Big Shoulders Display";
  src: url("fonts/big-shoulders-display-900.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/libre-franklin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/libre-franklin-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/libre-franklin-500-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/libre-franklin-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #0f1420;
  --surface: #171d2c;
  --surface-2: #202839;
  --ink: #eef2f7;
  --ink-dim: #9aa7bd;
  --ink-faint: #6b7690;
  --border: #2a3346;
  --accent: #2dd4bf;
  --accent-ink: #072220;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --grid-dot: rgba(255, 255, 255, 0.05);

  --voice-formal: #93c5fd;
  --voice-sarcastic: #f0abfc;
  --voice-tech: #86efac;
  --voice-everyday: #fdba74;

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Libre Franklin", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eaf0f5;
    --ink: #101827;
    --ink-dim: #4b5875;
    --ink-faint: #8291a8;
    --border: #dbe3ec;
    --accent: #0d9488;
    --accent-ink: #ffffff;
    --shadow: 0 20px 50px -24px rgba(16, 24, 39, 0.18);
    --grid-dot: rgba(16, 24, 39, 0.045);

    --voice-formal: #2563eb;
    --voice-sarcastic: #a21caf;
    --voice-tech: #16a34a;
    --voice-everyday: #ea580c;

    --good: #059669;
    --warn: #d97706;
    --bad: #dc2626;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #171d2c;
  --surface-2: #202839;
  --ink: #eef2f7;
  --ink-dim: #9aa7bd;
  --ink-faint: #6b7690;
  --border: #2a3346;
  --accent: #2dd4bf;
  --accent-ink: #072220;
  --grid-dot: rgba(255, 255, 255, 0.05);
  --voice-formal: #93c5fd;
  --voice-sarcastic: #f0abfc;
  --voice-tech: #86efac;
  --voice-everyday: #fdba74;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
}
:root[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eaf0f5;
  --ink: #101827;
  --ink-dim: #4b5875;
  --ink-faint: #8291a8;
  --border: #dbe3ec;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --grid-dot: rgba(16, 24, 39, 0.045);
  --voice-formal: #2563eb;
  --voice-sarcastic: #a21caf;
  --voice-tech: #16a34a;
  --voice-everyday: #ea580c;
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.75rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  letter-spacing: -0.01em;
  line-height: 0.9;
  margin: 0;
  text-wrap: balance;
}
.wordmark span { color: var(--accent); }

.tagline {
  font-size: 0.95rem;
  color: var(--ink-dim);
  max-width: 30ch;
  margin: 0.5rem 0 0;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

/* Matches the theme switch beside it: same pill, same label underneath */
.manual-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.manual-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}
.manual-btn svg { width: 20px; height: 20px; }
/* Glows in the theme accent: green on dark, deep blue on light */
.manual-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 65%, transparent);
}
.manual-btn-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  user-select: none;
}

/* Day/night sky switch: a cratered moon drifts across a starry night,
   or a glowing sun across a day sky. */
.theme-switch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.theme-switch {
  position: relative;
  width: 62px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(160deg, #0b1226 0%, #1c2547 100%);
  transition: background 0.45s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.theme-switch:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 45%, transparent);
}
:root[data-theme="light"] .theme-switch {
  background: linear-gradient(160deg, #7fc3ee 0%, #cde9fc 100%);
  border-color: #96c6e6;
}

.ts-stars i {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
  transition: opacity 0.35s ease;
}
.ts-stars i:nth-child(1) { top: 7px; left: 36px; }
.ts-stars i:nth-child(2) { top: 17px; left: 44px; width: 1.5px; height: 1.5px; opacity: 0.65; }
.ts-stars i:nth-child(3) { top: 10px; left: 52px; width: 1.5px; height: 1.5px; opacity: 0.75; }
.ts-stars i:nth-child(4) { top: 20px; left: 33px; width: 1.5px; height: 1.5px; opacity: 0.5; }
:root[data-theme="light"] .theme-switch .ts-stars i { opacity: 0; }

.ts-cloud {
  position: absolute;
  top: 15px;
  left: 10px;
  width: 14px;
  height: 5px;
  border-radius: 999px;
  background: #fff;
  box-shadow: -4px 3px 0 -1px #fff, 5px 3px 0 -1px rgba(255, 255, 255, 0.85);
  opacity: 0;
  transition: opacity 0.35s ease;
}
:root[data-theme="light"] .theme-switch .ts-cloud { opacity: 0.95; }

.ts-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  /* moon: pale disc with craters */
  background:
    radial-gradient(circle at 32% 34%, #c6d1e2 0 2.4px, transparent 3px),
    radial-gradient(circle at 62% 66%, #c6d1e2 0 1.9px, transparent 2.4px),
    radial-gradient(circle at 68% 32%, #c6d1e2 0 1.4px, transparent 1.9px),
    #edf1f8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.5, 1), background 0.45s ease, box-shadow 0.45s ease;
}
:root[data-theme="light"] .theme-switch .ts-knob {
  transform: translateX(32px);
  /* sun: golden disc with a warm glow */
  background: radial-gradient(circle at 40% 38%, #ffe27a 0 30%, #ffcf3f 100%);
  box-shadow: 0 0 9px 2px rgba(255, 196, 48, 0.85);
}

.theme-switch-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  user-select: none;
}

/* ---------- Stage: source + video ---------- */

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.dropzone-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0 0 0.35rem;
}
.dropzone-sub { color: var(--ink-dim); font-size: 0.88rem; margin: 0; }
.dropzone input[type="file"] { display: none; }
.dropzone.hidden { display: none; }

.examples-block { margin-top: 1.4rem; }
.examples-hint {
  margin: 0 0 0.6rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.examples {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}
.example-pill {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.example-pill:hover { color: var(--ink); border-color: var(--ink-faint); }
.example-pill.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* ---------- Clip carousel (character-select style) ---------- */

.carousel { display: none; margin-top: 1.25rem; }
.carousel.visible { display: block; }
/* Dropping files onto the stage while clips exist adds to the batch */
.carousel.drag-over .carousel-stage {
  outline: 1.5px dashed var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.carousel-stage {
  display: grid;
  place-items: center;
  perspective: 1200px;
  overflow: hidden;
}

.clip-slide {
  grid-area: 1 / 1;
  width: 68%;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.5s ease;
}
/* Side clips: pulled back, dimmed, standing just outside the spotlight. */
.clip-slide:not(.focused) {
  cursor: pointer;
  filter: brightness(0.5) saturate(0.8);
}
.clip-slide:not(.focused) video { pointer-events: none; }
.clip-slide:not(.focused) .clear-btn { display: none; }
.clip-slide:not(.focused) .video-progress { visibility: hidden; }
.carousel.locked .clear-btn { display: none; }

.clip-frame { position: relative; }

.clip-status {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 2;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.72);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}
.clip-status.queued { color: rgba(255, 255, 255, 0.65); }
.clip-status.running { border-color: var(--accent); color: var(--accent); }
.clip-status.done { border-color: var(--good); color: var(--good); }
.clip-status.error { border-color: var(--bad); color: var(--bad); }

.clip-slide-name {
  margin: 0.5rem 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
.carousel.single .carousel-nav { display: none; }

.carousel-arrow {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-dim);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.carousel-arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.carousel-arrow:disabled { opacity: 0.3; cursor: default; }

.carousel-dots { display: flex; gap: 0.45rem; }
.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.carousel-dot:hover { background: var(--ink-faint); }
.carousel-dot.active { background: var(--accent); transform: scale(1.3); }

.add-clip-row {
  display: flex;
  justify-content: center;
  margin-top: 0.6rem;
}
.add-clip-btn {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--ink-faint);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.add-clip-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.add-clip-btn:disabled { opacity: 0.45; cursor: not-allowed; }

video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 10px;
  background: #000;
  display: block;
}
/* The native scrubber can't be reliably restyled in modern browsers —
   hide it and drive seeking through our own .video-progress bar instead. */
video::-webkit-media-controls-timeline { display: none; }

.video-progress {
  margin-top: 0.6rem;
  outline: none;
}
.video-progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.video-progress-buffered,
.video-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
  width: 0%;
}
.video-progress-buffered { background: color-mix(in srgb, var(--ink-faint) 40%, transparent); }
.video-progress-fill { background: var(--accent); }
.video-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 2px 6px -1px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  transition: box-shadow 0.15s ease;
}
.video-progress-track:hover .video-progress-thumb,
.video-progress.dragging .video-progress-thumb {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent);
}
.video-progress-time {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.clear-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 14, 22, 0.65);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  z-index: 2;
}
.clear-btn:hover {
  background: color-mix(in srgb, var(--bad) 75%, black);
  border-color: var(--bad);
  transform: scale(1.08);
}

.faces-picker-title {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.faces-picker-title span {
  color: var(--accent);
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
  flex-wrap: wrap;
}

.style-toggles {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.style-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--ink-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem 0.35rem 0.6rem;
  cursor: pointer;
  user-select: none;
}
.style-toggle input { accent-color: var(--accent); margin: 0; }
.style-toggle:has(input:checked) { color: var(--ink); border-color: var(--ink-faint); }

.run-btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.run-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px -14px color-mix(in srgb, var(--accent) 70%, transparent);
}
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Progress ---------- */

.progress-block { margin-top: 2rem; display: none; }
.progress-block.visible { display: block; }

.progress-current {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  min-height: 1.4em;
}
.progress-current .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.stage-log {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stage-log li::before { content: "· "; }

.error-box {
  display: none;
  margin-top: 1rem;
  border: 1px solid var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  font-size: 0.88rem;
  color: var(--ink);
}
.error-box.visible { display: block; }

/* Live "which model is running this" badge inside the progress block. */
.model-badge {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.8rem 0 0;
  font-family: var(--mono);
}
.model-badge[hidden] { display: none; }
.model-badge-label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.model-badge-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  padding: 4px 16px;
  animation: model-live 1.6s ease-in-out infinite;
}
.model-badge.backup .model-badge-name {
  color: var(--warn);
  border-color: var(--warn);
}
@keyframes model-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Per-stage model attribution chips in the results meta row. */
.result-meta .model-chip b { color: var(--accent); }
.result-meta .model-chip.backup b { color: var(--warn); }
.result-meta .model-chip.none b { color: var(--ink-dim); font-style: italic; }

/* ---------- Voices strip ---------- */

.voices-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (max-width: 860px) { .voices-strip { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .voices-strip { grid-template-columns: 1fr; } }

.voice-chip {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--voice-color);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  transition: opacity 0.25s ease, filter 0.25s ease;
}
/* A Face unticked in the picker steps out of the line-up */
.voice-chip.dimmed {
  opacity: 0.35;
  filter: saturate(0.3);
}
.voice-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--voice-color);
  padding-top: 0.2rem;
}
.voice-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.2rem;
}
.voice-desc {
  font-size: 0.78rem;
  color: var(--ink-dim);
  margin: 0;
  line-height: 1.45;
}

/* ---------- Results ---------- */

.results { margin-top: 3rem; display: none; }
.results.visible { display: block; }

/* Brief entrance when the focused clip's results swap in */
@keyframes results-swap {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.results.swap { animation: results-swap 0.32s ease; }

.result-clip-name {
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
}

.section-eyebrow {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.9rem;
}

.result-meta {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-dim);
  margin-bottom: 1.5rem;
  font-variant-numeric: tabular-nums;
}
.result-meta b { color: var(--ink); font-weight: 500; }
.result-meta .budget-warn b { color: var(--warn); }
.result-meta .budget-over b { color: var(--bad); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.v-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.3rem 1.1rem;
  border-top: 3px solid var(--voice-color, var(--border));
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.talk-avatar {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--voice-color, var(--accent));
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.5), 0 0 0 3px var(--surface);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 3;
}
.card-speaking .talk-avatar {
  opacity: 1;
  transform: scale(1);
  animation: talk-bob 0.6s ease-in-out infinite;
}
.talk-avatar-eye {
  position: absolute;
  top: 11px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent-ink);
}
.talk-avatar-eye-l { left: 8px; }
.talk-avatar-eye-r { right: 8px; }
.talk-avatar-mouth {
  position: absolute;
  bottom: 7px;
  left: 50%;
  width: 10px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent-ink);
  transform: translateX(-50%);
  transform-origin: center;
}
.card-speaking .talk-avatar-mouth {
  animation: talk-mouth 0.32s ease-in-out infinite;
}
@keyframes talk-bob {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1) translateY(-2px); }
}
@keyframes talk-mouth {
  0%, 100% { height: 3px; width: 10px; border-radius: 3px; }
  50% { height: 6px; width: 7px; border-radius: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .card-speaking .talk-avatar { animation: none; }
  .card-speaking .talk-avatar-mouth { animation: none; }
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.v-card .eyebrow {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--voice-color);
  margin: 0;
}

.speak-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.speak-btn:hover:not(:disabled) { color: var(--voice-color); border-color: var(--voice-color); }
.speak-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.speak-icon { width: 16px; height: 16px; }
.speak-wave { opacity: 0.35; transition: opacity 0.15s ease; }
.speak-btn:hover:not(:disabled) .speak-wave { opacity: 0.7; }

.speak-btn.speaking {
  color: var(--voice-color);
  border-color: var(--voice-color);
  background: color-mix(in srgb, var(--voice-color) 14%, transparent);
}
.speak-btn.speaking .speak-wave { opacity: 1; }
.speak-btn.speaking .speak-wave-1 { animation: speak-pulse 0.9s ease-in-out infinite; }
.speak-btn.speaking .speak-wave-2 { animation: speak-pulse 0.9s ease-in-out infinite 0.15s; }
@keyframes speak-pulse {
  0%, 100% { opacity: 0.35; transform: scaleX(0.85); }
  50% { opacity: 1; transform: scaleX(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .speak-btn.speaking .speak-wave-1, .speak-btn.speaking .speak-wave-2 { animation: none; opacity: 1; }
}
.v-card .caption-text {
  flex-grow: 1;
  font-size: 1.02rem;
  border-radius: 6px;
  padding: 0.2rem 0.3rem;
  margin: -0.2rem -0.3rem;
  outline: none;
}
.v-card.formal .caption-text { font-weight: 400; line-height: 1.6; }
.v-card.sarcastic .caption-text { font-family: var(--body); font-weight: 500; font-style: italic; line-height: 1.45; }
.v-card.tech .caption-text { font-family: var(--mono); font-size: 0.9rem; line-height: 1.55; }
.v-card.tech .caption-text::before { content: "> "; color: var(--voice-color); }
.v-card.everyday .caption-text { font-weight: 700; letter-spacing: 0.005em; line-height: 1.5; }

.caption-text.editing {
  background: var(--surface-2);
  box-shadow: 0 0 0 1.5px var(--voice-color);
  cursor: text;
  white-space: pre-wrap;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.copy-btn, .edit-btn, .cancel-btn {
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-dim);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.copy-btn:hover, .edit-btn:hover { border-color: var(--voice-color); color: var(--ink); }
.copy-btn.copied { border-color: var(--good); color: var(--good); }
.cancel-btn:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- Evidence ---------- */

.evidence {
  margin-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.3rem 1.4rem;
}
.evidence-facts {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-dim);
  white-space: pre-wrap;
  margin: 0;
  overflow-x: auto;
}
.evidence-flags {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.flag {
  font-family: var(--mono);
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  color: var(--ink-faint);
}
.flag.warn { border-color: var(--bad); color: var(--bad); }

.footer {
  margin-top: 3.5rem;
  padding-top: 1.4rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-brand {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.15rem;
  margin: 0;
}
.footer-brand span { color: var(--accent); }
.footer-note {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 0;
}

/* ---------- Digital manual (page-flip book) ---------- */

.manual-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  /* Scrolls internally if the dialog is ever taller than the window; the
     top padding leaves room for the close button's -44px offset. */
  overflow-y: auto;
  padding: 4.5rem 1rem 2rem;
}
.manual-overlay[hidden] { display: none; }

.manual-backdrop {
  /* Fixed, not absolute: stays pinned to the viewport even when the
     overlay scrolls, so the dimmer can never slide away. */
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.72);
  backdrop-filter: blur(3px);
}

.manual-dialog {
  position: relative;
  z-index: 1;
  /* Auto margins center the dialog when it fits the viewport and pin it
     to the top (never clipped above) when it doesn't. */
  margin: auto;
  animation: manual-in 0.3s ease;
}
@keyframes manual-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.manual-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(10, 14, 22, 0.6);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.manual-close:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 60%, black); }

/* The book: sheets hinge on the spine (left edge of the right-hand half).
   The whole book slides so the visible spread stays centered. */
.manual-book {
  position: relative;
  /* Third bound caps the book by viewport height (aspect 1.55, ~10rem
     reserved for overlay padding + controls) so the whole manual always
     fits on screen and stays fully visible. */
  width: min(860px, 92vw, calc((100vh - 10rem) * 1.55));
  width: min(860px, 92vw, calc((100dvh - 10rem) * 1.55));
  aspect-ratio: 1.55;
  perspective: 2400px;
  transition: transform 0.7s cubic-bezier(0.4, 0.05, 0.3, 1);
}
.manual-book[data-state="0"] { transform: translateX(-25%); }
.manual-book[data-state="4"] { transform: translateX(25%); }

.manual-sheet {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4, 0.05, 0.3, 1);
}
.manual-sheet.flipped { transform: rotateY(-180deg); }

.sheet-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
}
.sheet-front {
  border-radius: 0 12px 12px 0;
  box-shadow: inset 10px 0 20px -14px rgba(0, 0, 0, 0.55);
}
.sheet-back {
  transform: rotateY(180deg);
  border-radius: 12px 0 0 12px;
  box-shadow: inset -10px 0 20px -14px rgba(0, 0, 0, 0.55);
}

/* Cover */
.manual-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.6rem;
  padding: 1.5rem;
  background: linear-gradient(145deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
}
.cover-eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin: 0;
}
.cover-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 0.95;
  margin: 0;
}
.cover-title span { color: var(--accent); }
.cover-sub {
  font-size: 0.85rem;
  color: var(--ink-dim);
  margin: 0;
  line-height: 1.5;
}
.cover-dots {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.cover-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--voice-color);
}
.cover-hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  margin: 1.2rem 0 0;
}

/* Inner pages */
.manual-page {
  position: relative;
  height: 100%;
  padding: clamp(1rem, 2.6vw, 1.7rem) clamp(1.1rem, 2.9vw, 1.8rem);
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 0.65rem;
}
.manual-page h3 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  letter-spacing: 0.01em;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}
.manual-page h3 span { color: var(--accent); }
.manual-page h3::after {
  content: "";
  display: block;
  width: 2.4rem;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin-top: 0.4rem;
}
.manual-page p {
  margin: 0;
  font-size: clamp(0.78rem, 1.7vw, 0.92rem);
  line-height: 1.55;
  color: var(--ink-dim);
}
.manual-page p b, .manual-page li b { color: var(--ink); font-weight: 700; }

/* Big ghost numeral filling the page corner */
.m-watermark {
  position: absolute;
  bottom: -2.2rem;
  right: 0.4rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(6rem, 14vw, 9rem);
  line-height: 1;
  color: color-mix(in srgb, var(--accent) 9%, transparent);
  pointer-events: none;
  user-select: none;
}
.sheet-back .m-watermark { right: auto; left: 0.4rem; }

.m-face-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.m-face-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--voice-color);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2);
}
.m-face-card b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(0.78rem, 1.7vw, 0.92rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--voice-color);
}
.m-face-card span {
  font-size: clamp(0.66rem, 1.45vw, 0.78rem);
  color: var(--ink-dim);
}

/* Two-outcome fork on the models page: what happens when both models fail. */
.m-fork {
  display: flex;
  gap: 0.6rem;
  margin: 0.55rem 0;
}
.m-fork .m-out {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: clamp(0.6rem, 1.35vw, 0.72rem);
  color: var(--ink-dim);
  line-height: 1.45;
}
.m-fork .m-out b {
  display: block;
  color: var(--ink);
  font-size: clamp(0.64rem, 1.45vw, 0.76rem);
  margin-bottom: 2px;
}

.m-tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  font-size: clamp(0.76rem, 1.65vw, 0.9rem);
  line-height: 1.5;
  color: var(--ink-dim);
}
.m-tips li::before { content: "· "; color: var(--accent); font-weight: 700; }

.m-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.2rem 0;
}
.m-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.95rem;
  font-family: var(--mono);
  font-size: clamp(0.62rem, 1.4vw, 0.74rem);
  color: var(--ink);
  background: var(--surface-2);
}
.m-box-accent { border-color: var(--accent); color: var(--accent); }
.m-box .m-ico { font-size: clamp(1.25rem, 2.8vw, 1.7rem); line-height: 1; }
.m-arrow {
  font-family: var(--mono);
  font-size: clamp(0.68rem, 1.5vw, 0.84rem);
  color: var(--accent);
  white-space: nowrap;
}

/* Four clip slots, like the character-select line-up */
.m-slots { display: flex; gap: 0.45rem; }
.m-slot {
  flex: 1;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem 0;
  font-family: var(--mono);
  font-size: clamp(0.6rem, 1.3vw, 0.7rem);
  color: var(--ink-faint);
}
.m-slot.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
}

/* Mini copy of the Faces picker */
.m-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.m-pill {
  font-family: var(--mono);
  font-size: clamp(0.58rem, 1.3vw, 0.68rem);
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  color: var(--ink-dim);
  background: var(--surface-2);
}
.m-pill i { font-style: normal; color: var(--accent); }

/* Mini progress line */
.m-progressline {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.m-progressline i {
  display: block;
  height: 100%;
  width: 42%;
  border-radius: 999px;
  background: var(--accent);
}

/* Mini copy of a caption card */
.m-mockcard {
  border: 1px solid var(--border);
  border-top: 3px solid var(--voice-color);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.m-mock-eyebrow {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.72rem !important;
  letter-spacing: 0.1em;
  color: var(--voice-color) !important;
}
.m-mock-text { color: var(--ink) !important; }
.m-mock-actions { display: flex; gap: 0.4rem; }
.m-mock-actions span {
  font-family: var(--mono);
  font-size: 0.62rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  color: var(--ink-dim);
}

.m-pageno {
  position: absolute;
  bottom: 0.7rem;
  right: 1rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-faint);
}
.sheet-back .m-pageno { right: auto; left: 1rem; }

.m-credit {
  font-family: var(--mono);
  font-size: 0.65rem !important;
  color: var(--ink-faint) !important;
  text-align: center;
}

.manual-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 1rem;
}
.manual-nav-btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.2s ease;
}
.manual-nav-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
}
.manual-nav-btn:disabled { opacity: 0.35; cursor: default; }
.manual-page-info {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  min-width: 5.5rem;
  text-align: center;
}
