/* Open Backup Vault – modeled after the Drime UI: soft gray canvas, white surfaces, green accent.
   Layers: --page (canvas) < --surface (cards, menus, dialogs) > --inset (quiet fills inside a surface). */
:root {
  --primary: 86 225 108;
  --primary-dark: 60 178 82;
  --accent-text: #0e7537; /* the green as text: readable on --surface and --page */
  --fg: 0 38 29;
  --page: #eceeed;
  --surface: #ffffff;
  --inset: #f2f4f3;
  --field: #ffffff;
  --chip: #e3e7e5;
  --text: rgb(var(--fg) / .88);
  --muted: rgb(var(--fg) / .68);
  --faint: rgb(var(--fg) / .5);
  --divider: rgb(var(--fg) / .1);
  --border: rgb(var(--fg) / .2);
  --hover: rgb(var(--fg) / .05);
  --selected: rgb(var(--primary) / .22);
  --danger: #d2353a;
  --danger-bg: #fde4e4; --danger-fg: #b42323;
  --warn: #f5a524;
  --warn-bg: #fdf0d0; --warn-fg: #7a5000;
  --info: #2f7de1;
  --info-bg: #e1edfc; --info-fg: #1c5fb8;
  --ok-bg: rgb(var(--primary) / .2); --ok-fg: var(--accent-text); /* chips: a quiet fill and a readable text on it */
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgb(0 38 29 / .05);
  --shadow: 0 1px 2px rgb(0 38 29 / .05), 0 10px 30px rgb(0 38 29 / .08);
  --sidebar: 264px;
  color-scheme: light;
}
/* Dark: chips and notes get translucent fills at low alpha and desaturated text – no pastel blocks. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: 226 244 236; --accent-text: rgb(86 225 108);
    --page: #0b110f; --surface: #151d1a; --inset: #1d2723; --field: #0f1613; --chip: rgb(226 244 236 / .08);
    --danger: #ff7a7e; --danger-bg: rgb(229 72 77 / .14); --danger-fg: #ee9a9d;
    --warn-bg: rgb(245 165 36 / .13); --warn-fg: #d9b46a;
    --info-bg: rgb(47 125 225 / .16); --info-fg: #9dbdea;
    --ok-bg: rgb(86 225 108 / .13); --ok-fg: #8fd9a0;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fg: 226 244 236; --accent-text: rgb(86 225 108);
  --page: #0b110f; --surface: #151d1a; --inset: #1d2723; --field: #0f1613; --chip: rgb(226 244 236 / .08);
  --danger: #ff7a7e; --danger-bg: rgb(229 72 77 / .14); --danger-fg: #ee9a9d;
  --warn-bg: rgb(245 165 36 / .13); --warn-fg: #d9b46a;
  --info-bg: rgb(47 125 225 / .16); --info-fg: #9dbdea;
  --ok-bg: rgb(86 225 108 / .13); --ok-fg: #8fd9a0;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
h1 { font-size: 22px; font-weight: 650; margin: 8px 0 4px; color: rgb(var(--fg)); letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 24px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--inset); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: rgb(var(--primary)); border-color: transparent; color: #00261d; }
.btn-primary:hover { background: rgb(var(--primary-dark)); }
.btn-danger { color: var(--danger); }
.btn-light { background: rgb(255 255 255 / .12); border-color: transparent; color: #fff; }
.btn-light:hover { background: rgb(255 255 255 / .2); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.light { color: #fff; } .icon-btn.light:hover { background: rgb(255 255 255 / .12); }
/* States */
.empty { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty .big { width: 64px; height: 64px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .big svg { width: 30px; height: 30px; }
.empty b { display: block; color: rgb(var(--fg)); font-size: 16px; margin-bottom: 4px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 72px 20px; color: var(--muted); flex-direction: column; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--chip); border-top-color: rgb(var(--primary)); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgb(0 20 15 / .45); display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 28px; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.01em; color: rgb(var(--fg)); }
.modal-card p { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--field); color: var(--text); outline: 0; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field textarea { min-height: 96px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px rgb(var(--primary) / .3); }
.field small { color: var(--muted); display: block; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal-card.wide { max-width: 640px; }
.modal.top { z-index: 60; }
/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 480px; }
.toast { background: #1d2a25; border: 1px solid rgb(255 255 255 / .08); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: #c92a2a; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; justify-content: inherit; }
.empty .actions { justify-content: center; }
/* selects, checkboxes */
.field select { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--field); color: var(--text); outline: 0; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 38px; background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8a85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); }
.field select:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px rgb(var(--primary) / .3); }
.field input:disabled, .field select:disabled { opacity: .6; }
.list-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: rgb(var(--primary)); }
.list.choose { max-height: 52vh; overflow: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
button.link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-text); font-weight: 550; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.sidebar-foot .link { margin-left: auto; font-size: 12px; }
.btn-lg { height: 50px; font-size: 15.5px; font-weight: 650; justify-content: center; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.link.quiet { color: var(--muted); font-size: 13.5px; font-weight: 500; align-self: center; padding: 4px 6px; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
.link.quiet:hover { color: var(--text); text-decoration-color: currentColor; }
.note { display: flex; align-items: center; gap: 10px; background: var(--inset); border-radius: 12px; padding: 11px 14px; font-size: 13.5px; color: var(--muted); }
.note svg { width: 18px; height: 18px; color: var(--accent-text); }
.note b { color: var(--text); }
.note.warn { background: linear-gradient(var(--warn-bg), var(--warn-bg)) var(--surface); color: var(--warn-fg); flex-wrap: wrap; overflow-wrap: anywhere; }
.note.warn svg { color: inherit; }
.note.warn .link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.note .spinner { width: 16px; height: 16px; border-width: 2px; }
.note.strip { margin-bottom: 12px; }
.content > .note { margin-bottom: 14px; }
.link.quiet .count { margin-left: 5px; font-size: 11.5px; color: var(--faint); }
.small { font-size: 12.5px; }
details.more { font-size: 13px; color: var(--muted); }
details.more summary { cursor: pointer; width: fit-content; border-radius: 6px; padding: 2px 4px; margin-left: -4px; }
details.more summary:hover { color: var(--text); }
details.raw { margin-top: 6px; }
details.raw pre { margin: 6px 0 0; padding: 8px 10px; font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; user-select: all;
  background: var(--divider); border-radius: 8px; color: var(--text); max-height: 160px; overflow: auto; }
details.more p { margin: 8px 0 0; max-width: 60ch; }
