:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2733;
  --muted: #6b7785;
  --primary: #2f6df6;
  --primary-soft: #e8f0ff;
  --danger: #e5484d;
  --ok: #1f9d55;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
  --radius: 8px;
  --conversation-font-size: 14px; /* 对话正文基准字号 */
  /* 峰谷配色（对话气泡 / 输入框边框；可在「设置 → 峰谷配色」里改）。
     回答色 = 提问色按「淡化程度」向【当前主题的面板色】混合：
       明亮主题（面板=白）→ 提亮成浅色；黑暗/自定义深色面板 → 压暗成深色 —— 自动适配主题。
     -a = 回答底色、-fg = 回答文字色（两者均由 JS 按当前主题算出并写行内变量；此处是 JS 未执行时的兜底值） */
  --pv-official-peak-q: #FF991C;   --pv-official-peak-a: #FFCE93;   --pv-official-peak-fg: #000;
  --pv-official-valley-q: #20BB20; --pv-official-valley-a: #ADF1AD; --pv-official-valley-fg: #000;
  --pv-go-peak-q: #EDE101;         --pv-go-peak-a: #FFF988;         --pv-go-peak-fg: #000;
  --pv-go-valley-q: #03D3D3;       --pv-go-valley-a: #89FEFE;       --pv-go-valley-fg: #000;
  /* 「GO 旧消息」兜底气泡（历史消息无 period 标记）底色/字色，随主题切换 */
  --pv-legacy-go-a: #eef7f2;       --pv-legacy-go-fg: #000;
}
/* 黑暗主题（设置 → 整体风格 = 黑暗） */
[data-theme="dark"] {
  --bg: #0f141a; --panel: #1a212b; --border: #2b3440;
  --text: #e6edf3; --muted: #8b98a5; --primary: #4f8cff; --primary-soft: #1c2942;
  /* 暗色主题：回答色兜底为「压暗」（= 提问色向暗面板混合 60%），回答文字用浅字。
     JS 运行时仍会按当前面板色重算并写行内变量，这里保证 JS 未执行 / 首帧也已是暗色。 */
  --pv-official-peak-a: #765125;   --pv-official-peak-fg: #e6edf3;
  --pv-official-valley-a: #1c5f27; --pv-official-valley-fg: #e6edf3;
  --pv-go-peak-a: #6e6e1a;         --pv-go-peak-fg: #e6edf3;
  --pv-go-valley-a: #11686e;       --pv-go-valley-fg: #e6edf3;
  --pv-legacy-go-a: #16302a;       --pv-legacy-go-fg: #d7f0e5;
}
/* 跟随系统：系统处于暗色时用暗色变量（明亮系统保持 :root 默认） */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg: #0f141a; --panel: #1a212b; --border: #2b3440;
    --text: #e6edf3; --muted: #8b98a5; --primary: #4f8cff; --primary-soft: #1c2942;
    --pv-official-peak-a: #765125;   --pv-official-peak-fg: #e6edf3;
    --pv-official-valley-a: #1c5f27; --pv-official-valley-fg: #e6edf3;
    --pv-go-peak-a: #6e6e1a;         --pv-go-peak-fg: #e6edf3;
    --pv-go-valley-a: #11686e;       --pv-go-valley-fg: #e6edf3;
    --pv-legacy-go-a: #16302a;       --pv-legacy-go-fg: #d7f0e5;
  }
}
/* 自定义主题：[data-theme="custom"] 时变量由 JS 从 gSettings.themeCustom 直接写到 html 上，此处不写固定值 */
* { box-sizing: border-box; }
/* 表单控件统一跟随主题（明亮/黑暗/自定义）：深色模式下输入框/下拉/文本域不再白底 */
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="email"], textarea, select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
}
/* overflow:hidden：单页外壳锁死「页面级滚动」——滚动只发生在 .messages / .sidebar-main 等内部容器。
   （否则手机上任何落在非滚动区的拖动都会把整页带着滚，表现为「拖目录却滚对话」） */
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* 登录 */
.login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef3fb 0%, #f7f9fc 100%);
  z-index: 100;
}
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 36px 32px; box-shadow: 0 12px 40px rgba(30,50,90,0.12);
  text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 12px 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; text-align: left; color: var(--muted); font-size: 12px; margin: 12px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 12px; border: none; border-radius: var(--radius);
  background: var(--primary); color: #fff; font-size: 15px; letter-spacing: 4px; cursor: pointer;
}
.login-card button:hover { background: #245ad6; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* 顶栏 */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar {
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px; flex-shrink: 0;
}
.brand { font-weight: 600; font-size: 15px; }
.brand span { color: var(--muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-tag { color: var(--muted); font-size: 13px; white-space: nowrap; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; }
.model-label { color: var(--muted); font-size: 13px; }
.topbar-right select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; background: var(--panel); font-size: 13px; max-width: 200px; }

/* 按钮 */
.btn-ghost, .btn-sm, .btn-primary, .btn-send, .btn-danger {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 13px; padding: 6px 10px;
}
.btn-ghost:hover, .btn-sm:hover { background: var(--bg); }
.btn-sm { padding: 5px 9px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #245ad6; }
.btn-danger { color: var(--danger); border-color: #f3c6c8; }
.btn-danger:hover { background: #fdeced; }
.btn-danger.btn-danger-active,
.btn-danger-active { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 600; }

/* 布局 */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  flex: 3 1 0; min-width: 260px; max-width: 55vw; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: visible; /* 2026-08-31 晚：模块 hover 浮层要能盖住下方、不受裁剪 */
}
/* 上部主滚动区（2026-08-26 三轮）：顶部两个模块 —— 对话目录模块 + 智能体模块，自适应排列、上对齐；
   回收区已并入各自模块（对话回收区在对话模块底部、智能体回收区在智能体模块底部），不再出现第三个游离区块 */
.sidebar-main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: visible; padding: 10px 10px 6px; gap: 10px; position: relative; } /* 不设 z-index：避免创建独立堆叠上下文，让各模块 hover 浮层（z-index:1000）能互相盖压 */
/* 通用模块卡片（对话目录 / 智能体 共用骨架） */
.panel-module { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 10px; flex-shrink: 0; }
.module-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13px; color: var(--text); padding: 2px 2px 6px; }
.module-actions { display: flex; gap: 6px; font-weight: 400; }
/* 对话目录模块（2026-08-31 晚改 hover 浮层）：默认只显示标题栏，内容收进 .module-body，
   hover 整块时 .module-body 浮层展开覆盖下方；树本身不再单独限高，由浮层内部滚动 */
.chat-module .tree { padding: 2px 2px 4px; }
.module-body .trash-area { display: block; }
.list-sync-tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.list-sync-tag.flash { color: var(--primary); font-weight: 600; }
.tree { flex: 1; overflow-y: auto; padding: 8px; }
/* 侧栏宽度拖拽条 */
.sidebar-resizer {
  width: 6px; flex-shrink: 0; cursor: col-resize; background: transparent; position: relative; z-index: 5;
}
.sidebar-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 3px;
  background: #d7dee8; transition: background .15s ease;
}
.sidebar-resizer:hover::after, .sidebar-resizer.active::after { background: var(--primary); }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
.sidebar-hint { padding: 8px 14px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }

/* 2026-08-31 晚：左侧栏模块「hover 浮层」—— 鼠标移到哪块，哪块内容浮在上方展开覆盖其他块，移开即收起；
   每个模块默认只显示标题栏（header），内容收进 .module-body；.module-body 相对模块绝对定位（脱离文档流，
   不挤动其他块），hover 时展开 + 实底 + 阴影盖住下方兄弟模块。底部「询问历史」向上展开避免超出视口。 */
.chat-module, .agent-panel, .prompt-wrap, .scratch-wrap, .inquiry-panel { position: relative; z-index: 1; }
.chat-module:hover, .agent-panel:hover, .prompt-wrap:hover, .scratch-wrap:hover, .inquiry-panel:hover { z-index: 1000; }
/* 2026-08-31 晚（终稿）：左侧栏模块「收缩显示最小 3 行 + hover 浮层展开 15 行」
   收缩态：.module-body 为文档流(position:static)占位 3 行，正常堆叠、不盖其他模块；
   hover 态：.module-body 变浮层(position:absolute)盖住相邻；上面的模块向下、下面的模块向上。
   所有内容区统一 收缩 3 行 / 展开 15 行；对话目录选中项必可见(JS scrollIntoView)。
   行高常量：目录树行 ~32px、文本框行 ~19.5px(1.5em@13px+16px 内边距)、询问项 ~28px */
.module-body { position: static; }

/* 对话目录 / 智能体 树：收缩 3 行、展开 15 行 */
.chat-module .tree, .agent-panel .agent-tree { max-height: calc(32px * 3); overflow-y: auto; }
.chat-module:hover .tree, .agent-panel:hover .agent-tree { max-height: calc(32px * 15); }

/* 提示词文本框：收缩 3 行、展开 15 行（高度由 CSS 控制，JS 不再干预） */
.prompt-wrap .module-body #promptBox { height: calc(19.5px * 3 + 16px); resize: none; }
.prompt-wrap:hover .module-body #promptBox { height: calc(19.5px * 15 + 16px); }
/* 速记文本框：收缩 3 行、展开 15 行 */
.scratch-wrap .module-body #scratchBox { height: calc(19.5px * 3 + 16px); resize: none; }
.scratch-wrap:hover .module-body #scratchBox { height: calc(19.5px * 15 + 16px); }

/* 询问历史列表：收缩 3 行、展开 15 行 */
.inquiry-panel .inquiry-list { max-height: calc(28px * 3); }
.inquiry-panel:hover .inquiry-list { max-height: calc(28px * 15); }

/* hover 浮层：上面的模块向下、下面的模块向上；自带实底+阴影盖住相邻。
   提示词区在速记区上方、下边顶住速记区 → 也向上展开（bottom:100%），不往下挤；
   速记区 / 询问历史 同样向上。对话目录 / 智能体 在上方 → 向下展开。各模块独立互不牵连。 */
.chat-module:hover .module-body, .agent-panel:hover .module-body {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 1000;
  background: var(--panel); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 10px 10px; box-shadow: 0 14px 30px rgba(20,30,50,.20);
  padding: 8px 10px 10px;
}
.prompt-wrap:hover .module-body, .scratch-wrap:hover .module-body,
.inquiry-panel:hover .module-body {
  position: absolute; left: 0; right: 0; bottom: 100%; z-index: 1000;
  background: var(--panel); border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0; box-shadow: 0 14px 30px rgba(20,30,50,.20);
  padding: 8px 10px 10px;
}

