:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2129;
  --border: #2d333b;
  --fg: #e6edf3;
  --fg-dim: #9198a1;
  --accent: #d97757;      /* claude 橙 */
  --blue: #4493f8;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --purple: #ab7df8;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.6 -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}

/* ---------- 窄屏/手机适配（含横屏 ≤900px）：侧栏变抽屉，内容全宽 ---------- */
@media (max-width: 900px) {
  /* 内容列不再按比例居中，占满可用宽 */
  #timeline > .msg, #timeline > .tool, #timeline > details,
  #timeline > .msg-system, #timeline > .msg-task { width: 100%; }
  #timeline { padding: 12px 12px 48px; }
  /* Dock 右栏在窄屏不提供（挡住时间线） */
  #dock, #dock-resizer { display: none !important; }
  #sidebar {
    position: absolute; left: 0; top: 41px; bottom: 0;
    width: min(85vw, 340px) !important; z-index: 20;
    box-shadow: 4px 0 18px rgba(0,0,0,.5);
  }
  #sidebar-resizer { display: none; }
  #timeline-wrap { width: 100%; }
  /* 打开会话：侧栏隐藏，时间线占满 */
  body.session-open #sidebar, body.session-open #sidebar-resizer { display: none; }
  /* 返回列表按钮：醒目 */
  #mobile-back {
    display: inline-flex !important;
    border-color: var(--accent); color: var(--accent);
    font-size: 13px; padding: 3px 12px;
  }
  /* 会话元信息：移动端默认收起，点"详情"展开；展开态用紧凑 chip 云而非整行列表 */
  #session-head .meta { display: none; }
  #session-head.meta-open .meta {
    display: flex; flex-wrap: wrap; gap: 4px 8px;
    font-size: 11px; line-height: 1.5; margin-top: 6px;
    padding-top: 6px; border-top: 1px dashed var(--border);
  }
  #session-head.meta-open .meta span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
  #session-head.meta-open .meta code { font-size: 10px; }
  #meta-toggle { display: inline-flex !important; }
  /* 会话头压缩 */
  #session-head { padding: 8px 12px; }
  #session-head h2 { font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
}
#mobile-back {
  display: none; background: var(--bg3); border: 1px solid var(--border); color: var(--fg);
  border-radius: 6px; font-size: 12px; padding: 2px 10px; margin-right: 8px; cursor: pointer;
  align-items: center; gap: 4px;
}
#meta-toggle {
  display: none; background: none; border: 1px solid var(--border); color: var(--fg-dim);
  border-radius: 6px; font-size: 11px; padding: 1px 8px; cursor: pointer; margin-left: auto;
}

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; background: var(--bg2); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { font-weight: 700; font-size: 15px; }
.brand span { color: var(--accent); font-weight: 600; }
.brand em {
  font-style: normal; font-size: 10px; color: var(--green);
  border: 1px solid var(--green); border-radius: 4px; padding: 0 5px; margin-left: 8px;
  vertical-align: 2px;
}
.tab {
  background: none; border: 1px solid transparent; color: var(--fg-dim);
  padding: 4px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.tab.active { color: var(--fg); background: var(--bg3); border-color: var(--border); }
.spacer { flex: 1; }
#conn { font-size: 12px; color: var(--fg-dim); display: flex; align-items: center; gap: 6px; }
#conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
#conn.on .dot { background: var(--green); }
#conn.off .dot { background: var(--red); }
/* P1 连接质量五态（架构 §8.2）：host 绿 / p2p 蓝 / relay 黄 / ws 灰 / 重连中 黄 */
#conn.mode-p2p .dot { background: var(--blue); }
#conn.mode-ws .dot { background: var(--fg-dim); }
#conn.warn .dot { background: var(--yellow); }

/* ---------- 两栏布局：左侧项目/会话树（可调宽/可收起），右侧时间线 ---------- */
#view-sessions { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 340px; flex: 0 0 auto; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; background: var(--bg2);
}
#sidebar-resizer {
  width: 5px; margin-left: -3px; flex: 0 0 auto; cursor: col-resize; z-index: 5;
  transition: background .15s;
}
#sidebar-resizer:hover, body.resizing #sidebar-resizer { background: var(--accent); opacity: .55; }
body.resizing { cursor: col-resize; user-select: none; }
body.sidebar-hidden #sidebar, body.sidebar-hidden #sidebar-resizer { display: none; }
#timeline-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane-title {
  padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--fg-dim);
  border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center;
  flex: 0 0 auto;
}
.pane-body { overflow-y: auto; flex: 1; min-height: 0; }
#session-filter, #source-filter {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); color: var(--fg);
  border-radius: 5px; padding: 2px 8px; font-size: 12px; outline: none;
}
#source-filter { flex: 0 0 auto; max-width: 110px; }

