/* ============================================
   娱乐客服系统 - 专业级样式
   ============================================ */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-tertiary: #1e2130;
  --bg-card: #1a1d2b;
  --bg-hover: #252839;
  --bg-active: #2d3148;
  --border: #2a2d3e;
  --border-light: #353850;
  --text-primary: #e8eaf0;
  --text-secondary: #9ca0b0;
  --text-muted: #6b6f82;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --agent-bubble: linear-gradient(135deg, #6366f1, #7c3aed);
  --visitor-bubble: #252839;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; }
input, textarea { font-family: inherit; outline: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== 登录页面 ==================== */
.login-page {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
}
.login-bg { position: absolute; inset: 0; overflow: hidden; }
.login-glow {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.3;
  animation: float 8s ease-in-out infinite;
}
.login-glow.g1 { width: 400px; height: 400px; background: #6366f1; top: -100px; left: -100px; }
.login-glow.g2 { width: 300px; height: 300px; background: #8b5cf6; bottom: -50px; right: -50px; animation-delay: -3s; }
.login-glow.g3 { width: 250px; height: 250px; background: #3b82f6; top: 50%; left: 60%; animation-delay: -5s; }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(30px, -20px); } }

.login-card {
  position: relative; z-index: 1;
  width: 380px; padding: 40px 36px;
  background: rgba(26,29,43,0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.logo-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.logo-title { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.logo-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; letter-spacing: 1px; text-transform: uppercase; }
.login-divider { height: 1px; background: var(--border); margin: 20px 0; }

.qr-container {
  width: 220px; height: 220px; margin: 0 auto;
  background: white; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  box-shadow: 0 4px 24px rgba(99,102,241,0.2), 0 0 0 1px rgba(255,255,255,0.1);
  padding: 10px;
}
.qr-container::before {
  content: ''; position: absolute; inset: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.08));
  pointer-events: none; z-index: 0;
}
.qr-container canvas, .qr-container img {
  position: relative; z-index: 1;
  border-radius: 8px;
  max-width: 100%; max-height: 100%;
}
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; position: relative; z-index: 1; }
.login-tip { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-secondary); }
.login-status-text { text-align: center; margin-top: 8px; font-size: 12px; color: var(--accent-light); min-height: 18px; }
.btn-refresh {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 16px; padding: 10px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-size: 13px; transition: all 0.2s;
}
.btn-refresh:hover { background: var(--bg-active); color: var(--text-primary); border-color: var(--accent); }
.login-footer { position: absolute; bottom: 24px; font-size: 11px; color: var(--text-muted); z-index: 1; }
.demo-notice {
  display: flex; align-items: center; gap: 6px;
  margin-top: 16px; padding: 10px 12px;
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
  border-radius: 8px; font-size: 11px; color: #f59e0b; line-height: 1.5;
}
.demo-notice svg { flex-shrink: 0; }

/* 演示站醒目横幅 */
.demo-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(245,158,11,0.08));
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 12px;
  position: relative; overflow: hidden;
}
.demo-banner::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #ef4444);
}
.demo-banner-icon {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
  background: rgba(239,68,68,0.15); display: flex; align-items: center; justify-content: center;
  color: #ef4444;
}
.demo-banner-text { flex: 1; min-width: 0; }
.demo-banner-title {
  font-size: 13px; font-weight: 700; color: #ef4444;
  letter-spacing: 1px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.demo-banner-title::after {
  content: 'DEMO'; font-size: 9px; padding: 1px 5px;
  background: rgba(239,68,68,0.2); border-radius: 3px;
  color: #ef4444; font-weight: 600;
}
.demo-banner-desc {
  font-size: 11px; color: rgba(255,255,255,0.65); line-height: 1.6;
}
.demo-banner-desc strong { color: #f59e0b; font-weight: 600; }

/* 表单样式 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.form-input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: 14px; transition: border-color 0.2s;
  box-sizing: border-box;
}
.form-input:focus { border-color: var(--accent); outline: none; }
.form-input::placeholder { color: var(--text-muted); }
.form-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.btn-full { width: 100%; padding: 12px; font-size: 14px; }

/* ==================== 主应用布局 ==================== */
.main-app {
  display: flex; height: 100vh; height: 100dvh; width: 100%;
  background: var(--bg-primary);
}

/* 左侧导航 */
.sidebar {
  width: 60px; background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; flex-shrink: 0;
}
.sidebar-logo { margin-bottom: 24px; }
.sb-logo-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.nav-items { flex: 1; display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
.nav-item {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.2s; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-secondary); }
.nav-item.active { background: var(--accent); color: white; box-shadow: 0 2px 10px rgba(99,102,241,0.4); }
.nav-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
}
.nav-bottom { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.conn-status { margin-top: 12px; padding: 8px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.conn-dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* 会话列表 */
.conversation-list {
  width: 300px; background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.cl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px;
}
.cl-title { font-size: 18px; font-weight: 700; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.cl-search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 12px; padding: 9px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-muted);
  transition: border-color 0.2s;
}
.cl-search:focus-within { border-color: var(--accent); }
.cl-search input {
  flex: 1; background: none; border: none; color: var(--text-primary);
  font-size: 13px;
}
.cl-search input::placeholder { color: var(--text-muted); }

.cl-stats {
  display: flex; gap: 12px; padding: 0 18px 12px;
  font-size: 11px; color: var(--text-muted);
}
.cl-stats strong { color: var(--text-secondary); font-weight: 600; }

.cl-items { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.cl-empty { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 13px; }

.cl-item {
  display: flex; gap: 12px; padding: 12px;
  border-radius: var(--radius-md); cursor: pointer;
  transition: background 0.15s; position: relative;
  margin-bottom: 2px;
}
.cl-item:hover { background: var(--bg-hover); }
.cl-item.active { background: var(--bg-active); }
.cl-item.pinned::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 24px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.cl-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 16px; flex-shrink: 0;
}
.cl-item-info { flex: 1; min-width: 0; }
.cl-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cl-item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-icon { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; margin-right: 4px; vertical-align: middle; flex-shrink: 0; }
.device-icon svg { width: 100%; height: 100%; display: block; }
.device-icon.ios svg { color: #e8e8ed; }
.device-icon.android svg { color: #3ddc84; }
.device-icon.unknown svg { color: #6b7280; }
.cl-item-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; margin-left: 8px; }
.cl-item-bottom { display: flex; justify-content: space-between; align-items: center; }
.cl-item-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.visitor-status { font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-right: 4px; font-weight: 500; display: inline-block; }
.visitor-status.online { background: rgba(34,197,94,0.15); color: #22c55e; }
.visitor-status.offline { background: rgba(107,114,128,0.15); color: #9ca3af; }
.visitor-status.disconnected { background: rgba(239,68,68,0.15); color: #ef4444; }
.cl-item-unread {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 700;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 8px;
}

/* 聊天窗口 */
.chat-window { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted);
}
.chat-empty-icon { color: var(--border-light); margin-bottom: 16px; }
.chat-empty-text { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.chat-empty-sub { font-size: 13px; }

.chat-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: 10px;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 15px;
  flex-shrink: 0;
}
.chat-header-text { flex: 1; min-width: 0; overflow: hidden; }
.chat-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
#chatStatus .device-icon { margin-right: 2px; width: 12px; height: 12px; }
.chat-header-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* 消息区域 */
.messages-area {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.msg-day-divider {
  text-align: center; margin: 16px 0;
  font-size: 11px; color: var(--text-muted);
}
.msg-day-divider span {
  background: var(--bg-tertiary); padding: 4px 12px;
  border-radius: 10px; border: 1px solid var(--border);
}

/* 系统消息（居中提示） */
.message.system-msg {
  max-width: 100%; justify-content: center; margin: 8px 0;
}
.system-msg-text {
  background: rgba(239,68,68,0.1); color: #f87171;
  padding: 6px 14px; border-radius: 12px;
  font-size: 12px; text-align: center;
  border: 1px solid rgba(239,68,68,0.2);
}

.message { display: flex; gap: 8px; margin-bottom: 10px; max-width: 88%; }
.message.visitor { align-self: flex-start; }
.message.agent { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700; flex-shrink: 0;
  letter-spacing: 0.5px;
}
.message.visitor .msg-avatar { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.message.agent .msg-avatar { background: var(--accent-gradient); }
.msg-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.message.agent .msg-body { align-items: flex-end; }
.msg-bubble {
  padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.55; word-break: break-word;
  position: relative; max-width: 100%; white-space: pre-wrap;
  display: inline-block; min-height: 20px;
  box-sizing: border-box;
}
.message.visitor .msg-bubble {
  background: var(--visitor-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message.agent .msg-bubble {
  background: var(--agent-bubble);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(99,102,241,0.25);
}
/* 表情消息：统一气泡大小，更整齐 */
.msg-bubble.msg-emoji {
  font-size: 22px; padding: 6px 10px; line-height: 1.2;
  min-width: 40px; text-align: center;
}
.msg-bubble img { max-width: 240px; border-radius: 8px; cursor: pointer; display: block; }
.msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; background: rgba(255,255,255,0.08);
  border-radius: 8px; min-width: 200px;
}
.msg-file-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
}
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-size { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.msg-voice {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; min-width: 100px;
  cursor: pointer; user-select: none;
}
.msg-voice.playing .msg-voice-bars span { animation: voiceBar 0.8s ease-in-out infinite; }
.msg-voice.playing .msg-voice-bars span:nth-child(2) { animation-delay: 0.1s; }
.msg-voice.playing .msg-voice-bars span:nth-child(3) { animation-delay: 0.2s; }
.msg-voice.playing .msg-voice-bars span:nth-child(4) { animation-delay: 0.3s; }
.msg-voice.playing .msg-voice-bars span:nth-child(5) { animation-delay: 0.4s; }
@keyframes voiceBar { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1.2); } }
.msg-voice-bars { display: flex; gap: 2px; align-items: flex-end; height: 16px; }
.msg-voice-bars span { width: 3px; background: currentColor; border-radius: 1px; opacity: 0.6; }
.msg-voice-duration { font-size: 12px; opacity: 0.8; }
.msg-media { display: inline-block; }
/* 图片/视频去掉气泡背景，直接显示 */
.message .msg-bubble.msg-media {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 12px;
}
.msg-media img { max-width: 220px; max-height: 280px; border-radius: 10px; cursor: pointer; display: block; background: var(--bg-secondary); }
/* 图片加载占位符 */
.msg-image-wrap {
  position: relative;
  display: inline-block;
  min-width: 160px;
  min-height: 160px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}
.msg-image-wrap .msg-image-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 1;
}
.msg-image-wrap.loaded .msg-image-loading {
  display: none;
}
.msg-image-wrap img {
  position: relative;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 220px;
  max-height: 280px;
}
.msg-image-wrap.loaded img {
  opacity: 1;
}
.msg-media video {
  max-width: 240px;
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 10px;
  display: block;
  background: #000;
  outline: none;
}
/* 视频加载占位符：加载前显示统一尺寸，加载后按视频实际比例显示 */
.msg-video-wrap {
  position: relative;
  display: inline-block;
  max-width: 220px;
  max-height: 320px;
  min-width: 160px;
  min-height: 120px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}
.msg-video-wrap .msg-video-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 1;
}
/* 高级科技风加载动画：四个旋转方块 */
.msg-video-loader {
  position: relative;
  width: 40px;
  height: 40px;
}
.msg-video-loader span {
  position: absolute;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.6);
  animation: videoLoader 1.2s ease-in-out infinite;
}
.msg-video-loader span:nth-child(1) { top: 0; left: 0; animation-delay: 0s; }
.msg-video-loader span:nth-child(2) { top: 0; right: 0; animation-delay: 0.3s; }
.msg-video-loader span:nth-child(3) { bottom: 0; right: 0; animation-delay: 0.6s; }
.msg-video-loader span:nth-child(4) { bottom: 0; left: 0; animation-delay: 0.9s; }
@keyframes videoLoader {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.6); opacity: 0.5; }
}
.msg-video-loading-text {
  color: rgba(167, 139, 250, 0.9);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}
.msg-video-wrap.loaded .msg-video-loading {
  display: none;
}
.msg-video-wrap video {
  position: relative;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  background: #000;
}
.msg-video-wrap.loaded video {
  opacity: 1;
}
/* 自定义播放按钮覆盖层（未播放时显示，避免原生控制条遮挡画面） */
.msg-video-play-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: background 0.2s;
}
.msg-video-play-overlay:hover {
  background: rgba(0, 0, 0, 0.35);
}
.msg-video-play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #1a1a2e;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s, background 0.15s;
  padding-left: 4px; /* 视觉居中三角形 */
}
.msg-video-play-overlay:hover .msg-video-play-btn {
  transform: scale(1.08);
  background: #fff;
}
/* 加载中时隐藏播放按钮（加载动画已显示） */
.msg-video-wrap:not(.loaded) .msg-video-play-overlay {
  display: none;
}
/* 视频缓冲提示 */
.msg-video-buffering {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 12px;
}
.msg-video-buf-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
/* 视频控制条优化：确保按钮齐全且对齐 */
.msg-video-wrap video::-webkit-media-controls {
  display: flex !important;
  align-items: center;
}
/* 隐藏原生中央大播放按钮（用自定义的替代） */
.msg-video-wrap video::-webkit-media-controls-overlay-play-button {
  display: none !important;
}
.msg-video-wrap video::-webkit-media-controls-panel {
  display: flex;
  align-items: center;
  min-height: 36px;
}
.msg-video-wrap video::-webkit-media-controls-play-button {
  display: flex;
  align-items: center;
}
.msg-video-wrap video::-webkit-media-controls-current-time-display,
.msg-video-wrap video::-webkit-media-controls-time-remaining-display {
  display: flex;
  align-items: center;
  font-size: 11px;
}
.msg-video-wrap video::-webkit-media-controls-timeline {
  display: flex;
  align-items: center;
  flex: 1;
}
.msg-video-wrap video::-webkit-media-controls-mute-button,
.msg-video-wrap video::-webkit-media-controls-volume-slider {
  display: flex;
  align-items: center;
}
.msg-video-wrap video::-webkit-media-controls-fullscreen-button {
  display: flex;
  align-items: center;
}
.msg-media video::-webkit-media-controls-panel {
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}
.msg-media video::-webkit-media-controls-play-button {
  transform: scale(0.9);
}
.msg-media-placeholder { padding: 20px 30px; opacity: 0.7; font-size: 13px; }
.msg-media-error {
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(255,107,107,0.08) 0%, rgba(139,92,246,0.08) 100%);
  border: 1px solid rgba(255,107,107,0.2);
  border-radius: 12px;
  min-width: 180px;
  transition: all 0.2s;
}
.msg-media-error:hover {
  border-color: rgba(255,107,107,0.4);
  background: linear-gradient(135deg, rgba(255,107,107,0.12) 0%, rgba(139,92,246,0.12) 100%);
}
.msg-error-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.8;
}
.msg-error-title {
  color: #ff6b6b;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.msg-error-desc {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
}
.msg-voice-download { font-size: 14px; opacity: 0.6; margin-left: 4px; }
.msg-voice-icon { font-size: 12px; opacity: 0.7; margin-left: 4px; min-width: 14px; text-align: center; }
.msg-ref {
  font-size: 12px; opacity: 0.7; padding: 6px 10px;
  background: rgba(0,0,0,0.15); border-radius: 6px;
  margin-bottom: 6px; border-left: 3px solid rgba(255,255,255,0.3);
}
.msg-time { font-size: 10px; color: var(--text-muted); padding: 0 4px; }
.message.agent .msg-time { text-align: right; }
.msg-sending-indicator { color: var(--accent); opacity: 0.8; margin-left: 4px; }
.message.msg-sending .msg-bubble { opacity: 0.7; }
/* 访客离线提示条 */
.visitor-offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 8px 12px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: #f87171;
  font-size: 13px;
  text-align: center;
}

