:root {
  --fg: #1a1a1a;
  --muted: #6a6a6a;
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --border: #e4e7ec;
  --accent: #2558c9;
  --internal: #2a7a2a;
  --external: #1a4fb8;
  --rewrite: #a83232;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 880px; margin: 0 auto; padding: 48px 24px 80px; }

.hero { text-align: center; padding: 48px 0 24px; border-bottom: 1px solid var(--border); margin-bottom: 48px; }
.hero h1 {
  font-size: 2.8rem;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.hero h1 .emoji {
  font-size: 2.2rem; display: inline-block;
  /* keep emojis full-color, don't inherit letter-spacing */
  letter-spacing: 0; font-weight: 400;
}

.tagline-badge {
  display: inline-block;
  margin: 8px auto 16px;
  padding: 6px 18px;
  font-size: 0.95rem; font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #ff8a3d 0%, #ff6b3d 50%, #d84340 100%);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(255,107,61,0.3);
  letter-spacing: 0.01em;
}

.pr-badge-line { margin: -4px 0 18px; }
.pr-badge {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #fff4ec 0%, #ffe7d9 100%);
  border: 1px solid #ff8a3d;
  color: #b84a1e;
  font-size: 0.92rem; font-weight: 600;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(255,138,61,0.15);
  transition: all 0.15s;
}
.pr-badge:hover {
  background: linear-gradient(90deg, #ffe4cf 0%, #ffd6b7 100%);
  box-shadow: 0 2px 10px rgba(255,138,61,0.3);
  transform: translateY(-1px);
}
.pr-badge code {
  background: rgba(184,74,30,0.12);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pr-badge-sep { opacity: 0.5; }
.pr-badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ff8a3d;
  box-shadow: 0 0 0 0 rgba(255,138,61,0.7);
  animation: prBadgePulse 2s ease-out infinite;
  flex-shrink: 0;
}
@keyframes prBadgePulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,138,61,0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(255,138,61,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,138,61,0); }
}
.hero .subtitle { font-size: 1.2rem; color: var(--fg); margin: 0 auto 24px; max-width: 680px; font-weight: 500; }
.hero .authors { color: var(--muted); font-style: italic; margin: 0 0 4px; }
.hero .venue { color: var(--muted); font-size: 0.95rem; margin: 0 0 24px; }
.hero .links { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 8px 20px; border: 1px solid var(--border);
  border-radius: 999px; text-decoration: none; color: var(--fg); font-size: 0.95rem;
  background: var(--bg); transition: all 0.15s;
}
.btn:hover { background: var(--bg-alt); border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--fg); color: #fff; border-color: var(--fg);
}
.btn-primary:hover { background: #000; border-color: #000; color: #fff; }

h2 {
  font-size: 1.6rem; letter-spacing: -0.01em; margin: 48px 0 16px;
  padding-bottom: 8px; border-bottom: 2px solid var(--bg-alt);
}
h2 .emoji {
  font-size: 1.4rem; display: inline-block;
  letter-spacing: 0; font-weight: 400;
  margin: 0 2px; vertical-align: baseline;
}
h3 { font-size: 1.15rem; margin: 24px 0 12px; }
p { margin: 0 0 16px; }
em { font-style: italic; }
strong { font-weight: 600; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--bg-alt); padding: 1px 6px; border-radius: 4px; }
pre { background: var(--bg-alt); padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 0.9rem; }
pre code { background: none; padding: 0; }

/* Method section — token cards */
.tokens { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 24px 0; }
.token-card {
  padding: 20px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); transition: transform 0.15s;
}
.token-card:hover { transform: translateY(-2px); }
.token-card[data-tok="internal"] { border-top: 4px solid var(--internal); }
.token-card[data-tok="external"] { border-top: 4px solid var(--external); }
.token-card[data-tok="rewrite"]  { border-top: 4px solid var(--rewrite); }
.token-card code { display: inline-block; font-size: 0.95rem; margin-bottom: 4px; }
.token-card h3 { margin: 8px 0 4px; font-size: 1.05rem; }
.token-card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.55; }

/* Demo cases */
.case-group { margin: 32px 0; }
.case-group h3 { margin-bottom: 4px; font-size: 1.2rem; }
.case-group.internal h3 { color: var(--internal); }
.case-group.external h3 { color: var(--external); }
.case-group.rewrite  h3 { color: var(--rewrite); }
.group-desc { color: var(--muted); font-size: 0.95rem; margin-bottom: 16px; }

.case-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 14px; background: var(--bg);
  border-left: 4px solid var(--border);
}
.case-card.internal { border-left-color: var(--internal); }
.case-card.external { border-left-color: var(--external); }
.case-card.rewrite  { border-left-color: var(--rewrite); }

