/* =====================================================================
   Aegis Vault — design system
   Light/dark via [data-theme] (or system), accent via [data-accent].
   No inline styles anywhere: the CSP has no 'unsafe-inline' for style.
   ===================================================================== */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --sidebar-w: 236px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* accent palette: each accent defines a light (-l) and dark (-d) value */
  --accent-l: #956200; --accent-d: #e8b54d;
  --accent-fg-l: #ffffff; --accent-fg-d: #1b1404;

  /* light theme */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7eaf0;
  --border: #e3e6ec;
  --border-strong: #cdd2db;
  --text: #13161b;
  --text-2: #4a5361;
  --text-3: #858e9c;
  --danger: #c8321f;
  --danger-soft: #fdecea;
  --warn: #a35a00;
  --warn-soft: #fff4e0;
  --ok: #0f7a4d;
  --ok-soft: #e5f6ee;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .06);
  --shadow: 0 10px 30px rgb(16 24 40 / .12), 0 2px 8px rgb(16 24 40 / .06);
  --overlay: rgb(14 17 23 / .44);
  --accent: var(--accent-l);
  --accent-fg: var(--accent-fg-l);
  --hover: rgb(16 24 40 / .045);
  --avatar-s: 60%; --avatar-l: 92%; --avatar-fg-l: 34%;
  color-scheme: light;
}