/* 输入区域 */
.input-area {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 12px 16px 14px;
  position: relative;
}
.input-typing {
  font-size: 12px; color: var(--text-muted);
  padding: 4px 0 8px; display: flex; align-items: center; gap: 6px;
}
.input-typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted); animation: typing 1.4s infinite;
}
.input-typing span:nth-child(2) { animation-delay: 0.2s; }
.input-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.tool-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.2s; flex-shrink: 0;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--accent-light); }
.tool-btn.active { background: var(--bg-active); color: var(--accent-light); }
.plus-toggle-btn.active svg { transform: rotate(45deg); }
.plus-toggle-btn svg { transition: transform 0.3s ease; }
.voice-toggle-btn.recording { color: #ff4757; animation: pulse 1s infinite; background: rgba(255,71,87,0.15); }

.input-wrapper { display: flex; gap: 8px; align-items: center; }
.input-wrapper textarea {
  flex: 1; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; color: var(--text-primary);
  font-size: 14px; resize: none; max-height: 120px; min-height: 40px;
  transition: border-color 0.2s; line-height: 20px; height: 40px;
  display: flex; align-items: center;
}
.input-wrapper textarea:focus { border-color: var(--accent); }
.input-wrapper textarea::placeholder { color: var(--text-muted); }

.send-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px; background: var(--accent-gradient);
  color: white; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  transition: all 0.2s; white-space: nowrap; flex-shrink: 0;
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.send-btn:active { transform: translateY(0); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* 展开工具栏 */
.expand-toolbar {
  display: flex; gap: 16px; justify-content: flex-start;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
  margin-top: 0; padding: 0 4px;
}
.expand-toolbar.open {
  max-height: 80px; opacity: 1; margin-top: 12px;
}
.expand-tool-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-muted); transition: all 0.2s; cursor: pointer;
  padding: 8px 12px; border-radius: 12px;
}
.expand-tool-item:hover { background: var(--bg-hover); color: var(--accent-light); transform: translateY(-2px); }
.expand-tool-item span { font-size: 11px; }
.expand-tool-item.recording { color: #ff4757; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* 表情面板 */
.emoji-panel, .quick-panel {
  position: absolute; bottom: 100%; left: 12px; right: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 10px; margin-bottom: 8px; z-index: 200;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}
.emoji-panel.open, .quick-panel.open {
  max-height: 260px; opacity: 1; padding: 10px;
}
.emoji-scroll {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  max-height: 220px; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.emoji-scroll::-webkit-scrollbar { width: 4px; }
.emoji-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.emoji-item {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 20px; border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.emoji-item:hover { background: var(--bg-hover); }
.emoji-item:active { background: var(--bg-active); transform: scale(0.85); }
.emoji-dots { display: none; }

.quick-header { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.quick-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.quick-item {
  padding: 8px 12px; background: var(--bg-tertiary); border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: background 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quick-item:hover { background: var(--bg-active); color: var(--accent-light); }

/* 访客信息面板 */
.info-panel {
  width: 280px; background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.info-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.info-body { flex: 1; overflow-y: auto; padding: 20px 18px; }
.info-avatar {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 24px; font-weight: 600;
  margin: 0 auto 12px;
}
.info-name { text-align: center; font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.info-id { text-align: center; font-size: 11px; color: var(--text-muted); word-break: break-all; margin-bottom: 20px; }
.info-section { margin-bottom: 20px; }
.info-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.info-remark { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.info-tag {
  padding: 3px 10px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 10px; font-size: 11px; color: var(--text-secondary);
}
.link-btn { font-size: 12px; color: var(--accent-light); background: none; border: none; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.info-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.info-stat { text-align: center; }
.info-stat span { display: block; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.info-stat label { font-size: 10px; color: var(--text-muted); }
.danger-btn {
  width: 100%; padding: 8px; background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3); color: var(--danger);
  border-radius: var(--radius-md); font-size: 13px; transition: all 0.2s;
}
.danger-btn:hover { background: rgba(239,68,68,0.2); }

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: 480px; max-height: 80vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 0.2s ease;
}
.modal-wide { width: 640px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 16px;
}
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}

.setting-group { margin-bottom: 24px; }
.setting-title { font-size: 13px; font-weight: 600; color: var(--accent-light); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row textarea, .setting-row input[type="number"] {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; color: var(--text-primary);
  font-size: 13px; width: 200px;
}
.setting-row textarea { resize: vertical; min-height: 40px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 11px; transition: 0.3s;
}
.slider:before {
  content: ''; position: absolute; height: 16px; width: 16px;
  left: 2px; bottom: 2px; background: var(--text-muted);
  border-radius: 50%; transition: 0.3s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); background: white; }

.status-badge {
  padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--bg-tertiary); color: var(--text-muted);
}
.status-badge.ok { background: rgba(34,197,94,0.15); color: var(--success); }
.status-badge.err { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-badge.cyan { background: rgba(6,182,212,0.15); color: #06b6d4; }

.btn-primary {
  padding: 9px 20px; background: var(--accent-gradient);
  color: white; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-secondary {
  padding: 9px 20px; background: var(--bg-tertiary);
  border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--radius-md); font-size: 13px; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 自动回复管理 */
.ar-add-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.ar-input {
  flex: 1; min-width: 120px; padding: 8px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px;
}
.ar-input:focus { border-color: var(--accent); }
.ar-select {
  padding: 8px 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 13px;
}
.ar-reply { flex: 2; }
.ar-list { display: flex; flex-direction: column; gap: 8px; }
.ar-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.ar-keyword {
  padding: 3px 10px; background: var(--accent); color: white;
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.ar-reply-text { flex: 1; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-delete { color: var(--danger); font-size: 12px; }

/* 图片查看器 */
.image-viewer {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
}
.image-viewer img { max-width: 90%; max-height: 90%; border-radius: 8px; }
.viewer-close {
  position: absolute; top: 20px; right: 24px;
  font-size: 32px; color: white; background: none; border: none;
  cursor: pointer; width: 40px; height: 40px;
}

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toastIn 0.3s ease; display: flex; align-items: center; gap: 8px;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* 亮色模式覆盖 */
body.light {
  --bg-primary: #f5f6f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f5;
  --bg-card: #ffffff;
  --bg-hover: #e8eaf0;
  --bg-active: #dde0ea;
  --border: #e2e4ea;
  --border-light: #d0d3dc;
  --text-primary: #1a1d2b;
  --text-secondary: #555a6e;
  --text-muted: #8b8fa3;
  --visitor-bubble: #ffffff;
}
body.light .login-card { background: rgba(255,255,255,0.9); }
body.light .msg-bubble img { filter: none; }

/* 视图容器 */
.view-content { flex: 1; display: flex; min-width: 0; }

/* 搜索页面 */
.search-page { flex: 1; display: flex; flex-direction: column; padding: 24px; overflow-y: auto; }
.search-page-header { margin-bottom: 20px; }
.sp-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.search-page-input {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
}
.search-page-input input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 15px;
}
.search-page-input svg { color: var(--text-muted); flex-shrink: 0; }
.search-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.search-tab {
  padding: 10px 20px; background: none; border: none;
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.search-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.search-results { flex: 1; }
.search-empty { text-align: center; color: var(--text-muted); padding: 60px 20px; font-size: 14px; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-hover); }
.sr-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 16px; flex-shrink: 0;
}
.sr-info { flex: 1; min-width: 0; }
.sr-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.sr-msg { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* 统计页面 */
.stats-page { flex: 1; padding: 24px; overflow-y: auto; }
.stats-header { margin-bottom: 24px; }
.stats-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stats-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stats-section { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.stats-section-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.stats-visitor-list { display: flex; flex-direction: column; gap: 2px; }
.sv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
}
.sv-item:hover { background: var(--bg-hover); }
.sv-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.sv-info { flex: 1; min-width: 0; }
.sv-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sv-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ==================== 响应式（手机端适配） ==================== */
.back-btn { display: none; }

@media (max-width: 768px) {
  .sidebar { width: 52px; }
  .sb-logo-icon { width: 36px; height: 36px; }
  .nav-item { width: 40px; height: 40px; }

  /* 手机端：会话列表和聊天窗口切换显示 */
  .conversation-list {
    width: 100%;
    min-width: 0;
    flex: 1;
  }
  .chat-window {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: var(--bg-primary);
    display: none !important;
  }
  .chat-window.active {
    display: flex !important;
  }
  .back-btn { display: flex; }

  /* 访客信息面板：手机端全屏模态框 */
  .info-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100% !important;
    z-index: 200;
    background: var(--bg-primary);
    border-left: none;
  }
  .info-panel[style*="display: none"] { display: none !important; }
  .info-panel[style*="display: flex"] { display: flex !important; }

  /* 登录页适配 */
  .login-card {
    width: 90%;
    max-width: 340px;
    padding: 24px 20px;
  }
  .qr-container { width: 180px; height: 180px; }

  /* 模态框适配 */
  .modal {
    width: 92%;
    max-height: 85vh;
    margin: 10px;
  }

  /* 统计页面 */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }

  /* 搜索页面 */
  .search-page { padding: 16px; }
}

@media (max-width: 480px) {
  .sidebar { width: 48px; }
  .cl-header { padding: 12px 14px; }
  .cl-title { font-size: 18px; }
  .cl-search { margin: 0 12px 10px; }
  .cl-stats { padding: 0 14px 10px; font-size: 11px; }
  .chat-header { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .chat-name { font-size: 15px; }
  .input-area { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .messages-area { padding: 12px; }
  .message { max-width: 92%; margin-bottom: 12px; }
  .msg-avatar { width: 32px; height: 32px; border-radius: 7px; font-size: 11px; }
  .msg-bubble { font-size: 14px; padding: 9px 13px; border-radius: 13px; }
  .msg-bubble.msg-emoji { font-size: 20px; padding: 5px 9px; }
  .emoji-scroll { grid-template-columns: repeat(8, 1fr); gap: 1px; max-height: 200px; }
  .emoji-item { font-size: 18px; border-radius: 4px; }
  .emoji-panel.open { max-height: 240px; padding: 8px; }
  .expand-toolbar { gap: 10px; }
  .expand-tool-item { padding: 6px 10px; }
  .send-btn { padding: 10px 14px; }
  .send-btn span { display: none; }
  /* 手机端禁止横向滚动 */
  body { overflow-x: hidden; }
  .main-app { height: 100dvh; }
}

/* ==================== 输入框隐藏滚动条 ==================== */
.input-wrapper textarea {
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.input-wrapper textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ==================== 高级科技风弹窗 ==================== */
.tech-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: techFadeIn 0.2s ease;
}
@keyframes techFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes techSlideUp { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.tech-modal {
  position: relative;
  width: 90%; max-width: 400px;
  background: linear-gradient(145deg, #1a1d2e 0%, #151827 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.1);
  animation: techSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.tech-modal-glow {
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
  pointer-events: none;
}
.tech-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  position: relative; z-index: 1;
}
.tech-modal-title {
  font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}
.tech-modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.2s;
}
.tech-modal-close:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }

.tech-modal-body { padding: 20px; position: relative; z-index: 1; }
.tech-modal-body textarea {
  width: 100%; box-sizing: border-box;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 14px; line-height: 1.6;
  resize: none; outline: none;
  transition: all 0.2s;
  font-family: inherit;
}
.tech-modal-body textarea:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: rgba(0, 0, 0, 0.4);
}
.tech-modal-body textarea::placeholder { color: var(--text-muted); }

.tech-modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(99, 102, 241, 0.1);
  position: relative; z-index: 1;
}
.tech-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}
.tech-btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.tech-btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
.tech-btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.tech-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4); }
.tech-btn-primary:active { transform: translateY(0); }
.tech-btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.tech-btn-danger:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4); }
.tech-btn-danger:active { transform: translateY(0); }

.tech-modal-sm { max-width: 340px; }
.tech-confirm-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 50%;
  color: #ef4444;
}
.tech-confirm-text {
  text-align: center;
  font-size: 14px; line-height: 1.6;
  color: var(--text-primary);
}

/* 退出选项弹窗 */
.logout-option {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
}
.logout-option:last-child { margin-bottom: 0; }
.logout-option:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.25);
  transform: translateX(2px);
}
.logout-option:active { transform: translateX(0); }
.logout-option-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  border: 1px solid;
}
.logout-option-info { flex: 1; min-width: 0; }
.logout-option-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.logout-option-desc {
  font-size: 12px; line-height: 1.4;
  color: var(--text-muted);
}

