:root {
  color-scheme: dark;
  font-family: Georgia, "Times New Roman", serif;
  --ember: #ff7038;
  --ghost: #b7ffdb;
  --night: #09070d;
  --panel: rgba(20, 15, 27, 0.86);
  --level: 0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: #f6ede4;
  background:
    radial-gradient(circle at 50% 20%, rgba(88, 36, 94, 0.34), transparent 42%),
    radial-gradient(circle at 10% 90%, rgba(170, 55, 22, 0.18), transparent 35%),
    var(--night);
  overflow-x: hidden;
}

button, input { font: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.character {
  isolation: isolate;
  position: relative;
  width: min(720px, 100%);
  padding: clamp(24px, 6vw, 56px);
  text-align: center;
  border: 1px solid rgba(255, 112, 56, 0.23);
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(31, 20, 38, 0.94), var(--panel));
  box-shadow: 0 36px 100px rgba(0, 0, 0, 0.55), inset 0 0 70px rgba(255, 102, 45, 0.035);
  overflow: hidden;
}

.character::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--ember);
  font: 700 0.72rem/1.2 system-ui, sans-serif;
  letter-spacing: 0.24em;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 10vw, 5.6rem);
  line-height: 0.95;
  font-weight: 500;
  text-shadow: 0 0 35px rgba(255, 112, 56, 0.28);
}

.invitation {
  margin: 18px 0 22px;
  color: #cbbdca;
  font-style: italic;
}

.face {
  position: relative;
  width: min(360px, 88vw);
  height: 190px;
  margin: 10px auto 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  gap: 64px;
}

.eye {
  position: relative;
  width: 88px;
  height: 48px;
  border-radius: 70% 20% 70% 20%;
  background: radial-gradient(circle at center, rgba(183, 255, 219, 0.6), rgba(46, 145, 115, 0.08) 52%, transparent 68%);
  border: 1px solid rgba(183, 255, 219, 0.35);
  filter: drop-shadow(0 0 14px rgba(89, 255, 191, 0.28));
  transform: rotate(5deg) scaleY(0.12);
  transition: transform 500ms ease, opacity 500ms ease;
  opacity: 0.45;
}

.eye:nth-child(2) { transform: rotate(85deg) scaleY(0.12); }

.pupil {
  position: absolute;
  width: 20px;
  height: 28px;
  left: 34px;
  top: 10px;
  border-radius: 50%;
  background: #07100c;
  box-shadow: 0 0 12px var(--ghost);
  transition: transform 450ms ease;
}

.face:not([data-state="dormant"]) .eye {
  transform: rotate(5deg) scaleY(1);
  opacity: 1;
}

.face:not([data-state="dormant"]) .eye:nth-child(2) { transform: rotate(85deg) scaleY(1); }
.face[data-state="listening"] .pupil { transform: translateX(-9px); }
.face[data-state="hearing"] .pupil { transform: translateX(9px) scale(1.08); }
.face[data-state="thinking"] .pupil { transform: translateY(-7px); }

.voice-ring {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 76px;
  height: 36px;
  translate: -50% 0;
  border: 2px solid rgba(255, 112, 56, 0.36);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transform: scale(calc(0.82 + var(--level) * 0.38));
  box-shadow: 0 0 calc(10px + var(--level) * 38px) rgba(255, 112, 56, calc(0.2 + var(--level) * 0.5));
  transition: transform 70ms linear;
}

.voice-core {
  width: 45%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 112, 56, calc(0.18 + var(--level) * 0.76));
}

.face[data-state="thinking"] .voice-ring { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.18); box-shadow: 0 0 34px rgba(255, 112, 56, 0.45); }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 130px;
  justify-content: center;
  margin-bottom: 18px;
  color: #d9ced8;
  font: 600 0.82rem/1.2 system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #615762;
  box-shadow: 0 0 0 4px rgba(97, 87, 98, 0.14);
}

.face[data-state="listening"] ~ .status .status-light,
.face[data-state="hearing"] ~ .status .status-light { background: var(--ghost); box-shadow: 0 0 12px var(--ghost); }
.face[data-state="thinking"] ~ .status .status-light { background: #d58cff; box-shadow: 0 0 12px #d58cff; }
.face[data-state="speaking"] ~ .status .status-light { background: var(--ember); box-shadow: 0 0 12px var(--ember); }
.face[data-state="error"] ~ .status .status-light { background: #ff365c; box-shadow: 0 0 12px #ff365c; }

.transcript {
  min-height: 70px;
  padding: 18px 20px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  color: #d8ced7;
  line-height: 1.5;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #f6ede4;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

button:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, 0.1); }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(183, 255, 219, 0.55); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.38; }
button.primary { color: #190c08; background: linear-gradient(135deg, #ff8a4b, #e94f26); border-color: transparent; font-weight: 800; }

.settings {
  margin: 20px auto 0;
  max-width: 420px;
  color: #998d9b;
  font: 0.82rem/1.5 system-ui, sans-serif;
}

.settings summary { cursor: pointer; }
.settings label { display: block; margin: 14px 0 6px; color: #cbbdca; }
.settings input { width: 100%; padding: 12px; border: 1px solid rgba(255, 255,255, 0.14); border-radius: 10px; color: white; background: rgba(0, 0, 0, 0.25); }
.settings p { margin: 8px 0 0; }
.disclosure { margin: 22px 0 0; color: #766b78; font: 0.72rem/1.4 system-ui, sans-serif; }

.mist {
  position: absolute;
  z-index: -1;
  width: 300px;
  height: 110px;
  border-radius: 50%;
  background: rgba(158, 103, 172, 0.07);
  filter: blur(18px);
  animation: drift 13s ease-in-out infinite alternate;
}

.mist-one { top: 10%; left: -18%; }
.mist-two { right: -15%; bottom: 18%; animation-delay: -6s; }

@keyframes drift { to { transform: translateX(80px) scale(1.3); } }

@media (max-width: 520px) {
  .shell { padding: 0; }
  .character { min-height: 100vh; border-radius: 0; display: flex; flex-direction: column; justify-content: center; }
  .face { gap: 38px; }
  .controls button { flex: 1 1 42%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
