:root {
  color-scheme: light;
  --ink: #25354b;
  --muted: #748094;
  --cream: #fff9f0;
  --paper: rgba(255, 255, 255, 0.88);
  --purple: #7669ec;
  --purple-dark: #6254dc;
  --purple-soft: #eeeaff;
  --peach: #ffb37e;
  --peach-soft: #fff0df;
  --mint: #63d7bd;
  --shadow: 0 22px 60px rgba(78, 62, 135, 0.14);
  font-family: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Yuanti SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 9%, rgba(255, 199, 159, 0.42), transparent 24rem),
    radial-gradient(circle at 90% 40%, rgba(188, 181, 255, 0.36), transparent 28rem),
    linear-gradient(145deg, #fffaf2 0%, #fffdf8 48%, #f8f5ff 100%);
  -webkit-tap-highlight-color: transparent;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  border: 1px solid rgba(118, 105, 236, 0.09);
  border-radius: 50%;
  content: "";
}

body::before {
  top: -11rem;
  right: 13%;
  box-shadow: 0 0 0 3.6rem rgba(118, 105, 236, 0.025), 0 0 0 8rem rgba(118, 105, 236, 0.018);
}

body::after {
  bottom: -13rem;
  left: 7%;
  box-shadow: 0 0 0 4rem rgba(255, 179, 126, 0.035), 0 0 0 9rem rgba(255, 179, 126, 0.02);
}

button,
input {
  font: inherit;
}

button,
label {
  touch-action: manipulation;
}

