:root {
  --bg-0: #07090f;
  --bg-1: #0d1219;
  --bg-card: rgba(20, 26, 36, 0.72);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf5;
  --text-dim: #8a97a8;
  --text-faint: #5a6473;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --accent-glow: rgba(34, 211, 238, 0.55);
  --warm: #fb7185;
  --warm-soft: rgba(251, 113, 133, 0.16);
  --ok: #34d399;
  --warn: #f59e0b;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
  --radius: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, rgba(124, 58, 237, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, var(--bg-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: 0.01em;
}

.stage {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 22px 64px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---- header ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    conic-gradient(from 220deg at 50% 50%, #22d3ee, #7c3aed, #22d3ee);
  box-shadow: 0 8px 24px -8px var(--accent-glow), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-text p {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}
.status-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-variant: tabular-nums;
}
.status-chip .status-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 transparent;
}
.status-chip[data-state="connecting"] .status-dot { background: var(--warn); animation: pulse 1.2s ease-out infinite; }
.status-chip[data-state="connected"]  .status-dot { background: var(--ok); }
.status-chip[data-state="connected"]  { color: var(--text); border-color: rgba(52, 211, 153, 0.35); }
.status-chip[data-state="error"]      .status-dot { background: var(--warm); }
.status-chip[data-state="error"]      { color: var(--warm); border-color: rgba(251, 113, 133, 0.4); }
.status-chip[data-state="ended"]      .status-dot { background: var(--text-faint); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ---- main card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* ---- orb visualizer ---- */
.orb-wrap { padding: 16px 0 6px; }
.orb {
  position: relative;
  width: 168px;
  height: 168px;
  display: grid;
  place-items: center;
  --intensity: 0;
}
.orb-core {
  width: 64px; height: 64px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #67e8f9, #22d3ee 55%, #0e7490 95%);
  box-shadow:
    0 0 30px var(--accent-glow),
    inset 0 0 16px rgba(255,255,255,0.18);
  transition: transform 120ms ease;
  transform: scale(calc(1 + var(--intensity) * 0.20));
}
.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  opacity: 0.6;
}
.orb-ring.r1 { transform: scale(0.55); }
.orb-ring.r2 { transform: scale(0.75); }
.orb-ring.r3 { transform: scale(0.95); }
.orb[data-state="connecting"] .orb-ring { animation: ring-pulse 2s ease-out infinite; }
.orb[data-state="connecting"] .orb-ring.r2 { animation-delay: 0.4s; }
.orb[data-state="connecting"] .orb-ring.r3 { animation-delay: 0.8s; }
.orb[data-state="agent-speaking"] .orb-core {
  background: radial-gradient(circle at 35% 30%, #f0abfc, #a855f7 55%, #6b21a8 95%);
  box-shadow: 0 0 36px rgba(168, 85, 247, 0.55), inset 0 0 16px rgba(255,255,255,0.20);
}
.orb[data-state="ended"] .orb-core,
.orb[data-state="idle"]  .orb-core {
  background: radial-gradient(circle at 35% 30%, #94a3b8, #475569 55%, #1f2937 95%);
  box-shadow: none;
}
@keyframes ring-pulse {
  0%   { opacity: 0.0; transform: scale(0.5); }
  60%  { opacity: 0.6; }
  100% { opacity: 0.0; transform: scale(1.05); }
}

/* ---- meters ---- */
.meters {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.meter {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 12px;
}
.meter-label {
  display: flex; justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.meter-state { color: var(--text-faint); }
.meter-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 80ms linear;
}
.meter-fill.you   { background: linear-gradient(90deg, #22d3ee, #67e8f9); }
.meter-fill.agent { background: linear-gradient(90deg, #a855f7, #f0abfc); }

/* ---- controls ---- */
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font: 600 14px/1 var(--font);
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.btn:hover { background: rgba(255,255,255,0.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(180deg, rgba(34,211,238,0.22), rgba(34,211,238,0.10));
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 10px 30px -15px var(--accent-glow);
}
.btn-primary:hover { background: linear-gradient(180deg, rgba(34,211,238,0.30), rgba(34,211,238,0.14)); }
.btn-primary[data-mode="end"] {
  background: linear-gradient(180deg, rgba(251,113,133,0.22), rgba(251,113,133,0.10));
  border-color: rgba(251, 113, 133, 0.55);
  box-shadow: 0 10px 30px -15px rgba(251,113,133,0.6);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost.is-muted { color: var(--warm); border-color: rgba(251,113,133,0.4); }

.hint {
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0 0;
  text-align: center;
}
.hint.is-error { color: var(--warm); }

/* ---- transcript ---- */
.transcript {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}
.transcript header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
}
.transcript h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 600;
}
.muted { color: var(--text-faint); font-size: 12px; }
.transcript-body {
  min-height: 80px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.transcript-body:empty::before {
  content: "no captions yet.";
  color: var(--text-faint);
  font-size: 13px;
}
.line {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.08);
}
.line:last-child { border-bottom: none; }
.line .who {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-faint);
  padding-top: 2px;
}
.line.you .who   { color: var(--accent); }
.line.agent .who { color: #d8b4fe; }
.line .text.interim { color: var(--text-dim); font-style: italic; }

/* ---- footer ---- */
.foot {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 12px;
}
.foot code { font-family: var(--mono); color: var(--text-dim); }
.foot .dot { opacity: 0.5; }

/* ---- responsive ---- */
@media (max-width: 520px) {
  .stage { padding: 28px 14px 40px; }
  .orb { width: 144px; height: 144px; }
  .meters { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .orb-ring, .status-chip[data-state="connecting"] .status-dot { animation: none !important; }
  .orb-core { transition: none; }
}
