/* ═══════════════════════════════════════════════════════════════════════
   Postern Desktop — design system
   Identity: sovereign secure instrument panel. Dark graphite surfaces,
   one warm brass signal (the Seal), cool mono data. Status colors are
   semantic and never reuse the accent.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* surfaces (dark instrument — default) */
  --bg0: #0a0e13;          /* window */
  --bg1: #0f151d;          /* sidebar / topbar */
  --bg2: #141c26;          /* card */
  --bg3: #1a2431;          /* inset / input */
  --line: #223140;
  --line-strong: #2e4152;

  /* ink */
  --fg: #d9e4ec;
  --muted: #8499a8;
  --faint: #5a6e7c;

  /* the brass seal — Postern's one accent */
  --brass: #d9b45b;
  --brass-bright: #f2cc70;
  --brass-ink: #241b06;                 /* text on brass */
  --brass-dim: rgba(217, 180, 91, .13);
  --brass-line: rgba(217, 180, 91, .38);

  /* semantic status (distinct from accent) */
  --ok: #3fc98c;
  --ok-dim: rgba(63, 201, 140, .12);
  --warn: #e8973f;
  --warn-dim: rgba(232, 151, 63, .12);
  --crit: #e85d5d;
  --crit-dim: rgba(232, 93, 93, .12);
  --info: #5fa8d3;
  --info-dim: rgba(95, 168, 211, .12);

  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 12px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg0: #e9edf1;
  --bg1: #f2f5f7;
  --bg2: #fbfcfd;
  --bg3: #e6ebef;
  --line: #d0d9e0;
  --line-strong: #b4c2cd;

  --fg: #202e39;
  --muted: #566977;
  --faint: #8496a3;

  --brass: #97731c;
  --brass-bright: #7a5d15;
  --brass-ink: #fdf6e3;
  --brass-dim: rgba(151, 115, 28, .10);
  --brass-line: rgba(151, 115, 28, .40);

  --ok: #178a58;
  --ok-dim: rgba(23, 138, 88, .10);
  --warn: #b06410;
  --warn-dim: rgba(176, 100, 16, .10);
  --crit: #c23c36;
  --crit-dim: rgba(194, 60, 54, .09);
  --info: #2d6f9e;
  --info-dim: rgba(45, 111, 158, .10);

  --shadow: 0 8px 24px rgba(32, 46, 57, .10);
}

/* ── reset-ish ─────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font-ui);
  background: var(--bg0);
  color: var(--fg);
  overflow: hidden;               /* the app manages its own scroll regions */
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; }
code { font-family: var(--font-mono); }
::selection { background: var(--brass-dim); }

/* keyboard focus — always visible, brass */
:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── app shell ─────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  height: 100vh;
}

/* sidebar */
.sidebar {
  background: var(--bg1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-seal { width: 26px; height: 26px; color: var(--brass); flex: none; }
.brand-name strong {
  display: block;
  font-size: 15px;
  letter-spacing: .18em;
  font-weight: 700;
}
.brand-name span {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .22em;
  color: var(--faint);
  margin-top: 1px;
}

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 8px; min-height: 0; }
.nav-group { margin-bottom: 14px; }
/* Advanced · testnet (zero value) — collapsible <details> group, closed by default. */
details.nav-group-advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
details.nav-group-advanced > summary.nav-group-label {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details.nav-group-advanced > summary.nav-group-label::-webkit-details-marker { display: none; }
details.nav-group-advanced > summary.nav-group-label::before { content: "▸"; font-size: 8px; }
details.nav-group-advanced[open] > summary.nav-group-label::before { content: "▾"; }
.nav-group-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .24em;
  color: var(--faint);
  padding: 0 8px 5px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 8px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 1px;
  transition: background .12s ease, color .12s ease;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--bg2); color: var(--fg); }
.nav-item.active {
  background: var(--bg3);
  color: var(--fg);
  border-color: var(--line);
}
.nav-item.active svg { color: var(--brass); opacity: 1; }
.nav-item .nav-flag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
}
.nav-item .nav-flag.live { color: var(--ok); border-color: transparent; background: var(--ok-dim); }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--line); }
.panic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--crit);
  color: var(--crit);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .04em;
  transition: background .12s ease;
}
.panic-btn svg { width: 15px; height: 15px; }
.panic-btn:hover { background: var(--crit-dim); }
.sidebar-meta {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  color: var(--faint);
  text-align: center;
}

/* Persistent honesty strip — the two load-bearing claims must never scroll away:
   this is an unaudited public beta, and it hardens but does not anonymize. */
.honesty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  padding: 7px 8px;
  border: 1px dashed var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-dim);
  cursor: help;
}
.honesty-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .13em;
  font-weight: 700;
  color: var(--warn);
  text-transform: uppercase;
}
.honesty-note {
  font-size: 10px;
  letter-spacing: .03em;
  color: var(--faint);
}

