:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --bg: #f2f4f8;
  --panel: #ffffff;
  --line: #e7ebf2;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

[hidden] { display: none !important; }

/* ---------------- 登录 ---------------- */

.login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(37, 99, 235, 0.24), transparent 60%),
    radial-gradient(900px 500px at 85% 85%, rgba(14, 165, 233, 0.18), transparent 55%),
    linear-gradient(140deg, #0b1220 0%, #16213a 55%, #0f2747 100%);
  padding: 24px;
  z-index: 10;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 18px;
  padding: 34px 32px 26px;
  box-shadow: 0 30px 80px rgba(2, 8, 23, 0.45);
  animation: rise 0.35s ease;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.32);
}

.login-card h1 {
  margin: 18px 0 6px;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
  min-width: 0;
}

.field > span {
  font-size: 13px;
  color: #334155;
  font-weight: 500;
}

.field input,
.field select,
.field textarea,
.quick-form input,
.quick-form textarea,
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field textarea { resize: vertical; min-height: 64px; }

.field input:focus,
.field select:focus,
.field textarea:focus,
.quick-form input:focus,
.quick-form textarea:focus,
.search input:focus,
.composer-box textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: #475569;
}

.btn-ghost:hover { border-color: #cbd5e1; background: #f8fafc; }

.btn-block { width: 100%; padding: 11px; font-size: 14px; }

.form-error {
  margin: -4px 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 12px;
}

.login-hint {
  margin: 18px 0 0;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 顶栏 ---------------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  flex: none;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand strong { font-size: 15px; }

.conn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--faint);
}

.conn i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
}

.conn.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }

.conn.off i { background: var(--red); }

.topbar-center {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 14px;
  border-right: 1px solid var(--line);
}

.stat:last-child { border-right: 0; }

.stat b {
  font-size: 17px;
  font-weight: 600;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}

