/* =========================================================================
 *  语音对话助手 · 界面样式（微信风格）
 * ========================================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #ededed;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ===== 顶部栏 ===== */
.header {
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}
.header .title {
  font-size: 17px;
  font-weight: 500;
  color: #1a1a1a;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.header .actions { display: flex; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 34px; height: 34px;
  border: none; border-radius: 8px;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #1a1a1a;
}
.icon-btn:active { background: #dcdcdc; }
.icon-btn.active { background: #d3e8d0; }

/* ===== 消息区 ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.msg-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 10px;
}
.msg-row.user { flex-direction: row-reverse; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.avatar.ai { background: linear-gradient(135deg, #4facfe, #00c6a9); }
.avatar.me { background: #e0c48f; font-size: 20px; }
.bubble-wrap { max-width: calc(100% - 110px); display: flex; flex-direction: column; }
.msg-row.user .bubble-wrap { align-items: flex-end; }
.bubble {
  position: relative;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.55;
  color: #1a1a1a;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}
.msg-row.ai .bubble { background: #ffffff; }
.msg-row.user .bubble { background: #95ec69; }
.msg-row.ai .bubble::before {
  content: "";
  position: absolute; left: -5px; top: 14px;
  border-top: 5px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid #ffffff;
}
.msg-row.user .bubble::after {
  content: "";
  position: absolute; right: -5px; top: 14px;
  border-top: 5px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid #95ec69;
}
.bubble.error { background: #fff3f3; color: #c0392b; }
.bubble .speaking-mark { font-size: 12px; color: #999; margin-top: 4px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #bbb;
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ===== 录音浮动提示 ===== */
.record-tip {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  border-radius: 12px;
  padding: 24px 32px;
  text-align: center;
  z-index: 50;
  display: none;
}
.record-tip.show { display: block; }
.record-tip .mic-anim {
  width: 54px; height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #4facfe;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79,172,254,.5); }
  70% { box-shadow: 0 0 0 18px rgba(79,172,254,0); }
  100% { box-shadow: 0 0 0 0 rgba(79,172,254,0); }
}
.record-tip .interim { font-size: 14px; max-width: 260px; min-height: 20px; word-break: break-all; }

/* ===== 输入操作提示 ===== */
.input-hint {
  flex-shrink: 0;
  background: #f7f7f7;
  font-size: 11px;
  color: #999;
  text-align: center;
  padding: 4px 8px 0;
  user-select: none;
}

/* ===== 底部输入栏 ===== */
.input-bar {
  flex-shrink: 0;
  background: #f7f7f7;
  border-top: 1px solid #d6d6d6;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.input-bar textarea {
  flex: 1;
  border: none;
  background: #ffffff;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  outline: none;
  font-family: inherit;
}
.bar-btn {
  border: none;
  border-radius: 6px;
  height: 38px;
  min-width: 44px;
  padding: 0 12px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: transparent;
  color: #1a1a1a;
  font-weight: 500;
}
.bar-btn:active { background: #e0e0e0; }
.bar-btn.recording { color: #e74c3c; animation: blink 1s infinite; }
.bar-btn.send { background: #07c160; color: #fff; }
.bar-btn.send:disabled { background: #a8dfa9; cursor: not-allowed; }
.bar-btn.stop { background: #f0f0f0; color: #333; }
#micBtn { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }

/* ===== 语音播放 / 重试按钮 ===== */
.voice-play {
  display: block;
  margin-top: 6px;
  border: none;
  background: #eef7ee;
  color: #077d3f;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.voice-play:active { background: #d8ecd8; }
.voice-play.playing { background: #07c160; color: #fff; }