/* 设置页面扩展样式 */
.setting-value {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.setting-row-column {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.setting-row-column label {
  font-size: 13px;
  color: var(--text-primary);
}
.domain-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.setting-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
  min-width: 0;
}
.setting-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.setting-input::placeholder { color: var(--text-muted); }
.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
  white-space: nowrap;
}
.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.btn-full:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.test-result {
  font-size: 12px;
  min-height: 16px;
}
.test-result.ok { color: #22c55e; }
.test-result.error { color: #ef4444; }
.test-result.testing { color: #eab308; }

/* 提示音选择 */
.sound-select-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.sound-select-row select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* 发送延迟滑块 */
.setting-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 4px;
}
.delay-slider-row {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}
.delay-slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.delay-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s;
}
.delay-slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.delay-slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
.delay-slider-row input[type="number"] {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
}

/* ==================== 手机端信息面板（适中大小） ==================== */
@media (max-width: 768px) {
  .info-panel {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 88% !important;
    max-width: 360px;
    max-height: 80vh;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  .info-panel[style*="display: none"] { display: none !important; }
  .info-panel[style*="display: flex"] { display: flex !important; }
  .info-body { padding: 16px; }
  .info-avatar { width: 56px; height: 56px; font-size: 20px; }
  .info-name { font-size: 15px; }
  .info-section { margin-bottom: 16px; }
  .danger-btn { padding: 10px 16px; font-size: 13px; }
}