/* 树节点 */
.tree-row {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px;
  cursor: pointer; user-select: none; border: 1px solid transparent;
}
.tree-row:hover { background: var(--bg); }
.tree-row.selected { background: var(--primary-soft); border-color: #cfe0ff; }
.tree-row.dragover { background: #fff4d6; border-color: #f0c868; }
.tree-row .caret {
  width: 28px; text-align: center; color: var(--muted); cursor: pointer; flex-shrink: 0;
  transition: transform .15s ease; user-select: none; font-size: 1.25em; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; height: 1.2em;
  transform: scaleX(1.5); /* 箭头横向拉长，长宽比更扁更长 */
}
.tree-row .caret.open { transform: rotate(90deg) scaleX(1.5); }
.tree-row .caret.caret-leaf { cursor: default; } /* 无子分支的占位箭头：保留宽度但对齐，不响应点击 */
.tree-row .icon { width: 18px; text-align: center; flex-shrink: 0; }
.tree-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 行最右的扩展按钮：hover 行时出现，hover 扩展按钮弹出功能菜单 */
.tree-row .row-more {
  display: none; width: 20px; flex-shrink: 0; text-align: center; cursor: pointer; user-select: none;
  font-size: 14px; line-height: 1; color: var(--muted); border-radius: 4px;
}
.tree-row:hover .row-more { display: inline-flex; align-items: center; justify-content: center; }
.tree-row .row-more:hover { background: #e3e8ef; color: var(--fg); }
/* 功能按钮弹出层：默认隐藏，hover 扩展按钮（或菜单本身）时显示 */
.tree-row .row-actions {
  display: none; gap: 4px;
  position: absolute; right: 8px; top: calc(100% - 4px); z-index: 30; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 6px; box-shadow: 0 6px 16px rgba(30,50,90,0.15);
}
.tree-row .row-more:hover + .row-actions, .tree-row .row-actions:hover { display: flex; }
.tree-row .row-actions.show { display: flex; } /* 事件委托控制：⋮→菜单 间隙不闪没 */
.tree-row .row-actions button {
  border: none; background: transparent; cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 4px; color: var(--muted);
}
.tree-row .row-actions button:hover { background: #e3e8ef; }

/* 对话区 */
.chat-area { flex: 7 1 0%; display: flex; flex-direction: column; min-width: 0; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-icon { font-size: 46px; margin-bottom: 10px; }
.empty-sub { font-size: 12px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.chat-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-tag { font-size: 11px; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 10px; }
.chat-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-head-actions select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; background: var(--panel); }

.messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: 90%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 11px 14px; border-radius: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant .bubble { background: var(--panel); color: var(--text); border-bottom-left-radius: 3px; }
.msg-meta { font-size: 11px; color: var(--muted); margin: 4px 2px 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
/* meta 区每个显示模块（usage/金额/通道/标志/时间/轮次/分叉点/操作）为整体：行宽不够时按模块整体换行，模块内不拆字 */
.msg-meta > * { flex-shrink: 0; white-space: nowrap; max-width: 100%; }
.msg-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.msg-actions button { white-space: nowrap; }
.hit-badge { color: var(--ok); border: 1px solid #bfe6cd; background: #ecfaf0; padding: 0 6px; border-radius: 8px; }
.msg-actions button {
  border: none; background: transparent; color: var(--primary); cursor: pointer; font-size: 11px; padding: 1px 5px; border-radius: 4px;
}
.usage { color: var(--muted); background: var(--bg); border: 1px solid var(--border); padding: 0 6px; border-radius: 8px; white-space: nowrap; }
/* token 统计随「通道 + 官方峰谷时段」着色（鲜色版，与气泡同系）：官方 峰橙/谷青绿；GO 峰柠黄/谷蓝 */
.usage.peak { color: #ea580c; background: #fff7ed; border-color: rgba(249,115,22,.5); }   /* 官方·峰·橙子橙 */
.usage.valley { color: #0d9488; background: #f0fdfa; border-color: rgba(13,148,136,.5); } /* 官方·谷·青绿 */
.usage.go.peak { color: #d97706; background: #fefce8; border-color: rgba(250,204,21,.6); }/* GO·峰·柠黄 */
.usage.go.valley { color: #2563eb; background: #eff6ff; border-color: rgba(37,99,235,.5); }/* GO·谷·蓝 */
/* 回答来源标志：已联网/未联网、思考/未思考（有=黄、无=灰） */
.msg-flag { font-size: 11px; padding: 0 6px; border-radius: 8px; white-space: nowrap; }
.msg-flag.yes { color: #b45309; background: #fef3c7; border: 1px solid #f59e0b; }
.msg-flag.no { color: var(--muted); background: var(--bg); border: 1px solid var(--border); }
/* 每轮提问/回复时间（精确到秒） */
.msg-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-stats {
  padding: 8px 16px; font-size: 12px; color: var(--text); background: var(--primary-soft);
  border-bottom: 1px solid var(--border); display: flex; gap: 14px; flex-wrap: wrap;
}
.chat-stats b { color: var(--primary); font-weight: 600; }
/* 金额显示：按「通道 + 官方峰谷时段」着色 —— 官方通道 峰橙/谷青绿，GO 通道 峰柠黄/谷蓝 */
.cost-badge { font-weight: 600; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border); white-space: nowrap; }
.chan-tag { font-weight: 600; font-size: 11px; padding: 0 6px; border-radius: 8px; white-space: nowrap; cursor: help; color: #475569; background: #f1f5f9; border: 1px solid #cbd5e1; } /* 新增通道默认中性灰 */
.chan-tag.ch-go { color: #854d0e; background: #fef9c3; border: 1px solid #fde047; } /* GO 柠黄 */
.chan-tag.ch-ds { color: #166534; background: #ecfdf5; border: 1px solid #a7f3d0; } /* 官方 绿 */
.cost-badge.peak, .chat-total-cost.peak { color: #ea580c; }            /* 官方·峰·橙子橙 */
.cost-badge.valley, .chat-total-cost.valley { color: #0d9488; }        /* 官方·谷·青绿 */
.cost-badge.go.peak, .chat-total-cost.go.peak { color: #d97706; }      /* GO·峰·柠黄 */
.cost-badge.go.valley, .chat-total-cost.go.valley { color: #2563eb; }  /* GO·谷·蓝 */
.chat-total-cost { font-size: 12px; font-weight: 600; white-space: nowrap; }
/* 对话栏精简布局：token 统计（左）与 对话名称/分支标签/模型/分支切换（右）两个模块【整体】考虑——
   一行放得下就并排；放不下则整个右侧模块换到下一行（一人一行）；某一模块自身还放不下时其内部再换行（再加）。 */
.stats-row { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--primary-soft); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.stats-row .chat-stats { flex: 1 1 auto; min-width: 280px; padding: 0; background: transparent; border: none; line-height: 1.5; }
/* 右侧模块：不收缩、整块换行；max-width:100% 保证绝不超出容器 → 不产生横向滚动条，超宽时内部换行逐行加 */
.stats-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; min-width: 0; max-width: 100%; }
/* 对话名称：一行放不下就换行逐行加（不截断省略号、不出现滚动条） */
.stats-right .chat-name { font-weight: 600; font-size: 14px; max-width: 100%; white-space: normal; word-break: break-word; }
.stats-right select { border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; background: var(--panel); max-width: 170px; }
.msg-actions button:hover { background: var(--primary-soft); }
/* 回退分叉点：在每条消息处明确「从此处开新分支」的位点 */
.point-tag {
  color: var(--primary); background: var(--primary-soft); border: 1px dashed #b9d2ff;
  padding: 0 6px; border-radius: 8px; font-size: 11px;
}
.rollback-btn { font-weight: 600; border: 1px solid #b9d2ff !important; }
/* 气泡正下方的一键复制栏：始终可见，青色系区分于「开新分支」的蓝色 */
.copy-bar { display: flex; padding: 3px 0 4px 2px; }
.copy-msg-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  border-radius: 6px; font-size: 11px; padding: 1px 10px; cursor: pointer; line-height: 1.5;
}
.copy-msg-btn:hover { color: #0b6e6e; border-color: #b7dede; background: #ecfdf5; }
/* 本轮实际使用联网搜索的标记（气泡底部，青色系） */
.searched-tag {
  font-size: 11px; color: #047857; background: #ecfdf5; border: 1px solid #a7f3d0;
  padding: 0 8px; border-radius: 6px; line-height: 1.5; align-self: center; white-space: nowrap;
}
.branch-row { font-size: 13px; }
.branch-row .icon { opacity: 0.85; }

/* 对话栏（2026-08-25 十一轮）：输入框在上，功能区按钮横铺在下（原右列竖排全部移到下方，从左到右排列） */
.composer { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer-input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-family: inherit; font-size: 14px; line-height: 1.5; outline: none; overflow-y: auto; max-height: calc(20 * 1.5em + 20px);
}
.composer-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* 输入框边框 = 当前提问色（2026-08-31 用户定稿）：框的颜色与提问气泡一致（官方 峰橙/谷青绿；GO 峰柠黄/谷蓝），
   框内保持默认白底黑字、不染色；发送后锁定发送时刻颜色，重新输入恢复跟随时段。
   通道判定跟随「本对话最近一次实际回答的通道」（app.js lastAssistantChannel），先官方后 GO 会自动换色 */
.composer-input.peak { border-color: var(--pv-official-peak-q); }        /* 官方峰橙 */
.composer-input.valley { border-color: var(--pv-official-valley-q); }      /* 官方谷绿 */
.composer-input.go-mode.peak { border-color: var(--pv-go-peak-q); }/* GO峰黄 */
.composer-input.go-mode.valley { border-color: var(--pv-go-valley-q); } /* GO谷青 */
.composer-input.peak:focus { border-color: var(--pv-official-peak-q); box-shadow: 0 0 0 3px rgba(255,153,28,.22); }
.composer-input.valley:focus { border-color: var(--pv-official-valley-q); box-shadow: 0 0 0 3px rgba(32,187,32,.2); }
.composer-input.go-mode.peak:focus { border-color: var(--pv-go-peak-q); box-shadow: 0 0 0 3px rgba(237,225,1,.25); }
.composer-input.go-mode.valley:focus { border-color: var(--pv-go-valley-q); box-shadow: 0 0 0 3px rgba(3,211,211,.22); }
/* 消息气泡峰谷着色（2026-08-31 用户标准 RGB 定稿）：官方 峰#FF991C/谷#20BB20；GO 峰#EDE101/谷#03D3D3。
   提问=纯色，回答=同色系浅色（见 :root --pv-* 变量，可在「设置 → 峰谷配色」里改）。
   黄/青底用深字保证可读 */
.msg.user.go .bubble { background: #1f7a5c; }                        /* GO 旧消息兜底（无 period 标记）墨绿 */
.msg.assistant.go .bubble { background: var(--pv-legacy-go-a); color: var(--pv-legacy-go-fg, #000); }  /* GO 旧消息兜底：底色/字色随主题 */
/* 2026-09-16 用户定稿：文字色「问=白字、答=黑字」；
   2026-09-16 晚补充：答色随主题自动适配 —— 回答底色 = 提问色按淡化程度向【当前主题面板色】混合
   （明亮=浅底黑字；黑暗/自定义深色面板=深底浅字），字色变量 -fg 由 JS 按实际底色亮度算出，此处 #000 仅为兜底 */
.msg.user.peak .bubble { background: var(--pv-official-peak-q); color: #fff; }         /* 官方·峰·提问橙 白字 */
.msg.user.valley .bubble { background: var(--pv-official-valley-q); color: #fff; }      /* 官方·谷·提问绿 白字 */
.msg.assistant.peak .bubble { background: var(--pv-official-peak-a); color: var(--pv-official-peak-fg, #000); }        /* 官方·峰·回答 */
.msg.assistant.valley .bubble { background: var(--pv-official-valley-a); color: var(--pv-official-valley-fg, #000); }  /* 官方·谷·回答 */
.msg.user.go.peak .bubble { background: var(--pv-go-peak-q); color: #fff; }         /* GO·峰·提问黄 白字 */
.msg.user.go.valley .bubble { background: var(--pv-go-valley-q); color: #fff; }     /* GO·谷·提问青 白字 */
.msg.assistant.go.peak .bubble { background: var(--pv-go-peak-a); color: var(--pv-go-peak-fg, #000); }                 /* GO·峰·回答 */
.msg.assistant.go.valley .bubble { background: var(--pv-go-valley-a); color: var(--pv-go-valley-fg, #000); }           /* GO·谷·回答 */
/* 功能区按钮行：输入框下方横铺，从左到右，自动换行；整体右对齐（十二轮） */
.composer-func { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; flex-shrink: 0; width: auto; justify-content: flex-end; }
/* 智能体权限组：左对齐（margin-right:auto 顶到最左），权限勾选内联；2026-08-30 起开关按钮已取消 */
.agent-group { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; flex-wrap: wrap; }
.agent-perms { display: inline-flex; align-items: center; gap: 2px; }
.agent-perms-title { font-size: 11px; font-weight: 600; color: var(--muted); margin-right: 4px; white-space: nowrap; user-select: none; }
.agent-perm { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; padding: 3px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); user-select: none; white-space: nowrap; }
.agent-perm:hover { background: #eef4ff; border-color: #c9d9f5; }
.agent-perm input { margin: 0; accent-color: #1e4fa3; }
.agent-perm.on { color: #1e4fa3; border-color: #b8cdf5; background: #e3ecfb; }
.agent-perm.off { opacity: .55; }
.composer-func .composer-func-btn { font-size: 12px; padding: 6px 10px; min-height: 30px; border-radius: 6px; white-space: nowrap; flex: 0 0 auto; }
/* 「🔒 加密」按钮缩小（不再需要撑满整列） */
.composer-func .enc-toggle { flex: 0 0 auto; min-height: 30px; }
.composer-func .btn-send { min-height: 36px; padding: 8px 22px; font-size: 14px; }
/* 兼容旧布局：composerVertical=false 时回退为「输入框在左、按钮右列竖排」（ui-config 可配） */
body.composer-vertical .composer { flex-direction: row; align-items: stretch; }
body.composer-vertical .composer-func { flex-direction: column; align-items: stretch; width: 100px; }
body.composer-vertical .composer-func .btn-send { min-height: 42px; }
.btn-toggle {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 12px; padding: 5px 10px; user-select: none;
}
.btn-toggle:hover { background: var(--bg); }
.btn-toggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* GO 通道下思考按钮锁定：置灰 + 虚线 + 禁用光标，明确告知「本通道无法关闭思考」 */
.composer-func-btn.locked, #deepBtn.locked {
  opacity: .6; cursor: not-allowed; background: var(--bg); color: var(--muted);
  border-style: dashed; border-color: var(--border);
}
.composer-func-btn.locked:hover, #deepBtn.locked:hover { background: var(--bg); }
/* 左侧目录栏 · 询问栏（全局唯一）：置底固定（十二轮：tree 置顶，三面板底部 回收→速记→询问）；
   高度由 CSS 变量控制（默认 5 条/hover 20 条，ui-config 可改），hover 展开，超出滚动；单击某条放大独占 */
.inquiry-panel {
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  padding: 6px 8px; margin: 0 10px 8px 0; display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0; /* 置底固定，不随目录树滚动 */
}
.inquiry-head { font-size: 12px; color: var(--muted); font-weight: 600; }
.inquiry-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.inquiry-empty { color: var(--muted); font-size: 12px; padding: 6px 4px; }
.inquiry-item { display: flex; gap: 8px; padding: 5px 4px; border-bottom: 1px dashed var(--border); cursor: pointer; border-radius: 4px; }
.inquiry-item:hover { background: var(--panel); }
.inquiry-item:last-child { border-bottom: none; }
.iq-num { color: var(--muted); font-size: 12px; flex-shrink: 0; min-width: 18px; text-align: right; }
.iq-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; flex: 1; max-height: 2.6em; overflow: hidden; }
/* 独占放大详情态 */
.inquiry-detail { display: flex; flex-direction: column; gap: 8px; }
.iq-detail-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; max-height: calc(15 * 1.6em + 16px); overflow-y: auto; }
/* 详情态操作区：跳转按钮右对齐（2026-08-25 八轮）；点击详情区任意位置返回列表 */
.iq-detail-actions { display: flex; gap: 8px; justify-content: flex-end; }
.iq-detail-actions button { flex: 0 0 auto; }
.inquiry-detail { cursor: pointer; }
.inquiry-detail .iq-detail-actions { cursor: default; }
/* 输入行：文本框 + 发送 */
.composer-input-row { display: flex; gap: 10px; align-items: flex-end; }
.btn-send { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 16px 22px; min-height: 56px; line-height: 1.3; cursor: pointer; font-size: 15px; }
.btn-send:hover { background: #245ad6; }
/* 「■ 停止」态（2026-08-31）：回复进行中且输入框为空时，发送按钮变红色停止按钮 */
.btn-send.stopping { background: #f97316; color: #111; border-color: #f97316; }
.btn-send.stopping:hover { background: #ea6a00; }
/* 顶栏「🌐 联网」按钮激活态 */
.web-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-send:disabled { opacity: 0.6; cursor: default; }
.chat-status { padding: 0 16px 10px; color: var(--muted); font-size: 12px; min-height: 16px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20,30,50,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-card { width: 420px; background: var(--panel); border-radius: 12px; padding: 24px; box-shadow: 0 12px 40px rgba(30,50,90,0.2); }
/* 设置弹窗：放宽到浏览器窗口 70%，避免内容过窄 */
/* 设置弹窗：固定宽高 —— 切换页签时窗口尺寸恒定，不再「一会大一会小」（内容超出时由 .settings-scroll 内部滚动） */
#settingsModal .modal-card { width: 74vw; max-width: 1100px; height: 88vh; max-height: 88vh; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 0; }
/* 常驻标题栏 + 右上角 ✕：所有页签都可见（原来唯一「关闭」在「账户」页签里，别的页签关不掉） */
.settings-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 8px; border-bottom: 1px solid var(--border); }
.settings-head .settings-title { font-weight: 600; font-size: 15px; }
.settings-x { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; flex: 0 0 auto; padding: 0; }
.settings-x:hover { color: var(--text); border-color: var(--text); }
/* 设置弹窗：左侧标签导航 + 右侧可滚动内容 */
.settings-tabs { flex-shrink: 0; display: flex; gap: 2px; flex-wrap: wrap; padding: 12px 20px 0; border-bottom: 1px solid var(--border); }
.settings-tab { padding: 8px 12px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; user-select: none; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-scroll { flex: 1; overflow-y: auto; padding: 18px 24px 24px; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
/* 风格 / 峰谷配色 表单小部件 */
.theme-opts { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.theme-opt { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; }
.theme-opt input { accent-color: var(--primary); }
.theme-opt.active { border-color: var(--primary); background: var(--primary-soft); }
.custom-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 10px 0; }
.custom-colors label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 0; }
.custom-colors input[type=color] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.pv-grid { display: flex; flex-direction: column; gap: 14px; margin: 10px 0; }
.pv-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); }
.pv-item.pv-channel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-item.pv-channel > .pv-name { grid-column: 1 / -1; }
.pv-item .pv-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.pv-period { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.pv-period-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.pv-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 6px 0; }
.pv-row span { width: 42px; }
.pv-row input[type=color] { width: 46px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.pv-preview { display: flex; gap: 8px; margin-top: 10px; }
.pv-preview .b-q, .pv-preview .b-a { flex: 1; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.pv-preview .b-q { color: #fff; }
.pv-preview .b-a { color: #000; }
/* 回答色淡化程度（一个拖动条决定所有通道「答 vs 问」的底色差异） */
.pv-lighten { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.pv-lighten > label { font-size: 12px; font-weight: 600; color: var(--text); }
.pv-lighten-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.pv-lighten-row input[type=range] { flex: 1; accent-color: var(--primary); cursor: pointer; }
.pv-lighten-val { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; color: var(--text); font-weight: 600; }
.pv-hint { font-size: 11px; color: var(--muted); margin-top: 6px; }
.inline-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.inline-row select, .inline-row input[type=number] { width: auto; min-width: 120px; }
.modal-card h3 { margin: 0 0 8px; }
.modal-sub { color: var(--muted); font-size: 12px; line-height: 1.5; }
.cache-usage { color: var(--muted); font-size: 12px; margin-top: 6px; }
/* 全局提示浮层：叠加在当前页面之上，显示在触发按钮旁边，几秒后自动消失 */
.toast {
  position: fixed; z-index: 9999; max-width: 360px; max-height: 70vh; overflow-y: auto; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; line-height: 1.5; color: #fff; pointer-events: none;
  opacity: 0; transform: translateY(4px); transition: opacity .18s ease, transform .18s ease;
  box-shadow: 0 6px 18px rgba(20,40,80,.25); white-space: normal;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast.info { background: #2563eb; }
.modal-card label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12px; }
.modal-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; outline: none; }
.modal-card textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; outline: none; resize: vertical; font-family: inherit; line-height: 1.5; }
.modal-card textarea:focus, .modal-card input:focus, .modal-card select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.opt-hint { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-msg { margin-top: 12px; font-size: 13px; min-height: 16px; }
.modal-msg.ok { color: var(--ok); }
.modal-msg.err { color: var(--danger); }

/* 导出网页结果区 */
.export-result { margin-top: 12px; font-size: 13px; }
.export-result code { background: var(--panel); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.export-summary { color: var(--muted); margin-bottom: 8px; }
.export-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.export-list li { padding: 7px 10px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.export-list li:last-child { border-bottom: none; }
.export-list a { color: var(--primary); font-weight: 600; text-decoration: none; }
.export-list a:hover { text-decoration: underline; }
.export-branch { color: var(--muted); font-size: 12px; }
.export-empty { color: var(--muted); }
.export-tip { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* 移动节点弹窗 */
.move-list { max-height: 320px; overflow: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.move-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 14px; }
.move-item:last-child { border-bottom: none; }
.move-item:hover:not(.disabled) { background: #eef3fb; }
.move-item.disabled { color: var(--muted); cursor: not-allowed; opacity: 0.55; }
.move-item .mi-icon { font-size: 15px; }
.move-item .mi-tag { margin-left: auto; font-size: 11px; color: var(--muted); }

/* 标记颜色：10 色（!important 覆盖 hover/选中态）。改变文字色与底色 */
.tree-row.tag-0 { background: #fde9e7 !important; color: #b42318 !important; }
.tree-row.tag-1 { background: #fef0e6 !important; color: #b54708 !important; }
.tree-row.tag-2 { background: #fdf3d3 !important; color: #8a6100 !important; }
.tree-row.tag-3 { background: #e4f6ea !important; color: #1f7a3d !important; }
.tree-row.tag-4 { background: #e0f5f5 !important; color: #0b6e6e !important; }
.tree-row.tag-5 { background: #e7efff !important; color: #1d4ed8 !important; }
.tree-row.tag-6 { background: #e8e9fd !important; color: #4338ca !important; }
.tree-row.tag-7 { background: #f0e9fd !important; color: #6d28d9 !important; }
.tree-row.tag-8 { background: #fde7f0 !important; color: #be185d !important; }
.tree-row.tag-9 { background: #eceff3 !important; color: #475467 !important; }

/* 第几轮回复 / 提问 */
.round-tag { color: var(--muted); border: 1px solid var(--border); background: var(--bg); padding: 0 7px; border-radius: 8px; white-space: nowrap; }

/* 设置页目录选择行 */
.dir-row { display: flex; gap: 8px; }
.dir-row input { flex: 1; }
.dir-row .btn-sm { flex-shrink: 0; }
/* 设置页修改密码行 */
.pwd-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.pwd-row label { flex-shrink: 0; width: 76px; color: var(--muted); font-size: 13px; }
.pwd-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; }
.pwd-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 历史提问快捷跳转条：锁定在左侧列表下方，跟随侧栏宽度 */
.jump-bar {
  flex: 0 0 auto; margin: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(20,30,50,0.06);
  /* 询问栏字号固定 12px（对话正文的约 86%） */
  font-size: 12px;
  /* 约显示 10 条（每条约 2.7em + 间距 6px），超出可拖动滚动 */
  max-height: calc(10 * 2.7em + 9 * 6px + 16px);
  overflow-y: auto; scrollbar-width: thin;
}
.jump-bar::-webkit-scrollbar { width: 6px; }
.jump-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.jb-arrow { display: none; }
.jb-strip {
  display: flex; flex-direction: column; gap: 6px; padding: 2px;
}
.jb-chip {
  text-align: left; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 1em; padding: 0 9px; line-height: 1.35;
  /* 固定 2 行：高度锁定为 2 行，超出截断 */
  height: 2.7em; overflow: hidden; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.jb-chip:hover { background: var(--primary-soft); border-color: #b9d2ff; color: var(--primary); }
.jb-chip:active { transform: translateY(1px); }

/* 跳转定位时的高亮 */
.msg-flash { outline: 2px solid var(--primary); outline-offset: 2px; background: #fffbe9; }

/* 标记色板弹窗 */
.tag-swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.tag-swatch {
  width: 56px; height: 38px; border-radius: 8px; border: 2px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.tag-swatch:hover { filter: brightness(0.97); }
.tag-swatch.selected { border-color: #1f2733; box-shadow: 0 0 0 2px rgba(0,0,0,0.15); }

/* 可点击的目录输入框：点击即打开/选择，无需按钮 */
input#exportDirInput, input#importDirInput, input#dataDirInput { cursor: pointer; background: var(--panel); }
input#exportDirInput:hover, input#importDirInput:hover, input#dataDirInput:hover { border-color: var(--primary); }
input#exportDirInput::-webkit-input-placeholder, input#importDirInput::-webkit-input-placeholder { color: #9aa0a6; }
/* 思考过程折叠区 */
.reasoning { margin: 0 0 8px; border: 1px dashed var(--border); border-radius: 8px; background: var(--panel); }
.reasoning > summary { cursor: pointer; padding: 6px 10px; font-size: 12px; color: var(--muted); user-select: none; }
.reasoning-body { padding: 0 10px 8px; font-size: 13px; color: var(--text); white-space: pre-wrap; word-break: break-word; border-top: 1px dashed var(--border); margin-top: 2px; padding-top: 8px; }

/* 保存按钮 + 未保存红点 */
.save-btn { display: inline-flex; align-items: center; gap: 6px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: #c4ccd6; box-shadow: 0 0 0 0 rgba(0,0,0,0); transition: background .15s ease; }
.save-btn.dirty .save-dot { background: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,0.18); }
.save-btn.dirty { border-color: #f3c6c8; color: var(--danger); }

/* 速记区（三面板之二，置顶）：初始若干行，鼠标悬停展开到更多行（ui-config 可改），超出滚动 */
.scratch-wrap { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); margin: 0 10px 8px 0; flex-shrink: 0; }
.scratch-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.scratch-hint { color: #9aa0a6; font-weight: 400; margin-left: 6px; }
.scratch-box {
  width: 100%; min-height: 0; max-height: 400px; resize: vertical; overflow-y: auto;
  transition: height .15s ease; /* hover 展开/收起平滑 */
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13px;
  line-height: 1.5; outline: none; background: var(--panel); color: var(--text);
}
.scratch-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 提示词区输入区：默认 5 行，鼠标移过去展开到 15 行，更多内容框内滚动（高度由 JS 按行高算） */
.brief-box { resize: none; max-height: 420px; }
.brief-box:focus, .prompt-box:focus { border-color: #f0a020; box-shadow: 0 0 0 3px rgba(240,160,32,0.16); }

/* 工具条（回退/前进靠左，打开/保存靠右）：提示词区一条、速记区一条，随速记区整体一起移动 */
.scratch-actions { display: flex; align-items: center; gap: 6px; margin: 6px 0 8px; flex-wrap: wrap; row-gap: 4px; }
.scratch-actions .act-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.scratch-actions .act-right { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.scratch-actions .btn-sm { padding: 3px 8px; font-size: 12px; line-height: 1.5; }
.scratch-actions .btn-sm:disabled { opacity: .42; cursor: not-allowed; background: var(--panel); }
.scratch-actions .btn-sm:not(:disabled):hover { background: var(--bg); }
/* 提示词「发送」主按钮：蓝色实心（优先级高于上方通用按钮样式） */
.scratch-actions #promptSendBtn { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.scratch-actions #promptSendBtn:not(:disabled):hover { background: #245ad6; color: #fff; }
.scratch-hist-info { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.scratch-hist-info.saved { color: #1a9e4b; }
.scratch-hist-info.unsaved { color: #b07a10; }
.scratch-actions-note { margin-bottom: 0; }

/* 提示词区顶栏：左边「提示词区」，右边当前打开的提示词文件名 */
.prompt-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.prompt-title { font-size: 12px; color: var(--muted); }
.prompt-file {
  margin-left: auto; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: #6b7280; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 8px;
}
.prompt-file.named { color: #1d4ed8; border-color: #c7d7fe; background: #eef3ff; }

/* 「打开提示词」下拉：列出保存过的各个版本 */
.prompt-file-menu {
  position: fixed; z-index: 3000; min-width: 236px; max-width: 320px; max-height: 320px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .16); padding: 4px;
}
.prompt-file-menu .pf-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; font-size: 12px; color: var(--text); font-family: inherit;
}
.prompt-file-menu .pf-item:hover { background: var(--bg); }
.prompt-file-menu .pf-item.sel { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.prompt-file-menu .pf-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-file-menu .pf-meta { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
.prompt-file-menu .pf-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.prompt-file-menu .pf-empty { padding: 8px; font-size: 11px; color: var(--muted); }

/* 对话页内的帮助按钮（模型旁） */
.help-inline { padding: 4px 9px; font-size: 12px; }

/* 帮助弹窗 */
#helpModal .modal-card.help-card { width: 76vw; max-width: 960px; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; }
.help-body { overflow-y: auto; padding-right: 6px; margin-top: 10px; }
.help-body h4 { margin: 16px 0 6px; font-size: 14px; color: var(--primary); }
.help-body h4:first-child { margin-top: 0; }
.help-body p, .help-body li { font-size: 13px; line-height: 1.7; color: var(--text); }
.help-body ul { margin: 4px 0 4px 18px; padding: 0; }
.help-body code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 12px; word-break: break-all; }
.help-example { background: #f3f7ff; border: 1px solid #d8e6ff; border-radius: 8px; padding: 10px 12px; color: #2a4a7a; }
.help-example code { background: #fff; }
.help-body .modal-actions, .help-card .modal-actions { margin-top: 14px; }

/* 顶栏默认模型选择器：点名称出弹层（思考模式 / 推理速度 / 对话缓存） */
.model-select-wrap { position: relative; }
.model-name-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 8px 0 0 8px; background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px;
}
.model-name-btn:hover { border-color: var(--primary); }
/* 2026-08-31 双区交互：右箭头独立按钮 = 直接选模型（连体） */
.model-arrow-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; padding: 5px 0;
  border: 1px solid var(--border);   border-left: none; border-radius: 0 8px 8px 0; background: var(--panel);
  color: var(--text-soft); cursor: pointer; font-size: 12px;
}
.model-arrow-btn:hover { color: var(--primary); border-color: var(--primary); }
.quick-model-pop { min-width: 280px; }
.qm-list { max-height: 320px; overflow-y: auto; }
.qm-group { font-size: 11px; color: var(--text-soft); margin: 6px 0 2px; }
.qm-item { padding: 5px 8px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.qm-item:hover { background: #eef4ff; }
.qm-item.sel { background: #e0ecff; color: var(--primary); font-weight: 600; }
.model-popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; width: 280px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(20,40,80,.16);
  padding: 12px 14px;
}
.model-popover .mp-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; color: var(--primary); }
.model-popover .mp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.model-popover .mp-row label { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.model-popover .mp-row select, .model-popover .mp-row input { flex: 1; min-width: 0; padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.model-popover .mp-actions { margin-top: 10px; display: flex; justify-content: flex-end; }
.model-popover .mp-hint { margin-top: 8px; font-size: 11px; color: var(--text-soft); line-height: 1.5; }
.model-popover .mp-websearch { flex-wrap: wrap; align-items: flex-start; }
.model-popover .mp-websearch > label:first-child { flex: 1 0 100%; margin-bottom: 2px; }
.model-popover .mp-websearch .switch { display: flex; align-items: flex-start; gap: 8px; font-size: 11px; color: var(--text-soft); line-height: 1.5; }
.model-popover .mp-websearch .switch input { margin-top: 2px; flex: 0 0 auto; }
.model-popover .mp-websearch .switch-label { flex: 1; min-width: 0; }

/* 回收区（删除的目录/分支暂存，可恢复）：置底在速记之上；高度由 CSS 变量控制（默认 3 条/max 15 条，ui-config 可改） */
/* 对话回收区：并入「对话目录模块」最底部（2026-08-26 七轮）；与智能体回收区同款交互 —— 点标题收起/展开列表 */
.trash-area { margin-top: 8px; border-top: 1px dashed #d7dee8; padding: 8px 2px 2px; flex-shrink: 0; }
.trash-head { font-size: 12px; font-weight: 600; color: var(--text-soft); display: flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 6px; padding: 2px; }
.trash-head:hover { background: #e6eefb; }
.trash-caret { transition: transform .15s ease; font-size: 10px; color: var(--muted); }
.trash-area.open .trash-caret { transform: rotate(90deg); }
.trash-list { display: none; margin-top: 6px; flex-direction: column; gap: 4px; max-height: var(--trash-h, 110px); overflow-y: auto; }
.trash-area.open .trash-list { display: flex; }
.trash-item, .trash-item-hint { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; background: #f0f7ff; border: 1px solid #d7e6fb; flex-wrap: wrap; }
.trash-item .ti-icon { font-size: 14px; }
/* 对话回收区条目 = 智能体本机回收区同款（ar-item 浅蓝小条），恢复/删除小按钮 hover 显示（六轮） */
.trash-list .ar-item { background: rgba(255,255,255,.7); }
.trash-list .ar-act { display: none; background: none; border: none; cursor: pointer; font-size: 12px; color: #1e4fa3; padding: 0 4px; border-radius: 4px; flex-shrink: 0; }
.trash-list .ar-item:hover .ar-act { display: inline-block; }
.trash-list .ar-act:hover { background: #dbe7ff; }
.trash-list .ar-item .ti-name { flex: 1; min-width: 0; font-size: 11px; color: #3b66b0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-list .ar-item span:first-child { font-size: 12px; }
.trash-item .ti-name { flex: 1; min-width: 0; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-item .trash-del { color: #dc2626; border-color: #f3c6c6; }
.trash-item .trash-del:hover { background: #fee2e2; }
.trash-empty { font-size: 12px; color: #3b66b0; padding: 5px 6px; border-radius: 6px; background: #f0f7ff; border: 1px solid #d7e6fb; display: none; }
/* 删除进行中：按下立即变灰（服务器确认后进回收站，不再二次确认，2026-09-08） */
.tree-row.deleting { opacity: .4; filter: grayscale(100%); pointer-events: none; }
.tree-row.deleting .label { text-decoration: line-through; }
.trash-area.open .trash-empty { display: block; }

/* 智能体工作区模块（2026-08-26 三轮）：浅蓝底卡片，紧跟「对话目录模块」下方；
   目录树完全复用对话目录的 .tree-row 体系（同 padding/gap/hover/选中/caret/缩进），仅 hover/选中改浅蓝系区分 */
.agent-panel {
  flex-shrink: 0; padding: 8px 10px 10px;
  background: #eef4ff; border: 1px solid #c9d9f5; border-radius: 10px;
}
.agent-head { font-size: 12px; font-weight: 600; color: #1e4fa3; display: flex; align-items: center; gap: 6px; }
.agent-ws-status { font-weight: 400; font-size: 11px; color: #5b7bb8; opacity: .9; }
.agent-ws-status.err { color: #c2410c; }
.agent-ws-row { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px; flex-wrap: wrap; }
.agent-ws-path { flex: 1; min-width: 0; font-size: 10px; color: #3b66b0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; }
/* 树容器：不再单独限高，hover 模块时由 .module-body 浮层统一展开滚动（2026-08-31 晚） */
.agent-tree { margin-top: 4px; }
.agent-tree-empty { padding: 10px 4px; color: #7a93c4; font-size: 11px; line-height: 1.6; }
/* 行：完全继承 .tree-row（对话目录同款：flex/gap 6px/padding 6px 8px/圆角/caret 22px/icon 18px/label 省略号），
   仅 hover 与 selected 换成浅蓝系（对话目录是 --bg / --primary-soft，这里用同明度的蓝） */
.agent-panel .tree-row:hover { background: #e3ecfb; }
.agent-panel .tree-row.selected { background: #d3e2ff; border-color: #a9c4f2; }
/* 文件大小小字：紧跟 label，右对齐不挤压名称 */
.agent-file-size { font-size: 10px; color: #7a93c4; flex-shrink: 0; margin-left: 4px; }
/* 弹出操作菜单：白底（浅蓝面板内更清晰） */
.agent-panel .tree-row .row-actions { background: #ffffff; }
/* 本机回收区：默认不显示，模块浮层展开（.module-body）时才显示（2026-08-31 晚） */
.agent-foot, .agent-recycle-list { display: none; }
.module-body .agent-foot { display: flex; }
.module-body .agent-recycle-list { display: flex; }
.agent-recycle-info { font-size: 11px; color: #5b7bb8; }
.agent-recycle-list { margin-top: 4px; max-height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.agent-recycle-list .ar-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #3b66b0; padding: 3px 5px; border-radius: 5px; background: rgba(255,255,255,.7); }
/* 智能体消息气泡边饰 */
/* 智能体消息左缘边饰已移除（2026-08-27：橙/蓝边与 GO 峰谷配色冲突，用户反馈"发的绿底橙边、回的绿底蓝边"突兀） */

/* 我的 token 明细表 */
.token-log { margin-top: 8px; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.token-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.token-table th, .token-table td { border-bottom: 1px solid var(--border); padding: 5px 7px; text-align: right; white-space: nowrap; }
.token-table th { position: sticky; top: 0; background: var(--bg); color: var(--text-soft); font-weight: 600; }
.token-table td:first-child, .token-table th:first-child { text-align: left; }
.token-empty { font-size: 12px; color: var(--text-soft); padding: 10px; }

/* 分支定位高亮（开分支后当前页列表自动定位） */
.branch-locate { animation: branchLocate 1.6s ease; }
@keyframes branchLocate {
  0% { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
  100% { background: transparent; box-shadow: none; }
}

/* 敏感信息加密工具条（发送按钮上方） */
.enc-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; flex-wrap: wrap; }
.enc-toggle.active { background: #e8f0ff; border-color: var(--primary); color: var(--primary); }
/* 右侧「标记敏感」小按钮：位于 加密 与 发送 之间，紧凑（与功能区其它小按钮一致高度） */
.composer-func .enc-mark { flex: 0 0 auto; min-height: 30px; font-size: 12px; padding: 6px 8px; }
/* 加密/标记敏感 的说明行：默认隐藏，点按钮才展开，小字不占地方 */
.enc-hint { font-size: 11px; color: var(--muted); line-height: 1.6; padding: 0 16px 8px; }
.enc-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.enc-item .enc-type { font-size: 12px; color: var(--muted); }
.enc-item .enc-val { font-size: 15px; margin-top: 4px; word-break: break-all; }
.enc-item .enc-val b { color: #c0392b; }
.enc-method-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.enc-method-row label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.enc-method-row select, .enc-method-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.enc-method-row select:focus, .enc-method-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
#encModal .modal-card { width: 460px; }
.enc-restored { background: #fff3cd; border-bottom: 1px dotted #d39e00; cursor: help; }
/* 敏感信息检测提示（输入栏上方，开启加密时显示） */
.enc-detect { padding: 4px 16px 0; font-size: 12px; color: #b45309; }
/* 敏感信息加密管理窗口（可拖动浮层） */
.enc-win {
  position: fixed; top: 120px; left: 50%; transform: translateX(-50%); z-index: 400;
  width: min(720px, 92vw); max-height: 88vh; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.25); display: flex; flex-direction: column;
}
.enc-win-head {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  background: var(--primary-soft); border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0;
  font-weight: 600; cursor: move; user-select: none;
}
.enc-win-close { cursor: pointer; font-size: 14px; color: var(--muted); padding: 2px 6px; }
.enc-win-close:hover { color: #dc2626; }
.enc-win-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.enc-win-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.enc-win-tip { font-size: 11px; color: var(--muted); }
/* 三列表格：最多 30 行滚动，每格 30 字符滚动 */
.enc-table-wrap { overflow-y: auto; max-height: 30em; border: 1px solid var(--border); border-radius: 8px; }
.enc-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.enc-table th, .enc-table td { border-bottom: 1px solid var(--border); padding: 4px 6px; font-size: 12px; text-align: left; vertical-align: middle; }
.enc-table th { position: sticky; top: 0; background: var(--primary-soft); font-weight: 600; }
.enc-table td:nth-child(1) { width: 34%; }
.enc-table td:nth-child(2) { width: 46%; }
.enc-table td:nth-child(3) { width: 20%; }
.enc-cell { max-width: 30ch; overflow-x: auto; white-space: nowrap; }
.enc-op-input { width: 60px; padding: 2px 4px; font-size: 12px; }
.enc-empty { color: var(--muted); text-align: center; padding: 12px; }
/* 运算库（k=原始值，1-99 号） */
.enc-ops-head { font-size: 12px; font-weight: 600; color: var(--muted); }
.enc-ops-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px; max-height: 10em; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.enc-op-item { font-size: 11px; padding: 2px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enc-op-item:hover { background: var(--primary-soft); }
.enc-op-no { display: inline-block; min-width: 22px; color: var(--primary); font-weight: 600; }
.enc-win-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }
/* 加密窗口手动添加行 */
.enc-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.enc-add-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.enc-add-input { flex: 1; min-width: 180px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.enc-add-op { width: 70px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.enc-add-input:focus, .enc-add-op:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }

/* 本机搜索注入面板 */
.pasted-panel { display: flex; flex-direction: column; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.pasted-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.pasted-input { width: 100%; box-sizing: border-box; resize: vertical; font-family: inherit; font-size: 13px; line-height: 1.5; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.pasted-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.pasted-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pasted-hint { font-size: 12px; color: var(--muted); }
.pasted-hint.ok { color: var(--ok); }
#pasteBtn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* 新建条目高亮闪烁（八轮：新建后自动滚动定位 + 金色高亮，防止"在树里看不见"） */
.just-created { background: #fff3cd !important; outline: 1px solid #f0c868; animation: jc-flash .6s ease 2; }
@keyframes jc-flash { 0%,100% { background:#fff3cd; } 50% { background:#ffe9a8; } }
/* 智能体任务列表（夜 10：任务只属智能体模块，与对话目录各管各的） */
.agent-task-list { margin: 2px 0 2px; display: flex; flex-direction: column; gap: 3px; max-height: 96px; overflow-y: hidden; transition: max-height .15s ease; }
.agent-panel:hover .agent-task-list { max-height: 30vh; overflow-y: auto; }
.agent-task-empty { font-size: 11px; color: #7a93c4; padding: 4px 2px; }
.agent-task-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #24344f; padding: 3px 6px; border-radius: 6px; background: #e3ecfb; border: 1px solid #c9d9f5; cursor: pointer; }
.agent-task-item:hover { background: #d3e2ff; }
.agent-task-item.current { background: #cfe4ff; border-color: #8fb4ef; font-weight: 600; }
.agent-task-item .atk-icon { font-size: 12px; }
.agent-task-item .atk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-task-item .row-more { display: none; }
.agent-task-item:hover .row-more { display: inline-flex; }
.agent-task-item .row-actions { z-index: 35; }

/* 智能体目录里的「任务」行：作为工作区文件夹下的子条目，显示绑定工作区标签（夜 11 重做） */
.agent-task-row { color: #1f3a5f; }
.agent-task-row .agent-ws-tag { font-size: 10px; color: #6b86b3; margin-left: 6px; opacity: .85; }
.agent-task-row.selected { background: #cfe4ff; border-color: #8fb4ef; }

/* =====================================================================
   手机竖屏布局（body.mobile-mode）
   —— 由 app.js 切换：自动探测手机+竖屏 / 顶栏「📱 手机版」按钮手动切换 / 设置→外观里三档设置。
   目标：一屏一栏 —— 左侧目录变可滑出的抽屉，对话区占满宽度，按钮加大便于点按。
   z-index 刻意低于弹窗(200)，保证设置页等弹窗仍盖在最上层。
   ===================================================================== */
.mobile-backdrop { display: none; }
.mobile-only { display: none !important; }

body.mobile-mode .mobile-only { display: inline-flex !important; }

/* 单栏布局：上下排列 */
body.mobile-mode .layout { flex-direction: column; position: relative; }
body.mobile-mode .sidebar-resizer { display: none; }

/* 侧栏 → 左侧抽屉（默认移出屏外，mobile-nav-open 时滑入） */
body.mobile-mode .sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 86vw; max-width: 340px; min-width: 0; max-height: none; flex: none;
  z-index: 150; border-right: 1px solid var(--border); border-bottom: none;
  transform: translateX(-103%); transition: transform .22s ease;
  box-shadow: 2px 0 26px rgba(10,20,40,.28);
}
body.mobile-mode.mobile-nav-open .sidebar { transform: translateX(0); }
/* 抽屉滚动容器 = .sidebar 自身。
   原因：.sidebar-main 基础样式是 flex:1（桌面下把「提示词区/速记区/询问历史」压到侧栏底部是有意的），
   手机上它会把下方三个模块推到抽屉最底 → 中间留一大片空白，观感很空。
   改法：手机上 sidebar-main 不再撑高（flex:0 0 auto），改由 .sidebar 统一滚动，抽屉头 sticky 常驻。 */
body.mobile-mode .sidebar { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.mobile-mode .sidebar-main { flex: 0 0 auto; overflow: visible; }
/* 抽屉打开时锁住背后页面滚动：避免手指在遮罩上滑动把对话内容带着滚 */
body.mobile-mode.mobile-nav-open { overflow: hidden; }
/* 抽屉头部（仅手机模式出现）：明确的「收起」按钮，解决「开了收不回」 */
.mobile-drawer-head { display: none; }
body.mobile-mode .mobile-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex: 0 0 auto; padding: 8px 10px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
body.mobile-mode .mobile-drawer-head .mobile-drawer-title { font-weight: 600; font-size: 13px; color: var(--text); }
body.mobile-mode .mobile-drawer-head #mobileNavClose { padding: 5px 12px; font-size: 12px; flex: 0 0 auto; }
body.mobile-mode .mobile-backdrop {
  display: block; position: fixed; inset: 0; z-index: 145;
  background: rgba(10,20,40,.38); opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
body.mobile-mode.mobile-nav-open .mobile-backdrop { opacity: 1; pointer-events: auto; }

/* 抽屉内取消「hover 浮层」：触摸设备没有 hover，内容改为常驻展开 */
body.mobile-mode .module-body { position: static !important; }
body.mobile-mode .chat-module:hover .module-body,
body.mobile-mode .agent-panel:hover .module-body,
body.mobile-mode .prompt-wrap:hover .module-body,
body.mobile-mode .scratch-wrap:hover .module-body,
body.mobile-mode .inquiry-panel:hover .module-body {
  position: static !important; border: none; box-shadow: none; border-radius: 0; padding: 0;
}
body.mobile-mode .chat-module .tree, body.mobile-mode .agent-panel .agent-tree { max-height: 40vh; }
body.mobile-mode .prompt-wrap .module-body #promptBox,
body.mobile-mode .prompt-wrap:hover .module-body #promptBox { height: calc(19.5px * 5 + 16px); }
body.mobile-mode .scratch-wrap .module-body #scratchBox,
body.mobile-mode .scratch-wrap:hover .module-body #scratchBox { height: calc(19.5px * 5 + 16px); }
body.mobile-mode .inquiry-panel .inquiry-list,
body.mobile-mode .inquiry-panel:hover .inquiry-list { max-height: 30vh; }
body.mobile-mode .chat-module .tree-row { padding: 8px 6px; }

/* 对话区占满宽度 */
body.mobile-mode .chat-area { flex: 1 1 auto; width: 100%; min-width: 0; }
body.mobile-mode .messages { padding: 10px 8px; gap: 10px; }
body.mobile-mode .msg .bubble { max-width: 92%; }
body.mobile-mode .composer { padding: 6px 8px 8px; }
body.mobile-mode .composer-bottom { flex-wrap: wrap; gap: 6px; }

/* 窄屏额外紧凑化（顶栏换行、字号、输入框防 iOS 自动放大等） */
@media (max-width: 899px) {
  body.mobile-mode .topbar { height: auto; min-height: 46px; padding: 6px 8px; flex-wrap: wrap; gap: 4px 6px; }
  body.mobile-mode .brand { font-size: 13px; }
  body.mobile-mode .brand span { display: none; }
  body.mobile-mode .topbar-right { gap: 6px; flex-wrap: wrap; justify-content: flex-end; width: 100%; }
  body.mobile-mode .user-tag { max-width: 34vw; font-size: 12px; }
  body.mobile-mode .topbar .btn-ghost { padding: 5px 8px; font-size: 12px; }
  body.mobile-mode .stats-row { padding: 6px 8px; font-size: 11px; flex-wrap: wrap; gap: 4px; }
  body.mobile-mode .stats-right { flex-wrap: wrap; gap: 4px; }
  body.mobile-mode .composer-input { font-size: 16px; } /* ≥16px：iOS 聚焦时不再自动放大整页 */
  body.mobile-mode .composer-bottom .flag-bar { order: 1; width: 100%; }
  body.mobile-mode .composer-func { flex-wrap: wrap; gap: 4px; margin-left: auto; order: 2; }
  body.mobile-mode .composer-func-btn, body.mobile-mode .btn-send { padding: 7px 10px; font-size: 12px; }
  body.mobile-mode .modal-card { width: 94vw !important; max-width: none; }
  /* 设置弹窗竖屏（2026-09-17 01:20 修正）：**不遮挡左侧功能条** —— 卡片贴功能条右侧展开，
     顶边与功能条齐平，高度占满下方可用空间，内容在卡片内滚动（其他模块也是浮在对话上不挡 rail）。
     层级：z-index 145 < 功能条 146 —— 弹窗会被 JS 搬进 .app 内（否则 .app 的 fixed 层叠上下文
     会让侧栏无论多高都被压住），这样功能条始终浮在弹窗之上可点。 */
  body.mobile-mode #settingsModal { align-items: flex-start; justify-content: flex-start; background: rgba(20,30,50,0.18); z-index: 145; }
  body.mobile-mode #settingsModal .modal-card { position: absolute !important; width: auto !important; height: auto !important; max-height: none !important; border-radius: 12px; }
  body.mobile-mode #settingsModal .settings-head { padding: 8px 14px 6px; }
  body.mobile-mode #settingsModal .settings-x { width: 42px; height: 42px; font-size: 17px; }
  body.mobile-mode .settings-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 8px 10px 0; gap: 0; }
  body.mobile-mode .settings-tabs::-webkit-scrollbar { display: none; }
  body.mobile-mode .settings-tab { flex: 0 0 auto; padding: 9px 12px; font-size: 12.5px; }
  body.mobile-mode .settings-scroll { padding: 12px 12px 18px; }
  body.mobile-mode .pv-item.pv-channel { grid-template-columns: 1fr; }
  body.mobile-mode .custom-colors { grid-template-columns: 1fr 1fr; }
  /* 主题选项：4 个卡原来在 390px 下挤成「3 + 1」参差两行 → 改 2×2 网格，整齐且触摸目标更大 */
  body.mobile-mode .theme-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  body.mobile-mode .theme-opt { padding: 11px 12px; font-size: 13.5px; }
  /* 峰谷配色卡片与预览：手机上缩小内边距，一屏能看到更多 */
  body.mobile-mode .pv-item { padding: 10px; }
  body.mobile-mode .pv-item.pv-channel { gap: 8px; }
  body.mobile-mode .settings-pane h3 { font-size: 15px; margin: 12px 0 6px; }
}

/* =====================================================================
   手机端 v2 精简（2026-09-16 二轮迭代，全部限定 body.mobile-mode，桌面零影响）
   修的三件事：① column 布局下 flex 子项 min-height:auto 把 .chat-area 撑开 → 整页可滚；
              ② 顶栏挤成两行、按钮文字过长；
              ③ 抽屉里次要模块全部摊开、消息每条 4~5 行辅助信息 → 一屏看不了两句。
   ===================================================================== */

/* ① 布局根因修复（不只手机模式：column 方向下 .chat-area 也必须能收缩） */
.chat-area { min-height: 0; }
.messages { min-height: 0; }
body.mobile-mode { overscroll-behavior: none; }
/* 界面缩放（html{zoom}）适配：vw/vh/dvh 是「视口单位」，**不随 zoom 缩放**，
   而 fixed + inset/百分比 是相对 containing block 计算的，**会自动跟随 zoom**。
   所以手机模式把「整屏高度」改用 fixed：否则 zoom<1 时 .app 会比屏幕矮（实测 0.85 时只有 717px，下方留白）。 */
body.mobile-mode .app { position: fixed; inset: 0; height: auto; }
body.mobile-mode .layout, body.mobile-mode .chat-panel { min-height: 0; }
body.mobile-mode .messages {
  overscroll-behavior: contain;      /* 对话区自身滚到底后，不再把滚动链传出去 */
  -webkit-overflow-scrolling: touch;
}

/* ② 抽屉：只让「对话目录」唱主角，其余模块折叠成一行标题 */
/* 抽屉宽度/高度同样改用百分比 + top/bottom 拉伸（基础规则已有 top:0/bottom:0）：
   原来写 88vw / 100dvh，在界面放大（zoom>1）时会比屏幕还宽、在缩小时又会偏窄。 */
body.mobile-mode .sidebar { width: 88%; max-width: none; height: auto; }
body.mobile-mode .sidebar-hint { display: none; }
body.mobile-mode .sidebar-main { padding: 8px 8px 4px; gap: 8px; }
/* 抽屉头 sticky：抽屉整体滚动时「📁 目录 / ✕ 收起」始终贴在顶部，收起入口永远够得着 */
body.mobile-mode .mobile-drawer-head {
  padding: 10px 12px; position: sticky; top: 0; z-index: 3;
  box-shadow: 0 1px 0 var(--border);
}
/* 抽屉底部留出手机手势条安全区，避免最后一行被系统横条压住 */
body.mobile-mode .sidebar { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
body.mobile-mode .mobile-drawer-head .mobile-drawer-title { font-size: 14px; }
body.mobile-mode .chat-module { padding: 8px 8px 6px; }
body.mobile-mode .chat-module .module-head { font-size: 13.5px; }
body.mobile-mode .chat-module .tree { max-height: none; overflow: visible; padding: 0; flex: 0 0 auto; }
body.mobile-mode .tree-row { min-height: 44px; padding: 0 8px; font-size: 14px; border-radius: 8px; }
body.mobile-mode .tree-row .label { font-size: 14px; }
/* 次要模块默认折叠：点标题行展开/收起 */
body.mobile-mode .m-collapsed > .module-body { display: none !important; }
body.mobile-mode .m-collapsed > .module-head,
body.mobile-mode .m-collapsed > .inquiry-head,
body.mobile-mode .m-collapsed > .agent-head { cursor: pointer; }
body.mobile-mode .m-collapsed > .module-head::after,
body.mobile-mode .m-collapsed > .inquiry-head::after,
body.mobile-mode .m-collapsed > .agent-head::after { content: '▸'; float: right; color: var(--muted); font-weight: 400; }
body.mobile-mode .m-collapsed { padding: 4px 10px; }
body.mobile-mode .m-collapsed > .module-head,
body.mobile-mode .m-collapsed > .inquiry-head,
body.mobile-mode .m-collapsed > .agent-head { padding: 8px 2px; }

/* ③ 消息：默认只留「徽标 + 通道 + 时间」，其余点气泡才展开（每轮省 3~4 行） */
body.mobile-mode .messages { padding: 8px 10px; gap: 8px; }
body.mobile-mode .msg { max-width: 94%; }
body.mobile-mode .msg .bubble { font-size: 15px; line-height: 1.62; padding: 9px 12px; border-radius: 12px; word-break: break-word; }
/* 三档信息密度（body.m-dens-compact / m-dens-normal(默认) / m-dens-rich，由顶栏「Aa」里切换）：
   compact = 只留 徽标+通道+时间；
   normal  = 再加 金额 + 联网/思考标记（默认，比旧版多给两行信息）；
   rich    = 全显示（含 token 明细 / 第几轮 / 复制 / 分叉按钮），等同桌面。
   token 明细(usage)、第几轮、复制条、分叉按钮在任何档都默认收起 —— 它们很长，需要时点气泡展开。 */
body.mobile-mode .msg .usage,
body.mobile-mode .msg .round-tag,
body.mobile-mode .msg .msg-actions,
body.mobile-mode .msg .copy-bar { display: none; }
body.mobile-mode.m-dens-compact .msg .cost-badge,
body.mobile-mode.m-dens-compact .msg .msg-flag { display: none; }
/* 点气泡展开（紧凑 / 标准档） */
body.mobile-mode .msg.op-open .usage,
body.mobile-mode .msg.op-open .cost-badge,
body.mobile-mode .msg.op-open .msg-flag,
body.mobile-mode .msg.op-open .round-tag { display: inline-flex; align-items: center; }
body.mobile-mode .msg.op-open .msg-actions { display: inline-flex; }
body.mobile-mode .msg.op-open .copy-bar { display: flex; }
/* 丰富档：全部常显，不必点 */
body.mobile-mode.m-dens-rich .msg .usage,
body.mobile-mode.m-dens-rich .msg .round-tag { display: inline-flex; align-items: center; }
body.mobile-mode.m-dens-rich .msg .msg-actions { display: inline-flex; }
body.mobile-mode.m-dens-rich .msg .copy-bar { display: flex; }
body.mobile-mode .msg-meta { font-size: 10.5px; gap: 3px 5px; margin: 3px 2px 0; }
body.mobile-mode .msg.op-open .msg-meta { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; }
body.mobile-mode .msg.op-open { outline: 1px dashed var(--border); outline-offset: 4px; border-radius: 12px; }
body.mobile-mode .msg .hit-badge { font-size: 10px; padding: 0 5px; }

/* ④ 输入区与统计条：紧凑 + 加大触摸目标 + 按钮行绝不溢出屏幕 */
body.mobile-mode .composer { padding: 6px 8px 8px; gap: 6px; }
body.mobile-mode .composer-input { font-size: 16px; line-height: 1.45; padding: 8px 10px; min-height: 46px; max-height: 26vh; }
body.mobile-mode .flag-bar { font-size: 11px; padding: 3px 7px; flex: 1 1 auto; min-width: 0; width: auto !important; }
body.mobile-mode .composer-bottom { flex-wrap: wrap; row-gap: 6px; }
/* 按钮组：独占可用宽度并右对齐换行 —— 之前 6 个按钮一行塞不下，直接把「发送」顶到屏幕外 451px 处 */
body.mobile-mode .composer-func {
  flex: 1 1 100%; width: 100%; min-width: 0;
  flex-wrap: wrap; justify-content: flex-end; gap: 5px; margin-left: 0;
}
body.mobile-mode .composer-func-btn, body.mobile-mode .composer-func .btn-sm {
  min-height: 32px; padding: 4px 7px; font-size: 11.5px; line-height: 1.2;
}
body.mobile-mode .btn-send { min-height: 34px; min-width: 66px; padding: 5px 12px; font-size: 13.5px; font-weight: 600; }
/* 统计条：手机上 token 明细太长会把对话名挤到第二行 → 只留对话名 + 分支 */
body.mobile-mode .stats-row { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; overflow: hidden; }
body.mobile-mode .stats-row .chat-stats,
body.mobile-mode .stats-row #chatTotalCost { display: none; }
body.mobile-mode .stats-right { flex: 1 1 auto; min-width: 0; overflow: hidden; gap: 6px; justify-content: space-between; }
body.mobile-mode .stats-right #helpBtn2 { display: none; }
body.mobile-mode .chat-name { max-width: 58vw; font-size: 13.5px; }
body.mobile-mode .branch-tag { font-size: 11px; }
body.mobile-mode button, body.mobile-mode .btn-sm { min-height: 30px; }

/* ⑤ 顶栏（窄屏）：强制单行 + 图标化，按钮只留符号 */
@media (max-width: 899px) {
  body.mobile-mode .topbar {
    height: 54px; min-height: 54px; padding: 0 8px;
    flex-wrap: nowrap; gap: 6px; overflow: hidden; align-items: center;
  }
  body.mobile-mode .brand { flex: 0 1 auto; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.mobile-mode .brand span { display: none; }
  body.mobile-mode .topbar-right {
    flex: 1 1 auto; width: auto; min-width: 0; height: 100%;
    flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 4px;
  }
  /* 模型选择：强制单行 —— 否则「模型名 + ▾」在窄屏换行，把顶栏撑成 64px 高、内容上下溢出 */
  body.mobile-mode .model-select-wrap {
    min-width: 0; flex: 0 1 auto; max-width: 128px; overflow: hidden;
    display: flex; flex-direction: row; align-items: center;
  }
  /* flex item 默认 min-width:auto 会拒绝被压缩到内容宽度以下（于是 max-width 被顶开、顶栏被撑爆）→ 必须显式 min-width:0 */
  body.mobile-mode #modelNameBtn { flex: 1 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; height: 32px; }
  body.mobile-mode .model-arrow-btn { flex: 0 0 auto; padding: 0 5px; height: 32px; }
  body.mobile-mode #userTag, body.mobile-mode #globalTokens { display: none; }
  body.mobile-mode .topbar .btn-ghost, body.mobile-mode .topbar .mobile-btn {
    height: 34px; min-width: 34px; padding: 0 6px; font-size: 0 !important;
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  }
  body.mobile-mode .topbar #mobileNavBtn::after { content: '☰'; font-size: 17px; }
  body.mobile-mode .topbar #mobileBtn::after { content: '📱'; font-size: 16px; }
  /* 「Aa」= 显示面板（缩放进 / 缩放出 / 信息密度 / 侧栏模块），比放大镜更贴近「字号·显示」语义 */
  body.mobile-mode .topbar #mViewBtn::after { content: 'Aa'; font-size: 14px; font-weight: 700; }
  body.mobile-mode .topbar #mViewBtn.btn-primary { color: #fff; }
  body.mobile-mode .topbar #settingsBtn::after { content: '⚙'; font-size: 16px; }
  /* ⎋（带箭头的圆圈）几乎没人认得出是「退出」→ 手机上直接用文字，语义零歧义 */
  body.mobile-mode .topbar #logoutBtn { min-width: 46px; }
  body.mobile-mode .topbar #logoutBtn::after { content: '退出'; font-size: 12px; font-weight: 500; }
  body.mobile-mode .topbar .mobile-btn.btn-primary { color: #fff; }
  /* 手机上隐藏品牌（品牌信息在对话名/设置里都有），把宽度让给模型名 ---- 否则「DeepSeek V3 (Chat)」被砍成「DeepSeek V3 (」 */
  body.mobile-mode .brand { display: none; }
  body.mobile-mode .model-select-wrap { max-width: 190px; }
  body.mobile-mode #modelNameLabel { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* 功能按钮图标化（文字隐藏、title 保留说明）：6 个带字按钮一行塞不下，会把「发送」顶出屏幕 */
  body.mobile-mode .composer-func { flex: 0 1 auto; width: auto; min-width: 0; flex-wrap: nowrap; justify-content: flex-end; gap: 4px; }
  body.mobile-mode .composer-func-btn {
    font-size: 0 !important; padding: 0; width: 32px; min-width: 32px; height: 32px; min-height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  body.mobile-mode .composer-func-btn::after { font-size: 15px; line-height: 1; }
  body.mobile-mode #deepBtn::after { content: '🧠'; }
  body.mobile-mode #webBtn::after { content: '🌐'; }
  /* 📥 在 15px 下渲染成一团红灰方块、🖍 太像铅笔（易与「修改」混），换成语义更清楚的 📎 / 🏷 */
  body.mobile-mode #pasteBtn::after { content: '📎'; }
  body.mobile-mode #encToggle::after { content: '🔒'; }
  body.mobile-mode #encMarkBtn::after { content: '🏷'; }
  body.mobile-mode #sendKeyBtn::after { content: '⏎'; }
  body.mobile-mode #sendBtn { flex: 0 0 auto; min-width: 60px; }
  /* 标识词条精简：手机上只显示「本对话标识词」（前缀标识词与默认值在 title 与点击后弹窗里说明） */
  body.mobile-mode #flagBar > .flag-seg:first-child,
  body.mobile-mode #flagBar > .flag-bar-sep { display: none; }
  /* 用 % 而不是 vw：vw 是视口单位、不随界面缩放变化，放大时会明显偏宽 */
  body.mobile-mode #flagBar { flex: 0 1 auto; max-width: 48%; }
}

/* =====================================================================
   手机端「显示」面板（2026-09-16 三轮迭代）：界面缩放 / 信息密度 / 侧栏模块
   入口：顶栏「Aa」按钮（仅手机模式显示）。面板本身也只存在于手机模式。
   缩放实现 = html{zoom}。实测要点（见 _server_pull/zoom_lab.js）：
     · zoom 下 fixed / inset / 百分比 会**跟随**缩放 → 全屏与抽屉都改用它们；
     · vw / vh / dvh 是视口单位、**不跟随** → 手机模式已全部避开（.app / .sidebar / #flagBar）。
   ===================================================================== */
.m-view-pop { display: none; }
body.mobile-mode .m-view-pop {
  display: block; position: fixed; z-index: 260;
  top: 62px; right: 8px; left: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(10, 20, 40, .3);
  padding: 10px 12px 12px;
}
body.mobile-mode .m-view-pop.hidden { display: none; }
.mv-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text); }
.mv-x { background: none; border: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 4px; }
.mv-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0 2px; }
.mv-label { flex: 0 0 auto; font-size: 12.5px; color: var(--text); }
.mv-zoom { display: flex; align-items: center; gap: 5px; }
.mv-step { width: 34px; height: 32px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; font-size: 17px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; }
.mv-step:active { background: var(--primary-soft, #e8f0ff); }
.mv-val { min-width: 54px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--primary); }
.mv-seg { display: flex; gap: 4px; flex: 0 1 auto; }
.mv-seg button { padding: 0 10px; min-height: 30px; font-size: 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.mv-seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.mv-hint { font-size: 11px; color: var(--muted); line-height: 1.45; margin: 3px 0 0; }
/* 缩放滑块：50%~200% 连续可拖（± 按钮仍保留做微调） */
.mv-slide { margin: 6px 0 0; }
.mv-slide input[type="range"] { width: 100%; height: 26px; margin: 0; background: transparent;
  -webkit-appearance: none; appearance: none; }
.mv-slide input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 50%, var(--border) 50%, var(--border) 100%); }
.mv-slide input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--primary);
  margin-top: -8px; box-shadow: 0 1px 4px rgba(10,20,40,.35); }
.mv-slide input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
.mv-slide input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary); }
.mv-reset { width: auto; min-width: 48px; padding: 0 8px; font-size: 12px; }

/* 空态快捷入口：手机上目录在抽屉里，没开对话时给两个明确动作 */
.empty-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.empty-actions .btn-sm { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }
body:not(.mobile-mode) .empty-actions .mobile-only-b { display: none; }   /* 桌面侧栏常显，不需要「打开目录」 */
@media (max-width: 899px) {
  body.mobile-mode .m-view-pop { top: 58px; left: 6px; right: 6px; padding: 9px 10px 11px; }
  .mv-row { gap: 8px; margin: 8px 0 2px; }
}

/* ===================== 手机竖屏 v4：左侧「功能块」= 一条定长横带（2026-09-17）=====================
   规则（用户拍板）：
   1) 左段功能条 + 右段展开页 = 同一条横带：顶边齐、底边齐、一样长（用 flex align-items:stretch 天然等高，
      高度由左段的功能个数决定，不写死任何数值）。
   2) 内容多 → 只往右加宽（width:max-content，最长那行文字不截断），上限 = 整宽。
   3) 宽到顶仍放不下 → 内容区内部滚动（可拖动查看编辑），横带高度不变。
   4) 功能图标竖排不下 → 自动横向扩列（flex-wrap），横带高度不变。
   5) 只认「✕ 关闭」按钮退出（rail 末尾的红键）；点对话 / 点外部 / 滑动都不关。
   6) 展开时浮在对话之上，对话区宽度不变，照样滚动 / 编辑 / 发送。
   —— 以下规则放在文件末尾，用于覆盖上面「侧栏=左侧抽屉」那套旧规则（同特异性后者胜）。 */
body.mobile-mode .sidebar {
  position: fixed; left: 6px; top: 58px; right: auto; bottom: auto;
  width: auto; max-width: calc(100vw - 12px); min-width: 0; height: auto; max-height: none;
  flex: none; display: flex; flex-direction: row; align-items: stretch;
  transform: none !important; transition: none; box-shadow: none;
  overflow: visible; z-index: 146;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 0;
}
/* 抽屉头部不再需要：模块自带的 .module-head 就是面板标题，收起只走 rail 上的「✕ 关闭」 */
body.mobile-mode .mobile-drawer-head { display: none !important; }
/* 旧抽屉的遮罩整块撤掉：不再靠点外部收起 */
body.mobile-mode .mobile-backdrop { display: none !important; }
/* 旧规则「抽屉打开时锁住背后页面滚动」作废：现在展开时对话仍要能滚动（用户要求不影响对话） */
body.mobile-mode.mobile-nav-open { overflow: visible !important; }
/* 抽屉滚动改到内容区自己身上（.sidebar 不再滚动，否则会把横带撑出屏） */
body.mobile-mode .sidebar { overflow: visible; }
body.mobile-mode .sidebar-hint { display: none !important; }
body.mobile-mode #promptFileMenu { display: none !important; }
/* .sidebar-main 用 display:contents 让内部模块直接成为横带的 flex 项（这样目录/智能体与提示词等平级） */
body.mobile-mode .sidebar-main { display: contents; }

/* 左段：功能条 */
.mobile-rail { display: none; }
body.mobile-mode .mobile-rail {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 0 0 auto; padding: 4px 3px; flex-wrap: nowrap;
  background: var(--panel); border-right: 1px solid var(--border);
  border-radius: 12px 0 0 12px;
}
body.mobile-mode .mobile-rail.mrail-multi { flex-wrap: wrap; justify-content: flex-start; align-content: flex-start; }
body.mobile-mode .mrail-btn {
  width: 32px; height: 32px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); cursor: pointer;
}
body.mobile-mode .mrail-btn.active { border-color: var(--primary); color: var(--primary); background: var(--bg); }
body.mobile-mode .mrail-close {
  width: 32px; height: 26px; flex: 0 0 auto; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; padding: 0; border: none; border-radius: 8px;
  background: #c0392b; color: #fff; cursor: pointer;
}

/* 右段：展开页（与左段等高；内容多就加宽，放不下内部滚） */
/* 选择器必须限定为「模块容器」：功能条上的按钮也带 data-mnav，不能一起隐藏 */
body.mobile-mode .sidebar > [data-mnav],
body.mobile-mode .sidebar-main > [data-mnav] { display: none; }
body.mobile-mode .sidebar > [data-mnav].mnav-on,
body.mobile-mode .sidebar-main > [data-mnav].mnav-on {
  /* 绝对定位是关键：内容区不参与撑高，横带高度只由左段（功能条）决定，
     展开页再用 top:0/bottom:0 拉成与功能条一模一样的高度（顶边齐、底边齐）。 */
  position: absolute; left: 100%; top: 0; bottom: 0; height: auto;
  display: flex; flex-direction: column; flex: 0 0 auto;
  width: max-content; min-width: 132px; max-width: calc(100vw - 58px);
  min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 6px 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 0 12px 12px 0;
}
body.mobile-mode .sidebar [data-mnav].mnav-on > .module-head { flex-wrap: wrap; gap: 4px 6px; font-size: 12.5px; }
body.mobile-mode .sidebar [data-mnav].mnav-on > .module-body { max-height: none; overflow: visible; }
/* 目录里的对话名不截断、不换行：面板靠它撑宽（内容多 → 往宽里长） */
body.mobile-mode .chat-module.mnav-on .tree-row { white-space: nowrap; }
body.mobile-mode .chat-module.mnav-on .tree-row .label { overflow: visible; text-overflow: clip; }
body.mobile-mode .chat-module.mnav-on .tree { max-height: none; overflow: visible; }
body.mobile-mode .inquiry-panel.mnav-on .inquiry-list { max-height: none; overflow: visible; }
body.mobile-mode .prompt-wrap.mnav-on #promptBox,
body.mobile-mode .scratch-wrap.mnav-on #scratchBox { height: 96px; min-height: 96px; }

/* ============================================================
   手机/窄屏下「关闭手机模式」＝ 完整电脑版画面 + 可左右拖动（2026-09-17）
   背景：手机模式关掉后，.app 仍被压成屏宽（393），侧栏吃掉 260、对话区只剩 130，
        且 html/body 是 overflow:hidden → 既不是电脑画面，也没法横移看被裁掉的部分。
   规则：窄屏（<1024）且未启用手机模式时，把 .app 钉成一个固定桌面宽度，
        body 放开横向滚动（触摸可直接左右拖）。
   只对已登录（body.app-ready）生效 —— 登录页不撑宽、保持居中。
   竖屏适配（2026-09-17 01:50）：画面 1024 → **860**，左列目录 306 → **200**，
        对话区 712 → **654** —— 一屏 393 里「目录 + 对话开头」都看得见，横向拖动量也从 631 降到 467。
   ============================================================ */
@media (max-width: 1023px) {
  body.app-ready:not(.mobile-mode) {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  /* --bw-zoom：缩放档（JS 写入）。dvh 不跟随 zoom，除以它才能让 .app 在任何缩放档都正好一屏高 */
  body.app-ready:not(.mobile-mode) .app {
    min-width: 700px; height: 100vh; height: calc(100dvh / var(--bw-zoom, 1));
  }
  /* 左列目录收窄到 200（电脑默认 306、最小 260 在竖屏太占地方）；
     !important 是为了压过拖拽过拖拽条时写下的 inline `flex:0 0 Wpx` */
  body.app-ready:not(.mobile-mode) .sidebar {
    flex: 0 0 200px !important; min-width: 200px !important; max-width: 200px !important;
  }
  body.app-ready:not(.mobile-mode) .chat-panel { min-width: 0; }
  body.app-ready:not(.mobile-mode) .user-tag { max-width: 300px; }
  body.app-ready:not(.mobile-mode) .chat-name { max-width: 380px; }
  body.app-ready:not(.mobile-mode) .sidebar-resizer { display: none; } /* 竖屏下没有鼠标可拖，去掉占位 */
  /* 竖屏看电脑版同样要能缩放：顶栏「Aa 显示」在窄屏非手机模式下也显示，面板只留缩放一段 */
  body.app-ready:not(.mobile-mode) #mViewBtn { display: inline-flex !important; }
  body.app-ready:not(.mobile-mode) .m-view-pop {
    display: block; position: fixed; z-index: 300;
    top: 56px; left: 8px; right: auto; width: 268px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 14px 36px rgba(10, 20, 40, .3); padding: 10px 12px 12px;
  }
  body.app-ready:not(.mobile-mode) .m-view-pop.hidden { display: none; }
  body.app-ready:not(.mobile-mode) .mv-mobile-only { display: none !important; } /* 信息密度 / 侧栏模块 仅手机版有意义 */

  /* ---- 竖屏电脑画面紧凑化（2026-09-17 02:30）：700 宽下顶栏/侧栏按钮禁止换行竖排 ----
     截图自检发现两处挤压：① 顶栏「手机版/Aa 显示/设置」文字竖排；② 侧栏 200px 里
     「回收区 (15 项) 清空 ↻」「+文件夹 +对话」挤成一团竖排字。根因都是 flex 子项被压缩后
     CJK 文字逐字换行 → 一律 white-space:nowrap + flex 收紧 + 字号下调。 */
  body.app-ready:not(.mobile-mode) .topbar { padding: 0 10px; gap: 8px; }
  body.app-ready:not(.mobile-mode) .brand {
    font-size: 13px; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 0 auto;
  }
  body.app-ready:not(.mobile-mode) .topbar-right { gap: 5px; flex-wrap: nowrap; min-width: 0; }
  body.app-ready:not(.mobile-mode) .topbar-right .btn-ghost,
  body.app-ready:not(.mobile-mode) .topbar-right .model-name-btn,
  body.app-ready:not(.mobile-mode) .topbar-right .model-arrow-btn {
    flex: 0 0 auto; white-space: nowrap; padding: 5px 8px; font-size: 12.5px;
  }
  body.app-ready:not(.mobile-mode) .topbar-right .model-name-btn { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
  body.app-ready:not(.mobile-mode) .user-tag { max-width: 150px; }
  body.app-ready:not(.mobile-mode) .sidebar .btn-ghost,
  body.app-ready:not(.mobile-mode) .sidebar .btn-sm {
    white-space: nowrap; padding: 4px 7px; font-size: 12px; flex: 0 0 auto;
  }
  body.app-ready:not(.mobile-mode) .sidebar .module-head { font-size: 12.5px; gap: 4px; flex-wrap: nowrap; }
  body.app-ready:not(.mobile-mode) .sidebar .module-head .btn-sm { flex: 0 0 auto; }
  body.app-ready:not(.mobile-mode) .sidebar .trash-head { white-space: nowrap; flex-wrap: nowrap; font-size: 11.5px; }
  body.app-ready:not(.mobile-mode) .sidebar .trash-sub { white-space: nowrap; }
  body.app-ready:not(.mobile-mode) .sidebar .module { padding-left: 8px; padding-right: 8px; }

  /* 顶栏关键控件常驻视口右上角（2026-09-17 02:40）：窄屏电脑画面下顶栏内容按 700 布局宽排，
     Aa/设置/退出会被排到 x>393 的屏外区 —— 缩放入口第一屏看不到。把「Aa 显示」「手机版」
     fixed 到视口右上，横滚时也常驻可见；设置/退出留在顶栏里横滑可达。 */
  body.app-ready:not(.mobile-mode) #mobileBtn { position: fixed; top: 9px; right: 10px; z-index: 150; }
  body.app-ready:not(.mobile-mode) #mViewBtn { position: fixed; top: 9px; right: 84px; z-index: 150; }
}
