/* ─── Layout ────────────────────────────────────────────────────────────────── */
.chat-page { height: 100dvh; overflow: hidden; }
.chat-layout {
  max-width: 860px; height: 100dvh;
  margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}

/* desktop two-pane layout */
.desktop-chat-page {
  background: #e5e5e5;
  background-image: radial-gradient(circle at 15% 20%, rgba(0,0,0,.035) 0 90px, transparent 91px), radial-gradient(circle at 86% 42%, rgba(0,0,0,.035) 0 120px, transparent 121px);
}
.chat-layout.has-sidebar {
  max-width: 1280px; height: calc(100dvh - 108px); margin: 36px auto;
  flex-direction: row; border: none; border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 28px rgba(15,23,42,.08);
}
.chat-sidebar { width: 330px; flex-shrink: 0; background:#fff; border-right:1px solid var(--border); display:flex; flex-direction:column; }
.sidebar-head { height:60px; padding:0 16px; display:flex; align-items:center; justify-content:space-between; font-size:20px; }
.sidebar-link { font-size:13px; color:var(--primary); }
.sidebar-list { flex:1; overflow-y:auto; padding:4px 8px 12px; }
.sidebar-item { display:flex; align-items:center; gap:10px; padding:10px 8px; border-radius:10px 0 0 10px; text-decoration:none; color:inherit; position:relative; flex:1; min-width:0; }
.sidebar-item:hover,.sidebar-item.active { text-decoration:none; }
.sidebar-avatar { width:44px; height:44px; border-radius:50%; object-fit:cover; flex-shrink:0; }
.sidebar-info { min-width:0; flex:1; }
.sidebar-name { font-size:14px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-text { font-size:12px; color:var(--text-muted); margin-top:2px; line-height:1.5; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; word-break:normal; overflow-wrap:anywhere; }
.sidebar-text span { white-space:nowrap; }
.sidebar-badge { background:#ef4444; color:#fff; border-radius:99px; min-width:18px; height:18px; padding:0 5px; display:flex; align-items:center; justify-content:center; font-size:11px; }
.chat-main { flex:1; min-width:0; display:flex; flex-direction:column; background:#fff; }
.has-sidebar .chat-header { height:142px; align-items:flex-start; padding-top:24px; }
.has-sidebar .messages { padding:28px 26px; }
.has-sidebar .chat-input-area { padding:12px 18px 16px; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px 0 18px; height: 60px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.back-btn { font-size: 20px; color: var(--text-muted); text-decoration: none; padding: 4px 8px 4px 0; line-height: 1; transition: color .15s; }
.back-btn:hover { color: var(--text); text-decoration: none; }
.header-avatar { width:42px; height:42px; border-radius:50%; object-fit:cover; flex-shrink:0; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-title { display: block; font-size: 16px; font-weight: 700; color: var(--text); }
.chat-subtitle { display: block; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-setting-link { margin-top:-4px; }

.sound-btn { flex-shrink: 0; background: transparent; border: none; cursor: pointer; color: var(--text-muted); padding: 6px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: color .15s, background .15s; }
.sound-btn:hover { color: var(--primary); background: var(--primary-light); }
.sound-btn.muted { color: var(--text-light); }

/* ─── Messages area ─────────────────────────────────────────────────────────── */
.messages { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.messages:empty::before { content: '暂无消息，开始对话吧。'; font-size: 13px; color: var(--text-light); text-align: center; margin-top: 40px; }

/* ─── 微信式时间分隔 ───────────────────────────────────────────────────────── */
.chat-date-divider {
  align-self: center; flex: 0 0 auto; width: 100%;
  margin: 2px 0 -2px; padding: 2px 0;
  color: var(--text-light); font-size: 12px; line-height: 1.5;
  text-align: center; letter-spacing: .02em;
  -webkit-user-select: none; user-select: none;
}
html[data-admin-mode="dark"] .chat-date-divider { color: #8ea1bd; }

/* ─── Message bubbles ───────────────────────────────────────────────────────── */
.message { display:flex; gap:8px; max-width:78%; -webkit-user-select:none; user-select:none; }
.message.self { align-self:flex-end; flex-direction:row-reverse; }
.message.other { align-self:flex-start; }
.msg-avatar { width:30px; height:30px; border-radius:50%; object-fit:cover; flex-shrink:0; margin-top:18px; }
.message.self .msg-avatar { display:none; }
/* 客户页展示客户自己的头像；后台侧仍隐藏，避免和客服头像重复 */
.user-chat-page .message.self .msg-avatar { display:block; }
.msg-body { display:flex; flex-direction:column; min-width:0; }
.message.self .msg-body { align-items:flex-end; }
.message.other .msg-body { align-items:flex-start; }
.bubble { padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.6; word-break: break-word; cursor: default; }
.message.self .bubble { background: var(--primary); color:#fff; border-bottom-right-radius:4px; }
.message.other .bubble { background:#f1f3f7; color:var(--text); border-bottom-left-radius:4px; }
.message.bot .bubble { background:var(--brand-soft,#eff6ff); border:1px solid var(--brand-border,#dbeafe); color:var(--text); border-bottom-left-radius:4px; }
.message.bot .msg-avatar { background:var(--brand-soft,#eff6ff); }
.message.system { align-self:center; max-width:92%; }
.message.system .msg-body { align-items:center; }
.system-note {
  display:inline-flex; align-items:flex-start; justify-content:center; gap:6px;
  max-width:100%; padding:7px 14px; border-radius:999px;
  background:var(--surface-2,#f3f4f6); border:1px solid var(--border,#e5e7eb);
  color:var(--text-muted,#6b7280); font-size:12px; line-height:1.6; text-align:center;
  word-break:break-word;
}
.system-note-ico {
  width:15px; height:15px; margin-top:3px; border-radius:50%; flex-shrink:0;
  display:inline-flex; align-items:center; justify-content:center; line-height:1;
  background:var(--border,#e5e7eb); color:var(--text-muted,#6b7280);
  font-size:9px; font-weight:700; font-style:italic;
}
.system-meta { justify-content:center; padding:0; }
.system-sender { font-weight:500; color:var(--text-muted,#6b7280); }
.message.retracted .bubble { background: transparent !important; color: var(--text-light) !important; border: 1px dashed var(--border); font-style: italic; font-size: 13px; padding: 6px 12px; }

.bubble.media { background: transparent !important; color: inherit !important; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.bubble.media img { max-width: 280px; max-height: 320px; object-fit: cover; display: block; cursor: zoom-in; border-radius: 9px; }
.bubble.media video { max-width: 320px; max-height: 280px; display: block; border-radius: 9px; }
.bubble.media .video-wrap { padding: 4px; background: #000; border-radius: 9px; }

/* ─── 消息里的链接：正文链接 + 纯网址卡片 ─────────────────────────────────── */
.msg-link { color: var(--brand-2,#2563eb); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.message.self .msg-link { color: #fff; text-decoration-color: rgba(255, 255, 255, .65); }
.link-card {
  display: flex; align-items: center; gap: 10px; width: 232px; max-width: 100%;
  padding: 10px 12px; border-radius: 12px; background: #fff;
  border: 1px solid #e2e8f0; text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.link-card:hover { border-color: var(--brand-border,#bfdbfe); box-shadow: 0 4px 12px rgba(37, 99, 235, .14); transform: translateY(-1px); }
.link-card:active { transform: scale(.98); }
.link-card-ico {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft,#eff6ff); color: var(--brand-2,#2563eb);
}
.link-card-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-card-title { font-size: 13px; font-weight: 600; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card-sub { font-size: 11.5px; color: var(--brand-2,#2563eb); }

.bubble.audio-bubble { width:190px; min-height:42px; background:#f8fafc !important; border:1px solid #dbe5f2; border-radius:22px !important; padding:6px 12px !important; display:grid; grid-template-columns:30px 1fr 38px; align-items:center; column-gap:10px; color:#64748b !important; }
.message.self .bubble.audio-bubble { background:var(--brand-soft,#eff6ff) !important; border-color:var(--brand-border,#bfdbfe); color:var(--primary) !important; }
.audio-play-btn { width:30px; height:30px; border-radius:50%; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.message.self .audio-play-btn { background:var(--primary); color:#fff; }
.message.other .audio-play-btn { background:var(--primary-light); color:var(--primary); }
.audio-duration { font-size:12px; opacity:.95; text-align:right; font-variant-numeric:tabular-nums; }
.audio-wave { display:flex; align-items:center; gap:3px; min-width:0; justify-content:flex-start; }
.audio-wave span { display:inline-block; width:3px; background:currentColor; border-radius:2px; opacity:.65; animation:wave 1s ease-in-out infinite; }
.audio-wave span:nth-child(1){height:8px}.audio-wave span:nth-child(2){height:14px}.audio-wave span:nth-child(3){height:10px}.audio-wave span:nth-child(4){height:16px}.audio-wave span:nth-child(5){height:8px}
.audio-bubble:not(.playing) .audio-wave span { animation:none; height:8px; }
@keyframes wave { 0%,100%{transform:scaleY(1)} 50%{transform:scaleY(1.8)} }

.msg-meta { display:flex; align-items:center; gap:6px; font-size:11px; color:var(--text-light); margin-top:4px; padding:0 2px; }
.msg-sender { font-weight:500; }
.msg-read { font-size:11px; color:var(--text-light); }
.msg-read.read { color:var(--primary); }
.msg-status { display:inline-block; }
.msg-status.sending::after { content:''; display:inline-block; width:10px; height:10px; border:1.5px solid var(--text-light); border-top-color:transparent; border-radius:50%; animation:spin .8s linear infinite; vertical-align:middle; margin-left:4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* input */
.chat-input-area { border-top:1px solid var(--border); background:var(--surface); flex-shrink:0; padding:10px 14px 12px; position:relative; }
.input-row { display:flex; align-items:center; gap:8px; }
.media-btn { background:transparent; border:none; cursor:pointer; color:var(--text-muted); padding:6px; border-radius:var(--radius); flex-shrink:0; transition:color .15s, background .15s; display:flex; align-items:center; justify-content:center; }
.media-btn:hover,.mic-btn.voice-mode { color:var(--primary); background:var(--primary-light); }
.quick-trigger { width:auto; gap:5px; padding:5px 10px; border:1px solid var(--brand-border,#bfdbfe); border-radius:18px; background:var(--brand-soft,#eff6ff); color:var(--brand-2,#2563eb); font-size:12px; font-weight:600; line-height:1; }
.quick-trigger:hover { background:var(--brand-soft,#dbeafe); color:var(--brand-2,#1d4ed8); }
.quick-trigger.active { background:var(--brand-2,#2563eb); border-color:var(--brand-2,#2563eb); color:#fff; }
.quick-trigger .qt-short { display:none; }
.press-talk-btn { flex:1; height:40px; border-radius:20px; border:1.5px solid var(--border); background:var(--bg); font-size:14px; font-weight:500; color:var(--text-muted); cursor:pointer; display:none; align-items:center; justify-content:center; gap:8px; -webkit-user-select:none; user-select:none; }
.press-talk-btn.active-voice-mode { display:flex; }
.press-talk-btn.pressing { background:var(--danger); border-color:var(--danger); color:#fff; animation:pulse-rec 1s ease-in-out infinite; }
@keyframes pulse-rec { 0%,100%{box-shadow:0 0 0 0 rgba(220,38,38,.4)} 50%{box-shadow:0 0 0 6px rgba(220,38,38,0)} }
.msg-input.hide-in-voice { display:none; }
.msg-input { flex:1; resize:none; border:1px solid var(--border); border-radius:20px; padding:8px 14px; font-family:inherit; outline:none; background:var(--bg); color:var(--text); max-height:120px; line-height:1.5; font-size:16px; min-width:0; }
.msg-input:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,.10); background:var(--surface); }
.send-btn { min-width:72px; height:40px; flex-shrink:0; background:var(--brand,#4274ff); border:none; border-radius:20px; color:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:background .15s; }
.send-btn svg { display:none; }
.send-btn::after { content:'发送'; font-size:14px; }
.send-btn:hover:not(:disabled) { background:var(--brand,#4274ff); }
.send-btn:disabled { opacity:.5; cursor:not-allowed; }

.upload-progress { height:3px; background:var(--border); border-radius:99px; overflow:hidden; margin-bottom:8px; }
.progress-fill { height:100%; width:0%; background:var(--primary); border-radius:99px; transition:width .2s; }
.ctx-menu { position:fixed; z-index:3000; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-lg); overflow:hidden; min-width:120px; }
.ctx-item { display:block; width:100%; padding:10px 16px; background:none; border:none; text-align:left; font-size:14px; cursor:pointer; color:var(--text); }
.ctx-item:hover { background:var(--surface-2); }
.ctx-retract:hover { color:var(--danger); }

/* ─── 表情选择器 ─────────────────────────────────────────────────────────── */
.emoji-btn.active { color:var(--primary); background:var(--primary-light); }
.emoji-picker {
  position:absolute; left:12px; bottom:calc(100% + 8px); width:328px; max-width:calc(100vw - 24px);
  background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow:0 16px 40px rgba(15,23,42,.18); z-index:2600; display:none; overflow:hidden;
}
.emoji-picker.show { display:block; animation:uiPop .16s ease-out; }
.emoji-picker-head { display:flex; align-items:center; justify-content:space-between; padding:10px 14px 6px; font-size:12px; font-weight:600; color:var(--text-muted); }
.emoji-close { border:0; background:transparent; color:var(--text-light); font-size:18px; line-height:1; cursor:pointer; padding:0 2px; }
.emoji-close:hover { color:var(--text); }
.emoji-grid { display:grid; grid-template-columns:repeat(8,1fr); gap:2px; padding:4px 8px 12px; max-height:260px; overflow-y:auto; overscroll-behavior:contain; }
.emoji-item { border:0; background:transparent; font-size:22px; line-height:1.25; padding:4px 0; border-radius:8px; cursor:pointer; }
.emoji-item:hover { background:var(--primary-light); }

/* ─── 快捷回复面板（后台） ───────────────────────────────────────────────── */
.quick-panel {
  position:absolute; left:12px; bottom:calc(100% + 8px); width:326px; max-width:calc(100vw - 24px);
  background:#fff; border:1px solid var(--border); border-radius:14px;
  box-shadow:0 18px 46px rgba(14,34,66,.2); z-index:2600; display:none; overflow:hidden;
}
.quick-panel.show { display:block; animation:uiPop .16s ease-out; }
.qp-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:9px 11px; background:linear-gradient(180deg,var(--brand-soft,#eff6ff),#fff); border-bottom:1px solid var(--border); }
.qp-head-left { display:flex; align-items:center; gap:7px; min-width:0; }
.qp-bolt { display:inline-flex; align-items:center; justify-content:center; width:23px; height:23px; border-radius:6px; background:linear-gradient(135deg,var(--brand,#4274ff),var(--brand-2,#2563eb)); color:#fff; flex-shrink:0; box-shadow:0 3px 10px var(--brand-ring,rgba(66,116,255,.2)); }
.qp-bolt svg { width:13px; height:13px; }
.qp-title { display:flex; align-items:center; gap:6px; color:var(--text); font-size:12.5px; font-weight:700; }
.qp-count { padding:1px 5px; border-radius:5px; background:var(--brand-soft,#eff6ff); color:var(--brand-2,#2563eb); font-size:9px; font-weight:700; line-height:1.5; }
.qp-head-right { display:flex; align-items:center; gap:5px; flex-shrink:0; }
.qp-head a { color:var(--brand-2,#2563eb); text-decoration:none; font-size:10.5px; font-weight:600; }
.qp-head a:hover { text-decoration:underline; }
.qp-close { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border:0; border-radius:6px; background:rgba(255,255,255,.65); color:var(--text-light); font-size:15px; line-height:1; cursor:pointer; }
.qp-close:hover { background:#fff; color:var(--text); }
.qp-tip { padding:5px 11px; background:#fbfcfe; border-bottom:1px solid rgba(57,123,228,.1); color:var(--text-muted); font-size:10px; line-height:1.5; }
.qp-body { padding:6px; }
.qp-search { position:relative; display:flex; align-items:center; margin-bottom:4px; }
.qp-search svg { position:absolute; left:8px; width:12px; height:12px; color:#9aa8bb; pointer-events:none; }
.qp-search input { width:100%; height:29px; padding:0 8px 0 25px; border:1px solid #e4ebf3; border-radius:7px; background:#f8fafc; color:var(--text); font-size:11px; outline:none; }
.qp-search input:focus { border-color:var(--brand-border,#bfdbfe); background:#fff; box-shadow:0 0 0 3px var(--brand-ring,rgba(66,116,255,.1)); }
.qp-search input::placeholder { color:#a4b0bf; }
.qp-list { max-height:246px; overflow-y:auto; padding:2px; scrollbar-width:thin; }
.qp-item { display:flex; align-items:center; gap:8px; width:100%; border:0; background:transparent; text-align:left; padding:6px; border-radius:8px; cursor:pointer; }
.qp-item:hover { background:var(--brand-soft,#eff6ff); }
.qp-item img { width:34px; height:34px; border-radius:7px; object-fit:cover; flex-shrink:0; background:var(--bg); border:1px solid #edf1f6; }
.qp-thumb { width:34px; height:34px; border-radius:7px; background:var(--brand-soft,#eff6ff); color:var(--brand-2,#2563eb); display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:800; flex-shrink:0; border:1px solid var(--brand-border,#bfdbfe); }
.qp-info { min-width:0; flex:1; }
.qp-title-text { display:block; font-size:12px; font-weight:650; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.qp-preview { display:block; margin-top:1px; font-size:10px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.qp-act { flex-shrink:0; padding:2px 6px; border-radius:5px; background:var(--brand-soft,#eff6ff); color:var(--brand-2,#2563eb); font-size:9.5px; font-weight:700; }
.qp-empty { padding:20px 12px; text-align:center; color:var(--text-muted); font-size:11px; line-height:1.8; }
.qp-empty a { color:var(--brand-2,#2563eb); text-decoration:none; }

.lightbox { position:fixed; inset:0; background:rgba(0,0,0,.88); display:flex; align-items:center; justify-content:center; z-index:2000; cursor:zoom-out; }
.lightbox img { max-width:94vw; max-height:94vh; object-fit:contain; border-radius:4px; }

@media (max-width: 900px) {
  .chat-layout.has-sidebar { margin:0; height:100dvh; border-radius:0; }
  .chat-sidebar { display:none; }
  .has-sidebar .chat-header { height:60px; align-items:center; padding-top:0; }
  .chat-setting-link { display:none; }
}
@media (max-width: 600px) {
  .desktop-chat-page .chat-input-area { padding:8px 10px 10px; }
  .desktop-chat-page .input-row { gap:4px; }
  .desktop-chat-page .media-btn { padding:5px; }
  .quick-trigger { padding:5px 8px; gap:4px; font-size:11px; }
  .quick-trigger .qt-long { display:inline; }
  .quick-trigger .qt-short { display:none; }
  .quick-panel { width: calc(100vw - 24px); }
  .qp-list { max-height: 230px; }
}
@media (max-width: 360px) {
  .quick-trigger { padding:5px 7px; }
  .quick-trigger .qt-long { display:none; }
  .quick-trigger .qt-short { display:inline; }
  .user-chat-page .input-row { gap:4px; }
  .user-chat-page .media-btn { padding:5px; }
  @media (max-width: 340px) { .user-chat-page #vidBtn { display:none; } }
  .bubble.media img { max-width:220px; }
  .bubble.media video { max-width:260px; }
  .message { max-width:86%; }
  .msg-avatar { width:28px; height:28px; }
  .send-btn { min-width:42px; width:42px; border-radius:50%; }
  .send-btn::after { content:''; }
  .send-btn svg { display:block; }
  .emoji-picker, .quick-panel { left:8px; right:8px; width:auto; }
  .emoji-grid { grid-template-columns:repeat(8,1fr); max-height:230px; }
}

/* ─── 关键词快捷条（客户侧） ──────────────────────────────────────────────── */
.quick-chips {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 14px; background: #fafbfc; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.quick-chips-label { font-size: 11px; color: var(--text-light); margin-right: 2px; flex-shrink: 0; }
.quick-chip {
  border: 1px solid #dbe5f2; background: #fff; color: var(--brand-2,#2563eb);
  border-radius: 14px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  transition: background .15s, border-color .15s; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.quick-chip:hover { background: var(--brand-soft,#eff6ff); border-color: var(--brand-border,#bfdbfe); }
.quick-chip:active { transform: scale(.97); }

/* ─── 转人工按钮与状态横幅 ────────────────────────────────────────────────── */
.handoff-btn {
  flex-shrink: 0; border: 1px solid #dbe5f2; background: #fff; color: var(--brand-2,#2563eb);
  border-radius: 16px; padding: 5px 12px; font-size: 12px; cursor: pointer;
  transition: all .15s; margin-right: 6px;
}
.handoff-btn:hover { background: var(--brand-soft,#eff6ff); border-color: var(--brand-border,#bfdbfe); }
.handoff-btn:disabled { opacity: .65; cursor: default; }

/* 客户聊天页专用：品牌实心胶囊，不影响后台和其他页面 */
.user-chat-page .handoff-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; border-radius: 999px; padding: 7px 13px;
  background: linear-gradient(135deg, var(--brand-2,#2563eb), var(--brand,#3b82f6));
  color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: .2px;
  box-shadow: 0 4px 12px rgba(37,99,235,.22);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.user-chat-page .handoff-btn .handoff-ico { width: 14px; height: 14px; flex-shrink: 0; }
.user-chat-page .handoff-btn:hover { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,.26); }
.user-chat-page .handoff-btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(37,99,235,.2); }
.user-chat-page .handoff-btn:disabled {
  background: #e8effa; color: #7b8aa3; box-shadow: none;
  opacity: 1; cursor: default; transform: none;
}

.human-banner {
  padding: 8px 16px; font-size: 12.5px; line-height: 1.6;
  border-bottom: 1px solid transparent; flex-shrink: 0;
}
.human-banner.hs-waiting    { background: #fffbeb; color: #b45309; border-bottom-color: #fde68a; }
.human-banner.hs-processing { background: var(--brand-soft,#eff6ff); color: var(--brand-2,#1d4ed8); border-bottom-color: var(--brand-border,#bfdbfe); }
.human-banner.hs-resolved   { background: #f0fdf4; color: #15803d; border-bottom-color: #bbf7d0; }
.human-banner.hs-completed  { background: #f5f3ff; color: #6d28d9; border-bottom-color: #ddd6fe; }

/* ─── 自动回复标记 ─────────────────────────────────────────────────────────── */
.msg-auto-tag {
  background: var(--brand-soft,#eff6ff); color: var(--brand-2,#2563eb); border-radius: 4px;
  font-size: 10px; padding: 1px 5px; line-height: 1.5; flex-shrink: 0;
}

/* ─── 客户侧邮箱补填 ──────────────────────────────────────────────────────── */


/* 多行自动回复保留换行 */
.bubble:not(.media):not(.audio-bubble) { white-space: pre-wrap; }

@media (max-width: 600px) {
  .quick-chips { padding: 6px 10px; }
  .quick-chip { font-size: 11.5px; padding: 3px 9px; }
  .human-banner { font-size: 12px; padding: 7px 12px; }
  .handoff-btn { padding: 4px 9px; font-size: 11.5px; }
}

/* 未留邮箱提示条：聊天区顶部，轻量不挡输入 */
.user-chat-page .email-capture{
  display:flex;align-items:center;gap:10px;padding:9px 14px;
  background:#f8fafc;border-bottom:1px solid #eef2f7;flex-wrap:wrap;
}
.user-chat-page .email-capture-icon{
  width:30px;height:30px;border-radius:9px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  color:var(--brand,#4274ff);background:var(--brand-soft,#eef3ff);
}
.user-chat-page .email-capture-text{flex:1;min-width:150px}
.user-chat-page .email-capture-title{font-size:12.5px;font-weight:600;color:#334155;line-height:1.35}
.user-chat-page .email-capture-sub{font-size:11px;color:#94a3b8;line-height:1.4;margin-top:1px}
.user-chat-page .email-capture-form{display:flex;align-items:center;gap:6px;flex-shrink:0}
.user-chat-page .email-capture-input{
  width:190px;height:32px;padding:0 10px;border:1px solid #e2e8f0;border-radius:8px;
  font-size:12.5px;color:#334155;background:#fff;outline:none;box-sizing:border-box;
  transition:border-color .15s,box-shadow .15s;
}
.user-chat-page .email-capture-input:focus{border-color:var(--brand,#4274ff);box-shadow:0 0 0 3px var(--brand-ring,rgba(66,116,255,.15))}
.user-chat-page .email-capture-save{
  height:32px;padding:0 12px;border:0;border-radius:8px;cursor:pointer;
  background:var(--brand,#4274ff);color:#fff;font-size:12.5px;font-weight:600;white-space:nowrap;
}
.user-chat-page .email-capture-save:disabled{opacity:.6;cursor:default}
.user-chat-page .email-capture-later{
  height:32px;padding:0 6px;border:0;background:transparent;color:#94a3b8;
  font-size:12px;cursor:pointer;white-space:nowrap;
}
.user-chat-page .email-capture-later:hover{color:#64748b}
@media(max-width:760px){
  .user-chat-page .email-capture{padding:8px 12px;gap:8px}
  .user-chat-page .email-capture-text{min-width:0;flex:1 1 calc(100% - 40px)}
  .user-chat-page .email-capture-form{width:100%;padding-left:38px;box-sizing:border-box}
  .user-chat-page .email-capture-input{flex:1;min-width:0;width:auto}
  .user-chat-page .email-capture-save{padding:0 10px}
}

@media (max-width: 600px) {
  .desktop-chat-page #vidBtn, .desktop-chat-page #micBtn { display: flex !important; }
  .desktop-chat-page .chat-input-area { padding: 8px 10px 10px; }
  .desktop-chat-page .input-row { gap: 4px; }
  .desktop-chat-page .msg-input { padding: 8px 10px; }
  .desktop-chat-page .msg-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .desktop-chat-page .media-btn:not(.quick-trigger) { width: 30px; height: 30px; padding: 5px; }
  .desktop-chat-page .media-btn:not(.quick-trigger) > svg { width: 20px; height: 20px; flex: 0 0 auto; display: block; }
  .desktop-chat-page .send-btn { min-width: 40px; width: 40px; height: 40px; border-radius: 50%; padding: 0; flex: 0 0 40px; }
  .desktop-chat-page .send-btn::after { content: none; }
  .desktop-chat-page .send-btn svg { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
  .desktop-chat-page #quickBtn { width: 30px; height: 30px; padding: 0; gap: 0; justify-content: center; border-radius: 10px; flex: 0 0 30px; order: -1; }
  .desktop-chat-page #quickBtn > svg { width: 18px; height: 18px; flex: 0 0 auto; }
  .desktop-chat-page #quickBtn .qt-long,
  .desktop-chat-page #quickBtn .qt-short { display: none !important; }
}

@supports (padding: max(0px)) {
  .chat-input-area,
  .user-chat-page .chat-input-area,
  .desktop-chat-page .chat-input-area {
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
  .chat-page { height: 100dvh; }
}
