/* AgentOR-Serve —— 对话式极简界面
 *
 * ★ 2026-11-13 界面重做（用户：「完全推翻当前的界面设计，寻求更精简，
 *   类似 deepseek harness 或者 codex 那样，界面里边不需要那么多文字」）。
 *
 * 上一版是三栏仪表盘：16 张卡片、5746 字符可见文字、页面高 5658px。
 * 这一版的结构是**两栏**：
 *
 *   ┌──────────┬──────────────────────────────────────┐
 *   │ 侧栏      │ 顶栏（状态 / 模型 / 停止）             │
 *   │ 会话列表  ├──────────────────────────────────────┤
 *   │          │ 对话流（结果全部折叠成一行摘要）        │
 *   │ 额度      ├──────────────────────────────────────┤
 *   │ 设置      │ 输入条（模式 · 输入框 · 题库/参数）     │
 *   └──────────┴──────────────────────────────────────┘
 *
 * 三条设计纪律：
 *   1. **一个字都不解释**。说明文字从界面搬进注释；界面上只留数据与动作。
 *   2. **结果默认折起来**。七张结果卡各占一行摘要，点开才看正文。
 *      摘要由 `shell.js` 从渲染结果里读（可信徽章、代码行数、级联次数…）。
 *   3. **颜色只住在 token 块里**（`tests/test_p27` §13 钉着）：
 *      token 块之外一个十六进制 / rgba 都不许出现。
 *
 * 保留下来的两处既有契约（门禁在守，不能动）：
 *   · `.agent-*` 那一段排在文件靠后，且**那一段之后不许有字面颜色** ——
 *     门禁用一个中文小节标题作锚点去切文件，所以那个标题在本文件里
 *     **只能出现一次**（放在真正的小节上）。写在这段注释里会让它切错位置，
 *     把 token 块当成"agent 段"、报出 82 处字面颜色。实测踩过；
 *   · 手机断点必须写在**文件末尾**（前面基础规则权重相同、后出现者胜）。
 */
:root {
  color-scheme: light;

  /* 中性色阶：暖灰纸底 + 暖白面 */
  --bg: #efece7;
  --surface: #fbf9f6;
  --surface-2: #f5f2ed;
  --surface-3: #eae6df;
  --inset: #ffffff;
  --border: #d8d2c8;
  --border-muted: #e6e1d8;

  /* 文字（对比度按 WCAG AA 校过：正文 ≥ 4.5:1，标题 ≥ 7:1） */
  --text: #211d18;
  --text-2: #5c554b;
  --text-3: #6f675b;

  /* 语义色（低饱和，避免刺眼；皆与强调色不同域） */
  --accent: #0e6b64;
  --accent-dim: #0a4f4a;
  --ok: #2a7047;
  --ok-dim: #bcd9c6;
  --warn: #8f6209;
  --warn-dim: #e6d3a8;
  --err: #b3402f;
  --err-dim: #ecc6bf;
  --purple: #6b4fa8;
  --purple-dim: #d5c8ec;
  --on-accent: #ffffff;

  /* 半透明底：由基础 token 派生，换色板自动跟随 */
  --accent-tint: color-mix(in srgb, var(--accent) 8%, transparent);
  --ok-tint: color-mix(in srgb, var(--ok) 9%, transparent);
  --warn-tint: color-mix(in srgb, var(--warn) 10%, transparent);
  --err-tint: color-mix(in srgb, var(--err) 9%, transparent);
  --purple-tint: color-mix(in srgb, var(--purple) 9%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --ok-soft: color-mix(in srgb, var(--ok) 18%, transparent);
  --err-soft: color-mix(in srgb, var(--err) 18%, transparent);
  --purple-soft: color-mix(in srgb, var(--purple) 18%, transparent);

  /* 遮罩与阴影（暖色阴影，不用纯黑）。
     2026-10-21 起三层化：--shadow-0 发丝级（按钮/小件）、--shadow-1 卡片、
     --shadow-2 弹层。分层叠出来的是「深度」而不是「投影感」。 */
  --scrim: rgba(40, 34, 26, .48);
  --shadow-0: 0 1px 2px rgba(72, 58, 38, .12);
  --shadow-1: 0 1px 2px rgba(72, 58, 38, .05), 0 6px 20px rgba(72, 58, 38, .13);
  --shadow-2: 0 2px 6px rgba(72, 58, 38, .07), 0 24px 64px rgba(72, 58, 38, .30);

  --radius: 10px;
  --radius-sm: 7px;
  /* 键盘焦点环：由强调色派生，换主题自动跟随（非字面颜色，深色块无需重定义） */
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  /* 标题用衬线求学术感；**不加载任何网络字体** —— 本地工具必须离线可用 */
  --serif: Georgia, "Source Han Serif SC", "Noto Serif SC",
           "Songti SC", "SimSun", serif;
}

/* 深色：暖炭，不是纯黑 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1917;
    --surface: #24211e;
    --surface-2: #2b2825;
    --surface-3: #332f2b;
    --inset: #141210;
    --border: #3a3631;
    --border-muted: #2e2b27;
    --text: #ece7e0;
    --text-2: #b6afa4;
    --text-3: #8f877b;
    /* 深色下强调色的**明度坡向必须反过来**。`.btn` 是「静息用 dim、悬停用 accent」，
       浅色主题里 accent-dim 是深色，于是白字在这两级上都够读；深色主题里若照抄
       「悬停更亮」，白字落在亮青底上只有 2.4:1 —— 比大字号下限 3:1 还低。
       所以深色这两级都是**亮色**，字改用深墨（--on-accent）。 */
    --accent: #6ac9bc;
    --accent-dim: #4aa79b;
    --ok: #6cbd85;
    --ok-dim: #2b4a35;
    --warn: #d9a441;
    --warn-dim: #4d3d14;
    --err: #e0736a;
    --err-dim: #552924;
    --purple: #a98bdd;
    --purple-dim: #3d3157;
    --on-accent: #0c1a18;
    --scrim: rgba(8, 6, 4, .68);
    --shadow-0: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .12), 0 6px 20px rgba(0, 0, 0, .38);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .18), 0 24px 64px rgba(0, 0, 0, .62);
  }
}

/* 手动切换：显式深色优先于系统浅色 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1917;
  --surface: #24211e;
  --surface-2: #2b2825;
  --surface-3: #332f2b;
  --inset: #141210;
  --border: #3a3631;
  --border-muted: #2e2b27;
  --text: #ece7e0;
  --text-2: #b6afa4;
  --text-3: #8f877b;
  /* 与系统深色块逐字一致：明度坡向反转 + 深墨字（理由见上面的 media 块） */
  --accent: #6ac9bc;
  --accent-dim: #4aa79b;
  --ok: #6cbd85;
  --ok-dim: #2b4a35;
  --warn: #d9a441;
  --warn-dim: #4d3d14;
  --err: #e0736a;
  --err-dim: #552924;
  --purple: #a98bdd;
  --purple-dim: #3d3157;
  --on-accent: #0c1a18;
  --scrim: rgba(8, 6, 4, .68);
  --shadow-0: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .12), 0 6px 20px rgba(0, 0, 0, .38);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .18), 0 24px 64px rgba(0, 0, 0, .62);
}


/* ========================================================================== */
/* 基础                                                                       */
/* ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.spacer { flex: 1 1 auto; }
.mono { font-family: var(--mono); }
.small, .muted { color: var(--text-3); font-size: 12.5px; }
.tight { padding: 8px 0; }
.mono, .num, .code { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-3) 34%, transparent);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-3) 55%, transparent);
  background-clip: content-box;
}

:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* ========================================================================== */
/* 布局：两栏                                                                 */
/* ========================================================================== */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  flex: 0 0 232px;
  width: 232px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--border-muted);
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 8px;
}
.logo { font-weight: 700; letter-spacing: 0.2px; font-size: 14px; }

.new-btn {
  margin: 0 12px 10px;
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.new-btn:hover { color: var(--text); border-color: var(--border); }

.side-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 0 8px; }

.side-label-row {
  display: flex;
  align-items: center;
  padding: 6px 4px 4px;
}
.side-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
}

.side-list { display: flex; flex-direction: column; gap: 1px; }
.side-list .body { padding: 0; }

