/* Self-hosted Geist variable fonts */
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #08080f;
  --bg-surface: #0d0d1a;
  --bg-elevated: #12121f;
  --bg-input: #0a0a16;

  --text: #d4d4d8;
  --text-muted: #71717a;
  --text-dim: #52525b;

  --accent: #f7931a;
  --accent-hover: #e8850f;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #d29922;
  --info: #8ecae6;

  --border: #1e1e2e;
  --border-subtle: #161622;

  /* Tinted fills, derived from the semantic colors. Consolidated here so both
     themes stay consistent and inline rgba() literals don't drift. */
  --accent-soft: rgba(247, 147, 26, 0.1);
  --accent-ring: rgba(247, 147, 26, 0.3);
  --success-soft: rgba(34, 197, 94, 0.1);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --warning-soft: rgba(210, 153, 34, 0.1);

  /* Self-hosted Geist Mono leads so the bundled font actually renders; the
     system fallbacks only kick in if the woff2 fails to load. */
  --font-family: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;

  /* Type scale */
  --fs-display: 2.5rem;
  --fs-eyebrow: 0.6875rem;
  --tracking-eyebrow: 0.14em;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 0.5rem;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

html.light {
  --bg: #f5f5f0;
  --bg-surface: #ffffff;
  --bg-elevated: #fafaf8;
  --bg-input: #ffffff;

  --text: #1a1a1a;
  --text-muted: #6b6560;
  --text-dim: #9a9490;

  --accent: #e07800;
  --accent-hover: #c86a00;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #b45309;
  --info: #2563eb;

  --border: #e0ddd8;
  --border-subtle: #ebe8e3;

  --accent-soft: rgba(224, 120, 0, 0.09);
  --accent-ring: rgba(224, 120, 0, 0.25);
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger-soft: rgba(220, 38, 38, 0.08);
  --warning-soft: rgba(180, 83, 9, 0.1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle film-grain texture overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

::selection {
  background: rgba(247, 147, 26, 0.3);
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

body {
  margin: 0;
  padding: 24px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1 {
  margin: 0 0 6px 0;
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--accent);
}

#pageSubtitle {
  margin: 0 0 40px 0;
  color: var(--text-muted);
  font-size: 1.0625rem;
  font-weight: 450;
  letter-spacing: 0.01em;
}

/* Mono uppercase eyebrow — structural signposting on each stage of the flow.
   Encodes the real sequence (load → prove → done), not decoration. */
.stage-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-dim);
}

.stage-eyebrow .stage-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.625rem;
  flex-shrink: 0;
}

.stage-eyebrow .stage-title {
  color: var(--text-muted);
}

.stage-eyebrow .stage-rule {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Layout */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Sections */
#heading {
  text-align: center;
  margin-bottom: 8px;
}

#multisigSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

#xpubRadioContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Before extraction the container is empty markup — don't render a hollow card. */
#xpubRadioContainer:empty {
  display: none;
}

#elementsBelowXpub {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Form Elements */
textarea,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  resize: vertical;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.15);
}

textarea::placeholder,
input::placeholder {
  color: var(--text-dim);
}

#multisigConfigInput {
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.98);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.3);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Upload Button */
#uploadContainer {
  width: 100%;
  margin-bottom: 16px;
}

#fileInput {
  display: none;
}

#uploadButton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

#uploadButton:hover {
  background: var(--bg-input);
  border-color: var(--accent);
  color: var(--accent);
}

/* Drag-and-drop states */
#uploadContainer.dragover #uploadButton {
  border-color: var(--accent);
  background: rgba(247, 147, 26, 0.05);
  color: var(--accent);
}

/* Descriptor action buttons */
.descriptor-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
}

.descriptor-actions button {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.descriptor-actions button:hover {
  background: var(--bg-input);
  color: var(--accent);
  border-color: var(--accent);
}

/* Extract Button */
#extractXpubsButton {
  width: 100%;
  margin-top: 16px;
  padding: 12px 20px;
}

