/* Self-hosted typefaces (offline-safe, no CDN).
   Switzer — geometric grotesque for UI. Instrument Serif — editorial display. */
@font-face {
  font-family: "Switzer"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/switzer-400.woff2") format("woff2");
}
@font-face {
  font-family: "Switzer"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/switzer-500.woff2") format("woff2");
}
@font-face {
  font-family: "Switzer"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/switzer-600.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/instrument-serif-400.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/instrument-serif-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/manrope-400.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/manrope-500.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/manrope-600.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/outfit-400.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/outfit-500.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/outfit-600.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/space-grotesk-400.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/space-grotesk-500.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/space-grotesk-600.woff2") format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/playfair-display-400.woff2") format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/playfair-display-500.woff2") format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/playfair-display-600.woff2") format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/playfair-display-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/montserrat-400.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/montserrat-500.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/montserrat-600.woff2") format("woff2");
}
@font-face {
  font-family: "Work Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/work-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Work Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/work-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "Work Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/work-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "DM Serif Display"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/dm-serif-display-400.woff2") format("woff2");
}
@font-face {
  font-family: "DM Serif Display"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/dm-serif-display-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Lora"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/lora-400.woff2") format("woff2");
}
@font-face {
  font-family: "Lora"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/lora-500.woff2") format("woff2");
}
@font-face {
  font-family: "Lora"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/lora-600.woff2") format("woff2");
}
@font-face {
  font-family: "Lora"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/lora-400-italic.woff2") format("woff2");
}

/* LihimVault — editorial minimalism.
    Warm bone canvas, hairline borders, flat surfaces, serif display,
    pastel accents only. Motion is quiet; shadows barely exist. */
