/* 对话页。布局与顶栏参考 Grok Bot，对话流与输入框参考 Codex：
   顶栏 56（头像 + 名称 | 新对话 · 信息面板），760 阅读列；用户消息是浅灰气泡，机器人回复是整列正文；
   底部是两行输入框（文字区 + 工具栏：更多 | 模型 · 发送）。
   顶栏和输入框盖在对话流上：几乎不透，消息从底下滚过去只隐约看得到。 */
@layer app {
/* 对话列和输入框同宽、同一个居中列（两侧至少 --page-gutter）。输入框浮在主区底部，
   对话列的下边距和"回到底部"的位置都从它的高度算出来，改输入框的内边距时这里跟着变。 */
.chat, .composer {
  --composer-line: calc(24px * var(--fs-scale));   /* 输入框的行高：跟着设置 › 外观 › 字体大小变 */
  --composer-pad: var(--space-2-5); /* 工具栏离输入框的左、右、下边：加号和发送钮都贴着这条线 */
  /* 一行字时输入框的高度：文字区（上 16 + 行高 + 下 4）+ 工具栏（上 6 + 发送钮 + 下 --composer-pad） */
  --composer-h: calc(var(--space-4) + var(--composer-line) + var(--space-1) + var(--space-1-5) + var(--ctl-lg) + var(--composer-pad));
}
.chat {
  --col: min(var(--col-w), calc(100% - 2 * var(--page-gutter)));
  --dock-pb: var(--space-4);      /* 输入框离主区下沿 */
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
}

/* —— 顶栏：对话页里盖在滚动内容上，靠毛玻璃和内容分开，不画线、不加投影 —— */
.chat-head {
  flex: none; display: flex; align-items: center; gap: var(--bar-gap); height: var(--head-h); padding: 0 var(--head-px);
  -webkit-app-region: drag;
}
.chat > .chat-head {
  position: absolute; z-index: var(--z-float); top: 0; left: 0; right: 0;
  background: var(--glass-chrome); backdrop-filter: var(--glass-filter);
}
.chat-head > * { -webkit-app-region: no-drag; }
.chat-head .grow { -webkit-app-region: drag; align-self: stretch; }
.chat-head .icon-btn { --ib-size: var(--ctl-md); }   /* 16 的图标四周各 --ib-inset：最右的图标外沿落在 --head-px + --ib-inset = --pane-px，和左边的头像对称 */
.head-bot {
  display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; height: var(--ctl-lg); padding: 0 var(--ctl-px-lg) 0 var(--ib-inset);
  border-radius: var(--r-ctl); font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--fg);
  transition: background var(--t-fast);
}
button.head-bot:hover { background: var(--pill); }
button.head-bot[aria-pressed="true"] { background: var(--pill-hover); }
button.head-bot:active { background: var(--pill-press); }
.head-bot .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* —— 对话流 ——
   滚动条总是占着右边那一条（scrollbar-gutter），输入框的底座也留同样一条：对话列和输入框按同一个宽度居中，左右边对齐 */
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; scroll-padding-top: var(--head-h); scrollbar-gutter: stable;
  /* 输入框下面那一窄条：内容淡出，露出主区本身 */
  mask-image: linear-gradient(to top, transparent, var(--black) var(--space-4));
}
/* 下边距 = 输入框占的高度 + 48，最后一条消息滚到底时停在输入框上方 */
.chat-col {
  width: var(--col); margin: 0 auto;
  padding: calc(var(--head-h) + var(--space-6)) 0 calc(var(--dock-pb) + var(--composer-h) + var(--space-12)); display: flex; flex-direction: column;
}
.chat-skel { display: grid; gap: var(--space-3-5); margin-top: var(--space-6); }
.chat-skel .skel { height: 34px; border-radius: var(--r-bubble); }
.chat-skel .skel:nth-child(2) { justify-self: end; }
.chat-col > .notice { margin-top: var(--space-2); }
/* 历史读到之后整列淡入一次（不是一行行弹出来）；之后的新消息各自有入场 */
.chat-col.ready { animation: fade-in var(--dur-base) var(--ease-out); }

.msg-row { position: relative; display: flex; flex-direction: column; margin-top: var(--space-5); }
.msg-row.cont { margin-top: var(--space-1); }
.msg-row.user { align-items: flex-end; }
.msg-row.assistant { align-items: stretch; }
.msg { font-size: var(--fs-xl); word-break: break-word; overflow-wrap: anywhere; cursor: text; }
.msg-row.user .msg {
  max-width: min(var(--bubble-w), 80%); padding: var(--space-3) var(--space-5); border-radius: var(--r-bubble);
  background: var(--bubble-user); color: var(--fg); line-height: var(--lh-relaxed); white-space: pre-wrap;
}
.msg-row.assistant .msg { color: var(--fg); line-height: var(--lh-prose); }
.msg-row.pending .msg { opacity: .85; }

/* —— 对话流的动效：一句话"发出 → 思考 → 输出 → 收尾"，每一步只动一样东西，只淡入淡出，不位移、不缩放 —— */
.msg-row.user.enter, .msg-row.assistant.enter { animation: fade-in var(--dur-base) var(--ease-out); }
/* 思考：工作状态行比你的气泡晚一拍（--stagger）淡入，先看到"发出去了"，再看到"在想" */
.msg-row.live > .work { animation: fade-in var(--dur-moderate) var(--ease-out) var(--stagger) backwards; }
/* 输出：新出现的段落、列表项淡入，已经在的不重播；只在输出中，回复结束后不再有动画 */
.msg-row.live .md > *, .msg-row.live .md > :is(ul, ol) > li + li { animation: fade-in var(--dur-moderate) var(--ease-out); }
/* 输出中：最后一段文字末尾一个慢慢呼吸的小点，视线不用离开正在读的地方就知道"还在写"（代码块、表格结尾不画） */
.msg-row.live .md > :is(p, h1, h2, h3, h4):last-child::after,
.msg-row.live .md > :is(ul, ol):last-child > li:last-child:not(:has(> :is(ul, ol)))::after,
.msg-row.live .md > blockquote:last-child > :last-child::after {
  content: ""; display: inline-block; width: .45em; height: .45em; margin-left: .35em; vertical-align: .08em;
  border-radius: 50%; background: var(--muted);
  animation: breathe var(--dur-pulse) var(--ease-in-out) infinite;
}

