:root {
  --bg: #ffffff;
  --bg-side: #f7f7f5;
  --bg-hover: rgba(55, 53, 47, .06);
  --bg-active: rgba(55, 53, 47, .1);
  --bg-elev: #ffffff;
  --fg: #37352f;
  --fg-muted: rgba(55, 53, 47, .6);
  --fg-faint: rgba(55, 53, 47, .38);
  --border: rgba(55, 53, 47, .13);
  --accent: #2383e2;
  --accent-fg: #ffffff;
  --danger: #e03e3e;
  --shadow: 0 0 0 1px rgba(15, 15, 15, .05), 0 3px 6px rgba(15, 15, 15, .1), 0 9px 24px rgba(15, 15, 15, .2);
  --code-bg: #f7f6f3;
  --inline-code: rgba(135, 131, 120, .15);
  --select: rgba(35, 131, 226, .14);
  --sb-width: 248px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  /* option & text colours */
  --c-gray: #787774; --c-brown: #9f6b53; --c-orange: #d9730d; --c-yellow: #cb912f; --c-green: #448361;
  --c-blue: #337ea9; --c-purple: #9065b0; --c-pink: #c14c8a; --c-red: #d44c47;
  --bg-gray: #f1f1ef; --bg-brown: #f4eeee; --bg-orange: #fbecdd; --bg-yellow: #fbf3db; --bg-green: #edf3ec;
  --bg-blue: #e7f3f8; --bg-purple: #f6f3f9; --bg-pink: #faf1f5; --bg-red: #fdebec;
  --tag-default: rgba(227, 226, 224, .5); --tag-gray: #e3e2e0; --tag-brown: #eee0da; --tag-orange: #fadec9; --tag-yellow: #fdecc8;
  --tag-green: #dbeddb; --tag-blue: #d3e5ef; --tag-purple: #e8deee; --tag-pink: #f5e0e9; --tag-red: #ffe2dd;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919; --bg-side: #202020; --bg-hover: rgba(255, 255, 255, .055); --bg-active: rgba(255, 255, 255, .09); --bg-elev: #252525;
    --fg: rgba(255, 255, 255, .87); --fg-muted: rgba(255, 255, 255, .52); --fg-faint: rgba(255, 255, 255, .3); --border: rgba(255, 255, 255, .1);
    --shadow: 0 0 0 1px rgba(15, 15, 15, .1), 0 3px 6px rgba(15, 15, 15, .2), 0 9px 24px rgba(15, 15, 15, .4);
    --code-bg: #202020; --inline-code: rgba(135, 131, 120, .25); --select: rgba(35, 131, 226, .28);
    --c-gray: #9b9b9b; --c-brown: #ba856f; --c-orange: #c77d48; --c-yellow: #ca9849; --c-green: #529e72;
    --c-blue: #5e87c9; --c-purple: #9d68d3; --c-pink: #d15796; --c-red: #df5452;
    --bg-gray: #2f2f2f; --bg-brown: #4a3228; --bg-orange: #5c3b23; --bg-yellow: #564328; --bg-green: #243d30;
    --bg-blue: #143a4e; --bg-purple: #3c2d49; --bg-pink: #4e2c3c; --bg-red: #522e2a;
    --tag-default: rgba(255, 255, 255, .094); --tag-gray: #5a5a5a; --tag-brown: #603b2c; --tag-orange: #854c1d; --tag-yellow: #89632a;
    --tag-green: #2b593f; --tag-blue: #28456c; --tag-purple: #492f64; --tag-pink: #69314c; --tag-red: #6e3630;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191919; --bg-side: #202020; --bg-hover: rgba(255, 255, 255, .055); --bg-active: rgba(255, 255, 255, .09); --bg-elev: #252525;
  --fg: rgba(255, 255, 255, .87); --fg-muted: rgba(255, 255, 255, .52); --fg-faint: rgba(255, 255, 255, .3); --border: rgba(255, 255, 255, .1);
  --shadow: 0 0 0 1px rgba(15, 15, 15, .1), 0 3px 6px rgba(15, 15, 15, .2), 0 9px 24px rgba(15, 15, 15, .4);
  --code-bg: #202020; --inline-code: rgba(135, 131, 120, .25); --select: rgba(35, 131, 226, .28);
  --c-gray: #9b9b9b; --c-brown: #ba856f; --c-orange: #c77d48; --c-yellow: #ca9849; --c-green: #529e72;
  --c-blue: #5e87c9; --c-purple: #9d68d3; --c-pink: #d15796; --c-red: #df5452;
  --bg-gray: #2f2f2f; --bg-brown: #4a3228; --bg-orange: #5c3b23; --bg-yellow: #564328; --bg-green: #243d30;
  --bg-blue: #143a4e; --bg-purple: #3c2d49; --bg-pink: #4e2c3c; --bg-red: #522e2a;
  --tag-default: rgba(255, 255, 255, .094); --tag-gray: #5a5a5a; --tag-brown: #603b2c; --tag-orange: #854c1d; --tag-yellow: #89632a;
  --tag-green: #2b593f; --tag-blue: #28456c; --tag-purple: #492f64; --tag-pink: #69314c; --tag-red: #6e3630;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--select); }
[hidden] { display: none !important; }
kbd { font: 12px var(--mono); background: var(--bg-hover); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

.muted { color: var(--fg-muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.pad { padding: 8px 12px; }
.spacer { flex: 1; }
.row-gap { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mono { font-family: var(--mono); font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---- buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 14px; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn.block { width: 100%; padding: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; border-radius: 4px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fg-muted); font-size: 16px; flex: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn.on { color: #e9b200; }
.icon-btn.tiny { width: 20px; height: 20px; font-size: 14px; }
.tbtn { border: 0; background: none; border-radius: 4px; padding: 3px 8px; cursor: pointer; color: var(--fg-muted); font-size: 14px; white-space: nowrap; }
.tbtn:hover { background: var(--bg-hover); color: var(--fg); }
.tbtn.on { color: var(--accent); }
.mini { border: 0; background: none; border-radius: 4px; padding: 2px 6px; cursor: pointer; color: var(--fg-muted); font-size: 12px; }
.mini:hover { background: var(--bg-hover); color: var(--fg); }
.mini.danger:hover { color: var(--danger); }
.ghost { border: 0; background: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; color: var(--fg-faint); font-size: 14px; }
.ghost:hover { background: var(--bg-hover); color: var(--fg-muted); }
.chip { border: 1px solid var(--border); background: var(--bg-hover); border-radius: 4px; padding: 1px 6px; margin: 2px; cursor: pointer; font-size: 12px; }
.input { width: 100%; border: 1px solid var(--border); background: var(--bg-hover); border-radius: 6px; padding: 6px 9px; outline: none; font-size: 14px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea.input { resize: vertical; }
select.input { padding: 5px 6px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fg-muted); }
.form h3 { margin: 10px 0 0; font-size: 14px; }
.check-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 6px; color: var(--fg) !important; font-size: 14px; cursor: pointer; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg-active); border-radius: 20px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(14px); }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 600; flex: none; vertical-align: middle; }

/* ---- layout ---- */
#app.shell { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sb-width); flex: none; background: var(--bg-side); display: flex; flex-direction: column; position: relative; transition: margin-left .2s; user-select: none; border-right: 1px solid var(--border); }
#app.sb-hidden #sidebar { margin-left: calc(-1 * var(--sb-width)); }
#main { flex: 1; min-width: 0; height: 100vh; position: relative; }
.sidebar-open { display: none; }
#app.sb-hidden .sidebar-open { display: inline-flex; }
.sb-backdrop { display: none; }
.sb-resizer { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.sb-resizer:hover { background: var(--accent); opacity: .3; }

.sb-top { display: flex; align-items: center; padding: 6px 6px 2px; gap: 2px; }
.sb-workspace { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; background: none; border-radius: 6px; padding: 6px 8px; cursor: pointer; text-align: left; font-weight: 600; font-size: 14px; }
.sb-workspace:hover { background: var(--bg-hover); }
.ws-icon { width: 22px; height: 22px; border-radius: 4px; background: var(--bg-active); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-collapse { opacity: 0; }
#sidebar:hover .sb-collapse { opacity: 1; }
.sb-quick, .sb-foot { padding: 2px 6px; }
.sb-foot { border-top: 1px solid var(--border); padding-top: 6px; padding-bottom: 8px; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.sb-item { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; padding: 2px 8px; border: 0; background: none; border-radius: 5px; cursor: pointer; color: var(--fg-muted); font-size: 14px; text-decoration: none; text-align: left; position: relative; }
.sb-item:hover { background: var(--bg-hover); }
.sb-item.active { background: var(--bg-active); color: var(--fg); font-weight: 500; }
.sb-icon { width: 20px; text-align: center; flex: none; font-size: 14px; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-hint { font-size: 11px; color: var(--fg-faint); }
.sb-section { margin-top: 14px; }
.sb-section-head { display: flex; align-items: center; padding: 0 2px 0 8px; border-radius: 5px; }
.sb-section-head.drop-into { background: var(--select); }
.sb-section-title { flex: 1; text-align: left; border: 0; background: none; color: var(--fg-faint); font-size: 12px; font-weight: 600; padding: 4px 0; cursor: pointer; }
.sb-section-head .icon-btn { opacity: 0; }
.sb-section-head:hover .icon-btn { opacity: 1; }
.sb-empty { font-size: 13px; padding: 3px 10px 3px 30px; }
.tree-arrow { border: 0; background: none; width: 20px; height: 20px; border-radius: 4px; font-size: 14px; line-height: 1; color: var(--fg-faint); cursor: pointer; flex: none; padding: 0; transition: transform .12s; }
.tree-arrow:hover { background: var(--bg-active); }
.tree-arrow.open { transform: rotate(90deg); }
.tree-item .sb-icon { margin-left: -4px; }
.tree-actions { display: none; gap: 2px; }
.tree-item:hover .tree-actions { display: flex; }
.tree-item.drop-into { background: var(--select); box-shadow: inset 0 0 0 1px var(--accent); }
.tree-item.drop-before::before, .tree-item.drop-after::after { content: ""; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent); border-radius: 2px; }
.tree-item.drop-before::before { top: -1px; }
.tree-item.drop-after::after { bottom: -1px; }

/* ---- page ---- */
.page-view { display: flex; flex-direction: column; height: 100%; position: relative; }
.page-view.with-drawer .page-scroll { margin-right: 340px; }
.topbar { display: flex; align-items: center; gap: 4px; height: 45px; padding: 0 12px; flex: none; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; font-size: 14px; }
.crumb { padding: 2px 6px; border-radius: 4px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; color: var(--fg-muted); }
a.crumb:hover { background: var(--bg-hover); }
.crumb.current { color: var(--fg); }
.crumb-sep { color: var(--fg-faint); }
.save-status { font-size: 12px; margin-right: 6px; white-space: nowrap; }
.page-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.cover { height: 30vh; max-height: 280px; min-height: 140px; background-size: cover; background-position: center; position: relative; }
.cover-actions { position: absolute; right: 24px; bottom: 12px; display: none; gap: 6px; }
.cover:hover .cover-actions { display: flex; }
.page-inner { max-width: 900px; margin: 0 auto; padding: 72px 96px 30vh; position: relative; }
.page-inner.full { max-width: none; }
.page-inner.has-cover { padding-top: 24px; }
.page-inner.has-cover.has-icon { padding-top: 0; }
.page-inner.has-cover .page-icon { margin-top: -42px; }
.page-icon { font-size: 72px; line-height: 1; border: 0; background: none; padding: 4px; border-radius: 6px; cursor: pointer; display: block; margin: 0 0 4px -4px; position: relative; }
.page-icon:hover:not(:disabled) { background: var(--bg-hover); }
.page-icon:disabled { cursor: default; }
.page-controls { display: flex; gap: 4px; margin: 0 0 4px -8px; opacity: 0; transition: opacity .15s; min-height: 28px; }
.page-inner:hover .page-controls, .page-controls:focus-within { opacity: 1; }
.page-title { font-size: 40px; font-weight: 700; line-height: 1.2; margin: 0 0 12px; outline: none; word-break: break-word; }
.page-title.small { font-size: 28px; }
.page-title:empty::before { content: attr(data-placeholder); color: var(--fg-faint); }
.page-meta { font-size: 12px; margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--border); }
.page-loading, .page-missing, .empty-home { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; text-align: center; padding: 20px; }
.big-icon { font-size: 48px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 8px 16px; background: var(--bg-blue); font-size: 14px; }
.banner.danger { background: var(--danger); color: #fff; }
.banner.danger .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.banner.warn { background: var(--bg-yellow); }
.row-props { margin: 0 0 6px; }
.rp-row { display: flex; align-items: flex-start; min-height: 34px; }
.rp-label { width: 180px; flex: none; display: flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--fg-muted); font-size: 14px; padding: 6px 6px; border-radius: 4px; cursor: pointer; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rp-label:hover { background: var(--bg-hover); }
.rp-value { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 14px; min-height: 32px; word-break: break-word; }
.rp-value:hover, .rp-value.editing { background: var(--bg-hover); }
.rp-value.ro { cursor: default; }
.rp-add { border: 0; background: none; color: var(--fg-faint); padding: 6px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.rp-add:hover { background: var(--bg-hover); color: var(--fg-muted); }
.row-sep { border-top: 1px solid var(--border); margin: 10px 0 20px; }
.cell-empty { color: var(--fg-faint); }

/* ---- editor ---- */
.editor { position: relative; outline: none; padding-bottom: 8px; }
.editor-tail { min-height: 120px; cursor: text; }
.block { position: relative; display: flex; padding: 1px 0; margin-left: calc(var(--indent, 0) * 26px); border-radius: 4px; }
.block.selected { background: var(--select); }
.gutter { position: absolute; left: -50px; top: 3px; display: flex; opacity: 0; transition: opacity .1s; user-select: none; }
.block:hover > .gutter, .block.selected > .gutter { opacity: 1; }
.g-add, .g-handle { width: 24px; height: 24px; border: 0; background: none; border-radius: 4px; color: var(--fg-faint); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; padding: 0; }
.g-handle { font-size: 12px; letter-spacing: -2px; cursor: grab; width: 18px; }
.g-add:hover, .g-handle:hover { background: var(--bg-hover); color: var(--fg-muted); }
.body { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 2px; }
.content { flex: 1; min-width: 0; outline: none; padding: 3px 2px; white-space: pre-wrap; word-break: break-word; caret-color: var(--fg); min-height: 1.5em; }
.content[data-placeholder]:empty:focus::before { content: attr(data-placeholder); color: var(--fg-faint); pointer-events: none; }
.b-h1 .content[data-placeholder]:empty::before, .b-h2 .content[data-placeholder]:empty::before, .b-h3 .content[data-placeholder]:empty::before,
.b-bullet .content:empty::before, .b-numbered .content:empty::before, .b-todo .content:empty::before, .b-toggle .content:empty::before,
.b-quote .content:empty::before, .b-callout .content:empty::before { content: attr(data-placeholder); color: var(--fg-faint); pointer-events: none; }
.share-mode .content:empty::before, .export .content:empty::before { content: none !important; }
.b-h1 { margin-top: 1.4em; } .b-h1 .content { font-size: 1.875em; font-weight: 700; line-height: 1.3; }
.b-h2 { margin-top: 1.1em; } .b-h2 .content { font-size: 1.5em; font-weight: 600; line-height: 1.3; }
.b-h3 { margin-top: .8em; } .b-h3 .content { font-size: 1.25em; font-weight: 600; line-height: 1.3; }
.b-h1 .gutter { top: 10px; } .b-h2 .gutter { top: 6px; } .b-h3 .gutter { top: 3px; }
.prefix { flex: none; width: 24px; display: inline-flex; align-items: center; justify-content: center; min-height: 30px; user-select: none; }
.prefix.bullet { font-size: 1.2em; }
.prefix.number { width: auto; min-width: 24px; padding-right: 4px; font-variant-numeric: tabular-nums; }
.prefix.check { width: 16px; height: 16px; margin: 7px 6px 0 4px; min-height: 0; cursor: pointer; accent-color: var(--accent); }
.block.checked > .body > .content { text-decoration: line-through; color: var(--fg-faint); }
.prefix.arrow { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--fg); border-radius: 4px; height: 24px; margin-top: 3px; min-height: 0; transition: transform .12s; padding: 0; }
.prefix.arrow:hover { background: var(--bg-hover); }
.prefix.arrow.open { transform: rotate(90deg); }
.toggle-empty { position: absolute; top: 100%; left: 26px; font-size: 14px; color: var(--fg-faint); cursor: pointer; padding: 3px 2px; }
.b-toggle:has(.toggle-empty) { margin-bottom: 30px; }
.b-quote .body { border-left: 3px solid currentColor; padding-left: 14px; }
.b-quote .content { font-size: 1.1em; }
.b-callout .body { background: var(--bg-hover); border-radius: 6px; padding: 12px 14px 12px 10px; }
.emoji-btn { border: 0; background: none; font-size: 20px; cursor: pointer; border-radius: 4px; height: 30px; width: 30px; }
.emoji-btn:hover { background: var(--bg-active); }
.b-divider .body { padding: 8px 0; cursor: pointer; }
.b-divider hr { flex: 1; border: 0; border-top: 1px solid var(--border); margin: 0; }
.code-wrap { flex: 1; min-width: 0; background: var(--code-bg); border-radius: 6px; margin: 4px 0; position: relative; }
.code-head { display: flex; gap: 6px; align-items: center; padding: 6px 10px 0; opacity: 0; transition: opacity .12s; }
.code-wrap:hover .code-head, .code-wrap:focus-within .code-head { opacity: 1; }
.code-lang { border: 0; background: none; font-size: 12px; color: var(--fg-muted); cursor: pointer; }
.content.code { font: 13.5px/1.6 var(--mono); padding: 8px 16px 18px; margin: 0; white-space: pre; overflow-x: auto; tab-size: 2; }
.content.code.wrap { white-space: pre-wrap; }
.content code, .card code { font-family: var(--mono); font-size: 85%; background: var(--inline-code); color: #eb5757; border-radius: 4px; padding: 0.2em 0.4em; }
.content a, .comment-body a { color: inherit; text-decoration: underline; text-decoration-color: var(--fg-faint); text-underline-offset: 2px; cursor: pointer; }
.content a.mention { text-decoration: none; font-weight: 500; border-radius: 4px; padding: 0 2px; }
.content a.mention:hover { background: var(--bg-hover); }
.mention-date { color: var(--fg-muted); }
.page-link { display: flex; align-items: center; gap: 6px; flex: 1; padding: 3px 4px; border-radius: 4px; text-decoration: none; font-weight: 500; }
.page-link:hover { background: var(--bg-hover); }
.page-link .pl-title { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.page-link.missing { color: var(--fg-faint); }
.toc { display: flex; flex-direction: column; flex: 1; padding: 4px 0; }
.toc a { color: var(--fg-muted); text-decoration: none; padding: 3px 4px; border-radius: 4px; font-size: 14px; }
.toc a:hover { background: var(--bg-hover); }
.toc .toc-h2 { padding-left: 20px; } .toc .toc-h3 { padding-left: 38px; }
.media-empty { flex: 1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bg-hover); border-radius: 6px; padding: 12px 14px; color: var(--fg-muted); font-size: 14px; }
.media-empty .input { flex: 1; min-width: 200px; }
.img-block { flex: 1; margin: 6px 0; display: flex; flex-direction: column; min-width: 0; }
.img-block.align-center { align-items: center; } .img-block.align-right { align-items: flex-end; }
.img-frame { position: relative; max-width: 100%; }
.img-frame img { display: block; width: 100%; border-radius: 4px; }
.img-grip { position: absolute; right: -4px; top: 50%; width: 8px; height: 48px; margin-top: -24px; background: rgba(15,15,15,.6); border: 1px solid rgba(255,255,255,.8); border-radius: 6px; cursor: ew-resize; opacity: 0; }
.img-frame:hover .img-grip { opacity: 1; }
figcaption.content { font-size: 14px; color: var(--fg-muted); padding: 6px 2px 2px; min-height: 0; width: 100%; }
figcaption.content:empty::before { content: attr(data-placeholder); color: var(--fg-faint); opacity: 0; }
.img-block:hover figcaption.content:empty::before, figcaption.content:empty:focus::before { opacity: 1; }
.embed-block { flex: 1; margin: 6px 0; min-width: 0; }
.embed-frame { position: relative; padding-top: 56.25%; border-radius: 6px; overflow: hidden; background: var(--bg-hover); }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bookmark { display: block; flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; text-decoration: none; margin: 4px 0; }
.bookmark:hover { background: var(--bg-hover); }
.bm-title { font-size: 14px; font-weight: 500; }
.bm-url { font-size: 12px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-block { flex: 1; padding: 3px 0; }
.file-block a { text-decoration: none; padding: 4px 6px; border-radius: 4px; display: inline-block; }
.file-block a:hover { background: var(--bg-hover); }
.fb-name { text-decoration: underline; text-decoration-color: var(--border); }
.drop-marker { position: absolute; right: 0; height: 4px; background: var(--accent); opacity: .5; border-radius: 2px; pointer-events: none; z-index: 3; }

/* colours */
.c-gray { color: var(--c-gray); } .c-brown { color: var(--c-brown); } .c-orange { color: var(--c-orange); } .c-yellow { color: var(--c-yellow); }
.c-green { color: var(--c-green); } .c-blue { color: var(--c-blue); } .c-purple { color: var(--c-purple); } .c-pink { color: var(--c-pink); } .c-red { color: var(--c-red); }
.bg-gray { background: var(--bg-gray); } .bg-brown { background: var(--bg-brown); } .bg-orange { background: var(--bg-orange); } .bg-yellow { background: var(--bg-yellow); }
.bg-green { background: var(--bg-green); } .bg-blue { background: var(--bg-blue); } .bg-purple { background: var(--bg-purple); } .bg-pink { background: var(--bg-pink); } .bg-red { background: var(--bg-red); }
span.bg-gray, span.bg-brown, span.bg-orange, span.bg-yellow, span.bg-green, span.bg-blue, span.bg-purple, span.bg-pink, span.bg-red { border-radius: 3px; padding: 0 2px; }
.color-gray .content { color: var(--c-gray); } .color-brown .content { color: var(--c-brown); } .color-orange .content { color: var(--c-orange); }
.color-yellow .content { color: var(--c-yellow); } .color-green .content { color: var(--c-green); } .color-blue .content { color: var(--c-blue); }
.color-purple .content { color: var(--c-purple); } .color-pink .content { color: var(--c-pink); } .color-red .content { color: var(--c-red); }
.color-gray_bg > .body { background: var(--bg-gray); } .color-brown_bg > .body { background: var(--bg-brown); } .color-orange_bg > .body { background: var(--bg-orange); }
.color-yellow_bg > .body { background: var(--bg-yellow); } .color-green_bg > .body { background: var(--bg-green); } .color-blue_bg > .body { background: var(--bg-blue); }
.color-purple_bg > .body { background: var(--bg-purple); } .color-pink_bg > .body { background: var(--bg-pink); } .color-red_bg > .body { background: var(--bg-red); }
[class*="_bg"] > .body { border-radius: 4px; }
.tag { display: inline-flex; align-items: center; gap: 2px; border-radius: 3px; padding: 0 6px; font-size: 13px; line-height: 20px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.opt-default { background: var(--tag-default); } .opt-gray { background: var(--tag-gray); } .opt-brown { background: var(--tag-brown); } .opt-orange { background: var(--tag-orange); }
.opt-yellow { background: var(--tag-yellow); } .opt-green { background: var(--tag-green); } .opt-blue { background: var(--tag-blue); } .opt-purple { background: var(--tag-purple); }
.opt-pink { background: var(--tag-pink); } .opt-red { background: var(--tag-red); }
.color-dot { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag-x { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; opacity: .6; font-size: 14px; line-height: 1; }
.tag-x:hover { opacity: 1; }

/* ---- popovers, menus, modals, toasts ---- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
#layer > * { pointer-events: auto; }
.popover { position: fixed; background: var(--bg-elev); border-radius: 8px; box-shadow: var(--shadow); max-height: min(70vh, 520px); overflow-y: auto; z-index: 101; font-size: 14px; }
.menu-pop { min-width: 220px; max-width: 320px; }
.menu { padding: 4px; display: flex; flex-direction: column; }
.menu .item, .menu-pop .item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border: 0; background: none; border-radius: 4px; text-align: left; cursor: pointer; font-size: 14px; min-height: 30px; }
.menu .item.active, .menu .item:hover, .menu-pop .item:focus { background: var(--bg-hover); outline: none; }
.item.danger { color: var(--danger); }
.mi-icon { width: 20px; text-align: center; flex: none; color: var(--fg-muted); }
.mi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-hint { color: var(--fg-faint); font-size: 12px; margin-left: auto; }
.mi-check { color: var(--fg-muted); margin-left: auto; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-head { font-size: 11px; font-weight: 600; color: var(--fg-faint); padding: 8px 8px 4px; text-transform: uppercase; letter-spacing: .03em; }
.menu-empty { color: var(--fg-faint); padding: 8px 10px; font-size: 14px; }
.menu-filter { width: calc(100% - 12px); margin: 6px; border: 1px solid var(--border); background: var(--bg-hover); border-radius: 5px; padding: 5px 8px; outline: none; font-size: 14px; }
.slash-menu { width: 330px; padding: 4px; }
.slash-item { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.slash-item.active { background: var(--bg-hover); }
.si-icon { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 16px; font-weight: 600; }
.search-item .si-icon { width: 28px; height: 28px; border: 0; background: none; }
.si-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.si-text b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-text small { color: var(--fg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-toolbar { display: flex; align-items: center; padding: 3px; gap: 1px; overflow: visible; }
.tb { border: 0; background: none; height: 28px; min-width: 28px; padding: 0 7px; border-radius: 4px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.tb:hover { background: var(--bg-hover); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; }
.link-pop { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.lp-url { font-size: 13px; color: var(--accent); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 6px; }
.emoji-picker { padding: 6px; }
.emoji-bar { display: flex; gap: 4px; align-items: center; }
.emoji-bar .menu-filter { margin: 0; flex: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); max-height: 300px; overflow-y: auto; margin-top: 6px; }
.emoji-cat { grid-column: 1 / -1; font-size: 11px; color: var(--fg-faint); font-weight: 600; padding: 6px 2px 2px; }
.emoji { border: 0; background: none; font-size: 22px; padding: 2px; border-radius: 4px; cursor: pointer; line-height: 1.3; }
.emoji:hover { background: var(--bg-hover); }
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 15, 15, .45); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; z-index: 100; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg-elev); border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.small { max-width: 400px; } .modal.medium { max-width: 560px; } .modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; }
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-body { padding: 12px 16px 16px; overflow-y: auto; }
.confirm p { margin: 4px 0 8px; }
.modal.search { max-width: 640px; }
.modal.search .modal-body { padding: 0; }
.search-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 16px 18px; font-size: 17px; outline: none; background: none; }
.search-results { max-height: 55vh; overflow-y: auto; padding: 4px; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.search-item.active { background: var(--bg-hover); }
.snippet mark { background: var(--bg-yellow); color: inherit; }
.modal.peek { max-width: 980px; height: 86vh; max-height: none; }
.modal-wrap:has(.peek) { padding-top: 5vh; }
.modal.peek .modal-body { padding: 0; flex: 1; overflow: hidden; }
.peek-holder { height: 100%; }
.peek-view .page-inner { padding: 30px 64px 120px; }
.peek-view .page-inner.has-cover { padding-top: 20px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: #2f2f2f; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); pointer-events: auto; max-width: 90vw; animation: up .15s; }
.toast.error { background: var(--danger); }
.toast .linkish { color: #9fd0ff; }
.toast.out { opacity: 0; transition: opacity .2s; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---- databases ---- */
.dbview { margin-top: 4px; }
.db-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; flex-wrap: wrap; }
.db-tabs { display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.db-tab { border: 0; background: none; padding: 6px 8px; border-bottom: 2px solid transparent; cursor: pointer; font-size: 14px; color: var(--fg-muted); white-space: nowrap; margin-bottom: -1px; }
.db-tab.active { color: var(--fg); border-bottom-color: var(--fg); }
.db-tab:hover { background: var(--bg-hover); border-radius: 4px 4px 0 0; }
.db-actions { display: flex; align-items: center; gap: 2px; padding: 4px 0; }
.db-search { border: 0; background: none; outline: none; width: 90px; padding: 3px 6px; font-size: 14px; border-radius: 4px; transition: width .15s; }
.db-search:focus { width: 160px; background: var(--bg-hover); }
.db-empty { color: var(--fg-muted); padding: 30px 10px; text-align: center; }
.tbl-scroll { overflow-x: auto; padding-bottom: 8px; }
.tbl { display: inline-block; min-width: 100%; font-size: 14px; }
.tr { display: grid; border-bottom: 1px solid var(--border); min-height: 34px; position: relative; }
.tr.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.th-row { color: var(--fg-muted); border-top: 1px solid var(--border); }
.th { display: flex; align-items: center; gap: 6px; padding: 0 8px; cursor: pointer; border-right: 1px solid var(--border); position: relative; white-space: nowrap; overflow: hidden; font-size: 13px; }
.th:hover { background: var(--bg-hover); }
.th.add { justify-content: center; border-right: 0; }
.th-icon { color: var(--fg-faint); font-size: 12px; flex: none; }
.th-name { overflow: hidden; text-overflow: ellipsis; }
.col-grip { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 1; }
.col-grip:hover { background: var(--accent); opacity: .5; }
.td { padding: 6px 8px; border-right: 1px solid var(--border); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; position: relative; min-width: 0; }
.tbl.wrap .td { white-space: normal; word-break: break-word; }
.td:hover { background: var(--bg-hover); }
.td.editing { box-shadow: inset 0 0 0 2px var(--accent); }
.td-title { font-weight: 500; }
.td-more { border-right: 0; display: flex; align-items: center; justify-content: center; padding: 0; }
.row-more { border: 0; background: none; cursor: pointer; color: var(--fg-faint); opacity: 0; border-radius: 4px; width: 24px; height: 24px; }
.tr:hover .row-more { opacity: 1; }
.row-more:hover { background: var(--bg-active); }
.open-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: none; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 4px; font-size: 11px; padding: 1px 6px; cursor: pointer; color: var(--fg-muted); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.td-title:hover .open-btn { display: block; }
.new-row { display: block; color: var(--fg-faint); padding: 7px 8px; cursor: pointer; }
.new-row:hover { background: var(--bg-hover); color: var(--fg-muted); }
.tbl-foot { padding: 6px 8px; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.td-number { text-align: right; }
.cell-link { color: inherit; text-decoration: underline; text-decoration-color: var(--fg-faint); }
.cell-error { color: var(--danger); font-size: 12px; }
.cell-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.row-icon { margin-right: 4px; }
.people { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 2px; }
.rel-chip { text-decoration: none; border-bottom: 1px solid var(--border); font-size: 13px; }
.cell-pop { padding: 6px; }
.cell-pop > .input, .cell-pop > textarea { border: 0; background: none; box-shadow: none; }
.date-pop { display: flex; flex-direction: column; gap: 8px; padding: 4px; width: 260px; }
.date-end { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.opt-picker { padding: 0; }
.opt-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; }
.opt-chips:empty { display: none; }
.opt-item { gap: 6px; }
.opt-item .drag-dots { color: var(--fg-faint); font-size: 10px; }
.opt-more { margin-left: auto; opacity: 0; }
.opt-item:hover .opt-more { opacity: 1; }
.opt-menu { padding: 6px; display: flex; flex-direction: column; }
.prop-menu .input { margin-bottom: 4px; }
.filter-pop { padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.filter-row { display: flex; gap: 6px; align-items: center; width: 100%; }
.filter-row .input { width: auto; flex: 1; min-width: 0; }
.filter-join { width: 64px; flex: none; font-size: 13px; color: var(--fg-muted); }
.filter-join .input { width: 64px; }
.props-pop .item { cursor: default; }
.props-pop .mi-label { cursor: pointer; }
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding: 6px 0 16px; }
.board-col { width: 260px; flex: none; border-radius: 8px; padding: 4px; }
.board-col.drop { background: var(--bg-hover); }
.board-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px; font-size: 14px; }
.board-cards { display: flex; flex-direction: column; gap: 8px; min-height: 10px; }
.board-new, .dblist-new, .board-add-group { border: 0; background: none; color: var(--fg-faint); text-align: left; padding: 6px 6px; border-radius: 4px; cursor: pointer; width: 100%; font-size: 14px; }
.board-new:hover, .dblist-new:hover, .board-add-group:hover { background: var(--bg-hover); color: var(--fg-muted); }
.board-add-group { width: 200px; flex: none; }
.card { background: var(--bg-elev); border-radius: 6px; box-shadow: 0 0 0 1px var(--border), 0 2px 4px rgba(15,15,15,.05); padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-size: 14px; overflow: hidden; text-align: left; border: 0; }
.card:hover { background: var(--bg-hover); }
.card.dragging { opacity: .5; }
.card-title { font-weight: 500; word-break: break-word; }
.card-prop { font-size: 13px; }
.card-cover { margin: -10px -10px 0; height: 140px; background-size: cover; background-position: center; }
.card-preview { margin: -10px -10px 0; height: 120px; padding: 10px; font-size: 11px; color: var(--fg-muted); white-space: pre-wrap; overflow: hidden; background: var(--bg-hover); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding: 8px 0; }
.card-new { align-items: center; justify-content: center; color: var(--fg-faint); min-height: 80px; }
.dblist-item { display: flex; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 4px; cursor: pointer; border-bottom: 1px solid var(--border); }
.dblist-item:hover { background: var(--bg-hover); }
.dblist-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dblist-props { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--fg-muted); flex-wrap: wrap; justify-content: flex-end; }
.calendar { padding: 4px 0 20px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.cal-head h3 { margin: 0; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.cal-dow { font-size: 12px; color: var(--fg-muted); padding: 4px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; }
.cal-day { min-height: 110px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--bg-hover); }
.cal-day.other .cal-num { color: var(--fg-faint); }
.cal-day.drop { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: 12px; text-align: right; padding: 0 4px; }
.cal-day.today .cal-num { color: #fff; }
.cal-day.today .cal-num::before { content: ""; }
.cal-day.today .cal-num { background: var(--c-red); border-radius: 10px; align-self: flex-end; padding: 0 6px; }
.cal-ev { background: var(--bg-elev); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(15,15,15,.06); border-radius: 4px; padding: 2px 6px; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev:hover { background: var(--bg-hover); }
.cal-add { position: absolute; left: 4px; top: 3px; border: 0; background: none; color: var(--fg-faint); cursor: pointer; opacity: 0; border-radius: 4px; width: 20px; height: 20px; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--bg-active); }
.cal-undated { margin-top: 12px; font-size: 14px; }
.cal-undated .cal-ev { display: inline-block; margin: 4px 4px 0 0; }

/* ---- side panels & dialogs ---- */
.comments-drawer { position: absolute; right: 0; top: 45px; bottom: 0; width: 340px; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; z-index: 5; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.drawer-head b { flex: 1; }
.comments-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment.resolved { opacity: .6; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.comment-body { white-space: pre-wrap; margin: 4px 0 0 30px; font-size: 14px; word-break: break-word; }
.comment-actions { margin-left: 26px; }
.comment-new { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.share-pop { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.share-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.cover-pop { padding: 8px; }
.cover-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px; }
.cover-swatch { height: 46px; border: 0; border-radius: 4px; cursor: pointer; }
.cover-swatch:hover { outline: 2px solid var(--accent); }
.cover-pop .row-gap .input { flex: 1; width: auto; }
.trash-list { max-height: 360px; overflow-y: auto; }
.trash-item .mi-label { cursor: pointer; }
.history { display: flex; gap: 16px; height: 60vh; }
.history-list { width: 240px; flex: none; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 8px; }
.history-item { display: flex; flex-direction: column; align-items: flex-start; border: 0; background: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; text-align: left; font-size: 14px; }
.history-item:hover, .history-item.active { background: var(--bg-hover); }
.history-right { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-preview { flex: 1; overflow-y: auto; padding-left: 50px; }
.settings { display: flex; gap: 20px; min-height: 50vh; }
.settings-nav { width: 160px; flex: none; display: flex; flex-direction: column; gap: 2px; }
.settings-tab { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 5px; cursor: pointer; font-size: 14px; color: var(--fg-muted); }
.settings-tab:hover { background: var(--bg-hover); }
.settings-tab.active { background: var(--bg-active); color: var(--fg); }
.settings-body { flex: 1; min-width: 0; }
.members { width: 100%; border-collapse: collapse; font-size: 14px; }
.members td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.members td:first-child { width: 34px; }
.shortcuts { width: 100%; border-collapse: collapse; font-size: 14px; }
.shortcuts td { padding: 5px 4px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { width: 45%; }
.move-dialog .menu { max-height: 50vh; overflow-y: auto; }

/* ---- auth ---- */
#app.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h1 { font-size: 24px; margin: 8px 0 6px; }
.auth-logo { font-size: 44px; }
.auth-error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---- share & print ---- */
.share-mode #main { height: 100vh; }
body.export { max-width: 900px; margin: 40px auto; padding: 0 24px; }
body.export .page-inner { padding: 0; }
@media print {
  #sidebar, .topbar, .page-controls, .gutter, .page-meta, .db-toolbar, .editor-tail, .code-head, .comments-drawer, .banner, #toasts { display: none !important; }
  #app.shell, #main, .page-view, .page-scroll { height: auto; overflow: visible; display: block; }
  .page-inner { padding: 0; max-width: none; }
}

/* ---- mobile ---- */
@media (max-width: 760px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; box-shadow: var(--shadow); width: min(85vw, 300px); }
  #app.sb-hidden #sidebar { margin-left: calc(-1 * min(85vw, 300px) - 10px); }
  #app.shell:not(.sb-hidden) .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 49; }
  .sidebar-open { display: inline-flex !important; }
  .page-inner, .peek-view .page-inner { padding: 40px 16px 30vh 28px; }
  .page-title { font-size: 30px; }
  .gutter { left: -26px; }
  .g-add { display: none; }
  .block { margin-left: calc(var(--indent, 0) * 18px); }
  .rp-label { width: 120px; }
  .page-view.with-drawer .page-scroll { margin-right: 0; }
  .comments-drawer { width: 100%; }
  .modal-wrap { padding-top: 16px; }
  .modal.peek { height: 92vh; }
  .settings { flex-direction: column; }
  .settings-nav { width: auto; flex-direction: row; overflow-x: auto; }
  .history { flex-direction: column; height: auto; }
  .history-list { width: auto; max-height: 30vh; border-right: 0; }
  .history-preview { padding-left: 0; }
  .crumb { max-width: 110px; }
  .db-actions { flex-wrap: wrap; }
  .grid2 { grid-template-columns: 1fr; }
  .filter-row { flex-wrap: wrap; }
}

/* ---- inline & linked databases ---- */
.b-database > .body { display: block; }
.inline-db { flex: 1; min-width: 0; margin: 8px 0 4px; user-select: text; }
.idb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.idb-title { font-size: 1.25em; font-weight: 700; text-decoration: none; }
.idb-title-input { font-size: 1.25em; font-weight: 700; border: 0; background: none; outline: none; padding: 2px 0; flex: 1; min-width: 0; }
.idb-title-input::placeholder { color: var(--fg-faint); }
.idb-tag { font-size: 11px; color: var(--fg-muted); background: var(--bg-hover); border-radius: 4px; padding: 1px 6px; }
.idb-open { margin-left: auto; color: var(--fg-faint); text-decoration: none; border-radius: 4px; padding: 0 6px; opacity: 0; }
.inline-db:hover .idb-open { opacity: 1; }
.idb-open:hover { background: var(--bg-hover); color: var(--fg); }
.inline-db .dbview { margin-top: 0; }
.split-btn { display: inline-flex; }
.split-btn .btn:first-child { border-radius: 6px 0 0 6px; }
.split-btn .btn:last-child { border-radius: 0 6px 6px 0; border-left: 1px solid rgba(255,255,255,.35); padding-left: 6px; padding-right: 6px; }

/* ---- backlinks, templates ---- */
.backlinks { margin: -4px 0 10px; }
.backlinks-toggle { border: 0; background: none; color: var(--fg-muted); font-size: 13px; padding: 2px 6px; margin-left: -6px; border-radius: 4px; cursor: pointer; }
.backlinks-toggle:hover { background: var(--bg-hover); }
.backlinks-list { display: flex; flex-direction: column; padding: 2px 0 4px 8px; }
.backlink { font-size: 14px; text-decoration: none; padding: 2px 6px; border-radius: 4px; color: var(--fg-muted); width: fit-content; }
.backlink:hover { background: var(--bg-hover); color: var(--fg); text-decoration: underline; }
.banner.template { background: var(--bg-purple); }
.start-panel { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin: 8px 0 0; }
.start-panel > .muted { margin: 0 0 6px 6px; }
.start-panel .start-sub { margin: 10px 0 4px 6px; }
.start-item { display: inline-flex; gap: 8px; align-items: center; border: 0; background: none; color: var(--fg-muted); font-size: 14px; padding: 4px 6px; border-radius: 4px; cursor: pointer; }
.start-item:hover { background: var(--bg-hover); color: var(--fg); }
.start-item span { width: 20px; text-align: center; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tpl-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 8px; padding: 12px; cursor: pointer; }
.tpl-card:hover { background: var(--bg-hover); border-color: var(--accent); }
.tpl-icon { font-size: 26px; }
.tpl-card small { font-size: 12px; }
