/* Satsumap v2. Tema oscuro con acento mandarina.
   La disciplina del "chrome" (barra y sidebar casi negras, texto blanco en tres niveles de opacidad,
   ítems de 44 px con borde de acento a la izquierda) viene del design system de boardtender: es la
   misma casa. El acento sí es propio: la mandarina de Satsumap, no el azul de boardtender. */

:root {
  --background: #141414;
  --surface: #1f1f1f;
  --surface-raised: #2a2a2a;
  --border: #3a3a3a;
  /* chrome: barra superior y sidebar */
  --chrome: #0a0a0b;
  --chrome-text: #ffffff;
  --chrome-text-2: rgba(255, 255, 255, 0.62);
  --chrome-text-3: rgba(255, 255, 255, 0.46);
  --chrome-border: rgba(255, 255, 255, 0.1);
  --chrome-hover: rgba(255, 255, 255, 0.06);
  --chrome-pressed: rgba(255, 255, 255, 0.12);
  --rail-width: 56px;
  --rail-width-open: 232px;
  /* Sangría que deja el ícono centrado en el riel angosto: (ancho − caja del ícono) / 2, menos el
     borde izquierdo de 2px del ítem. No cambia al desplegarse, así el ícono no se mueve de lugar. */
  --rail-icon-inset: calc((var(--rail-width) - 20px) / 2 - 2px);
  /* Cae hacia la derecha, que es el lado por el que la barra se monta sobre el mapa: una sombra
     hacia abajo no despega nada porque arriba y abajo la barra toca los bordes de la ventana. */
  --rail-shadow: 8px 0 30px rgba(0, 0, 0, 0.45);
  --legend-width: 320px;
  --text: #f2f2f2;
  --text-muted: #9a9a9a;
  --accent: #f7931a;
  --accent-strong: #ffa940;
  --danger: #ff5252;
  --unspent: #5cff9d;
  --topbar-height: 64px;
  --panel-width: 400px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

/* Un anillo propio: el del navegador casi no se ve sobre un fondo tan oscuro. */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.node:focus-visible {
  outline: none;
}

.node:focus-visible .shape {
  stroke: var(--accent-strong);
  stroke-width: 3;
}

.panel tr:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  display: flex;
  flex-direction: column;
}

/* ---------- barra superior ---------- */

.topbar {
  position: relative;
  min-height: var(--topbar-height);
  padding: 0.6rem 1rem;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Barra de carga: aparece mientras hay pedidos en vuelo. */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  opacity: 0;
  transition: opacity 0.2s;
}

body.is-loading .topbar::after {
  opacity: 1;
  animation: loading-sweep 1.1s linear infinite;
}

@keyframes loading-sweep {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.25);
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 420px;
  min-width: 0;
}

.search-label {
  color: var(--text-muted);
  white-space: nowrap;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: var(--accent);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
}

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

.tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.language-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.language {
  padding: 0.45rem 0.6rem;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.language.is-active {
  background: var(--accent);
  color: #1a1a1a;
}

/* ---------- área de trabajo ---------- */

/* La sidebar y el mapa conviven: el mapa ocupa lo que queda, así el SVG no pasa por debajo. */
.shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* La barra de misión ocupa su fila y el mapa toma el resto: encima tapaba el panel. */
.workspace {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: relative;
  flex: 0 0 var(--rail-width);
  width: var(--rail-width);
  /* Desplegada tapa el mapa, y el mapa trae elementos posicionados (panel, leyenda) que si no
     pintarían encima por venir después en el documento. */
  z-index: 2;
  transition: flex-basis 160ms ease, width 160ms ease;
}

/* Fijada con el botón: además de desplegarse, ocupa lugar en la fila y corre el mapa. */
.sidebar.is-open {
  flex-basis: var(--rail-width-open);
  width: var(--rail-width-open);
}

/* La capa visible, separada del hueco que la barra ocupa en la fila. Va absoluta para que
   desplegarse al pasar el puntero NO recalcule el layout: si el mapa se corriera cada vez que el
   puntero roza el borde, saltaría justo mientras se está trabajando sobre él. */
.sidebar-inner {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: var(--rail-width);
  background: var(--chrome);
  border-right: 1px solid var(--chrome-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  container-type: inline-size;
  transition: width 160ms ease, box-shadow 160ms ease;
}

.sidebar.is-open .sidebar-inner {
  width: var(--rail-width-open);
}

/* Con el foco del teclado se despliega en cualquier dispositivo: si no, tabular por los íconos no
   diría qué hace cada uno. Va con :has(:focus-visible) y no con :focus-within porque un TOQUE también
   deja el foco adentro: medido el 07/09, en el celular la barra se quedaba abierta tapando media
   pantalla después de tocar cualquier herramienta. :focus-visible lo pone el teclado, no el dedo. */
.sidebar:not(.is-open):has(:focus-visible) .sidebar-inner {
  width: var(--rail-width-open);
  box-shadow: var(--rail-shadow);
}

/* Con el puntero, solo donde hay puntero de verdad: en táctil el :hover queda pegado después de un
   toque y la barra taparía el mapa sin que nadie la haya abierto. */
@media (hover: hover) {
  .sidebar:not(.is-open):hover .sidebar-inner {
    width: var(--rail-width-open);
    box-shadow: var(--rail-shadow);
  }
}

.rail {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
}

.rail-foot {
  margin-top: auto;
  border-top: 1px solid var(--chrome-border);
}

.rail-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0 0 var(--rail-icon-inset);
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--chrome-text-2);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}

/* El Inspector es un enlace (lleva a /inspector/) y se ve igual que los botones de herramientas. */
a.rail-item {
  text-decoration: none;
}

.rail-item:hover {
  background: var(--chrome-hover);
  color: var(--chrome-text);
}

.rail-item.is-active {
  background: var(--chrome-pressed);
  border-left-color: var(--accent);
  color: var(--chrome-text);
}

.rail-icon {
  flex: none;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-icon .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.rail-text {
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 120ms ease;
}

/* El nombre aparece cuando el riel es ancho de verdad, sin importar el motivo (fijado, puntero o
   foco): la condición es el espacio disponible. 120px es donde ya entra una palabra entera. */
@container (min-width: 120px) {
  .rail-text {
    opacity: 1;
  }
}

.sidebar-toggle {
  min-height: 40px;
  border: 0;
  border-top: 1px solid var(--chrome-border);
  background: transparent;
  color: var(--chrome-text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: var(--chrome-hover);
  color: var(--chrome-text);
}

.sidebar-toggle .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transition: transform 160ms ease;
}

/* Colapsada, la flecha invita a abrir; abierta, a cerrar. */
.sidebar:not(.is-open) .sidebar-toggle .icon {
  transform: rotate(180deg);
}

.graph {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

.graph:active {
  cursor: grabbing;
}

.node {
  cursor: pointer;
}

.node .shape {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
  transition: stroke-width 0.15s;
}

.node:hover .shape {
  stroke: #ffffff;
  stroke-width: 2.5;
}

.node.selected .shape {
  stroke: #ffffff;
  stroke-width: 3;
}

.node.unconfirmed .shape {
  stroke-dasharray: 6 4;
  stroke: var(--accent);
}

@keyframes node-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

.node.appearing {
  animation: node-appear 420ms ease-out;
}

/* Dibujado pero todavía sin mostrar: la cámara está viajando y este nodo entra cuando llegue. */
.node.waiting {
  opacity: 0;
  pointer-events: none;
}

.node.dimmed {
  opacity: 0.28;
}

.node.tag .shape {
  stroke-width: 1.5;
}

/* Sin gastar: filete verde por dentro del borde y fondo con un tinte del mismo verde. El verde de
   los scripts es más apagado; este es más claro para que no se confundan. */
.node.tag.unspent .shape {
  fill: #12291d;
}

.tag-filet {
  stroke: var(--unspent);
  stroke-width: 1.2;
  pointer-events: none;
}

.node.tag:hover .shape {
  stroke-width: 2.5;
  filter: brightness(1.15);
}

.node.tag.selected .shape {
  stroke: #ffffff;
  stroke-width: 3;
}

/* Hermana: la misma dirección que la seleccionada, en otro lugar del mapa. Se distingue de la
   seleccionada a propósito — blanco lleno y grueso es "esta elegiste", punteado naranja es "acá
   está la misma dirección otra vez" — así una no se confunde con la otra. */
.node.tag.sibling .shape {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 5 3;
}

.tag-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}

.tag-sublabel {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
  user-select: none;
}

.node.aggregate .tag-label {
  fill: var(--text-muted);
}

.tag-reused {
  fill: var(--danger);
  stroke: var(--background);
  stroke-width: 1.5;
}

.node-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}

