/* ─────────────────────────────────────────────────────────────────────
   Vault (2026 redesign): a neutral, file-browser-style tree.
   Scoped under #vault-app, built on Crux's own variables so light and
   dark follow the app. Colour is used in one place only: each domain's
   small dot. Structure comes from thin 1px lines, the same language as
   Chronicle's threads: a line runs down from each parent, a curved elbow
   leads into each child, and the line stops at the last child. Domains
   are separated by thin rules.
   ───────────────────────────────────────────────────────────────────── */
#vault-app {
  --v-dot-DELIVER: #0ea5e9; --v-dot-LEDGER: #f59e0b; --v-dot-VITAL: #f43f5e; --v-dot-EVOLVE: #10b981;
  --v-dot-PERSONAL: #8b5cf6; --v-dot-SPARK: #f97316; --v-dot-VAULT: #6366f1; --v-dot-OTHER: #94a3b8;
  --v-surface: #ffffff;
  --v-line: rgba(51,65,85,.16);
  --v-hover: rgba(51,65,85,.045);
  --v-sel: rgba(51,65,85,.085);
  --v-muted: #5f6b7c;
  --v-icon: #6b7686;
  --v-danger: #b42318;
  display: flex; flex-direction: column; min-height: 100%;
  padding: 22px 26px 48px;
  color: var(--text1); font-size: 13px; line-height: 1.45;
}
[data-theme="dark"] #vault-app {
  --v-surface: var(--bg2);
  --v-line: rgba(255,255,255,.13);
  --v-hover: rgba(255,255,255,.04);
  --v-sel: rgba(255,255,255,.08);
  --v-muted: #98a3b3;
  --v-icon: #a3adbb;
  --v-danger: #fda4af;
}
#vault-app *, #vault-app *::before, #vault-app *::after { box-sizing: border-box; }
/* Zero-specificity resets, so component rules below always win. */
:where(#vault-app) :where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(#vault-app) :where(button) { cursor: pointer; }
#vault-app :focus-visible { outline: 2px solid var(--text3); outline-offset: 2px; }
#vault-app .v-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#vault-app svg { flex-shrink: 0; }

/* ── Header ─────────────────────────────────────────────────────────── */
.v-head { display: flex; align-items: center; gap: 10px; padding: 0 0 18px; flex-wrap: wrap; }
.v-search { flex: 1; min-width: 220px; max-width: 480px; height: 36px; padding: 0 12px; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border2); border-radius: 10px; background: var(--v-surface); color: var(--v-muted); }
.v-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text1); font-size: 13px; }
.v-search:focus-within { border-color: var(--text3); }
.v-kbd { font-family: var(--mono, monospace); font-size: 10.5px; padding: 1px 6px; border: 1px solid var(--border2); border-radius: 5px; color: var(--v-muted); }
.v-count { font-size: 12px; color: var(--v-muted); white-space: nowrap; }
.v-spacer { flex: 1; }
.v-btn { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border2); background: var(--v-surface); color: var(--text2);
  font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.v-btn:hover { border-color: var(--text3); color: var(--text1); }
.v-btn-sq { width: 32px; padding: 0; }
.v-btn-primary { height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--brand, #334155); color: #fff; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
[data-theme="dark"] .v-btn-primary { background: #d6dde8; color: #111827; }
.v-btn-primary:hover { filter: brightness(1.12); }
.v-btn-danger { border-color: var(--v-danger); color: var(--v-danger); }
.v-btn[disabled], .v-btn-primary[disabled] { opacity: .5; cursor: default; }
.v-icon-btn { width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--v-muted); display: inline-flex; align-items: center; justify-content: center; }
.v-icon-btn:hover { background: var(--v-surface); border-color: var(--border2); color: var(--text1); }
.v-menu-wrap { position: relative; }
.v-menu { position: absolute; right: 0; top: 38px; z-index: 30; min-width: 220px; padding: 6px; border-radius: 12px; border: 1px solid var(--border2);
  background: var(--v-surface); box-shadow: 0 12px 32px rgba(15,23,42,.12); display: flex; flex-direction: column; }
.v-menu button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font-size: 13px; color: var(--text1); }
.v-menu button:hover { background: var(--v-hover); }