/* ── Keymaster ledger ─────────────────────────────────────────────
   The quorum tracker: an M-of-N readout plus a row per keymaster that
   gets sealed (key → stamped check) once it proves control. This is the
   app's payoff, so it carries the most visual weight. */
input[type="radio"] {
  display: none;
}

#xpubRadioContainer br {
  display: none;
}

/* Quorum readout header */
#verificationProgress {
  width: 100%;
  margin-bottom: 6px;
}

.quorum-readout {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 2px 2px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.quorum-count {
  display: flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.quorum-verified {
  font-size: 2.75rem;
  color: var(--accent);
  transition: color var(--transition-normal);
}

.quorum-sep {
  font-size: 1.625rem;
  color: var(--text-dim);
  margin: 0 3px;
}

.quorum-total {
  font-size: 1.625rem;
  color: var(--text-muted);
}

#verificationProgress.quorum-met .quorum-verified {
  color: var(--success);
}

.quorum-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.quorum-threshold {
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.quorum-threshold.met {
  color: var(--success);
}

.quorum-threshold i {
  margin-right: 5px;
}

/* Keymaster rows */
#xpubRadioContainer label {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  margin: 8px 0 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition-fast),
    background var(--transition-fast), transform var(--transition-fast);
}

#xpubRadioContainer label:hover {
  border-color: var(--accent);
  background: var(--bg-input);
}

#xpubRadioContainer label:active {
  transform: scale(0.995);
}

/* Seal — a key that becomes a stamped check once proven */
.keymaster-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 0.8125rem;
  transition: all var(--transition-fast);
}

.keymaster-seal .seal-check {
  display: none;
}

.keymaster-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.keymaster-fp {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
}

.keymaster-xpub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keymaster-state {
  flex-shrink: 0;
  font-weight: 500;
}

.keymaster-state .state-pending {
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.keymaster-state .state-pending i {
  margin-left: 6px;
  font-size: 0.5625rem;
}

.keymaster-state .state-proven {
  display: none;
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--success);
}

#xpubRadioContainer label:hover .keymaster-seal {
  border-color: var(--accent);
  color: var(--accent);
}

#xpubRadioContainer label:hover .keymaster-state .state-pending {
  color: var(--accent);
}

/* Selected keymaster (only while still unproven — proven always wins) */
#xpubRadioContainer input[type="radio"]:checked + label:not(.cosigner-verified) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#xpubRadioContainer input[type="radio"]:checked + label:not(.cosigner-verified) .keymaster-seal {
  border-color: var(--accent);
  color: var(--accent);
}

#xpubRadioContainer input[type="radio"]:checked + label:not(.cosigner-verified) .keymaster-fp {
  color: var(--accent);
}

#xpubRadioContainer input[type="radio"]:checked + label:not(.cosigner-verified) .state-pending {
  color: var(--accent);
}

/* Proven keymaster — sealed. Wins over the selected state. */
#xpubRadioContainer label.cosigner-verified {
  border-color: var(--success);
  background: var(--success-soft);
}

#xpubRadioContainer label.cosigner-verified .keymaster-seal {
  border-color: var(--success);
  background: var(--success);
  color: var(--bg);
}

#xpubRadioContainer label.cosigner-verified .seal-key {
  display: none;
}

#xpubRadioContainer label.cosigner-verified .seal-check {
  display: inline-block;
}

#xpubRadioContainer label.cosigner-verified .keymaster-fp {
  color: var(--text);
}

#xpubRadioContainer label.cosigner-verified .state-pending {
  display: none;
}

#xpubRadioContainer label.cosigner-verified .state-proven {
  display: inline;
}