/* 回复上方的工作状态：进行中带微光，结束后是一行灰字的"用时"，和正文之间只留间距，不画线。
   外面包一层可以收起的轨道 .work（grid 1fr → 0fr）：很快答完、不显示"用时"的回复，这一行平滑收起，
   正文不会一下跳上去。这是对话流里唯一的布局动画，只播一次 */
.work { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--t-moderate), opacity var(--t-base); }
.work.gone { grid-template-rows: 0fr; opacity: 0; }
.work-in { min-height: 0; overflow: hidden; }
.work-line {
  display: flex; align-items: center; gap: var(--space-1-5); padding-bottom: var(--space-1); margin-bottom: var(--space-3);
  font-size: var(--fs-md); color: var(--muted);
}
.msg-row.assistant .work-line:last-child { margin-bottom: 0; }

/* 处理过程（代理回合）：工作状态行可以展开，默认折叠；展开后是一块 --well，步骤之间不画线。
   每步一行：状态点 + 类别图标 + 名称 + 等宽摘要 + 用时；有参数或输出的步骤再点开看全文 */
.work-line.toggle { width: 100%; text-align: left; transition: color var(--t-fast); }
.work-line.toggle:hover { color: var(--fg); }
.work-line .chev, .act-head .chev { flex: none; transition: transform var(--t-fast); }
[aria-expanded="true"] > .chev { transform: rotate(90deg); }
.activity { display: grid; grid-template-columns: minmax(0, 1fr); }
.activity.open > .work-line { margin-bottom: var(--space-2); }
.msg-row.assistant .activity + .notice { margin-top: var(--space-1); }
/* 一块 --well 里不画行间分隔线：步骤是内缩的行，悬停才浮出底色（与菜单项同一写法：列表离边 --list-pad，项再缩 --item-px，字在 16 的内容线上）；
   展开只是折叠打开：参数和输出直接排在这一行下面，不再套底色或内边距 */
.act-list { --act-r: var(--r-item-sm); list-style: none; margin: 0 0 var(--space-3); padding: var(--list-pad); background: var(--well); border-radius: var(--r-card); font-size: var(--fs-sm); display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.act-list.empty { padding: var(--space-2-5) var(--group-pad); }
.act-step { min-width: 0; border-radius: var(--act-r); }
.act-head {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--ctl-md);
  padding: var(--space-1) var(--item-px); color: var(--fg-2); text-align: left; border-radius: var(--act-r);
}
button.act-head { --focus-offset: -2px; transition: background var(--t-fast); }
button.act-head:hover { background: var(--pill); }
button.act-head:active { background: var(--pill-hover); }
.act-head .k { flex: none; color: var(--muted); }
.act-head .t { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); font-weight: var(--fw-medium); }
.act-head .s { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--code); font-size: var(--fs-xs); color: var(--muted); }
.act-head .d { flex: none; font-size: var(--fs-xs); color: var(--muted); }
.act-body { display: grid; gap: var(--space-1); padding: 0 var(--item-px) var(--space-1-5); }
.act-body .t-label { margin-top: var(--space-1); }
.act-body pre {
  margin: 0; max-height: 240px; overflow: auto; font: var(--fs-xs)/var(--lh-relaxed) var(--code);
  color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere;
}

.msg-row.assistant > .work-line:last-child, .msg-row.assistant > .work:last-child .work-line { margin-bottom: 0; }
/* "思考中 → 正在回复 → 用时"换阶段时文字淡入（换的是 key，秒数跳动不重播） */
.work-line > .wl { animation: fade-in var(--dur-base) var(--ease-out); }
/* 文字微光：底色是 --muted，一道 --fg-2 的光慢慢扫过去再停一拍；对比只差一档，余光里知道"在动"就够了 */
.shimmer {
  color: transparent;
  background: linear-gradient(90deg, var(--muted) 35%, var(--fg-2) 50%, var(--muted) 65%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  animation: sheen var(--dur-sheen) var(--ease-in-out) infinite;
}
.work-line > .wl.shimmer { animation: fade-in var(--dur-base) var(--ease-out), sheen var(--dur-sheen) var(--ease-in-out) infinite; }

/* 消息下方的操作：悬停出现；最后一条回复常显 */
.msg-actions {
  display: flex; align-items: center; gap: var(--bar-gap); height: var(--ctl-sm); margin-top: var(--space-0-5);
  color: var(--muted); opacity: 0; transition: opacity var(--t-fast);
}
.msg-row.user .msg-actions { flex-direction: row-reverse; }
.msg-row:hover .msg-actions, .msg-row.last .msg-actions, .msg-actions:focus-within { opacity: 1; }
/* 收尾：回复写完，复制和时刻晚一拍淡入（输出中不出现，免得在正文下面闪） */
.msg-row.assistant.last .msg-actions { animation: fade-in var(--dur-moderate) var(--ease-out) var(--stagger) backwards; }
.msg-actions .when { font-size: var(--fs-xs); }
.msg-actions .icon-btn { --ib-size: var(--ctl-sm); }

.caret { display: inline-block; width: 7px; height: 15px; margin-left: var(--space-0-5); vertical-align: -2px; border-radius: 1px; background: var(--accent); animation: blink var(--dur-blink) steps(2) infinite; }
.typing { display: inline-flex; gap: var(--space-1); padding: var(--space-2) var(--space-0-5); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: breathe var(--dur-shimmer) var(--ease-in-out) infinite; }
.typing i:nth-child(2) { animation-delay: var(--stagger); }
.typing i:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }

.time-sep { align-self: center; margin: var(--space-8) 0 0; font-size: var(--fs-xs); color: var(--muted); }
.time-sep + .msg-row { margin-top: var(--space-4); }
/* 「已开始新对话」：用户主动开新对话的位置，一条灰色细线中间一行小字（刷新、重开后仍在原位置） */
.conv-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-8) 0 var(--space-2); font-size: var(--fs-xs); color: var(--muted); }
.conv-divider::before, .conv-divider::after { content: ""; flex: 1; height: var(--hairline); background: var(--line); }
.conv-divider.enter { animation: fade-in var(--dur-base) var(--ease-out); }
.conv-divider + .msg-row, .conv-divider + .time-sep { margin-top: var(--space-4); }
/* 对话底部的轻提示（已经是新对话了 / 代理没有启用 / 没能开始新对话）：输入框上方一颗深色胶囊，几秒后消失 */
.chat-hint {
  position: absolute; z-index: var(--z-float); left: 50%; bottom: calc(var(--dock-pb) + var(--composer-h) + var(--space-6)); translate: -50% 0;
  max-width: min(480px, calc(100% - 2 * var(--page-gutter))); padding: var(--space-1-5) var(--ctl-px-md); border-radius: var(--r-ctl);
  background: var(--primary); color: var(--on-primary); font-size: var(--fs-sm); line-height: var(--lh-normal); text-align: center; overflow-wrap: anywhere;
  box-shadow: var(--shadow-float); pointer-events: none; animation: fade-in var(--dur-base) var(--ease-out);
}

