:root {
  --ink: #151927;
  --muted: #6b7280;
  --line: #dfe6f2;
  --paper: #fbfcff;
  --user: #eaf1ff;
  --avatar: #fff0e9;
  --blue: #2eaeea;
  --stage: #344153;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, #ffffff 0 22%, transparent 35%),
    linear-gradient(145deg, #eef3fa 0%, #f8fbff 48%, #e6edf7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

.phone-shell {
  width: min(430px, 100%);
  height: min(920px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto minmax(300px, 48vh) minmax(178px, 1fr) auto;
  gap: 14px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(179, 191, 211, .7);
  border-radius: 32px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 24px 70px rgba(46, 57, 82, .18), inset 0 0 0 1px rgba(255,255,255,.9);
}

.topbar {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
}

.back {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 15px;
  color: #48546e;
  background: #f2f5fb;
  font-size: 25px;
}

h1 { margin: 0; font-size: 28px; line-height: 1; letter-spacing: -.04em; }
.topbar p { margin: 5px 0 0; color: #66708a; font-size: 15px; }
.status { padding: 8px 13px; border-radius: 999px; color: #197542; background: #dbffe8; border: 1px solid #a6efbf; font-weight: 750; }
.avatar-picker {
  margin-top: 8px;
  max-width: 190px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #cfd9e9;
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.avatar-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid #cbd6e6;
  border-radius: 24px;
  background: var(--stage);
  contain: strict;
}

.stage-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 2%, rgba(255,255,255,.64) 0 8%, rgba(255,255,255,.18) 23%, transparent 43%),
    linear-gradient(155deg, #2f3949, #5e6f87);
}

.avatar-video,
.avatar-canvas {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: -1px;
  width: auto;
  height: 100%;
  transform: translateX(-50%);
  object-fit: contain;
}

.avatar-video { display: none; }

.avatar-canvas {
  opacity: 0;
  transition: opacity 320ms ease;
}

.avatar-canvas.is-active {
  opacity: 1;
}

.mode-badge {
  position: absolute;
  z-index: 3;
  left: 12px;
  bottom: 12px;
  display: block;
  padding: 5px 9px;
  border-radius: 999px;
  color: rgba(255,255,255,.9);
  background: rgba(18, 26, 39, .55);
  font-size: 11px;
  letter-spacing: .02em;
}

.chat {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.72);
}

.bubble {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.28;
  white-space: pre-wrap;
}

.bubble.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 8px; }
.bubble.avatar { align-self: flex-start; background: var(--avatar); border-bottom-left-radius: 8px; }

.composer {
  display: grid;
  grid-template-columns: 46px 1fr 54px;
  gap: 10px;
  align-items: end;
  position: relative;
  padding-top: 20px;
}

.voice-status {
  position: absolute;
  left: 4px;
  top: 0;
  color: #7a849b;
  font-size: 12px;
  line-height: 1;
}

.composer input {
  min-width: 0;
  height: 54px;
  padding: 0 16px;
  border: 1px solid #cfd9e9;
  border-radius: 18px;
  color: var(--ink);
  background: #fbfcff;
  font-size: 16px;
  outline: none;
}

.mic,
.send {
  height: 54px;
  display: grid;
  place-items: center;
  border: 0;
}

.mic {
  width: 46px;
  padding: 0;
  border-radius: 17px;
  background: transparent;
  color: #287fc4;
  border: 0;
}

.mic-track {
  position: relative;
  width: 34px;
  height: 54px;
  display: block;
  border-radius: 999px;
  background: #e9f1fb;
  border: 1px solid #cfe0f3;
  box-shadow: inset 0 2px 8px rgba(74, 91, 124, .08);
}

.mic-thumb {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #287fc4;
  background: #fff;
  box-shadow: 0 5px 12px rgba(42, 89, 142, .18);
  transition: transform 220ms ease, background 220ms ease, color 220ms ease;
}

.mic.is-voice-on .mic-track {
  background: linear-gradient(180deg, #76d8ff, #1da7e4);
  border-color: #31ace8;
  box-shadow: 0 10px 24px rgba(46, 174, 234, .25);
}

.mic.is-voice-on .mic-thumb {
  color: #1595d3;
  transform: translateY(-20px);
}

.mic.is-recording .mic-thumb {
  color: #fff;
  background: #f15d5d;
}

.send {
  width: 54px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(46, 174, 234, .28);
}

.mic svg { width: 16px; height: 16px; fill: currentColor; }
.send svg { width: 27px; height: 27px; fill: #fff; }

.mic:disabled,
.send:disabled {
  opacity: .56;
  cursor: not-allowed;
}

@media (max-height: 780px) {
  .phone-shell { grid-template-rows: auto minmax(260px, 42vh) minmax(150px, 1fr) auto; }
  .bubble { font-size: 15px; }
}
