/* ---------- fonts (bundled, SIL OFL) ---------- */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: block;
  src: url(fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: block;
  src: url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: block;
  src: url(fonts/jetbrains-mono-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: block;
  src: url(fonts/jetbrains-mono-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */
/* All themes are dark. The default (Dark) is :root; the others override
   their base colours and mix the rest from them below. */
:root {
  color-scheme: dark;
  --bg: #16171b;
  --side: #1c1d22;
  --surface: #23242b;
  --hover: #2a2b33;
  --active: #2f2c55;
  --border: #2b2c34;
  --border-strong: #393a45;
  --text: #e7e7ec;
  --text-2: #b7b8c3;
  --muted: #80828f;
  --accent: #8d87ff;
  --accent-hover: #a29dff;
  --accent-soft: #29274a;
  --accent-border: #3f3b7a;
  --tag-bg: #2a2850;   --tag-fg: #b9b4ff;
  --person-bg: #3a2b1d; --person-fg: #f2b27c;
  --notel-bg: #173a2d;  --notel-fg: #72d9ab;
  --danger: #ff6b6b;
  --code-bg: #1f2026;
  --seg-bg: #1b1c21;
  --btn-primary: #625cf0;
  --btn-primary-hover: #716bff;
  --selection: #3b3870;
  --scroll: #34353f;
  --scroll-hover: #474856;
  --toast-bg: #33343e;
  --toast-fg: #ffffff;
  --btn-fg: #ffffff;
  --backdrop: rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 0, 0, .6);
  --radius: 8px;
  --sans: "Inter", "Cantarell", "Noto Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace;
  --side-w: 288px;
  --panel-w: 272px;
  /* Code highlighting, from each theme's own colours (themes set those on
     this same element, so no theme needs its own code colours). */
  --tok-keyword: var(--tag-fg);
  --tok-string: var(--notel-fg);
  --tok-number: var(--person-fg);
  --tok-comment: var(--muted);
  --tok-function: var(--accent);
  --tok-type: color-mix(in srgb, var(--person-fg) 55%, var(--text));
  --tok-property: color-mix(in srgb, var(--accent) 45%, var(--text));
  --tok-special: color-mix(in srgb, var(--danger) 70%, var(--text));
}

:root[data-theme="nord"] {
  color-scheme: dark;
  --bg: #2e3440; --side: #292e39; --surface: #3b4252; --code-bg: #343a47;
  --text: #eceff4; --text-2: #d8dee9; --muted: #8a94a8;
  --accent: #88c0d0; --btn-primary: #5e81ac; --btn-fg: #ffffff;
  --tag-fg: #81a1c1; --person-fg: #d08770; --notel-fg: #a3be8c; --danger: #bf616a;
}

:root[data-theme="dracula"] {
  color-scheme: dark;
  --bg: #282a36; --side: #21222c; --surface: #343746; --code-bg: #2f3140;
  --text: #f8f8f2; --text-2: #d6d6e0; --muted: #8b93b8;
  --accent: #bd93f9; --btn-primary: #bd93f9; --btn-fg: #282a36;
  --tag-fg: #ff79c6; --person-fg: #ffb86c; --notel-fg: #50fa7b; --danger: #ff5555;
}

:root[data-theme="catppuccin"] {
  color-scheme: dark;
  --bg: #1e1e2e; --side: #181825; --surface: #2a2b3c; --code-bg: #181825;
  --text: #cdd6f4; --text-2: #bac2de; --muted: #7f849c;
  --accent: #cba6f7; --btn-primary: #cba6f7; --btn-fg: #1e1e2e;
  --tag-fg: #89b4fa; --person-fg: #fab387; --notel-fg: #a6e3a1; --danger: #f38ba8;
}

:root[data-theme="tokyo-night"] {
  color-scheme: dark;
  --bg: #1a1b26; --side: #16161e; --surface: #24283b; --code-bg: #16161e;
  --text: #c0caf5; --text-2: #a9b1d6; --muted: #737aa2;
  --accent: #7aa2f7; --btn-primary: #7aa2f7; --btn-fg: #1a1b26;
  --tag-fg: #bb9af7; --person-fg: #ff9e64; --notel-fg: #9ece6a; --danger: #f7768e;
}

:root[data-theme="one-dark"] {
  color-scheme: dark;
  --bg: #282c34; --side: #21252b; --surface: #2c313a; --code-bg: #21252b;
  --text: #d7dae0; --text-2: #abb2bf; --muted: #7f848e;
  --accent: #61afef; --btn-primary: #61afef; --btn-fg: #282c34;
  --tag-fg: #c678dd; --person-fg: #d19a66; --notel-fg: #98c379; --danger: #e06c75;
}

:root[data-theme="monokai"] {
  color-scheme: dark;
  --bg: #272822; --side: #1e1f1c; --surface: #31322c; --code-bg: #1e1f1c;
  --text: #f8f8f2; --text-2: #cfcfc2; --muted: #908f84;
  --accent: #a6e22e; --btn-primary: #a6e22e; --btn-fg: #272822;
  --tag-fg: #66d9ef; --person-fg: #fd971f; --notel-fg: #e6db74; --danger: #f92672;
}

/* Shared shades for the palette themes, mixed from each theme's base colours. */
:root[data-theme="nord"],
:root[data-theme="dracula"],
:root[data-theme="catppuccin"],
:root[data-theme="tokyo-night"],
:root[data-theme="one-dark"],
:root[data-theme="monokai"] {
  --hover: color-mix(in srgb, var(--text) 8%, var(--side));
  --active: color-mix(in srgb, var(--accent) 22%, var(--side));
  --border: color-mix(in srgb, var(--text) 11%, var(--bg));
  --border-strong: color-mix(in srgb, var(--text) 20%, var(--bg));
  --accent-hover: color-mix(in srgb, var(--accent) 85%, var(--text));
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--bg));
  --accent-border: color-mix(in srgb, var(--accent) 45%, var(--bg));
  --btn-primary-hover: color-mix(in srgb, var(--btn-primary) 88%, var(--text));
  --tag-bg: color-mix(in srgb, var(--tag-fg) 17%, var(--bg));
  --person-bg: color-mix(in srgb, var(--person-fg) 17%, var(--bg));
  --notel-bg: color-mix(in srgb, var(--notel-fg) 17%, var(--bg));
  --seg-bg: color-mix(in srgb, var(--text) 5%, var(--side));
  --selection: color-mix(in srgb, var(--accent) 32%, var(--bg));
  --scroll: color-mix(in srgb, var(--text) 18%, var(--bg));
  --scroll-hover: color-mix(in srgb, var(--text) 30%, var(--bg));
  --toast-bg: color-mix(in srgb, var(--text) 88%, var(--bg));
  --toast-fg: var(--bg);
  --backdrop: rgba(0, 0, 0, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .25), 0 24px 60px rgba(0, 0, 0, .5);
}
/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
kbd {
  font: 500 11px/1 var(--sans); color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 2px 5px;
}
.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 500; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--btn-fg); box-shadow: 0 1px 2px rgba(91, 85, 232, .3); }
.btn.primary:hover { background: var(--btn-primary-hover); }
.btn.small { height: 26px; padding: 0 10px; font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn .i { width: 18px; height: 18px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- layout ---------- */
#app {
  display: grid; height: 100vh;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
}
body.no-side #app { grid-template-columns: 0 minmax(0, 1fr); }
body.no-side #sidebar { visibility: hidden; }
/* An open image's EXIF details: a column left of the picture, where a PDF shows its pages. */
body:not(.exif-open) #panel { display: none; }

/* ---------- sidebar ---------- */
#sidebar {
  background: var(--side); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand { white-space: nowrap; min-width: 0; }
.logo {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #4338ca, #7c3aed 55%, #c026d3); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: -.02em;
  box-shadow: 0 1px 3px rgba(91, 33, 182, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.logo sup { font-size: 8.5px; color: #fde047; margin-left: .5px; transform: translateY(-1px); }
#new-btn { height: 30px; padding: 0 11px; }
#new-btn .i { width: 15px; height: 15px; }

.search {
  position: relative; display: flex; align-items: center; margin: 0 12px 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  height: 34px; padding: 0 8px 0 10px; gap: 8px; color: var(--muted);
  transition: border-color .12s, box-shadow .12s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 0; }
#search::placeholder { color: var(--muted); }
.search .clear { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 2px; border-radius: 4px; }
.search .clear:hover { color: var(--text); background: var(--hover); }
.search:focus-within .search-kbd, .search .clear:not([hidden]) ~ .search-kbd { display: none; }

.replace-row { display: flex; align-items: center; gap: 6px; margin: -2px 12px 8px; }
.replace-row[hidden] { display: none; }
#replace {
  flex: 1; min-width: 0; height: 30px; padding: 0 10px; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); outline: 0; font-size: 13px;
}
#replace::placeholder { color: var(--muted); }
#replace:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.replace-row .btn.small { height: 30px; flex: none; }

/* Background indexing (start-up, vault switch): search and tags fill in as it goes. */
.index-status { display: flex; align-items: center; gap: 7px; margin: -2px 16px 6px; font-size: 11.5px; color: var(--muted); }
.index-status .spinner {
  width: 10px; height: 10px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#refresh-btn.busy .i { animation: spin .8s linear infinite; }

/* Find in the open note (Ctrl+F): the search box shows which file it searches. */
.search .scope, .search .find-count, .search .find-nav { display: none; }
.search.find { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.search.find .scope {
  display: inline-flex; align-items: center; gap: 4px; flex: none; max-width: 38%; height: 22px; padding: 0 4px 0 7px;
  border: 0; border-radius: 6px; background: var(--accent); color: var(--btn-fg); font-size: 12px; font-weight: 600;
}
.search.find .scope span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search.find .scope .i { width: 12px; height: 12px; flex: none; }
.search.find .find-count { display: block; flex: none; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.search.find .find-count.none { color: var(--danger); }
.search.find .find-nav { display: grid; place-items: center; flex: none; border: 0; background: transparent; color: var(--text-2); padding: 2px; border-radius: 4px; }
.search.find .find-nav:hover { background: var(--hover); color: var(--text); }
.search.find .find-nav .i { width: 14px; height: 14px; }
.search.find .find-nav.up .i { transform: rotate(180deg); }
.search.find .clear, .search.find .search-kbd, .search.find > .i { display: none; }

#filters { padding: 2px 8px 4px; overflow-y: auto; max-height: 34vh; flex: none; }
.filter-group { margin-top: 2px; }
.group-head {
  display: flex; align-items: center; gap: 4px; width: 100%;
  border: 0; background: transparent; padding: 6px 8px 4px 4px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.group-head:hover { color: var(--text-2); }
.group-head .chev { width: 14px; height: 14px; transition: transform .15s; }
.filter-group.collapsed .chev { transform: rotate(-90deg); }
.filter-group.collapsed .chips { display: none; }
.count { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 11.5px; letter-spacing: 0; text-transform: none; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 6px 6px; }
.chips .empty { font-size: 12.5px; color: var(--muted); }
/* Pinned files and folders */
.pins { list-style: none; margin: 0; padding: 0 0 6px; }
.filter-group.collapsed .pins { display: none; }
.pins li[data-path] {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 4px 0 10px; border-radius: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
}
.pins li[data-path]:hover { background: var(--hover); color: var(--text); }
.pins li.active { background: var(--active); color: var(--text); }
.pins .i { width: 15px; height: 15px; flex: none; color: var(--muted); }
.pins .pin-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pins .unpin { display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); padding: 3px; border-radius: 4px; visibility: hidden; }
.pins li:hover .unpin { visibility: visible; }
.pins .unpin:hover { color: var(--text); background: var(--active); }
.pins .unpin .i { width: 13px; height: 13px; }
.pins li.none { font-size: 12.5px; color: var(--muted); padding: 2px 10px 4px; cursor: default; }
.tree-item .pin-mark { width: 11px; height: 11px; flex: none; color: var(--muted); margin-left: -2px; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } }

.list-head {
  display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px 14px; margin-top: 4px; border-top: 1px solid var(--border);
}
/* The folder shown below: its name stands out; a small tag says it is the vault. */
.folder-title { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--text); }
.folder-title > .i { width: 16px; height: 16px; flex: none; color: var(--accent); }
#list-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-tag {
  flex: none; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px;
}
.close-folder { display: none; place-items: center; flex: none; border: 0; background: transparent; color: var(--muted); padding: 3px; border-radius: 5px; }
.close-folder:hover { background: var(--hover); color: var(--text); }
.close-folder .i { width: 13px; height: 13px; }
body.browsing .close-folder { display: grid; }
body.browsing .folder-tag, body.searching .folder-tag { display: none; }
.list-head .count { margin-left: 0; flex: none; }
.sort-wrap { margin-left: auto; display: flex; align-items: center; gap: 1px; flex: none; }
.sort-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
}
.sort-btn:hover { background: var(--hover); color: var(--text); }
.sort-btn .i { width: 15px; height: 15px; }
body.searching .sort-wrap > #new-folder-btn, body.searching .sort-wrap > #refresh-btn { display: none; }
#sort-menu { top: 30px; min-width: 190px; }
#sort-menu .check { visibility: hidden; width: 14px; height: 14px; }
#sort-menu button.on .check { visibility: visible; color: var(--accent); }

#note-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
.note-item {
  padding: 9px 10px 10px; border-radius: var(--radius); cursor: pointer; margin-bottom: 2px;
  transition: background .1s;
}
.note-item:hover { background: var(--hover); }
.note-item.active { background: var(--active); }
.note-row { display: flex; align-items: baseline; gap: 8px; }
.note-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.note-date { flex: none; font-size: 11.5px; color: var(--muted); }
.note-snippet {
  margin-top: 2px; font-size: 12.5px; color: var(--text-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note-tags { margin-top: 5px; display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.note-tags span { font-size: 11px; font-weight: 500; color: var(--tag-fg); background: var(--tag-bg); padding: 0 6px; border-radius: 5px; white-space: nowrap; }
.note-item.active .note-tags span { background: var(--surface); }
li.none { color: var(--muted); font-size: 13px; padding: 16px 10px; text-align: center; cursor: default; list-style: none; }

.side-foot { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.foot-space { flex: 1; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; border: 0;
  font: 500 12.5px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--tag-bg); color: var(--tag-fg);
  transition: filter .1s, box-shadow .1s;
}
.chip.mention { background: var(--person-bg); color: var(--person-fg); }
.chip.mention.note { background: var(--notel-bg); color: var(--notel-fg); }
.chip:hover { filter: brightness(.96) saturate(1.1); }
button.chip.on { box-shadow: inset 0 0 0 1.5px currentColor; }
button.chip small { margin-left: 5px; opacity: .6; font-size: 11px; }

/* ---------- main ---------- */
#main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
#topbar {
  display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 10px; flex: none;
  border-bottom: 1px solid transparent; transition: border-color .15s;
}
#main.scrolled #topbar { border-bottom-color: var(--border); }
#title {
  flex: 1; min-width: 0; height: 32px; padding: 0 8px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; outline: 0;
  font-size: 14px; font-weight: 600; color: var(--text); text-overflow: ellipsis;
  user-select: text;
}
#title:hover:not(:disabled) { background: var(--hover); }
#title:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#title:disabled { color: var(--muted); }
#status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; transition: opacity .4s; }
#status .i { width: 13px; height: 13px; }
#status.fade { opacity: 0; }
#status.error { color: var(--danger); opacity: 1; }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--seg-bg); border: 1px solid var(--border); }
.seg button {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500;
  transition: background .12s, color .12s, box-shadow .12s;
}
.seg button .i { width: 14px; height: 14px; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button:disabled { cursor: default; opacity: .5; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 38px; z-index: 30; min-width: 260px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  animation: pop .12s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 13px;
}
.menu button:hover { background: var(--hover); }
.menu button kbd { margin-left: auto; white-space: nowrap; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }


#doc { position: relative; flex: 1; min-height: 0; display: flex; }
#editor { flex: 1; min-width: 0; display: flex; }

/* ---------- empty state ---------- */
#empty { margin: auto; padding: 24px; text-align: center; max-width: 420px; color: var(--text-2); animation: fade .25s ease-out; }
.empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
}
.empty-icon .i { width: 26px; height: 26px; }
#empty h2 { margin: 0 0 4px; font-size: 18px; font-weight: 650; color: var(--text); letter-spacing: -.01em; }
#empty p { margin: 0 0 18px; color: var(--muted); }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 26px; }
.shortcuts { display: grid; grid-template-columns: auto auto; gap: 8px 14px; justify-content: center; margin: 0; font-size: 12.5px; text-align: left; }
.shortcuts dt { text-align: right; }
.shortcuts dd { margin: 0; color: var(--muted); }
.shortcuts code { font: 12px var(--mono); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; color: var(--text-2); }

/* ---------- editor (CodeMirror) ---------- */
#editor .cm-editor { flex: 1; min-width: 0; height: 100%; background: var(--bg); color: var(--text); }
#editor .cm-editor.cm-focused { outline: none; }
#editor .cm-scroller { overflow-y: auto; font-family: var(--sans); line-height: 1.72; }
#editor .cm-content {
  max-width: calc(720px * var(--zoom, 1)); margin: 0 auto; padding: 18px 32px 96px; box-sizing: content-box;
  caret-color: var(--accent); user-select: text;
}
#editor .cm-line { padding: 0; }
#editor .cm-cursor { border-left: 2px solid var(--accent); }
#editor .cm-selectionBackground, #editor .cm-focused .cm-selectionBackground,
#editor .cm-content ::selection { background: var(--selection) !important; }
#editor .cm-placeholder { color: var(--muted); }
#editor .cm-gutters { display: none; }

/* live preview: proportional text, rendered blocks */
#editor .live .cm-content { font-size: calc(16px * var(--zoom, 1)); }
#editor .live .cm-h { font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
#editor .live .cm-h1 { font-size: 2em; letter-spacing: -.025em; padding-top: .35em; padding-bottom: .1em; }
#editor .live .cm-h2 { font-size: 1.45em; padding-top: .8em; }
#editor .live .cm-h3 { font-size: 1.18em; padding-top: .6em; }
#editor .live .cm-h4, #editor .live .cm-h5, #editor .live .cm-h6 { font-size: 1em; padding-top: .4em; }
#editor .live .cm-setext-mark { font-size: 0; line-height: 0; height: 2px; overflow: hidden; }
#editor .cm-strong { font-weight: 650; }
#editor .cm-em { font-style: italic; }
#editor .cm-strike { text-decoration: line-through; color: var(--muted); }
#editor .live .cm-inline-code {
  font-family: var(--mono); font-size: .86em; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 5px; padding: .1em .35em;
}
#editor .cm-link { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-border); text-underline-offset: 3px; }
#editor .live .cm-link { cursor: pointer; }
#editor .live .cm-quote { border-left: 3px solid var(--accent-border); padding-left: 16px; color: var(--text-2); }
#editor .live .cm-bullet { color: var(--muted); display: inline-block; width: .9em; }
#editor .live .cm-list-num { color: var(--muted); }
#editor .cm-task-box {
  accent-color: var(--accent); width: 15px; height: 15px; margin: 0 8px 0 0; vertical-align: -2px; cursor: pointer;
}
#editor .cm-task-done { color: var(--muted); text-decoration: line-through; }
#editor .live .cm-hr-line:not(.editing) { background: linear-gradient(var(--border-strong), var(--border-strong)) center / 100% 1px no-repeat; }
#editor .live .cm-codeblock {
  font-family: var(--mono); font-size: calc(13.5px * var(--zoom, 1)); line-height: 1.6; background: var(--code-bg);
  border-left: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0 16px;
}
#editor .live .cm-codeblock.first { border-top: 1px solid var(--border); border-radius: 10px 10px 0 0; padding-top: 8px; }
#editor .live .cm-codeblock.last { border-bottom: 1px solid var(--border); border-radius: 0 0 10px 10px; padding-bottom: 8px; }
#editor .live .cm-codeblock.first.last { border-radius: 10px; }
#editor .live .cm-codeblock.fence { color: var(--muted); font-size: calc(12px * var(--zoom, 1)); }
#editor { --find-bg: color-mix(in srgb, #ffc400 38%, transparent); --find-current: color-mix(in srgb, #ff8a00 60%, transparent); }
#editor .cm-find { background: var(--find-bg); border-radius: 2px; }
#editor .cm-find-current { background: var(--find-current); box-shadow: 0 0 0 1px var(--accent); }
#editor .cm-image { max-width: 100%; max-height: 60vh; border-radius: 8px; vertical-align: middle; }
#editor .cm-image-missing { color: var(--muted); font-size: .9em; }
#editor .cm-table-wrap { margin: 4px 0 8px; overflow-x: auto; cursor: text; }
#editor .cm-table-wrap table { border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: .94em; }
#editor .cm-table-wrap th { background: var(--side); font-weight: 600; text-align: left; }
#editor .cm-table-wrap th, #editor .cm-table-wrap td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
#editor .cm-table-wrap tr:last-child td { border-bottom: 0; }
#editor .cm-table-wrap code { font: .86em var(--mono); background: var(--code-bg); padding: .1em .35em; border-radius: 5px; }