.edge {
  cursor: pointer;
  transition: opacity 0.15s;
}

.edge.dimmed {
  opacity: 0.22;
}

.edge.selected .line {
  filter: drop-shadow(0 0 4px #ffffff);
}

.edge:hover .line {
  filter: drop-shadow(0 0 3px #ffffff);
}

.edge-label {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  paint-order: stroke;
  stroke: var(--background);
  stroke-width: 4px;
  pointer-events: none;
  user-select: none;
}

/* ---------- panel lateral ---------- */

/* El panel flota sobre el grafo. Si estuviera en el flujo, al abrirse achicaría el SVG y el grafo se
   correría bajo el puntero (el segundo click de un doble click caería en el fondo). Lo que tapa se
   descuenta al encuadrar (viewport.fit con insets). */
.panel {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  width: var(--panel-width);
  max-width: 55%;
  padding: 0.5rem 0.9rem 1rem;
  background: rgba(31, 31, 31, 0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.85rem;
}

.panel[hidden] {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  padding: 0.4rem 0;
  background: rgba(31, 31, 31, 0.96);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.panel-block {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.panel-subtitle {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-weight: 400;
}

.close-panel, .close-dialog {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.close-panel:hover, .close-dialog:hover {
  color: var(--text);
}

.panel table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.9rem;
}

.panel caption {
  text-align: left;
  padding: 0.5rem 0 0.3rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.panel td, .panel th {
  padding: 0.3rem 0.4rem;
  vertical-align: top;
  text-align: left;
}

.panel .details th {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  width: 32%;
}

/* overflow-wrap: anywhere corta primero en los espacios (entre "BTC", "·" y "sats") y recién si no
   hay dónde, adentro de la palabra (un hash de 64 caracteres). word-break: break-all partía números. */
.panel .details td {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.panel a {
  color: var(--accent-strong);
  text-decoration: none;
}

.panel a:hover {
  text-decoration: underline;
}

.panel .io tr.row-clickable {
  cursor: pointer;
}

.panel .io tr.row-clickable:hover {
  background: rgba(255, 255, 255, 0.07);
}

.panel .io tr.row-loaded {
  background: rgba(247, 147, 26, 0.08);
}

.panel .io tr.row-loaded .address::before {
  content: "● ";
  color: var(--accent);
}

.panel .io .address {
  font-family: var(--font-mono);
  word-break: break-all;
  width: 62%;
}

.panel .io .address code {
  font-family: inherit;
}

.panel .io .amount {
  text-align: right;
  white-space: nowrap;
}

.panel .io .amount .btc {
  display: block;
  font-family: var(--font-mono);
}

.panel .io .amount .sats {
  display: block;
  color: var(--text-muted);
  font-size: 0.78em;
}

.panel .io .row-origin td {
  padding-top: 0;
  padding-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.78em;
  font-family: var(--font-mono);
}

.panel .muted {
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- notación ---------- */

.chip {
  display: inline-block;
  border: 1px solid var(--border);
  font: inherit;
  cursor: pointer;
  padding: 0.05rem 0.4rem;
  margin: 0 0.3rem 0.2rem 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.explanation {
  margin: 0.35rem 0 0.1rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  background: rgba(247, 147, 26, 0.08);
  color: var(--text);
  line-height: 1.45;
}

.explanation[hidden] {
  display: none;
}

.chip-kind {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1a1a;
}

.chip-flag {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.chip-version {
  color: var(--text-muted);
}

.chip-script {
  border-color: var(--chip-color);
  color: var(--chip-color);
  background: transparent;
}

.notation {
  padding: 0.2rem 0 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.4rem;
}

.notation-scripts {
  margin-left: 0.2rem;
}

.node-badge {
  fill: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  paint-order: stroke;
  stroke: var(--background);
  stroke-width: 3px;
  pointer-events: none;
  user-select: none;
}

.legend-code {
  display: inline-block;
  min-width: 3.6em;
  margin-right: 0.4rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-strong);
}

/* Una sola columna: el panel es angosto y a dos columnas los nombres se cortaban. */
.legend-codes li {
  break-inside: avoid;
}

/* ---------- panel de salida / dirección ---------- */

.full-address {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.9em;
  word-break: break-all;
  vertical-align: middle;
  max-width: calc(100% - 4.5em);
}

.script-explanation {
  margin: 0.2rem 0 0.6rem;
  font-size: 0.85em;
}

.section-title {
  margin: 0.8rem 0 0.2rem;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.tx-link {
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
}

.tx-link:hover {
  border-color: var(--accent);
}

.tx-link.tx-loaded::before {
  content: "● ";
  color: var(--accent);
}

.address-reuse {
  margin: 0.3rem 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.03);
  line-height: 1.4;
}

.address-reuse-few {
  border-left-color: var(--danger);
}

.address-reuse-many {
  border-left-color: var(--accent);
}

/* Servicio: el mismo rojo que "few" pero con fondo, para que se lea como el escalón más fuerte.
   No se cambia el color del texto: el contraste sobre el panel ya está medido y verificado. */
/* El buzón no es una advertencia: es una aclaración. Va con el borde neutro de la caja y un fondo
   apenas marcado, para que no compita con el rojo del reúso ni con el naranja del acento. */
.address-reuse-mailbox {
  border-left-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.address-reuse-service {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* Naranja a propósito: es el mismo color del borde punteado con que quedan marcadas las hermanas
   en el mapa. La nota y las etiquetas encendidas se leen como una sola cosa. */
/* El mensaje se muestra tal cual está en la cadena: con sus renglones, que es como se escribió.
   `pre` respeta los saltos de línea; `overflow-wrap` corta el base64 largo de un bloque PGP para que
   no desborde el panel. */
.message-text {
  margin: 0.4rem 0;
  padding: 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 22rem;
  overflow-y: auto;
}

.message-armor {
  margin: 0.3rem 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--accent-strong);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--accent-strong) 10%, transparent);
  line-height: 1.4;
  font-size: 0.86rem;
}

.address-occurrences {
  margin: 0.3rem 0 0.6rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  line-height: 1.4;
  font-size: 0.86rem;
}

.address-note {
  margin: 0.4rem 0 0.6rem;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  line-height: 1.4;
  font-size: 0.86rem;
}

.address-note-error {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ---------- línea de tiempo de una dirección ---------- */

.address-timeline {
  margin: 0.6rem 0;
}

.address-timeline figcaption {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.address-timeline svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-raised);
  border-radius: 6px;
}

.timeline-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.timeline-divider {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.timeline-label {
  fill: var(--text-muted);
  font-family: var(--font-body);
  font-size: 9px;
}

.timeline-hit {
  fill: transparent;
  cursor: pointer;
}

.timeline-in .timeline-mark {
  fill: #36d38c;
}

.timeline-out .timeline-mark {
  fill: #fea1c9;
}

.timeline-none .timeline-mark {
  fill: var(--text-muted);
}

.timeline-bar.is-loaded .timeline-mark {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.timeline-bar:hover .timeline-hit {
  fill: rgba(255, 255, 255, 0.08);
}

.timeline-legend,
.timeline-note {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.timeline-key-in {
  color: #36d38c;
}

.timeline-key-out {
  color: #fea1c9;
}

.history-more {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.8rem;
}

.history-when {
  display: block;
  color: var(--text-muted);
  font-size: 0.78em;
  font-family: var(--font-body);
}

.panel .io .net-in .btc {
  color: #36d38c;
}

.panel .io .net-out .btc {
  color: #fea1c9;
}

/* ---------- observaciones ---------- */

.observations h3 {
  margin: 0.6rem 0 0.3rem;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.finding {
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.55rem;
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.03);
}

.finding-high {
  border-left-color: var(--accent);
}

.finding-medium {
  border-left-color: #5d87fd;
}

.finding summary {
  cursor: pointer;
  list-style: none;
}

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

.finding-title {
  font-weight: 600;
}

.finding-title::before {
  content: "▸ ";
  color: var(--text-muted);
}

.finding[open] .finding-title::before {
  content: "▾ ";
}

.finding-line {
  margin: 0.35rem 0 0;
  color: var(--text);
  word-break: break-word;
}

.finding-confidence {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
  border-bottom: 1px dotted var(--text-muted);
}

.finding-why {
  margin: 0.4rem 0 0.1rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: rgba(247, 147, 26, 0.08);
  color: var(--text);
  line-height: 1.45;
}

.finding-why[hidden] {
  display: none;
}

.why-toggle {
  display: inline-block;
  width: 1.4em;
  height: 1.4em;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1.3em;
  text-align: center;
  cursor: pointer;
  vertical-align: middle;
}

.why-toggle:hover, .why-toggle[aria-expanded="true"] {
  background: var(--accent);
  color: #1a1a1a;
}

.highlight-badge {
  fill: var(--accent);
  stroke: var(--background);
  stroke-width: 2;
}

.highlight-count {
  fill: #1a1a1a;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

/* Texto oscuro sobre el rojo: en blanco medía 3,19:1 y no llegaba a AA. */
.badge-reused {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  background: var(--danger);
  color: #1a1a1a;
  font-weight: 600;
  font-size: 0.72em;
  font-family: var(--font-body);
  vertical-align: middle;
}

.expand-bar {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}

.expand-neighbours {
  flex: 1 1 0;
  padding: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.expand-neighbours:hover {
  border-color: var(--accent);
}

/* ---------- leyenda ---------- */

/* La leyenda es un panel al costado, no un cartel encima del mapa: se puede dejar abierta mientras
   se trabaja, y el encuadre la descuenta. */
.legend {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--legend-width);
  max-width: 80%;
  overflow-y: auto;
  padding: 0.4rem 0.9rem 1rem;
  background: rgba(31, 31, 31, 0.97);
  border-right: 1px solid var(--border);
  font-size: 0.8rem;
}

.legend[hidden] {
  display: none;
}

.legend-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 0.3rem;
  background: rgba(31, 31, 31, 0.97);
}

.legend-head h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
}

.legend p {
  margin: 0.5rem 0 0.3rem;
  color: var(--text-muted);
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.12rem 0;
}

.legend .swatch {
  display: inline-block;
  width: 26px;
  height: 5px;
  border-radius: 3px;
  flex: none;
}

.legend .shape-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.legend .shape-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.legend .shape-icon.filet {
  color: transparent;
}

.legend .shape-icon.filet svg {
  stroke: var(--unspent);
  stroke-width: 2;
}

.legend .shape-icon.dashed {
  color: transparent;
}

.legend .shape-icon.dashed svg {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

/* ---------- misiones ---------- */

.mission-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  background: rgba(10, 10, 11, 0.94);
  border-bottom: 2px solid var(--accent);
}

.mission-bar[hidden] {
  display: none;
}

.mission-bar-main {
  min-width: 0;
}

.mission-bar-title {
  display: block;
  font-weight: 700;
  color: var(--accent-strong);
}

.mission-bar-goal,
.mission-bar-done,
.mission-bar-step,
.mission-bar-hint {
  margin: 0.15rem 0 0;
  line-height: 1.4;
}

/* El número del paso en el acento, para que se ubique de un vistazo dónde va. */
.mission-bar-step-count {
  color: var(--accent);
  font-weight: 700;
  margin-right: 0.35rem;
}

.mission-bar-hint {
  color: var(--accent-strong);
}

.mission-bar-done {
  color: var(--unspent);
}

.mission-bar-actions {
  display: flex;
  gap: 0.5rem;
  flex: none;
}


/* ---------- estado vacío ---------- */

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
  padding: 1rem;
  pointer-events: none;
}

.empty-state[hidden] {
  display: none;
}

.empty-state button {
  pointer-events: auto;
}

.empty-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.empty-hint {
  margin: 0;
  max-width: 32ch;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- avisos ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 20px);
  max-width: min(90%, 560px);
  padding: 0.6rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-left-color: var(--danger);
  cursor: pointer;
  pointer-events: auto;
}

/* ---------- ajustes ---------- */

.button-icon {
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
}

.settings {
  width: min(94%, 520px);
}

.setting {
  display: grid;
  grid-template-columns: 8rem 1fr 7rem;
  align-items: center;
  gap: 0.6rem;
  margin: 0.7rem 0;
}

.setting-name {
  font-weight: 600;
}

.setting input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.setting-value {
  color: var(--accent-strong);
  text-align: right;
}

.setting-hint {
  margin: 0.2rem 0 1rem;
  line-height: 1.45;
}

.setting-actions {
  display: flex;
  gap: 0.5rem;
}

.panel .amount .usd, .panel .details .usd {
  display: block;
  color: var(--accent-strong);
  font-size: 0.8em;
  font-family: var(--font-body);
}

.panel .details .usd {
  display: inline;
  margin-left: 0.3rem;
  white-space: nowrap;
}

.panel .io .utxo {
  color: var(--unspent);
}

.chip-unspent {
  background: var(--unspent);
  border-color: var(--unspent);
  color: #10281c;
}

.chip-spent, .chip-unspendable, .chip-unknown {
  color: var(--text-muted);
}

.tag-utxo {
  fill: var(--unspent);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
  pointer-events: none;
  user-select: none;
}

/* ---------- ayuda ---------- */

.help {
  width: min(92%, 620px);
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.55;
}

.help::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.help-close-form {
  float: right;
  margin: -0.5rem -0.75rem 0 0;
}

.help h2 {
  margin-top: 0;
  color: var(--accent);
}

.help h3 {
  margin-bottom: 0.4rem;
}

.help ol, .help ul {
  padding-left: 1.3rem;
}

.help li {
  margin-bottom: 0.4rem;
}

/* ---------- pantallas chicas ---------- */

@media (max-width: 820px) {
  :root {
    --panel-width: 100%;
    --topbar-height: 52px;
    --rail-width: 48px;
  }

  .topbar {
    padding: 0.4rem 0.6rem;
    gap: 0.5rem;
  }

  .brand-tagline,
  .search-label {
    display: none;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  /* El buscador ocupa su propia fila y las acciones van al lado del logo: dos filas, no tres. */
  .search {
    order: 3;
    flex: 1 0 100%;
  }

  .tools {
    gap: 0.35rem;
  }

  .button {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
  }

  .rail-icon .icon {
    width: 18px;
    height: 18px;
  }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 55%;
    border-radius: 12px 12px 0 0;
  }

  .legend {
    bottom: auto;
    top: 0.75rem;
    max-width: 240px;
  }
}
