/* 跟 todos.dev 同一套视觉：左侧导航（项目树 / 话题），右侧看板；默认深色锌灰，浅色暖石；Inter + JetBrains Mono */
:root {
  color-scheme: dark;
  --surface: #18181b; --surface-2: #1f1f23; --surface-3: #27272a; --inset: #09090b; --hover: #1f1f23;
  --text: #fafaf9; --text-2: #d4d4d8; --text-3: #939399; --dim: #88888f;  /* 小字对比度 ≥ 4.5:1（见 M6） */
  --line: #27272a; --line-strong: #3f3f46;
  --zinc: #71717a; --blue: #3b82f6; --amber: #f59e0b; --green: #22c55e; --rose: #f43f5e; --violet: #8b5cf6;
  --amber-text: #fbbf24; --rose-text: #fb7185; --green-text: #4ade80;
  --primary-bg: #fafaf9; --primary-fg: #18181b;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --surface: #faf7f2; --surface-2: #f2ede6; --surface-3: #e8e2d9; --inset: #f2ede6; --hover: #ece6dd;
    --text: #1c1917; --text-2: #57534e; --text-3: #665f59; --dim: #6f6862;
    --line: #e2dbd1; --line-strong: #cec6bb;
    --amber-text: #b45309; --rose-text: #be123c; --green-text: #15803d;
    --primary-bg: #1c1917; --primary-fg: #faf7f2;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; background: var(--surface); }
body { margin: 0; color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
body.nav-open, body.drawer-open, body.locked { overflow: hidden; }  /* 侧栏 / 抽屉打开时背景不跟着滚 */
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }

/* 左侧导航 */
.side { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.logo { width: 18px; height: 18px; border-radius: 5px; background: var(--text); flex-shrink: 0; }
.side-title { font-weight: 600; font-size: 15px; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-3); }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 13px; color: var(--text-2); }
.muted-head { margin-top: 14px; color: var(--text-3); }
.count { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 6px;
  background: transparent; font-size: 13px; color: var(--text-2); cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.tree { display: flex; flex-direction: column; gap: 1px; margin: 0 0 8px 17px; padding-left: 8px; border-left: 1px solid var(--line); }
.tree.sub { margin: 1px 0 2px 15px; padding-left: 6px; }
.tree-dir { display: flex; flex-direction: column; gap: 1px; }
/* “项目”标题行、目录行：按钮，带小三角（展开时转 90°） */
.group-toggle { width: 100%; border: 0; border-radius: 6px; background: transparent; cursor: pointer; text-align: left; }
.group-toggle:hover { background: var(--hover); }
.chev { width: 12px; height: 12px; flex-shrink: 0; display: inline-flex; color: var(--text-3); transition: transform .15s ease; }
.chev svg { width: 100%; height: 100%; }
[aria-expanded="true"] > .chev { transform: rotate(90deg); }
.group-toggle .chev { margin-left: -4px; opacity: .8; }
.group-cur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-3);
  padding: 0 6px; border-radius: 4px; background: var(--surface-3); }
/* 目录行：左边小三角（折叠 / 展开），右边目录名（选这个目录范围） */
.dir-row { gap: 0; padding: 0; color: var(--text-3); font: 12px var(--mono); cursor: default; }
.dir-tog, .dir-sel { display: flex; align-items: center; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; align-self: stretch; }
.dir-tog { flex-shrink: 0; padding: 7px 4px 7px 4px; border-radius: 6px 0 0 6px; }
.dir-tog:hover { color: var(--text); }
.dir-sel { flex: 1; min-width: 0; gap: 6px; padding: 7px 8px 7px 2px; border-radius: 0 6px 6px 0; text-align: left; }
.dir-row .count { font: 11px var(--sans); }
.dir-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-row:hover { color: var(--text-2); }
.dir-row.active { color: var(--text); }
/* 当前项目在折起的目录里：目录行亮一点，并在右边带个蓝点 */
.dir-row.has-current.collapsed { color: var(--text); background: var(--surface-2); }
.dir-row.has-current.collapsed .count::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px;
  border-radius: 999px; background: var(--blue); vertical-align: 1px; }
.proj-mark { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff; }  /* 字色由 20-nav.js 按底色亮度选黑或白 */
.proj-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-count { font-size: 11px; color: var(--dim); }
.proj-row.active .proj-count { color: var(--text-3); }
/* 项目组下面两项全局的“看板 / 话题”：数字是当前范围（全部项目或当前项目）的 */
.nav-view.active .ico { color: var(--text); }
.members-for { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: -4px; font-size: 12px; color: var(--dim); }
.members { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.member { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); padding: 3px 0; }
.member-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .when { margin-left: auto; color: var(--text-3); font-size: 11px; white-space: nowrap; }
.member .when.green { color: var(--green-text); }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; align-items: center; gap: 8px; }
.side-foot .nav-item { width: 100%; }  /* 和其他导航项一样整行宽，高亮条撑满 */
.stamp { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.ico { width: 16px; height: 16px; flex-shrink: 0; display: inline-flex; color: var(--text-3); }
.ico svg, .view-ico svg { width: 100%; height: 100%; }
.dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; background: var(--zinc); }
.dot.blue { background: var(--blue); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); }
.dot.rose { background: var(--rose); } .dot.violet { background: var(--violet); } .dot.zinc { background: var(--zinc); }

/* 右侧主区 */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main-head { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  background: var(--surface); }
.main-head h1 { white-space: nowrap; }
.main-head h1 { margin: 0; font-size: 15px; font-weight: 600; }
.view-ico { width: 26px; height: 26px; padding: 5px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); display: inline-flex; }
/* 头部项目选择：原生 select，外观跟按钮一致；小三角用两段渐变画（CSP 不许 data: 图片） */
.ws-pick { appearance: none; -webkit-appearance: none; min-width: 0; max-width: 280px; flex: 0 1 auto; height: 30px; padding: 0 28px 0 10px;
  font: 500 13px var(--sans); color: var(--text); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.ws-pick:hover { background-color: var(--hover); border-color: var(--line-strong); }
.ws-pick:disabled { cursor: default; padding-right: 10px; background-image: none; opacity: 1; }
.ws-pick:disabled:hover { background-color: var(--surface); border-color: var(--line); }
.ws-pick option, .ws-pick optgroup { background: var(--surface); color: var(--text); }
/* 目录下拉在项目下拉前面：等宽字体显示路径，一行放不下时先缩它 */
.dir-pick { max-width: 200px; flex: 0 2 auto; font: 500 12px var(--mono); color: var(--text-2); }
.dir-pick + .ws-pick { margin-left: -4px; }
/* 头部视图切换：看板 | 话题，分段按钮 */
.view-tabs { display: inline-flex; flex-shrink: 0; height: 30px; padding: 2px; gap: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--inset); }
.view-tabs [role=tab] { height: 24px; padding: 0 10px; border: 0; border-radius: 4px; background-color: transparent; cursor: pointer;
  font: 500 12px var(--sans); color: var(--text-3); white-space: nowrap; }
.view-tabs [role=tab]:hover { color: var(--text); }
.view-tabs [role=tab][aria-selected="true"] { background-color: var(--surface-3); color: var(--text); }  /* 只改底色：手机上靠 background-clip 缩进 */
#reload { margin-left: -4px; color: var(--text-3); }
#reload:hover { color: var(--text); }
#reload .ico, #reload svg { width: 16px; height: 16px; }
.icon-btn { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); }
.icon-btn > svg { width: 16px; height: 16px; flex-shrink: 0; }
.menu { display: none; }
.noscript { margin: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-2); font-size: 13px; }
.error { margin: 12px 20px 0; padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--rose-text);
  background: color-mix(in srgb, var(--rose) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--rose) 30%, var(--surface)); }

