/* =========================================================
   Airhide · Styles
   Light/dark tokens · desktop split view · mobile list→detail
   ========================================================= */

/* Non-colour tokens */
:root {
  --radius: 9px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --appbar-h: 58px;
  --row-h: 34px;
  --row-h-touch: 48px;
  --pad-content: 14px 20px 18px;
  --pad-editor: 22px 26px;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
html[data-density="compact"] {
  --row-h: 29px;
  --row-h-touch: 42px;
  --pad-content: 10px 14px 12px;
  --pad-editor: 16px 18px;
}

/* =========================================================
   Themes
   Every [data-theme] element gets a full palette (neutrals + accent), so
   the theme picker cards preview each theme exactly, whatever the page theme.
   Light values first, then [data-scheme="dark"] overrides.
   ========================================================= */

/* Shared neutrals · light */
:root, [data-theme] {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-3: #e7e9ec;
  --border: #e3e5e8;
  --border-strong: #d0d4d9;
  --text: #111418;
  --text-2: #4b5360;
  --text-3: #8b929c;

  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, .10);
  --warn: #b45309;
  --warn-strong: #92400e;
  --warn-soft: rgba(217, 119, 6, .12);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .10);
  --info: #2563eb;
  --info-strong: #1e40af;
  --info-soft: rgba(37, 99, 235, .10);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-xl: 0 24px 64px -12px rgba(16, 24, 40, .32);

  /* Graphite accent (default) */
  --accent: #1f2329;
  --accent-hover: #3a4049;
  --accent-strong: #1f2329;
  --accent-soft: rgba(31, 35, 41, .08);
  --accent-text: #ffffff;

  --note-font: var(--font);
  --note-size: 15px;
}

