/* ============ Geek Notes ============ */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --bg-hover: #efefec;
  --panel: #fbfbfa;
  --line: #e7e7e3;
  --line-strong: #d4d4cf;
  --text: #1f2328;
  --text-2: #57606a;
  --muted: #8b949e;
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.08);
  --radius: 10px;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, 'SF Mono', Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --side-w: 400px;
}
[data-theme='dark'] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-hover: #1f262e;
  --panel: #10151c;
  --line: #262d36;
  --line-strong: #353d48;
  --text: #e6edf3;
  --text-2: #9da7b3;
  --muted: #6e7681;
  --accent: #3fb950;
  --accent-soft: rgba(63, 185, 80, 0.14);
  --danger: #f85149;
  --code-bg: #161b22;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--bg); cursor: pointer; font-size: 13px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary kbd { background: transparent; color: inherit; border-color: currentColor; opacity: .6; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost.danger { color: var(--danger); }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.sm { width: 22px; height: 22px; font-size: 13px; }

/* ---------- login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
}
.login-box {
  width: 100%; max-width: 380px; padding: 32px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-hover);
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { font: 700 24px var(--mono); }
.prompt { color: var(--accent); }
.login-line { color: var(--muted); font-size: 13px; }
.login-label { font-size: 13px; color: var(--text-2); }
.login-box input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg-soft); font-family: var(--mono); outline: none;
}
.login-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-box .btn { height: 40px; justify-content: center; }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--side-w); flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.logo { font: 700 18px var(--mono); letter-spacing: -.5px; }
.cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.search { position: relative; margin: 6px 12px 10px; }
.search input {
  width: 100%; height: 34px; padding: 0 64px 0 28px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { position: absolute; left: 11px; top: 6px; color: var(--accent); font-weight: 700; }
.search-kbd { position: absolute; right: 8px; top: 8px; }
.tree-wrap { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.tree-root {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; font-size: 14px; color: var(--text-2);
}
.tree-root:hover { background: var(--bg-hover); color: var(--text); }
.tree-root.active { background: var(--accent-soft); color: var(--text); }
.tree-root .mono { color: var(--accent); width: 22px; }
.count { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.tree-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 8px 4px; font-size: 11px; letter-spacing: 1px; color: var(--muted);
}
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 13px; border-left: 1px dashed var(--line-strong); padding-left: 4px; }
.tree li.collapsed > ul { display: none; }
.node {
  position: relative; display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text-2);
  user-select: none;
}
.node:hover { background: var(--bg-hover); color: var(--text); }
.node.active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.node.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.node.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.node .caret {
  display: inline-block; width: 16px; flex: none; text-align: center; font: 10px var(--mono); color: var(--muted); transition: transform .15s;
}
.node .caret.noc { visibility: hidden; }
li:not(.collapsed) > .node .caret:not(.noc) { transform: rotate(90deg); }
.node .ico { width: 18px; flex: none; text-align: center; font-size: 13px; }
.node .ico.lv { font: 11px var(--mono); color: var(--accent); }
.node .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .ops { display: none; gap: 0; }
.node:hover .ops { display: flex; }
.node:hover .count { display: none; }
.node .ops button {
  width: 20px; height: 20px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0;
}
.node .ops button:hover { background: var(--line); color: var(--text); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px;
  background: var(--bg-soft); border: 1px solid var(--line); font: 12px var(--mono); color: var(--text-2); cursor: pointer;
}
.tag:hover, .tag.active { border-color: var(--accent); color: var(--accent); }
.tag small { margin-left: 4px; color: var(--muted); }
.side-foot { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-top: 1px solid var(--line); }
.side-foot .small { margin-left: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 110px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 54px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.crumbs { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--muted); margin: 0 6px; }
.crumbs .cur { color: var(--text); }
.top-actions { display: flex; gap: 8px; }

/* ---------- list / masonry ---------- */
.list-view { flex: 1; overflow-y: auto; padding: 20px 24px 60px; }
.list-info { font-size: 12px; margin-bottom: 12px; }
.subcats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.subcat {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; background: var(--bg-soft); cursor: pointer;
}
.subcat:hover { border-color: var(--accent); }
.subcat .count { margin-left: 4px; }
.masonry { display: flex; gap: 16px; align-items: flex-start; }
.masonry .col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.card {
  display: block; margin: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.card-cover { display: block; width: 100%; max-height: 260px; object-fit: cover; background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px 12px; }
.card-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; line-height: 1.45; word-break: break-word; }
.card-title .pin { color: var(--accent); font-size: 12px; margin-right: 4px; }
.card-excerpt {
  margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.65; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden;
}
.card-excerpt mark, .doc mark.hl { background: rgba(250, 204, 21, .35); color: inherit; border-radius: 2px; padding: 0 1px; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font: 11px var(--mono); color: var(--muted); }
.kind { padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; }
.card-foot .tag { height: 18px; font-size: 11px; padding: 0 6px; }
.card-foot .when { margin-left: auto; }
.card-path { font: 11px var(--mono); color: var(--accent); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty {
  padding: 60px 20px; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 13px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.empty .big { font-size: 28px; color: var(--accent); margin-bottom: 8px; }
.list-more { text-align: center; padding: 12px; }
.skeleton { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--bg-soft), var(--bg-hover), var(--bg-soft)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- document ---------- */
.doc-view { flex: 1; overflow-y: auto; }
.doc-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.doc-toolbar-right { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.doc-layout { display: flex; justify-content: center; gap: 40px; padding: 32px 24px 120px; }
.doc { width: 100%; max-width: 820px; min-width: 0; }
.outline {
  width: 200px; flex: none; position: sticky; top: 72px; align-self: flex-start; max-height: calc(100vh - 120px); overflow-y: auto;
  font-size: 12px; border-left: 1px solid var(--line); padding-left: 12px;
}
.outline:empty { display: none; }
.outline .ol-title { font: 11px var(--mono); letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.outline a { display: block; padding: 3px 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outline a:hover { color: var(--accent); }
.outline a.l3 { padding-left: 12px; }
.outline a.l4 { padding-left: 24px; }
.doc-meta-edit { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-meta-edit select, .doc-meta-edit input {
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-soft); font-size: 13px; outline: none;
}
.doc-meta-edit select { max-width: 320px; }
.doc-meta-edit input { flex: 1; min-width: 200px; }
.doc-meta-edit :focus { border-color: var(--accent); }
.doc-title { font-size: 34px; font-weight: 700; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.5px; word-break: break-word; }
.doc-title-input { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 0; overflow: hidden; display: block; }
.doc-meta { font-size: 12px; margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.doc-meta .tag { height: 20px; font-size: 11px; }

/* 渲染后的正文 */
.doc-body { font-size: 16px; line-height: 1.8; }
.doc-body > * { margin: 0 0 14px; }
.doc-body h2, .doc-body h3, .doc-body h4 { line-height: 1.4; margin: 28px 0 10px; scroll-margin-top: 70px; }
.doc-body h2 { font-size: 24px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-body h3 { font-size: 20px; }
.doc-body h4 { font-size: 17px; }
.doc-body h2::before, .doc-body h3::before, .doc-body h4::before { font: 400 .7em var(--mono); color: var(--accent); margin-right: 8px; }
.doc-body h2::before { content: '##'; }
.doc-body h3::before { content: '###'; }
.doc-body h4::before { content: '####'; }
.doc-body a, .ce-paragraph a { color: var(--accent); border-bottom: 1px dashed currentColor; }
.doc-body ul, .doc-body ol { padding-left: 24px; }
.doc-body li { margin: 3px 0; }
.doc-body code.inline-code, .doc-body .inline-code, .inline-code {
  font: .88em var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--danger);
}
.doc-body mark.cdx-marker, .cdx-marker { background: rgba(250, 204, 21, .35); color: inherit; padding: 0 2px; }
.doc-body blockquote {
  margin: 0 0 14px; padding: 8px 16px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 0 8px 8px 0; color: var(--text-2);
}
.doc-body blockquote cite { display: block; font-size: 13px; color: var(--muted); font-style: normal; margin-top: 4px; }
.doc-body blockquote cite::before { content: '— '; }
.doc-body hr { border: 0; text-align: center; margin: 28px 0; }
.doc-body hr::after { content: '* * *'; font-family: var(--mono); color: var(--muted); letter-spacing: 6px; }
.doc-body .tbl { overflow-x: auto; margin: 0 0 14px; }
.doc-body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc-body th { background: var(--bg-soft); font-weight: 600; }
.checklist { list-style: none; padding-left: 4px !important; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; }
.checklist .box { font-family: var(--mono); color: var(--muted); }
.checklist .done { color: var(--muted); text-decoration: line-through; }
.checklist .done .box { color: var(--accent); text-decoration: none; }
.callout {
  display: flex; gap: 10px; padding: 12px 16px; border-radius: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.callout .callout-ico { font-size: 18px; line-height: 1.5; }
.callout b { display: block; }
.callout p { margin: 0; color: var(--text-2); font-size: 15px; }

/* 媒体块（渲染 & 编辑共用） */
.gn-figure { margin: 0 0 16px; }
.gn-figure img { display: block; max-width: 100%; margin: 0 auto; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: var(--bg-soft); }
.gn-figure.stretched img { width: 100%; }
.gn-figure video { display: block; width: 100%; max-height: 70vh; border-radius: 8px; background: #000; }
.gn-figure audio { display: block; width: 100%; }
.gn-figure iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; }
.gn-caption { text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 1em; outline: none; }
.gn-caption:empty::before { content: attr(data-placeholder); opacity: .6; }
.gn-audio-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.gn-audio-card .nm { font: 12px var(--mono); color: var(--text-2); }
.gn-file {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft);
}
.gn-file .ext { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: var(--text); color: var(--bg); font: 700 10px var(--mono); text-transform: uppercase; flex: none; }
.gn-file .info { flex: 1; min-width: 0; }
.gn-file .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gn-file .sz { font: 12px var(--mono); color: var(--muted); }
.gn-link {
  display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); transition: border-color .15s;
  border-bottom: 1px solid var(--line) !important; color: inherit !important;
}
.gn-link:hover { border-color: var(--accent); }
.gn-link .lk-text { flex: 1; min-width: 0; padding: 12px 14px; }
.gn-link .lk-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.gn-link .lk-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 4px; }
.gn-link .lk-url { font: 12px var(--mono); color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gn-link .lk-img { width: 140px; flex: none; background: var(--bg-soft) center / cover no-repeat; border-left: 1px solid var(--line); }

/* 代码块 */
.gn-code { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: hidden; margin: 0 0 16px; }
.gn-code-head {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line);
  font: 12px var(--mono); color: var(--muted);
}
.gn-code-head .dots { display: flex; gap: 5px; margin-right: 4px; }
.gn-code-head .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); display: block; }
.gn-code-head .dots i:nth-child(1) { background: #ff5f57; }
.gn-code-head .dots i:nth-child(2) { background: #febc2e; }
.gn-code-head .dots i:nth-child(3) { background: #28c840; }
.gn-code-head .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: transparent; border: 0; outline: none; font: inherit; color: var(--text-2); }
.gn-code-head select { height: 24px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font: 12px var(--mono); }
.gn-code-head .copy { border: 1px solid var(--line); background: var(--bg); border-radius: 5px; height: 24px; padding: 0 8px; font: 11px var(--mono); cursor: pointer; color: var(--text-2); }
.gn-code-head .copy:hover { color: var(--accent); border-color: var(--accent); }
.gn-code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13px/1.65 var(--mono); tab-size: 2; }
.gn-code pre code.hljs { background: transparent; padding: 0; }
.gn-code textarea {
  display: block; width: 100%; min-height: 120px; border: 0; outline: none; resize: vertical; padding: 14px 16px;
  font: 13px/1.65 var(--mono); background: transparent; white-space: pre; tab-size: 2;
}

/* 上传占位（编辑态） */
.gn-uploader {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1.5px dashed var(--line-strong); border-radius: 10px;
  background: var(--bg-soft); font-size: 13px; color: var(--text-2);
}
.gn-uploader.drag { border-color: var(--accent); background: var(--accent-soft); }
.gn-uploader .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gn-uploader input[type='url'], .gn-uploader input[type='text'] {
  flex: 1; min-width: 200px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); outline: none; font: 13px var(--mono);
}
.gn-uploader input:focus { border-color: var(--accent); }
.gn-uploader .hint { font: 12px var(--mono); color: var(--muted); }
.gn-progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.gn-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Editor.js 主题适配 */
.editor { font-size: 16px; }
.editor .codex-editor__redactor { padding-bottom: 200px !important; }
.editor .ce-block__content, .editor .ce-toolbar__content { max-width: none; }
.editor .ce-popover__container, .editor .ce-popover { animation: none !important; }
.ce-popover { --max-height: min(70vh, 420px) !important; }
.editor .ce-header { font-weight: 700; padding: .4em 0 .2em; }
.editor h2.ce-header { font-size: 24px; }
.editor h3.ce-header { font-size: 20px; }
.editor h4.ce-header { font-size: 17px; }
.editor .ce-paragraph[data-placeholder]:empty::before { color: var(--muted); }
.editor .cdx-block { padding: .3em 0; }
.editor .cdx-quote__text { min-height: 60px; }
.editor .cdx-input { border-color: var(--line); background: var(--bg); box-shadow: none; }
[data-theme='dark'] .ce-toolbar__plus, [data-theme='dark'] .ce-toolbar__settings-btn { color: var(--text-2); }
[data-theme='dark'] .ce-toolbar__plus:hover, [data-theme='dark'] .ce-toolbar__settings-btn:hover { background: var(--bg-hover); }
[data-theme='dark'] .ce-popover, [data-theme='dark'] .ce-popover__container, [data-theme='dark'] .ce-inline-toolbar, [data-theme='dark'] .ce-conversion-toolbar, [data-theme='dark'] .ce-settings, [data-theme='dark'] .ce-popover--inline .ce-popover__container {
  --color-background: #161b22; --color-text-primary: #e6edf3; --color-border: #30363d; --color-background-item-hover: #1f262e; --color-background-icon-active: #1f262e;
  background: #161b22; color: #e6edf3; border-color: #30363d;
}
[data-theme='dark'] .ce-popover-item__icon, [data-theme='dark'] .ce-inline-tool, [data-theme='dark'] .ce-inline-toolbar__dropdown { background: transparent; color: #e6edf3; }
[data-theme='dark'] .ce-popover-item:hover, [data-theme='dark'] .ce-inline-tool:hover { background: #1f262e; }
[data-theme='dark'] .ce-block--selected .ce-block__content { background: rgba(63, 185, 80, .12); }
[data-theme='dark'] .tc-wrap { --color-border: #30363d; --color-background: #161b22; }
[data-theme='dark'] .cdx-search-field { background: #0d1117; border-color: #30363d; }
[data-theme='dark'] .tc-popover { --color-background: #161b22; --color-border: #30363d; }

/* ---------- modal / toast / lightbox ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); display: grid; place-items: center; padding: 20px; }
.modal-box { width: 100%; max-width: 420px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-hover); }
.modal-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.modal-title::before { content: '> '; color: var(--accent); }
#modal-body { display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-2); }
#modal-body label { font: 12px var(--mono); color: var(--muted); display: block; margin-bottom: 4px; }
#modal-body input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-soft); outline: none;
}
#modal-body input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-box.danger #modal-ok { background: var(--danger); border-color: var(--danger); color: #fff; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 60; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 12px; transition: all .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .85); display: grid; place-items: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ---------- responsive ---------- */
.only-mobile { display: none; }
@media (max-width: 1100px) { .outline { display: none; } }
@media (max-width: 800px) {
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-hover); }
  .app.side-open .sidebar { transform: none; }
  .side-mask { display: none; }
  .app.side-open .side-mask { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .3); }
  .topbar { padding: 0 12px; }
  .list-view { padding: 14px 12px 60px; }
  .masonry, .masonry .col { gap: 12px; }
  .doc-layout { padding: 20px 16px 100px; }
  .doc-title { font-size: 26px; }
  .doc-toolbar { padding: 8px 12px; }
  #new-note { padding: 0 10px; }
  .gn-link .lk-img { width: 90px; }
  .btn kbd { display: none; }
}

/* ---------- 多列分类（一级 | 二级 | 弹出三级+） ---------- */
.cols { flex: 1; min-height: 0; display: flex; border-top: 1px solid var(--line); }
.cols .col { overflow-y: auto; padding: 6px 6px 16px; }
.cols .col1 { width: 46%; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.cols .col1 .tags-box { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); }
.cols .col2 { flex: 1; min-width: 0; background: var(--bg); }
.col-title {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  margin: 10px 6px 4px; font: 11px var(--mono); letter-spacing: .5px; color: var(--muted);
}
.col-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols .col2 .col-title { margin-top: 6px; }
.cols .col2 .col-title .t { color: var(--accent); }
.cols .tree-root { font-size: 13px; padding: 5px 6px; }
.cols .tree-root .mono { width: 20px; }
.hint { padding: 6px 8px; line-height: 1.6; }
.node .lv { font-size: 12px; color: var(--accent); }
.node .more { width: 10px; flex: none; color: var(--muted); font: 14px var(--mono); text-align: center; }
.node.sel { background: var(--bg-hover); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.node.on-path { background: var(--bg-hover); color: var(--text); font-weight: 500; }
.node.on-path .more, .node.sel .more { color: var(--accent); }
.cols .tag-cloud { padding: 4px 4px; }

.flyout {
  position: relative; z-index: 6; flex: none; height: 100vh;
  display: flex; background: var(--panel); border-right: 1px solid var(--line-strong);
  box-shadow: 12px 0 32px rgba(0, 0, 0, .08); animation: flyIn .16s ease-out;
}
[data-theme='dark'] .flyout { box-shadow: 12px 0 32px rgba(0, 0, 0, .5); }
@keyframes flyIn { from { opacity: 0; transform: translateX(-8px); } }
.fcol { width: 200px; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: var(--fly-top, 99px) 6px 16px; animation: flyIn .16s ease-out; }
.fcol .col-title { margin-top: 6px; }
.fcol:last-of-type { border-right: 0; }
.fcol .col-title .t { color: var(--accent); }
.fcol-body { flex: 1; overflow-y: auto; }
.fly-close { position: absolute; top: calc(var(--fly-top, 99px) - 34px); right: 8px; height: 26px; width: auto; padding: 0 8px; font: 11px var(--mono); border: 1px solid var(--line); background: var(--bg); }

@media (max-width: 800px) {
  :root { --side-w: min(400px, 92vw); }
  .flyout { position: fixed; top: 0; bottom: 0; left: 0; right: 0; height: auto; z-index: 45; overflow-x: auto; }
  .fcol { padding-top: 54px; }
  .fly-close { top: 12px; }
  .fcol { width: 70vw; flex: none; }
}
/* ---------- 分享 ---------- */
.share-anchor { position: relative; display: inline-flex; }
#doc-share.shared { color: var(--accent); }
.share-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: 420px; max-width: calc(100vw - 24px);
  padding: 16px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-hover);
  display: flex; flex-direction: column; gap: 10px; font-size: 13px;
}
.share-pop .sp-title { font-weight: 700; color: var(--accent); }
.share-pop .sp-desc { color: var(--text-2); line-height: 1.6; }
.share-pop .sp-row { display: flex; flex-direction: column; gap: 8px; }
.share-pop .sp-row .btn { align-self: flex-end; }
.share-pop .sp-row input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-soft); font-size: 12px; outline: none;
}
.share-pop .sp-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }