@charset "UTF-8";
/* ============================================================================
 * DocFusion 前端样式表 —— DeepSeek 风格皮肤层
 * ----------------------------------------------------------------------------
 * 全站只有这一份 CSS，没有预处理器、没有构建步骤。
 * 这么定的原因很实际：这套界面同时要被三种壳复用（浏览器 / Electron /
 * Capacitor 安卓），一旦引入构建步骤，三种壳就都要各自配一遍打包链，
 * 而收益只是"少写几个 CSS 变量"。**配色与间距全部走变量**，
 * 想换主题只改 :root 那一段。
 *
 * 本版按 DeepSeek 官方 token 重写（深紫 → 白底蓝调）：
 *   · 颜色全部走变量，明暗两套主题各一份；组件里不写死颜色；
 *   · 阴影只保留"浮层"一档（弹窗/菜单/toast），普通卡片按钮一律平面；
 *   · 全局滚动条 5px 细圆头；
 *   · 类名钩子与旧版一比一对应——views/*.js 的 DOM 与文案还没换，
 *     这一版只换皮，不改结构（批次 B 再动 DOM）。
 *
 * 结构：
 *   1. 设计变量        2. 基础重置        3. 骨架布局
 *   4. 侧边栏          5. 顶栏            6. 按钮与表单
 *   7. 卡片与统计      8. 徽标与状态      9. 表格
 *   10. 拖放区         11. 反馈（toast/空态/骨架）
 *   12. 抽屉与弹窗     13. 页面级组件
 *   14. 对话形态       15. 文件预览与虚拟表格
 *   16. 登录页与账号区
 * ========================================================================== */

/* ── 1. 设计变量 ─────────────────────────────────────────────────────────── */
/* 浅色主题：DeepSeek 官方浅色 token。主蓝 #4D6BFE，背景近纯白，
   边框三档发丝线（.04 / .10 / .12），文字四档。 */
:root {
  color-scheme: light;

  --brand: #4D6BFE;              /* 主蓝：按钮 / 激活 / 焦点 */
  --brand-600: #3A5BE0;          /* hover 加深一档 */
  --brand-text: #3A5BE0;         /* 选中态文字 / 链接（暗色下单独给 #7AAAFF） */
  --brand-soft: #DBEAFE;         /* 选中底 / soft 按钮底 */
  --brand-soft-2: #CBDCFE;       /* soft 底的描边一档（views 里内联样式也引用了它，必须保留） */
  --brand-tint: #F0F4FE;         /* 更浅的蓝 tint：hero / accent 卡片 */
  --bubble: #EDF3FE;             /* 用户消息气泡 */

  --bg: #FFFFFF;                 /* 主区 */
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;          /* 侧栏 / 表头 / 代码块底 */
  --surface-3: #F1F3F5;          /* 再深一档：chip / 徽标底 */

  --border: rgba(0, 0, 0, .04);
  --border-strong: rgba(0, 0, 0, .10);
  --border-heavier: rgba(0, 0, 0, .12);

  --text: #0F1115;
  --text-2: #61666B;
  --text-3: #81858C;
  --text-caption: #ADB2B8;       /* placeholder / 弱文字 */

  --hover: rgba(38, 49, 72, .06);
  --hover-strong: rgba(38, 49, 72, .10);

  --ok: #22C55E;   --ok-soft: rgba(34, 197, 94, .10);
  --warn: #F59E0B; --warn-soft: rgba(245, 158, 11, .10);
  --danger: #EC1313; --danger-soft: rgba(236, 19, 19, .08);
  --info: #4D6BFE; --info-soft: rgba(77, 107, 254, .08);

  --code-bg: #EBEEF2;            /* 行内代码底 */
  --code-block-bg: #F9FAFB;      /* 代码块底（暗色下与 surface-2 不同，故单独一档） */
  --toast-bg: #292929;           /* toast 恒为深灰底白字（明暗主题一致） */

  /* 阴影只留浮层一档：弹窗 / 菜单 / toast / 抽屉 / composer 悬浮菜单。
     普通卡片、按钮、激活态一律无阴影、无彩色投影。 */
  --shadow-pop: 0 0 1px 0 rgba(0, 0, 0, .2), 0 0 4px 0 rgba(0, 0, 0, .02), 0 12px 32px 0 rgba(0, 0, 0, .08);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-composer: 24px;

  /* 控件高三档：28 / 32 / 36 / 40 */
  --h-sm: 28px;
  --h-md: 32px;
  --h: 36px;
  --h-lg: 40px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;

  /* 滚动条（全局 5px 细圆头，明暗各一份 thumb 色） */
  --sb-thumb: rgba(0, 0, 0, .08);
  --sb-thumb-hover: rgba(0, 0, 0, .15);

  /* 侧栏这一层的文字 / hover：浅色主题下侧栏就是浅灰面板，
     直接映射到文字三档；暗色下侧栏是 #1B1B1C，另给一套（见 dark 块）。
     .sess-* / .brand / .side-status 全部走这组变量，明暗不需要各写一遍。 */
  --side-bg: var(--surface-2);
  --side-text: var(--text);
  --side-text-2: var(--text-3);
  --side-line: var(--border);
  --side-hover: var(--hover);

  --sessions-w: 210px;
  --sidebar-w: 260px;
  --topbar-h: 48px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* 暗色主题：底 #151517、侧栏 #1B1B1C、面板分层 #232324/#2C2C2E/#353638。
   主蓝按钮 #5686FE、链接/选中文字 #7AAAFF、选中底 rgba(86,134,254,.12)。 */
[data-theme="dark"] {
  color-scheme: dark;

  --brand: #5686FE;
  --brand-600: #4A76E8;
  --brand-text: #7AAAFF;
  --brand-soft: rgba(86, 134, 254, .12);
  --brand-soft-2: rgba(86, 134, 254, .22);
  --brand-tint: rgba(86, 134, 254, .08);
  --bubble: #2C2C2E;

  --bg: #151517;
  --surface: #232324;
  --surface-2: #2C2C2E;
  --surface-3: #353638;

  --border: rgba(255, 255, 255, .06);
  --border-strong: rgba(255, 255, 255, .12);
  --border-heavier: rgba(255, 255, 255, .16);

  --text: #F9FAFB;
  --text-2: #CFD3D6;
  --text-3: #ADB2B8;
  --text-caption: #7B7F85;

  --hover: rgba(255, 255, 255, .08);
  --hover-strong: rgba(255, 255, 255, .14);

  --ok: #4ADE80;   --ok-soft: rgba(74, 222, 128, .12);
  --warn: #FBBF24; --warn-soft: rgba(251, 191, 36, .12);
  --danger: #F87171; --danger-soft: rgba(248, 113, 113, .12);
  --info: #5B8CFF; --info-soft: rgba(91, 140, 255, .12);

  --code-bg: #2C2C2E;
  --code-block-bg: #1B1B1C;
  --toast-bg: #292929;

  --shadow-pop: 0 0 1px 0 rgba(0, 0, 0, .4), 0 0 4px 0 rgba(0, 0, 0, .06), 0 12px 32px 0 rgba(0, 0, 0, .32);

  --sb-thumb: rgba(255, 255, 255, .15);
  --sb-thumb-hover: rgba(255, 255, 255, .24);

  --side-bg: #1B1B1C;
  --side-text: var(--text-2);
  --side-text-2: var(--text-3);
  --side-line: rgba(255, 255, 255, .08);
  --side-hover: var(--hover);
}

/* ── 2. 基础重置 ─────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.6 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); }

/* 全局滚动条 5px：轨道透明、圆头，明暗各一套 thumb 色（见变量） */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); }

::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-radius: 4px; }

