/* ===== Interactive States (A7) =====
 * 按钮 hover / active / focus-visible 态、菜单打开 pill 高亮、禁用态、
 * view-* 页面类（A6 登记前先交付通用 .view-card）、滚动条
 * 加载顺序：styles.css 之后
 *
 * 纯结构类（无样式需求，仅标记用途）：
 *   .am-menu-item-label —— A3 toolbar.js 菜单项 label span，样式由父级 .am-menu-item 继承
 */

/* --- .icon-btn :active 缩放 --- */
.icon-btn:active {
  transform: scale(.96);
}

/* --- 菜单打开时 pill 高亮 --- */
.pill.menu-open {
  background: rgba(0,0,0,.06);
}

/* --- 禁用态 --- */
button:disabled,
.icon-btn:disabled,
.pill:disabled,
.nav-row:disabled,
.task-row:disabled,
.proj-row:disabled,
.seg-item:disabled {
  opacity: .38;
  pointer-events: none;
}

/* --- focus-visible 轮廓环 --- */
.icon-btn:focus-visible,
.pill:focus-visible,
.nav-row:focus-visible,
.task-row:focus-visible,
.proj-row:focus-visible,
.seg-item:focus-visible,
.am-menu-item:focus-visible,
.send:focus-visible {
  outline: 2px solid var(--orange-icon);
  outline-offset: 1px;
}

/* --- view-* 页面样式（依据 SPEC §6 A6 登记清单；协调者裁决版 2026-09-22） --- */
.view-card {
  background: #f6f7f8;
  border-radius: 8px;
  padding: 14px;
  font-size: var(--type-body-size);
 line-height: var(--type-body-line); }

.view-proj-card { }

/* 裁决补充：视图模式下 thread 内卡片纵向间距 */
.thread[class*=" view-"] > .view-card { margin-bottom: 10px; }

.view-card h2 {
  font-size: var(--type-section-size);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
 line-height: var(--type-section-line); }

