:root {
  color-scheme: dark;
  --bg: #05060c;
  --ink: #f7fbff;
  --mute: #9eb0c8;
  --yes: #e8ff4a;
  --cyan: #3cf0ff;
  --pink: #ff5bd3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at 50% 18%, #163057 0%, transparent 42%),
    radial-gradient(circle at 20% 90%, #2a1040 0%, transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.stage {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 1.5rem;
}

.status {
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute);
  font-size: 0.85rem;
}

.status.think {
  color: var(--yes);
}

.status.hear {
  color: var(--cyan);
  text-shadow: 0 0 18px #3cf0ffaa;
}

.face {
  width: min(72vh, 560px);
  height: min(86vh, 720px);
  position: relative;
  display: grid;
  place-items: center;
  background: #05060c;
}

.face canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ring {
  display: none;
}

.ring-a {
  border-top-color: var(--cyan);
  border-right-color: #ffffff33;
  filter: drop-shadow(0 0 12px var(--cyan));
  animation: spin 7s linear infinite;
}

.ring-b {
  inset: -2%;
  border-bottom-color: var(--pink);
  border-left-color: var(--yes);
  opacity: 0.85;
  animation: spin 12s linear infinite reverse;
}

.spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--yes);
  box-shadow: 0 0 16px var(--yes);
  animation: orbit 4.8s linear infinite;
}

.s1 {
  animation-duration: 5.5s;
}

.s2 {
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
  animation-duration: 7.2s;
  animation-delay: -2s;
}

.s3 {
  background: var(--pink);
  box-shadow: 0 0 16px var(--pink);
  animation-duration: 6.1s;
  animation-delay: -4s;
}

.orb {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 50% 28%, #6ee7ff 0%, #1a4dff 34%, #091433 70%);
  box-shadow:
    0 0 40px #3cf0ff88,
    0 0 120px #1a4dff66,
    inset 0 -30px 50px #050814aa;
  animation: breathe 3.6s ease-in-out infinite;
  overflow: hidden;
}

.glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, #ffffff55, transparent 46%);
  pointer-events: none;
}

.eye {
  width: 16%;
  height: 16%;
  background: #f4fbff;
  border-radius: 50%;
  position: absolute;
  top: 34%;
  box-shadow: 0 0 18px #fff;
  overflow: hidden;
  animation: blink 5.4s infinite;
}

.eye.left {
  left: 24%;
}

.eye.right {
  right: 24%;
}

.eye i {
  display: block;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: #09122a;
  position: absolute;
  left: 29%;
  top: 32%;
  animation: glance 6s ease-in-out infinite;
}

.mouth {
  width: 34%;
  height: 7%;
  background: #07101f;
  border-radius: 0 0 50px 50px;
  position: absolute;
  left: 33%;
  top: 64%;
  box-shadow: inset 0 8px 12px #0008;
  transition: height 90ms linear, top 90ms linear, border-radius 90ms linear;
}

.face.mic-off {
  filter: grayscale(0.75) brightness(0.72) saturate(0.2);
}

