@charset "UTF-8";
/* app.css —— Obsidian Web 的零依赖界面样式。深色为主，支持浅色与五种强调色。 */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-text: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "Noto Serif CJK SC", "Songti SC", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #18171d;
  --bg-elevated: #201e26;
  --bg-panel: #1b1a20;
  --bg-panel-2: #211f27;
  --bg-editor: #1d1b22;
  --bg-hover: rgba(255, 255, 255, 0.045);
  --bg-active: rgba(168, 139, 250, 0.12);
  --border: #302d38;
  --border-strong: #3d3948;
  --text: #dedbe8;
  --text-strong: #f3f0fa;
  --text-muted: #938ea2;
  --text-faint: #6d6879;
  --shadow: 0 14px 50px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.22);
  --input-bg: #24222b;
  --code-bg: rgba(255, 255, 255, 0.045);
  --graph-grid: rgba(255, 255, 255, 0.028);
  --graph-edge: rgba(190, 178, 220, 0.22);
  --titlebar-h: 40px;
  --status-h: 27px;
  --ribbon-w: 58px;
  --left-w: 266px;
  --right-w: 310px;
  --editor-font-size: 15px;
  --radius: 8px;
  --radius-sm: 6px;
  --danger: #ff7b8b;
  --danger-soft: rgba(255, 92, 112, 0.12);
  --success: #78d7a3;
  --warning: #e7bd73;
  --content-max: 780px;
}
:root[data-theme="light"] {
  --bg: #f3f0ea;
  --bg-elevated: #fbf9f5;
  --bg-panel: #f2efe9;
  --bg-panel-2: #eae5dd;
  --bg-editor: #fbf9f5;
  --bg-hover: rgba(44, 36, 66, 0.055);
  --bg-active: rgba(110, 84, 200, 0.12);
  --border: #ddd8cf;
  --border-strong: #c9c2b6;
  --text: #34313a;
  --text-strong: #1e1b23;
  --text-muted: #726c79;
  --text-faint: #9b95a0;
  --shadow: 0 18px 55px rgba(55, 44, 76, 0.16);
  --shadow-soft: 0 4px 18px rgba(55, 44, 76, 0.1);
  --input-bg: #f6f2eb;
  --code-bg: rgba(49, 40, 70, 0.055);
  --graph-grid: rgba(50, 40, 70, 0.055);
  --graph-edge: rgba(70, 55, 95, 0.2);
  --danger: #b63348;
  --danger-soft: rgba(182, 51, 72, 0.1);
  --success: #257a4c;
  --warning: #8b5c00;
}
:root[data-accent="violet"] { --accent: #a88bfa; --accent-strong: #c1aaff; --accent-soft: rgba(168, 139, 250, 0.15); --accent-contrast: #20192e; --accent-deep: #7f62d8; }
:root[data-accent="blue"] { --accent: #7cb8ff; --accent-strong: #a5cfff; --accent-soft: rgba(124, 184, 255, 0.14); --accent-contrast: #11202f; --accent-deep: #3f7fcb; }
:root[data-accent="teal"] { --accent: #72d8c6; --accent-strong: #9ae9dc; --accent-soft: rgba(114, 216, 198, 0.13); --accent-contrast: #102522; --accent-deep: #3a9c8d; }
:root[data-accent="rose"] { --accent: #f19ab4; --accent-strong: #ffb8cb; --accent-soft: rgba(241, 154, 180, 0.14); --accent-contrast: #2a141a; --accent-deep: #b75d78; }
:root[data-accent="amber"] { --accent: #e8bb73; --accent-strong: #f5d39a; --accent-soft: rgba(232, 187, 115, 0.14); --accent-contrast: #271c0c; --accent-deep: #af7d32; }
:root[data-theme="light"][data-accent="violet"] { --accent: #7054c7; --accent-strong: #5a3fb0; --accent-soft: rgba(112, 84, 199, 0.11); --accent-contrast: #ffffff; --accent-deep: #5a3fb0; }
:root[data-theme="light"][data-accent="blue"] { --accent: #2d6db4; --accent-strong: #225b9b; --accent-soft: rgba(45, 109, 180, 0.1); --accent-contrast: #ffffff; --accent-deep: #225b9b; }
:root[data-theme="light"][data-accent="teal"] { --accent: #237c70; --accent-strong: #19675c; --accent-soft: rgba(35, 124, 112, 0.1); --accent-contrast: #ffffff; --accent-deep: #19675c; }
:root[data-theme="light"][data-accent="rose"] { --accent: #b04d6a; --accent-strong: #963c58; --accent-soft: rgba(176, 77, 106, 0.1); --accent-contrast: #ffffff; --accent-deep: #963c58; }
:root[data-theme="light"][data-accent="amber"] { --accent: #95651d; --accent-strong: #7d5212; --accent-soft: rgba(149, 101, 29, 0.1); --accent-contrast: #ffffff; --accent-deep: #7d5212; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--text-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
a { color: var(--accent); }
h1, h2, h3, h4, p { margin: 0; }
kbd {
  font-family: var(--font-mono); font-size: 10px; line-height: 1; padding: 3px 5px;
  border: 1px solid var(--border); border-bottom-color: var(--border-strong);
  border-radius: 4px; background: var(--bg-panel-2); color: var(--text-muted);
  box-shadow: 0 1px 0 rgba(0,0,0,.12);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-faint) 38%, transparent); border: 3px solid transparent; background-clip: padding-box; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-faint) 60%, transparent); border: 3px solid transparent; background-clip: padding-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--text-muted); }

/* ---------- generic buttons ---------- */
.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); width: 30px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.icon-btn.tiny { width: 26px; height: 24px; }
.ow-btn {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: var(--radius-sm); min-height: 32px; padding: 5px 12px;
  font-size: 12.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ow-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.ow-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.ow-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.ow-btn.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.ow-btn.danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.ow-btn.small { min-height: 28px; padding: 3px 9px; font-size: 12px; }
.text-link { border: none; background: none; color: var(--accent); padding: 0; text-align: left; font-size: 12.5px; }
.text-link:hover { text-decoration: underline; }

/* ---------- app frame ---------- */
.app-shell { height: 100vh; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.titlebar {
  height: var(--titlebar-h); flex: 0 0 var(--titlebar-h); display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(220px, 1.3fr) minmax(280px, 1fr);
  align-items: center; padding: 0 10px; background: var(--bg-panel);
  border-bottom: 1px solid var(--border); user-select: none; -webkit-app-region: drag;
}
.titlebar-left, .titlebar-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
.titlebar-actions { justify-content: flex-end; }
.titlebar-center { display: flex; justify-content: center; min-width: 0; }
.brand {
  display: flex; align-items: center; gap: 7px; border: 0; background: transparent;
  color: var(--text-strong); padding: 3px 6px; border-radius: var(--radius-sm); -webkit-app-region: no-drag;
}
.brand:hover { background: var(--bg-hover); }
.brand-title { font-size: 13px; font-weight: 660; letter-spacing: .2px; white-space: nowrap; }
.edition-badge {
  font-size: 9px; font-weight: 800; letter-spacing: .09em; padding: 2px 6px;
  border-radius: 4px; margin-left: 2px; color: var(--text-muted); border: 1px solid var(--border);
}
.edition-badge.prod { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 9%, transparent); }
.edition-badge.dev { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.vault-switcher {
  display: flex; align-items: center; gap: 7px; border: 1px solid transparent;
  background: transparent; color: var(--text); border-radius: var(--radius-sm);
  padding: 4px 10px; max-width: 330px; -webkit-app-region: no-drag;
}
.vault-switcher:hover { background: var(--bg-hover); border-color: var(--border); }
.vault-symbol { color: var(--accent); display: inline-flex; }
.vault-chevron { color: var(--text-faint); display: inline-flex; }
#vault-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 560; }
.quick-open {
  height: 27px; display: flex; align-items: center; gap: 6px; margin-right: 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated);
  color: var(--text-muted); padding: 0 8px 0 7px; -webkit-app-region: no-drag;
}
.quick-open:hover { color: var(--text); border-color: var(--border-strong); }
.quick-open-icon { display: inline-flex; }
.quick-open-label { font-size: 11.5px; }
.quick-open kbd { border: none; background: transparent; box-shadow: none; padding: 0 0 0 3px; font-size: 9.5px; color: var(--text-faint); }
.app-body { flex: 1; min-height: 0; display: flex; position: relative; }

/* ---------- ribbon ---------- */
.ribbon {
  width: var(--ribbon-w); flex: 0 0 var(--ribbon-w); background: var(--bg-panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 10px 5px 8px; gap: 4px; user-select: none;
}
.ribbon-group { display: flex; flex-direction: column; gap: 3px; }
.ribbon-main { align-items: stretch; }
.ribbon-bottom { margin-top: auto; align-items: stretch; gap: 2px; }
.ribbon-spacer { flex: 1; }
.ribbon-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); min-height: 45px; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: color .12s ease, background .12s ease;
}
.ribbon-btn span { font-size: 9.5px; letter-spacing: .02em; color: var(--text-faint); }
.ribbon-btn:hover { color: var(--text); background: var(--bg-hover); }
.ribbon-btn:hover span { color: var(--text-muted); }
.ribbon-btn.active { color: var(--accent); background: var(--accent-soft); }
.ribbon-btn.active span { color: var(--accent); }

/* ---------- left sidebar ---------- */
.left-sidebar {
  width: var(--left-w); flex: 0 0 var(--left-w); min-width: 0; background: var(--bg-panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0;
}
.sidebar-tabs-row { height: 38px; flex: 0 0 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 7px 0 10px; border-bottom: 1px solid var(--border); }
.sidebar-tabs { display: flex; gap: 2px; }
.sidebar-tab {
  width: 29px; height: 26px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-faint); display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-tab:hover { color: var(--text); background: var(--bg-hover); }
.sidebar-tab.active { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 5px; color: var(--text-muted); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.panel-count { color: var(--text-faint); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.panel-tools { display: flex; align-items: center; gap: 1px; padding: 0 8px 5px 10px; }
.tool-spacer { flex: 1; }
.file-tree-scroll { flex: 1; overflow: auto; min-height: 0; padding: 1px 6px 10px; }
.file-tree { outline: none; min-height: 60px; }
.file-tree.root-drop-target { background: var(--accent-soft); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.tree-empty { display: flex; flex-direction: column; align-items: center; gap: 5px; margin: 30px 14px; color: var(--text-faint); text-align: center; }
.tree-empty svg { color: var(--text-muted); opacity: .6; }
.tree-empty p { color: var(--text-muted); font-size: 12px; margin: 0; }
.tree-empty span { font-size: 11px; }
.tree-folder { position: relative; }
.tree-row {
  display: flex; align-items: center; gap: 2px; height: 27px; margin: 1px 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding-left: calc(4px + var(--tree-depth) * 14px); padding-right: 4px;
  color: var(--text-muted); user-select: none; cursor: pointer; min-width: 0;
  position: relative;
}
.tree-row:hover { background: var(--bg-hover); color: var(--text); }
.tree-row.active { background: var(--accent-soft); color: var(--text-strong); }
.tree-row.active::before { content: ""; position: absolute; left: -6px; top: 5px; bottom: 5px; width: 2px; border-radius: 2px; background: var(--accent); }
.tree-row.drop-target { background: var(--accent-soft); border-color: var(--accent); }
.tree-row.dragging { opacity: .4; }
.tree-chevron { width: 15px; flex: 0 0 15px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-faint); }
.tree-chevron.empty { opacity: 0; }
.tree-icon { width: 18px; flex: 0 0 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-faint); }
.tree-folder > .tree-row .tree-icon { color: color-mix(in srgb, var(--accent) 55%, var(--text-faint)); }
.tree-row.active .tree-icon { color: var(--accent); }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; flex: 1; text-align: left; }
.tree-note .tree-label { color: var(--text); }
.tree-row.active .tree-label { color: var(--text-strong); }
.tree-mini-action {
  opacity: 0; border: none; background: transparent; color: var(--text-faint); width: 20px; height: 20px;
  border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.tree-row:hover .tree-mini-action { opacity: 1; }
.tree-mini-action:hover { background: var(--bg-active); color: var(--accent); }
.sidebar-footer { height: 29px; flex: 0 0 29px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 10.5px; overflow: hidden; white-space: nowrap; }
.tree-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 12%, transparent); flex: 0 0 6px; }

/* ---------- search ---------- */
.search-panel { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.search-box { display: flex; align-items: center; gap: 6px; margin: 11px 11px 6px; padding: 0 8px; height: 31px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.search-box-icon { color: var(--text-faint); display: inline-flex; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.search-box input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-size: 12px; }
.search-box input::placeholder { color: var(--text-faint); }
.search-box kbd { border: none; background: transparent; box-shadow: none; padding: 0; font-size: 9px; color: var(--text-faint); }
.search-summary { padding: 4px 14px 7px; font-size: 10.5px; color: var(--text-faint); }
.search-results { flex: 1; overflow: auto; min-height: 0; padding: 2px 7px 14px; }
.search-result { width: 100%; border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); padding: 7px 8px 8px; display: flex; flex-direction: column; gap: 2px; text-align: left; color: var(--text); }
.search-result:hover { background: var(--bg-hover); border-color: var(--border); }
.search-result-title { font-size: 12.5px; font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-title mark, .search-result-snippet mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text-strong); border-radius: 2px; padding: 0 1px; }
.search-result-path { font-size: 10px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-snippet { color: var(--text-muted); font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.search-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 20px; color: var(--text-faint); text-align: center; gap: 5px; }
.search-empty strong { color: var(--text-muted); font-size: 12px; }
.search-empty span { font-size: 11px; }
.tag-cloud { border-top: 1px solid var(--border); padding: 10px 12px 14px; max-height: 36%; overflow: auto; }
.tag-cloud-head { color: var(--text-faint); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 7px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-pill { border: 1px solid var(--border); background: var(--bg-hover); color: var(--text-muted); font-size: 10.5px; border-radius: 20px; padding: 2px 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- workspace and tabs ---------- */
.workspace { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.tab-bar { height: 38px; flex: 0 0 38px; display: flex; align-items: stretch; border-bottom: 1px solid var(--border); background: var(--bg-panel); }
.tabs { display: flex; overflow-x: auto; overflow-y: hidden; min-width: 0; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; min-width: 105px; max-width: 220px; border-right: 1px solid var(--border); color: var(--text-muted); background: var(--bg-panel); position: relative; flex: 0 0 auto; }
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active { background: var(--bg-editor); color: var(--text-strong); box-shadow: inset 0 2px 0 var(--accent); }
.tab-title { height: 100%; border: none; background: transparent; color: inherit; display: flex; align-items: center; gap: 6px; padding: 0 4px 0 11px; min-width: 0; flex: 1; text-align: left; }
.tab-title > span:not(.tab-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.tab-title svg { color: var(--text-faint); flex: 0 0 13px; }
.tab.active .tab-title svg { color: var(--accent); }
.tab-dot { width: 5px; height: 5px; background: var(--accent); border-radius: 50%; flex: 0 0 5px; margin-left: 1px; }
.tab-close { width: 20px; height: 20px; flex: 0 0 20px; border: none; background: transparent; color: var(--text-faint); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; padding: 0; opacity: 0; margin-right: 5px; }
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--danger-soft); color: var(--danger); }
.tab-actions { display: flex; align-items: center; gap: 1px; padding: 0 6px; border-left: 1px solid var(--border); flex: 0 0 auto; }
.workspace-content { flex: 1; min-height: 0; position: relative; display: flex; background: var(--bg-editor); }
.editor-host { flex: 1; min-width: 0; min-height: 0; display: flex; }
.graph-host { flex: 1; min-width: 0; min-height: 0; }
.workspace-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; background: radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 45%), var(--bg-editor); }
.empty-orb { width: 76px; height: 76px; border-radius: 22px; display: flex; align-items: center; justify-content: center; background: var(--bg-panel); border: 1px solid var(--border); box-shadow: var(--shadow-soft); margin-bottom: 20px; }
.workspace-empty h1 { font-size: 24px; color: var(--text-strong); letter-spacing: -.02em; }
.workspace-empty p { color: var(--text-muted); font-size: 13px; line-height: 1.7; max-width: 430px; margin: 8px auto; }
.empty-actions { display: flex; gap: 8px; margin: 12px 0; }
.empty-hint { font-size: 11px; color: var(--text-faint) !important; }

/* ---------- note view ---------- */
.note-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg-editor); }
.note-view.is-empty .editor-split { display: none; }
.note-header { flex: 0 0 auto; min-height: 62px; padding: 10px 22px 8px 26px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--bg-editor); }
.note-path-wrap { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.note-path { color: var(--text-faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48vw; }
.crumb-folder { color: var(--text-faint); }
.crumb-current { color: var(--text-muted); }
.note-title-button { border: none; background: transparent; color: var(--text-strong); padding: 0; font-size: 17px; line-height: 1.35; font-weight: 650; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48vw; border-radius: 3px; }
.note-title-button:hover { color: var(--accent-strong); }
.note-header-actions { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.editor-save-state { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.editor-save-state[data-state="saving"] { color: var(--accent); }
.editor-save-state[data-state="dirty"] { color: var(--warning); }
.editor-save-state[data-state="error"], .editor-save-state[data-state="conflict"] { color: var(--danger); }
.mode-switch { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-panel); padding: 2px; gap: 1px; }
.mode-switch button { width: 27px; height: 24px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--text-faint); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.mode-switch button:hover { color: var(--text); background: var(--bg-hover); }
.mode-switch button.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, transparent); }
.note-more { margin-left: 1px; }
.conflict-banner { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--danger-soft); border-bottom: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); padding: 8px 22px 8px 26px; }
.conflict-copy { display: flex; gap: 8px; align-items: baseline; min-width: 0; color: var(--danger); font-size: 11.5px; }
.conflict-copy strong { font-size: 12px; white-space: nowrap; }
.conflict-copy span { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conflict-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.editor-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: hidden; }
.source-pane { display: flex; min-width: 0; min-height: 0; position: relative; background: var(--bg-editor); }
.source-scroll { flex: 1; min-width: 0; min-height: 0; display: flex; overflow: hidden; }
.markdown-source {
  flex: 1; width: 100%; height: 100%; min-height: 100%; resize: none; border: none; outline: none;
  background: transparent; color: var(--text); font-family: var(--font-mono);
  font-size: var(--editor-font-size); line-height: 1.75; letter-spacing: -0.01em;
  padding: 21px 26px 60px; tab-size: 2; caret-color: var(--accent);
}
.markdown-source::selection { background: var(--accent-soft); }
.markdown-source::placeholder { color: var(--text-faint); }
.preview-pane { min-width: 0; min-height: 0; overflow: auto; border-left: 1px solid var(--border); background: var(--bg-editor); position: relative; }
.note-view[data-mode="source"] .editor-split { grid-template-columns: minmax(0, 1fr); }
.note-view[data-mode="source"] .preview-pane { display: none; }
.note-view[data-mode="split"] .markdown-preview { padding-top: 22px; }
.note-view[data-mode="read"] .editor-split { grid-template-columns: minmax(0, 1fr); }
.note-view[data-mode="read"] .source-pane { display: none; }
.note-view[data-mode="read"] .preview-pane { border-left: none; }
.note-view[data-mode="read"] .markdown-preview { max-width: 820px; margin: 0 auto; padding-top: clamp(28px, 5vh, 64px); padding-bottom: 90px; }
.note-view.wide-editor .markdown-preview { max-width: 1080px; }
.wikilink-popover { position: absolute; left: 22px; right: 22px; bottom: 24px; max-height: 238px; overflow: auto; z-index: 12; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: var(--shadow); padding: 5px; }
.suggest-head { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); padding: 5px 8px 4px; }
.suggest-item { width: 100%; display: flex; flex-direction: column; gap: 1px; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 6px 8px; color: var(--text); }
.suggest-item:hover, .suggest-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.suggest-title { font-size: 12px; font-weight: 600; color: var(--text-strong); }
.suggest-path { font-size: 10px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; color: var(--text-muted); }
.empty-mark { width: 52px; height: 52px; border: 1px solid var(--border); background: var(--bg-panel); border-radius: 14px; transform: rotate(45deg); margin-bottom: 24px; position: relative; }
.empty-mark::after { content: ""; position: absolute; inset: 17px; border: 1px solid var(--accent); border-radius: 4px; }
.note-empty h2 { font-size: 18px; color: var(--text-strong); margin-bottom: 6px; }
.note-empty p { font-size: 12px; }