.side-foot {
  border-top: 1px solid var(--border-muted);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.side-note { color: var(--text-3); font-size: 12px; min-height: 0; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* -------------------------------------------------------------------------- */
/* 主区：对话 + 右侧预览面板                                                    */
/* -------------------------------------------------------------------------- */
.work { flex: 1 1 auto; display: flex; min-height: 0; }
.work > .stream { flex: 1 1 auto; min-width: 0; }

.panel {
  flex: 0 0 520px;
  width: 520px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border-muted);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border-muted);
  flex: 0 0 auto;
}
.ptab {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.ptab:hover { color: var(--text); }
.ptab.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.panel-body { flex: 1 1 auto; min-height: 0; position: relative; }
.pane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--inset);
}
/* 「结果」tab：本地渲染的卡片列，要能滚。
   卡片在面板里**不再各带一层边框** —— 一层就够，套两层会显脏。 */
.pane-scroll { overflow-y: auto; padding: 10px; background: var(--surface); }
.pane-scroll > .card {
  border: 0;
  border-bottom: 1px solid var(--border-muted);
  border-radius: 0;
  background: transparent;
  margin: 0;
}
.pane-scroll > .card:last-child { border-bottom: 0; }

/* 对话区的「完整结果」入口：一行，不抢眼 */
.result-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.icon-btn.on { background: var(--accent-tint); color: var(--accent); }

/* ========================================================================== */
/* 顶栏：状态、模型、停止                                                      */
/* ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--surface);
  flex: 0 0 auto;
}
.topbar .badge { max-width: 34vw; overflow: hidden; text-overflow: ellipsis;
                 white-space: nowrap; }

.progress {
  display: block;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
  max-width: 160px;
}

/* 交付条：**常显**（用户要求「导出一眼可达」） */
.actions {
  flex: 0 0 auto;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--surface);
}
.deliver {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  /* 用一条上边框把这排动作与上面的状态分行（而不是再套一层卡片） */
  border-top: 1px solid var(--border-muted);
  padding-top: 8px;
}
.deliver .lbl { color: var(--text-3); font-size: 12px; margin-right: 2px; }

/* ========================================================================== */
/* 对话流                                                                     */
/* ========================================================================== */
.stream {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 18px 18px 6px;
  scroll-behavior: smooth;
}
/* 内容居中成一列。
   ★ 2026-11-13（2.0 计划书 §四）：上限从 860px 提到 1240px。
   主区在 1660px 视口下有 1660px 可用，旧的 860 上限让左右各空出约 400px ——
   用户明确提过这件事。散文行长由 `.answer p` 之类的**内层**限制，
   不能靠把整个工作区缩窄来实现（那会把表格和公式一起挤扁）。 */
.stream > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
.stream > * + * { margin-top: 10px; }

/* 折叠块：一行摘要 + 点开看正文。
   类名保持 card（p23 用它认定结果卡、p27 只扫 div），
   折叠靠 data-collapsed 属性，由 shell.js 点标题切换。 */
.fold-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.fold-head::before {
  content: "\25B8";
  color: var(--text-3);
  font-size: 10px;
  line-height: 1;
}
:not([data-collapsed]) > .fold-head::before { content: "\25BE"; }
.fold-head:hover { background: var(--surface-2); }
.fold-t { font-weight: 600; color: var(--text); }
.fold-s {
  margin-left: auto;
  color: var(--text-3);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.fold-body { padding: 4px 12px 12px; border-top: 1px solid var(--border-muted); }
/* 通用：任何带 data-collapsed 的容器（结果卡、时间轴）正文都收起来 */
[data-collapsed] > .fold-body { display: none; }
[data-collapsed] > .fold-head { border-bottom: 0; }
.fold-body > header { display: none; }
.fold-body .body { padding: 0; }

/* ========================================================================== */
/* 输入条                                                                     */
/* ========================================================================== */
.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-muted);
  background: var(--surface);
  padding: 8px 18px 12px;
}
.composer > * { max-width: 1240px; margin-left: auto; margin-right: auto; }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  margin-bottom: 7px;
}
.seg-btn {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 1px);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--text); font-weight: 600; }