.face.mic-off .orb {
  animation: breathe 4.8s ease-in-out infinite;
  background:
    radial-gradient(circle at 50% 28%, #9aa3ad 0%, #4a5560 36%, #1a1f28 72%);
  box-shadow:
    0 0 28px #0006,
    inset 0 -30px 50px #050814aa;
}

.face.mic-off .ring,
.face.mic-off .spark {
  opacity: 0.28;
  animation-duration: 18s;
  filter: none;
}

.face.mic-off .glow {
  background: radial-gradient(circle at 30% 20%, #ffffff22, transparent 46%);
}

.face.mic-off .eye {
  background: #d8dde3;
  box-shadow: 0 0 8px #ffffff44;
}

.status.mic-off {
  color: #8a93a0;
}

body.mic-off {
  background:
    radial-gradient(circle at 50% 18%, #1a1d22 0%, transparent 42%),
    var(--bg);
}

.face.listening .orb {
  box-shadow:
    0 0 50px #3cf0ffaa,
    0 0 140px #2b6dff77,
    inset 0 -30px 50px #050814aa;
}

.face.hearing .orb {
  animation: hear-glow 0.35s ease-in-out infinite;
  background:
    radial-gradient(circle at 50% 28%, #b8fff6 0%, #17d4ff 34%, #062a4a 72%);
  box-shadow:
    0 0 70px #3cf0ff,
    0 0 160px #3cf0ff99,
    inset 0 -30px 50px #050814aa;
}

.face.hearing .ring-a,
.face.hearing .ring-b {
  animation-duration: 0.7s;
}

.face.hearing .mouth {
  height: 14%;
  top: 60%;
  box-shadow: 0 0 18px #3cf0ff88;
}

.face.thinking .orb {
  animation: think-glow 0.9s ease-in-out infinite;
  background:
    radial-gradient(circle at 50% 28%, #fff36a 0%, #ff8a1a 32%, #2a0b3d 72%);
}

.face.thinking .ring-a,
.face.thinking .ring-b {
  animation-duration: 1.1s;
}

.face.speaking .orb {
  animation: speak-glow 0.28s ease-in-out infinite;
}

.face.speaking .mouth {
  height: 22%;
  top: 56%;
  border-radius: 0 0 90px 90px;
  background: #02040a;
  box-shadow:
    inset 0 10px 16px #000a,
    0 0 24px #3cf0ff88;
}

.thought {
  margin: 0;
  min-height: 1.2em;
  font-size: clamp(2rem, 7vh, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--yes);
  text-shadow: 0 0 24px #e8ff4a99;
}

.thought.hidden {
  visibility: hidden;
}

.dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}

.subtitle {
  min-height: 3.2em;
  max-width: 42rem;
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
  line-height: 1.4;
}

.card {
  width: min(36rem, 100%);
  background: #0f1728ee;
  border: 1px solid #3cf0ff44;
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
}

.card.hidden {
  display: none;
}

.card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.card p {
  margin: 0 0 1rem;
  color: #d5dbe6;
}

.actions {
  display: flex;
  gap: 0.8rem;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.3rem;
  background: var(--yes);
  color: #111;
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: #1a2740;
  color: var(--ink);
}

.ask {
  display: flex;
  gap: 0.6rem;
  width: min(42rem, 100%);
}

.gate {
  display: flex;
  gap: 0.6rem;
  width: min(28rem, 100%);
}

.gate.hidden {
  display: none;
}

.ask input,
.gate input {
  flex: 1;
  border: 1px solid #2c4a6e;
  background: #0b1220;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

#mic.live {
  background: #ff3b30;
  color: #fff;
  box-shadow: 0 0 18px #ff3b3088;
}

#mic.hot {
  background: #ffd400;
  color: #111;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@keyframes blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.08);
  }
}

@keyframes glance {
  0%,
  40%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(18%, 6%);
  }
  70% {
    transform: translate(-12%, 4%);
  }
}

@keyframes orbit {
  from {
    transform: rotate(0deg) translate(min(27vh, 210px)) rotate(0deg);
  }
  to {
    transform: rotate(360deg) translate(min(27vh, 210px)) rotate(-360deg);
  }
}

@keyframes think-glow {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 40px #e8ff4a66, 0 0 90px #ff8a1a55;
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 90px #e8ff4acc, 0 0 160px #ff5bd388;
  }
}

@keyframes hear-glow {
  0%,
  100% {
    transform: scale(1.02);
    filter: brightness(1.1);
  }
  50% {
    transform: scale(1.08);
    filter: brightness(1.35);
  }
}

@keyframes speak-glow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.25);
  }
}

@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75% {
    content: "...";
  }
}

@media (max-width: 700px) {
  .spark {
    display: none;
  }
}