/* chips & wiki links (both modes) */
#editor .cm-chip { border-radius: 6px; padding: 1px 5px; font-weight: 500; background: var(--tag-bg); color: var(--tag-fg); }
#editor .cm-chip.mention { background: var(--person-bg); color: var(--person-fg); }
#editor .cm-chip.mention.note { background: var(--notel-bg); color: var(--notel-fg); }
#editor .live .cm-chip { cursor: pointer; font-size: .88em; }
#editor .cm-wikilink { color: var(--accent); font-weight: 500; background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }
#editor .cm-wikilink.missing { color: var(--muted); background: none; border-bottom: 1px dashed var(--border-strong); }
#editor .cm-wikilink *, #editor .cm-chip * { color: inherit; }
#editor .live .cm-wikilink:not(.raw) { cursor: pointer; }

/* plain markdown: monospace */
#editor .source .cm-scroller { font-family: var(--mono); line-height: 1.75; }
#editor .source .cm-content { font-size: calc(14px * var(--zoom, 1)); }

/* code and text files: monospace, full width, line numbers */
#editor .code .cm-scroller { font-family: var(--mono); line-height: 1.6; }
#editor .code .cm-content { font-size: calc(13.5px * var(--zoom, 1)); max-width: none; margin: 0; padding: 12px 24px 96px 12px; }
#editor .code .cm-gutters {
  display: flex; background: var(--bg); border: 0; color: var(--muted);
  font-size: calc(12px * var(--zoom, 1)); padding-left: 8px;
}
#editor .code .cm-lineNumbers .cm-gutterElement { padding: 0 10px 0 6px; min-width: 32px; }
#editor .code .cm-activeLineGutter { background: transparent; color: var(--text-2); }
body.text-open #mode-seg, body.text-open #image-btn { display: none; }
#status.info { color: var(--muted); }