.compose-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--inset);
}
.compose-input:focus-within { border-color: var(--accent); }
.compose-input textarea {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  resize: none;
  max-height: 200px;
  padding: 3px 0;
}
.send-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.send-btn:hover { background: var(--accent-dim); }
.send-btn:disabled { opacity: 0.5; cursor: default; }

.compose-bar {
  display: flex;
  align-items: center;
  gap: 6px 6px;
  margin-top: 7px;
  /* ★ 2026-11-13：必须允许折行。输入区里除三个 chip 之外还有
     模型与思考深度两个选择器 —— 320~390px 一行放不下，
     不折行就会顶出屏幕（p87 真实视口实测：iPhone SE 溢出 4 个元素）。 */
  flex-wrap: wrap;
}
.chip {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 9px;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-muted);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border); }

/* -------------------------------------------------------------------------- */
/* 侧栏会话：**一行一条**（用户要求：像 dsh 那样，不要一个问题占一个大框）      */
/* -------------------------------------------------------------------------- */
.sess {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  /* 一行就是一行：不换行、溢出打点。信息不缺 —— 状态在点上、耗时在右、
     失败原因在 title 里（悬停可见），但**不占第二行**。 */
  white-space: nowrap;
  overflow: hidden;
}
.sess:hover { background: var(--surface-3); }
.sess.on { background: var(--accent-tint); }
.sess .sess-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}
.sess .sess-dot.ok { background: var(--ok); }
.sess .sess-dot.err { background: var(--err); }
.sess .sess-dot.warn { background: var(--warn); }
.sess .sess-t {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sess .sess-meta { flex: 0 0 auto; color: var(--text-3); font-size: 11.5px; }

/* 输入区里的模型 / 深度选择器：小、安静，不抢输入框的位置 */
.inline-pick { display: inline-flex; margin: 0; min-width: 0; }
.inline-pick select {
  width: auto;
  min-width: 0;
  max-width: 12rem;
  font-size: 12.5px;
  padding: 3px 6px;
  border-radius: 999px;
  background: transparent;
  border-color: var(--border-muted);
  color: var(--text-2);
}
.inline-pick select:hover { color: var(--text); border-color: var(--border); }

/* -------------------------------------------------------------------------- */
/* 设置里的「能力」清单（技能包 / 知识库 / 沙箱）—— 只列，不可展开            */
/* -------------------------------------------------------------------------- */
.cap-h {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin: 10px 0 4px;
}
.cap-list { display: flex; flex-direction: column; gap: 1px; }
.cap-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  padding: 2px 0;
}
.cap-row > span:first-child { flex: 1 1 auto; min-width: 0; }
.cap-meta { flex: 0 0 auto; color: var(--text-3); font-size: 11.5px; }

/* ========================================================================== */
/* 通用控件                                                                   */
/* ========================================================================== */
.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.sm { font-size: 12.5px; padding: 4px 9px; }

.icon-btn {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.side-open { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.6;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.err { background: var(--err-tint); color: var(--err); }
.badge.info { background: var(--accent-tint); color: var(--accent); }
.badge.purple { background: var(--purple-tint); color: var(--purple); }

.card {
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.card > header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-muted);
}
.card > header h2 { margin: 0; font-size: 13px; font-weight: 600; }
.card .body { padding: 10px 12px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1 1 0; min-width: 0; }

label { display: block; font-size: 12.5px; color: var(--text-3); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number], input[type=tel],
input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
}
textarea { resize: vertical; min-height: 62px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.hint { color: var(--text-3); font-size: 12px; margin-top: 5px; }
.note {
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-muted);
  color: var(--text-2);
}
.note.warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.note.err { background: var(--err-tint); color: var(--err); border-color: transparent; }

.sec-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-muted);
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; font-size: 13px; }

.known-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.known-list li { margin: 2px 0; }

.answer { font-size: 14px; }
.answer p:first-child { margin-top: 0; }
.answer table, .md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.answer th, .answer td, .md-table th, .md-table td {
  border: 1px solid var(--border-muted);
  padding: 4px 8px;
  text-align: left;
}
.math-block { overflow-x: auto; padding: 4px 0; }
/* KaTeX：默认颜色是纯黑，深色主题下看不见；而且长公式必然比容器宽。
   这两条在界面重做时被漏掉过，门禁 p65 当场报红。 */