.page-shell {
  width: min(100%, 920px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(1.1rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 2.3rem) max(1rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.brand-mark {
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 0.9rem 0.9rem 0.9rem 0.3rem;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #968cff, var(--purple-dark));
  box-shadow: 0 8px 20px rgba(98, 84, 220, 0.28);
  font-size: 1.08rem;
  font-weight: 900;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 0.05rem;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.voice-picker {
  position: relative;
  margin: 0;
  padding: 0.27rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(77, 69, 142, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 7px 24px rgba(84, 73, 139, 0.07);
  overflow: hidden;
}

.voice-picker legend,
.voice-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.voice-picker label {
  position: relative;
  z-index: 2;
  min-width: 5.3rem;
  padding: 0.58rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  transition: color 180ms ease, transform 180ms ease;
}

.voice-picker label span {
  margin-right: 0.15rem;
}

.voice-picker input:checked + label {
  color: white;
}

.voice-picker input:focus-visible + label {
  outline: 3px solid rgba(118, 105, 236, 0.28);
  outline-offset: 2px;
}

.voice-slider {
  position: absolute;
  z-index: 1;
  top: 0.27rem;
  bottom: 0.27rem;
  left: 0.27rem;
  width: calc(50% - 0.27rem);
  border-radius: 999px;
  background: linear-gradient(135deg, #9186fb, #6f61e5);
  box-shadow: 0 5px 12px rgba(98, 84, 220, 0.24);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#voice-miaomiao:checked ~ .voice-slider {
  transform: translateX(100%);
  background: linear-gradient(135deg, #ffb681, #ff8f73);
}

.call {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.72fr);
  align-items: center;
  gap: clamp(1.2rem, 5vw, 4rem);
}

.friend {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.availability {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
  padding: 0.42rem 0.75rem;
  color: #4d8679;
  border: 1px solid rgba(99, 215, 189, 0.28);
  border-radius: 999px;
  background: rgba(230, 255, 247, 0.72);
  font-size: 0.73rem;
  font-weight: 800;
}

.availability i {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0.24rem rgba(99, 215, 189, 0.16);
}

.avatar-wrap {
  position: relative;
  width: clamp(12.2rem, 28vw, 16.5rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(118, 105, 236, 0.12);
}

.orbit-one {
  inset: 2%;
  animation: orbit-pulse 4.8s ease-in-out infinite;
}

.orbit-two {
  inset: 10%;
  border-color: rgba(255, 179, 126, 0.14);
  animation: orbit-pulse 4.8s 0.7s ease-in-out infinite;
}

.avatar {
  position: relative;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 46% 46% 48% 48%;
  background: linear-gradient(145deg, #9488ff 0%, #7466e8 64%, #6659d4 100%);
  box-shadow: 0 22px 48px rgba(93, 78, 205, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.3);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.ear {
  position: absolute;
  top: -5%;
  width: 35%;
  height: 39%;
  border-radius: 70% 30% 58% 42%;
  background: #897df5;
}

.ear::after {
  position: absolute;
  inset: 27%;
  border-radius: inherit;
  background: rgba(255, 190, 178, 0.82);
  content: "";
}

.ear-left {
  left: 1%;
  transform: rotate(-23deg);
}

.ear-right {
  right: 1%;
  transform: scaleX(-1) rotate(-23deg);
}

.face {
  position: absolute;
  inset: 19% 10% 9%;
  border-radius: 48% 48% 45% 45%;
  background: linear-gradient(145deg, #fffdfb, #fff1e7);
  box-shadow: inset 0 -0.6rem 1.2rem rgba(255, 177, 144, 0.1);
}

.eye {
  position: absolute;
  top: 40%;
  width: 0.72rem;
  height: 0.92rem;
  border-radius: 50%;
  background: #3d3c5b;
  box-shadow: inset 0.17rem 0.1rem 0 white;
  transform-origin: center;
  animation: blink 5s infinite;
}

.eye-left {
  left: 27%;
}

.eye-right {
  right: 27%;
}

.cheek {
  position: absolute;
  top: 59%;
  width: 1rem;
  height: 0.48rem;
  border-radius: 50%;
  background: rgba(255, 151, 153, 0.3);
  filter: blur(0.5px);
}

.cheek-left {
  left: 17%;
}

.cheek-right {
  right: 17%;
}

.mouth {
  position: absolute;
  top: 61%;
  left: 50%;
  width: 1.45rem;
  height: 0.72rem;
  border-bottom: 0.2rem solid #5f5270;
  border-radius: 0 0 1.5rem 1.5rem;
  transform: translateX(-50%);
}

.star {
  position: absolute;
  color: #fff5ba;
  text-shadow: 0 2px 8px rgba(67, 54, 159, 0.28);
}

.star-one {
  top: 18%;
  left: 14%;
  font-size: 1.05rem;
}

.star-two {
  top: 29%;
  right: 12%;
  font-size: 0.72rem;
}

.friend h1 {
  margin: 0.35rem 0 0.35rem;
  font-size: clamp(1.55rem, 4.8vw, 2.55rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.status-copy {
  min-height: 1.6em;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 2vw, 1rem);
  font-weight: 600;
}

.sound-wave {
  height: 2.5rem;
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity 180ms ease;
}

.sound-wave i {
  width: 0.29rem;
  height: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(to top, var(--purple), #a99ffa);
  animation: wave 900ms ease-in-out infinite alternate;
}

.sound-wave i:nth-child(2),
.sound-wave i:nth-child(6) {
  animation-delay: -560ms;
}

.sound-wave i:nth-child(3),
.sound-wave i:nth-child(5) {
  animation-delay: -240ms;
}

.sound-wave i:nth-child(4) {
  animation-delay: -700ms;
}

.call[data-state="recording"] .sound-wave,
.call[data-state="speaking"] .sound-wave {
  opacity: 1;
}

.call[data-state="recording"] .avatar {
  box-shadow: 0 22px 55px rgba(93, 78, 205, 0.3), 0 0 0 0.8rem rgba(118, 105, 236, 0.07);
  animation: listen 1.8s ease-in-out infinite;
}

.call[data-state="thinking"] .avatar,
.call[data-state="transcribing"] .avatar {
  animation: think 1.4s ease-in-out infinite;
}

.call[data-state="speaking"] .mouth {
  width: 1.1rem;
  height: 0.95rem;
  border: 0.18rem solid #5f5270;
  border-top-width: 0.1rem;
  border-radius: 50%;
  animation: talk 420ms ease-in-out infinite alternate;
}

.moment {
  width: 100%;
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8rem;
}

.photo-card {
  position: relative;
  width: min(100%, 18rem);
  margin: 0 auto 0.25rem;
  padding: 0.5rem;
  border-radius: 1.5rem;
  background: white;
  box-shadow: var(--shadow);
  animation: card-in 330ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.photo-card img {
  width: 100%;
  max-height: 12rem;
  display: block;
  border-radius: 1.05rem;
  object-fit: cover;
}

.photo-card figcaption {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  padding: 0.36rem 0.62rem;
  color: #35695d;
  border-radius: 999px;
  background: rgba(234, 255, 248, 0.92);
  box-shadow: 0 5px 15px rgba(38, 86, 75, 0.12);
  backdrop-filter: blur(7px);
  font-size: 0.68rem;
  font-weight: 800;
}

.speech-card {
  position: relative;
  max-width: 92%;
  padding: 0.9rem 1rem 0.9rem 3.5rem;
  border-radius: 1.2rem;
  box-shadow: 0 10px 28px rgba(74, 63, 119, 0.08);
  animation: card-in 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.speech-card p {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.55;
}

.child-card {
  align-self: flex-end;
  background: var(--peach-soft);
}

.answer-card {
  align-self: flex-start;
  background: var(--purple-soft);
}

.speaker-dot {
  position: absolute;
  top: 50%;
  left: 0.8rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 0.7rem;
  font-weight: 900;
  transform: translateY(-50%);
}

.child-dot {
  background: linear-gradient(145deg, #ffc18f, #ff9a72);
}

.jiajia-dot {
  background: linear-gradient(145deg, #9388fb, #6b5dde);
}

.actions {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(8.5rem, 12rem));
  justify-content: center;
  gap: 0.75rem clamp(0.8rem, 3vw, 1.2rem);
  padding-top: 0.2rem;
}

.action-button {
  min-height: 4.65rem;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: 1.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.72rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.action-button:active {
  transform: translateY(2px) scale(0.98);
}

.action-button:focus-visible {
  outline: 4px solid rgba(118, 105, 236, 0.22);
  outline-offset: 3px;
}

.action-button[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.52;
}

.camera-button {
  color: #a45531;
  background: rgba(255, 237, 218, 0.94);
  box-shadow: 0 12px 26px rgba(212, 113, 67, 0.13), inset 0 0 0 1px rgba(224, 127, 83, 0.09);
}

.mic-button {
  color: white;
  background: linear-gradient(145deg, #897df6, #6557dc);
  box-shadow: 0 14px 30px rgba(98, 84, 220, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.call[data-state="recording"] ~ .actions .mic-button {
  background: linear-gradient(145deg, #ff997b, #f66f74);
  box-shadow: 0 14px 30px rgba(222, 83, 92, 0.24), 0 0 0 0.45rem rgba(255, 117, 119, 0.1);
}

.action-icon {
  position: relative;
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
}

.camera-icon {
  width: 2rem;
  height: 1.45rem;
  border: 0.15rem solid currentColor;
  border-radius: 0.42rem;
}

.camera-icon::before {
  position: absolute;
  top: -0.43rem;
  left: 0.42rem;
  width: 0.75rem;
  height: 0.36rem;
  border-radius: 0.22rem 0.22rem 0 0;
  background: currentColor;
  content: "";
}

.camera-icon i {
  width: 0.7rem;
  height: 0.7rem;
  border: 0.14rem solid currentColor;
  border-radius: 50%;
}

.mic-icon i {
  width: 0.78rem;
  height: 1.25rem;
  border: 0.14rem solid currentColor;
  border-radius: 999px;
}

.mic-icon::before {
  position: absolute;
  top: 0.74rem;
  width: 1.35rem;
  height: 0.85rem;
  border: 0.14rem solid currentColor;
  border-top: 0;
  border-radius: 0 0 1rem 1rem;
  content: "";
}

.mic-icon::after {
  position: absolute;
  bottom: 0.1rem;
  width: 0.15rem;
  height: 0.42rem;
  border-radius: 999px;
  background: currentColor;
  box-shadow: -0.36rem 0.35rem 0 -0.02rem currentColor, 0.36rem 0.35rem 0 -0.02rem currentColor;
  content: "";
}

.privacy-note {
  grid-column: 1 / -1;
  margin: 0.06rem 0 0;
  color: #8b91a0;
  font-size: 0.66rem;
  font-weight: 600;
  text-align: center;
}

.privacy-note span {
  color: var(--mint);
  font-weight: 900;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.8rem 1rem;
  color: white;
  border-radius: 1rem;
  background: rgba(48, 50, 68, 0.93);
  box-shadow: 0 12px 32px rgba(35, 37, 52, 0.24);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  animation: toast-in 220ms ease-out;
}

[hidden] {
  display: none !important;
}

@keyframes orbit-pulse {
  0%, 100% { transform: scale(0.96); opacity: 0.52; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes blink {
  0%, 45%, 49%, 100% { transform: scaleY(1); }
  47% { transform: scaleY(0.08); }
}

@keyframes wave {
  from { height: 0.48rem; }
  to { height: 1.75rem; }
}

@keyframes listen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

@keyframes think {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg) translateY(-0.2rem); }
}

@keyframes talk {
  from { transform: translateX(-50%) scaleY(0.72); }
  to { transform: translateX(-50%) scaleY(1.08); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(0.55rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 0.5rem); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 700px) {
  .page-shell {
    gap: 0.55rem;
  }

  .voice-picker label {
    min-width: 4.15rem;
    padding: 0.52rem 0.55rem;
    font-size: 0.7rem;
  }

  .call {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 0;
  }

  .avatar-wrap {
    width: clamp(10.7rem, 44vw, 13rem);
  }

  .availability {
    margin-bottom: 0.35rem;
  }

  .friend h1 {
    margin-top: 0.1rem;
  }

  .sound-wave {
    height: 1.9rem;
    margin-top: 0.25rem;
  }

  .moment {
    min-height: 0;
    max-height: 32vh;
    margin: 0.1rem auto 0.2rem;
    overflow: auto;
    scrollbar-width: none;
  }

  .moment:empty {
    display: none;
  }

  .photo-card {
    width: min(66vw, 13.5rem);
  }

  .photo-card img {
    max-height: 8rem;
  }

  .speech-card {
    max-width: 96%;
    padding-top: 0.72rem;
    padding-bottom: 0.72rem;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-button {
    min-height: 4.25rem;
    border-radius: 1.25rem;
  }
}

@media (max-width: 390px) {
  .brand small {
    display: none;
  }

  .voice-picker label span {
    display: none;
  }

  .friend h1 {
    font-size: 1.45rem;
  }

  .status-copy {
    font-size: 0.79rem;
  }

  .action-button {
    min-height: 3.95rem;
  }
}

@media (max-height: 680px) and (max-width: 700px) {
  .availability {
    display: none;
  }

  .avatar-wrap {
    width: 8.7rem;
  }

  .moment {
    max-height: 27vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