label { font-size: 12px; font-weight: 500; color: var(--text-2); }
input { font: 13px var(--sans); height: 34px; padding: 0 10px; border-radius: 6px; width: 100%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn { font: 500 13px var(--sans); height: 30px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }

/* 看板 */
.board { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 16px 20px; overflow-x: auto; }
.col { display: flex; flex-direction: column; flex: 1; min-width: 260px; border-radius: 12px; background: var(--inset); min-height: 0; }
.col.collapsed { flex: 0 0 48px; min-width: 48px; align-items: center; cursor: pointer; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.col.collapsed .col-head { flex-direction: column; padding: 14px 0; gap: 10px; }
.col-name { font-size: 13px; font-weight: 500; color: var(--text-2); }
.col.collapsed .col-name { writing-mode: vertical-rl; letter-spacing: .1em; }
.col-count { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* 列头收起 / 展开按钮：展开时在列头最右，收起时在竖排窄列最上面 */
.col-btn { margin-left: auto; width: 26px; height: 26px; border-radius: 5px; color: var(--text-3); flex-shrink: 0; }
.col-btn:hover { color: var(--text-2); }
.col-btn .ico { width: 14px; height: 14px; color: inherit; }
.col.collapsed .col-btn { margin-left: 0; }
.col.collapsed .cards { display: none; }
.card:focus-visible, .col-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.card:focus-visible { border-color: var(--line-strong); }
.cards { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; min-width: 0; }
.card:hover { border-color: var(--line-strong); }
.card.active { border-color: var(--line-strong); background: var(--surface-2); }
.card-top { display: flex; align-items: center; gap: 6px; }
.tid { font: 11px var(--mono); color: var(--text-3); }
.tag { margin-left: auto; font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.tag.amber { color: var(--amber-text); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.tag.rose { color: var(--rose-text); background: color-mix(in srgb, var(--rose) 15%, transparent); }
.tag.green { color: var(--green-text); background: color-mix(in srgb, var(--green) 15%, transparent); }
.tag.zinc { color: var(--text-3); background: var(--surface-3); }
.title { margin-top: 4px; font-size: 13px; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.meta { margin-top: 6px; font-size: 11px; color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.meta a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.note { margin-top: 6px; font-size: 12px; color: var(--text-2); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 12px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.empty-icon svg { width: 18px; height: 18px; }
.empty-text { font-size: 13px; color: var(--text-3); text-align: center; }

/* 话题 */
.topics { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.topic-list { border-right: 1px solid var(--line); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.convo { overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.convo-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 2px; justify-items: start; }
.convo-back { display: none; margin-bottom: 8px; }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }

/* 任务详情抽屉 */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 20; box-shadow: -12px 0 32px color-mix(in srgb, #000 25%, transparent);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); }
.drawer-title { padding: 14px 20px 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.drawer .meta { padding: 0 20px 12px; border-bottom: 1px solid var(--line); }
#d-error { margin: 12px 20px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#d-error .btn { height: 26px; padding: 0 10px; font-size: 12px; }
.drawer .msgs { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; gap: 3px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-who { font-size: 12px; font-weight: 600; color: var(--text); }
.msg-when { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.msg-body { font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.msg.progress .msg-body { background: transparent; border-style: dashed; }
.section-label { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .04em; }

/* 手机：导航收进抽屉，列竖排 */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; min-height: 100dvh; padding-top: 0; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 85vw); z-index: 30; transform: translateX(-100%);
    transition: transform .2s ease; padding-top: env(safe-area-inset-top); }
  .app.nav-open .side { transform: none; }
  .scrim { position: fixed; inset: 0; background: color-mix(in srgb, #000 40%, transparent); z-index: 25; }
  .menu { display: inline-flex; }
  /* 头部（菜单、刷新、更新于）钉在顶上：滚到看板底部也能打开导航 */
  .main-head { position: sticky; top: 0; z-index: 10; height: auto; min-height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 6px 0 12px; gap: 8px; }
  #error { position: sticky; top: calc(56px + env(safe-area-inset-top) + 8px); z-index: 9; margin: 8px 12px 0; }
  /* 有目录 / 项目下拉时头部分两行：第一行菜单、视图切换、更新于、刷新，第二行两个下拉（一行放不下两个 44px 的下拉） */
  .main-head:has(> .ws-pick:not([hidden])) { flex-wrap: wrap; row-gap: 4px; padding-top: calc(env(safe-area-inset-top) + 6px); padding-bottom: 6px; }
  .main-head:has(> .ws-pick:not([hidden]))::after { content: ""; order: 9; flex-basis: 100%; }
  .main-head:has(> .ws-pick:not([hidden])) ~ #error { top: calc(104px + env(safe-area-inset-top) + 8px); }
  .main-head > .ws-pick { order: 10; }
  body { overflow: auto; }
  body.nav-open, body.drawer-open, body.locked { overflow: hidden; }
  .main { min-height: 100vh; min-height: 100dvh; }
  .side-nav, .drawer .msgs { overscroll-behavior: contain; }
  /* 触控区 ≥ 44px：图标按钮直接放大（背景只在悬停时出现，视觉不变）；带边框的按钮用透明边框扩点击区，看上去还是原来的尺寸 */
  .icon-btn { width: 44px; height: 44px; }
  .menu { margin-left: -10px; }
  #reload { margin-left: -10px; }
  .drawer-head { padding-right: 6px; }
  .col-btn { width: 44px; height: 44px; margin: -9px -9px -9px auto; }
  .col.collapsed .col-btn { margin: -9px -9px -9px auto; }
  .nav-item, .group-toggle { min-height: 44px; }
  /* 手机头部：省掉视图图标和目录路径，把地方留给项目选择；透明边框把点击区扩到 44px，看上去仍是 36px */
  .view-ico { display: none; }
  .ws-pick { flex: 1 1 auto; max-width: none; height: 44px; font-size: 16px; padding: 0 30px 0 10px; border: 4px solid transparent; border-radius: 10px;
    background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--line); margin: 0 -4px; }
  .ws-pick:hover, .ws-pick:disabled:hover { border-color: transparent; }
  .ws-pick:disabled { padding-right: 10px; }
  .main-head > .ws-pick:not(.dir-pick) { flex: 1 1 0; }  /* 基准宽 0：长项目名不会把它挤到第三行 */
  .dir-pick { flex: 0 1 auto; max-width: 45%; }
  .dir-tog { width: 32px; justify-content: center; padding: 0; }
  .main-head h1 { flex-shrink: 0; }
  /* 有“看板 | 话题”切换时标题就重复了：手机上省掉 */
  .main-head:has(> .view-tabs:not([hidden])) h1 { display: none; }
  /* 视图切换：同样用透明边框把每个按钮的点击区扩到 44px，看上去是 36px 高的分段按钮 */
  .view-tabs { height: 44px; padding: 0; gap: 0; border: 4px solid transparent; border-radius: 10px; background-clip: padding-box;
    box-shadow: inset 0 0 0 1px var(--line); margin: 0 -4px; }
  /* 四个标签（看板 | 话题 | 定时 | 记忆）：左右内边距 2px，iPhone 13 宽度下菜单、标签、更新于、刷新仍在一行；每个标签点击区仍 ≥ 44px 宽 */
  .view-tabs [role=tab] { height: 44px; margin: -4px 0; padding: 0 2px; border: 6px solid transparent; border-radius: 10px;
    background-clip: padding-box; font-size: 14px; }
  .view-tabs [role=tab]:first-child { margin-left: -4px; }
  .view-tabs [role=tab]:last-child { margin-right: -4px; }
  .nav-view, .proj-row { font-size: 14px; }
  .btn { height: 44px; border: 7px solid transparent; border-radius: 13px; background-clip: padding-box;  /* 外圆角 = 6px + 透明边框，内侧看上去仍是 6px */
    box-shadow: inset 0 0 0 1px var(--line); padding: 0 12px; }
  .btn.primary { border-color: transparent; box-shadow: none; }
  .btn, .btn:hover, .btn.primary { background-clip: padding-box; }  /* background 简写会把 clip 重置回 border-box */
  .row { gap: 0; margin: 1px -7px 0; }
  #d-error .btn { height: 40px; border-width: 7px; margin: -7px 0; }
  .btn.small { height: 44px; border-width: 9px; border-radius: 15px; padding: 0 8px; margin: -9px -9px -1px; }
  input { height: 44px; font-size: 16px; }  /* 16px 以上 iOS 聚焦时不自动放大 */
  .board { flex-direction: column; overflow: visible; padding: 12px; }
  .col, .col.collapsed { flex: none; min-width: 0; width: 100%; align-items: stretch; }
  .col.collapsed .col-head { flex-direction: row; padding: 12px 14px; }
  .col.collapsed .col-name { writing-mode: horizontal-tb; letter-spacing: 0; }
  .cards { overflow: visible; }
  .empty { flex-direction: row; justify-content: flex-start; padding: 0 14px 14px; }
  .empty-icon { display: none; }
  .topics { grid-template-columns: minmax(0, 1fr); }
  .topic-list { border-right: 0; }
  .topics:not(.reading) .convo-pane { display: none; }
  .topics.reading .topic-col { display: none; }
  .convo { padding: 12px; }
  .convo-back { display: inline-flex; align-items: center; }
}
@media (prefers-reduced-motion: reduce) { .side, .chev { transition: none; } }

/* == 汇总视图（board 路） == */
/* 项目概况：每个项目一张小卡（桌面最多两行、多了竖向滚；手机横向滑），下面一排项目筛选；再下面是合并看板 */
.overview { flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 0; min-width: 0; }
.overview:empty { display: none; }
.overview:not([hidden]) + .board { padding-top: 12px; }
.ov-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 288px; overflow-y: auto;
  padding: 2px; margin: -2px; }  /* 两行卡片正好放下（每张约 137px），多了竖向滚；留 2px 给焦点框 */
.ov-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 12px 12px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; }
.ov-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.ov-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ov-card.busy { border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); }
.ov-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-head .proj-mark { width: 26px; height: 26px; border-radius: 7px; font-size: 11px; }
.ov-names { min-width: 0; display: grid; }
.ov-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-parent { font: 11px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.ov-num { display: flex; flex-direction: column; min-width: 0; }
.ov-num b { font-size: 16px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--text); }
.ov-num span { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.ov-num.blue b { color: color-mix(in srgb, var(--blue) 75%, var(--text)); }
.ov-num.amber b { color: var(--amber-text); }
.ov-num.rose b { color: var(--rose-text); }
.ov-num.zero b { color: var(--dim); font-weight: 400; opacity: .7; }
.ov-num.zero span { opacity: .8; }
.ov-foot { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; color: var(--text-3); }
.ov-link { flex-shrink: 0; height: 22px; padding: 0 8px; border: 0; border-radius: 5px; background: var(--surface-3); color: var(--text-2);
  font-size: 11px; cursor: pointer; }
.ov-link:hover { color: var(--text); background: var(--line-strong); }
.ov-when { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-filter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding: 2px; margin: -2px; }
.ov-chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 999px;
  background: transparent; box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.ov-chip:hover { background: var(--hover); color: var(--text); }
.ov-chip.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); font-weight: 500; }
.ov-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; display: inline-block; }
/* 合并看板卡片上的项目标签 */
.card-proj { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: 11px; color: var(--text-2); }
.card-proj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
@media (max-width: 760px) {
  .overview { padding: 12px 12px 0; gap: 8px; }
  .ov-cards { display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    margin: 0 -12px; padding: 2px 12px 4px; scroll-padding: 0 12px; scrollbar-width: none; }
  .ov-card { flex: 0 0 min(250px, 74vw); scroll-snap-align: start; }
  /* 触控区 ≥ 44px：透明边框扩点击区，看上去尺寸不变 */
  .ov-link { height: 44px; border: 11px solid transparent; border-radius: 16px; background-clip: padding-box; margin: -11px 0 -11px -11px; padding: 0 8px; }
  .ov-filter { gap: 0; margin: 0 -12px; padding: 0 8px; scrollbar-width: none; }
  .ov-chip { height: 44px; border: solid transparent; border-width: 8px 3px; border-radius: 999px; background-clip: padding-box; }
  .ov-chip, .ov-chip:hover, .ov-chip.on { background-clip: padding-box; }
  .overview:not([hidden]) + .board { padding-top: 4px; }
}

/* 会话：卡片角落的小图标、派发方小字、抽屉里的会话块、留言底部的复制按钮 */
.card-sess { margin-left: auto; display: inline-flex; width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.card-sess svg { width: 14px; height: 14px; }
.card-top .tag + .card-sess { margin-left: 2px; }
.card-by { color: var(--dim); font-size: 11px; white-space: nowrap; }
.sess { display: grid; gap: 4px; min-width: 0; }
.drawer .sess:not(.compact) { padding: 10px 20px 12px; border-bottom: 1px solid var(--line); }
.sess-head { display: flex; align-items: center; gap: 8px; }
.sess-label { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .04em; }
.sess-tool { font: 500 11px var(--mono); color: var(--text-2); background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }
.sess-id { font: 12px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sess-note { font: 11px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sess-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; min-width: 0; }
.sess.compact .sess-actions { margin-top: 2px; }
.sess-copy { display: contents; }
/* 话题卡片第二行：参与者 + 右侧紧凑的“复制恢复命令” */
.card-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.card-row .title { flex: 1 1 0; min-width: 0; }
.card-row .btn.small { flex-shrink: 0; margin-top: 4px; height: 24px; }
.sess-fallback { flex: 1 1 100%; min-width: 0; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-strong);
  background: var(--inset); color: var(--text); font: 12px var(--mono); }
@media (max-width: 760px) {
  .sess-actions .btn.small { margin: -9px -9px -9px -9px; }
  .sess.compact .sess-actions { margin-top: 6px; }
  .card-row .btn.small { height: 44px; margin: -6px -9px -9px 0; }  /* 看上去 26px，点击区 44px */
  .sess-fallback { height: 44px; font-size: 16px; }  /* 16px：iOS 聚焦不放大页面 */
}

/* == 定时（只读列表）：桌面一行一条、按列对齐；手机每条一张卡片，每格带标签 == */
.schedules { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; }
.sched-table { --sc-cols: minmax(220px, 2.4fr) minmax(84px, .8fr) minmax(72px, .7fr) 72px minmax(170px, 1.6fr) minmax(130px, 1.1fr) 56px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--inset); overflow: hidden; }
.sched-head, .sched-row { display: grid; grid-template-columns: var(--sc-cols); gap: 12px; align-items: center; padding: 10px 16px; }
.sched-head { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .04em; border-bottom: 1px solid var(--line); padding-top: 12px; }
.sched-list { display: flex; flex-direction: column; }
.sched-row { background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.sched-row:last-child { border-bottom: 0; }
.sched-row.inactive .title { color: var(--text-2); }
.sc-main { min-width: 0; }
.sc-top { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.sc-main .title { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-cell { min-width: 0; font-size: 12px; color: var(--text-2); }
.sc-val { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.sc-lbl { display: none; }
.sc-cell .tag { margin-left: 0; }
.sc-runs { font-variant-numeric: tabular-nums; }
.sc-next, .sc-dim { font-variant-numeric: tabular-nums; }
.sc-dim { color: var(--text-3); white-space: nowrap; }
.sc-gate { font-size: 11px; padding: 0 6px; border-radius: 4px; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong); white-space: nowrap; }
.sc-run { font: 12px var(--mono); color: var(--text); background: transparent; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.sc-run:hover { text-decoration-color: var(--text-3); }
/* 定时任务生成的任务：卡片、抽屉上的“定时 · #n” */
.sched-tag { font-size: 11px; padding: 0 6px; border-radius: 4px; white-space: nowrap; color: var(--text-2); background: var(--surface-3); }
@media (max-width: 760px) {
  .schedules { padding: 12px; overflow: visible; }
  .sched-table { border: 0; background: transparent; border-radius: 0; }
  .sched-head { display: none; }
  .sched-list { gap: 8px; }
  .sched-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
  .sched-row:last-child { border-bottom: 1px solid var(--line); }
  .sc-main { grid-column: 1 / -1; }
  .sc-main .title { white-space: normal; overflow-wrap: anywhere; }
  /* 两两成行：间隔 | 派给，状态 | 累计，上次运行（整行），下次运行 */
  .sc-every { order: 1; } .sc-who { order: 2; } .sc-status { order: 3; } .sc-runs { order: 4; }
  .sc-last { order: 5; grid-column: 1 / -1; } .sc-next { order: 6; grid-column: 1 / -1; }
  .sc-lbl { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 1px; }
  .sc-cell { font-size: 13px; }
  /* 任务号的点击区扩到 44px，看上去不变 */
  .sc-run { font-size: 13px; padding: 12px 0; margin: -12px 0; }
}

/* == 记忆（只读）：通用偏好 + 每个项目的快照（偏好原文、踩坑、ADR、约束）；手机上表格每行折成两行 == */
.memory { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; }
.mem { display: flex; flex-direction: column; gap: 20px; max-width: 980px; }
.mem-sec { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mem-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.mem-n { font-size: 11px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mem-proj { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--inset); min-width: 0; }
.mem-proj .mem-h { font-size: 12px; color: var(--text-2); }
.mem-proj-head { display: flex; align-items: center; min-width: 0; }
.mem-proj-head .card-proj { font-size: 12px; }
.mem-stamp { margin: 0; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mem-none { margin: 0; font-size: 12px; color: var(--text-3); }
.mem-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; color: var(--text-2);
  padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); max-height: 420px; overflow-y: auto; }
.mem-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.mem-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; gap: 12px; align-items: baseline; padding: 7px 12px;
  border-bottom: 1px solid var(--line); font-size: 13px; min-width: 0; }
.mem-row:last-child { border-bottom: 0; }
.mem-c { min-width: 0; }
.mem-id { font: 12px var(--mono); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-title { color: var(--text); overflow-wrap: anywhere; }
.mem-mod, .mem-date, .mem-st { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mem-row:has(> .mem-st) { grid-template-columns: 96px minmax(0, 1fr) auto; }
.mem-row:not(:has(> .mem-mod)):not(:has(> .mem-st)) { grid-template-columns: 96px minmax(0, 1fr); }
/* 可点的行（点开看全文）：行尾“›”绝对定位，不占网格列（桌面 / 手机的列定义不用改） */
/* 选择器带上 .mem-pane .mem-list：比手机上按列数改 padding 的 :has 规则更具体，“›”的位置一直留着 */
.mem-pane .mem-list > .mem-row.mem-open { position: relative; padding-right: 30px; cursor: pointer; }
.mem-row.mem-open:hover, .mem-row.mem-open.active { background: var(--surface-2); }
.mem-row.mem-open:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.mem-go { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 16px; line-height: 1; }
.drawer .msgs .mem-doc { max-width: none; }
.drawer .msgs > .mem-stamp { margin-bottom: -4px; }
@media (max-width: 760px) {
  .memory { padding: 12px; overflow: visible; }
  .mem { gap: 16px; }
  .mem-proj { padding: 12px; }
  .mem-text { font-size: 14px; max-height: none; }
  .mem-row, .mem-row:has(> .mem-st), .mem-row:not(:has(> .mem-mod)):not(:has(> .mem-st)) {
    grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 9px 12px; }
  .mem-id { grid-row: 1; }
  .mem-title { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow-wrap: anywhere; font-size: 14px; }
  .mem-mod, .mem-st { grid-row: 1; justify-self: end; }
  .mem-date { grid-row: 1; }
  .mem-row:has(> .mem-mod) .mem-mod { grid-column: 2; justify-self: start; }
  .mem-row:has(> .mem-mod) { grid-template-columns: auto auto minmax(0, 1fr); }
  .mem-row:has(> .mem-mod) .mem-date { grid-column: 3; justify-self: end; }
}

/* == 定时任务详情（复用任务抽屉，只读）：整行可点；抽屉里元信息两列、先检查 / 验证命令等宽 == */
.sched-row { cursor: pointer; }
.sched-row:hover { background: var(--surface-2); }
.sched-row.active { background: var(--surface-2); }
.sched-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.sd-info { flex: 1 1 100%; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 10px 0 0; font-size: 12px; }
.sd-info dt { color: var(--text-3); white-space: nowrap; }
.sd-info dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.sd-info .tag { margin-left: 0; }
.sd-sub { font: 11px var(--mono); color: var(--text-3); }
.sd-sec { display: flex; flex-direction: column; gap: 8px; }
.sd-tpl { display: flex; flex-direction: column; gap: 12px; }
.sd-part { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sd-h { font-size: 12px; font-weight: 600; color: var(--text); }
.sd-text { font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.sd-none { font-size: 12px; color: var(--text-3); }
.sd-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.sd-list li { overflow-wrap: anywhere; }
.sd-list.mono { font: 12px var(--mono); }
.sd-codes { display: flex; flex-direction: column; gap: 6px; }
.sd-code { margin: 0; font: 12px var(--mono); color: var(--text); background: var(--inset); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sd-run { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sd-run .sc-run { font-size: 13px; }
@media (max-width: 760px) {
  .sched-row:focus-visible { outline-offset: 2px; }
  .sd-info { font-size: 13px; }
  .sd-run .sc-run { padding: 12px 0; margin: -12px 0; }
}

/* == 规划（只读）：跟随范围；桌面一行一份（标题 / 状态 / 进度 / 更新时间），手机折两行；抽屉复用任务抽屉 == */
:root { --blue-text: #60a5fa; }
@media (prefers-color-scheme: light) { :root { --blue-text: #1d4ed8; } }
.tag.blue { color: var(--blue-text); background: color-mix(in srgb, var(--blue) 15%, transparent); }
.plans { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; }
.pl { display: flex; flex-direction: column; gap: 16px; max-width: 980px; }
.pl-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pl-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--inset); overflow: hidden; }
.pl-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 180px 84px; gap: 14px; align-items: center; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.pl-row:last-child { border-bottom: 0; }
.pl-row:hover, .pl-row.active { background: var(--surface-2); }
.pl-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.pl-row > .tag { margin-left: 0; justify-self: start; }
.pl-main { min-width: 0; }
.pl-main .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-when { font-size: 12px; color: var(--text-3); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.pl-prog { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; color: var(--text-2); }
.pl-bar { position: relative; flex: 1 1 auto; min-width: 60px; max-width: 140px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.pl-fill { position: absolute; inset: 0 auto 0 0; background: var(--green); border-radius: 3px; }
.pl-n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-none { color: var(--text-3); white-space: nowrap; }
.sd-info .pl-prog { width: 100%; max-width: 240px; }
.pl-sec { gap: 6px; }
.pl-line { font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.pl-ul { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.pl-ul li { overflow-wrap: anywhere; }
.pl-ul:has(> .pl-step) { padding-left: 0; list-style: none; gap: 8px; }
.pl-step { display: flex; gap: 8px; align-items: flex-start; }
.pl-mark { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.pl-step.done .pl-mark { background: var(--green); box-shadow: none; }
.pl-step.doing .pl-mark { background: linear-gradient(90deg, var(--blue) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--blue); }
.pl-step.todo .pl-mark { box-shadow: inset 0 0 0 1.5px var(--zinc); }
.pl-step:not(.done):not(.doing):not(.review):not(.todo) .pl-mark { width: 4px; height: 4px; margin: 8px 3px 0; background: var(--text-3); box-shadow: none; }
.pl-step-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pl-step.done .pl-step-text { color: var(--text-3); }
.pl-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pl-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 0;
  background: var(--surface-3); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.pl-chip-id { font-family: var(--mono); color: var(--text); }
.pl-chip.green { color: var(--green-text); background: color-mix(in srgb, var(--green) 15%, transparent); }
.pl-chip.blue { color: var(--blue-text); background: color-mix(in srgb, var(--blue) 15%, transparent); }
.pl-chip.amber { color: var(--amber-text); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.pl-chip.rose { color: var(--rose-text); background: color-mix(in srgb, var(--rose) 15%, transparent); }
.pl-chip.missing { cursor: default; color: var(--text-3); background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); font-family: var(--mono); }
.pl-chip:not(.missing):hover { filter: brightness(1.15); }
@media (max-width: 760px) {
  .plans { padding: 12px; overflow: visible; }
  .pl-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px; }
  .pl-main { grid-column: 1 / -1; }
  .pl-main .title { white-space: normal; overflow-wrap: anywhere; }
  .pl-row .pl-prog { justify-self: start; }
  .pl-bar { min-width: 80px; }
  .pl-chip { padding: 6px 8px; font-size: 12px; }
}
@media (max-width: 760px) {
  /* 五个标签（多了“规划”）：iPhone 13 宽度下“更新于 时间”折成两行小字，菜单、标签、更新于、刷新仍在一行 */
  .stamp { white-space: normal; width: min-content; line-height: 1.25; text-align: right; }
}

/* == 规划页顶部切换（规划 | 代码结构）、可能过时提示、进度流程线、架构图、代码结构目录树 == */
.pl-tabs { align-self: flex-start; margin-bottom: 14px; }
.plans-body { display: flex; flex-direction: column; min-width: 0; }
.pl-stale { font-size: 12px; color: var(--amber-text); overflow-wrap: anywhere; }
.pl-main .pl-stale { margin-top: 2px; }
/* 流程线：横排，节点之间一条细线；颜色 灰 未开始 / 蓝 进行中 / 橙 待确认 / 绿 完成 */
.pl-flow { list-style: none; margin: 0; padding: 4px 0 2px; display: flex; gap: 0; overflow-x: auto; flex-shrink: 0; }  /* 抽屉里是纵向 flex：别被压扁 */
.pl-node { --c: var(--zinc); position: relative; flex: 1 0 92px; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0 4px; text-align: center; min-width: 0; }
.pl-node + .pl-node::before { content: ""; position: absolute; top: 11px; right: calc(50% + 14px); width: calc(100% - 28px); height: 2px; background: var(--line-strong); }
.pl-node.done + .pl-node::before { background: var(--green); }
.pl-node.doing { --c: var(--blue); } .pl-node.review { --c: var(--amber); } .pl-node.done { --c: var(--green); }
.pl-dot { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  font: 600 11px var(--sans); color: var(--c); box-shadow: inset 0 0 0 2px var(--c); background: var(--surface); }
.pl-node.done .pl-dot, .pl-node.doing .pl-dot, .pl-node.review .pl-dot { background: var(--c); color: #fff; box-shadow: none; }
.pl-node.none .pl-dot { box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--text-3); }
.pl-node-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; width: 100%; }
.pl-node-text { font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pl-node-state { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.pl-node.doing .pl-node-state { color: var(--blue-text); } .pl-node.review .pl-node-state { color: var(--amber-text); } .pl-node.done .pl-node-state { color: var(--green-text); }
.pl-step.review .pl-mark { background: var(--amber); box-shadow: none; }
.pl-diagram { flex-shrink: 0; display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
/* 代码结构：每行 折叠钮 / 目录名 / 文件数 / 行数 / 占比细条；子目录按层缩进 */
.st-head { overflow-wrap: anywhere; }
.st-tree { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.st-kids { display: flex; flex-direction: column; }
.st-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 72px 88px minmax(60px, 160px); gap: 10px; align-items: center;
  padding: 6px 14px 6px calc(14px + var(--depth, 0) * 18px); border-bottom: 1px solid var(--line); font-size: 13px; }
.st-tree > .st-row:last-child, .st-tree > .st-kids:last-child > .st-row:last-child { border-bottom: 0; }
.st-tog { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; }
.st-tog:hover { background: var(--hover); }
.st-tog .chev { width: 12px; height: 12px; }
.st-leaf { cursor: default; }
.st-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.st-files, .st-lines { font-size: 12px; color: var(--text-3); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.st-fill { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
@media (max-width: 760px) {
  .pl-tabs { align-self: stretch; }
  .pl-tabs [role=tab] { flex: 1 1 0; }
  /* 流程线手机上竖排：圆点在左，文字在右，节点之间竖线 */
  .pl-flow { flex-direction: column; gap: 10px; overflow: visible; }
  .pl-node { flex: none; max-width: none; flex-direction: row; align-items: flex-start; gap: 10px; text-align: left; padding: 0; }
  .pl-node + .pl-node::before { top: -10px; right: auto; left: 11px; width: 2px; height: 10px; }
  .pl-node-info { padding-top: 2px; }
  .st-row { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 2px 8px; padding: 8px 12px 8px calc(8px + var(--depth, 0) * 14px); }
  .st-tog { width: 32px; height: 32px; margin: -6px 0; }
  .st-files { display: none; }
  .st-bar { grid-column: 2 / -1; }
  .st-name { font-size: 13px; }
}

/* == 记忆：和话题页一样两栏（左边分类卡片，右边内容）；手机先看左栏，点分类进右栏 == */
.memory:has(> .mem-split) { padding: 0; overflow: hidden; }
.mem-split { flex: 1; min-height: 0; }
.mem-group { display: flex; align-items: center; min-width: 0; margin: 8px 2px 0; }
.mem-group:first-child { margin-top: 0; }
.mem-group .card-proj { font-size: 12px; }
.mem-card .card-top { min-height: 18px; }
.mem-card-name { font-size: 13px; font-weight: 500; color: var(--text); }
.mem-card .note { margin-top: 4px; -webkit-line-clamp: 1; color: var(--text-3); }
.mem-pane .convo-head .card-proj { font-size: 12px; }
.mem-pane .convo-head .title { font-size: 15px; font-weight: 600; }
.mem-doc { display: flex; flex-direction: column; gap: 6px; max-width: 860px; }
.mem-doc .sd-h { margin-top: 6px; }
.mem-doc .sd-h:first-child { margin-top: 0; }
.mem-search { max-width: 360px; }
.mem-pane .mem-list { max-width: 980px; }
@media (max-width: 760px) {
  .memory:has(> .mem-split) { overflow: visible; }
  .mem-search { max-width: none; }
  .mem-search input { height: 44px; font-size: 16px; }  /* 16px：iOS 聚焦不放大页面 */
  .mem-doc .pl-line, .mem-doc .pl-ul { font-size: 14px; }
}

/* == 动态架构图：内联 SVG（白底，作者的配色照旧）；带 data-step 的元素按步骤状态上色 ==
   灰 未开始 / 蓝 进行中 / 橙 待确认 / 绿 完成；底色固定白，深浅色主题下都用同一套深一点的色值。
   节点 = rect circle ellipse polygon（描边 + 淡填充），连线 = line polyline path（只改描边），文字 = text / tspan（改字色） */
.pl-figure { flex-shrink: 0; min-width: 0; }
svg.pl-diagram { width: 100%; height: auto; --st: #71717a; --st-fill: #f4f4f5; --st-text: #52525b; }
.pl-diagram .st-doing { --st: #2563eb; --st-fill: #dbeafe; --st-text: #1d4ed8; }
.pl-diagram .st-review { --st: #d97706; --st-fill: #fef3c7; --st-text: #b45309; }
.pl-diagram .st-done { --st: #16a34a; --st-fill: #dcfce7; --st-text: #15803d; }
.pl-diagram :is(rect, circle, ellipse, polygon):is(.st-todo, .st-doing, .st-review, .st-done) { stroke: var(--st); fill: var(--st-fill); stroke-width: 2.5px; }
.pl-diagram :is(line, polyline, path):is(.st-todo, .st-doing, .st-review, .st-done) { stroke: var(--st); }
.pl-diagram :is(text, tspan):is(.st-todo, .st-doing, .st-review, .st-done) { fill: var(--st-text); stroke: none; }
.pl-diagram :is(rect, circle, ellipse, polygon).st-todo { stroke-dasharray: 5 4; }  /* 未开始：虚线框 */
/* 进行中：连线上的虚线往前流动；节点描边柔和地呼吸 */
.pl-diagram :is(line, polyline, path).st-doing { stroke-dasharray: 7 5; animation: pl-flow .9s linear infinite; }
.pl-diagram :is(rect, circle, ellipse, polygon).st-doing { animation: pl-breathe 1.8s ease-in-out infinite; }
@keyframes pl-flow { to { stroke-dashoffset: -24; } }  /* 一周期 12 的整数倍：无缝循环 */
@keyframes pl-breathe { 0%, 100% { stroke-width: 2.5px; stroke-opacity: 1; } 50% { stroke-width: 4.5px; stroke-opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .pl-diagram .st-doing { animation: none !important; } }
.pl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-3); }
.pl-lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pl-lg-sw { width: 14px; height: 10px; border-radius: 3px; background: #f4f4f5; box-shadow: inset 0 0 0 2px #71717a; }
.pl-lg.doing .pl-lg-sw { background: #dbeafe; box-shadow: inset 0 0 0 2px #2563eb; }
.pl-lg.review .pl-lg-sw { background: #fef3c7; box-shadow: inset 0 0 0 2px #d97706; }
.pl-lg.done .pl-lg-sw { background: #dcfce7; box-shadow: inset 0 0 0 2px #16a34a; }
/* 免审标签：外形同“定时 · #n”，绿色字区分 */
.sched-tag.auto-tag { color: var(--green); }

/* 记忆/规划原文：行内代码与表格 */
.md-code { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .92em; padding: 1px 5px; border-radius: 4px; background: var(--inset); overflow-wrap: anywhere; }
.md-tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0; }
.md-tbl { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.5; }
.md-tbl th, .md-tbl td { padding: 7px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.md-tbl th { font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.md-tbl tr:last-child td { border-bottom: 0; }
.md-tbl td:first-child { white-space: nowrap; }
@media (max-width: 720px) { .md-tbl { font-size: 12px; min-width: 560px; } .md-tbl td:first-child { white-space: normal; } }
.md-tbl .md-code { white-space: nowrap; overflow-wrap: normal; }
.md-quote { padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
/* 派发方自记任务标签：外形同上，紫色字区分 */
.sched-tag.self-tag { color: var(--violet); }

/* 设置 · Lark 通知 */
.lark-status { margin: 0; font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.lark-status.on { color: var(--green-text); }
.lark-status.bad { color: var(--amber-text); }
.lark-msg { margin: 0; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.lark-msg.bad { color: var(--rose-text); }
.setup .btn:disabled { opacity: .6; cursor: default; }
/* 自记任务的步骤进度 */
.card-step { margin-top: 6px; }
.card-step .pl-prog { width: 100%; }
.card-step .pl-bar { max-width: none; }
.sd-list li.step-done { color: var(--text-3); }
.step-mark { color: var(--green); }
/* 抽屉里的任务内容折叠块 */
.task-info { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.task-info > .task-info-head { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-2); list-style: none; }
.task-info > .task-info-head::-webkit-details-marker { display: none; }
.task-info > .task-info-head::before { content: "▸ "; color: var(--text-3); }
.task-info[open] > .task-info-head::before { content: "▾ "; }
.task-info[open] > .task-info-head { margin-bottom: 8px; }
.task-info .sd-sec + .sd-sec { margin-top: 10px; }
#d-msgs > .sd-sec + .task-info { margin-top: 2px; }
/* 已完成列底部：加载更多 / 没有更早的了 */
.done-more { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0 2px; }
.done-more-note { font-size: 12px; color: var(--text-3); text-align: center; outline: none; }
.done-more-note.bad { color: var(--rose-text); }
/* 竖向滚动容器（flex 列）里的子块不许被压扁：圆角列表带 overflow:hidden 时会被压到容器高度、多出的内容被裁掉、外层也滚不动 */
.convo > *, .schedules > *, .plans > *, .plans-body > *, .memory > *:not(.mem-split), .drawer .msgs > *, .topic-list > * { flex-shrink: 0; }

/* == 网页聊天（第十八轮）：话题列表上的“+ 新建话题”、对话输入框、设置页“本设备”、话题页三栏（看板侧栏） == */
.topic-col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.topic-col .topic-list { flex: 1; min-height: 0; border-right: 0; }
.topic-tools { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0; }
.topic-form { display: grid; gap: 6px; margin: 10px 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.topic-pick { max-width: none; width: 100%; }
.topic-form-hint { margin: 0; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.topic-form-hint:empty { display: none; }
.topic-form .row { margin-top: 4px; }
.topic-form .btn:disabled, .composer .btn:disabled { opacity: .55; cursor: default; }
.convo-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.convo-pane .convo { flex: 1; min-height: 0; }
.composer { position: sticky; bottom: 0; z-index: 5; display: grid; gap: 6px; padding: 10px 24px 14px; border-top: 1px solid var(--line); background: var(--surface);
  padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; min-width: 0; resize: none; min-height: 38px; max-height: 160px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 14px/1.5 var(--sans); }
.composer textarea:focus { border-color: var(--line-strong); }
.composer textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.composer .btn.primary { height: 38px; }
.composer-status, .composer-hint { margin: 0; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.composer-status.busy { color: var(--text-2); }
.composer-status.busy::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 999px; background: var(--blue);
  vertical-align: 1px; animation: chat-pulse 1.2s ease-in-out infinite; }
.composer-status.warn { color: var(--amber-text); }
.composer-status.bad { color: var(--rose-text); }
.composer-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--amber-text); }
@keyframes chat-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .composer-status.busy::before { animation: none; } }
.msg.mine .msg-body { background: var(--surface-3); }
.msg-body.md { white-space: normal; display: grid; gap: 4px; }
.device input:disabled { color: var(--text-3); background: var(--surface-2); }

/* 桌面三栏：.main 变成两列网格，左边话题（列表 + 对话），右边看板侧栏；收起时右边一条窄栏 */
.main.chat-side, .main.chat-rail { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); }
.main.chat-side { grid-template-columns: minmax(0, 1fr) 340px; }
.main.chat-rail { grid-template-columns: minmax(0, 1fr) 44px; }
.main.chat-side > .main-head, .main.chat-rail > .main-head, .main.chat-side > #error, .main.chat-rail > #error { grid-column: 1 / -1; }
.main.chat-side > .main-head, .main.chat-rail > .main-head { grid-row: 1; }
.main.chat-side > #error, .main.chat-rail > #error { grid-row: 2; }
.main.chat-side > #topics, .main.chat-rail > #topics { grid-column: 1; grid-row: 3 / 5; min-height: 0; }
.main.chat-side > .side-board-head { grid-column: 2; grid-row: 3; }
.main.chat-side > #board { grid-column: 2; grid-row: 4; }
.main.chat-rail > .side-board-rail { grid-column: 2; grid-row: 3 / 5; }
.side-board-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; border-left: 1px solid var(--line); min-width: 0; }
.side-board-title { font-size: 13px; font-weight: 600; margin-right: auto; }
.side-board-rail { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0; border: 0; border-left: 1px solid var(--line);
  background: transparent; color: var(--text-3); cursor: pointer; font: 500 12px var(--sans); }
.side-board-rail:hover { background: var(--hover); color: var(--text); }
.side-board-rail > span:last-child { writing-mode: vertical-rl; letter-spacing: .1em; }
.board.side { flex-direction: column; gap: 8px; padding: 4px 12px 16px; overflow-x: hidden; overflow-y: auto; border-left: 1px solid var(--line); }
.board.side .col, .board.side .col.collapsed { flex: none; min-width: 0; width: 100%; align-items: stretch; }
.board.side .cards { flex: none; overflow: visible; }
.board.side .col-head { padding: 10px 12px 8px; }
.board.side .col.collapsed .col-head { flex-direction: row; padding: 10px 12px; gap: 8px; }
.board.side .col.collapsed .col-name { writing-mode: horizontal-tb; letter-spacing: 0; }
.board.side .col.collapsed .col-head > .dot { order: 0; }
.board.side .col.collapsed .col-head > .col-name { order: 1; }
.board.side .col.collapsed .col-head > .col-count { order: 2; }
.board.side .col.collapsed .col-head > .col-btn { order: 3; margin-left: auto; }
.board.side .empty { flex-direction: row; justify-content: flex-start; padding: 0 12px 12px; }
.board.side .empty-icon { display: none; }
.main.chat-side .topics { grid-template-columns: 260px minmax(0, 1fr); }
@media (max-width: 1099px) { .main.chat-rail .topics { grid-template-columns: 260px minmax(0, 1fr); } }
@media (min-width: 1400px) { .main.chat-side .topics { grid-template-columns: 300px minmax(0, 1fr); } .main.chat-side { grid-template-columns: minmax(0, 1fr) 380px; } }
@media (max-width: 760px) {
  .topic-col { border-right: 0; }
  .topic-tools { padding: 12px 12px 0; }
  .topic-form .row { margin: 1px -7px 0; }
  .composer { padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; }  /* 16px 以上 iOS 聚焦时不自动放大 */
  .composer .btn.primary { height: 44px; }
  .composer-hint .btn.small { margin: -9px 0; }
  .topic-pick { height: 44px; }
}

/* == 我的对话（第二十一轮）：侧栏「+ 新建」菜单、“对话 N”列表；对话页（话题视图 + .convo：不显示话题列表，全宽，大圆角输入框） == */
.new-wrap { position: relative; margin-bottom: 4px; }
.new-btn .ico { color: var(--text); }
.new-btn[aria-expanded="true"] { background: var(--hover); }
.new-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 180px; padding: 6px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); box-shadow: 0 10px 28px color-mix(in srgb, #000 18%, transparent); }
.new-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); font-size: 13px; cursor: pointer; text-align: left; }
.new-item:hover, .new-item:focus-visible { background: var(--hover); }
.new-item .ico { color: var(--text-2); }
.convos-toggle { margin-top: 6px; }
.convo-tree { margin-bottom: 10px; }
.convo-row { flex-direction: column; align-items: stretch; gap: 2px; padding: 7px 8px; }
.convo-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.convo-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-when { flex-shrink: 0; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.convo-row.active .convo-when { color: var(--text-3); }
.convo-row .card-proj { font-weight: 400; }
.convo-none { padding: 6px 8px; font-size: 12px; color: var(--text-3); }

.topics.convo-mode { grid-template-columns: minmax(0, 1fr) !important; }
.topics.convo-mode .topic-col { display: none !important; }
.topics.convo-mode .convo-pane { display: flex !important; }
.topics.convo-mode .convo { padding: 16px max(24px, calc((100% - 860px) / 2)); }
.topics.convo-mode .convo-head .title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.convo-meta { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.topic-form-title { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.topics.convo-mode .topic-form { margin: 12px max(24px, calc((100% - 860px) / 2)) 0; }
.composer-foot { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.composer-meta { display: none; }
.send-ico { display: none; }
.topics.convo-mode .composer { border-top: 0; padding: 8px max(24px, calc((100% - 860px) / 2)) 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.topics.convo-mode .composer-row { flex-direction: column; align-items: stretch; gap: 6px; padding: 12px 12px 10px 16px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface-2); box-shadow: 0 2px 10px color-mix(in srgb, #000 6%, transparent); }
.topics.convo-mode .composer-row:focus-within { border-color: var(--line-strong); }
.topics.convo-mode .composer textarea { min-height: 48px; padding: 2px 0; border: 0; border-radius: 0; background: transparent; outline: none; }
.topics.convo-mode .composer textarea:disabled { background: transparent; }
.topics.convo-mode .composer-foot { align-items: center; justify-content: space-between; }
.topics.convo-mode .composer-meta { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-3); }
.topics.convo-mode #composer-send { flex-shrink: 0; width: 34px; height: 34px; padding: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.topics.convo-mode .send-text { display: none; }
.topics.convo-mode .send-ico { display: inline-flex; width: 16px; height: 16px; }
.topics.convo-mode .send-ico svg { width: 100%; height: 100%; }
@media (max-width: 760px) {
  .new-menu { min-width: 200px; }
  .new-item { min-height: 44px; font-size: 14px; }
  .convo-row { min-height: 44px; justify-content: center; font-size: 14px; }
  .topics.convo-mode .convo { padding: 12px; }
  .topics.convo-mode .topic-form { margin: 12px 12px 0; }
  .topics.convo-mode .composer { padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .topics.convo-mode .composer-row { padding: 10px 8px 8px 14px; border-radius: 16px; }
  .topics.convo-mode .composer textarea { min-height: 44px; }
  /* 发送按钮：看上去 34px 的圆，透明边框把点击区扩到 44px */
  .topics.convo-mode #composer-send { width: 44px; height: 44px; border: 5px solid transparent; background-clip: padding-box; margin: -5px; }
}
@media (max-width: 760px) {
  /* 对话页没有高亮的标签：“对话”标题放到第二行两个下拉前面 */
  .main-head.convo-on h1 { display: block !important; order: 10; font-size: 16px; margin-right: 4px; }
}

/* == 我的对话（第二十三轮）：新建前选对象（浮层 / 手机底部弹出）、本机 / 云端标签、对话操作菜单、复制提示 == */
.peer-tag { flex-shrink: 0; display: inline-block; font-size: 10.5px; font-weight: 500; line-height: 16px; padding: 0 5px; border-radius: 4px; white-space: nowrap; vertical-align: 1px; }
.peer-tag.local { color: var(--green-text); background: color-mix(in srgb, var(--green) 15%, transparent); }
.peer-tag.cloud { color: var(--blue-text); background: color-mix(in srgb, var(--blue) 15%, transparent); }
.convo-meta .peer-tag { margin: 0 1px; }

.convo-picker { position: fixed; z-index: 45; width: min(340px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto; margin: 0;
  border-radius: 12px; background: var(--surface); box-shadow: 0 10px 28px color-mix(in srgb, #000 22%, transparent); }
.topics.convo-mode .topic-form.convo-picker, .convo-picker { margin: 0; }
.convo-picker label, .topic-peer-label { margin: 4px 0 0; font-size: 12px; font-weight: 500; color: var(--text-2); }
.topic-peer { display: grid; gap: 2px; outline: none; }
.peer-group { margin: 6px 0 0; font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--text-3); }
.peer-empty { margin: 4px 0; font-size: 12px; color: var(--text-3); }
.peer-opt { display: flex; align-items: flex-start; gap: 8px; margin: 0 !important; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text) !important; font-weight: 400 !important; }
.peer-opt:hover { background: var(--hover); }
.peer-opt:has(input:checked) { background: var(--surface-3); }
.peer-opt input { margin: 2px 0 0; accent-color: var(--text); flex-shrink: 0; }
.peer-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.peer-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.peer-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.peer-state { margin-left: auto; flex-shrink: 0; font-size: 11px; color: var(--dim); }
.peer-state.on { color: var(--green-text); }
.peer-note { font-size: 11px; color: var(--text-3); }
.picker-scrim { position: fixed; inset: 0; z-index: 44; background: color-mix(in srgb, #000 40%, transparent); }

.convo-item { position: relative; display: flex; align-items: stretch; min-width: 0; }
.convo-item > .convo-row { flex: 1; min-width: 0; padding-right: 30px; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.convo-item.pinned .convo-title { font-weight: 500; }
.convo-pin { flex-shrink: 0; display: inline-flex; width: 12px; height: 12px; color: var(--text-3); align-self: center; }
.convo-pin svg { width: 100%; height: 100%; }
.convo-line .peer-tag { align-self: center; }
.convo-more { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; opacity: 0; }
.convo-more svg { width: 16px; height: 16px; }
.convo-item:hover .convo-more, .convo-item.menu-on .convo-more, .convo-more:focus-visible, .convo-more[aria-expanded="true"] { opacity: 1; }
.convo-item:hover .convo-when, .convo-item.menu-on .convo-when, .convo-item:focus-within .convo-when { visibility: hidden; }
.convo-more:hover, .convo-more[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.convo-rename { width: 100%; min-width: 0; height: 32px; margin: 2px 0; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: 13px var(--sans); }
.arch-toggle { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.arch-list .convo-row { opacity: .8; }

.convo-menu { position: fixed; z-index: 50; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: 0 12px 32px color-mix(in srgb, #000 22%, transparent); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); font: 13px var(--sans); cursor: pointer; text-align: left; }
.menu-item .ico { display: inline-flex; width: 17px; height: 17px; color: var(--text-2); }
.menu-item .ico svg { width: 100%; height: 100%; }
.menu-item:hover, .menu-item:focus-visible, .menu-item:focus { background: var(--hover); outline: none; }
.menu-item.danger, .menu-item.danger .ico { color: var(--rose-text); }
.menu-sep { height: 1px; margin: 3px 10px; background: var(--line); }

.convo-toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: min(520px, calc(100vw - 32px));
  padding: 8px 14px; border-radius: 10px; background: var(--primary-bg); color: var(--primary-fg); font-size: 13px; box-shadow: 0 8px 24px color-mix(in srgb, #000 25%, transparent); }
.convo-toast.bad { background: var(--rose); color: #fff; }
.convo-toast.manual { display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.toast-head { display: flex; align-items: center; gap: 8px; }
.toast-head .toast-text { flex: 1; font-size: 12px; color: var(--text-2); }
.toast-box { width: 100%; height: auto; min-height: 30px; font: 12px/1.5 var(--mono); resize: vertical; }
textarea.toast-box { padding: 6px 8px; }

.btn.danger { background: var(--rose); border-color: var(--rose); color: #fff; }
.convo-confirm { max-width: min(380px, calc(100vw - 32px)); padding: 18px 18px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: 0 16px 40px color-mix(in srgb, #000 30%, transparent); }
.convo-confirm::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.convo-confirm-title { margin: 0 0 6px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.convo-confirm-text { margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.convo-confirm .row { justify-content: flex-end; }

.msg-head { position: relative; }
.msg-copy { margin-left: auto; width: 24px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-3); cursor: pointer; opacity: 0; align-self: center; }
.msg-copy svg { width: 14px; height: 14px; }
.msg:hover .msg-copy, .msg-copy:focus-visible, .msg:focus-within .msg-copy { opacity: 1; }
.msg-copy:hover { background: var(--hover); color: var(--text); }
@media (hover: none) { .msg-copy, .convo-more { opacity: 1; } .convo-item .convo-when { visibility: hidden; } }
@media (max-width: 760px) {
  .convo-picker.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-height: 85vh; border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
  .peer-opt { min-height: 44px; align-items: center; }
  .peer-name { font-size: 14px; }
  .convo-more { opacity: 1; width: 40px; height: 40px; right: 0; }
  .convo-item > .convo-row { padding-right: 44px; }
  .convo-item .convo-when { visibility: hidden; }
  .menu-item { min-height: 44px; font-size: 14px; }
  .msg-copy { opacity: 1; width: 36px; height: 30px; margin: -6px -6px -6px auto; }
  .convo-rename { height: 44px; font-size: 16px; }
}
.msg.interject .msg-body { border-style: dashed; border-color: var(--amber); }
.convo-picker .peer-opt input[type=radio] { appearance: auto; width: 16px; height: 16px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; flex: none; }

/* == 设置（和定时页一样是主区里的一个视图：自己滚动，内容居中最宽 680px；三组圆角列表，一行一项） == */
.setup { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.set-page { max-width: 680px; margin: 0 auto; padding: 24px 20px calc(48px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 28px; }
.set-sec h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text); }
.set-cap { margin: 0 0 10px; font-size: 12px; color: var(--text-3); }
.set-group { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; min-height: 52px; }
.set-group > * + * { border-top: 1px solid var(--line); }
.set-lbl { width: 96px; flex-shrink: 0; font-size: 13px; font-weight: 400; color: var(--text-2); }
.set-val { flex: 1; min-width: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.set-val > input { flex: 1; }
.set-mono { font: 12.5px var(--mono); color: var(--text); letter-spacing: .02em; }
.set-sub { font-size: 12px; color: var(--text-3); }
.set-sub.bad { color: var(--amber-text); }
.set-edit { display: grid; gap: 6px; flex: 1; min-width: 0; }
.set-edit input, .set-val > input { border-color: var(--line-strong); }
.set-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.set-acts:empty { display: none; }
.set-tag { margin-left: 6px; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-3); white-space: nowrap; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-3); box-shadow: none; }
@media (hover: hover) { .btn.ghost:hover { background-color: var(--hover); color: var(--text); } }
.btn.ghost, .btn.ghost:hover { background-clip: padding-box; }
.btn.ghost.warn { color: var(--rose-text); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; color: var(--text-2); background: var(--surface-3); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.pill.ok { color: var(--green-text); background: color-mix(in srgb, var(--green) 14%, var(--surface)); }
.pill.wait { color: var(--amber-text); background: color-mix(in srgb, var(--amber) 16%, var(--surface)); }
.pill.bad { color: var(--rose-text); background: color-mix(in srgb, var(--rose) 14%, var(--surface)); }
.set-msg { padding: 10px 16px; font-size: 12px; }
.set-step { padding: 12px 16px; background: var(--inset); display: grid; gap: 8px; }
.set-step p { margin: 0; font-size: 12px; color: var(--text-2); }
.device-cmd { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.device-cmd-text { font: 12px var(--mono); color: var(--text); overflow-wrap: anywhere; flex: 1; min-width: 0; }
.set-acts .sess-fallback, .device-cmd .sess-fallback { flex-basis: 160px; }
/* 设置期间：头部只留标题（+ 齿轮），不要视图切换和目录 / 项目下拉 */
.main.setup-on > .main-head > .view-tabs, .main.setup-on > .main-head > .ws-pick { display: none !important; }
@media (min-width: 761px) {
  .set-acts .btn { height: 28px; padding: 0 10px; font-size: 12px; }
}
@media (max-width: 760px) {
  /* 手机：body 滚动，设置区跟着内容长；名称在值上方，操作靠右；按钮点击区 44px（看上去仍是小按钮） */
  .setup { flex: none; overflow: visible; }
  .set-page { padding: 16px 12px calc(40px + env(safe-area-inset-bottom)); gap: 24px; }
  .set-row { flex-wrap: wrap; gap: 4px 12px; padding: 12px 14px; }
  .set-lbl { width: 100%; font-size: 12px; color: var(--text-3); }
  .set-val { flex: 1 1 0; }
  .set-acts { gap: 0; margin: -6px -7px -6px auto; }
  .set-acts .btn.small { margin: 0; height: 44px; border-width: 7px; border-radius: 13px; padding: 0 12px; font-size: 13px; }
  .device-cmd .btn.small { margin: -6px -6px -6px 0; }
  .set-msg { padding: 10px 14px; }
  .set-step { padding: 12px 14px; }
  .main.setup-on .main-head h1 { display: block !important; }
  /* 下拉藏起来了（CSS 藏，不是 hidden 属性）：头部不按“有下拉”分两行，报错条也不按两行头部的高度往下挪 */
  .main.setup-on > .main-head { flex-wrap: nowrap; padding-top: env(safe-area-inset-top); padding-bottom: 0; }
  .main.setup-on > .main-head::after { content: none; }
  .main.setup-on .stamp { white-space: nowrap; width: auto; }  /* 设置头部没有标签，“更新于”放得下一行 */
  .main.setup-on > .main-head ~ #error { top: calc(56px + env(safe-area-inset-top) + 8px); }
  .main.setup-on .view-ico { display: inline-flex; }
}

/* == 规划 → 架构（75-arch.js）：左边按层分列的模块图（SVG 由脚本生成，样式全在这里），右边面板；手机上图在上、面板在下 == */
.ar { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr); flex: 1 0 auto; min-height: 560px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.ar-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-3); }
.ar-hint-top { min-width: 0; }
.ar-when { margin-left: auto; white-space: nowrap; }
.ar-proj { max-width: 280px; height: 28px; }
.ar-canvas { min-width: 0; padding: 16px 12px; display: flex; align-items: flex-start; justify-content: center; border-right: 1px solid var(--line); overflow: auto; }
.ar-svg { width: 100%; height: auto; max-height: 78vh; display: block; font-family: var(--sans); --node: var(--surface); --node-line: var(--line-strong);
  --edge: color-mix(in srgb, var(--text-3) 55%, transparent); --on: var(--blue); --on-fill: color-mix(in srgb, var(--blue) 14%, var(--surface)); }
.ar-lane { font-size: 11px; font-weight: 600; letter-spacing: .05em; fill: var(--text-3); }
.ar-sep { stroke: var(--line); stroke-width: 1; }
.ar-edge { fill: none; stroke: var(--edge); stroke-width: 1.5; transition: opacity .2s; }
.ar-edge.rel { stroke: var(--text-2); stroke-width: 2; }
.ar-edge.dim { opacity: .45; }
.ar-edge.on { stroke: var(--on); stroke-width: 3; }
marker .ar-tip { fill: var(--edge); }
marker .ar-tip.on { fill: var(--on); }
.ar-node { cursor: pointer; outline: none; transition: opacity .2s; }
.ar-box { fill: var(--node); stroke: var(--node-line); stroke-width: 1.2; }
.ar-name { font-size: 13px; font-weight: 600; fill: var(--text); }
.ar-sub { font-size: 10.5px; fill: var(--text-3); }
.ar-node:hover .ar-box { stroke: var(--text-3); }
.ar-node:focus-visible .ar-box { stroke: var(--blue); stroke-width: 2; stroke-dasharray: 4 3; }
.ar-node.sel .ar-box { stroke: var(--text); stroke-width: 2.4; }
.ar-node.on .ar-box { fill: var(--on-fill); stroke: var(--on); stroke-width: 2; }
.ar-node.dim { opacity: .55; }
.ar-pill { fill: var(--on); }
.ar-pill-text { font-size: 11px; fill: #fff; text-anchor: middle; }
.ar-panel { min-width: 0; overflow-y: auto; padding: 16px; }
.ar-panel-in { display: flex; flex-direction: column; gap: 12px; }
.ar-sec { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); margin-top: 4px; }
.ar-hint { margin: 0; font-size: 13px; color: var(--text-2); }
.ar-mhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ar-mhead .tag { margin-left: 0; }
.ar-mname { margin: 0; font-size: 18px; font-weight: 600; }
.ar-summary { margin: 0; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.ar-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface); }
.ar-kv { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px 10px; margin: 0; font-size: 12.5px; }
.ar-kv dt { color: var(--text-3); }
.ar-kv dd { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.ar-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ar-code { font: 11.5px var(--mono); background: var(--inset); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.ar-stat, .ar-more, .ar-none { font-size: 12px; color: var(--text-3); }
.ar-refs { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ar-ref { max-width: 100%; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); border: 0; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-ref.link { cursor: pointer; }
.ar-ref.link:hover { color: var(--text); background: var(--hover); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ar-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ar-acts .btn.small, .ar-ctl .btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.ar-acts .btn:disabled, .ar-ctl .btn:disabled { opacity: .45; cursor: default; }
.ar-flows { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.btn.ar-flow-link { height: auto; min-height: 26px; padding: 3px 8px; text-align: left; white-space: normal; }
.ar-select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: 13px var(--sans); min-width: 0; }
.ar-ctl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ar-count { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ar-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ar-step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 7px 8px; border-radius: 8px; font-size: 12.5px; color: var(--text-3); cursor: pointer; }
.ar-step:hover { background: var(--hover); }
.ar-step b { font-weight: 500; color: var(--text-2); }
.ar-step-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.ar-n { width: 20px; height: 20px; border-radius: 99px; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 11px; }
.ar-step.done .ar-n { background: var(--surface-3); border-color: var(--surface-3); }
.ar-step.cur { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); color: var(--text); }
.ar-step.cur .ar-n { background: var(--blue); border-color: var(--blue); color: #fff; }
.ar-step.cur b { color: var(--text); }
.btn.ar-back { align-self: flex-start; }
@media (max-width: 760px) {
  .ar { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; min-height: 0; }
  .ar-canvas { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 4px; }
  .ar-svg { max-height: none; }
  .ar-panel { overflow: visible; padding: 14px 12px 18px; }
  .ar-select { height: 44px; font-size: 16px; }
  .ar-step { padding: 10px 8px; font-size: 14px; }
  .ar-kv { font-size: 13.5px; grid-template-columns: 64px minmax(0, 1fr); }
  .ar-acts .btn.small, .ar-ctl .btn.small { height: 44px; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .ar-edge, .ar-node { transition: none; } }