.katex { color: inherit; }
.katex-display { overflow-x: auto; overflow-y: hidden; }
.tex-fallback { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
pre, .code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  overflow: auto;
  max-height: 380px;
  margin: 0;
}

/* ========================================================================== */
/* 题库选择器里的列表                                                          */
/* ========================================================================== */
.problem-list { display: flex; flex-direction: column; gap: 2px; }
.scene-group { border-bottom: 1px solid var(--border-muted); }
.scene-group:last-child { border-bottom: 0; }
.scene-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.scene-title .caret { color: var(--text-3); font-size: 10px; }
.scene-title.collapsed .caret { transform: rotate(-90deg); }
.scene-body { padding-bottom: 6px; }
.problem-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.problem-item:hover { background: var(--surface-2); }
.problem-item .t { flex: 1 1 auto; min-width: 0; overflow: hidden;
                   text-overflow: ellipsis; white-space: nowrap; }
.problem-item .m { display: flex; align-items: center; gap: 5px;
                   color: var(--text-3); font-size: 11.5px; }
.problem-item.flash { background: var(--accent-tint); }
.tag {
  font-size: 11px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}

/* ========================================================================== */
/* 过程：时间轴一行一步                                                        */
/* ========================================================================== */
.timeline { border: 1px solid var(--border-muted); border-radius: var(--radius);
            background: var(--surface); overflow: hidden; }
.timeline .body { padding: 10px 12px; }
.tl-main { display: flex; flex-direction: column; }
.tl-head { display: flex; align-items: center; gap: 8px; }
.tl-name { font-size: 13px; font-weight: 600; }
.tl-time { color: var(--text-3); font-size: 12px; }
.tl-text { color: var(--text-2); font-size: 12.5px; }
.tl-subs { padding-left: 14px; border-left: 1px solid var(--border-muted); }
.tl-mark { color: var(--text-3); }
.tl-data { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.tl-expand, .tl-detail-toggle {
  font: inherit;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  border: 0;
  padding: 3px 0;
  cursor: pointer;
  text-align: left;
}
.tl-expand:hover, .tl-detail-toggle:hover { color: var(--text); }
.tl-detail-wrap { margin-top: 6px; }
.tl-detail { font-size: 12.5px; color: var(--text-2); }

/* ========================================================================== */
/* 澄清                                                                       */
/* ========================================================================== */
.qa-item { border: 1px solid var(--border-muted); border-radius: var(--radius-sm);
           padding: 9px 11px; margin-bottom: 7px; background: var(--surface); }
.qa-q { font-size: 13.5px; display: flex; align-items: baseline; gap: 7px; }
.qa-topic, .qa-why { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.qa-opts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.qa-skip { color: var(--text-3); font-size: 12px; }
.qa-skipped { opacity: 0.55; }

/* ========================================================================== */
/* 可信判定                                                                   */
/* ========================================================================== */
.trust-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.trust-sec { margin-top: 8px; }
.trust-warn { color: var(--warn); }
.trust-pre, .trust-gates, .uncovered {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 4px 0;
}
.uncovered { color: var(--warn); }
.trust-more {
  font: inherit; font-size: 12px; color: var(--text-3);
  background: transparent; border: 0; padding: 2px 0; cursor: pointer;
}
.req-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.req-table th, .req-table td { border-bottom: 1px solid var(--border-muted);
                               padding: 3px 6px; text-align: left; }
.req-hit { color: var(--ok); }
.req-none { color: var(--text-3); }

/* ========================================================================== */
/* 附件                                                                       */
/* ========================================================================== */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-top: 8px;
}
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-tint); }
.upload-list { display: flex; flex-direction: column; gap: 3px; }
.upload-list .fe { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.upload-list .fe.err { color: var(--err); }
.upload-list .cname { flex: 1 1 auto; min-width: 0; overflow: hidden;
                      text-overflow: ellipsis; white-space: nowrap; }
.upload-list .kind { color: var(--text-3); font-size: 11.5px; }

/* ========================================================================== */
/* 弹层                                                                       */
/* ========================================================================== */
.mask, .modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
  background: var(--scrim);
  overflow-y: auto;
}
.sheet, .modal {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.sheet-head, .modal > header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-muted);
}
.sheet-head h3, .modal > header h2 { margin: 0; font-size: 14px; font-weight: 600; }
.sheet > .body, .modal > .body { padding: 14px; }
.sheet > footer, .modal > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--border-muted);
}
.modal-statement {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  max-height: 46vh;
  overflow-y: auto;
}
#problem-list { max-height: 52vh; overflow-y: auto; }