/* markdown：回复是正文，标题和段落有呼吸感 */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table, .md hr { margin: 0 0 var(--space-3); }
.md h1, .md h2, .md h3, .md h4 { margin: var(--space-5) 0 var(--space-2); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-normal); }
.md h1 { font-size: var(--fs-2xl); letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); }
.md h4 { font-size: var(--fs-lg); }
.md h5, .md h6 { margin: var(--space-4) 0 var(--space-2); font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: var(--lh-normal); }
.md h6 { color: var(--fg-2); }
/* 任务列表：只读的勾选框，落在列表符号的位置上 */
.md li.task { list-style: none; }
.md li.task > input { margin: 0 var(--space-2) 0 calc(-1 * var(--space-5)); vertical-align: -2px; accent-color: var(--accent); }   /* 微调：勾选框和文字基线对齐 */
/* Markdown 图片（PRD R7、R8）：对话里最宽 360、最高 320，预览里不超过正文宽度；等比缩小不裁切。加载中是一块浅灰，失败是虚线占位 */
.md .md-img { position: relative; display: block; width: fit-content; max-width: 100%; margin: var(--space-2) 0; border-radius: var(--r-card); overflow: hidden; cursor: zoom-in; }
.md .md-img img { display: block; width: auto; height: auto; max-width: min(100%, 360px); max-height: 320px; }
.md .md-img.doc img { max-width: 100%; max-height: none; }
.md a .md-img, .md .md-img:is(span) { cursor: inherit; }
.md .md-img.loading { width: min(100%, 360px); height: 120px; background: var(--well); }
.md .md-img.doc.loading { width: 100%; height: 160px; }
.md .md-img.loading img { position: absolute; inset: 0; opacity: 0; }
.md-img-fail {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1); width: min(100%, 360px); margin: var(--space-2) 0; padding: var(--space-4) var(--space-3);
  border: 1px dashed var(--line-2); border-radius: var(--r-card); color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh-normal); text-align: center;   /* 描边：图片没加载出来时的占位，虚线表示"这里本该有一张图" */
}
.md-img-fail.doc { width: 100%; }
.md-img-fail .ic { color: var(--faint); }
.md-img-alt { color: var(--fg-2); font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.md-img-src { display: inline-flex; align-items: baseline; gap: var(--space-1); max-width: 100%; font-size: var(--fs-xs); }
.md-img-src .v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-img-fail .link { color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.md-img-fail .link:hover { color: var(--fg); }
.md ul, .md ol { padding-left: var(--space-6); }
.md li + li { margin-top: var(--space-1); }
.md blockquote { padding-left: var(--space-3); border-left: 3px solid var(--line); color: var(--fg-2); }   /* 描边：引文的排版记号（灰色、不圈住内容），不是提示框的色条 */
.md hr { border: 0; border-top: 1px solid var(--line); }
.md code { font-size: .86em; padding: .12em .36em; border-radius: var(--r-mark); background: var(--code-bg); }   /* 跟着所在文字缩放：正文、标题、表格里一样合身 */
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md .table-wrap { overflow-x: auto; margin: 0 0 var(--space-3); }
.md table { border-collapse: collapse; font-size: var(--fs-md); line-height: var(--lh-normal); margin: 0; }
/* 表格不画格子：只有表头下一条 --line-2，行与行之间靠行高分开，没有外框、竖线和表头底色；列靠右边距分开，第一列贴着正文左边 */
.md th, .md td { padding: var(--space-1-5) var(--space-5) var(--space-1-5) 0; text-align: left; vertical-align: top; }
.md :is(th, td):last-child { padding-right: 0; }
.md th { font-weight: var(--fw-semibold); border-bottom: 1px solid var(--line-2); }
/* 代码块：一块 --well，不描边 */
.codeblock { margin: 0 0 var(--space-3); border-radius: var(--r-card); background: var(--well); overflow: hidden; }
/* 语言名和代码左对齐，都在组的内容线（--group-pad）上；复制钮离右边和上边一样远（36 高的条里放 28 的按钮，四周 4） */
.codeblock .bar {
  display: flex; align-items: center; height: var(--ctl-lg); padding: 0 var(--space-1) 0 var(--group-pad);
  font-family: var(--code); font-size: var(--fs-2xs); color: var(--muted);
}
.codeblock .bar .lang { flex: 1; }
.codeblock .bar .icon-btn { --ib-size: var(--ctl-sm); }
.codeblock pre { margin: 0; padding: 0 var(--group-pad) var(--group-pad); overflow-x: auto; font: var(--fs-sm)/var(--lh-relaxed) var(--code); color: var(--fg); white-space: var(--code-wrap); overflow-wrap: anywhere; }
.codeblock pre code { font-size: inherit; padding: 0; background: none; }

/* 流里的一组：提问 / 审批 / 文件。一块 --well，不描边、不加投影；里面不再套框——
   命令是一行等宽字，选项是可悬停的行，只有输入框留着自己的边 */
.card {
  width: min(var(--bubble-w), 100%); background: var(--well); border-radius: var(--r-card-lg);
  padding: var(--card-pad); display: grid; gap: var(--stack-gap);
}
.card .q { font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--fg); line-height: var(--lh-snug); }
.card .q-detail { font-size: var(--fs-md); color: var(--fg-2); line-height: var(--lh-normal); white-space: pre-wrap; }
.card .q-block { display: grid; gap: var(--space-2); }
.card .opts { display: grid; gap: var(--space-0-5); margin: 0 calc(-1 * var(--item-px)); }   /* 选项的悬停底往外伸出 --item-px，字仍在卡片的内容线上 */
.card .opt {
  --focus-offset: 0px;
  display: flex; align-items: center; gap: var(--space-2-5); min-height: var(--ctl-xl); padding: var(--space-1) var(--item-px); border-radius: var(--r-item);
  text-align: left; font-size: var(--fs-lg); line-height: var(--lh-snug); color: var(--fg); transition: background var(--t-fast);
}
.card .opt:hover:not(:disabled) { background: var(--pill); }
.card .opt:active:not(:disabled) { background: var(--pill-hover); }
/* 选项字母平时只是一列字；选中后才填成一块（这是状态，不是容器） */
.card .opt .letter {
  width: var(--ctl-xs); height: var(--ctl-xs); border-radius: var(--r-tile-sm); flex: none; display: grid; place-items: center;
  color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), color var(--t-fast);
}
.card .opt:hover:not(:disabled) .letter { color: var(--fg); }
.card .opt .desc { display: block; margin-top: var(--space-0-5); font-size: var(--fs-sm); color: var(--muted); }
.card .opt.picked .letter, .card .opt.picked:hover .letter { background: var(--fg); color: var(--surface-solid); }
.card.done .q { color: var(--muted); }
.card.done .opt { color: var(--placeholder); }
.card .meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--muted); }
.card .actions { display: flex; gap: var(--ctl-gap); flex-wrap: wrap; }
.card .cmd {
  font: var(--fs-sm)/var(--lh-normal) var(--code);
  white-space: pre-wrap; word-break: break-all; color: var(--fg-2); max-height: 160px; overflow: auto;
}
.card .answer { display: flex; gap: var(--ctl-gap); }
/* 交付的文件（components/files.js）：按交付的顺序挂在回复的文字下面，放得下就排在一行。
   文件卡片是一块 --well，整块可点（打开），悬停深一级；桌面版右边一个「在文件夹中显示」。找不到的文件不能点 */
.msg-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); }
.msg-row .msg + .msg-files { margin-top: var(--space-3); }
.msg-row :is(.msg, .msg-files) + .notice { margin-top: var(--space-3); }
/* 回合中交付的：淡入（已经在的不重播） */
.msg-row.live .msg-files > * { animation: fade-in var(--dur-moderate) var(--ease-out); }
.file-card {
  display: flex; align-items: center; gap: var(--space-3); width: min(360px, 100%); padding: var(--space-2-5) var(--group-pad) var(--space-2-5) var(--space-2);
  background: var(--well); border-radius: var(--r-card); color: var(--fg); text-align: left; transition: background var(--t-fast);
}
a.file-card:hover { text-decoration: none; }
a.file-card:hover, .file-card:has(> .file-open:hover) { background: var(--well-hover); }
a.file-card:active, .file-card:has(> .file-open:active) { background: var(--well-press); }
.file-card:has(> .file-open) { padding-right: var(--space-2); }
.file-open { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; text-align: left; border-radius: var(--r-item-sm); }
.file-card .fic { flex: none; --ic-size: var(--ic-xl); margin: var(--space-2); color: var(--fg-2); }   /* 24px 图标 + 四周 8 = 40 见方，和两行文字等高；卡片左边 8 + 8，图标落在组的内容线（16）上 */
.file-card .grow { display: grid; min-width: 0; }
.file-card .fname { font-size: var(--fs-lg); font-weight: var(--fw-medium); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .fsub { margin-top: var(--space-0-5); font-size: var(--fs-xs); color: var(--muted); }
.file-card.off .fname { color: var(--muted); }
/* 图片直接显示：缩略图保持比例，限宽限高（读出来之前先占一小块 --well）；点开看大图 */
.msg-img { display: block; max-width: 100%; overflow: hidden; border-radius: var(--r-card); background: var(--well); cursor: zoom-in; }
.msg-img img { display: block; width: auto; height: auto; min-width: 48px; min-height: 48px; max-width: min(320px, 100%); max-height: 240px; }
.msg-row .notice { max-width: min(var(--bubble-w), 100%); }

.chat-empty { margin: auto; padding-top: 16vh; display: grid; justify-items: center; gap: var(--space-3); text-align: center; color: var(--muted); }
/* 头像和标题之间多留一点：大头像会呼吸、会动，贴太近显得挤 */
.chat-empty h2 { margin-top: var(--space-3); font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); color: var(--fg); }
.chat-empty { --empty-w: 480px; }   /* 标题下那句说明的栏宽；群聊的引导区（规则、示例）也用这一栏 */
.chat-empty > p { max-width: var(--empty-w); margin: 0; font-size: var(--fs-lg); line-height: var(--lh-normal); }
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-4); }
/* 建议：和次级按钮一样是一层静默填充，不描边、不浮起 */
.chip {
  height: var(--ctl-lg); padding: 0 var(--ctl-px-lg); border-radius: var(--r-ctl); background: var(--pill);
  font-size: var(--fs-sm); color: var(--fg-2); transition: background var(--t-fast), color var(--t-fast);
}
.chip:hover { background: var(--pill-hover); color: var(--fg); }
.chip:active { background: var(--pill-press); }