/* ── Layout ─────────────────────────────────────────────────────────── */
.v-body { display: flex; align-items: flex-start; gap: 32px; flex: 1; min-height: 0; }
.v-side { width: 184px; flex-shrink: 0; position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px; }
.v-side-h { padding: 0 10px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--v-muted); }
.v-side-list { display: flex; flex-direction: column; gap: 1px; }
.v-side-item { height: 30px; padding: 0 10px; border-radius: 7px; border: 0; background: transparent; color: var(--text2); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 9px; text-align: left; width: 100%; }
.v-side-item:hover { background: var(--v-hover); color: var(--text1); }
.v-side-item[aria-current="true"], .v-side-item[aria-pressed="true"] { background: var(--v-sel); color: var(--text1); font-weight: 600; }
.v-side-item .v-n { margin-left: auto; font-family: var(--mono, monospace); font-size: 11px; color: var(--v-muted); font-weight: 400; }
.v-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--dd, var(--v-dot-OTHER)); }
.v-side-toggle { width: 100%; border: 0; background: transparent; display: flex; align-items: center; justify-content: space-between; text-align: left; }
.v-side-toggle span { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--v-muted); }
.v-side-toggle:hover span { color: var(--text1); text-decoration: underline; text-underline-offset: 2px; }
.v-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 6px 0; }
.v-tag { min-height: 26px; padding: 3px 9px; border-radius: 13px; border: 1px solid var(--border2); background: transparent; font-size: 11.5px; color: var(--text2); }
.v-tag:hover { border-color: var(--text3); }
.v-tag[aria-pressed="true"] { background: var(--v-sel); border-color: var(--text3); color: var(--text1); }

.v-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.v-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--v-muted); margin: -6px 0 12px; }
.v-crumbs:empty { display: none; }
.v-crumb { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--border2); background: var(--v-surface); color: var(--text1); font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; }
.v-cols { height: 30px; display: grid; grid-template-columns: minmax(0, 1fr) 100px 110px 72px; align-items: center; gap: 12px; padding: 0 10px 0 6px;
  border-bottom: 1px solid var(--v-line); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--v-muted); }
.v-cols button { justify-self: start; border: 0; background: none; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--v-muted); }
.v-cols button:hover { color: var(--text1); }
.v-cols .v-right { text-align: right; }
.v-empty { padding: 48px 0; text-align: center; color: var(--v-muted); }
.v-empty strong { display: block; color: var(--text1); font-size: 14px; margin-bottom: 4px; }

/* ── Domains: separated by thin rules ──────────────────────────────── */
.v-dom { padding: 8px 0 10px; border-bottom: 1px solid var(--v-line); }
.v-dom:last-child { border-bottom: 0; }
.v-row-d { position: relative; min-height: 34px; padding: 0 4px 0 6px; border-radius: 8px; display: flex; align-items: center; gap: 6px; scroll-margin-top: 12px; }
.v-toggle { flex: 1; min-width: 0; height: 32px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; gap: 9px; text-align: left; }
.v-dname { font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--text1); }
.v-is-empty .v-dname { color: var(--v-muted); font-weight: 600; }
/* A small dot marks a group that holds more: filled when closed, a
   hollow ring when open. No arrows. */
.v-kid { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.v-kid::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--v-icon); }
.v-kid-open::before { width: 6px; height: 6px; background: transparent; box-shadow: inset 0 0 0 1.25px var(--v-icon); }
.v-toggle:hover .v-kid::before { background: var(--text1); }
.v-toggle:hover .v-kid-open::before { background: transparent; box-shadow: inset 0 0 0 1.25px var(--text1); }
.v-n { font-family: var(--mono, monospace); font-size: 11px; color: var(--v-muted); }

/* ── Tree rows and their connector lines ───────────────────────────── */
.v-row-g, .v-row-i, .v-row-edit, .v-row-menu, .v-row-rename { position: relative; }
.v-lines { position: absolute; inset: 0; pointer-events: none; }
.v-rail { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--v-line); }
.v-elbow { position: absolute; top: 0; height: 50%; width: 11px; border-left: 1px solid var(--v-line); border-bottom: 1px solid var(--v-line); border-bottom-left-radius: 8px; }
.v-row-edit .v-elbow { height: 22px; }

