/* omnify Vault – web shell. Mobile first, two columns from 768px, light and dark. */
:root {
  color-scheme: light dark;
  --bg: #f5f6ef;
  --surface: #ffffff;
  --surface-2: #eef1e7;
  --ink: #172d27;
  --muted: #52665e;
  --line: #d4dbcf;
  --line-strong: #aebbaf;
  --brand: #164b3c;
  --brand-ink: #ffffff;
  --accent: #d8f296;
  --focus: #2f7d5f;
  --link: #14614a;
  --danger: #a3261d;
  --danger-ink: #ffffff;
  --ok-bg: #e3f3d6;
  --ok-ink: #1f4a23;
  --info-bg: #e7eef0;
  --info-ink: #24424a;
  --warn-bg: #fbf0cf;
  --warn-ink: #5c4300;
  --error-bg: #fbe1dd;
  --error-ink: #7a1a12;
  --shadow: 0 1px 2px rgba(23, 45, 39, .06), 0 8px 24px rgba(23, 45, 39, .07);
  --radius: 12px;
  --tap: 44px;
  --bar-h: 60px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a16;
    --surface: #16241f;
    --surface-2: #1d2e28;
    --ink: #e6ede6;
    --muted: #9db0a6;
    --line: #2a3c35;
    --line-strong: #456055;
    --brand: #d8f296;
    --brand-ink: #10261e;
    --accent: #d8f296;
    --focus: #b9e08a;
    --link: #b9e08a;
    --danger: #ff8d80;
    --danger-ink: #2a0b08;
    --ok-bg: #1f3a24;
    --ok-ink: #c9ecc0;
    --info-bg: #1c3238;
    --info-ink: #c5dfe6;
    --warn-bg: #3d3210;
    --warn-ink: #f3dc93;
    --error-bg: #46201c;
    --error-ink: #ffcdc6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  overflow-wrap: anywhere;
}
h1, h2, h3, h4, p, ul, fieldset, legend { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: var(--link); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
strong, b { font-weight: 650; }

:focus { outline: none; }
:focus-visible, .file-btn:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1:focus-visible, h2:focus-visible { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  min-width: 0 !important; min-height: 0 !important;
  margin: -1px !important; padding: 0 !important; border: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}
/* Containing blocks for the hidden helpers above, so they never widen the page. */
.card, .dialog-body, .list-col, .pane-col, .field, .row, .check, .segmented, .group { position: relative; }
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  padding: 10px 14px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink);
}
.skip:focus { top: 8px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.muted { color: var(--muted); }
.break { word-break: break-all; }
.pre { white-space: pre-wrap; }
.fine { font-size: .875rem; color: var(--muted); }
.hint { font-size: .875rem; color: var(--muted); }
.hint.is-error { color: var(--error-ink); }
.lead { color: var(--muted); }
.icon { flex: none; }
.icon-xl { width: 44px; height: 44px; color: var(--line-strong); }

/* --- status surfaces */
.boot { padding: 48px 20px; text-align: center; color: var(--muted); }
.banner {
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--warn-bg); color: var(--warn-ink);
  font-size: .9rem; text-align: center;
  border-bottom: 1px solid var(--line);
}
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 12px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow);
  font-size: .95rem;
}
.msg {
  display: block;
  padding: 10px 12px; border-radius: 10px;
  background: var(--info-bg); color: var(--info-ink);
  font-size: .95rem;
}
.msg .icon { vertical-align: -4px; }
.msg-ok { background: var(--ok-bg); color: var(--ok-ink); }
.msg-warn { background: var(--warn-bg); color: var(--warn-ink); }
.msg-error { background: var(--error-bg); color: var(--error-ink); }