/* —— 回到底部：玻璃小圆钮 —— */
.to-bottom {
  position: absolute; z-index: var(--z-float); left: 50%; bottom: calc(var(--dock-pb) + var(--composer-h) + var(--space-6)); translate: -50% 0;
  width: var(--ctl-lg); height: var(--ctl-lg); border-radius: 50%; display: grid; place-items: center;
  background: var(--glass-float); backdrop-filter: var(--glass-filter-sm); color: var(--fg-2); box-shadow: var(--shadow-float);
  animation: fade-in var(--dur-base) var(--ease-out);
  transition: color var(--t-fast);
}
.to-bottom.leaving { animation: fade-out var(--dur-base) var(--ease-in) forwards; pointer-events: none; }
.to-bottom:hover { color: var(--fg); }
.to-bottom .new { position: absolute; top: 0; right: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 2px var(--surface-solid); }   /* 描边：压在圆钮上的缺口（和底同色），不是边框 */
.to-bottom .new { animation: fade-in var(--dur-base) var(--ease-out); }

/* —— 输入框：文字区 + 工具栏两行，盖在对话流上的一块实色填充（比主区深一档），不描边、不加投影。
   拖入文件时再深一级并加一圈淡光晕 —— */
/* 底座是透明的、不接收指针 */
.composer-dock {
  position: absolute; z-index: var(--z-float); left: 0; right: 0; bottom: 0; padding: var(--space-12) 0 var(--dock-pb); pointer-events: none;
  overflow: hidden; scrollbar-gutter: stable;
}
.composer {
  --composer-bg: color-mix(in srgb, var(--fg) 4.5%, var(--surface-solid));   /* 实色：盖在滚动的内容上，不能透出底下的字 */
  --composer-shadow: 0 0 transparent;
  --composer-tint: transparent;
  pointer-events: auto; position: relative;
  width: var(--col, auto); margin: 0 auto;
  display: flex; flex-direction: column;
  background: linear-gradient(var(--composer-tint), var(--composer-tint)), var(--composer-bg);
  border-radius: var(--r-composer);
  box-shadow: var(--composer-shadow);
  transition: box-shadow var(--t-fast), background var(--t-fast);
}
.composer.drag { --composer-shadow: 0 0 0 3px var(--accent-soft); --composer-tint: var(--pill); }   /* 描边：拖入文件时的淡光晕（临时的），告诉你可以松手 */
@media (forced-colors: active) { .composer { border: 1px solid CanvasText; } }   /* 描边：系统高对比度模式下没有填充，要一道系统色的边 */
.composer textarea {
  display: block; width: 100%; min-width: 0; border: 0; outline: none; background: transparent; resize: none;
  font-size: var(--fs-xl); line-height: var(--composer-line); padding: var(--space-4) var(--space-5) var(--space-1);
  max-height: calc(var(--composer-line) * 8 + var(--space-4) + var(--space-1)); overflow-y: auto; color: var(--fg);
}
.composer textarea::placeholder { color: var(--placeholder); }
.composer textarea:focus-visible { outline: none; }
.composer-bar { display: flex; align-items: center; gap: var(--bar-gap); padding: var(--space-1-5) var(--composer-pad) var(--composer-pad); }
.composer-bar .grow { flex: 1; }
/* 加号钮和发送钮一样是 36 的圆：加号的图标落在 --composer-pad + 10 = 20，和上面文字的起点对齐；模型胶囊矮一档（32），不和两端的圆钮抢 */
.composer :is(.plus, .model-chip) {
  flex: none; height: var(--ctl-md); display: inline-flex; align-items: center; justify-content: center; color: var(--ctl-fg);
  transition: background var(--t-fast), color var(--t-fast);
}
.composer :is(.plus, .model-chip):hover { background: var(--pill); color: var(--fg); }
.composer :is(.plus, .model-chip)[aria-expanded="true"] { background: var(--pill-hover); color: var(--fg); }
.composer :is(.plus, .model-chip):active { background: var(--pill-press); }
.composer .plus { width: var(--ctl-lg); height: var(--ctl-lg); border-radius: 50%; }
.composer .plus .ic { transition: transform var(--t-fast); }
.composer .plus[aria-expanded="true"] .ic { transform: rotate(45deg); }
.composer .model-chip { max-width: 240px; padding: 0 calc(var(--ctl-px-md) - var(--ctl-trail)) 0 var(--ctl-px-md); border-radius: var(--r-ctl); gap: var(--space-1); font-size: var(--fs-sm); }
.composer .model-chip .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer .model-chip .ic { --ic-size: var(--ic-xs); transition: transform var(--t-fast); }
.composer .model-chip[aria-expanded="true"] .ic:last-child { transform: rotate(180deg); }
.composer .model-chip .ic.lead { --ic-size: var(--ic-sm); }
.composer .model-chip.perm { max-width: 160px; }
/* 完全权限：胶囊常驻一层淡红，图标用 --red；字仍是 --fg（淡红底上的红字对比度不够）。悬停 / 打开 / 按下在淡红上再叠一层 */
.composer .model-chip.perm.full { background: var(--red-wash); color: var(--fg); }
.composer .model-chip.perm.full .ic.lead { color: var(--red); }
.composer .model-chip.perm.full:hover { background: linear-gradient(var(--pill), var(--pill)), var(--red-wash); }
.composer .model-chip.perm.full[aria-expanded="true"] { background: linear-gradient(var(--pill-hover), var(--pill-hover)), var(--red-wash); }
.composer .model-chip.perm.full:active { background: linear-gradient(var(--pill-press), var(--pill-press)), var(--red-wash); }
/* 发送：空的时候是中性的灰钮（不用半透明的主操作色，会发浑）；能发了才变成主操作色。
   发出后换成停止方块，回复结束换回箭头，都只是淡入 */