.v-row-g { min-height: 34px; padding: 0 4px 0 var(--pad); border-radius: 8px; display: flex; align-items: center; gap: 6px; }
.v-row-g:hover { background: var(--v-hover); }
.v-gname { font-size: 13px; font-weight: 500; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-g1 .v-gname { font-weight: 600; }
.v-folder { color: var(--v-icon); display: inline-flex; }
.v-folder svg { width: 15px; height: 15px; }

/* Row actions stay out of the way until you point at the row. */
.v-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.v-row-g:hover .v-actions, .v-row-d:hover .v-actions, .v-row-g:focus-within .v-actions, .v-row-d:focus-within .v-actions, .v-drop .v-actions { opacity: 1; }
@media (hover: none) { .v-actions { opacity: 1; } }

.v-row-i { width: 100%; min-height: 36px; padding: 3px 10px 3px var(--pad); border: 0; border-radius: 8px; background: transparent; display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 110px 72px; align-items: center; gap: 12px; text-align: left; color: var(--text1); }
.v-comfy .v-row-i { min-height: 48px; }
.v-row-i:hover { background: var(--v-hover); }
.v-row-i[aria-current="true"] { background: var(--v-sel); }
.v-drop { box-shadow: inset 0 0 0 1px var(--text3); background: var(--v-hover); }
.v-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.v-kind { width: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--v-icon); }
.v-kind svg { width: 15px; height: 15px; }
.v-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.v-title { font-size: 13px; font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-sub { font-size: 11.5px; color: var(--v-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.v-comfy .v-sub { display: block; }
.v-cell { font-size: 12px; color: var(--v-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-size { font-family: var(--mono, monospace); font-size: 11px; color: var(--v-muted); text-align: right; }
.v-badge { height: 18px; padding: 0 7px; border-radius: 9px; border: 1px solid var(--border2); font-size: 10.5px; font-weight: 600; color: var(--v-muted); display: inline-flex; align-items: center; }

.v-row-menu { min-height: 40px; padding: 4px 8px 6px var(--pad); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.v-row-rename { min-height: 42px; padding: 4px 6px 4px var(--pad); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.v-row-edit { padding: 8px 10px 12px var(--pad); }
.v-edit-card { padding: 12px; border: 1px solid var(--border2); border-radius: 10px; background: var(--v-surface); display: flex; flex-direction: column; gap: 10px; }
.v-edit-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.v-edit-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.v-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.v-field label, .v-label { font-size: 11px; font-weight: 600; color: var(--v-muted); }
.v-input, .v-select, .v-textarea { height: 34px; padding: 0 10px; border: 1px solid var(--border2); border-radius: 8px; background: var(--v-surface); color: var(--text1); font-size: 13px; width: 100%; }
.v-textarea { height: auto; min-height: 76px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.v-input:focus, .v-select:focus, .v-textarea:focus { outline: 0; border-color: var(--text3); }
.v-title-input { flex: 1; min-width: 200px; font-weight: 500; }
.v-hint { font-size: 11.5px; color: var(--v-muted); }
.v-note-ok { font-size: 12px; color: var(--text2); }
.v-error { font-size: 12.5px; color: var(--v-danger); }
.v-file-pick { position: relative; overflow: hidden; }
.v-file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── Side panel ─────────────────────────────────────────────────────── */
.v-panel { width: 340px; flex-shrink: 0; position: sticky; top: 0; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--v-surface); display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 140px); overflow-y: auto; }
.v-panel-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.v-panel-h h2 { margin: 3px 0 0; font-size: 16px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.v-path { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; color: var(--v-muted); overflow-wrap: anywhere; }
.v-close { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--border2); background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--text2); }
.v-preview { min-height: 110px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--v-muted); font-size: 12px; }
.v-preview img { max-width: 100%; max-height: 240px; display: block; }
.v-preview iframe { width: 100%; height: 260px; border: 0; background: #fff; }
.v-preview .v-ext { font-family: var(--mono, monospace); font-size: 16px; font-weight: 500; color: var(--v-icon); }
.v-meta { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 7px 12px; font-size: 12.5px; margin: 0; padding-top: 12px; border-top: 1px solid var(--v-line); }
.v-meta dt { color: var(--v-muted); }
.v-meta dd { margin: 0; overflow-wrap: anywhere; }
.v-desc { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text2); white-space: pre-wrap; }
.v-content { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.v-panel-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding-top: 12px; border-top: 1px solid var(--v-line); }
.v-panel-actions .v-btn, .v-panel-actions .v-btn-primary { height: 34px; }
.v-tree-pick { display: flex; flex-direction: column; gap: 1px; max-height: 360px; overflow-y: auto; padding: 4px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg); }
.v-node { min-height: 32px; padding: 3px 10px 3px var(--pad); border-radius: 7px; border: 0; background: transparent; display: flex; align-items: center; gap: 8px; text-align: left; font-size: 12.5px; color: var(--text1); }
.v-node:hover:not([disabled]) { background: var(--v-hover); }
.v-node[aria-pressed="true"] { background: var(--v-sel); font-weight: 600; }
.v-node[disabled] { opacity: .45; cursor: not-allowed; }
.v-node .v-why { margin-left: auto; font-size: 10.5px; color: var(--v-muted); white-space: nowrap; font-weight: 400; }
.v-node .v-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-node-d .v-lbl { font-weight: 700; font-size: 11px; letter-spacing: .08em; }
.v-links { display: flex; flex-direction: column; gap: 6px; }
.v-link-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border); font-size: 12px; }
.v-link-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-status { display: flex; flex-direction: column; border-radius: 11px; border: 1px solid var(--border); }
.v-status div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; font-size: 12.5px; }
.v-status div + div { border-top: 1px solid var(--v-line); }
.v-status span:last-child { color: var(--v-muted); text-align: right; overflow-wrap: anywhere; }
.v-ok { color: var(--text1) !important; font-weight: 600; }