:root {
  --bg: #F7F6F3;
  --card: #FFFFFF;
  --card-alt: #F9F8F6;
  --border: #EAEAEA;
  --border-soft: #F1EFE9;
  --text: #44403C;
  --muted: #746D68;
  --faint: #857F78;
  --accent: #292524;
  --accent-hover: #44403C;
  --accent-soft: #ECE9E2;
  --focus-ring: #78716C;
  --focus-ring-soft: rgba(87, 83, 78, .16);
  --danger: #9F2F2D;
  --danger-soft: #FDEBEC;
  --ok: #346538;
  --ok-soft: #EDF3EC;
  --warn-soft: #FBF3DB;
  --warn-text: #956400;
  --info-soft: #E1F3FE;
  --info-text: #1F6C9F;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --touch: 40px;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
  --shadow-lg: 0 12px 32px rgba(41, 37, 36, .10);
  --shadow-modal: 0 4px 16px rgba(41, 37, 36, .08), 0 24px 64px rgba(41, 37, 36, .16);
  --font: "Switzer", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", "Lyon Text", "Newsreader", "Playfair Display", Georgia, serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { touch-action: manipulation; }
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--text); color: var(--bg); font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; text-decoration: none;
  transition: top .18s ease;
}
.skip-link:focus-visible { top: 12px; color: var(--bg); outline: 2px solid var(--focus-ring); outline-offset: 2px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-w1 { color: var(--brand-1, var(--text)); }
.brand-w2 { color: var(--brand-2, var(--info-text)); }
html[data-theme="dark"] .brand-w1 { color: var(--brand-1-dark, var(--text)); }
html[data-theme="dark"] .brand-w2 { color: var(--brand-2-dark, var(--accent)); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; color: #fff;
  background: #292524;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { color: var(--muted); font-weight: 500; padding: 7px 12px; border-radius: 8px; font-size: 14px; }
.nav a:hover { background: var(--card-alt); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
/* Tools submenu: same pill look as nav links, dropdown card below. */
.nav details.tools-menu { position: relative; }
.nav details.tools-menu > summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 500; padding: 7px 12px; border-radius: 999px; font-size: 14px; }
.nav details.tools-menu > summary::-webkit-details-marker { display: none; }
.nav details.tools-menu > summary:hover { background: var(--card-alt); color: var(--text); }
.nav details.tools-menu > summary.tools-active { background: var(--accent-soft); color: var(--accent); }
.nav .tools-list { position: absolute; top: calc(100% + 6px); left: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 60; display: flex; flex-direction: column; }
.nav .tools-list a { padding: 9px 12px; border-radius: 8px; }
.nav .tools-list a:hover { background: var(--card-alt); text-decoration: none; }
.topbar-spacer { flex: 1; }
.user-chip { font-size: 13px; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 8px; }
.link-btn:hover { background: var(--card-alt); color: var(--text); }

/* layout */
.page { max-width: 880px; margin: 0 auto; padding: 40px 24px 96px; }
.page-narrow { max-width: 460px; }
h1 {
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: -.03em; line-height: 1.1; margin: 4px 0 8px;
  text-wrap: balance;
}
.modal h3 { text-wrap: balance; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 14.5px; }

/* cards — flat bento boxes: 1px hairline, crisp corners, roomy padding */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 16px;
  transition: box-shadow .2s ease;
}
a.card-row, div.card-row { transition: box-shadow .2s ease; }
.card-row { display: flex; align-items: center; gap: 14px; }
#vault-rows > .card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .04); }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: var(--accent-soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.grow { flex: 1; min-width: 0; }
.title { font-weight: 600; font-size: 15.5px; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--muted);
  background: var(--card-alt); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; margin-right: 6px;
}
.pill.blue { background: var(--info-soft); border-color: transparent; color: var(--info-text); }
.pill.red { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.pill.green { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.amber { background: var(--warn-soft); border-color: transparent; color: var(--warn-text); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* secret field rows */
.field-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-top: 1px solid var(--border-soft);
}
.field-row:first-of-type { border-top: none; }
.field-label { width: 150px; flex: none; color: var(--muted); font-size: 13.5px; }
.field-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.field-value.revealed {
  white-space: normal; word-break: break-all;
  user-select: text; -webkit-user-select: text; cursor: text; /* long-press to copy manually */
}
.icon-btn {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--faint); border-radius: 8px; padding: 7px;
  min-width: var(--touch); min-height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--card-alt); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.ok { color: var(--ok); }

/* forms */
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14.5px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--focus-ring-soft); }
textarea { min-height: 76px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .field-label { width: 118px; } }
details.group { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); margin-top: 10px; background: #fbfcfd; }
details.group summary { cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 14px; list-style: none; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary:before { content: "+ "; color: var(--accent); font-weight: 700; }
details.group[open] summary:before { content: "– "; }
details.group .body { padding: 0 14px 14px; }

/* buttons — crisp, flat, monochrome */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14.5px; padding: 10px 22px;
  background: var(--accent); color: #fff; box-shadow: none;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--card); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--card-alt); }
.btn:disabled, .btn.secondary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover { background: var(--accent); }
.btn.secondary:disabled:hover { background: var(--card); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--card-alt); color: var(--text); }
.btn.ghost:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
/* Small inline tools (Generate / Check breach next to a field). */
.btn-mini { padding: 4px 12px; font-size: 12px; }
/* Title-bar action (e.g. Generator in the record modal header). */
.btn-sm { padding: 6px 14px; font-size: 13px; flex: none; }
/* Chip buttons: same secondary look, fixed input height so a row of
   presets + a number input reads as one even control strip. */
