/* 微信风格聊天界面 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #d8d8d8;
}

.phone {
  max-width: 520px;
  height: 100vh;
  height: 100dvh;  /* 移动端动态视口高度，避免被浏览器工具栏遮挡 */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #ededed;
  box-shadow: 0 0 24px rgba(0,0,0,.18);
  position: relative;
  overflow: hidden;
}

/* 顶部导航 */
.nav {
  height: 52px;
  background: #f7f7f7;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
}
.nav-back { font-size: 26px; color: #333; cursor: default; }
.nav-more { font-size: 22px; color: #333; letter-spacing: 2px; cursor: default; }
.nav-records { font-size: 18px; color: #555; text-decoration: none; width: 26px; text-align: right; }
.nav-title-spacer { width: 26px; }  /* 占位保持标题居中（客服页无管理入口） */
.nav-title { text-align: center; }
.nav-name { display: block; font-size: 16px; font-weight: 600; color: #111; }
.nav-status { display: block; font-size: 11px; color: #07c160; margin-top: 1px; }
.nav-status.typing { color: #07c160; }

/* 模式切换栏 */
.modebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f7f7f7;
  border-bottom: 1px solid #e2e2e2;
  flex-shrink: 0;
}
.mode-tabs {
  display: flex;
  background: #e8e8e8;
  border-radius: 7px;
  padding: 2px;
}
.mode-tab {
  border: none;
  background: none;
  font-size: 12.5px;
  color: #666;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
}
.mode-tab.active { background: #fff; color: #07c160; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.scenario-tag { flex: 1; font-size: 12px; color: #999; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.end-train {
  border: 1px solid #ee5a5a;
  color: #ee5a5a;
  background: #fff;
  font-size: 12px;
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
  flex-shrink: 0;
}

/* 训练情景选择面板 */
.scenario-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.scenario-panel {
  width: 82%;
  max-height: 70%;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  padding: 18px 16px 16px;
  animation: msgIn .2s ease-out;
}
.scenario-title { font-size: 15.5px; font-weight: 600; color: #111; margin-bottom: 12px; }
.scenario-sub { font-size: 12px; color: #999; font-weight: 400; }
.scenario-list { display: flex; flex-direction: column; gap: 8px; }
.scenario-item {
  border: 1px solid #e3e3e3;
  background: #fafafa;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: #333;
  text-align: left;
  cursor: pointer;
}
.scenario-item:active { background: #eafbf1; border-color: #07c160; }
.scenario-random {
  width: 100%;
  margin-top: 12px;
  border: none;
  background: #07c160;
  color: #fff;
  font-size: 14px;
  border-radius: 8px;
  padding: 9px 0;
  cursor: pointer;
}

/* 等待连发提示条 */
.waitbar {
  background: #fff8e6;
  color: #b8860b;
  font-size: 12px;
  padding: 5px 12px;
  border-top: 1px solid #f0e6c8;
  flex-shrink: 0;
}

/* 聊天区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 10px;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 0; }

.time-divider {
  text-align: center;
  color: #999;
  font-size: 12px;
  margin: 8px 0 12px;
  white-space: pre-line;  /* 支持多行提示 */
}

.msg-row {
  display: flex;
  margin-bottom: 14px;
  align-items: flex-start;
  animation: msgIn .18s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-row.user { flex-direction: row-reverse; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}
.avatar.bot { background: linear-gradient(135deg, #07a15a, #0ac268); }
.avatar.usr { background: linear-gradient(135deg, #5b7fa6, #7498c4); }
.avatar.cust { background: linear-gradient(135deg, #d98b3a, #eda955); }

.bubble {
  max-width: 68%;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 15.5px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  margin: 0 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.msg-row.bot .bubble { background: #fff; color: #111; }
.msg-row.user .bubble { background: #95ec69; color: #111; }

/* 气泡小三角 */
.msg-row.bot .bubble::before,
.msg-row.user .bubble::before {
  content: "";
  position: absolute;
  top: 12px;
  border: 5px solid transparent;
}
.msg-row.bot .bubble::before { left: -9px; border-right-color: #fff; }
.msg-row.user .bubble::before { right: -9px; border-left-color: #95ec69; }

/* 贴纸消息：也带说话气泡，内边距收紧、表情放大 */
.sticker-bubble {
  font-size: 24px;
  line-height: 1.2;
  padding: 6px 10px;
}

/* 文件消息气泡 */
.file-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 68%;
  margin: 0 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff;
  color: #111;
  text-decoration: none;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  border: 1px solid #e8e8e8;
}
.file-msg:active { background: #f2f2f2; }
.msg-row.user .file-msg { background: #95ec69; border-color: #8ade60; }
.file-icon { font-size: 22px; flex-shrink: 0; }
.file-name {
  font-size: 13.5px;
  line-height: 1.35;
  word-break: break-all;
  max-width: 200px;
}

/* 图片消息 */
.img-msg {
  max-width: 45%;
  max-height: 220px;
  border-radius: 6px;
  margin: 0 10px;
  display: block;
}

/* 正在输入 */
.typing-bubble {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 13px 14px;
}
.typing-bubble i {
  width: 7px; height: 7px;
  background: #b5b5b5;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-bubble i:nth-child(2) { animation-delay: .15s; }
.typing-bubble i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 快捷问题 */
.chips {
  display: flex;
  gap: 7px;
  padding: 8px 10px;
  overflow-x: auto;
  background: #f5f5f5;
  border-top: 1px solid #e2e2e2;
  flex-shrink: 0;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  border: 1px solid #07c160;
  color: #07c160;
  background: #fff;
  font-size: 12.5px;
  border-radius: 14px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background .15s;
}
.chip:active { background: #eafbf1; }

/* 输入区 */
.inputbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  /* 底部抬高：圆弧屏/手势条安全区 + 整体上移一点 */
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: #f7f7f7;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
}
.ib-btn {
  width: 34px; height: 34px;
  border: none;
  background: none;
  font-size: 25px;
  line-height: 1;  /* 文字图标（表情/加号）垂直居中，避免字形偏上 */
  color: #666;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.ib-btn svg { display: block; }  /* 去掉内联基线空隙，图标在行内真正居中 */
.ib-btn:active { background: #e5e5e5; }
.ib-input {
  flex: 1;
  min-height: 38px;
  max-height: 110px;
  border: none;
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
  font-size: 15.5px;
  outline: none;
  resize: none;
  line-height: 1.35;
  font-family: inherit;
}
.ib-send {
  height: 36px;
  padding: 0 15px;
  border: none;
  border-radius: 6px;
  background: #07c160;
  color: #fff;
  font-size: 14.5px;
  cursor: pointer;
  transition: opacity .15s;
}
.ib-send:disabled { opacity: .45; cursor: not-allowed; }
.ib-send:not(:disabled):active { opacity: .8; }

/* 语音输入条（按住说话） */
.voice-bar {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 6px;
  background: #fff;
  font-size: 15px;
  color: #333;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;  /* iOS 长按不弹出选中/放大镜菜单 */
  touch-action: none;  /* 按住时禁止页面滚动，手势才能生效 */
}
.voice-bar:active { background: #e5e5e5; }

/* 语音录制覆盖层：微信风格 */
.rec-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 30;
  touch-action: none;
}
/* 覆盖层及内部所有元素都不可选中，避免长按/滑动手势选中"松开发送"等文字 */
.rec-mask, .rec-mask * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
/* 实时识别文字：顶部居中 */
.rec-transcript {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 82%;
  min-height: 20px;
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  background: rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 10px 14px;
}
.rec-transcript:empty { display: none; }
/* 提示语：悬在弧形上方 */
.rec-hint {
  position: absolute;
  bottom: 300px;
  left: 0; right: 0;
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: 14px;
  letter-spacing: 1px;
}
/* 底部大弧（松开 发送） */
.rec-arc {
  position: absolute;
  left: 50%;
  bottom: -210px;
  transform: translateX(-50%);
  width: 560px;
  max-width: 150%;
  height: 330px;
  background: #f4f4f4;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 42px;
  box-sizing: border-box;
  transition: opacity .15s;
}
/* 横着的"wifi"声波图标：三层右开口弧线，依次脉冲 */
.rec-arc-mic {
  position: relative;
  width: 40px;
  height: 36px;
}
.rec-arc-mic i {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
  border: 2.5px solid transparent;
  border-right-color: #333;
  border-radius: 50%;
  animation: wavePulse 1.2s infinite ease-in-out;
}
.rec-arc-mic i:nth-child(1) { width: 12px; height: 12px; animation-delay: 0s; }
.rec-arc-mic i:nth-child(2) { width: 22px; height: 22px; animation-delay: .15s; }
.rec-arc-mic i:nth-child(3) { width: 32px; height: 32px; animation-delay: .3s; }
@keyframes wavePulse {
  0%, 100% { opacity: .2; }
  50% { opacity: 1; }
}
.rec-arc-text {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #333;
  letter-spacing: 2px;
}
.rec-time {
  margin-top: 6px;
  color: #999;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
/* 滑向两侧时弧变淡，突出目标区 */
.rec-mask.to-cancel .rec-arc,
.rec-mask.to-totext .rec-arc { opacity: .25; }

/* 取消 / 转文字 两个手势区（命中判定在 JS 里做，这里只占位展示） */
.rec-zone {
  position: absolute;
  bottom: 150px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  transition: transform .12s, background .12s, box-shadow .12s;
}
.rec-zone.cancel { left: 20px; }
.rec-zone.totext { right: 20px; }
.rec-zone-icon { font-size: 24px; line-height: 1; }
.rec-zone.cancel.active {
  background: #fa5151;
  transform: scale(1.18);
  box-shadow: 0 0 0 6px rgba(250,81,81,.25), 0 4px 14px rgba(0,0,0,.4);
}
.rec-zone.totext.active {
  background: #07c160;
  transform: scale(1.18);
  box-shadow: 0 0 0 6px rgba(7,193,96,.25), 0 4px 14px rgba(0,0,0,.4);
}

/* 表情面板 */
.sticker-panel {
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 12px 10px 16px;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  max-height: 218px;
  overflow-y: auto;
  flex-shrink: 0;
}
.sticker-panel.open { display: grid; }
.sticker-cell {
  border: none;
  background: none;
  font-size: 20px;
  padding: 5px 0;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}
.sticker-cell:active { background: #e5e5e5; }

@media (max-width: 520px) {
  .phone { max-width: 100%; }
}
