/* ════════════════════════════════════════════════════════════
   34. 自然对话回合(T164)
   ────────────────────────────────────────────────────────────
   每轮回复:正文直接开始(无头像抬头)→ 成果文件 → 元信息(模型 · 用时 · 用了 N 项能力 · 复制)
   → 按需展开的过程记录。进行中时,本轮末端一行低强调活动行(回响图标 + 能力名)。
   全部颜色走 5 原色派生 token,深浅主题自动适配。
   ════════════════════════════════════════════════════════════ */

/* ─── 回合结构元素:抬头只作边界,等待元素只作信号 ─── */
.msg-ai-turn-header { height: 0; margin: 0; overflow: hidden; }
.thinking-row { display: none; }
.tool-console:empty { display: none; }
.tool-console:not(:empty) {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  width: 100%; max-width: 800px; margin-bottom: 16px;
}

.turn-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.turn-chev { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.2s ease; }
[aria-expanded="true"] > .turn-chev { transform: rotate(180deg); }

/* ─── 进行中:正文的元信息等回合结束再出现;活动行紧挨前一个内容(正文或卡片)─── */
.msg-ai-reply[data-turn-live] .msg-ai-footer { display: none; }
.msg-ai:has(+ .turn-activity),
.msg-ai:has(+ .thinking-row + .turn-activity) { margin-bottom: 10px; }

/* ─── 活动行 ─── */
.turn-activity {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; max-width: 800px; margin-bottom: 56px;
}
.turn-activity.is-entering { animation: turnActIn 0.2s ease both; }
@keyframes turnActIn { from { opacity: 0; } to { opacity: 1; } }
.turn-act-row {
  display: inline-flex; align-items: center;
  max-width: 100%; min-height: 30px; margin-left: -6px; padding: 3px 8px 3px 6px;
  border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--text-dim); font: inherit; font-size: 13px; text-align: left; cursor: default;
}
.turn-act-row.is-clickable { cursor: pointer; }
.turn-act-row, .turn-cap-entry, .turn-rec-row { -webkit-user-select: none; user-select: none; }
.turn-act-row > *, .turn-cap-entry > *, .turn-rec-row > * { pointer-events: none; }
.turn-act-row.is-clickable:hover { background: var(--bg-hover); }
.turn-act-row:focus-visible { outline: 2px solid var(--brand-border); outline-offset: 2px; }
.turn-act-row:not(.is-clickable) > .turn-chev { display: none; }
.turn-act-lead {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 18px; height: 18px; margin-right: 10px;
}