.case-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.case-id { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.decision-pill {
  font-family: var(--mono); font-size: 0.82rem; padding: 3px 10px; border-radius: 999px;
  color: white; font-weight: 600;
}
.decision-pill.internal { background: var(--internal); }
.decision-pill.external { background: var(--external); }
.decision-pill.rewrite  { background: var(--rewrite); }
.decision-pill.asr      { background: #555; }

/* ASR case cards — text-only, no audio player */
.case-card.asr { border-left-color: #555; }
.asr-preds .nbest-cell { padding: 4px 10px 4px 0; }
.nbest-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.nbest-line:last-child { margin-bottom: 0; }
.nbest-rank {
  display: inline-block; min-width: 18px; text-align: center;
  font-family: var(--mono); font-size: 0.75rem; color: var(--muted);
  background: var(--bg-alt); border-radius: 3px; padding: 0 4px;
}
.nbest-line code { font-size: 0.86em; }

/* WER badge for ASR cases */
.wer-badge {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 4px 0 10px; font-size: 0.85rem; font-family: var(--mono);
}
.wer-qwen { color: var(--rewrite); }
.wer-ext  { color: var(--external); }
.wer-sh   { color: var(--internal); font-weight: 600; }
.wer-arrow { color: var(--muted); }
.wer-label { color: var(--muted); font-size: 0.78rem; font-family: var(--sans); }

/* Demo subsection headers (Agent integration / Audio QA / Speech Recognition) */
#demo > h3 { margin-top: 40px; font-size: 1.35rem; color: var(--accent); }
#demo > h3:first-of-type { margin-top: 20px; }
.case-group h4 { margin-bottom: 4px; font-size: 1.1rem; }
.case-group.internal h4 { color: var(--internal); }
.case-group.external h4 { color: var(--external); }
.case-group.rewrite  h4 { color: var(--rewrite); }

/* --- Cinematic OpenClaw integration demo --- */
.integration-demo.cinematic {
  margin: 16px 0 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.integration-demo.cinematic .integ-controls {
  padding: 12px 16px; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: 10px 10px 0 0;
  border-bottom: none;
  margin: 0;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.integration-demo.cinematic .ctrl-hint {
  color: var(--muted); font-size: 0.82rem;
}
.integration-demo.cinematic .ctrl-hint kbd {
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 0.85em;
  border: 1px solid var(--border);
}

.cine-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 560px;
  background: radial-gradient(circle at 50% 45%, #141a2a 0%, #06080f 80%);
  overflow: hidden;
  border-radius: 0 0 10px 10px;
  color: #eef1f8;
  font-family: var(--sans);
}

.letterbox {
  position: absolute; left: 0; right: 0; height: 28px; background: #000;
  z-index: 20;
}
.letterbox.top    { top: 0; }
.letterbox.bottom { bottom: 0; }

/* Act caption */
.act-caption {
  position: absolute; left: 50%; top: 44px; transform: translateX(-50%);
  text-align: center; z-index: 15;
  opacity: 0; transition: opacity 0.35s ease;
  pointer-events: none;
}
.act-caption.show { opacity: 1; }
.act-label {
  display: block; font-family: var(--mono);
  font-size: 0.82rem; letter-spacing: 0.22em; color: #7a8ab5;
  text-transform: uppercase; margin-bottom: 6px;
}
.act-title {
  display: block;
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
  color: #fff;
  max-width: 620px; margin: 0 auto;
  line-height: 1.25;
}

/* Task badge in corner */
.task-badge {
  position: absolute; right: 20px; top: 44px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(37,88,201,0.18);
  border: 1px solid rgba(134,163,226,0.45);
  backdrop-filter: blur(6px);
  font-size: 0.82rem; color: #d2deff;
  opacity: 0; transform: translateX(12px);
  transition: opacity 0.4s, transform 0.4s;
  z-index: 14;
}
.task-badge.show { opacity: 1; transform: translateX(0); }
.task-badge.asr   { background: rgba(42,122,42,0.25); border-color: rgba(92,170,92,0.55); color: #d4f2d4; }
.task-badge.audio { background: rgba(168,50,50,0.22); border-color: rgba(220,120,120,0.5); color: #ffd6d6; }
.task-badge .task-icon { font-size: 1.05rem; }

/* Acts — stacked absolute, only one visible at a time */
.act {
  position: absolute; inset: 80px 20px 48px;
  opacity: 0; transform: scale(0.98);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.act.show { opacity: 1; transform: scale(1); pointer-events: auto; }

/* Act 1: user bubble */
.act-1 {
  display: flex; align-items: center; justify-content: center;
}
.act-1 .chat-bubble.user {
  max-width: 520px; width: 90%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  color: #eef1f8; backdrop-filter: blur(6px);
  opacity: 1;
}
.act-1 .bubble-label { color: #a0adc6; font-weight: 700; letter-spacing: 0.05em; }
.act-1 .mic-icon { opacity: 0.85; filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)); }
.act-1 .waveform { opacity: 0.85; }
.act-1 .waveform span { background: #7ca0ff; }
.act-1 .audio-timer { color: #a0adc6; }
.act-1 .user-context {
  background: rgba(255,255,255,0.06); color: #eef1f8;
  border-left-color: #ff6b3d;
  padding: 0; border-left: none;
}

/* Task-specific user-context panels */
.task-panel {
  padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
}
.task-panel.audio_qa { border-left: 4px solid #ff8a8a; }
.task-panel.asr      { border-left: 4px solid #5cc24e; }
.task-panel-head {
  font-size: 0.82rem; font-weight: 700;
  color: #fff; margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.task-question {
  font-size: 1.02rem; font-weight: 500;
  color: #fff; margin-bottom: 10px; line-height: 1.35;
}
.mcq-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.mcq-option {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; font-size: 0.86rem;
  color: #d6deef;
}
.mcq-letter {
  display: inline-flex; width: 22px; height: 22px;
  align-items: center; justify-content: center;
  background: rgba(255,138,138,0.22);
  color: #ffb7b7; font-weight: 700;
  border-radius: 50%; font-size: 0.78rem;
  font-family: var(--mono);
  flex-shrink: 0;
}
.task-asr-note {
  font-size: 0.88rem; color: #d6deef; font-style: italic;
}

/* Task-specific final answer in Act III */
.qa-answer {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 6px 0;
}
.qa-letter {
  display: inline-flex; width: 58px; height: 58px;
  align-items: center; justify-content: center;
  border: 3px solid currentColor; border-radius: 12px;
  font-family: var(--mono); font-size: 2.2rem; font-weight: 800;
  box-shadow: 0 0 24px rgba(125,236,122,0.35);
  color: #7dec7a;
}
.qa-text {
  font-size: 1.2rem; color: #fff; text-align: left;
  font-weight: 500;
}
.asr-transcript {
  font-size: 1.15rem; color: #fff; font-style: italic;
  line-height: 1.4; padding: 4px 0;
}
.asr-transcript .asr-text { font-style: normal; }

/* Act core: central orb + lanes */
.act-core { display: flex; align-items: center; justify-content: center; }
.core-scene {
  position: relative; width: 100%; height: 100%;
  max-width: 820px; max-height: 100%;
  margin: 0 auto;
}

/* Central Speech-Hands orb */
.sh-core {
  position: absolute; left: 50%; top: 22%;
  width: 120px; height: 120px; transform: translate(-50%, 0);
  z-index: 8;
}
.core-inner {
  position: absolute; inset: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #8ec5ff 0%, #2558c9 60%, #153066 100%);
  box-shadow: 0 0 40px rgba(125,180,255,0.45), inset 0 0 20px rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  animation: core-breathe 3.2s ease-in-out infinite;
}
.core-label {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  text-align: center; color: #fff; line-height: 1.1;
  letter-spacing: 0.04em;
}
.core-ring {
  position: absolute; inset: 0; border: 2px solid rgba(125,180,255,0.55);
  border-radius: 50%;
  animation: core-ring 2.4s ease-out infinite;
}
.core-ring.slow { animation-duration: 3.6s; animation-delay: 0.8s; }
@keyframes core-breathe {
  0%,100% { transform: scale(1); box-shadow: 0 0 40px rgba(125,180,255,0.45), inset 0 0 20px rgba(255,255,255,0.15); }
  50%     { transform: scale(1.06); box-shadow: 0 0 60px rgba(125,180,255,0.65), inset 0 0 30px rgba(255,255,255,0.22); }
}
@keyframes core-ring {
  0%   { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2); opacity: 0; }
}
.sh-core.deliberating .core-inner {
  animation: core-breathe 1s ease-in-out infinite;
}
.sh-core.locked .core-inner {
  animation: core-lock 0.8s ease-out forwards;
}
@keyframes core-lock {
  0%   { transform: scale(1.1); box-shadow: 0 0 80px rgba(255,255,255,0.7); }
  100% { transform: scale(1);   box-shadow: 0 0 40px rgba(125,180,255,0.45), inset 0 0 20px rgba(255,255,255,0.15); }
}

/* 3 radial token lanes */
.lane {
  position: absolute; width: 180px; text-align: center;
  color: #eef1f8; opacity: 0.55; transition: opacity 0.4s, transform 0.4s;
  z-index: 6;
}
/* Lanes form a 3-prong fork below the core:
 *   lane-internal (left)   — directly under internal thought card
 *   lane-external (right)  — directly under external tool-call card
 *   lane-rewrite (center)  — below core, representing the synthesis
 *                            of both candidate streams. */
.lane-internal { left: 4%;   top: 62%; width: 22%; min-width: 140px; }
.lane-rewrite  { left: 39%;  top: 62%; width: 22%; min-width: 140px; }
.lane-external { left: 74%;  top: 62%; width: 22%; min-width: 140px; }

/* Default vertical line from core down to the rewrite lane */
.lane-line {
  position: absolute; background: linear-gradient(to bottom, rgba(125,180,255,0.4) 0%, rgba(125,180,255,0) 100%);
  width: 2px; height: 80px; top: -80px; left: 50%; transform: translateX(-50%); z-index: -1;
}
/* Diagonal lines for internal (from upper-right toward core) and
 * external (from upper-left toward core) */
.lane-internal .lane-line {
  left: 85%; top: -70px;
  width: 2px; height: 100px;
  transform: rotate(20deg); transform-origin: 50% 100%;
  background: linear-gradient(to bottom, rgba(125,236,122,0.4) 0%, rgba(125,236,122,0) 100%);
}
.lane-external .lane-line {
  left: 15%; top: -70px;
  width: 2px; height: 100px;
  transform: rotate(-20deg); transform-origin: 50% 100%;
  background: linear-gradient(to bottom, rgba(142,176,255,0.4) 0%, rgba(142,176,255,0) 100%);
}
.lane-rewrite .lane-line {
  background: linear-gradient(to bottom, rgba(255,138,138,0.4) 0%, rgba(255,138,138,0) 100%);
}

.lane-tok {
  padding: 12px 18px; border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 2px solid rgba(255,255,255,0.32);
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700;
  color: #fff; letter-spacing: 0.02em;
  display: inline-block;
  margin-bottom: 8px;
  transition: all 0.35s;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.lane-tok code { color: inherit; background: none; }
.lane-desc {
  font-size: 0.82rem; color: #c6d0e8;
  letter-spacing: 0.02em;
}
.lane.considering {
  opacity: 1;
}
.lane.considering .lane-tok {
  animation: lane-pulse 0.8s ease-out;
  background: rgba(125,180,255,0.35);
  border-color: rgba(180,210,255,0.9);
  color: #fff;
}
@keyframes lane-pulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(125,180,255,0.55); }
  60%  { transform: scale(1.08); box-shadow: 0 0 36px 6px rgba(180,210,255,0.55); }
  100% { transform: scale(1.02); box-shadow: 0 0 0 0 rgba(125,180,255,0); }
}
.lane.rejected {
  opacity: 0.25; transform: scale(0.85);
  filter: grayscale(0.8) brightness(0.5);
  transition: opacity 0.5s, transform 0.5s, filter 0.5s;
}
.lane.selected { opacity: 1; transform: scale(1.15); }
.lane.selected .lane-tok {
  background: var(--accent); border-color: #fff;
  color: #fff; font-weight: 700;
  box-shadow: 0 0 40px rgba(125,180,255,0.85);
  animation: lane-lock 0.6s ease-out;
}
.lane.selected[data-tok="internal"] .lane-tok {
  background: var(--internal); border-width: 3px;
  box-shadow: 0 0 60px 6px rgba(80,220,80,0.75),
              0 0 0 4px rgba(125,236,122,0.35);
}
.lane.selected[data-tok="external"] .lane-tok {
  background: var(--external); border-width: 3px;
  box-shadow: 0 0 60px 6px rgba(80,140,255,0.75),
              0 0 0 4px rgba(142,176,255,0.35);
}
.lane.selected[data-tok="rewrite"] .lane-tok {
  background: var(--rewrite); border-width: 3px;
  box-shadow: 0 0 60px 6px rgba(255,90,90,0.8),
              0 0 0 4px rgba(255,138,138,0.4);
}

/* Big "SELECTED" ribbon under the winning lane */
.lane .selected-ribbon {
  display: none;
  margin-top: 10px;
  font-family: var(--mono); font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.16em;
  padding: 4px 12px; border-radius: 4px;
  color: #fff; text-transform: uppercase;
  animation: ribbon-pop 0.5s ease-out;
}
.lane.selected .selected-ribbon { display: inline-block; }
.lane[data-tok="internal"].selected .selected-ribbon { background: var(--internal); }
.lane[data-tok="external"].selected .selected-ribbon { background: var(--external); }
.lane[data-tok="rewrite"].selected  .selected-ribbon { background: var(--rewrite); }
@keyframes ribbon-pop {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes lane-lock {
  0%   { transform: scale(0.9); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Candidate cards — prominent, left + right of core */
.cand-card-abs {
  position: absolute; width: 30%; min-width: 230px; max-width: 290px;
  padding: 14px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  color: #eef1f8;
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  z-index: 7;
  backdrop-filter: blur(6px);
}
.cand-card-abs.show { opacity: 1; transform: translateY(0); }
.cand-card-abs.internal { left: 2%;  top: 8%;  border-top: 4px solid #7dec7a; }
.cand-card-abs.external { right: 2%; top: 8%;  border-top: 4px solid #8eb0ff; }

/* role header: icon + title + subtitle explaining what this candidate IS */
.cand-card-abs .cand-role {
  display: flex; gap: 10px; align-items: flex-start;
  padding-bottom: 10px; border-bottom: 1px dashed rgba(255,255,255,0.2);
  margin-bottom: 10px;
}
.cand-card-abs .role-icon {
  font-size: 1.8rem; line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.4));
}
.cand-card-abs .role-title {
  font-size: 0.88rem; font-weight: 700; color: #fff;
  letter-spacing: 0.02em;
}
.cand-card-abs .role-sub {
  font-size: 0.74rem; color: #a0adc6; margin-top: 2px;
  font-family: var(--sans);
}
.cand-card-abs .role-sub span {
  font-family: var(--mono); color: #d2deff;
}
.cand-card-abs .cand-pred {
  font-size: 0.9rem; padding: 8px 10px;
  background: rgba(0,0,0,0.32); border-radius: 6px; line-height: 1.45;
  color: #fff;
  min-height: 34px;
}
.cand-card-abs .cand-verdict {
  margin-top: 8px; font-size: 0.82rem; opacity: 0;
  transition: opacity 0.35s; display: flex; align-items: center; gap: 6px;
  font-weight: 600;
}
.cand-card-abs .cand-verdict.show { opacity: 1; }
.cand-card-abs .cand-verdict .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 0.8rem;
}
.cand-card-abs.ok  .cand-verdict { color: #7dec7a; }
.cand-card-abs.ok  .cand-verdict .mark { background: #5cc24e; }
.cand-card-abs.bad .cand-verdict { color: #ff8a8a; }
.cand-card-abs.bad .cand-verdict .mark { background: #d64545; }

/* Giant ✓/✗ overlay that flashes on wrong/right candidate */
.cand-card-abs .big-mark {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.5);
  font-size: 4.5rem; font-weight: 900; color: transparent;
  -webkit-text-stroke: 3px currentColor;
  z-index: 10; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.35s;
}
.cand-card-abs.ok  .big-mark { color: #5cc24e; }
.cand-card-abs.bad .big-mark { color: #d64545; }
.cand-card-abs.flash .big-mark {
  opacity: 1; transform: translate(-50%,-50%) scale(1.2);
  animation: big-mark-pop 0.5s ease-out;
}
@keyframes big-mark-pop {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  60%  { transform: translate(-50%,-50%) scale(1.35); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
}

/* Particle layer */
.particle-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
}
.particle {
  position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: #7dbaff; box-shadow: 0 0 8px #7dbaff;
  opacity: 0; will-change: transform, opacity;
}

/* Decision bolt — flash that originates at the winning lane, not the center */
.decision-bolt {
  position: absolute;
  /* JS sets left / top to the winning lane's center before flashing */
  left: 50%; top: 62%;
  width: 320px; height: 320px; transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 60%);
  pointer-events: none; z-index: 9; opacity: 0;
}
.decision-bolt.flash {
  animation: bolt 0.55s ease-out;
}
@keyframes bolt {
  0%   { transform: translate(-50%,-50%) scale(0);   opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.5); opacity: 0; }
}

/* Act 3: final answer + reply */
.act-reply { display: flex; flex-direction: column; gap: 16px; justify-content: center; align-items: center; }
.final-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px; padding: 16px 24px;
  max-width: 620px; width: 92%;
  text-align: center; color: #eef1f8;
  backdrop-filter: blur(6px);
}
.final-label {
  font-size: 0.78rem; color: #8e9cbe; text-transform: uppercase;
  letter-spacing: 0.12em; margin-bottom: 6px;
}
.final-token {
  font-family: var(--mono); font-size: 1.4rem; font-weight: 700;
  margin-bottom: 10px;
}
.final-token.internal { color: #7dec7a; }
.final-token.external { color: #8eb0ff; }
.final-token.rewrite  { color: #ff8a8a; }
.final-answer {
  font-size: 1.1rem; line-height: 1.4; color: #fff;
}
.act-reply .chat-bubble.assistant {
  max-width: 520px; width: 92%;
  background: rgba(125,180,255,0.1);
  border: 1px solid rgba(125,180,255,0.3);
  color: #eef1f8;
}
.act-reply .bubble-label { color: #a0adc6; font-weight: 700; letter-spacing: 0.05em; }
.act-reply .reply { color: #eef1f8; }

/* Act 4: payoff stats */
.act-stats { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.stats-big { display: flex; gap: 48px; justify-content: center; flex-wrap: wrap; }
.stat-item { text-align: center; }
.stat-value {
  font-size: 3.6rem; font-weight: 800; color: #7dec7a;
  letter-spacing: -0.01em; line-height: 1;
  text-shadow: 0 0 30px rgba(125,220,125,0.45);
}
.stat-value.down { color: #7dec7a; }
.stat-unit { font-size: 0.45em; margin-left: 2px; color: #a0adc6; font-weight: 600; }
.stat-label {
  font-size: 0.9rem; color: #a0adc6; margin-top: 6px;
  letter-spacing: 0.02em;
}
.stats-subtitle {
  font-size: 1rem; color: #d2deff; text-align: center;
  font-style: italic; margin-top: 10px;
}

/* Tab controls below stage */
.integration-demo.cinematic .integ-tabs {
  padding: 10px 16px; background: var(--bg-alt);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 10px 10px;
  display: flex; gap: 8px; justify-content: center;
}

/* Hide the legacy case-meta footer */
.integration-demo.cinematic .case-meta { display: none; }

@media (max-width: 720px) {
  .cine-stage { aspect-ratio: 4 / 5; max-height: none; }
  .sh-core { width: 90px; height: 90px; top: 28%; }
  .lane { width: 30% !important; min-width: 0 !important; }
  .lane-internal { left: 2%;  top: 64%; }
  .lane-rewrite  { left: 35%; top: 64%; }
  .lane-external { left: 68%; top: 64%; }
  .cand-card-abs { width: 46%; min-width: 0; }
  .cand-card-abs.internal { left: 2%;  top: 6%; }
  .cand-card-abs.external { right: 2%; left: auto; top: 6%; }
  .stat-value { font-size: 2.4rem; }
  .act-title { font-size: 1.2rem; }
}
#integ-play {
  font-family: var(--sans); font-size: 1rem; padding: 10px 20px;
  border: none; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
  transition: background 0.15s, transform 0.15s;
}
#integ-play:hover { background: #1d47a6; transform: translateY(-1px); }
#integ-play:disabled { background: var(--muted); cursor: wait; }
.integ-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.integ-tabs button {
  font-size: 0.78rem; font-family: var(--sans); padding: 4px 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); cursor: pointer;
}
.integ-tabs button.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.integ-stage {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg); border-radius: 10px; padding: 16px;
  border: 1px solid var(--border);
}

/* Chat header strip */
.chat-header {
  display: flex; align-items: center; gap: 8px; padding: 2px 0 10px;
  border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--fg);
}
.chat-header .brand-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: #ff6b3d;
}
.chat-header .header-meta {
  margin-left: auto; display: flex; gap: 6px; align-items: center;
  font-size: 0.78rem;
}
.chat-header .benchmark {
  font-family: var(--mono); color: var(--fg); background: var(--bg-alt);
  padding: 2px 8px; border-radius: 999px;
}
.chat-header .routing-pill {
  font-family: var(--mono); padding: 2px 8px; border-radius: 999px;
  color: #fff; font-weight: 600;
}

/* Chat bubbles (user + assistant) */
.chat-bubble {
  max-width: 88%; padding: 12px 16px; border-radius: 14px;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0.35; transition: opacity 0.3s, box-shadow 0.3s;
}
.chat-bubble.active { opacity: 1; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.chat-bubble.user {
  align-self: flex-end; background: #fff8f3; border: 1px solid #ffd6bd;
}
.chat-bubble.assistant {
  align-self: flex-start; background: #eef1fe; border: 1px solid #c9d4ff;
}
.bubble-label {
  font-size: 0.75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px;
  font-weight: 600;
}

.mic-row { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.mic-icon {
  font-size: 1.8rem; opacity: 0.5; transition: opacity 0.2s, transform 0.2s;
}
.chat-bubble.user.speaking .mic-icon {
  opacity: 1; animation: mic-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes mic-pulse {
  0% { transform: scale(1); }  100% { transform: scale(1.15); }
}
.waveform {
  display: flex; align-items: flex-end; gap: 3px;
  height: 24px; opacity: 0.3; transition: opacity 0.2s; flex: 1;
}
.waveform span {
  display: inline-block; flex: 1; background: var(--accent);
  height: 40%; border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite alternate paused;
}
.chat-bubble.user.speaking .waveform { opacity: 1; }
.chat-bubble.user.speaking .waveform span { animation-play-state: running; }
.waveform span:nth-child(2) { animation-delay: 0.05s; height: 60%; }
.waveform span:nth-child(3) { animation-delay: 0.10s; height: 80%; }
.waveform span:nth-child(4) { animation-delay: 0.15s; height: 100%; }
.waveform span:nth-child(5) { animation-delay: 0.20s; height: 90%; }
.waveform span:nth-child(6) { animation-delay: 0.25s; height: 70%; }
.waveform span:nth-child(7) { animation-delay: 0.30s; height: 55%; }
.waveform span:nth-child(8) { animation-delay: 0.35s; height: 40%; }
.waveform span:nth-child(9) { animation-delay: 0.40s; height: 30%; }
@keyframes wave { 0% { transform: scaleY(0.3); } 100% { transform: scaleY(1); } }
.audio-timer {
  font-family: var(--mono); font-size: 0.75rem; color: var(--muted);
  min-width: 38px;
}
.user-context {
  font-size: 0.92rem; line-height: 1.5;
  padding: 8px 10px; background: #fff; border-radius: 8px;
  border-left: 3px solid #ff6b3d;
  opacity: 0; transition: opacity 0.4s;
}
.user-context.show { opacity: 1; }

/* Tool-call indicator between bubbles and skill panel */
.tool-call-label {
  display: flex; align-items: center; gap: 10px; padding: 2px 0;
  opacity: 0.35; transition: opacity 0.3s;
}
.tool-call-label.active { opacity: 1; }
.tool-call-label .dotline {
  flex: 1; height: 1px;
  background: repeating-linear-gradient(to right, var(--border) 0, var(--border) 4px, transparent 4px, transparent 8px);
}
.tool-call-label .tool-name {
  font-size: 0.82rem; color: var(--muted); font-family: var(--sans);
  white-space: nowrap;
}
.tool-call-label .tool-name code {
  background: var(--bg-alt); padding: 1px 6px; border-radius: 4px;
  font-size: 0.85em; color: var(--fg);
}
.tool-call-label.active .tool-name {
  color: var(--accent); font-weight: 600;
}
.tool-call-label.return.active .tool-name {
  color: var(--internal);
}

/* Speech-Hands inspection panel */
.sh-panel {
  background: linear-gradient(180deg, #fafbfd 0%, #eef2f8 100%);
  border: 2px solid var(--border);
  border-radius: 12px; padding: 16px;
  opacity: 0.35; transition: opacity 0.4s, border-color 0.3s;
}
.sh-panel.active { opacity: 1; border-color: var(--accent); }
.sh-panel-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.sh-badge {
  background: var(--accent); color: #fff; padding: 4px 10px;
  border-radius: 6px; font-size: 0.82rem; font-weight: 600;
}
.sh-panel-subtitle { color: var(--muted); font-size: 0.85rem; }

/* Candidate row */
.cand-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 16px;
}
.cand-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.45s, transform 0.45s, border-color 0.3s, box-shadow 0.3s;
}
.cand-card.show { opacity: 1; transform: translateY(0); }
.cand-card.internal { border-top: 4px solid var(--internal); }
.cand-card.external { border-top: 4px solid var(--external); }
.cand-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600;
}
.cand-head .src-pill {
  background: var(--bg-alt); padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono); text-transform: none;
  font-size: 0.75rem; letter-spacing: 0;
}
.cand-pred {
  font-size: 0.9rem; line-height: 1.45; color: var(--fg);
  padding: 8px 10px; background: var(--bg-alt); border-radius: 6px;
  min-height: 36px;
}
.cand-verdict {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 600; opacity: 0;
  transition: opacity 0.4s;
  padding: 2px 0;
}
.cand-verdict.show { opacity: 1; }
.cand-verdict.ok    { color: var(--internal); }
.cand-verdict.bad   { color: var(--rewrite); }
.cand-verdict .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  color: #fff; font-size: 0.72rem; font-weight: 700;
}
.cand-verdict.ok .mark  { background: var(--internal); }
.cand-verdict.bad .mark { background: var(--rewrite); }

/* Action-token decision */
.decision-row {
  padding: 12px 0 0; border-top: 1px dashed var(--border);
  margin-top: 8px;
}
.decision-label {
  font-size: 0.82rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600; margin-bottom: 8px;
}
.tok-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
}
.tok-card {
  background: #fff; border: 2px solid var(--border); border-radius: 10px;
  padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  opacity: 0.55;
  transition: opacity 0.3s, transform 0.35s, border-color 0.3s, box-shadow 0.3s;
  position: relative;
}
.tok-card code { font-size: 0.95rem; font-weight: 600; }
.tok-card[data-tok="internal"] code { color: var(--internal); }
.tok-card[data-tok="external"] code { color: var(--external); }
.tok-card[data-tok="rewrite"]  code { color: var(--rewrite); }
.tok-desc {
  font-size: 0.78rem; color: var(--muted); line-height: 1.4;
}
.tok-verdict {
  display: none; margin-top: 4px;
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; padding: 3px 10px; border-radius: 999px;
  color: #fff;
}
.tok-card.active {
  opacity: 1; transform: scale(1.06);
  animation: tok-select 0.9s ease-out;
}
.tok-card.active .tok-verdict { display: inline-block; }
.tok-card[data-tok="internal"].active {
  border-color: var(--internal); box-shadow: 0 4px 14px rgba(42,122,42,0.28);
}
.tok-card[data-tok="internal"].active .tok-verdict { background: var(--internal); content: "SELECTED"; }
.tok-card[data-tok="external"].active {
  border-color: var(--external); box-shadow: 0 4px 14px rgba(26,79,184,0.28);
}
.tok-card[data-tok="external"].active .tok-verdict { background: var(--external); }
.tok-card[data-tok="rewrite"].active {
  border-color: var(--rewrite); box-shadow: 0 4px 14px rgba(168,50,50,0.28);
}
.tok-card[data-tok="rewrite"].active .tok-verdict { background: var(--rewrite); }
@keyframes tok-select {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.16); }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1.06); }
}

.sh-final {
  margin-top: 14px;
  font-size: 0.95rem; background: #fff; padding: 12px 14px;
  border-radius: 8px; border-left: 4px solid var(--internal);
  opacity: 0; transition: opacity 0.4s;
}
.sh-final.show { opacity: 1; }
.sh-final .fin-label {
  display: block; font-size: 0.74rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-bottom: 4px;
}
.sh-final code { font-weight: 600; color: var(--internal); }

/* Assistant reply bubble */
.reply {
  font-size: 0.95rem; line-height: 1.5; padding: 6px 0;
  opacity: 0; transition: opacity 0.4s;
}
.reply.show { opacity: 1; }

@media (max-width: 800px) {
  .cand-row { grid-template-columns: 1fr; }
  .tok-row  { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 100%; }
}

.case-question { margin: 8px 0; font-size: 1rem; }
.case-choices { font-family: var(--mono); font-size: 0.88rem; white-space: pre-wrap; margin: 8px 0 12px; padding: 10px 14px; }

.case-card audio { width: 100%; height: 36px; margin: 8px 0 12px; }

.preds { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 0.92rem; }
.preds td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.preds td:first-child { color: var(--muted); width: 40%; }
.preds td code { font-size: 0.88em; }
.preds tr.final td { font-weight: 600; background: #fafcff; }
.preds tr:last-child td { border-bottom: none; }

/* Method figures */
.method-figure { margin: 24px 0 32px; padding: 0; text-align: center; }
.method-figure img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.method-figure figcaption {
  color: var(--muted); font-size: 0.9rem; margin-top: 10px; text-align: left;
  line-height: 1.5;
}

/* Result tables */
.table-lede { color: var(--muted); font-size: 0.94rem; margin: 4px 0 12px; }
.table-wrap { overflow-x: auto; margin: 12px 0 28px; border: 1px solid var(--border); border-radius: 8px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--bg); }
.results-table th, .results-table td {
  text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.results-table th:first-child, .results-table td:first-child { text-align: left; }
.results-table th { background: var(--bg-alt); font-weight: 600; font-size: 0.88rem; color: var(--fg); }
.results-table th.final-col, .results-table td.final-col { background: #fafcff; border-left: 1px solid var(--border); }
.results-table .section-row td {
  text-align: left; font-weight: 600; font-size: 0.85rem;
  background: #eef1f6; color: var(--fg); padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.results-table .section-row.cascaded td { background: #fff4e6; }
.results-table .section-row.speech-hands td { background: #e6f4ea; color: var(--internal); }
.results-table .section-row.f1 td { background: #eaf0fd; }
.results-table tr.best { background: #f0f7ff; }
.results-table tr.best td { font-weight: 600; }
.results-table tr:last-child td { border-bottom: none; }
.results-table b { color: var(--accent); }
.token-table td { font-variant-numeric: tabular-nums; }

.note { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

/* BibTeX */
#bibtex pre { font-size: 0.85rem; line-height: 1.5; }

footer {
  margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.88rem; text-align: center;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

@media (max-width: 600px) {
  main { padding: 24px 16px 60px; }
  .hero h1 { font-size: 2.2rem; }
  .hero .subtitle { font-size: 1rem; }
  .tokens { grid-template-columns: 1fr; }
}
