:root {
  --bg-top: #0b1026;
  --bg-bottom: #1b1450;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f5f7ff;
  --muted: #b8c0e0;
  --accent: #7dd3fc;
  --accent-2: #ff9f43;
  --ok: #6ee7b7;
  --warn: #ffd166;
  --bad: #fca5a5;
  --focus: #ffd166;
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.space {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 8%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 42% 64%, #cfe8ff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 72%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 24% 88%, #fff 50%, transparent 51%);
  opacity: 0.7;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  padding: 8px 12px;
  background: var(--warn);
  color: #111;
  border-radius: 8px;
  z-index: 10;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  text-align: center;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.console {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(6px);
}

.stage {
  position: relative;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(125, 211, 252, 0.35);
  opacity: 0;
}

.orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, #5b8cff, #2b1d7a 70%);
  box-shadow: 0 0 40px rgba(91, 140, 255, 0.45);
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.orb svg {
  width: 72px;
  height: 72px;
}

.mission {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.8em;
}

.link-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.timer {
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
  color: var(--text);
}

.call-button {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 14px 32px;
  border: 0;
  border-radius: 999px;
  color: #111;
  background: linear-gradient(90deg, var(--warn), var(--accent-2));
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 159, 67, 0.35);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.call-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font: inherit;
}

.ghost,
.danger {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.danger {
  border-color: rgba(252, 165, 165, 0.6);
  color: var(--bad);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.status {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  font-size: 0.98rem;
}

.status[data-type="info"] {
  color: var(--muted);
}

.status[data-type="success"] {
  color: var(--ok);
}

.status[data-type="warning"] {
  color: var(--warn);
}

.status[data-type="error"] {
  color: var(--bad);
}

.mic-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  max-width: 48ch;
}

body[data-state="requesting-token"] .orb,
body[data-state="initializing"] .orb,
body[data-state="registering"] .orb,
body[data-state="ready"] .orb,
body[data-state="ending"] .orb {
  transform: scale(0.96);
}

body[data-state="dialing"] .ring,
body[data-state="connected"] .ring {
  opacity: 1;
  animation: pulse 2.4s ease-out infinite;
}

body[data-state="dialing"] .ring-2,
body[data-state="connected"] .ring-2 {
  animation-delay: 0.8s;
}

body[data-state="dialing"] .ring-3,
body[data-state="connected"] .ring-3 {
  animation-delay: 1.6s;
}

body[data-state="connected"] .orb {
  box-shadow: 0 0 60px rgba(110, 231, 183, 0.55);
}

body[data-state="connected"] .dot {
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

body[data-state="error"] .dot {
  background: var(--bad);
}

body[data-state="ended"] .dot {
  background: var(--accent);
}

.how {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.how h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.step-num {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #0b1026;
  font-weight: 700;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@media (max-width: 480px) {
  .console {
    padding: 22px 16px;
  }

  .stage {
    width: 180px;
    height: 180px;
  }

  .orb {
    width: 100px;
    height: 100px;
  }

  .call-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  body[data-state="dialing"] .ring,
  body[data-state="connected"] .ring {
    opacity: 0.5;
  }
}