/* ── 3. 骨架布局 ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.content { flex: 1; overflow-y: auto; padding: 26px 30px 60px; scroll-behavior: smooth; }
.content > .page { max-width: 1420px; margin: 0 auto; animation: pageIn .26s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 4. 侧边栏 ───────────────────────────────────────────────────────────── */
/* 浅灰面板 + 一条发丝右边框，没有渐变、没有辉光。
   内部文字一律走 --side-* 变量，明暗主题各映射一份。 */
.sidebar {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  color: var(--side-text);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.brand-mark {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  overflow: hidden;                   /* 品牌图与任务栏/安装包图标同源（assets/icon.png），圆角裁齐 */
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 15px; font-weight: 600; color: var(--side-text); letter-spacing: .3px; }
.brand-text span { display: block; font-size: 10.5px; color: var(--side-text-2); letter-spacing: 1.1px; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-group { margin: 14px 0 6px; padding: 0 8px; font-size: 10.5px; letter-spacing: 1.3px; color: var(--side-text-2); text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; margin-bottom: 2px; border-radius: var(--radius-sm);
  color: var(--side-text); font-size: 13.5px; text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .78; }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-badge {
  font-size: 10.5px; padding: 1px 5px; border-radius: 5px; letter-spacing: .5px;
  background: var(--side-hover); color: var(--side-text-2);
}
.nav-item:hover { background: var(--side-hover); color: var(--side-text); }
/* 激活 = 品牌浅底 + 品牌文字，无投影无渐变（DeepSeek 的选中形态） */
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item.active .nav-badge { background: var(--brand-soft-2); color: var(--brand-text); }

/* 运行状态：弱文字小卡，白底（暗色下是面板色）+ 发丝边框 */
.side-status { margin: 0 12px 14px; padding: 11px 13px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--side-line); }
.side-status .ss-row { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--side-text-2); }
.side-status .ss-row + .ss-row { margin-top: 7px; }
.side-status .ss-k { flex: none; color: var(--text-caption); white-space: nowrap; }
.side-status .ss-v {
  flex: 1; min-width: 0;
  /* 现在是一句人话状态（"服务正常 · 算法就绪 · 语料 N 块"），让它自然换行；
     旧的省略号截断是逐行状态表时代的产物（那时要显示很长的设备名/指纹） */
  line-height: 1.5;
  font-size: 11.5px; color: var(--side-text);
}
.side-status .ss-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 11px; letter-spacing: 1px; color: var(--side-text-2); text-transform: uppercase; }

/* 状态圆点：纯色小点，busy 加呼吸动画；不再套彩色光圈 */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--text-caption); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }
.dot.busy { background: var(--warn); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ── 会话子列表（侧栏里「文档助手」下面）────────────────────────────────
   形态保持：一行一个（图标 + 名字 + 相对时间），当前会话高亮；
   默认显示 5 行，超出滚动；悬停时右侧时间换成"重命名 / 归档"。
   配色全部走 --side-* / --brand-*，在明暗两套侧栏底色上都成立。 */
.side-sessions { margin: 2px 0 4px; }
.sess-block { padding-left: 10px; border-left: 1px solid var(--side-line); margin-left: 12px; }
.sess-head {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; cursor: pointer;
  user-select: none; border-radius: var(--radius-sm);
}
.sess-head:hover { background: var(--side-hover); }
.sess-head .sess-title { flex: 1; font-size: 10.5px; letter-spacing: 1.2px; color: var(--side-text-2); text-transform: uppercase; }
.sess-head .sess-count { font-size: 10.5px; color: var(--side-text-2); white-space: nowrap; }
/* 「有会话正在处理」只用一个小圆点表示：侧栏窄，写全"正在处理 N 个"会挤成三行（实测踩过）。 */
.sess-head .sess-count .sess-busy-dot { display: inline-block; width: 6px; height: 6px; margin-left: 5px; box-shadow: none; vertical-align: middle; }
.sess-head .grow { flex: 1; }
.sess-head .icon-btn { width: 22px; height: 22px; border-radius: 6px; color: var(--side-text-2); }
.sess-head .icon-btn:hover { background: var(--side-hover); color: var(--side-text); }
/* 侧栏这一行很窄，「新建」用紧凑版：图标 + 两个字，仍比一个 + 号好认 */
.sess-head .icon-btn.labeled { width: auto; padding: 0 8px; gap: 4px; font-size: 11.5px; }
.sess-head .icon-btn.labeled svg { width: 12px; height: 12px; }
.sess-list { max-height: calc(5 * 30px); overflow-y: auto; padding: 2px 0; }
.sess-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 10px; margin-bottom: 1px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--side-text); font-size: 12.5px; cursor: pointer;
  transition: background .15s var(--ease);
}
.sess-item svg { width: 13px; height: 13px; flex: none; opacity: .7; }
.sess-item:hover { background: var(--side-hover); }
.sess-item.active {
  background: var(--brand-soft); color: var(--brand-text);
  font-weight: 600;
}
.sess-item.disabled { opacity: .4; cursor: not-allowed; }
.sess-item .sess-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-item .sess-meta { flex: none; font-size: 11px; color: var(--side-text-2); }
.sess-item .sess-acts { display: none; gap: 2px; flex: none; }
.sess-item:hover .sess-acts { display: flex; }
.sess-item:hover .sess-meta { display: none; }   /* 位置让给按钮，避免换行 */
.sess-item .sess-acts button {
  width: 20px; height: 20px; border: 0; border-radius: 6px; background: transparent;
  color: var(--side-text-2); display: grid; place-items: center; cursor: pointer;
}
.sess-item .sess-acts button:hover { background: var(--side-hover); color: var(--side-text); }
.sess-empty { padding: 6px 10px; font-size: 11.5px; line-height: 1.5; color: var(--side-text-2); }

