/* =============================================================
   Build pages — form + preview layout.
   Layered on top of styles.css (live). Reuses --app-radius,
   --app-shadow, --md-sys-color-surface-container-* tokens.
   ============================================================= */

.mono { font-family: "Roboto Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* Build page header stays centered (matches dashboard). */

/* Top nav (Inspect / Build) — sits between brand and theme button */
.topbar__nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.topbar__nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--app-radius);
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.topbar__nav-link:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}
.topbar__nav-link[aria-current="page"] {
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container);
}
.topbar__nav-link[aria-current="page"]::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
}

@media (max-width: 600px) {
  .topbar__nav {
    margin-left: 0;
    order: 3;
    flex: 1 1 100%;
  }
  .topbar__theme-btn {
    margin-left: auto;
  }
}

/* ---------- two-column layout ---------- */
.build-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) { .build-layout { grid-template-columns: 1fr; } }

.form-column { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preview-column { position: sticky; top: 16px; min-width: 0; }

/* ---------- form section (mirrors scope-card visual language) ---------- */
.form-section {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
:root[data-theme="dark"] .form-section { box-shadow: var(--app-shadow-dark); }
.form-section__head { display: flex; align-items: baseline; gap: 10px; }
.form-section__num {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--md-sys-color-primary);
  padding: 2px 6px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 4px;
  background: var(--md-sys-color-primary-container);
}
.form-section__title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.005em; color: var(--md-sys-color-on-surface); font-family: "Roboto Flex", system-ui, sans-serif; }
.form-section__hint { margin: -6px 0 0; color: var(--md-sys-color-on-surface-variant); font-size: 13px; line-height: 1.5; }
.form-section__body { display: flex; flex-direction: column; gap: 12px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--md-sys-color-on-surface);
}
.field__input {
  width: 100%;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid transparent;
  border-radius: var(--app-radius);
  padding: 12px 14px;
  font: 400 14px/1.4 "Roboto Flex", system-ui, sans-serif;
  color: var(--md-sys-color-on-surface);
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  appearance: none; outline: none;
}
.field__input:hover { border-color: var(--md-sys-color-outline-variant); }
.field__input:focus {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-low);
  box-shadow: 0 0 0 3px rgb(0 106 112 / 0.14);
}
:root[data-theme="dark"] .field__input:focus { box-shadow: 0 0 0 3px rgb(120 220 226 / 0.18); }
.field__input--mono { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.field__textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.field__num { position: relative; display: flex; align-items: center; }
.field__num .field__input { padding-right: 56px; }
.field__suffix {
  position: absolute; right: 14px;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}
.field__hint { color: var(--md-sys-color-on-surface-variant); font-size: 12px; line-height: 1.45; }

/* Inline form validation — outline the offending input
   in the error color and surface a one-line caption
   underneath.  Mirrors the typed-failure highlight that
   server-side BuildFailure / WizardFailure variants ask
   the frontend to apply on the matching `[data-field]`. */
.field__input[data-error="true"],
.field__input[data-error="true"]:focus {
  border-color: var(--md-sys-color-error);
  box-shadow: 0 0 0 3px rgb(186 26 26 / 0.18);
}
.field__error {
  margin-top: 6px;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-error);
  line-height: 1.45;
}
input[type="number"].field__input::-webkit-outer-spin-button,
input[type="number"].field__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].field__input { -moz-appearance: textfield; }

