:root {
  color-scheme: dark;
  --color-paper: oklch(15% 0.008 60);
  --color-panel: oklch(21% 0.009 60);
  --color-ink: oklch(95% 0.009 75);
  --color-muted: oklch(72% 0.012 75);
  --color-line: oklch(34% 0.012 60);
  --color-accent: oklch(80% 0.1 72);
  --color-accent-ink: oklch(18% 0.02 72);
  --color-stop: oklch(54% 0.19 26);
  --color-error: oklch(79% 0.12 26);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

body {
  min-height: 100svh;
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font: 16px system-ui, sans-serif;
}

header { padding: 32px clamp(24px, 5vw, 64px); }
header h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.06em; }
header span { margin-left: 5px; color: var(--color-accent); }

main {
  padding: 9svh 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.voice-mark {
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  position: relative;
  margin-bottom: 44px;
}

.halo {
  position: absolute;
  width: 208px;
  height: 208px;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  opacity: 0.65;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

.voice-core {
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 50%;
  background: var(--color-panel);
}

.voice-core span {
  width: 5px;
  height: 28px;
  background: var(--color-accent);
  border-radius: 8px;
  transform: scaleY(0.6);
}

.voice-core span:nth-child(2), .voice-core span:nth-child(4) { height: 48px; }
.voice-core span:nth-child(3) { height: 64px; }

#status {
  color: var(--color-muted);
  min-height: 24px;
  margin: 0 0 24px;
}

.talk {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 176px;
  min-height: 60px;
  border: 0;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font: 600 18px system-ui, sans-serif;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}

.talk:hover { transform: translateY(-2px); }
.talk:active { transform: translateY(1px); }
.talk:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 5px; }
.talk svg { width: 24px; height: 24px; }
.talk .microphone { stroke: currentColor; stroke-width: 1.7; }
.talk .pause { display: none; fill: currentColor; }
.talk.is-active { background: var(--color-stop); color: var(--color-ink); }
.talk.is-active .microphone { display: none; }
.talk.is-active .pause { display: block; }

.captions {
  width: min(100%, 560px);
  margin-top: 32px;
  text-align: center;
  line-height: 1.8;
}

.captions p {
  margin: 0 0 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.captions .user { color: var(--color-muted); }
.captions p:empty, #notice:empty { display: none; }
#notice { color: var(--color-error); text-align: center; }

:is([data-state="listening"], [data-state="responding"], [data-state="speaking"]) .halo {
  transform: scale(1.08);
  opacity: 1;
  border-color: var(--color-accent);
}

[data-state="speaking"] .voice-core span { animation: voice 800ms var(--ease-out) infinite alternate; }
[data-state="speaking"] .voice-core span:nth-child(2n) { animation-delay: -350ms; }
[data-state="connecting"] .voice-mark { opacity: 0.55; }

@keyframes voice { to { transform: scaleY(1); } }

@media (max-width: 414px) {
  header { padding: 24px; }
  main { padding-top: 6svh; }
  .voice-mark { margin-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .halo, .talk { transition: none; }
  [data-state="speaking"] .voice-core span { animation: none; }
}
