/* ============ 灵伴 SpiritMate - H5 设计系统 ============
   DESIGN.md tokens: 陶土红#E07A5F 鼠尾草绿#81B29A 蜂蜜金#F2CC8F
   背景#FAF7F2 卡片#FFFFFF 文字主#2D3142 文字次#7C7F8E
   字号>=14px 圆角>=12px 暖色阴影，不用纯黑阴影 */

:root {
  --primary: #E07A5F;
  --secondary: #81B29A;
  --accent: #F2CC8F;
  --background: #FAF7F2;
  --surface: #FFFFFF;
  --inset: #F0EBE4;
  --text-primary: #2D3142;
  --text-secondary: #7C7F8E;
  --success: #81B29A;
  --warning: #F2CC8F;
  --error: #E07A5F;
  --icon-pink: #FF5F91;
  --icon-orange: #FF865F;
  --icon-purple: #8068E8;
  --icon-blue: #5D9CEC;
  --icon-teal: #3DB5A5;
  --icon-ink: #513B52;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(224, 122, 95, 0.12);
  --shadow-lg: 0 6px 24px rgba(224, 122, 95, 0.18);
  --max-width: 480px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--background);
  color: var(--text-primary);
  font-size: 16px;
}

body { display: flex; justify-content: center; }

#app {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  background: var(--background);
  position: relative;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 16px; }

.circle-btn > i,
.icon-btn > i,
.back-btn > i,
.mic-btn > i,
.call-ctrl-btn > i,
.call-end-btn > i {
  line-height: 1;
  pointer-events: none;
}

/* ============ 通用组件 ============ */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); box-shadow: var(--shadow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--secondary); }
.btn-ghost { background: var(--surface); color: var(--text-primary); border: 1px solid var(--inset); }

.circle-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(81, 59, 82, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(81, 59, 82, 0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  color: var(--icon-ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.circle-btn:active { transform: scale(0.94); box-shadow: 0 1px 5px rgba(81, 59, 82, 0.10); }
#btnCall { color: var(--icon-orange); background: #FFF0EA; }
#btnMute { color: var(--icon-purple); background: #F1EEFF; }
#btnNewChat {
  color: #fff;
  background: linear-gradient(145deg, #FF8A67, #FF5F91);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(255, 95, 145, 0.28);
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(255, 95, 145, 0.10);
  background: #FFF0F4;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  color: var(--icon-pink);
  box-shadow: 0 2px 7px rgba(81, 59, 82, 0.08);
  position: relative;
}
[data-act="copy"] { color: var(--icon-purple); background: #F1EEFF; }
[data-act="speak"] { color: var(--icon-orange); background: #FFF0EA; }
[data-act="regen"] { color: var(--icon-blue); background: #EDF5FF; }
.icon-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
  background: rgba(224, 122, 95, 0.1);
}
.icon-btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(224, 122, 95, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
}
.icon-btn.playing {
  color: #fff;
  background: linear-gradient(145deg, #FF9A6C, #FF5F91);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(255, 95, 145, 0.26);
}
.icon-btn.playing > i { animation: speakingIconPulse 0.72s ease-in-out infinite; }
.icon-btn.playing::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid rgba(255, 134, 95, 0.48);
  border-radius: 14px;
  pointer-events: none;
  animation: speakingWave 1.15s ease-out infinite;
}
/* 准备中（朗读已请求、首音未出）：渐变底+白色转圈，覆盖播放波纹；保持可点停止 */
.icon-btn.playing.loading { color: transparent; pointer-events: auto; }
.icon-btn.playing.loading::after {
  width: 14px; height: 14px;
  inset: auto;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes speakingIconPulse {
  0%, 100% { transform: scale(0.88); opacity: 0.78; }
  50% { transform: scale(1.14); opacity: 1; }
}
@keyframes speakingWave {
  0% { transform: scale(0.88); opacity: 0.9; }
  100% { transform: scale(1.22); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .icon-btn.playing,
  .icon-btn.playing > i,
  .icon-btn.playing::after { animation: none; }
}

/* 页面标题栏 */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--inset);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-header h1 { font-size: 18px; flex: 1; }
.page-header .back-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #F1EEFF;
  color: var(--icon-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(128, 104, 232, 0.12);
}

/* 弹层 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: var(--max-width);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 70vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: rgba(45, 49, 66, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#toast.show { opacity: 1; }

/* 加载指示 */
.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--inset);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ 唤醒页 ============ */

.wake-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1A1B2E 0%, #2D2240 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 50;
}
.wake-glow {
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(224, 122, 95, 0.25);
  animation: glowPulse 3.2s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.7); opacity: 0.4; }
}
.moon-container { position: relative; width: 180px; height: 180px; display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
.moon-glow-ring {
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(242, 204, 143, 0.15);
  display: flex; align-items: center; justify-content: center;
  animation: breathe 5s ease-in-out infinite;
  cursor: pointer;
}
@keyframes breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.06) translateY(-4px); }
}
.moon {
  width: 108px; height: 108px;
  border-radius: 50%;
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
  box-shadow: 0 0 40px rgba(242, 204, 143, 0.4), inset 0 -8px 16px rgba(232, 191, 122, 0.5);
  border: 3px solid rgba(255, 255, 255, 0.35);
}
.wake-name {
  font-size: 28px; font-weight: 800; color: #EEEAF6;
  letter-spacing: 2px; margin-bottom: 12px;
}
.wake-hint {
  font-size: 15px; color: #8E8BA3; text-align: center;
  animation: hintFlash 3s ease-in-out infinite;
}
@keyframes hintFlash { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.wake-listening-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #81B29A;
  margin: 0 auto 8px;
  animation: blink 1.2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
.wake-overlay {
  position: absolute;
  width: 100px; height: 100px; border-radius: 50%;
  background: #E07A5F;
  opacity: 0;
  pointer-events: none;
}
.wake-overlay.show { animation: wakeBurst 0.9s ease-out forwards; }
@keyframes wakeBurst {
  0% { transform: scale(1); opacity: 0.9; }
  60% { opacity: 0.8; }
  100% { transform: scale(50); opacity: 0; }
}
/* 唤醒页识别调试信息 */
.wake-debug {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: #8E8BA3;
  z-index: 60;
  padding: 0 20px;
  word-break: break-all;
}

/* ============ 聊天页 ============ */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--inset);
  position: sticky;
  top: 0;
  z-index: 20;
}
.chat-header .header-right { display: flex; gap: 8px; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0;
  z-index: 90;
  display: flex;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);  /* 整屏统一遮罩（深浅可调） */
}
.drawer {
  position: relative;
  z-index: 1;
  width: 78%;
  max-width: 340px;
  height: 100%;
  background: var(--surface);
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  /* 默认在屏幕外，打开时由 .show 过渡滑入，避免 display 切换瞬间闪白块 */
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.drawer-mask.show .drawer { transform: translateX(0); }
.drawer .avatar {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  margin-bottom: 8px;
}
.drawer h2 { font-size: 20px; }
.drawer .subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.drawer-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--inset);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}
.drawer-search > i { color: var(--icon-purple); font-size: 18px; }
.drawer-search input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; color: var(--text-primary); }
.drawer-content { flex: 1; overflow-y: auto; }
.drawer-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
}
.drawer-item:hover { background: var(--inset); }
.drawer-item.active { background: rgba(224, 122, 95, 0.1); }
.drawer-item .d-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 3px 9px rgba(81, 59, 82, 0.08);
}
.drawer-item .d-icon-pink { color: var(--icon-pink); background: linear-gradient(145deg, #FFF2F6, #FFDDE8); }
.drawer-item .d-icon-orange { color: var(--icon-orange); background: linear-gradient(145deg, #FFF4ED, #FFE0D1); }
.drawer-item .d-icon-purple { color: var(--icon-purple); background: linear-gradient(145deg, #F5F1FF, #E4DCFF); }
.drawer-item .d-icon-new { color: var(--icon-blue); background: linear-gradient(145deg, #F0F7FF, #DCEBFF); }
.drawer-item .d-icon-chat { color: var(--icon-ink); background: transparent; box-shadow: none; }
.drawer-item .d-text { flex: 1; font-size: 15px; }
.drawer-item .d-arrow { color: var(--text-secondary); font-size: 14px; }
.drawer .section-title { margin-top: 16px; }

/* 欢迎页 */
.welcome { flex: 1; overflow-y: auto; padding: 24px 20px 16px; }
.hero { text-align: center; margin-bottom: 20px; }
.hero .hero-avatar {
  width: 56px; height: 56px; border-radius: 28px;
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  margin: 0 auto 10px;
}
.hero h2 { font-size: 20px; }
.hero h2 .hl { color: var(--primary); }
.hero p { font-size: 14px; color: var(--text-secondary); margin-top: 4px; line-height: 1.6; }
.quick-row { display: flex; gap: 10px; margin-bottom: 16px; }
.quick-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 12px rgba(81, 59, 82, 0.08);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  border: 1px solid rgba(81, 59, 82, 0.05);
  transition: transform 0.15s;
}
.quick-card:active { transform: scale(0.96); }
.quick-card .q-icon {
  width: 44px; height: 44px; border-radius: 13px;
  margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(81, 59, 82, 0.10);
}
.quick-card .q-icon > i { font-size: 24px; line-height: 1; }
.q-icon-story { color: #C87A19; background: linear-gradient(145deg, #FFF6CF, #FFD978); }
.q-icon-music { color: var(--icon-teal); background: linear-gradient(145deg, #ECFFF9, #C9F4E8); }
.q-icon-baby { color: var(--icon-pink); background: linear-gradient(145deg, #FFF1F6, #FFD5E4); }
.q-icon-elderly { color: var(--icon-orange); background: linear-gradient(145deg, #FFF3EC, #FFD9C8); }
.q-icon-health { color: var(--icon-purple); background: linear-gradient(145deg, #F4F0FF, #DDD5FF); }
.quick-card .q-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* 消息区 */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg-row { display: flex; gap: 8px; align-items: flex-start; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
  margin-top: 2px;
}
.msg-avatar.ai {
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
}
.msg-avatar.me {
  background: url('../img/user-320.png') center / cover no-repeat;
}
.msg-body { max-width: 78%; display: flex; flex-direction: column; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px; line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-row.assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--inset);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-row.user .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-actions { display: flex; gap: 6px; margin-top: 6px; }
.msg-actions .icon-btn { width: 32px; height: 32px; font-size: 14px; }

/* 音乐列表 */
.music-list {
  background: var(--surface);
  border: 1px solid var(--inset);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 8px;
}
.music-list .ml-head { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--primary); }
.music-list .ml-head > i { color: var(--icon-pink); font-size: 17px; }
.music-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--background);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 4px;
  font-size: 13px;
  cursor: pointer;
}
.music-item:active { background: var(--inset); }
.music-item > i { color: var(--icon-orange); font-size: 18px; }
/* 预置曲目播放态：当前播放行高亮，图标在 播放/暂停 间切换 */
.music-item .mi-icon { color: var(--icon-orange); font-size: 18px; }
.music-item .mi-pause { display: none; }
.music-item.playing { background: rgba(224, 122, 95, 0.12); }
.music-item.playing .mi-play { display: none; }
.music-item.playing .mi-pause { display: inline-flex; color: var(--primary); }
.music-item .m-title { flex: 1; word-break: break-all; }

/* 输入区 */
.input-area {
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--background);
}
.input-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--inset);
  border-radius: 24px;
  padding: 6px 8px;
}
.input-box:focus-within { border-color: var(--primary); }
.input-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text-primary);
  min-height: 36px;
  padding-left: 6px;
}
.mic-btn {
  width: 36px; height: 36px;
  border-radius: 18px;
  border: 1.5px solid var(--text-primary);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  color: var(--text-primary);
  cursor: pointer;
}
.mic-btn.recording { border-color: var(--error); color: var(--error); animation: pulseBorder 1s infinite; }
@keyframes pulseBorder { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
/* 启动中/识别中：禁用 + 转圈 */
.mic-btn.busy {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
}
.mic-btn.busy::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(124, 127, 142, 0.3);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
}
/* 语音切换钮：弱化描边 */
.toggle-btn {
  border-color: #E1DAFF;
  color: var(--icon-purple);
  background: #F3F0FF;
  box-shadow: 0 2px 7px rgba(128, 104, 232, 0.12);
}
.toggle-btn.recording { border-color: var(--error); color: var(--error); }
/* 发送钮 */
.send-btn {
  color: var(--surface);
  background: linear-gradient(145deg, #FF8A67, #FF5F91);
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(255, 95, 145, 0.28);
}
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* 语音态：隐藏输入框与发送钮，显示"按住说话" */
.input-box .hold-talk { display: none; }
.input-box.voice-mode .hold-talk { display: flex; }
.input-box.voice-mode input,
.input-box.voice-mode .send-btn { display: none; }
.hold-talk {
  flex: 1;
  align-items: center; justify-content: center;
  height: 42px;
  border: 1.5px solid var(--inset);
  border-radius: 21px;
  background: var(--background);
  color: var(--text-primary);
  font-size: 16px; font-weight: 600; letter-spacing: 3px;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none; cursor: pointer;
  transition: all 0.15s;
}
.hold-talk.holding {
  border-color: var(--primary);
  background: rgba(224, 122, 95, 0.1);
  color: var(--primary);
  animation: pulseBorder 1s infinite;
}
.hold-talk:disabled { opacity: 0.6; cursor: not-allowed; }
/* 通话界面（火山 Realtime Duplex 语音通话） */
.call-screen {
  position: fixed; inset: 0; z-index: 120;
  background: linear-gradient(180deg, #FAF7F2, #F0EDE8);
  display: flex; justify-content: center;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.call-inner {
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

/* 顶部状态 */
.call-header {
  text-align: center;
  padding: 8px 16px 12px;
}
#callStatusText { font-size: 16px; font-weight: 600; }
.call-duration { font-size: 13px; color: var(--text-secondary); font-family: monospace; margin-top: 6px; }

/* 主区 */
.call-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 呼叫中头像区 */
.call-avatar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.call-avatar-ring {
  position: relative;
  width: 116px; height: 116px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.call-avatar-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(224, 122, 95, 0.15);
  animation: callBreathe 2.4s ease-in-out infinite;
}
@keyframes callBreathe {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.18); opacity: 0.25; }
}
.call-avatar {
  width: 104px; height: 104px; border-radius: 52px;
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.call-name { font-size: 24px; font-weight: 700; }
.call-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* 通话气泡区 */
.call-transcript {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.call-empty {
  margin: auto;
  color: var(--text-secondary);
  font-size: 14px;
}
.call-line {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
}
.call-line .call-av {
  width: 34px; height: 34px;
  border-radius: 17px;
  background: url('../img/xiaorong-320.png') center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #fff;
  flex-shrink: 0;
}
.call-line .call-bubble {
  font-size: 14px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 80%;
  word-break: break-word;
}
/* 小融在左：头像 + 气泡 */
.call-line.ai { justify-content: flex-start; }
.call-line.ai .call-bubble {
  background: rgba(224, 122, 95, 0.12);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
/* 用户在右：气泡 */
.call-line.user { justify-content: flex-end; }
.call-line.user .call-bubble {
  background: rgba(129, 178, 154, 0.18);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

/* 底部操作栏 */
.call-footer {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 16px 24px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(224, 122, 95, 0.08);
}
.call-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.call-ctrl-btn, .call-end-btn {
  width: 64px; height: 64px;
  border-radius: 32px;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.call-ctrl-btn {
  background: #FFF0EA;
  color: var(--icon-orange);
  box-shadow: 0 4px 12px rgba(255, 134, 95, 0.18);
}
#btnCallText { color: var(--icon-purple); background: #F1EEFF; box-shadow: 0 4px 12px rgba(128, 104, 232, 0.18); }
.call-ctrl-btn.active {
  background: var(--primary);
  color: #fff;
}
.call-end-btn {
  background: linear-gradient(145deg, #FF7C66, #FF4F7B);
  color: #fff;
  box-shadow: 0 4px 14px rgba(224, 122, 95, 0.35);
}
.call-end-btn > i { transform: rotate(135deg); }

/* 通话解锁浮层（自动呼出：浏览器非手势自动播放被限制时点击解锁） */
.call-unlock {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(45, 49, 66, 0.55);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s;
}
.call-unlock-inner {
  width: min(320px, 80%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px 20px;
  text-align: center;
}
.call-unlock-icon { font-size: 40px; color: var(--icon-purple); margin-bottom: 8px; }
.call-unlock-text { font-size: 15px; color: var(--text-primary); margin-bottom: 16px; }

/* ============ 测评页 ============ */

.assess-page { flex: 1; overflow-y: auto; padding: 20px 16px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.form-field input {
  width: 100%;
  border: 1px solid var(--inset);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
}
.form-field input:focus { border-color: var(--primary); }

.question-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; margin-bottom: 16px; }
.question-text { font-size: 17px; font-weight: 600; line-height: 1.6; margin-bottom: 14px; }
.option-btn {
  display: block; width: 100%; text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--inset);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--text-primary);
  transition: all 0.15s;
}
.option-btn:active { border-color: var(--primary); background: rgba(224, 122, 95, 0.06); }
.option-btn.selected { border-color: var(--primary); background: rgba(224, 122, 95, 0.08); }

.result-card { text-align: center; padding: 24px 16px; }
.result-score { font-size: 52px; font-weight: 800; color: var(--primary); }
.result-label { font-size: 20px; font-weight: 700; margin: 8px 0 12px; }
.result-desc { font-size: 15px; line-height: 1.7; color: var(--text-secondary); text-align: left; background: var(--inset); border-radius: var(--radius-sm); padding: 14px; }
.result-desc b { color: var(--text-primary); }

.history-list { margin-top: 24px; }
.history-item { cursor: pointer; margin-bottom: 10px; }
.history-item:hover { box-shadow: var(--shadow-lg); }
.history-item .h-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.history-item .h-name { font-size: 15px; font-weight: 600; }
.history-item .h-score { font-size: 14px; color: var(--primary); font-weight: 700; }
.history-item .h-result { font-size: 14px; color: var(--secondary); font-weight: 600; margin-bottom: 4px; }
.history-item .h-date { font-size: 13px; color: var(--text-secondary); }
.history-item .h-rec { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-top: 4px; }

/* ============ 健康回顾页 ============ */

.review-page { flex: 1; overflow-y: auto; padding: 16px; }
.type-tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.type-tab {
  flex: 1;
  border: 1.5px solid var(--inset);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}
.type-tab.active { border-color: var(--primary); color: var(--primary); background: rgba(224, 122, 95, 0.06); }

.chart-card { margin-bottom: 14px; padding: 12px 8px; }
#chart { width: 100%; height: 240px; }

.record-item { cursor: pointer; margin-bottom: 10px; }
.record-item .r-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.record-item .r-value { font-size: 20px; font-weight: 700; color: var(--primary); }
.record-item .r-unit { font-size: 13px; color: var(--text-secondary); margin-left: 4px; }
.record-item .r-date { font-size: 13px; color: var(--text-secondary); }
.record-item .r-note { font-size: 14px; color: var(--text-secondary); }
.record-item .r-raw { font-size: 12px; color: var(--text-secondary); opacity: 0.8; margin-top: 4px; }

.detail-modal .row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--inset); font-size: 15px; }
.detail-modal .row:last-child { border-bottom: none; }
.detail-modal .row .k { width: 90px; color: var(--text-secondary); flex-shrink: 0; }
.detail-modal .row .v { flex: 1; word-break: break-all; }

.empty-tip { text-align: center; color: var(--text-secondary); font-size: 14px; padding: 40px 0; }

/* 流式阶段状态条 */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  border-bottom: 1px solid var(--inset);
}
.status-bar .spinner {
  width: 14px; height: 14px;
  border-width: 2px;
}

/* 知识库管理页 */
.dropzone {
  border: 2px dashed var(--inset);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--background);
}
.dropzone:hover, .dropzone.dragging { border-color: var(--primary); background: rgba(224, 122, 95, 0.04); }
.dropzone-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--icon-purple); line-height: 1; margin: 0 auto 10px;
  background: linear-gradient(145deg, #F4F0FF, #DDD5FF);
  box-shadow: 0 4px 10px rgba(128, 104, 232, 0.14);
}
.dropzone-icon.selected { font-size: 26px; color: var(--icon-teal); background: #E8FBF5; margin-bottom: 6px; }
.h-name { font-weight: 600; }
.record-name { display: inline-flex; align-items: center; gap: 6px; }
.record-name > i {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--icon-purple); background: #F1EEFF;
  font-size: 17px; flex-shrink: 0;
}


/* ============ 居家护理评估（elderly-assessment） ============ */
.care-sticky {
  position: sticky; top: 0; z-index: 30;
  background: var(--background);
}
.care-sticky .page-header { position: static; border-bottom: none; padding-bottom: 4px; }
.seg-tabs {
  display: flex; gap: 10px; padding: 6px 16px 12px;
}
.seg-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 0; border: none; border-radius: 14px;
  background: var(--surface); color: var(--text-secondary);
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 4px rgba(124, 127, 142, 0.10);
}
.seg-tab.active { background: var(--primary); color: #fff; }
.seg-tab i { font-size: 17px; }
.seg-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #fff; color: var(--primary);
  font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.seg-tab.active .seg-badge { background: rgba(255, 255, 255, 0.25); color: #fff; }

.care-page .card { margin-bottom: 18px; padding: 18px 16px; }
.care-page .section-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800; color: var(--text-primary);
  margin-bottom: 14px;
}
.step-badge {
  width: 26px; height: 26px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
}
.step-1 { background: linear-gradient(135deg, #6C63FF, #8E7BFF); }
.step-2 { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.step-3 { background: linear-gradient(135deg, #00B894, #55C9A9); }
.tip-text { font-size: 12.5px; color: var(--text-secondary); margin: -8px 0 12px; line-height: 1.6; }

.form-field { margin-bottom: 16px; }
.form-field:last-child { margin-bottom: 0; }
.form-field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1.5px solid var(--inset);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
}
.form-field textarea { resize: vertical; font-family: inherit; line-height: 1.5; }
.form-field select { -webkit-appearance: none; appearance: none; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.12); }
.req { color: var(--error); margin-right: 1px; }

.record-row {
  position: relative;
  border: 1px solid var(--inset);
  border-radius: 14px;
  padding: 12px 12px 6px;
  margin-bottom: 12px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(124, 127, 142, 0.06);
}
.row-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; padding-right: 2px; }
.rf { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rf label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf input {
  border: 1.5px solid var(--inset);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  min-width: 0;
  height: 42px;
}
.rf input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.12); }
.row-del {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: 9px;
  border: none; background: rgba(224, 122, 95, 0.08); color: var(--error);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.row-del:active { background: rgba(224, 122, 95, 0.2); }
.btn-add-row {
  width: 100%; height: 44px; margin-top: 2px;
  border: 1.5px dashed var(--primary); background: rgba(224, 122, 95, 0.05);
  color: var(--primary); font-size: 15px; font-weight: 700;
  border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-add-row i { font-size: 18px; }
.btn-submit {
  width: 100%; height: 50px; margin-bottom: 20px;
  font-size: 17px; font-weight: 800; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 6px 16px rgba(224, 122, 95, 0.28);
}
.btn-submit i { font-size: 20px; }
.btn-submit:disabled { opacity: 0.6; box-shadow: none; }

.report-card {
  border: 2px solid rgba(224, 122, 95, 0.35);
  box-shadow: 0 8px 24px rgba(224, 122, 95, 0.14);
  animation: fadeIn 0.35s ease;
}
.report-card-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800; color: var(--primary);
  margin-bottom: 12px;
}
.report-card-head > i { font-size: 20px; }
.report-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px;
  background: rgba(224, 122, 95, 0.12); color: var(--primary);
}
.report-badge.ai { background: rgba(0, 184, 148, 0.12); color: #00967B; }
.report-meta { font-size: 12.5px; color: var(--text-secondary); margin: -4px 0 12px; }
.report-item { margin-bottom: 14px; }
.report-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 800; color: var(--primary);
  margin-bottom: 6px;
}
.report-label::before {
  content: ''; width: 6px; height: 6px; border-radius: 3px;
  background: var(--primary); flex-shrink: 0;
}
.report-text {
  font-size: 15px; line-height: 1.75; color: var(--text-primary);
  background: var(--background); border-radius: 12px; padding: 12px 14px;
}
.report-text > div { margin-bottom: 3px; }
.report-text > div:last-child { margin-bottom: 0; }
.report-item.summary { padding-bottom: 4px; border-bottom: 1px dashed var(--inset); }
.report-item.summary .report-label { color: #B3623F; }
.report-item.summary .report-text { background: rgba(224, 122, 95, 0.07); font-weight: 500; }

#panelHistory .section-title { font-size: 15px; margin-bottom: 12px; }
.history-item { cursor: pointer; margin-bottom: 12px; padding: 14px; }
.history-item .h-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.history-item .h-name { font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.history-item .h-name i { color: var(--primary); }
.history-item .h-date { font-size: 12.5px; color: var(--text-secondary); flex-shrink: 0; }
.h-summary { font-size: 13px; color: var(--text-secondary); line-height: 1.65; margin: 6px 0; }
.h-badge {
  display: inline-block; font-size: 11px; color: var(--warning);
  border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; margin-bottom: 6px;
}
.h-actions { margin-top: 4px; }
.btn-sm { width: auto; padding: 8px 16px; font-size: 13.5px; border-radius: 10px; }
.btn-back {
  width: 100%; margin-bottom: 14px; height: 44px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
body.page-elderly-care #detailBody .report-card { border: none; box-shadow: none; padding: 0; animation: none; }
body.page-elderly-care #detailBody .report-card-head { font-size: 15px; }
/* ============ M-CHAT-R/F 筛查（baby-assessment） ============ */
.mchat-intro .section-head { margin-bottom: 10px; }
.q-progress { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.q-tag { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.q-bar { height: 8px; border-radius: 4px; background: var(--inset); overflow: hidden; margin-bottom: 18px; }
.q-bar-inner { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width 0.25s; }
.q-text { font-size: 17px; font-weight: 700; line-height: 1.7; margin-bottom: 20px; }
.q-options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
/* 初筛 是/否：与追问同款卡片单选（纵向堆叠，选中态 sel 分明） */
.fu-opt-btn.screen-q {
  padding: 14px 16px; font-size: 16px; font-weight: 600;
  justify-content: center; text-align: center;
}
.btn-back-q { width: 100%; margin-top: 4px; }
.mchat-big { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 15px; margin-bottom: 14px; padding: 12px 14px; background: var(--background); border-radius: 12px; }
.mchat-grade { font-weight: 800; padding: 3px 12px; border-radius: 10px; font-size: 14px; }
.grade-ok { background: rgba(0, 184, 148, 0.14); color: #00967B; }
.grade-warn { background: rgba(242, 153, 74, 0.16); color: #C97A1F; }
.grade-high { background: rgba(224, 122, 95, 0.18); color: var(--error); }
.result-tag { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 8px; }
.tag-red { background: rgba(224, 122, 95, 0.16); color: var(--error); }
.tag-green { background: rgba(0, 184, 148, 0.14); color: #00967B; }
.result-line { font-size: 14px; color: var(--text-primary); margin: 0 0 10px 2px; }
.h-result-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-secondary); margin-bottom: 8px; }
.btn-restart { width: 100%; margin-top: 4px; }

/* FU 追问平铺控件 */
.fu-block { margin-bottom: 18px; padding-top: 2px; }
.fu-block + .fu-block { border-top: 1px dashed var(--inset); padding-top: 14px; }
.fu-question { font-size: 15px; font-weight: 700; line-height: 1.6; margin-bottom: 4px; }
.fu-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.5; }
.fu-options { display: flex; flex-direction: column; gap: 8px; }
.fu-opt-btn, .fu-check {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1.5px solid var(--inset); background: var(--surface);
  border-radius: 12px; padding: 11px 12px; font-size: 14.5px; text-align: left;
  color: var(--text-primary); cursor: pointer; line-height: 1.5;
}
.fu-opt-btn.sel { border-color: var(--primary); background: rgba(224, 122, 95, 0.08); color: var(--primary); font-weight: 700; }
.fu-check .fu-checkbox {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  border: 1.5px solid var(--inset); background: var(--background);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.fu-check.sel { border-color: var(--primary); background: rgba(224, 122, 95, 0.06); }
.fu-check.sel .fu-checkbox { background: var(--primary); border-color: var(--primary); }


/* ============ M-CHAT 动效与报告版式 ============ */
@keyframes qIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.anim-in { animation: qIn 0.26s ease; }
@keyframes pickPop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }
.fu-opt-btn.sel.picked, .fu-check.sel.picked { animation: pickPop 0.22s ease; }
.fu-opt-btn, .fu-check { transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease; }
.fu-opt-btn:active, .fu-check:active { transform: scale(0.97); }
#fuDone.done-ok { animation: pickPop 0.25s ease; }

.mchat-big.big { font-size: 16px; align-items: center; }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip {
  font-size: 12.5px; color: var(--error); line-height: 1.4;
  background: rgba(224, 122, 95, 0.10); border: 1px solid rgba(224, 122, 95, 0.28);
  border-radius: 8px; padding: 4px 9px;
}
.mchip.ok { color: #00967B; background: rgba(0, 184, 148, 0.10); border-color: rgba(0, 184, 148, 0.28); }
.rep-head { margin-bottom: 6px; }
.rep-title { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 800; color: var(--text-primary); }
.rep-title i { color: var(--primary); font-size: 20px; }
.rep-meta { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }
.rep-sec { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--inset); }
.rep-sec-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 800; color: var(--primary); margin-bottom: 8px;
}
.rep-sec-title::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: var(--primary); }