/* autocomplete popup */
.cm-tooltip.cm-tooltip-autocomplete {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 4px; font: 13px var(--sans); color: var(--text);
}
.cm-tooltip.cm-tooltip-autocomplete > ul { font-family: var(--sans); max-height: 260px; }
.cm-tooltip.cm-tooltip-autocomplete > ul > li { display: flex; align-items: center; gap: 12px; padding: 4px 9px !important; border-radius: 6px; line-height: 22px; }
.cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--active); color: var(--text); }
.cm-tooltip-autocomplete .cm-completionDetail { margin-left: auto; color: var(--muted); font-style: normal; font-size: 11.5px; }
.cm-tooltip-autocomplete .cm-completionMatchedText { text-decoration: none; font-weight: 600; }
.cm-tooltip-autocomplete .cm-completionLabel { font-family: var(--sans); }


/* ---------- right panel: image details (EXIF) ---------- */
#panel { flex: none; width: var(--panel-w); background: var(--side); border-right: 1px solid var(--border); overflow-y: auto; padding: 8px 14px 16px; }
#panel h3 {
  display: flex; align-items: center; gap: 7px; margin: 8px 0 10px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
#panel h3 .i { width: 14px; height: 14px; }
#exif-form { display: flex; flex-direction: column; gap: 10px; }
#exif-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
#exif-form input, #exif-form textarea {
  font-size: 13px; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; outline: 0; resize: vertical;
  transition: border-color .12s, box-shadow .12s;
}
#exif-form input::placeholder, #exif-form textarea::placeholder { color: var(--muted); }
#exif-form input:focus, #exif-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exif-hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
#exif-info { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; }
#exif-info dt { color: var(--muted); }
#exif-info dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.note-title .i { width: 13px; height: 13px; margin-right: 5px; vertical-align: -2px; color: var(--muted); }