.stat span { font-size: 11px; color: var(--muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 15px;
}

.icon-btn:hover { background: #f8fafc; border-color: #cbd5e1; }

.icon-btn.muted { opacity: 0.45; }

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 12px;
  color: #475569;
}

.ghost-btn:hover { background: #f8fafc; }

.agent-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: #f8fafc;
  font-size: 12px;
  color: #334155;
}

.agent-chip span:first-child {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.status-btn {
  border-radius: 30px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-btn:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.status-btn.off {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.status-btn.off:before { background: #94a3b8; }

/* ---------------- 布局 ---------------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr) 304px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-right: 1px solid var(--line);
}

.search { padding: 14px 14px 8px; }

.search input {
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 9px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px 12px 10px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tabs button:hover { background: #f8fafc; }

.tabs button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.session-list::-webkit-scrollbar,
.chat-body::-webkit-scrollbar,
.detail-pane::-webkit-scrollbar { width: 6px; }

.session-list::-webkit-scrollbar-thumb,
.chat-body::-webkit-scrollbar-thumb,
.detail-pane::-webkit-scrollbar-thumb { background: #dfe5ee; border-radius: 3px; }

.session-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

.session-item {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.session-item:hover { background: #f7f9fc; }

.session-item.active { background: var(--accent-soft); }

.session-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e8edf6;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex: none;
}

.session-item.active .session-avatar { background: #dbeafe; color: var(--accent); }

.session-avatar .online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #fff;
}

.session-avatar .online-dot.on { background: var(--green); }

.session-main { flex: 1; min-width: 0; }

.session-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
  flex: none;
}

.session-line2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.session-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.session-unread {
  flex: none;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pill {
  flex: none;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.5;
}

.pill.waiting { background: #fff7ed; color: #b45309; }
.pill.serving { background: #f0fdf4; color: #15803d; }
.pill.closed { background: #f1f5f9; color: #64748b; }

.sidebar-foot {
  flex: none;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--faint);
  background: #fbfcfe;
}

/* ---------------- 会话区 ---------------- */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f6f8fb;
}

.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.chat-current-label {
  display: none;
  flex: none;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eff6ff;
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
}

.chat-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e8edf6;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex: none;
}

.session-avatar svg,
.mini-session-avatar svg,
.chat-avatar svg,
.msg-ava svg,
.visitor-avatar svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.mini-session-avatar svg,
.msg-ava svg { width: 16px; height: 16px; }

.visitor-avatar svg { width: 22px; height: 22px; }

.session-avatar img,
.mini-session-avatar img,
.chat-avatar img,
.msg-ava img,
.visitor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.chat-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sub {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 4px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #eef3fb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 10px;
}

.chat-empty p { margin: 0; font-size: 14px; }

.chat-empty small { color: var(--faint); font-size: 12px; max-width: 320px; text-align: center; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.message-list {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 22px 26px 10px;
}

.day-sep {
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  margin: 8px 0 16px;
}

.msg-row {
  display: flex;
  gap: 9px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.msg-row.agent { flex-direction: row-reverse; }

.msg-ava {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #e8edf6;
  color: #475569;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 2px;
}

.msg-row.agent .msg-ava {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}

.msg-col {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.msg-row.agent .msg-col { align-items: flex-end; }

.msg-name {
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 3px;
  padding: 0 2px;
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid #e8edf5;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.msg-row.agent .msg-bubble {
  background: linear-gradient(135deg, #3b82f6, var(--accent-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.msg-time {
  font-size: 10px;
  color: #b0bbcb;
  margin-top: 4px;
  padding: 0 3px;
}

.msg-img {
  display: block;
  max-width: 260px;
  max-height: 260px;
  border-radius: 9px;
  cursor: zoom-in;
}

.msg-sys {
  text-align: center;
  margin: 6px 0 16px;
}

.msg-sys span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 7px;
  background: #e9edf4;
  color: #64748b;
  font-size: 11px;
}

.typing-hint {
  padding: 0 26px 10px;
  font-size: 11px;
  color: var(--faint);
}

/* ---------------- 输入区 ---------------- */

.composer {
  flex: none;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 18px 8px;
}

.quick-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.quick-strip::-webkit-scrollbar { display: none; }

.quick-strip button {
  flex: none;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  border-radius: 14px;
  padding: 5px 10px;
  font-size: 11.5px;
}

.quick-strip button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 6px 8px;
  background: #fbfcfe;
}

.composer-box textarea {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 13.5px;
  line-height: 1.55;
  max-height: 120px;
  padding: 6px 4px;
  min-height: 24px;
}

.composer-box textarea:focus { box-shadow: none; }

.tool-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  flex: none;
}

.tool-btn:hover { background: #f1f5f9; }

.send-btn { flex: none; padding: 8px 18px; }

.composer-tip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 0;
  font-size: 10.5px;
  color: var(--faint);
}

.chat-ended-bar {
  flex: none;
  padding: 14px 20px;
  text-align: center;
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  border-top: 1px solid var(--line);
}

.modal-card.small { max-width: 400px; }
.modal-foot .left-action { margin-right: auto; }

/* ---------------- 右侧详情 ---------------- */

.detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-left: 1px solid var(--line);
}

.detail-tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.detail-tabs button {
  flex: 1;
  border: 0;
  background: #f8fafc;
  border-radius: 8px;
  padding: 7px;
  font-size: 12px;
  color: var(--muted);
}

.detail-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.detail-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.visitor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.visitor-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  flex: none;
}

.visitor-name { font-size: 14px; font-weight: 600; }

.visitor-state { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 5px; margin-top: 2px; }

.visitor-state i { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; }

.visitor-state i.on { background: var(--green); }

.info-group { margin-top: 16px; }

.info-group h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.info-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px dashed #eef1f6;
}

.info-row:last-child { border-bottom: 0; }

.info-row span:first-child {
  flex: none;
  width: 66px;
  color: var(--faint);
}

.info-row span:last-child {
  flex: 1;
  min-width: 0;
  color: #334155;
  word-break: break-all;
}

.info-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  background: #eff6ff;
  color: var(--accent);
  font-size: 11px;
  margin: 0 4px 4px 0;
}

.muted { color: var(--faint); font-size: 12px; }

.quick-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.quick-form input,
.quick-form textarea {
  padding: 9px 10px;
  font-size: 12.5px;
  border-radius: 9px;
}

.quick-form textarea { resize: vertical; min-height: 62px; }

.quick-form .btn { align-self: flex-end; padding: 7px 14px; }

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

.quick-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fbfcfe;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.quick-item:hover { border-color: #bfdbfe; background: var(--accent-soft); }

.quick-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 3px;
}

.quick-item-title .del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  padding: 0 2px;
}

.quick-item-title .del:hover { color: var(--red); }

.quick-item-text {
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------- 悬浮工作台访客列表 ---------------- */

.mini-sessions {
  display: none;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-right: 1px solid var(--line);
}

body.mini-mode .mini-sessions,
body.embed-mode .mini-sessions { display: flex; }

.mini-sessions-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid #f1f5f9;
}

.mini-sessions-title b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  background: #eef2f7;
  color: #475569;
  font-size: 10px;
}

