/* 小鹈鹕 — 设计令牌与组件样式 */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e4e6eb;
  --border-strong: #d0d3d9;
  --text: #1c1e21;
  --text-2: #5c6270;
  --text-3: #8b90a0;
  --accent: #f59e0b;
  --accent-strong: #d97706;
  --accent-soft: #fef3c7;
  --accent-text: #92400e;
  --blue: #0ea5e9;
  --blue-soft: #e0f2fe;
  --blue-text: #075985;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --green-text: #166534;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --red-text: #b91c1c;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
  --sidebar-w: clamp(176px, 17vw, 240px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: clamp(13px, 0.9vw + 3px, 16px);
  line-height: 1.6;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; width: 100%; }

/* ---------- 顶部状态栏 ---------- */
.topbar {
  height: 48px;
  flex: 0 0 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-sep { width: 1px; height: 18px; background: var(--border); }
.hb { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; }
.hb-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-3);
  display: inline-block;
  margin-right: 7px;
  flex: 0 0 9px;
}
.hb-dot.on { background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .35); }
  50% { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); }
}
.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
  white-space: nowrap;
}
.pill.unread { cursor: pointer; }
.pill.unread:hover { border-color: var(--accent); color: var(--accent-text); }
.pill.unread.has { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.pill.push-ok { background: var(--green-soft); border-color: var(--green); color: var(--green-text); }
.pill.push-warn { background: var(--red-soft); border-color: var(--red); color: var(--red-text); font-weight: 600; }

.main { flex: 1; display: flex; min-height: 0; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  padding: 4px 8px 16px;
}
.brand img { height: 26px; width: auto; border-radius: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.nav-group-btn:hover { background: var(--surface-2); }
.nav-group-btn.open { color: var(--accent-text); background: var(--accent-soft); }
.nav-group-btn .caret { margin-left: auto; color: var(--text-3); font-size: 12px; transition: transform .15s; }
.nav-group-btn.open .caret { transform: rotate(90deg); }
.nav-sub { display: none; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.nav-sub.open { display: flex; }
.nav-standalone { padding-left: 12px !important; margin-top: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 30px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-foot { font-size: 12px; color: var(--text-3); padding: 8px; }

/* ---------- 内容区 ---------- */
.content { flex: 1; min-width: 0; overflow: hidden; }
#view { height: 100%; }
.view { height: 100%; overflow-y: auto; padding: clamp(16px, 2.2vw, 28px); }
.view.padless { padding: 0; overflow: hidden; }
.view.proactive-dashboard { height: 100%; overflow-y: auto; overflow-x: hidden; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 18px;
  max-width: none;
}
.card h2 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.card .desc { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; }
.btn-danger { background: var(--red-soft); border-color: transparent; color: var(--red-text); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-confirm { background: var(--green-soft); border-color: transparent; color: var(--green-text); }
.btn-confirm:hover { background: var(--green); color: #fff; }
.btn-edit { background: var(--blue-soft); border-color: transparent; color: var(--blue-text); }
.btn-edit:hover { background: var(--blue); color: #fff; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 70px; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  margin: 0 4px;
}
.badge.info { background: var(--green-soft); color: var(--green-text); }
.badge.warn { background: var(--accent-soft); color: var(--accent-text); }
.badge.success { background: var(--green-soft); color: var(--green-text); }
.badge.error { background: var(--red-soft); color: var(--red-text); }

.empty { color: var(--text-3); text-align: center; padding: 48px 0; }
.muted { color: var(--text-2); font-size: 13px; }

/* ---------- 对话页 ---------- */
.chat-layout { display: flex; height: 100%; min-height: 0; }
.chat-convs {
  width: clamp(200px, 22vw, 280px);
  flex: 0 0 clamp(200px, 22vw, 280px);
  border-right: 1px solid var(--border);
  min-height: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  position: relative;
  padding: 9px 28px 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); }
.conv-item .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .s { font-size: 11px; color: var(--text-3); }
.conv-item .del {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; opacity: 0; font-size: 13px;
}
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { background: var(--red-soft); border-radius: 4px; }
.chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 76%; padding: 10px 14px; border-radius: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { border-color: var(--red); color: var(--red-text); }
.chat-input { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input .input { flex: 1; }

/* ---------- 档案页 ---------- */
.contacts-layout { display: flex; height: 100%; background: var(--surface); }
.contact-sidebar { width: clamp(220px, 26vw, 340px); flex: 0 0 clamp(220px, 26vw, 340px); border-right: 1px solid var(--border); background: var(--surface-2); padding: 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.contact-sidebar > .input { width: 100%; box-sizing: border-box; }
.contact-list {
  width: clamp(200px, 24vw, 300px);
  flex: 0 0 clamp(200px, 24vw, 300px);
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 12px;
}
.contact-item { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.contact-item:hover { background: var(--surface-2); }
.contact-item.active { background: var(--accent-soft); }
.contact-item .name { font-weight: 600; }
.contact-item .sub { font-size: 12px; color: var(--text-3); }
.contact-detail { flex: 1; overflow-y: auto; padding: 24px 30px; }
.contact-chat { height: calc(100% - 4px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.contact-chat-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 26px; border-bottom: 1px solid var(--border); background: var(--surface); }
.contact-chat-header h2 { margin: 0 0 4px; }
.contact-chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 26px; background: var(--surface-2); }
.contact-chat-actions { padding: 12px 26px; border-top: 1px solid var(--border); background: var(--surface); }
.profile-panel { padding: 24px 26px; overflow-y: auto; }
.contact-messages { padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.contact-messages .msg { padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.star-btn { border: none; background: none; cursor: pointer; font-size: 22px; color: var(--text-3); padding: 0; }
.star-btn.on { color: var(--accent); }
.contact-header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.contact-profile-view {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
}
.contact-profile-edit {
  resize: vertical;
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.7;
}
.msg { display: flex; gap: 8px; padding: 3px 0; }
.msg .t { color: var(--text-3); font-size: 12px; white-space: nowrap; font-family: ui-monospace, monospace; }

/* ---------- 意图/日志列表 ---------- */
.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--surface);
}
.item-card .meta { color: var(--text-2); font-size: 12px; margin-top: 6px; }
.item-card .actions { margin-top: 10px; display: flex; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-2);
}
.stat-val { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.row .stat-mini { flex: 1; }

/* ---------- 渠道列表 ---------- */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.channel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}
.channel-card.ghost { opacity: .78; }
.channel-head { display: flex; gap: 12px; align-items: center; }
.channel-icon { font-size: 24px; }
.channel-name { font-weight: 600; }
.channel-type { font-size: 12px; color: var(--text-3); }
.channel-head .badge { margin-left: auto; }
.channel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 记忆输入来源卡片 */
.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0;
}
.source-item .src-icon { font-size: 22px; }
.source-item .src-name { font-weight: 600; }
.source-item .src-desc { font-size: 12px; color: var(--text-3); }
.source-item .src-state { margin-left: auto; }
.log-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; background: var(--surface); font-size: 13px; }
.log-item .log-time { color: var(--text-3); font-size: 12px; font-family: ui-monospace, monospace; }
.log-item .log-source { color: var(--blue-text); font-weight: 600; margin-left: 6px; }

/* ---------- 设置页 ---------- */
.settings-page { max-width: 760px; }
.settings-page .card { max-width: none; }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* 提示浮层 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1c1e21;
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .25s;
  z-index: 99;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* ---------- Agent 任务（DSH） ---------- */
.agent-page { max-width: 1200px; }
.agent-page textarea.input { resize: vertical; min-height: 90px; font-family: inherit; }
.agent-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.agent-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}
.agent-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.agent-item:hover { background: var(--surface-2); }
.agent-item.active { background: var(--blue-soft); border-color: var(--blue); }
.agent-item .t {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.agent-item .s { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.agent-detail { min-width: 0; }
.agent-detail .card { max-width: none; }
.agent-events {
  max-height: calc(100vh - 420px);
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 4px;
}
.event-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 0;
  background: var(--surface);
}
.event-item .event-body { margin-top: 4px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.event-item .agent-think { color: var(--text-2); }
.event-item .agent-tool { background: var(--blue-soft); border-radius: var(--radius-sm); padding: 8px; }
.event-item .agent-tool-result { background: var(--green-soft); border-radius: var(--radius-sm); padding: 8px; }
.event-item pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
}
.tool-name { font-weight: 600; }
.agent-final {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}
.agent-final pre { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.agent-error { color: var(--red-text); background: var(--red-soft); border: 1px solid var(--red); border-radius: var(--radius); padding: 12px; margin-top: 12px; white-space: pre-wrap; }

/* ---------- 对话页 DSH 实时活动流（浅色主题） ---------- */
.dsh-activity {
  align-self: flex-start;
  max-width: 86%;
  min-width: min(560px, 80%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}
.dsh-activity-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}
.dsh-pulse {
  color: var(--blue);
  animation: dshPulse 1.2s infinite;
}
@keyframes dshPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.8); }
}
.dsh-events {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dsh-empty { color: var(--text-3); font-size: 12px; }
.dsh-event {
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 10px;
  background: var(--bg);
  padding: 8px 10px;
  font-size: 13px;
}
.dsh-event-meta { color: var(--text-3); font-size: 11px; margin-bottom: 2px; }
.dsh-event-body { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.dsh-think { color: #7c3aed; }
.dsh-tool { background: #eff6ff; border-left-color: #38bdf8; }
.dsh-tool-result { background: #ecfdf5; border-left-color: #34d399; }
.dsh-tool-name { font-weight: 600; color: #0369a1; }
.dsh-event pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
}
.dsh-think-details {
  border: 1px solid var(--border);
  border-left: 3px solid #7c3aed;
  border-radius: 10px;
  background: var(--bg);
  padding: 8px 10px;
  font-size: 13px;
}
.dsh-think-details summary {
  cursor: pointer;
  font-weight: 600;
  color: #7c3aed;
  user-select: none;
}
.dsh-think-details pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
}

/* 对话页：DSH 正式回复卡片（思考/工具附在回复气泡内） */
.dsh-answer-card {
  max-width: 86%;
  color: var(--text);
}
.dsh-message-group {
  align-self: flex-start;
  width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.dsh-message-group > .dsh-answer-text {
  max-width: min(100%, 860px);
  padding: 10px 14px;
  overflow: visible;
}
.dsh-answer-card .dsh-answer-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
}
.dsh-answer-card .dsh-reasoning-collapse {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 14px;
}
.dsh-answer-card .dsh-reasoning-collapse summary {
  cursor: pointer;
  font-weight: 600;
  color: #7c3aed;
  user-select: none;
}
.dsh-answer-card .dsh-reasoning-collapse pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
}
.dsh-answer-card .dsh-answer-tools {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dsh-answer-card .dsh-answer-tool {
  border: 1px solid var(--border);
  border-left: 3px solid #38bdf8;
  border-radius: 8px;
  background: #eff6ff;
  padding: 6px 8px;
  font-size: 12px;
}
.dsh-answer-card .dsh-answer-tool-result {
  border-left-color: #34d399;
  background: #ecfdf5;
}
.dsh-answer-card .dsh-answer-tool-name {
  font-weight: 600;
  color: #0369a1;
}
.dsh-answer-card .dsh-answer-tool pre {
  margin: 4px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
}
.dsh-answer-card .dsh-answer-text {
  line-height: 1.6;
  word-break: break-word;
  color: var(--text);
}
.dsh-answer-card .dsh-answer-text > div + div { margin-top: 4px; }
.dsh-answer-card .dsh-answer-text ul { margin: 6px 0; padding-left: 22px; }
.dsh-answer-card .dsh-answer-text li + li { margin-top: 4px; }
.dsh-answer-card .dsh-answer-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: ui-monospace, Consolas, monospace;
  font-size: .92em;
}
.dsh-answer-card .rich-spacer { height: 6px; }

/* 增量回答卡片：执行过程整体折叠，工具结果限高，最终回答永远独立可见 */
.dsh-answer-card .dsh-process-collapse {
  width: min(620px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 8px 12px;
}
.dsh-answer-card .dsh-process-collapse > summary {
  cursor: pointer;
  font-weight: 600;
  color: #334155;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dsh-answer-card .dsh-process-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.dsh-answer-card .dsh-process-body {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-right: 4px;
}
.dsh-answer-card .dsh-reasoning-collapse {
  border: 1px solid var(--border);
  border-left: 3px solid #7c3aed;
  border-radius: 8px;
  background: var(--surface);
  padding: 6px 8px;
  font-size: 12px;
}
.dsh-answer-card .dsh-reasoning-collapse summary {
  cursor: pointer;
  font-weight: 600;
  color: #7c3aed;
  user-select: none;
}
.dsh-answer-card .dsh-reasoning-collapse pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
  max-height: 220px;
  overflow-y: auto;
}
.dsh-answer-card .dsh-tool-details {
  border: 1px solid var(--border);
  border-left: 3px solid #38bdf8;
  border-radius: 8px;
  background: #eff6ff;
  padding: 6px 8px;
  font-size: 12px;
}
.dsh-answer-card .dsh-tool-details > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.dsh-answer-card .dsh-tool-name,
.dsh-answer-card .dsh-answer-tool-name {
  font-weight: 600;
  color: #0369a1;
}
.dsh-answer-card .dsh-tool-state {
  font-size: 11px;
  color: var(--text-3);
}
.dsh-answer-card .dsh-tool-args,
.dsh-answer-card .dsh-tool-result pre,
.dsh-answer-card .dsh-process-item pre {
  margin: 6px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-2);
  max-height: 160px;
  overflow-y: auto;
}
.dsh-answer-card .dsh-tool-result {
  margin-top: 6px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  color: var(--text-2);
}
.dsh-answer-card .dsh-tool-result.dsh-tool-error {
  color: var(--red-text);
}
.dsh-answer-card .dsh-tool-result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #047857;
  font-size: 12px;
}
.dsh-answer-card .dsh-tool-result.dsh-tool-error .dsh-tool-result-head { color: var(--red-text); }
.dsh-answer-card .dsh-tool-truncated {
  font-weight: 400;
  color: var(--text-3);
}
.dsh-answer-card .dsh-process-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px 8px;
  font-size: 12px;
}
.dsh-answer-card .dsh-process-item-label {
  font-weight: 600;
  color: #334155;
}
.dsh-answer-card .dsh-answer-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
}

/* ---------- 主动仪表盘 ---------- */
.proactive-dashboard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proactive-dashboard > * { flex-shrink: 0; }
.proactive-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.proactive-hero h2 {
  margin: 0 0 4px;
}
.proactive-heart {
  min-width: 240px;
  margin-bottom: 0;
  padding: 14px 18px;
}
.hb-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.proactive-stat {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.proactive-stats .stat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.proactive-tab-card {
  padding: 0;
  overflow: hidden;
  margin-bottom: 0;
}
.proactive-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0 10px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.proactive-tab {
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.proactive-tab:hover {
  color: var(--text);
  background: var(--accent-soft);
}
.proactive-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-strong);
  background: var(--accent-soft);
}
.proactive-panels {
  min-height: 420px;
}
.pane {
  min-width: 0;
}
.pane.view {
  height: auto;
  overflow: visible;
  padding: 16px;
}

/* ---------- 日历 ---------- */
.calendar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cal-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-title-block { min-width: 150px; text-align: center; line-height: 1.25; }
.cal-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cal-title {
  font-size: 18px;
  font-weight: 700;
  display: block;
}
.cal-month-meta {
  display: block;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 400;
}
.cal-nav {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-2);
}
.cal-nav:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}
.cal-legend {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.cal-dot.once { background: var(--accent); }
.cal-dot.cron { background: var(--blue); }
.cal-dot.ai-task { background: var(--accent); }
.cal-dot.schedule { background: var(--green, #16a34a); }
.cal-dot.reminder { background: var(--blue, #0ea5e9); }
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-week-cell {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  padding: 4px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  cursor: grab;
  user-select: none;
}
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 280px);
  gap: 18px;
  align-items: start;
}
.cal-main { min-width: 0; min-height: 0; }
.cal-side {
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: none;
  contain: size;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cal-side-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.cal-side-head > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cal-side-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.cal-side-tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  padding: 7px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}
.cal-side-tab:hover { color: var(--text); background: var(--surface-2); }
.cal-side-tab.active { color: var(--accent-text); background: var(--accent-soft); }
.cal-side-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-gutter: stable;
}
.cal-side-footer {
  flex: 0 0 auto;
  min-height: 0;
}
.cal-side-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 2px;
  background: var(--surface-2);
}
.cal-todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}
.cal-todo-item:last-child { margin-bottom: 0; }
.cal-todo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.cal-todo-title { min-width: 0; font-weight: 600; word-break: break-word; }
.cal-todo-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cal-cell {
  min-height: clamp(72px, 7.5vh, 96px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-cell:hover {
  background: #fff;
  border-color: var(--border-strong);
}
.cal-cell:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.cal-cell.dim {
  opacity: .4;
  min-height: clamp(72px, 7.5vh, 96px);
}
.cal-cell.today {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.cal-cell.selected {
  box-shadow: 0 0 0 2px var(--accent-strong);
}
.cal-day-num {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-2);
}
.cal-task {
  border: 0;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1.2;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-text);
  overflow: hidden;
}
.cal-task-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: currentColor;
}
.cal-task.cron {
  background: var(--blue-soft);
  color: var(--blue-text);
}
.cal-task.schedule {
  background: var(--green-soft, #dcfce7);
  color: var(--green-text, #166534);
}
.cal-task.reminder {
  background: var(--blue-soft);
  color: var(--blue-text);
}
.cal-task-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.cal-task-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-more {
  font-size: 11px;
  color: var(--text-3);
  text-align: right;
}
.cal-day-detail {
  min-height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px;
}
.cal-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.cal-detail-item {
  margin-bottom: 6px;
  background: var(--surface);
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.cal-detail-item:hover { border-color: var(--accent); }
.cal-detail-empty { padding: 24px 8px; font-size: 12px; }
.proactive-calendar {
  margin-bottom: 4px;
}

/* ---------- 日程表 ---------- */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.schedule-day {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 12px;
}
.schedule-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}
.schedule-day-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.schedule-day-label.overdue {
  color: var(--red-text);
}
.schedule-day-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.schedule-item {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.schedule-item.overdue {
  opacity: .75;
}
.schedule-time {
  flex: 0 0 52px;
  font-weight: 700;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.schedule-main {
  min-width: 0;
  flex: 1;
}
.schedule-title {
  font-weight: 600;
  word-break: break-word;
}

/* ---------- 任务看板 ---------- */
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.task-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.board-column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 300px;
}
.board-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
}
.board-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 30px;
  margin-top: 12px;
}
.list-pager-label {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}
.board-empty {
  color: var(--text-3);
  text-align: center;
  padding: 18px 0;
  font-size: 13px;
}
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.error-text { color: var(--danger, #dc2626) !important; }
.task-title {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px;
}
.modal h3 {
  margin: 0 0 12px;
}
@media (max-width: 900px) {
  .proactive-stats .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-layout { grid-template-columns: 1fr; }
  .cal-side { height: auto !important; max-height: min(606px, 65vh); contain: none; }
  .cal-day-detail { min-height: 0; }
  .task-board { grid-template-columns: 1fr; }
  .board-column { min-height: 120px; }
}
@media (max-width: 560px) {
  .calendar-card { padding: 12px; }
  .cal-head { align-items: flex-start; }
  .cal-legend { width: 100%; justify-content: flex-end; }
  .cal-head-actions { width: 100%; justify-content: space-between; }
  .cal-side { padding: 12px; }
  .cal-cell, .cal-cell.dim { min-height: 72px; padding: 5px 4px; }
  .cal-task { padding: 3px; gap: 3px; }
  .cal-task-time { display: none; }
  .cal-task-text { font-size: 10px; }
}
.unified-item-card { min-width: 0; }
.unified-type-badge { margin-right: 3px; vertical-align: 1px; }

/* ============================================================
   手机适配（本项目追加）
   TinyPelican 原本只有日历区域的响应式规则，外壳（侧边栏 + 顶栏）
   是固定宽度的，窄屏下会把内容挤到只剩一条。
   ============================================================ */
@media (max-width: 760px) {
  .main { flex-direction: column; }

  .topbar { flex-wrap: nowrap; gap: 6px; padding: 8px 10px; }
  .topbar-left { gap: 6px; min-width: 0; overflow: hidden; }
  .topbar-sep,
  .topbar-left .muted { display: none; }
  .topbar-right { gap: 6px; flex: none; }
  .pill { font-size: 11px; padding: 3px 8px; }

  .sidebar {
    width: 100%;
    flex: none;
    padding: 8px 10px 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 2px 2px 8px; font-size: 15px; }
  .brand img { height: 20px; }

  .nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item,
  .nav-standalone {
    flex: none;
    white-space: nowrap;
    padding: 7px 12px !important;
    border-radius: 999px;
    background: var(--surface-2);
  }
  .sidebar-bottom {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding-bottom: 8px;
  }
  .sidebar-foot { padding: 0; }

  .content { padding: 10px; }
  .calendar-card { padding: 10px; }
  .cal-layout { gap: 10px; }
  .cal-side { padding: 10px; }
}

@media (max-width: 420px) {
  .sidebar-foot { display: none; }
  .cal-cell, .cal-cell.dim { min-height: 60px; }
}

/* 窄屏的格子里放不下事件标题（手机上一个格子只有 ~40px 宽），
   改成按类型着色的小圆点：有几个点就是这天有几件事，点开格子看当天详情。 */
@media (max-width: 560px) {
  .cal-task {
    width: 10px;
    height: 10px;
    min-height: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 auto;
    background: #0284c7;
  }
  .cal-task .cal-task-dot,
  .cal-task .cal-task-time,
  .cal-task .cal-task-text { display: none !important; }
  .cal-task.schedule { background: #0284c7; }
  .cal-task.todo { background: #d97706; }
  .cal-task.reminder { background: #7c3aed; }
}

/* ---------- 微信式联系人聊天 ---------- */
.wechat-contacts-layout { display: flex; height: 100%; min-height: 0; background: #f5f5f5; }
.wechat-sidebar { width: 290px; flex: 0 0 290px; display: flex; flex-direction: column; min-height: 0; background: #e9eaec; border-right: 1px solid #d5d6d8; }
.wechat-search-wrap { padding: 18px 16px 12px; background: #e9eaec; }
.wechat-search { width: 100%; height: 38px; border: 0; border-radius: 5px; background: #fff; padding: 0 12px; font-size: 14px; color: #333; box-shadow: inset 0 0 0 1px #ddd; }
.wechat-search:focus { outline: 2px solid #07c160; box-shadow: none; }
.wechat-contact-list { flex: 1; overflow-y: auto; padding: 0 0 18px; }
.wechat-contact-item { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 58px; border: 0; border-bottom: 1px solid #ddd; background: transparent; padding: 10px 14px; text-align: left; cursor: pointer; }
.wechat-contact-item:hover { background: #dfe1e3; }
.wechat-contact-item.active { background: #07c160; color: #fff; }
.wechat-contact-item.active small, .wechat-contact-item.active time { color: rgba(255,255,255,.8); }
.wechat-avatar, .wechat-msg-avatar { display: none; }
.wechat-contact-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.wechat-contact-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.wechat-contact-copy small, .wechat-contact-item time { color: #8b8f95; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wechat-contact-item time { align-self: flex-start; }
.wechat-chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #f5f5f5; }
.wechat-chat-head { height: 62px; flex: 0 0 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid #ddd; background: #f7f7f7; }
.wechat-chat-title { display: flex; flex-direction: column; min-width: 0; }
.wechat-chat-title strong { font-size: 18px; font-weight: 600; }
.wechat-chat-title small { color: #999; font-size: 11px; }
.wechat-head-actions { display: flex; align-items: center; gap: 12px; }
.wechat-head-btn { border: 1px solid #d4d4d4; border-radius: 4px; background: #fff; padding: 7px 12px; cursor: pointer; font-size: 13px; }
.wechat-head-btn:hover { border-color: #07c160; color: #079b4f; }
.wechat-head-icon { border: 0; background: transparent; color: #888; font-size: 25px; cursor: pointer; }
.wechat-head-icon.on { color: #f59e0b; }
.wechat-chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 30px 18px; display: flex; flex-direction: column; gap: 17px; }
.wechat-msg-row { display: flex; align-items: flex-start; max-width: 78%; }
.wechat-msg-row.outgoing { align-self: flex-end; flex-direction: row-reverse; }
.wechat-msg-body { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.wechat-msg-row.outgoing .wechat-msg-body { align-items: flex-end; }
.wechat-msg-body time { color: #b1b1b1; font-size: 10px; margin-bottom: 3px; }
.wechat-bubble { padding: 9px 12px; border-radius: 5px; background: #fff; border: 1px solid #e4e4e4; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.wechat-msg-row.outgoing .wechat-bubble { background: #95ec69; border-color: #95ec69; }
.wechat-composer { flex: 0 0 72px; padding: 10px 20px; background: #f7f7f7; border-top: 1px solid #ddd; }
.wechat-compose-input { width: 100%; height: 48px; resize: none; border: 1px solid #ddd; border-radius: 4px; padding: 10px; background: #fff; font: inherit; color: #999; }
.wechat-profile-pane { width: 0; flex: 0 0 0; overflow: hidden; background: #fff; border-left: 1px solid #ddd; transition: width .2s ease; }
.wechat-profile-pane.open { width: 360px; flex-basis: 360px; overflow-y: auto; padding: 20px; }
.wechat-profile-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; margin-bottom: 20px; }
.wechat-close-btn { border: 0; background: transparent; color: #888; font-size: 24px; cursor: pointer; }
.wechat-profile-name { font-size: 20px; font-weight: 600; margin-bottom: 18px; }
.wechat-profile-label { display: block; margin: 14px 0 6px; color: #666; font-size: 12px; }
.wechat-profile-editor { min-height: 240px; resize: vertical; line-height: 1.7; }
.wechat-profile-pane .btn { margin-top: 12px; }
.wechat-no-selection, .wechat-empty { color: #aaa; text-align: center; padding: 70px 20px; width: 100%; }

/* ---------- 微信式 Agent 对话 ---------- */
.agent-chat-layout { background: #f5f5f5; }
.agent-chat-sidebar { width: 300px; flex-basis: 300px; }
.agent-search-wrap { display: flex; align-items: center; gap: 8px; }
.agent-search-wrap .wechat-search { flex: 1; min-width: 0; }
.wechat-new-chat-btn { width: 36px; height: 36px; flex: 0 0 36px; border: 1px solid #c9cacc; border-radius: 50%; background: #f7f7f7; color: #555; font-size: 22px; line-height: 1; cursor: pointer; }
.wechat-new-chat-btn:hover { border-color: #07c160; color: #079b4f; }
.agent-chat-sidebar .wechat-contact-item { min-height: 64px; }
.agent-chat-sidebar .wechat-contact-item .agent-conv-delete { border: 0; background: transparent; color: #999; font-size: 17px; opacity: 0; cursor: pointer; padding: 4px 7px; }
.agent-chat-sidebar .wechat-contact-item:hover .agent-conv-delete { opacity: 1; }
.agent-chat-sidebar .wechat-contact-item.active .agent-conv-delete { color: rgba(255,255,255,.85); }
.agent-chat-sidebar .wechat-contact-item .agent-conv-delete:hover { color: #d33; }
.agent-chat-sidebar .wechat-contact-item.active .agent-conv-delete:hover { color: #fff; }
.agent-chat-log { background: #f5f5f5; }
.agent-chat-log .wechat-msg-row { max-width: 84%; }
.agent-chat-log .wechat-bubble { font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.agent-chat-log .answer-card, .agent-chat-log .agent-answer-incoming { align-self: flex-start; max-width: 84%; }
.agent-composer { display: flex; align-items: flex-end; gap: 10px; }
.agent-composer .wechat-compose-input { flex: 1; min-height: 44px; max-height: 140px; color: #333; resize: vertical; }
.wechat-send-btn { flex: 0 0 auto; border: 1px solid #07c160; border-radius: 4px; background: #07c160; color: #fff; padding: 9px 18px; font-size: 13px; cursor: pointer; }
.wechat-send-btn:hover { background: #06ad56; }
.wechat-send-btn:disabled { opacity: .5; cursor: not-allowed; }
.wechat-chat-title-name { font-size: 18px; font-weight: 600; }
@media (max-width: 800px) { .wechat-sidebar { width: 220px; flex-basis: 220px; } .wechat-profile-pane.open { position: absolute; right: 0; top: 0; bottom: 0; width: min(360px, 90vw); z-index: 3; box-shadow: -4px 0 14px rgba(0,0,0,.12); } }

/* ---------- 登录 / 注册 / 扫码：独立页面外壳 ---------- */
/* 三个页面共用一套外壳：品牌图标 → 白卡片 → 表单 → 底部链接。 */
body.auth-body {
  overflow-y: auto;
  background: var(--bg);
}
body.auth-body #app { height: auto; min-height: 100vh; }

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  overflow-y: auto;
  padding: clamp(16px, 4vh, 48px) 16px;
  /* 顶部一抹暖色，和图标里的橙黄呼应；没有硬边，不会在小屏上割出横线。 */
  background: radial-gradient(900px 380px at 50% -120px, #fff2da 0%, rgba(255, 242, 218, 0) 72%);
}
#view > .auth-page { min-height: 100%; padding: clamp(16px, 4vh, 48px) 16px; }
.auth-shell { margin: auto; width: 100%; max-width: 400px; }

.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; }
.auth-brand img { width: 76px; height: 76px; }
.auth-brand .auth-name { font-size: 16px; font-weight: 700; letter-spacing: .02em; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 26px 24px;
}
.auth-title { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.auth-sub { margin: 0 0 18px; color: var(--text-2); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field { margin: 0; }
.auth-actions { margin-top: 18px; }
.btn-lg { width: 100%; padding: 11px 18px; font-size: 15px; border-radius: 10px; }
.auth-error { min-height: 18px; margin-top: 12px; font-size: 13px; color: var(--red-text); }
.auth-error.ok { color: var(--green-text); }
.auth-alt { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--text-2); }
.auth-alt a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
.auth-note { margin-top: 12px; font-size: 12px; color: var(--text-3); line-height: 1.8; }
.auth-note a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.auth-note a:hover { text-decoration: underline; }
/* 扫码页顶部的返回链接：让人一眼看到怎么回去 */
.auth-back { color: var(--text-2); font-size: 13px; text-decoration: none; }
.auth-back:hover { color: var(--accent-strong); text-decoration: underline; }
/* 卡片里的说明文字与链接按钮 */
.auth-card .desc { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.auth-card a.desc { display: inline; color: var(--accent-strong); }
a.btn { display: inline-flex; align-items: center; justify-content: center; line-height: 1.4; text-decoration: none; }

@media (max-width: 480px) {
  .auth-card { padding: 22px 18px; border-radius: 14px; }
  .auth-brand img { width: 72px; height: 72px; }
}

/* ---------- 管理员看板 ---------- */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 150px; margin-top: 8px; }
.trend-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.trend-bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; }
.trend-val { font-size: 11px; color: var(--text-3); }
.trend-label { font-size: 10px; color: var(--text-3); white-space: nowrap; }

.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.funnel-label { width: 92px; flex: 0 0 92px; font-size: 13px; color: var(--text-2); }
.funnel-track { flex: 1; min-width: 0; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.funnel-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.funnel-fill.alt { background: var(--blue); }
.funnel-count { width: 84px; flex: 0 0 84px; text-align: right; font-size: 12px; color: var(--text-3); }

.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.admin-table th { font-size: 12px; font-weight: 600; color: var(--text-3); }
.admin-table tbody tr:hover { background: var(--surface-2); }

/* 四象限标签 */
.badge.q1 { background: var(--red-soft); color: var(--red-text); }
.badge.q2 { background: var(--blue-soft); color: var(--blue-text); }
.badge.q3 { background: var(--accent-soft); color: var(--accent-text); }
.badge.q4 { background: var(--surface-2); color: var(--text-3); }

/* 除了标签，整张卡片也按象限加一条颜色边，扫一眼就能区分 */
.item-card.q1 { border-left: 4px solid var(--red); }
.item-card.q2 { border-left: 4px solid var(--blue); }
.item-card.q3 { border-left: 4px solid var(--accent); }
.item-card.q4 { border-left: 4px solid var(--border-strong); }

/* 窄屏：14 根柱子的日期标签会挤在一起，改成每 3 天显示一个 */
@media (max-width: 620px) {
  .trend { gap: 3px; }
  .trend-val { font-size: 10px; }
  .trend-label { display: none; }
  .trend-col:nth-child(3n + 1) .trend-label { display: block; }
  .funnel-label { width: 76px; flex: 0 0 76px; font-size: 12px; }
  .funnel-count { width: 68px; flex: 0 0 68px; }
}

/* ---------- 使用说明（独立文档页） ---------- */
body.doc-body { overflow-y: auto; background: var(--bg); }
.doc-wrap { max-width: 1040px; margin: 0 auto; padding: 24px 20px 64px; }
.doc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px;
}
.doc-brand { display: flex; align-items: center; gap: 12px; }
.doc-brand img { width: 40px; height: 40px; }
.doc-title { font-size: 18px; font-weight: 700; }
.doc-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }

.doc-layout { display: flex; gap: 24px; align-items: flex-start; }
.doc-toc {
  position: sticky; top: 20px; flex: 0 0 190px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.doc-toc-title { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.doc-toc a { color: var(--text-2); font-size: 13px; text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.doc-toc a:hover { background: var(--surface-2); color: var(--accent-text); }

.doc-main { flex: 1; min-width: 0; }
.doc-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 16px;
}
.doc-section h2 { margin: 0 0 12px; font-size: 17px; }
.doc-h3 { margin: 18px 0 6px; font-size: 14px; color: var(--text); }
.doc-section p { margin: 10px 0; color: var(--text-2); font-size: 14px; line-height: 1.75; }
.doc-section code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-size: 13px; font-family: ui-monospace, Consolas, monospace; color: var(--accent-text);
}
.doc-steps { margin: 0; padding-left: 22px; }
.doc-steps li { margin-bottom: 16px; color: var(--text-2); font-size: 14px; line-height: 1.8; }
.doc-steps li strong { color: var(--text); }
.doc-list { margin: 0; padding-left: 20px; }
.doc-list li { margin-bottom: 10px; color: var(--text-2); font-size: 14px; line-height: 1.8; }
.doc-list li strong { color: var(--text); }
.doc-note {
  display: block; margin-top: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.7;
  background: var(--accent-soft); color: var(--accent-text); border-radius: var(--radius-sm);
}
.doc-tip { border-left: 3px solid var(--accent); padding-left: 12px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.doc-table th, .doc-table td { border-bottom: 1px solid var(--border); padding: 9px 10px; text-align: left; vertical-align: top; }
.doc-table th { font-size: 12px; color: var(--text-3); font-weight: 600; white-space: nowrap; }
.doc-table td { color: var(--text-2); line-height: 1.7; }
.doc-table td strong { color: var(--text); }
.doc-pre {
  margin: 10px 0 0; padding: 14px 16px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.8; color: var(--text);
}
.doc-foot { margin-top: 24px; text-align: center; color: var(--text-3); font-size: 12px; }

/* 侧边栏里的说明入口是个链接，样式跟按钮一致 */
a.nav-item { text-decoration: none; }

@media (max-width: 820px) {
  .doc-layout { flex-direction: column; }
  .doc-toc { position: static; flex: none; width: 100%; box-sizing: border-box; flex-direction: row; flex-wrap: wrap; }
  .doc-toc-title { width: 100%; }
  .doc-section { padding: 16px; }
  .doc-head { flex-direction: column; align-items: flex-start; }
}

/* ---------- 助手时间线 ---------- */
.timeline-summary { overflow: hidden; }
.timeline-summary-head h2 { margin-bottom: 6px; }
.timeline-summary-head .btn { flex: 0 0 auto; white-space: nowrap; }
.timeline-pills { align-items: center; }
.timeline-current {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); gap: 18px;
  margin-top: 18px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
}
.timeline-current-label, .timeline-label {
  font-size: 11px; letter-spacing: .1em; color: var(--text-3); font-weight: 700; text-transform: uppercase;
}
.timeline-current-state { margin-top: 6px; font-size: 19px; line-height: 1.45; font-weight: 700; color: var(--text); }
.timeline-current-side { display: grid; gap: 10px; font-size: 13px; line-height: 1.55; }
.timeline-current-side > div { display: grid; grid-template-columns: 68px 1fr; gap: 8px; }
.timeline-next {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); background: var(--accent-soft); font-size: 13px;
}
.timeline-next strong { color: var(--accent-text); font-weight: 600; }
.timeline-next-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.timeline-list { position: relative; margin-top: 18px; }
.timeline-entry { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; }
.timeline-rail { position: relative; display: flex; justify-content: center; }
.timeline-node {
  position: relative; z-index: 1; width: 10px; height: 10px; margin-top: 22px;
  border: 2px solid var(--surface); border-radius: 50%; background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-soft);
}
.timeline-entry-delivery .timeline-node { background: var(--green, #2f9e62); box-shadow: 0 0 0 2px rgba(47, 158, 98, .16); }
.timeline-entry-error .timeline-node, .timeline-entry-delivery_error .timeline-node { background: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }
.timeline-line { position: absolute; top: 34px; bottom: -14px; width: 1px; background: var(--border); }
.timeline-entry:last-of-type .timeline-line { display: none; }
.timeline-card {
  min-width: 0; margin-bottom: 14px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(30, 34, 28, .035);
}
.timeline-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.timeline-meta time { margin-left: auto; white-space: nowrap; }
.timeline-wake { color: var(--text-2); font-weight: 600; }
.timeline-title { margin: 12px 0 0; font-size: 17px; line-height: 1.55; color: var(--text); }
.timeline-quote {
  margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--accent);
  color: var(--text-2); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; line-height: 1.75;
}
.timeline-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.timeline-label { margin-bottom: 6px; }
.timeline-mainline { font-size: 14px; font-weight: 600; line-height: 1.65; color: var(--text); }
.timeline-detail-line { margin-top: 4px; font-size: 13px; line-height: 1.65; color: var(--text-2); }
.timeline-followup { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.timeline-bubble {
  width: fit-content; max-width: min(92%, 620px); margin-top: 7px; padding: 9px 12px;
  border-radius: 12px 12px 12px 4px; background: var(--blue-soft); color: var(--blue-text);
  font-size: 13px; line-height: 1.65; white-space: pre-wrap;
}
.timeline-memory { color: var(--text-3); }
.timeline-delivery-list { display: grid; gap: 7px; }
.timeline-delivery-line {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12px;
}
.timeline-delivery-line.ok { border-color: rgba(47, 158, 98, .28); }
.timeline-delivery-line.fail { border-color: rgba(197, 73, 73, .3); background: var(--red-soft); }
.timeline-delivery-status { font-weight: 700; color: var(--text-2); white-space: nowrap; }
.timeline-delivery-line.ok .timeline-delivery-status { color: var(--green-text, #237a4b); }
.timeline-delivery-line.fail .timeline-delivery-status { color: var(--red-text); }
.timeline-delivery-text { color: var(--text); line-height: 1.55; overflow-wrap: anywhere; }
.timeline-delivery-error { grid-column: 1 / -1; color: var(--red-text); line-height: 1.55; overflow-wrap: anywhere; }
.timeline-delivery-empty {
  padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-3); font-size: 12px; line-height: 1.65;
}
.timeline-error {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--red-soft); color: var(--red-text); font-size: 12px; line-height: 1.65;
  overflow-wrap: anywhere;
}
.timeline-source { margin-top: 12px; color: var(--text-3); font-size: 11px; line-height: 1.55; }

/* 助手记忆面板：展示当前长期记忆与未结束话题 */
.timeline-memory-panel { margin-bottom: 18px; }
.timeline-memory-panel h3 { margin: 0 0 4px; font-size: 17px; }
.timeline-memory-threads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.timeline-memory-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 14px; max-height: 460px; overflow-y: auto; padding-right: 4px;
}
.timeline-memory-entry { border-left: 3px solid var(--border-strong, #d8c8a8); padding: 4px 0 4px 12px; }
.timeline-memory-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.timeline-memory-weight { color: var(--text-3); font-size: 11px; }
.timeline-memory-text { margin-top: 4px; font-size: 14px; line-height: 1.6; color: var(--text-1); overflow-wrap: anywhere; }
.timeline-memory-tags { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; margin-top: 2px; }

@media (max-width: 760px) {
  .timeline-current { grid-template-columns: 1fr; padding: 14px; }
  .timeline-card { padding: 15px; }
  .timeline-title { font-size: 15px; }
  .timeline-meta time { width: 100%; margin-left: 0; }
  .timeline-entry { grid-template-columns: 16px minmax(0, 1fr); gap: 8px; }
  .timeline-node { width: 8px; height: 8px; }
}