/* ---------- Markdown preview ---------- */
.markdown-preview { color: var(--text); font-family: var(--font-text); font-size: var(--editor-font-size); line-height: 1.82; padding: 24px clamp(26px, 4.2vw, 58px) 90px; overflow-wrap: break-word; }
.markdown-preview > * { max-width: 100%; }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3, .markdown-preview h4, .markdown-preview h5, .markdown-preview h6 {
  color: var(--text-strong); font-family: var(--font-ui); line-height: 1.3; font-weight: 680; letter-spacing: -.018em;
  margin: 1.65em 0 .55em; scroll-margin-top: 18px; position: relative;
}
.markdown-preview > h1:first-child, .markdown-preview > h2:first-child { margin-top: .1em; }
.markdown-preview h1 { font-size: 1.92em; letter-spacing: -.03em; }
.markdown-preview h2 { font-size: 1.38em; border-bottom: 1px solid var(--border); padding-bottom: .28em; }
.markdown-preview h3 { font-size: 1.14em; }
.markdown-preview h4 { font-size: 1em; color: var(--text); }
.markdown-preview p { margin: .78em 0; }
.markdown-preview strong { color: var(--text-strong); font-weight: 700; }
.markdown-preview em { color: var(--text-strong); }
.markdown-preview del { color: var(--text-faint); }
.markdown-preview mark, .md-highlight { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--text-strong); border-radius: 3px; padding: 0 2px; }
.markdown-preview a { text-decoration: none; }
.markdown-preview a:hover { text-decoration: underline; text-underline-offset: 2px; }
.internal-link { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.internal-link:hover { color: var(--accent-strong); border-bottom-color: var(--accent); }
.internal-link.is-unresolved { color: var(--text-faint); border-bottom-style: dashed; border-bottom-color: var(--text-faint); }
.internal-link.is-unresolved:hover { color: var(--text-muted); border-bottom-color: var(--text-muted); }
.internal-embed::before { content: "↪ "; color: var(--text-faint); }
.md-link { color: var(--accent); }
.tag { display: inline-block; font-family: var(--font-ui); font-size: .78em; color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 20px; padding: 0 .5em; line-height: 1.8; text-decoration: none !important; vertical-align: .06em; }
.tag:hover { border-color: var(--accent); }
.markdown-preview ul, .markdown-preview ol { margin: .7em 0; padding-left: 1.55em; }
.markdown-preview li { margin: .24em 0; padding-left: .15em; }
.markdown-preview li > p { margin: .25em 0; }
.markdown-preview li::marker { color: var(--text-faint); }
.markdown-preview ul { list-style: disc; }
.markdown-preview ul ul { list-style: circle; }
.markdown-preview ol { list-style: decimal; }
.task-list { list-style: none; padding-left: .25em !important; }
.task-list .task-list { padding-left: 1.4em !important; }
.task-list-item { display: flex; align-items: flex-start; gap: 8px; padding-left: 0 !important; }
.task-list-item > span { flex: 1; }
.task-checkbox { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; flex: 0 0 15px; margin: 6px 0 0; border: 1.5px solid var(--text-faint); border-radius: 4px; background: transparent; cursor: pointer; position: relative; transition: border-color .1s ease, background .1s ease; }
.task-checkbox:hover { border-color: var(--accent); }
.task-checkbox:checked { border-color: var(--accent); background: var(--accent); }
.task-checkbox:checked::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--accent-contrast); border-width: 0 2px 2px 0; transform: rotate(43deg); }
.markdown-preview blockquote { margin: 1.05em 0; padding: .25em 1.1em; border-left: 3px solid color-mix(in srgb, var(--accent) 60%, var(--border)); background: var(--bg-hover); border-radius: 0 6px 6px 0; color: var(--text-muted); }
.markdown-preview blockquote p { margin: .45em 0; }
.callout { margin: 1em 0; border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: .8em 1.1em; font-family: var(--font-ui); font-size: .92em; line-height: 1.7; }
.callout-title { color: var(--accent-strong); font-weight: 700; margin: 0 0 .35em; font-size: .93em; letter-spacing: .01em; }
.callout p { margin: .35em 0; color: var(--text); }
.callout-info { border-left-color: var(--accent); }
.callout-tip { border-left-color: var(--success); background: color-mix(in srgb, var(--success) 9%, transparent); }
.callout-tip .callout-title { color: var(--success); }
.callout-warning { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, transparent); }
.callout-warning .callout-title { color: var(--warning); }
.callout-danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout-danger .callout-title { color: var(--danger); }
.callout-example, .callout-quote { border-left-color: var(--text-faint); background: var(--bg-hover); }
.inline-code { font-family: var(--font-mono); font-size: .85em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: .08em .35em; color: var(--accent-strong); }
.md-code { margin: 1.1em 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: color-mix(in srgb, var(--bg) 40%, var(--bg-elevated)); font-family: var(--font-ui); }
.md-code-head { display: flex; align-items: center; justify-content: space-between; height: 29px; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--bg-hover); color: var(--text-faint); font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; }
.md-copy { border: 1px solid transparent; background: transparent; color: var(--text-faint); font-size: 10px; border-radius: 4px; padding: 2px 7px; cursor: pointer; }
.md-copy:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.md-code pre { margin: 0; padding: 14px 16px; overflow: auto; }
.md-code code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; color: var(--text); white-space: pre; }
.md-table-wrap { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--border); border-radius: 8px; }
.markdown-preview table { border-collapse: collapse; width: 100%; min-width: 320px; font-family: var(--font-ui); font-size: .88em; }
.markdown-preview th, .markdown-preview td { border-bottom: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
.markdown-preview th { background: var(--bg-hover); color: var(--text-strong); font-weight: 650; }
.markdown-preview tr:last-child td { border-bottom: none; }
.markdown-preview tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-hover) 45%, transparent); }
.md-hr { border: none; height: 1px; background: var(--border); margin: 1.9em 0; }
.md-image { max-width: 100%; border-radius: 7px; border: 1px solid var(--border); display: block; margin: 1em auto; cursor: zoom-in; box-shadow: var(--shadow-soft); }
.heading-anchor { color: var(--text-faint); opacity: 0; font-family: var(--font-ui); font-weight: 400; font-size: .62em; margin-left: .35em; text-decoration: none; vertical-align: .18em; }
.markdown-preview h1:hover .heading-anchor, .markdown-preview h2:hover .heading-anchor, .markdown-preview h3:hover .heading-anchor, .markdown-preview h4:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--accent) !important; }
.md-properties { margin: 0 0 1.4em; padding: 10px 13px; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--bg-hover) 55%, transparent); font-family: var(--font-ui); font-size: 11.5px; }
.property-row { display: grid; grid-template-columns: 92px 1fr; gap: 9px; align-items: start; padding: 2px 0; }
.property-key { color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.property-value { color: var(--text); line-height: 1.6; display: flex; flex-wrap: wrap; gap: 3px; }
.property-chip { background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent); padding: 0 6px; border-radius: 99px; font-size: 10.5px; }
.property-empty { color: var(--text-faint); font-style: italic; }
.preview-placeholder { min-height: 40vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; color: var(--text-muted); font-family: var(--font-ui); }
.preview-placeholder h2 { color: var(--text-strong); font-size: 1.8em; margin-bottom: 8px; }
.preview-placeholder p { font-size: 12.5px; line-height: 1.7; }
.render-error { color: var(--danger); }
.image-lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(7, 6, 10, .82); backdrop-filter: blur(7px); display: flex; align-items: center; justify-content: center; padding: 40px; }
.image-lightbox img { max-width: min(94vw, 1500px); max-height: 88vh; border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,.55); }
.lightbox-close { position: fixed; right: 20px; top: 18px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(20,18,25,.7); color: white; display: inline-flex; align-items: center; justify-content: center; }
.clipboard-fallback { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---------- right sidebar ---------- */
.right-sidebar { width: var(--right-w); flex: 0 0 var(--right-w); min-width: 0; border-left: 1px solid var(--border); background: var(--bg-panel); display: flex; flex-direction: column; min-height: 0; }
.right-header { height: 38px; flex: 0 0 38px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 13px; color: var(--text-muted); font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.right-tabs { display: flex; padding: 7px 8px 6px; gap: 2px; border-bottom: 1px solid var(--border); }
.right-tabs button { flex: 1; height: 25px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid transparent; background: transparent; color: var(--text-faint); font-size: 10.5px; border-radius: 4px; }
.right-tabs button:hover { background: var(--bg-hover); color: var(--text-muted); }
.right-tabs button.active { border-color: var(--border); background: var(--bg-hover); color: var(--text); }
.right-content { flex: 1; min-height: 0; overflow: auto; padding-bottom: 30px; }
.right-section-title { font-size: 10px; font-weight: 700; color: var(--text-faint); letter-spacing: .08em; text-transform: uppercase; padding: 15px 15px 7px; }
.right-details { border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.right-details summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 11px 14px; color: var(--text-muted); font-size: 10.5px; font-weight: 650; user-select: none; }
.right-details summary::-webkit-details-marker { display: none; }
.right-details summary svg { color: var(--text-faint); }
.right-details summary em { margin-left: auto; color: var(--text-faint); font-style: normal; font-size: 9.5px; background: var(--bg-hover); padding: 0 5px; border-radius: 10px; min-width: 17px; text-align: center; }
.right-details[open] summary { color: var(--text); }
.right-details[open] summary em { color: var(--text-muted); }
.right-list { padding: 0 7px 8px; }
.link-row { width: 100%; display: flex; flex-direction: column; gap: 2px; align-items: stretch; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; padding: 6px 7px; color: var(--text); text-align: left; }
.link-row:hover { background: var(--bg-hover); border-color: var(--border); }
.link-row-title { font-size: 11.5px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row-path { color: var(--text-faint); font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row.unresolved .link-row-title { color: var(--warning); text-decoration: underline dashed; text-underline-offset: 2px; }
.mention-row { width: 100%; border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 2px; padding: 6px 7px; text-align: left; color: var(--text-muted); }
.mention-row:hover { background: var(--bg-hover); border-color: var(--border); }
.mention-snippet { font-size: 10px; line-height: 1.45; color: var(--text-faint); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.right-empty-block { margin: 16px 14px; padding: 14px; border: 1px dashed var(--border); border-radius: 8px; text-align: center; }
.right-empty-block h3 { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.right-empty-block p, .right-empty-inline p { font-size: 10.5px; line-height: 1.55; color: var(--text-faint); }
.right-empty-inline { padding: 8px 8px 10px; }
.right-empty-inline h3 { font-size: 10.5px; color: var(--text-faint); margin-bottom: 3px; }
.right-mini-stats { display: flex; margin: 4px 14px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-hover); overflow: hidden; }
.right-mini-stats div { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 9px 4px; border-right: 1px solid var(--border); }
.right-mini-stats div:last-child { border-right: 0; }
.right-mini-stats strong { color: var(--text-strong); font-size: 15px; font-weight: 650; }
.right-mini-stats span { color: var(--text-faint); font-size: 9px; }
.right-action-btn { margin: 0 14px; height: 30px; width: calc(100% - 28px); border: 1px solid var(--border); border-radius: 5px; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--text-muted); font-size: 11px; }
.right-action-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }
.right-action-btn.danger { color: var(--danger); }
.right-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 14px; }
.right-actions-grid .right-action-btn { margin: 0; width: 100%; }
.outline-list { padding: 1px 8px 10px; }
.outline-row { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: var(--text-muted); border-radius: 4px; padding: 4px 7px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outline-row:hover { background: var(--bg-hover); color: var(--text); }
.outline-row.level-1 { font-weight: 650; color: var(--text); }
.outline-row.level-2 { padding-left: 17px; }
.outline-row.level-3 { padding-left: 29px; color: var(--text-faint); }
.outline-row.level-4, .outline-row.level-5, .outline-row.level-6 { padding-left: 41px; color: var(--text-faint); font-size: 10.5px; }
.right-footnote { color: var(--text-faint); font-size: 9.5px; padding: 12px 14px; border-top: 1px solid var(--border); }
.info-table { padding: 2px 14px 9px; display: flex; flex-direction: column; gap: 1px; }
.info-table > div { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 5px 3px; border-bottom: 1px dashed color-mix(in srgb, var(--border) 55%, transparent); font-size: 10.5px; line-height: 1.45; }
.info-table > div > span:first-child { color: var(--text-faint); }
.info-table > div > span:last-child { color: var(--text-muted); overflow-wrap: anywhere; }
.property-list { padding: 0 14px 8px; }
.property-list > div { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 4px 3px; font-size: 10.5px; line-height: 1.45; }
.property-key { color: var(--text-faint); }
.property-val { color: var(--text-muted); overflow-wrap: anywhere; }
.tag-row { padding: 0 14px 10px; }

/* ---------- status bar ---------- */
.statusbar { height: var(--status-h); flex: 0 0 var(--status-h); border-top: 1px solid var(--border); background: var(--bg-panel); display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 13px; color: var(--text-faint); font-size: 9.5px; user-select: none; gap: 12px; }
.status-left, .status-center, .status-right { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; white-space: nowrap; }
.status-item { display: inline-flex; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; }
.status-divider { width: 1px; height: 11px; background: var(--border); flex: 0 0 1px; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); flex: 0 0 5px; }
.mini-dot.ok { background: var(--success); }
.mini-dot.dirty { background: var(--warning); }
.mini-dot.saving { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.mini-dot.error { background: var(--danger); }
.edition-mini { color: var(--text-faint); font-size: 9px; letter-spacing: .06em; margin-left: 2px; }

/* ---------- command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; z-index: 210; background: rgba(9, 8, 12, .56); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.command-palette { width: min(650px, 95vw); max-height: 68vh; display: flex; flex-direction: column; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; animation: rise .13s ease-out; }
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.palette-leading { color: var(--text-muted); display: inline-flex; }
.palette-input { flex: 1; min-width: 0; height: 25px; border: none; background: transparent; color: var(--text-strong); outline: none; font-family: var(--font-ui); font-size: 15px; }
.palette-input::placeholder { color: var(--text-faint); }
.palette-esc { font-size: 9px; }
.palette-meta { padding: 6px 16px 2px; color: var(--text-faint); font-size: 10px; }
.palette-results { flex: 1; overflow-y: auto; min-height: 60px; padding: 5px 7px 8px; }
.palette-row { width: 100%; min-height: 43px; border: 1px solid transparent; border-radius: 6px; background: transparent; display: flex; align-items: center; gap: 9px; padding: 5px 9px; color: var(--text); text-align: left; }
.palette-row:hover, .palette-row.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 16%, transparent); }
.palette-icon { color: var(--text-muted); display: inline-flex; flex: 0 0 18px; }
.palette-row.active .palette-icon { color: var(--accent); }
.palette-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.palette-row-title { color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row.active .palette-row-title { color: var(--text-strong); }
.palette-row-sub { color: var(--text-faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row kbd { border: none; background: transparent; box-shadow: none; color: var(--text-faint); padding: 0 2px; font-size: 9px; flex: 0 0 auto; }
.palette-time { color: var(--text-faint); font-size: 9px; flex: 0 0 auto; }
.palette-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100px; color: var(--text-faint); gap: 4px; }
.palette-empty p { color: var(--text-muted); font-size: 12px; margin: 0; }
.palette-empty span { font-size: 10.5px; }
.palette-footer { height: 30px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 14px; color: var(--text-faint); font-size: 9.5px; }
.palette-footer span { display: flex; align-items: center; gap: 4px; }
.palette-footer kbd { font-size: 8px; padding: 1px 3px; }
body.palette-open .app-shell { pointer-events: none; }
body.palette-open .palette-backdrop { pointer-events: auto; }

/* ---------- dialogs, forms, menus, toasts ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 250; background: rgba(8, 7, 11, .58); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); max-height: 88vh; overflow-y: auto; width: 480px; max-width: 94vw; animation: rise .14s ease-out; }
.modal-content { padding: 20px 22px 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { color: var(--text-strong); font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.modal-desc { color: var(--text-muted); font-size: 12px; line-height: 1.7; margin: 7px 0 12px; }
.modal-details { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); white-space: pre-wrap; max-height: 180px; overflow: auto; margin: 4px 0 14px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 5px; }
.field-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.field-help { font-size: 10.5px; color: var(--text-faint); line-height: 1.5; }
.text-input { height: 34px; width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); padding: 0 10px; outline: none; font-size: 13px; color: var(--text); }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.form-error { color: var(--danger); font-size: 11px; margin-top: 7px; }
.context-menu { position: fixed; z-index: 400; min-width: 208px; max-width: 286px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; animation: rise .1s ease-out; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--text); font-size: 11.5px; text-align: left; }
.menu-item:hover { background: var(--bg-hover); border-color: var(--border); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item svg { color: var(--text-muted); flex: 0 0 15px; }
.menu-item.danger svg { color: var(--danger); }
.menu-icon-space { width: 15px; flex: 0 0 15px; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-shortcut { color: var(--text-faint); font-size: 9px; }
.menu-separator { height: 1px; background: var(--border); margin: 4px 7px; }
.toast-stack { position: fixed; right: 16px; bottom: 38px; z-index: 500; display: flex; flex-direction: column-reverse; gap: 7px; max-width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; min-height: 36px; padding: 9px 12px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: 6px; box-shadow: var(--shadow-soft); color: var(--text); font-size: 11.5px; line-height: 1.5; animation: slide-in .16s ease-out; cursor: pointer; }
.toast svg { flex: 0 0 15px; margin-top: 1px; color: var(--accent); }
.toast-success { border-left-color: var(--success); }
.toast-success svg { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error svg { color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(5px); transition: opacity .16s ease, transform .16s ease; }
.image-lightbox, .toast, .command-palette, .modal, .context-menu { z-index: 550; }

/* ---------- graph ---------- */
.graph-view { height: 100%; display: flex; flex-direction: column; background: radial-gradient(circle at 50% 44%, var(--accent-soft), transparent 36%), var(--bg-editor); }
.graph-header { display: flex; align-items: flex-end; justify-content: space-between; padding: 18px 24px 10px; border-bottom: 1px solid var(--border); gap: 16px; flex: 0 0 auto; }
.graph-title-block h2 { margin: 0; color: var(--text-strong); font-size: 18px; font-weight: 660; letter-spacing: -.02em; }
.graph-subtitle { margin: 4px 0 0; color: var(--text-faint); font-size: 11px; }
.graph-stats { color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.graph-toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; flex-wrap: wrap; background: var(--bg-panel); }
.graph-search { flex: 0 1 250px; display: flex; align-items: center; height: 27px; border: 1px solid var(--border); border-radius: 5px; background: var(--input-bg); padding: 0 8px; }
.graph-search:focus-within { border-color: var(--accent); }
.graph-search input { width: 100%; border: none; outline: none; background: transparent; font-size: 11px; color: var(--text); }
.check-label { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 10.5px; user-select: none; }
.check-label input { accent-color: var(--accent); }
.graph-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.graph-zoom { display: inline-flex; align-items: center; gap: 1px; padding-left: 4px; border-left: 1px solid var(--border); margin-left: 3px; }
.graph-actions .icon-btn { color: var(--text-muted); }
.graph-canvas-wrap { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; outline: none; }
.graph-canvas.dragging { cursor: grabbing; }
.graph-tooltip { position: absolute; z-index: 3; pointer-events: none; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 5px; color: var(--text); font-size: 10px; padding: 4px 7px; box-shadow: var(--shadow-soft); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.graph-hint { position: absolute; left: 16px; bottom: 13px; color: var(--text-faint); font-size: 9.5px; background: color-mix(in srgb, var(--bg-panel) 76%, transparent); border: 1px solid var(--border); padding: 4px 7px; border-radius: 4px; pointer-events: none; }

/* ---------- settings & help ---------- */
.settings-body { display: flex; flex-direction: column; gap: 17px; max-height: 64vh; overflow: auto; padding-right: 3px; }
.settings-section { border-bottom: 1px solid var(--border); padding-bottom: 13px; }
.settings-section:last-child { border-bottom: none; padding-bottom: 0; }
.settings-section h3 { font-size: 12px; color: var(--text-strong); margin: 0 0 8px; font-weight: 650; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; color: var(--text-muted); font-size: 11.5px; }
.settings-row select, .settings-row input[type="number"], .settings-row input[type="text"] { height: 28px; border: 1px solid var(--border); border-radius: 5px; background: var(--input-bg); color: var(--text); padding: 0 7px; font-size: 11.5px; }
.settings-row input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.range-wrap { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 10px; }
.range-wrap input { accent-color: var(--accent); width: 130px; }
.accent-swatches { display: flex; gap: 7px; }
.accent-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; background: var(--accent); padding: 0; box-shadow: inset 0 0 0 2px var(--bg-elevated); }
.accent-swatch[data-accent="violet"] { background: #a88bfa; }
.accent-swatch[data-accent="blue"] { background: #7cb8ff; }
.accent-swatch[data-accent="teal"] { background: #72d8c6; }
.accent-swatch[data-accent="rose"] { background: #f19ab4; }
.accent-swatch[data-accent="amber"] { background: #e8bb73; }
.accent-swatch.selected { border-color: var(--text); }
.settings-note { color: var(--text-muted); font-size: 11px; line-height: 1.65; margin: 8px 0; }
.settings-note.subtle { color: var(--text-faint); font-size: 10.5px; }
.settings-action-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.help-body { display: flex; flex-direction: column; gap: 16px; max-height: 68vh; overflow: auto; padding-right: 3px; }
.help-body section { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.help-body section:last-child { border-bottom: none; }
.help-hero { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 8px; padding: 13px 15px; }
.help-body h3 { color: var(--text-strong); font-size: 14px; margin: 0 0 5px; }
.help-body h4 { color: var(--text-strong); font-size: 12px; margin: 0 0 7px; }
.help-body p { color: var(--text-muted); font-size: 11.5px; line-height: 1.7; margin: 0; }
.help-body code { font-family: var(--font-mono); font-size: .9em; background: var(--code-bg); border: 1px solid var(--border); padding: 1px 4px; border-radius: 3px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 15px; margin-bottom: 9px; }
.shortcut-grid > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.shortcut-grid span { color: var(--text-muted); font-size: 10.5px; }
.shortcut-grid kbd { white-space: nowrap; }
.disclaimer p { color: var(--text-faint); font-size: 10px; }

/* ---------- loading / fatal ---------- */
.loading-screen, .fatal-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 43%), var(--bg); color: var(--text); padding: 30px; text-align: center; }
.loading-screen h1 { font-size: 22px; color: var(--text-strong); font-weight: 660; margin: 16px 0 6px; letter-spacing: -.02em; }
.loading-screen p { color: var(--text-muted); font-size: 12px; }
.loading-brand { opacity: .94; animation: breathe 2.2s ease-in-out infinite; }
.loading-bar { width: 150px; height: 2px; background: var(--border); border-radius: 3px; margin-top: 24px; overflow: hidden; }
.loading-bar span { display: block; width: 45%; height: 100%; background: var(--accent); border-radius: 3px; animation: loading 1.25s ease-in-out infinite; }
.fatal-screen h1 { font-size: 21px; color: var(--text-strong); margin: 14px 0 7px; }
.fatal-screen p { max-width: 520px; color: var(--text-muted); line-height: 1.7; font-size: 12px; }
.fatal-logo { opacity: .8; }
.fatal-detail { margin: 16px 0; max-width: min(680px, 88vw); max-height: 180px; overflow: auto; background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--danger); padding: 10px 13px; font-family: var(--font-mono); font-size: 10.5px; text-align: left; white-space: pre-wrap; }
.fatal-actions { display: flex; gap: 7px; }
.fatal-health { margin-top: 14px; color: var(--text-faint); font-family: var(--font-mono); font-size: 10px; white-space: pre-wrap; text-align: left; }
.drop-overlay { position: fixed; inset: 14px; z-index: 180; border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, rgba(10,8,15,.72)); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--accent); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 22px 28px; box-shadow: var(--shadow); }
.drop-overlay strong { font-size: 14px; color: var(--text-strong); }
.drop-overlay span { font-size: 11px; color: var(--text-muted); }
.scrim { position: fixed; inset: var(--titlebar-h) 0 var(--status-h) 0; z-index: 32; background: rgba(7,6,10,.48); backdrop-filter: blur(2px); }

/* ---------- layout variants & responsive ---------- */
.app-shell.hide-left .left-sidebar { display: none; }
.app-shell.hide-right .right-sidebar { display: none; }
.app-shell.hide-left .workspace { border-left: 1px solid transparent; }
@media (max-width: 1180px) {
  .titlebar { grid-template-columns: minmax(210px, 1fr) minmax(170px, 1.2fr) minmax(235px, 1fr); }
  .quick-open-label { display: none; }
  .app-shell.right-overlay:not(.hide-right) .right-sidebar { position: fixed; z-index: 50; right: 0; top: var(--titlebar-h); bottom: var(--status-h); width: min(340px, 88vw); box-shadow: -20px 0 45px rgba(0,0,0,.28); }
  .note-header { padding-left: 18px; padding-right: 14px; }
  .note-path, .note-title-button { max-width: 42vw; }
  .markdown-preview { padding-left: 28px; padding-right: 28px; }
}
@media (max-width: 900px) {
  :root { --ribbon-w: 48px; --left-w: 264px; }
  .titlebar { grid-template-columns: 1fr auto; padding: 0 7px; }
  .titlebar-center { display: none; }
  .titlebar-actions .quick-open { display: none; }
  .brand-title { font-size: 12px; }
  .edition-badge { font-size: 8px; }
  .ribbon { padding-left: 3px; padding-right: 3px; }
  .ribbon-btn { min-height: 41px; }
  .ribbon-btn span { font-size: 8.5px; }
  .app-shell.left-overlay:not(.hide-left) .left-sidebar { position: fixed; z-index: 45; left: var(--ribbon-w); top: var(--titlebar-h); bottom: var(--status-h); box-shadow: 20px 0 45px rgba(0,0,0,.3); }
  .note-header-actions { gap: 5px; }
  .editor-save-state { display: none; }
  .note-path { max-width: 45vw; }
  .note-title-button { font-size: 15px; max-width: 45vw; }
  .mode-switch button { width: 25px; }
  .status-center { display: none; }
  .statusbar { padding-left: 8px; padding-right: 8px; }
  .search-panel .tag-cloud { max-height: 30%; }
}
@media (max-width: 640px) {
  .titlebar { height: 38px; flex-basis: 38px; }
  .note-header { min-height: 55px; padding: 8px 10px 7px 13px; }
  .note-path { display: none; }
  .note-title-button { max-width: 43vw; font-size: 14px; }
  .mode-switch button { width: 23px; height: 22px; }
  .note-more { display: none; }
  .editor-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr 1fr; }
  .note-view[data-mode="split"] .preview-pane { border-left: none; border-top: 1px solid var(--border); }
  .markdown-source { padding: 15px 15px 40px; }
  .markdown-preview { padding: 18px 16px 56px; font-size: calc(var(--editor-font-size) - 1px); }
  .markdown-preview h1 { font-size: 1.6em; }
  .note-view[data-mode="read"] .markdown-preview { padding-top: 24px; }
  .right-sidebar { width: min(320px, 93vw); }
  .status-right .status-divider, .status-right #status-mode { display: none; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .modal { border-radius: 10px; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { max-height: 92vh; width: 100%; }
  .settings-body, .help-body { max-height: 72vh; }
  .palette-backdrop { padding-top: 8vh; }
  .command-palette { max-height: 75vh; }
  .graph-header { padding: 13px 14px 8px; }
  .graph-subtitle { display: none; }
  .graph-toolbar { padding: 7px 9px; gap: 8px; }
  .graph-search { flex: 1 1 160px; }
  .graph-hint { display: none; }
  .drop-overlay > div { padding: 17px 18px; }
}
@media print {
  .titlebar, .ribbon, .left-sidebar, .right-sidebar, .statusbar, .tab-bar, .note-header-actions { display: none !important; }
  html, body, .app-shell, .app-body, .workspace, .workspace-content, .editor-host, .note-view, .editor-split { display: block; height: auto; overflow: visible; }
  .source-pane, .note-header .note-path-wrap { display: none !important; }
  .preview-pane { border: none; overflow: visible; }
  .markdown-preview { max-width: 100%; color: #111; background: white; padding: 0; }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(.995); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes breathe { 0%,100% { opacity: .75; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.02); } }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
