:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e3de;
  --accent: #2b6cb0; --accent-bg: #e8f0fa; --warn: #c05621; --warn-bg: #fdf0e6; --ok: #2f855a; --ok-bg: #e6f4ec;
  --danger: #c53030; --badge: #d9534f; --code-bg: #f1f1ee; --font: -apple-system, "PingFang SC", "Helvetica Neue", "Noto Sans SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16171a; --panel: #1f2024; --text: #e8e8e4; --muted: #9a9a94; --line: #32333a;
    --accent: #7fb0e8; --accent-bg: #223247; --warn: #f0a070; --warn-bg: #3a2a20; --ok: #7fcf9a; --ok-bg: #203a2a;
    --danger: #f08080; --code-bg: #26272c; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { display: flex; align-items: center; gap: 18px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
nav { display: flex; gap: 4px; flex: 1; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--text); position: relative; }
nav a.active { background: var(--accent-bg); color: var(--accent); }
.badge { display: none; position: absolute; top: 1px; right: 2px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--badge); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 600; }
.badge.on { display: inline-block; }
main { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 24px; margin: 0 0 14px; }
h2 { font-size: 18px; margin: 26px 0 10px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 300px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.panel.attn { border-color: var(--warn); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .t { flex: 1; min-width: 200px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--code-bg); color: var(--muted); white-space: nowrap; }
.chip.open, .chip.pending, .chip.awaiting_review, .chip.waiting_answer, .chip.inbox { background: var(--warn-bg); color: var(--warn); }
.chip.done, .chip.resolved, .chip.ingested, .chip.approved, .chip.digested { background: var(--ok-bg); color: var(--ok); }
.chip.running, .chip.exploring, .chip.lab, .chip.answered { background: var(--accent-bg); color: var(--accent); }
.chip.failed, .chip.blocked, .chip.dropped, .chip.rejected { background: var(--warn-bg); color: var(--danger); }
.chip.unread { background: var(--badge); color: #fff; }
button, .btn { font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
textarea, input, select { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
textarea { min-height: 110px; resize: vertical; }
.form-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.form-row > * { width: auto; }
.form-row input, .form-row select { flex: 1; min-width: 120px; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.md { line-height: 1.7; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; margin-top: 22px; } .md h3 { font-size: 16px; }
.md pre { background: var(--code-bg); padding: 10px 12px; border-radius: 8px; overflow: auto; font-size: 13px; }
.md code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md pre code { background: none; padding: 0; }
.md img { max-width: 100%; border-radius: 6px; }
.md blockquote { border-left: 3px solid var(--line); margin: 0; padding: 2px 14px; color: var(--muted); }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 4px 10px; }
.md a.wikilink { border-bottom: 1px dashed var(--accent); }
.md a.wikilink.missing { color: var(--warn); border-bottom-color: var(--warn); }
.katex-display { overflow-x: auto; overflow-y: hidden; }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; background: var(--code-bg); padding: 12px; border-radius: 8px; max-height: 70vh; overflow: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 500; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 90px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.on { opacity: 1; }
.two { display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } header { flex-wrap: wrap; } }
.side a { display: block; padding: 4px 0; border-bottom: 1px solid var(--line); }
.side a.cur { color: var(--text); font-weight: 600; }
/* 图：alt 当图注；lab 页画廊 */
.fig { margin: 14px 0; text-align: center; }
.fig img { max-width: 100%; max-height: 520px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.fig figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.gallery .fig { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.gallery .fig img { max-height: 260px; object-fit: contain; }
/* 2026-10-04：可读性——首页课题状态、当前回答预览、目录、文档页 */
.md { max-width: 880px; }
.gallery, .status .md { max-width: none; }
.answer { font-size: 13.5px; color: var(--text); opacity: .85; margin-top: 3px; line-height: 1.5; }
.lab-row .t { min-width: 260px; }
.subtitle { margin: -8px 0 10px; font-size: 14px; }
.chip.kind { background: var(--accent-bg); color: var(--accent); }
.toc { font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.toc b { display: block; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.toc a { display: block; padding: 2px 0; color: var(--text); cursor: pointer; }
.toc a.h3 { padding-left: 14px; color: var(--muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }
.side .toc { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.crumbs { color: var(--muted); }
.crumbs span { color: var(--muted); }
details.panel > summary { font-weight: 600; color: var(--text); }
details.panel[open] > summary { margin-bottom: 10px; }
.status h1 { font-size: 20px; }
.status .md h2 { font-size: 16px; margin-top: 18px; }
.answer .md { line-height: 1.5; max-width: none; }
.answer .md p { margin: 0; }
.answer .katex { font-size: 1em; }

/* 想法页：问题树的卡片分支图（2026-10-04） */
main.full { max-width: none; padding: 14px 20px 40px; }
.qtree { --card-w: 232px; --card-h: 150px; }
.qtree .qbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.qtree .qbar h1 { margin: 0 6px 0 0; }
.qtree .qbar .spacer { flex: 1; }
.qtree .qbar button { font-size: 13px; padding: 4px 10px; }
.qtree .qbar button.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.qtree .zoom { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.qtree .zoom button { border: 0; padding: 3px 8px; }
.qtree .zoom .pct { font-size: 12px; color: var(--muted); min-width: 42px; text-align: center; }
.qtree .legend { font-size: 12px; color: var(--muted); }
.qtree .capture { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.qtree .capture textarea { min-height: 44px; }
.qtree .inbox { font-size: 13px; margin: 8px 0 0; }
.qtree .inbox a { margin-right: 10px; }
.qtree .wrap { display: grid; grid-template-columns: 1fr; position: relative; min-height: 60vh; margin-top: 8px; }
.qtree .wrap.wide.open { grid-template-columns: 1fr 440px; }
.qtree .canvas-outer { overflow: auto; padding: 10px 0 30px; }
.qtree .fit-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; min-height: 14px; }
.qtree .canvas-scale { transform-origin: top left; }
.qtree .canvas { position: relative; }
.qtree .canvas svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.qtree .canvas svg path { fill: none; stroke: var(--line); stroke-width: 1.6; }
.qtree .canvas svg path.hot { stroke: var(--accent); stroke-width: 2; }
.qcard { position: absolute; width: var(--card-w); height: var(--card-h); box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px 8px; cursor: pointer; transition: box-shadow .15s, border-color .15s; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.qcard:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: var(--accent); }
.qcard.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.qcard.dim { opacity: .5; }
.qcard.root { border-width: 2px; }
.qcard .top { display: flex; gap: 6px; align-items: center; min-height: 18px; }
.qcard .q { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.qcard .chip { font-size: 11px; padding: 0 7px; }
.qcard .title { font-size: 13.5px; font-weight: 600; line-height: 1.35; height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qcard .verdict { font-size: 12.5px; color: var(--text); line-height: 1.4; height: 2.8em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qcard .verdict::before { content: "→ "; color: var(--accent); }
.qcard .verdict.fallback { color: var(--muted); }
.qcard .verdict .katex { font-size: .95em; }
.qcard .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); min-height: 18px; }
.qcard .foot a { color: var(--accent); }
.qcard .tog { border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; background: var(--bg); font-size: 11px; cursor: pointer; }
.qcard .tog:hover { border-color: var(--accent); color: var(--accent); }
.qdetail { border-left: 1px solid var(--line); background: var(--panel); padding: 16px 18px 30px; overflow: auto; }
.qtree .wrap.wide .qdetail { position: sticky; top: 58px; height: calc(100vh - 70px); display: none; }
.qtree .wrap.wide.open .qdetail { display: block; }
.qtree .wrap:not(.wide) .qdetail { position: fixed; top: 48px; right: 0; bottom: 0; width: 420px; max-width: 92vw; transform: translateX(105%); transition: transform .2s; box-shadow: -6px 0 24px rgba(0,0,0,.08); z-index: 6; }
.qtree .wrap:not(.wide).open .qdetail { transform: none; }
.qdetail .close { float: right; font-size: 12px; margin-left: 8px; }
.qdetail h2 { font-size: 17px; margin: 0 0 8px; line-height: 1.35; }
.qdetail h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 6px; letter-spacing: .3px; }
.qdetail .verdict-line { font-size: 14px; font-weight: 600; margin: 4px 0 10px; }
.qdetail .verdict-line::before { content: "→ "; color: var(--accent); }
.qdetail .answer-box { background: var(--accent-bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.65; }
.qdetail .md { font-size: 13.5px; max-width: none; }
.qdetail .md p { margin: 6px 0; }
.qdetail .md ul { padding-left: 18px; margin: 4px 0; }
.qdetail .kids a { display: block; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0; color: var(--text); font-size: 13px; }
.qdetail .kids a:hover { border-color: var(--accent); text-decoration: none; }
.qdetail .kids .v { color: var(--muted); font-size: 12px; }
.qdetail details { margin: 6px 0; }
.qdetail details summary { font-weight: 600; color: var(--text); font-size: 13px; }
/* 只读访客：看得见内容，看不见任何操作控件 */
body.readonly button, body.readonly textarea, body.readonly .form-row, body.readonly #projects { display: none !important; }
body.readonly #host { color: var(--warn); font-weight: 600; }