/* 数据源徽标 */
.tag-src {
  font-size: 10px; border-radius: 4px; padding: 0 5px; border: 1px solid;
  color: var(--fg-dim); border-color: var(--border);
}
.tag-src-claude { color: var(--accent); border-color: var(--accent); }
.tag-src-codex { color: #10a37f; border-color: #10a37f; }

/* 项目重命名：hover 显示 ✏️，行内输入编辑 */
.rename-btn {
  position: absolute; right: 10px; top: 8px; opacity: 0; cursor: pointer;
  font-size: 12px; padding: 0 4px; border-radius: 4px; transition: opacity .12s;
}
.proj-head:hover .rename-btn { opacity: .7; }
.rename-btn:hover { opacity: 1; }
.rename-btn.renamed { opacity: .55; color: var(--accent); }
.proj-head:hover .rename-btn.renamed { opacity: .8; }
.rename-input {
  flex: 1; min-width: 0; background: var(--bg3); border: 1px solid var(--accent);
  color: var(--fg); border-radius: 4px; font-size: 13px; padding: 1px 6px; outline: none;
}

/* 置顶按钮：行 hover 显示 */
.sess { position: relative; }
.pin-btn {
  position: absolute; top: 6px; right: 8px; opacity: 0; cursor: pointer;
  font-size: 12px; padding: 0 3px; border-radius: 4px; transition: opacity .12s;
}
.sess:hover .pin-btn { opacity: .7; }
.pin-btn:hover { opacity: 1; }
.sess.active .pin-btn { opacity: .6; }

/* 轻提示 toast */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--bg3); border: 1px solid var(--border); color: var(--fg);
  padding: 6px 16px; border-radius: 8px; font-size: 12px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 99;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 被隐藏的加密会话提示 */
.hidden-note {
  padding: 2px 14px 6px; font-size: 11px; color: var(--fg-dim);
}

/* 本地文件链接（走 /api/open 系统打开） */
.md a.open-local, a.open-local {
  color: var(--accent);
  text-decoration: underline dotted;
  cursor: pointer;
}