.btn-chip { min-height: 44px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
/* Generator modal rows: form-aligned, single source for spacing. */
.gen-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.gen-Muse { max-width: 110px; }
.gen-out { font-family: monospace; }
.mono-sm { font-size: 12px; }
/* In the record modal, switches sit next to their labels instead of being
   flung to the far edge of a narrow dialog. */
#record-body .switch-row { gap: 4px 12px; }
#record-body .switch { margin-left: 12px; flex: none; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.searchbar { display: flex; gap: 10px; margin-bottom: 16px; }
.searchbar input { flex: 1; border-radius: 999px; padding-left: 18px; }

/* Modal button rows behave exactly like page button rows: left-aligned
   with breathing room above. (An old centered, margin-less variant caused
   buttons to glue themselves to the input above in every content modal.) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 20, 26, .45);
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.1);
  display: none; align-items: center; justify-content: center; padding: 24px 20px; z-index: 50;
  opacity: 0; transition: opacity .22s ease;
}
.modal-backdrop.open { display: flex; opacity: 1; }
.modal {
  --modal-pad: 26px;
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  max-width: 420px; width: 100%; padding: var(--modal-pad); text-align: center;
  max-height: calc(100vh - 60px); overflow-y: auto; overscroll-behavior: contain; position: relative;
  transform: translateY(16px) scale(.98);
  transition: transform .26s cubic-bezier(.16, 1, .3, 1);
}
.modal-backdrop.open .modal { transform: none; }
.modal-wide { max-width: 640px; text-align: left; }
.modal-left { text-align: left; }
.modal-h { margin: 0 0 4px; font-size: 17px; }
.modal-sub { margin-top: 0; }
.modal-note { margin: 8px 0 0; }
.auth-alt { margin: 10px 0 2px; }
/* Inline forms that sit inside a row of content (unlink, delete, favorite). */
.form-inline { display: inline; }
/* Small glyph icons that sit inside running text or buttons. */
.inline-icon { vertical-align: -1px; }
.muted-icon { color: var(--muted); }
/* Detail-page and auth headings use the editorial serif for warmth. */
.auth-head h1, .record-title { font-family: var(--serif); font-weight: 400; letter-spacing: 0; }
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  flex: none; min-width: var(--touch); min-height: var(--touch);
}
.modal h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.01em; }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
/* NOTE: modal button rows deliberately inherit the page .btn-row look
   (left-aligned, 18px breathing room). Never add margin-top:0 or centering
   here — it glues buttons to the input above in every content modal. */

/* toast stack: slides up, auto-closes with a draining progress bar */
#toast-stack {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 70; pointer-events: none; width: min(420px, calc(100vw - 32px));
}
.toast {
  background: #292524; color: #fff; font-size: 14px; font-weight: 500;
  padding: 11px 22px 13px; border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(14px) scale(.97); pointer-events: none;
  transition: opacity .28s ease, transform .28s cubic-bezier(.16, 1, .3, 1);
  position: relative; overflow: hidden; max-width: 100%;
  white-space: nowrap; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: none; }
