/* Veilbox: one stylesheet for the site, the phone app and the extension's full page.
   One spacing scale (--s1 … --s6), one control height (--ctl, --ctl-sm for small buttons), one page padding (--pad). */
:root {
  --accent: #7c6cff;
  --on-accent: #fff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Roboto Mono", monospace;
  --bg: #0f1117; --surface: #171a23; --surface-2: #1f2330; --surface-3: #272c3b; --border: #2b3040;
  --text: #e9ebf2; --muted: #9aa1b4; --faint: #6b7286;
  --danger: #ff5d6c; --ok: #35d39a; --warn: #ffb547;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar: 250px;
  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* sizes */
  --ctl: 38px;            /* buttons, inputs, selects, pills in one row */
  --ctl-sm: 30px;         /* small buttons (inside rows and fields) */
  --row-h: 60px;          /* list rows */
  --set-h: 64px;          /* settings rows */
  --pad: var(--s6);       /* page side padding */
  --pad-top: var(--s5);   /* page top padding */
  --list-pad: var(--s4);  /* list pane side padding */
  --form-max: 760px;
  --radius: 12px; --radius-ctl: 10px; --radius-sm: 8px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5fa; --surface: #ffffff; --surface-2: #eef0f6; --surface-3: #e4e7f0; --border: #dfe2ec;
  --text: #171a24; --muted: #5b6275; --faint: #8a90a2;
  --danger: #d92d43; --ok: #11966a; --warn: #b26b00;
  --shadow: 0 10px 30px rgba(30, 35, 60, .12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 640; }
h3 { font-size: .95rem; font-weight: 620; }
p { margin: 0 0 var(--s2); }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); letter-spacing: .01em; }
.small { font-size: .85rem; }
.hint { font-size: .8rem; color: var(--faint); }
.hint.err { color: var(--danger); }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boot { display: grid; place-items: center; align-content: center; gap: var(--s3); min-height: 100vh; color: var(--muted); }
.noscript { padding: var(--s5); }

