:root {
  --bg: #0a0a0f;
  --bg-2: #11111a;
  --surface: #171722;
  --surface-2: #1e1e2c;
  --border: #2a2a3a;
  --border-hi: #3a3a50;
  --text: #ece9df;
  --muted: #8e8a7a;
  --gold: #d4af37;
  --gold-hi: #e6c458;
  --gold-lo: #9c7d24;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --danger: #e0625c;
  --ok: #8dc77a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .55);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(212,175,55,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(212,175,55,.045), transparent 60%),
    var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--gold-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--gold-hi); }
.center { justify-content: center; }
.error { color: var(--danger); margin: 6px 0 0; font-size: 13px; }

/* ========= Login page ========= */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-bottom: 24px;
}
.brand h1 {
  margin: 0; font-size: 32px; letter-spacing: 2px; font-weight: 600;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  background: var(--gold);
  color: #1a1408; font-weight: 600;
  padding: 12px 22px; border-radius: var(--radius);
  border: 1px solid var(--gold-lo);
  box-shadow: 0 8px 24px rgba(212,175,55,.25);
  transition: transform .1s ease, background .2s ease;
}
.google-btn:hover { background: var(--gold-hi); text-decoration: none; transform: translateY(-1px); }

/* ========= Buttons / inputs ========= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { border-color: var(--border-hi); background: #252535; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: #1a1408; border-color: var(--gold-lo);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(224,98,92,.1); border-color: rgba(224,98,92,.4); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.full { width: 100%; }

input, select, textarea {
  font: inherit; color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
textarea { resize: vertical; min-height: 60px; font-family: inherit; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > :is(input, select, textarea) { margin-top: 6px; }
.input-wrap { position: relative; }
.input-wrap .eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  padding: 6px; font-size: 16px;
}
.input-wrap .eye:hover { color: var(--gold-hi); }

/* ========= Lock screen ========= */
.lock {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background:
    radial-gradient(800px 500px at 50% 10%, rgba(212,175,55,.08), transparent 60%),
    rgba(10,10,15,.95);
  backdrop-filter: blur(6px);
}
.lock-card {
  width: min(420px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.lock-card h2 {
  margin: 8px 0 6px; font-size: 20px; font-weight: 600;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.strength { margin: -4px 0 8px; }
.strength .bar {
  height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden;
  border: 1px solid var(--border);
}
.strength .bar span {
  display: block; height: 100%; width: 0;
  transition: width .2s ease, background .2s ease;
}
.strength small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

/* ========= Shell ========= */
.shell {
  display: grid;
  grid-template-columns: 280px 360px 1fr;
  height: 100dvh;
  overflow: hidden;
}
@media (min-width: 901px) {
  .shell.overview-active {
    grid-template-columns: 280px 1fr;
  }
}
.shell.overview-active .list-pane { display: none; }
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px;
  min-width: 0;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 10px;
  font-size: 18px; letter-spacing: 1.5px;
}
.logo span {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 600;
}
.search input { background: var(--surface); }

.overview-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.overview-btn:hover {
  border-color: var(--border-hi);
  background: var(--surface);
  color: var(--gold-hi);
}
.overview-btn svg { color: var(--muted); flex: 0 0 auto; transition: color .12s ease; }
.overview-btn:hover svg { color: var(--gold-hi); }
.overview-btn.active {
  background: var(--gold-soft);
  border-color: rgba(212,175,55,.3);
  color: var(--gold-hi);
}
.overview-btn.active svg { color: var(--gold-hi); }
.cats {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  margin-top: 4px;
  padding-right: 2px;
}

/* --- Category tree --- */
.cat-tree {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column;
}
.cat-li { list-style: none; position: relative; }

/* Nested trees: indent + subtle vertical guide line */
.cat-li > .cat-tree {
  margin-left: 11px;
  padding-left: 10px;
  border-left: 1px dashed rgba(255, 255, 255, .06);
}

.cat-row {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 6px;
  min-height: 30px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 13.5px;
  user-select: none;
  transition: background .12s ease, color .12s ease;
}
.cat-row:hover { background: rgba(255, 255, 255, .035); }
.cat-row.active {
  background: rgba(212, 175, 55, .10);
  color: var(--gold-hi);
}
.cat-row.active::before {
  content: '';
  position: absolute;
  left: -2px; top: 6px; bottom: 6px;
  width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  box-shadow: 0 0 8px rgba(212, 175, 55, .35);
}
.cat-row.active .cat-name { font-weight: 600; }

/* Section labels: "Toutes" / "Non classées" */
.cat-row.special {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 26px;
  padding-top: 4px; padding-bottom: 4px;
  margin-top: 2px;
}
.cat-row.special .cat-name { font-weight: 600; }
.cat-row.special.active { color: var(--gold-hi); }
.cat-row.special:first-of-type { margin-top: 0; }

.cat-spacer {
  width: 14px; flex: 0 0 14px;
}
.cat-toggle {
  width: 14px; height: 14px; flex: 0 0 14px;
  background: transparent; border: 0;
  color: var(--muted); cursor: pointer; padding: 0;
  font-size: 9px; line-height: 1;
  display: grid; place-items: center;
  transition: transform .18s ease, color .12s ease;
}
.cat-toggle.expanded { transform: rotate(90deg); }
.cat-toggle:hover { color: var(--gold-hi); }

.cat-row .cat-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cat-row .c-count {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  min-width: 20px; text-align: right;
  flex: 0 0 auto;
}
.cat-row:hover .c-count { color: var(--text); }
.cat-row.active .c-count { color: var(--gold-hi); }

.cat-row .cat-actions {
  display: inline-flex; gap: 0;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity .15s ease, transform .15s ease;
  flex: 0 0 auto;
  pointer-events: none;
}
.cat-row:hover .cat-actions,
.cat-row:focus-within .cat-actions {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.cat-action {
  width: 22px; height: 22px;
  background: transparent; border: 0; color: var(--muted);
  cursor: pointer; border-radius: 5px;
  display: grid; place-items: center;
  padding: 0; font-size: 11px;
  transition: background .12s ease, color .12s ease;
}
.cat-action:hover { background: rgba(255, 255, 255, .06); color: var(--gold-hi); }
.cat-action[data-action="delete"]:hover { color: var(--danger); background: rgba(224, 98, 92, .08); }

.cat-row.dragging { opacity: .35; }
.cat-row.drop-ok {
  background: rgba(212, 175, 55, .14);
  box-shadow: inset 0 0 0 1.5px var(--gold);
}

.entry-list li.dragging { opacity: .35; }
.entry-list li[draggable="true"] { cursor: grab; }
.entry-list li[draggable="true"]:active { cursor: grabbing; }

.add-root-cat {
  margin-top: 10px;
  width: 100%; text-align: left;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, .08);
  border-radius: 6px;
  color: var(--muted); cursor: pointer;
  padding: 8px 12px;
  font: inherit; font-size: 12.5px;
  transition: color .15s ease, border-color .15s ease, background .12s ease;
}
.add-root-cat:hover {
  color: var(--gold-hi);
  border-color: var(--gold);
  background: rgba(212, 175, 55, .05);
}
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.foot-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.foot-btn {
  height: 38px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.foot-btn:hover {
  color: var(--gold-hi);
  border-color: var(--border-hi);
  background: var(--surface-2);
}
.foot-btn:active { transform: translateY(1px); }
.foot-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(224, 98, 92, .4);
  background: rgba(224, 98, 92, .08);
}
.foot-btn svg { pointer-events: none; }

/* ========= List pane ========= */
.list-pane {
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex; flex-direction: column; min-width: 0;
}
.list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 18px 10px;
}
.list-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.count { color: var(--muted); font-size: 12px; }
.entry-list { list-style: none; margin: 0; padding: 6px 10px 18px; overflow-y: auto; flex: 1; }
.entry-list li {
  padding: 12px 12px; border-radius: var(--radius-sm);
  margin-bottom: 2px; cursor: pointer;
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.entry-list li:hover { background: var(--surface); }
.entry-list li.active {
  background: var(--gold-soft);
  border-color: rgba(212,175,55,.25);
}
.entry-list .av {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  display: grid; place-items: center;
  color: var(--gold); font-weight: 600; border: 1px solid var(--border);
}
.entry-list .et { min-width: 0; }
.entry-list .et strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-list .et small { color: var(--muted); font-size: 12px; }
.entry-list .cat { font-size: 11px; color: var(--muted); background: var(--surface); padding: 3px 7px; border-radius: 99px; border: 1px solid var(--border); }
.empty {
  flex: 1; display: grid; place-items: center; color: var(--muted); gap: 10px;
}

/* ========= Detail ========= */
.detail { overflow-y: auto; padding: 32px 36px 80px; }
.detail.empty { display: grid; place-items: center; padding: 0; }
.detail-empty { text-align: center; color: var(--muted); }

.editor {
  max-width: 740px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 24px;
}

/* --- Header --- */
.editor-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
}
.editor-title {
  flex: 1; min-width: 0;
  font-size: 28px; font-weight: 600; letter-spacing: -0.3px;
  background: transparent; border: 0;
  padding: 4px 0;
  color: var(--text);
  width: 100%;
}
.editor-title::placeholder { color: var(--muted); font-style: italic; font-weight: 500; }
.editor-title:focus {
  outline: none;
  color: var(--gold-hi);
  background: transparent;
  box-shadow: none;
  border: 0;
}
.editor-header-actions {
  display: flex; gap: 6px;
  flex: 0 0 auto;
  margin-top: 2px;
}

/* --- Icon buttons --- */
.icon-btn {
  width: 38px; height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.icon-btn:hover {
  border-color: var(--border-hi);
  color: var(--gold-hi);
  background: var(--surface-2);
}
.icon-btn:active { transform: translateY(1px); }
.icon-btn.danger:hover {
  border-color: rgba(224,98,92,.45);
  color: var(--danger);
  background: rgba(224,98,92,.08);
}
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn svg { flex: 0 0 auto; }
.icon-btn.revealed svg { color: var(--gold-hi); }

/* --- Meta row --- */
.editor-meta {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 500;
  transition: all .12s ease;
}
.cat-chip:hover {
  border-color: var(--gold);
  color: var(--gold-hi);
  background: var(--gold-soft);
}
.cat-chip svg { color: var(--gold); flex: 0 0 auto; }
.cat-chip .cat-picker-label { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-chip .cat-picker-label.empty { color: var(--muted); font-style: italic; font-weight: 400; }
.meta-date-wrap { display: inline-flex; align-items: center; gap: 10px; }
.meta-sep { color: var(--border-hi); }
.meta-date { font-variant-numeric: tabular-nums; }

/* --- Sections --- */
.editor-section { display: flex; flex-direction: column; gap: 10px; }
.section-title {
  margin: 0 0 0 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.editor-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  min-height: 60px;
  resize: vertical;
  font-family: inherit;
  transition: border-color .12s ease, background .12s ease;
}
.editor-note:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

/* --- Fields --- */
.fields { display: flex; flex-direction: column; gap: 10px; }

.field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s ease, background .12s ease;
}
.field:hover { border-color: var(--border-hi); }
.field:focus-within {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.field-top {
  display: flex; align-items: center; gap: 10px;
}
.field-label-input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .85;
}
.field-label-input::placeholder {
  color: var(--border-hi);
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  font-size: 12px;
}
.field-label-input:focus {
  outline: none;
  color: var(--gold-hi);
  opacity: 1;
  box-shadow: none;
}

.field-type {
  appearance: none; -webkit-appearance: none;
  width: auto;
  padding: 4px 22px 4px 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  background-color: var(--bg-2);
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%238e8a7a' d='M4 5 0 0h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
  flex: 0 0 auto;
}
.field-type:hover { border-color: var(--border-hi); color: var(--text); }
.field-type:focus {
  outline: none;
  border-color: var(--gold);
  color: var(--gold-hi);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.field-bottom {
  display: flex; align-items: stretch; gap: 6px;
}
.field-value-input {
  flex: 1; min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s ease;
}
.field-value-input::placeholder { color: var(--muted); opacity: .6; }
.field-value-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-soft);
}
.field.type-password .field-value-input,
.field.type-otp .field-value-input {
  font-family: var(--mono);
  letter-spacing: .4px;
  font-size: 13.5px;
}
.field.type-textarea .field-value-input {
  min-height: 80px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.field-actions {
  display: inline-flex; gap: 2px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity .15s ease, transform .15s ease;
  flex: 0 0 auto;
}
.field:hover .field-actions,
.field:focus-within .field-actions {
  opacity: 1;
  transform: translateX(0);
}
.field-actions .icon-btn.sm {
  width: 34px;
  background: transparent;
  border-color: transparent;
}
.field-actions .icon-btn.sm:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

/* --- Add field / quick add --- */
.fields-actions {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.btn-add-field {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500;
  transition: all .12s ease;
}
.btn-add-field:hover {
  color: var(--gold-hi);
  border-color: var(--gold);
  background: rgba(212, 175, 55, .05);
}
.btn-add-field svg { color: inherit; }

.quick-add {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.quick-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .5px;
  margin-right: 2px;
}
.quick-add button {
  padding: 5px 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  cursor: pointer;
  font: inherit; font-size: 12px;
  transition: all .12s ease;
}
.quick-add button:hover {
  color: var(--gold-hi);
  border-color: var(--gold);
  background: var(--gold-soft);
}
.quick-add button:disabled {
  opacity: .35;
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,.2);
}
.quick-add button:disabled:hover {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

/* --- Footer --- */
.editor-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.editor-foot-actions { display: flex; gap: 10px; }

/* ========= Overview page ========= */
.detail.overview-mode { padding: 0; display: block; }
.overview {
  max-width: 820px; margin: 0 auto;
  padding: 28px 28px 60px;
}
.overview-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.overview-head h2 {
  margin: 0; font-size: 22px; font-weight: 600;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overview-stats {
  display: flex; gap: 20px; align-items: center;
}
.overview-stats .stat {
  display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1.1;
}
.overview-stats .stat strong {
  font-size: 20px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.overview-stats .stat small {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-top: 2px;
}
.ov-empty {
  text-align: center; color: var(--muted);
  padding: 40px; font-size: 14px;
}
.ov-tree {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.ov-li > .ov-tree {
  padding-left: 16px;
  margin-left: 12px;
  border-left: 1px dashed rgba(255, 255, 255, .08);
  margin-top: 2px;
}
.ov-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .1s ease, border-color .1s ease, transform .05s ease;
}
.ov-row:hover {
  background: var(--surface);
  border-color: var(--border);
}
.ov-row:active { transform: translateY(1px); }

/* Category row */
.ov-cat-row {
  font-size: 14px;
  font-weight: 500;
}
.ov-cat-row .ov-icon {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  display: grid; place-items: center;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--gold);
}
.ov-cat-row.ov-unsorted .ov-icon {
  color: var(--muted);
}
.ov-cat-row .ov-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ov-cat-row .ov-count {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 11px;
  flex: 0 0 auto;
}
.ov-cat-row .ov-count strong {
  color: var(--text); font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.ov-cat-row .ov-count small {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
}
.ov-cat-row .ov-count .sep { opacity: .4; margin: 0 2px; }
.ov-cat-row:hover .ov-count strong { color: var(--gold-hi); }

/* Entry row */
.ov-entry-row {
  padding: 6px 10px;
  font-size: 13.5px;
}
.ov-entry-av {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  color: var(--gold);
  font-weight: 600; font-size: 12px;
}
.ov-entry-main {
  display: flex; flex-direction: column; gap: 0;
  flex: 1; min-width: 0;
}
.ov-entry-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.ov-entry-sub {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.ov-entry-row:hover .ov-entry-title { color: var(--gold-hi); }

/* Header right cluster (stats + add-root button) */
.overview-head-right {
  display: flex; align-items: center; gap: 14px;
}
.btn.ov-add-root {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 12px;
  border-radius: 6px;
}
.btn.ov-add-root svg { flex: 0 0 auto; }

/* Inline row actions on each category row ("+" subcat, pencil rename, delete) */
.ov-cat-row .ov-add-sub,
.ov-cat-row .ov-edit-cat,
.ov-cat-row .ov-del-cat {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  margin-left: 4px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .1s ease, color .1s ease, background .1s ease, border-color .1s ease;
}
.ov-cat-row .ov-edit-cat,
.ov-cat-row .ov-del-cat { margin-left: 2px; }
.ov-cat-row:hover .ov-add-sub,
.ov-cat-row:focus-within .ov-add-sub,
.ov-cat-row:hover .ov-edit-cat,
.ov-cat-row:focus-within .ov-edit-cat,
.ov-cat-row:hover .ov-del-cat,
.ov-cat-row:focus-within .ov-del-cat {
  opacity: 1;
}
.ov-cat-row .ov-add-sub:hover,
.ov-cat-row .ov-edit-cat:hover {
  color: var(--gold-hi);
  background: var(--surface-2);
  border-color: var(--border);
}
.ov-cat-row .ov-del-cat:hover {
  color: var(--danger);
  background: rgba(224, 98, 92, .08);
  border-color: rgba(224, 98, 92, .4);
}

/* Inline rename mode — row becomes an editable input */
.ov-cat-row.ov-editing {
  cursor: default;
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}
.ov-rename-input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; outline: 0;
  color: var(--text);
  font: inherit; font-weight: 500;
  padding: 2px 0;
}

/* Inline add-form row */
.ov-add-li .ov-add-row {
  cursor: default;
  border: 1px dashed var(--gold);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}
.ov-add-li .ov-add-row:hover { background: color-mix(in srgb, var(--gold) 10%, transparent); }
.ov-add-input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; outline: 0;
  color: var(--text);
  font: inherit;
  padding: 2px 0;
}
.ov-add-input::placeholder { color: var(--muted); opacity: .7; }
.ov-add-actions {
  display: inline-flex; gap: 4px; flex: 0 0 auto;
}

/* Trailing "add root category" button */
.ov-add-root-trigger {
  margin-top: 6px;
}
.ov-add-root-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: color .1s ease, border-color .1s ease, background .1s ease;
}
.ov-add-root-btn:hover {
  color: var(--gold-hi);
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 6%, transparent);
}

/* ========= Toast ========= */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--gold); padding: 10px 16px;
  border-radius: 99px; font-size: 13px; opacity: 0;
  pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ========= Category picker ========= */
.cat-picker-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
  margin-top: 6px;
}
.cat-picker-btn:hover { border-color: var(--border-hi); background: var(--surface); }
.cat-picker-btn:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.cat-picker-label {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-picker-label.empty { color: var(--muted); font-style: italic; }
.cat-picker-chevron { color: var(--muted); font-size: 12px; flex: 0 0 auto; }

.cat-picker-dialog {
  max-width: 560px; width: calc(100% - 32px);
  padding: 0;
  overflow: hidden;
}
.cat-picker-form {
  display: flex; flex-direction: column;
  height: min(640px, 80vh);
}
.cat-picker-search-wrap {
  position: relative;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.cat-picker-search-icon {
  position: absolute;
  left: 28px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
#cat-picker-search {
  padding: 11px 14px 11px 38px;
  font-size: 15px;
  border-radius: 8px;
  background: var(--bg-2);
}
#cat-picker-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.cat-picker-list {
  list-style: none; padding: 8px; margin: 0;
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.cat-picker-item {
  position: relative;
  display: flex; align-items: center;
  gap: 10px;
  padding: 9px 14px 9px calc(10px + var(--depth, 0) * 20px);
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .1s ease, border-color .1s ease;
}
.cat-picker-item:hover,
.cat-picker-item.highlighted {
  background: var(--surface);
  border-color: var(--border);
}
.cat-picker-item.current {
  background: var(--gold-soft);
  color: var(--gold-hi);
  border-color: rgba(212, 175, 55, .25);
}
.cat-picker-item.highlighted.current {
  background: rgba(212, 175, 55, .18);
  border-color: rgba(212, 175, 55, .45);
}
.cat-picker-item.none {
  font-style: italic;
  color: var(--muted);
}
.cat-picker-item.none.current { color: var(--gold-hi); font-style: normal; }

/* Tree guide lines for nested items (non-search view) */
.cat-picker-list:not(.searching) .cat-picker-item[style*="--depth:"]:not([style*="--depth: 0"]):not([style*="--depth:0"])::before {
  content: '';
  position: absolute;
  left: calc((var(--depth) - 1) * 20px + 19px);
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .05);
}

/* Folder / leaf icon */
.cat-picker-item-icon {
  width: 18px; height: 18px; flex: 0 0 18px;
  display: grid; place-items: center;
  color: var(--muted);
  opacity: .8;
}
.cat-picker-item-icon::before {
  font-size: 14px; line-height: 1;
}
.cat-picker-item.has-children .cat-picker-item-icon::before { content: '📁'; }
.cat-picker-item.leaf .cat-picker-item-icon::before {
  content: ''; width: 6px; height: 6px;
  background: var(--muted); border-radius: 50%; opacity: .4;
}
.cat-picker-item.none .cat-picker-item-icon::before { content: '∅'; font-size: 13px; opacity: .6; }
.cat-picker-item.current .cat-picker-item-icon { opacity: 1; color: var(--gold-hi); }
.cat-picker-item.current.leaf .cat-picker-item-icon::before { background: var(--gold-hi); opacity: 1; }

.cat-picker-item-main {
  display: flex; flex-direction: column; gap: 3px;
  flex: 1; min-width: 0;
}
.cat-picker-item-name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-picker-item-path {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .3px;
}
.cat-picker-item.current .cat-picker-item-path { color: var(--gold-hi); opacity: .7; }
.cat-picker-item-check {
  color: var(--gold-hi); font-size: 14px; flex: 0 0 auto;
}
.cat-picker-empty {
  padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px;
  list-style: none;
}
.cat-picker-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.cat-picker-foot .muted { font-size: 11px; }

/* ========= Import dialog ========= */
.import-dialog { max-width: 520px; width: calc(100% - 32px); padding: 24px; }
.import-dialog h3 { margin: 0 0 12px; font-size: 18px; }
.import-summary {
  display: flex; gap: 28px;
  padding: 14px 4px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.import-stat { display: flex; flex-direction: column; line-height: 1.15; }
.import-stat strong {
  font-size: 24px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.import-stat small {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px;
  margin-top: 3px;
}
.import-strategies-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 10px;
}
.import-strategies { display: grid; gap: 10px; margin-bottom: 20px; }
.import-strategy {
  display: block; cursor: pointer; position: relative;
  margin: 0;
}
.import-strategy input {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px;
}
.import-strategy-card {
  display: flex; flex-direction: column; gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.import-strategy-card strong {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.import-strategy-card small {
  font-size: 12px; color: var(--muted); line-height: 1.4;
}
.import-strategy:hover .import-strategy-card { border-color: var(--border-hi); }
.import-strategy input:checked + .import-strategy-card {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(212,175,55,.10), rgba(212,175,55,.04));
  box-shadow: 0 0 0 2px var(--gold-soft);
}
.import-strategy input:checked + .import-strategy-card strong { color: var(--gold-hi); }
.import-strategy input:focus-visible + .import-strategy-card { outline: 2px solid var(--gold); outline-offset: 2px; }
.import-strategy.disabled { opacity: .5; pointer-events: none; }
.import-strategy.disabled .import-strategy-card { background: var(--bg-2); }
.import-strategy code { font-family: var(--mono); font-size: 11px; background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }

/* ========= Dialog ========= */
.dialog {
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text);
  padding: 22px; max-width: 420px; width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.dialog h3 { margin: 0 0 14px; font-size: 16px; }
.gen-output { display: flex; gap: 8px; margin-bottom: 14px; }
.gen-output input { font-family: var(--mono); font-size: 15px; }
.gen-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 10px 0 16px; }
.gen-opts label { margin: 0; color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.gen-opts input[type=checkbox] { width: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ========= Responsive ========= */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px 320px 1fr; }
}
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto 1fr;
    padding-bottom: var(--mobile-foot-h, 120px);
  }
  .shell.overview-active {
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    border-right: 0; border-bottom: 1px solid var(--border);
    max-height: 42vh;
    overflow-y: auto;
    padding-bottom: 14px;
  }
  .sidebar-foot {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    margin: 0;
  }
  .list-pane { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .detail { padding: 20px 16px 60px; }
  .detail.overview-mode { padding: 0; }
  .overview { padding: 20px 16px 40px; }
  .overview-head { gap: 12px; }
  .overview-head h2 { font-size: 18px; }
  .overview-stats { gap: 14px; }
  .overview-stats .stat strong { font-size: 17px; }

  /* Editor */
  .editor { gap: 18px; }
  .editor-title { font-size: 22px; }
  .editor-header { flex-wrap: wrap; }
  .field-top { flex-wrap: wrap; }
  .field-bottom { flex-wrap: wrap; }
  .field-value-input { min-width: 0; width: 100%; }
  .field-actions { width: 100%; justify-content: flex-end; opacity: 1; transform: none; }
  .editor-foot { flex-direction: column; gap: 10px; align-items: stretch; }
  .editor-foot-actions { justify-content: flex-end; }
  .editor-meta { flex-wrap: wrap; }
  .fields-actions { flex-direction: column; align-items: stretch; }
  .quick-add { width: 100%; }

  /* Category picker */
  .cat-picker-form { height: 90vh; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 20px; }
  .brand h1 { font-size: 28px; }
  .editor-title { font-size: 20px; }
  .overview-head { flex-direction: column; align-items: flex-start; }
  .overview-stats { width: 100%; justify-content: flex-start; }
  .overview-stats .stat { align-items: flex-start; }
  .ov-cat-row .ov-count { font-size: 10px; }
  .ov-cat-row .ov-count small { display: none; }
  .detail { padding: 16px 12px 40px; }
  .overview { padding: 16px 12px 30px; }
  .sidebar-foot .row { flex-wrap: wrap; }
  .cat-action { width: 26px; height: 26px; }
  .cat-row .cat-actions { opacity: 1; transform: none; pointer-events: auto; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