.toast::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 6px; height: 2px;
  border-radius: 2px; background: rgba(255, 255, 255, .35);
  transform-origin: left; animation: toast-drain 3.6s linear forwards;
}
@keyframes toast-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-info { background: #292524; }
html[data-theme="dark"] .toast-info { border: 1px solid var(--border); }

/* misc */
.alert { border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px; margin-bottom: 14px; }
.alert.error { background: var(--danger-soft); color: #a4123f; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.big { font-size: 40px; margin-bottom: 8px; }
.hist-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }
.hist-row { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.hist-row:first-of-type { border-top: none; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border-soft); font-size: 14px; }
.kv:first-of-type { border-top: none; }
.kv .k { color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.switch-row:first-of-type { border-top: none; }
.switch { margin-left: auto; flex: none; width: 46px; height: 27px; border-radius: 999px;
  background: var(--border); position: relative; cursor: pointer;
  appearance: none; -webkit-appearance: none; border: none; padding: 0;
  transition: background-color .2s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(41, 37, 36, .3);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(19px); }
html[data-theme="dark"] .switch { background: var(--border); }
html[data-theme="dark"] .switch::after { background: #fff; }
.switch:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after { transition: none; }
}
.footer-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 34px; }

/* Show/hide eye inside password inputs (wrapper injected by VaultPwToggle). */
.pw-wrap { position: relative; }
.pw-wrap > input { padding-right: 42px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* Live safety countdowns (reveal auto-hide, clipboard wipe). */
.reveal-count { font-size: 12px; white-space: nowrap; }
#vclip-count { font-variant-numeric: tabular-nums; }
/* Account dropdown + theme toggle in the top bar. */
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 8px; background: none;
  border: none; cursor: pointer; padding: 6px 8px; border-radius: 10px;
  font: inherit; color: var(--text); }
.user-menu-btn:hover { background: var(--card-alt); }
html[data-theme="dark"] .user-menu-btn:hover { background: #2a2c33; }
.user-menu-list { display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); min-width: 180px; padding: 6px; z-index: 60; }
.user-menu.open .user-menu-list { display: block; }
.user-menu-list a, .user-menu-item { display: block; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: 14px;
  background: none; border: none; cursor: pointer; font: inherit; box-sizing: border-box; }
.user-menu-list a:hover, .user-menu-item:hover { background: var(--card-alt); text-decoration: none; }
html[data-theme="dark"] .user-menu-list a:hover,
html[data-theme="dark"] .user-menu-item:hover { background: #2a2c33; }
.user-menu-list form { margin: 0; }
.avatar-xs { width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; }
.caret { font-size: 11px; color: var(--faint); display: inline-block;
  transition: transform .2s ease; }
.user-menu.open .caret { transform: rotate(180deg); }
.user-text { display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.25; max-width: 170px; }
.user-name { font-weight: 600; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.user-email { font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#theme-toggle { background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 8px; border-radius: 8px; display: inline-flex; }
/* Envelope inbox icon beside the theme toggle, with its unread counter. */
#inbox-icon { background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 8px; border-radius: 8px; display: inline-flex; position: relative;
  text-decoration: none; }
#inbox-icon:hover { background: var(--card-alt); color: var(--text); }
#inbox-icon.active { background: var(--accent-soft); color: var(--text); }
#inbox-icon .inbox-badge { position: absolute; top: 1px; right: 1px; margin: 0;
  min-width: 16px; height: 16px; padding: 0 4px; font-size: 10.5px; }
#theme-toggle:hover { background: var(--card-alt); color: var(--text); }
html[data-theme="dark"] #theme-toggle:hover { background: #2a2c33; }
html[data-theme="dark"] #inbox-icon:hover { background: #2a2c33; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
/* Tag pills on the account form (progressive enhancement over the comma input). */
.tagbox { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; min-height: 46px; }
html[data-theme="dark"] .tagbox { background: #26282e; }
.tagbox-list { display: contents; }
.tagbox-input { border: none !important; outline: none !important; box-shadow: none !important;
  flex: 1; min-width: 120px; background: transparent !important;
  padding: 6px 4px !important; width: auto !important; }
.tagbox-x { background: none; border: none; cursor: pointer; color: inherit;
  font-size: 14px; padding: 0 0 0 2px; line-height: 1; }
/* Unread inbox count: full circle riding upper-right of the label. */
.inbox-badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
  line-height: 1; margin-left: 5px; vertical-align: super; }
/* Helper icon: a real button (always fits) that opens the explanation popup. */
.hint-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--muted);
  color: var(--muted); background: transparent; font-size: 12px; font-weight: 700;
  line-height: 1; cursor: pointer; margin-left: 5px; vertical-align: 1px; padding: 0;
  font-style: normal; font-family: inherit; }
.hint-icon:hover { background: var(--card-alt); color: var(--text); border-color: var(--text); }
/* Floating helper tooltip (click to pin, hover a moment to peek). */
#hint-tip { position: fixed; z-index: 70; max-width: 280px; background: var(--card);
  color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: 13.5px; line-height: 1.5; }