/* ---------- modal & toast ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding-top: 18vh;
  background: var(--backdrop); animation: fade .12s ease-out;
}
#modal-form {
  width: min(440px, 92vw); padding: 20px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .15s ease-out;
}
#modal-text { margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: pre-wrap; }
#modal-input {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); outline: 0; font-size: 14px; user-select: text;
}
#modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#modal-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 6px 0 8px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; }
#modal-form .btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
#modal-detail { margin: -6px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
#modal-form .btn.left { margin-right: auto; }
#modal-input + #modal-error:empty { min-height: 8px; }

/* right-click menu, theme menu */
.menu.ctx { position: fixed; top: 0; left: 0; right: auto; z-index: 70; width: max-content; min-width: 180px; max-width: 280px; }
.menu.ctx:not(.is-dir) .dir-only, .menu.ctx.is-dir .file-only { display: none; }
/* Move / Copy to Vault: only for things outside the vault. */
.menu.ctx:not(.outside) .outside-only { display: none; }
.menu.ctx.current [data-act="open"] { display: none; }
.settings-wrap { position: relative; }
#settings {
  /* a child of <body> (see main.js), so the sidebar edge does not cut it off */
  position: absolute; top: auto; bottom: 52px; left: 10px; right: auto; z-index: 40; width: 360px; max-height: calc(100vh - 70px); overflow-y: auto; padding: 8px;
  animation: none; /* opens instantly; the pop-in fade made this large panel slow to appear */
}
.settings-title { font-size: 14px; font-weight: 650; padding: 4px 8px 8px; }
#settings .menu-label {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 4px;
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
#settings .menu-label .i { width: 13px; height: 13px; }
#settings .menu-label kbd { margin-left: auto; text-transform: none; letter-spacing: 0; }
.theme-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.theme-list button { font-size: 12.5px; padding: 6px 8px; white-space: nowrap; }
.theme-list button span:not(.swatch) { overflow: hidden; text-overflow: ellipsis; }
#settings .theme-list .menu-label { grid-column: 1 / -1; padding: 6px 8px 2px; font-size: 10.5px; color: var(--muted); text-transform: none; }
.theme-list button .check { margin-left: auto; visibility: hidden; color: var(--accent); width: 14px; height: 14px; flex: none; }
.theme-list button.on { background: var(--active); }
.theme-list button.on .check { visibility: visible; }
.set-row { align-items: flex-start !important; gap: 12px !important; padding: 8px !important; height: auto !important; }
.set-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; text-align: left; white-space: normal; }
.set-text b { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.3; }
.set-text small { font-size: 11.5px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.set-text small.warn { color: var(--danger); }
.switch {
  position: relative; flex: none; width: 32px; height: 18px; margin-top: 1px; border-radius: 9px;
  background: var(--border-strong); transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.set-row.on .switch { background: var(--accent); }
.set-row.on .switch::after { transform: translateX(14px); }
.set-row:disabled { opacity: .6; cursor: progress; }
.set-action { flex: none; align-self: center; font-size: 12px; color: var(--accent); }
.set-hint { margin: 4px 8px 4px; font-size: 11px; line-height: 1.45; color: var(--muted); }
.swatch {
  position: relative; flex: none; width: 26px; height: 18px; border-radius: 5px; overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 25%, transparent);
  display: flex; align-items: flex-end; justify-content: flex-end; gap: 2px; padding: 3px;
}
.swatch i { width: 6px; height: 6px; border-radius: 50%; }

#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60;
  padding: 9px 14px; border-radius: 10px; background: var(--toast-bg); color: var(--toast-fg); font-size: 13px;
  box-shadow: var(--shadow); animation: rise .18s ease-out; max-width: 70vw;
}
#toast.error { background: var(--danger); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