/* --- 项目页 --- */
.view-proj-header { display: flex; align-items: center; gap: 8px; position: relative; padding-right: 30px; }
.view-proj-icon { width: 16px; height: 16px; color: #3a3a3a; }
.view-proj-name { font-size: var(--type-body-size); font-weight: 500; color: #202020;  line-height: var(--type-body-line); }

/* 侧栏项目行 hover（协调者补：与 .task-row:hover 一致的体系色） */
.proj-row:hover { background: rgba(0,0,0,.04); }

/* 项目卡片 hover 浮现操作按钮（宿主实证 work-projects__card:hover → card-actions opacity 0→1 150ms；图标同步变色） */
.view-proj-more {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: #6f6f6f; cursor: default;
  opacity: 0; transition: opacity .15s ease;
}
.view-proj-more svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.view-proj-more:hover { background: rgba(0,0,0,.06); color: var(--text); }
.view-proj-card:hover .view-proj-more,
.view-proj-card:focus-within .view-proj-more { opacity: 1; }
.view-proj-card:hover .view-proj-icon { color: var(--text); }
.view-proj-body { margin-top: 10px; }
.view-empty-row { display: flex; align-items: center; gap: 8px; color: #808080; font-size: var(--type-body-size);  line-height: var(--type-body-line); }
.view-empty-row svg { width: 14px; height: 14px; color: #b5b5b5; }

/* 项目页任务行（A6 views.js，惰性 DOM，不影响初始截图） */
.view-task-row {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: var(--type-body-size);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
 line-height: var(--type-body-line); }

.view-task-row:hover {
  background: rgba(0,0,0,.04);
}

.view-task-row:active {
  transform: scale(.98);
}

.view-task-current,
.view-task-selected {  /* A6 登记的别名类（与 current 同挂 selected 任务）— 协调者补 2026-09-22 */
  background: var(--selected-bg);
}

/* --- 提示卡 --- */
.view-hint-card { display: flex; align-items: flex-start; gap: 10px; border: 1px dashed #ddd; background: transparent; }
.view-hint-icon { width: 20px; height: 20px; color: #808080; }
.view-hint-text { display: flex; flex-direction: column; gap: 2px; }
.view-hint-title { font-weight: 600; font-size: var(--type-body-size); color: #202020;  line-height: var(--type-body-line); }
.view-hint-desc { font-size: var(--type-body-size); color: #808080;   line-height: var(--type-body-line); }

/* R29 追加指令：专家·技能页（.view-skill-*）/ 生态连接页（.view-connect-*）/ 定时任务页（.view-cron-*）
   三段样式随视图删除（2026-09-24），.view-hint-* 由项目页继续使用。 */

/* --- 助手回复 Markdown（A4 thread.js，惰性 DOM，不影响初始截图） --- */
/* SPEC §6 登记：.msg.assistant .md-pre / .md-code / .md-ul / .md-ol */
.msg.assistant .md-pre {
  font-family: var(--mono);
  font-size: var(--type-caption-size);
  
  background: #f6f7f8;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  white-space: pre;
  overflow-x: auto;
 line-height: var(--type-caption-line); }

.msg.assistant .md-code {
  font-family: var(--mono);
  font-size: var(--type-caption-size);
  background: #f1f1f1;
  border-radius: 4px;
  padding: 1px 4px;
 line-height: var(--type-caption-line); }

.msg.assistant .md-ul {
  margin: 8px 0;
  padding-left: 22px;
}

.msg.assistant .md-ol {
  margin: 8px 0;
  padding-left: 22px;
}

/* --- 全局滚动条（不覆盖已有定制） --- */
.transcript::-webkit-scrollbar {
  width: 4px;
}
.transcript::-webkit-scrollbar-track {
  background: #f6f7f8;
}
.transcript::-webkit-scrollbar-thumb {
  background: #d8d8d8;
  border-radius: 2px;
}

/* sb-scroll 保持隐藏滚动条 */
.sb-scroll::-webkit-scrollbar {
  width: 0;
}

/* --- prefers-reduced-motion：禁用动画与缩放 --- */
@media (prefers-reduced-motion: reduce) {
  .am-menu { animation: none; }
  .icon-btn:active { transform: none; }
}

/* 思考过程块（宿主真实场景实证 2026-09-22 截图）：副行缩进对齐主行文字（图标 14px + ml 2 + gap 5 ≈ 21px） */
.tool-row.think-phase { padding-left: 21px; }

/* --- 窄窗 thread 防溢出（L1 修复，断点 1199 ≤1267 基线不受影响） --- */
/* 根因：styles.css .thread {width:808;margin-left:96;max-width:calc(100%-40px)} 中
   max-width 不含 margin-left，窄窗下 96px+thread宽 > 主区宽导致溢出被硬裁剪。
   方案：窄窗下 margin auto 居中 + width:auto 让 max-width 全权约束。 */
@media (max-width: 1199px) {
  .thread {
    margin: 0 auto;
    width: auto;
    max-width: calc(100% - 40px);
  }
}

/* ═══════════════════════════════════════════════════════════════════════
 * 任务行 hover 操作 + 任务菜单 + 运行态动效（2026-09-22 代写）
 * 宿主证据 docs/HOST-EVIDENCE-A1-DRAFT.md §8/§9（work-surface-sidebar__task-actions /
 * task-more / sidebar-action-menu / glass-session-dot-loader 实证规格）。
 * 所有关联 DOM 均由 sidebar.js 首次交互惰性创建 → 无交互时不命中，不影响像素基线。
 * ═══════════════════════════════════════════════════════════════════════ */

/* --- 定位上下文：more 按钮绝对定位（position:relative 无偏移，不改布局） --- */
.task-row { position: relative; }

/* --- hover 浮现三点 more（宿主 task-actions：right 4 / 垂直居中 / opacity 0→1） --- */
.am-task-more {
  position: absolute; top: 50%; right: 4px; z-index: 1;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 2px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--text-2);
  opacity: 0; pointer-events: none;
}
.task-row:hover .am-task-more,
.task-row:focus-within .am-task-more { opacity: 1; pointer-events: auto; }
.am-task-more:hover { background: rgba(0,0,0,.06); color: var(--text); }
.am-task-more:active { background: rgba(0,0,0,.1); }
.am-task-more svg { width: 16px; height: 16px; }
/* 三点为实心点（宿主 lucide Ellipsis 视觉为圆点） */
.am-task-more circle { fill: currentColor; stroke: none; }

/* --- 任务菜单（宿主 sidebar-action-menu：紧凑宽度，item 32px / icon 16 sw1.75） --- */
.am-task-menu { min-width: 150px; width: max-content; }
.am-task-menu .am-menu-item { height: 32px; padding: 6px 10px; }
.am-task-menu .am-menu-item svg { width: 16px; height: 16px; stroke-width: 1.75; color: var(--text-2); }
.am-task-menu .am-menu-item:hover svg { color: var(--text); }

/* 危险项（宿主 --destructive = #c00900cf 浅色；hover 10% 红底） */
.am-menu-item.danger,
.am-menu-item.danger svg { color: #c00900cf; }
.am-menu-item.danger:hover { background: rgba(192,9,0,.1); border-radius: 8px; color: #c00900cf; }

/* --- 重命名行内输入框（宿主 task-rename-input：h24 / radius6） --- */
.am-task-rename {
  height: 24px; min-width: 0; flex: 1;
  padding: 0 4px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text);
  font: inherit; outline: none;
  user-select: text;
}

/* --- 删除确认面板（复用 .am-menu 容器） --- */
.am-task-confirm { min-width: 200px; width: max-content; }
.am-task-confirm-title { font-size: var(--type-body-size); font-weight: 600; color: var(--text); padding: 6px 10px 2px;  line-height: var(--type-body-line); }
.am-task-confirm-desc { font-size: var(--type-caption-size); color: var(--text-2); padding: 0 10px 10px;  line-height: var(--type-caption-line); }
.am-task-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 10px 6px; }
.am-task-confirm-cancel,
.am-task-confirm-ok {
  height: 26px; padding: 0 12px;
  border-radius: 6px; font-size: var(--type-body-size);
 line-height: var(--type-body-line); }
.am-task-confirm-cancel { background: #f1f1f1; color: var(--text); }
.am-task-confirm-cancel:hover { background: rgba(0,0,0,.08); }
.am-task-confirm-ok { background: #c00900cf; color: #fff; }
.am-task-confirm-ok:hover { background: #a00700; }

/* --- 运行态六点 loader（宿主 glass-session-dot-loader 实证规格 §8.3） --- */
/* 2×3 网格 / 点径 2px / 间距 2px / 容器 14×14 / opacity .7 / 1.82s steps(6) 循环
   各点相位差 130ms 步进，第 5/6 点用 long/short 变体形成波浪扫过效果 */
.am-task-loader {
  display: inline-grid;
  grid-template-columns: repeat(2, 2px); grid-template-rows: repeat(3, 2px);
  gap: 2px; place-content: center;
  width: 14px; height: 14px; flex: none;
  margin: 0 8px 0 0;
  color: currentColor; opacity: .7; pointer-events: none;
}
.am-task-loader i {
  display: block; width: 2px; height: 2px; border-radius: 50%;
  background: currentColor;
  opacity: 0; transform: translateY(-4px);
  animation: am-dot-cycle 1.82s steps(6, jump-none) infinite;
}
.am-task-loader i:nth-child(1) { animation-delay: .52s; }
.am-task-loader i:nth-child(2) { animation-delay: .65s; }
.am-task-loader i:nth-child(3) { animation-delay: .26s; }
.am-task-loader i:nth-child(4) { animation-delay: .39s; }
.am-task-loader i:nth-child(5) { animation-name: am-dot-cycle-long; }
.am-task-loader i:nth-child(6) { animation-name: am-dot-cycle-short; animation-delay: .13s; }

@keyframes am-dot-cycle {
  0% { opacity: 0; transform: translateY(-4px); }
  9.34%, 57.14% { opacity: 1; transform: translateY(0); }
  66.48%, 100% { opacity: 0; transform: translateY(7px); }
}
@keyframes am-dot-cycle-long {
  0% { opacity: 0; transform: translateY(-4px); }
  9.34%, 64.29% { opacity: 1; transform: translateY(0); }
  73.63%, 100% { opacity: 0; transform: translateY(7px); }
}
@keyframes am-dot-cycle-short {
  0% { opacity: 0; transform: translateY(-4px); }
  9.34%, 50% { opacity: 1; transform: translateY(0); }
  59.34%, 100% { opacity: 0; transform: translateY(7px); }
}

/* --- toast（复制反馈） --- */
.am-toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  padding: 7px 14px;
  background: #1e1e1e; color: #fff;
  font-size: var(--type-body-size); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: am-toast-in .18s ease-out;
 line-height: var(--type-body-line); }
@keyframes am-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- prefers-reduced-motion 补充（本节新增动效全部退化为静态） --- */
@media (prefers-reduced-motion: reduce) {
  .am-task-loader i { animation: none; opacity: 1; transform: none; }
  .am-toast { animation: none; }
}

/* ═══════════════════ 编码模式（SPEC §2.7，惰性 DOM）═══════════════════ */
/* 编码模式侧栏背景（与办公一致 #f1f1f1） */
.sb-code-proj {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 6px 8px;
  border-radius: 6px; font-size: var(--type-body-size);
  color: var(--text); cursor: default;
 line-height: var(--type-body-line); }
.sb-code-proj:hover { background: rgba(0,0,0,.04); }
.sb-code-proj svg { width: 16px; height: 16px; color: #3a3a3a; stroke-width: 1.75; }

/* 会话行：h-8=32px + 行间 1px = 33px 步长（HOST-EVIDENCE-2 §4.3）
 *
 * trail 槽位契约（供 session-status.js / context-menu.js 共用）：
 * - .sb-code-session-trail：右侧 24px 固定宽容器，position:relative
 * - .sb-code-session-time：绝对定位右对齐，默认 visible，hover 时 opacity→0
 *   （HOST-EVIDENCE-2 §3.3：hover 淡出让位 Ellipsis 16px）
 * - 「…」按钮（context-menu.js 注入）：绝对定位同槽，session:hover 时 opacity→1 */
.sb-code-session {
  display: flex; align-items: center;
  height: 32px; margin-bottom: 1px; padding: 0 8px 0 8px;
  border-radius: 6px; font-size: var(--type-body-size);
  color: var(--text); cursor: default;
 line-height: var(--type-body-line); }
.sb-code-session:hover { background: rgba(0,0,0,.04); }
.sb-code-session:active { transform: scale(.98); }
/* 行首状态 slot（14px，供 session-status.js 填充） */
.sb-code-session-status {
  width: 14px; height: 14px; flex: none; margin-right: 8px;
}
.sb-code-session-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
  font-size: var(--type-body-size); color: var(--text);
 line-height: var(--type-body-line); }
.sb-code-session-time {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-size: var(--type-caption-size); 
  color: #9e9e9e;
  white-space: nowrap;
  transition: opacity .15s ease;
 line-height: var(--type-caption-line); }
.sb-code-session:hover .sb-code-session-time { opacity: 0; }
/* trail 槽位：右侧 24px 固定宽，时间与「…」按钮共用 */
.sb-code-session-trail {
  position: relative; width: auto; min-width: 24px;
  flex: none; margin-left: 8px; align-self: stretch;
}
/* 当前会话选中态（侧栏 .task-row.selected 对应的 session） */
.sb-code-session-current {
  background: var(--selected-bg); /* #dbdbdb */
}

/* 编码模式下 sb-section-title 间距 */
.sb-code-tasks { margin-top: 13px; }
.sb-code-tasks .task-row { position: relative; }

/* ── 编码模式侧栏几何对齐（HOST-EVIDENCE-2 §4.3 行带表，1x，容差 ±2）──
 * 目标带位：项目标题 247 / 项目行 277 / 会话1 310（步长 33）/ 选中行高 32 / 任务标题带间 34 / 任务行带间 17
 * 推导（sb-scroll 顶 204 = 编码 nav 底）：
 *   +31(pt)+11(mt) = 246 项目标题框顶（带 247）
 *   +13(标题框)+10(mt) = 269 项目行框顶（带 277，图标/文字带在 32px 框内居中 +8）
 *   +32(项目行)+1(mt) = 302 会话1 框顶（带 310；行间 32+1mb = 步长 33）
 *   任务标题 mt24：普通会话行结尾 → 标题带间 34（§4.3 457→491）
 *   任务区 mt13：标题带底 → 任务行带间 17（§4.3 505→522） */
.sb-code-wrap { padding-top: 31px; }
.sb-code-wrap .sb-code-proj { margin-top: 10px; }
.sb-code-proj + .sb-code-session { margin-top: 1px; }
.sb-code-title-tasks { margin-top: 24px; }

/* ===== Q12 token 落地（round-26 N2 · DESIGN-TOKENS 差异表 sidebar/全局段 · 逐条 cmp2） =====
 * 授权范围仅限差异表列出的行（SPEC §2.12 Q12）。styles.css 冻结，靠 :root 变量覆盖。
 * #3  --selected-bg #dbdbdb → var(--am-selection-bg)（= --am-gray-a4 #00000017，叠 #f1f1f1 = #dbdbdb，与基准图选中底 (219,219,219) 一致）
 *     【DESIGN-TOKENS #3 · 宿主 L12524 sidebar-selection-bg】cmp2 40 项 0 超标（28×0 + 12×±1，与基线完全一致）
 * #50 编码模式选中底 .sb-code-session-current 引用 var(--selected-bg)，随 #3 一并闭环【DESIGN-TOKENS #50 · states.css:384】
 * #5  --text #1e1e1e → var(--am-gray-12) #202020【DESIGN-TOKENS #5 · L12520】cmp2 40 项 0 超标（nav1 text 0→-1px，仍 ≤1）
 * #14 --seg-bg → var(--am-gray-4) #e8e8e8：已试装并回退——cmp2 'seg bg' diff (6,11,-41,-1) 超标
 *     （cmp2 用 #e3e3e3 精确色检测分段底，换色即失配；基准图 ref/win.png 分段底实测 (227,227,227)=#e3e3e3）。像素冲突待裁决。
 * #7  --text-muted-nav #9e9e9e → var(--am-gray-a8) #0004：cmp2 通过（0 超标），但未落地——
 *     #0004 叠 #f1f1f1 ≈ #b1b1b1，基准图「收起显示」实测 (158,158,158)=#9e9e9e；差异表本条标注「无直接对应（介于 a8/a7）」，
 *     缺宿主实证（HOST-EVIDENCE 无占位行/折叠行文字色 token），按 §0 铁律⑤「无证据退回」不改。待裁决。 */
:root {
  --selected-bg: var(--am-selection-bg);
  --text: var(--am-gray-12);
}

/* ═══════════════════════════════════════════════════════════════════════
 * R29 五 Tab 骨架（S6 · 金融大改造 · 2026-09-24，PROGRESS 第 29 轮契约 §6/§7）
 * 本段为纯追加（styles.css 冻结）：侧栏顶部五 Tab rail / Folder 树 / 底部用户区 /
 * 模块缺席占位。初始视图 = tasks Tab = 内容区像素基线，本段仅作用于侧栏与惰性视图 DOM。
 * ═══════════════════════════════════════════════════════════════════════ */

/* --- 五 Tab rail（替换原 办公/编码 seg；激活态逐项参照 styles.css .seg-item.active，冻结不改）---
 * 几何来源：--seg-bg 轨道 + radius 8/padding 2（.segmented 同款）；item 高 30 / radius 6 /
 * 14px 字 / svg 14 sw2 #787878；active = 白底 + 600 字重 + 0 1px 2px 阴影（.seg-item.active 同款）。
 * 竖向 rail 裁决依据：280px 侧栏 − 14/8 padding = 258px 可用宽，5 项「图标+文字」横排放不下
 * （策略中心 ≈ 76px × 5 > 258px），沿用 seg pill 视觉语言纵向排布。 */
.sb-tabs {
  margin: 19px 14px 0 8px;
  background: var(--seg-bg);
  border-radius: 8px;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-tab {
  height: 30px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: var(--type-body-size);
  color: #767676;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
 line-height: var(--type-body-line); }
.sb-tab svg { width: 14px; height: 14px; stroke-width: 2; color: #787878; }
.sb-tab.active { background: #fff; color: #2c2c2c; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.sb-tab.active svg { color: #4f4f4f; }

/* R29 用户指令（18:5X）：Folder 样式段已删（DOM 结构移除） */
/* --- 底部用户区（头像占位 + 用户名 + 持仓金额；.sb-footer 布局沿用 styles.css）--- */
.sb-user { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; margin-top: 6px; }
.sb-user-name { font-size: var(--type-body-size); color: var(--text);   line-height: var(--type-body-line); }
.sb-user-equity { font-size: var(--type-caption-size); color: #808080;  font-variant-numeric: tabular-nums;  line-height: var(--type-caption-line); }

/* --- 「模块加载中」占位（views.js Tab 路由兜底；模块交付后自动让位）--- */
.view-pending {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 320px; text-align: center;
}
.view-pending-icon { width: 32px; height: 32px; color: #808080; }
.view-pending-text { font-size: var(--type-section-size); font-weight: 600; color: #202020; margin-top: 12px;  line-height: var(--type-section-line); }

/* --- R29 新增控件 focus-visible（沿既有轮廓环体系）--- */
.sb-tab:focus-visible {
  outline: 2px solid var(--orange-icon);
  outline-offset: 1px;
}