/* 回响:一个品牌金节点 + 两圈向外扩散的回波 */
.turn-echo { position: relative; width: 18px; height: 18px; }
.turn-echo i, .turn-echo b {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
}
.turn-echo i { background: var(--brand-primary); animation: turnEchoCore 1.8s ease-in-out infinite; }
.turn-echo b {
  border: 1px solid var(--brand-primary); opacity: 0;
  animation: turnEchoRing 1.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.turn-echo b + b { animation-delay: 0.9s; }
@keyframes turnEchoCore { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes turnEchoRing { 0% { transform: scale(1); opacity: 0.75; } 100% { transform: scale(2.8); opacity: 0; } }
.turn-act-recon { width: 15px; height: 15px; color: var(--text-muted); animation: turnSpin 2.4s linear infinite; }
@keyframes turnSpin { to { transform: rotate(360deg); } }

/* 能力名只占一个格子:新旧名字上下滚动替换,宽度平滑伸缩 */
.turn-act-slot {
  position: relative; display: inline-block; flex-shrink: 1; min-width: 0;
  width: 0; height: 20px; overflow: hidden;
  transition: width 0.26s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.turn-act-lbl {
  position: absolute; left: 0; top: 0; height: 20px;
  width: max-content;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  color: var(--text-muted);
  transition: opacity 0.2s ease, transform 0.26s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.turn-act-name, .turn-act-progress { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.turn-act-name { flex: 0 1 auto; }
.turn-act-progress { flex: 1 1 auto; }
.turn-act-cnt, .turn-act-ic, .turn-act-stack { flex-shrink: 0; }
.turn-act-lbl.is-in { opacity: 0; transform: translateY(9px); }
.turn-act-lbl.is-out { opacity: 0; transform: translateY(-9px); }
.turn-act-ic, .turn-act-stack { display: inline-flex; align-items: center; gap: 3px; color: var(--text-dim); }
.turn-act-lbl svg, .turn-rec-ic svg { width: 14px; height: 14px; flex-shrink: 0; }
.turn-act-lbl img.skill-logo-img, .turn-rec-ic img.skill-logo-img {
  width: 14px; height: 14px; object-fit: contain; border-radius: 3px; display: block;
}
.turn-act-progress, .turn-act-cnt { color: var(--text-dim); }
.turn-act-progress::before { content: '·'; margin-right: 6px; }
.turn-act-text { color: var(--text-muted); }
.turn-act-record { width: 100%; }
/* 已完成:能力做完、模型想下一步时留在格子里,降一级并带小勾,不扫光 */
.turn-act-lbl.is-done { color: var(--text-dim); }
.turn-act-lbl.is-done .turn-act-name { color: var(--text-dim); }
.turn-act-lbl svg.turn-act-check { width: 13px; height: 13px; color: var(--brand-primary); margin-left: -2px; }
/* 交代:顾问说的话,比正文低一级;逐字出现,换句时旧句向上淡出 */
.turn-act-note {
  position: relative; max-width: 100%; margin: 0 0 6px; color: var(--text-muted);
  font-size: 15px; line-height: 1.7; overflow-wrap: anywhere;
}
.turn-act-note[hidden] { display: none; }
.turn-act-note-text { display: inline; }
.turn-act-note-text.is-out {
  position: absolute; left: 0; top: 0; right: 0;
  animation: turnNoteOut 0.26s ease both;
}
@keyframes turnNoteOut { to { opacity: 0; transform: translateY(-8px); } }

/* 扫光:进行中的文字上一道亮光从左往右扫过,只用现有文字色 */
.turn-shimmer {
  background: linear-gradient(100deg, var(--text-muted) 0%, var(--text-muted) 38%, var(--text-bright) 50%, var(--text-muted) 62%, var(--text-muted) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: turnShimmer 2.4s linear infinite;
}
@keyframes turnShimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.turn-rec-note {
  padding: 9px 10px; color: var(--text-muted); line-height: 1.65;
  overflow-wrap: anywhere; border-bottom: 1px solid var(--border-glass);
}
/* 正文续写时用户仍展开着过程:收起图标与能力名,只留可收起的箭头和记录 */
.turn-activity.is-quiet .turn-act-lead,
.turn-activity.is-quiet .turn-act-slot { display: none; }

/* ─── 元信息里的能力入口 ─── */
.msg-ai-cap:empty { display: none; }
.msg-ai-cap { display: inline-flex; align-items: center; margin-left: -4px; }
.msg-ai-cap::before { content: '·'; margin-right: 2px; }
.turn-cap-entry {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 6px; border: 0; border-radius: var(--radius-full);
  background: transparent; color: var(--text-muted);
  font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer;
}
.turn-cap-entry:hover { background: var(--bg-hover); color: var(--text-bright); }
.turn-cap-entry:focus-visible, .turn-rec-row:focus-visible { outline: 2px solid var(--brand-border); outline-offset: 2px; }
.turn-cap-warn { width: 6px; height: 6px; border-radius: 50%; background: var(--warning-color); flex-shrink: 0; }
.turn-standalone-meta { display: flex; align-items: center; font-size: 12px; color: var(--text-muted); margin-left: -6px; }

/* ─── 过程记录:第一层能力名/次数/状态,第二层逐次明细 ─── */
.msg-ai-record:empty { display: none; }
.msg-ai-record { width: 100%; }
.turn-record {
  width: 100%; max-width: 520px; margin-top: 8px; padding: 4px;
  border-radius: 14px; background: var(--bg-subtle); border: 1px solid var(--border-glass);
  font-size: 13px; animation: turnRise 0.22s ease both;
}
@keyframes turnRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.turn-rec-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-main); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.turn-rec-row:hover { background: var(--bg-hover); }
.turn-rec-ic { display: inline-flex; color: var(--text-muted); flex-shrink: 0; }
.turn-rec-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-rec-sum { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.turn-rec-row > .turn-chev { color: var(--text-dim); }
.turn-bad { color: var(--warning-color); }
.turn-rec-calls {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  padding: 2px 10px 10px 35px; color: var(--text-muted); font-size: 12.5px;
}
.turn-rec-call { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.turn-rec-n { color: var(--text-dim); min-width: 3.4em; }
.turn-rec-link {
  padding: 0; border: 0; background: none; color: var(--text-main);
  font: inherit; font-size: 12.5px; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--brand-border); text-underline-offset: 3px;
}
.turn-rec-calls .sb-panel-host { width: 100%; }
.turn-rec-detail {
  margin: -3px 0 0 calc(3.4em + 8px); color: var(--text-main); font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 12px; line-height: 1.5; overflow-wrap: anywhere;
}
.turn-rec-calls .turn-rec-link { margin-left: calc(3.4em + 8px); }
.turn-rec-output {
  width: 100%; box-sizing: border-box; margin: 0; padding: 8px 10px; max-height: 320px; overflow: auto;
  border-radius: 10px; background: var(--bg-hover); color: var(--text-body, var(--text-main));
  font-family: var(--font-mono, ui-monospace, Menlo, monospace); font-size: 11.5px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ─── 正文没放的工具图片:归在正文之后、成果文件与底栏之前 ─── */
.msg-ai-gallery { width: 100%; max-width: 800px; margin-top: 16px; }
.msg-ai-gallery:not(:has(> .msg-ai:not([data-image-duplicate]))) { display: none; }
.msg-ai-gallery > .msg-ai { margin: 0; }

/* ─── 成果文件:与正文分开,直接下载 ─── */
.msg-ai-results:empty { display: none; }
.msg-ai-results { width: 100%; margin-top: 16px; }
.turn-files { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 440px; }
.turn-file {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 12px; border-radius: 14px;
  border: 1px solid var(--border-light); background: var(--bg-layer-1);
  color: var(--text-main); text-decoration: none;
  animation: turnRise 0.32s ease both;
}
.turn-file:hover { background: var(--bg-surface-hover); }
.turn-file:focus-visible { outline: 2px solid var(--brand-border); outline-offset: 2px; }
.turn-file-ext {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg-surface-hover); color: var(--text-muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
}
.turn-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.turn-file-name { font-size: 14px; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-file-sub { margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.turn-file-dl {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 34px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-light); color: var(--text-main); font-size: 13px;
}
.turn-file-dl svg { width: 15px; height: 15px; }

/* ─── 发送键:生成中变停止,停止确认前显示"正在停止" ─── */
#btn-send { position: relative; }
#btn-send .send-ic-stop { display: none; width: 12px; height: 12px; border-radius: 3px; background: currentColor; }
#btn-send.is-stop .send-ic-send,
#btn-send.is-stopping .send-ic-send { display: none; }
#btn-send.is-stop .send-ic-stop,
#btn-send.is-stopping .send-ic-stop { display: block; }
#btn-send.is-stop,
#btn-send.is-stopping:disabled {
  background: var(--bg-surface-hover); color: var(--text-bright);
  box-shadow: inset 0 0 0 1px var(--border-light);
}
#btn-send.is-stop:hover { background: var(--bg-active); transform: none; }
#btn-send.is-stopping { cursor: progress; }
#btn-send.is-stopping .send-ic-stop { opacity: 0.5; }
#btn-send.is-stopping::after {
  content: ''; position: absolute; inset: 9px; border-radius: 50%;
  border: 2px solid var(--border-light); border-top-color: var(--text-bright);
  animation: turnSpin 0.9s linear infinite;
}
#btn-send.is-stop-unconfirmed::after { animation: none; }
.turn-stop-hint { color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.turn-stop-hint button {
  margin-left: 8px; color: var(--text-main); background: transparent;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 6px 10px;
}

/* ─── tool_call 旧类型兜底(EXPECTED_TYPES 契约保留)─── */
.tool-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; margin: 6px 0;
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-surface); border: 1px solid var(--border-glass); border-radius: 12px;
}
.tool-status.tool-error { color: var(--error-color); border-color: var(--error-border); }

/* ─── 减少动态效果:回响只保留柔和明暗,能力名直接切换 ─── */
@media (prefers-reduced-motion: reduce) {
  .turn-echo b { animation: none; opacity: 0; }
  .turn-echo i { animation-duration: 2.4s; }
  .turn-act-slot, .turn-act-lbl { transition: none; }
  .turn-shimmer { animation: none; background: none; -webkit-text-fill-color: currentColor; color: var(--text-muted); }
  .turn-act-note-text.is-out { animation: none; }
  .turn-activity.is-entering, .turn-record, .turn-file { animation: none; }
  .turn-act-recon, #btn-send.is-stopping::after { animation-duration: 4s; }
}
