:root {
  --bg-0: #03060f;
  --fg: #eef2fb;
  --muted: #7d8aa8;
  --blue-1: #4ea3ff;
  --blue-2: #2b6bff;
  --green-1: #34d399;
  --green-2: #059669;
  --red-1: #ef4444;
  --red-2: #b91c1c;
  --ok: #22c55e;
  --danger: #ef4444;
  --border: rgba(120, 160, 255, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-0);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.01em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
}
#scene canvas { display: block; width: 100%; height: 100%; }

/* === Brand (top-left) === */
.brand {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 32px rgba(78, 163, 255, 0.45);
  user-select: none;
  animation: brandIn 600ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes brandIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 14px currentColor;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.brand.connected .dot {
  background: var(--ok);
  box-shadow: 0 0 22px var(--ok);
  animation: pulseDot 1.5s ease-in-out infinite;
}
.brand.error .dot { background: var(--danger); }
@keyframes pulseDot {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.25); }
}
.brand-name {
  font-family: "Inter", -apple-system, sans-serif;
  background: linear-gradient(180deg, #eef6ff 0%, #9dc3ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* === Status pill (top-right) === */
.muted {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 10;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 14, 30, 0.55);
  backdrop-filter: blur(10px);
  user-select: none;
  animation: brandIn 600ms cubic-bezier(.2,.8,.2,1) both;
}

/* === Controls (bottom-center, fixed) === */
.controls {
  position: fixed;
  left: 50%;
  bottom: calc(36px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* === Speaker picker (top-right, left of status pill) === */
.speaker-wrap {
  position: fixed;
  top: 22px;
  right: 120px;
  z-index: 10;
  display: inline-flex;
  animation: brandIn 600ms cubic-bezier(.2,.8,.2,1) both;
}

button.icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  background: rgba(8, 14, 30, 0.55);
  backdrop-filter: blur(10px);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
  cursor: pointer;
  transition: background 200ms ease, transform 180ms ease, box-shadow 220ms ease;
}
button.icon-btn:hover {
  background: rgba(20, 30, 56, 0.75);
  transform: translateY(-1px);
}
button.icon-btn[aria-expanded="true"] {
  background: rgba(20, 30, 56, 0.85);
  box-shadow: 0 0 0 1px rgba(78, 163, 255, 0.4), 0 12px 28px rgba(0, 0, 0, 0.4);
}
.speaker-label {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.85);
}

.speaker-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: rgba(8, 14, 30, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  animation: menuIn 160ms cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.speaker-menu li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
  transition: background 160ms ease;
}
.speaker-menu li:hover { background: rgba(78, 163, 255, 0.12); }
.speaker-menu li[aria-selected="true"] {
  background: rgba(78, 163, 255, 0.18);
  color: white;
}
.speaker-menu li .check {
  width: 14px;
  flex: 0 0 14px;
  color: var(--blue-1);
  opacity: 0;
}
.speaker-menu li[aria-selected="true"] .check { opacity: 1; }

button.primary {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  padding: 14px 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  /* IDLE = green (start to call) */
  background: linear-gradient(180deg, var(--green-1) 0%, var(--green-2) 100%);
  box-shadow:
    0 16px 40px rgba(5, 150, 105, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition:
    transform 220ms cubic-bezier(.2,.8,.2,1),
    box-shadow 280ms ease,
    background 280ms ease,
    filter 200ms ease;
  animation: btnFloat 4s ease-in-out infinite;
}
@keyframes btnFloat {
  0%, 100% { transform: translate(-50%, 0px); }
  50%      { transform: translate(-50%, -3px); }
}
.controls button.primary { transform: none; animation: none; }
.controls { animation: ctrlIn 700ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes ctrlIn {
  from { opacity: 0; transform: translate(-50%, 18px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
button.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 22px 48px rgba(5, 150, 105, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}
button.primary:active { transform: translateY(0) scale(0.98); }

/* LIVE = red (end call) — pulse */
button.primary.live {
  background: linear-gradient(180deg, var(--red-1) 0%, var(--red-2) 100%);
  box-shadow:
    0 16px 40px rgba(239, 68, 68, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  animation: livePulse 2.0s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% {
    box-shadow:
      0 16px 40px rgba(239, 68, 68, 0.50),
      inset 0 1px 0 rgba(255, 255, 255, 0.28),
      0 0 0 0 rgba(239, 68, 68, 0.55);
  }
  50% {
    box-shadow:
      0 16px 40px rgba(239, 68, 68, 0.65),
      inset 0 1px 0 rgba(255, 255, 255, 0.32),
      0 0 0 14px rgba(239, 68, 68, 0);
  }
}
button.primary.live:hover {
  box-shadow:
    0 22px 48px rgba(239, 68, 68, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

button.primary[disabled] { opacity: 0.7; cursor: progress; filter: saturate(0.7); }
button.primary svg { transition: transform 200ms ease; }
button.primary:hover svg { transform: scale(1.08); }

/* === Responsive === */
@media (max-width: 640px) {
  .brand { top: 18px; left: 18px; font-size: 16px; }
  .muted { top: 22px; right: 18px; font-size: 10px; padding: 5px 10px; }
  .speaker-wrap { top: 18px; right: 90px; }
  .controls { bottom: calc(24px + var(--safe-bottom)); gap: 8px; }
  button.primary { padding: 12px 22px; font-size: 14px; }
  button.icon-btn { padding: 8px 10px; font-size: 12px; }
  .speaker-label { max-width: 60px; }
  .speaker-menu { min-width: 220px; max-width: 86vw; }
}
@media (max-width: 480px) {
  .speaker-wrap { top: 56px; right: 18px; }
  .muted { top: 22px; right: 18px; }
}
@media (max-width: 380px) {
  .brand-name { display: inline; }
}