@media (max-width: 980px) {
  body #panel { display: none; }
}
@media (max-width: 760px) {
  :root { --side-w: 240px; }
  .seg button { padding: 0 8px; }
}

/* ---------- images & PDFs ---------- */
#media { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#media-body { flex: 1; min-height: 0; display: flex; }
#media-scroll {
  flex: 1; min-width: 0; overflow: auto; background: var(--code-bg);
  padding: 24px 32px 96px; display: flex; justify-content: center;
}
#media-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; height: max-content; }
.sheet { position: relative; flex: none; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.is-image .sheet {
  background: repeating-conic-gradient(#e9e9ef 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}
.sheet > canvas, .sheet > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }
.sheet > svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.page-label {
  position: absolute; right: -2px; bottom: -22px; font-size: 11.5px; color: var(--muted);
}
#media[data-tool="select"] .sheet { cursor: default; }
#media[data-tool="text"] .sheet { cursor: text; }
#media:not([data-tool="select"]):not([data-tool="text"]) .sheet { cursor: crosshair; }
#media[data-tool="select"] .ann { cursor: move; }
.ann .hl { mix-blend-mode: multiply; }
.ann .hit { pointer-events: stroke; }
.sel-box { fill: none; stroke: var(--accent); stroke-width: 1.5px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.crop-shade { fill: rgba(0, 0, 0, .45); pointer-events: none; }
.crop-rect { fill: none; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; pointer-events: none; }
.crop-handle { fill: #fff; stroke: rgba(0, 0, 0, .55); stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.crop-grip { cursor: move; pointer-events: all; }
.crop-grip circle { fill: rgba(0, 0, 0, .45); stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.crop-grip path { fill: none; stroke: #fff; stroke-width: 1.6px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.crop-grip:hover circle { fill: var(--accent); }
.crop-hit { fill: transparent; pointer-events: all; }
.crop-hit.n, .crop-hit.s { cursor: ns-resize; }
.crop-hit.e, .crop-hit.w { cursor: ew-resize; }
.crop-hit.nw, .crop-hit.se { cursor: nwse-resize; }
.crop-hit.ne, .crop-hit.sw { cursor: nesw-resize; }
.text-edit {
  position: absolute; z-index: 5; min-width: 40px; margin: 0; padding: 0 2px; border: 1px dashed var(--accent);
  border-radius: 3px; background: rgba(255, 255, 255, .7); resize: none; overflow: hidden; outline: none;
  font-family: Helvetica, Arial, "Liberation Sans", sans-serif; white-space: pre; user-select: text;
}

/* floating toolbar */
.toolpill {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 2px; padding: 5px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.toolpill button:not(.btn) {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); font: 600 12px var(--sans);
}
.toolpill button:not(.btn):hover { background: var(--hover); color: var(--text); }
.toolpill button.on { background: var(--active); color: var(--accent); }
.toolpill .i { width: 17px; height: 17px; }
.toolpill .sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border); }
.toolpill .zoom-label { min-width: 48px; font-variant-numeric: tabular-nums; }
#doc-zoom { position: absolute; right: 16px; bottom: 14px; left: auto; transform: none; opacity: .55; transition: opacity .15s; }
#doc-zoom:hover { opacity: 1; }
#media:not(.is-image) .img-only { display: none !important; }
.colors { display: inline-flex; gap: 4px; padding: 0 4px; }
.toolpill button.swatch-btn:not(.btn) {
  min-width: 0; width: 18px; height: 18px; padding: 0; margin: 0 2px; border-radius: 50%; background: var(--c) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}
.toolpill button.swatch-btn.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
#crop-bar { bottom: 70px; gap: 8px; padding: 6px 6px 6px 14px; font-size: 13px; color: var(--text-2); }
#crop-bar .crop-size { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; min-width: 76px; }
#crop-bar select, #crop-bar input {
  height: 26px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text);
  font-size: 12.5px; padding: 0 6px; outline: 0;
}
#crop-bar input { width: 110px; }
#crop-bar select:focus, #crop-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#crop-bar input.bad { border-color: var(--danger); }

/* PDF page strip */
#pdf-pages {
  flex: none; width: 132px; overflow-y: auto; padding: 14px 12px 90px; background: var(--side);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px;
}
.strip-head {
  position: sticky; top: -14px; z-index: 1; flex: none; display: flex; gap: 1px;
  margin: -14px -12px 0; border-bottom: 1px solid var(--border); background: var(--border);
}
.strip-head button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; height: 32px; padding: 0 4px; border: 0;
  background: var(--side); color: var(--text-2); font-size: 12.5px; font-weight: 500;
}
.strip-head button:hover { color: var(--text); background: var(--hover); }
.strip-head .i { width: 14px; height: 14px; }
/* PDFs dragged onto the strip: a line where their pages will go. */
#pdf-pages.dropping { box-shadow: inset 0 0 0 2px var(--accent-border); }
.thumb.drop-before::before, #pdf-pages.drop-end::after {
  content: ''; display: block; height: 3px; border-radius: 2px; background: var(--accent);
}
.thumb.drop-before::before { position: absolute; left: 0; right: 0; top: -9px; }
.thumb { position: relative; cursor: grab; border-radius: 4px; }
.thumb canvas { display: block; width: 100%; height: auto; background: #fff; border-radius: 3px; box-shadow: var(--shadow-sm); outline: 1px solid var(--border); }
.thumb:hover canvas { outline: 2px solid var(--accent-border); }
.thumb.dragging { opacity: .4; }
.thumb-num { display: block; margin-top: 4px; text-align: center; font-size: 11.5px; color: var(--muted); }
.thumb-del {
  position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 6px; background: var(--surface); color: var(--danger); box-shadow: var(--shadow-sm);
  opacity: 0; transition: opacity .1s;
}
.thumb:hover .thumb-del { opacity: 1; }
.thumb-del .i { width: 14px; height: 14px; }

/* while a file (not a note) is open */
body.media-open #mode-seg, body.media-open #image-btn, body.media-open .menu button[data-act="image"] { display: none; }
#media-save { height: 28px; }

/* ---------- "All" tree ---------- */
#note-list.tree { padding: 0 6px 8px; }
.tree-item {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 calc(4px + var(--depth, 0) * 16px);
  border-radius: 7px; cursor: pointer; color: var(--text-2); font-size: 13.5px; user-select: none;
}
.tree-item:hover { background: var(--hover); color: var(--text); }
/* The tree is a virtual list (main.js): spacers stand in for rows out of view. */
#note-list > li.spacer { padding: 0; margin: 0; border: 0; pointer-events: none; list-style: none; }
/* Search results: rows outside the visible area skip layout and painting. */
#note-list > .note-item { content-visibility: auto; contain-intrinsic-size: auto 72px; }
.tree-item.active { background: var(--active); color: var(--text); }
.tree-item .twisty { flex: none; width: 14px; display: grid; place-items: center; color: var(--muted); }
.tree-item .twisty .i { width: 13px; height: 13px; transform: rotate(-90deg); transition: transform .12s; }
.tree-item.open .twisty .i { transform: none; }
.tree-item > .i { width: 16px; height: 16px; color: var(--muted); }
.tree-item.kind-dir > .i { color: var(--accent); }
.tree-item.kind-pdf > .i { color: var(--danger); }
.tree-item.kind-image > .i { color: var(--notel-fg); }
.tree-item.kind-dir .tree-name { font-weight: 600; color: var(--text); }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-date { flex: none; font-size: 11px; color: var(--muted); opacity: 0; transition: opacity .1s; }
.tree-item:hover .tree-date, .tree-item.active .tree-date { opacity: 1; }
.tree-item.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.tree-item.drop-target, .list-head.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.list-head.drop-target { border-radius: 7px; }

/* picture overlays */
.handle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5px; vector-effect: non-scaling-stroke; cursor: nwse-resize; }
#media[data-tool="select"] .ann image { cursor: move; }

