/* ===== 主题变量（取自 Notion 的配色） ===== */
:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica,
    "PingFang SC", "Microsoft YaHei", "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --mono: "SFMono-Regular", Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;
  --bg: #ffffff;
  --bg-sidebar: #f8f8f7;
  --bg-hover: rgba(55, 53, 47, .06);
  --bg-active: rgba(55, 53, 47, .1);
  --bg-elevated: #ffffff;
  --bg-input: rgba(242, 241, 238, .6);
  --bg-code: #f7f6f3;
  --text: rgb(55, 53, 47);
  --text-2: rgba(55, 53, 47, .65);
  --text-3: rgba(55, 53, 47, .45);
  --text-sidebar: rgb(95, 94, 91);
  --border: rgba(55, 53, 47, .09);
  --border-strong: rgba(55, 53, 47, .16);
  --shadow: rgba(15, 15, 15, .05) 0 0 0 1px, rgba(15, 15, 15, .1) 0 3px 6px, rgba(15, 15, 15, .2) 0 9px 24px;
  --card-shadow: rgba(15, 15, 15, .1) 0 0 0 1px, rgba(15, 15, 15, .1) 0 2px 4px;
  --blue: #2383e2;
  --blue-hover: #0077d4;
  --select-bg: rgba(35, 131, 226, .14);
  --red: #eb5757;
  --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: rgba(244, 240, 247, .8); --bg-pink: rgba(249, 238, 243, .8); --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; --tag-text: rgb(50, 48, 44);
  --sidebar-w: 240px;
}
[data-theme="dark"] {
  --bg: #191919;
  --bg-sidebar: #202020;
  --bg-hover: rgba(255, 255, 255, .055);
  --bg-active: rgba(255, 255, 255, .1);
  --bg-elevated: #252525;
  --bg-input: rgba(255, 255, 255, .055);
  --bg-code: rgba(255, 255, 255, .03);
  --text: rgba(255, 255, 255, .81);
  --text-2: rgba(255, 255, 255, .46);
  --text-3: rgba(255, 255, 255, .28);
  --text-sidebar: rgba(255, 255, 255, .6);
  --border: rgba(255, 255, 255, .094);
  --border-strong: rgba(255, 255, 255, .15);
  --shadow: rgba(15, 15, 15, .1) 0 0 0 1px, rgba(15, 15, 15, .2) 0 3px 6px, rgba(15, 15, 15, .4) 0 9px 24px;
  --card-shadow: rgba(255, 255, 255, .094) 0 0 0 1px;
  --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: #4a3229; --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: rgba(90, 90, 90, .5); --tag-brown: #603b2c;
  --tag-orange: #854c1d; --tag-yellow: #89632a; --tag-green: #2b593f; --tag-blue: #28456c; --tag-purple: #492f64;
  --tag-pink: #69314c; --tag-red: #6e3630; --tag-text: rgba(255, 255, 255, .88);
  color-scheme: dark;
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: auto; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--select-bg); }
.scroller {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(55, 53, 47, 0.25) transparent;
}
[data-theme="dark"] .scroller {
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.scroller::-webkit-scrollbar,
.popover::-webkit-scrollbar,
.popover ::-webkit-scrollbar,
.menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.scroller::-webkit-scrollbar-thumb,
.popover::-webkit-scrollbar-thumb,
.popover ::-webkit-scrollbar-thumb,
.menu::-webkit-scrollbar-thumb {
  background: rgba(55, 53, 47, 0.22);
  border-radius: 4px;
}
.scroller::-webkit-scrollbar-thumb:hover,
.popover::-webkit-scrollbar-thumb:hover,
.popover ::-webkit-scrollbar-thumb:hover,
.menu::-webkit-scrollbar-thumb:hover {
  background: rgba(55, 53, 47, 0.38);
}
[data-theme="dark"] .scroller::-webkit-scrollbar-thumb,
[data-theme="dark"] .popover::-webkit-scrollbar-thumb,
[data-theme="dark"] .popover ::-webkit-scrollbar-thumb,
[data-theme="dark"] .menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}
[data-theme="dark"] .scroller::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .popover::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .popover ::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}
.scroller::-webkit-scrollbar-track,
.popover::-webkit-scrollbar-track,
.popover ::-webkit-scrollbar-track,
.menu::-webkit-scrollbar-track {
  background: transparent;
}
.icon {
  width: 16px; height: 16px; display: inline-block; flex-shrink: 0; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
}
.hidden { display: none !important; }

#app { display: flex; height: 100vh; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#content { flex: 1; position: relative; }