/* ── Archived list ──────────────────────────────────────────────────── */
.v-arch { min-height: 46px; padding: 6px 6px; border-bottom: 1px solid var(--v-line); display: flex; align-items: center; gap: 10px; }
.v-arch .v-title { flex: 1; }
.v-arch small { color: var(--v-muted); font-size: 11.5px; }

/* ── Dialog ─────────────────────────────────────────────────────────── */
.v-dialog-back { position: fixed; inset: 0; z-index: 3000; background: rgba(15,23,42,.32); display: flex; align-items: center; justify-content: center; padding: 20px; }
.v-dialog { width: 420px; max-width: 100%; padding: 22px; border-radius: 16px; background: var(--v-surface); color: var(--text1); display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 48px rgba(15,23,42,.18); }
.v-dialog h2 { margin: 0; font-size: 16px; }
.v-dialog p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text2); }
.v-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ── Narrower screens ───────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .v-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 2500; width: min(380px, 100%); margin: 0; border-radius: 0; max-height: none; box-shadow: -12px 0 32px rgba(15,23,42,.14); }
}
@media (max-width: 860px) {
  #vault-app { padding: 14px 14px 40px; }
  .v-body { flex-direction: column; gap: 10px; }
  .v-side { width: 100%; position: static; flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .v-side > div { flex-shrink: 0; }
  .v-side-h, .v-tags-block { display: none; }
  .v-side-list { flex-direction: row; gap: 5px; }
  .v-side-item { width: auto; height: 30px; border: 1px solid var(--border2); border-radius: 15px; white-space: nowrap; }
  .v-side-item .v-n { margin-left: 4px; }
  .v-cols { display: none; }
  .v-row-i { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .v-row-i .v-cell, .v-row-i .v-size { display: none; }
  .v-row-i .v-sub { display: block; }
  .v-edit-grid { grid-template-columns: 1fr; }
  .v-kbd { display: none; }
  .v-head .v-search { order: 10; flex-basis: 100%; max-width: none; }
}
@media (prefers-reduced-motion: reduce) { #vault-app * { transition: none !important; } }