/* Shared neutrals · dark */
[data-scheme="dark"], [data-scheme="dark"] [data-theme] {
  --bg: #0e1013;
  --surface: #16191d;
  --surface-2: #1d2126;
  --surface-3: #262b31;
  --border: #272c33;
  --border-strong: #353b44;
  --text: #e8eaed;
  --text-2: #a1a8b3;
  --text-3: #6c7480;

  --danger: #ef6a5f;
  --danger-soft: rgba(239, 106, 95, .14);
  --warn: #f5a524;
  --warn-strong: #fbbf24;
  --warn-soft: rgba(245, 165, 36, .13);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --info: #60a5fa;
  --info-strong: #93c5fd;
  --info-soft: rgba(96, 165, 250, .13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-xl: 0 28px 70px -12px rgba(0, 0, 0, .75);

  --accent: #e8eaed;
  --accent-hover: #ffffff;
  --accent-strong: #f3f4f6;
  --accent-soft: rgba(232, 234, 237, .11);
  --accent-text: #111418;
}
html[data-scheme="dark"] { color-scheme: dark; }
html[data-scheme="light"] { color-scheme: light; }

/* Indigo */
[data-theme="indigo"] {
  --bg: #f5f6fa; --surface-2: #f0f2f7; --surface-3: #e5e8f0; --border: #e1e4ec; --border-strong: #cdd2de;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-strong: #4338ca; --accent-soft: rgba(79, 70, 229, .10); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="indigo"], [data-scheme="dark"] [data-theme="indigo"] {
  --bg: #0d0f17; --surface: #151824; --surface-2: #1c2030; --surface-3: #252a3d; --border: #262b3d; --border-strong: #343a52;
  --accent: #818cf8; --accent-hover: #a5b4fc; --accent-strong: #a5b4fc; --accent-soft: rgba(129, 140, 248, .15); --accent-text: #0b0d1f;
}

/* Ocean */
[data-theme="ocean"] {
  --bg: #f3f7fa; --surface-2: #edf3f7; --surface-3: #e0e9f0; --border: #dde6ed; --border-strong: #c7d4de;
  --accent: #0369a1; --accent-hover: #075985; --accent-strong: #075985; --accent-soft: rgba(3, 105, 161, .10); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="ocean"], [data-scheme="dark"] [data-theme="ocean"] {
  --bg: #0a1118; --surface: #101a24; --surface-2: #16222e; --surface-3: #1e2d3b; --border: #1f2e3c; --border-strong: #2c3f51;
  --accent: #38bdf8; --accent-hover: #7dd3fc; --accent-strong: #7dd3fc; --accent-soft: rgba(56, 189, 248, .14); --accent-text: #04202e;
}

/* Teal */
[data-theme="teal"] {
  --bg: #f4f6f8; --surface-2: #f1f3f6; --surface-3: #e8ecf0; --border: #e2e6eb; --border-strong: #cfd6de;
  --accent: #0f766e; --accent-hover: #115e59; --accent-strong: #0f766e; --accent-soft: rgba(15, 118, 110, .10); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="teal"], [data-scheme="dark"] [data-theme="teal"] {
  --bg: #0b0f14; --surface: #121820; --surface-2: #19212b; --surface-3: #212b37; --border: #232d39; --border-strong: #313d4b;
  --accent: #2dd4bf; --accent-hover: #5eead4; --accent-strong: #5eead4; --accent-soft: rgba(45, 212, 191, .13); --accent-text: #042f2c;
}

/* Amethyst */
[data-theme="amethyst"] {
  --bg: #f7f5fa; --surface-2: #f3f0f8; --surface-3: #e9e4f2; --border: #e5e0ee; --border-strong: #d2cbe0;
  --accent: #7c3aed; --accent-hover: #6d28d9; --accent-strong: #6d28d9; --accent-soft: rgba(124, 58, 237, .10); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="amethyst"], [data-scheme="dark"] [data-theme="amethyst"] {
  --bg: #100d17; --surface: #181422; --surface-2: #201b2d; --surface-3: #2a2439; --border: #2b2539; --border-strong: #3b3350;
  --accent: #a78bfa; --accent-hover: #c4b5fd; --accent-strong: #c4b5fd; --accent-soft: rgba(167, 139, 250, .15); --accent-text: #1a0b2e;
}

/* Sand */
[data-theme="sand"] {
  --bg: #f6f2eb; --surface: #fffcf7; --surface-2: #f2ece2; --surface-3: #e9e0d2; --border: #e6ddcf; --border-strong: #d5c8b4;
  --text: #221c14; --text-2: #5c5143; --text-3: #978a78;
  --accent: #b45309; --accent-hover: #92400e; --accent-strong: #92400e; --accent-soft: rgba(180, 83, 9, .10); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="sand"], [data-scheme="dark"] [data-theme="sand"] {
  --bg: #13100c; --surface: #1b1712; --surface-2: #231e17; --surface-3: #2d261d; --border: #2e271e; --border-strong: #3e3428;
  --text: #efe7da; --text-2: #b3a692; --text-3: #7b705f;
  --accent: #f59e0b; --accent-hover: #fbbf24; --accent-strong: #fbbf24; --accent-soft: rgba(245, 158, 11, .14); --accent-text: #1f1300;
}

/* Rose */
[data-theme="rose"] {
  --bg: #faf5f6; --surface-2: #f7f0f2; --surface-3: #efe4e7; --border: #ede2e5; --border-strong: #dccbd0;
  --accent: #e11d48; --accent-hover: #be123c; --accent-strong: #be123c; --accent-soft: rgba(225, 29, 72, .09); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="rose"], [data-scheme="dark"] [data-theme="rose"] {
  --bg: #140d0f; --surface: #1d1417; --surface-2: #261a1e; --surface-3: #312228; --border: #322329; --border-strong: #463139;
  --accent: #fb7185; --accent-hover: #fda4af; --accent-strong: #fda4af; --accent-soft: rgba(251, 113, 133, .14); --accent-text: #2a0610;
}

/* Nord */
[data-theme="nord"] {
  --bg: #eceff4; --surface: #f8f9fb; --surface-2: #e5e9f0; --surface-3: #d8dee9; --border: #d8dee9; --border-strong: #c2cad8;
  --text: #2e3440; --text-2: #4c566a; --text-3: #7b8699;
  --accent: #5e81ac; --accent-hover: #4c6d96; --accent-strong: #4c6d96; --accent-soft: rgba(94, 129, 172, .14); --accent-text: #ffffff;
}
[data-scheme="dark"][data-theme="nord"], [data-scheme="dark"] [data-theme="nord"] {
  --bg: #2e3440; --surface: #353c4a; --surface-2: #3b4252; --surface-3: #434c5e; --border: #434c5e; --border-strong: #4c566a;
  --text: #eceff4; --text-2: #d0d6e1; --text-3: #8e99ad;
  --accent: #88c0d0; --accent-hover: #8fbcbb; --accent-strong: #88c0d0; --accent-soft: rgba(136, 192, 208, .16); --accent-text: #2e3440;
}

/* Terminal */
[data-theme="terminal"] {
  --font: var(--mono);
  --bg: #f1f5f0; --surface: #fbfdfa; --surface-2: #eaf0e8; --surface-3: #dde6da; --border: #d8e2d4; --border-strong: #bfcdb9;
  --text: #0f1f12; --text-2: #3d5541; --text-3: #7a8f7c;
  --accent: #15803d; --accent-hover: #166534; --accent-strong: #166534; --accent-soft: rgba(21, 128, 61, .10); --accent-text: #ffffff;
  --radius: 4px; --radius-lg: 6px; --radius-xl: 8px;
}
[data-scheme="dark"][data-theme="terminal"], [data-scheme="dark"] [data-theme="terminal"] {
  --bg: #050805; --surface: #0a0f0a; --surface-2: #0f1710; --surface-3: #152016; --border: #1a2a1c; --border-strong: #274029;
  --text: #b8f5c4; --text-2: #6fcf83; --text-3: #3f7d4c;
  --accent: #22c55e; --accent-hover: #4ade80; --accent-strong: #4ade80; --accent-soft: rgba(34, 197, 94, .14); --accent-text: #021006;
}

/* Folder mode: a light reading pane inside a dark page.
   The rules above use “[data-scheme="dark"] [data-theme]” (any dark ancestor);
   these compound selectors come later with the same specificity, so the pane’s
   own scheme wins. A dark pane in a light page needs nothing extra. */
[data-scheme="light"][data-theme] {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-3: #e7e9ec;
  --border: #e3e5e8;
  --border-strong: #d0d4d9;
  --text: #111418;
  --text-2: #4b5360;
  --text-3: #8b929c;

  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, .10);
  --warn: #b45309;
  --warn-strong: #92400e;
  --warn-soft: rgba(217, 119, 6, .12);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .10);
  --info: #2563eb;
  --info-strong: #1e40af;
  --info-soft: rgba(37, 99, 235, .10);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-xl: 0 24px 64px -12px rgba(16, 24, 40, .32);

  /* Graphite accent (default) */
  --accent: #1f2329;
  --accent-hover: #3a4049;
  --accent-strong: #1f2329;
  --accent-soft: rgba(31, 35, 41, .08);
  --accent-text: #ffffff;

}
[data-scheme="light"][data-theme="indigo"] {
  --bg: #f5f6fa; --surface-2: #f0f2f7; --surface-3: #e5e8f0; --border: #e1e4ec; --border-strong: #cdd2de;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-strong: #4338ca; --accent-soft: rgba(79, 70, 229, .10); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="ocean"] {
  --bg: #f3f7fa; --surface-2: #edf3f7; --surface-3: #e0e9f0; --border: #dde6ed; --border-strong: #c7d4de;
  --accent: #0369a1; --accent-hover: #075985; --accent-strong: #075985; --accent-soft: rgba(3, 105, 161, .10); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="teal"] {
  --bg: #f4f6f8; --surface-2: #f1f3f6; --surface-3: #e8ecf0; --border: #e2e6eb; --border-strong: #cfd6de;
  --accent: #0f766e; --accent-hover: #115e59; --accent-strong: #0f766e; --accent-soft: rgba(15, 118, 110, .10); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="amethyst"] {
  --bg: #f7f5fa; --surface-2: #f3f0f8; --surface-3: #e9e4f2; --border: #e5e0ee; --border-strong: #d2cbe0;
  --accent: #7c3aed; --accent-hover: #6d28d9; --accent-strong: #6d28d9; --accent-soft: rgba(124, 58, 237, .10); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="sand"] {
  --bg: #f6f2eb; --surface: #fffcf7; --surface-2: #f2ece2; --surface-3: #e9e0d2; --border: #e6ddcf; --border-strong: #d5c8b4;
  --text: #221c14; --text-2: #5c5143; --text-3: #978a78;
  --accent: #b45309; --accent-hover: #92400e; --accent-strong: #92400e; --accent-soft: rgba(180, 83, 9, .10); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="rose"] {
  --bg: #faf5f6; --surface-2: #f7f0f2; --surface-3: #efe4e7; --border: #ede2e5; --border-strong: #dccbd0;
  --accent: #e11d48; --accent-hover: #be123c; --accent-strong: #be123c; --accent-soft: rgba(225, 29, 72, .09); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="nord"] {
  --bg: #eceff4; --surface: #f8f9fb; --surface-2: #e5e9f0; --surface-3: #d8dee9; --border: #d8dee9; --border-strong: #c2cad8;
  --text: #2e3440; --text-2: #4c566a; --text-3: #7b8699;
  --accent: #5e81ac; --accent-hover: #4c6d96; --accent-strong: #4c6d96; --accent-soft: rgba(94, 129, 172, .14); --accent-text: #ffffff;
}
[data-scheme="light"][data-theme="terminal"] {
  --font: var(--mono);
  --bg: #f1f5f0; --surface: #fbfdfa; --surface-2: #eaf0e8; --surface-3: #dde6da; --border: #d8e2d4; --border-strong: #bfcdb9;
  --text: #0f1f12; --text-2: #3d5541; --text-3: #7a8f7c;
  --accent: #15803d; --accent-hover: #166534; --accent-strong: #166534; --accent-soft: rgba(21, 128, 61, .10); --accent-text: #ffffff;
  --radius: 4px; --radius-lg: 6px; --radius-xl: 8px;
}
#contentPane[data-scheme="dark"] { color-scheme: dark; }
#contentPane[data-scheme="light"] { color-scheme: light; }

/* Note typography (on <html> for the vault default, on #contentPane for a folder's own choice) */
[data-note-font="serif"] { --note-font: var(--serif); }
[data-note-font="mono"] { --note-font: var(--mono); }
[data-note-size="s"] { --note-size: 14px; }
[data-note-size="l"] { --note-size: 17px; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: var(--mono); font-size: .92em; }
[hidden], .hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* never let content widen the page */
  grid-template-rows: var(--appbar-h) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.app[data-view="welcome"] .vaultOnly,
.app[data-view="welcome"] #vaultView { display: none !important; }
.app[data-view="vault"] #welcomeView { display: none !important; }