/* 通用小按钮 */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 4px; color: var(--text-3); flex-shrink: 0; transition: background .1s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-2); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 4px;
  color: var(--text-2); white-space: nowrap; transition: background .1s;
}
.btn:hover { background: var(--bg-hover); }
.btn.active { color: var(--blue); }
.btn-primary {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 4px;
  background: var(--blue); color: #fff; font-weight: 500; white-space: nowrap;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-danger { color: var(--red); border: 1px solid rgba(235, 87, 87, .5); height: 32px; padding: 0 12px; border-radius: 4px; }
.btn-danger:hover { background: rgba(235, 87, 87, .1); }
.input {
  width: 100%; height: 28px; padding: 0 8px; border-radius: 4px; border: 0; outline: 0;
  background: var(--bg-input); box-shadow: inset 0 0 0 1px var(--border-strong);
}
.input:focus { box-shadow: inset 0 0 0 1px rgba(35, 131, 226, .57), 0 0 0 2px rgba(35, 131, 226, .3); }
select.input { padding: 0 4px; }

/* ===== 侧栏 ===== */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-sidebar); color: var(--text-sidebar);
  display: flex; flex-direction: column; position: relative; border-right: 1px solid var(--border);
  transition: margin-left .2s ease; user-select: none;
}
#app.sidebar-collapsed #sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.sb-resize { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 5; }
.sb-resize:hover { box-shadow: inset -2px 0 0 var(--border-strong); }
.sb-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 14px; }
.sb-ws { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; }
.sb-ws-icon {
  width: 22px; height: 22px; border-radius: 4px; background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.sb-actions { padding: 0 4px 8px; }
.sb-item {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 10px; border-radius: 6px;
  margin: 1px 4px; cursor: pointer; font-weight: 500; white-space: nowrap; overflow: hidden;
}
.sb-item:hover { background: var(--bg-hover); }
.sb-item .icon { color: var(--text-3); width: 18px; height: 18px; }
.sb-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; }
.sb-section { margin-top: 10px; }
.sb-section-title {
  display: flex; align-items: center; justify-content: space-between; height: 26px; padding: 0 8px 0 14px;
  font-size: 12px; font-weight: 500; color: var(--text-3); margin: 0 4px; border-radius: 6px;
}
.sb-section-title .btn-icon { opacity: 0; }
.sb-section-title:hover .btn-icon { opacity: 1; }
.tree-row {
  display: flex; align-items: center; height: 30px; margin: 1px 4px; border-radius: 6px; cursor: pointer;
  padding-right: 4px; position: relative;
}
.tree-row:hover { background: var(--bg-hover); }
.tree-row.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.tree-row.drop-inside { box-shadow: inset 0 0 0 2px rgba(35, 131, 226, .5); background: var(--select-bg); }
.tree-row.drop-before::before, .tree-row.drop-after::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 2px; background: rgba(35, 131, 226, .6);
}
.tree-row.drop-before::before { top: -1px; }
.tree-row.drop-after::after { bottom: -1px; }
.tree-toggle {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 4px;
  color: var(--text-3); flex-shrink: 0; transition: transform .15s;
}
.tree-toggle:hover { background: var(--bg-active); }
.tree-toggle.open .icon { transform: rotate(90deg); }
.tree-icon { width: 22px; text-align: center; flex-shrink: 0; font-size: 15px; line-height: 1; }
.tree-icon .icon { color: var(--text-3); width: 17px; height: 17px; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.tree-acts { display: none; gap: 2px; }
.tree-row:hover .tree-acts { display: flex; }
.tree-empty { padding-left: 34px; height: 28px; line-height: 28px; color: var(--text-3); font-size: 13px; }
.sb-foot { border-top: 1px solid var(--border); padding: 6px 0; }

/* ===== 顶栏 ===== */
#topbar {
  height: 44px; display: flex; align-items: center; gap: 4px; padding: 0 12px; flex-shrink: 0;
  background: var(--bg); z-index: 3;
}
.crumbs { display: flex; align-items: center; min-width: 0; flex: 1; overflow: hidden; }
.crumb {
  text-decoration: none;
  display: flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.crumb:hover { background: var(--bg-hover); }
.crumb-sep { color: var(--text-3); margin: 0 2px; }
.save-state { color: var(--text-3); font-size: 13px; margin-right: 8px; white-space: nowrap; }
#app:not(.sidebar-collapsed) .only-collapsed { display: none; }

/* ===== 页面 ===== */
.page { padding-bottom: 30vh; }
.page-cover { height: 30vh; max-height: 280px; min-height: 120px; position: relative; background-size: cover; background-position: center; }
.page-cover .cover-acts {
  position: absolute; right: 12px; bottom: 12px; display: none; gap: 0; background: var(--bg-elevated);
  border-radius: 4px; box-shadow: var(--card-shadow); overflow: hidden;
}
.page-cover:hover .cover-acts { display: flex; }
.cover-acts .btn { border-radius: 0; height: 26px; font-size: 12px; }
.page-inner { max-width: 900px; margin: 0 auto; padding: 0 96px; }
.page.full-width .page-inner { max-width: none; }
.page-header { position: relative; padding-top: 80px; }
.page.has-cover .page-header { padding-top: 0; }
.page-icon {
  font-size: 78px; line-height: 1.1; height: 80px; width: 80px; display: flex; align-items: center;
  justify-content: center; border-radius: 4px; cursor: pointer; user-select: none; margin-bottom: 4px;
}
.page-icon:hover { background: var(--bg-hover); }
.page.has-cover .page-icon { margin-top: -42px; position: relative; z-index: 1; }
.page-icon img { width: 78px; height: 78px; }
.page-head-acts { display: flex; gap: 2px; height: 28px; margin-left: -8px; opacity: 0; transition: opacity .15s; margin-bottom: 4px; }
.page-header:hover .page-head-acts { opacity: 1; }
.page-head-acts .btn { color: var(--text-3); }
.page-title {
  font-size: 40px; font-weight: 700; line-height: 1.2; outline: none; padding: 3px 2px; margin-bottom: 8px;
  word-break: break-word; caret-color: var(--text);
}
.page-title:empty::before { content: attr(data-placeholder); color: var(--text-3); opacity: .6; }
.row-props { margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.row-prop { display: flex; align-items: flex-start; min-height: 34px; }
.row-prop-name {
  width: 160px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px;
  color: var(--text-2); border-radius: 4px; cursor: pointer; overflow: hidden; white-space: nowrap;
}
.row-prop-name:hover { background: var(--bg-hover); }
.row-prop-val { flex: 1; min-width: 0; min-height: 34px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; padding: 4px 8px; }
.row-prop-val:hover { background: var(--bg-hover); }
.row-prop-val.readonly { cursor: default; }
.row-prop-val.readonly:hover { background: none; }

/* ===== 块编辑器 ===== */
.editor { padding-top: 4px; font-size: 16px; line-height: 1.5; }
.block { position: relative; margin: 1px 0; }
.block-main { display: flex; align-items: flex-start; position: relative; border-radius: 3px; }
.block.selected > .block-main { background: var(--select-bg); }
.block-handle {
  position: absolute; left: -48px; top: 2px; display: flex; gap: 0; opacity: 0; transition: opacity .1s;
  height: 24px; align-items: center;
}
.block-main:hover > .block-handle, .block-handle.show { opacity: 1; }
.block-handle .btn-icon { width: 22px; height: 24px; color: var(--text-3); }
.block-handle .drag { cursor: grab; width: 18px; }
.rt {
  flex: 1; min-width: 0; outline: none; padding: 3px 2px; white-space: pre-wrap; word-break: break-word;
  caret-color: var(--text); min-height: 1.5em;
}
.rt:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.rt:not(:focus):empty::before { content: ""; }
.block[data-type="text"] .rt:focus:empty::before { content: "输入 “/” 唤起命令…"; }
.block-children { padding-left: 26px; }
.block.drop-before > .block-main::before, .block.drop-after > .block-main::after {
  content: ""; position: absolute; left: 0; right: 0; height: 4px; background: rgba(35, 131, 226, .4); z-index: 2;
}
.block.drop-before > .block-main::before { top: -3px; }
.block.drop-after > .block-main::after { bottom: -3px; }
.block.drop-inside > .block-main::after {
  content: ""; position: absolute; left: 26px; right: 0; height: 4px; background: rgba(35, 131, 226, .4); bottom: -3px;
}

/* 标题 */
.block[data-type="heading_1"] { margin-top: 1.4em; }
.block[data-type="heading_2"] { margin-top: 1.1em; }
.block[data-type="heading_3"] { margin-top: .9em; }
.block[data-type="heading_4"] { margin-top: .75em; }
.block[data-type="heading_1"] .rt { font-size: 1.875em; font-weight: 600; line-height: 1.3; }
.block[data-type="heading_2"] .rt { font-size: 1.5em; font-weight: 600; line-height: 1.3; }
.block[data-type="heading_3"] .rt { font-size: 1.25em; font-weight: 600; line-height: 1.3; }
.block[data-type="heading_4"] .rt { font-size: 1.1em; font-weight: 600; line-height: 1.3; }
.block[data-type^="heading"] > .block-main > .block-handle { top: calc(.15em + 4px); }
.block[data-type="heading_1"] > .block-main > .block-handle { top: 10px; }

/* 列表前缀 */
.block-prefix {
  width: 24px; flex-shrink: 0; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 3px; margin-right: 2px; user-select: none;
}
.bullet { font-size: 1.5em; line-height: 1; margin-top: -1px; }
.num { padding-top: 3px; line-height: 1.5; }
.block[data-type="numbered_list"] .block-prefix { padding-top: 0; }
.todo-box {
  width: 16px; height: 16px; border: 1.5px solid var(--text); border-radius: 2px; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.todo-box.checked { background: var(--blue); border-color: var(--blue); }
.todo-box.checked::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.block.checked > .block-main .rt { text-decoration: line-through; color: var(--text-3); }
.toggle-arrow { width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .15s; }
.toggle-arrow:hover { background: var(--bg-hover); }
.block.open > .block-main .toggle-arrow { transform: rotate(90deg); }
.block[data-type="toggle"]:not(.open) > .block-children { display: none; }
.toggle-empty { color: var(--text-3); padding: 3px 2px; cursor: pointer; font-size: 15px; }

/* 引用、提示 */
.block[data-type="quote"] .rt { border-left: 3px solid currentColor; padding-left: 14px; font-size: 1.05em; margin: 4px 0; }
.callout { display: flex; padding: 16px 16px 16px 12px; border-radius: 4px; background: var(--bg-gray); flex: 1; min-width: 0; }
.callout-icon { font-size: 21px; line-height: 1; width: 26px; height: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-right: 8px; flex-shrink: 0; }
.callout-icon:hover { background: var(--bg-active); }
.callout .rt { padding: 0 2px; }

/* 代码 */
.code-wrap { flex: 1; min-width: 0; background: var(--bg-code); border-radius: 4px; position: relative; margin: 4px 0; }
.code-bar { display: flex; justify-content: space-between; padding: 6px 8px 0; font-size: 12px; color: var(--text-3); opacity: 0; transition: opacity .1s; }
.code-wrap:hover .code-bar { opacity: 1; }
.code-bar select { background: none; border: 0; color: var(--text-3); font-size: 12px; cursor: pointer; outline: 0; }
.code-wrap .rt { font-family: var(--mono); font-size: 14px; line-height: 1.6; padding: 8px 32px 32px 32px; tab-size: 2; white-space: pre; overflow-x: auto; }

/* 分割线、图片、书签 */
.divider { flex: 1; height: 13px; display: flex; align-items: center; cursor: pointer; padding: 0 2px; }
.divider::after { content: ""; width: 100%; border-bottom: 1px solid var(--border-strong); }
.block.selected .divider::after { border-color: var(--blue); }
.image-wrap { flex: 1; min-width: 0; padding: 4px 0; }
.image-wrap img { max-width: 100%; border-radius: 3px; display: block; }
.image-wrap figcaption { color: var(--text-2); font-size: 14px; padding-top: 6px; outline: none; min-height: 1em; }
.image-empty {
  display: flex; align-items: center; gap: 10px; background: var(--bg-hover); padding: 12px 36px 12px 12px;
  border-radius: 4px; color: var(--text-2); cursor: pointer; flex: 1; font-size: 14px;
}
.image-empty:hover { background: var(--bg-active); }
.bookmark {
  flex: 1; min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--border-strong); border-radius: 4px;
  padding: 12px 14px; text-decoration: none; margin: 4px 0; font-size: 14px;
}
.bookmark:hover { background: var(--bg-hover); }
.bookmark .bm-url { color: var(--text-2); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.child-page { flex: 1; display: flex; align-items: center; gap: 6px; padding: 3px 2px; border-radius: 3px; cursor: pointer; text-decoration: none; }
.child-page:hover { background: var(--bg-hover); }
.child-page .t { font-weight: 500; border-bottom: 1px solid var(--border-strong); line-height: 1.3; }
.add-block-hint { color: var(--text-3); padding: 6px 2px; cursor: text; font-size: 16px; min-height: 80px; }

/* 行内样式 */
.rt b, .rt strong { font-weight: 600; }
.rt code, .inline-code {
  font-family: var(--mono); font-size: 85%; background: rgba(135, 131, 120, .15); color: #eb5757;
  border-radius: 4px; padding: .2em .4em;
}
.rt a, .rich a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 2px; cursor: pointer; }
.rt a:hover { text-decoration-color: var(--text); }
.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); }
.callout.bg-default { background: var(--bg-gray); }