/* main column */
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar-title h1 { font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.topbar-title p { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-status { display: flex; align-items: center; gap: 8px; flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--fg); }
.chip svg { width: 13px; height: 13px; }
.chip-icon { padding: 5px 8px; }
.chip-seal { border-color: var(--brass-line); color: var(--brass); font-weight: 600; }
.chip-seal:hover { color: var(--brass-bright); border-color: var(--brass); }
.chip-seal.seal-genuine { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.chip-seal.seal-compromised { background: var(--crit-dim); color: var(--crit); border-color: var(--crit); }
.chip.on { color: var(--fg); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.dot.crit { background: var(--crit); }
@media (prefers-reduced-motion: no-preference) {
  .dot.pulse { animation: pulse 2.2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .45; } }
}

/* content region — the only vertical scroller */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  min-height: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .content > .module { animation: modIn .16s ease-out; }
  @keyframes modIn { from { opacity: 0; transform: translateY(4px); } }
}

/* ── layout primitives ─────────────────────────────────────────────────── */
.module { max-width: 1060px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 980px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }

.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 13.5px; font-weight: 650; letter-spacing: .01em; }
.card-head .spacer { flex: 1; }

/* honest-stub + status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-stub { color: var(--warn); background: var(--warn-dim); border: 1px dashed var(--warn); }
.badge-live { color: var(--ok); background: var(--ok-dim); border: 1px solid transparent; }
.badge-ok   { color: var(--ok);   background: var(--ok-dim); }
.badge-warn { color: var(--warn); background: var(--warn-dim); }
.badge-crit { color: var(--crit); background: var(--crit-dim); }
.badge-info { color: var(--info); background: var(--info-dim); }
.badge-brass { color: var(--brass); background: var(--brass-dim); border: 1px solid var(--brass-line); }

/* fields */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}
.field input, .field textarea, .field select, .input {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
.field input:focus, .field textarea:focus, .field select:focus, .input:focus {
  outline: none;
  border-color: var(--brass);
}
.field input[readonly] { color: var(--brass); font-family: var(--font-mono); font-size: 12.5px; }
.field textarea { resize: vertical; font-family: var(--font-mono); font-size: 12.5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--fg); cursor: pointer; user-select: none;
}
.check input { accent-color: var(--brass); width: 14px; height: 14px; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  padding: 7px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: 550;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--brass-line); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brass-bright); border-color: var(--brass-bright); }
.btn-danger { background: none; border-color: var(--crit); color: var(--crit); }
.btn-danger:hover:not(:disabled) { background: var(--crit-dim); border-color: var(--crit); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--fg); border-color: var(--line); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.actions:first-child { margin-top: 0; }

/* stat tiles (instrument readouts) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  min-width: 0;
}
.stat b {
  display: block;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat b.accent { color: var(--brass); }
.stat span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--faint);
}

/* mono value rows (address, key, hash…) */
.kv { display: flex; flex-direction: column; gap: 6px; }
.kv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.kv-row .k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  flex: none;
  width: 110px;
}
.kv-row .v {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.kv-row .v.accent { color: var(--brass); }

/* tables (explorer etc.) */
.scroll-x { overflow-x: auto; max-width: 100%; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  white-space: nowrap;
}
table.data tr:hover td { background: var(--bg3); }
table.data .num { text-align: right; }

/* logs / raw output */
.logview {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  height: 300px;
  overflow: auto;
  margin: 0;
  font: 11.5px/1.6 var(--font-mono);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}
.logview .log-preview { color: var(--warn); }

/* notes & callouts */
.note { font-size: 12px; color: var(--muted); line-height: 1.55; }
.note + .note { margin-top: 6px; }
.callout {
  border-radius: var(--r-md);
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--muted);
}
.callout strong { color: var(--fg); font-weight: 600; }
.callout-warn { border-color: var(--warn); background: var(--warn-dim); color: var(--fg); }
.callout-crit { border-color: var(--crit); background: var(--crit-dim); color: var(--fg); }
.callout-brass { border-color: var(--brass-line); background: var(--brass-dim); color: var(--fg); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout li { margin: 2px 0; }

/* mnemonic reveal */
.mnemonic {
  background: var(--warn-dim);
  border: 1px solid var(--warn);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 12px;
}
.mnemonic strong { color: var(--warn); display: block; margin-bottom: 8px; font-size: 12.5px; }
.mnemonic code { color: var(--fg); word-spacing: 6px; line-height: 1.9; font-size: 13px; }

/* audit checklist (seal) */
.audit-list { display: flex; flex-direction: column; gap: 6px; }
.audit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 12px;
}
.audit-item .a-name { font-family: var(--font-mono); font-size: 12px; flex: none; width: 150px; }
.audit-item .a-detail { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* seal emblem (seal module hero) */
.seal-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--brass-line);
  background:
    radial-gradient(600px 200px at 20% 0%, var(--brass-dim), transparent 60%),
    var(--bg2);
}
.seal-hero svg { width: 58px; height: 58px; color: var(--brass); flex: none; }
.seal-hero .sh-verdict { font-family: var(--font-mono); font-size: 18px; font-weight: 700; letter-spacing: .08em; }
.seal-hero .sh-verdict.ok { color: var(--ok); }
.seal-hero .sh-verdict.warn { color: var(--warn); }
.seal-hero .sh-verdict.crit { color: var(--crit); }
.seal-hero p { font-size: 12.5px; color: var(--muted); margin-top: 3px; max-width: 60ch; }

