:root {
  --bg: #ededed; /* 微信经典背景色 */
  --header-bg: #f7f7f7;
  --text-main: #000000;
  --text-sub: #888888;
  --primary: #07c160; /* 微信绿 */
  --primary-light: #e1f5e8;
  --assistant-bubble: #ffffff;
  --user-bubble: #95ec69; /* 微信用户气泡色 */
  --user-text: #000000;
  --border: #e0e0e0;
  --accent: #fa5151;
  --success: #07c160;
  --safe-area-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* 防止浏览器整体滚动 */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 600px;
  height: 100%; /* 使用 100% 适配移动端高度 */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* 首页沉浸式设计 */
.home-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #2c3e50, #000000);
  color: white;
  transition: all 0.5s ease;
  padding: 20px;
  z-index: 10;
}

.companion-container {
  text-align: center;
  margin-bottom: 40px;
  cursor: pointer;
}

.companion-orb {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 0 auto 30px;
  position: relative;
  transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-core {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a29bfe, #6c5ce7);
  z-index: 2;
  box-shadow: inset -5px -5px 15px rgba(0,0,0,0.3), inset 5px 5px 15px rgba(255,255,255,0.4);
}

.orb-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  background: rgba(108, 92, 231, 0.3);
  border-radius: 50%;
  filter: blur(20px);
  z-index: 1;
}

/* 沉睡状态 */
.sleeping .orb-core {
  opacity: 0.6;
  transform: scale(0.9);
  filter: grayscale(0.5);
}

.sleeping .orb-glow {
  animation: orb-sleep 4s ease-in-out infinite;
}

@keyframes orb-sleep {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.2); opacity: 0.4; }
}

/* 苏醒状态 */
.awake .orb-core {
  animation: orb-breathe 3s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(108, 92, 231, 0.6); }
  50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(108, 92, 231, 0.8); }
}

.awake .orb-glow {
  background: rgba(108, 92, 231, 0.5);
  animation: orb-glow-pulse 3s ease-in-out infinite;
}

@keyframes orb-glow-pulse {
  0%, 100% { transform: scale(1.2); opacity: 0.5; }
  50% { transform: scale(1.5); opacity: 0.8; }
}

/* 菜单布局 */
.menu-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.menu-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  padding: 14px 8px;
  border-radius: 16px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 85px;
}

/* 首页菜单高亮 */
.menu-item.highlighted {
  background: rgba(7, 193, 96, 0.15);
  border: 1px solid rgba(7, 193, 96, 0.3);
  transform: scale(1.05);
}

.menu-item.highlighted .icon {
  filter: drop-shadow(0 0 5px var(--primary));
}

/* 通话波纹动画 */
.call-visualizer-container {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
}

.voice-wave span {
  display: block;
  width: 3px;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: wave-pulse 1s ease-in-out infinite;
}

.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.1s; }
.voice-wave span:nth-child(5) { animation-delay: 0s; }

@keyframes wave-pulse {
  0%, 100% { height: 6px; }
  50% { height: 20px; }
}

/* 隐藏正在说话时的波纹 */
.speaking-now .voice-wave span {
  animation: none;
  height: 2px;
  opacity: 0.3;
}
.multi-hint-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(7, 193, 96, 0.2);
  padding: 8px 20px;
  border-radius: 30px;
  margin-top: 15px;
  margin-bottom: 30px; /* 增加下方间距 */
  border: 1px solid rgba(7, 193, 96, 0.4);
  animation: hint-glow 2s infinite;
  box-shadow: 0 0 15px rgba(7, 193, 96, 0.2);
}

.multi-hint {
  font-size: 15px;
  font-weight: 600;
  color: #07c160;
  margin: 0;
  animation: none; /* 覆盖之前的简单动画 */
}

.hint-icon {
  font-size: 18px;
}

@keyframes hint-glow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(7, 193, 96, 0.2); }
  50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(7, 193, 96, 0.4); }
}

#wakeText {
  font-size: 20px;
  font-weight: 300;
  margin-bottom: 8px;
  opacity: 0.8;
}

.hint-text {
  font-size: 14px;
  opacity: 0.5;
  letter-spacing: 1px;
}

/* 交互菜单 */
.action-menu {
  width: 100%;
  max-width: 320px;
  animation: slide-up 0.5s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.menu-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 15px;
  border-radius: 16px;
  width: 80px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-item:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.2);
}

.menu-item .icon { font-size: 24px; margin-bottom: 8px; }
.menu-item .label { font-size: 12px; }

.menu-item.small {
  width: 200px;
  padding: 10px;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
}

/* 聊天页适配 */
.chat-screen {
  position: absolute; /* 使用绝对定位充满容器，防止 flex 布局高度失效 */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 5;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 确保子元素分布在两端 */
  position: relative;
  width: 100%;
  height: 44px; /* 微信标准高度 */
  padding: 0 16px;
}

.centered-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
  pointer-events: none; /* 防止遮挡按钮点击 */
}