/* ===== 弹出层 / 菜单 ===== */
.popover {
  position: fixed; z-index: 100; background: var(--bg-elevated); border-radius: 6px; box-shadow: var(--shadow);
  min-width: 180px; max-height: 70vh; overflow: auto; font-size: 14px; animation: pop .1s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.menu { padding: 6px 0; }
.menu-section { padding: 6px 14px 4px; font-size: 12px; color: var(--text-3); font-weight: 500; user-select: none; }
.menu-item {
  display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 10px; margin: 0 4px; border-radius: 4px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.menu-item.active, .menu-item:hover { background: var(--bg-hover); }
.menu-item .icon { color: var(--text-2); }
.menu-item .hint { margin-left: auto; color: var(--text-3); font-size: 12px; padding-left: 12px; }
.menu-item.danger:hover, .menu-item.danger.active { color: var(--red); }
.menu-item.danger:hover .icon { color: var(--red); }
.menu-item .check { margin-left: auto; color: var(--text); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-input { padding: 4px 10px 6px; }
.menu-empty { padding: 6px 14px; color: var(--text-3); }
.slash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  margin: 1px 0;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .08s ease;
}
/* Notion 风格 "/" 斜杠快捷菜单 */
.slash-menu {
  width: 250px;
  max-width: 260px;
  padding: 4px;
  max-height: 380px;
  overflow-y: auto;
  user-select: none;
}

.slash-item.active,
.slash-item:hover {
  background: rgba(55, 53, 47, 0.08);
}

[data-theme="dark"] .slash-item.active,
[data-theme="dark"] .slash-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.slash-badge {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
  overflow: hidden;
  box-sizing: border-box;
}

[data-theme="dark"] .slash-badge {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.slash-badge-text {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.slash-badge-text.slash-badge-h {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.slash-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slash-badge-icon svg {
  display: block;
}

.slash-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slash-hint {
  margin-left: auto;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  display: inline-flex;
  align-items: baseline;
  user-select: none;
  flex-shrink: 0;
}

.slash-hint .slash-prefix {
  color: var(--blue, #2383e2);
  font-weight: 500;
}

.slash-hint .slash-code {
  color: var(--text-3);
  font-weight: 400;
}

.slash-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  margin: 1px 0;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
  transition: background .08s ease;
}

.slash-action-item:hover,
.slash-action-item.active {
  background: rgba(55, 53, 47, 0.08);
}

[data-theme="dark"] .slash-action-item:hover,
[data-theme="dark"] .slash-action-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.slash-action-icon {
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}

.slash-action-arrow {
  margin-left: auto;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1;
}

.slash-section-label {
  padding: 6px 8px 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  user-select: none;
  letter-spacing: 0.2px;
}

/* Notion 风格 "@" 快捷日期时间菜单 */
.at-menu {
  width: 200px;
  min-width: 180px;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  user-select: none;
}
.at-menu-section {
  padding: 6px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  user-select: none;
  letter-spacing: 0.2px;
}
.at-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  margin: 1px 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  transition: background .08s ease;
}
.at-menu-item.active,
.at-menu-item:hover {
  background: rgba(55, 53, 47, 0.08);
}
[data-theme="dark"] .at-menu-item.active,
[data-theme="dark"] .at-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.at-menu-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}
.at-menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Notion 风格日期提及标签与弹窗 */
.date-mention {
  color: var(--text-2);
  background: rgba(55, 53, 47, 0.08);
  border-radius: 3px;
  padding: 1px 4px;
  margin: 0 1px;
  cursor: pointer;
  font-weight: normal;
  user-select: all;
  display: inline-block;
  line-height: 1.3;
  vertical-align: baseline;
  transition: background .12s, color .12s;
}
.date-mention:hover {
  background: rgba(55, 53, 47, 0.16);
  color: var(--text);
}
[data-theme="dark"] .date-mention {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .date-mention:hover {
  background: rgba(255, 255, 255, 0.16);
}

.date-popover {
  width: 254px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  font-size: 14px;
  user-select: none;
  animation: pop .1s ease-out;
}
.date-popover-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1.5px solid var(--blue);
  box-sizing: border-box;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  margin-bottom: 10px;
}
.date-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}
.date-popover-month-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.date-popover-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 12px;
}
.date-popover-dow {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}
.date-popover-day {
  height: 28px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  padding: 0;
  transition: background .08s;
}
.date-popover-day:hover:not(.selected) {
  background: var(--bg-hover);
}
.date-popover-day.other {
  color: var(--text-3);
  opacity: 0.6;
}
.date-popover-day.today:not(.selected) {
  font-weight: 600;
  color: var(--blue);
}
.date-popover-day.selected {
  background: var(--blue) !important;
  color: #ffffff !important;
  font-weight: 600;
}
.date-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2px;
  font-size: 13px;
  color: var(--text);
  min-height: 30px;
}
.date-popover-select {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
  text-align: right;
}
.date-popover-select:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.date-popover-clear {
  padding: 6px 4px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 4px;
  transition: background .08s, color .08s;
}
.date-popover-clear:hover {
  color: var(--red);
  background: var(--bg-hover);
}