/* ── 5. 顶栏 ─────────────────────────────────────────────────────────────── */
/* 66px → 48px：背景与主区同色，只压一条发丝下边线；不再做毛玻璃 */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 5;
}
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.topbar-title h1 { font-size: 16px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.topbar-title p { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* 幽灵图标按钮：无边框，hover 浅灰底 */
.icon-btn {
  width: var(--h-md); height: var(--h-md); border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
/* 图标 + 文字的手机（顶栏的设置/刷新/主题、侧栏的「新建」）：
   图标单独看认不出时用它 —— 宽度放开、图标缩一点，让中文有位置 */
.icon-btn.labeled {
  width: auto; height: var(--h-md); padding: 0 11px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2);
}
.icon-btn.labeled svg { width: 15px; height: 15px; }
.icon-btn.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 服务状态 pill：小圆点 + 弱文字，不再是带底色的胶囊 */
#pillServer.pill { background: transparent; color: var(--text-3); padding: 0 2px; height: auto; }
#pillServer.pill.ok, #pillServer.pill.warn, #pillServer.pill.bad { background: transparent; color: var(--text-3); }

/* 顶栏账号区：和"图标 + 文字"按钮并排，长得像它们（同类并排才不突兀）；
   本地模式下整块 hidden，顶栏保持原来的样子 */
.account { display: inline-flex; align-items: center; gap: 8px; }
.account[hidden] { display: none; }
.account-name {
  max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: var(--text-2);
}
/* 角色徽章：顶栏里紧跟在名字后面，比正文徽标小一档（顶栏只有 48px 高） */
.role-badge { height: 20px; padding: 0 8px; font-size: 11px; font-weight: 500; }
/* 首次初始化页的说明行：与登录表单的 field 间距保持一致 */
.setup-intro { font-size: 12.5px; line-height: 1.75; color: var(--text-3); margin-bottom: 18px; }

/* ── 6. 按钮与表单 ───────────────────────────────────────────────────────── */
/* 控件高 28 / 32 / 36 / 40；primary 实色蓝、无渐变、无投影，hover 只加深 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--h); padding: 0 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .16s var(--ease), border-color .16s, color .16s;
}
.btn svg { width: 15.5px; height: 15.5px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-heavier); background: var(--hover); }
.btn-soft { background: var(--brand-soft); color: var(--brand-text); }
.btn-soft:hover:not(:disabled) { background: var(--brand-soft-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.btn-sm { height: var(--h-sm); padding: 0 11px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: var(--h-lg); padding: 0 22px; font-size: 14.5px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); line-height: 1.55; }
.input, .select, .textarea {
  width: 100%; height: var(--h); padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; padding: 9px 12px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-heavier); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-caption); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
.select { appearance: none; padding-right: 30px;
  /* 箭头颜色取 --text-caption（#ADB2B8）：明暗两套主题都看得见 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ADB2B8' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.input[type="number"] { font-variant-numeric: tabular-nums; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; transition: background .18s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch .switch-label { font-size: 13px; color: var(--text-2); }

/* 分段选择（设置里的"本地模型 / 远端接口"）*/
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.seg-btn:hover { border-color: var(--brand-soft-2); color: var(--brand-text); }
.seg-btn.on { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--brand-text); font-weight: 600; }

/* ── 7. 卡片与统计 ───────────────────────────────────────────────────────── */
/* 白底 + 发丝边框 + radius 16，无阴影；层次靠边框与底色，不靠投影 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head .card-title { flex: 1; min-width: 0; }
.card-head h2 { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head h2 svg { width: 16px; height: 16px; color: var(--brand); }
.card-head p { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-head .card-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.card-body { padding: 18px; }
.card-body.tight { padding: 14px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split-2-1 { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3, .grid.split-2-1 { grid-template-columns: minmax(0, 1fr); } }

/* 概览 hero：大紫卡 → 白底浅蓝 tint 简洁卡（无渐变、无辉光、无投影） */
.hero {
  padding: 24px 26px; border-radius: var(--radius-lg);
  background: var(--brand-tint);
  border: 1px solid var(--border);
  color: var(--text);
}
.hero h2 { font-size: 20px; font-weight: 600; letter-spacing: .3px; }
.hero p { margin-top: 7px; font-size: 13px; color: var(--text-2); max-width: 760px; line-height: 1.75; }
.hero .hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero .hero-tag { font-size: 12px; padding: 4px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.hero .hero-body { min-width: 0; }

.stat { padding: 17px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: border-color .18s var(--ease); }
.stat:hover { border-color: var(--border-strong); }
.stat .stat-label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat .stat-label svg { width: 14px; height: 14px; }
.stat .stat-value { margin-top: 9px; font-size: 27px; font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.stat .stat-sub { margin-top: 5px; font-size: 11.5px; color: var(--text-3); }
/* accent：去掉渐变，浅蓝 tint 底 + 品牌色数值 */
.stat.accent { background: var(--brand-tint); border-color: var(--border); }
.stat.accent .stat-value { color: var(--brand-text); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 13px; align-items: baseline; }
.kv dt { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }
.kv dd.mono { font-family: var(--mono); font-size: 12px; }

/* ── 8. 徽标与状态 ───────────────────────────────────────────────────────── */
/* 徽标全部 flat：soft 底 + 同色文字，无渐变无投影 */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.pill svg { width: 13px; height: 13px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-text); }
.pill.outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: var(--surface-3); color: var(--text-2); }
.tag.mono { font-family: var(--mono); font-size: 11px; letter-spacing: -.2px; }
.tag.file { background: var(--brand-soft); color: var(--brand-text); font-family: var(--mono); font-size: 10.5px; letter-spacing: .3px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.chip:hover { background: var(--brand-soft); color: var(--brand-text); }
.chip.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }

/* ── 9. 表格 ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table-wrap.maxh { max-height: 520px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap;
  padding: 9px 13px; border-bottom: 1px solid var(--border-strong);
}
table.tbl td { padding: 9px 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--hover); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono { font-family: var(--mono); font-size: 12px; }
table.tbl td.empty-cell { color: var(--text-3); font-style: italic; }
table.tbl .rowkey { font-family: var(--mono); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ── 10. 拖放区 ──────────────────────────────────────────────────────────── */
/* 浅灰虚线框；hover / 拖入时给蓝 tint（激活态只有底色变化，无投影） */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 26px 18px; border-radius: var(--radius); text-align: center;
  border: 1.5px dashed var(--border-strong); background: var(--surface-2);
  transition: border-color .18s, background .18s;
  cursor: pointer;
}
.drop:hover { border-color: var(--brand); background: var(--brand-tint); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop svg { width: 26px; height: 26px; color: var(--brand); opacity: .85; }
.drop .drop-title { font-size: 13.5px; font-weight: 500; }
.drop .drop-sub { font-size: 12px; color: var(--text-3); }
.drop.busy { pointer-events: none; opacity: .7; }

/* ── 11. 反馈 ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
/* toast：恒为深灰底白字（#292929），浮层阴影；tone 只影响左侧小图标颜色 */
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--toast-bg); color: #fff; border: none; box-shadow: var(--shadow-pop);
  animation: toastIn .26s var(--ease);
}
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px) scale(.97); } }
.toast .t-icon { width: 18px; height: 18px; flex: none; margin-top: 1px; }
/* toast 底恒为深灰，图标用高亮度语义色（浅色主题的 --danger 在深灰上对比不足） */
.toast.ok .t-icon { color: #4ADE80; }
.toast.warn .t-icon { color: #FBBF24; }
.toast.bad .t-icon { color: #F87171; }
.toast.info .t-icon { color: #5B8CFF; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-size: 13px; font-weight: 600; color: #fff; }
.toast .t-msg { font-size: 12.5px; color: rgba(255, 255, 255, .72); margin-top: 2px; word-break: break-word; }
.toast .t-close { color: rgba(255, 255, 255, .55); padding: 2px; }
.toast .t-close:hover { color: #fff; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; }
.empty svg { width: 34px; height: 34px; color: var(--text-3); opacity: .55; }
.empty .empty-title { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.empty .empty-sub { font-size: 12.5px; color: var(--text-3); max-width: 460px; line-height: 1.7; }

/* 骨架屏：中性灰 shimmer（全库唯一允许保留的装饰性渐变之一） */
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--code-bg) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-line { height: 12px; margin-bottom: 9px; }
.sk-block { height: 84px; }

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--brand); animation: spin .75s linear infinite; flex: none; }
.spinner.lg { width: 22px; height: 22px; border-width: 2.5px; }

/* 不确定进度条：本系统不画"编出来的百分比"，只给节拍器式的流动条 + 已耗时。
   纯蓝填充（去双色渐变）。 */
.bar { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; width: 34%; border-radius: 3px; background: var(--brand); animation: slide 1.5s var(--ease) infinite; }
.bar > i.det { animation: none; width: var(--w, 0%); transition: width .4s var(--ease); }
@keyframes slide { 0% { left: -34%; } 100% { left: 100%; } }

/* ── 12. 抽屉与弹窗 ──────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); backdrop-filter: blur(2px); z-index: 100; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 92vw); z-index: 101;
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-pop);
  animation: drawerIn .28s var(--ease);
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { flex: 1; font-size: 15px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); }

/* 弹窗：radius 18 + 官方柔和阴影（浮层一档） */
.modal { position: fixed; z-index: 101; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-pop); overflow: hidden; animation: modalIn .24s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ── 13. 页面级组件 ──────────────────────────────────────────────────────── */
/* 操作明细：每条指令一行，命中数用大字号，一眼看出"哪条没落到实处" */
.op-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.op-row + .op-row { margin-top: 9px; }
.op-row .op-desc { font-size: 13px; font-weight: 500; }
.op-row .op-meta { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); margin-top: 3px; word-break: break-all; }
.op-row .op-msg { font-size: 12px; color: var(--text-2); margin-top: 5px; }
.op-row.bad { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.op-row.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); background: var(--warn-soft); }
.op-row.ok { border-color: color-mix(in srgb, var(--ok) 26%, var(--border)); }
.hits { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; height: fit-content; }
.hits.ok { background: var(--ok-soft); color: var(--ok); }
.hits.warn { background: var(--warn-soft); color: var(--warn); }
.hits.bad { background: var(--danger-soft); color: var(--danger); }

/* ── 抽取页（模块②）单栏聚焦流 ────────────────────────────────────────
   与聊天页同一列宽（840px 居中）：顶部一行弱状态小字，下面输入卡
   （composer 家族：白底发丝边框、radius 20、无阴影、focus 蓝边），
   结果流追加在输入卡下方。原右栏「语料库」卡已删，样式一并清理。 */
.xf-col { max-width: 840px; margin: 0 auto; display: flex; flex-direction: column; }
.xf-status { text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.xf-panel { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-xl); padding: 14px 16px 12px; transition: border-color .15s; }
.xf-panel:focus-within { border-color: var(--brand); }
.xf-q { width: 100%; border: none; outline: none; resize: none; background: none; font: inherit; font-size: 14px; line-height: 1.7; min-height: 56px; max-height: 220px; color: var(--text); padding: 2px; }
.xf-q::placeholder { color: var(--text-caption); }
.xf-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
/* 抽取条数：弱化成 30px 小 select（继承 .select 的底与箭头，只改尺寸） */
.xf-minisel { width: auto; height: 30px; padding: 0 26px 0 10px; font-size: 12.5px; max-width: 128px; flex: none; }

/* 答案卡：浅蓝 tint 平面卡；卡头 = 左「答案」+ 右一行耗时小字（原为一排 pills） */
.answer { padding: 14px 16px; border-radius: var(--radius); background: var(--brand-tint); border: 1px solid var(--border); }
.answer .xf-anshead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.answer .xf-anstick { font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--brand-text); }
.answer .xf-anstime { font-family: var(--mono); font-size: 11px; color: var(--text-3); white-space: nowrap; }
.answer .xf-ansval { margin-top: 8px; font-size: 16px; font-weight: 600; letter-spacing: -.2px; line-height: 1.65; word-break: break-word; }
.answer .xf-ansnote { margin-top: 8px; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }

/* 出处：一行式（[n] 文件名 · 相关度 · 依据标记），默认原文单行省略，
   点击整行展开/收起全文 —— 纯类名切换（.open），不加新依赖 */
.cite { padding: 9px 13px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.cite:hover { border-color: var(--border-strong); }
.cite.open { border-color: var(--brand-soft-2); background: var(--brand-tint); }
.cite + .cite { margin-top: 8px; }
.cite .c-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); min-width: 0; }
.cite .c-src { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; color: var(--brand-text); }
.cite .c-score { margin-left: auto; flex: none; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.cite .c-text { margin-top: 4px; font-size: 12.5px; line-height: 1.75; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: break-all; }
.cite.open .c-text { white-space: pre-wrap; word-break: break-word; }

/* 入库记录：默认收起的 details 折叠（形态与聊天页「用过的工具」一致） */
.xf-records { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.xf-records > summary { padding: 10px 13px; font-size: 12.5px; color: var(--text-3); cursor: pointer; list-style: none; user-select: none; }
.xf-records > summary::-webkit-details-marker { display: none; }
.xf-records > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-3); }
.xf-records[open] > summary::before { content: "▾"; }
.xf-records > summary:hover { color: var(--text); }
.xf-records-body { padding: 2px 13px 13px; }

/* ── 填报页（模块③）单栏聚焦流 ────────────────────────────────────────
   同一列宽；提交卡合一（拖放区 + 模板列表 + 行数上限 + 主按钮）；
   结果表上方一行摘要代替原 4 张统计卡，复制/下载 JSON 收进右上角按钮组。 */
.tb-col { max-width: 840px; margin: 0 auto; display: flex; flex-direction: column; }
/* 结果区破格：比单栏更宽，装得下填报结果大表（长题目列在 840px 会挤成竖条） */
.tb-result { width: 100%; max-width: 1160px; margin: 18px auto 0; }
.tb-submit { margin-top: 14px; }
.tb-tblhead { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; }
.tb-sum { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; color: var(--text-2); }
.tb-sum b { font-weight: 600; color: var(--text); }
.tb-sep { color: var(--text-caption); }
.tb-sum .tb-ok { color: var(--ok); }
.tb-sum .tb-bad { color: var(--danger); }

mark { background: var(--warn-soft); color: var(--warn); padding: 0 2px; border-radius: 3px; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--border-strong); }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.tl-item.done::before { background: var(--ok); border-color: var(--ok); }
.tl-item.now::before { background: var(--brand); border-color: var(--brand); }
.tl-item .tl-t { font-size: 13px; font-weight: 500; }
.tl-item .tl-s { font-size: 12px; color: var(--text-3); font-family: var(--mono); }

