/* SciAgent 界面样式：以"论文阅读器"的信息密度为准，不做花哨装饰 */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ee;
  --text: #1c1f26;
  --muted: #6b7280;
  --brand: #2f5bd7;
  --warn: #c2410c;
  --hl: rgba(250, 204, 21, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
}
[v-cloak] { display: none; }

/* 顶栏 */
.topbar {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 500; letter-spacing: .5px;
}
.title { font-size: 15px; font-weight: 500; }
.sub { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 6px; align-items: center; }
/* 模型切换：两个分段按钮。刻意不用「徽标+下拉」——那枚 el-tag 摆在只读徽标的位置上，
   再明显也像状态展示，没人会去点第二下；按钮的边框和按下态是唯一不会误读的形态。 */
.model-switch { display: flex; align-items: center; gap: 4px; }
.ms-btn {
  height: 22px; padding: 0 9px; font-size: 12px; line-height: 20px; border-radius: 11px;
  border: 1px solid var(--el-border-color); background: transparent;
  color: var(--el-text-color-regular); cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.ms-btn:hover { border-color: var(--el-color-primary-light-5); color: var(--el-color-primary); }
.ms-btn.on {
  background: var(--el-color-primary); border-color: var(--el-color-primary); color: #fff;
}
/* 本地态换成绿色：本项目的主色本身就是橙黄色，用 warning 去标"本地"会跟"云端激活"
   撞成同一个颜色——实测两张截图放一起分不出来。绿色只表示"本地/离线中"，
   不参与任何状态色语义。 */
.ms-btn.on.local {
  background: #2f9e44; border-color: #2f9e44; color: #fff;
}
.ms-name {
  font-size: 12px; color: var(--el-text-color-secondary); margin-left: 2px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 三栏布局 */
.layout {
  display: grid; grid-template-columns: 260px 1fr 380px;
  gap: 10px; padding: 10px; height: calc(100vh - 48px);
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden;
}
/* ---------- 面板头部：三个面板共用一套控件标尺 ----------
 * QA 实测（tests/ui_layout_check.py）：.chat-tools 原本没有任何样式，
 * 下拉框/按钮组/流式开关按 inline 基线排列，中心线极差 3.25px
 * （下拉与开关 75.88，按钮组 79.13）——肉眼就是"全部文献和问答没对齐"。
 * 统一改成 flex + align-items:center 后，三者中心线必须完全一致。
 */
.panel-head {
  height: 44px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line);
  font-weight: 500; flex: none;
}
.panel-head > span:first-child {
  flex: 0 1 auto; min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-head small {
  color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 11.5px;
}

/* 中栏头部：三段固定结构 —— 视图切换 / 标题 / 工具。
 * 之前视图切换混在右侧那排工具里，工具数量随视图变化（阅读 7 个、图谱 3 个），
 * 整组被右对齐推着左右漂移，切一次视图按钮就换个位置。
 * 现在切换钉在最左、标题紧随其后、工具用 margin-left:auto 靠右，位置恒定。 */
.panel.center .panel-head { gap: 8px; }
.panel.center .panel-head > .view-switch { flex: none; }
.panel.center .panel-head > .ph-title {
  flex: 0 1 auto; min-width: 0; max-width: 46%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel.center .panel-head > .viewer-tools { margin-left: auto; }

/* 工具栏：中栏翻页与右栏模式切换共用同一套对齐规则 */
.viewer-tools, .chat-tools {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
}
.viewer-tools .el-radio-group,
.viewer-tools .el-button,
.chat-tools .el-radio-group,
.chat-tools .el-switch { flex: none; }

/* 右栏 380px 内要塞下标题+下拉+两段切换+开关，宽度必须卡死，
 * 否则 select 会被 flex 压缩、文字截成"全部文…" */
.chat-tools .scope-select { width: 88px; flex: none; }
/* 「问答 / 对比」这四个字原来顶格：inner 是 inline-block、line-height 12px、
 * 垂直 padding 为 0，文字从 24px 高的块顶部排起，实测文字行盒 top 比按钮 top
 * 还高 1px（溢出），下方却空了 9px。改成 inline-flex 居中，横向 padding 不动。 */
.chat-tools .el-radio-button__inner { padding: 0 9px; }
.chat-tools .stream-switch { margin-left: 0; }
/* 头部控件统一 24px 视觉高度（Element small 默认值），
 * 用行高而不是 padding 撑，避免 select 与按钮组各自算高 */
.panel-head .el-select__wrapper,
.panel-head .el-radio-button__inner,
.panel-head .el-button--small { min-height: 24px; }
/* 左栏 220px 宽时，标题 + 三个文字按钮要 284px，「刷新」会被裁掉（实测 66px）。
 * 后两个入口改成图标/短词，并收紧横向 padding，任何视口都不再溢出。 */
.panel.left .panel-head { gap: 8px; }
.head-tbtn { padding: 0 6px !important; }
.head-ibtn { width: 26px; min-width: 26px; padding: 0 !important; font-size: 14px; }
@media (max-width: 1439px) {
  /* 窄一档时先把篇数省掉：篇数在列表里数得出来，刷新按钮点不到才是真问题 */
  .panel.left .panel-head small { display: none; }
}
/* 头部所有分段按钮统一垂直居中：只给 min-height 不居中，文字会贴着上边缘
 * （line-height 小于字号时还会往上溢出，肉眼就是「顶格」） */
.panel-head .el-radio-button__inner,
.viewer-tools .el-radio-button__inner {
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* 页码：等宽数字 + 固定宽度，翻到 10/15 时不会左右跳 */
.pager-group { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.pager {
  font-size: 12px; color: var(--muted); padding: 0 6px;
  font-variant-numeric: tabular-nums; text-align: center; min-width: 52px;
}
/* 缩放控件：- 百分比 +，比下拉菜单少一次点击，工具条上也放得下 */
.zoom-group { display: inline-flex; align-items: center; gap: 0; flex: none; }
.zoom-pct {
  font-size: 12px; color: #3a4150; min-width: 44px; text-align: center;
  font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 4px; padding: 2px 4px;
}
.zoom-pct:hover { background: #eef2fe; color: var(--brand); }

/* 左栏 */
.upload-area { padding: 10px; border-bottom: 1px solid var(--line); }
/* 批量操作条：只在有勾选时出现，不占常驻空间 */
.sel-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  padding: 6px 8px; background: #f2f6ff; border-bottom: 1px solid #dbe4f8;
  font-size: 11.5px; color: #4b5563;
}
.sel-bar .sel-info { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.sel-bar .sel-n { color: var(--brand); font-size: 13px; }
.sel-bar .sel-hint { font-size: 10.5px; color: #8a93a3; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.sel-bar .sel-acts { display: flex; align-items: center; gap: 3px; width: 100%; }
.sel-bar .sel-btn { padding: 0 6px !important; height: 22px; font-size: 11.5px; }
.sel-bar .sel-del { height: 22px; padding: 0 8px; font-size: 11.5px; margin-left: auto; }
.doc-list { overflow-y: auto; padding: 6px; flex: 1; }
.doc-item {
  /* 顶部对齐：标题最多两行，若垂直居中，复选框会飘到第二行旁边
   * （截图实测 "Understanding Deep Learning" 那行就是这样）。
   * 复选框与删除按钮都对齐到第一行标题。 */
  display: flex; align-items: flex-start; gap: 7px; padding: 7px 6px;
  border-radius: 8px; border: 1px solid transparent;
}
.doc-item .el-checkbox { flex: none; margin-top: 1px; height: auto; }
.doc-item:hover { background: #f7f8fa; }
.doc-item.active { background: #eef2fe; border-color: #c9d6f8; }
/* 删除按钮常驻会让 37 篇文献每一行都挂一个红字，视觉噪音太大。
 * 改成 hover 才淡入，键盘可达（focus-visible）时也显示。 */
.doc-item .doc-del {
  flex: none; opacity: 0; transition: opacity .15s;
  padding: 1px 5px; min-height: 19px; font-size: 11px; margin-top: 1px;
}
.doc-item:hover .doc-del,
.doc-item .doc-del:focus-visible { opacity: 1; }
@media (hover: none) {
  .doc-item .doc-del { opacity: .55; }  /* 触屏没有 hover，保持常显但压低 */
}
.doc-main { flex: 1; min-width: 0; cursor: pointer; }
.doc-title {
  font-size: 12.5px; line-height: 1.35; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
/* 「54 页 · 268 段」里的「段」对用户是生词，hover 给完整解释。
 * cursor:help 是唯一能暗示「这里可以悬浮看说明」的低成本手段，不加图标免得每行都吵。 */
.doc-meta { font-size: 11px; color: var(--muted); margin-top: 2px; cursor: help; }
.tag-warn {
  color: var(--warn); border: 1px solid #f5c9ae; background: #fdf1e8;
  border-radius: 4px; padding: 0 3px; margin-left: 4px; font-size: 10px;
}
.empty { color: var(--muted); font-size: 12px; padding: 14px; text-align: center; }
.empty.big { margin: auto; }
.empty a { display: block; color: var(--brand); text-decoration: none; margin-top: 6px; }

/* 中栏：阅读器 */
.viewer-wrap { position: relative; flex: 1; display: flex; overflow: hidden; }
.tree {
  width: 210px; border-right: 1px solid var(--line); overflow-y: auto; padding: 6px 0;
}
.tree-title { font-size: 11px; color: var(--muted); padding: 4px 10px 8px; }
.tree-item {
  font-size: 12px; padding: 4px 8px; cursor: pointer; line-height: 1.4;
  color: #333;
}
.tree-item:hover { background: #f2f4f8; }
.lvl { color: #9aa1ad; font-size: 10px; margin-right: 5px; }
.page-stage {
  position: relative; flex: 1; overflow: auto; padding: 12px 12px 28px;
  background: #eceef2;
  /* 连续滚动：所有页纵向排列，页与页之间留一条缝，像 PDF 阅读器那样一路滑下去。
     align-items 必须是 flex-start + 子项 margin:auto，不能用 center：
     放大到超过容器宽度时，center 会把左侧那截挤到可视区之外且滚不回去。 */
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
}
/* page-frame 恰好等于页图的渲染尺寸，是所有覆盖层的唯一定位基准。
 * 之前 .hl 直接挂在外层 .page-stage 上，容器有 12px padding，窄屏图片一旦贴边
 * 高亮框就会整体偏 12px —— 只是之前没人逐像素核对过。
 * 连续滚动下宽度固定（不再跟着图片 fit-content），高度由 aspect-ratio 撑开：
 * 图片没下载完占位就对，滚动条不会因为懒加载一路乱跳。 */
.page-frame {
  position: relative; width: 100%; max-width: none;
  margin: 0 auto;             /* 不超宽时居中；超宽时由 align-items:flex-start 保底，左端可滚 */
  box-shadow: 0 1px 6px rgba(0, 0, 0, .12); background: #fff; line-height: 0;
  flex: none;
  /* 文本层按 PDF 原始 pt 布局（宽 612px）再整体 scale 缩小，它的布局宽度
     不会跟着 transform 变，窄屏上就会把滚动容器撑出横向滚动条（实测 390px
     视口里 scrollWidth=910）。裁在页框内，缩放后的可视区域刚好等于页图。 */
  overflow: hidden;
}
.page-frame.is-cur { box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
/* 页脚角标：连续滚动时用户需要一个"这是第几页"的参照，否则滚到一半完全没概念 */
.page-no {
  position: absolute; right: 6px; bottom: 6px; z-index: 3;
  font-size: 10.5px; line-height: 1; color: #6b7280;
  background: rgba(255, 255, 255, .86); border-radius: 8px; padding: 3px 6px;
  pointer-events: none;
}
.pdf-page {
  display: block; width: 100%; height: 100%; object-fit: contain;
  /* 扫描件没有文本层，默认图片可拖：拖一下整张页图就被浏览器拽走，
     只剩下一个幽灵影像跟着光标，看起来像"文档被拖跑了"。 */
  -webkit-user-drag: none; user-select: none;
}
/* 句级高亮：一行一个框，像用荧光笔划过一样贴着文字。
   不加边框——边框会把相邻行之间的 1px 缝隙描成网格，反而更"块"；
   用半透明黄 + 底部一条深一点的线，视觉上仍是"划过"而不是"盖住"。 */
.hl {
  position: absolute; background: rgba(255, 214, 64, .42);
  border-radius: 2px; pointer-events: none; transition: opacity .2s; z-index: 1;
  box-shadow: inset 0 -1px 0 rgba(240, 170, 30, .55);
}
/* 扫描件没有词级文本层，只能给出区块级范围：虚线 + 更淡，明确表示"这是近似" */
.hl.approx {
  background: rgba(255, 214, 64, .18);
  border: 1px dashed rgba(240, 170, 30, .8);
  box-shadow: none;
}

/* 右栏：对话 */
.chat-list { flex: 1; overflow-y: auto; padding: 10px; }
.msg { margin-bottom: 10px; display: flex; align-items: flex-start; }

/* 单条删除：气泡外侧的小圆钮，鼠标移到这条消息上才浮现。
   一直显示会让整屏都是叉号，读答案时很吵。 */
.msg-del {
  flex: none; align-self: flex-start; margin: 3px 0 0 4px;
  width: 18px; height: 18px; padding: 0; line-height: 1;
  border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: #bcc3cf; font-size: 14px;
  cursor: pointer; opacity: 0;
  transition: opacity .12s, color .12s, background .12s, border-color .12s;
}
.msg:hover .msg-del { opacity: 1; }
.msg-del:hover { color: #e5484d; background: #fff1f1; border-color: #f6d0d1; }
.msg-del:focus-visible { opacity: 1; outline: 2px solid var(--brand); outline-offset: 1px; }

/* 清空对话：和流式开关同一行，用最小的视觉重量——它不是高频操作 */
.chat-clear {
  flex: none; height: 24px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 12px; color: var(--muted); cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.chat-clear:hover:not(:disabled) { color: #e5484d; border-color: #f6d0d1; background: #fff1f1; }
.chat-clear:disabled { opacity: .5; cursor: not-allowed; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 96%; padding: 8px 10px; border-radius: 10px;
  background: #f5f6f8; border: 1px solid var(--line); line-height: 1.6;
  font-size: 13px; word-break: break-word;
}
.msg.user .bubble { background: #eef2fe; border-color: #c9d6f8; }
.bubble.loading { color: var(--muted); }
.md code { background: #eef0f3; padding: 0 3px; border-radius: 3px; font-size: 12px; }
/* 表格：自然宽度 + 横向滚动，绝不在窄栏里把中文挤成一字一行 */
.md-table-wrap {
  overflow-x: auto; margin: 6px 0; border-radius: 6px;
  border: 1px solid var(--line);
}
.md-table {
  border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px;
}
.md-table th, .md-table td {
  border: 1px solid var(--line); padding: 4px 9px;
  text-align: left; white-space: normal; min-width: 64px; vertical-align: top;
}
.md-table th { background: #f7f8fa; font-weight: 500; white-space: nowrap; }
.anchor {
  display: inline-block; background: #fff7e6; border: 1px solid #f0b429;
  color: #92400e; border-radius: 4px; padding: 0 4px; font-size: 11px;
  cursor: pointer; margin: 0 2px;
}
.anchor:hover { background: #ffe9bd; }
.verify { font-size: 11px; color: #166534; margin-top: 6px; }
.verify .warn { color: var(--warn); }
.trace { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.step {
  font-size: 10px; color: #475569; background: #eef0f3;
  border-radius: 4px; padding: 1px 5px;
}
.evid { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.evid-title {
  font-size: 11px; color: var(--muted); margin-bottom: 4px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.evid-hint { font-size: 10.5px; color: #a7aebb; flex: none; }
/* 10 条证据全部展开会把整屏占满，给个限高让回答本身留在视野里 */
.evid-list { max-height: 196px; overflow-y: auto; }
.evid-item {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 11px; padding: 3px 4px; border-radius: 5px;
  cursor: pointer; color: #374151;
}
.evid-item:hover { background: #f7f8fa; }
/* 序号徽标曾经会被 flex 压缩，[10] 被拆成「1」「0」两行——必须不可压缩 */
.evid-idx {
  flex: none; white-space: nowrap; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
/* 页码单独成列且不可压缩：文档名再怎么截，"第几页"必须一眼可见 */
.evid-page {
  flex: none; white-space: nowrap; color: #6b7280;
  font-variant-numeric: tabular-nums;
}
/* 文档名固定占比：原来 flex-basis:auto 会和摘要按内容比例抢宽度，
 * 实测被压到只剩 "1706.03…"，v1 与 v1_img 两篇根本分不出来 */
.evid-doc {
  flex: 0 0 40%; min-width: 0;
  color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.evid-txt {
  flex: 1 1 0; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ask-bar { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); align-items: center; }
.ask-bar .el-input { flex: 1; }

/* 快速 / 深思：把"多想一会儿"做成一个可以现场切换的开关。
   默认灰（快速），开启后染成品牌蓝 + 小圆点发光，一眼能看出当前在哪个模式。 */
.think-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 12px; color: var(--muted); user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.think-btn:hover:not(:disabled) { background: #f2f4f8; color: var(--text); }
.think-btn:disabled { opacity: .55; cursor: not-allowed; }
/* 本地模型下深思不可用：虚线边框，和"正在生成所以临时禁点"（实线、很快恢复）
   区分开——否则用户会以为再等等就能点。 */
.think-btn.locked { border-style: dashed; }
.think-btn .think-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #c3c9d4;
  transition: background .15s, box-shadow .15s;
}
.think-btn.on { background: #eaf0fe; border-color: #c9d6f8; color: var(--brand); font-weight: 600; }
.think-btn.on .think-dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(47, 91, 215, .14); }

/* 回答上方的模式与耗时。用等宽数字，多问几条并排看时不跳动 */
.msg-meta {
  font-size: 11px; color: #8a93a3; margin: -2px 0 6px;
  font-variant-numeric: tabular-nums; letter-spacing: .2px;
}

/* 去重弹窗 */
.dup-msg { margin: 0 0 8px; color: #374151; }
.dup-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; }
.dup-name { font-size: 13px; }
.dup-reason { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

@media (max-width: 1280px) {
  /* 右栏 320px 时头部塞不下「标题 + 88px 下拉 + 87px 切换 + 64px 开关」，
   * 实测标题被压到 33px 会截断成「智能…」。放宽到 360px 后一行放得下。 */
  .layout { grid-template-columns: 220px 1fr 360px; }
}

@media (max-width: 1100px) {
  /* 再窄就让右栏头部换行：标题独占一行，工具栏右对齐，绝不压缩文字 */
  .panel.right .panel-head {
    height: auto; min-height: 44px; flex-wrap: wrap;
    padding: 7px 12px; row-gap: 5px;
  }
  .panel.right .panel-head > span:first-child { max-width: 100%; }
  .chat-tools { width: 100%; justify-content: flex-end; }
}

/* ---------- 引用图谱 ---------- */
.graph-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.graph-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.graph-stat { color: var(--text); }
.graph-loading { color: var(--warn); }
.legend { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.legend .dot:first-child { margin-left: 0; }
.dot.cornerstone { background: #d94f4f; }
.dot.bridge { background: #8a63d2; }
.dot.normal { background: #4a7fd4; }
.dot.peripheral { background: #9aa4b2; }

.graph-body { position: relative; flex: 1; min-height: 0; }
.graph-canvas { width: 100%; height: 100%; min-height: 320px; }

.node-card {
  position: absolute; right: 12px; top: 12px; width: 250px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 6px 18px rgba(20, 24, 34, .08); font-size: 12px;
}
.node-title { font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.node-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.node-row b { color: var(--text); font-weight: 500; }

.graph-insight {
  padding: 8px 12px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}

/* 领域综述弹窗 */
.survey-body { max-height: 420px; overflow-y: auto; line-height: 1.75; font-size: 13px; }
.survey-body b { color: var(--brand); }
.survey-refs { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- 中英对照阅读 ----------
 * 两栏各自独立滚动（不是同一个滚动容器切两半），
 * 这样任一侧都能被拖动，联动由 JS 按"段落锚点"驱动。
 */
.bi-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.bi-head {
  height: 28px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); background: #fafbfd;
}
.bi-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-progress { color: var(--brand); flex: none; margin-left: 8px; }

.bi-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.bi-pane { position: relative; overflow-y: auto; scroll-behavior: auto; }
.bi-pane.zh { border-left: 1px solid var(--line); background: #fbfcfe; }
.bi-col-title {
  position: sticky; top: 0; z-index: 3;
  padding: 5px 10px; background: #fff; border-bottom: 1px solid var(--line);
  font-size: 10.5px; color: #8a93a3; letter-spacing: .6px;
}
.bi-pane.zh .bi-col-title { background: #fbfcfe; }

.bi-seg { padding: 8px 10px 10px; border-bottom: 1px dashed #eef0f4; cursor: pointer; }
.bi-seg:hover { background: #f6f9ff; }
.bi-seg.cur { background: #edf3ff; box-shadow: inset 3px 0 0 var(--brand); }
/* 鼠标指向的段落：左右两侧同时点亮。用底色 + 左侧色条，不用描边——
   描边会让相邻两段之间多出一条缝，看起来像表格而不是段落。 */
.bi-seg.hov {
  background: #e8f0ff;
  box-shadow: inset 3px 0 0 var(--brand);
  border-radius: 3px;
}
.bi-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: #9aa4b2; }
.bi-page {
  flex: none; color: var(--brand); background: #eef2fe; border-radius: 4px;
  padding: 0 4px; font-variant-numeric: tabular-nums;
}
.bi-sec { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-text {
  margin: 0; font-size: calc(12.5px * var(--bi-scale, 1)); line-height: 1.62; color: #2a2f38;
  white-space: pre-wrap; word-break: break-word;
}
.bi-text.zh { font-size: calc(13px * var(--bi-scale, 1)); line-height: 1.78; color: #1c1f26; }
.bi-text.pending { color: #b9c0cb; font-style: italic; }
/* 段落头（页码 + 章节名）跟着正文一起放大，否则正文变大、标签还是小字，读起来割裂 */
.bi-meta { font-size: calc(10.5px * var(--bi-scale, 1)); }
.bi-more, .bi-end { padding: 12px; text-align: center; font-size: 11.5px; color: var(--muted); }

/* 流式思考过程时间线 */
.think-timeline {
  border-left: 2px solid #dbe3f5; margin: 0 0 8px; padding-left: 8px;
  font-size: 11px; color: #7b8598; line-height: 1.7;
}
.think-step { display: flex; align-items: baseline; gap: 6px; }
.think-dot {
  flex: none; width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand); display: inline-block; transform: translateY(-1px);
}
.trash-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line);
}
.trash-main { flex: 1; min-width: 0; }

/* ---------- 右栏空状态：样本问题做成可点卡片 ----------
 * 原来是「试试点这个：」+ 一串 a 标签，长问题换行后参差不齐、也没有可点的边界。
 */
.chat-empty { padding: 18px 6px; text-align: left; }
.chat-empty-tip {
  font-size: 11.5px; color: #9aa4b2; letter-spacing: .3px;
  padding: 0 4px 8px; border-bottom: 1px dashed var(--line); margin-bottom: 8px;
}
.sample-q {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: 12.5px; line-height: 1.5; color: #2f3a4d;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px;
  /* 悬挂缩进：换行后与第一行正文左边缘对齐，而不是顶到 ▸ 下方 */
  padding: 7px 9px 7px 21px; text-indent: -12px;
  margin-bottom: 6px; transition: all .15s;
}
.sample-q:hover {
  background: #f2f6ff; border-color: #bfd0f5; color: var(--brand);
  transform: translateX(2px);
}
.sample-q::before { content: "▸ "; color: #b9c2d0; }
.sample-q:hover::before { color: var(--brand); }

/* ---------- 页内文本层：页图负责"好看"，这层负责"可选可点" ----------
 * 布局单位是 PDF 原始 pt（1pt = 1px），整体靠 transform: scale 缩放到图片实际宽度。
 * 这样窗口缩放只改一个 scale，不用重算几百个词的位置。
 * 文字 color: transparent —— 视觉全部来自下面的页图，这层只有选区高亮和点击热区。
 */
.text-layer {
  position: absolute; top: 0; left: 0; z-index: 2;
  transform-origin: top left; pointer-events: none;
}
.tw {
  position: absolute;
  color: transparent; white-space: pre; cursor: text;
  user-select: text; pointer-events: auto;
}
.tw::selection { background: rgba(64, 120, 255, .30); }

/* 点章节树跳转后的高亮提示：标题文字闪 1 秒（默认时长，可用
   localStorage sciagent.secFlashMs 调）。只闪标题那几个词，不是整页涂色——
   整页涂色在 541 页的书里等于没提示，读者仍然不知道"跳到哪一行了"。*/
.tw.secflash {
  background: rgba(255, 196, 0, .55);
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(255, 176, 0, .45);
  animation: secflash 1s ease-out;
}
@keyframes secflash {
  0%   { background: rgba(255, 196, 0, .95); }
  70%  { background: rgba(255, 196, 0, .55); }
  100% { background: rgba(255, 196, 0, .55); }
}
/* 没有文字层（扫描件）时退化成整页描边闪烁 */
.page-frame.sec-flash { animation: pageflash 1s ease-out; }
@keyframes pageflash {
  0%   { box-shadow: 0 0 0 3px rgba(255, 176, 0, .95); }
  100% { box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
}

/* 悬停翻译的原句高亮：贴在页图上的一层淡琥珀色，pointer-events:none 保证
   鼠标还能穿过它落到词上（否则移进去就 leave，气泡会闪）。
   用琥珀而不是蓝色：蓝色已经被"引用角标可点"和"划词选中"占了，语义会混。 */
.hsent {
  position: absolute; pointer-events: none; z-index: 0;
  background: rgba(255, 202, 74, .34);
  box-shadow: 0 0 0 1px rgba(214, 158, 20, .28) inset;
  border-radius: 2px;
}
.hover-tip-hint { font-size: 10.5px; color: #9aa3b2; margin-top: 4px; }
/* 正文角标：hover 时透出一块浅蓝底，告诉用户"这里能点"。
   只用背景不用边框，避免在密集正文里画出一堆方块。 */
.tw.cite { cursor: pointer; border-radius: 2px; }
.tw.cite:hover { background: rgba(64, 120, 255, .22); box-shadow: 0 0 0 1px rgba(64, 120, 255, .5); }
/* 编号在 References 区找不到时用橙色，和"可跳转"的蓝色区分开 */
.tw.cite:not(.refhit):hover { background: rgba(240, 160, 60, .22); box-shadow: 0 0 0 1px rgba(240, 160, 60, .6); }

.tl-note {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px;
  background: rgba(38, 44, 54, .88); color: #fff; font-size: 11.5px;
  padding: 6px 7px 6px 12px; border-radius: 10px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(20, 30, 60, .22);
}
.tl-note-t { pointer-events: none; }

/* 划词翻译浮层：整体就是一张卡片，标题栏是拖动手柄。
   之所以不用 el-dialog：浮层要贴着选区原地出现，模态遮罩会打断阅读。 */
.sel-pop {
  position: fixed; z-index: 3000; width: 320px; max-width: calc(100vw - 16px);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 30, 60, .18);
  overflow: hidden;
}
.sel-pop.dragging {
  box-shadow: 0 18px 44px rgba(20, 30, 60, .28);
  border-color: #c3d0ef;
}
/* 拖动全程禁掉文字选择，否则会把正文一起刷蓝 */
body.is-dragging, body.is-dragging * { user-select: none !important; }

.sel-head {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 5px 0 9px;
  background: #f4f6fb; border-bottom: 1px solid var(--line);
  cursor: grab; touch-action: none;   /* 触屏上拖动不和页面滚动抢手势 */
}
.sel-pop.dragging .sel-head { cursor: grabbing; background: #eef2fe; }
.sel-grip {
  flex: none; width: 10px; height: 14px;
  background-image: radial-gradient(circle, #b9c2d4 1.1px, transparent 1.2px);
  background-size: 5px 5px; background-position: 0 1px;
}
.sel-head-t {
  flex: 1; font-size: 11px; color: #6b7484; letter-spacing: .2px;
  user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sel-x {
  flex: none; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; color: #9aa4b2; font-size: 15px; line-height: 1; cursor: pointer;
}
.sel-x:hover { background: #e2e7f2; color: #3a4250; }

/* 长选区（接口上限 4000 字符）译完可能有上千字，不加高度上限会变成一整屏的白块：
   框内滚动，框本身永远不超过半屏，拖起来也仍然可控 */
.sel-body { padding: 9px 11px 8px; max-height: 46vh; overflow-y: auto; }
/* 系统隐藏滚动条时用户不知道下面还有字，给一条常驻的细条当"还有内容"的信号 */
.sel-body::-webkit-scrollbar { width: 8px; }
.sel-body::-webkit-scrollbar-track { background: transparent; }
.sel-body::-webkit-scrollbar-thumb {
  background: #d3dbec; border-radius: 4px; border: 2px solid #fff;
}
.sel-body::-webkit-scrollbar-thumb:hover { background: #b9c4dc; }
.sel-src {
  font-size: 11px; color: #9aa4b2; line-height: 1.5; margin-bottom: 5px;
  border-left: 2px solid #dbe3f5; padding-left: 6px;
}
/* pre-wrap：整页翻译是多段拼接，段落之间的空行要保留，否则挤成一坨 */
.sel-zh { font-size: 13px; color: #1c1f26; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.sel-foot {
  display: flex; align-items: center; justify-content: flex-end;
  margin-top: 6px; font-size: 10.5px; color: #b0b8c4;
}
.sel-tip { cursor: default; }

/* 参考文献详情浮层：点正文 [11] 后出现，内容与高亮同时到位 */
.cite-pop {
  position: fixed; right: 24px; bottom: 96px; z-index: 3000; width: 400px;
  /* 加了「正文引用 N 处」列表后会变高，屏幕矮时必须自己滚，不能顶出视口 */
  max-height: calc(100vh - 140px); overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 30, 60, .18); padding: 10px 12px;
}
.cite-pop-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 7px;
}
.cite-pop-idx {
  font-size: 12px; color: var(--brand); background: #eef2fe;
  border-radius: 4px; padding: 0 5px; font-variant-numeric: tabular-nums;
}
.cite-pop-page { flex: 1; font-size: 11px; color: var(--muted); }
.cite-pop-text { font-size: 12px; line-height: 1.7; color: #2a2f38; }
.cite-pop-foot { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- 写作 Copilot ---------- */
.write-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.write-head {
  flex: none; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd;
}
.write-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 7px;
}
.write-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.write-body { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }
.write-error {
  margin-bottom: 10px; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  color: #a33; background: #fdf1f1; border: 1px solid #f3cccc;
}

/* 无幻觉证据条：本功能的立论就在这四个数字上，放在正文最前面 */
.write-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.wc-item {
  font-size: 11px; padding: 2px 7px; border-radius: 10px;
  background: #f2f4f8; color: #5b6472; border: 1px solid var(--line);
}
.wc-item.ok { background: #eef8f0; border-color: #c6e6cd; color: #2f7a44; }
.wc-item.bad { background: #fdf1f1; border-color: #f3cccc; color: #a33; }

.write-title {
  font-size: 15px; font-weight: 600; line-height: 1.45; color: #1c2530;
  margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line);
}
.write-sec { margin-bottom: 14px; }
.write-sec-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
  font-size: 12px; font-weight: 600; color: var(--brand);
}
.write-sec-cites {
  font-size: 10.5px; font-weight: 400; color: #8a93a3;
  font-variant-numeric: tabular-nums;
}
.write-sec-text {
  margin: 0; font-size: 12.8px; line-height: 1.75; color: #2a2f38;
  text-align: justify;
}

.write-refs { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.write-refs-head {
  font-size: 12px; font-weight: 600; color: #1c2530; margin-bottom: 7px;
}
.write-refs-head small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 10.5px; }
.write-ref {
  display: flex; gap: 7px; padding: 5px 6px; border-radius: 6px; cursor: pointer;
  font-size: 11.5px; line-height: 1.6; color: #374151;
}
.write-ref:hover { background: #f4f7ff; }
.write-ref.dim { opacity: .45; }
.write-ref-idx { flex: none; color: var(--brand); font-variant-numeric: tabular-nums; }
.write-ref-text { min-width: 0; }

/* 正文引用徽章：可点，点了跳到 References 对应条目 */
.wcite {
  color: var(--brand); background: #eef2fe; border-radius: 3px;
  padding: 0 3px; cursor: pointer; font-variant-numeric: tabular-nums;
  font-size: 11px; vertical-align: 1px; transition: background .12s;
}
.wcite:hover { background: #dde7ff; }
.write-ref.flash { background: #fff6d8; box-shadow: inset 0 0 0 1px #f0c95a; }

/* ---------- 论文发现与推荐（官方 1.4） ---------- */
.disc-drawer .el-drawer__body { padding: 0 18px 26px; }
.disc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.disc-title { font-size: 15px; font-weight: 500; color: #1c1f26; }
.disc-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.disc-search { display: flex; gap: 8px; margin-bottom: 10px; }
/* 输入框是 width:100% 的 flex 子项，不给它 min-width:0 会把「搜索」按钮挤出容器
   （手机上直接看不到按钮） */
.disc-search .el-input { flex: 1 1 auto; min-width: 0; }
.disc-search .el-button { flex: none; }
.disc-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted); margin-bottom: 8px;
}
.disc-hint {
  font-size: 11.5px; color: #8a93a3; line-height: 1.6;
  background: #f6f8fc; border-left: 2px solid #dbe3f5;
  padding: 6px 10px; border-radius: 4px; margin-bottom: 10px;
}

.disc-list { min-height: 80px; }
.disc-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 9px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.disc-card:hover { border-color: #c8d3ea; box-shadow: 0 4px 14px rgba(20, 30, 60, .07); }
.disc-card.ref { display: flex; align-items: flex-start; gap: 10px; }
.ref-body { flex: 1; min-width: 0; }

.disc-card-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px;
}
.disc-aid {
  font-size: 10.5px; color: var(--brand); background: #eef2fe;
  border-radius: 4px; padding: 1px 5px; font-variant-numeric: tabular-nums;
}
.disc-date { font-size: 10.5px; color: #9aa4b2; }
.disc-cat { font-size: 10.5px; color: #6b7484; }
.disc-gh {
  font-size: 10.5px; color: #0f6e56; background: #e1f5ee;
  border-radius: 4px; padding: 1px 5px; margin-left: auto;
}
.disc-rel {
  font-size: 10.5px; color: #854f0b; background: #faeeda;
  border-radius: 4px; padding: 1px 5px; margin-left: auto;
}

.disc-name { font-size: 13px; color: #1c1f26; line-height: 1.5; font-weight: 500; }
.disc-authors { font-size: 11px; color: #8a93a3; margin-top: 2px; }
.disc-abs {
  font-size: 11.5px; color: #5b6474; line-height: 1.65; margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.disc-reason {
  font-size: 12px; color: #3b4453; line-height: 1.65; margin-top: 5px;
  background: #f7f9fd; border-radius: 6px; padding: 6px 9px;
}
.disc-actions { display: flex; align-items: center; gap: 4px; margin-top: 7px; flex-wrap: wrap; }

.disc-ref-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.ref-cites {
  font-size: 10.5px; color: #5b6474; background: #f1f3f8;
  border-radius: 4px; padding: 1px 5px; cursor: help;
}
.tag-ok { font-size: 10.5px; color: #0f6e56; background: #e1f5ee; border-radius: 4px; padding: 1px 5px; }
.tag-aid { font-size: 10.5px; color: #185fa5; background: #e6f1fb; border-radius: 4px; padding: 1px 5px; }
.tag-miss { font-size: 10.5px; color: #8a93a3; background: #f1f3f8; border-radius: 4px; padding: 1px 5px; }

.disc-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); margin-top: 4px;
}
.disc-job { border-top: 1px dashed var(--line); padding-top: 10px; }
.disc-job-row {
  display: flex; align-items: baseline; gap: 8px; font-size: 11.5px;
  padding: 3px 0; color: #4b5361;
}
.job-ok { color: #0f6e56; flex: none; }
.job-bad { color: #a32d2d; flex: none; }
.job-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-err { color: #a32d2d; font-size: 10.5px; }

/* ---------- 整篇中译英（官方 1.6.4） ---------- */
.en-head-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.en-progress { padding: 6px 0 12px; }
.en-preview {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  background: #fcfdff; font-size: 13px; line-height: 1.75; color: #23272f;
  max-height: calc(100vh - 210px); overflow-y: auto;
}
.en-preview h1 { font-size: 18px; font-weight: 600; margin: 0 0 10px; line-height: 1.4; }
.en-preview h2 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; color: #1c1f26; }
.en-preview h3 { font-size: 13px; font-weight: 500; margin: 12px 0 4px; }
.en-preview p { margin: 0 0 9px; }
.en-preview hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.en-preview::-webkit-scrollbar { width: 8px; }
.en-preview::-webkit-scrollbar-thumb { background: #d3dbec; border-radius: 4px; border: 2px solid #fff; }

/* 证据列表里的「关键句」标记：说明这一条已经定位到具体句子，点击只会高亮那一句 */
.evid-focus {
  flex: none; font-size: 10px; color: #854f0b; background: #faeeda;
  border-radius: 3px; padding: 0 4px; line-height: 15px; cursor: help;
}

/* 顶栏「控制台」入口：弱化成文字链接，避免和右侧聊天区的按钮抢注意力 */
.admin-link {
  font-size: 11.5px; color: var(--brand); text-decoration: none;
  border: 1px solid #d7e0f5; background: #f6f9ff;
  border-radius: 5px; padding: 3px 8px; line-height: 1.2;
}
.admin-link:hover { background: #eaf0ff; border-color: #bfd0ff; }

/* ---------- 悬停翻译（官方 1.3.3.1） ---------- */
.hover-switch { margin: 0 6px 0 2px; }
.hover-switch .el-switch__label { font-size: 11.5px; }

/* pointer-events:none 不能省：否则鼠标移进浮层会触发词的 mouseleave，
   浮层闪一下就消失，来回抖动 */
.hover-tip {
  position: fixed; z-index: 3100; width: 340px; pointer-events: none;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 10px 26px rgba(20, 30, 60, .16); padding: 8px 11px;
}
.hover-tip-zh { font-size: 12.5px; line-height: 1.68; color: #1c1f26; }
.hover-tip-load { font-size: 12px; color: #9aa4b2; }
.hover-tip-src {
  font-size: 10.5px; color: #98a2b1; line-height: 1.5; margin-top: 5px;
  border-left: 2px solid #dbe3f5; padding-left: 6px;
}

/* ---------- 引用浮层：正文引用列表（官方 1.3.2 反向跳转） ---------- */
.cite-pop-cites {
  margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 7px;
  max-height: 190px; overflow-y: auto;
}
.cite-pop-sub { font-size: 10.5px; color: var(--muted); margin-bottom: 5px; }
.cite-pop-hit {
  display: flex; align-items: baseline; gap: 6px; padding: 4px 6px;
  border-radius: 5px; cursor: pointer;
}
.cite-pop-hit:hover { background: #f3f7ff; }
.cph-page {
  flex: none; font-size: 10px; color: var(--brand); background: #eef2fe;
  border-radius: 3px; padding: 0 4px; font-variant-numeric: tabular-nums;
}
.cph-txt {
  flex: 1; min-width: 0; font-size: 11px; color: #4b5361; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cph-n { flex: none; font-size: 10px; color: #854f0b; }

/* ---------- 中文译本抽屉（官方 1.3.3.2） ---------- */
.zh-more { font-size: 11px; color: #9aa4b2; text-align: center; padding: 8px 0 2px; }

/* ---------- 写作助手：架构图 / 数据图表（官方 1.6.2 / 1.6.3） ---------- */
/* 三个 tab 放在写作视图顶部：1.6.1 框架 / 1.6.2 架构图 / 1.6.3 数据图表 */
.wtabs {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 0 12px; height: 34px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.wtab {
  padding: 4px 11px; border-radius: 7px; font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none; transition: background .15s, color .15s;
}
.wtab:hover { background: #f2f4f8; color: var(--text); }
.wtab.on { background: #eaf0fe; color: var(--brand); font-weight: 600; }
.wtabs-note { margin-left: auto; font-size: 11px; color: #a6adba; }

/* 图表/架构图共用的左右两栏：左边代码，右边预览 */
.viz-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.viz-title {
  font-size: 13px; font-weight: 600; color: #1c2530; margin: 2px 0 8px;
}
/* 写作视图本身只占中间一栏（约 700px），左右分栏后每栏只剩 340px，
   Mermaid 的 7 节点架构图会缩到看不清。这里改成上下堆叠，宽度全给一块。 */
.viz-split {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 10px; align-items: start;
}
.viz-pane {
  min-width: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; overflow: hidden;
}
.viz-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; background: #fafbfd; border-bottom: 1px solid var(--line);
}
.viz-bar-t { font-size: 11.5px; font-weight: 600; color: #4b5563; }
.viz-note { font-size: 10.5px; color: #a6adba; }
.viz-fmts { display: flex; gap: 2px; flex-wrap: wrap; }
.viz-fmt {
  padding: 2px 8px; border-radius: 6px; font-size: 11.5px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.viz-fmt:hover { background: #eef1f6; }
.viz-fmt.on { background: #eaf0fe; color: var(--brand); font-weight: 600; }
.viz-acts { display: flex; gap: 2px; align-items: center; }

/* 代码块：等宽 + 可滚。高度封顶，长代码不把右侧预览顶出屏幕 */
.viz-pre {
  margin: 0; padding: 9px 11px; max-height: 340px; overflow: auto;
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-size: 11.5px; line-height: 1.6; color: #24303f;
  background: #fcfcfe; tab-size: 2; white-space: pre;
}
.viz-pre::-webkit-scrollbar { width: 8px; height: 8px; }
.viz-pre::-webkit-scrollbar-thumb { background: #d5d9e2; border-radius: 4px; }

.viz-prev {
  padding: 10px; min-height: 200px; max-height: 440px; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
}
/* 不让 mermaid 的 SVG 缩到容器宽度：7 个节点的图缩到 400px 时字号只剩 6px。
   保持它自己算出的自然尺寸，放不下就滚动——预览要的是"看得清结构"。 */
.viz-prev svg { width: auto !important; max-width: none !important; height: auto; }
/* 架构图预览：ECharts 自己排版，高度由层数决定（JS 里写行内 height） */
.topo-chart { width: 100%; height: 260px; }
/* 数据图表预览：ECharts 自绘（纵轴从 0 起），高度 JS 里给 */
.chart-chart { width: 100%; height: 320px; }

.viz-prev-hint {
  padding: 14px 12px; font-size: 11.5px; line-height: 1.7; color: var(--muted);
  background: repeating-linear-gradient(135deg, #fbfcfd, #fbfcfd 8px, #f7f8fb 8px, #f7f8fb 16px);
  min-height: 120px;
}
.viz-table {
  border-collapse: collapse; font-size: 11.5px; width: 100%;
  font-variant-numeric: tabular-nums;
}
.viz-table th, .viz-table td {
  border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: right;
}
.viz-table th:first-child, .viz-table td:first-child { text-align: left; }
.viz-table th { background: #fafbfd; font-weight: 600; color: #3b4351; }
.viz-table tr:last-child td { border-bottom: none; }

/* CSV 输入区：左边文本域，右边按钮列 */
.csv-row { display: flex; gap: 8px; align-items: stretch; }
.csv-input { flex: 1; min-width: 0; }
.csv-side { display: flex; flex-direction: column; gap: 6px; justify-content: flex-start; }
.chart-opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fmt-select { width: 148px; }
.title-input { width: 168px; }

/* 图注卡片：中英双版 + 趋势 + 数字核对结果 */
.cap-card {
  margin-top: 12px; padding: 11px 13px 12px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
}
.cap-head {
  display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600;
  color: var(--brand); margin-bottom: 7px;
}
.cap-head small { font-weight: 400; color: #8a93a3; font-size: 10.5px; }
.cap-acts { margin-left: auto; }
.cap-zh { margin: 0 0 7px; font-size: 12.5px; line-height: 1.8; color: #2a2f38; text-align: justify; }
.cap-en {
  margin: 0 0 9px; font-size: 12px; line-height: 1.75; color: #4a5260;
  font-family: "Times New Roman", Georgia, serif; text-align: justify;
}
.cap-trend {
  font-size: 11.5px; line-height: 1.7; color: #2f7a44; background: #f2faf4;
  border: 1px solid #d6ecdc; border-radius: 7px; padding: 6px 9px;
}
.cap-trend-t { font-weight: 600; margin-right: 6px; }
.cap-warn {
  margin-top: 8px; font-size: 11.5px; line-height: 1.6; color: #a33;
  background: #fdf1f1; border: 1px solid #f3cccc; border-radius: 7px; padding: 6px 9px;
}

/* 冷启动提示条：只在云端首次访问、预热超过 3 秒时出现 */
.warm-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.9);
  color: #f9fafb;
  font-size: 13px;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  animation: warm-in 0.25s ease-out;
}
.warm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  animation: warm-pulse 1.1s ease-in-out infinite;
}
@keyframes warm-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}
@keyframes warm-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================ 手机版（≤760px）
 * 原来窄屏只是把三栏从 260/1fr/380 依次收窄，收到手机上就是这个样子：
 * 左栏被切成半截、字号小到看不清、整页还能左右拖。手机不是"窄一点的桌面"，
 * 一次只能看一栏，所以这里改成「一栏 + 底部切换」。
 */
.mnav { display: none; }

@media (max-width: 760px) {
  html, body { height: 100%; }
  body { font-size: 13.5px; -webkit-text-size-adjust: 100%; }

  /* 顶栏：去掉副标题与两个次要标签，剩下的放得下就不换行。
     badges 必须能收缩——390px 下"模型名 + 文献数"两个标签正好差几个像素，
     原来写 flex:none 会把「文献 38」挤出右边缘（截图里能看到边框被切掉）。 */
  .topbar { height: 44px; padding: 0 10px; gap: 6px; }
  .brand { gap: 6px; min-width: 0; flex: 0 0 auto; }
  .brand .sub { display: none; }
  .badges { gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .badges .el-tag { flex: 0 1 auto; min-width: 0; }
  /* 首个徽标位置现在是模型切换（div）：手机上只留两个按钮，模型名省掉 */
  .badges .model-switch { flex: 0 0 auto; }
  .badges .ms-name { display: none; }
  /* 有切换按钮时，其余徽标在手机上全部让位（按钮本身就是要点的东西）；
     没有按钮（公网无本地模型）时退化成原来的只读模型标签，规则同上 */
  .badges .el-tag:nth-child(2), .badges .el-tag:nth-child(3),
  .badges .el-tag:nth-child(4) { display: none; }
  .badges .admin-link { display: none; }

  /* 布局：不再用 grid，一栏占满；高度扣掉顶栏与底部导航 */
  .layout {
    display: block; height: auto; padding: 0; gap: 0;
    height: calc(100vh - 44px - 58px);
    height: calc(100dvh - 44px - 58px);
  }
  .layout > .panel { display: none; height: 100%; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .mpane-docs   > .panel.left   { display: flex; }
  .mpane-reader > .panel.center { display: flex; }
  .mpane-qa     > .panel.right  { display: flex; }

  /* 面板头：标题一行、工具一行，工具横向可滑（阅读器那排按钮 6 个，硬挤会换三行） */
  .panel .panel-head {
    height: auto; min-height: 42px; flex-wrap: wrap;
    padding: 6px 10px; row-gap: 5px; gap: 6px;
  }
  .panel .panel-head > span:first-child { max-width: 100%; }
  /* 换行而不是横向滚动：横滑会把「下一页」藏到屏幕外，
     而翻页恰恰是阅读器最常用的操作。换行后六件控件两行内都看得见。 */
  .viewer-tools, .chat-tools {
    width: 100%; justify-content: flex-start; gap: 4px; flex-wrap: wrap; row-gap: 4px;
  }
  .viewer-tools > *, .chat-tools > * { flex: none; }
  .pager { min-width: 44px; }
  .chat-tools .scope-select { width: 96px; }
  .panel-head .el-radio-button__inner { padding: 0 8px; }
  /* 触屏没有 hover，悬停翻译在手机上不可能触发；留着只占位置，
     还会把「上一页/下一页」挤出可视区 */
  .viewer-tools .hover-switch { display: none; }

  /* 文献列表：行高加大到能点准（原来 7px padding，手指一按就点到隔壁） */
  .doc-item { padding: 11px 8px; gap: 9px; }
  .doc-title { font-size: 13.5px; -webkit-line-clamp: 3; }
  .doc-meta { font-size: 11.5px; }
  .upload-area { padding: 8px; }
  .doc-item .doc-del { opacity: .55; font-size: 12px; padding: 3px 7px; }

  /* 阅读器：页图满宽，章节树改成浮层（原来 210px 会把正文挤成一条） */
  .page-stage { padding: 6px; }
  .panel.center .tree {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 8;
    width: 74%; max-width: 260px; background: var(--panel);
    box-shadow: 2px 0 14px rgba(0, 0, 0, .12);
  }

  /* 问答：气泡满宽，引用来源那块单独滚，不要把整栏顶出去 */
  .chat-list { padding: 8px; }
  .empty.chat-empty { padding: 8px; }
  /* 触屏可点高度：原来 7px 上下留白，实际只有 35px，手指容易点到隔壁 */
  .sample-q { font-size: 12.5px; line-height: 1.5; padding: 11px 9px 11px 23px; }

  /* 图谱 / 写作：这两个视图内部本来就有自己的滚动区 */
  .graph-bar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .legend { margin-left: 0; }
  .write-wrap { padding: 0 8px 8px; }
  .wtabs { overflow-x: auto; scrollbar-width: none; }
  .wtabs::-webkit-scrollbar { display: none; }
  .wtabs .wtab { flex: none; }
  .viz-split { display: block; }
  .viz-pane + .viz-pane { margin-top: 8px; }

  /* 弹窗与抽屉：Element 用的是行内 width/size，只能 !important 盖掉 */
  .el-dialog { width: 94vw !important; max-width: 94vw; margin-top: 8vh !important; }
  .el-drawer { width: 100% !important; max-width: 100vw; }
  .el-drawer__body { padding: 10px; }

  /* 保活提示原来贴底居中，会被底部导航压住 */
  .warm-toast { left: 10px; right: 10px; bottom: 66px; font-size: 12px; }

  /* 底部导航 */
  .mnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: 58px; padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .mnav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; border: 0; background: none; color: var(--muted);
    font-size: 11px; font-family: inherit; cursor: pointer; padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav-btn .mnav-i {
    width: 22px; height: 22px; border-radius: 6px; display: flex;
    align-items: center; justify-content: center;
    font-size: 12px; background: #eef1f6; color: #5b6472;
  }
  .mnav-btn.on { color: var(--brand); font-weight: 500; }
  .mnav-btn.on .mnav-i { background: var(--brand); color: #fff; }
}

/* 超窄屏（≤380px，如 iPhone SE）：再省一点横向空间 */
@media (max-width: 380px) {
  .brand .title { font-size: 14px; }
  .badges .el-tag:nth-child(3) { display: none; }
  .doc-title { font-size: 13px; }
}


/* 页图加载失败占位：尺寸撑住阅读区，避免整块塌成 0 高让布局跳一下 */
/* page-frame 原本是 width: fit-content，跟着图片走。图片加载失败时 fit-content
 * 就等于 0 宽，提示文字会被挤成一列竖排（实测宽度只剩 40px）。失败态给它一个
 * 明确宽度，顺便把 line-height:0 还原——那是为了消除图片底部空隙设的。 */
.page-frame.is-failed { width: min(100%, 760px); min-height: 62vh; line-height: normal; }
.img-fail {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 24px 18px;
  text-align: center; color: var(--muted); background: #fafbfd;
}
.img-fail-t { font-size: 14.5px; font-weight: 500; color: #3a4150; }
.img-fail-s { font-size: 12.5px; line-height: 1.65; max-width: 380px; }


/* ---------- 思考过程与流式输出 ---------- */
/* 流式期间的最后一个光标：字一个个冒出来之外，还要有个"正在写"的信号，
   否则用户分不清是输出完了还是卡住了 */
.md p.streaming::after {
  content: "▍";
  margin-left: 1px;
  color: var(--brand);
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.think-stage {
  display: inline-block; margin-right: 6px; padding: 0 5px;
  border-radius: 4px; background: #eef1f6; color: #5b6472;
  font-size: 10.5px; line-height: 16px; vertical-align: 1px;
}
.think-step.running .think-stage { background: #e8f0ff; color: var(--brand); }
.think-step.running .think-dot { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.7); }
}

/* 推理原文：等宽一点、浅底、限高滚动；它是过程不是结论，不能抢正文 */
.reason { margin: 6px 0 8px; border: 1px solid #e7eaf0; border-radius: 8px; background: #fafbfd; }
.reason-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: 11.5px; color: #6b7280; text-align: left;
}
.reason-title { color: #4b5563; font-weight: 500; }
.reason-meta { color: #9aa3b2; font-variant-numeric: tabular-nums; }
.reason-toggle { margin-left: auto; color: var(--brand); }
.reason-body {
  max-height: 180px; overflow-y: auto; padding: 0 10px 9px;
  font-size: 11.5px; line-height: 1.7; color: #6b7280;
  white-space: pre-wrap; word-break: break-word;
}