/* messenger */
.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 340px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.msg { max-width: 78%; align-self: flex-end; }
.msg.them { align-self: flex-start; }
.msg .bubble {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 10px 10px 3px 10px;
  padding: 8px 11px;
  font-size: 13px;
  word-break: break-word;
}
.msg.them .bubble { border-radius: 10px 10px 10px 3px; }
.msg .meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--faint);
  margin-top: 3px;
  text-align: right;
}
.msg.them .meta { text-align: left; }
.msg .cipher {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  word-break: break-all;
  margin-top: 4px;
  border-top: 1px dashed var(--line);
  padding-top: 4px;
}

/* dropzone (courier / hygiene) */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brass); background: var(--brass-dim); color: var(--fg); }
.dropzone strong { display: block; color: var(--fg); margin-bottom: 3px; }
.dropzone input { display: none; }

/* vault entries */
.entry-list { display: flex; flex-direction: column; gap: 6px; }
.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 12px;
}
.entry .e-name { font-family: var(--font-mono); font-size: 12.5px; flex: none; }
.entry .e-secret {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry .e-secret.revealed { color: var(--brass); }

/* locked state */
.locked-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
}
.locked-box svg { width: 40px; height: 40px; color: var(--faint); }
.locked-box strong { color: var(--fg); font-size: 15px; }

/* sub-tabs inside a module */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.subtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 7px 13px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--fg); }
.subtab.active { color: var(--brass); border-bottom-color: var(--brass); font-weight: 600; }

/* raw JSON viewer */
.json-view {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  margin: 0;
  max-height: 360px;
  overflow: auto;
  font: 11.5px/1.6 var(--font-mono);
  color: var(--muted);
  white-space: pre;
}

/* inline error / result lines */
.result-line { font-family: var(--font-mono); font-size: 12px; min-height: 18px; }
.result-line.ok { color: var(--ok); }
.result-line.err { color: var(--crit); }
.result-line.muted { color: var(--muted); }

.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* copy affordance */
.copy-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--faint);
  cursor: pointer;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  flex: none;
}
.copy-btn:hover { color: var(--brass); border-color: var(--brass-line); }

/* ── toasts ────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  max-width: 340px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 12.5px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--crit); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toastIn .18s ease-out; }
  @keyframes toastIn { from { opacity: 0; transform: translateX(12px); } }
}

/* ── panic overlay ─────────────────────────────────────────────────────── */
.panic-overlay[hidden] { display: none; }
.panic-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg0) 88%, transparent);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.panic-overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--crit);
  padding: 30px 40px;
  border: 1px solid var(--crit);
  border-radius: var(--r-lg);
  background: var(--bg1);
}
.panic-overlay-box svg { width: 52px; height: 52px; }
.panic-overlay-box strong { font-family: var(--font-mono); font-size: 19px; letter-spacing: .18em; }
.panic-overlay-box span { color: var(--muted); font-size: 12.5px; max-width: 40ch; }
@media (prefers-reduced-motion: no-preference) {
  .panic-overlay-box { animation: panicIn .18s ease-out; }
  @keyframes panicIn { from { opacity: 0; transform: scale(.96); } }
}

/* scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Phone-as-Signer (modules/pair.js) ─────────────────────────────────── */
.qr-box { display: inline-block; padding: 12px; background: #fff; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); }
.qr-box svg { display: block; width: 200px; height: 200px; }
.pr-val { padding: 8px 10px; background: var(--brass-ink); border: 1px solid var(--line);
  border-radius: var(--r-sm); word-break: break-all; font-size: 12px; }
.pr-val.small { font-size: 11px; color: var(--muted); }

.sas-box { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--brass-line);
  border-radius: var(--r-md); background: var(--brass-dim); text-align: center; }
.sas-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.sas-digits { font-size: 32px; font-weight: 700; letter-spacing: .18em; color: var(--brass-bright);
  margin: 4px 0 6px; }

