/* ============ EBV 研究知识库 — DeepSeek 风格 ============ */
:root {
  --bg: #0e1117;
  --bg-2: #141821;
  --bg-3: #1c212b;
  --bg-4: #242a38;
  --line: #2d3546;
  --line-2: #3a4458;
  --text: #e4e8ef;
  --text-dim: #8b95a8;
  --text-muted: #6b7588;
  --accent: #4a9eff;
  --accent-2: #7c5cff;
  --accent-hover: #5aa8ff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --code-bg: #0d1117;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --transition: 0.15s ease;
  --mono: "JetBrains Mono", "Consolas", "Menlo", monospace;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --composer-h: 100px;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-2: #ffffff;
  --bg-3: #f0f2f5;
  --bg-4: #e4e7ec;
  --line: #e0e3e8;
  --line-2: #d0d4db;
  --text: #1a1d23;
  --text-dim: #616876;
  --text-muted: #8b91a0;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --accent-hover: #2563eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --code-bg: #f0f2f5;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* ============ 布局 ============ */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }

.sidebar-left {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
  z-index: 100;
  position: relative;
  overflow: hidden;
}

/* 品牌 */
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.brand-dot { font-size: 22px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-toolbar { display: flex; gap: 6px; padding: 2px 0; justify-content: center; flex-wrap: wrap; }
.icon-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn:active { transform: scale(0.95); }

.health {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.health.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.health.bad .dot { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.stat b { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; }
.stat span { font-size: 11px; color: var(--text-dim); }

.section-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 0; }
.section-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }

.dirs { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; max-height: 190px; padding-right: 2px; }
.dirs.collapsed { display: none; }
.dirs-empty { color: var(--text-dim); font-size: 12px; padding: 8px; }
.dir-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; font-size: 12.5px;
  transition: all var(--transition);
}
.dir-item:hover { background: var(--bg-3); border-color: var(--line); }
.dir-item.active { background: rgba(74, 158, 255, 0.14); border-color: var(--accent); }
.dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-item .n { color: var(--text-dim); font-size: 11px; margin-left: 8px; flex-shrink: 0; }

.history-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.history-panel.collapsed { display: none; }
.history-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.history-title { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.history-actions { display: flex; gap: 4px; }
.history-actions .icon-btn { width: 24px; height: 24px; font-size: 11px; }

.conversation-list { flex: 1; overflow-y: auto; padding-right: 4px; }
.conv-section { margin-bottom: 10px; }
.conv-section-title { display: block; font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; padding-left: 4px; }
.conv-item {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.conv-item:hover { border-color: var(--line); background: var(--bg-2); }
.conv-item.active { border-color: var(--accent); background: rgba(74, 158, 255, 0.12); }
.conv-main { display: flex; flex-direction: column; gap: 3px; padding-right: 55px; }
.conv-title { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 10px; color: var(--text-dim); }
.conv-actions { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 3px; opacity: 0; transition: opacity var(--transition); }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions { opacity: 1; }
.conv-pin, .conv-delete { background: transparent; border: none; padding: 3px 5px; border-radius: 4px; font-size: 11px; cursor: pointer; color: var(--text-dim); transition: all var(--transition); }
.conv-pin:hover { background: var(--warn); color: #000; }
.conv-delete:hover { background: var(--bad); color: #fff; }
.conv-empty { text-align: center; padding: 20px; color: var(--text-dim); font-size: 12px; }

.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--text-dim); line-height: 1.6; flex-shrink: 0; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 190; }
.sidebar-overlay.open { display: block; }

/* ============ 主区域 ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; overflow: hidden; }
.topbar {
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-menu-btn { display: none; }
.tabs { display: flex; gap: 4px; }
.tab-btn { background: transparent; color: var(--text-dim); border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; transition: all var(--transition); }
.tab-btn:hover { color: var(--text); background: var(--bg-3); }
.tab-btn.active { color: var(--text); background: var(--bg-3); border-color: var(--line); }
[data-theme="dark"] .tab-btn.active { color: #fff; background: linear-gradient(135deg, #1c2c4e, #22204a); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.tab { display: none; flex: 1; min-height: 0; overflow: hidden; }
.tab.active { display: flex; flex-direction: column; }

/* ============ 聊天区域 ============ */
.chat-area {
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--topbar-h) - var(--composer-h));
  height: calc(100dvh - var(--topbar-h) - var(--composer-h));
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-log {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 72px 30px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.empty { text-align: center; padding: 70px 20px; color: var(--text-dim); margin: auto 0; }
.empty-ico { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty p { font-size: 15px; margin: 8px 0; }
.empty-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 8px !important; }

.msg { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 900px; margin: 0 auto; }
.msg-user { align-items: flex-end; }
.msg-user .msg-q { text-align: right; }
.msg-q { font-size: 12px; color: var(--text-dim); margin-bottom: 2px; font-weight: 500; }
.msg-q .tag { margin-left: 8px; font-size: 10px; padding: 1px 7px; background: var(--bg-3); border-radius: 5px; font-weight: 600; color: var(--accent); }
.msg-a { font-size: 14px; line-height: 1.75; color: var(--text); min-width: 0; }
.user-bubble {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  max-width: 82%;
  word-break: break-word;
}
.msg-meta { font-size: 11px; color: var(--text-dim); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.msg-target { animation: msg-flash 1.6s ease; border-radius: 10px; }
@keyframes msg-flash {
  0% { box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.55); background: rgba(74, 158, 255, 0.08); }
  100% { box-shadow: 0 0 0 0 rgba(74, 158, 255, 0); background: transparent; }
}

/* Markdown */
.msg-a h1, .msg-a h2, .msg-a h3, .msg-a h4 { line-height: 1.4; margin: 16px 0 8px; color: var(--text); }
.msg-a h1 { font-size: 19px; }
.msg-a h2 { font-size: 16.5px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.msg-a h3 { font-size: 15px; }
.msg-a h4 { font-size: 14px; }
.msg-a p { margin: 8px 0; }
.msg-a ul, .msg-a ol { margin: 8px 0; padding-left: 24px; }
.msg-a li { margin: 4px 0; }
.msg-a hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.msg-a blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--bg-3); border-radius: 0 8px 8px 0; color: var(--text-dim); }
.msg-a strong { color: var(--text); font-weight: 700; }
.msg-a a { color: var(--accent); text-decoration: none; }
.msg-a a:hover { text-decoration: underline; }
.msg-a pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; margin: 10px 0; }
.msg-a code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 2px 5px; border-radius: 4px; }
.msg-a pre code { background: transparent; padding: 0; }
.table-wrap { width: 100%; overflow-x: auto; margin: 12px 0; }
.msg-a table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 12.5px; }
.msg-a th, .msg-a td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.msg-a th { background: var(--bg-3); font-weight: 700; white-space: nowrap; }
.msg-a tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }

/* 加载 / 提示 */
.loading { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 12px 2px; color: var(--text-dim); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: 10px 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; color: var(--text-dim); font-size: 13px; }
.notice.error { color: var(--bad); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }

/* 证据链 */
.evidence { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); overflow: hidden; }
.evidence-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text); user-select: none; }
.evidence-head .ev-count { font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.ev-chevron { transition: transform var(--transition); display: inline-block; font-size: 10px; color: var(--text-dim); }
.evidence-head.open .ev-chevron { transform: rotate(180deg); }
.ev-cards { overflow: hidden; }
.ev-cards.collapsed { display: none; }
.ev-card { padding: 11px 12px; border-top: 1px solid var(--line); max-width: 100%; word-wrap: break-word; }
.ev-card:first-child { border-top: none; }
.ev-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.ev-title { font-weight: 600; font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; word-break: break-word; }
.ev-no { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #fff; margin-right: 4px; vertical-align: 1px; }
.ev-badge { font-size: 9.5px; padding: 1px 5px; background: var(--warn); color: #000; border-radius: 3px; white-space: nowrap; }
.ev-score { font-size: 10.5px; color: var(--accent); background: var(--bg-2); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); white-space: nowrap; }
.ev-src { font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; word-break: break-word; }
.ev-text { font-size: 12px; color: var(--text); line-height: 1.6; background: var(--bg); padding: 9px; border-radius: 7px; border: 1px solid var(--line); max-height: 190px; overflow-y: auto; white-space: pre-wrap; word-wrap: break-word; }
.ev-link { display: flex; gap: 6px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.ev-link a { color: var(--accent); text-decoration: none; font-size: 11.5px; }
.ev-link a:hover { text-decoration: underline; }
.ev-open, .ev-download { background: var(--bg-3); border: 1px solid var(--line); color: var(--text); padding: 4px 9px; border-radius: 5px; font-size: 11px; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.ev-open:hover, .ev-download:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.ev-download:disabled { opacity: 0.6; cursor: wait; }
.ev-card.hl { animation: hl-flash 1.8s ease; }
@keyframes hl-flash {
  0% { background: rgba(74, 158, 255, 0.28); }
  60% { background: rgba(74, 158, 255, 0.1); }
  100% { background: transparent; }
}

.ev-ref { display: inline-flex; align-items: center; padding: 1px 7px; background: var(--accent); color: #fff !important; border-radius: 8px; font-size: 10.5px; font-weight: 600; cursor: pointer; margin: 0 2px; transition: all var(--transition); text-decoration: none !important; white-space: nowrap; }
.ev-ref:hover { background: var(--accent-2); transform: translateY(-1px); }

/* 思维导图 */
.mindmap-wrap { margin-top: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #0e1117; padding: 4px; }
.mindmap-wrap svg { display: block; max-width: none; }
.mindmap-cites { margin-top: 10px; padding: 8px 10px; background: var(--bg-3); border-radius: 8px; font-size: 11.5px; color: var(--text-dim); }
.mindmap-cites b { color: var(--text); }

/* 报告操作 */
.report-actions { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.report-actions .ghost-btn { width: auto; padding: 6px 12px; font-size: 12px; }
.saved-note { font-size: 11.5px; color: var(--ok); margin-left: 2px; }

/* ============ 底部固定输入区 ============ */
.composer-fixed {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  height: var(--composer-h);
  z-index: 60;
  background: linear-gradient(to top, var(--bg) 55%, rgba(14, 17, 23, 0.75), transparent);
  padding: 8px 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: none;
}
[data-theme="light"] .composer-fixed { background: linear-gradient(to top, var(--bg) 55%, rgba(247, 248, 250, 0.8), transparent); }
.composer-inner {
  width: 100%;
  max-width: 960px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 10px;
  pointer-events: auto;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15), var(--shadow); }

.composer-left { flex-shrink: 0; position: relative; }
.intent-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.intent-trigger:hover { background: var(--bg-4); border-color: var(--line-2); }
.intent-trigger:focus { outline: none; border-color: var(--accent); }
.intent-icon { font-size: 13px; }
.intent-label { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
.intent-chevron { font-size: 10px; color: var(--text-dim); transition: transform var(--transition); }
.intent-trigger[aria-expanded="true"] .intent-chevron { transform: rotate(180deg); }

.intent-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 120;
  display: none;
  padding: 4px;
  animation: dropdown-in 0.12s ease;
}
@keyframes dropdown-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.intent-dropdown.open { display: block; }
.intent-option { padding: 9px 10px; font-size: 13px; color: var(--text); cursor: pointer; border-radius: 7px; transition: background var(--transition); white-space: nowrap; }
.intent-option:hover, .intent-option.selected { background: var(--bg-3); color: var(--accent); }

.composer-center { flex: 1; min-width: 0; display: flex; align-items: center; }
.composer-center textarea {
  width: 100%;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  padding: 8px 0;
  overflow-y: auto;
}
.composer-center textarea::placeholder { color: var(--text-muted); }
.composer-hint { max-width: 960px; width: 100%; text-align: center; font-size: 11px; color: var(--text-muted); line-height: 16px; height: 16px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.composer-right { flex-shrink: 0; }
.ask-btn, .stop-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.ask-btn { background: var(--accent); box-shadow: 0 2px 8px rgba(74, 158, 255, 0.35); }
.ask-btn:hover { background: var(--accent-hover); transform: scale(1.05); box-shadow: 0 4px 14px rgba(74, 158, 255, 0.45); }
.ask-btn:active { transform: scale(0.95); }
.stop-btn { background: var(--bad); box-shadow: 0 2px 8px rgba(248, 113, 113, 0.35); font-size: 15px; }
.stop-btn:hover { filter: brightness(1.08); transform: scale(1.05); }
.stop-btn:active { transform: scale(0.95); }

/* ============ 右侧对话节点导航 ============ */
.conv-nav {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: var(--composer-h);
  width: 48px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.conv-nav-track {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 12px 0;
  overflow-y: auto;
  pointer-events: auto;
  scrollbar-width: none;
}
.conv-nav-track::-webkit-scrollbar { display: none; }
.conv-nav-stripe {
  width: 5px;
  flex: 1 1 0;
  min-height: 4px;
  max-height: 34px;
  border: none;
  border-radius: 3px;
  background: var(--line-2);
  cursor: pointer;
  padding: 0;
  transition: background var(--transition), width var(--transition), box-shadow var(--transition);
  opacity: 0.75;
}
.conv-nav-stripe:hover { background: var(--accent); width: 9px; opacity: 1; }
.conv-nav-stripe.active { background: var(--accent); width: 8px; opacity: 1; box-shadow: 0 0 8px rgba(74, 158, 255, 0.7); }
.conv-nav-empty {
  width: 4px;
  flex: 1;
  max-height: 100%;
  border-radius: 2px;
  background: repeating-linear-gradient(to bottom, transparent, transparent 12px, var(--line-2) 12px, var(--line-2) 16px);
  opacity: 0.45;
}

.conv-nav-panel {
  position: absolute;
  right: 48px;
  top: 0;
  bottom: 0;
  width: 300px;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.2s ease, opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  z-index: 10;
}
.conv-nav:hover .conv-nav-panel,
.conv-nav:focus-within .conv-nav-panel,
.conv-nav.panel-open .conv-nav-panel { transform: translateX(0); opacity: 1; visibility: visible; pointer-events: auto; }
.conv-nav.panel-locked .conv-nav-panel { transform: translateX(102%); opacity: 0; visibility: hidden; pointer-events: none; }
.conv-nav-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.conv-nav-title { font-size: 13px; font-weight: 600; color: var(--text); }
.conv-nav-header .icon-btn { width: 24px; height: 24px; font-size: 12px; }
.conv-nav-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-nav-item { background: var(--bg-3); border: 1px solid transparent; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: all var(--transition); }
.conv-nav-item:hover { border-color: var(--line); background: var(--bg-2); }
.conv-nav-item.active { border-color: var(--accent); background: rgba(74, 158, 255, 0.12); }
.conv-nav-item-title { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.conv-nav-item-preview { font-size: 10.5px; color: var(--text-dim); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-nav-item-time { font-size: 9.5px; color: var(--text-muted); margin-top: 4px; }

/* 跳转到底部 */
.scroll-to-bottom-btn {
  position: fixed;
  right: 72px;
  bottom: calc(var(--composer-h) + 16px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all 0.2s ease;
  z-index: 55;
}
.scroll-to-bottom-btn.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-to-bottom-btn:hover { background: var(--accent-hover); transform: scale(1.06); }

/* ============ 设置弹窗 ============ */
.settings-backdrop { position: fixed; inset: 0; z-index: 490; display: none; background: transparent; }
.settings-backdrop.open { display: block; }
.settings-popover {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 16px;
  width: 344px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--topbar-h) - 24px);
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.settings-popover.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.settings-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
.settings-header h3 { margin: 0; font-size: 15px; }
.settings-close { background: transparent; border: none; color: var(--text-dim); font-size: 17px; cursor: pointer; padding: 4px; line-height: 1; border-radius: 6px; }
.settings-close:hover { color: var(--text); background: var(--bg-3); }
.settings-body { padding: 12px 16px 16px; }
.settings-section { margin-bottom: 16px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h4 { margin: 0 0 8px; font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.settings-item { margin-bottom: 9px; }
.settings-item:last-child { margin-bottom: 0; }
.settings-item label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; }
.settings-item select {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.settings-item select:focus { border-color: var(--accent); }
.zoom-control { display: flex; align-items: center; gap: 6px; }
.zoom-btn { width: 30px; height: 30px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 14px; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; justify-content: center; }
.zoom-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.zoom-value { min-width: 52px; text-align: center; font-size: 12px; color: var(--text); font-family: var(--mono); }
.about-line { font-size: 12px; color: var(--text-dim); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}
.ghost-btn:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }
.ghost-btn:disabled { opacity: 0.55; cursor: default; }
.ghost-btn.danger { color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }
.ghost-btn.danger:hover { background: rgba(248, 113, 113, 0.1); border-color: var(--bad); color: var(--bad); }

/* ============ 抽屉 ============ */
.drawer-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 400; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(760px, 94vw);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  z-index: 410;
  transform: translateX(105%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
.drawer-head h2 { margin: 0; font-size: 15.5px; line-height: 1.4; word-break: break-word; }
.drawer-meta { font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.drawer-meta a { color: var(--accent); text-decoration: none; }
.drawer-meta a:hover { text-decoration: underline; }
.drawer-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text-dim); padding: 4px; line-height: 1; }
.drawer-close:hover { color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 30px; }
.drawer-actions { display: flex; gap: 8px; margin: 12px 0 4px; }
.drawer-actions .ghost-btn { width: auto; }
.abstract, .fulltext-wrap { margin-top: 14px; }
.abstract h4, .fulltext-wrap h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.abstract p { margin: 0; line-height: 1.75; }
.fulltext { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.65; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; }
.lib-empty { text-align: center; color: var(--text-dim); padding: 40px 0; font-size: 13px; }

/* ============ 文献库 ============ */
#tab-library { padding: 16px 22px 24px; overflow-y: auto; }
.lib-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.lib-q {
  flex: 1;
  min-width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.lib-q:focus { border-color: var(--accent); }
.lib-toolbar select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  max-width: 220px;
}
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.chk input { accent-color: var(--accent); }
.lib-refresh { width: auto; }
.paper-table { display: flex; flex-direction: column; gap: 4px; }
.paper-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: all var(--transition); }
.paper-row:hover { border-color: var(--accent); background: var(--bg-3); transform: translateX(2px); }
.seed-flag { font-size: 9.5px; padding: 1px 5px; background: var(--accent); color: #fff; border-radius: 3px; font-weight: 600; flex-shrink: 0; }
.paper-main { flex: 1; min-width: 0; }
.paper-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paper-sub { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paper-dirs { display: flex; gap: 3px; flex-wrap: wrap; max-width: 300px; justify-content: flex-end; }
.paper-dirs span { font-size: 10px; padding: 1px 6px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 4px; color: var(--text-dim); white-space: nowrap; }
.paper-ft { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; font-weight: 600; flex-shrink: 0; }
.paper-ft.full { color: var(--ok); background: rgba(52, 211, 153, 0.15); }
.paper-ft.abs { color: var(--text-dim); background: var(--bg-3); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: calc(var(--composer-h) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  max-width: min(90vw, 560px);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast.error { border-color: var(--bad); color: var(--bad); }
.toast.success { border-color: var(--ok); color: var(--ok); }

/* ============ 原始回答弹窗 ============ */
.raw-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.raw-dialog { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; width: min(920px, 94vw); max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.raw-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.raw-head h3 { margin: 0; font-size: 14px; }
.raw-close { background: transparent; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }
.raw-close:hover { color: var(--text); }
.raw-pre { margin: 0; padding: 16px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; line-height: 1.65; color: var(--text); }

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .sidebar-left { position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; z-index: 200; transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar-left.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .composer-fixed { left: 0; }
  .conv-nav { display: none; }
  .chat-log { padding: 18px 20px 28px; }
  .scroll-to-bottom-btn { right: 18px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 10px; }
  .tab-btn { padding: 7px 9px; font-size: 12.5px; }
  .composer-fixed { padding: 6px 10px 8px; }
  .composer-inner { padding: 0 7px; gap: 6px; height: 54px; }
  .intent-trigger { padding: 0 8px; height: 38px; }
  .intent-label { max-width: 72px; font-size: 12px; }
  .ask-btn, .stop-btn { width: 38px; height: 38px; }
  .composer-center textarea { height: 38px; min-height: 38px; max-height: 38px; font-size: 14px; }
  .composer-hint { font-size: 10px; }
  .chat-log { padding: 14px 12px 22px; }
  .msg-a { font-size: 13.5px; }
  .user-bubble { max-width: 92%; }
  .settings-popover { right: 8px; width: calc(100vw - 16px); }
  .paper-dirs { display: none; }
  .lib-q { min-width: 100%; }
}