.back-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* 首页历史入口 */
.history-entry-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 通话记录页样式 */
.history-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.history-item {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 0.5px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item-time {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.history-item-duration {
  font-size: 12px;
  color: var(--text-sub);
}

.history-item-play {
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
}

.empty-history {
  text-align: center;
  padding: 40px;
  color: var(--text-sub);
  font-style: italic;
}

header {
  padding: 12px 16px;
  background: var(--header-bg);
  border-bottom: 0.5px solid var(--border);
  text-align: center;
  flex-shrink: 0;
}

/* 迷你圆球形象 */
.orb-core.mini {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 30% 30%, #a29bfe, #6c5ce7);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(108, 92, 231, 0.5);
  animation: orb-breathe 3s ease-in-out infinite;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot.online { background-color: var(--success); }

h1 { font-size: 17px; font-weight: 600; }
.subtitle { font-size: 11px; color: var(--text-sub); margin-bottom: 6px; }

.header-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px; /* 增加间距 */
  margin-bottom: 4px;
}

/* 按住说话时的反馈样式 */
.icon-btn.active {
  background-color: #e0e0e0;
  transform: scale(0.9);
}

.voice-visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px;
  background: rgba(7, 193, 96, 0.1); /* 微信绿背景 */
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(7, 193, 96, 0.2);
}

.voice-visualizer .voice-status {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
}

button.primary.small {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  background: #ffffff;
  color: var(--primary);
  border: 0.5px solid var(--primary);
  font-weight: 500;
  cursor: pointer;
}

button.secondary.small {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  background: #ffffff;
  border: 0.5px solid var(--border);
  color: #333;
  cursor: pointer;
}

.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #2c3e50, #000000);
  z-index: 9999; /* 确保在最顶层 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
}

.call-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 80%;
  width: 100%;
  padding: 40px 0;
}

.fox-head-mini {
  width: 40px;
  height: 40px;
  background: #ff9f43;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.fox-head-mini::before, .fox-head-mini::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 12px;
  height: 15px;
  background: #ee5253;
  border-radius: 4px;
}
.fox-head-mini::before { left: 5px; transform: rotate(-15deg); }
.fox-head-mini::after { right: 5px; transform: rotate(15deg); }

.end-call-btn {
  background: #fa5151;
  color: white;
  border: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(250, 81, 81, 0.4);
  transform: rotate(135deg); /* 挂断电话的图标角度 */
}

/* 通话记录卡片 */
.bubble.call-record {
  background: #f7f7f7 !important;
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.call-record-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-sub);
  font-size: 13px;
}

.call-record-duration {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.call-record-summary {
  font-size: 13px;
  color: var(--text-sub);
  font-style: italic;
  padding-top: 4px;
  border-top: 0.5px dashed var(--border);
}

main {
  flex: 1;
  overflow-y: auto; /* 核心滚动区域 */
  padding: 16px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch; /* iOS 丝滑滚动 */
  height: 0; /* 关键：强制 flex 子元素在 overflow 时收缩并显示滚动条 */
}

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
}

.message {
  max-width: 85%;
  display: flex;
  flex-direction: column;
}

.message.assistant { align-self: flex-start; }
.message.user { align-self: flex-end; }

.message-info {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 4px;
  margin-left: 4px;
}

.user .message-info {
  margin-left: 0;
  margin-right: 4px;
  text-align: right;
}

.bubble {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.assistant .bubble {
  background-color: var(--assistant-bubble);
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.assistant .bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  border: 5px solid transparent;
  border-right-color: var(--assistant-bubble);
}

.user .bubble {
  background-color: var(--user-bubble);
  color: var(--user-text);
  border-top-right-radius: 2px;
}

.user .bubble::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 10px;
  border: 5px solid transparent;
  border-left-color: var(--user-bubble);
}

/* 结构化诊断报告样式 */
.diagnosis-report {
  margin-top: 12px;
  background: #ffffff;
  border-radius: 8px;
  border: 0.5px solid var(--border);
  padding: 12px;
  font-size: 14px;
}

.report-title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 6px;
}

.report-section { margin-bottom: 10px; }
.section-label { font-weight: 600; font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }

.diagnosis-meta { display: flex; gap: 12px; margin-bottom: 8px; }
.meta-item { background: #f7f7f7; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.meta-value { font-weight: 700; color: var(--primary); }

.mechanism-list { padding-left: 16px; }
.mechanism-list li { margin-bottom: 2px; }

.chart-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  display: flex;
  overflow: hidden;
  margin-bottom: 6px;
}
.bar-user { background: var(--primary); }
.bar-partner { background: var(--accent); opacity: 0.6; }

footer {
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-area-bottom));
  background: #f7f7f7;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.role-btn {
  padding: 2px 10px;
  border-radius: 10px;
  border: 0.5px solid var(--border);
  background: #ffffff;
  font-size: 11px;
  cursor: pointer;
}

.role-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 4px;
  outline: none;
  font-size: 16px;
  background: #ffffff;
}

button.primary {
  background-color: var(--primary);
  color: white;
  border: none;
  height: 36px;
  padding: 0 12px;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
}

.icon-btn {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
}

/* 录音时的全屏遮罩提示 (可选，增强反馈) */
.voice-visualizer {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 30px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  z-index: 2000;
  width: 160px;
  height: 160px;
}

.voice-visualizer .bar {
  width: 4px;
  height: 24px;
  background: var(--primary);
  animation: wave 1s infinite;
}

@keyframes wave {
  0%, 100% { height: 10px; }
  50% { height: 30px; }
}

.voice-visualizer .voice-status {
  color: white;
  font-size: 16px;
}

.icon-btn.pulse-highlight {
  animation: pulse-green 1s infinite;
  border-color: var(--primary);
}

@keyframes pulse-green {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.4); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(7, 193, 96, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(7, 193, 96, 0); }
}

.flex-1 { flex: 1; }
.flex { display: flex; }
.gap-8 { gap: 8px; }

.hold-to-talk-btn {
  flex: 1;
  height: 36px;
  background: #ffffff;
  border: 0.5px solid var(--border);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.hold-to-talk-btn.active {
  background: #d0d0d0;
  color: var(--primary);
  border-color: var(--primary);
}

/* 语音消息气泡样式 */
.bubble.voice-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 60px;
  cursor: pointer;
}

.voice-icon {
  font-size: 16px;
}

.voice-duration {
  font-size: 12px;
  opacity: 0.7;
}

.user .bubble.voice-bubble {
  flex-direction: row-reverse;
}

.hidden { display: none !important; }
