/* =========================================================================
   AI 客服坐席工作台 · 样式
   纯原生 CSS，零外部依赖，桌面优先；宽度 < 900px 时会话信息栏折叠为抽屉。
   ========================================================================= */

:root {
  --primary: #1677ff;
  --primary-strong: #0958d9;
  --primary-soft: #eaf3ff;
  --primary-line: #cfe3ff;

  --bg: #eff2f7;
  --panel: #ffffff;
  --panel-sub: #f8fafc;
  --border: #e5e9f0;
  --border-strong: #d5dbe6;

  --text: #1f2733;
  --text-secondary: #566274;
  --text-muted: #8b95a7;

  --green: #0f8a5f;
  --green-soft: #e7f7f0;
  --orange: #c26a00;
  --orange-soft: #fff4e5;
  --red: #d92d20;
  --red-soft: #fff0ee;
  --gray-soft: #f1f3f7;

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 8px;

  --shadow-panel: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.045);
  --shadow-pop: 0 18px 50px rgba(15, 23, 42, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-app { overflow: hidden; }

h1, h2, h3, p, ul, dl, dd, dt { margin: 0; }
ul { padding: 0; list-style: none; }
button { font-family: inherit; }
textarea, input { font-family: inherit; }
a { color: var(--primary); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd6e2; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #b9c2d2; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid rgba(22, 119, 255, 0.4);
  outline-offset: 1px;
}

/* ============================== 通用按钮 ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn:disabled { opacity: .48; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(22, 119, 255, .24);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-strong); border-color: var(--primary-strong); }

.btn-outline { border-color: var(--border-strong); color: var(--text-secondary); background: #fff; }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: #f0f3f8; color: var(--text); }

.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px 16px; font-size: 14px; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }

.ghost-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.ghost-btn:hover { color: var(--primary); background: var(--primary-soft); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: #f0f3f8; color: var(--text); }

.link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ============================== 品牌区 ============================== */

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, #1677ff 0%, #4d9bff 100%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .4px;
  box-shadow: 0 3px 10px rgba(22, 119, 255, .28);
}

.brand-text { min-width: 0; }
.brand-text h1 { font-size: 15px; font-weight: 650; letter-spacing: .2px; line-height: 1.25; }
.brand-text p { margin-top: 2px; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* ============================== 登录页 ============================== */

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 12% -10%, #e2efff 0%, rgba(226, 239, 255, 0) 60%),
    radial-gradient(800px 480px at 100% 110%, #e9eeff 0%, rgba(233, 238, 255, 0) 62%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  padding: 30px 30px 26px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .1), 0 2px 6px rgba(15, 23, 42, .04);
}

.brand-login { margin-bottom: 26px; }
.brand-login .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 14px; }
.brand-login h1 { font-size: 18px; }
.brand-login p { font-size: 12px; }

.login-form label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.password-field { position: relative; }

.password-field input {
  width: 100%;
  padding: 11px 58px 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.password-field input::placeholder { color: #b3bccb; }
.password-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .12);
}
.password-field .ghost-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }

.form-error, .form-hint {
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  line-height: 1.5;
}
.form-error { background: var(--red-soft); color: var(--red); }
.form-hint { background: var(--primary-soft); color: var(--primary-strong); }

.login-form .btn-block { margin-top: 18px; }

.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ============================== 主界面骨架 ============================== */

.app-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
  flex: 0 0 auto;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
}

.header-right { display: flex; align-items: center; gap: 6px; }

.conn-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: #b3bccb; flex: 0 0 auto; }

.conn-state.is-on { background: var(--green-soft); color: var(--green); }
.conn-state.is-on .conn-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 138, 95, .14); }

.conn-state.is-reconnecting { background: var(--orange-soft); color: var(--orange); }
.conn-state.is-reconnecting .conn-dot { background: var(--orange); animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 0 4px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #eef2f8;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  user-select: none;
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-lg { width: 38px; height: 38px; font-size: 13.5px; background: var(--primary-soft); color: var(--primary); }

/* ============================== 三栏工作区 ============================== */

.workspace {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr) 320px;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 16px 16px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
}

.panel-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-head h2 { font-size: 14px; font-weight: 650; letter-spacing: .2px; }

.count-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}

.panel-foot {
  flex: 0 0 auto;
  padding: 8px 15px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  background: var(--panel-sub);
}

.panel-foot.is-error { color: var(--orange); }

/* ============================== 左：会话列表 ============================== */

.conv-panel { position: relative; }

