@font-face {
  font-family: "Outfit";
  src: url("/assets/fonts/outfit-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, sans-serif;
  background: #100f0e;
  color: #f0ede7;
  --surface: #1b1916;
  --line: #39342d;
  --muted: #b7afa2;
  --accent: #ffce75;
  --accent-light: #ffe4a6;
  --radius: 22px;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html:has(body.demo) { scrollbar-gutter: stable both-edges; }
body {
  margin: 0;
  min-width: 290px;
  min-height: 100vh;
  background: radial-gradient(ellipse at 32% 5%, #292117 0, transparent 56%), #100f0e;
}

body.demo {
  --accent: #82e1fa;
  --accent-light: #b7eeff;
  --muted: #9aaec3;
  font-family: "Outfit", system-ui, sans-serif;
  color: #e3f0fa;
  background:
    radial-gradient(ellipse at 50% 35%, #0c2036 0%, #080f1c 39%, transparent 68%),
    #060a12;
}
button, textarea { font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .53; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.workspace {
  --hud-size: min(calc(100vw - 32px), 37rem, 67svh);
  width: min(100% - 32px, 42rem);
  min-height: 100svh;
  margin-inline: auto;
  padding-block: max(18px, calc((100svh - var(--hud-size) - 13rem) / 2)) clamp(18px, 4svh, 48px);
  display: grid;
  align-content: start;
  gap: clamp(20px, 4svh, 38px);
}

.voice {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 12px;
}

.face {
  position: relative;
  width: var(--hud-size);
  max-width: 100%;
  --voice-level: 0;
  --hud-signal: #6bcbe9;
  --hud-strength: .47;
  --hud-scan: .42;
  --hud-packet-light: .68;
  color: var(--hud-signal);
}

.hud {
  display: block;
  width: 100%;
  height: auto;
}

.camera-preview {
  position: absolute;
  z-index: 1;
  inset: 50% auto auto 50%;
  display: block;
  width: 38%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  background: #070e17;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.86);
  transition: opacity 360ms ease, transform 620ms cubic-bezier(.2, .75, .25, 1);
}

.face[data-camera="active"] .camera-preview {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition-delay: 160ms;
}

.hud__static > circle:first-child { fill: var(--hud-field-fill, url("#hud-field")); }
.hud__core > circle:first-child { fill: var(--hud-field-fill, url("#hud-center")); }

.hud__rim, .hud__orbit, .hud__scan, .hud__core, .hud__pulse, .hud__trace,
.hud__segments, .hud__packets, .hud__beacons, .hud__listen-scan, .hud__thinking-rings {
  transform-box: view-box;
  transform-origin: center;
}

.hud__rim { animation: hud-rotation 96s linear infinite reverse; }
.hud__orbit { animation: hud-rotation 34s linear infinite; }
.hud__orbit--counter { animation-duration: 24s; animation-direction: reverse; }

.hud__segments {
  animation: hud-rotation 19s linear infinite reverse;
  opacity: calc(.78 + var(--voice-level) * .22);
}

.hud__packets {
  animation: hud-rotation 12s linear infinite;
  opacity: calc(var(--hud-packet-light) + var(--voice-level) * .24);
  scale: calc(1 + var(--voice-level) * .038);
  transition: opacity 180ms ease-out, scale 140ms ease-out;
}

.hud__packet--glint {
  animation: hud-glint 2.8s ease-in-out infinite;
}

.hud__packet--glint:nth-child(even) { animation-delay: -1.35s; }

.hud__beacons {
  animation: hud-rotation 37s linear infinite reverse;
  opacity: calc(.76 + var(--voice-level) * .24);
}

.hud__scan {
  animation: hud-rotation 12s linear infinite;
  opacity: var(--hud-scan);
  transition: opacity 240ms ease;
}

.hud__trace {
  animation: hud-rotation 17s linear infinite reverse;
  opacity: calc(var(--hud-strength) + var(--voice-level) * .32);
  transition: opacity 140ms linear;
}

.hud__eq-guide {
  stroke: #407f9f;
  stroke-width: .8;
  opacity: .62;
}

.hud__eq-bars .hud__bar {
  fill: var(--hud-eq-fill, url("#hud-eq-light"));
  stroke: none;
}

.hud__wave {
  stroke: currentColor;
  stroke-width: .9;
  stroke-linejoin: round;
  opacity: calc(.26 + var(--voice-level) * .44);
}

.hud__core {
  transform: scale(calc(1 + var(--voice-level) * .055));
  transition: transform 110ms ease-out;
}

.hud__pulse {
  opacity: calc(.4 + var(--voice-level) * .55);
  transform: scale(calc(1 + var(--voice-level) * .09));
  transition: opacity 140ms linear, transform 140ms ease-out;
}

.hud__error-ripples, .hud__listen-scan, .hud__thinking-rings { display: none; }

.hud__listen-scan {
  color: #a4ffcd;
  animation: hud-rotation 7s linear infinite reverse;
  opacity: calc(.67 + var(--voice-level) * .32);
  transition: opacity 140ms ease-out;
}

.hud__listen-scan path { stroke: currentColor; }
.hud__listen-scan circle { fill: currentColor; }

.hud__wordmark, .hud__full-name {
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 500ms ease, transform 680ms cubic-bezier(.22, .72, .28, 1);
}

.hud__full-name {
  fill: #bbd1e3;
}

.hud__camera-name-orbit {
  visibility: hidden;
  opacity: 0;
  transform-box: view-box;
  transform-origin: center;
}

.hud__camera-wordmark {
  fill: #e8f7ff;
  stroke: #08111e;
  stroke-width: 2;
  paint-order: stroke;
  font-weight: 700;
  letter-spacing: .14em;
}

.face[data-camera="active"] .hud__wordmark {
  opacity: 0;
  transform: translateY(-102px) scale(.56);
}

.face[data-camera="active"] .hud__full-name {
  opacity: 0;
  transform: translateY(12px);
}

.face[data-camera="active"] .hud__camera-name-orbit {
  visibility: visible;
  opacity: 1;
  transition: opacity 420ms ease 470ms;
  animation: hud-rotation 18s linear 650ms infinite;
}

.face:is([data-state="listening"], [data-state="thinking"], [data-state="error"])
  .hud__full-name {
  fill: #dce5ec;
  fill: color-mix(in srgb, currentColor 40%, #dce5ec);
}

.face[data-state="connecting"] {
  --hud-strength: .64;
  --hud-scan: .74;
}

.face[data-state="listening"] {
  --hud-signal: #5eefa3;
  --hud-strength: .87;
  --hud-scan: .75;
  --hud-packet-light: .86;
  --hud-field-fill: url("#hud-field-listening");
  --hud-eq-fill: url("#hud-eq-listening");
}

.face[data-state="listening"] .hud__listen-scan { display: inline; }
.face[data-state="listening"] .hud__static [stroke] { stroke: #286251; }

.face[data-state="listening"] :is(.hud__core [stroke], .hud__pulse [stroke], .hud__eq-guide) {
  stroke: #5bba8a;
}

.face[data-state="listening"] :is(.hud__packets, .hud__beacons) > use {
  color: #a3ffca;
  fill: currentColor;
}

.face[data-state="listening"] :is(.hud__rim, .hud__scan, .hud__orbit) circle { fill: #b7ffda; }
.face[data-state="listening"] .hud__scan path:first-child { fill: #66efa5; fill-opacity: .12; }
.face[data-state="listening"] .hud__scan path[stroke] { stroke: currentColor; }
.face[data-state="listening"] .hud__wordmark { fill: #dcffe9; }

.face[data-state="thinking"] {
  --hud-signal: #ffab58;
  --hud-strength: .76;
  --hud-scan: .62;
  --hud-packet-light: .76;
  --hud-field-fill: url("#hud-field-thinking") #21150b;
  --hud-eq-fill: url("#hud-eq-thinking") #f1a259;
}

.face[data-state="thinking"] .hud__static [stroke] { stroke: #754d33; }

.face[data-state="thinking"] :is(.hud__core [stroke], .hud__pulse [stroke], .hud__eq-guide) {
  stroke: #c9824a;
}

.face[data-state="thinking"] :is(.hud__packets, .hud__beacons) > use {
  color: #ffc184;
  fill: currentColor;
}

.face[data-state="thinking"] :is(.hud__rim, .hud__scan, .hud__orbit) circle { fill: #ffd1a0; }
.face[data-state="thinking"] .hud__scan path:first-child { fill: #ffab58; fill-opacity: .12; }
.face[data-state="thinking"] .hud__scan path[stroke] { stroke: currentColor; }
.face[data-state="thinking"] .hud__wordmark { fill: #ffeacf; }

.face[data-state="thinking"] .hud__thinking-rings {
  display: inline;
  stroke: currentColor;
  animation: hud-thinking-breath 3.8s ease-in-out infinite;
}

.face[data-state="thinking"] .hud__pulse {
  animation: hud-thinking-breath 3.8s -.7s ease-in-out infinite;
}

.face[data-state="thinking"] .hud__trace {
  animation: hud-rotation 17s linear infinite reverse, hud-thinking-glow 3.8s ease-in-out infinite;
}

.face[data-state="speaking"] {
  --hud-signal: #b1f1ff;
  --hud-strength: .68;
  --hud-scan: .66;
  --hud-packet-light: .76;
}

.face[data-state="error"] {
  --hud-signal: #ff6575;
  --hud-strength: .92;
  --hud-scan: .74;
  --hud-packet-light: .8;
  --hud-field-fill: url("#hud-field-alert");
  --hud-eq-fill: url("#hud-eq-alert");
}

.face:is([data-state="listening"], [data-state="thinking"], [data-state="error"])
  :is(.hud__rim, .hud__orbit, .hud__segments) [stroke] {
  stroke: currentColor;
}

.face[data-state="error"] .hud__static [stroke] { stroke: #713040; }

.face[data-state="error"] :is(.hud__core [stroke], .hud__pulse [stroke], .hud__eq-guide) {
  stroke: #b94a5c;
}

.face[data-state="error"] :is(.hud__packets, .hud__beacons) > use {
  color: #ff969f;
  fill: currentColor;
}

.face[data-state="error"] :is(.hud__rim, .hud__scan, .hud__orbit) circle {
  fill: #ffc0bc;
}

.face[data-state="error"] .hud__scan path:first-child { fill: #ff5f71; fill-opacity: .14; }
.face[data-state="error"] .hud__scan path[stroke] { stroke: currentColor; }
.face[data-state="error"] .hud__wordmark { fill: #ffe6e8; }
.face[data-state="error"] .hud__error-ripples { display: inline; }

.hud__error-ripples circle {
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: .44;
  transform-box: view-box;
  transform-origin: center;
  animation: hud-error-ripple 2.8s ease-out infinite;
}

.hud__error-ripples circle + circle {
  stroke-width: 2.2;
  animation-delay: -1.4s;
}

.face[data-state="connecting"] .hud__pulse {
  animation: hud-ping 1.65s ease-out infinite;
}

@keyframes hud-rotation { to { transform: rotate(360deg); } }

@keyframes hud-glint {
  0%, 100% { opacity: .33; }
  28%, 64% { opacity: 1; }
}

@keyframes hud-ping {
  from { opacity: .8; transform: scale(.99); }
  to { opacity: .15; transform: scale(1.09); }
}

@keyframes hud-thinking-breath {
  0%, 100% { opacity: .34; transform: scale(.985); }
  50% { opacity: .9; transform: scale(1.045); }
}

@keyframes hud-thinking-glow {
  0%, 100% { opacity: .54; }
  50% { opacity: .93; }
}

@keyframes hud-error-ripple {
  from { opacity: .75; transform: scale(.91); }
  to { opacity: 0; transform: scale(1.5); }
}

.voice-controls {
  display: grid;
  justify-items: center;
  text-align: center;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.5;
}

.voice:has(.face[data-state="listening"]) .status { color: #99ffbe; }
.voice:has(.face[data-state="thinking"]) .status { color: #ffc088; }
.voice:has(.face[data-state="speaking"]) .status { color: var(--accent); }
.voice:has(.face[data-state="error"]) .status { color: #ff9eaa; }

.voice-controls__buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 13px;
}

.wake-button, .end-button, .camera-button {
  min-height: 48px;
  padding: 10px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  font-weight: 700;
}

.wake-button {
  background: var(--accent);
  color: #071827;
}

.wake-button:not(:disabled):hover { background: var(--accent-light); }
.wake-button svg, .send-button svg, .camera-button svg { width: 21px; height: 21px; }
.end-button, .camera-button { background: #152539; color: #dcebf6; }
.end-button:hover, .camera-button:not(:disabled):hover { background: #1d344c; }

.voice:has(.face[data-camera="active"]) .camera-button {
  background: #223b52;
  color: #c6f4ff;
}

.notice {
  max-width: 48ch;
  margin: 16px 0 0;
  color: #f0c2ae;
  font-size: .9rem;
  line-height: 1.5;
}
.notice button {
  padding: .18rem .25rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .15em;
}

.chat {
  width: min(100%, 32rem);
  min-width: 0;
  margin-inline: auto;
  display: grid;
  gap: 8px;
}

.chat-log {
  max-height: min(26svh, 14rem);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 3px 6px;
  scrollbar-color: #3a566e transparent;
}

.chat-empty {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
}

.message {
  width: fit-content;
  max-width: 95%;
  padding: 3px 0;
  overflow-wrap: anywhere;
}

.message--user { align-self: flex-end; color: #a6eafa; }
.message__label { display: block; margin: 0 0 3px; color: var(--muted); font-size: .875rem; font-weight: 650; }
.message--user .message__label { text-align: right; }
.message__text { margin: 0; line-height: 1.5; white-space: pre-wrap; }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 5px;
  border-radius: 9px;
  background: #101b2c;
}
.chat-form:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.chat-form textarea {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 6px 10px 9px;
  border: 0;
  background: transparent;
  color: #e2effa;
  line-height: 1.5;
  resize: vertical;
}
.chat-form textarea::placeholder { color: #9aaec3; }
.chat-form textarea:focus-visible { outline: none; }
.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #1a3045;
  color: var(--accent);
}
.send-button:not(:disabled):hover { background: #243f58; }
.noscript { color: var(--muted); }

@media (max-width: 420px) {
  .workspace {
    --hud-size: min(calc(100vw - 32px), 58svh);
    gap: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud__rim, .hud__orbit, .hud__scan, .hud__core, .hud__pulse, .hud__trace,
  .hud__segments, .hud__packets, .hud__packet--glint, .hud__beacons,
  .hud__error-ripples circle, .hud__listen-scan, .hud__thinking-rings,
  .hud__camera-name-orbit, .hud__wordmark, .hud__full-name {
    animation: none !important;
    transition: none;
    transform: none;
    scale: none;
  }

  .camera-preview { transition: none; }
  .hud__error-ripples circle + circle { display: none; }
}