/* ── Sub-step headers inside the challenge card ──────────────────── */
.substep-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 2px 0 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.substep-divider {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.substep-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.challenge-target {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
}

.challenge-target:empty::before {
  content: "a keymaster";
  color: var(--text-dim);
}

/* Derivation Controls */
#derivationControls {
  display: flex;
  gap: 16px;
  width: 100%;
  margin-bottom: 20px;
}

#addressTypeContainer,
#relativePathContainer {
  flex: 1;
}

#addressTypeContainer label,
#relativePathContainer label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

/* Taproot Warning */
#taprootWarning {
  display: none;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
}

#taprootWarning i {
  margin-top: 2px;
  flex-shrink: 0;
}

#taprootWarning.visible {
  display: flex;
}

select,
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

select:hover,
input[type="number"]:hover {
  border-color: var(--text-dim);
}

select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.15);
}

select option {
  background: var(--bg-surface);
  color: var(--text);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Derivation Path Result */
#derivationPathResult {
  width: 100%;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
}

#derivationPathResult.error {
  border-left-color: var(--danger);
}

#derivationPathResult .path-info {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

#derivationPathResult .path-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

#derivationPathResult strong {
  display: block;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--warning);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

#derivationPathResult strong.address {
  color: var(--success);
}

#derivationPathResult .instructions {
  margin: 12px 0 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  color: var(--text-dim);
}

#derivationPathResult .error-message {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
}

#derivationPathResult .error-message i {
  font-size: 1rem;
}

/* Message & Signature Inputs */
#messageInputContainer,
#signatureInputContainer {
  width: 100%;
  margin-bottom: 16px;
}

#signatureFormatContainer {
  margin-bottom: 12px;
}

#signatureFormatContainer label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

#signatureFormatSelect {
  margin-top: 6px;
}

#buttonHolder {
  display: flex;
  align-items: center;
  gap: 8px;
}

#messageInput,
#signatureInput {
  flex: 1;
}

#copyButton,
#exportButton,
#seedsignerQrButton {
  flex-shrink: 0;
  padding: 10px 12px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

#copyButton:hover,
#exportButton:hover,
#seedsignerQrButton:hover {
  background: var(--bg-input);
  color: var(--accent);
  border-color: var(--accent);
}

#copyNotification {
  display: none;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border-radius: var(--radius-sm);
  animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Signature action buttons */
.signature-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.signature-actions button {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.signature-actions button:hover {
  background: var(--bg-input);
  color: var(--accent);
  border-color: var(--accent);
}

/* Signature format detection display */
#signatureFormatDetected {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--info);
}

#evaluateSignatureButton {
  width: 100%;
  margin-top: 8px;
  padding: 12px 20px;
  background: var(--accent);
}

#evaluateSignatureButton:hover {
  background: var(--accent-hover);
}

#evaluateSignatureButton:focus {
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.3);
}

/* Validation Result */
#validationResult {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding: 14px 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: left;
  border-radius: var(--radius-md);
}

#validationResult:not(:empty) {
  display: flex;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
}

#validationResult.success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success);
}

#validationResult i {
  font-size: 1.1875rem;
  flex-shrink: 0;
}

#validationResult strong {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ── Receipt payoff & new-descriptor reset ──────────────────────── */
#importDescriptorContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
}

/* Shown by JS once at least one keymaster is proven — the reward for the flow */
#receiptReady {
  display: none;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 22px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.receipt-hint {
  margin: 0 0 16px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}

#downloadReceiptButton {
  width: 100%;
  padding: 13px 20px;
  font-weight: 600;
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success);
}

#downloadReceiptButton:hover {
  background: var(--success);
  color: var(--bg);
}

#downloadReceiptButton:focus {
  box-shadow: 0 0 0 3px var(--success-soft);
}

#importDescriptorButton {
  display: none;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

#importDescriptorButton:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--text-dim);
}

/* Intro Details */
#introDetails {
  max-width: 560px;
  width: 100%;
  margin-bottom: 24px;
  background: var(--bg-surface);
  border-color: var(--accent);
}

#introDetails summary {
  color: var(--accent);
}