/* ════════════ 右栏 Dock：独立文档查看系统 ════════════ */
#dock {
  flex: 0 0 auto; width: 420px; min-width: 240px; max-width: 900px;
  display: flex; flex-direction: column; border-left: 1px solid var(--border);
  background: var(--bg2);
}
#dock-resizer { flex: 0 0 5px; cursor: col-resize; background: transparent; }
#dock-resizer:hover, body.resizing #dock-resizer { background: var(--accent); }
body.dock-hidden #dock, body.dock-hidden #dock-resizer { display: none; }
#dock-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  border-bottom: 1px solid var(--border); padding: 4px 6px;
}
#dock-tabs { flex: 1; display: flex; gap: 2px; overflow-x: auto; min-width: 0; }
.dock-tab {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  font-size: 12px; border-radius: 5px; cursor: pointer; user-select: none;
  color: var(--fg-dim); white-space: nowrap; border: 1px solid transparent;
}
.dock-tab:hover { background: var(--bg3); }
.dock-tab.active { background: var(--bg3); color: var(--fg); border-color: var(--border); }
.dock-tab .dt-title { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.dock-tab .dt-x { color: var(--fg-dim); padding: 0 2px; border-radius: 3px; }
.dock-tab .dt-x:hover { color: var(--red); }
#dock-collapse {
  flex: 0 0 auto; background: none; border: 1px solid var(--border); color: var(--fg-dim);
  border-radius: 5px; cursor: pointer; padding: 2px 8px; font-size: 12px;
}
#dock-collapse:hover { color: var(--fg); }
#dock-body { display: flex; flex-direction: column; }
.dock-toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 11px;
}
.dock-toolbar .dock-path { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.dock-toolbar .spacer { flex: 1; }
.dock-act {
  background: none; border: 1px solid var(--border); color: var(--fg-dim);
  border-radius: 4px; cursor: pointer; padding: 1px 7px; font-size: 12px;
}
.dock-act:hover { color: var(--fg); }
.dock-content { flex: 1; overflow-y: auto; min-height: 0; padding: 10px 14px; }
.dock-code {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap;
  word-break: break-word; margin: 0;
}
.dock-code .jk { color: #7dd3fc; }   /* json key */
.dock-code .js { color: #86efac; }   /* json string */
.dock-code .jn { color: #fbbf24; }   /* json number */
.dock-code .jb { color: #f472b6; }   /* json bool/null */
.dock-html { width: 100%; height: 100%; min-height: 400px; border: none; background: #fff; border-radius: 6px; }
.dock-img-wrap { text-align: center; }
.dock-img-wrap img { max-width: 100%; border-radius: 6px; }

/* 文件引用（可点击路径）：工具卡片 + 记忆引用条目 */
.file-ref {
  color: var(--accent); cursor: pointer; text-decoration: underline dotted;
  word-break: break-all;
}
.file-ref:hover { text-decoration-style: solid; }
.mc-entry {
  background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 4px; padding: 1px 6px; font-size: 11px; cursor: pointer;
}
.mc-entry:hover { border-color: var(--accent); }
.mc-id-btn {
  background: none; border: none; color: var(--fg-dim);
  font-family: var(--mono); font-size: 11px; cursor: pointer; padding: 1px 4px;
}
.mc-id-btn:hover { color: var(--accent); text-decoration: underline dotted; }

/* 记忆引用条（oai-mem-citation） */
.mem-citation {
  margin: 4px 0; padding: 4px 10px; font-size: 11px; color: var(--fg-dim);
  background: var(--bg3); border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.mem-citation .mc-label { font-weight: 600; }
.mem-citation .mc-id { font-size: 11px; color: var(--fg); }
.mem-citation .msg-time { margin-left: auto; }
.placeholder { color: var(--fg-dim); text-align: center; margin-top: 40px; }

/* 项目节点（吸顶） */
.proj { border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-bottom: 4px; }
.proj-head {
  position: relative; padding: 8px 12px 4px; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--bg2); z-index: 2;
}
.proj-head:hover { background: var(--bg3); }
.p-row1 { display: flex; align-items: center; gap: 7px; }
.proj-head .caret { color: var(--fg-dim); font-size: 10px; width: 10px; flex: 0 0 auto; }
.proj-head .p-name {
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.proj-head .p-count { font-size: 10px; color: var(--fg-dim); flex: 0 0 auto; }
/* 元信息：悬停时以悬浮卡片显示，不占布局、不推动其他行 */
.proj-head .p-meta {
  display: none; position: absolute; top: 100%; left: 28px; z-index: 30;
  margin: 0; padding: 4px 10px; gap: 8px; flex-wrap: wrap; max-width: 260px;
  font-size: 10px; color: var(--fg-dim);
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.proj-head:hover .p-meta { display: flex; }

/* 嵌套会话行：缩进 + 呼吸间距，无引导线 */
.sess {
  position: relative;
  padding: 9px 12px 9px 14px; margin-left: 28px;
  cursor: pointer; border-radius: 0 6px 6px 0;
}
.sess:hover { background: var(--bg3); }
.sess.active { background: var(--bg3); box-shadow: inset 2px 0 0 var(--accent); }
.s-row1 { display: flex; align-items: center; gap: 8px; }
.sess .s-title {
  font-size: 12px; font-weight: 400; color: #b8c0c8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.sess.active .s-title { color: var(--fg); }
.sess .s-meta {
  display: none; position: absolute; top: 100%; left: 14px; z-index: 30;
  margin: 0; padding: 4px 10px; gap: 8px; flex-wrap: wrap; max-width: 260px;
  font-size: 10px; color: var(--fg-dim);
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.sess:hover .s-meta { display: flex; }

/* 状态圆点：运行中=绿脉冲，在线空闲=空心绿 */
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.busy { background: var(--green); animation: wg-pulse 1.2s ease-in-out infinite; }
.status-dot.idle { border: 1.5px solid var(--green); background: transparent; box-sizing: border-box; }

/* 会话头部的进行中徽章（保留给会话头用） */
.badge-live { color: var(--green); border: 1px solid var(--green); border-radius: 4px; padding: 0 4px; font-size: 9px; flex: 0 0 auto; }
.badge-live.busy { color: var(--yellow); border-color: var(--yellow); }

/* 加载更多：纯文字链接样式 */
.load-more {
  display: block; background: none; border: none; text-align: left;
  margin: 2px 12px 6px 42px; padding: 4px 0;
  color: var(--fg-dim); font-size: 11px; cursor: pointer;
}
.load-more:hover { color: var(--blue); }

/* 会话头 */
#session-head {
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg2);
  flex: 0 0 auto; display: none;
}
#session-head.show { display: block; }
#session-head h2 { margin: 0 0 4px; font-size: 15px; }
#session-head .meta { font-size: 12px; color: var(--fg-dim); display: flex; gap: 14px; flex-wrap: wrap; }
#session-head .meta code { font-family: var(--mono); font-size: 11px; }

/* ---------- 时间线 ---------- */
#timeline { padding: 16px 24px 60px; }
/* 内容列宽的唯一事实源：所有时间线条目共享同一约束（居中的 72%，640-1200px 夹紧）。
   新增条目类型时把选择器加进这一组即可；将来加右边栏只动这一个变量。 */
:root {
  --content-w: clamp(640px, 72%, 1200px);
}
#timeline > .msg, #timeline > .tool, #timeline > details,
#timeline > .msg-system, #timeline > .msg-task, #timeline > .mem-citation {
  width: var(--content-w);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.msg { margin: 0 0 12px; }
.msg-time { font-size: 10px; color: var(--fg-dim); font-family: var(--mono); margin-top: 3px; }

.msg-user .bubble {
  background: #1f2a3d; border: 1px solid #2d4a6b; border-radius: 10px;
  padding: 8px 14px; word-break: break-word;
}
.msg-user .who { color: var(--blue); }
/* AI 回答：文档流，无框；顶层 AI 区块前加细分隔线 */
.msg-assistant .bubble {
  background: none; border: none; border-radius: 0; padding: 4px 0;
}
#timeline > .msg-assistant {
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 20px;
}
.msg-assistant .who { color: var(--fg-dim); font-weight: 500; }
.who { font-size: 11px; font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.who .usage { font-weight: 400; color: var(--fg-dim); font-family: var(--mono); font-size: 10px; }
.tag-synthetic, .tag-meta, .tag-error {
  font-size: 10px; border-radius: 4px; padding: 0 5px; border: 1px solid;
}
.tag-meta { color: var(--fg-dim); border-color: var(--border); }
.tag-error { color: var(--red); border-color: var(--red); }

.msg-user img { max-width: 240px; max-height: 180px; border-radius: 6px; margin-top: 6px; display: block; }

/* 悬停复制按钮 */
.bubble { position: relative; }
.copy-btn {
  position: absolute; top: 6px; right: 8px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--fg-dim);
  border-radius: 5px; font-size: 11px; padding: 1px 8px; cursor: pointer;
  opacity: 0; transition: opacity .15s; z-index: 2;
}
.msg:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.copy-btn.copied { color: var(--green); border-color: var(--green); opacity: 1; }
.msg-assistant .copy-btn { top: 0; right: 0; }

/* thinking */
details.thinking { margin: 0 0 12px; }
details.thinking summary {
  cursor: pointer; color: var(--purple); font-size: 12px; user-select: none;
  list-style: none;
}
details.thinking summary::before { content: "▸ "; }
details.thinking[open] summary::before { content: "▾ "; }
details.thinking .think-body {
  margin-top: 4px; padding: 8px 12px; background: var(--bg2);
  border-left: 3px solid var(--purple); border-radius: 0 8px 8px 0;
  color: var(--fg-dim); font-size: 13px; white-space: pre-wrap; word-break: break-word;
}

/* 工具卡片 */
.tool {
  margin: 0 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg2);
  overflow: hidden;
}
.tool-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  cursor: pointer; user-select: none; font-family: var(--mono); font-size: 12px;
}
.tool-head:hover { background: var(--bg3); }
.tool-head .t-name { color: var(--accent); font-weight: 700; }
.tool-head .t-summary { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tool-head .t-status { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.tool-head .t-status.ok { background: var(--green); }
.tool-head .t-status.err { background: var(--red); }
.tool-head .t-status.pending { background: var(--yellow); }
.tool-head .caret { color: var(--fg-dim); }
.tool-body { border-top: 1px solid var(--border); display: none; }
.tool.open .tool-body { display: block; }
.tool-section { padding: 8px 12px; }
.tool-section + .tool-section { border-top: 1px dashed var(--border); }
.tool-section h5 { margin: 0 0 4px; font-size: 11px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; }
.tool-section pre {
  margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 400px; overflow-y: auto;
}
.tool-section pre.err { color: #ffa198; }
.trunc-note { font-size: 11px; color: var(--yellow); margin-top: 4px; font-family: var(--mono); }

/* Bash 终端样式 */
.tool-section pre.cmd {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px 8px 26px; position: relative; color: #9ece6a;
}
.tool-section pre.cmd::before {
  content: "$"; position: absolute; left: 10px; top: 8px; color: var(--fg-dim);
}
.cmd-desc { color: var(--fg-dim); font-size: 12px; margin-bottom: 4px; }
.cmd-meta { color: var(--fg-dim); font-size: 11px; font-family: var(--mono); margin-top: 4px; }
.tool-section pre.dim { color: var(--fg-dim); }

/* Edit diff 样式 */
.tool-section pre.diff { max-height: 240px; }
.diff-del { color: #ffa198; background: rgba(248,81,73,.08); display: block; }
.diff-add { color: #7ee787; background: rgba(63,185,80,.08); display: block; }

/* shell 语法高亮 */
.sh-str { color: #e5c07b; }
.sh-com { color: var(--fg-dim); font-style: italic; }
.sh-op { color: #ff7a93; font-weight: 600; }
.sh-var { color: #56c2d6; }
.sh-flag { color: #ab7df8; }

/* unified diff 视图 */
.diff-view {
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  border: 1px solid var(--border); border-radius: 6px; overflow: auto; max-height: 420px;
}
.diff-hunk {
  color: var(--blue); background: rgba(68,147,248,.08);
  padding: 2px 10px; user-select: none;
}
.diff-line { display: flex; padding: 0 10px 0 0; white-space: pre-wrap; word-break: break-word; }
.diff-sign { width: 20px; flex: 0 0 auto; text-align: center; opacity: .55; user-select: none; }
.diff-line.dl { background: rgba(248,81,73,.10); color: #ffa198; }
.diff-line.al { background: rgba(63,185,80,.10); color: #7ee787; }
.diff-line.cl { color: var(--fg-dim); }

/* 工作过程折叠条：纯文字行（学截图交互，无框） */
details.workgroup { margin: 0 0 4px; }
details.workgroup summary {
  cursor: pointer; user-select: none; list-style: none;
  font-size: 12px; font-family: var(--mono); color: var(--fg-dim);
  padding: 2px 0; display: flex; align-items: center; gap: 6px;
}
details.workgroup summary::-webkit-details-marker { display: none; }
details.workgroup summary::after { content: '›'; margin-left: 2px; transition: transform .15s; }
details.workgroup[open] summary::after { transform: rotate(90deg); }
details.workgroup summary:hover { color: var(--fg); }
.wg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: 0 0 auto; }
details.workgroup.working .wg-dot { background: var(--green); animation: wg-pulse 1s ease-in-out infinite; }
details.workgroup.working summary { color: var(--green); }
@keyframes wg-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.75); } }
.wg-live { color: var(--green); }
.wg-body { margin: 6px 0 10px 16px; padding-left: 12px; border-left: 2px solid var(--border); }

/* 系统消息 */
.msg-system { font-size: 11px; color: var(--fg-dim); font-family: var(--mono); text-align: center; margin: 14px 0; }

/* 后台任务完成通知：安静的事件行 */
.msg-task {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-family: var(--mono); color: var(--fg-dim);
  margin: 10px auto; padding: 3px 0;
}
.msg-task .t-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.msg-task.err .t-dot { background: var(--red); }
.msg-task .t-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-task.err .t-text { color: #ffa198; }
.msg-system.away_summary { text-align: left; }
.msg-system.away_summary .sum {
  border: 1px dashed var(--border); border-radius: 8px; padding: 6px 12px;
  display: inline-block; max-width: 700px; white-space: pre-wrap;
}

/* 子代理交还报告：紫色折叠卡，展开渲染 markdown */
details.agent-report { margin: 0 0 12px; }
details.agent-report summary {
  cursor: pointer; user-select: none; list-style: none;
  font-size: 12px; color: var(--purple); padding: 5px 0;
  display: flex; gap: 6px; align-items: baseline;
}
details.agent-report summary::-webkit-details-marker { display: none; }
details.agent-report summary::after { content: '›'; margin-left: auto; transition: transform .15s; }
details.agent-report[open] summary::after { transform: rotate(90deg); }
details.agent-report summary b { font-weight: 600; }
details.agent-report .ar-title {
  color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
details.agent-report .ar-body {
  margin: 4px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--purple);
}

/* 子代理 */
details.sidechain { margin: 0 0 12px; }
details.sidechain summary {
  cursor: pointer; user-select: none; list-style: none; font-size: 12px;
  color: var(--purple); padding: 6px 12px;
  border: 1px solid var(--purple); border-radius: 8px; background: rgba(171,125,248,.06);
}
details.sidechain summary::before { content: "▸ "; }
details.sidechain[open] summary::before { content: "▾ "; }
details.sidechain .sc-body {
  margin: 6px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--purple);
}
details.sidechain .sc-preview { color: var(--fg-dim); font-weight: 400; }

/* markdown-lite */
.md { line-height: 1.75; }
.md p { margin: 10px 0; }
.md p:first-child { margin-top: 0; }
.md p:last-child { margin-bottom: 0; }
.md pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  margin: 10px 0;
}
.md code { font-family: var(--mono); font-size: .92em; background: rgba(110,118,129,.25); border-radius: 4px; padding: 1px 5px; }
.md pre code { background: none; padding: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 6px; line-height: 1.35; }
.md h1:first-child, .md h2:first-child, .md h3:first-child, .md h4:first-child { margin-top: 4px; }
.md h1 { font-size: 1.25em; } .md h2 { font-size: 1.15em; } .md h3, .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 8px 0; padding-left: 24px; }
.md li { margin: 4px 0; }
.md a { color: var(--blue); text-decoration: none; border-bottom: 1px solid rgba(68,147,248,.35); }
.md a:hover { border-bottom-color: var(--blue); }
.md blockquote { border-left: 3px solid var(--border); margin: 6px 0; padding: 2px 12px; color: var(--fg-dim); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md .md-table { border-collapse: collapse; margin: 8px 0; font-size: 13px; max-width: 100%; }
.md .md-table th, .md .md-table td { border: 1px solid var(--border); padding: 4px 10px; }
.md .md-table th { background: var(--bg3); font-weight: 600; }
.md .md-table tbody tr:nth-child(even) td { background: rgba(110,118,129,.06); }

/* ---------- 统计 ---------- */
#view-stats { flex: 1; overflow-y: auto; padding: 20px; }
.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; min-width: 140px;
}
.stat-card .v { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.stat-card .k { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.chart { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.chart h3 { margin: 0 0 12px; font-size: 13px; color: var(--fg-dim); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; }
.bars .bar { flex: 1; min-width: 3px; background: var(--accent); border-radius: 2px 2px 0 0; position: relative; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.bars .bar .tip {
  display: none; position: absolute; bottom: 105%; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border); border-radius: 5px;
  font-size: 11px; padding: 2px 7px; white-space: nowrap; z-index: 5; font-family: var(--mono);
}
.bars .bar:hover .tip { display: block; }
table.stats { border-collapse: collapse; width: 100%; font-size: 12px; }
table.stats th, table.stats td { text-align: left; padding: 4px 10px; border-bottom: 1px solid var(--border); }
table.stats th { color: var(--fg-dim); font-weight: 600; }
table.stats td { font-family: var(--mono); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* 滚动区域（侧栏/时间线）：滚动条自动隐藏，滚动或悬停时出现 */
.pane-body::-webkit-scrollbar-thumb { background: transparent; transition: background .25s; }
.pane-body:hover::-webkit-scrollbar-thumb,
.pane-body.scrolling::-webkit-scrollbar-thumb { background: var(--border); }
