/* Channel Registry: a utilitarian product UI. Tokens first; dark mode
   redefines them. No external fonts, no inline styles (CSP style-src 'self'). */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c3cad4;
  --text: #16191d;
  --muted: #5a6470;
  --accent: #0a62c6;
  --accent-strong: #084e9e;
  --accent-soft: #e7f0fb;
  --accent-border: #a9c8ef;
  --on-accent: #ffffff;
  --amber: #8a5300;
  --amber-soft: #fdf1da;
  --amber-border: #efcf90;
  --red: #b42318;
  --red-soft: #fdeceb;
  --red-border: #f1b8b2;
  --green: #17723a;
  --green-soft: #e6f4ea;
  --green-border: #a8d9b7;
  --neutral-soft: #eef0f3;
  --skeleton: #e4e8ed;
  --focus: #0a62c6;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
  --backdrop: rgb(10 14 20 / 55%);
  --radius: 10px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c2129;
    --border: #2a313c;
    --border-strong: #3b4452;
    --text: #e6e9ee;
    --muted: #9ba5b2;
    --accent: #5ea9f6;
    --accent-strong: #84bdf8;
    --accent-soft: #132840;
    --accent-border: #29507d;
    --on-accent: #08111d;
    --amber: #f0b95e;
    --amber-soft: #2b2110;
    --amber-border: #5c4519;
    --red: #f38a7f;
    --red-soft: #33171a;
    --red-border: #5f2b2b;
    --green: #6fd08c;
    --green-soft: #12271a;
    --green-border: #2c5a3a;
    --neutral-soft: #222833;
    --skeleton: #262c36;
    --focus: #84bdf8;
    --shadow: none;
    --backdrop: rgb(0 0 0 / 65%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; }
