: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;
}

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; }
  .controls { bottom: calc(24px + var(--safe-bottom)); }
  button.primary { padding: 12px 22px; font-size: 14px; }
}
@media (max-width: 380px) {
  .brand-name { display: inline; }
}