:root[data-accent="ocean"]    { --accent-l: #1d64d8; --accent-d: #6ea8ff; --accent-fg-l: #fff; --accent-fg-d: #04122b; }
:root[data-accent="emerald"]  { --accent-l: #04784f; --accent-d: #3fd29a; --accent-fg-l: #fff; --accent-fg-d: #032217; }
:root[data-accent="violet"]   { --accent-l: #6b2fd6; --accent-d: #ad8cff; --accent-fg-l: #fff; --accent-fg-d: #170733; }
:root[data-accent="rose"]     { --accent-l: #c0174a; --accent-d: #ff7a9a; --accent-fg-l: #fff; --accent-fg-d: #2e0613; }
:root[data-accent="sunset"]   { --accent-l: #c2410c; --accent-d: #ff9a52; --accent-fg-l: #fff; --accent-fg-d: #2a0f02; }
:root[data-accent="graphite"] { --accent-l: #2f333b; --accent-d: #d6d9df; --accent-fg-l: #fff; --accent-fg-d: #121418; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14;
    --surface: #14171e;
    --surface-2: #1a1e27;
    --surface-3: #232835;
    --border: #252a36;
    --border-strong: #343b4b;
    --text: #e8ebf0;
    --text-2: #a7afbd;
    --text-3: #6f7889;
    --danger: #ff6b5c;
    --danger-soft: rgb(255 107 92 / .12);
    --warn: #f0a940;
    --warn-soft: rgb(240 169 64 / .12);
    --ok: #3dd68c;
    --ok-soft: rgb(61 214 140 / .12);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow: 0 14px 40px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .35);
    --overlay: rgb(3 4 7 / .62);
    --accent: var(--accent-d);
    --accent-fg: var(--accent-fg-d);
    --hover: rgb(255 255 255 / .05);
    --avatar-s: 35%; --avatar-l: 22%; --avatar-fg-l: 78%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14;
  --surface: #14171e;
  --surface-2: #1a1e27;
  --surface-3: #232835;
  --border: #252a36;
  --border-strong: #343b4b;
  --text: #e8ebf0;
  --text-2: #a7afbd;
  --text-3: #6f7889;
  --danger: #ff6b5c;
  --danger-soft: rgb(255 107 92 / .12);
  --warn: #f0a940;
  --warn-soft: rgb(240 169 64 / .12);
  --ok: #3dd68c;
  --ok-soft: rgb(61 214 140 / .12);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow: 0 14px 40px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .35);
  --overlay: rgb(3 4 7 / .62);
  --accent: var(--accent-d);
  --accent-fg: var(--accent-fg-d);
  --hover: rgb(255 255 255 / .05);
  --avatar-s: 35%; --avatar-l: 22%; --avatar-fg-l: 78%;
  color-scheme: dark;
}

:root {
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 38%, transparent);
}

/* ------------------------------ base ------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; display: block; }
.noscript { padding: 24px; text-align: center; }
.boot { height: 100%; }

.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 0.95em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.selectable { user-select: text; word-break: break-all; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.danger-text { color: var(--danger); }
.error-text { color: var(--danger); font-size: 13px; min-height: 0; }
.error-text:empty { display: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------ buttons ------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); border-color: transparent; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.lg { height: 42px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.loading .btn-status::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.icon-btn.active { color: var(--accent); }
.icon-btn.active-fav { color: #e0a100; }
.icon-btn.active-fav .icon path { fill: currentColor; }
.link-btn {
  border: 0; background: none; padding: 0; color: var(--accent); font-weight: 550; font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--text-3); text-decoration: none; }

/* ------------------------------ inputs ------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.input, .textarea, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; width: auto; min-width: 120px; }
.select.sm { height: 32px; font-size: 13px; min-width: 0; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled { opacity: .6; }
.input.mono { font-family: var(--mono); }
.input.num { width: 72px; text-align: center; padding: 0 6px; }
.input-group { display: flex; align-items: center; gap: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); padding-right: 3px; transition: border-color .15s, box-shadow .15s; }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; }
.input-group .icon-btn { width: 32px; height: 32px; }

.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; width: 240px; height: 36px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-2); cursor: pointer; line-height: 1.4; }
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

input[type="range"].range { flex: 1; accent-color: var(--accent); min-width: 0; }

.switch {
  position: relative; width: 40px; height: 23px; flex: none;
  border-radius: 999px; border: 0; padding: 0;
  background: var(--surface-3);
  transition: background .2s;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(17px); }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2); font-weight: 550; font-size: 13px;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.sm button { height: 26px; padding: 0 8px; }

/* ------------------------------ chips, meters, misc ------------------------------ */

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.chip.sm { height: 24px; padding: 0 8px; font-size: 12px; gap: 4px; }
.chip.filter { cursor: pointer; }
.chip.filter:hover { color: var(--text); border-color: var(--border-strong); }
.chip.filter[aria-selected="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip-count { color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.filter[aria-selected="true"] .chip-count { color: inherit; opacity: .8; }
.chip.warn { color: var(--warn); }
.chip.warn:not(.filter), .chip.warn.filter[aria-selected="true"] { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.danger { color: var(--danger); }
.chip.danger:not(.filter), .chip.danger.filter[aria-selected="true"] { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag { color: var(--accent); font-size: 12px; }

.meter-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; width: 112px; flex: none; }
.meter span { height: 5px; border-radius: 3px; background: var(--surface-3); transition: background .2s; }
.meter[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.meter[data-level="2"] span:nth-child(-n+2) { background: var(--warn); }
.meter[data-level="3"] span:nth-child(-n+3) { background: #2fa36b; }
.meter[data-level="4"] span { background: var(--ok); }
.meter-label { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; white-space: nowrap; }
.meter-label b { font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

.progress { display: block; height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress-bar { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }
.progress.warn .progress-bar { background: var(--warn); }
.progress.danger .progress-bar { background: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r); background: var(--accent-soft); color: var(--text); font-size: 13px; }
.callout .icon { color: var(--accent); margin-top: 1px; }
.callout.danger { background: var(--danger-soft); }
.callout.danger .icon { color: var(--danger); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.empty h3 { font-size: 16px; color: var(--text); }
.empty p { max-width: 380px; font-size: 13.5px; }
.empty .btn { margin-top: 10px; }

.avatar {
  --hue: 210;
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: hsl(var(--hue) var(--avatar-s) var(--avatar-l));
  color: hsl(var(--hue) 55% var(--avatar-fg-l));
  font-weight: 700; font-size: 15px;
}
.avatar.lg { width: 48px; height: 48px; border-radius: 13px; font-size: 20px; }

/* ------------------------------ menus ------------------------------ */

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 180px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow);
  display: none;
}
.menu.open { display: block; animation: pop .12s var(--ease); }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 34px; padding: 0 10px; border: 0; border-radius: 6px;
  background: none; text-align: left; font-size: 13.5px; color: var(--text);
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ------------------------------ toasts ------------------------------ */

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 15px; border-radius: 11px;
  background: #1b1f27; color: #f2f4f7; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s var(--ease);
}
.toast .icon { color: #5ee0a0; }
.toast.danger .icon { color: #ff8a7a; }
.toast.show { opacity: 1; transform: none; }

/* ------------------------------ modal ------------------------------ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 16px;
  background: var(--overlay);
  opacity: 0; transition: opacity .16s;
  backdrop-filter: blur(2px);
}
.modal-backdrop.show { opacity: 1; }
.modal-backdrop:not(.show) { pointer-events: none; } /* a closing (fading) backdrop must not swallow clicks */
.modal {
  width: min(100%, 480px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateY(8px) scale(.985); transition: transform .18s var(--ease);
}
.modal-backdrop.show .modal { transform: none; }
.modal.sm { width: min(100%, 430px); }
.modal.md { width: min(100%, 560px); }
.modal-form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.modal-title { font-size: 17px; font-weight: 650; }
.modal-body { padding: 10px 20px 8px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }

/* ------------------------------ lock screen ------------------------------ */

.lock {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 40px 16px;
  background:
    radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
  position: relative;
}
.lock-theme { position: absolute; top: 14px; right: 14px; }
.lock-card {
  width: min(100%, 410px);
  padding: 28px 26px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 18px;
}
.lock-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.lock-brand h1 { font-size: 22px; font-weight: 700; margin-top: 6px; }
.lock-brand p { font-size: 13.5px; max-width: 300px; }
.lock-card .seg { width: 100%; }
.lock-card .seg button { flex: 1; }
.lock-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.pw-extra { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 0; }
.pw-extra:has(.meter-host:empty):has(.link-btn[hidden]) { display: none; }
.suggestion { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: var(--r-sm); }

.brand-mark {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: 10px; background: linear-gradient(160deg, #f0c35a, #b8841c); color: #1a1407;
}
.brand-mark .icon path:first-child { fill: currentColor; }
.brand-mark .icon path:last-child { fill: #f0c35a; stroke: none; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; box-shadow: 0 8px 24px color-mix(in srgb, #b8841c 35%, transparent); }
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; }

/* ------------------------------ app shell ------------------------------ */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100%; }
.topbar { display: none; }
.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 12px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 4px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); font-weight: 550; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-label { flex: 1; }
.nav-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item[aria-current="page"] .nav-count { color: inherit; opacity: .75; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sync-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); padding: 0 8px; }
.sync-status .icon { color: var(--ok); }
.sync-status.danger-text, .sync-status.danger-text .icon { color: var(--danger); }
.storage-mini {
  display: flex; flex-direction: column; gap: 7px; padding: 10px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-2); text-align: left;
}
.storage-mini:empty { display: none; }
.storage-mini:hover { border-color: var(--border-strong); }
.storage-text { display: flex; justify-content: space-between; align-items: center; font-size: 12px; gap: 6px; }
.storage-text > span:first-child { display: flex; align-items: center; gap: 6px; font-weight: 600; }

.main { overflow: auto; padding: 26px 30px 40px; min-width: 0; outline: none; }
.view { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.view-passwords, .view-notes { height: 100%; min-height: 540px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.view-title-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.view-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.view-sub { color: var(--text-3); font-size: 13px; }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ split (list + detail) ------------------------------ */

.split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; flex: 1; min-height: 0; }
.split-list, .split-detail { min-height: 0; overflow: auto; }
.split-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px; }
.list { display: flex; flex-direction: column; gap: 1px; }
.list-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; color: var(--text);
}
.list-item:hover { background: var(--hover); }
.list-item[aria-selected="true"] { background: var(--accent-soft); }
.li-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.li-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-flags { display: flex; align-items: center; gap: 6px; }
.icon.fav { color: #e0a100; }
.icon.fav path { fill: currentColor; }
.icon.pin { color: var(--accent); }
.back-btn { display: none; }
.detail-empty { height: 100%; display: grid; place-items: center; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }

.detail { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.detail-title { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.detail-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; width: fit-content; }
.detail-actions { display: flex; align-items: center; gap: 4px; }
.fields { padding: 4px 0; }
.field-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 18px; }
.field-row + .field-row { border-top: 1px solid var(--border); }
.field-row-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding-top: 3px; }
.field-row-value { min-width: 0; padding-top: 2px; }
.field-row-actions { display: flex; gap: 2px; margin-top: -4px; }
.secret { font-size: 15px; word-break: break-all; }
.secret.masked { letter-spacing: 2px; color: var(--text-2); }
.breach-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-meta { font-size: 12px; color: var(--text-3); padding: 0 4px; }
.disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 13px 18px; cursor: pointer; font-weight: 600; font-size: 13.5px; list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
.history { display: flex; flex-direction: column; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 8px 18px; min-width: 0; }
.history-row > :first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row + .history-row { border-top: 1px solid var(--border); }
.masked { letter-spacing: 2px; }

/* ------------------------------ notes ------------------------------ */

.notes-split { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
.note-item { align-items: flex-start; }
.note-excerpt { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; }
.note-meta { display: flex; gap: 8px; font-size: 11.5px; color: var(--text-3); margin-top: 4px; flex-wrap: wrap; }
.editor {
  height: 100%; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.editor-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 4px 20px; }
.title-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; padding: 4px 0; }
.title-input::placeholder { color: var(--text-3); }
.editor-actions { display: flex; align-items: center; gap: 2px; }
.editor-bar { display: flex; align-items: center; gap: 8px; padding: 4px 14px 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.md-toolbar { display: flex; align-items: center; gap: 1px; flex-wrap: wrap; }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.editor-body.mode-write { grid-template-columns: 1fr; }
.editor-body.mode-write .md-preview { display: none; }
.editor-body.mode-preview { grid-template-columns: 1fr; }
.editor-body.mode-preview .md-input { display: none; }
.md-input {
  width: 100%; height: 100%; min-height: 240px; resize: none; border: 0; outline: none;
  padding: 18px 20px; background: transparent; color: var(--text);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7; tab-size: 2;
}
.editor-body.mode-split .md-input { border-right: 1px solid var(--border); }
.md-preview { padding: 16px 22px 24px; overflow: auto; min-height: 0; }
.editor-body.mode-split .md-preview { background: var(--surface-2); }
.editor-foot { display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.tags-field { display: flex; align-items: center; gap: 6px; color: var(--text-3); min-width: 160px; flex: 1; }
.tags-input { border: 0; outline: none; background: transparent; font-size: 13px; color: var(--accent); flex: 1; min-width: 0; }

/* Markdown content */
.markdown { font-size: 14.5px; line-height: 1.7; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin: 1.3em 0 .5em; font-weight: 700; }
.markdown h1 { font-size: 1.6em; }
.markdown h2 { font-size: 1.35em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.15em; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 1em; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown pre, .markdown .table-wrap { margin: 0 0 .9em; }
.markdown ul, .markdown ol { padding-left: 1.5em; }
.markdown li { margin: .15em 0; }
.markdown li > ul, .markdown li > ol { margin: .2em 0; }
.markdown li.task { list-style: none; margin-left: -1.4em; display: flex; gap: .55em; align-items: flex-start; }
.markdown li.task > input { margin-top: .42em; accent-color: var(--accent); width: 15px; height: 15px; flex: none; cursor: pointer; }
.markdown li.task.done > .task-body { color: var(--text-3); text-decoration: line-through; }
.markdown .task-body { flex: 1; min-width: 0; }
.markdown blockquote { padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.markdown code { font-family: var(--mono); font-size: .88em; padding: .15em .4em; border-radius: 5px; background: var(--surface-3); }
.markdown pre { padding: 14px 16px; border-radius: 10px; background: var(--surface-3); overflow: auto; line-height: 1.55; }
.markdown pre code { padding: 0; background: none; font-size: 13px; }
.markdown hr { border: 0; height: 1px; background: var(--border); margin: 1.4em 0; }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.markdown table, .data-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.markdown th, .markdown td, .data-table th, .data-table td { padding: 7px 11px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.markdown th, .data-table th { background: var(--surface-2); font-weight: 650; position: sticky; top: 0; }
.markdown tr:last-child td, .data-table tr:last-child td { border-bottom: 0; }

/* ------------------------------ files ------------------------------ */

.files-view { position: relative; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.usage { display: flex; flex-direction: column; gap: 7px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.usage:empty { display: none; }
.usage-text { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.usage-text > span:first-child { display: flex; align-items: center; gap: 6px; }
.usage-text .icon { color: var(--text-3); }
.usage .progress { height: 7px; }
.settings .usage { border: 0; padding: 4px 0 0; background: none; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 14px; }
.file-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease);
}
.file-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.file-thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.file-thumb img, .thumb-host img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-host { width: 100%; height: 100%; display: grid; place-items: center; }
.file-info { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px 11px; min-width: 0; }
.file-name { font-weight: 600; font-size: 13.5px; }
.file-card-actions { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; }
.file-card-actions .icon-btn { background: var(--surface); box-shadow: var(--shadow-sm); width: 30px; height: 30px; }
.file-card:hover .file-card-actions, .file-card:focus-within .file-card-actions { opacity: 1; }
.file-icon { --k: var(--text-3); position: relative; display: grid; place-items: center; color: var(--k); }
.file-ext { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; background: var(--k); color: #fff; white-space: nowrap; }
.file-thumb .file-icon .icon { width: 40px; height: 40px; }
.k-image { --k: #8b5cf6; } .k-video { --k: #e11d48; } .k-audio { --k: #f97316; } .k-pdf { --k: #dc2626; }
.k-document { --k: #2563eb; } .k-spreadsheet { --k: #16a34a; } .k-presentation { --k: #ea580c; } .k-ebook { --k: #b45309; }
.k-markdown, .k-text { --k: #64748b; } .k-code { --k: #0d9488; } .k-data { --k: #059669; } .k-key { --k: #ca8a04; }
.k-archive { --k: #a16207; } .k-font { --k: #475569; } .k-other { --k: #6b7280; }

.file-rows { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 4px; }
.file-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 120px 80px 110px 34px; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 9px; cursor: pointer; }
.file-row:hover { background: var(--hover); }
.file-row-thumb { width: 38px; height: 38px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.file-row-thumb .file-ext { display: none; }

.uploads:empty { display: none; }
.upload-list { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.upload-head { display: flex; justify-content: space-between; align-items: center; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 28px; gap: 14px; align-items: center; }
.upload-name { display: flex; flex-direction: column; min-width: 0; font-weight: 550; font-size: 13px; }
.upload-progress { display: flex; flex-direction: column; gap: 4px; }
.upload-item.done .progress-bar { background: var(--ok); }

.dropzone {
  position: absolute; inset: -8px; z-index: 20; display: none; place-items: center;
  border: 2px dashed var(--accent); border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(4px);
}
.files-view.dragging .dropzone { display: grid; }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--accent); pointer-events: none; }
.dropzone-inner strong { font-size: 17px; color: var(--text); }
.dropzone-inner span { color: var(--text-2); font-size: 13px; }
.drop-empty { border: 2px dashed var(--border-strong); border-radius: 18px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop-empty:hover { border-color: var(--accent); background: var(--accent-soft); }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto minmax(0, 1fr); background: rgb(8 10 14 / .94); color: #eef1f5; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.viewer .icon-btn { color: #c9cfd8; }
.viewer .icon-btn:hover { background: rgb(255 255 255 / .1); color: #fff; }
.viewer .muted { color: #9aa3b0; }
.viewer-bar { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 20px; border-bottom: 1px solid rgb(255 255 255 / .08); }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-actions { display: flex; gap: 2px; }
.viewer-main { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 16px 64px; }
.viewer-stage { width: 100%; height: 100%; display: grid; place-items: center; min-height: 0; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgb(255 255 255 / .08) !important; }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-img { max-width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgb(0 0 0 / .5); background: repeating-conic-gradient(#2a2f38 0% 25%, #1f232a 0% 50%) 50% / 20px 20px; }
.viewer-video { max-width: 100%; max-height: calc(100dvh - 110px); border-radius: 8px; background: #000; }
.viewer-audio { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.viewer-audio audio { width: min(460px, 80vw); }
.viewer-pdf { width: min(1100px, 100%); height: calc(100dvh - 100px); border: 0; border-radius: 6px; background: #fff; }
.viewer-doc { width: min(960px, 100%); max-height: calc(100dvh - 100px); overflow: auto; padding: 26px 30px; border-radius: 12px; background: var(--surface); color: var(--text); }
.viewer-text { margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.viewer-cut { margin-top: 14px; }
.viewer-loading, .viewer-fallback { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.viewer-loading .progress { width: 220px; background: rgb(255 255 255 / .12); }
.viewer-fallback .file-icon .icon { width: 56px; height: 56px; }
.viewer-fallback .file-ext { bottom: -14px; }
.viewer-fallback strong { margin-top: 10px; font-size: 16px; overflow-wrap: anywhere; }

/* ------------------------------ generator ------------------------------ */

.gen { display: flex; flex-direction: column; gap: 16px; max-width: 760px; width: 100%; }
.gen-mode .seg { flex-wrap: wrap; }
.gen-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.gen-output {
  min-height: 74px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 16px 18px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
  font-size: 22px; line-height: 1.4; word-break: break-all; user-select: all; letter-spacing: .01em;
}
.gen-output.long { font-size: 16px; }
.ch-d { color: var(--accent); }
.ch-s { color: #d9480f; }
:root[data-theme="dark"] .ch-s { color: #ff9a6a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ch-s { color: #ff9a6a; } }
.gen-strength { display: flex; justify-content: center; }
.gen-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gen-breach { text-align: center; font-size: 13px; display: flex; gap: 6px; justify-content: center; align-items: center; color: var(--text-2); }
.gen-breach:empty { display: none; }
.gen-breach.good { color: var(--ok); }
.gen-breach.bad { color: var(--danger); }
.gen-options { padding: 6px 20px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; }
.opt-row + .opt-row { border-top: 1px solid var(--border); }
.opt-label { display: flex; flex-direction: column; font-weight: 550; }
.range-row { display: flex; align-items: center; gap: 12px; flex: 1; max-width: 380px; }
.gen-options > .hint { padding: 4px 0 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px 18px 10px; flex-wrap: wrap; }
.section-head h3 { font-size: 14px; }
.gen-history .history-row { padding: 8px 18px; }

/* ------------------------------ settings ------------------------------ */

.settings { display: flex; flex-direction: column; gap: 16px; max-width: 780px; width: 100%; }
.settings-section { padding: 4px 20px 8px; }
.settings-section .section-head { padding: 16px 0 6px; flex-direction: column; gap: 3px; }
.settings-section h2 { font-size: 15.5px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; }
.setting-row + .setting-row, .usage + .setting-row { border-top: 1px solid var(--border); }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-label { font-weight: 600; }
.setting-control { flex: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  position: relative; width: 30px; height: 30px; border-radius: 50%; padding: 0;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
  display: grid; place-items: center; color: #fff;
}
.swatch-dot { position: absolute; inset: 2px; border-radius: 50%; }
.swatch .icon { position: relative; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--accent); }
.swatch[data-swatch="aegis"] .swatch-dot { background: linear-gradient(140deg, #f0c35a, #b8841c); }
.swatch[data-swatch="ocean"] .swatch-dot { background: linear-gradient(140deg, #6ea8ff, #1d64d8); }
.swatch[data-swatch="emerald"] .swatch-dot { background: linear-gradient(140deg, #3fd29a, #04784f); }
.swatch[data-swatch="violet"] .swatch-dot { background: linear-gradient(140deg, #ad8cff, #6b2fd6); }
.swatch[data-swatch="rose"] .swatch-dot { background: linear-gradient(140deg, #ff7a9a, #c0174a); }
.swatch[data-swatch="sunset"] .swatch-dot { background: linear-gradient(140deg, #ff9a52, #c2410c); }
.swatch[data-swatch="graphite"] .swatch-dot { background: linear-gradient(140deg, #9aa1ad, #2f333b); }
.crypto-readout { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 16px; margin: 4px 0 14px; font-size: 13px; }
.crypto-readout dt { color: var(--text-2); font-weight: 600; }
.crypto-readout dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 1080px) {
  .search .input { width: 190px; }
  .file-row { grid-template-columns: 38px minmax(0, 1fr) 80px 34px; }
  .file-row .hide-sm { display: none; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; height: 52px; padding: 6px 2px; justify-content: center; font-size: 11px; }
  .nav-label { flex: none; }
  .nav-count { display: none; }
  .main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .view-passwords, .view-notes { height: auto; min-height: 0; }
  .view-title { font-size: 21px; }
  .view-head { align-items: stretch; flex-direction: column; }
  .view-actions { width: 100%; }
  .view-actions .search { flex: 1; }
  .search .input { width: 100%; }
  .split, .notes-split { grid-template-columns: minmax(0, 1fr); }
  .split .split-detail { display: none; }
  .split.show-detail .split-detail { display: block; }
  .split.show-detail .split-list { display: none; }
  .split-list, .split-detail { overflow: visible; }
  .detail-empty { display: none; }
  .back-btn { display: inline-grid; margin-left: -8px; }
  .field-row { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 14px; }
  .field-row-label { grid-column: 1 / -1; padding: 0; }
  .editor { height: auto; min-height: calc(100dvh - 190px); }
  .editor-body, .editor-body.mode-split { grid-template-columns: 1fr; }
  .editor-body.mode-split .md-preview { display: none; }
  .editor-body.mode-split .md-input { border-right: 0; }
  .md-input { min-height: 50dvh; padding: 14px 16px; }
  .editor-head { padding: 10px 10px 2px 14px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .file-card-actions { opacity: 1; }
  .upload-item { grid-template-columns: minmax(0, 1fr) 28px; }
  .upload-item .upload-progress, .upload-item > .danger-text { grid-column: 1; grid-row: 2; }
  .upload-item > .icon-btn { grid-row: 1 / span 2; grid-column: 2; }
  .viewer-main { padding: 8px; }
  .viewer-nav { top: auto; bottom: 14px; transform: none; z-index: 2; }
  .viewer-doc { padding: 18px; }
  .viewer-bar { padding: 8px 8px 8px 14px; }
  .setting-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-control { display: flex; }
  .crypto-readout { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .crypto-readout dd { margin-bottom: 8px; }
  .opt-row { flex-wrap: wrap; }
  .range-row { max-width: none; min-width: 200px; }
  .gen-output { font-size: 18px; }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100% !important; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
