:root {
  --bg: #0b1320;
  --bg-glow: #12305a;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #eef2f7;
  --muted: #94a3b8;
  --teal: #2dd4bf;
  --gold: #f5b942;
  --red: #ef4444;
  --radius: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 24px 16px;
  display: grid;
  place-items: center;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 50% -10%, var(--bg-glow), transparent 70%),
    var(--bg);
}

.card {
  width: 100%;
  max-width: 460px;
  padding: 28px 24px 20px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #0b1320;
  background: linear-gradient(135deg, var(--gold), #f59e0b);
}

h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }

.tagline { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }

.timer {
  margin-left: auto;
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
}

.timer[data-low="true"] { color: var(--gold); border-color: rgba(245, 185, 66, 0.5); }

.call { display: flex; flex-direction: column; align-items: center; padding: 30px 0 12px; }

/* ── Orb + call button ────────────────────────────────── */
.orb {
  position: relative;
  width: 200px;
  height: 200px;
  max-width: 62vw;
  max-height: 62vw;
  display: grid;
  place-items: center;
}

.orb::before,
.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--teal);
  opacity: 0;
  pointer-events: none;
}

.call-btn {
  position: relative;
  z-index: 1;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  font: 600 1rem/1.25 inherit;
  font-family: inherit;
  color: #04201c;
  background: linear-gradient(145deg, #5eead4, var(--teal) 55%, #14b8a6);
  box-shadow: 0 12px 40px rgba(45, 212, 191, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.call-btn:hover:not(:disabled) { transform: scale(1.03); box-shadow: 0 16px 50px rgba(45, 212, 191, 0.5); }
.call-btn:active:not(:disabled) { transform: scale(0.98); }
.call-btn:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.call-btn:disabled { cursor: default; }

body[data-state="idle"] .orb::before { animation: ripple 2.8s ease-out infinite; }

body[data-state="connecting"] .call-btn,
body[data-state="waiting"] .call-btn { animation: breathe 1.2s ease-in-out infinite; }

body[data-state="live"] .call-btn {
  color: var(--text);
  background: radial-gradient(circle at 35% 30%, #1e3a5f, #0f2440);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.4), 0 12px 40px rgba(0, 0, 0, 0.4);
}

.orb[data-speaking="agent"]::before,
.orb[data-speaking="agent"]::after { border-color: var(--gold); animation: ripple 1.1s ease-out infinite; }
.orb[data-speaking="agent"]::after { animation-delay: 0.55s; }

.orb[data-speaking="user"]::before { border-color: var(--teal); animation: ripple 1.1s ease-out infinite; }

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(1.12); opacity: 0; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.96); }
}

/* ── Status + actions ─────────────────────────────────── */
.status { margin: 20px 0 0; font-size: 0.95rem; color: var(--muted); text-align: center; min-height: 1.4em; }

.error {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  text-align: center;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }

.actions button {
  font: 600 0.95rem/1 inherit;
  font-family: inherit;
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
}

.hangup { color: #fff; background: var(--red); }
.hangup:hover { background: #dc2626; }

.secondary { color: var(--text); background: transparent; border-color: var(--card-border) !important; }

/* ── Live transcript + badges ─────────────────────────── */
.live { margin-top: 18px; border-top: 1px solid var(--card-border); padding-top: 14px; }

.badges { display: flex; flex-direction: column; gap: 8px; }

.badge {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  animation: pop 0.25s ease-out;
}

.badge.booking { color: #a7f3d0; background: rgba(45, 212, 191, 0.12); border: 1px solid rgba(45, 212, 191, 0.4); }
.badge.escalation { color: #fecaca; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.45); }

@keyframes pop {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.transcript {
  margin-top: 12px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}

.transcript:empty { display: none; }

.bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  max-width: 88%;
  transition: opacity 0.2s ease;
}

.bubble[data-final="false"] { opacity: 0.65; }

.bubble .who {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}

.bubble.agent { align-self: flex-start; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--card-border); }
.bubble.user { align-self: flex-end; background: rgba(45, 212, 191, 0.12); border: 1px solid rgba(45, 212, 191, 0.3); }

.fine { margin-top: 16px; text-align: center; font-size: 0.75rem; color: var(--muted); opacity: 0.8; }

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