:root {
  --paper: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #221f1c;
  --ink-2: #4a4540;
  --muted: #7a736b;
  --line: #e4dfd7;
  --line-strong: #cfc8bd;
  --beam: #3b2f28;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-weak: #f7e7de;
  --agent: #2a6b66;
  --agent-weak: #dcefed;
  --ok: #2f7a43;
  --ok-weak: #e1f1e4;
  --warn: #a86b00;
  --danger: #b3261e;
  --danger-weak: #fbe4e2;
  --add-bg: #e3f4e6;
  --del-bg: #fbe6e4;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .06);
  --shadow-lg: 0 10px 40px rgba(40, 30, 20, .18);
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171513; --surface: #1f1c19; --surface-2: #24211d; --ink: #ede8e1; --ink-2: #cfc8bf; --muted: #9a9289;
    --line: #34302b; --line-strong: #49433c; --beam: #d9cbbd; --accent: #e07a4c; --accent-ink: #1a1310; --accent-weak: #3a271d;
    --agent: #6cc3bb; --agent-weak: #1d3533; --ok: #7cc78f; --ok-weak: #1e3324; --warn: #e0a64a; --danger: #ff8a80; --danger-weak: #3d1f1d;
    --add-bg: #1e3a25; --del-bg: #43211f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-weak); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* top bar */
.topbar { height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--beam); color: #f3ece4; position: sticky; top: 0; z-index: 20; }
@media (prefers-color-scheme: dark) { .topbar { background: #0f0d0c; border-bottom: 1px solid var(--line); } }
.topbar a { color: inherit; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; font-size: 16px; }
.brand svg { width: 24px; height: 24px; }
.topbar .crumb { opacity: .65; }
.topbar .proj-name { font-weight: 600; }
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav a { padding: 6px 12px; border-radius: 6px; color: #e8dfd4; font-weight: 500; }
.topnav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topnav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .user { display: flex; gap: 6px; align-items: center; }
.topbar .btn.ghost { color: #f3ece4; }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.1); border-color: transparent; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #6c6; display: inline-block; box-shadow: 0 0 0 3px rgba(102,204,102,.2); }
.live-dot.off { background: #c66; box-shadow: none; }

/* layout */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.page h1 { margin: 0 0 4px; font-size: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 28px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card { padding: 16px; display: block; color: inherit; transition: transform .08s, box-shadow .08s; }
.project-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.project-card h3 { margin: 0 0 4px; font-size: 16px; }
.project-card .key { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.project-card p { margin: 8px 0 12px; color: var(--ink-2); min-height: 20px; }
.stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.stats b { color: var(--ink); }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  linear-gradient(135deg, transparent 49.6%, var(--line) 49.6%, var(--line) 50.4%, transparent 50.4%) 0 0/120px 120px,
  linear-gradient(45deg, transparent 49.6%, var(--line) 49.6%, var(--line) 50.4%, transparent 50.4%) 0 0/120px 120px, var(--paper); }
.auth { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 22px; }
.auth h1 svg { width: 28px; height: 28px; color: var(--beam); }
.auth p { margin: 0 0 20px; color: var(--muted); }
.error-msg { color: var(--danger); background: var(--danger-weak); padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; }

/* docs */
.doc-layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 52px); }
.sidebar { border-right: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.tree { overflow: auto; padding: 8px 6px 40px; flex: 1; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 11px; }
.tree-row { display: flex; align-items: center; gap: 2px; padding: 3px 6px; border-radius: 5px; cursor: pointer; user-select: none; position: relative; color: var(--ink-2); }
.tree-row:hover { background: var(--surface); }
.tree-row.active { background: var(--accent-weak); color: var(--ink); font-weight: 600; }
.tree-row .tw { width: 16px; height: 16px; display: inline-grid; place-items: center; color: var(--muted); flex: none; border-radius: 3px; font-size: 10px; }
.tree-row .tw:hover { background: var(--line); }
.tree-row .num { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-right: 4px; flex: none; }
.tree-row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row.drop-inside { outline: 2px solid var(--accent); outline-offset: -2px; }
.tree-row.drop-before::before, .tree-row.drop-after::after { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; background: var(--accent); }
.tree-row.drop-before::before { top: -1px; } .tree-row.drop-after::after { bottom: -1px; }
.tree-row.dragging { opacity: .4; }
.search-results { list-style: none; margin: 0; padding: 4px; }
.search-results li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.search-results li:hover { background: var(--surface); }
.search-results .snip { font-size: 12px; color: var(--muted); }

.doc-main { overflow: auto; min-width: 0; }
.doc-toolbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding: 8px 24px; display: flex; gap: 6px; align-items: center; }
.breadcrumb { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.doc-body { max-width: 860px; margin: 0 auto; padding: 28px 32px 80px; }
.doc-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 6px; font-family: var(--serif); font-size: 32px; font-weight: 600; }
.doc-title .num { font-family: var(--mono); font-size: 18px; color: var(--accent); font-weight: 500; }
.doc-meta { color: var(--muted); font-size: 12px; margin-bottom: 20px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.todo-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip b { font-family: var(--mono); color: var(--accent); }

.md { font-size: 15.5px; line-height: 1.7; color: var(--ink); overflow-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); margin: 1.6em 0 .5em; }
.md h1 { font-size: 26px; } .md h2 { font-size: 21px; } .md h3 { font-size: 17px; } .md h4 { font-size: 15px; }
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .table-wrap { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.5em; }
.md li.task { list-style: none; margin-left: -1.3em; }
.md code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; overflow: auto; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; }
.md blockquote { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 14px; color: var(--ink-2); }
.md blockquote.callout { border-left-color: var(--accent); background: var(--accent-weak); padding: 10px 14px; border-radius: 0 6px 6px 0; }
.md blockquote.callout.warning, .md blockquote.callout.warnung { border-left-color: var(--warn); }
.md blockquote > :last-child { margin-bottom: 0; }
.md .table-wrap { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.md img { max-width: 100%; border-radius: 6px; }
.md a.xref { border-bottom: 1px dashed var(--accent); }
.md a.xref:hover { text-decoration: none; }
.md .xref.missing { color: var(--danger); border-bottom: 1px dashed var(--danger); }
.empty-content { color: var(--muted); font-style: italic; }

.children { margin-top: 36px; }
.children h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; }
.child-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.child-list a { display: flex; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.child-list a:hover { border-color: var(--accent); text-decoration: none; }
.child-list .num { font-family: var(--mono); color: var(--muted); font-size: 12px; padding-top: 2px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pager .next { text-align: right; grid-column: 2; }

.fulldoc .toc { padding: 16px 20px; margin-bottom: 32px; }
.fulldoc .toc a { display: block; padding: 2px 0; color: var(--ink-2); }
.fulldoc section { scroll-margin-top: 60px; }
.fulldoc .sec-head { display: flex; align-items: baseline; gap: 10px; margin: 2.2em 0 .6em; font-family: var(--serif); }
.fulldoc .sec-head .num { font-family: var(--mono); color: var(--accent); font-size: .7em; }
.fulldoc .sec-head a.edit { font-family: var(--sans); font-size: 12px; opacity: 0; }
.fulldoc section:hover .sec-head a.edit { opacity: 1; }

/* editor */
.editor { display: flex; flex-direction: column; height: calc(100vh - 52px); }
.editor-head { padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editor-head .title-input { font-size: 18px; font-weight: 600; flex: 1; min-width: 240px; }
.mdtools { display: flex; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mdtools .btn { height: 26px; min-width: 28px; padding: 0 6px; font-size: 12px; }
.editor-panes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.editor-panes textarea { border: 0; border-right: 1px solid var(--line); resize: none; padding: 20px 24px; font: 14px/1.65 var(--mono); background: var(--surface); outline: none; height: 100%; }
.editor-panes .preview { overflow: auto; padding: 20px 28px; }
.editor-foot { padding: 10px 20px; border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.editor-foot .input { max-width: 460px; }

/* board */
.board-wrap { height: calc(100vh - 52px); display: flex; flex-direction: column; }
.board-bar { padding: 10px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface); }
.board-bar .input { width: auto; }
.board { flex: 1; display: flex; gap: 12px; padding: 14px 16px; overflow-x: auto; align-items: flex-start; }
.col { flex: 1 0 260px; max-width: 360px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.col-head { padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.col-head .count { font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.col.done .col-head { color: var(--ok); }
.col-body { padding: 4px 8px 10px; overflow-y: auto; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.col-body.over { background: var(--accent-weak); border-radius: 0 0 var(--radius) var(--radius); }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.03); position: relative; }
.tcard:hover { border-color: var(--line-strong); }
.tcard.dragging { opacity: .35; }
.tcard .tnum { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tcard .ttitle { font-weight: 500; margin: 2px 0 8px; overflow-wrap: anywhere; }
.tcard .tmeta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.tcard .node-link { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard.prio-high { border-left: 3px solid var(--warn); }
.tcard.prio-urgent { border-left: 3px solid var(--danger); }
.placeholder { height: 44px; border: 2px dashed var(--accent); border-radius: 6px; background: var(--accent-weak); }
.prio { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 5px; border-radius: 3px; }
.prio.high { background: #fbeccb; color: #7a4d00; } .prio.urgent { background: var(--danger-weak); color: var(--danger); } .prio.low { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) { .prio.high { background: #3d2f12; color: var(--warn); } }

.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; background: var(--accent-weak); color: var(--accent); flex: none; }
.avatar.agent { background: var(--agent-weak); color: var(--agent); border-radius: 5px; }
.avatar.lg { width: 30px; height: 30px; font-size: 12px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
.badge.agent { background: var(--agent-weak); color: var(--agent); border-color: transparent; }
.badge.admin { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.badge.ok { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.badge.mcp { background: var(--agent-weak); color: var(--agent); border-color: transparent; font-family: var(--mono); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 14, 10, .45); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow: auto; animation: fade .12s; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .14s; }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.todo-grid { display: grid; grid-template-columns: 1fr 260px; gap: 22px; }
.todo-grid aside label.field select { width: 100%; }
.todo-title-input { font-size: 18px; font-weight: 600; border-color: transparent; padding-left: 6px; }
.todo-title-input:hover { border-color: var(--line); }
.desc-view { padding: 10px 12px; border: 1px solid transparent; border-radius: 6px; cursor: text; min-height: 48px; }
.desc-view:hover { border-color: var(--line); }
.rev-block { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; overflow: hidden; }
.rev-block > header { padding: 8px 12px; background: var(--surface-2); font-size: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.diff { font: 12.5px/1.55 var(--mono); overflow-x: auto; max-height: 420px; overflow-y: auto; }
.diff div { padding: 0 12px; white-space: pre-wrap; word-break: break-word; }
.diff .a { background: var(--add-bg); } .diff .a::before { content: '+ '; color: var(--ok); }
.diff .d { background: var(--del-bg); text-decoration: line-through; text-decoration-color: rgba(179,38,30,.35); } .diff .d::before { content: '− '; color: var(--danger); }
.diff .e::before { content: '  '; }
.diff .skip { color: var(--muted); background: var(--surface-2); font-style: italic; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity li.event { color: var(--muted); font-size: 12px; padding: 4px 0 4px 32px; border: 0; }
.activity .body { flex: 1; min-width: 0; }
.activity .body .md { font-size: 14px; }

/* tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: var(--surface-2); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.secret { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--accent); padding: 10px 12px; border-radius: 6px; word-break: break-all; }
pre.snippet { font: 12px/1.5 var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: 6px; overflow: auto; margin: 6px 0 12px; }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .15s; }
.toast.error { background: var(--danger); color: #fff; }
.banner { background: var(--accent-weak); color: var(--ink); padding: 8px 20px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin: 0 0 6px; }

@media (max-width: 860px) {
  .doc-layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-panes { grid-template-columns: 1fr; }
  .editor-panes .preview { display: none; }
  .todo-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 6px 10px; }
  .topnav { order: 10; width: 100%; margin-left: 0; overflow-x: auto; }
  .topnav a { padding: 6px 10px; white-space: nowrap; }
  .topbar .crumb, .topbar .uname, .topbar .live-dot { display: none; }
  .topbar .user { flex-wrap: wrap; justify-content: flex-end; }
  .doc-toolbar { flex-wrap: wrap; padding: 8px 16px; }
  .breadcrumb { width: 100%; }
  .board-wrap, .editor { height: calc(100vh - 92px); }
  .doc-body { padding: 20px 16px 60px; }
}

@media print {
  .topbar, .sidebar, .doc-toolbar, .toast-wrap, .sec-head a.edit { display: none !important; }
  .doc-layout { display: block; height: auto; }
  .doc-main { overflow: visible; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
