:root {
  --bg: #0a0a0a;
  --bg-soft: #131313;
  --bg-raised: #1a1a1a;
  --line: #232323;
  --text: #f4f4f4;
  --text-dim: #888;
  --text-mute: #555;
  --amber: #f5a623;
  --amber-soft: rgba(245, 166, 35, 0.18);
  --amber-glow: rgba(245, 166, 35, 0.35);
  --red: #ef4444;
  --green: #22c55e;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-mark {
  color: var(--amber);
  font-size: 1.2em;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand-sub {
  color: var(--text-mute);
  font-size: 0.78rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-mute);
  transition: background 200ms ease, box-shadow 200ms ease;
}

body[data-state="connecting"] .status .dot { background: var(--amber); animation: pulse 1.2s infinite; }
body[data-state="live"]       .status .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,0.18); }
body[data-state="ending"]     .status .dot { background: var(--amber); animation: pulse 1.2s infinite; }
body[data-state="error"]      .status .dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--amber-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* ── Main ───────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 32px 0;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.primary-btn {
  appearance: none;
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--text);
  padding: 18px 42px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 160ms ease, transform 80ms ease, box-shadow 160ms ease;
  font-family: inherit;
  min-width: 220px;
}

.primary-btn:hover { background: rgba(245, 166, 35, 0.28); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }

body[data-state="live"] .primary-btn {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.18);
}
body[data-state="live"] .primary-btn:hover { background: rgba(239, 68, 68, 0.28); }

body[data-state="connecting"] .primary-btn,
body[data-state="ending"] .primary-btn {
  opacity: 0.6;
  pointer-events: none;
}

.meter {
  height: 4px;
  width: 220px;
  background: var(--bg-raised);
  border-radius: 2px;
  overflow: hidden;
}

.meter-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--amber);
  transition: width 60ms linear;
}

body[data-state="idle"] .meter,
body[data-state="ended"] .meter,
body[data-state="error"] .meter { opacity: 0.35; }

.hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--mono);
  letter-spacing: 0.3px;
}

/* ── Transcript ─────────────────────────────────────── */
.transcript-wrap {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 280px;
  overflow: hidden;
}

.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.transcript-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-mute);
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.transcript .placeholder {
  margin: 0;
  color: var(--text-mute);
  font-style: italic;
  text-align: center;
  padding: 32px 0;
}

.transcript .line {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: baseline;
}

.transcript .line .ts {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mute);
  white-space: nowrap;
}

.transcript .line .text { color: var(--text); }

.transcript .line.system {
  background: transparent;
  border-color: transparent;
  border-bottom: 1px dashed var(--line);
  border-radius: 0;
  padding: 6px 0;
}

.transcript .line.system .text { color: var(--text-dim); font-size: 0.85rem; font-family: var(--mono); }

.transcript .line.error .text { color: var(--red); }

/* ── Footer ─────────────────────────────────────────── */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-mute);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.ghost-btn:hover { border-color: var(--text-dim); color: var(--text); }

@media (max-width: 480px) {
  body { padding: 16px 14px 12px; }
  .primary-btn { width: 100%; min-width: 0; }
  .meter { width: 100%; }
}