/* iOS 风格平滑切换开关 */
.ndp-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.ndp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.ndp-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--text-3);
  border-radius: 20px;
  transition: .15s ease;
}
.ndp-slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: .15s ease;
}
.ndp-switch input:checked + .ndp-slider {
  background-color: var(--blue);
}
.ndp-switch input:checked + .ndp-slider::before {
  transform: translateX(14px);
}

.color-dot { width: 20px; height: 20px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-weight: 500; border: 1px solid var(--border); }

/* 浮动工具栏 */
.format-bar {
  position: fixed; z-index: 90; display: flex; background: var(--bg-elevated); box-shadow: var(--shadow);
  border-radius: 6px; padding: 2px; height: 34px; align-items: center; animation: pop .1s ease-out;
}
.format-bar button { height: 28px; min-width: 28px; padding: 0 6px; border-radius: 4px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.format-bar button:hover { background: var(--bg-hover); }
.format-bar button.on { color: var(--blue); }
.format-bar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 4px 2px; }

/* emoji 选择器已迁移至 icon-picker.css */

/* 模态框 */
.overlay { position: fixed; inset: 0; background: rgba(15, 15, 15, .5); z-index: 80; display: flex; justify-content: center; align-items: flex-start; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--bg-elevated); border-radius: 10px; box-shadow: var(--shadow); margin-top: 12vh;
  width: 620px; max-width: calc(100vw - 32px); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
}
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--border); }
.search-box input { flex: 1; border: 0; outline: 0; background: none; font-size: 17px; }
.search-results { overflow-y: auto; padding: 6px 0; }
.search-hit { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; margin: 0 6px; border-radius: 6px; cursor: pointer; }
.search-hit.active { background: var(--bg-hover); }
.search-hit .ic { width: 22px; text-align: center; font-size: 17px; }
.search-hit .t { font-weight: 500; }
.search-hit .p { font-size: 12px; color: var(--text-3); }
.search-hit .s { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.search-hit mark { background: none; color: inherit; font-weight: 600; text-decoration: underline; }

/* 侧边预览（打开数据库行） */
.peek-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(15, 15, 15, .2); animation: fade .15s; }
.peek {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 90vw); background: var(--bg); z-index: 71;
  box-shadow: rgba(15, 15, 15, .1) 0 0 0 1px, rgba(15, 15, 15, .2) 0 5px 30px; display: flex; flex-direction: column;
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.peek-bar { height: 44px; display: flex; align-items: center; gap: 4px; padding: 0 12px; flex-shrink: 0; }
.peek .page-inner { padding: 0 64px; }
.peek .page-header { padding-top: 24px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #2f2f2f; color: #fff;
  padding: 8px 14px; border-radius: 6px; z-index: 200; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 12px; align-items: center;
}
.toast button { color: #8ab4f8; }

/* 空状态 / 首页 */
.empty-state { max-width: 560px; margin: 18vh auto 0; text-align: center; color: var(--text-2); }
.empty-state h1 { font-size: 28px; color: var(--text); }
.trash-list .menu-item { min-height: 32px; }

/* ===== 数据库通用 ===== */
.db { margin: 8px 0 12px; font-size: 14px; line-height: 1.5; }
.db-full { padding: 0 96px; }
.db-full .db-title { font-size: 40px; font-weight: 700; margin: 0 0 8px; }
.db-head { display: flex; align-items: center; min-height: 42px; border-bottom: 1px solid var(--border); gap: 4px; margin-bottom: 0; }
.db-title { font-size: 20px; font-weight: 600; outline: none; padding: 3px 2px; min-width: 40px; }
.db-title:empty::before { content: "无标题"; color: var(--text-3); }
.db-inline-titlebar { display: flex; align-items: center; gap: 4px; margin-top: 12px; }
.view-tabs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; height: 42px; }
.view-tab {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 4px; color: var(--text-2);
  cursor: pointer; white-space: nowrap; position: relative; flex-shrink: 0; font-weight: 500;
}
.view-tab:hover { background: var(--bg-hover); }
.view-tab.active { color: var(--text); }
.view-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 2px; background: var(--text); }
.view-tab .icon { color: inherit; }
.db-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.db-tools .btn { height: 28px; font-size: 14px; }
.db-tools .btn .icon { color: var(--text-3); }
.db-tools .btn.active .icon { color: var(--blue); }
.db-new-btn { display: flex; align-items: stretch; border-radius: 4px; overflow: hidden; margin-left: 6px; }
.db-filterbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 32px;
  border: 1px solid rgba(35, 131, 226, .35); background: rgba(35, 131, 226, .07); color: var(--blue); font-size: 13px;
  cursor: pointer; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { background: rgba(35, 131, 226, .14); }
