/* 颜色、字号、间距、圆角：浅色和深色两套。页面只用这些变量，下面的旧名字指到新变量上 */
:root {
  --bg: #F7F6F3; --surface: #FFFFFF; --side: #F0EEE9; --sunken: #F3F1EC; --line: #E2DED6; --line-2: #D3CEC4;
  --text: #1F1D1A; --text-2: #57524B; --text-3: #6F695F;
  --accent: #B4532A; --accent-weak: #F7E8E0; --on-accent: #FFFFFF;
  --wait: #A14B00; --wait-bg: #FFF1D6; --wait-dot: #E08600;
  --run: #1D4ED8; --run-bg: #E3ECFD; --run-dot: #2F6BEA;
  --bad: #B42318; --bad-bg: #FDE7E4; --bad-dot: #D92D20;
  --ok: #1E7A3C; --ok-bg: #E2F4E7; --ok-dot: #2E9E55;
  --idle: #6B675F; --idle-bg: #EEECE7; --off: #A9A398;
  --f-xs: 12px; --f-s: 13px; --f-m: 14px; --f-l: 15px; --f-xl: 17px; --f-xxl: 20px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r1: 6px; --r2: 8px; --r3: 12px; --r4: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  /* 旧名字 */
  --muted: var(--text-3); --hover: #E8E5DE; --sel: #E4DED2; --busy: var(--run-dot);
  --tag: var(--sunken); --tag-text: var(--text-2); --sub: #6B5FB0;
  --bubble: #ECE7DC; --card: var(--surface); --code: var(--sunken); --warn: var(--wait); --warn-bg: var(--wait-bg);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151413; --surface: #1E1D1B; --side: #1A1917; --sunken: #252421; --line: #34322E; --line-2: #45423D;
    --text: #ECE8E2; --text-2: #C2BCB3; --text-3: #9C958B;
    --accent: #E0784A; --accent-weak: #3A2219; --on-accent: #1A0E08;
    --wait: #F5B84A; --wait-bg: #3A2C12; --wait-dot: #F0A22E;
    --run: #8DB6FF; --run-bg: #17284A; --run-dot: #5B93F5;
    --bad: #FF9B8F; --bad-bg: #43201C; --bad-dot: #F2675A;
    --ok: #7FD69B; --ok-bg: #163322; --ok-dot: #3DB36A;
    --idle: #A8A196; --idle-bg: #2A2926; --off: #6A655E;
    --hover: #2A2825; --sel: #34312C; --bubble: #2C2925; --sub: #B3A8F0;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151413; --surface: #1E1D1B; --side: #1A1917; --sunken: #252421; --line: #34322E; --line-2: #45423D;
  --text: #ECE8E2; --text-2: #C2BCB3; --text-3: #9C958B;
  --accent: #E0784A; --accent-weak: #3A2219; --on-accent: #1A0E08;
  --wait: #F5B84A; --wait-bg: #3A2C12; --wait-dot: #F0A22E;
  --run: #8DB6FF; --run-bg: #17284A; --run-dot: #5B93F5;
  --bad: #FF9B8F; --bad-bg: #43201C; --bad-dot: #F2675A;
  --ok: #7FD69B; --ok-bg: #163322; --ok-dot: #3DB36A;
  --idle: #A8A196; --idle-bg: #2A2926; --off: #6A655E;
  --hover: #2A2825; --sel: #34312C; --bubble: #2C2925; --sub: #B3A8F0;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: var(--f-m)/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
#app { flex: 1; min-height: 0; display: flex; }
#side { width: 360px; min-width: 280px; max-width: 520px; resize: horizontal; overflow: hidden; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); }
#main { flex: 1; min-width: 0; display: flex; align-items: stretch; justify-content: center; }
.empty { color: var(--muted); }
.side-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side-title { display: flex; align-items: baseline; justify-content: space-between; font-weight: 600; font-size: 15px; }
.side-title .muted { font-weight: 400; font-size: 12px; }
#q { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.only-live { color: var(--muted); font-size: 12px; user-select: none; }
.muted { color: var(--muted); }
.tree { flex: 1; overflow: auto; padding: 6px 0 20px; }
.hint { padding: 16px; color: var(--muted); }
.side-foot { padding: 6px 12px; border-top: 1px solid var(--line); font-size: 11px; }

.proj { margin-top: 4px; }
.proj-head { display: flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer; user-select: none; position: sticky; top: -6px; background: var(--side); z-index: 1; }
.proj-head:hover { background: var(--hover); }
.proj-name { font-weight: 600; }
.proj-path { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.count b { color: var(--busy); font-weight: 600; }
.caret { width: 12px; color: var(--muted); font-size: 10px; flex: none; text-align: center; }

.node { position: relative; }
.row { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 0; cursor: pointer; border-radius: 6px; margin: 0 6px; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--sel); }
.row .caret { cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; border: 1.5px solid var(--off); }
.dot.idle { border-color: var(--idle); }
.dot.busy { background: var(--busy); border-color: var(--busy); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.body { flex: 1; min-width: 0; }
.title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title.untitled { color: var(--muted); }
.meta { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; }
.meta .branch { overflow: hidden; text-overflow: ellipsis; }
.time { color: var(--muted); font-size: 11px; white-space: nowrap; flex: none; }
.tag { font-size: 10.5px; padding: 0 5px; border-radius: 4px; background: var(--tag); color: var(--tag-text); white-space: nowrap; flex: none; }
.tag.fork { color: var(--accent); }
.tag.sub { color: var(--sub); }
.children { position: relative; }
.children::before { content: ""; position: absolute; top: 0; bottom: 6px; border-left: 1px solid var(--line); }
.agent .title { font-size: 12px; }
.agent .dot { border-style: dotted; }
.more { padding: 4px 12px 4px 32px; color: var(--muted); cursor: pointer; font-size: 12px; }
.more:hover { color: var(--text); }
.filters { display: flex; gap: 14px; }

/* 右边：会话内容 */
.conv { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.conv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-title #cvTitle { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-title #cvMeta { font-size: 11.5px; }
.levels { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; flex: none; }
.levels button { border: 0; background: transparent; color: var(--muted); font: inherit; padding: 4px 12px; cursor: pointer; }
.levels button + button { border-left: 1px solid var(--line); }
.levels button:hover { color: var(--text); background: var(--hover); }
.levels button.on { background: var(--sel); color: var(--text); font-weight: 600; }
.conv-body { flex: 1; overflow-y: auto; padding: 12px max(20px, calc((100% - 860px) / 2)) 40px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; line-height: 1.6; }
.load-more { text-align: center; padding: 6px; font-size: 12px; color: var(--accent); cursor: pointer; }
.load-more.muted { color: var(--muted); cursor: default; }
.msg.user { align-self: flex-end; max-width: 80%; margin-top: 14px; display: flex; flex-direction: column; align-items: flex-end; }
.bubble { background: var(--bubble); padding: 8px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.stamp { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stamp-inline { font-size: 11px; color: var(--muted); margin-left: auto; flex: none; }
.msg.asst { overflow-wrap: anywhere; }
.msg p, .thinking p, .fold-body p, .bubble p { margin: 4px 0; }
.msg h2, .msg h3, .msg h4, .msg h5, .msg h6 { margin: 12px 0 4px; font-size: 14px; }
.msg h2 { font-size: 15.5px; }
.msg ul, .msg ol, .fold-body ul, .fold-body ol { margin: 4px 0; padding-left: 22px; }
.msg blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
code { font: 12px ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--code); padding: 0 4px; border-radius: 4px; }
pre.code, pre.io { font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--code); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.code code { background: none; padding: 0; }
pre.io { max-height: 420px; overflow-y: auto; }
pre.io.err { color: var(--bad); }
.mdtable { overflow-x: auto; margin: 6px 0; }
.mdtable table { border-collapse: collapse; font-size: 12.5px; }
.mdtable th, .mdtable td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; vertical-align: top; }
.mdtable th { background: var(--code); }
.mdlink { text-decoration: underline dotted; }
a { color: var(--accent); }
.tool, .fold { border-radius: 6px; }
.tool-row, .fold-row { display: flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; min-width: 0; user-select: none; }
.tool-row:hover, .fold-row:hover { background: var(--hover); }
.tool-name { font-weight: 600; flex: none; }
.tool-sum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tool.pending .tool-name::after { content: " …"; color: var(--muted); }
.tool-detail, .fold-body { margin: 2px 0 6px 18px; }
.io-label { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.bad { color: var(--bad); }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fold.peer { background: var(--card); border: 1px solid var(--line); margin: 8px 0; }
.fold.peer .fold-row { padding: 6px 8px; }
.peer-from { font-weight: 600; color: var(--sub); flex: none; }
.fold.peer .fold-body { margin: 0; padding: 0 12px 8px; }
.fold.think .thinking { color: var(--muted); font-style: italic; border-left: 2px solid var(--line); padding-left: 10px; }
.line { font-size: 12.5px; padding: 1px 6px; }
.line.run { padding-left: 6px; }
.notice { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.dot-s { width: 6px; height: 6px; border-radius: 50%; background: var(--off); flex: none; }
.dot-s.ok { background: var(--ok); } .dot-s.bad { background: var(--bad); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }

/* 交互组件 */
.ui-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.ui-card.gone { opacity: .55; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--tag); color: var(--tag-text); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { color: var(--bad); }
.small { font-size: 11.5px; }
.wrapup { border-left: 3px solid var(--line); }
.wrapup.live { border-left-color: var(--accent); }
.wrapup .recap { color: var(--text); }
.wrap-ask { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: inherit; font-size: 12.5px; padding: 4px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { cursor: not-allowed; opacity: .6; }
.wrapup.live .btn:disabled { opacity: .85; }
.btn.chosen { opacity: 1 !important; outline: 2px solid var(--ok); }
.q + .q { border-top: 1px dashed var(--line); padding-top: 8px; }
.q-head { display: flex; gap: 8px; align-items: center; }
.q-text { font-weight: 600; margin: 2px 0 6px; }
.opts { display: flex; flex-direction: column; gap: 4px; }
.opt { border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; }
.opt.on { border-color: var(--ok); background: var(--ok-bg); }
.opt.off { opacity: .55; }
.opt-label { font-weight: 500; }
.opt-desc { color: var(--muted); font-size: 12px; }
.own { font-size: 12.5px; padding: 4px 9px; border-left: 3px solid var(--ok); }
.divider.chapter { color: var(--text); font-weight: 600; font-size: 13px; margin: 22px 0 10px; }
.divider.chapter::before, .divider.chapter::after { border-top-style: solid; }
.fold.peer.out { border-style: dashed; }
.file-list { display: flex; flex-wrap: wrap; gap: 10px; }
.file { font-size: 12.5px; }
.file.img { margin: 0; display: flex; flex-direction: column; gap: 2px; max-width: 260px; }
.file.img img { max-width: 260px; max-height: 200px; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; object-fit: contain; background: var(--code); }
.file.img figcaption { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
iframe.widget { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.plan-list { list-style: none; margin: 4px 0 2px; padding: 0 0 0 18px; font-size: 12.5px; }
.plan-list li { display: flex; gap: 6px; padding: 1px 0; }
.plan-list .mark { width: 14px; flex: none; color: var(--muted); }
.plan-list li.completed { color: var(--muted); }
.plan-list li.completed .mark { color: var(--ok); }
.plan-list li.in_progress { font-weight: 600; }
.plan-list li.in_progress .mark { color: var(--accent); }
.chapters-wrap { position: relative; flex: none; }
.chap-btn { font: inherit; font-size: 12px; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 7px; padding: 4px 10px; cursor: pointer; }
.chap-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); min-width: 260px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.chap-menu button { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; font: inherit; font-size: 12.5px; border: 0; background: transparent; color: var(--text); padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.chap-menu button:hover { background: var(--hover); }

/* 标签页 */
.tabs { display: flex; gap: 2px; padding: 0 max(20px, calc((100% - 860px) / 2)); border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab-count { font-weight: 400; color: var(--muted); }
.tab-count.hot { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; margin-left: 4px; font-size: 11px; }
.conv-body[hidden] { display: none; }
.plan-page { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.plan-sum { font-size: 14px; }
.plan-list { font-size: 13.5px; padding-left: 0; }
.plan-list li { padding: 5px 8px; border-radius: 6px; gap: 8px; }
.plan-list li.in_progress { background: var(--sel); }
.plan-list .num { color: var(--muted); width: 22px; flex: none; text-align: right; }
.card-bar { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.ask-item { margin: 6px 0 14px; }
.ask-item > .card-bar { margin-bottom: -2px; padding: 0 4px; }
.ask-item .ui-card { margin-top: 4px; }
.lnk { font: inherit; font-size: 12px; border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0; }
.lnk:hover { text-decoration: underline; }
.skipped-list { opacity: .7; }
.anchor { display: block; height: 0; }
.ui-card.flash, .fold.flash { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .3s; }

/* 需要我做 */
.todo-note { padding: 6px 2px 2px; }
.ui-card.todo.done, .ui-card.todo.dropped { opacity: .7; }
.ui-card.todo.blocked { border-left: 3px solid var(--bad); }
.ui-card.todo.todo { border-left: 3px solid var(--warn); }
.todo-detail p { margin: 4px 0; }
.todo-detail ul, .todo-detail ol { margin: 4px 0; padding-left: 22px; }
.todo-log { border-top: 1px dashed var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.log-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.log-text { flex-basis: 100%; white-space: pre-wrap; padding-left: 8px; border-left: 3px solid var(--ok); }
.log-img { max-width: 160px; max-height: 120px; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.compose { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.compose textarea { width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.compose-bar { display: flex; align-items: center; gap: 10px; }
.compose-bar .grow { flex: 1; }
.compose-bar .btn { white-space: nowrap; flex-shrink: 0; }
.compose .btn:not(:disabled) { cursor: pointer; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { font-size: 12px; background: var(--tag); border-radius: 5px; padding: 1px 6px; }

/* 底部输入框 */
.composer { flex: none; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding: 8px max(20px, calc((100% - 860px) / 2)) 10px; background: var(--bg); }
.composer[hidden] { display: none; }
.composer textarea { width: 100%; font: inherit; font-size: 13.5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); resize: vertical; min-height: 44px; max-height: 40vh; }
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer textarea:disabled { opacity: .6; cursor: not-allowed; }
.composer .btn:not(:disabled) { cursor: pointer; }
.composer .picked:empty { display: none; }
#ccStatus { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 正在等你的卡片 */
.ui-card.ask.live, .ui-card.approve { border-color: var(--warn); }
.ui-card .btn:not(:disabled) { cursor: pointer; }
.opt.pickable { font: inherit; text-align: left; background: var(--bg); color: var(--text); cursor: pointer; width: 100%; }
.opt.pickable:hover { border-color: var(--accent); }
.ask-other { width: 100%; font: inherit; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); margin-top: 4px; }
.ask-other:focus { outline: none; border-color: var(--accent); }
.ui-card.approve pre.io { max-height: 240px; overflow: auto; }

/* 文件链接和右边的看文件栏 */
a.flink, code.flink { cursor: pointer; }
code.flink { text-decoration: underline dotted; text-underline-offset: 2px; }
code.flink:hover { color: var(--accent); }
.viewer { flex: none; width: 46%; min-width: 280px; max-width: calc(100% - 360px); display: flex; flex-direction: column; height: 100%; border-left: 1px solid var(--line); background: var(--bg); position: relative; }
.viewer[hidden] { display: none; }
.vw-drag { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.vw-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.vw-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vw-title b, .vw-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-head a.chap-btn { text-decoration: none; }
.vw-body { flex: 1; overflow: auto; }
.vw-code { font: 12px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; padding: 6px 0 30px; min-width: max-content; }
.vw-code .cl { display: flex; white-space: pre; }
.vw-code .cl.hl { background: var(--warn-bg); }
.vw-code .ln { width: 52px; flex: none; text-align: right; padding-right: 12px; color: var(--muted); user-select: none; position: sticky; left: 0; background: inherit; }
.vw-code .cl:not(.hl) .ln { background: var(--bg); }
.vw-code .lc { padding-right: 16px; }
.vw-md { padding: 12px 18px 30px; }
.vw-img { padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.vw-img img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--code); }
.vw-dir { padding: 6px; display: flex; flex-direction: column; }
.vw-ent { display: flex; gap: 8px; align-items: center; padding: 4px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13px; }
.vw-ent:hover { background: var(--hover); }
.vw-ent .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-asked { margin-top: 6px; word-break: break-all; }
@media (max-width: 900px) {
  .viewer { position: fixed; inset: 0; width: auto !important; max-width: none; z-index: 20; }
  .vw-drag { display: none; }
}

/* 新建项目和会话 */
.add-btn { font: inherit; font-size: 11.5px; border: 1px solid var(--line); background: var(--bg); color: var(--accent); border-radius: 6px; padding: 1px 7px; cursor: pointer; flex: none; white-space: nowrap; }
.add-btn:hover { border-color: var(--accent); }
.side-title .add-btn { margin-left: auto; font-size: 12px; padding: 2px 9px; }
.proj-head .add-btn { visibility: hidden; }
.proj-head:hover .add-btn, .proj-head:focus-within .add-btn { visibility: visible; }
.row .row-add { visibility: hidden; padding: 0 6px; align-self: center; }
.row:hover .row-add, .row.sel .row-add, .row:focus-within .row-add { visibility: visible; }
@media (hover: none) { .proj-head .add-btn, .row .row-add { visibility: visible; } }
.tree > .proj > .hint.small { padding: 4px 32px 8px; }
dialog.dlg { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog.dlg::backdrop { background: rgba(0,0,0,.35); }
.dlg-form { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 16px; }
.dlg-form h2 { margin: 0; font-size: 16px; }
.dlg-form .field { display: flex; flex-direction: column; gap: 4px; }
.dlg-form .field > label:first-child { font-weight: 600; font-size: 12.5px; }
.dlg-form input:not([type=checkbox]):not([type=radio]), .dlg-form textarea, .dlg-form select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); width: 100%; }
.dlg-form textarea { resize: vertical; min-height: 90px; }
.dlg-form input:focus, .dlg-form textarea:focus, .dlg-form select:focus { outline: none; border-color: var(--accent); }
.dlg-form .field.bad input, .dlg-form .field.bad textarea { border-color: var(--bad); }
.dlg-form .chk { display: flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.dlg-form .chk.dim { color: var(--muted); }
.dlg-form .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .dlg-form .row3 { grid-template-columns: 1fr; } }
.dlg-form .note { min-height: 1.4em; }
.dlg-form .sub-input { margin-left: 22px; width: calc(100% - 22px) !important; }
.dlg-err:empty { display: none; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-btns .btn { cursor: pointer; padding: 5px 16px; }
.dir-list { display: flex; flex-direction: column; max-height: 200px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; padding: 4px; background: var(--bg); }
.dir-list:empty { display: none; }
.dir-cur { padding: 2px 6px 4px; }
.dir-item { font: inherit; font-size: 12.5px; text-align: left; border: 0; background: transparent; color: var(--text); padding: 3px 6px; border-radius: 5px; cursor: pointer; }
.dir-item:hover { background: var(--hover); }
.side-title { align-items: center; gap: 8px; justify-content: flex-start; }
.side-title #summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 账号 */
.acc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 11.5px; cursor: pointer; }
.acc-bar .add-btn { margin-left: auto; }
.acc-chip { padding: 1px 7px; border-radius: 10px; background: var(--tag); color: var(--tag-text); white-space: nowrap; }
.acc-chip.warn { background: var(--warn-bg); color: var(--warn); }
.acc-chip.bad { color: var(--bad); outline: 1px solid var(--bad); }
.acc-list { display: flex; flex-direction: column; gap: 8px; }
.acc-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.acc-item.bad { border-color: var(--bad); }
.acc-item.warn { border-color: var(--warn); }
.acc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acc-top .grow { flex: 1; }
.acc-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.dlg-form .row3.two { grid-template-columns: 1fr 1fr; }
.acc-add summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.acc-add[open] { display: flex; flex-direction: column; gap: 10px; }
.acc-add .steps { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.acc-add .cmd { display: flex; gap: 8px; align-items: center; margin-top: 3px; }
.acc-add .cmd code { word-break: break-all; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.ok-text { color: var(--ok); }

/* ===== 第一期改版：字号（正文不小于 14 像素） ===== */
.small, .meta, .count, .time, .side-foot, .acc-bar, .opt-desc, .io-label, .stamp, .stamp-inline, .tag, .pill { font-size: var(--f-xs); }
.conv-body { font-size: var(--f-l); }
.tool-row, .fold-row, .line, .btn, .card-head, .file, .chap-btn, .tabs button, .lnk, .ask-other, .compose textarea, .composer textarea, .dlg-form input:not([type=checkbox]):not([type=radio]), .dlg-form textarea, .dlg-form select, .dlg-form .chk, .plan-list, .mdtable table, .vw-ent { font-size: var(--f-m); }
code, pre.code, pre.io, .vw-code { font-size: var(--f-s); }
.dlg-form .field > label:first-child { font-size: var(--f-m); }
.conv-title #cvTitle { font-size: var(--f-l); }
.btn { padding: 6px 14px; border-radius: var(--r2); cursor: pointer; }
.btn:disabled { cursor: not-allowed; }
.btn.primary { color: var(--on-accent); }
.add-btn { font-size: var(--f-xs); }
.muted { color: var(--text-3); }

/* 连不上会话台 */
.net-banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); background: var(--bad-bg); color: var(--bad); border-bottom: 1px solid var(--bad-dot); font-size: var(--f-m); }
.net-banner[hidden] { display: none; }
.net-banner span { flex: 1; min-width: 0; }
body[data-offline] .act, body[data-offline] .btn.primary, body[data-offline] #ccSend { opacity: .45; cursor: not-allowed; }

/* 状态点：等你（琥珀实心带光圈）、在做（蓝，一闪一闪）、出错（红菱形）、歇着（空心圈）、只能看（虚线圈）、做完没看（强调色） */
.sd { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; border: 1.5px solid var(--off); background: transparent; vertical-align: middle; }
.sd-wait { background: var(--wait-dot); border-color: var(--wait-dot); box-shadow: 0 0 0 3px var(--wait-bg); }
.sd-run { background: var(--run-dot); border-color: var(--run-dot); animation: pulse 1.4s ease-in-out infinite; }
.sd-bad { background: var(--bad-dot); border-color: var(--bad-dot); border-radius: 1px; transform: rotate(45deg) scale(.85); }
.sd-idle { border-color: var(--idle); }
.sd-ro { border-style: dashed; border-color: var(--off); }
.sd-done { background: var(--accent); border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .sd-run { animation: none; } }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: var(--f-xs); font-weight: 600; padding: 1px 7px; border-radius: 10px; white-space: nowrap; flex: none; }
.st-wait { color: var(--wait); background: var(--wait-bg); }
.st-run { color: var(--run); background: var(--run-bg); }
.st-bad { color: var(--bad); background: var(--bad-bg); }
.st-idle, .st-ro { color: var(--idle); background: var(--idle-bg); }
.st-done { color: var(--accent); background: var(--accent-weak); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--wait-dot); color: #1F1300; font-size: var(--f-xs); font-weight: 700; text-align: center; line-height: 18px; flex: none; }

/* 侧栏 */
.side-head { gap: var(--s2); }
.side-title { font-size: var(--f-l); }
.home-btn { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.home-btn:hover { border-color: var(--line-2); }
.home-btn.sel { border-color: var(--accent); background: var(--accent-weak); }
.home-btn .badge { margin-left: auto; }
#q { font-size: var(--f-m); padding: 7px 10px; background: var(--surface); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: var(--f-s); padding: 3px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip .sd { width: 7px; height: 7px; box-shadow: none; }
.chip .n:not(:empty) { font-weight: 700; color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-weak); color: var(--text); font-weight: 600; }
.chip.ghost { margin-left: auto; }
.proj-head { font-size: var(--f-m); }
.count b { color: var(--wait); }
.row { align-items: flex-start; gap: 4px; padding: 6px 8px 6px calc(6px + var(--depth, 0) * 16px); margin: 1px 6px; border-radius: var(--r2); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row .caret { font: inherit; font-size: 11px; width: 18px; height: 20px; padding: 0; border: 0; background: transparent; color: var(--text-3); cursor: pointer; border-radius: 4px; flex: none; }
.row .caret:not(:disabled):hover { background: var(--hover); color: var(--text); }
.row .caret:disabled { cursor: default; }
.row .body { display: flex; flex-direction: column; gap: 2px; }
.row .l1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row .l1 .title { flex: 1; min-width: 0; font-size: var(--f-m); }
.row.unread .l1 .title { font-weight: 700; }
.row .l2 { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--f-s); }
.row .l2 .ln { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .l3 { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row .kidsum { font-size: var(--f-xs); font-weight: 600; padding: 0 6px; border-radius: 8px; }
.row.ro .l1 .title { color: var(--text-2); }
.row .row-add { margin-top: 1px; }
.tag.branch { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.more { display: block; width: calc(100% - 12px); margin: 0 6px; text-align: left; font: inherit; font-size: var(--f-s); border: 0; background: transparent; color: var(--text-3); padding: 4px 8px 4px calc(28px + var(--depth, 0) * 16px); border-radius: var(--r1); cursor: pointer; }
.more:hover { color: var(--text); background: var(--hover); }
.children::before { left: calc(14px + var(--depth, 0) * 16px); }

/* 等你处理（首页） */
.inbox { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.ib-head { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s4) max(var(--s5), calc((100% - 860px) / 2)) var(--s3); border-bottom: 1px solid var(--line); }
.ib-head h1 { margin: 0; font-size: var(--f-xxl); }
.ib-count { font-size: var(--f-l); color: var(--wait); font-weight: 700; }
.ib-head .grow { flex: 1; }
.ib-scroll { flex: 1; overflow-y: auto; }
.ib-list { padding: var(--s3) max(var(--s5), calc((100% - 860px) / 2)) var(--s6); display: flex; flex-direction: column; gap: var(--s3); }
.ib-group { display: flex; flex-direction: column; gap: var(--s3); }
.ib-group h2 { margin: var(--s3) 0 0; font-size: var(--f-l); display: flex; align-items: baseline; gap: var(--s2); }
.ib-n { font-size: var(--f-s); color: var(--text-3); font-weight: 400; }
.ib-empty { padding: var(--s5) var(--s4); text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r3); }
.ib-more { align-self: flex-start; margin-top: var(--s2); font-size: var(--f-m); }
.ib-skipped, .ib-done .icard { opacity: .85; }

/* 一件事的卡片（首页和停靠区） */
.icard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); box-shadow: var(--shadow); }
.icard.k-ask, .icard.k-approve, .icard.k-decide, .icard.k-proposal, .icard.k-todo, .icard.k-offer { border-left: 4px solid var(--wait-dot); }
.icard.k-error { border-left: 4px solid var(--bad-dot); }
.icard.k-done { border-left: 4px solid var(--accent); }
.icard.done-row { flex-direction: row; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); box-shadow: none; color: var(--text-2); }
.ic-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: var(--f-s); }
.ic-head .grow { flex: 1; }
.ic-head time { color: var(--text-3); font-size: var(--f-xs); }
.ic-sess { font-weight: 600; font-size: var(--f-m); color: var(--text); text-decoration: none; }
.ic-sess:hover { text-decoration: underline; }
.ic-proj { font-size: var(--f-xs); color: var(--text-3); }
.ic-body { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--f-m); }
.ic-q { font-weight: 600; }
.ic-recap { color: var(--text-2); }
.ic-btns { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.ic-err { color: var(--bad); background: var(--bad-bg); padding: 4px 10px; border-radius: var(--r1); font-size: var(--f-s); }
.ic-text { width: 100%; font: inherit; font-size: var(--f-m); padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg); color: var(--text); resize: vertical; }
.ic-text:focus { outline: none; border-color: var(--accent); }
.ic-raw summary, .ic-brief summary { cursor: pointer; color: var(--text-3); font-size: var(--f-s); }
.ic-plan { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r2); padding: 4px 12px; }
.icard .opts { gap: 6px; }
.icard .opt.pickable { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: var(--r2); }
.icard .opt.pickable .opt-label { display: block; font-weight: 600; }
.icard .opt.pickable .opt-desc { display: block; }
.icard .opt.on { border-color: var(--accent); background: var(--accent-weak); }
.opt-mark { color: var(--accent); flex: none; }
.opt.ro { opacity: .8; }

/* 会话页：停靠区（输入框正上方） */
.dock { flex: none; max-height: 48vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) max(20px, calc((100% - 860px) / 2)) 0; border-top: 1px solid var(--line); background: var(--bg); }
.dock:empty { display: none; }
.dock[hidden] { display: none; }
.dock .icard { box-shadow: none; }
.dock-todo { align-self: flex-start; padding: 2px 0 6px; }
#cvMeta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: var(--f-s); }
.back-btn { display: none; }

/* 手机（760 以下）：一次一屏。底部标签「等你处理 / 会话 / 账号」（web/phone.js 加的）；会话页占满全屏、不显示底部标签。
   按看得见的高度（--app-h，phone.js 按 visualViewport 算）排版，键盘弹出时输入框跟着上来。能点的地方不小于 44 像素。 */
.phone-nav { display: none; }
@media (max-width: 760px) {
  :root { --ph-nav: 58px; }
  html, body { height: var(--app-h, 100dvh); overflow: hidden; }
  #app { flex-direction: column; min-height: 0; }
  body:not(.in-session) #app { padding-bottom: calc(var(--ph-nav) + env(safe-area-inset-bottom, 0px)); }
  #side { flex: 1; min-height: 0; width: 100% !important; max-width: none; min-width: 0; resize: none; border-right: 0; }
  #main { flex: 1; min-height: 0; }
  /* 哪一屏：会话页 > 会话列表 > 等你处理（phone.js 还没跑时也先给等你处理） */
  body:not(.ph-list) #side, body.in-session #side { display: none; }
  body.ph-list:not(.in-session) #main { display: none; }
  body.ph-list:not(.in-session) #side { display: flex; }
  /* 侧栏在手机上：「等你处理」按钮由底部标签代替，账号条放进「账号」标签 */
  #homeBtn, #accBar { display: none; }
  .side-head { padding: 10px 12px 6px; }
  .side-head input[type="search"] { min-height: 44px; font-size: 16px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters .chip { min-height: 40px; padding: 0 14px; flex: none; }
  .side-foot { display: none; }
  #side .tree { max-height: none; flex: 1; }
  .tree .row { min-height: 52px; }
  .tree .row .caret { min-width: 32px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
  .tree .row .row-add { min-width: 40px; min-height: 40px; border: 0; background: none; color: var(--text-3); font-size: 18px; }
  .tree .proj-head { min-height: 44px; }

  /* 底部标签 */
  .phone-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--ph-nav) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--surface); border-top: 1px solid var(--line); }
  body.in-session .phone-nav { display: none; }
  .phone-nav button { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--f-s); cursor: pointer; }
  .phone-nav button.on { color: var(--accent); font-weight: 600; }
  .phone-nav .ph-ico { font-size: 18px; line-height: 1; }
  .phone-nav .ph-n { position: absolute; top: 4px; left: calc(50% + 10px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--wait); color: #fff; font-size: 12px; line-height: 20px; font-weight: 700; }
  .phone-nav .ph-dot { position: absolute; top: 8px; left: calc(50% + 10px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

  /* 等你处理 */
  .ib-list, .ib-head { padding-left: 12px; padding-right: 12px; }
  .ib-head h1 { font-size: 20px; }

  /* 会话页：头部两行（← 标题 / 详尽程度），标签页横着滑 */
  .back-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font: inherit; font-size: var(--f-m); border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--r2); padding: 0 10px; cursor: pointer; flex: none; }
  .conv-head { flex-wrap: wrap; padding: 6px 12px; gap: 6px 8px; }
  .conv-title { flex: 1 1 calc(100% - 120px); }
  .levels { order: 3; flex: 1 1 100%; display: flex; overflow-x: auto; }
  .levels button { flex: 1; min-height: 36px; padding: 0 8px; white-space: nowrap; }
  .chapters-wrap { order: 2; }
  .chap-btn { min-height: 44px; }
  .tabs { padding: 0 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
  .tabs button { min-height: 44px; padding: 0 10px; white-space: nowrap; }
  .conv-body, .composer, .dock { padding-left: 12px; padding-right: 12px; }
  .conv-body { padding-bottom: 16px; }
  .dock { max-height: 50%; }
  body.kb .dock { max-height: 30%; }
  body.kb .tabs, body.kb .levels { display: none; }
  .composer textarea { font-size: 16px; min-height: 44px; }
  body.kb .composer textarea { max-height: 30vh; }
  .compose-bar { flex-wrap: wrap; row-gap: 4px; }
  .compose-bar #ccStatus { order: 5; flex: 1 1 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #ccPick { min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }

  /* 手指点得准：卡片和对话里的按钮、链接按钮至少 44 像素 */
  .btn, .compose-bar .btn { min-height: 44px; padding-left: 16px; padding-right: 16px; }
  .icard .lnk, .ib-more, .card-bar .lnk, .dock-todo { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .icard .ic-sess { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  .conv { overflow: hidden; }
  .icard .btns, .icard .acts { gap: 8px; flex-wrap: wrap; }
  .ib-more { padding: 0 4px; }
  dialog, .dlg { max-width: 100vw; }
}
.fold-row.inline { display: inline-flex; margin-left: 8px; color: var(--text-3); font-size: var(--f-s); }