.send {
  width: var(--ctl-lg); height: var(--ctl-lg); border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--send-bg); color: var(--send-fg);
  transition: background var(--t-fast), color var(--t-fast);
}
.send.stop .ic, .send.back .ic { animation: fade-in var(--dur-base) var(--ease-out); }
.send:hover:not(:disabled) { background: var(--primary-hover); }
.send:active:not(:disabled) { background: var(--primary-press); }
.send:disabled:not([aria-busy="true"]) { background: var(--pill); color: var(--faint); }
/* 正在停止：保持本色转圈，只是不可点（同 Button 的 loading） */
.send[aria-busy="true"] { cursor: progress; }
.send .spinner { width: 12px; height: 12px; }
.composer-disabled { pointer-events: auto; width: var(--col); margin: 0 auto var(--space-2); }

/* —— 后台任务：请求那条消息的回复下面一个胶囊，一句话「后台任务「GPU 价格调研」进行中 ›」（静默填充，不描边；太长时只截标题）；
   点开是最新进展、文件夹、每次运行折叠的处理过程（和回复上方的"用时"同一种写法）和停止 —— */
.task-chip { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; margin-top: var(--space-2); }
.task-pill {
  display: inline-flex; align-items: center; gap: var(--space-1-5); max-width: 100%; height: var(--ctl-md); padding: 0 calc(var(--ctl-px-md) - var(--ctl-trail)) 0 var(--ctl-px-md);
  border-radius: var(--r-ctl); background: var(--pill); font-size: var(--fs-sm); color: var(--fg-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.task-pill:hover { background: var(--pill-hover); color: var(--fg); }
.task-pill:active { background: var(--pill-press); }
.task-pill .l { display: flex; min-width: 0; white-space: nowrap; }
.task-pill .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--fg); font-weight: var(--fw-medium); }
.task-pill .chev { flex: none; color: var(--muted); transition: transform var(--t-fast); }
.task-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); width: 100%; margin-top: var(--space-3); }
/* 详情里一行一样：小标签 + 值 + 行尾的大小、文字按钮（改预算、打开、保留）；每次运行一行折叠的处理过程，行间不画线 */
.task-line { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--fs-sm); color: var(--fg-2); }
.task-line .t-label { flex: none; min-width: 4em; }
.task-line .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-line .v.mono { font-family: var(--code); font-size: var(--fs-xs); }
.task-line .n { flex: none; font-size: var(--fs-xs); color: var(--muted); }
.task-line .task-note { display: block; color: var(--muted); }   /* 问题下面那一句：不回复就按中文做 */
.task-line .text { flex: none; margin: calc(-1 * var(--space-1)) 0; }   /* 文字按钮的悬停底不把行撑高 */
button.task-origin { text-align: left; font-size: inherit; color: inherit; border-radius: var(--r-mark); transition: color var(--t-fast); }
button.task-origin:hover { color: var(--fg); }
.task-budget-edit { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.task-budget-edit .field { width: 88px; --field-h: var(--ctl-sm); }
.task-detail .activity, .task-detail .work-line { margin-bottom: 0; }
.task-detail .work-line { border-bottom: 0; padding-bottom: 0; }
.task-actions { display: flex; justify-content: flex-start; gap: var(--space-1); }
}