.pair-list, .grant-list { display: flex; flex-direction: column; gap: 8px; }
.pair-row, .grant-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  align-items: center; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--brass-ink); }
.pair-row.revoked, .grant-row.dead { opacity: .6; }
.pair-main, .grant-main { display: flex; align-items: center; gap: 8px; }
.pair-meta, .grant-meta { grid-column: 1 / 2; font-size: 12px; color: var(--muted); }
.pair-actions, .grant-actions { grid-row: 1 / 3; grid-column: 2; align-self: center; }

.signreq { border: 1px solid var(--brass-line); border-radius: var(--r-md); padding: 14px;
  background: var(--brass-dim); }
.signreq-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.signreq-summary { font-size: 14px; margin: 4px 0 10px; }
.sr-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 12px;
  color: var(--muted); }

/* ── shared loading / empty / error states (UI.loadingState/emptyState/errorState) ──
   Theme-var based: the dark defaults and the light overrides in
   :root[data-theme="light"] both flow through automatically. */
.state { display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border: 1px dashed var(--line); border-radius: var(--r-md); font-size: 13px;
  color: var(--muted); background: var(--bg3); }
.state-loading .state-dot { width: 9px; height: 9px; border-radius: 50%;
  background: var(--info); animation: state-pulse 1.1s ease-in-out infinite; flex: none; }
@keyframes state-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.state-empty { flex-direction: column; align-items: flex-start; gap: 4px; }
.state-empty .state-hint { font-size: 12px; color: var(--faint); }
.state-error { border-style: solid; border-color: var(--crit); color: var(--crit);
  background: var(--crit-dim); }

/* ── per-pane privacy caveat (UI.privacyCaveat) — one honest block, every pane ── */
.pane-caveat { margin-top: 4px; padding: 10px 14px; border: 1px solid var(--warn);
  border-left-width: 4px; border-radius: var(--r-md); background: var(--warn-dim);
  color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ── Mobile PWA layout ─────────────────────────────────────────────────────
   The desktop shell is a fixed 224px sidebar + content, side by side. On a
   phone that leaves ~160px for the content column, which crushes every pane.
   Below 720px the sidebar becomes a horizontal, scrollable nav strip on top and
   the content takes the full width — the same panes, laid out for one hand. */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;   /* stack: nav on top, content below */
    grid-template-rows: auto 1fr;
    height: 100vh;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;             /* nav never eats more than ~2/5 of the screen */
  }
  /* The brand block is dead weight on a phone — collapse it to a thin bar. */
  .brand { padding: 10px 14px; }
  .brand-name span { display: none; }
  /* Nav items get bigger touch targets. */
  .nav-item { padding: 11px 12px; font-size: 15px; }
  .nav-item svg { width: 18px; height: 18px; }
  /* Content breathes edge-to-edge; kill any desktop max-width centering. */
  .main-col { min-width: 0; }
  .pane, .card, .panel { border-radius: 10px; }
  /* Tables and pre blocks must scroll inside themselves, never widen the page. */
  .pane table, .pane pre, .card table, .card pre {
    display: block; max-width: 100%; overflow-x: auto;
  }
  /* Buttons and inputs go full-width so they are tappable, not fiddly. */
  .btn { min-height: 44px; }
  input, select, textarea { font-size: 16px; }  /* 16px stops iOS zoom-on-focus */
}

/* Very narrow phones: let the nav strip scroll horizontally instead of wrapping
   into a tall block that pushes the content off-screen. */
@media (max-width: 420px) {
  .sidebar { max-height: 38vh; }
  .brand-name strong { font-size: 13px; letter-spacing: .12em; }
}

/* ── Mobile nav collapse ───────────────────────────────────────────────────
   The hamburger lives in the brand bar and is desktop-hidden. On a phone it
   toggles .nav-collapsed on .app: the sidebar shrinks to just its brand bar so
   the content pane gets the whole screen, and expands back on tap. Selecting a
   pane auto-collapses (see main.js) so you are never left staring at the menu. */
.nav-toggle {
  display: none;
  background: none; border: none; color: var(--brass);
  padding: 4px; margin: -4px 6px -4px -2px; cursor: pointer; border-radius: 6px;
  align-items: center;
}
.nav-toggle:hover { background: rgba(180,140,60,.12); }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  /* When collapsed, the sidebar is only as tall as its brand bar. */
  .app.nav-collapsed { grid-template-rows: auto 1fr; }
  .app.nav-collapsed .sidebar { max-height: none; }
  .app.nav-collapsed .nav,
  .app.nav-collapsed .sidebar-foot { display: none; }
  /* Expanded: the nav strip returns, capped so it cannot bury the content. */
  .app:not(.nav-collapsed) .sidebar { max-height: 46vh; }
}