#hint-tip[hidden] { display: none; }
/* Collapsible settings cards (same open/close feel as the account form groups). */
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h3 { display: inline; }
details.card > summary::after { content: "–"; float: right; color: var(--faint);
  font-weight: 700; font-size: 18px; line-height: 1.4; }
details.card:not([open]) > summary::after { content: "+"; }
/* Site-wide notice banner (admin-set). */
.banner { background: var(--warn-soft); color: var(--warn-text); text-align: center;
  font-size: 14px; font-weight: 500; padding: 9px 16px; border-bottom: 1px solid var(--border); }

/* Dark theme (personal choice in Settings). Flips the design tokens only. */
html[data-theme="dark"] {
  --bg: #131416; --card: #1e1f23; --card-alt: #26282e;
  --border: #2e3036; --border-soft: #26282e;
  --text: #E7E5E4; --muted: #A8A29E; --faint: #82868F;
  --accent: #F5F4F0; --accent-hover: #ffffff; --accent-soft: #2a2c33;
  --danger: #f25c7d; --danger-soft: #3d1f2a;
  --ok: #4cc38a; --ok-soft: #16352a; --warn-soft: #3a2f18; --warn-text: #f2b23e;
  --info-soft: #1d2f4d; --info-text: #7db1f8;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4);
  --shadow-modal: 0 4px 16px rgba(0, 0, 0, .3), 0 24px 64px rgba(0, 0, 0, .5);
}
html[data-theme="dark"] .topbar { background: rgba(30, 31, 35, .92); }
html[data-theme="dark"] .nav a:hover, html[data-theme="dark"] .link-btn:hover { background: #2a2c33; }
html[data-theme="dark"] .nav details.tools-menu > summary:hover,
html[data-theme="dark"] .nav .tools-list a:hover { background: #2a2c33; }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: #26282e; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .modal { background: var(--card); }

/* Per-account colors (pastel pairs, same semantics in both themes). */
.avatar.blue { background: var(--info-soft); color: var(--info-text); }
.avatar.green { background: var(--ok-soft); color: var(--ok); }
.avatar.amber { background: var(--warn-soft); color: var(--warn-text); }
.avatar.red { background: var(--danger-soft); color: var(--danger); }
.avatar.purple { background: #F1EAFB; color: #6B4FA1; }

/* Dark theme follow-ups: every rule above that hardcodes a light surface.
   Native controls (date pickers, scrollbars, dropdowns) follow color-scheme. */
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] .btn.secondary { background: #2a2c33; }
html[data-theme="dark"] .btn.secondary:hover { background: #33363d; }
html[data-theme="dark"] .btn.ghost:hover { background: #2a2c33; }
html[data-theme="dark"] .icon-btn:hover { background: #2a2c33; }
html[data-theme="dark"] .pill { background: #2a2c33; }
html[data-theme="dark"] .pill.amber { color: #f2b23e; }
html[data-theme="dark"] details.group { background: #1a1b20; }
html[data-theme="dark"] .alert.error { color: #f27d9a; }
html[data-theme="dark"] .avatar { background: var(--accent-soft); }
html[data-theme="dark"] .toast-info { border: 1px solid var(--border); }
html[data-theme="dark"] ::placeholder { color: var(--muted); }
::placeholder { color: var(--muted); opacity: 1; }

/* Reader typeface picks (My preferences → Look & feel). */
html[data-font-sans="manrope"] { --font: "Manrope", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html[data-font-sans="outfit"] { --font: "Outfit", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html[data-font-sans="space-grotesk"] { --font: "Space Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html[data-font-sans="montserrat"] { --font: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html[data-font-sans="work-sans"] { --font: "Work Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html[data-font-display="playfair"] { --serif: "Playfair Display", Georgia, serif; }
html[data-font-display="dm-serif"] { --serif: "DM Serif Display", Georgia, serif; }
html[data-font-display="lora"] { --serif: "Lora", Georgia, serif; }

/* Keyboard focus: one thin warm line, always visible. Form fields already
   signal focus with border + halo, so the extra outline is dropped there —
   one indicator only, never two lines. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 1px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
/* Browser surfaces carry the design too: selection, caret, scrollbars. */
::selection { background: var(--accent); color: #fff; }
input, textarea { caret-color: var(--accent); }
.modal::-webkit-scrollbar, .tagbox-list::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb, .tagbox-list::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px; }

/* Record modal title bar: pinned while the record scrolls underneath. */
.record-topbar {
  position: sticky; top: calc(-1 * var(--modal-pad)); z-index: 2;
  margin: calc(-1 * var(--modal-pad)) calc(-1 * var(--modal-pad)) 12px;
  padding: 14px 12px 10px var(--modal-pad);
  background: var(--card); border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; gap: 10px;
}
.record-topbar .grow { min-width: 0; flex: 1; }
.record-topbar .title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-topbar .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Inside the title bar the X rides along instead of floating. */
.record-topbar .modal-close {
  position: static; transform: none; flex: none; margin: 0;
}
/* Send-to-device modal pieces (shared by detail page + quick-view). */
.qr-box { background: #fff; border-radius: 12px; padding: 10px; display: inline-block; margin-bottom: 8px; }
.code-input { font-family: monospace; text-align: center; font-size: 17px; letter-spacing: .08em; }
.link-input { font-family: monospace; font-size: 12px; }
.countdown-note { margin: 0 0 8px; }
/* Generator launch row on full-page forms (modal forms use the title bar). */
.gen-launch { margin: 10px 0 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border-soft); padding-top: 12px; }
/* Quick-view group headings reuse the detail page's rhythm. */
.record-group { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 2px; }
.record-title { font-size: 16px; }
.record-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.record-spin { text-align: center; color: var(--muted); padding: 26px 0; }
.record-err { text-align: center; color: var(--danger); padding: 26px 0; }

/* Dark theme: near-white primary buttons need dark text. */
html[data-theme="dark"] .btn { color: #292524; }
html[data-theme="dark"] .btn.danger { color: #fff; }
html[data-theme="dark"] .btn.secondary,
html[data-theme="dark"] .btn.ghost { color: var(--text); }

/* Bento grid: asymmetrical stat/feature cards on health + tool pages. */
.bento { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.bento .card { margin-bottom: 0; }

/* Quiet entrance: fade + 12px rise, staggered, transform/opacity only. */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(12px); }
  .reveal.in {
    opacity: 1; transform: none;
    transition: opacity .6s ease, transform .6s cubic-bezier(.16, 1, .3, 1);
    transition-delay: calc(var(--index, 0) * 80ms);
  }
}

/* Keystroke micro-UI. */
kbd {
  border: 1px solid var(--border); border-radius: 4px; background: var(--card-alt);
  font-family: var(--mono); font-size: 12px; padding: 1px 6px;
}

/* Vault filter menus: Types / Folders / Order, each its own dropdown.
   Types gets the wide multi-column panel; Folders uses the same scaling
   grid so it grows into columns as folders are added. */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.filter-menu { position: relative; }
.filter-menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border: 1px solid var(--border); border-radius: 6px;
  max-width: 240px;
}
.filter-menu > summary::-webkit-details-marker { display: none; }
.filter-menu > summary:hover { background: var(--card-alt); }
.filter-menu .filter-name { color: var(--muted); font-weight: 500; flex: none; }
.filter-menu .filter-value { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-menu .caret { font-size: 11px; color: var(--faint); flex: none; }
.filter-menu[open] > summary { border-color: var(--text); }
.filter-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 55;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 16px 20px;
}
.filter-panel-wide { width: min(720px, calc(100vw - 48px)); }
.filter-panel-med { width: min(520px, calc(100vw - 48px)); min-width: 280px; }
.filter-panel-min { min-width: 200px; }
.filter-grid { display: grid; gap: 2px 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.filter-grid a, .filter-links a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--muted);
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filter-grid a:hover, .filter-links a:hover { background: var(--card-alt); color: var(--text); text-decoration: none; }
.filter-grid a.active, .filter-links a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.filter-cols { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; margin-top: 16px; }
.filter-links { display: flex; flex-direction: column; gap: 2px; }
.filter-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
@media (max-width: 560px) {
  .filter-panel-wide, .filter-panel-med { left: 0; right: auto; width: min(520px, calc(100vw - 48px)); }
}

/* Mobile topbar: hamburger folds the nav into a dropdown panel. */
#nav-toggle { display: none; }
@media (max-width: 760px) {
  #nav-toggle { display: inline-flex; }
  .topbar-inner { flex-wrap: wrap; }
  .topbar-inner .nav {
    display: none; position: absolute; top: 100%; left: 12px; right: 12px;
    flex-direction: column; align-items: stretch; gap: 2px; margin: 0;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: 8px; z-index: 55;
  }
  .topbar-inner.nav-open .nav { display: flex; }
  .topbar-inner { position: relative; }
  .nav details.tools-menu .tools-list { position: static; box-shadow: none; border: none; padding: 0 0 0 12px; }
  .searchbar { flex-wrap: wrap; }
}

/* Reduced motion: instant, calm UI for those who ask for it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .modal { transform: none; }
  .toast { transform: none; }
  .toast::after { display: none; }
  .reveal { opacity: 1; transform: none; }
}

/* PWA install banner (Phase 1): subtle bottom card, dismissible, quiet motion.
   JS-injected only; invisible without JS. Honors prefers-reduced-motion. */
#pwa-banner {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 12px);
  z-index: 65; display: flex; align-items: center; gap: 12px;
  max-width: min(480px, calc(100vw - 32px)); padding: 12px 12px 12px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .22s ease, transform .22s ease;
}
#pwa-banner.show { opacity: 1; transform: translate(-50%, 0); }
#pwa-banner[hidden] { display: none; }
#pwa-banner .pwa-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
#pwa-banner .pwa-text { display: flex; flex-direction: column; gap: 1px; flex: 1; font-size: 14px; }
@media (prefers-reduced-motion: reduce) {
  #pwa-banner { transition: none; }
  #pwa-banner.show { transform: translate(-50%, 0); }
}

/* ---- Rhythm pass: one spacing/alignment system, no one-off styles ----
   Operate mode: precision over expression. Every rule here replaces a
   repeated inline style found across templates. Theme-safe: vars only. */

/* Section titles inside cards (replaces h3 margin/font-size one-offs). */
.card > h3, .section-h {
  font-family: var(--font); font-size: 15px; font-weight: 600;
  letter-spacing: -.01em; margin: 0 0 4px;
}
.card > h3 + .meta, .card > h3 + .sub { margin-top: 0; }
details.card > summary > h3 { font-size: 15px; font-weight: 600; margin: 0; }
details.card > summary + .meta, details.card > summary + .sub { margin-top: 0; }
/* Form labels inside centered modals read left (never centered). */
.modal .lbl { text-align: left; }
/* Block forms inside cards share one top rhythm (labels carry the rest). */
.form-block { margin-top: 12px; }
/* Danger text-actions (same weight as .link-btn, danger color). */
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn.ghost.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: var(--danger-soft); color: var(--danger); }
html[data-theme="dark"] .btn.ghost.danger { color: var(--danger); }
html[data-theme="dark"] .btn.ghost.danger:hover { background: var(--danger-soft); color: var(--danger); }
/* Alignment utilities. */
.text-center { text-align: center; }
.btn-row.center { justify-content: center; }
.btn-block { width: 100%; box-sizing: border-box; }
/* Inline forms that sit inside a row of content (unlink, delete, favorite). */
.form-inline { display: inline; }
/* Inline forms: folder rows, record action rows. */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form > input, .inline-form > select { flex: 1; min-width: 140px; width: auto; }
.inline-form > select.fit, .inline-form > .fit { flex: none; width: auto; min-width: 0; }
/* Radio/checkbox rows that read as one control. */
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text); margin: 10px 0 0; }
label.check input { width: auto; flex: none; margin-top: 3px; }
/* Pill rows under a title (vault rows). */
.pill-row { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 0; }
/* Clickable rows show the hand, and lift gently on hover. */
.card-row.clickable { cursor: pointer; }
.card-row.clickable:hover { background: var(--card-alt); }
/* Dimmed icon toggle (unstarred star). */
.icon-btn.dim { opacity: .35; }
.icon-btn.dim:hover { opacity: 1; }
/* Anchored headings never hide under the sticky topbar. */
h1, h2, h3 { scroll-margin-top: 76px; }
/* Centered result cards (verify, check-email, receive, offline…). */
.card.center { text-align: center; }
.card.roomy { padding: 40px 28px; }
/* Slim empty states for small sections (history, health lists). */
.empty.slim { padding: 22px 20px; }
/* One-line boundary notes under feature buttons. */
.fineprint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
/* Auth headers/footers (login, register, otp). */
.auth-head { text-align: center; margin: 26px 0 20px; }
.auth-head .sub { margin-bottom: 10px; }
.auth-head .sub:last-child { margin-bottom: 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 14px; }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 16px; }
.brand-mark.lg svg { width: 26px; height: 26px; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; }
.avatar-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar-xl { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
/* In-memory clipboard bar, theme-aware (was hardcoded dark). */
#vclip-bar.vclip { display: none; position: fixed; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translateX(-50%); z-index: 55; align-items: center; gap: 10px;
  background: var(--accent); color: var(--bg); border-radius: 999px;
  padding: 9px 10px 9px 18px; font-size: 14px;
  box-shadow: 0 8px 40px rgba(16,24,40,.25); max-width: 92vw; }
#vclip-bar.vclip .link-btn { color: inherit; opacity: .7; }
#vclip-bar.vclip .btn { flex: none; }
/* Tabular numerals for counts, badges, timers. */
.tnum, .inbox-badge, #vclip-count { font-variant-numeric: tabular-nums; }
/* Tag strips (vault filter chips reuse the mini tool-button size). */
.tag-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
/* Centered alert variant. */
.alert.center { text-align: center; }
/* Recovery slot titles + JS proof messages share one rhythm. */
.card h4 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
/* A section title following an action row keeps its separation. */
details.card .btn-row + h3 { margin-top: 14px; }
p.proof-msg { margin: 4px 0 0; }
/* Display treatment for the staged recovery phrase. */
.phrase-words { font-size: 17px; letter-spacing: .02em; }
/* Brand lock micro-interaction: the shackle lifts on hover. One authored
   moment, transform-only, off under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .brand-mark svg .shackle { transition: transform .3s cubic-bezier(.16, 1, .3, 1);
    transform-box: fill-box; transform-origin: center; }
  .brand:hover .brand-mark svg .shackle { transform: translateY(-1.5px); }
}
/* Detail headers, unread rows, row actions, code display. */
.title.lg { font-size: 19px; }
.code-lg { font-size: 22px; letter-spacing: .15em; }
.code-xl { font-size: 22px; letter-spacing: .35em; }
.card .field-row + .meta { margin-top: 6px; }
.card.unread { border-color: var(--accent); }
.row-actions { display: flex; gap: 6px; }
/* Record-form method blocks + flush grid bodies. */
.method { border-top: 1px solid var(--border-soft); padding-top: 12px; margin-top: 4px; }
.body.flush { padding: 0; }
/* Admin color wells + large brand logo. */
.color-well { width: 64px; height: 38px; padding: 2px; }
.brand-logo.lg { width: 48px; height: 48px; }
/* Centered result cards sit lower on the page. */
.card.lift { margin-top: 40px; }