.chip.ghost { border-color: transparent; background: none; color: var(--text-3); }
.chip.ghost:hover { background: var(--bg-hover); }
.db-search { width: 0; transition: width .2s; border: 0; outline: 0; background: none; padding: 0; }
.db-search.open { width: 150px; padding: 0 4px; }

/* 标签（select / multi_select 的选项） */
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 3px; font-size: 14px;
  line-height: 120%; white-space: nowrap; color: var(--tag-text); background: var(--tag-default); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; flex-shrink: 0;
}
.tag .x { margin-left: 4px; opacity: .5; cursor: pointer; display: inline-flex; }
.tag .x:hover { opacity: 1; }
.tag-gray { background: var(--tag-gray); } .tag-brown { background: var(--tag-brown); } .tag-orange { background: var(--tag-orange); }
.tag-yellow { background: var(--tag-yellow); } .tag-green { background: var(--tag-green); } .tag-blue { background: var(--tag-blue); }
.tag-purple { background: var(--tag-purple); } .tag-pink { background: var(--tag-pink); } .tag-red { background: var(--tag-red); }
.tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; min-width: 0; }
.cell-check { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; margin: 0; }
.prop-empty { color: var(--text-3); }
.url-val { text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 2px; word-break: break-all; }

/* ===== 表格视图 ===== */
.tbl-wrap { overflow-x: auto; position: relative; padding-bottom: 4px; }
.tbl { display: table; border-collapse: collapse; min-width: 100%; }
.tbl-row { display: flex; border-bottom: 1px solid var(--border); position: relative; }
.tbl-head { color: var(--text-2); border-top: 0; }
.tbl-head .tbl-cell { cursor: pointer; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; user-select: none; font-size: 14px; }
.tbl-head .tbl-cell:hover { background: var(--bg-hover); }
.tbl-head .tbl-cell .icon { color: var(--text-3); }
.tbl-cell {
  border-right: 1px solid var(--border); flex-shrink: 0; position: relative; min-height: 34px; overflow: hidden;
}
.tbl-cell:last-child { border-right: 0; }
.tbl-cell .col-resize { position: absolute; right: -1px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.tbl-cell .col-resize:hover, .tbl-cell .col-resize.dragging { background: rgba(35, 131, 226, .5); width: 3px; }
.tbl-body .tbl-cell { padding: 6px 8px; cursor: default; display: flex; align-items: flex-start; }
.tbl-body .tbl-cell.editable:hover { background: var(--bg-hover); }
.tbl-body .tbl-cell.focused { box-shadow: inset 0 0 0 2px rgba(35, 131, 226, .57); background: rgba(35, 131, 226, .04); }
.tbl-body .tbl-cell .cell-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tbl.wrap .tbl-body .tbl-cell .cell-text { white-space: pre-wrap; word-break: break-word; }
.tbl-body .tbl-cell .tags { flex-wrap: nowrap; overflow: hidden; }
.tbl.wrap .tbl-body .tbl-cell .tags { flex-wrap: wrap; }
.tbl-title-cell { font-weight: 500; }
.tbl-title-cell .row-icon { margin-right: 6px; }
.open-btn {
  position: absolute; right: 6px; top: 5px; display: none; align-items: center; gap: 4px; height: 24px; padding: 0 6px;
  border-radius: 4px; background: var(--bg-elevated); box-shadow: var(--card-shadow); font-size: 12px; color: var(--text-2);
  font-weight: 500; text-transform: uppercase; letter-spacing: .3px;
}
.tbl-row:hover .open-btn { display: inline-flex; }
.open-btn:hover { background: var(--bg-hover); }
.tbl-row-handle {
  position: absolute; left: -48px; top: 5px; width: 46px; display: flex; justify-content: flex-end; opacity: 0;
}
.tbl-body .tbl-row:hover .tbl-row-handle, .tbl-row.selected .tbl-row-handle { opacity: 1; }
.tbl-row.selected { background: var(--select-bg); }
.tbl-row-handle input { margin: 4px 6px 0 0; accent-color: var(--blue); }
.tbl-add-col { width: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.tbl-add-row {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; color: var(--text-3); cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.tbl-add-row:hover { background: var(--bg-hover); }
.tbl-calc { display: flex; color: var(--text-3); font-size: 12px; height: 32px; align-items: center; }
.tbl-calc > div { flex-shrink: 0; padding: 0 8px; text-align: right; }
.tbl-row.drop-before { box-shadow: 0 -2px 0 rgba(35, 131, 226, .6); }
.tbl-row.drop-after { box-shadow: 0 2px 0 rgba(35, 131, 226, .6); }
.cell-editor {
  position: fixed; z-index: 95; background: var(--bg-elevated); box-shadow: var(--shadow); border-radius: 4px;
  font-size: 14px; line-height: 1.5;
}
.cell-editor textarea, .cell-editor input.ce {
  width: 100%; border: 0; outline: 0; background: none; resize: none; padding: 6px 8px; display: block; min-height: 34px;
}
.group-head { display: flex; align-items: center; gap: 8px; height: 42px; margin-top: 16px; cursor: pointer; user-select: none; }
.group-head .cnt { color: var(--text-3); }
.group-head .tree-toggle.open .icon { transform: rotate(90deg); }

/* ===== 看板视图 ===== */
.board { display: flex; gap: 12px; overflow-x: auto; padding: 12px 0 16px; align-items: flex-start; min-height: 200px; }
.board-col { width: 260px; flex-shrink: 0; border-radius: 6px; padding: 0 6px 6px; }
.board-col.drag-over { background: var(--bg-hover); }
.board-col-head { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 2px; }
.board-col-head .cnt { color: var(--text-3); }
.board-col-head .acts { margin-left: auto; display: flex; opacity: 0; }
.board-col:hover .board-col-head .acts { opacity: 1; }
.board-cards { display: flex; flex-direction: column; gap: 8px; min-height: 10px; }
.card {
  background: var(--bg); border-radius: 6px; box-shadow: var(--card-shadow); cursor: pointer; overflow: hidden;
  position: relative; transition: background .1s;
}
[data-theme="dark"] .card { background: #252525; }
.card:hover { background: var(--bg-hover); }
[data-theme="dark"] .card:hover { background: #2c2c2c; }
.card.dragging { opacity: .4; }
.card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-weight: 500; word-break: break-word; line-height: 1.4; }
.card-prop { font-size: 12px; color: var(--text-2); display: flex; min-width: 0; }
.card-prop .tag { font-size: 12px; height: 18px; }
.card-cover { height: 120px; background: var(--bg-hover) center/cover; }
.card-acts { position: absolute; top: 6px; right: 6px; display: none; gap: 2px; background: var(--bg-elevated); border-radius: 4px; box-shadow: var(--card-shadow); }
.card:hover .card-acts { display: flex; }
.card-drop-line { height: 3px; background: rgba(35, 131, 226, .6); border-radius: 2px; margin: -5px 0; }
.board-add { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; color: var(--text-3); border-radius: 4px; cursor: pointer; margin-top: 4px; }
.board-add:hover { background: var(--bg-hover); }
.board-hidden { width: 220px; flex-shrink: 0; color: var(--text-3); }
.board-hidden .menu-item { color: var(--text-2); }
.card-title-input { border: 0; outline: 0; background: none; width: 100%; font-weight: 500; padding: 0; }

/* ===== 日历视图 ===== */
.cal-head { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.cal-head .month { font-weight: 600; font-size: 14px; margin-right: auto; }
.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(--text-3); text-align: center; height: 28px; line-height: 28px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-day {
  min-height: 116px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; position: relative;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.cal-day.other { background: var(--bg-sidebar); }
.cal-day.other .cal-num { color: var(--text-3); }
.cal-day.weekend { background: rgba(55, 53, 47, .02); }
.cal-day.drag-over { background: var(--select-bg); }
.cal-num { text-align: right; font-size: 14px; height: 24px; line-height: 24px; padding-right: 4px; }
.cal-day.today .cal-num span { background: var(--red); color: #fff; border-radius: 50%; display: inline-block; width: 24px; text-align: center; }
.cal-add { position: absolute; left: 4px; top: 4px; opacity: 0; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-ev {
  background: var(--bg); box-shadow: var(--card-shadow); border-radius: 4px; padding: 3px 6px; font-size: 12px; font-weight: 500;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="dark"] .cal-ev { background: #2c2c2c; }
.cal-ev:hover { background: var(--bg-hover); }
.cal-ev .sub { font-weight: 400; color: var(--text-2); display: block; }
.cal-nodate { margin-top: 12px; color: var(--text-3); font-size: 13px; }

/* ===== 画廊视图 ===== */
.gallery { display: grid; gap: 16px; padding: 16px 0; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.gallery.large { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.gallery .card-cover { height: 140px; display: flex; align-items: flex-start; padding: 12px 14px; overflow: hidden; font-size: 10px; color: var(--text-3); line-height: 1.5; border-bottom: 1px solid var(--border); background-color: var(--bg); }
.gallery .card-cover.preview { background-color: var(--bg-sidebar); }
.gallery .card-cover .big-icon { font-size: 54px; margin: auto; }
.gallery-add { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); border-radius: 6px; min-height: 120px; cursor: pointer; }
.gallery-add:hover { background: var(--bg-hover); }

/* ===== 列表视图 ===== */
.list-view { padding: 6px 0; }
.list-row { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 6px; border-radius: 4px; cursor: pointer; border-bottom: 1px solid var(--border); }
.list-row:hover { background: var(--bg-hover); }
.list-row .t { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .props { display: flex; gap: 10px; color: var(--text-2); font-size: 12px; }

/* 日期选择器 */
.datepicker { width: 250px; padding: 8px; user-select: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; font-weight: 500; padding: 4px 4px 8px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 1px; }
.dp-grid .dow { font-size: 12px; color: var(--text-3); height: 28px; line-height: 28px; }
.dp-grid button { height: 30px; border-radius: 4px; font-size: 13px; }
.dp-grid button:hover { background: var(--bg-hover); }
.dp-grid button.other { color: var(--text-3); }
.dp-grid button.today { color: var(--red); font-weight: 600; }
.dp-grid button.sel { background: var(--blue); color: #fff; }
.dp-grid button.range { background: var(--select-bg); }

/* 属性编辑弹层 */
.prop-panel { width: 260px; padding: 6px 0; }
.prop-panel .row { padding: 4px 12px; }
.opt-row { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; margin: 0 4px; border-radius: 4px; cursor: pointer; }
.opt-row:hover, .opt-row.active { background: var(--bg-hover); }
.opt-row .grip { color: var(--text-3); cursor: grab; display: inline-flex; }
.opt-row .more { margin-left: auto; opacity: 0; }
.opt-row:hover .more { opacity: 1; }
.select-editor { width: 300px; }
.select-editor .se-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; background: var(--bg-input); border-bottom: 1px solid var(--border); align-items: center; }
.select-editor .se-input input { flex: 1; min-width: 60px; border: 0; outline: 0; background: none; padding: 0; }
.filter-row { display: flex; align-items: center; gap: 6px; padding: 4px 10px; }
.filter-row select, .filter-row input { height: 28px; }
.filter-panel { min-width: 420px; padding: 6px 0; }
.sort-panel { min-width: 340px; padding: 6px 0; }

@media (max-width: 800px) {
  .page-inner, .db-full { padding: 0 20px; }
  :root { --sidebar-w: 220px; }
}

/* 页面设置：外观仅作用于文档，菜单保持系统字体。 */
@font-face {
  font-family: 'Canger Huaxin';
  src: url('/static/fonts/canger-huaxinti.woff2') format('woff2'), url('/static/fonts/canger-huaxinti.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
.page[data-font="canger"] .page-title, .page[data-font="canger"] .editor, .font-preview[data-font="canger"] { font-family: 'Canger Huaxin', var(--font); }
.page[data-font="serif"] .page-title, .page[data-font="serif"] .editor, .font-preview[data-font="serif"] { font-family: 'Songti SC', SimSun, serif; }
.page[data-layout="compact"] .editor { line-height: 1.4; }
.page[data-layout="compact"] .block { margin-top: 0; margin-bottom: 0; }
.page[data-layout="compact"] .rt { padding-top: 1px; padding-bottom: 1px; }
.page[data-layout="wide"] .editor { line-height: 1.8; }
.page[data-layout="wide"] .block { margin-top: 5px; margin-bottom: 5px; }
.page.small-text .editor { font-size: 14px; }
.page.small-text .page-title { font-size: 32px; }
.page-toc { margin: 20px 0 24px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; font-family: var(--font); }
.page-toc[hidden] { display: none; }
.toc-title { font-size: 12px; color: var(--text-2); margin: 0 8px 8px; }
.toc-link { display: block; width: 100%; text-align: left; padding: 5px 8px; color: var(--text-2); border-radius: 4px; overflow-wrap: anywhere; }
.toc-link:hover { background: var(--bg-hover); color: var(--text); }
.toc-empty { color: var(--text-2); font-size: 13px; margin: 8px; }
.page-settings { width: min(280px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; padding: 10px; font-family: var(--font); }
.page-settings hr { border: 0; border-top: 1px solid var(--border); margin: 10px 4px; }
.settings-toggle, .settings-action { display: flex; align-items: center; width: 100%; gap: 10px; padding: 8px; border-radius: 5px; text-align: left; min-height: 34px; }
.settings-toggle { justify-content: space-between; }
.settings-toggle:hover, .settings-action:hover { background: var(--bg-hover); }
.settings-action.danger { color: var(--red); }
.settings-switch { width: 30px; height: 18px; border-radius: 20px; background: var(--text-3); padding: 2px; flex-shrink: 0; }
.settings-switch::after { content: ''; display: block; width: 14px; height: 14px; background: white; border-radius: 50%; box-shadow: 0 1px 3px #0003; }
[aria-checked="true"] .settings-switch { background: var(--blue); }
[aria-checked="true"] .settings-switch::after { transform: translateX(12px); }
.settings-label { font-size: 12px; color: var(--text-2); margin: 15px 8px 9px; }
.settings-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0 8px 12px; }
.settings-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 64px; padding: 5px 1px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 12px; color: var(--text-2); }
.settings-choice[aria-pressed="true"] { border-color: var(--blue); background: var(--select-bg); color: var(--blue); }
.font-preview { font-size: 17px; color: var(--text); }
.layout-preview { display: grid; gap: 3px; width: 20px; height: 27px; border: 1px solid var(--border-strong); padding: 4px 3px; }
.layout-preview i { background: var(--text-2); height: 2px; }
.layout-preview i:first-child { height: 5px; }
.layout-preview[data-layout="compact"] { gap: 1px; }
.layout-preview[data-layout="wide"] { gap: 5px; }
.page-info { display: grid; grid-template-columns: auto 1fr; gap: 9px 12px; border-top: 1px solid var(--border); padding: 14px 8px 0; font-size: 12px; }
.page-info dt { color: var(--text-2); }
.page-info dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.settings-note { font-size: 11px; line-height: 1.6; color: var(--text-2); margin: 8px; }
.page-settings button:focus-visible, .toc-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.page-settings button:disabled { opacity: .6; cursor: wait; }
@media (max-width: 600px) { .peek .page-inner { padding: 0 24px; } }

/* 图片仅在选中后展示调整工具，尺寸始终受正文宽度约束。 */
.image-wrap { position: relative; }
.image-frame { position: relative; width: fit-content; max-width: 100%; }
.image-frame img { width: 100%; height: auto; user-select: none; cursor: pointer; }
.image-wrap[data-align="center"] .image-frame { margin-left: auto; margin-right: auto; }
.image-wrap[data-align="right"] .image-frame { margin-left: auto; margin-right: 0; }
.image-wrap[data-align="center"] figcaption { text-align: center; }
.image-wrap[data-align="right"] figcaption { text-align: right; }
.image-toolbar { display: none; position: absolute; top: 10px; right: 6px; z-index: 4; padding: 3px; gap: 2px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--card-shadow); }
.image-toolbar .btn { font-size: 12px; padding: 4px 7px; }
.image-toolbar [aria-pressed="true"] { color: var(--blue); background: var(--select-bg); }
.image-resize { display: none; position: absolute; top: 50%; transform: translateY(-50%); width: 20px; height: 44px; padding: 0; cursor: ew-resize; touch-action: none; z-index: 3; }
.image-resize::after { content: ''; display: block; width: 5px; height: 28px; margin: auto; border: 1px solid white; border-radius: 4px; background: var(--blue); box-shadow: 0 0 2px #0005; }
.image-resize-left { left: -10px; }
.image-resize-right { right: -10px; }
.block[data-type="image"].selected > .block-main .image-toolbar { display: flex; }
.block[data-type="image"].selected > .block-main .image-resize { display: block; }
.block[data-type="image"].selected > .block-main .image-frame { outline: 2px solid var(--blue); outline-offset: 1px; }
.image-toolbar button:focus-visible, .image-resize:focus-visible, .image-frame img:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.image-wrap figcaption.rt:empty::before { content: none; }
.block[data-type="image"].selected > .block-main .image-wrap figcaption.rt:empty::before { content: attr(data-placeholder); color: var(--text-2); }
.image-wrap figcaption.rt { padding: 6px 0 0; }

/* 页面设置二级菜单 */
.settings-submenu-trigger { position: relative; }
.settings-submenu-trigger .submenu-chevron { margin-left: auto; color: var(--text-3); width: 14px; height: 14px; }
.page-settings-submenu {
  width: 160px; padding: 6px; background: var(--bg-elevated); border-radius: 8px;
  box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px;
}
.page-settings-submenu .settings-action { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 4px; }
.page-settings-submenu .settings-action:hover { background: var(--bg-hover); }
.page-settings-submenu .settings-action .icon { width: 16px; height: 16px; }

/* 导出模态框 */
.export-overlay {
  position: fixed; inset: 0; background: rgba(15, 15, 15, .4); z-index: 1000;
  display: flex; justify-content: center; align-items: center; animation: fade .12s ease-out;
}
.export-modal {
  background: var(--bg-elevated); border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .16), 0 2px 8px rgba(0, 0, 0, .08);
  border: 1px solid var(--border); width: 330px; max-width: calc(100vw - 32px);
  padding: 24px; margin: 0; display: flex; flex-direction: column; overflow: visible;
}
.export-row {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 38px; margin-bottom: 8px;
}
.export-label { font-size: 14px; color: var(--text-2); }
.export-select-wrap { position: relative; display: inline-flex; align-items: center; }
.export-select {
  appearance: none; -webkit-appearance: none; background: transparent; border: none;
  font-size: 14px; font-weight: 500; color: var(--text); padding: 4px 20px 4px 8px;
  cursor: pointer; text-align: right; direction: rtl; outline: none; border-radius: 4px;
}
.export-select:hover { background: var(--bg-hover); }
.export-select:focus-visible { outline: 2px solid var(--blue); }
.export-select option { direction: ltr; background: var(--bg-elevated); color: var(--text); }
.export-arrow {
  position: absolute; right: 4px; pointer-events: none; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--text-3);
}
.export-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.export-btn { padding: 6px 18px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all .12s; }
.export-btn-cancel { border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); }
.export-btn-cancel:hover { background: var(--bg-hover); }
.export-btn-submit { border: none; background: var(--blue); color: #fff; }
.export-btn-submit:hover { filter: brightness(.92); }
.export-hint { font-size: 12px; color: var(--text-2); line-height: 1.5; padding: 10px 0 2px; }

/* 打印与导出 PDF 样式 */
@media print {
  #app .sidebar,
  .topbar,
  .crumbs,
  .block-handle,
  .block-adder,
  .popover,
  .modal,
  .overlay,
  .toast,
  .page-toc,
  .image-toolbar,
  .image-resize,
  .format-bar,
  .at-menu,
  .slash-menu,
  .editor-tail,
  .tail-hint,
  .settings-note,
  .btn-icon {
    display: none !important;
  }

  html, body, #app, .app, .main {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #111 !important;
    overflow: visible !important;
    height: auto !important;
    width: 100% !important;
  }

  .page-wrap {
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  .page-inner {
    max-width: 100% !important;
    padding: 0 16px !important;
    margin: 0 auto !important;
  }

  .page-title {
    color: #111 !important;
    font-size: 32px !important;
    line-height: 1.3 !important;
    margin-bottom: 16px !important;
  }

  .block,
  .block[data-type="image"],
  .block[data-type="code"],
  .block[data-type="callout"],
  .block[data-type="quote"],
  .block[data-type="table"],
  .db-table-wrap {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  [data-placeholder]::before {
    display: none !important;
  }
}