.file-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, background .15s; }
.file-item + .file-item { margin-top: 8px; }
.file-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.file-item.sel { border-color: var(--brand); background: var(--brand-tint); }
/* 文件格式图标：flat 色块（soft 底 + 深色字），docx 蓝 / xlsx 绿 / txt 灰 / pdf 红 */
.file-item .f-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.file-item .f-icon svg { width: 17px; height: 17px; }
.file-item .f-icon.docx { background: var(--brand-soft); color: var(--brand-text); }
.file-item .f-icon.xlsx { background: rgba(34, 197, 94, .12); color: #15803D; }
.file-item .f-icon.md { background: var(--brand-soft); color: var(--brand-text); }
.file-item .f-icon.txt { background: var(--surface-3); color: var(--text-2); }
/* PDF 用红系：这是唯一一个"用户自己带进来的"格式（题目语料里没有），
   一眼能把它和那四种原生格式分开（F-62 之后新增的支持，见问题记录） */
.file-item .f-icon.pdf { background: var(--danger-soft); color: #DC2626; }
/* 暗色主题：soft 底换暗色等价物，文字提亮（overview.js 里还有内联 brand-soft 的等价用法，
   会随变量自动跟随，这里只补固定色相的三种） */
[data-theme="dark"] .file-item .f-icon.xlsx { background: rgba(74, 222, 128, .14); color: #4ADE80; }
[data-theme="dark"] .file-item .f-icon.pdf { background: rgba(248, 113, 113, .14); color: #F87171; }
.file-item .f-body { flex: 1; min-width: 0; }
.file-item .f-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 10px; margin-top: 3px; flex-wrap: wrap; align-items: center; }
/* 行内操作按钮平时藏起来，指到这一行才出现：一列垃圾桶图标会让列表看起来像危险区。
   触摸设备没有 hover，所以那里始终保持可见（否则功能等于不存在）。 */
.file-item .f-act { display: flex; gap: 5px; flex: none; opacity: 0; transition: opacity .15s; }
@media (hover: none) { .file-item .f-act { opacity: 1; } }
.file-item:hover .f-act, .file-item:focus-within .f-act, .file-item.sel .f-act { opacity: 1; }
/* 长列表（15 个模板、16 份语料）要限高滚动，否则左栏会把右栏拉成一条空白 */
.file-list { max-height: 520px; overflow-y: auto; padding-right: 2px; }

.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 12.5px; line-height: 1.7; }
.note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.note.info { background: var(--info-soft); color: var(--text-2); }
.note.info svg { color: var(--info); }
.note.warn { background: var(--warn-soft); color: var(--text-2); }
.note.warn svg { color: var(--warn); }
.note.bad { background: var(--danger-soft); color: var(--text-2); }
.note.bad svg { color: var(--danger); }
.note.ok { background: var(--ok-soft); color: var(--text-2); }
.note.ok svg { color: var(--ok); }
.note b { color: var(--text); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { position: relative; padding: 9px 14px; font-size: 13.5px; color: var(--text-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: color .15s, background .15s; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--brand-text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.tab .tab-n { font-size: 11px; color: var(--text-caption); margin-left: 5px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 0; }
.sep { width: 1px; height: 20px; background: var(--border-strong); }

.checklist { display: flex; flex-direction: column; gap: 9px; }
.cl-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.cl-item svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.cl-item.ok svg { color: var(--ok); }
.cl-item.bad svg { color: var(--danger); }
.cl-item.wait svg { color: var(--text-3); }
.cl-item .cl-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* 工具类 */
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; } .mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; } .mt-18 { margin-top: 18px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-10 { margin-bottom: 10px; } .mb-14 { margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.scroll-y { overflow-y: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════════════
 * 14. 对话形态（模块①）
 * --------------------------------------------------------------------------
 * 按 DeepSeek 的对话形态换皮（DOM 本批次不动，批次 B 才改）：
 *
 *   · **阅读宽度 840px 居中**：答案里有大段中文，一行铺满 1400px 会很难读；
 *   · **用户消息是气泡（#EDF3FE / 暗色 #2C2C2E），助手消息不是**：
 *     助手回复往往很长（含表格与列表），套气泡会把内容压窄、也显得局促；
 *     助手正文 16px / 1.75 行高、无底无框；
 *   · .avatar 保留样式但已弱化成小徽标——批次 B 会把 DOM 里的头像删掉；
 *   · 助手消息下面固定一行**操作按钮**（复制/重新生成），
 *     其中"查看变更明细"是本项目特有的：改了文档就必须能看见改了哪里。
 * ══════════════════════════════════════════════════════════════════════════ */

.chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 40px); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 4px 4px 8px; }
.chat-inner { max-width: 840px; margin: 0 auto; }

/* 空态：大标题 + 建议问法 +（桌面端）桌面文件夹里的文档 */
.chat-hero { padding: 40px 0 10px; text-align: center; }
.chat-hero h2 { font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.chat-hero p { margin-top: 8px; font-size: 13.5px; color: var(--text-3); }
.chat-hints { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px auto 0; max-width: 660px; }
@media (max-width: 760px) { .chat-hints { grid-template-columns: 1fr; } }
/* 建议问法：浅灰 chip；hover 白底浮起（浮层阴影在这里是明示允许的例外） */
.chat-hint {
  text-align: left; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid transparent;
  transition: background .15s, transform .15s var(--ease), box-shadow .15s var(--ease);
}
.chat-hint:hover { background: var(--surface); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.chat-hint .ch-t { font-size: 13px; font-weight: 500; }
.chat-hint .ch-s { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

.folder-list { margin: 26px auto 0; max-width: 660px; text-align: left; }
.folder-list .fl-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.folder-list .fl-head .grow { flex: 1; }
.folder-chip {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid transparent; margin-bottom: 6px; transition: background .15s;
}
.folder-chip:hover { background: var(--hover); }
.folder-chip .fc-name { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chip .fc-size { font-size: 11px; color: var(--text-3); font-family: var(--mono); }

/* ── 消息 ────────────────────────────────────────────────────────────── */
.msg { display: flex; gap: 12px; padding: 14px 0; }
/* 头像：批次 B 会删 DOM，这里先弱化成小徽标（纯色 soft 底，无渐变无投影） */
.msg .avatar {
  width: 26px; height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--brand-text);
  background: var(--brand-soft); letter-spacing: -.5px;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--surface-3); color: var(--text-3); font-size: 11px; }
.msg .body { flex: 1; min-width: 0; }
/* 用户消息：整行右对齐（批次 B 会去掉头像列，这里用 row-reverse 保证两种 DOM 都对） */
.msg.user .body { display: flex; justify-content: flex-end; }
.msg .who { font-size: 12px; color: var(--text-caption); margin-bottom: 6px; }

/* 用户气泡：#EDF3FE（暗色 #2C2C2E）、radius 22、无边框无投影 */
.bubble {
  display: inline-block; max-width: 86%; padding: 10px 16px; border-radius: 22px;
  background: var(--bubble); color: var(--text); font-size: 14px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}

/* 助手正文：16px / 1.75，无底无框全宽（覆盖上面抽取页 .answer 卡片样式） */
.msg .answer { padding: 0; background: none; border: none; font-size: 16px; line-height: 1.75; color: var(--text); word-break: break-word; }
.msg .answer > :first-child { margin-top: 0; }
.msg .answer p { margin: 0 0 10px; }
.msg .answer h3, .msg .answer h4, .msg .answer h5, .msg .answer h6 { margin: 16px 0 8px; font-size: 16px; font-weight: 600; }
.msg .answer ul, .msg .answer ol { margin: 0 0 10px; padding-left: 22px; }
.msg .answer li { margin-bottom: 4px; }
.msg .answer code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg .answer pre.md-code {
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto;
  background: var(--code-block-bg); border: 1px solid var(--border);
}
.msg .answer pre.md-code code { background: none; padding: 0; font-size: 13px; line-height: 1.7; }
.msg .answer blockquote {
  margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.msg .answer hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md-table-wrap { overflow-x: auto; margin: 0 0 12px; }
.md-table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--border-heavier); padding: 6px 10px; text-align: left; }
.md-table th { background: var(--surface-2); font-weight: 600; }

/* 结果卡片：改了文档就给出"改了哪里 + 下载"。浅灰面板 radius 16 */
.result-card {
  margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-2); overflow: hidden;
}
.result-card .rc-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px;
  border-bottom: 1px solid var(--border); background: transparent; font-size: 12.5px;
}
.result-card .rc-head .grow { flex: 1; }
.result-card .rc-body { padding: 12px 13px; }
/* 「本次修改」折叠栏（D16）：摘要一行常驻，明细按需展开。
   用原生 <details> —— 键盘可达、不用自己管开合状态 */
.result-card .rc-fold > summary {
  padding: 9px 13px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
  list-style: none; user-select: none;
}
.result-card .rc-fold > summary::-webkit-details-marker { display: none; }
.result-card .rc-fold > summary::before {
  content: "▸"; display: inline-block; width: 14px; color: var(--text-3);
}
.result-card .rc-fold[open] > summary::before { content: "▾"; }
.result-card .rc-fold > summary:hover { background: var(--hover); color: var(--text); }
.result-card .rc-fold[open] > summary { border-bottom: 1px solid var(--border); }
.result-card .rc-actions { padding: 10px 13px; border-bottom: 1px solid var(--border); }

/**
 * 助手消息下面那一行动作：**图标 + 文字**（只留「复制」「重新生成」）。
 * flat ghost：无边框无底，hover 浅灰。
 */
.msg-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.msg-actions .act {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-3);
  border: none; background: transparent;
  transition: background .15s, color .15s;
}
.msg-actions .act svg { width: 14px; height: 14px; }
.msg-actions .act:hover { background: var(--hover); color: var(--text); }

/* 正文为空时的中性说明（不是报错）：小字灰色，别让人以为这一轮失败了 */
.msg .answer.answer-empty { font-size: 12.5px; line-height: 1.7; color: var(--text-3); }

.chat-disclaimer { margin-top: 10px; font-size: 11.5px; color: var(--text-caption); }

.ctx-note {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px;
  background: var(--info-soft); color: var(--info);
}
.ctx-note.warn { background: var(--warn-soft); color: var(--warn); }

/* ── 输入区 ──────────────────────────────────────────────────────────── */
.composer-wrap { padding-top: 10px; }
/* composer：radius 24 白底 + 发丝边框，无阴影（focus 只描蓝边） */
.composer {
  max-width: 840px; margin: 0 auto; padding: 12px 14px 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-composer);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--brand); }
