:root {
  --bg-0: #0b0f1a;
  --bg-1: #12182a;
  --text: rgba(255, 255, 255, 0.88);
  --text-dim: rgba(255, 255, 255, 0.55);
  --orb-a: #8ab4f8;
  --orb-b: #c58af9;
  --orb-c: #f6aea9;
  --orb-d: #81c995;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background:
    radial-gradient(1200px 700px at 50% 35%, rgba(138, 180, 248, 0.12), transparent 60%),
    radial-gradient(900px 600px at 50% 70%, rgba(197, 138, 249, 0.1), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  color: var(--text);
  font-family: Outfit, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

.stage {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2.75rem;
  padding: 2rem;
}

.orb-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  outline: none;
}

.orb-button:focus-visible .orb {
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.45);
}

.orb {
  --size: min(42vw, 220px);
  position: relative;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 280ms ease;
}

.orb-button:hover .orb {
  transform: scale(1.03);
}

.orb__core {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85), transparent 28%),
    radial-gradient(circle at 30% 35%, var(--orb-a), transparent 55%),
    radial-gradient(circle at 70% 40%, var(--orb-b), transparent 50%),
    radial-gradient(circle at 45% 75%, var(--orb-c), transparent 55%),
    radial-gradient(circle at 65% 70%, var(--orb-d), transparent 45%),
    #5b7cfa;
  filter: saturate(1.15);
  animation: breathe 4.5s ease-in-out infinite, hue 12s linear infinite;
  box-shadow:
    inset 0 -18px 40px rgba(0, 0, 0, 0.22),
    inset 0 18px 30px rgba(255, 255, 255, 0.18);
}

.orb__glow {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(138, 180, 248, 0.45) 0%,
    rgba(197, 138, 249, 0.22) 38%,
    transparent 68%
  );
  filter: blur(18px);
  animation: pulse 4.5s ease-in-out infinite;
}

.orb__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: scale(0.92);
}

.status {
  margin: 0;
  min-height: 1.5em;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  text-align: center;
  user-select: none;
}

/* Call states */
body.is-connecting .orb__core,
body.is-live .orb__core {
  animation-duration: 2.8s, 10s;
}

body.is-connecting .status,
body.is-live .status {
  color: var(--text);
}

body.is-listening .orb__ring {
  opacity: 1;
  animation: ring 1.8s ease-out infinite;
}

body.is-speaking .orb {
  transform: scale(1.06);
}

body.is-speaking .orb__core {
  animation: speak 0.9s ease-in-out infinite, hue 8s linear infinite;
}

body.is-speaking .orb__glow {
  animation: pulse 0.9s ease-in-out infinite;
  opacity: 1;
}

body.is-error .status {
  color: #f28b82;
}

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

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.05);
  }
}

@keyframes hue {
  from {
    filter: saturate(1.15) hue-rotate(0deg);
  }
  to {
    filter: saturate(1.15) hue-rotate(360deg);
  }
}

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

@keyframes ring {
  0% {
    opacity: 0.55;
    transform: scale(0.95);
  }
  100% {
    opacity: 0;
    transform: scale(1.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb__core,
  .orb__glow,
  .orb__ring,
  body.is-speaking .orb__core,
  body.is-speaking .orb__glow,
  body.is-listening .orb__ring {
    animation: none;
  }
}