/* ---------- buttons: .btn (secondary) + .primary / .ghost / .danger, .small, .icon ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); flex: none; height: var(--ctl); max-width: 100%; padding: 0 var(--s4); border-radius: var(--radius-ctl); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 560; line-height: 1; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s, transform .05s; }
.btn .ico { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .row:focus-visible, .nav a:focus-visible, .chip:focus-visible, .code-card:focus-visible, .type-pick button:focus-visible, .swatch:focus-visible, input.switch:focus-visible, .tabs button:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn.small { height: var(--ctl-sm); padding: 0 var(--s3); gap: 6px; font-size: .85rem; border-radius: var(--radius-sm); }
.btn.small .ico { width: 16px; height: 16px; }
.btn.icon { padding: 0; width: var(--ctl); }
.btn.icon.small { width: var(--ctl-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; }

/* ---------- inputs ---------- */
.input { display: block; width: 100%; height: var(--ctl); padding: 0 var(--s3); border-radius: var(--radius-ctl); border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; }
textarea.input { height: auto; min-height: 96px; padding: var(--s2) var(--s3); resize: vertical; line-height: 1.45; }
select.input { padding-right: 28px; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); outline: none; }
.input[disabled] { opacity: .6; }
.field { display: grid; gap: 6px; margin: 0 0 var(--s4); min-width: 0; align-content: start; }
.field > span:first-child, .field > label { font-size: .85rem; color: var(--muted); font-weight: 560; }
.field .hint { margin-top: -2px; }
.field.error .input { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: .85rem; }
.field > div > .btn { margin-top: 2px; }
.input-row { display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.input-row .input { flex: 1; min-width: 0; }
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group .input { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { display: inline-flex; align-items: center; height: var(--ctl); padding: 0 var(--s3); border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; background: var(--surface-2); color: var(--muted); white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
input.switch { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
input.switch:checked { background: var(--accent); border-color: transparent; }
input.switch:checked::after { transform: translateX(18px); }
input[type="range"] { accent-color: var(--accent); width: 100%; margin: 0; }
input[type="checkbox"]:not(.switch) { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; flex: none; }
.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; }
/* a switch with its label: label (+ description) on the left, the switch on the right */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 56px; padding: var(--s2) var(--s4); margin: 0 0 var(--s4); border: 1px solid var(--border); border-radius: var(--radius-ctl); background: var(--surface); cursor: pointer; }
.switch-row .grow { display: flex; flex-direction: column; gap: 2px; }
.switch-row .label { font-weight: 560; }
.switch-row .desc { color: var(--muted); font-size: .85rem; }
/* a checkbox or switch shown as a control box (same height as the inputs next to it) */
.toggle-box { display: inline-flex; align-items: center; gap: var(--s2); height: var(--ctl); padding: 0 var(--s3); border: 1px solid var(--border); border-radius: var(--radius-ctl); background: var(--surface); color: var(--muted); font-size: .9rem; white-space: nowrap; cursor: pointer; flex: none; }
.toggle-box:hover { color: var(--text); }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); background: radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent), radial-gradient(700px 500px at 110% 110%, rgba(45, 212, 191, .14), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: var(--s6); box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: var(--s5); }
.auth-card h1 { margin-bottom: var(--s2); }
.auth-card .lead { color: var(--muted); margin-bottom: var(--s5); }
.auth-card form > .btn.primary, .auth-card > .btn.primary { width: 100%; height: 44px; }
.auth-card .check { margin: 0 0 var(--s4); }
.auth-foot { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: .85rem; }
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--radius-ctl); background: var(--surface-2); border: 1px solid var(--border); font-size: .88rem; color: var(--muted); margin: 0 0 var(--s4); }
.notice .ico { color: var(--accent); margin-top: 1px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.notice.warn .ico { color: var(--warn); }
.notice.danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.notice.danger .ico { color: var(--danger); }
.notice.small { padding: var(--s2) var(--s3); font-size: .8rem; gap: var(--s2); }
.notice.small .ico { width: 16px; height: 16px; }
.form-error { color: var(--danger); font-size: .9rem; margin: 0 0 var(--s3); }
.form-error:empty { display: none; }
.brand { display: flex; align-items: center; gap: var(--s3); font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }

/* ---------- the shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: var(--s4) var(--s3); display: flex; flex-direction: column; gap: var(--s1); }
.sidebar .brand { padding: var(--s1) var(--s3) var(--s3); min-height: var(--ctl); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button { display: flex; align-items: center; gap: var(--s3); min-height: 36px; padding: var(--s1) var(--s3); border-radius: var(--radius-ctl); color: var(--muted); text-decoration: none; font-weight: 540; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav a > span:not(.count), .nav button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.nav a.active .ico { color: var(--accent); }
.nav .count { margin-left: auto; min-width: 22px; text-align: right; font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.nav .count.unread { color: var(--on-accent); background: var(--accent); border-radius: 99px; padding: 0 7px; text-align: center; line-height: 20px; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: var(--s4) var(--s3) var(--s1); font-weight: 650; }
.sidebar .spacer { flex: 1; min-height: var(--s4); }
.sidebar .notice { margin: 0 0 var(--s1); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.bottomnav { display: none; }
.offline-bar { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--text); font-size: .85rem; padding: var(--s2) var(--pad); border-bottom: 1px solid var(--border); }

/* ---------- pages ---------- */
.page { padding: var(--pad-top) var(--pad) var(--s6); max-width: 1100px; width: 100%; }
.page.full { max-width: none; }
.page-head { display: flex; align-items: center; gap: var(--s3); min-height: var(--ctl); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.page-head + p { margin: calc(var(--s3) * -1) 0 var(--s4); max-width: 72ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s5); margin-bottom: var(--s4); min-width: 0; }
.card > h2 { margin-bottom: var(--s3); }
.card > h2 + .card-desc { margin-top: calc(var(--s1) * -1); }
.card .card-desc { color: var(--muted); font-size: .9rem; margin: 0 0 var(--s4); max-width: 72ch; }
.card > :last-child { margin-bottom: 0; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s4); }
.card-actions .hint { flex-basis: 100%; }
.card-actions .hint:empty { display: none; }
.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); min-width: 0; }
.toolbar select.input { width: auto; flex: 0 1 auto; }
.search { position: relative; flex: 1 1 180px; min-width: 0; }
.search .ico { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--faint); width: 18px; height: 18px; pointer-events: none; }
.search .input { padding-left: 38px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: var(--s1); height: 26px; padding: 0 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; color: var(--muted); text-decoration: none; white-space: nowrap; max-width: 100%; }
button.chip { cursor: pointer; font: inherit; font-size: .8rem; }
.chip.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
/* pills: a row of toggles (filters, sections), the same height as the controls next to them */
.pills { gap: var(--s2); }
.pills > .chip { height: var(--ctl); padding: 0 var(--s4); gap: var(--s2); font-size: .9rem; font-weight: 560; color: var(--muted); cursor: pointer; }
.pills > .chip:hover { color: var(--text); background: var(--surface-3); }
.pills > .chip.on:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 99px; font-size: .75rem; background: var(--surface-3); color: var(--muted); font-weight: 600; white-space: nowrap; flex: none; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); text-align: center; padding: var(--s6) var(--s5); color: var(--muted); }
.empty .ico { width: 44px; height: 44px; color: var(--faint); margin-bottom: var(--s1); }
.empty h2 { color: var(--text); }
.empty p { max-width: 440px; margin: 0; }
.empty .btns { display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap; margin-top: var(--s2); }
.empty > .btn { margin-top: var(--s2); }
.empty .btn .ico, .notice .btn .ico { width: 18px; height: 18px; margin: 0; color: inherit; }
.pane-view .empty { min-height: min(60vh, 520px); }