.composer textarea {
  width: 100%; border: none; outline: none; resize: none; background: none;
  font: inherit; font-size: 14px; line-height: 1.7; max-height: 180px; min-height: 24px;
  color: var(--text);
}
.composer textarea::placeholder { color: var(--text-caption); }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer-row .grow { flex: 1; }
.attach-btn {
  width: var(--h-md); height: var(--h-md); border-radius: 50%; display: grid; place-items: center;
  color: var(--text-2); border: none; background: var(--surface-3);
  transition: background .15s, color .15s;
}
.attach-btn:hover { background: var(--hover-strong); color: var(--text); }
.attach-btn.armed { background: var(--brand-soft); color: var(--brand-text); }
/* 发送：34px 正圆蓝底白箭头；禁用/断连只降透明度（保持蓝底） */
.send-btn {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff;
  transition: background .15s, opacity .15s, transform .08s;
}
.send-btn:hover:not(:disabled) { background: var(--brand-600); }
.send-btn:active:not(:disabled) { transform: translateY(1px); }
.send-btn:disabled, .send-btn.disconnected { opacity: .4; cursor: not-allowed; }

/* 正在生成：指示点 + 已耗时（**不编造进度百分比**，与填报页同一条原则） */
.typing { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; }
.typing .dots { display: inline-flex; gap: 4px; }
.typing .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-caption);
  animation: typing 1.2s ease-in-out infinite;
}
.typing .dots i:nth-child(2) { animation-delay: .15s; }
.typing .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ── 流式状态行 ──────────────────────────────────────────────────────
   模型在工具轮会说一句"我在查…"，那不是答案正文，所以单独一行灰字显示。
   三个小点沿用 .dots（与"正在思考"同一套视觉），.mini 只是缩小一号。
   ──────────────────────────────────────────────────────────────────── */
.stream-status {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  color: var(--text-3); font-size: 12.5px; font-style: italic;
}
.stream-status .dots.mini i { width: 5px; height: 5px; }

/* ── 附件卡片（输入框上方）────────────────────────────────────────────
   附加的文件以圆角条排在输入框里：名称 + 格式与大小两行，右上角可移除。
   图标改为 flat 色块（与 .f-icon 同一套语义色）。 */