.mini-waiting {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff1f2;
  color: #dc2626;
  font-size: 10px;
  font-weight: 600;
}

.mini-session-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.mini-session-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.mini-session-item:hover { background: #f7f9fc; }
.mini-session-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

.mini-session-avatar {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #e8edf6;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex: none;
}

.mini-session-item.active .mini-session-avatar { background: #dbeafe; color: var(--accent); }

.mini-session-avatar .online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #fff;
}

.mini-session-avatar .online-dot.on { background: var(--green); }

.mini-session-main { flex: 1; min-width: 0; }

.mini-session-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-session-name {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-session-status {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  line-height: 1.4;
  background: #fff7ed;
  color: #b45309;
}

.mini-session-time {
  margin-left: auto;
  flex: none;
  font-size: 10px;
  color: var(--faint);
}

.mini-session-preview {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-session-unread {
  flex: none;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.32);
}

.mini-session-empty {
  padding: 14px 6px 12px;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}

/* ---------------- 迷你悬浮模式 ---------------- */

body.mini-mode { background: linear-gradient(135deg, #eef3fb 0%, #e8eff9 55%, #edf6f7 100%); }

body.mini-mode::before {
  content: "迷你悬浮模式已开启 · 点击右上角方形按钮退出";
  position: fixed;
  left: 24px;
  top: 22px;
  font-size: 12px;
  color: #8fa0ba;
  letter-spacing: 0.3px;
}

body.mini-mode .app {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(640px, calc(100vw - 36px));
  height: min(650px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
  border-radius: 16px;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

body.mini-mode .topbar { height: 52px; padding: 0 12px; gap: 8px; }

body.mini-mode .topbar-center,
body.mini-mode .brand strong,
body.mini-mode .agent-chip,
body.mini-mode #settingsBtn,
body.mini-mode #popBtn,
body.mini-mode #logoutBtn { display: none; }

body.mini-mode .brand { flex-direction: row; align-items: center; }

body.mini-mode .logo { width: 32px; height: 32px; }

body.mini-mode .layout,
body.embed-mode .layout { grid-template-columns: 190px minmax(0, 1fr); }

body.mini-mode .sidebar,
body.mini-mode .detail { display: none; }

body.mini-mode .chat-head { padding: 10px 12px; gap: 8px; background: #f8fafc; }

body.mini-mode .chat-id { flex: 0 1 auto; }

body.mini-mode .chat-current-label,
body.embed-mode .chat-current-label { display: inline-flex; }

body.mini-mode .chat-avatar,
body.embed-mode .chat-avatar { display: none; }

body.mini-mode .chat-actions { flex: none; }

body.mini-mode .chat-sub { display: none; }
body.embed-mode .chat-sub { display: block; font-size: 10px; }

body.mini-mode #closeBtn { display: none; }

body.mini-mode .chat-actions .btn { padding: 7px 10px; font-size: 12px; }

body.mini-mode .message-list { padding: 16px 12px 8px; }

body.mini-mode .msg-col { max-width: 80%; }

body.mini-mode .composer { padding: 8px 10px 6px; }

body.mini-mode .agent-chip { display: none; }

/* 迷你模式下的状态按钮保留，但压缩文字 */

body.mini-mode .status-btn { padding: 5px 9px; font-size: 11px; }

/* 嵌入 iframe：去掉卡片外框，铺满容器 */
#embedCloseBtn { display: none; }

body.embed-mode {
  background: transparent;
}

body.embed-mode::before { display: none; }

body.embed-mode .app {
  position: relative;
  right: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

body.embed-mode #miniBtn { display: none; }

body.embed-mode #embedCloseBtn { display: none; }

body.embed-mode .topbar { height: 48px; padding: 0 10px; }

body.embed-mode .chat-head { padding: 8px 10px; }

/* ---------------- 弹窗 / 提示 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 60px);
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(2, 8, 23, 0.3);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { margin: 0; font-size: 16px; }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 13px;
  color: #334155;
}

.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: 9px;
  z-index: 30;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr) 270px; }
  .topbar-center .stat:nth-child(4) { display: none; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .detail { display: none; }
  .topbar-center { display: none; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 0 12px; }
  .topbar-right .ghost-btn { display: none; }
}

@media (max-width: 560px) {
  body.mini-mode .layout,
  body.embed-mode .layout { grid-template-columns: minmax(0, 1fr); }

  body.mini-mode .mini-sessions,
  body.embed-mode .mini-sessions {
    max-height: 148px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.mini-mode .mini-session-list,
  body.embed-mode .mini-session-list {
    flex: none;
    max-height: 110px;
  }
}
