:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111318;
  color: #f4f4f5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 24%, rgba(255,255,255,.07), transparent 31rem),
    #111318;
}

.shell { width: min(92vw, 760px); padding: 32px 0; }

.companion-card {
  text-align: center;
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px;
  background: rgba(25, 28, 35, .88);
  box-shadow: 0 24px 90px rgba(0,0,0,.35);
}

.face-wrap {
  position: relative;
  width: min(60vw, 320px);
  margin: 0 auto 18px;
  transition: transform 240ms ease, filter 240ms ease;
}

#face { width: 100%; display: block; overflow: visible; }

.head {
  fill: #f5d86e;
  stroke: rgba(255,255,255,.15);
  stroke-width: 4;
  filter: drop-shadow(0 16px 28px rgba(0,0,0,.22));
}

.eye { fill: #20232a; transform-box: fill-box; transform-origin: center; animation: blink 6.2s infinite; }
.eye-glint { fill: #fff; opacity: .8; }

@keyframes blink {
  0%, 45%, 48%, 100% { transform: scaleY(1); }
  46.2%, 46.8% { transform: scaleY(.08); }
}

.idle-mouth {
  fill: none;
  stroke: #20232a;
  stroke-width: 9;
  stroke-linecap: round;
  transition: d 220ms ease, opacity 120ms ease;
}

.speaking-mouth {
  fill: #20232a;
  opacity: 0;
  transform-origin: center;
}

.face-wrap.state-thinking { animation: thinking 1.15s ease-in-out infinite alternate; }
@keyframes thinking { from { transform: translateY(0); } to { transform: translateY(-5px); } }

.face-wrap.state-speaking .idle-mouth { opacity: 0; }
.face-wrap.state-speaking .speaking-mouth { opacity: 1; }
.face-wrap.emotion-happy { filter: saturate(1.08) brightness(1.03); }
.face-wrap.emotion-happy .idle-mouth { stroke-width: 10; }

.state-label {
  position: absolute;
  right: 0;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: .04em;
  color: rgba(255,255,255,.68);
  background: rgba(0,0,0,.28);
}

h1 { margin: 0 0 12px; font-size: clamp(24px, 5vw, 36px); font-weight: 650; }
.reply { min-height: 3.4em; margin: 0 auto 26px; max-width: 580px; color: rgba(255,255,255,.82); line-height: 1.6; }

.composer { display: flex; gap: 10px; }
.composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(0,0,0,.2);
  color: inherit;
  padding: 14px 16px;
  font: inherit;
  outline: none;
}
.composer input:focus { border-color: rgba(255,255,255,.35); }
.composer button {
  border: 0;
  border-radius: 14px;
  padding: 0 20px;
  font: inherit;
  font-weight: 650;
  background: #f4f4f5;
  color: #18181b;
  cursor: pointer;
}
.composer button:disabled { opacity: .45; cursor: default; }
.status { margin: 14px 0 0; font-size: 12px; color: rgba(255,255,255,.42); }

@media (max-width: 560px) {
  .composer { flex-direction: column; }
  .composer button { min-height: 46px; }
}

.face-wrap.state-listening { animation: listening 900ms ease-in-out infinite alternate; }
.face-wrap.state-listening .eye { animation-duration: 3.6s; }
@keyframes listening {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.025); filter: brightness(1.06); }
}

.mic-button {
  width: 52px;
  flex: 0 0 52px;
  padding: 0 !important;
  font-size: 20px !important;
  background: rgba(255,255,255,.10) !important;
  color: #f4f4f5 !important;
  border: 1px solid rgba(255,255,255,.12) !important;
}
.mic-button.recording {
  background: #f4f4f5 !important;
  color: #18181b !important;
  animation: recordPulse 1s ease-in-out infinite alternate;
}
@keyframes recordPulse { from { transform: scale(1); } to { transform: scale(.94); } }
.transcript {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 13px;
  color: rgba(255,255,255,.62);
}

@media (max-width: 560px) {
  .composer {
    display: grid;
    grid-template-columns: 52px 1fr;
  }
  .composer input { min-height: 46px; }
  .composer #send { grid-column: 1 / -1; min-height: 46px; }
}
