/* 布局骨架：顶栏、会话列表（按需）、对话列、右侧面板（按需）。尺寸、颜色等全部是 theme.css 的 token（规范见 docs/design/界面规范.md），
   模块内部的样式在 chat.css。 */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  display: flex; flex-direction: row; height: 100vh; height: 100dvh; overflow: hidden;
  font: var(--fs-body)/var(--lh) var(--sans); color: var(--fg); background: var(--surface);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, select, input, textarea { font: inherit; color: inherit; }
/* 不用浏览器的默认外观：每个按钮、输入框的底色与边框都来自 theme.css 的变量（审查 M4；ui-selftest.py 的外观检查断言这一条）。 */
button, select, input, textarea { appearance: none; -webkit-appearance: none; }
button { cursor: pointer; }
button:disabled { cursor: default; }
/* 图标旁的文字垂直居中（界面规范第二十六节，协议 §277）。
   根因：行盒的高度与基线位置按“第一个可用字体”（拉丁字体，如 SF / Segoe UI / DejaVu）的上升、下降量算，而中文字形来自后备的 CJK 字体，
   字面（墨迹）的中心比拉丁字体的“行盒中心”高出约 0.1–0.2em，图标用 flex 的 align-items: center 对准的是行盒中心，所以中文总比图标高一截
   （拉丁文因为字形中心贴近行盒中心，没这么明显，所以只在中文界面里被看出来）。
   做法：把文字的“行盒”修剪到“大写字母高度到基线”（text-box: trim-both cap alphabetic）——中文字面正好落在这一段里，拉丁字母的大写与小写也都在里面——
   再上下各补约 .3em 的内边距（不补的话 overflow: hidden 的省略号文字会把下伸笔画和上标裁掉）。上 .32em、下 .28em 的 0.04em 差是实测的校正：字面的视觉中心比“大写字母高度的中点”略高（e5 的 Noto CJK 与 DejaVu，12–14px 下零点几像素），整体下移一点，中文与拉丁文都落进 0.5 像素以内。
   这一处选择器列表是全站唯一的规则：新写“图标 + 文字”的一行，文字放在下面列出的类里，或把它的类名加进这里，不要在别处各自微调。
   不支持 text-box 的浏览器（Firefox）保持原样（@supports 之外不改动）。 */