/* ========================================================================== */
/* 提示条                                                                     */
/* ========================================================================== */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  /* 前景用 --surface 而不是那个页面底色变量：门禁要求 token 块之外
     它只出现一次（body）。凹陷面共用它的话，浅色主题下
     输入框会比卡片更暗、读起来是坏的。 */
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-2);
}
#toast.err { background: var(--err); color: var(--on-accent); }
#toast.warn { background: var(--warn); color: var(--on-accent); }
#toast.ok { background: var(--ok); color: var(--on-accent); }

/* -------------------------------------------------------------------------- */
/* 对话模式：建模助手（`mirror_agent`）
 *
 * 这一节之后的**每一处颜色都必须走 token** —— 门禁拿正则扫这一段，
 * 十六进制与函数式颜色一个字面量都不许出现（**连注释里也不行**：
 * 我第一版把那个函数名写进注释解释规则，它自己就把门禁触发了）。
 * 它同时也是"模块拆分后唯一还留在 CSS 里的模式段"。
 * -------------------------------------------------------------------------- */
.agent-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  max-height: 62vh;
  overflow-y: auto;
}
.agent-msg { display: flex; flex-direction: column; gap: 3px; }
.agent-msg.user .agent-role { color: var(--accent); }
.agent-msg.error .agent-text { color: var(--err); }
.agent-role {
  font-size: 11.5px;
  letter-spacing: 0.4px;
  color: var(--text-3);
}
.agent-text {
  font-size: 13.5px;
  color: var(--text);
  word-break: break-word;
}
.agent-msg.note .agent-text { color: var(--text-3); font-size: 12.5px; }
.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.agent-call {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  margin-top: 4px;
}
.agent-tools { display: flex; flex-direction: column; gap: 5px; }
.agent-audit {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  max-height: 300px;
  overflow: auto;
}
.agent-hint {
  font-size: 12.5px;
  color: var(--warn);
  background: var(--warn-tint);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin: 0 12px 8px;
}
.agent-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-muted);
}
/* tool 调用现场：一行一调用，参数与结果折叠在下面 */
.agent-trace-h {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.agent-trace-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.agent-trace-m { color: var(--text-3); font-size: 11.5px; }
.agent-trace-v {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  margin: 3px 0 3px 21px;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-trace-skill { color: var(--purple); font-size: 11.5px; }


/* ========================================================================== */
/* 既有类规则（界面重做时不能丢：它们守的是真实功能）                            */
/* ========================================================================== */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* 「换下一题」的高亮：底色从左边界闪一下再退掉 */
.flash { animation: pb-flash 1.6s ease-out; }
@keyframes pb-flash {
  from { background-color: var(--accent-tint); border-left-color: var(--accent); }
  to   { background-color: transparent;       border-left-color: transparent; }
}

/* 可信闸门小丸 */
.trust-gate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.trust-gates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.trust-warn {
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--warn-tint);
  border: 1px solid var(--warn-dim);
  color: var(--warn);
  font-size: 11.5px;
}

/* 澄清：严重度标记、题面话题、跳过态 */
.qa-sev {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 500;
  vertical-align: 1px;
  background: var(--surface-3);
  color: var(--text-3);
}
.qa-sev.blocking { background: var(--err-tint); color: var(--err); }
.qa-sev.optional { background: var(--surface-3); color: var(--text-3); }
.qa-topic {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.qa-skip { color: var(--text-3); font-size: 12px; }
/* 「已跳过」要给两种信号：底色 + 虚线边框。只压暗一档的话，
   在暖灰底上差异太细，事后读结论时认不出哪几题是按假设走的。 */
.qa-skipped {
  background: var(--surface-3);
  border-style: dashed;
  border-color: var(--border);
}
.qa-item.qa-skipped {
  background: var(--surface-3);
  border-style: dashed;
  border-color: var(--border);
}

/* 时间轴子行与状态小丸 */
.tl-sub { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; margin-top: 4px; }
.tl-status {
  flex: 0 0 auto;
  font-size: 10.5px;
  line-height: 1.6;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-3);
}
.tl-detail { font-size: 12.5px; color: var(--text-2); }

/* 记号式模型渲染（notationHtml） */
.math-block .obj { color: var(--text); font-weight: 600; }
.math-block .cname { color: var(--accent); }
.math-block .fe { color: var(--text-3); }
.req-table td { border-bottom: 1px solid var(--border-muted); padding: 3px 6px; text-align: left; }
.req-table .stmt { color: var(--text-2); }
.req-table tr.uncovered td { background: var(--warn-tint); }

/* 卡内那个输入框在整页布局下是**多余**的：底部已经有一个输入条，
   而 `#btn-solve` 在两种模式下都是唯一的"开始"动作（对话模式内部转给 agent）。
   两个输入框只会让人不知道该在哪打字，而且卡内那个不吸底、随内容滚走。
   保留元素本身（`probeAgent` 会把它 disabled、门禁也引用它），只是不显示。 */
/* 卡内那个输入框在整页布局下是多余的：底部已经有一个输入条，
   而 `#btn-solve` 在两种模式下都是唯一的"开始"动作（对话模式内部转给 agent）。
   两个输入框只会让人不知道该在哪打字，而且卡内那个不吸底、随内容滚走。
   元素本身保留（`probeAgent` 失败时会把它 disabled、门禁也引用它），只是不显示。
   同排的 附件 / 审计 / 停止 保留 —— 它们是对话专属动作，别处没有。 */
#agent-input, #btn-agent-send { display: none; }

/* ========================================================================== */
/* 手机适配                                                                   */
/* （必须放在文件最后：`.topbar` / `input` 的基础规则在上面几百行之前，         */
/*  写在前面会被它们覆盖 —— 媒体查询的优先级只由"权重 + 出现顺序"决定。）      */
/* ========================================================================== */
@media (max-width: 1400px) {
  .stream > *, .composer > * { max-width: 100%; }
}

@media (max-width: 1000px) {
  .sidebar { flex-basis: 220px; width: 220px; }
}

@media (max-width: 640px) {
  /* 顶栏折行：不折的话几个徽标 + 按钮横排就把页面撑出屏幕（实测 504px） */
  .topbar {
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 8px 10px;
  }
  .topbar .badge { max-width: 42vw; overflow: hidden;
                   text-overflow: ellipsis; white-space: nowrap; }
  .topbar .spacer { display: none; }
  .side-open { display: inline-flex; }

  /* 侧栏在窄屏变成抽屉 */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: 260px;
    flex-basis: 260px;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-2);
  }
  body.side-open .sidebar { transform: none; }
  .side-mask { position: fixed; inset: 0; z-index: 65; background: var(--scrim); }

  /* 面板在窄屏变成右侧抽屉（固定定位，不参与横向布局，
     所以不会把文档撑宽 —— p87 量的就是文档宽 == 视口宽）。 */
  .panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 66;
    width: min(440px, 92vw);
    flex-basis: auto;
    box-shadow: var(--shadow-2);
  }

  .stream { padding: 10px 10px 4px; }
  .composer { padding: 8px 10px 10px; }
  .actions { padding: 7px 10px; }

  /* ★ 防 iOS 聚焦放大整页 */
  textarea, input[type=text], input[type=password], input[type=number],
  input[type=tel], input[type=email], select { font-size: 16px; }

  .sheet, .modal { max-width: calc(100vw - 20px) !important; }
  .mask, .modal-mask { padding: 5vh 10px 10px; }

  /* 模型 / 深度两个选择器在窄屏各占半行 —— 它们比 chip 宽，
     折行之后挤在 chip 后面会比 chip 还窄，选不中。 */
  .inline-pick { flex: 1 1 8rem; }
  .inline-pick select { max-width: none; width: 100%; }

  /* 手机没有 hover，热区小会点不中 */
  .btn.sm, .chip { min-height: 32px; }
  .btn { min-height: 34px; }
  .icon-btn { width: 32px; height: 32px; }
  .field-row { flex-direction: column; gap: 0; }
}