/* ---------- lists: avatar column, title + subtitle stacked, the end of the row on the right ---------- */
.list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s3); min-height: var(--row-h); padding: var(--s2) var(--s3); border-radius: var(--radius-ctl); cursor: pointer; color: var(--text); text-decoration: none; border: 1px solid transparent; background: none; width: 100%; text-align: left; font: inherit; min-width: 0; }
.row:hover { background: var(--surface-2); }
.row.active { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.row > .grow { display: flex; flex-direction: column; gap: 2px; }
.row .meta { color: var(--muted); font-size: .85rem; }
.row .title { font-weight: 580; }
.row .row-end { display: flex; align-items: center; gap: var(--s1); flex: none; margin-left: auto; }
.row .row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; flex: none; }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: .95rem; text-transform: uppercase; }
.avatar .ico { width: 19px; height: 19px; }
.avatar.soft { background: var(--surface-3); color: var(--accent); }
.fav-star { color: var(--warn); width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; }

/* split view: a list next to the thing you opened (vault, inbox, aliases) */
.split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); height: 100vh; min-height: 0; }
.pane-list { border-right: 1px solid var(--border); overflow-y: auto; padding: var(--pad-top) var(--list-pad) var(--s5); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane-list > .page-head { margin-bottom: var(--s4); }
.pane-list > .toolbar { margin-bottom: var(--s3); }
.pane-list > .toolbar .search { flex-basis: 140px; }
.pane-view { overflow-y: auto; min-width: 0; min-height: 0; }
.pane-view > .page { max-width: 820px; }
.list-foot { color: var(--faint); font-size: .8rem; padding: var(--s3) var(--s3) 0; text-align: center; }
/* a page with its title and toolbar above a split (inbox, aliases): the split runs edge to edge under a line */
.page:has(> .split) { max-width: none; height: 100vh; display: flex; flex-direction: column; padding-bottom: 0; overflow-y: auto; }
.page:has(> .split) > .page-head, .page:has(> .split) > .toolbar, .page:has(> .split) > .card { flex: none; }
.page > .split { flex: 1 1 0; min-height: 420px; height: auto; margin: 0 calc(var(--pad) * -1); border-top: 1px solid var(--border); }
.page > .split > .pane-list { padding: var(--s4) var(--s3) var(--s5) var(--pad); }
.page > .split > .pane-view { padding: var(--s4) var(--pad) var(--s6); }
.page > .split > .pane-view > .empty:only-child { min-height: 100%; }

/* ---------- item view: one column of fields, their buttons at a fixed spot on the right ---------- */
.item-head { display: flex; gap: var(--s4); align-items: center; margin-bottom: var(--s5); flex-wrap: wrap; }
.item-head > .grow { display: flex; flex-direction: column; gap: var(--s1); }
.item-head .avatar { width: 52px; height: 52px; border-radius: 14px; font-size: 1.3rem; }
.item-head h1 { overflow-wrap: anywhere; }
.item-head .page-head { margin: 0; min-height: 0; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "k tools" "v tools"; column-gap: var(--s3); row-gap: 2px; align-items: center; min-height: 60px; padding: var(--s2) var(--s2) var(--s2) var(--s4); border-radius: var(--radius-ctl); background: var(--surface); border: 1px solid var(--border); margin-bottom: var(--s2); position: relative; }
.kv .k { grid-area: k; font-size: .78rem; color: var(--muted); font-weight: 560; }
.kv .v { grid-area: v; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); min-width: 0; min-height: 24px; overflow-wrap: anywhere; }
.kv .v .txt { flex: 1 1 140px; min-width: 0; }
.kv .v.pre .txt { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.kv .v .btn { flex: none; }
.kv .tools { grid-area: tools; display: flex; gap: 2px; align-items: center; justify-content: flex-end; min-width: calc(var(--ctl-sm) * 3 + 4px); }
.group { margin-bottom: var(--s5); }
.group > h3 { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; margin: 0 0 var(--s2); }
.group > .btn { margin-bottom: var(--s2); }
.group .chips { gap: var(--s2); }
.secret { font-family: var(--mono); letter-spacing: .04em; }
.totp-code { font-family: var(--mono); font-size: 1.35rem; font-weight: 650; letter-spacing: .08em; color: var(--accent); }
.ring { --p: 1; width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--surface-3) 0); display: grid; place-items: center; flex: none; }
.ring::after { content: attr(data-s); width: 20px; height: 20px; border-radius: 50%; background: var(--surface); font-size: .66rem; display: grid; place-items: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.ring.low { background: conic-gradient(var(--danger) calc(var(--p) * 360deg), var(--surface-3) 0); }
.stamps { color: var(--faint); font-size: .8rem; margin-top: var(--s5); display: grid; gap: 2px; }
.back-row { margin-bottom: var(--s4); }

/* strength meter */
.meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s1); margin: var(--s1) 0; }
.meter i { height: 5px; border-radius: 3px; background: var(--surface-3); }
.meter[data-s="0"] i:nth-child(-n+1) { background: var(--danger); }
.meter[data-s="1"] i:nth-child(-n+2) { background: #ff8a4c; }
.meter[data-s="2"] i:nth-child(-n+3) { background: var(--warn); }
.meter[data-s="3"] i:nth-child(-n+4) { background: #8bd450; }
.meter[data-s="4"] i { background: var(--ok); }
.meter-label { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; min-height: 1.2em; }
.meter + .meter-label + .hint { margin-top: var(--s1); }

/* editor: one grid, labels above the fields, help under them */
.editor { max-width: var(--form-max); }
.editor .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); align-items: start; }
.editor .field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.custom-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: var(--s2); align-items: center; margin-bottom: var(--s2); }
.url-row { display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.url-row .input { flex: 1; }
.editor-actions { position: sticky; bottom: 0; display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) 0; margin-top: var(--s2); background: linear-gradient(transparent, var(--bg) 30%); }
.type-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); max-width: var(--form-max); }
.type-pick button { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); min-height: 112px; padding: var(--s4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.type-pick button .ico { color: var(--accent); margin-bottom: var(--s1); }
.type-pick button:hover { border-color: var(--accent); }
.type-pick small { color: var(--muted); }

/* generator */
.gen-out { display: flex; gap: var(--s2); align-items: center; min-height: 64px; padding: var(--s3) var(--s3) var(--s3) var(--s4); border-radius: var(--radius-ctl); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: var(--s3); }
.gen-out .pw { flex: 1; min-width: 0; font-family: var(--mono); font-size: 1.15rem; overflow-wrap: anywhere; word-break: break-all; }
.gen-out .pw .d { color: var(--accent); }
.gen-out .pw .s { color: var(--warn); }
.tabs { display: inline-flex; gap: 2px; height: var(--ctl); padding: 3px; border-radius: var(--radius-ctl); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: var(--s4); max-width: 100%; }
.tabs button { border: 0; background: none; height: 100%; padding: 0 var(--s4); border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 560; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s2); }
.opt { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; min-height: 52px; padding: var(--s2) var(--s3) var(--s2) var(--s4); border: 1px solid var(--border); border-radius: var(--radius-ctl); background: var(--surface-2); cursor: pointer; min-width: 0; }
.opt select.input { width: auto; max-width: 60%; background: var(--surface); }
.range-row { display: flex; align-items: center; gap: var(--s3); height: var(--ctl); }
.range-row output { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }

/* 2FA codes */
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s3); }
.codes > .empty { grid-column: 1 / -1; }
.code-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px var(--s3); align-items: center; min-height: 100px; padding: var(--s4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); cursor: pointer; text-align: left; font: inherit; min-width: 0; }
.code-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.code-card .name { font-weight: 600; grid-column: 2 / 4; }
.code-card .sub { color: var(--muted); font-size: .8rem; grid-column: 2 / 4; min-height: 1.2em; }
.code-card .totp-code { grid-column: 2; }
.code-card .avatar { grid-row: 1 / span 3; align-self: center; }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: var(--s5) var(--s4); text-align: center; color: var(--muted); cursor: pointer; margin: 0 0 var(--s4); }
.drop.over { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.qr-box { background: #fff; padding: var(--s3); border-radius: var(--radius); width: 220px; max-width: 100%; margin: 0 0 var(--s4); }
.qr-box img { display: block; width: 100%; }

/* settings: cards of rows, label + description left, the control right */
.settings-nav { margin-bottom: var(--s5); }
.settings-body { max-width: 900px; }
.set-row { display: flex; gap: var(--s5); align-items: center; justify-content: space-between; min-height: var(--set-h); padding: var(--s3) 0; border-top: 1px solid var(--border); }
.card > h2 + .set-row { border-top: 0; padding-top: 0; }
.set-row > .grow { display: flex; flex-direction: column; gap: 2px; }
.set-row .label { font-weight: 560; }
.set-row .desc { color: var(--muted); font-size: .85rem; max-width: 64ch; }
.set-row .control { flex: none; display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; min-width: 0; max-width: 100%; }
.set-row .control select.input { width: 240px; }
.set-row .set-warn { margin: var(--s2) 0 0; max-width: 64ch; }
.set-row .control .input-row { width: 340px; max-width: 100%; }
.swatches { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.session { display: flex; gap: var(--s3); align-items: center; min-height: var(--set-h); padding: var(--s3) 0; border-top: 1px solid var(--border); }
.session:first-child { border-top: 0; padding-top: 0; }
.session > .ico { color: var(--muted); }
.session .label { font-weight: 560; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.session .devid { color: var(--faint); font-size: .8rem; font-weight: 400; }

/* dialogs and toasts */
.modal-wrap { position: fixed; inset: 0; background: rgba(5, 7, 12, .55); display: grid; place-items: center; z-index: 50; padding: var(--s4); backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s4) 0 var(--s5); }
.modal-head h2 { flex: 1; min-width: 0; }
.modal-body { padding: var(--s4) var(--s5) var(--s5); }
.modal-body p { margin: 0 0 var(--s4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); flex-wrap: wrap; }
.modal-body .notice { margin-top: var(--s1); }
.confirm-text { white-space: pre-line; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: var(--s5); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); min-height: 44px; padding: var(--s2) var(--s2) var(--s2) var(--s4); border-radius: var(--radius); display: flex; gap: var(--s3); align-items: center; z-index: 60; box-shadow: var(--shadow); transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px); font-weight: 520; }
#toast > span { padding-right: var(--s2); overflow-wrap: anywhere; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { background: var(--danger); color: #fff; }
#toast .btn { color: inherit; border-color: currentColor; }
#toast .btn:hover { background: color-mix(in srgb, currentColor 14%, transparent); }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  :root { --pad: var(--s4); --pad-top: var(--s4); --list-pad: var(--s3); }
  body { font-size: 15.5px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; gap: var(--s2); position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s3) var(--s2) var(--s4); border-bottom: 1px solid var(--border); min-height: 54px; }
  .topbar h1 { flex: 1; font-size: 1.1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s2) 2px 7px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; position: relative; }
  .bottomnav a.active { color: var(--accent); }
  .bottomnav .dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 16px; height: 16px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: .62rem; display: grid; place-items: center; padding: 0 var(--s1); }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .page { padding-bottom: var(--s6); }
  .page-head { margin-bottom: var(--s4); }
  .page-head h1, .pane-list .page-head h1 { display: none; }
  .page-head { justify-content: flex-end; }
  .page-head:not(:has(.actions > *)) { display: none; }
  .page-head + p { margin-top: 0; }
  .page-head.hide-phone, .hide-phone { display: none !important; }
  .split { display: block; height: auto; }
  .split > .pane-list { border: 0; padding: var(--s3) var(--pad) var(--s5); overflow: visible; }
  .split > .pane-view { overflow: visible; }
  .split.viewing > .pane-list { display: none; }
  .split:not(.viewing) > .pane-view { display: none; }
  .page:has(> .split) { height: auto; overflow: visible; display: block; }
  .page > .split { margin: 0 calc(var(--pad) * -1); }
  .page > .split > .pane-list { padding: var(--s3) var(--pad) var(--s5); }
  .page > .split > .pane-view { padding: var(--s3) var(--pad) var(--s6); }
  .page > .split.viewing { border-top: 0; }
  .pane-view .empty { min-height: 0; }
  .row .row-actions { display: none; }
  .editor .field-row, .editor .field-row.three { grid-template-columns: minmax(0, 1fr); }
  .custom-field { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .custom-field .hide-toggle { display: none; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .type-pick { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--s4); }
  .set-row { flex-wrap: wrap; gap: var(--s2) var(--s4); }
  .set-row > .grow { flex: 1 1 200px; }
  .set-row:has(select, .input-row, .swatches) { flex-direction: column; align-items: stretch; }
  .set-row:has(select, .input-row, .swatches) > .grow { flex: none; }
  .set-row:has(select, .input-row, .swatches) .control { justify-content: flex-start; }
  .set-row .control select.input, .set-row .control .input-row { width: 100%; }
  .swatches { justify-content: flex-start; }
  .editor-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
  form.editor { padding-bottom: 96px; }
  .item-head { gap: var(--s3); }
  .item-head .page-head { width: 100%; justify-content: flex-start; }
  .back-row { margin-bottom: var(--s3); }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .modal-wrap { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .modal-head { padding: var(--s4) var(--s3) 0 var(--s4); }
  .modal-body { padding: var(--s3) var(--s4) var(--s5); }
  .auth-card { padding: var(--s5) var(--s4); }
  .vb-inbox:has(.vb-split.viewing) > .page-head, .vb-inbox:has(.vb-split.viewing) > .vb-toolbar { display: none; }
}
@media (min-width: 761px) { .phone-only { display: none !important; } }

/* small details (all sizes) */
.gen-actions { margin: var(--s3) 0 0; }
.kv .v .txt:has(> .totp-code) { flex: none; }
.pane-list > .toolbar select.input { max-width: 150px; }
.pane-view > .page:has(> .empty:only-child) { height: 100%; display: flex; flex-direction: column; }
.pane-view > .page > .empty:only-child { flex: 1; }
.list.card { padding: var(--s2); }