/* --- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); min-width: var(--tap);
  padding: 9px 16px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-weight: 560; text-decoration: none;
  cursor: pointer; user-select: none;
  overflow-wrap: normal; word-break: normal;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.12); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.1); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-link { border-color: transparent; background: transparent; color: var(--link); text-decoration: underline; font-weight: 500; }
.btn-icon { padding: 9px; }
.btn-wide { width: 100%; }
.file-btn { position: relative; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions-center { justify-content: center; }
.actions-split { justify-content: space-between; margin-top: 8px; }
.stack { display: grid; gap: 14px; }
.stack > * { min-width: 0; }

/* --- form controls */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .group > legend { font-weight: 600; font-size: .95rem; }
input[type="text"], input[type="password"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[readonly] { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--focus); flex: none; }
input[type="range"] { width: 100%; min-height: var(--tap); accent-color: var(--focus); }
.control-row { display: flex; gap: 6px; align-items: center; }
.control-row > input, .control-row > textarea { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.strength-row { display: flex; align-items: center; gap: 10px; min-height: 20px; }
.strength { flex: 1; height: 10px; max-width: 220px; }
.strength-text { font-size: .875rem; color: var(--muted); }
progress.bar, .totp-bar { accent-color: var(--focus); }
progress.bar { width: 100%; height: 12px; }

details.more { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
details.more > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 560; }
details.more[open] { padding-bottom: 12px; }

/* --- gate screens (start, register, unlock, recovery) */
.gate {
  min-height: 100dvh;
  display: grid; place-items: start center;
  padding: clamp(16px, 6vh, 72px) 16px 32px;
  padding-top: calc(clamp(16px, 6vh, 72px) + env(safe-area-inset-top));
}
.card {
  width: 100%; max-width: 440px;
  display: grid; gap: 16px;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -.01em; hyphens: auto; overflow-wrap: break-word; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; white-space: nowrap; font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; }
.brand b { font-weight: 450; color: var(--muted); }
.brandmark {
  position: relative; flex: none;
  width: 30px; height: 30px; border-radius: 9px;
  background: #164b3c;
}
.brandmark::before, .brandmark::after {
  content: ""; position: absolute; top: 7px;
  width: 6px; border-radius: 5px; background: #d8f296;
}
.brandmark::before { left: 8px; height: 16px; transform: skew(18deg); }
.brandmark::after { left: 16px; height: 12px; transform: skew(-18deg); }
.recovery-key, .link-code {
  padding: 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem; letter-spacing: .04em; line-height: 1.7;
  text-align: center; user-select: all;
}

/* --- dialog */
.dialog {
  width: min(92vw, 440px);
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 20, 16, .55); }
.dialog-body { display: grid; gap: 14px; padding: 20px; }
.dialog-body h2 { font-size: 1.2rem; }
.dialog-body .actions { justify-content: flex-end; }

/* --- vault shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--bar-h);
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-size: 1.05rem; }
.account { display: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9rem; text-align: right; }
.top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; flex: none; }
.top-actions .btn { white-space: nowrap; }
.top-actions .btn-primary { margin-right: 6px; }

.shell[data-pane="open"] .list-col { display: none; }
.shell[data-pane="closed"] .pane-col { display: none; }

.list-col { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.list-tools {
  position: sticky; top: var(--bar-h); z-index: 10;
  display: grid; gap: 10px;
  padding: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { padding-left: 40px !important; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 36px; padding: 6px 11px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer; font-size: .875rem;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.list-status { display: grid; gap: 8px; padding: 10px 14px 4px; font-size: .875rem; }
.list-status:empty { display: none; }
.list { padding: 4px 8px calc(24px + env(safe-area-inset-bottom)); }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px;
  padding: 8px 10px;
  border: 0; border-radius: 10px;
  background: transparent; color: inherit; text-align: left; cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row[aria-current="true"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--focus); }
.row-icon {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
}
.row-text { display: grid; min-width: 0; }
.row-title, .row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .875rem; }

.pane-col { min-width: 0; min-height: calc(100dvh - var(--bar-h)); background: var(--surface); }
.pane-head {
  position: sticky; top: var(--bar-h); z-index: 10;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
/* Up to two lines in the sticky header; the detail view repeats a longer title in full below. */
.pane-title {
  flex: 1; min-width: 0; font-size: 1.15rem; line-height: 1.25;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.full-title { font-weight: 600; overflow-wrap: anywhere; }
.pane-actions { display: flex; align-items: center; gap: 6px; }
.pane-body { display: grid; gap: 18px; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); max-width: 760px; }
.pane-body > * { min-width: 0; }
.pane-empty { display: grid; gap: 14px; justify-items: center; padding: 64px 20px; text-align: center; color: var(--muted); }