.attach-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.attach-chip {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 240px; min-width: 200px; max-width: 340px;
  padding: 9px 30px 9px 10px; position: relative;
  border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border);
  animation: chipIn .2s var(--ease);
}
@keyframes chipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* 主文档：蓝 tint 底 + 蓝描边，不用渐变 */
.attach-chip.primary { border-color: var(--brand-soft-2); background: var(--brand-tint); }
.attach-chip .ac-icon {
  width: 32px; height: 32px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
}
.attach-chip .ac-icon.xlsx { background: rgba(34, 197, 94, .12); color: #15803D; }
.attach-chip .ac-icon.txt { background: var(--surface-3); color: var(--text-2); }
.attach-chip .ac-icon.pdf { background: var(--danger-soft); color: #DC2626; }
[data-theme="dark"] .attach-chip .ac-icon.xlsx { background: rgba(74, 222, 128, .14); color: #4ADE80; }
[data-theme="dark"] .attach-chip .ac-icon.pdf { background: rgba(248, 113, 113, .14); color: #F87171; }
.attach-chip .ac-body { flex: 1; min-width: 0; }
.attach-chip .ac-name {
  font-size: 13.5px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-chip .ac-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; letter-spacing: .3px; }
.attach-chip .ac-x {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-3); opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.attach-chip:hover .ac-x { opacity: 1; }
.attach-chip .ac-x:hover { background: var(--danger-soft); color: var(--danger); }
@media (hover: none) { .attach-chip .ac-x { opacity: 1; } }
/* 上传中：图标位置换成转圈，名字变灰 */
.attach-chip.uploading { opacity: .75; }
.attach-chip .ac-spin {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong);
  border-top-color: var(--text-2); animation: spin .75s linear infinite;
}
.attach-chip .ac-role {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px; margin-left: 6px;
  background: var(--surface-3); color: var(--text-3);
}
.attach-chip.primary .ac-role { background: var(--brand-soft); color: var(--brand-text); }

/* 抽取入库提示（回复里的一行） */
.record-link {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.record-link .btn { margin-left: auto; }

/* 用过的工具（回复里的一行摘要 + 明细折叠）。浅灰面板 radius 16 */
.tool-calls { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.tool-calls > summary { padding: 7px 11px; font-size: 12px; color: var(--text-3); cursor: pointer; list-style: none; }
.tool-calls > summary::-webkit-details-marker { display: none; }
.tool-calls > summary::before { content: "▸"; display: inline-block; width: 13px; }
.tool-calls[open] > summary::before { content: "▾"; }
.tool-calls > summary:hover { color: var(--text); }
.tool-calls .tc-body { padding: 2px 11px 9px; display: grid; gap: 5px; }
.tool-calls .tc-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.tool-calls .tc-row .pill { flex: none; }
.tool-calls .tc-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.tool-calls .tc-sec { flex: none; font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* ── 本会话模型选择器（对话栏底部，回形针旁边 · D30）
   菜单**向上弹出**：它在页面底部，向下弹会被浏览器窗口切掉；
   右对齐到按钮，长模型名（供应商 · 模型）也不会把菜单顶出屏幕。 */
.model-pick { position: relative; }
.model-pick-btn {
  display: flex; align-items: center; gap: 6px; max-width: 260px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: transparent;
  color: var(--text-2); font-size: 12px; padding: 6px 10px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.model-pick-btn:hover { background: var(--hover); color: var(--text); }
.model-pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pick-name.weak { color: var(--text-caption); }
.model-pick-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 40;
  min-width: 240px; max-width: 340px; max-height: 320px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.model-pick-opt {
  display: flex; align-items: center; gap: 7px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text);
  font-size: 12px; text-align: left; padding: 7px 9px; cursor: pointer;
}
.model-pick-opt:hover { background: var(--hover); }
.model-pick-opt.on { color: var(--brand-text); font-weight: 600; }
.model-pick-cfg { border-top: 1px dashed var(--border-strong); border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 4px; color: var(--text-2); }
.model-pick-empty { padding: 6px 9px; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }

/* 拉取到的可用模型清单：可滚动的按钮列表，点一下加入 */
.pick-list { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.pick-scroll { margin-top: 6px; max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-item {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font-size: 12px; text-align: left; padding: 5px 8px; cursor: pointer;
}
.pick-item:hover { background: var(--hover); }
.pick-item.on { color: var(--brand-text); background: var(--brand-soft); cursor: default; }

/* 供应商卡片（设置对话框里） */
.prov-card { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.prov-head { display: flex; align-items: center; gap: 8px; }
.prov-head .input { flex: 1; font-weight: 600; }
.prov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prov-models { display: grid; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.prov-model-row { display: flex; align-items: center; gap: 8px; }
.prov-model-row .input { flex: 1; }
.switch-mini { display: inline-flex; align-items: center; flex: none; }


/* ══════════════════════════════════════════════════════════════════════════
 * 15. 文件预览（资产库）
 * --------------------------------------------------------------------------
 * 预览复用 ui.js 的 modal，只把宽度、滚动与内容排版另立一节：
 *   · 弹层本身限高 90vh，正文独立滚动，长文档/大表格不会把关闭按钮顶出屏幕；
 *   · PDF 用 iframe 吃原文件流，固定 62vh；
 *   · 表格横向滚动、单元格限宽换行，窄屏再收一档。
 * 配色全部走变量，明暗两套主题不需要各写一遍。
 * ══════════════════════════════════════════════════════════════════════════ */

.modal.preview-modal {
  width: min(1000px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal.preview-modal .drawer-head { flex: none; }
.modal.preview-modal .drawer-head h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.preview-modal .drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; }
.modal.preview-modal .drawer-foot { flex: none; }

.preview-body { min-height: 90px; }
.preview-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 38px 10px; color: var(--text-3); font-size: 13px;
}
.preview-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px; font-size: 12px; color: var(--text-3);
}
.preview-meta a { font-size: 12px; }
.preview-iframe {
  display: block; width: 100%; height: 62vh;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.preview-pre {
  margin: 0; padding: 14px 16px; max-height: 58vh; overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word; color: var(--text);
  background: var(--code-block-bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.preview-hint { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.preview-empty { padding: 34px 14px; text-align: center; font-size: 13px; color: var(--text-3); }

/* Word 正文：标题层级只到 h3/h4，段落保留换行 */
.preview-doc { font-size: 13.5px; line-height: 1.85; }
.preview-doc h3 { margin: 18px 0 8px; font-size: 16px; font-weight: 600; }
.preview-doc h4 { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.preview-doc > :first-child { margin-top: 0; }
.preview-doc p { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }

/* 表格：限高 + 横向滚动，单元格限宽后换行，避免一列把整张表撑出屏幕 */
.preview-table-wrap {
  max-height: 56vh; overflow: auto; margin: 10px 0 4px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.preview-table { border-collapse: collapse; min-width: 100%; font-size: 12.5px; }
.preview-table td {
  padding: 6px 9px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  vertical-align: top; max-width: 260px; white-space: pre-wrap; word-break: break-word;
}
.preview-table tr td:last-child { border-right: none; }
.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:nth-child(even) td { background: var(--surface-2); }

/* 工作表切换 */
.preview-sheets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.preview-sheet-btn {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-2); font-size: 12.5px;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s, color .15s;
}
.preview-sheet-btn:hover { background: var(--hover); color: var(--text); }
.preview-sheet-btn.active {
  background: var(--brand-soft); color: var(--brand-text); font-weight: 600;
}

@media (max-width: 760px) {
  .modal.preview-modal { width: 96vw; max-height: 92vh; }
  .preview-iframe { height: 58vh; }
  .preview-pre, .preview-table-wrap { max-height: 50vh; }
  .preview-table td { max-width: 200px; }
}

/* ── 虚拟滚动表格：对话产物预览 >200 行自动启用。────────────────────────
   数据一次全量到手，DOM 里只画可见行；**行高必须与 preview.js 的
   VROW_H = 30 一致**（.vtable-row / .vtable-cell 都是 30px，含 1px 底边，
   border-box 下外框总高正好 30）——改这里必须连 preview.js 一起改。
   旧版在这里写死了浅色 hex（暗色主题不跟随），现在全部走变量。 */
.vtable-scroll {
  height: 56vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.vtable-grid { display: grid; width: max-content; min-width: 100%; font-size: 12.5px; }
.vtable-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); border-bottom: 1px solid var(--border-strong);
}
.vtable-body { position: relative; }
.vtable-window { position: absolute; left: 0; top: 0; }
.vtable-row {
  height: 30px; display: grid; align-items: center;
  border-bottom: 1px solid var(--border);
}
.vtable-row:nth-child(even) { background: var(--surface-2); }
.vtable-cell {
  height: 30px; line-height: 30px; padding: 0 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.vtable-cell-head { font-weight: 600; color: var(--text-2); }
.vtable-cell-idx { color: var(--text-caption); }
/* 可点击的表头（排序）与筛选工具条 */
.vtable-cell.vtable-click { cursor: pointer; user-select: none; }
.vtable-cell.vtable-click:hover { background: var(--hover); }
.vtable-cell.vtable-cell-sorted { color: var(--brand-text); }
.vtable-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.vtable-toolbar input, .vtable-toolbar .vtable-filter {
  flex: 0 1 280px;
  height: var(--h-sm); padding: 0 10px; font-size: 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none;
}
.vtable-toolbar input::placeholder, .vtable-toolbar .vtable-filter::placeholder { color: var(--text-caption); }
.vtable-toolbar input:focus, .vtable-toolbar .vtable-filter:focus { border-color: var(--brand); }
.vtable-toolbar .preview-meta { margin: 0; }

/* ── 对话产物预览（排序/筛选面板）────────────────────────────────────────
   弹窗定高，滚动只发生在表格自己身上——不再出现"页面 + 弹窗 + 表格"
   三层滚动条；水平滚动条常驻表格底部。
   中间各层的尺寸由 preview.js 内联样式钉死，这里只负责"弹窗不滚 + 锁页面滚动"。
   下面四条是**布局契约**：preview.js 的几何依赖它们，语义不可改。 */
.preview-body.preview-flex {
  /* drawer-body 是 block 布局，这里必须用 height:100% 定高（flex 属性无效），
     定高之后滚动只发生在 .vtable-scroll 里。 */
  height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; overflow: hidden;
}
.preview-body.preview-flex > div {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.preview-body.preview-flex > .preview-sheets { flex: none; }
.preview-body.preview-flex > .preview-meta { flex: none; }
/* 高度必须是**确定值**（不能只靠 max-height），drawer-body 的 flex 高度
   才会被视为确定，子元素的 height:100% 才能解析——否则预览区被内容撑爆
   （preview-body 被撑到 9000px、滚动条全部消失的教训）。 */
.modal.preview-modal:has(.preview-body.preview-flex) { height: 90vh; }
.modal.preview-modal .drawer-body:has(> .preview-body.preview-flex) { overflow: hidden; }
body.ov-lock { overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════════════
 * 16. 登录页与账号区
 * --------------------------------------------------------------------------
 * 登录页只在多账号模式出现（本地模式 /api/auth/me 直接答 authed:true，
 * 启动流程不会画它）。整屏覆盖而不是嵌进 #view：未登录时侧栏/顶栏/路由
 * 一概不初始化，盖住空骨架最省事，也最不容易漏出半截界面。
 * 登录成功后整页重载，所以没有"从登录页切回应用"的过渡要处理。
 * 紫色 radial 辉光已去掉：纯 --bg 底 + 白卡 radius 20 + 官方柔和阴影。
 * ══════════════════════════════════════════════════════════════════════════ */

.login-gate {
  position: fixed; inset: 0; z-index: 60;      /* 盖住整屏（顶栏 z-index 是 5，弹窗层在它之上也无妨） */
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

/* 启动连接面纱：登录判定的一次公网往返（1~3s）里盖住空骨架，
   不让"半成品主界面"先闪出来；判定完成即整体揭开 */
.boot-veil {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot-veil-box { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13.5px; }
.boot-veil-ring {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid rgba(77,107,254,.25); border-top-color: var(--brand);
  animation: bv-spin .8s linear infinite;
}
@keyframes bv-spin { to { transform: rotate(360deg); } }
/* hidden 属性会被上面的 display:flex 盖掉，必须显式写回来（[hidden] 的经典坑） */
.login-gate[hidden] { display: none; }

.login-card {
  width: 384px; max-width: calc(100vw - 44px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
  padding: 30px 30px 26px;
  animation: pageIn .26s var(--ease);
}

/* 卡片头：logo 复用侧栏 .brand-mark（纯色主蓝方块 + 白描边），登录前后的品牌感一致 */
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.login-brand .brand-mark svg { width: 23px; height: 23px; }
.login-title h1 { font-size: 19px; font-weight: 600; letter-spacing: .3px; }
.login-title p { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.login-form .field + .field { margin-top: 14px; }
.login-form .btn { margin-top: 20px; }
.login-error { margin-top: 14px; }
.login-error .note { padding: 9px 12px; font-size: 12px; }

/* ══════════════════════════════════════════════════════════════════════════
   检索调试（只读）—— 资产库工具栏弹窗
   四路结果并排：BM25 / 向量 / RRF / final。只在弹窗内使用，不影响其它页面。
   ══════════════════════════════════════════════════════════════════════════ */
.retrieval-out { margin-top: 14px; }
.retrieval-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.retrieval-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.retrieval-col { border: 1px solid var(--side-line); border-radius: var(--radius); background: var(--surface); min-width: 0; overflow: hidden; }
.retrieval-col-title { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--side-line); background: var(--brand-tint); }
.retrieval-list { max-height: 360px; overflow: auto; padding: 6px; }
.retrieval-row { padding: 8px; border: 1px solid transparent; border-bottom: 1px solid var(--side-line); border-radius: var(--radius-sm); }
.retrieval-row:last-child { border-bottom-color: transparent; }
.retrieval-row.both { background: var(--brand-tint); border-color: var(--brand-soft-2); }
.retrieval-row.final { background: var(--brand-tint); }
.rr-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-3); }
.rr-cid, .rr-score { color: var(--text-2); }
.rr-src { margin-left: auto; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-text { margin-top: 4px; font-size: 12px; line-height: 1.55; color: var(--text); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.retrieval-final { margin-top: 12px; border: 1px solid var(--side-line); border-radius: var(--radius); overflow: hidden; }
.retrieval-final .retrieval-col-title { border-bottom: 1px solid var(--side-line); }
.retrieval-empty { padding: 14px 10px; font-size: 12px; color: var(--text-3); }
@media (max-width: 900px) {
  .retrieval-grid { grid-template-columns: 1fr; }
  .retrieval-list { max-height: 260px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   引用列表 / 预览定位
   ══════════════════════════════════════════════════════════════════════════ */
.cite.used { border-color: var(--brand-soft-2); }
.cite .c-locate { flex: none; height: 22px; padding: 0 7px; font-size: 11px; gap: 3px; }
.citation-list.compact .cite { padding: 7px 10px; }
.citation-list.compact .cite + .cite { margin-top: 6px; }
.citation-list.compact .c-text { font-size: 12px; }
.chat-cites { margin-top: 10px; }
.chat-cites > summary { cursor: pointer; font-size: 12px; color: var(--text-3); user-select: none; }
.chat-cites > summary:hover { color: var(--text-2); }
.chat-cites .citation-list { margin-top: 8px; }
.preview-hit {
  background: var(--brand-soft);
  color: var(--text);
  outline: 1px solid var(--brand);
  outline-offset: 1px;
  border-radius: 3px;
  padding: 0 1px;
}
.preview-hit-block {
  background: var(--brand-tint);
  outline: 1px solid var(--brand-soft-2);
  border-radius: 4px;
}

/* 对话里的检索日志：跟着「调用工具 N 次」折叠，不占正文 */
.tc-item { min-width: 0; }
.tc-retrieval { margin: 2px 0 4px; }
.tc-retrieval > summary { font-size: 11px; color: var(--brand-text); cursor: pointer; list-style: none; }
.tc-retrieval > summary::-webkit-details-marker { display: none; }
.tc-retrieval > summary::before { content: "▸"; display: inline-block; width: 12px; }
.tc-retrieval[open] > summary::before { content: "▾"; }
.tc-retrieval-body { padding: 6px 0 2px; }
.tc-retrieval .retrieval-grid { gap: 6px; }
.tc-retrieval .retrieval-col-title { padding: 5px 7px; font-size: 11px; }
.tc-retrieval .retrieval-list { max-height: 220px; padding: 4px; }
.tc-retrieval .retrieval-row { padding: 5px; }
.tc-retrieval .rr-text { -webkit-line-clamp: 3; font-size: 11.5px; }
.tc-retrieval .retrieval-final { margin-top: 6px; }

/* ══════════════════════════════════════════════════════════════════════════
   检索日志（只读历史页）
   --------------------------------------------------------------------------
   从对话里移出来的过程记录：工具栏筛选 + 一行一条的列表 + 详情抽屉。
   详情复用上方 .retrieval-grid / .retrieval-col / .retrieval-row 那一套，
   这里只补列表本身的排版，不改全局表格与虚拟滚动。
   ══════════════════════════════════════════════════════════════════════════ */
.log-toolbar { margin-bottom: 14px; }
.log-toolbar .log-q { width: 240px; }
.log-toolbar .select { width: auto; min-width: 132px; }

.log-list { margin: -4px -6px; }        /* 抵消卡片内边距，让行的 hover 底铺满 */
.log-head, .log-row {
  display: grid;
  grid-template-columns: 118px 168px minmax(0, 1fr) 84px 72px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}
.log-head {
  font-size: 11.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.log-row {
  width: 100%;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.log-row:last-child { border-bottom: 0; }
.log-row:hover { background: var(--surface-2); }
.log-row:focus-visible { outline: none; background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand-soft-2); }
.log-row .log-time, .log-row .log-sess, .log-row .log-hits, .log-row .log-mode {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-row .log-hits { font-variant-numeric: tabular-nums; }
.log-row .log-query {
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-head .log-col-num { text-align: right; }
.log-row .log-hits { text-align: right; }
.log-list .empty { padding: 34px 20px; }

.log-error { padding: 8px 4px; }
.log-foot-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; width: 100%; }
.log-pager { display: flex; align-items: center; gap: 8px; }
.log-detail .retrieval-meta { margin-bottom: 12px; }

@media (max-width: 900px) {
  .log-toolbar .log-q { width: 100%; }
  .log-head { display: none; }
  .log-row { grid-template-columns: 1fr auto; gap: 4px 10px; padding: 11px 12px; }
  .log-row .log-time { order: 2; text-align: right; }
  .log-row .log-query { grid-column: 1 / -1; order: 1; }
  .log-row .log-sess { order: 3; }
  .log-row .log-hits { order: 4; }
  .log-row .log-mode { order: 5; }
}

/* ══════════════════════════════════════════════════════════════════════════
   账号管理（管理员）
   --------------------------------------------------------------------------
   统计卡与表格都复用全局 .stat / .tbl，这里只补三处：
   · 账号行要能一眼扫出"谁被停用了"——停用行整行降饱和，不是只靠一枚小徽标；
   · 操作列三个小按钮不换行（窄屏才允许折行）；
   · 角色徽章在表格里保持正文尺寸（顶栏那枚 .role-badge 是小号）。
   ══════════════════════════════════════════════════════════════════════════ */
.acct-table td { vertical-align: middle; }
.acct-table tbody tr.acct-row[data-status="DISABLED"] .mono,
.acct-table tbody tr.acct-row[data-status="DISABLED"] td:nth-child(2) {
  color: var(--text-3);
}
.acct-table td:last-child .row { flex-wrap: nowrap; }
.acct-table .tag { background: var(--surface-3); color: var(--text-2); }
@media (max-width: 1080px) {
  .acct-table td:last-child .row { flex-wrap: wrap; }
}

/* ══════════════════════════════════════════════════════════════════════════
   语料备份（管理员）
   --------------------------------------------------------------------------
   表格沿用全局 .tbl / .table-wrap，这里只补三处：
   · 顶部说明与第一张卡片之间的呼吸（说明是"整页口径"，不该贴进卡片里）；
   · 日期 / 时间列不换行，文件数 / 大小列右对齐（.num 已在全局）；
   · 涉及文件名可能很长：单行省略，完整清单在 title 里，行高不被撑破。
   ══════════════════════════════════════════════════════════════════════════ */
.bk-intro { margin-bottom: 14px; line-height: 1.7; }
.bk-table td { vertical-align: middle; }
.bk-table .bk-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bk-table .bk-act { width: 1%; white-space: nowrap; text-align: right; }
.bk-names { max-width: 360px; }
.bk-names-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.bk-table td.num { color: var(--text-2); }
