:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1a1f2b;
  --text: #e7ecf3;
  --muted: #8a93a6;
  --accent: #5aa0ff;
  --accent-2: #8b5cf6;
  --listening: #22c55e;
  --thinking: #f59e0b;
  --speaking: #8b5cf6;
  --danger: #ef4444;
  --border: #232838;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.brand h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.brand .subtitle { margin: 4px 0 0; color: var(--muted); }

.voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin: 48px 0;
}

/* --- Orb: layered core + ring + spinner --- */
.orb {
  position: relative;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}
.orb-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2) 60%, #1a1f2e 100%);
  box-shadow: 0 0 60px rgba(90, 160, 255, 0.30);
  transition: transform 0.35s ease, box-shadow 0.35s ease, filter 0.35s ease;
}
.orb-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.orb-spinner {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.08);
  border-top-color: rgba(255,255,255,0.9);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* State-driven orb styling (body[data-state="..."]) */
body[data-state="idle"] .orb-core {
  filter: saturate(0.7) brightness(0.85);
}
body[data-state="listening"] .orb-core {
  background: radial-gradient(circle at 30% 30%, #6ee7a8, var(--listening) 55%, #0f2a17 100%);
  box-shadow: 0 0 70px rgba(34, 197, 94, 0.55);
  animation: pulse-soft 1.4s ease-in-out infinite;
}
body[data-state="listening"] .orb-ring {
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.6);
  animation: ring-pulse 1.4s ease-out infinite;
}
body[data-state="thinking"] .orb-core {
  background: radial-gradient(circle at 30% 30%, #fcd34d, var(--thinking) 55%, #3b2410 100%);
  box-shadow: 0 0 70px rgba(245, 158, 11, 0.45);
  filter: brightness(0.65);
}
body[data-state="thinking"] .orb-spinner { opacity: 1; animation: spin 1s linear infinite; }
body[data-state="speaking"] .orb-core {
  background: radial-gradient(circle at 30% 30%, #c4b5fd, var(--speaking) 55%, #2a1852 100%);
  box-shadow: 0 0 80px rgba(139, 92, 246, 0.65);
  animation: pulse-strong 0.8s ease-in-out infinite;
}
body[data-state="error"] .orb-core {
  background: radial-gradient(circle at 30% 30%, #fca5a5, var(--danger) 55%, #3b0a0a 100%);
  box-shadow: 0 0 70px rgba(239, 68, 68, 0.45);
}
body[data-state="reconnecting"] .orb-core { filter: brightness(0.5) saturate(0.4); }
body[data-state="reconnecting"] .orb-spinner { opacity: 1; animation: spin 1.2s linear infinite; }
body[data-state="booting"] .orb-core { filter: brightness(0.5) saturate(0.4); }

@keyframes pulse-soft { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes pulse-strong { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes ring-pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- Mic button with state-aware icon swap --- */
.mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 6px 24px rgba(90, 160, 255, 0.35);
}
.mic-btn:hover:not(:disabled) { transform: scale(1.05); }
.mic-btn:disabled { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
.mic-btn .stop-icon { display: none; }

body[data-state="listening"] .mic-btn {
  background: var(--danger);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.4);
}
body[data-state="listening"] .mic-btn .mic-icon { display: none; }
body[data-state="listening"] .mic-btn .stop-icon { display: block; }

body[data-state="speaking"] .mic-btn {
  background: var(--speaking);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.4);
}

body[data-state="thinking"] .mic-btn,
body[data-state="booting"] .mic-btn,
body[data-state="reconnecting"] .mic-btn {
  background: var(--panel-2);
  color: var(--muted);
}

/* --- Status + hint labels --- */
.status {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  min-height: 1.4em;
}
.hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}
body[data-state="error"] .status { color: var(--danger); }

/* --- Broker card --- */
.broker-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
}
.broker-card h2 { margin: 0 0 8px; font-size: 16px; color: var(--muted); font-weight: 500; }
.broker-card p { margin: 4px 0; }
.call-link {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 18px;
  background: var(--listening);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
}

/* --- Transcript --- */
.transcript-wrapper h2 {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.transcript {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-height: 360px;
  overflow-y: auto;
}
.transcript-line { margin-bottom: 12px; }
.transcript-line .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}
.transcript-line.user .label { color: var(--accent); }
.transcript-line.agent .label { color: var(--accent-2); }

/* --- Debug overlay (Alt+D) --- */
.debug-overlay {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: rgba(10, 12, 20, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  z-index: 50;
  backdrop-filter: blur(6px);
  min-width: 200px;
}
.debug-overlay[hidden] { display: none; }
.debug-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.debug-row code { color: var(--text); }
.debug-hint { margin-top: 6px; color: var(--border); font-size: 10px; text-align: right; }