/* --- detail */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.badge, .tag { padding: 3px 10px; border-radius: 999px; font-size: .8rem; }
.badge { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.tag { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.block { display: grid; gap: 4px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.block > * { min-width: 0; }
.block > h3, .block-head h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 8px; }
.block-head { display: flex; align-items: center; justify-content: space-between; }
.kv { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv-label { font-size: .8rem; color: var(--muted); }
.kv-body { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kv-value { flex: 1; min-width: 0; }
.kv-actions { display: flex; flex: none; }
.note { padding: 4px 0 10px; }
.totp { flex: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.totp-code { flex: none; font-size: 1.4rem; font-weight: 600; letter-spacing: .06em; }
.totp-bar { width: 72px; height: 8px; }
.totp-bar.is-low { accent-color: var(--danger); }
.totp-rest { font-size: .85rem; font-variant-numeric: tabular-nums; }
.files, .devices { display: grid; gap: 4px; }
.file, .device { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file:last-child, .device:last-child { border-bottom: 0; }
.file-icon { color: var(--muted); display: grid; place-items: center; flex: none; }
.file-text { flex: 1 1 160px; display: grid; min-width: 0; font-size: .9rem; }
.file-name { font-weight: 600; font-size: 1rem; }
.file-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.preview { display: grid; gap: 8px; padding: 8px 0 12px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preview-img { display: block; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.preview-open { margin-bottom: 10px; text-decoration: none; }
.preview-frame { display: block; width: 100%; height: min(75vh, 900px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.meta { padding: 0 2px; }

/* --- forms in the pane */
.form { display: grid; gap: 16px; }
.form > * { min-width: 0; }
.group { display: grid; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.group > legend { float: left; width: 100%; padding: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group > legend + * { clear: both; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.segment { position: relative; display: grid; place-items: center; min-height: var(--tap); cursor: pointer; font-weight: 560; }
.segment + .segment { border-left: 1px solid var(--line-strong); }
.segment input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segment:has(input:checked) { background: var(--brand); color: var(--brand-ink); }
.segment:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.generator { display: grid; gap: 12px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.gen-out { display: block; min-height: 2.9em; padding: 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 1.05rem; }
.gen-length { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.gen-length output { min-width: 2.5ch; padding-bottom: 12px; text-align: right; }
.gen-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.extras { display: grid; gap: 10px; }
.extras:empty { display: none; }
.extra { display: grid; grid-template-columns: 1fr; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.form-actions { justify-content: flex-end; position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.conflict { display: grid; gap: 10px; }

/* --- import and settings */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.stat strong { font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; color: var(--muted); }
.facts { display: grid; gap: 6px; padding-left: 18px; list-style: disc; }
.warnings { display: grid; gap: 6px; padding-left: 18px; list-style: disc; max-height: 40vh; overflow: auto; font-size: .9rem; }
.settings-block { gap: 12px; padding: 6px 14px 16px; }
.sub { padding-top: 14px; border-top: 1px solid var(--line); }
.sub h4 { font-size: 1rem; }
.danger-zone h4 { color: var(--danger); }

/* Narrow phones: pane actions shrink to icons, the label stays for screen readers. */
@media (max-width: 479px) {
  .topbar .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .pane-actions .btn { padding: 9px; }
  .pane-actions .btn > span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* --- two columns from tablet width */
@media (min-width: 768px) {
  .card { padding: 32px 28px; }
  .shell { height: 100dvh; display: flex; flex-direction: column; }
  .topbar { position: static; padding: 8px 20px; }
  .account { display: block; }
  .pane-col { min-height: 0; }
  .columns { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
  .shell[data-pane="open"] .list-col { display: flex; }
  .shell[data-pane="closed"] .pane-col { display: block; }
  .list-col { border-right: 1px solid var(--line); overflow-y: auto; }
  .list-tools { top: 0; }
  .pane-col { overflow-y: auto; }
  .pane-head { top: 0; padding: 8px 20px; }
  .pane-back { display: none; }
  .pane-body { padding: 20px 24px 48px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .extra { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; align-items: center; border-bottom: 0; padding-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .btn, .chip, .row[aria-current="true"] { border: 1px solid ButtonText; }
  .brandmark { forced-color-adjust: none; }
}
@media print {
  .topbar, .list-col, .pane-head, .toast, .banner { display: none !important; }
}
