:root {
  --bg0: #d8ebf5;
  --bg1: #b7d4e6;
  --night: #1e3a4c;
  --snow: #f7fcff;
  --mist: #6a8fa3;
  --ice: #7eb8d4;
  --ice-soft: #c5e4f2;
  --blush: #e8a8b8;
  --blush-soft: #f3c9d4;
  --danger: #d97878;
  --font-display: "ZCOOL XiaoWei", "Songti SC", serif;
  --font-ui: "Nunito", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--night);
  background: var(--bg0);
  overflow: hidden;
}

/* Soft winter dusk — icy blues + pale blush, not flat */
.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 70% at 50% -5%, rgba(255, 255, 255, 0.85), transparent 55%),
    radial-gradient(ellipse 55% 45% at 12% 78%, rgba(232, 168, 184, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 50% at 92% 88%, rgba(126, 184, 212, 0.35), transparent 50%),
    linear-gradient(165deg, #eef7fc 0%, #c9e2f0 42%, #a8c9dc 78%, #8fb4c9 100%);
  pointer-events: none;
  z-index: 0;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  opacity: 0.7;
  mix-blend-mode: soft-light;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.45) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.35) 0 1.5px, transparent 3px),
    radial-gradient(circle at 45% 60%, rgba(255, 255, 255, 0.3) 0 1px, transparent 2px),
    radial-gradient(circle at 85% 55%, rgba(255, 255, 255, 0.4) 0 1px, transparent 2px);
  background-size: 180px 180px, 220px 220px, 160px 160px, 200px 200px;
  opacity: 0.55;
}

.flake {
  position: absolute;
  top: -8%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
  animation: snowfall linear infinite;
  opacity: 0.55;
}

.flake:nth-child(1) { left: 12%; animation-duration: 14s; animation-delay: 0s; width: 5px; height: 5px; }
.flake:nth-child(2) { left: 28%; animation-duration: 18s; animation-delay: -4s; width: 7px; height: 7px; }
.flake:nth-child(3) { left: 48%; animation-duration: 16s; animation-delay: -8s; }
.flake:nth-child(4) { left: 62%; animation-duration: 20s; animation-delay: -2s; width: 4px; height: 4px; }
.flake:nth-child(5) { left: 78%; animation-duration: 15s; animation-delay: -6s; width: 6px; height: 6px; }
.flake:nth-child(6) { left: 90%; animation-duration: 17s; animation-delay: -10s; width: 5px; height: 5px; }

.stage {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 1rem 1rem 1.25rem;
  gap: 0.4rem;
  --phone-block: clamp(11.5rem, 30vh, 15.5rem);
}

.brand {
  text-align: center;
  padding-top: 0.15rem;
  animation: brand-float 5.5s ease-in-out infinite;
}

.brand-mark {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.75;
  margin-bottom: 0.15rem;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.35rem, 7.5vw, 3.15rem);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  line-height: 1.15;
  color: var(--night);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7),
    0 8px 24px rgba(126, 184, 212, 0.25);
}

.tagline {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--mist);
}

/* Size container for the middle grid row — lets the plane fit 9:16 in either axis */
.avatar-slot {
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}

.avatar-plane {
  /* Clips are 720×1280 — frame matches so contain fills with no pillarbox bars */
  --avatar-ar: 9 / 16;
  --avatar-bg: #e8eaf0;
  position: relative;
  box-sizing: border-box;
  /* Fit inside slot: width limited by slot width OR by slot height × 9/16 */
  width: min(100cqw, calc(100cqh * 9 / 16));
  height: auto;
  max-height: 100cqh;
  aspect-ratio: var(--avatar-ar);
  min-height: 0;
  overflow: hidden;
  border-radius: 1.75rem;
  background:
    radial-gradient(ellipse 75% 60% at 50% 42%, #f4f5f8 0%, var(--avatar-bg) 55%, #dcdfe8 100%);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.55),
    0 0 0 6px rgba(195, 228, 242, 0.45),
    0 18px 40px rgba(30, 58, 76, 0.18);
  animation: fade-in 1s ease both;
}

.avatar-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse at 50% 55%, rgba(232, 168, 184, 0.18), transparent 55%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
  transition: opacity 0.5s ease;
}