/* ---------- segmented ---------- */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  padding: 3px;
  gap: 2px;
  width: max-content;
  max-width: 100%;
}
.segmented__option {
  min-width: 0;
  background: transparent; border: 0;
  padding: 7px 12px;
  border-radius: calc(var(--app-radius) - 2px);
  font: 500 12px/1.2 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.04em;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  text-align: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.segmented__option:hover { color: var(--md-sys-color-on-surface); }
.segmented__option[data-active="true"] {
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

/* ---------- scope picker (uses per-scope accents matching dashboard nth-child) ---------- */
.scope-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}
.scope-pill {
  --scope-accent: var(--md-sys-color-primary);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid transparent;
  border-radius: var(--app-radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  position: relative;
  overflow: hidden;
}
.scope-pill::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--scope-accent);
  opacity: 0.35;
  transition: opacity 0.12s ease;
}
.scope-pill[data-active="true"]::before { opacity: 1; }
.scope-pill[data-scope="core_development"]    { --scope-accent: #006a70; }
.scope-pill[data-scope="ops_and_use_cases"]   { --scope-accent: #8f5f00; }
.scope-pill[data-scope="network_compliance"]  { --scope-accent: #5865c9; }
.scope-pill[data-scope="middleware"]          { --scope-accent: #7d5260; }
.scope-pill[data-scope="contingency"]         { --scope-accent: #486a20; }
:root[data-theme="dark"] .scope-pill[data-scope="core_development"]    { --scope-accent: #78dce2; }
:root[data-theme="dark"] .scope-pill[data-scope="ops_and_use_cases"]   { --scope-accent: #e0c15f; }
:root[data-theme="dark"] .scope-pill[data-scope="network_compliance"]  { --scope-accent: #c3c8ff; }
:root[data-theme="dark"] .scope-pill[data-scope="middleware"]          { --scope-accent: #efb8c8; }
:root[data-theme="dark"] .scope-pill[data-scope="contingency"]         { --scope-accent: #aad47b; }
.scope-pill:hover { border-color: var(--md-sys-color-outline-variant); }
.scope-pill[data-active="true"] {
  background: var(--md-sys-color-surface-container-low);
  border-color: var(--scope-accent);
  box-shadow: inset 0 0 0 1px var(--scope-accent);
}
.scope-pill__name { font: 600 13px/1.2 "Roboto Flex", system-ui, sans-serif; color: var(--md-sys-color-on-surface); }
.scope-pill__meta { display: flex; width: 100%; justify-content: space-between; align-items: baseline; gap: 8px; }
.scope-pill__slug { font: 500 10px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.04em; color: var(--md-sys-color-on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-pill__ada { font: 700 11px/1 "Roboto Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface); white-space: nowrap; }
/* #338 SB3 — tighten the scope picker on phones so the five
   pills (Disburse includes Contingency) wrap to a 2-up grid
   instead of overflowing a narrow viewport. */
@media (max-width: 600px) {
  .segmented { width: 100%; }
  .segmented__option { flex: 1 1 0; }
  .scope-picker { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 4px; }
  .scope-pill { padding: 10px; }
  .scope-pill__name { font-size: 12px; }
}

/* ---------- signers picker ---------- */
.signers-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.signer-chip {
  min-width: 0;
  max-width: 100%;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid transparent;
  border-radius: var(--app-radius);
  padding: 6px 12px;
  font: 500 12px/1.25 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
  white-space: normal;
  transition: all 0.12s ease;
}
.signer-chip:hover { border-color: var(--md-sys-color-outline-variant); color: var(--md-sys-color-on-surface); }
.signer-chip[data-active="true"] { background: var(--md-sys-color-primary-container); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary-container); }
.signer-chip__check { color: var(--md-sys-color-primary); font-weight: 700; }
:root[data-theme="dark"] .signer-chip__check { color: var(--md-sys-color-on-primary-container); }
/* #338 SB5 — read-only required-signer chip for the contingency
   case: looks active (it will sign) but is not interactive. */
.signer-chip--required { cursor: default; }
.signer-chip--required:hover { border-color: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary-container); }
.signer-chip__req { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.signers-picker__hint { flex-basis: 100%; font-size: 12px; color: var(--md-sys-color-on-surface-variant); line-height: 1.5; margin-top: 4px; }

/* ---------- repeated form rows ----------
   Shared card layout for removable row sets on /operate:
   rationale references and contingency destinations.  The
   controls inside remain the shared `.field` /
   `.field__input` / `.btn` primitives. */
.repeated-row-list,
.destination-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.repeated-row-list__actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 2px;
}
.repeated-row-card,
.destination-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container);
}
.repeated-row-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.repeated-row-card__title {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}
.repeated-row-card__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.reference-card__fields {
  grid-template-columns:
    minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr);
}
.destination-card__fields {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.repeated-row-card__remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  white-space: nowrap;
}
.repeated-row-card__remove md-icon {
  font-size: 18px;
  line-height: 1;
}
.audit-output-card {
  gap: 8px;
  padding: 10px;
}
.audit-output-card__badges {
  min-width: 0;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.audit-output-card__summary {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(9rem, 0.6fr);
  gap: 8px 12px;
  align-items: center;
}
.audit-output-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.audit-output-field__label,
.audit-output-chip__label {
  flex: 0 0 auto;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.audit-output-field__value {
  min-width: 0;
  color: var(--md-sys-color-on-surface);
}
.audit-output-card .audit-copy {
  gap: 4px;
}
.audit-output-card .audit-copy .copy-icon-btn {
  width: 26px;
  height: 26px;
}
.audit-output-card .audit-copy .copy-icon-btn md-icon {
  font-size: 17px;
}
.audit-output-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.audit-output-chip {
  min-width: 0;
  max-width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-size: 12px;
  line-height: 1.2;
}
.audit-output-chip code {
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--md-sys-color-on-surface);
}
@media (max-width: 600px) {
  .repeated-row-card__head { align-items: flex-start; }
  .repeated-row-card__fields,
  .reference-card__fields,
  .destination-card__fields { grid-template-columns: 1fr; }
  .repeated-row-card__remove { align-self: flex-start; }
  .repeated-row-list__actions .btn { width: 100%; }
  .audit-output-card__summary { grid-template-columns: 1fr; }
  .audit-output-field {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}
.signers-picker__hint .mono { font-size: 11px; }

/* ---------- buttons + actions ---------- */

/* #289 slice C — WCAG 2.1 SC 2.5.5: every interactive
   target on /operate must be ≥ 44×44 px.  Inputs already
   exceed this via padding; buttons / chips / pills /
   preview-tabs / per-block-copy buttons needed a floor.
   `box-sizing: border-box` so the min-* dimensions include
   borders + padding rather than adding to them.  Topbar +
   footer chrome (slice A's territory + slice H's pending
   palette pass) intentionally NOT covered by this rule. */
.btn,
.segmented__option,
.scope-pill,
.signer-chip,
.preview-tab,
.v-copy,
.field__input {
  min-height: 44px;
  min-width: 44px;
  box-sizing: border-box;
}

/* #289 slice G — /books empty-state disclosure.
   When every card in a group is empty, the whole group
   collapses behind a single-line button rather than
   stacking N identical "(no entries yet)" cards.
   `.books-group--empty` reuses the same headline scale +
   margins as the normal `.books-group` heading so the
   visual rhythm of the page stays steady when groups
   flip between empty and non-empty. */
.group-disclosure {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #44474e);
  padding-bottom: .4rem;
  margin: 2rem 0 .75rem 0;
  font: inherit;
  letter-spacing: .01em;
  cursor: pointer;
  opacity: .85;
  transition: opacity 0.12s ease;
}
.group-disclosure:hover,
.group-disclosure:focus-visible {
  opacity: 1;
}
.books-group--empty {
  font-size: 1rem;
  font-weight: 600;
}
/* #338 SB4 — post-import success summary line. */
.books-import-summary {
  color: var(--md-sys-color-primary);
  font-weight: 600;
  margin: 0;
}

/* #289 slice G — fade the per-card Copy / Export buttons
   when the card has no entries.  Operators see the
   affordance is wired but visually de-emphasised; the
   `pointer-events: none` rule blocks accidental clicks
   that would produce an empty `[]` bundle / clipboard
   blob.  Add new / Clear all stay active where applicable
   (different selectors). */
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* #289 slice D — sectioned progress indicator.  A
   horizontal row of state chips above the form, plus a
   right-edge Reset action.  The row wraps on
   narrow viewports (mirrors slice A's topbar flex-wrap
   pattern) and scrolls horizontally as a last resort. */
.operate-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #44474e);
}
.operate-progress__chip {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font: 500 12px/1.2 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.04em;
  background: var(--md-sys-color-surface-container, #22252b);
  color: var(--md-sys-color-on-surface-variant, #c4c7cb);
  border: 1px solid var(--md-sys-color-outline-variant, #44474e);
  border-radius: var(--app-radius);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.operate-progress__chip:hover {
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}
.operate-progress__chip[data-state="complete"] {
  background: var(--md-sys-color-primary-container, #b8d4d6);
  color: var(--md-sys-color-on-primary-container, #002022);
  border-color: var(--md-sys-color-primary, #006a70);
}
.operate-progress__chip[data-state="invalid"] {
  background: var(--md-sys-color-error-container, #ffdad6);
  color: var(--md-sys-color-on-error-container, #410002);
  border-color: var(--md-sys-color-error, #ba1a1a);
}
.operate-progress__chip[data-state="pending"] {
  /* Default surface — the operator can see where they
     haven't been yet without it visually shouting. */
}
.operate-progress__glyph {
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
.operate-progress__reset {
  margin-left: 0;
}
.btn {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--app-radius);
  padding: 10px 18px;
  font: 650 13px/1.2 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: all 0.12s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--md-sys-color-on-surface-variant); border-color: var(--md-sys-color-outline-variant); }
.btn--ghost:hover:not(:disabled) { color: var(--md-sys-color-on-surface); border-color: var(--md-sys-color-outline); }
.btn--danger {
  color: var(--md-sys-color-error);
  border-color: var(--md-sys-color-error);
  background: transparent;
}
.btn--danger:hover:not(:disabled) {
  color: var(--md-sys-color-on-error);
  background: var(--md-sys-color-error);
}
.btn--primary,
.btn--filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); border-color: var(--md-sys-color-primary); }
.btn--primary:hover:not(:disabled),
.btn--filled:hover:not(:disabled) { filter: brightness(1.08); }
.operate-save-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin: 12px;
  padding: 10px 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container);
}
.operate-save-pending .field__hint {
  min-width: 0;
  flex: 1 1 16rem;
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .operate-progress__chip { flex: 1 1 calc(50% - 8px); }
  .operate-progress__reset { flex: 1 1 100%; }
  .operate-save-pending { margin: 10px; }
  .operate-save-pending .btn { width: 100%; }
}

/* ---------- preview card ---------- */
.preview-card {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
:root[data-theme="dark"] .preview-card { box-shadow: var(--app-shadow-dark); }
.preview-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
}
.preview-tab-group {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.preview-tab-group + .preview-tab-group {
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--md-sys-color-outline-variant);
}
.preview-tab-group__label {
  color: var(--md-sys-color-on-surface-variant);
  font: 700 10px/1 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 4px;
  opacity: 0.75;
}
.preview-tab {
  min-width: 0;
  background: transparent; border: 0;
  padding: 6px 10px;
  border-radius: 6px;
  font: 500 11px/1.2 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all 0.12s ease;
}
.preview-tab:hover:not(:disabled) { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.preview-tab[data-active="true"] { background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); }
.preview-tab:disabled { opacity: 0.35; cursor: not-allowed; }
.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  padding: 4px 10px;
  border-radius: 6px;
  font: 500 11px/1 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.12s ease;
}
.copy-btn:hover { color: var(--md-sys-color-primary); border-color: var(--md-sys-color-primary); }
.preview-body { flex: 1; overflow: auto; padding: 16px 18px; font-size: 13px; }
@media (max-width: 600px) {
  .preview-tabs {
    align-items: stretch;
    padding: 8px 10px;
  }
  .preview-tab-group {
    flex: 1 1 100%;
    align-items: stretch;
  }
  .preview-tab-group + .preview-tab-group {
    margin-left: 0;
    padding-left: 0;
    padding-top: 6px;
    border-left: 0;
    border-top: 1px solid var(--md-sys-color-outline-variant);
  }
  .preview-tab-group__label {
    flex: 0 0 4.75rem;
    align-self: center;
    margin-right: 0;
  }
  .preview-tab {
    flex: 1 1 4.5rem;
    padding-inline: 8px;
  }
}

/* ---------- code blocks ---------- */
.cli-block, .cbor-hex {
  margin: 0;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--app-radius);
  padding: 12px 14px;
  overflow: auto;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}
.cbor-hex { font-size: 11px; word-break: break-all; white-space: pre-wrap; max-height: 240px; color: var(--md-sys-color-on-surface-variant); }
.cli-block code, .cbor-hex code { font-family: inherit; }

/* ---------- cbor view ---------- */
.cbor-view { display: flex; flex-direction: column; gap: 14px; }
.cbor-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.cbor-stat { display: flex; flex-direction: column; padding: 10px 12px; background: var(--md-sys-color-surface-container-high); border-radius: var(--app-radius); gap: 2px; }
.cbor-stat__k { font: 700 10px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); }
.cbor-stat__v { font: 650 16px/1.1 "Roboto Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface); letter-spacing: -0.01em; }
.cbor-next {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--md-sys-color-primary-container);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: var(--app-radius);
  font-size: 12px;
  overflow: auto;
}
.cbor-next__label { font: 700 10px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-sys-color-on-primary-container); white-space: nowrap; }
.cbor-next code { font: 500 12px/1.4 "Roboto Mono", ui-monospace, monospace; color: var(--md-sys-color-on-primary-container); white-space: nowrap; }

/* ---------- report view ---------- */
.report-view { display: flex; flex-direction: column; gap: 18px; }
.report-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--md-sys-color-primary-container);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: var(--app-radius);
  font: 500 12px/1 "Roboto Mono", ui-monospace, monospace;
  color: var(--md-sys-color-on-primary-container);
}
.report-status[data-ok="true"] .report-status__dot { background: #15a36e; box-shadow: 0 0 0 3px rgb(21 163 110 / 0.15); }
.report-status[data-ok="false"] .report-status__dot { background: var(--md-sys-color-error); }
.report-status__dot { width: 8px; height: 8px; border-radius: 50%; }
.report-section { display: flex; flex-direction: column; gap: 8px; }
.report-section__title { margin: 0; font: 700 11px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); padding-bottom: 6px; border-bottom: 1px dashed var(--app-rule); }
.report-section__body { display: flex; flex-direction: column; gap: 2px; }
.kv-row { display: grid; grid-template-columns: minmax(0, 200px) 1fr; gap: 12px; padding: 4px 0; font-size: 12px; border-bottom: 1px dotted var(--app-rule); }
.kv-row:last-child { border-bottom: 0; }
.kv-row__k { color: var(--md-sys-color-on-surface-variant); font-family: "Roboto Mono", ui-monospace, monospace; }
.kv-row__v { color: var(--md-sys-color-on-surface); text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- output role strip ---------- */
.role-strip { display: flex; flex-wrap: wrap; gap: 3px; padding: 6px 0; }
.role-pill { font: 700 9.5px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 6px; border-radius: 3px; }
.role-pill[data-role="swapOrder"] { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border: 1px solid var(--md-sys-color-primary); }
.role-pill[data-role="treasuryLeftover"] { background: rgb(143 95 0 / 0.10); color: #735b00; border: 1px solid rgb(143 95 0 / 0.30); }
.role-pill[data-role="walletChange"] { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }
:root[data-theme="dark"] .role-pill[data-role="treasuryLeftover"] { background: rgb(224 193 95 / 0.10); color: #e0c15f; border-color: rgb(224 193 95 / 0.30); }

/* ---------- signer row ---------- */
.signer-row { display: grid; grid-template-columns: minmax(120px, auto) minmax(140px, auto) 1fr; gap: 10px; align-items: baseline; padding: 6px 0; font-size: 12px; border-bottom: 1px dotted var(--app-rule); }
.signer-row:last-child { border-bottom: 0; }
.signer-row__source { font: 700 10px/1 "Roboto Mono", ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-sys-color-primary); }
.signer-row__scope { font-family: "Roboto Mono", ui-monospace, monospace; color: var(--md-sys-color-on-surface); }
.signer-row__hash { text-align: right; color: var(--md-sys-color-on-surface-variant); font-size: 11px; word-break: break-all; }

/* ---------- placeholder ---------- */
.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 48px 24px; color: var(--md-sys-color-on-surface-variant); text-align: center; }
.placeholder__icon { font: 700 36px/1 "Roboto Mono", ui-monospace, monospace; color: var(--md-sys-color-outline-variant); }
.placeholder__pulse { width: 28px; height: 28px; border-radius: 50%; background: var(--md-sys-color-primary); opacity: 0.4; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(0.7); opacity: 0.3; } 50% { transform: scale(1.0); opacity: 0.7; } }
.placeholder__txt { font-size: 13px; line-height: 1.5; max-width: 32ch; }
.placeholder strong { color: var(--md-sys-color-on-surface); font-weight: 650; }

/* ---------- scrollbars ---------- */
.preview-body::-webkit-scrollbar { width: 8px; height: 8px; }
.preview-body::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline-variant); border-radius: 4px; }
.preview-body::-webkit-scrollbar-track { background: transparent; }

/* JSON tree styling lives in `json-tree.css`, shipped by
   the browser-json-tree flake input.  The library ships
   light-mode defaults only; we override the `--jt-*`
   tokens against the project's sys-color tokens so the
   tree blends into both themes. */
.json-tree-wrapper {
  --jt-bg: var(--md-sys-color-surface-container-high);
  --jt-fg: var(--md-sys-color-on-surface);
  --jt-key: var(--md-sys-color-on-surface-variant);
  --jt-line: var(--md-sys-color-outline-variant);
  --jt-marker: var(--md-sys-color-outline);
  --jt-link: var(--md-sys-color-primary);
  --jt-link-hover: var(--md-sys-color-primary);
  --jt-null: var(--md-sys-color-on-surface-variant);
  --jt-bool-num: var(--md-sys-color-primary);
  --jt-str: var(--md-sys-color-on-surface);
  --jt-copy-fg: var(--md-sys-color-on-surface-variant);
  --jt-copy-border: var(--md-sys-color-outline-variant);
  --jt-copy-hover-fg: var(--md-sys-color-on-surface);
  --jt-copy-hover-bg:
    var(--md-sys-color-surface-container-highest);
  --jt-copy-ok-fg: var(--md-sys-color-on-primary);
  --jt-copy-ok-bg: var(--md-sys-color-primary);
  --jt-radius: var(--app-radius);
}

/* Issue #260 — surface a clear row boundary between each
   key/value pair inside the inspect JSON viewer.  The
   browser-json-tree library ships zero vertical separator
   on `.v-pair-leaf` and on the `<summary>` of compound
   pairs, which packs adjacent primitives ("slot: …",
   "lovelace: …") into a wall of text on dense inspect
   payloads.  Render a hairline `outline-variant` divider
   plus a tiny breathing room so each pair reads as a
   distinct row. */
.json-tree-wrapper .v-pair-leaf,
.json-tree-wrapper .v-pair-compound > summary {
  border-bottom: 1px solid var(--jt-line);
  padding-top: 3px;
  padding-bottom: 3px;
}


/* Structure-level "Copy ..." chip — used above the
   intent.json tree on /operate and per-scope on /view.
   Subdued look in both themes; sys-color tokens flip
   automatically.  Don't rely on UA `<button>` defaults
   (heavy raised chrome, system-font, jarring on dark
   especially). */
.v-copy--block {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 8px;
  padding: 4px 10px;
  font: 500 12px/1.2 "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface-variant);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}
.v-copy--block md-icon {
  font-size: 18px;
}
.v-copy--block:hover {
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-high);
}
.v-copy--block:active {
  background: var(--md-sys-color-surface-container-highest);
}
/* Brief flash when the JsonTreeBehaviour click handler
   confirms the clipboard write (adds the --ok class for
   ~700ms). */
.v-copy--block.v-copy--ok {
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary);
}
.v-copy--block.v-copy--ok::after { content: " ✓"; }

/* ---------- pending co-signing page ---------- */
.pending-header {
  align-items: flex-start;
  text-align: left;
}
.pending-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.pending-summary > * {
  max-width: 100%;
}
.pending-summary__chip,
.pending-summary__slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font: 600 12px/1 "Roboto Mono", ui-monospace, monospace;
}
.pending-summary__chip code,
.pending-summary__slot {
  color: var(--md-sys-color-primary);
}
.pending-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 16px;
  align-items: start;
}
.pending-lanes {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.pending-lane,
.pending-detail {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--app-shadow);
}
:root[data-theme="dark"] .pending-lane,
:root[data-theme="dark"] .pending-detail {
  box-shadow: var(--app-shadow-dark);
}
.pending-lane__head,
.pending-detail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.pending-lane__head h2,
.pending-detail__head h2,
.pending-detail__section h3 {
  margin: 0;
  color: var(--md-sys-color-on-surface);
}
.pending-lane__head h2,
.pending-detail__head h2 {
  font-size: 18px;
  line-height: 1.25;
}
.pending-detail__section h3 {
  font-size: 14px;
  line-height: 1.3;
}
.pending-lane__head code,
.pending-detail__head code {
  color: var(--md-sys-color-on-surface-variant);
}
.pending-entry-list,
.pending-roster,
.pending-graph__rows {
  display: grid;
  gap: 10px;
}
.pending-entry-card,
.pending-graph-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container);
}
.pending-entry-card[data-selected="true"] {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}
.pending-entry-card__button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.pending-entry-card__button:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 4px;
}
.pending-entry-card__title {
  font: 700 13px/1.3 "Roboto Mono", ui-monospace, monospace;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
}
.pending-entry-card__meta,
.pending-entry-card__history,
.pending-empty {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  line-height: 1.45;
}
.pending-entry-card__meta,
.pending-entry-card__history {
  overflow-wrap: anywhere;
}
.pending-entry-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pending-entry-card__actions .btn {
  min-height: 34px;
  padding: 7px 10px;
}
.pending-entry-card__signers {
  align-items: stretch;
}
.pending-entry-card__signers .signer-chip {
  flex: 1 1 min(100%, 22rem);
  justify-content: space-between;
}
.pending-entry-card__signers .signer-chip > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.pending-entry-card__signers .signer-chip__req {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}
.pending-banner {
  padding: 10px 12px;
  border: 1px solid var(--md-sys-color-error);
  border-radius: var(--app-radius);
  color: var(--md-sys-color-error);
  background: var(--md-sys-color-surface-container-low);
  font-size: 13px;
}
.pending-detail {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  overflow: hidden;
}
.pending-detail__section {
  display: grid;
  gap: 10px;
}
.pending-roster__row,
.pending-kv {
  display: grid;
  grid-template-columns: minmax(6rem, 0.34fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.pending-roster__row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.pending-roster__row {
  padding: 8px 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--app-radius);
  background: var(--md-sys-color-surface-container);
}
.pending-roster__row[data-active="true"] {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.pending-roster__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.pending-roster__actions .btn {
  min-height: 32px;
  padding: 6px 9px;
}
.pending-roster__row code,
.pending-kv code {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.pending-roster__row span {
  font-size: 12px;
  font-weight: 700;
}
.pending-kv span {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pending-kv code {
  justify-self: stretch;
  text-align: left;
  color: var(--md-sys-color-on-surface);
}
.pending-witness {
  padding-top: 2px;
}
.pending-witness__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, auto);
  gap: 10px;
  align-items: end;
}
.pending-witness__file {
  min-width: 0;
}
.pending-witness__status {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--app-radius);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}
.pending-witness__status--ok {
  color: var(--md-sys-color-on-primary-container);
  background: var(--md-sys-color-primary-container);
}
.pending-witness__status--error {
  color: var(--md-sys-color-error);
  border: 1px solid var(--md-sys-color-error);
  background: var(--md-sys-color-surface-container);
}
.pending-submit__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}
.pending-submit__hint {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  line-height: 1.45;
}
.pending-submit__status {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--app-radius);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.pending-submit__status code {
  color: inherit;
}
.pending-submit__status--ok {
  color: var(--md-sys-color-on-primary-container);
  background: var(--md-sys-color-primary-container);
}
.pending-submit__status--error {
  color: var(--md-sys-color-error);
  border: 1px solid var(--md-sys-color-error);
  background: var(--md-sys-color-surface-container);
}
@media (max-width: 900px) {
  .pending-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .pending-detail {
    position: static;
  }
}
@media (max-width: 480px) {
  .pending-lane,
  .pending-detail {
    padding: 12px;
  }
  .pending-roster__row,
  .pending-witness__row,
  .pending-kv {
    grid-template-columns: 1fr;
  }
  .pending-roster__actions {
    justify-content: stretch;
  }
  .pending-roster__actions .btn,
  .pending-entry-card__actions .btn {
    flex: 1 1 8rem;
  }
  .pending-detail .btn {
    width: 100%;
  }
}