p { margin: 0 0 8px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.mono { font-family: var(--mono); font-size: 0.86em; overflow-wrap: anywhere; }
.num, .r { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.block { display: block; }
.strong { font-weight: 650; }
.you { font-weight: 600; color: var(--accent); }
.nowrap { white-space: nowrap; overflow-wrap: normal; }
/* The program's own term, shown small beside the plain-words label. */
.term { font-family: var(--mono); font-size: 0.72rem; font-weight: 500; color: var(--muted); letter-spacing: 0; text-transform: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -10000px;
  top: 8px;
  background: var(--surface);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 6px;
  z-index: 10;
}
.skip-link:focus { left: var(--gutter); }

.wrap {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ------------------------------------------------------------ controls */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--red); border-color: var(--red-border); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 28px; padding: 3px 9px; font-size: 0.8125rem; }
.btn-xs { min-height: 24px; padding: 1px 7px; font-size: 0.75rem; font-weight: 500; }
.expand { min-width: 28px; font-weight: 700; }

input[type="text"], input[type="url"], textarea, .select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}
textarea { resize: vertical; line-height: 1.45; }
input.mono, textarea.mono { font-size: 0.875rem; }
input:disabled { background: var(--surface-2); color: var(--muted); }
[aria-invalid="true"] { border-color: var(--red); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.field { display: grid; gap: 4px; align-content: start; margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.field > label, fieldset.field > legend { font-weight: 600; font-size: 0.875rem; padding: 0; }
fieldset.field > legend { margin-bottom: 4px; }
.radios { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.radios label, .check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 0.9375rem; }
.check { white-space: nowrap; }
.hint-inline { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
.inline { display: flex; gap: 10px; align-items: center; }
.hint { color: var(--muted); font-size: 0.8125rem; margin: 2px 0 0; }
.field-error { color: var(--red); font-size: 0.8125rem; margin: 2px 0 0; }
.field-error:empty, .hint:empty { display: none; }

.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 16px; }
/* Bottom-aligned, so a label that wraps never pushes its input below its neighbour's. */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0 12px; }
.span-2 { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ------------------------------------------------------------- top bar */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding-block: 10px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: 4px 4px 0 var(--accent-border); }
.topbar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cluster .select { width: auto; min-width: 120px; }
.chain-label {
  font-size: 0.8125rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}
.chain-label[data-state="mismatch"] { color: var(--red); border-color: var(--red-border); background: var(--red-soft); font-weight: 600; }
.wallet, .wallet-connected { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wallet-id { display: grid; line-height: 1.25; }
.wallet-address { font-weight: 600; }
.wallet-balance { color: var(--muted); font-size: 0.875rem; }
.wallet-role { color: var(--muted); font-size: 0.75rem; }
.wallet-role:empty { display: none; }

.settings { margin-top: 12px; }

/* ---------------------------------------------------- product section */

a.btn { text-decoration: none; }
.brand { color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 0.9375rem; font-weight: 550; }
.site-nav a { display: inline-block; min-height: 24px; padding: 4px 0; text-decoration: none; }
.product { margin-top: 24px; }
.product h1 { font-size: 1.75rem; margin: 0 0 6px; letter-spacing: -0.01em; }
.lead { font-size: 1.125rem; font-weight: 550; }
.product-section { margin-top: 32px; }
.product-section h2, .registry-head h2 { font-size: 1.25rem; margin: 0 0 8px; }
.product-section h3 { font-size: 1rem; margin: 16px 0 6px; }
.prose p, .prose li, .prose dd { max-width: 68ch; }
.prose .kv { font-size: 0.9375rem; }
.steps { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.actions-start { justify-content: flex-start; }
.registry-head { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.registry-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.site-footer { border-top: 1px solid var(--border); padding-block: 16px 40px; color: var(--muted); font-size: 0.875rem; }
.advanced { margin: 0 0 12px; }
.advanced > summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; font-weight: 550; margin-bottom: 8px; }

/* ------------------------------------------------------- cards, notices */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-title { font-size: 1.0625rem; font-weight: 650; margin: 0 0 8px; }
.sub-title {
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 16px 0 6px;
}

.callout {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 0.9rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout-warn { background: var(--amber-soft); border-color: var(--amber-border); }
.callout-info { background: var(--accent-soft); border-color: var(--accent-border); }
.inline-callout, #summary-message, #publisher-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.inline-callout p, #summary-message p, #publisher-intro p { margin: 0; }
#summary-message p { font-weight: 550; }

.banner { padding: 10px var(--gutter); font-weight: 600; }
.banner-error { background: var(--red-soft); color: var(--red); border-bottom: 1px solid var(--red-border); }

.notices { display: grid; gap: 8px; }
.notices:has(> :not([hidden]):not(:empty)) { margin-top: 12px; }
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--amber-border);
  background: var(--amber-soft);
  border-radius: 8px;
  font-size: 0.875rem;
}
.notice-block { display: block; font-weight: 550; }
.notice-error { border-color: var(--red-border); background: var(--red-soft); color: var(--red); }
.notice-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notice-list:empty { display: none; }

/* -------------------------------------------------------------- summary */

main { padding-top: 16px; }
.summary { display: grid; gap: 10px; }
.summary .callout { margin: 0; }
.pills { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  min-height: 28px;
}
.pill:first-child { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.pill.skeleton, .pill.skeleton:first-child { min-width: 132px; background: var(--skeleton); border-color: transparent; }
.pills[aria-disabled="true"] { opacity: 0.6; }
.details > summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; font-weight: 550; width: max-content; }
.details[open] > summary { margin-bottom: 10px; }
.details .callout { margin: 0 0 10px; }
.details-kv { row-gap: 8px; }
.prices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 6px;
}
.prices li {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8125rem;
}
.region { font-weight: 700; color: var(--muted); margin-right: 4px; }
.key { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; max-width: 100%; }

/* The always-rendered status region (D4): never display:none, so screen
   readers have it in the tree before any message arrives. */
.status-bar { display: grid; margin: 10px 0 0; }
.status-text { margin: 0; font-size: 0.875rem; color: var(--muted); }
.status-text:not(:empty) { padding: 2px 2px 0; }
.status-alert { color: var(--red); font-weight: 600; }

.program-notice { padding: 28px 20px; text-align: center; display: grid; justify-items: center; gap: 6px; }
.notice-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.program-notice p { margin: 0; }
.program-notice .btn { margin-top: 10px; }

/* ------------------------------------------------------------ badges */

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--muted);
}
.badge-active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.badge-pending { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.badge-revoked { color: var(--muted); background: var(--neutral-soft); border-color: var(--border-strong); }
.badge-lapsed { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
.badge-kind { font-weight: 550; }
.badge-log-confirmed { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.badge-log-failed, .badge-log-expired { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
.badge-log-signing, .badge-log-sent { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }

/* ---------------------------------------------------------------- tabs */

.tabbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--border);
}
.tabbar #refresh { margin: 0 0 6px auto; flex: none; }
/* Tabs wrap onto a second row on narrow screens, so every tab (and the
   "Publisher · N pending" count) stays in view instead of scrolling off. */
.tabs {
  display: flex;
  flex: 1 1 0;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
}
[role="tab"] {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 12px;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  white-space: nowrap;
}
[role="tab"]:hover { color: var(--text); }
[role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
[role="tab"][aria-disabled="true"] { cursor: not-allowed; opacity: 0.5; }
.panel { min-width: 0; }
.panel-help { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; max-width: 72ch; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table.data { width: 100%; min-width: 940px; border-collapse: collapse; font-size: 0.875rem; }
.table-caption { caption-side: top; text-align: left; padding: 6px 10px; font-size: 0.75rem; color: var(--muted); }
.table-caption:empty { padding: 0; }
table.data th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 10px;
  white-space: nowrap;
  border-block: 1px solid var(--border);
}
/* The ten-column subscriptions table fits a desktop width only with its headers wrapped. */
@media (min-width: 1000px) {
  #subs-wrap th { white-space: normal; vertical-align: bottom; }
}
table.data th.r { text-align: right; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data td.r { white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.detail td { background: var(--surface-2); padding: 12px 16px; }
/* The table scrolls sideways on a narrow screen; keep the details in view. */
table.data tr.detail .kv { position: sticky; left: 0; max-width: calc(100vw - 2 * var(--gutter) - 34px); }
table.data tr.unreadable td { background: var(--amber-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 150px; }
.action-reason { color: var(--muted); font-size: 0.75rem; margin: 4px 0 0; max-width: 280px; }
.plain { list-style: none; padding: 0; margin: 0; }
.cell-gateways { min-width: 170px; }
/* Breaks only at the <wbr> after each colon, so the subscriptions table fits a desktop width. */
td.cell-group { overflow-wrap: normal; }
.skeleton-bar {
  display: block;
  height: 14px;
  width: 70%;
  margin: 4px 0;
  border-radius: 4px;
  background: var(--skeleton);
}
.skeleton-row:nth-child(2) .skeleton-bar { width: 55%; }
.skeleton-row:nth-child(3) .skeleton-bar { width: 62%; }
.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: 12px 0 0;
}
.empty p { margin: 0; }

/* --------------------------------------------------------- forms, preview */

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 860px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
.preview { position: sticky; top: 12px; }
@media (max-width: 860px) {
  .preview { position: static; }
}
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 0.875rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
}
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 0.875rem; }
.checks li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: baseline; }
.mark {
  display: inline-block;
  min-width: 40px;
  text-align: center;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid;
}
.mark-pass { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.mark-warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.mark-fail { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
.mark-pending { color: var(--muted); background: var(--neutral-soft); border-color: var(--border-strong); }
.runway { font-size: 0.875rem; margin: 0; }
#reserve-zero-deposit { margin: 8px 0 0; }
.gateway-status { font-size: 0.8125rem; }
.gateway-status .checks { margin-top: 6px; }
.warnings { list-style: none; padding: 0; margin: 0; }
.warnings .callout { margin: 8px 0 0; }

/* ------------------------------------------------------------ publisher */

#panel-publisher > * + * { margin-top: 16px; }
#panel-publisher > .panel-help + * { margin-top: 0; }
#config-hint { margin: 0 0 12px; }
.approvals { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.approval {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.approval-main { min-width: 0; flex: 1 1 360px; }
.approval-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; margin: 0 0 6px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 0; font-size: 0.8125rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.approval-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 320px; }
.approval-actions .action-reason { flex-basis: 100%; margin: 0; }
.skeleton-item { padding: 14px 12px; }
.skeleton-item .skeleton-bar { width: 60%; }

/* ------------------------------------------------------------- activity */

.activity { margin-top: 24px; margin-bottom: 48px; }
.activity summary { cursor: pointer; }
.activity summary h2 { display: inline; margin: 0; }
.log { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
}
.log-time { color: var(--muted); }
.log-title { font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.log-link, .log-error, .log-note { grid-column: 2 / -1; margin: 0; }
.log-error { color: var(--red); }

/* ---------------------------------------------------------------- modals */

dialog.modal {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgb(0 0 0 / 25%);
  overflow: auto;
}
dialog.modal-wide { width: min(720px, calc(100vw - 2 * var(--gutter))); }
dialog::backdrop { background: var(--backdrop); }
.modal-body { padding: 16px 18px; }
.confirm-title { margin-bottom: 2px; }
.term-line { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin: 0 0 12px; }
.wallet-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.wallet-option { width: 100%; justify-content: flex-start; padding: 10px 12px; min-height: 48px; font-size: 0.9375rem; }
.wallet-option img { width: 28px; height: 28px; border-radius: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; list-style: none; }
.accounts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.accounts li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.875rem;
}
.acct-label { font-weight: 600; min-width: 0; }
.acct-flags { font-size: 0.75rem; text-align: right; }
.acct-addr { grid-column: 1 / -1; min-width: 0; }
.sim { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 0.875rem; }
.sim[data-state="ok"] { border-color: var(--green-border); background: var(--green-soft); }
.sim[data-state="failed"] { border-color: var(--red-border); background: var(--red-soft); }
.sim p:last-child { margin-bottom: 0; }
.logs summary { cursor: pointer; font-size: 0.8125rem; color: var(--muted); margin-top: 6px; }
.logs pre {
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The transaction's stages (D4): the state is always in the text. */
.stages { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; gap: 6px; counter-reset: stage; }
.stage {
  counter-increment: stage;
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.stage::before { content: counter(stage) "."; font-weight: 700; margin-right: 4px; font-variant-numeric: tabular-nums; }
.stage-label { font-weight: 600; }
.stage-current { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.stage-done { color: var(--text); }
.stage-done .stage-state { color: var(--green); }
.stage-failed, .stage-expired { color: var(--red); border-color: var(--red-border); background: var(--red-soft); }
.signature-line { font-size: 0.875rem; margin: 0 0 10px; }
.result { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.result[data-state="done"] { border-color: var(--green-border); background: var(--green-soft); }
.result[data-state="failed"], .result[data-state="expired"] { border-color: var(--red-border); background: var(--red-soft); }
.result-title { font-size: 1rem; margin: 0 0 4px; }
/* Focused only to move the screen reader there; it is not a control. */
.result-title:focus { outline: none; }
.result p { margin: 0; }

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .card { padding: 14px; }
  .topbar-controls { width: 100%; }
  .cluster { flex: 1 1 100%; }
  .cluster .select { flex: 1 1 140px; }
  .actions .btn { flex: 1 1 auto; }
  .approval-actions { max-width: none; }
}