/* —— 群聊（screens/group.js）：回复上面一行头像和名字；几个头像叠在一起；系统提示；建群时选成员 —— */
.msg-author { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1-5); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--fg-2); }
.group-note { margin-top: var(--space-4); text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.group-avatars { display: inline-flex; align-items: center; flex: none; }
.group-avatars .ga { display: inline-flex; }
.group-avatars .ga + .ga { margin-left: calc(var(--ga-size) * -.3); }
/* 侧栏行：两个头像错开放进一个头像的位置 */
.group-avatars.pile { position: relative; width: var(--ga-size); height: var(--ga-size); }
.group-avatars.pile .ga { position: absolute; left: 0; top: 0; }
.group-avatars.pile .ga + .ga { margin-left: 0; left: auto; top: auto; right: 0; bottom: 0; }
.group-picks { display: grid; gap: var(--space-1); max-height: 280px; overflow-y: auto; margin: 0 calc(-1 * var(--item-px)); }   /* 悬停底往外伸，名字和对话框里的文字对齐 */
.group-pick {
  display: flex; align-items: center; gap: var(--space-2-5); min-height: var(--ctl-xl); padding: var(--space-1) var(--item-px);
  border-radius: var(--r-item); font-size: var(--fs-md); color: var(--fg); text-align: left; transition: background var(--t-fast);
}
.group-pick:hover { background: var(--pill); }
.group-pick:active { background: var(--pill-press); }
.group-pick.on { background: var(--pill-hover); }
.group-pick .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-pick .ic { color: var(--accent); }

@layer app {
/* 新建群聊的空状态：群名、一句导语居中；三条规则和可点的示例在同一栏里左对齐、拉满栏宽（长句从左边整齐折行，不出孤字）。
   间距按分组留白：名称和导语一组（紧），导语到规则、规则到示例各隔一段，要点之间、卡片之间更紧 */
.group-empty { gap: 0; }
.group-empty > * { width: min(100%, var(--empty-w)); }
.group-empty > .group-avatars { width: auto; }
.group-empty h2 { margin: var(--space-6) 0 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.group-empty > p { margin-top: var(--space-2); }
.group-rules { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; gap: var(--space-2); text-align: start; font-size: var(--fs-md); line-height: var(--lh-normal); color: var(--fg-2); }
.group-rules li { position: relative; padding-inline-start: var(--space-4); overflow-wrap: anywhere; }
.group-rules li::before { content: ""; position: absolute; inset-inline-start: var(--space-1); top: 0.62em; width: var(--space-1); height: var(--space-1); border-radius: 50%; background: var(--faint); }
.group-examples { display: grid; gap: var(--space-2); margin-top: var(--space-5); }
/* 示例：和目录 Bot 开场里的示例卡片同一种——浅底、通栏、左对齐，悬停加深，一看就是可点的 */
.group-example {
  display: block; width: 100%; padding: var(--space-2-5) var(--group-pad); border-radius: var(--r-card); background: var(--pill); color: var(--fg-2);
  font-size: var(--fs-md); line-height: var(--lh-snug); text-align: start; overflow-wrap: anywhere; transition: background var(--t-fast), color var(--t-fast);
}
.group-example:hover { background: var(--pill-hover); color: var(--fg); }
.group-example:active { background: var(--pill-press); }

/* 任务出错（第 9 项）：一句主提示，恢复入口在右边；原始报错折叠在"错误详情"里，长 JSON 不撑破双栏和窄窗口 */
.notice .err-main { display: block; }
.notice .err-hint { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: var(--space-0-5); }
.notice .err-details { display: block; margin-top: var(--space-1-5); font-size: var(--fs-xs); min-width: 0; }
.err-details > summary { cursor: pointer; color: var(--muted); width: fit-content; }
.err-details > summary:hover { color: var(--fg); }
.err-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin-top: var(--space-1); color: var(--muted); }
.err-meta code { font-family: var(--code); overflow-wrap: anywhere; }
.err-raw { margin: var(--space-1) 0; max-height: calc(var(--fs-xs) * 12); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-family: var(--code); font-size: var(--fs-2xs); color: var(--fg-2); }
.notice:has(.err-details) { align-items: flex-start; flex-wrap: wrap; }
.notice:has(.err-main) { align-items: flex-start; flex-wrap: wrap; }
.notice:has(.err-main) .notice-text { flex: 1 1 calc(100% - var(--ctl-lg)); }
.notice .err-actions { display: flex; flex-wrap: wrap; gap: var(--ctl-gap); width: 100%; padding-left: calc(var(--ic-sm) * 1px + var(--space-2)); }
.notice .notice-text { min-width: 0; overflow-wrap: anywhere; }

/* 电脑操作的系统权限（第 18 项）：贴在输入框上面，按缺的那几项列出来 */
.cu-perm { margin-bottom: var(--space-2); }
.cu-perm .notice-text { display: grid; gap: var(--space-1-5); }
.cu-perm-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.cu-perm-what { display: grid; min-width: 0; }
.cu-perm-what .hint, .cu-perm .hint { color: var(--muted); font-size: var(--fs-xs); }
.cu-perm-actions { margin-top: var(--space-0-5); }
}

@layer app {
  .notice > .err-details { flex: 1 1 100%; margin-left: calc(1px * var(--ic-sm) + var(--space-2-5)); }
}

/* 技能与应用：结束后接在「用时」后面的「已使用：…」；进行中在状态行下面逐行写「正在使用…」（状态点和步骤同一套颜色） */
.work-line .wl-sep { flex: none; color: var(--faint); }
.work-line .wl-used { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
.use-list { list-style: none; margin: 0 0 var(--space-3); padding: var(--space-1-5) var(--group-pad); background: var(--well); border-radius: var(--r-card); display: grid; gap: var(--space-1); font-size: var(--fs-sm); color: var(--fg-2); }
.activity.open > .use-list { margin-bottom: var(--space-2); }
.use-list .use { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.use-list .use-t { min-width: 0; overflow-wrap: anywhere; }
.use-list .use.error .use-t { color: var(--fg); }
.activity:has(> .use-list) > .work-line { margin-bottom: var(--space-2); }

/* 加号菜单 ›「技能与应用」：技能、应用两组，每项 图标 + 名称 / 一行说明；某组没有可用项时写原因和入口 */
.pop.use-pop { display: flex; flex-direction: column; }
.pop.use-pop ul { max-height: min(420px, 60vh); }
.pop.use-pop li.use-item { cursor: default; }
.pop.use-pop li.use-item .txt .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop.use-pop li.use-item .use-note { color: var(--amber); }
.pop.use-pop li .lead.use-initial {
  display: grid; place-items: center; width: var(--ctl-xs); height: var(--ctl-xs); margin-top: 0; align-self: center;
  border-radius: var(--r-mark); background: var(--pill); color: var(--fg-2); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
}
.pop.use-pop li .lead.use-mark { margin-top: 0; align-self: center; }
.pop.use-pop li.use-unassigned .btn { flex: none; margin-left: auto; }
.pop.use-pop li.use-unassigned:hover { background: none; }
.pop.use-pop .tone-warn { color: var(--amber); }
.pop.use-pop li.use-empty { display: grid; justify-items: start; gap: var(--space-1); padding: var(--space-1-5) var(--item-px) var(--space-2); white-space: normal; }
.pop.use-pop li.use-empty p { margin: 0; }
.pop.use-pop .use-empty-t { font-size: var(--fs-sm); color: var(--fg); }
.pop.use-pop .use-empty-b { font-size: var(--fs-xs); color: var(--muted); line-height: var(--lh-snug); }
.pop.use-pop li.use-empty .btn { margin-top: var(--space-1); }
.pop.use-pop li.use-loading, .pop.use-pop li.use-none { color: var(--muted); font-size: var(--fs-xs); }
.pop.menu-pop li .menu-sub { flex: none; margin-left: auto; color: var(--muted); }

/* —— 关于我（PRD 2026-11-15 R1–R2）：回复下面的一行提示（✓ 已记到关于我 · 撤销）、确认卡、建议卡 —— */
.aboutme-notes { display: grid; gap: var(--space-2); justify-items: start; margin-top: var(--space-2); }
.aboutme-hint {
  display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; min-height: var(--ctl-md); padding: 0 var(--ctl-px-md);
  border-radius: var(--r-ctl); background: var(--well); font-size: var(--fs-sm); color: var(--fg-2);
}
.aboutme-hint .aboutme-hint-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aboutme-hint .text { flex: none; }
.aboutme-hint.done { color: var(--muted); }
.aboutme-card .aboutme-quote { padding: var(--space-2) var(--space-3); border-radius: var(--r-card); background: var(--surface); font-size: var(--fs-md); color: var(--fg); }
.aboutme-card .aboutme-to { font-size: var(--fs-md); color: var(--fg); font-weight: var(--fw-medium); }

/* —— 机器人之间发消息（R7）：回复下面 / 汇总上面的一行灰色小字，带头像和名字，点开两人对话；不加卡片、状态表或进度条 —— */
.collab-lines { display: grid; gap: var(--space-1); justify-items: start; margin-top: var(--space-2); }
.msg-row.collab-row { align-items: flex-start; }
.msg-row.collab-row + .msg-row.collab-row { margin-top: var(--space-2); }
.msg-row .collab-lines:first-child { margin: 0 0 var(--space-2); }
.collab-line {
  display: inline-flex; align-items: center; gap: var(--space-1); max-width: 100%; padding: 0; border: 0; background: none;
  font: inherit; font-size: var(--fs-xs); color: var(--muted); cursor: pointer; text-align: left;
}
.collab-line:hover { color: var(--fg-2); }
.collab-line .spinner { width: 11px; height: 11px; border-width: 1.5px; margin-left: var(--space-1); } /* 描边：转圈本身就是一道缺了口的圆边，跟着小字缩小 */
.collab-who { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; }
.collab-who .collab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* 别的机器人（B）的审批和提问：卡片上面一行 B 的头像、名字和时间（R9） */
.signed-card { display: grid; gap: var(--space-2); width: min(var(--bubble-w), 100%); }
.signed-by { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); }
.signed-by .name { font-weight: var(--fw-semibold); color: var(--fg); }

/* 两人对话（R8）：只读，顶部两个头像和名字，按时间的往来、日期分隔、收起的处理过程、居中灰字；底部只有「关闭聊天」 */
.pair-sheet { --sheet-w: 680px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(86vh, 900px); }
.pair-head { display: flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-4) var(--space-5) var(--space-3); font-weight: var(--fw-semibold); }
.pair-arrow { color: var(--muted); font-weight: var(--fw-regular); }
.pair-scroll { overflow-y: auto; padding: 0 var(--space-5) var(--space-4); display: grid; align-content: start; gap: var(--space-3); }
.pair-date { justify-self: center; font-size: var(--fs-xs); color: var(--muted); margin-top: var(--space-2); }
.pair-note { justify-self: center; max-width: 92%; padding: var(--space-1) var(--space-3); border-radius: var(--r-ctl); background: var(--well); font-size: var(--fs-xs); color: var(--muted); text-align: center; }
.pair-msg { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-2-5); }
.pair-msg.cont { padding-left: calc(28px + var(--space-2-5)); /* 微调：和头像右边的正文对齐 */ grid-template-columns: minmax(0, 1fr); margin-top: calc(-1 * var(--space-2)); }
.pair-body { display: grid; gap: var(--space-1); min-width: 0; }
.pair-meta { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--fs-sm); }
.pair-name { font-weight: var(--fw-semibold); color: var(--fg); }
.pair-steps .text { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--fs-xs); color: var(--muted); }
.pair-step-list { margin: var(--space-1) 0 0; padding-left: var(--space-5); font-size: var(--fs-xs); color: var(--fg-2); display: grid; gap: var(--space-0-5); }
.pair-foot { padding: var(--space-3) var(--space-5) var(--space-5); }