/* 会话面板头部：标题在上、筛选条在下 */
.conv-panel .panel-head {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.conv-filters {
  display: flex;
  gap: 4px;
  margin-top: 11px;
  padding: 3px;
  border-radius: 8px;
  background: var(--gray-soft);
}

.chip-filter {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.chip-filter:hover { color: var(--text); }
.chip-filter.is-active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(22, 119, 255, .1);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 600;
}
.chip-filter.is-active .filter-count { background: var(--primary-soft); }

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conv-item {
  display: block;
  width: 100%;
  padding: 12px 14px 11px;
  border: 0;
  border-bottom: 1px solid #f0f3f7;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color .13s ease, border-color .13s ease;
}
.conv-item:hover { background: #f7f9fc; }
.conv-item.is-active {
  background: var(--primary-soft);
  border-left-color: var(--primary);
}
.conv-item.is-active .conv-name { color: var(--primary-strong); }

.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.conv-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.conv-time { flex: 0 0 auto; color: var(--text-muted); font-size: 11px; }

.conv-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}
.conv-preview {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.unread-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
}

.conv-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.is-muted { background: var(--gray-soft); color: var(--text-muted); }
.pill.is-muted::before { display: none; }
.pill.is-ai { background: var(--green-soft); color: var(--green); }
.pill.is-waiting { background: var(--orange-soft); color: var(--orange); }
.pill.is-human { background: var(--primary-soft); color: var(--primary); }
.pill.is-closed { background: var(--gray-soft); color: var(--text-muted); }

.pill-lang,
.pill-assignee { background: #f5f7fa; color: var(--text-secondary); }
.pill-lang::before,
.pill-assignee::before { display: none; }
.pill-assignee { max-width: 92px; overflow: hidden; text-overflow: ellipsis; display: inline-block; }

/* 列表加载 / 错误 / 空状态 */

.list-skeleton { padding: 6px 0; }
.skeleton-item { padding: 13px 14px; border-bottom: 1px solid #f0f3f7; }
.sk {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 37%, #eef1f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk-title { width: 55%; height: 12px; margin-bottom: 9px; }
.sk-line { width: 100%; margin-bottom: 7px; }
.sk-line.short { width: 68%; margin-bottom: 0; }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.inline-error {
  margin: 12px;
  padding: 12px;
  border: 1px solid #ffd7d2;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  line-height: 1.6;
}
.inline-error p { margin-bottom: 9px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-list { flex: 1 1 auto; overflow-y: auto; }
.chat-empty { flex: 1 1 auto; }

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  margin-bottom: 14px;
  border-radius: 15px;
  background: #f2f5fa;
  color: #9aa5b8;
}
.empty-icon-lg { width: 60px; height: 60px; border-radius: 18px; color: var(--primary); background: var(--primary-soft); }

.empty-title { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }
.empty-sub { margin-top: 6px; font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }

.empty-tips {
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: left;
  font-size: 12px;
  line-height: 2;
  color: var(--text-muted);
  background: #fbfcfe;
}
.empty-tips li::before { content: "·"; margin-right: 6px; color: var(--primary); font-weight: 700; }
.empty-tips code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f8;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* ============================== 中：聊天区 ============================== */

.chat-panel { position: relative; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.chat-peer { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chat-peer-text { min-width: 0; }
.chat-peer-text h2 {
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-peer-meta { display: flex; align-items: center; gap: 7px; margin-top: 4px; min-width: 0; }

.chat-page-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 11.5px;
}

.chat-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background:
    linear-gradient(180deg, #f7f9fc 0%, #f8fafd 100%);
}

.sync-banner {
  flex: 0 0 auto;
  margin: 10px 18px 0;
  padding: 7px 12px;
  border: 1px solid #ffe2b8;
  border-radius: 8px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12px;
}

.message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 10px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 18px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.date-divider::before,
.date-divider::after { content: ""; width: 42px; height: 1px; background: var(--border); }

.message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
  animation: message-in .18s ease both;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #eef2f8;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  user-select: none;
}

.message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(74%, 640px);
  min-width: 0;
}

.message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 3px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.message-author { font-weight: 600; color: var(--text-secondary); }
.message-time { font-size: 11px; }

.bubble {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  border-top-left-radius: 4px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  font-size: 13.5px;
  line-height: 1.68;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bubble-text { white-space: pre-wrap; }

.message.is-ai .message-avatar {
  background: linear-gradient(135deg, #1677ff 0%, #56a0ff 100%);
  color: #fff;
  font-size: 10px;
}
.message.is-ai .bubble {
  background: #f2f8ff;
  border-color: #d5e7ff;
  border-top-left-radius: 4px;
}

.message.is-agent { flex-direction: row-reverse; }
.message.is-agent .message-body { align-items: flex-end; }
.message.is-agent .message-head { flex-direction: row-reverse; }
.message.is-agent .message-avatar { background: var(--primary); color: #fff; }
.message.is-agent .bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(22, 119, 255, .22);
}

.message.is-pending .bubble { opacity: .62; }

.message.is-system {
  justify-content: center;
  margin: 2px 0 16px;
  animation: none;
}
.message-system-text {
  max-width: 84%;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .045);
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.6;
}

/* AI 消息的依据（知识条目） */

.citations {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed #bcd8fb;
}
.citations-label {
  display: block;
  margin-bottom: 6px;
  color: #4c77a8;
  font-size: 11px;
  font-weight: 500;
}
.citation-list { display: flex; flex-wrap: wrap; gap: 5px; }
.citation {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  border: 1px solid #c8ddf7;
  border-radius: 999px;
  background: #fff;
  color: #3a6a9e;
  font-size: 11px;
  line-height: 1.55;
  text-decoration: none;
}
a.citation:hover { border-color: var(--primary); color: var(--primary); }

/* 消息加载 / 错误 */

.messages-loading {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid #dbe6f5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== 输入区 ============================== */

.composer {
  flex: 0 0 auto;
  padding: 10px 16px 11px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.quick-replies {
  display: flex;
  gap: 6px;
  margin-bottom: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.quick-replies::-webkit-scrollbar { display: none; }

.quick-btn {
  flex: 0 0 auto;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 11px;
  border: 1px solid var(--primary-line);
  border-radius: 999px;
  background: #f7fbff;
  color: var(--primary-strong);
  font-size: 12px;
  cursor: pointer;
  transition: background-color .13s ease, border-color .13s ease;
}
.quick-btn:hover:not(:disabled) { background: var(--primary-soft); border-color: #a9ceff; }
.quick-btn:disabled { opacity: .45; cursor: not-allowed; }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#message-input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 132px;
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  resize: none;
  overflow-y: auto;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
#message-input::placeholder { color: #adb7c6; }
#message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .1);
}
#message-input:disabled { background: #f6f8fb; color: var(--text-muted); cursor: not-allowed; }

.send-btn { height: 40px; padding: 0 18px; flex: 0 0 auto; }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 11px;
}
.char-count { font-variant-numeric: tabular-nums; }

/* ============================== 右：会话信息 ============================== */

.info-panel { overflow: hidden; }

.info-close { display: none; }

.info-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.info-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.info-card-head h3 { font-size: 12.5px; font-weight: 650; color: var(--text); }

.info-list { display: flex; flex-direction: column; gap: 9px; }
.info-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.info-row dt { flex: 0 0 auto; color: var(--text-muted); font-size: 11.5px; line-height: 1.6; }
.info-row dd {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: right;
  word-break: break-word;
}

.mono { font-family: var(--mono); font-size: 11.5px !important; }
.break-all { word-break: break-all; }
.muted { color: var(--text-muted); font-size: 11.5px; line-height: 1.7; }

.page-link { color: var(--primary); text-decoration: none; }
.page-link:hover { text-decoration: underline; }

.info-row dd .pill { vertical-align: middle; }

.hint-card { background: #f6faff; border-color: #d9e9fd; }
.hint-text { font-size: 12.5px; line-height: 1.7; color: #315a86; }
.hint-tips {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed #cfe0f4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hint-tips li { position: relative; padding-left: 11px; color: #6f849c; font-size: 11.5px; line-height: 1.65; }
.hint-tips li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .62em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #9ec3ea;
}

.conn-card .info-card-head { margin-bottom: 7px; }
.conn-card p + p { margin-top: 3px; }

.panel-backdrop { display: none; }

/* ============================== 提示 / 弹窗 ============================== */

.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(440px, calc(100vw - 40px));
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(15, 23, 42, .14);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-show { opacity: 1; transform: none; }
.toast-success { border-color: #b7e7d0; color: #0b6e4b; background: #f2fdf8; }
.toast-error { border-color: #ffd2cd; color: #b42318; background: #fff6f5; }
.toast-warn { border-color: #ffe2b8; color: #9a5a00; background: #fffaf2; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(2px);
  animation: fade-in .15s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(390px, 100%);
  padding: 22px 22px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-pop);
  animation: modal-in .18s ease both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.modal-title { font-size: 15px; font-weight: 650; }
.modal-desc { margin-top: 9px; color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ============================== 响应式 ============================== */

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr) 300px; gap: 10px; padding: 10px 12px 12px; }
  .message-body { max-width: min(78%, 600px); }
}

@media (max-width: 1024px) {
  .workspace { grid-template-columns: 264px minmax(0, 1fr) 282px; }
  .agent-chip-label { display: none; }
  .agent-chip { padding: 3px; border-color: transparent; }
}

@media (max-width: 900px) {
  .workspace {
    position: relative;
    grid-template-columns: 250px minmax(0, 1fr);
    padding: 10px;
  }

  .info-panel {
    position: fixed;
    top: 70px;
    right: 10px;
    bottom: 10px;
    z-index: 80;
    width: min(348px, calc(100vw - 28px));
    transform: translateX(calc(100% + 24px));
    transition: transform .22s ease;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
  }
  body.panel-open .info-panel { transform: translateX(0); }
  .info-close { display: inline-flex; }

  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, .3);
    animation: fade-in .15s ease both;
  }

  .info-toggle { display: inline-flex; }
  .chat-actions { gap: 6px; }
  .message-list { padding: 16px 16px 8px; }
  .chat-header { padding: 10px 14px; }
  .composer { padding: 9px 13px 10px; }
}

@media (min-width: 901px) {
  .info-toggle,
  .info-close,
  .panel-backdrop { display: none !important; }
}

@media (max-width: 680px) {
  .app-header { padding: 0 12px; height: 56px; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 13.5px; }
  .header-right { gap: 2px; }
  .conn-state { padding: 4px 7px; }
  .conn-text { display: none; }
  .app-header .btn-ghost { padding: 6px 7px; font-size: 12px; }
  .workspace { grid-template-columns: 216px minmax(0, 1fr); height: calc(100dvh - 56px); }
  .workspace { padding: 8px; gap: 8px; }
  .conv-panel .panel-head { padding: 10px 11px; }
  .chat-actions .btn { padding: 6px 8px; font-size: 12px; }
  .chat-page-url { display: none; }
  .message-body { max-width: 86%; }
  .message-list { padding: 13px 11px 6px; }
  .quick-replies { margin-bottom: 7px; }
  .send-btn { padding: 0 12px; }
}

/* AI 回答与坐席回复统一靠右显示（访客消息保留左侧），便于区分"我方发出的消息" */
.message.is-ai { flex-direction: row-reverse; }
.message.is-ai .message-body { align-items: flex-end; }
.message.is-ai .message-head { flex-direction: row-reverse; }
.message.is-ai .bubble {
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}
.message.is-ai .citations { align-items: flex-end; }

/* ---------- 手机端（<=720px）：单栏全屏，会话列表与聊天二选一 ---------- */
.back-btn { display: none; }

@media (max-width: 720px) {
  .app-header { height: 52px; padding: 0 10px; gap: 6px; }
  .brand-text { display: none; }
  .brand-mark { width: 32px; height: 32px; font-size: 12px; }
  .agent-chip,
  .conn-state { display: none; }
  .header-right { gap: 3px; }
  .app-header .btn-ghost { padding: 5px 7px; font-size: 11.5px; }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
  }
  .panel { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .conv-panel { display: flex; }
  .chat-panel { display: none; }
  body.mobile-chat .conv-panel { display: none; }
  body.mobile-chat .chat-panel { display: flex; }

  .back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    font-size: 17px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: #26313f;
    cursor: pointer;
  }

  .chat-header { padding: 8px 10px; gap: 8px; }
  .chat-peer { min-width: 0; }
  .chat-actions { gap: 4px; }
  .chat-actions .btn { padding: 6px 8px; font-size: 11.5px; white-space: nowrap; }
  .chat-page-url { display: none; }
  .message-body { max-width: 88%; }
  .message-list { padding: 12px 10px 6px; }
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .quick-replies { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .quick-replies::-webkit-scrollbar { display: none; }
  .info-panel { top: 52px; right: 0; bottom: 0; width: 100%; border-radius: 0; }
}

/* 访客在线状态 */
.pill.pill-online { background: var(--green-soft); color: var(--green); }
.pill.pill-offline { background: var(--gray-soft); color: var(--text-muted); }
dd.is-online { color: var(--green); font-weight: 600; }
dd.is-offline { color: var(--text-muted); }
