:root {
  color-scheme: dark;
  --bg: #05080d;
  --panel: rgba(8, 17, 25, 0.86);
  --cyan: #5de8ff;
  --cyan-soft: rgba(93, 232, 255, 0.18);
  --text: #e8fbff;
  --muted: #7da0aa;
  --line: rgba(93, 232, 255, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(0, 167, 204, 0.16), transparent 34%),
    linear-gradient(180deg, #07111a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

.shell {
  width: min(100%, 720px);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0; color: var(--cyan); font-size: 10px; letter-spacing: .22em; }
h1 { margin: 3px 0 0; font-size: 27px; letter-spacing: .18em; font-weight: 500; }
.connection { color: var(--muted); font-size: 12px; }
.connection.online { color: #75ffc4; }

.conversation {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 10px 2px 104px;
  scrollbar-width: none;
}

.message {
  max-width: 88%;
  margin: 0 0 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 4px 17px 17px 17px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
}

.message.user {
  margin-left: auto;
  border-radius: 17px 4px 17px 17px;
  background: rgba(28, 67, 78, .62);
}

.message span { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 9px; letter-spacing: .18em; }
.message.user span { color: #a4b8be; }
.message p { margin: 0; line-height: 1.48; font-size: 15px; white-space: pre-wrap; }

.controls { position: relative; display: grid; justify-items: center; gap: 8px; }
.status { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; }
.status.alert { color: #ffbc79; }

.voice-stage {
  position: fixed;
  right: max(18px, calc((100vw - 720px) / 2 + 18px));
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  z-index: 20;
  pointer-events: none;
}

.orb {
  position: absolute;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(93, 232, 255, .55);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 229, 255, .28), rgba(5, 19, 27, .9) 58%);
  color: var(--text);
  box-shadow: 0 0 26px rgba(66, 218, 255, .2), inset 0 0 24px rgba(93, 232, 255, .14);
  font-size: 10px;
  letter-spacing: .2em;
  z-index: 2;
  pointer-events: auto;
  transition: opacity 320ms ease, transform 420ms cubic-bezier(.4, 0, .2, 1);
}

.orb-core {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(93, 232, 255, .35);
  border-radius: 50%;
  z-index: 0;
  background: radial-gradient(circle, rgba(183, 249, 255, .42), rgba(43, 196, 225, .08) 62%, transparent 70%);
  box-shadow: 0 0 26px rgba(93, 232, 255, .46);
}

.orb #mic-label { position: relative; z-index: 1; font-size: 8px; letter-spacing: .12em; }
.orb.recording { animation: pulse 1.15s infinite; border-color: #ff6e6e; }
.orb:disabled { opacity: .5; }

.voice-visualizer {
  position: absolute;
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(.45) rotate(-12deg);
  transition: opacity 380ms ease, transform 520ms cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.voice-visualizer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.voice-center {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #dffcff;
  background: radial-gradient(circle at 42% 36%, #d9fbff 0%, #67deee 13%, #087c98 42%, #03141d 74%);
  box-shadow: 0 0 24px rgba(93, 232, 255, .6), inset 0 0 22px rgba(223, 252, 255, .5);
  font-size: 7px;
  letter-spacing: .12em;
  transition: transform 80ms linear, box-shadow 80ms linear;
}

.voice-center span { text-shadow: 0 0 9px #033743; }

.voice-stage.processing .orb,
.voice-stage.speaking .orb {
  opacity: 0;
  transform: scale(.3) rotate(18deg);
}

.voice-stage.processing .voice-visualizer,
.voice-stage.speaking .voice-visualizer {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.voice-stage.processing .voice-center { animation: thinking 1.7s ease-in-out infinite; }

@keyframes pulse {
  50% { box-shadow: 0 0 42px rgba(255, 80, 80, .42), inset 0 0 22px rgba(255, 90, 90, .2); }
}

@keyframes thinking {
  50% { transform: scale(1.08); box-shadow: 0 0 42px rgba(93, 232, 255, .72), inset 0 0 28px rgba(223, 252, 255, .62); }
}

@media (prefers-reduced-motion: reduce) {
  .orb, .orb-core, .voice-visualizer, .voice-center { animation: none !important; transition: none !important; }
}

.composer { width: 100%; display: grid; grid-template-columns: 1fr 46px; gap: 8px; }
.composer input {
  width: 100%;
  min-height: 46px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: rgba(6, 15, 22, .94);
  color: var(--text);
  font: inherit;
}
.composer input:focus { border-color: var(--cyan); }
.composer button {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 18px;
}