.avatar-plane.is-speaking .avatar-glow {
  opacity: 1;
  background: radial-gradient(ellipse at 50% 55%, rgba(126, 184, 212, 0.28), transparent 55%);
}

.avatar-plane .avatar-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  background: transparent;
  filter: saturate(0.98) contrast(1.04);
  opacity: 0;
  transition: opacity 0.35s ease, filter 0.4s ease;
  pointer-events: none;
  z-index: 1;
}

.avatar-plane .avatar-layer.is-active {
  opacity: 1;
  z-index: 2;
}

.avatar-plane.is-speaking .avatar-layer.is-active {
  filter: saturate(1.06) contrast(1.06) brightness(1.04);
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  border-radius: inherit;
  /* Soft mist only — no navy/black edge that reads as letterbox bars */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 14%, transparent 86%, rgba(210, 216, 230, 0.22) 100%),
    radial-gradient(ellipse at center, transparent 62%, rgba(200, 208, 222, 0.14) 100%);
}

.phone {
  text-align: center;
  padding-top: 0.35rem;
  animation: fade-in 0.9s 0.12s ease both;
  max-height: var(--phone-block);
}

.status {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--mist);
  min-height: 1.35em;
  opacity: 1;
  transition: color 0.35s ease, opacity 0.35s ease;
}

.status.is-fading {
  opacity: 0;
}

.status[data-state="对方说话中"] {
  color: #4a8fad;
}

.status[data-state="思考中"],
.status[data-state="聆听中"] {
  color: #c47a8c;
}

.status[data-state="连接中"] {
  color: var(--ice);
}

.caption {
  margin: 0.45rem auto 0.7rem;
  max-width: 36rem;
  min-height: 2.2em;
  max-height: 3.2em;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  color: rgba(30, 58, 76, 0.78);
  word-break: break-word;
}

.actions {
  display: flex;
  justify-content: center;
}

.call-btn {
  appearance: none;
  position: relative;
  border: none;
  background: linear-gradient(160deg, #f7d4dc 0%, #e8a8b8 45%, #d992a6 100%);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  width: clamp(5.75rem, 19vmin, 7rem);
  height: clamp(5.75rem, 19vmin, 7rem);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.3s ease;
  box-shadow:
    0 10px 28px rgba(232, 168, 184, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.call-btn-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(232, 168, 184, 0.45);
  animation: dial-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.call-btn-label {
  position: relative;
  z-index: 1;
}

.call-btn:hover {
  transform: scale(1.04);
  box-shadow:
    0 14px 32px rgba(232, 168, 184, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.call-btn:active {
  transform: scale(0.96);
}

.call-btn[data-mode="active"] {
  background: linear-gradient(160deg, #f0b0b0 0%, #d97878 50%, #c45c5c 100%);
  box-shadow:
    0 10px 28px rgba(217, 120, 120, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.call-btn[data-mode="active"] .call-btn-ring {
  border-color: rgba(217, 120, 120, 0.5);
  animation: none;
  opacity: 0.55;
}

.call-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.call-btn:disabled .call-btn-ring {
  animation: none;
}

.error {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

@keyframes brand-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes dial-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.75;
  }
  70% {
    transform: scale(1.12);
    opacity: 0;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

@keyframes snowfall {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  8% {
    opacity: 0.55;
  }
  90% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(110vh) translateX(18px);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand,
  .flake,
  .call-btn-ring {
    animation: none;
  }
}

@media (max-height: 700px) {
  .brand h1 {
    font-size: 1.95rem;
  }

  .brand-mark {
    font-size: 0.6rem;
  }

  .tagline {
    font-size: 0.75rem;
  }

  .caption {
    margin: 0.3rem auto 0.45rem;
    min-height: 1.6em;
    max-height: 2.4em;
    font-size: 0.8rem;
  }

  .call-btn {
    width: 5.35rem;
    height: 5.35rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .stage {
    max-width: 100%;
    padding: 0.75rem 0.75rem 1rem;
  }

  .brand h1 {
    letter-spacing: 0.18em;
    text-indent: 0.18em;
  }

  .avatar-plane {
    border-radius: 1.35rem;
  }
}