/* Help Details */
details.help-details {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

details.help-details summary {
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--transition-fast);
  list-style: none;
}

details.help-details summary::-webkit-details-marker {
  display: none;
}

details.help-details summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 8px;
  font-size: 0.625rem;
  transition: transform var(--transition-fast);
}

details.help-details[open] summary::before {
  transform: rotate(90deg);
}

details.help-details summary:hover {
  color: var(--accent);
}

details.help-details .help-content {
  padding: 0 14px 14px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

details.help-details .help-content h4 {
  margin: 12px 0 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

details.help-details .help-content p {
  margin: 4px 0;
}

details.help-details .help-content code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 5px;
  background: var(--bg-input);
  border-radius: 3px;
  color: var(--accent);
}

/* QR Scanner */
#qrReaderContainer {
  display: none;
  width: 100%;
  max-width: 560px;
  margin-top: 16px;
}

#qrReaderContainer.visible {
  display: block;
}

#qr-reader {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
}

#qr-reader video {
  border-radius: var(--radius-md);
}

#qrScannerClose {
  margin-top: 8px;
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

#qrScannerClose:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Footer */
footer {
  margin-top: 48px;
  padding: 24px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  max-width: 560px;
  width: 100%;
}

footer p,
footer .footer-donation {
  margin: 8px 0;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* SeedSigner Info */
#seedsignerInfoToggle {
  flex-shrink: 0;
  padding: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  transition: color var(--transition-fast);
}

#seedsignerInfoToggle:hover {
  color: var(--accent);
}

#seedsignerInfo {
  display: none;
  margin: 8px 0 0 0;
  font-size: 0.6875rem;
  color: var(--text-dim);
  line-height: 1.5;
}

#seedsignerInfo.visible {
  display: block;
}

#seedsignerInfo a {
  color: var(--accent);
  text-decoration: none;
}

#seedsignerInfo a:hover {
  text-decoration: underline;
}

/* QR Overlay */
#qrOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#qrOverlay.visible {
  display: flex;
}

#qrModal {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 360px;
  width: 100%;
}

#qrModalClose {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

#qrModalClose:hover {
  background: var(--bg-input);
  color: var(--danger);
  border-color: var(--danger);
}

#qrModal .stage-eyebrow {
  justify-content: center;
  margin-bottom: 18px;
}

#qrModal .stage-eyebrow .stage-rule {
  display: none;
}

#qrSvgContainer {
  border-radius: var(--radius-md);
  overflow: hidden;
}

#qrSvgContainer svg {
  display: block;
  width: 100%;
  height: auto;
}

#qrLabel {
  margin: 16px 0 0 0;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  word-break: break-all;
  line-height: 1.5;
  text-align: left;
}

#qrLabel:empty {
  display: none;
}

/* Donation QR Code */
#donationQr {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
  z-index: 1000;
}

#donationQr svg {
  width: 100%;
  height: 100%;
}

#donationLink:hover ~ #donationQr {
  opacity: 1;
  visibility: visible;
}

/* Signature file input */
#signatureFileInput {
  display: none;
}

/* Responsive */
@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  h1 {
    font-size: 1.5rem;
  }

  #multisigSection,
  #xpubRadioContainer,
  #elementsBelowXpub {
    padding: 16px;
  }

  #derivationControls {
    flex-direction: column;
    gap: 12px;
  }

  #buttonHolder {
    flex-wrap: wrap;
  }

  #messageInput,
  #signatureInput {
    width: 100%;
    margin-bottom: 8px;
  }

  .descriptor-actions,
  .signature-actions {
    flex-direction: column;
  }
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9998;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Show the sun in dark mode (click to go light), the moon in light mode. */
.theme-toggle .theme-icon-moon {
  display: none;
}

html.light .theme-toggle .theme-icon-sun {
  display: none;
}

html.light .theme-toggle .theme-icon-moon {
  display: block;
}