@supports (text-box: trim-both cap alphabetic) {
  .activity-text, .chip-text, .entry-name, .attachment-name, .attachment-size, .group-label, .group-kinds,
  .card-head .tool-name, .card-head .brief, .card-head .meta, .fold-head > span:not(.icon), .view-btn-word,
  .folder-name, .folder-size, .folder-all-label, .flow-row .meta { text-box: trim-both cap alphabetic; padding-block: .32em .28em; }
}
/* 选中文字与滚动条：跟主题走（深色下浏览器默认的选中色与粗滚动条都很扎眼）。 */
::selection { background: var(--selection); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: var(--r-pill); background: var(--scroll) padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
/* 动效克制：系统要求“减少动态效果”时，一条规则去掉全部过渡、出场与脉动动画、平滑滚动（以后新加的动画不用再各写一遍）。
   只保留三处“进行中”的转圈——.attach-spin（上传中）、.session-active（会话在跑）、.activity-line（这一轮在进行或流程在计算；等用户、等重连时是静止的）：
   它们没有位移，只表示“还在进行”，静止了就看不出有没有在做。别的动画一律不保留。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .attach-spin, .session-active { animation: spin var(--dur-spin) linear infinite !important; }
  .activity-line:is([data-kind="busy"], [data-kind="computing"])::before { animation: turn-spin var(--dur-spin) linear infinite !important; }
}

/* —— 顶栏：会话按钮 · 标题 · 状态 · 面板开关 —— */
#content-header { position: relative; z-index: 2; flex: none; display: flex; align-items: center; gap: var(--sp-2); height: var(--top-h); padding: 0 var(--sp-4); border-bottom: 1px solid var(--sep); background: var(--surface); min-width: 0; }
.top-leading, .top-trailing { display: flex; align-items: center; min-width: 0; }
.top-leading { flex: 1 1 auto; gap: var(--sp-2); }
.top-trailing { flex: 0 0 auto; gap: var(--sp-2); }
.top-button { position: relative; flex: none; width: var(--ctl); height: var(--ctl); padding: 0; border: 0; border-radius: var(--r-sm); display: grid; place-items: center; background: transparent; color: var(--dim); --icon: var(--icon-lg); }
.top-button:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.top-button:active:not(:disabled) { background: var(--press); }
.top-button[aria-pressed="true"], .top-button[aria-expanded="true"] { background: var(--fill); color: var(--accent); }
.title-button { flex: 0 1 auto; min-width: 0; max-width: min(48vw, 520px); min-height: var(--ctl); display: inline-flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg); text-align: left; }
.title-button:hover, .title-button[aria-expanded="true"] { background: var(--hover); }
/* 会话栏开关与右侧面板开关：同一套样式（左右镜像的侧栏图标，外框加一侧的窗格）。展开时窗格淡淡填上、收起时只剩轮廓；它们是常驻状态而不是“选中了一项”，所以展开时不用蓝底。 */
#sessions-toggle[aria-expanded="true"], #panel-toggle[aria-pressed="true"] { background: transparent; color: var(--dim); }
#sessions-toggle[aria-expanded="true"]:hover:not(:disabled), #panel-toggle[aria-pressed="true"]:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
#sessions-toggle[aria-expanded="true"]:active:not(:disabled), #panel-toggle[aria-pressed="true"]:active:not(:disabled) { background: var(--press); }
#sessions-toggle .side-pane, #panel-toggle .side-pane { fill: currentColor; stroke: none; opacity: 0; transition: opacity var(--dur-2) var(--ease); }
#sessions-toggle[aria-expanded="true"] .side-pane, #panel-toggle[aria-pressed="true"] .side-pane { opacity: .26; }
#sessions-toggle:hover .side-pane, #panel-toggle:hover .side-pane { opacity: .4; }
/* 会话按钮上的圆点：别的会话有流程结束、用户还没看过。 */
.top-dot { position: absolute; top: 5px; right: 5px; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
/* 圆点本身可以点（去那个会话）：可点的范围比看得见的点大一圈；点开关的其余部分仍是折叠会话栏。 */
.top-dot { cursor: pointer; }
.top-dot::after { content: ""; position: absolute; inset: -7px; }
#title { flex: 0 1 auto; min-width: 0; max-width: min(38vw, 420px); font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status { flex: 0 1 auto; min-width: 0; max-width: min(34vw, 400px); display: flex; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--faint); overflow: hidden; white-space: nowrap; }
#status span { overflow: hidden; text-overflow: ellipsis; }
#s-error:not(:empty) { color: var(--bad); }
/* 断线：醒目地说（V6 第 28 节），不自己消失，重连上了才收起。 */
#s-gateway:not(:empty) { flex: 0 1 auto; max-width: 100%; padding: var(--sp-0) var(--sp-3); border-radius: var(--r-pill); background: var(--warn-soft); color: var(--warn); font-weight: var(--fw-medium); }
#status { margin-left: auto; }
/* 窄窗口下断线横幅独占顶栏下面的一行、整句显示（不省略）：顶栏允许换行，状态那一块撑满一行（main.js 在断线时给 <html> 设 data-offline）。 */
@media (max-width: 820px) {
  :root[data-offline="true"] #content-header { flex-wrap: wrap; height: auto; min-height: var(--top-h); padding-block: var(--sp-1); }
  :root[data-offline="true"] #panel-toggle { margin-left: auto; }
  :root[data-offline="true"] #status { order: 1; flex: 1 0 100%; max-width: none; margin-left: 0; white-space: normal; overflow: visible; }
  :root[data-offline="true"] #status span { overflow: visible; text-overflow: clip; }
  :root[data-offline="true"] #s-gateway:not(:empty) { max-width: none; }
}

/* —— 主体 —— */
#body { flex: 1; min-width: 0; min-height: 0; display: flex; }
/* 会话列表：推开式的侧栏，不盖在别的东西上面（桌面端原生 3D 窗口会盖住任何浮层）。 */
#sessions { flex: 0 0 clamp(240px, calc(13.5rem + 3.5vw), 320px); width: clamp(240px, calc(13.5rem + 3.5vw), 320px); min-width: 240px; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--sep); background: var(--fill); }
.sidebar-brand { height: var(--top-h); flex: none; display: flex; align-items: center; gap: 6px; padding: 0 var(--sp-2) 0 var(--sp-4); color: var(--fg); white-space: nowrap; }
.sidebar-brand img { width: 28px; height: 28px; object-fit: contain; }
.brand-lockup { min-width: 0; height: 28px; display: flex; align-items: flex-end; gap: 5px; }
/* MO 是画出来的圆头粗线字（圆角端点与圆角转折，和图标的圆润一致），不依赖系统有没有圆体字；底边与图标的底边在同一条线上。 */
.brand-wordmark { flex: none; display: block; height: 28px; width: auto; color: var(--fg); }
.brand-descriptor { min-width: 0; overflow: hidden; align-self: flex-end; margin-bottom: -1px; color: var(--dim); font-size: var(--fs-2xs); font-weight: 500; line-height: 1; letter-spacing: 0; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.sidebar-toggle { align-self: flex-end; margin: 0 var(--sp-3) var(--sp-1); }
#conversation { position: relative; flex: 1 1 0; min-width: min(360px, calc(100vw - 600px)); min-height: 0; display: flex; flex-direction: column; --gutter: max(var(--sp-4), calc((100% - var(--chat-max)) / 2)); }
/* 对话与输入区：内容最宽 --chat-max，居中。用内边距居中，滚动条仍贴着列的右边。 */
#chat { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable both-edges; padding: var(--sp-6) var(--gutter) var(--sp-4); }      /* 滚动条出现与消失时不让正文左右跳（展开折叠内容、内容变长时） */
/* 输入区连同流程区、提问卡片最多占对话列的一半高：对话始终留得出至少一半；放不下时在此区域滚动。 */
#dock-area { --composer-max: 736px; --gutter: max(var(--sp-4), calc((100% - var(--composer-max)) / 2)); flex: none; max-height: 50%; overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-1) var(--gutter) var(--sp-4); }
/* 提问卡片（多选 + “其他”输入框约 330px）出现时，输入区允许多占一些：50% 在 800px 高的窗口里放不下它与流程区的那一行，“跳过 / 提交”会被切在窗口下沿。对话区仍留三成以上。提问时决策区底下多了一行“打断”（约 36px，输入框让位后它是唯一的停止入口），1100×600 里提问卡加这一行是 355px，占 59%，贴着原来 60% 的上限（只差 5px，卡再高一点就冒出第二层滚动），放宽到 62%（上限 372px，对话区仍 ≥ 180px、占三成以上）。 */
#dock-area:has(#ask:not([hidden])) { max-height: 62%; }
/* 任务列表展开时：整个输入区的上限从 50% 放到 60%（与列表上限 240→288px 同步，都是 +20%），不然列表还没长到上限，外面这一层先封顶、出滚动条 */
#dock-area:has(.dock[data-expanded="true"]):not([data-deciding="true"]) { max-height: 60%; }      /* 决策区（计划卡、确认卡）出现时仍是 none：优先级比 [data-deciding] 那条高，要明确排除 */
#composer { width: 100%; }
/* 输入框让位：提问（data-asking，ask.js）与有等你决定的确认卡、流程确认卡（data-deciding，decision-dock.js）是同一种让位方式。 */
#dock-area:is([data-asking="true"], [data-deciding="true"]) #composer { display: none; }
/* 决策区里的卡自己有 max-height 与内部滚动：输入区不再另外限高、另起一层滚动（两层滚动里“开始 / 拒绝”会被挤到看不见的地方）。 */
#dock-area[data-deciding="true"] { max-height: none; }
#dock-area:has(.dock:not([hidden])):not([data-asking="true"], [data-deciding="true"]) { gap: 0; }
#dock-area:has(.dock:not([hidden])):not([data-asking="true"], [data-deciding="true"]) #composer .box { border-radius: 0 0 var(--r-composer) var(--r-composer); border-top-color: var(--sep); }
/* 模型在提问时，展开着的流程区只留那一行：步骤与按钮让位给提问卡片，答完再回来。 */
#dock-area:is([data-asking="true"], [data-deciding="true"]) .dock .steps, #dock-area:is([data-asking="true"], [data-deciding="true"]) .dock .flow-foot, #dock-area:is([data-asking="true"], [data-deciding="true"]) .dock .flow-list { display: none; }  /* 提问时流程区只留“当前任务”一行：任务列表与步骤让位，免得把提问卡片的“跳过 / 提交”挤到窗口下沿外面 */
#dock-area:is([data-asking="true"], [data-deciding="true"]) .dock { border-radius: var(--r-card); border-bottom: 1px solid var(--edge); }
/* 把文件拖到对话区上方时的提示：盖在对话列上的一层（虚线框、居中一句话），不接指针事件；
   只在对话列里，碰不到右侧面板（桌面端的 3D 是那里的原生窗口）。 */
.drop-hint { position: absolute; inset: var(--sp-3); z-index: 4; pointer-events: none; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: var(--r-card); background: var(--scrim); }
.drop-hint-box { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-4); text-align: center; color: var(--fg); }
.drop-hint-box .icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); --icon: var(--icon-lg); }
.drop-hint-box b { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.drop-hint-box small { max-width: 320px; font-size: var(--fs-sm); color: var(--dim); }

/* —— 输入框：一张圆角卡片——附件（有才出现）· 多行文字 · 底下一行（左“＋”，右发送 / 打断） —— */
#composer .box { display: flex; flex-direction: column; gap: var(--sp-0); padding: var(--sp-3) var(--sp-2) var(--sp-2) var(--sp-4); border: 1px solid var(--edge); border-radius: var(--r-composer); background: var(--surface); box-shadow: var(--shadow-composer); }
#composer .box { transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
/* 聚焦：边框淡淡染上强调色，外面一圈很淡的光（不再是粗的蓝框）。 */
#composer .box:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--edge)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 8%, transparent), var(--shadow-composer); }
#composer textarea { display: block; width: 100%; min-height: 48px; max-height: 200px; padding: var(--sp-0) var(--sp-2) var(--sp-0) 0; border: 0; background: transparent; resize: none; outline: none; line-height: 24px; }
#composer textarea::placeholder { color: var(--faint); }
#composer .bar { position: relative; display: flex; align-items: center; gap: var(--sp-2); margin-left: calc(-1 * var(--sp-2)); }
#composer .bar-gap { flex: 1; }
#composer .round { flex: none; width: var(--ctl); height: var(--ctl); padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--dim); --icon: var(--icon-lg); transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
#composer .round:active:not(:disabled) { transform: scale(.94); }
#composer .round:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
#composer .round:active:not(:disabled) { background: var(--press); }
/* 发送：有字时是强调色的实心圆，没字（或没连上、忙）时置灰。打断：同样大小的圆，里面一个方块。按下时叠一层 --press。 */
#composer .round.send, #composer .round.send:hover:not(:disabled) { background: var(--accent-fill); color: var(--on-accent); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent-fill) 35%, transparent); }
#composer .round.send:disabled { background: var(--fill-2); color: var(--faint); opacity: 1; box-shadow: none; }
#composer .round.stop, #composer .round.stop:hover:not(:disabled) { background: var(--fg); color: var(--surface); }
#composer .round.send:active:not(:disabled), #composer .round.stop:active:not(:disabled) { background-image: linear-gradient(var(--press), var(--press)); }
/* 忙的时候写了字：发送（排队）是主按钮，打断退成旁边一个描边的次要按钮。 */
#composer[data-queuing="true"] .round.stop, #composer[data-queuing="true"] .round.stop:hover:not(:disabled) { background: transparent; color: var(--dim); box-shadow: inset 0 0 0 1px var(--edge); }
#composer[data-queuing="true"] .round.stop:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
/* “加载内置示例结构”只给自检与演示用：平时不显示（main.js 在 ?ruler=1、桌面自检、?demo=1 时给 <html> 加类）。 */
#composer .round.demo-only { display: none; }
.selftest #composer .round.demo-only, .demo #composer .round.demo-only { display: grid; }
#composer .hint { text-align: center; font-size: var(--fs-xs); color: var(--warn); }
/* 附件卡片：图片是方形缩略图；其他文件是图标 + 名字 + 大小。上传中转圈，失败标红（原因在悬停提示与输入框下面）。 */
#composer .tray { display: flex; flex-wrap: wrap; gap: var(--sp-2); max-height: 140px; overflow-y: auto; padding: var(--sp-1) var(--sp-2) var(--sp-2) 0; }
.attach-card { position: relative; flex: none; display: flex; align-items: center; gap: var(--sp-2); max-width: 232px; height: 52px; padding: var(--sp-1) var(--sp-6) var(--sp-1) var(--sp-1); border: 1px solid var(--edge); border-radius: var(--r-view); background: var(--fill); }
.attach-card[data-kind="image"] { width: 52px; padding: 0; }
.attach-thumb { position: relative; flex: none; width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; overflow: hidden; background: var(--surface); color: var(--dim); --icon: var(--icon-lg); }
.attach-card[data-kind="image"] .attach-thumb { width: 50px; height: 50px; border-radius: calc(var(--r-view) - 1px); }
.attach-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.attach-spin { display: none; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid var(--run); border-right-color: transparent; border-radius: 50%; animation: spin var(--dur-spin) linear infinite; }
.attach-card[data-state="uploading"] .attach-spin { display: block; }
.attach-card[data-state="uploading"] .attach-thumb > :not(.attach-spin) { opacity: .3; }
.attach-meta { min-width: 0; display: flex; flex-direction: column; line-height: var(--lh-tight); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.attach-sub { white-space: nowrap; font-size: var(--fs-xs); color: var(--dim); font-variant-numeric: tabular-nums; }
/* 失败的卡片：红边、白底（红字在浅红底上不到 4.5:1）。 */
.attach-card[data-state="failed"] { border-color: var(--bad); background: var(--surface); }
.attach-card[data-state="failed"] .attach-sub { color: var(--bad); }
.attach-remove { position: absolute; top: var(--sp-1); right: var(--sp-1); width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--dim); --icon: 12px; }
.attach-remove:hover { background: var(--fill-2); color: var(--fg); }
.attach-card[data-kind="image"] .attach-remove { top: -6px; right: -6px; background: var(--surface); box-shadow: 0 0 0 1px var(--edge); }

/* —— 会话列表（侧栏）：新建会话 · 搜索 · 按时间分组的列表 · 账号区（另做） —— */
.sessions-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sessions-new { flex: none; display: flex; align-items: center; gap: var(--sp-3); min-height: var(--ctl-touch); margin: var(--sp-2) var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--sep); border-radius: var(--r-view); background: var(--surface); color: var(--fg); font-size: var(--fs-md); font-weight: var(--fw-medium); text-align: left; box-shadow: var(--shadow-seg); }
.sessions-new:hover { background: var(--hover); }
.sessions-new:active { background: var(--press); }
.sessions-new:disabled { opacity: .58; }
#sessions[data-switching="true"] .sessions-list { opacity: .58; pointer-events: none; }
.sessions-new .icon { width: var(--ctl-xs); height: var(--ctl-xs); display: grid; place-items: center; color: var(--dim); }
.sessions-search { flex: none; display: flex; align-items: center; gap: var(--sp-2); margin: 0 var(--sp-3) var(--sp-3); padding: var(--sp-2) var(--sp-3); min-height: var(--ctl-touch); border-radius: var(--r-item); background: var(--fill-2); color: var(--faint); }
.sessions-search:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.sessions-search input { flex: 1; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; font-size: var(--fs-md); }
.sessions-search input::placeholder { color: var(--faint); }
.sessions-search input:focus-visible { outline: none; }
.sessions-search input::-webkit-search-cancel-button { cursor: pointer; }
.sessions-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--sp-3) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); }
.sessions-group { flex: none; padding: var(--sp-4) var(--sp-2) var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--faint); }
.sessions-group:first-child { padding-top: var(--sp-2); }
.sessions-empty { padding: var(--sp-2); font-size: var(--fs-sm); color: var(--faint); }
.sessions-error { flex: none; margin: 0 var(--sp-3) var(--sp-3); font-size: var(--fs-sm); color: var(--bad); }
/* 每行一行字，放不下省略；悬停浅色圆角，当前会话填一层底色。 */
.session-item { position: relative; flex: none; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; min-height: var(--ctl-touch); padding: var(--sp-2) var(--sp-1) var(--sp-2) var(--sp-3); border-radius: var(--r-item); cursor: pointer; line-height: var(--lh-tight); }     /* 一行的标题用紧凑行高：14.5px × 1.75 + 16px 的内边距会把行撑到 41px，超出 40px 的触控高度 */
.session-item:hover { background: var(--hover); }
.session-item[data-current="true"] { background: var(--surface); box-shadow: var(--shadow-seg); cursor: default; }
.session-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); }
.session-item[data-current="true"] .session-title { font-weight: var(--fw-medium); }
.session-title.untitled { color: var(--dim); }
/* 全文搜索的命中：标题下面一行摘要（最多两行），命中的词用强调色的淡底 */
.session-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.session-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--faint); font-size: var(--fs-xs); line-height: var(--lh-tight); overflow-wrap: anywhere; }
.session-hit { padding: 0 1px; border-radius: 3px; background: var(--accent-soft); color: var(--fg); }
.session-rename { flex: 1; min-width: 0; padding: var(--sp-0) var(--sp-1); border: 1px solid var(--accent); border-radius: var(--r-xs); background: var(--surface); font-size: var(--fs-md); }
/* “…”：悬停、聚焦、当前会话、菜单开着时出现；触屏与窄窗口下常显（没有悬停）。 */
.session-more { flex: none; width: var(--ctl-xs); height: var(--ctl-xs); padding: 0; border: 0; border-radius: var(--r-xs); display: grid; place-items: center; background: transparent; color: var(--dim); visibility: hidden; }
.session-more:hover, .session-item[data-menu] .session-more { background: var(--hover); color: var(--fg); }
.session-item:hover .session-more, .session-item:focus-within .session-more, .session-item[data-current="true"] .session-more, .session-item[data-menu] .session-more { visibility: visible; }
@media (hover: none), (max-width: 820px) { .session-more { visibility: visible; } }
/* 每行一个状态位（V6 M5）：失败没看过的红点 > 结束没看过的蓝点 > 在跑的小转圈；都没有就不占地方。 */
.session-unseen, .session-failed, .session-active { flex: none; width: var(--dot); height: var(--dot); margin: 0 var(--sp-1); border-radius: 50%; }
.session-unseen { background: var(--accent); }
.session-failed { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.session-active { border: 1.5px solid var(--run); border-right-color: transparent; animation: spin var(--dur-spin) linear infinite; }
/* 等你确认：状态位里优先级最高，一枚黄色小胶囊写着“待确认”（触屏没有悬停，光一个圆点说不清；配色与顶栏的网关提示同一套）。 */
.session-waiting { flex: none; margin: 0 var(--sp-1); padding: 0 var(--sp-1); border-radius: var(--r-pill); background: var(--warn-soft); color: var(--warn); font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: var(--lh-tight); white-space: nowrap; }
/* 会话行的菜单（样子沿用标题菜单的 .mode-menu 浮层）。 */
.session-row-menu { min-width: 238px; }
/* 菜单里的一项：标题菜单与会话行菜单共用同一种行高、内边距、圆角、悬停（图标或勾在左边一列）。 */
.menu-item { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: var(--ctl); padding: var(--sp-1) var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg); font-size: var(--fs-md); text-align: left; }
.menu-item .icon { color: var(--dim); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item:active:not(:disabled) { background: var(--press); }
.menu-item:disabled { opacity: .5; }
.menu-item[data-testid="session-delete"]:not(:disabled), .menu-item[data-testid="session-delete"]:not(:disabled) .icon { color: var(--bad); }
.menu-item[data-armed="true"] { background: var(--bad-soft); font-weight: var(--fw-semibold); }
.menu-sep { height: 1px; margin: var(--sp-1) var(--sp-2); background: var(--sep); }
.menu-note { max-width: 260px; padding: var(--sp-1) var(--sp-2) var(--sp-2); font-size: var(--fs-xs); color: var(--dim); }
/* 账号区：侧栏底部，空着时不占地方。 */
.account-slot { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: var(--sp-2); border-top: 1px solid var(--sep); }
.account-slot:empty { display: none; }
/* 账号区里的一行（account.js）：首字头像 + 用户名，点了打开标题菜单。 */
.account-entry { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-width: 0; padding: var(--sp-1) var(--sp-2); border: 0; border-radius: var(--r-item); background: transparent; color: var(--fg); font-size: var(--fs-md); text-align: left; }
.account-entry:hover { background: var(--hover); }
.account-entry:active { background: var(--press); }
.account-avatar { flex: none; width: var(--ctl-sm); height: var(--ctl-sm); border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: var(--on-accent); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.account-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 游客（account.js，协议 §421）：头像里是人像图标，其余与登录用户同一个样子；整行点开登录框。 */
.account-avatar .icon { display: grid; place-items: center; }

/* —— 右侧面板 —— */
/* 分隔条：拖动调整面板宽度（main.js；宽度记在 localStorage）。平时看不见，指针移上去或拖动时才显出来。 */
#split { flex: none; width: 6px; margin-right: -6px; z-index: 1; cursor: col-resize; touch-action: none; }
#split:hover, #split[data-drag] { background: var(--accent-soft); }
/* 对话列留最小宽度（窄窗口时少一些），面板可以收缩（flex-shrink）让出位置：面板宽度按像素记在 localStorage，在大屏或小缩放下拖宽过、
   换到窄一些的窗口再打开，原来面板顶到上限、对话列被挤成几十像素一列字（Edge 上报“打开右侧栏后页面被吞掉”，刷新也一样，因为记的宽度不变） */
#panel { flex: 0 1 auto; width: var(--panel-w, 52%); min-width: 320px; max-width: calc(100% - 340px); min-height: 0; display: flex; flex-direction: column; background: var(--panel-bg); border-left: 1px solid var(--sep); }
#panel[data-open="false"] { display: none; }
body:not([data-panel="true"]) #split { display: none; }
/* 顶栏：像 Safari 的标签条——标题（标签）与右边的关闭按钮同在一行。条是下凹的轨道，选中的标签是浮起的亮块（细边加两层投影），
   没选中的标签平着、悬停才有底色，相邻的两个没选中的标签之间一道细线。底下一条细线把顶栏与内容分开。 */
.panel-bar { flex: none; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); min-height: var(--top-h); min-width: 0; margin-bottom: var(--sp-3); border-bottom: 1px solid var(--sep); }
.panel-tabs { flex: 1 1 auto; display: flex; align-items: center; gap: var(--sp-0); min-width: 0; padding: var(--sp-0); border-radius: var(--r-item); background: var(--seg-track); overflow-x: auto; scrollbar-width: none; }
.panel-tabs[hidden] { display: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
/* 每个标签是一个外层容器：里面是“选择”按钮（图标加名字）和“关闭”按钮（×，悬停或选中时才露出，和浏览器一样）。 */
.panel-tabs > .panel-tab { position: relative; flex: 1 1 0; min-width: 112px; max-width: 240px; min-height: var(--ctl-sm); display: inline-flex; align-items: center; border-radius: var(--r-sm); color: var(--dim); }
.panel-tab > button[role="tab"] { flex: 1; min-width: 0; align-self: stretch; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.panel-tab:has(.panel-tab-close) > button[role="tab"] { padding-right: var(--sp-1); }
.panel-tab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-tabs > .panel-tab:hover:not(.on) { background: var(--hover); color: var(--fg); }
.panel-tabs > .panel-tab.on { background: var(--seg-on); color: var(--fg); box-shadow: var(--shadow-tab); }
.panel-tabs > .panel-tab:not(.on) + .panel-tab:not(.on)::before { content: ""; position: absolute; left: calc(-1 * var(--sp-0) / 2); top: 25%; height: 50%; width: 1px; background: var(--sep); }
.panel-tabs > .panel-tab:hover::before, .panel-tabs > .panel-tab:hover + .panel-tab::before { visibility: hidden; }
.panel-tab-close { flex: none; width: 20px; height: 20px; margin-right: var(--sp-1); padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--faint); --icon: 12px; opacity: 0; transition: opacity var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease); }
.panel-tab:hover .panel-tab-close, .panel-tab.on .panel-tab-close, .panel-tab-close:focus-visible { opacity: 1; }
.panel-tab-close:hover { background: var(--press); color: var(--fg); }
@media (hover: none) { .panel-tab-close { opacity: 1; } }      /* 触屏没有悬停：一直露着 */
.panel-bar [data-testid="panel-close"] { margin-left: auto; }
.pane { display: none; flex: 1; min-width: 0; min-height: 0; margin: 0 var(--sp-3) var(--sp-3); flex-direction: column; gap: var(--sp-3); }
#panel[data-kind="view3d"] .pane[data-pane="view3d"],
#panel[data-kind="sketch2d"] .pane[data-pane="sketch2d"],
#panel[data-kind="file"] .pane[data-pane="file"],
#panel[data-kind="flow"] .pane[data-pane="flow"],
#panel[data-kind="rules"] .pane[data-pane="rules"] { display: flex; }
#panel[data-kind="report"] .pane[data-pane="report"],
#panel[data-kind="result"] .pane[data-pane="result"],
#panel[data-kind="record"] .pane[data-pane="record"] { display: flex; }
#panel[data-kind="record"] .pane[data-pane="record"] { overflow-y: auto; }
#viewport { flex: 1; min-width: 0; min-height: 0; position: relative; overflow: hidden; border-radius: var(--r-view); background: var(--stage); touch-action: none; box-shadow: var(--shadow-view); }
#viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* 桌面端自检：品红边框是对齐的标尺——原生画面应当恰好填满边框以内，四边都露出边框。 */
.selftest #viewport { border: 3px solid var(--ruler); border-radius: 0; background: var(--ruler-bg); }
#objects { flex: none; max-height: 120px; overflow: auto; }
/* 轨迹播放条（协议第 65 节）：在 3D 区域下面 */
.traj { flex: none; display: flex; flex-direction: column; gap: var(--sp-1); }
.traj[hidden] { display: none; }
.traj-row { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.traj-slider { flex: 1; min-width: 60px; accent-color: var(--accent); }
.traj-time { flex: none; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--fg); }
.traj-note { font-size: var(--fs-xs); color: var(--dim); }
.traj-note[data-error="true"] { color: var(--bad); }
.traj-play, .traj-close { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; }
#sketch { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: var(--r-view); background: var(--paper); color: var(--on-paper); box-shadow: var(--shadow-view); }
#sketch svg { max-width: 100%; max-height: 100%; }
/* chemkit 2D 窗口（chemkit-2d.js，协议 §277）：与 #sketch 同一个外框；有窗口时 #sketch（静态 SVG 的退路）自己不显示，仍留着做“有没有图”的标记。 */
#sketch-window { flex: 1; min-height: 0; display: flex; overflow: hidden; border-radius: var(--r-view); background: var(--paper); box-shadow: var(--shadow-view); }
#sketch-window[hidden] { display: none; }
/* iframe 里 chemkit 的画布在四边各画了一圈 1 像素的近黑线（直接打开 chemkit-2d/index.html 四边都有，不是这里的边框或阴影）：
   iframe 四边各外扩 1px，让外框的 overflow: hidden（与圆角）把这一圈裁掉。 */
#sketch-window .sketch-frame { flex: none; margin: -1px; width: calc(100% + 2px); height: calc(100% + 2px); border: 0; background: var(--paper); }
#sketch[data-window="true"] { display: none; }
.pane-empty { margin: auto; color: var(--faint); font-size: var(--fs-md); text-align: center; }
.pane-empty[data-problem="true"] { color: var(--bad); padding: 0 var(--sp-4); }        /* 2D 起不来的原因（缺字体等）：照样写在空白页里，用失败色 */
#sketch:not([hidden]) + .pane-empty { display: none; }

/* —— 窄窗口（手机宽度）：面板改为盖住对话的整页，会话列表盖在左边 ——
   只在浏览器端这样做（main.js 在桌面端给 <html> 加 native）：桌面端的 3D 是原生窗口，盖住整页的话对话就点不到了。 */
@media (max-width: 820px) {
  :root:not(.native) #split { display: none; }
  :root:not(.native) #panel { position: fixed; inset: var(--top-h) 0 0 0; width: auto; min-width: 0; max-width: none; border-left: 0; z-index: 5; }
  /* 会话侧栏：默认收着（sessions.js），展开时是盖在对话上的浮层——顶栏（含开关）留在上面，侧栏从顶栏下面起，遮罩（z-index 6）垫在它（7）后面、盖在窄窗口的面板（5）上面。 */
  :root:not(.native) #sessions { position: fixed; inset: var(--top-h) auto 0 0; z-index: 7; flex-basis: auto; width: min(280px, calc(100vw - 48px)); min-width: 0; box-shadow: var(--shadow-2); }
}
/* 遮罩（sessions.js 只在窄窗口的浮层打开时显示它）：盖住顶栏以下的整个页面，点它收起侧栏。 */
.sessions-scrim { position: fixed; inset: var(--top-h) 0 0 0; z-index: 6; background: var(--backdrop); }

/* 编辑器（协议第 154 节）：盖在当前内容上的一层。开着时其余的页只藏不销毁，所以滚动位置、子选项卡、展开状态“返回”后原样都在。 */
.pane[data-pane="editor"] { overflow: auto; }
#panel[data-editing="true"] .pane:not([data-pane="editor"]) { display: none; }
#panel[data-editing="true"] .pane[data-pane="editor"] { display: flex; }

/* 持续反馈：输入框右下角与对话末尾是同一个组件 .activity-line（turn-activity.js 的 activityLine）——转圈 + 一句短话，只有位置不同。
   data-kind：busy / computing 在转；waiting（等你确认）/ offline（等重连）是静止的半透明圈。 */
.activity-line { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-xs); color: var(--faint); }
.activity-line::before { content: ""; flex: 0 0 10px; width: 10px; height: 10px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: turn-spin var(--dur-spin) linear infinite; }
.activity-line:is([data-kind="waiting"], [data-kind="offline"])::before { animation: none; border-right-color: currentColor; opacity: .5; }
.activity-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-activity { max-width: 65%; }
@keyframes turn-spin { to { transform: rotate(360deg); } }

.attachment-menu { position: fixed; z-index: 1000; min-width: 176px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; padding: var(--sp-1); border: 1px solid var(--edge); border-radius: var(--r-view); background: var(--surface); box-shadow: var(--shadow-2); }
.attachment-option { display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: var(--sp-2) var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg); text-align: left; }
.attachment-option:hover { background: var(--hover); }
.attachment-option .icon { width: 18px; height: 18px; color: var(--dim); }

/* 手机窄屏走查补的（2026-11-15）：右侧面板的标签（28 高）到 36，仍在 --top-h 的标签条里放得下。 */
@media (pointer: coarse), (max-width: 820px) {
  .panel-tabs > .panel-tab { min-height: 36px; }
}
/* 游客（composer.js，协议 §421）：输入框下一行的剩余点数。 */