.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brandMark {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-text);
}
.brandMark svg { width: 18px; height: 18px; stroke-width: 2; }
.brandName { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.tag {
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.appbarStatus { flex: 1; min-width: 0; display: flex; justify-content: center; }
.appbarActions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.stateChip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; max-width: 100%;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stateChip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.stateChip[data-state="none"] { display: none; }
.stateChip .chipShort { display: none; }
.stateChip span { overflow: hidden; text-overflow: ellipsis; }
.stateChip[data-state="dirty"] { color: var(--warn); background: var(--warn-soft); }
.stateChip[data-state="pending"] { color: var(--info); background: var(--info-soft); }
.stateChip[data-state="exported"] { color: var(--ok); background: var(--ok-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, opacity .12s;
  position: relative;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btnIcon { display: contents; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 38px; padding: 0; }
.btn.block { width: 100%; }
.btn.lg { height: 46px; font-size: 15px; }
.btn.hasDot::after {
  content: ""; position: absolute; top: -3px; right: -3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn); border: 2px solid var(--surface);
}

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select.input {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; min-width: 0; }
.fieldLabel { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }
.inputWrap { position: relative; display: block; }
.inputWrap .input { padding-right: 46px; }
.inputIcon { position: absolute; top: 50%; right: 3px; transform: translateY(-50%); width: 34px !important; height: 34px; }

/* ---------- Welcome ---------- */
.welcome {
  overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px calc(32px + env(safe-area-inset-bottom));
}
@media (min-height: 780px) { .welcome { align-items: center; } }
.welcomeCard {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  display: grid; gap: 20px;
}
.welcomeHead h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.02em; line-height: 1.2; }
.welcomeHead p { margin: 0; color: var(--text-2); font-size: 14px; }
.stack { display: grid; gap: 16px; }

.dropArea {
  position: relative;
  display: grid; justify-items: center; gap: 4px;
  text-align: center;
  padding: 22px 44px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropArea:hover { border-color: var(--text-3); }
.dropIcon { color: var(--text-3); margin-bottom: 4px; }
.dropIcon svg { width: 26px; height: 26px; }
.dropArea strong { color: var(--text); font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.dropArea.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropArea.hasFile { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.dropArea.hasFile .dropIcon { color: var(--accent-strong); }
.clearSource { position: absolute; top: 6px; right: 6px; width: 32px !important; height: 32px; }

.localCopyBox {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color .12s, background .12s;
}
.localCopyBox.selected { border-color: var(--accent); background: var(--accent-soft); }
.localCopyUse {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text);
  text-align: left; cursor: pointer;
}
.localCopyUse:hover { background: var(--surface-2); }
.localCopyUse:disabled { cursor: not-allowed; opacity: .6; }
.localCopyIcon { color: var(--text-2); display: grid; place-items: center; flex: 0 0 auto; }
.localCopyIcon svg { width: 22px; height: 22px; }
.localCopyText { display: grid; min-width: 0; }
.localCopyText strong { font-size: 14px; }
.localCopyText span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.disclosure > summary {
  cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
  content: ""; width: 7px; height: 7px;
  border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure textarea { margin-top: 10px; min-height: 110px; font-size: 12.5px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.trustList {
  list-style: none; margin: 0; padding: 16px 0 0;
  border-top: 1px solid var(--border);
  display: grid; gap: 9px;
  font-size: 13px; color: var(--text-2);
}
.trustList li { display: flex; align-items: center; gap: 10px; }
.trustList svg { width: 16px; height: 16px; color: var(--ok); flex: 0 0 auto; }

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w, minmax(250px, 300px)) minmax(0, 1fr);
  min-height: 0;
}
.sidebar {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.sidebarHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 8px 18px; }
.sidebarTitle {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toolbar { display: flex; gap: 2px; flex: 0 0 auto; }
.toolbar .btn.icon { width: 34px; height: 34px; }
.treeScroll { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 8px; overscroll-behavior: contain; }

.tree { list-style: none; margin: 0; padding: 0; }
.node {
  display: flex; align-items: center; gap: 6px;
  height: var(--row-h);
  padding: 0 4px 0 calc(6px + var(--depth, 0) * 16px);
  border-radius: 8px;
  cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
}
.node:hover { background: var(--surface-2); }
.node.active { background: var(--accent-soft); color: var(--accent-strong); }
.node.active .nodeName { font-weight: 600; }
.node.dragging { opacity: .5; }
.node.drop-ok { box-shadow: inset 0 0 0 2px var(--accent); }
.node.drop-bad { box-shadow: inset 0 0 0 2px var(--danger); }
/* Drop badge: says what the drop will do (“Move into …”, “becomes a folder”, “Already in …”) */
.node { position: relative; }
.node[data-drop-hint]::after {
  content: attr(data-drop-hint);
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5;
  background: var(--accent); color: var(--accent-text);
  box-shadow: var(--shadow-sm); pointer-events: none; z-index: 2;
}
.node.drop-bad[data-drop-hint]::after { background: var(--danger); color: #fff; }
.trashButton.drop-ok { box-shadow: inset 0 0 0 2px var(--danger); background: var(--danger-soft); color: var(--danger); }
.nodeIcon { width: 18px; height: 18px; display: grid; place-items: center; color: var(--text-2); flex: 0 0 auto; }
.node.active .nodeIcon { color: inherit; }
.nodeIcon svg { width: 17px; height: 17px; }
.nodeIcon.locked { color: var(--warn); }
.nodeIcon.unlocked { color: var(--ok); }
.nodeName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.treeToggle {
  width: 20px; height: 20px; flex: 0 0 20px;
  padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-3);
  display: grid; place-items: center; cursor: pointer;
}
.treeToggle:hover { background: var(--surface-3); color: var(--text); }
.treeToggle svg { width: 13px; height: 13px; transition: transform .14s; }
.treeToggle.expanded svg { transform: rotate(90deg); }
.treeToggleSpacer { width: 20px; flex: 0 0 20px; }
.rowMore {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2);
  display: grid; place-items: center;
  opacity: 0; cursor: pointer;
}
.rowMore svg { width: 17px; height: 17px; }
.node:hover .rowMore, .node:focus-within .rowMore, .node.active .rowMore { opacity: 1; }
.rowMore:hover { background: var(--surface-3); color: var(--text); }

.trashButton {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 8px 0; padding: 0 12px;
  height: 38px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2);
  font-size: 14px; cursor: pointer; text-align: left;
}
.trashButton:hover { background: var(--surface-2); color: var(--text); }
.trashButton.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.trashButtonIcon svg { width: 17px; height: 17px; display: block; }
.trashButtonLabel { flex: 1; }
.trashCount { font-size: 12px; color: var(--text-3); font-weight: 500; }

.trashView { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 16px; }
.trashHead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.trashHead h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.trashHead p { margin: 2px 0 0; font-size: 13px; }
.trashList { display: grid; gap: 8px; }
.trashItem {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
}
.trashItem.sealed { border-style: dashed; }
.trashMain {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 10px 12px;
  border: 0; background: transparent; color: var(--text);
  text-align: left; cursor: pointer;
}
.trashMain:hover { background: var(--surface-2); }
.trashItemIcon { color: var(--text-2); flex: 0 0 auto; display: grid; place-items: center; }
.trashItemIcon svg { width: 20px; height: 20px; }
.trashItem.sealed .trashItemIcon { color: var(--warn); }
.trashItemText { display: grid; min-width: 0; }
.trashItemText strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trashItemText small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trashActions { display: flex; gap: 4px; padding: 0 8px; }
.trashActions .btn { height: 34px; }
.trashActions .btn.icon { width: 34px; }
.trashPreview { grid-column: 1 / -1; padding: 12px 16px 16px; border-top: 1px solid var(--border); max-height: 50vh; overflow: auto; }
.trashChildren { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.trashChildren li { display: flex; align-items: center; gap: 8px; }
.trashChildren svg { width: 16px; height: 16px; color: var(--text-2); }

.treeDrop {
  margin: 4px 12px 12px;
  padding: 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 12.5px; color: var(--text-3);
}
.treeDrop.dragover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }

/* ---------- Content ---------- */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: var(--pad-content); gap: 12px; }
/* The reading pane carries the folder theme (same palette tokens, scoped). */
#contentPane[data-theme] { background: var(--bg); color: var(--text); font-family: var(--font); transition: background-color .18s ease; }
.contentBar { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.breadcrumb {
  display: flex; align-items: center; gap: 2px;
  min-width: 0; overflow-x: auto; white-space: nowrap;
  scrollbar-width: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.crumb {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; max-width: 240px;
  padding: 0 8px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-size: 13.5px; cursor: pointer; flex: 0 0 auto;
}
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.crumb svg { width: 15px; height: 15px; flex: 0 0 auto; }
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumbSep { color: var(--text-3); flex: 0 0 auto; }
.mobileOnly { display: none !important; }

.emptyState {
  flex: 1;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  text-align: center; color: var(--text-2);
  padding: 32px 16px;
}
.emptyState > svg, .emptyState .emptyIcon svg { width: 44px; height: 44px; color: var(--text-3); stroke-width: 1.4; }
.emptyState h2 { margin: 0; font-size: 17px; color: var(--text); }
.emptyState p { margin: 0; max-width: 380px; font-size: 14px; }
.emptyActions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.editor {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.editorHead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.nameInput {
  flex: 1 1 220px; min-width: 0;
  height: 38px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text);
  font-size: 16px; font-weight: 700; letter-spacing: -.01em;
}
.nameInput:hover { border-color: var(--border); }
.nameInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.editorTools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.metaText { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }

.contentRegion { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.previewBox, .noteSource, .noteEditor, .textFileEditor {
  flex: 1; min-height: 0;
  overflow: auto;
  margin: 0; border: 0;
  padding: var(--pad-editor);
  background: transparent;
  color: var(--text);
}
.noteSource, .textFileEditor {
  width: 100%; resize: none;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.65; tab-size: 2;
}
.noteSource:focus, .textFileEditor:focus, .noteEditor:focus { outline: none; }
.noteEditor { font-family: var(--note-font); font-size: var(--note-size); line-height: 1.7; }
.noteEditor a { color: var(--accent-strong); }
.noteEditor img { max-width: 100%; height: auto; }
.noteEditor pre, .noteEditor code { font-family: var(--mono); }
.noteEditor pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow: auto; }
.noteEditor blockquote { margin: .8em 0; padding: .2em .9em; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }

.editorFoot {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
  white-space: nowrap;
}
.editorHints { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.itemDates { flex: 0 1 auto; margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.editorFoot code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- Markdown preview ---------- */
.notePreview { font-family: var(--note-font); font-size: var(--note-size); line-height: 1.7; overflow-wrap: anywhere; }
.notePreview > :first-child { margin-top: 0; }
.notePreview > :last-child { margin-bottom: 0; }
.notePreview h1, .notePreview h2, .notePreview h3, .notePreview h4, .notePreview h5, .notePreview h6 {
  line-height: 1.25; margin: 1.3em 0 .5em; letter-spacing: -.015em;
}
.notePreview h1 { font-size: 1.8em; }
.notePreview h2 { font-size: 1.45em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.notePreview h3 { font-size: 1.2em; }
.notePreview p { margin: .6em 0; }
.notePreview ul, .notePreview ol { margin: .5em 0 .9em; padding-left: 1.5em; }
.notePreview li { margin: .2em 0; }
.notePreview li.taskItem { list-style: none; margin-left: -1.3em; display: flex; gap: .55em; align-items: baseline; }
.notePreview .task {
  width: 14px; height: 14px; flex: 0 0 14px;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  transform: translateY(2px);
}
.notePreview .task.done { background: var(--accent); border-color: var(--accent); }
.notePreview blockquote {
  margin: .9em 0; padding: .3em 1em;
  border-left: 3px solid var(--accent);
  background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text-2);
}
.notePreview hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.notePreview code {
  padding: .1em .38em;
  border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.notePreview pre {
  margin: 1em 0; padding: 14px 16px;
  overflow: auto;
  border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.notePreview pre[data-lang]:not([data-lang=""])::before {
  content: attr(data-lang);
  display: block; margin-bottom: 8px;
  font: 700 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}
.notePreview pre code { display: block; padding: 0; border: 0; background: transparent; white-space: pre; font-size: 13px; line-height: 1.6; }
.notePreview a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.notePreview .wiki-link { text-decoration: none; border-bottom: 1px dashed currentColor; cursor: pointer; }
.notePreview .wiki-link::before { content: "[["; opacity: .35; }
.notePreview .wiki-link::after { content: "]]"; opacity: .35; }
.notePreview .wiki-link.missing { color: var(--danger); opacity: .85; }
.notePreview .wiki-link.md-link::before, .notePreview .wiki-link.md-link::after { content: none; }
.notePreview .file-link, .notePreview .heading-link { text-decoration: none; border-bottom: 1px dashed currentColor; cursor: pointer; }
.notePreview .ext-link::after {
  content: "↗"; display: inline-block; margin-left: .15em;
  font-size: .75em; text-decoration: none; opacity: .6;
}

/* Foldable headings */
.notePreview .foldable { position: relative; }
.notePreview .foldToggle {
  position: absolute; left: -1.35em; top: 50%; transform: translateY(-50%);
  width: 1.15em; height: 1.15em; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 5px; background: transparent; color: var(--text-3);
  cursor: pointer; opacity: 0; transition: opacity .12s, transform .12s;
}
.notePreview .foldToggle svg { width: .8em; height: .8em; transform: rotate(90deg); transition: transform .12s; }
.notePreview .foldable:hover .foldToggle, .notePreview .foldToggle:focus-visible, .notePreview .folded .foldToggle { opacity: 1; }
.notePreview .foldToggle:hover { color: var(--text); background: var(--surface-2); }
.notePreview .folded .foldToggle svg { transform: none; }
.notePreview .folded::after { content: " …"; color: var(--text-3); font-weight: 400; }
.notePreview .foldHidden { display: none !important; }
@media (hover: none) { .notePreview .foldToggle { opacity: .55; } }
.notePreview .wiki-link.ambiguous { color: var(--warn); }
.notePreview .wiki-embed-image {
  display: block; max-width: 100%; max-height: 72vh;
  width: auto; height: auto;
  margin: 1em auto;
  object-fit: contain;
  border-radius: 10px; border: 1px solid var(--border);
}
/* Embedded image: click opens the file, the corner handle resizes it */
.notePreview .embedFrame { position: relative; display: inline-block; vertical-align: top; max-width: 100%; margin: .25em .15em; line-height: 0; }
.notePreview .embedRow { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 12px; margin: 1em 0; }
.notePreview .embedLines { text-align: center; margin: 1em 0; }
.notePreview .embedLines .embedFrame { margin: 6px; }
.notePreview .embedRow .embedFrame { margin: 0; }
.notePreview .embedFrame .wiki-embed-image { margin: 0; cursor: pointer; }
.notePreview .embedFrame .wiki-embed-image:hover { border-color: var(--accent); }
.embedResize {
  position: absolute; right: -7px; bottom: -7px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface); box-shadow: var(--shadow-sm);
  cursor: nwse-resize; touch-action: none;
  opacity: 0; transition: opacity .12s ease;
}
.embedFrame:hover .embedResize, .embedResize:focus-visible, .embedFrame.resizing .embedResize { opacity: 1; }
.embedResize:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.embedFrame.resizing .wiki-embed-image { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .embedResize { opacity: .85; } }
.notePreview .wiki-embed {
  display: inline-block; padding: .1em .45em;
  border-radius: 7px; border: 1px dashed var(--border-strong);
  font-family: var(--mono); font-size: .9em;
}
.notePreview .wiki-embed.missing { border-color: var(--danger); color: var(--danger); }
.notePreview .wiki-embed.ambiguous { border-color: var(--warn); color: var(--warn); }
.notePreview .wiki-embed.unsupported { opacity: .7; }
.htmlNotePreviewFrame { width: 100%; height: 100%; min-height: 420px; border: 0; border-radius: 8px; background: #fff; display: block; }
.imgPreview { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 10px; border: 1px solid var(--border); }
.binaryNote { display: grid; place-items: center; gap: 8px; padding: 40px 0; color: var(--text-2); text-align: center; }
.videoPreview { display: block; width: 100%; max-height: 70vh; border-radius: 10px; background: #000; }
.audioPreview { display: block; width: 100%; margin: 24px 0; }
.pdfPreviewFrame { display: block; width: 100%; height: 100%; min-height: 70vh; border: 0; border-radius: 8px; background: #fff; }
.emptyHint { color: var(--text-3); font-style: italic; }

/* Page: children listed under the text */
.pageChildren { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-family: var(--font); }
.pageChildren.noText { margin-top: 12px; }
.addFolderText { height: 34px; padding: 0 12px; font-size: 13.5px; color: var(--text-2); border: 1px dashed var(--border-strong); font-family: var(--font); }
.addFolderText:hover { color: var(--text); border-color: var(--accent); }
.pageChildrenHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pageChildrenHead > span { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.pageChildrenActions { display: flex; flex-wrap: wrap; gap: 4px; }
.pageChildrenActions .btn { height: 32px; padding: 0 10px; font-size: 13px; }
.pageChildrenGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.childCard {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 10px 12px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.childCard:hover { border-color: var(--border-strong); background: var(--surface-2); }
.childIcon { grid-row: span 2; color: var(--text-2); display: grid; place-items: center; }
.childIcon svg { width: 20px; height: 20px; }
.childName { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.childMeta { font-size: 12px; color: var(--text-3); }

.binaryNote svg { width: 36px; height: 36px; color: var(--text-3); stroke-width: 1.4; }

/* ---------- Secret widgets: ```entry and ```totp ---------- */
.secretWidget { margin: 1em 0; }
.entryCard {
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}
.entryRow {
  display: grid;
  grid-template-columns: minmax(90px, 30%) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 6px 6px 14px;
}
.entryRow + .entryRow { border-top: 1px solid var(--border); }
.entryKey { font-size: 12.5px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entryVal { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text); }
.entryVal.mono { font-family: var(--mono); font-size: 13px; }
.entryVal.masked { letter-spacing: .12em; color: var(--text-3); user-select: none; }
/* Masked values (and revealed secrets) copy on click, like 2FA codes */
button.entryVal { appearance: none; border: 0; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; text-align: left; font: inherit; cursor: pointer; }
button.entryVal.mono { font-family: var(--mono); font-size: 13px; }
button.entryVal:hover { background: var(--surface-2); }
button.entryVal:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.entryVal a { color: var(--accent-strong); text-decoration: none; }
.entryVal a:hover { text-decoration: underline; }
.entryActions { display: flex; gap: 2px; }
.miniBtn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2);
  cursor: pointer;
}
.miniBtn svg { width: 16px; height: 16px; }
.miniBtn:hover { background: var(--surface-2); color: var(--text); }
.entryEmpty { padding: 12px 14px; font-size: 13px; color: var(--text-3); }

.otpRow { grid-template-columns: minmax(90px, 30%) auto 1fr auto; }
.otpCode {
  justify-self: start;
  padding: 2px 8px; margin-left: -8px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--accent-strong);
  font-size: 22px; font-weight: 700; letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.otpCode:hover { background: var(--accent-soft); }
.otpCode:disabled { cursor: default; color: var(--danger); font-size: 14px; letter-spacing: 0; }
.otpTimer {
  --p: 1;
  justify-self: start;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--surface-3) 0);
  font: 700 10px/1 var(--mono); color: var(--text-2);
  position: relative;
}
.otpTimer::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface); }
.otpTimer span { position: relative; }
.otpExpiring .otpTimer { background: conic-gradient(var(--warn) calc(var(--p) * 360deg), var(--surface-3) 0); }
.otpExpiring .otpCode { color: var(--warn); }
.otpCounter { font: 600 12px/1 var(--mono); color: var(--text-3); }
.otpError .entryKey { color: var(--danger); }
.totpCard .entryRow { min-height: 52px; }

/* ---------- Import dialogs ---------- */
.importHow { line-height: 1.45; }
.filePickRow {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.filePickRow.dragover, .filePickRow.hasFile { border-color: var(--accent); background: var(--accent-soft); }
.filePickRow.hasFile { border-style: solid; }
.filePickName { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.statGrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat {
  display: grid; gap: 2px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.stat strong { font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--text-2); }
.callout.list p { white-space: pre-line; }

/* ---------- Camera ---------- */
.cameraStage {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 56dvh;
  width: 100%;
  border-radius: var(--radius-lg);
  background: #000;
  overflow: hidden;
}
.cameraVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanReticle {
  position: absolute; left: 50%; top: 50%;
  width: min(62%, 280px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28);
  border: 2px solid rgba(255, 255, 255, .85);
  pointer-events: none;
}
.cameraPlaceholder {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 20px; text-align: center;
  background: var(--surface-2); color: var(--text-2); font-size: 14px;
}
.cameraPlaceholder svg { width: 36px; height: 36px; color: var(--text-3); }
.cameraSwitch {
  position: absolute; right: 10px; top: 10px;
  background: rgba(0, 0, 0, .45) !important; border-color: transparent !important; color: #fff !important;
}
.cameraStatus { font-size: 13.5px; color: var(--text-2); }
.cameraTools { display: flex; gap: 8px; flex-wrap: wrap; }
.scanResult {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--accent); border-radius: var(--radius-lg);
  background: var(--accent-soft);
  animation: pop .14s ease-out;
}
.scanResultIcon { color: var(--accent-strong); display: grid; place-items: center; }
.scanResultIcon svg { width: 22px; height: 22px; }
.scanResultText { display: grid; min-width: 0; }
.scanResultText strong { font-size: 14.5px; overflow-wrap: anywhere; }
.scanResultText span { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.scanResultActions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.scanResultActions .btn { height: 36px; }

/* ---------- Image metadata dialog ---------- */
.modal.xl { width: min(800px, calc(100vw - 24px)); }
.metaBody { display: grid; gap: 12px; min-width: 0; }
.metaSummary { font-size: 13px; color: var(--text-2); }
.metaGroup { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.metaGroup > summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 6px 8px 6px 14px;
  background: var(--surface-2);
  font-size: 13.5px; font-weight: 700;
  cursor: pointer; list-style: none;
}
.metaGroup > summary::-webkit-details-marker { display: none; }
.metaGroup > summary::before {
  content: ""; width: 6px; height: 6px; flex: 0 0 auto;
  border-right: 1.6px solid var(--text-3); border-bottom: 1.6px solid var(--text-3);
  transform: rotate(-45deg); transition: transform .15s;
}
.metaGroup[open] > summary::before { transform: rotate(45deg); }
.metaGroup > summary .count { color: var(--text-3); font-weight: 500; }
.metaSmallBtn { height: 30px !important; padding: 0 10px; font-size: 12.5px; margin-left: auto; }
.metaValue .metaSmallBtn { margin-left: 0; justify-self: start; }
.metaRow {
  display: grid; grid-template-columns: minmax(130px, 32%) minmax(0, 1fr) auto;
  gap: 4px 12px; align-items: start;
  padding: 8px 6px 8px 14px;
  border-top: 1px solid var(--border);
}
.metaGroup > .metaRow:first-of-type { border-top: 0; }
.metaName { display: grid; gap: 2px; padding-top: 7px; font-size: 13px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.metaName small { font: 500 11px/1.3 var(--mono); color: var(--text-3); }
.metaBadge {
  justify-self: start; margin-top: 2px;
  padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  background: var(--warn-soft); color: var(--warn);
}
.metaValue { display: grid; gap: 4px; min-width: 0; }
.metaValue .input { height: 36px; font-size: 13.5px; }
.metaValue textarea.input { height: auto; font-size: 13px; }
.metaValue textarea.mono { font-family: var(--mono); font-size: 12px; line-height: 1.45; }
.metaStatic { padding-top: 7px; font-size: 13.5px; color: var(--text); overflow-wrap: anywhere; }
.metaHint { font-size: 11.5px; color: var(--text-3); overflow-wrap: anywhere; }
.metaError { font-size: 12px; color: var(--danger); }
.metaError:empty { display: none; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.metaRow.removed .metaName > span:first-child, .metaRow.removed .metaStatic { text-decoration: line-through; opacity: .5; }
.metaRow.removed .metaValue > :not(.metaStatic):not(.metaHint) { opacity: .45; }
.metaToggle { width: auto; min-width: 36px; height: 34px !important; padding: 0 8px; }
.metaToggle span { font-size: 12.5px; }
.danger-text { color: var(--danger) !important; }
.metaProps { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; margin: 6px 0 0; font-size: 12.5px; }
.metaProps dt { color: var(--text-2); font-family: var(--mono); font-size: 11.5px; }
.metaProps dd { margin: 0; overflow-wrap: anywhere; }
.metaThumb { max-width: 180px; max-height: 140px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.metaAdd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 8px; padding: 10px 12px 4px; }
.metaGroup > .metaError { padding: 0 12px 10px; }
.metaStrip { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--danger); border-radius: var(--radius-lg); }
.metaStrip .btnRow { justify-content: flex-end; }
.metaStrip .btnRow .btn { flex: 0 0 auto; }

/* ---------- Menus (popover on desktop, action sheet on touch) ---------- */
.menuLayer { position: fixed; inset: 0; z-index: 900; }
.menuBackdrop { position: absolute; inset: 0; }
.menuPanel {
  position: absolute;
  min-width: 230px; max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: grid; gap: 1px;
  animation: pop .12s ease-out;
}
.menuItem {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text);
  font-size: 14px; text-align: left; cursor: pointer;
}
.menuItem svg { width: 17px; height: 17px; color: var(--text-2); flex: 0 0 auto; }
.menuItem:hover, .menuItem:focus-visible { background: var(--surface-2); outline: none; }
.menuItem.danger { color: var(--danger); }
.menuItem.danger svg { color: currentColor; }
.menuItem:disabled { opacity: .45; cursor: not-allowed; }
.menuSep { height: 1px; background: var(--border); margin: 5px 4px; }
.menuTitle {
  padding: 4px 10px 10px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menuLayer.sheetMode .menuBackdrop { background: rgba(8, 12, 18, .5); animation: fade .15s; }
.menuLayer.sheetMode .menuPanel {
  left: 8px; right: 8px; bottom: 8px; top: auto;
  min-width: 0; max-width: none; max-height: 82dvh; overflow: auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-radius: 18px;
  animation: sheetUp .2s ease-out;
}
.menuLayer.sheetMode .menuItem { height: 50px; font-size: 16px; padding: 0 14px; gap: 14px; }
.menuLayer.sheetMode .menuItem svg { width: 20px; height: 20px; }
.menuCancel { justify-content: center; font-weight: 600; margin-top: 6px; background: var(--surface-2) !important; }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); }
.modal {
  width: min(460px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  overflow: auto;
  overscroll-behavior: contain;
}
.modal.wide { width: min(560px, calc(100vw - 24px)); }
.modal[open] { animation: pop .16s ease-out; }
.modal::backdrop, .drawer::backdrop, .busy::backdrop { background: rgba(8, 12, 18, .55); }
.modalForm { display: grid; gap: 18px; padding: 22px; }
.modalHead { display: flex; align-items: flex-start; gap: 12px; }
.modalIcon {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.modalIcon svg { width: 20px; height: 20px; }
.modal.danger .modalIcon { background: var(--danger-soft); color: var(--danger); }
.modal.warn .modalIcon { background: var(--warn-soft); color: var(--warn); }
.modalTitles { flex: 1; min-width: 0; }
.modalTitle { margin: 1px 0 4px; font-size: 17px; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
.modalText { margin: 0; font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-line; }
.modalClose { margin: -6px -8px 0 0; }
.modalContent { display: grid; gap: 14px; min-width: 0; }
.modalContent:empty { display: none; }
.formError { font-size: 13.5px; color: var(--danger); font-weight: 500; }
.formError:empty { display: none; }
.modalActions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modalForm.pending .btn[type="submit"] { color: transparent !important; pointer-events: none; }
.modalForm.pending .btn[type="submit"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--accent-text); border-right-color: transparent; opacity: .85;
  animation: spin .8s linear infinite;
}
.pendingNote { font-size: 13px; color: var(--text-2); display: none; }
.modalForm.pending .pendingNote { display: block; }

.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; line-height: 1.5; }
.callout svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.callout.warn { background: var(--warn-soft); color: var(--warn-strong); }
.callout.info { background: var(--info-soft); color: var(--info-strong); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.callout p { margin: 0; }

.choiceList { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice.checked { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 auto; }
.choice strong { display: block; font-size: 14px; }
.choice span { display: block; font-size: 13px; color: var(--text-2); }
.checkRow { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; cursor: pointer; }
.checkRow input { margin: 3px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 auto; }
.checkRow small { display: block; color: var(--text-2); font-size: 12.5px; }

.folderList {
  max-height: min(50dvh, 360px); overflow: auto;
  display: grid; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px;
}
.folderOption {
  display: flex; align-items: center; gap: 8px;
  min-height: 38px;
  padding: 0 10px 0 calc(10px + var(--depth, 0) * 16px);
  border-radius: 7px; cursor: pointer; font-size: 14px;
}
.folderOption:hover { background: var(--surface-2); }
.folderOption.checked { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.folderOption.disabled { opacity: .45; cursor: not-allowed; }
.folderOption input { position: absolute; opacity: 0; pointer-events: none; }
.folderOption svg { width: 17px; height: 17px; flex: 0 0 auto; }
.folderOption em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--text-3); }

.strength { display: grid; gap: 6px; }
.strengthBar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.strengthBar > span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }
.strength[data-score="2"] .strengthBar > span { background: var(--warn); }
.strength[data-score="3"] .strengthBar > span { background: var(--info); }
.strength[data-score="4"] .strengthBar > span { background: var(--ok); }
.strengthText { font-size: 12.5px; color: var(--text-2); }

.pinInput { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; height: 52px; }
.qrHolder { display: grid; place-items: center; background: #fff; padding: 16px; border-radius: var(--radius); }
.qrHolder img, .qrHolder canvas { width: 100%; max-width: 380px; height: auto; image-rendering: pixelated; }

/* ---------- Drawer ---------- */
.drawer {
  margin: 0 0 0 auto;
  width: min(520px, 100vw); max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  padding: 0;
  border: 0; border-left: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.drawer[open] { display: flex; flex-direction: column; animation: slideIn .2s ease-out; }
.drawerHead {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawerHead h2 { margin: 0; font-size: 16px; flex: 1; }
.drawerBody {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; align-content: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid; gap: 12px;
  min-width: 0;
}
.cardHead { display: flex; align-items: flex-start; gap: 12px; }
.cardIcon {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.cardIcon svg { width: 18px; height: 18px; }
.cardHead h3 { margin: 0; font-size: 15px; }
.cardHead p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.blobState { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.blobState .badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.blobOut {
  width: 100%; height: 92px; resize: vertical;
  padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-2);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.4;
}
.btnRow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnRow .btn { flex: 1 1 auto; }
.carrierRow { display: flex; align-items: center; gap: 12px; min-width: 0; }
.carrierThumb {
  width: 56px; height: 56px; flex: 0 0 56px;
  border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-2);
}
.carrierText { min-width: 0; }
.carrierName { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
#carrierInfo { overflow-wrap: anywhere; white-space: pre-line; }
.carrierOption { min-height: 48px; }
.carrierOptionText { display: grid; min-width: 0; }
.carrierOptionText span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carrierOptionText small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.flash { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); transition: box-shadow .3s, border-color .3s; }

/* ---------- Appearance picker ---------- */
.themeGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.themeCard {
  display: block; padding: 0; overflow: hidden; cursor: pointer; text-align: left;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text); font-family: var(--font);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.themeCard:hover { transform: translateY(-1px); }
.themeCard.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.themeMock { height: 62px; display: grid; grid-template-columns: 32% 1fr; background: var(--bg); }
.themeMock .side { background: var(--surface); border-right: 1px solid var(--border); padding: 9px 7px; display: grid; gap: 5px; align-content: start; }
.themeMock .side i { display: block; height: 4px; border-radius: 2px; background: var(--border-strong); }
.themeMock .side i.on { background: var(--accent); }
.themeMock .main { padding: 9px; display: grid; gap: 5px; align-content: start; }
.themeMock .main b { display: block; height: 6px; width: 70%; border-radius: 3px; background: var(--text); opacity: .85; }
.themeMock .main i { display: block; height: 4px; width: 92%; border-radius: 2px; background: var(--text-3); opacity: .6; }
.themeMock .main u { display: block; height: 11px; width: 42%; border-radius: 4px; background: var(--accent); margin-top: 2px; }
.themeName { display: block; padding: 7px 9px; font-size: 12.5px; font-weight: 700; background: var(--surface); border-top: 1px solid var(--border); color: var(--text); }
.themeName small { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.optionRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.optionRow > span { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.optionRow .segmented button { height: 32px; }
.folderLookBody { display: grid; gap: 14px; }

/* Language switcher */
.langButton { gap: 5px; padding: 0 9px; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.langButton .langCode { line-height: 1; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Busy overlay ---------- */
.busy { border: 0; padding: 0; background: transparent; box-shadow: none; overflow: visible; max-width: calc(100vw - 32px); }
.busyCard {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  font-size: 14.5px; font-weight: 600;
}
.spinner {
  width: 22px; height: 22px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2.5px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  /* bottom-left: never covers the Export drawer (right) nor centred dialogs' actions */
  inset: auto auto 16px 16px;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--text);
  overflow: visible;
  width: min(390px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 8px 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toastIn .18s ease-out;
  transition: opacity .18s, transform .18s;
}
.toast.leaving { opacity: 0; transform: translateY(6px); }
.toastIcon { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.toastIcon svg { width: 20px; height: 20px; }
.toast.ok .toastIcon { color: var(--ok); }
.toast.warn .toastIcon { color: var(--warn); }
.toast.err .toastIcon { color: var(--danger); }
.toast.info .toastIcon { color: var(--info); }
.toast.err { border-color: var(--danger); }
.toastBody { flex: 1; min-width: 0; }
.toastTitle { font-weight: 600; overflow-wrap: anywhere; }
.toastDetail { margin-top: 3px; font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.toastAction {
  margin-top: 8px; padding: 0; border: 0; background: none;
  color: var(--accent-strong); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.toastClose {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-3);
  display: grid; place-items: center; cursor: pointer;
}
.toastClose:hover { background: var(--surface-2); color: var(--text); }
.toastClose svg { width: 15px; height: 15px; }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .4; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
@keyframes toastInTop { from { transform: translateY(-8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .spinner, .modalForm.pending .btn[type="submit"]::after { animation-duration: 1.2s !important; }
}

/* ---------- Touch devices ---------- */
@media (hover: none) {
  .rowMore { opacity: 1; }
  .miniBtn { width: 40px; height: 40px; }
  .treeDrop { display: none; }
}

/* ---------- Compact / mobile ---------- */
@media (max-width: 820px) {
  :root { --appbar-h: 56px; }

  .appbar { gap: 8px; }
  .collapseLabel { display: none; }
  .appbarActions .btn:not(.primary) { width: 42px; padding: 0; }

  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebarResizer { display: none; }
  .workspace[data-pane="tree"] .content { display: none; }
  .workspace[data-pane="content"] .sidebar { display: none; }
  .sidebar { border-right: 0; }
  .sidebarHead { padding: 12px 8px 8px 16px; }
  .toolbar .btn.icon { width: 42px; height: 42px; }
  .treeScroll { padding: 0 6px calc(12px + env(safe-area-inset-bottom)); }
  .node { height: var(--row-h-touch); border-radius: 10px; padding-left: calc(8px + var(--depth, 0) * 18px); }
  .nodeName { font-size: 16px; }
  .rowMore { width: 40px; height: 40px; }
  .treeToggle { width: 28px; height: 28px; flex-basis: 28px; }
  .treeToggleSpacer { width: 28px; flex-basis: 28px; }

  .mobileOnly { display: inline-flex !important; }
  .content { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  .editor { border-radius: 12px; }
  .editorHead { padding: 8px; gap: 8px; }
  .nameInput { flex-basis: 100%; }
  .editorTools { width: 100%; flex-wrap: nowrap; gap: 4px; }
  .editorTools .segmented { margin-right: auto; }
  .editorTools .pill { display: none; }
  .previewBox, .noteSource, .noteEditor, .textFileEditor { padding: 16px; }
  .editorHints { display: none; }
  .editorFoot { padding: 6px 12px; }
  .itemDates { margin-left: 0; text-align: left; }

  /* ≥16px prevents iOS focus zoom */
  .input, .nameInput, .noteSource, .textFileEditor, .noteEditor, textarea, select { font-size: 16px; }
  .blobOut { font-size: 11.5px; } /* read-only: no keyboard, keep it compact */
  .btn { height: 44px; }
  .btn.icon { width: 44px; }
  .inputIcon { width: 40px !important; height: 40px; }
  .input { height: 46px; }

  .modal {
    width: 100vw; max-width: 100vw;
    margin: auto 0 0;
    max-height: 94dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }
  .modal[open] { animation: sheetUp .2s ease-out; }
  .modalForm { padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
  .modalActions .btn { flex: 1 1 0; height: 48px; }

  .drawer {
    width: 100vw; height: auto; max-height: 94dvh;
    margin: auto 0 0;
    border-left: 0; border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
  }
  .drawer[open] { animation: sheetUp .2s ease-out; }
  .formGrid { grid-template-columns: 1fr; }

  /* Just below the app bar on mobile: dialogs/menus are bottom sheets and the bar stays usable. */
  .toasts { inset: calc(var(--appbar-h) + 8px + env(safe-area-inset-top)) 10px auto 10px; width: auto; }
  .toast { animation-name: toastInTop; }
  .toast.leaving { transform: translateY(-6px); }

  .welcome { padding: 20px 12px calc(20px + env(safe-area-inset-bottom)); }
  .welcomeCard { padding: 22px 18px; border-radius: 18px; gap: 18px; }
  .dropArea { padding: 20px 44px; }
}

@media (max-width: 520px) {
  .trashItem { grid-template-columns: 1fr; }
  .trashActions { padding: 0 12px 10px; justify-content: flex-end; }
  .metaRow { grid-template-columns: minmax(0, 1fr) auto; padding-left: 12px; }
  .metaRow .metaName { grid-column: 1 / -1; padding-top: 0; }
  .metaRow .metaValue { grid-column: 1; }
  .metaAdd { grid-template-columns: 1fr; }
  .statGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entryRow { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; padding-left: 12px; }
  .entryRow .entryKey { grid-column: 1 / -1; }
  .otpRow { grid-template-columns: auto 1fr auto; }
  .cameraStage { aspect-ratio: 3 / 4; }
  .scanResultActions .btn { flex: 1 1 auto; }
  .themeGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pageChildrenGrid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .appbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brandName, .tag { display: none; }
  .app[data-view="vault"] .brand { display: none; }
  .appbar { gap: 6px; }
  .stateChip { font-size: 12px; padding: 0 10px; gap: 6px; }
  .stateChip .chipLong { display: none; }
  .stateChip .chipShort { display: inline; }
  .appbarActions { gap: 6px; }
  .appbarActions .btn.primary { padding: 0 12px; }
  .metaText { display: none; }
  .langButton { padding: 0 7px; }
  .langButton svg { display: none; }
}

/* ---------- Settings dialogs (tabs) ---------- */
.tabs { display: grid; gap: 16px; }
.tabBar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabBar::-webkit-scrollbar { display: none; }
.tabButton {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 9px 12px; margin-bottom: -1px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabButton:hover { color: var(--text); }
.tabButton[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabButton:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.tabPanel { min-height: 120px; }
.settingsSection { display: grid; gap: 14px; }
.settingsRow { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.settingsRow > .input { width: auto; min-width: 220px; }
.settingsLabel { display: grid; gap: 2px; min-width: 180px; flex: 1 1 220px; }
.settingsLabel strong { font-size: 13.5px; color: var(--text); }
.settingsActions { display: flex; flex-wrap: wrap; gap: 8px; }
.settingsFoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.settingsFoot .hint { flex: 1 1 260px; }
.otherFormatSelect { margin-top: 8px; }
@media (max-width: 520px) {
  .settingsRow > .input, .settingsRow > .segmented { width: 100%; }
  .settingsRow > .segmented { overflow-x: auto; }
}

/* ---------- Search ---------- */
.searchBar { position: relative; display: flex; align-items: center; gap: 4px; margin: 0 12px 8px; }
.searchIcon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.searchIcon svg { width: 16px; height: 16px; }
.searchInput {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px 0 32px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13.5px;
}
.searchInput:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchInput { padding-right: 30px; }
.searchInput::-webkit-search-cancel-button, .searchInput::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.searchClear {
  position: absolute; right: 46px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: var(--surface-3); color: var(--text-2); cursor: pointer;
}
.searchClear svg { width: 13px; height: 13px; }
.searchClear:hover { background: var(--border-strong); color: var(--text); }
.searchClear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sidebar width: drag the right edge (desktop), double-click to reset */
.sidebarResizer {
  position: absolute; top: 0; bottom: 0; right: -5px; width: 10px; z-index: 5;
  cursor: col-resize; touch-action: none;
}
.sidebarResizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px;
  background: var(--accent); opacity: 0; transition: opacity .12s ease;
}
.sidebarResizer:hover::after, .sidebarResizer:focus-visible::after, .sidebarResizer.dragging::after { opacity: .6; }
.sidebarResizer:focus-visible { outline: none; }
body.resizingSidebar { cursor: col-resize; user-select: none; -webkit-user-select: none; }
.searchToggle {
  flex: none; height: 34px; min-width: 34px; padding: 0 7px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-3);
  font: 700 12.5px/1 var(--mono); cursor: pointer;
}
.searchToggle:hover { color: var(--text); }
.searchToggle[aria-pressed="true"] { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.searchStatus { margin: -2px 14px 8px; font-size: 12px; color: var(--text-3); line-height: 1.4; }
.searchStatus.error { color: var(--danger); }
.searchResults { display: grid; gap: 2px; padding-bottom: 8px; }
.searchHit {
  display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); cursor: pointer; font: inherit;
}
.searchHit:hover, .searchHit:focus-visible { background: var(--surface-2); outline: none; }
.searchHit.active { background: var(--accent-soft); }
.searchHit .nodeIcon { margin-top: 1px; }
.searchHitBody { display: grid; gap: 2px; min-width: 0; }
.searchHitName { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchHitPath { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchSnippet { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchSnippet.masked { font-style: italic; color: var(--text-3); }
.searchHit mark, mark.searchMark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.searchMark { box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); }

/* ---------- Sidebar views: tree | recent ---------- */
.sidebarViews { display: flex; gap: 2px; margin: 0 12px 6px; border-bottom: 1px solid var(--border); }
.sidebarTab {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  padding: 6px 10px; margin-bottom: -1px; font-size: 12.5px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent;
}
.sidebarTab:hover { color: var(--text); }
.sidebarTab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.sidebarTab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.recentSort { display: flex; margin: 2px 4px 8px; }
.recentSort button { flex: 1; height: 28px; font-size: 12px; }
.recentHit { align-items: center; }
.recentTime { margin-left: auto; flex: none; font-size: 11.5px; color: var(--text-3); white-space: nowrap; padding-left: 8px; }
.recentEmpty { margin: 12px; font-size: 13px; color: var(--text-3); }
.settingsControls { display: grid; gap: 8px; min-width: 220px; }

/* Search scope: “In <folder>” + widen to the whole vault */
.searchScope { display: flex; align-items: center; gap: 6px; margin: -2px 14px 6px; font-size: 12px; color: var(--text-2); min-width: 0; }
.searchScopeIcon { width: 14px; height: 14px; flex: none; color: var(--text-3); }
.searchScopeIcon svg { width: 14px; height: 14px; }
.searchScopeName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.searchScopeWiden { flex: none; border: 0; background: none; padding: 2px 4px; font: inherit; font-size: 12px; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.searchScopeWiden:hover { color: var(--text); }

/* ---------- Password generator ---------- */
.genPresets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.genPresets .hint { margin-right: 4px; }
.genOutputRow { display: flex; gap: 6px; align-items: center; }
.genOutput { flex: 1; min-width: 0; font-size: 16px; letter-spacing: .02em; }
.genLength { display: flex; align-items: center; gap: 12px; }
.genLength .fieldLabel { margin: 0; }
.genRange { flex: 1; accent-color: var(--accent); }
.genNumber { width: 76px; }
.genSets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; }
.genCheck span { display: grid; }
.genCheck small { color: var(--text-3); font-size: 12px; }
.genPresets .btn { flex: 0 0 auto; height: 30px; padding: 0 10px; font-size: 12.5px; border: 1px solid var(--border); }

/* Welcome: read only / read & write for a file opened with write capability */
.sourceAccess { display: grid; gap: 6px; margin-top: -4px; }
.sourceAccess .segmented { display: flex; width: 100%; }
.sourceAccess .segmented button { flex: 1; justify-content: center; white-space: nowrap; }
.sourceAccess .small { line-height: 1.4; }
#fileLinkRow, #imageLinkRow { margin-top: 12px; }
#fileLinkState, #imageLinkState { overflow-wrap: anywhere; }
