:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --ink: #1c1c1f;
  --muted: #66666d;
  --line: #dddbd4;
  --p1: #0072b2;          /* Okabe-Ito azul */
  --p2: #e69f00;          /* Okabe-Ito naranja */
  --p1-ink: #ffffff;
  --p2-ink: #1c1c1f;
  --p1-text: #0067a0;
  --p1-strong: #005a8c;   /* p1-text sobre la línea resaltada del código (AA) */
  --p2-text: #9a6400;
  --conflict: #d55e00;    /* Okabe-Ito bermellón */
  --conflict-text: #b34a00; /* bermellón oscurecido: texto con contraste AA sobre blanco y fondo */
  --wide: #009e73;        /* Okabe-Ito verde azulado */
  --mut: #cc79a7;         /* Okabe-Ito púrpura rojizo: gen mutado */
  --mut-ink: #1c1c1f;
  --hit: #cc79a7;
  --focus: #1c1c1f;
  --band: rgba(28, 28, 31, 0.055);
  --stripe: rgba(255, 255, 255, 0.55);
  --accent: #0072b2;
  --accent-ink: #ffffff;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --card: #1c1c20;
    --ink: #f0f0f2;
    --muted: #a2a2aa;
    --line: #34343a;
    --p1: #56b4e9;        /* Okabe-Ito celeste */
    --p2: #e69f00;
    --p1-ink: #0b1b26;
    --p2-ink: #1c1c1f;
    --p1-text: #7cc6f0;
    --p1-strong: #7cc6f0;
    --p2-text: #f2b53a;
    --conflict: #ff7a33;
    --conflict-text: #ff7a33;
    --wide: #33c99b;
    --mut: #e396c3;
    --mut-ink: #1c1c1f;
    --hit: #e396c3;
    --focus: #ffffff;
    --band: rgba(255, 255, 255, 0.06);
    --stripe: rgba(0, 0, 0, 0.35);
    --accent: #56b4e9;
    --accent-ink: #0b1b26;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

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

/* Barra superior */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.98rem;
}
.brand:hover span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark i { width: 10px; height: 18px; border-radius: 3px; background: var(--p1); display: block; }
.brand-mark i:nth-child(2) { background: var(--mut); }
.brand-mark i:nth-child(3) { background: var(--p1); opacity: 0.55; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 60ch;
}

/* Pantalla inicial */
.hero { margin: 8px 0 26px; max-width: 72ch; }
.hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
.lead { margin: 12px 0 0; font-size: 1.12rem; line-height: 1.6; color: var(--muted); }
.rep-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.rep-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rep-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rep-head h2 { margin: 0; font-size: 1.35rem; }
.rep-count { font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chromo { display: flex; flex-wrap: wrap; gap: 4px; }
.gene-mini {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: var(--p1);
  color: var(--p1-ink);
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.rep-desc { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }
.op-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.op-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
}
a.op-item:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.op-item.disabled { background: var(--bg); color: var(--muted); }
.op-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.op-name { font-weight: 700; }
.op-summary { font-size: 0.86rem; color: var(--muted); line-height: 1.4; }
.op-go { font-weight: 700; font-size: 1.2rem; color: var(--accent); }
.badge-soon {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px dashed var(--muted);
  color: var(--muted);
  white-space: nowrap;
}

/* Cabecera de la página de un operador */
.op-head { margin-bottom: 18px; }
.back {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
}
.back:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.op-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.op-switch-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.op-switch-items { display: flex; flex-wrap: wrap; gap: 6px; }
.op-chip {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}
a.op-chip:hover { border-color: var(--accent); }
.op-chip.current { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.op-chip.soon { border-style: dashed; color: var(--muted); background: transparent; }

.lang {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--card);
  flex-shrink: 0;
}
.lang button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.lang button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Tarjetas */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

/* Controles */
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 24px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.range-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
}
.range-wrap output {
  min-width: 2ch;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
input[type="range"] { accent-color: var(--accent); width: 150px; }
input[type="number"], input[type="text"], select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  height: 38px;
}
input[type="number"] { width: 110px; font-variant-numeric: tabular-nums; }
select { min-width: 220px; max-width: 100%; cursor: pointer; }
.params-box { display: flex; flex-wrap: wrap; gap: 14px 24px; }
.variant-desc { margin-top: 10px; max-width: 80ch; }
a:focus-visible, select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible, .handle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 38px;
  padding: 7px 16px;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { filter: brightness(1.08); }

details {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  width: fit-content;
}
.manual-form { margin-top: 8px; }
.manual-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 420px);
  justify-content: start;
  gap: 8px 12px;
  align-items: center;
}
.manual-grid label { font-weight: 600; font-size: 0.9rem; }
.manual-grid input { width: 100%; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.manual-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.error { margin: 0; color: var(--conflict-text); font-weight: 600; font-size: 0.92rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.86rem; }

/* Escenario */
.stage { padding-top: 10px; }
#viz {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.drag-hint { text-align: right; margin-top: -2px; }

.row-label { text-anchor: end; font-weight: 700; font-size: 17px; fill: var(--ink); }
.lbl-p1 { fill: var(--p1-text); }
.lbl-p2 { fill: var(--p2-text); }
.aux-caption { text-anchor: middle; fill: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0; transition: opacity 0.35s; }
.aux-caption.visible { opacity: 1; }
.idx { text-anchor: middle; font-size: 13px; fill: var(--muted); font-variant-numeric: tabular-nums; }

.band { fill: var(--band); opacity: 0; transition: opacity 0.35s, x 0.2s, width 0.2s; }
.band.visible { opacity: 1; }
.cut { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; transition: opacity 0.3s; }
.cut.faint { opacity: 0.25; }

.handle { cursor: grab; outline: none; }
.handle.dragging { cursor: grabbing; }
.handle-hit { fill: transparent; }
.handle-diamond { fill: var(--ink); stroke: var(--card); stroke-width: 2; transition: transform 0.15s; }
.handle:hover .handle-diamond, .handle.dragging .handle-diamond { transform: scale(1.2); }
.handle:focus-visible .handle-diamond { fill: var(--accent); }
.handle-stem { stroke: var(--ink); stroke-width: 2; opacity: 0.4; }

.slot {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  transition: stroke 0.2s;
}
.slot.focus { stroke: var(--focus); stroke-width: 3; stroke-dasharray: none; }

.gene .gene-rect { stroke: transparent; stroke-width: 3; transition: stroke 0.2s; }
.gene { transition: opacity 0.25s; }
.gene.dim { opacity: 0.3; }
.gene.active .gene-rect { stroke: var(--focus); }
.gene.conflict .gene-rect { stroke: var(--conflict); stroke-width: 5; }
.gene.conflict { animation: shake 0.45s ease-in-out 1; }
.gene-num {
  text-anchor: middle;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ink-p1 { fill: var(--p1-ink); }
.ink-p2 { fill: var(--p2-ink); }
.ink-mut { fill: var(--mut-ink); }
.gene-num-halo {
  fill: var(--ink);
  stroke: var(--card);
  stroke-width: 5px;
  paint-order: stroke;
  stroke-linejoin: round;
}
.hatch-stripe { fill: var(--stripe); }
.badge circle { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; }
.badge text { text-anchor: middle; fill: var(--ink); font-weight: 700; }
.ghost { pointer-events: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); }

.aux { opacity: 0; transition: opacity 0.35s; }
.aux.visible { opacity: 1; }
.pair { transition: opacity 0.25s; }
.pair.dim { opacity: 0.3; }
.pair-bg { fill: transparent; stroke: transparent; stroke-width: 3; }
.pair.active .pair-bg { fill: var(--band); stroke: var(--focus); }
.pair-a-num, .pair-b-num { text-anchor: middle; font-weight: 700; font-variant-numeric: tabular-nums; }
.pair-arrow { text-anchor: middle; fill: var(--muted); font-weight: 700; }
.ochip { transition: opacity 0.25s; }
.ochip.placed { opacity: 0.3; }
.ochip-rect { stroke: transparent; stroke-width: 3; }
.ochip.active .ochip-rect { stroke: var(--focus); }
.ochip-num { text-anchor: middle; font-weight: 700; font-variant-numeric: tabular-nums; }
.ochip-idx { text-anchor: middle; font-size: 11px; font-weight: 600; fill: var(--muted); font-variant-numeric: tabular-nums; }
.cycle-rect { stroke: transparent; stroke-width: 3; }
.cycle.active .cycle-rect { stroke: var(--focus); }
.cycle-text { text-anchor: middle; font-weight: 700; font-variant-numeric: tabular-nums; }
.link { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.link-head { fill: var(--ink); }
.miss-rect { fill: var(--card); stroke: var(--conflict); stroke-width: 2.5; stroke-dasharray: 5 3; }
.miss-text { text-anchor: middle; font-weight: 700; fill: var(--ink); }
.mcell-rect { fill: transparent; stroke: var(--line); stroke-width: 2; stroke-dasharray: 4 3; }
.mcell-bit { text-anchor: middle; font-weight: 700; fill: var(--muted); font-variant-numeric: tabular-nums; }
.mcell.shown .mcell-rect { stroke: var(--ink); stroke-dasharray: none; fill: var(--card); }
.mcell.shown .mcell-bit { fill: var(--ink); }
.mcell.shown.one .mcell-rect { fill: var(--ink); }
.mcell.shown.one .mcell-bit { fill: var(--card); }
.mcell.active .mcell-rect { stroke: var(--accent); stroke-width: 4; }
.lerp-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.lerp-tick { text-anchor: end; font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.lerp-seg { stroke: var(--muted); stroke-width: 3; stroke-linecap: round; }
.lerp-p { stroke: var(--card); stroke-width: 1.5; }
.lerp-p1 { fill: var(--p1); }
.lerp-p2 { fill: var(--p2); }
.lerp-c { opacity: 0; stroke: var(--ink); stroke-width: 1.5; transition: opacity 0.3s; }
.lerp-c.shown { opacity: 1; }
.lerp-col { transition: opacity 0.3s; }
.lerp-col.dim { opacity: 0.35; }
.lerp-col.active .lerp-seg { stroke: var(--focus); }
.cloud-box { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
.cloud-tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.cloud-axis-label { font-size: 12px; fill: var(--ink); font-weight: 600; }
.cloud-dot { fill: var(--wide); opacity: 0.35; }
.cloud-parent { stroke: var(--card); stroke-width: 1.5; }
.cloud-p1 { fill: var(--p1); }
.cloud-p2 { fill: var(--p2); }
.cloud-child { stroke: var(--card); stroke-width: 1.5; }
.cloud-c1 { fill: var(--ink); }
.cloud-c2 { fill: var(--card); stroke: var(--ink); stroke-width: 2.5; }
.gene .gene-rect.jump { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; }
.ecol { transition: opacity 0.25s; }
.ecol.used { opacity: 0.3; }
.ehead-rect { fill: var(--ink); stroke: transparent; stroke-width: 3; }
.ehead-num { text-anchor: middle; font-weight: 700; fill: var(--card); font-variant-numeric: tabular-nums; }
.ecol.current .ehead-rect { fill: var(--accent); stroke: var(--focus); }
.ecol.current .ehead-num { fill: var(--accent-ink); }
.ecol.cand .ehead-rect { stroke: var(--accent); stroke-dasharray: 4 3; }
.ecol.chosen .ehead-rect { stroke: var(--focus); stroke-width: 4; }
.echip { transition: opacity 0.25s; }
.echip-rect { stroke: transparent; stroke-width: 2.5; }
.echip-num { text-anchor: middle; font-weight: 700; font-variant-numeric: tabular-nums; }
.echip-strike { stroke: var(--ink); stroke-width: 2; opacity: 0; }
.echip.removed { opacity: 0.25; }
.echip.removed .echip-strike { opacity: 1; }
.echip.chosen .echip-rect { stroke: var(--focus); }
.slot-num { text-anchor: middle; font-weight: 600; fill: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }

@keyframes shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -3px 0; }
  75% { translate: 3px 0; }
}

/* Reproductor */
.player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.player-buttons { display: flex; gap: 8px; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover:not(:disabled) { border-color: var(--muted); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.play { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); width: 52px; height: 52px; }
.icon-btn.play .i-pause { display: none; }
.icon-btn.play.playing .i-pause { display: block; }
.icon-btn.play.playing .i-play { display: none; }

.progress { flex: 1 1 200px; min-width: 160px; }
.counter { font-size: 0.9rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--band); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.speed { flex-direction: row; align-items: center; gap: 10px; }
.speed input[type="range"] { width: 120px; }
.speed output { min-width: 3.2ch; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Narración */
.narration {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--bg);
  border-left: 4px solid var(--accent);
  min-height: 6.2em;
}
.narration p { margin: 0; font-size: 1.18rem; line-height: 1.5; max-width: 80ch; }
.chain { margin-top: 10px !important; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chain[hidden] { display: none; }
.chain .chain-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-right: 4px; }
.chain .chip {
  display: inline-grid;
  place-items: center;
  min-width: 2.2em;
  height: 2.2em;
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--ink);
  font-variant-numeric: tabular-nums;
}
.chain .chip.last { background: var(--ink); color: var(--card); }
.chain .arrow { color: var(--muted); font-weight: 700; }

/* Leyenda */
.legend {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  font-size: 0.9rem;
  color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 20px; height: 20px; border-radius: 5px; display: inline-block; flex-shrink: 0; }
.sw-p1 { background: var(--p1); }
.sw-p2 { background: var(--p2); }
.sw-mapped { background: repeating-linear-gradient(45deg, var(--p1) 0 5px, color-mix(in srgb, var(--p1) 45%, white) 5px 9px); }
.sw-conflict { border: 4px solid var(--conflict); }
.sw-segment { background: var(--band); border: 2px dashed var(--ink); }
.sw-mask { background: var(--ink); }
.sw-blend { background: linear-gradient(90deg, var(--p1), var(--p2)); }
.sw-cloud { background: transparent; border-radius: 50%; position: relative; box-shadow: inset 0 0 0 2px var(--muted); }
.sw-cloud::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--wide); }
.sw-cloud-c1, .sw-cloud-c2 { background: transparent; border-radius: 0; position: relative; }
.sw-cloud-c1::after, .sw-cloud-c2::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px; transform: rotate(45deg); box-sizing: border-box;
}
.sw-cloud-c1::after { background: var(--ink); border: 1.5px solid var(--card); }
.sw-cloud-c2::after { background: var(--card); border: 2.5px solid var(--ink); }
.sw-both { background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%); }
.sw-jump { background: var(--card); border: 2px dashed var(--muted); }
.sw-link { width: 24px; height: 12px; border-radius: 0; border-bottom: 3px solid var(--ink); border-right: 3px solid var(--ink); transform: skewX(-20deg); }

/* Para saber más */
.learn { padding-top: 16px; }
.learn-title {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs [role="tab"] {
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 10px 14px 9px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.panel { padding-top: 16px; }
.panel:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

.prose p { margin: 0 0 0.9em; font-size: 1.05rem; line-height: 1.65; max-width: 75ch; }
.prose p:last-child { margin-bottom: 0; }

.code-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  background: var(--bg);
}
.seg button {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.sync { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; font-weight: 600; cursor: pointer; }
.sync[hidden] { display: none; }
.sync input { accent-color: var(--accent); width: 18px; height: 18px; }
.code-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.code-actions .btn { white-space: nowrap; }
.copy-status { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.code-hint { margin-top: 10px; }

.code {
  margin: 10px 0 0;
  padding: 14px 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  tab-size: 4;
}
.code code { display: block; min-width: max-content; }
.code .line { display: block; padding: 0 18px; white-space: pre; border-left: 4px solid transparent; }
.code .line.pseudo { padding-left: calc(18px + var(--indent, 0) * 2.2ch); }
.code .line.current { background: color-mix(in srgb, var(--accent) 22%, transparent); border-left-color: var(--accent); }
.code .kw { font-weight: 700; color: var(--p1-text); }
.code .line.current .kw { color: var(--p1-strong); }
.code .comment { color: var(--muted); font-style: italic; }
.code[data-kind="pseudo"] { font-size: 1.02rem; }
.code[data-kind="pseudo"] code { min-width: 0; }
.code[data-kind="pseudo"] .line { white-space: pre-wrap; text-indent: -2.2ch; padding-left: calc(18px + (var(--indent, 0) + 1) * 2.2ch); }

.refs { margin: 12px 0 0; padding-left: 1.4em; display: grid; gap: 14px; }
.refs li { padding-left: 4px; }
.refs li::marker { color: var(--muted); font-weight: 600; }
.cite { margin: 0; line-height: 1.55; }
.cite a { color: var(--p1-text); display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.ref-note { margin: 3px 0 0; color: var(--muted); font-size: 0.93rem; }
.ref-badge {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: color-mix(in srgb, var(--p2) 25%, transparent);
  color: var(--ink);
}

.ref-badge.core { background: color-mix(in srgb, var(--p1) 22%, transparent); }

/* Modo práctica */
.practice-givens { margin: 10px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.practice-given { margin: 0; font-size: 0.92rem; line-height: 1.5; }
.practice-given-hint { color: var(--muted); }
.practice-form { margin-top: 12px; }
.practice-result { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.practice-result-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.practice-result-label { font-weight: 600; margin-right: 2px; }
.practice-gene {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1.5px solid transparent;
}
.practice-gene.ok { background: color-mix(in srgb, var(--wide) 22%, transparent); border-color: var(--wide); color: var(--ink); }
.practice-gene.bad { background: color-mix(in srgb, var(--conflict) 16%, transparent); border-color: var(--conflict); color: var(--ink); }
.practice-score { margin: 4px 0 0; font-weight: 700; }
.practice-score.all { color: var(--wide); }

/* Comparar operadores */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.cmp-link {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  color: var(--p1-text);
  font-weight: 700;
  text-decoration: none;
}
.cmp-link:hover { border-style: solid; box-shadow: 0 0 0 1px var(--accent); }
.cmp-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 10px; }
.cmp-section-head .learn-title { margin: 0; }
.cmp-scroll { overflow-x: auto; padding-bottom: 2px; }
.cmp-grid { --cw: 40px; display: grid; gap: 4px; width: max-content; }
.cmp-grid[data-rep="real"] { --cw: 54px; }
.cmp-row { display: grid; grid-template-columns: 2.4em repeat(var(--n), var(--cw)); gap: 4px; align-items: center; }
.cmp-row-label { font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.cmp-idx-num { text-align: center; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cmp-gene {
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  border: 2px solid transparent;
  white-space: nowrap;
}
.cmp-gene.p1 { background: var(--p1); color: var(--p1-ink); }
.cmp-gene.p2 { background: var(--p2); color: var(--p2-ink); }
.cmp-gene.moved { background: var(--card); color: var(--ink); border: 2px dashed var(--muted); }
.cmp-gene.same { background: var(--band); color: var(--muted); border-color: var(--line); }
.cmp-gene.inside {
  background: linear-gradient(90deg, color-mix(in srgb, var(--p1) 45%, var(--card)), color-mix(in srgb, var(--p2) 45%, var(--card)));
  color: var(--ink);
}
.cmp-gene.outside { background: var(--wide); color: var(--card); }
.cmp-gene.dup { border: 3px solid var(--conflict); }
.cmp-sw { width: 22px; height: 22px; flex-shrink: 0; }
.cmp-children { display: grid; gap: 14px; margin-top: 12px; }
.cmp-op { min-width: 0; padding: 12px 0 0 12px; border-top: 1px solid var(--line); border-left: 4px solid transparent; }
.cmp-op.from { border-left-color: var(--accent); }
.cmp-op-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.cmp-op-name { font-weight: 700; color: var(--ink); }
.cmp-op-meta { font-size: 0.86rem; color: var(--muted); }
.cmp-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cmp-mode-label { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.cmp-progress { font-size: 0.86rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5em; }
.table-scroll { overflow-x: auto; margin-top: 12px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.cmp-table th, .cmp-table td { padding: 10px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.cmp-table thead th { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cmp-table tbody th { font-weight: 700; min-width: 8em; }
.cmp-table tbody th a { color: var(--ink); }
.cmp-table tr.from { background: var(--band); }
.cmp-cell { min-width: 104px; display: flex; flex-direction: column; gap: 8px; }
.cmp-nums { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.cmp-val { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.cmp-ex { font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cmp-bar { position: relative; height: 8px; border-radius: 999px; background: var(--band); margin-top: 4px; }
.cmp-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); transition: width 0.4s; }
.cmp-tick {
  position: absolute;
  top: -8px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--ink);
  transform: translateX(-50%);
}
.cmp-defs-title { margin: 18px 0 8px; font-size: 1rem; }
.cmp-defs { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 0.93rem; line-height: 1.5; }
.cmp-defs dt { font-weight: 700; }
.cmp-defs dd { margin: 0; color: var(--muted); max-width: 80ch; }
.cmp-refs { margin-top: 16px; max-width: 90ch; line-height: 1.5; }

/* Rutas (permutaciones como circuitos del viajante) */
.route-maps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.route-map { margin: 0; min-width: 0; }
.route-map svg { display: block; width: 100%; height: auto; background: var(--bg); border-radius: 10px; }
.route-map figcaption { margin-top: 6px; font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.route-parent { fill: none; stroke-width: 2; stroke-linejoin: round; }
.route-p1 { stroke: var(--p1); opacity: 0.45; }
.route-parent-main { stroke: var(--p1); stroke-width: 3.5; }
.route-p2 { stroke: var(--p2); opacity: 0.7; stroke-dasharray: 6 4; }
.route-edge { stroke-width: 4; stroke-linecap: round; }
.route-edge.kept { stroke: var(--ink); }
.route-edge.new { stroke: var(--conflict); stroke-dasharray: 7 5; }
.city circle { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; }
.city text { text-anchor: middle; font-size: 10px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.city.visited circle { fill: var(--ink); }
.city.visited text { fill: var(--card); }
.city.missing circle { stroke: var(--conflict); stroke-width: 3; stroke-dasharray: 3 2; }
.sw-line { width: 26px; height: 5px; border-radius: 3px; }
.sw-route-p1 { background: var(--p1); opacity: 0.6; }
.sw-route-p2 { background: repeating-linear-gradient(90deg, var(--p2) 0 6px, transparent 6px 10px); }
.sw-route-kept { background: var(--ink); }
.sw-route-new { background: repeating-linear-gradient(90deg, var(--conflict) 0 7px, transparent 7px 11px); }
.sw-city { width: 16px; height: 16px; border-radius: 50%; background: var(--ink); }
.sw-city-missing { width: 16px; height: 16px; border-radius: 50%; border: 3px dashed var(--conflict); }

.foot { text-align: center; margin-top: 6px; }

/* Pie común y «Acerca de» */
.site-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
}
.site-foot-logos, .about-logos { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.site-foot-logos img { display: block; height: 30px; width: auto; border-radius: 4px; filter: grayscale(1); opacity: 0.7; transition: filter 0.2s, opacity 0.2s; }
.site-foot-logos img.main { height: 38px; }
.site-foot-logos a:hover img, .site-foot-logos img:hover { filter: none; opacity: 1; }
.site-foot-info { font-size: 0.85rem; color: var(--muted); text-align: right; }
.site-foot-info p { margin: 0; }
.site-foot-links { margin-top: 2px !important; }
.site-foot a, .about a { color: var(--p1-text); }
.about { max-width: 820px; padding: 26px 28px; }
.about h1 { margin-bottom: 10px; }
.about .lead { margin-top: 0; }
.about-section { margin-top: 22px; }
.about-section h2 { margin: 0 0 8px; font-size: 1.1rem; }
.about-section p { margin: 0 0 8px; line-height: 1.6; max-width: 75ch; }
.about-authors { font-weight: 600; }
.about-authors sup { font-weight: 600; margin-left: 1px; }
.about-affs { margin: 4px 0 10px !important; color: var(--muted); }
.about-logos { margin-top: 20px; }
.about-logos img { display: block; height: 48px; width: auto; border-radius: 6px; }
.about-logos img.main { height: 60px; }

@media (max-width: 960px) {
  .rep-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .wrap { padding: 18px 16px 28px; }
  .brand span:last-child { font-size: 0.9rem; }
  .buttons { margin-left: 0; width: 100%; }
  .buttons .btn { flex: 1; }
  .card { padding: 14px; }
  .narration p { font-size: 1.02rem; }
  .drag-hint { text-align: left; }
  .manual-grid { grid-template-columns: 1fr; }
  #variantField { flex: 1 1 100%; min-width: 0; }
  #variantField select { width: 100%; min-width: 0; }
  .code-actions { margin-left: 0; width: 100%; }
  .code-actions .btn { flex: 1 1 auto; white-space: normal; }
  .copy-status { order: 3; }
  .prose p { font-size: 1rem; }
  .cmp-grid { --cw: 27px; gap: 3px; }
  .cmp-grid[data-rep="real"] { --cw: 46px; }
  .cmp-row { gap: 3px; grid-template-columns: 2em repeat(var(--n), var(--cw)); }
  .cmp-gene { height: 30px; font-size: 0.8rem; border-radius: 5px; }
  .cmp-op { padding-left: 8px; }
  .cmp-defs { grid-template-columns: 1fr; gap: 2px; }
  .route-maps { grid-template-columns: 1fr; }
  .site-foot { justify-content: flex-start; }
  .site-foot-info { text-align: left; }
  .about { padding: 18px 16px; }
  .about-logos img { height: 38px; }
  .about-logos img.main { height: 46px; }
  .cmp-defs dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .gene.conflict { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Bancos de preguntas para Moodle ---------- */
.home-extra { margin: 22px 0 0; text-align: center; font-size: 0.95rem; }
.home-extra a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.home-extra a:hover { color: var(--ink); border-color: var(--muted); }
.home-extra.home-sister { margin-top: 26px; }
.home-extra.home-sister + .home-extra { margin-top: 10px; }
.home-extra.home-sister a { color: var(--p1-text); border-bottom-color: currentColor; }
.moodle { max-width: 900px; }
.moodle h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.mq-group { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 10px 14px 12px; min-width: 0; }
.mq-group legend { font-weight: 600; padding: 0 6px; }
.mq-group .hint { margin-bottom: 8px; }
.mq-items { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.mq-check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.4; }
.mq-check input { accent-color: var(--accent); margin-top: 3px; flex: none; }
.mq-num { display: inline-flex; align-items: center; gap: 10px; }
.mq-num input { width: 80px; }
.mq-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 16px; }
.mq-summary { margin: 0; flex: 1 1 280px; }
.mq-status { margin: 0; flex-basis: 100%; color: var(--muted); font-size: 0.9rem; }
.mq-status:empty { display: none; }
.mq-preview { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 10px; overflow-x: auto; }
.mq-preview:empty { display: none; }
.mq-qname { margin: 0 0 6px; color: var(--muted); font-size: 0.82rem; }
.mq-qtext p { margin: 6px 0; line-height: 1.5; }
.mq-qtext table { color: var(--ink); }
.mq-qtext input { width: 2.4em; }
.mq-options { margin: 6px 0; padding-left: 1.6em; list-style: lower-alpha; }
.mq-options li { margin: 3px 0; }
.mq-feedback { margin-top: 10px; }
.mq-feedback summary { cursor: pointer; font-weight: 600; }
.mq-feedback ul { margin: 6px 0; }
.mq-how { margin: 0 0 10px; padding-left: 1.4em; line-height: 1.6; }
@media (max-width: 600px) { .mq-items { flex-direction: column; } }

/* ---------- Mutación: números aleatorios por posición y giro de los genes que cambian ---------- */
.dcell-rect { fill: transparent; stroke: var(--line); stroke-width: 2; stroke-dasharray: 4 3; }
.dcell-r, .dcell-s { text-anchor: middle; font-weight: 700; fill: var(--muted); font-variant-numeric: tabular-nums; }
.dcell-s { font-weight: 600; }
.dcell.shown .dcell-rect { stroke: var(--ink); stroke-dasharray: none; fill: var(--card); }
.dcell.shown .dcell-r, .dcell.shown .dcell-s { fill: var(--ink); }
.dcell.shown.hit .dcell-rect { fill: var(--hit); stroke: var(--hit); }
.dcell.shown.hit .dcell-r, .dcell.shown.hit .dcell-s { fill: var(--mut-ink); }
.dcell.active .dcell-rect { stroke: var(--accent); stroke-width: 4; }

.gene-body { transform-box: fill-box; transform-origin: center; }
.gene-body.flip-in { animation-name: gene-flip-in; animation-timing-function: ease-out; animation-fill-mode: both; }
.gene-body.flip-out { animation-name: gene-flip-out; animation-timing-function: ease-in; animation-fill-mode: forwards; }
@keyframes gene-flip-in { from { transform: scaleY(0.02); } to { transform: scaleY(1); } }
@keyframes gene-flip-out { from { transform: scaleY(1); } to { transform: scaleY(0.02); } }
@media (prefers-reduced-motion: reduce) {
  .gene-body.flip-in, .gene-body.flip-out { animation: none; }
}

.sw-mut { background: var(--mut); }
.sw-hit { background: var(--hit); border: 2px solid var(--hit); }

.handle-name { font-size: 12px; font-weight: 700; fill: var(--ink); font-style: italic; }
.sw-moved { background: repeating-linear-gradient(45deg, var(--p1) 0 5px, color-mix(in srgb, var(--p1) 45%, var(--card)) 5px 9px); }

/* Distribución del valor mutado (representación real) */
.hist-title { text-anchor: middle; fill: var(--muted); font-weight: 600; font-size: 12.5px; }
.hist-frame { fill: var(--bg); stroke: var(--line); stroke-width: 1; }
.hist-bar { fill: var(--mut); opacity: 0.55; }
.hist-tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hist-parent line { stroke: var(--p1); stroke-width: 3; }
.hist-parent text { fill: var(--p1-text); font-size: 12px; font-weight: 700; }
.hist-mut { fill: var(--mut); stroke: var(--ink); stroke-width: 1.5; }
.sw-dist { background: color-mix(in srgb, var(--mut) 55%, transparent); border-radius: 2px; }

/* Comparar operadores (mutación) */
.cmp-gene.kept { background: var(--p1); color: var(--p1-ink); }
.cmp-gene.mutated { background: var(--mut); color: var(--mut-ink); }
.cmp-grid[data-rep="real"] { --cw: 54px; }

/* Return to the shared genetic algorithm tools portal. */
.topbar { flex-wrap: wrap; }
.portal-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto; color: var(--muted); text-decoration: none;
  font-size: 0.8rem; font-weight: 600;
}
.portal-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.portal-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
@media (max-width: 760px) {
  .portal-link { order: 3; flex-basis: 100%; margin-left: 0; }
}

/* ---------- Representación: problemas dentro de cada representación ---------- */
.problem-name { margin: 14px 0 0; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.series-links { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-left: 6px; }
.about-sisters { margin: 0 0 8px; padding-left: 1.2em; line-height: 1.7; }

/* ---------- Página de una codificación: etapas, formalización y mochila ---------- */
.stage-strip { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.stage-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.stage-btn:hover { color: var(--ink); border-color: var(--muted); }
.stage-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--band); color: var(--ink); font-size: 0.78rem; font-weight: 700;
}
.stage-btn.done .stage-num { background: color-mix(in srgb, var(--accent) 25%, var(--card)); }
.stage-btn.current { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.stage-btn.current .stage-num { background: var(--accent); color: var(--accent-ink); }

.formula { margin: 0 0 10px; padding: 12px 14px; border-radius: 12px; background: var(--band); }
.formula-rows { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; align-items: center; }
.formula-row { display: contents; }
.formula-label { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); transition: color 0.2s; }
.formula-math { font-size: 1.15rem; padding: 3px 8px; border-radius: 8px; border: 2px solid transparent; transition: opacity 0.25s, border-color 0.2s, background 0.2s; justify-self: start; }
.formula-math math { font-size: 1.1em; }
/* Lo que aún no ha llegado se ve en gris atenuado, pero legible (contraste AA): la etapa avanza sin ocultar texto */
.formula-row.pending .formula-math { color: var(--muted); }
.formula-row.current .formula-label { color: var(--ink); }
.formula-row.current .formula-math { border-color: var(--accent); background: var(--card); }
.formula-instance { margin-top: 8px; }

#viz { width: 100%; height: auto; display: block; overflow: visible; }
.row-label { fill: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; transition: opacity 0.25s; }

.item .item-rect { fill: var(--card); stroke: var(--line); stroke-width: 2; transition: fill 0.25s, stroke 0.25s, opacity 0.25s; }
.item text { text-anchor: middle; fill: var(--ink); font-variant-numeric: tabular-nums; pointer-events: none; }
.item .item-idx { fill: var(--muted); font-size: 13px; font-weight: 700; }
.item .item-w, .item .item-v { font-size: 16px; font-weight: 600; }
.item .item-tag { font-size: 12px; font-weight: 700; fill: var(--conflict); }
.item.in .item-rect { fill: color-mix(in srgb, var(--p1) 16%, var(--card)); stroke: var(--p1); }
.item.focus .item-rect { stroke: var(--focus); stroke-width: 3; }
.item.pending { opacity: 0.55; }
.item.removed .item-rect { stroke: var(--mut); stroke-dasharray: 6 4; }
.item.removed .item-w, .item.removed .item-v { text-decoration: line-through; fill: var(--muted); }
.item.removed .item-tag { fill: var(--mut); }
.item.skipped .item-rect { stroke: var(--conflict); stroke-dasharray: 6 4; }

.gene-btn { cursor: pointer; }
.gene-btn:focus { outline: none; }
.gene-btn:focus-visible .gene-rect { stroke: var(--focus); stroke-width: 3; stroke-dasharray: 4 3; }
.gene.one .gene-rect { fill: var(--p1); }
.gene.one .gene-num { fill: var(--p1-ink); }
.gene.zero .gene-rect { fill: var(--card); stroke: var(--line); stroke-width: 2; }
.gene.zero .gene-num { fill: var(--ink); }
.gene.changed .gene-rect { fill: var(--mut); stroke: var(--mut); }
.gene.changed .gene-num { fill: var(--mut-ink); }
.gene.active .gene-rect { stroke: var(--focus); stroke-width: 3; }
.gene-btn:hover .gene-rect { stroke: var(--focus); }
.gene-num { font-size: 18px; }

.bag-track { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.seg-rect { fill: var(--p1); }
.seg.focus .seg-rect { fill: color-mix(in srgb, var(--p1) 70%, var(--ink)); }
.seg-label { fill: var(--p1-ink); font-size: 13px; font-weight: 700; pointer-events: none; }
.excess { fill: url(#excessHatch); stroke: var(--conflict); stroke-width: 2; }
.excess-bg { fill: color-mix(in srgb, var(--conflict) 12%, transparent); }
.excess-line { stroke: var(--conflict); stroke-width: 3; }
.cap-line { stroke: var(--ink); stroke-width: 2.5; }
.cap-label { fill: var(--ink); font-size: 14px; font-weight: 700; }
.summary { fill: var(--ink); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .sum-over { fill: var(--conflict); }
.summary .sum-fit { fill: var(--accent); }

.sw-gene-one { background: var(--p1); }
.sw-gene-zero { background: var(--card); border: 2px solid var(--line); }
.sw-excess { background: repeating-linear-gradient(45deg, var(--conflict) 0 3px, color-mix(in srgb, var(--conflict) 12%, var(--card)) 3px 8px); border: 2px solid var(--conflict); }
.sw-skipped { background: var(--card); border: 2px dashed var(--conflict); }

.treat-table td.num { font-variant-numeric: tabular-nums; }
.treat-table td.over { color: var(--conflict-text); font-weight: 600; }
.treat-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.12em; }
.treat-table .bit-changed { color: var(--mut); font-weight: 700; text-decoration: underline; }
.treat-table tr.current { background: var(--band); }
.treat-table tr.current th .link-btn { text-decoration: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: currentColor; }

@media (max-width: 640px) {
  .formula-rows { grid-template-columns: 1fr; gap: 2px; }
  .formula-math { margin-bottom: 6px; font-size: 1rem; }
}
.viz-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  #viz { min-width: 640px; }
}

/* ---------- Viajante ---------- */
.map-bg-rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.route-optimal { fill: none; stroke: var(--wide); stroke-width: 3; stroke-dasharray: 8 6; opacity: 0.9; }
.route-edge.tour-go, .route-edge.tour-close { stroke: var(--p1); stroke-width: 4; stroke-linecap: round; }
.route-edge.tour-close { stroke-dasharray: 2 0; }
.route-edge.tour-repeat { stroke: var(--conflict); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 7 5; }
.route-edge.focus { stroke-width: 6; }
.city.big text { font-size: 13px; }
.city.visited circle { fill: var(--p1); stroke: var(--p1); }
.city.visited text { fill: var(--p1-ink); }
.city.start circle { stroke: var(--ink); stroke-width: 3.5; }
.city.repeated circle { fill: var(--conflict); stroke: var(--conflict); }
.city.repeated text { fill: var(--card); }
.city.missing circle { fill: var(--card); stroke: var(--conflict); stroke-width: 3; stroke-dasharray: 4 3; }
.gene-pos { fill: var(--muted); font-size: 12px; font-weight: 700; }
.gene.perm .gene-rect { fill: var(--p1); }
.gene.perm .gene-num { fill: var(--p1-ink); }
.gene.perm.repeat .gene-rect { fill: var(--conflict); }
.gene.perm.repeat .gene-num { fill: var(--card); }
.gene.perm.changed .gene-rect { fill: var(--mut); }
.gene.perm.changed .gene-num { fill: var(--mut-ink); }
.gene.picked .gene-rect { stroke: var(--focus); stroke-width: 4; stroke-dasharray: 5 3; }
.gene.picked { transform: translateY(-4px); }
.summary.sum-main { font-size: 18px; }
.summary.sum-opt { fill: var(--wide); }
.summary.sum-fit { fill: var(--accent); }
.equiv-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; font-size: 0.88rem; }
.equiv-table td.current-cell { background: color-mix(in srgb, var(--accent) 18%, var(--card)); font-weight: 700; }
.sw-city-dot { border-radius: 50%; background: var(--p1); }
.sw-city-start { border-radius: 50%; background: var(--p1); box-shadow: inset 0 0 0 3px var(--ink); }
.sw-tour { background: var(--p1); }
.sw-tour-opt { background: repeating-linear-gradient(90deg, var(--wide) 0 7px, transparent 7px 11px); }
.sw-tour-repeat { background: repeating-linear-gradient(90deg, var(--conflict) 0 7px, transparent 7px 11px); }
.sw-city-missing { border-radius: 50%; background: var(--card); border: 3px dashed var(--conflict); }
.enc-extra:empty { display: none; }
.formula-math { max-width: 100%; overflow-x: auto; overflow-y: hidden; padding-block: 6px; }

/* ---------- Asignación de tareas a máquinas ---------- */
.task-head { fill: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.task-head.focus { fill: var(--ink); }
.task-head.bad { fill: var(--conflict); }
.mach-label { fill: var(--muted); font-size: 13px; font-weight: 700; transition: opacity 0.25s; }
.pcell rect { fill: var(--card); stroke: var(--line); stroke-width: 1.5; transition: fill 0.2s, stroke 0.2s; }
.pcell text { fill: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; pointer-events: none; }
.pcell.fast text { font-weight: 800; }
.pcell.chosen rect { fill: color-mix(in srgb, var(--p1) 22%, var(--card)); stroke: var(--p1); stroke-width: 2; }
.pcell.focus rect { stroke: var(--focus); stroke-width: 3; }
.gene.machine .gene-rect { fill: var(--p1); }
.gene.machine .gene-num { fill: var(--p1-ink); }
.gene.machine.changed .gene-rect { fill: var(--mut); }
.col-bad { fill: none; stroke: var(--conflict); stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; }
.lane { fill: var(--bg); stroke: var(--line); stroke-width: 1; }
.bar rect { fill: var(--p1); }
.bar text { fill: var(--p1-ink); font-size: 12px; font-weight: 700; pointer-events: none; }
.bar.focus rect { fill: color-mix(in srgb, var(--p1) 70%, var(--ink)); }
.bar.dup rect { fill: url(#dupHatch); stroke: var(--conflict); stroke-width: 2; }
.bar.dup text { fill: var(--ink); }
.bar.changed rect { fill: var(--mut); }
.bar.changed text { fill: var(--mut-ink); }
.dup-bg { fill: color-mix(in srgb, var(--conflict) 14%, var(--card)); }
.dup-line { stroke: var(--conflict); stroke-width: 3; }
.mark line { stroke-width: 2.5; }
.mark text { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mark-cmax line { stroke: var(--ink); }
.mark-cmax text { fill: var(--ink); }
.mark-opt line { stroke: var(--wide); stroke-dasharray: 7 5; }
.mark-opt text { fill: var(--wide); }
.sw-cell-chosen { background: color-mix(in srgb, var(--p1) 22%, var(--card)); border: 2px solid var(--p1); }
.sw-cell-fast { background: var(--card); border: 1.5px solid var(--line); position: relative; }
.sw-cell-fast::after { content: '9'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.sw-col-bad { background: var(--card); border: 2px dashed var(--conflict); }
.sw-bar { background: var(--p1); }
.sw-bar-dup { background: repeating-linear-gradient(45deg, var(--conflict) 0 3px, color-mix(in srgb, var(--conflict) 14%, var(--card)) 3px 8px); border: 2px solid var(--conflict); }
.sw-cmax { background: var(--ink); }
.both-same { margin: 0 0 10px; }
.both-same code.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--band); }
.both-table tr.current { background: var(--band); }
.both-table tbody th a { font-weight: 700; }

/* ---------- Función continua (reales y binaria) ---------- */
.fbase { fill: var(--p1); }
.fband { fill: var(--card); fill-opacity: 0.11; stroke: var(--card); stroke-opacity: 0.35; stroke-width: 0.6; pointer-events: none; }
.fout { fill: url(#outHatch); pointer-events: none; }
.out-bg { fill: color-mix(in srgb, var(--card) 72%, transparent); }
.out-line { stroke: var(--conflict); stroke-width: 1.4; stroke-opacity: 0.55; }
.fbox { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }
.faxes .axis text { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.faxes .axis path, .faxes .axis line { stroke: var(--line); }
.faxes .axis-label { fill: var(--ink); font-size: 15px; font-weight: 700; font-style: italic; }
.map-hit { fill: transparent; pointer-events: none; }
.map-hit.active { pointer-events: all; }
.lattice-pt { fill: var(--ink); fill-opacity: 0.55; pointer-events: none; }
.fmin { fill: var(--p2); stroke: var(--ink); stroke-width: 1.2; pointer-events: none; }
.dec-line { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }
.nb-line { stroke: var(--mut); stroke-width: 1.6; stroke-opacity: 0.8; pointer-events: none; }
.nb-pt { fill: var(--mut); stroke: var(--card); stroke-width: 1.5; pointer-events: none; }
.ftarget { fill: none; stroke: var(--wide); stroke-width: 3; stroke-dasharray: 4 3; pointer-events: none; }
.fbest { fill: none; stroke: var(--wide); stroke-width: 3.5; pointer-events: none; }
.fpoint .fpoint-halo { fill: var(--card); fill-opacity: 0.55; }
.fpoint .fpoint-dot { fill: var(--ink); stroke: var(--card); stroke-width: 2.5; }
.fpoint.out .fpoint-dot { fill: var(--card); stroke: var(--conflict); stroke-width: 3.5; }
.fpoint.draggable { cursor: grab; }
.fpoint.draggable:active { cursor: grabbing; }
.fpoint:focus { outline: none; }
.fpoint:focus-visible .fpoint-halo { stroke: var(--focus); stroke-width: 2.5; stroke-dasharray: 4 3; }
.fpoint-treated { fill: var(--mut); stroke: var(--ink); stroke-width: 2; pointer-events: none; }
.ftreat { stroke: var(--mut); stroke-width: 3; pointer-events: none; }
.treat-head { fill: var(--mut); }
.gene.real .gene-rect { fill: var(--p1); }
.gene.real .gene-num { fill: var(--p1-ink); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gene.real.out .gene-rect { fill: var(--card); stroke: var(--conflict); stroke-width: 3; }
.gene.real.out .gene-num { fill: var(--conflict); }
.gene.binbit .gene-rect { opacity: 0.85; }
.gene.cliff .gene-rect { stroke: var(--wide); stroke-width: 4; stroke-dasharray: 5 3; }
.bit-head.gene-pos { font-size: 14px; }
.bit-weight { fill: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.dec-note { fill: var(--ink); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chrom-note { fill: var(--muted); font-size: 14px; }
.fp.summary { font-size: 16px; }
.fp.fp-main { font-size: 18px; }
.fp.fp-opt { fill: var(--wide); }
.fp.fp-best { fill: var(--wide); }
.fp.fp-fit { fill: var(--accent); }
.fscale-bar { fill: url(#fScale); stroke: var(--line); }
.fscale-lo { stop-color: var(--p1); }
.fscale-hi { stop-color: color-mix(in srgb, var(--p1) 27%, var(--card)); }
.fscale-title { fill: var(--muted); font-size: 13px; font-weight: 700; }
.fscale-lab { fill: var(--muted); font-size: 13px; }
.sw-fmap { background: linear-gradient(90deg, var(--p1), color-mix(in srgb, var(--p1) 27%, var(--card))); }
.sw-fmin { background: var(--p2); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border-radius: 0; }
.sw-fpoint { border-radius: 50%; background: var(--ink); box-shadow: inset 0 0 0 3px var(--card); }
.sw-fpoint-out { border-radius: 50%; background: var(--card); border: 3px solid var(--conflict); }
.sw-fout { background: repeating-linear-gradient(45deg, var(--conflict) 0 2px, var(--card) 2px 7px); }
.sw-ftreat { border-radius: 50%; background: var(--mut); border: 2px solid var(--ink); }
.sw-dec-line { background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px); }
.sw-lattice { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); opacity: 0.6; margin: 6px; }
.sw-fbest { border-radius: 50%; background: transparent; border: 3px solid var(--wide); }
.sw-nb { border-radius: 50%; background: var(--mut); width: 12px; height: 12px; margin: 4px; }
.sw-cliff { background: var(--card); border: 3px dashed var(--wide); }
.treat-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }

/* ---------- Practicar (fase 5) ---------- */
.stage-top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 14px; }
.stage-top .stage-strip { flex: 1 1 auto; }
.practice-btn { margin-left: auto; }
.practice-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--band); }
.stage-btn:disabled { cursor: default; }
.stage-btn:disabled:hover { color: var(--muted); border-color: var(--line); }
.stage-btn.current:disabled:hover { color: var(--ink); border-color: var(--ink); }

.practice { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.practice-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.practice-head .learn-title { margin: 0; }
.pr-types { flex-wrap: wrap; }
.practice-intro { margin-top: 8px; }
.pr-sub { margin: 16px 0 6px; font-size: 0.95rem; }
.practice-givens { display: flex; flex-direction: column; gap: 6px; }
.practice-given { margin: 0; font-size: 0.93rem; line-height: 1.5; }
.pr-dist { font-size: 0.86rem; width: auto; }
.pr-dist th, .pr-dist td { padding: 3px 8px; text-align: right; }

.practice-form { margin-top: 4px; }
.pr-group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0 0 10px; min-width: 0; }
.pr-group legend { font-weight: 700; font-size: 0.9rem; padding: 0 6px; }
.pr-items { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.pr-item { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; border-radius: 8px; padding: 2px; }
.pr-item.pr-bit { align-items: center; }
.pr-cap { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.pr-fix { font-size: 0.8rem; font-weight: 700; color: var(--conflict-text); min-height: 0; }
.pr-fix:empty { display: none; }
.pr-item.ok { box-shadow: 0 0 0 2px var(--wide); }
.pr-item.bad { box-shadow: 0 0 0 2px var(--conflict); }
.pr-num { width: 104px; font-variant-numeric: tabular-nums; }
.pr-items select { min-width: 92px; }
.pr-bit {
  width: 36px; height: 36px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer;
}
.pr-bit.one { background: var(--p1); border-color: var(--p1); color: var(--p1-ink); }
.pr-checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; cursor: pointer; padding: 4px 6px; }
.pr-yesno { padding: 3px; }
.pr-yesno button[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.pr-grid { border-collapse: separate; border-spacing: 4px; }
.pr-grid th { font-size: 0.82rem; color: var(--muted); font-weight: 700; padding: 0 4px; }
.pr-grid td { padding: 0; }
.pr-tour { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.pr-tour-label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-weight: 600; font-size: 0.9rem; }
.pr-tour-input { width: min(100%, 320px); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.pr-tour .buttons { margin-left: 0; }
.pr-edges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pr-edges:empty { display: none; }

.practice-result { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.practice-result-label { font-weight: 600; font-size: 0.9rem; margin-right: 2px; }
.practice-gene {
  display: inline-flex; align-items: center; justify-content: center; padding: 3px 9px; border-radius: 8px;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.9rem; border: 1.5px solid transparent;
}
.practice-gene.ok { background: color-mix(in srgb, var(--wide) 22%, transparent); border-color: var(--wide); color: var(--ink); }
.practice-gene.bad { background: color-mix(in srgb, var(--conflict) 16%, transparent); border-color: var(--conflict); color: var(--ink); }
.practice-score { margin: 0; font-weight: 700; }
.practice-score.all { color: var(--wide); }
.pr-equiv { display: flex; flex-wrap: wrap; gap: 6px; }
.pr-equiv code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; padding: 2px 7px; border-radius: 6px; background: var(--band); }
.pr-equiv code.mine { outline: 2px solid var(--wide); font-weight: 700; }

/* Circuito que marca el estudiante en el mapa del viajante */
.user-edge { stroke: var(--p2); stroke-width: 5; stroke-linecap: round; opacity: 0.9; pointer-events: none; }
.user-edge.close { stroke-dasharray: 6 5; }
.city.pickable { cursor: pointer; }
.city.pickable:hover circle { stroke-width: 3; }
.city.user-visited circle { stroke: var(--p2); stroke-width: 4; }
.city:focus-visible { outline: none; }
.city:focus-visible circle { stroke: var(--focus); stroke-width: 4; }

@media (max-width: 720px) {
  .practice-btn { margin-left: 0; width: 100%; }
  .pr-num { width: 88px; }
  .practice .manual-actions .btn { flex: 1 1 auto; }
}
.pr-item.pr-bit .pr-fix { display: none; }   /* un bit mal puesto solo puede ser el otro: basta el recuadro */
.pr-dist th, .pr-dist td { width: auto; min-width: 0; white-space: nowrap; }
.cmp-table.pr-dist tbody th { text-align: right; padding-right: 10px; min-width: 0; }

/* ---------- Comparar codificaciones (fase 6) ---------- */
.cmp-link-inline { margin-top: 14px; width: fit-content; max-width: 100%; }
.cmp-sol-line { margin: 10px 0 0; }
.cmp-bits .cmp-row { --cw: 30px; }
.cmp-bits .cmp-idx-num { text-align: left; font-weight: 700; }
#cmpView .cmp-table td { vertical-align: top; }
#cmpView .cmp-table thead th { text-transform: none; letter-spacing: 0; font-size: 0.84rem; }   /* f y Cmax no son F ni CMAX */

/* ---------- Preguntas para Moodle (fase 7) ---------- */
.mq-all { margin: 0 0 10px; justify-content: flex-start; margin-left: 0; }
.mq-pvbar { margin: 8px 0 0; }
.mq-pvbar select { min-width: 0; max-width: 100%; }
.mq-qtext table { max-width: 100%; }
.mq-qtext select { min-width: 0; font-size: 0.9rem; padding: 2px 4px; }
@media (max-width: 600px) { .mq-pvbar .mq-num { flex-wrap: wrap; } }
.mq-pvbar .mq-num { min-width: 0; max-width: 100%; }
.mq-pvbar select { width: 100%; flex: 1 1 auto; }
@media (max-width: 600px) { .mq-pvbar .mq-num { width: 100%; } }

/* ---------- initialization-and-evaluation-ga ---------- */

/* Dos familias en la portada */
.fam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .fam-grid { grid-template-columns: 1fr; } }

/* Nivel con el nombre completo y el color del libro (pistas de esquí: azul, rojo, negro) */
.badge-level {
  display: inline-block;
  vertical-align: 0.12em;
  margin-left: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 1px 7px;
  border-radius: 999px;
  color: #ffffff;
  white-space: nowrap;
}
.badge-level.basic { background: #1f63b0; }
.badge-level.advanced { background: #b3261e; }
.badge-level.further { background: #1c1c1c; box-shadow: inset 0 0 0 1px var(--muted); }

/* Vista de la población (js/viz/population-view.js) */
.pv-title { font-size: 14px; font-weight: 700; fill: var(--ink); }
.pv-sub { font-size: 11px; font-weight: 700; fill: var(--muted); }
.pv-label { font-size: 14px; font-weight: 700; fill: var(--muted); font-variant-numeric: tabular-nums; }
.pv-row.current .pv-label { fill: var(--ink); }
.pv-row.pending .pv-label { opacity: 0.7; }
.pv-gene rect { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
.pv-gene text { font-size: 13px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pv-gene.one rect { fill: var(--p1); stroke: var(--p1); }
.pv-gene.one text { fill: var(--p1-ink); }
.pv-gene.val rect { fill: var(--card); stroke: var(--muted); }
.pv-gene.empty rect { fill: none; stroke: var(--line); stroke-dasharray: 4 3; }
.pv-gene.fixed rect { fill: color-mix(in srgb, var(--p1) 16%, var(--card)); }
.pv-gene.active rect { stroke: var(--focus); stroke-width: 3; }
.pv-row.current .pv-gene.val rect, .pv-row.current .pv-gene.zero rect { stroke: var(--ink); }
.pv-swap { fill: none; stroke: var(--focus); stroke-width: 2; }
.pv-q { font-size: 13px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pv-q.infeasible { fill: var(--conflict-text); font-weight: 600; }
.pv-axis { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.pv-axisline { stroke: var(--line); stroke-width: 1.5; }
.pv-min { fill: var(--ink); stroke: var(--card); stroke-width: 1; }
.pv-pt circle { fill: var(--ink); stroke: var(--card); stroke-width: 2; }
.pv-pt.current circle { fill: var(--p2); stroke: var(--ink); stroke-width: 2.5; }
.pv-pt.infeasible circle { fill: var(--card); stroke: var(--conflict); stroke-width: 2.5; }
.pv-pt.infeasible.current circle { fill: var(--p2); stroke: var(--conflict); }
.pv-pt-label { font-size: 11px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.pv-feasible-band { fill: var(--band); }
.pv-cap { stroke: var(--conflict); stroke-width: 2; stroke-dasharray: 5 4; }
.pv-opt { stroke: var(--wide); stroke-width: 2; stroke-dasharray: 6 4; }
.pv-opt-label { fill: var(--ink); font-weight: 600; }
.pv-mini-bg { fill: var(--bg); stroke: var(--line); stroke-width: 1; }
.pv-mini.current .pv-mini-bg { stroke: var(--focus); stroke-width: 2.5; }
.pv-route { fill: none; stroke: var(--p1); stroke-width: 1.8; stroke-linejoin: round; }
.pv-mini.current .pv-route { stroke-width: 2.6; }
.pv-city { fill: var(--ink); }
.pv-mini-label { font-size: 11px; font-weight: 700; fill: var(--muted); }
.pv-bar { fill: var(--p1); }
.pv-barrow.current .pv-bar { fill: var(--p2); }
.pv-bar.infeasible, .pv-barrow.current .pv-bar.infeasible { fill: none; stroke: var(--conflict); stroke-width: 1.5; stroke-dasharray: 4 3; }
.pv-bar-note { font-size: 12px; font-weight: 600; fill: var(--conflict-text); }
.pv-dcell.diag { fill: var(--band); }
.pv-dcell.zero { stroke: var(--conflict); stroke-width: 2; }
.pv-dtext { font-size: 10px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pv-dtext.light { fill: var(--p1-ink); }
.sw-one { background: var(--p1); }
.sw-zero, .sw-val { background: var(--card); border: 2px solid var(--muted); }
.sw-active { background: var(--card); border: 3px solid var(--focus); }
.sw-empty { background: transparent; border: 2px dashed var(--line); }

/* Tarjeta de medidas */
.measures { width: 100%; max-width: 640px; border-collapse: collapse; font-size: 0.95rem; }
.measures th, .measures td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.measures th { font-weight: 600; color: var(--muted); }
.measures td { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
#vizScroll #viz { width: auto; min-width: 0; max-width: none; height: auto; }
.pv-seedmark { fill: var(--p2); }
.pv-row.seed .pv-label { fill: var(--p2-text); }
.pv-curve { fill: none; stroke: var(--p2); stroke-width: 2.5; }
.pv-cdot { fill: var(--p2); stroke: var(--card); stroke-width: 2; }
.pv-cdot.current { stroke: var(--ink); stroke-width: 2.5; }
.sw-seed { background: var(--p2); }
.measures thead th { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); text-align: right; }
.measures thead th:first-child { text-align: left; }
.pv-pt.seed circle { fill: var(--p2); stroke: var(--ink); }
.pv-bar.seed { fill: var(--p2); }
.pv-mini.seed .pv-route { stroke: var(--p2); stroke-width: 2.6; }

/* Fase 2: cuasialeatoria, inhibición secuencial e inicialización factible */
.pv-strata { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.55; }
.pv-ghost { fill: var(--card); stroke: var(--muted); stroke-width: 1.8; }
.pv-hole { fill: color-mix(in srgb, var(--p2) 14%, transparent); stroke: var(--p2-text); stroke-width: 2.5; }
.pv-hole.ghost { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 4; }
.pv-hole.centre { fill: var(--p2-text); stroke: none; }
.pv-hole.ghost.centre { fill: var(--muted); stroke: none; }
.pv-delta { fill: color-mix(in srgb, var(--p1) 10%, transparent); stroke: var(--p1); stroke-width: 1; stroke-dasharray: 3 3; }
.pv-candpt { stroke: var(--ink); stroke-width: 1.5; }
.pv-candpt.ok { fill: var(--wide); }
.pv-candpt.rej { fill: var(--conflict); }
.pv-cand-bg { fill: none; stroke: var(--wide); stroke-width: 2.5; }
.pv-cand.rej .pv-cand-bg { stroke: var(--conflict); stroke-dasharray: 6 4; }
.pv-cand.rej .pv-q { fill: var(--conflict-text); }
.pv-cand .pv-label { fill: var(--ink); }
.pv-near { fill: none; stroke: var(--p2-text); stroke-width: 2.5; stroke-dasharray: 5 3; }
.sw-ghost { background: var(--card); border: 2px solid var(--muted); border-radius: 50%; }
.sw-hole { background: color-mix(in srgb, var(--p2) 14%, transparent); border: 2.5px solid var(--p2-text); border-radius: 50%; }
.sw-cand { background: transparent; border: 3px solid var(--wide); }
.sw-rej { background: transparent; border: 3px dashed var(--conflict); }
.sw-near { background: transparent; border: 2.5px dashed var(--p2-text); }
.sw-delta { background: color-mix(in srgb, var(--p1) 10%, transparent); border: 1.5px dashed var(--p1); border-radius: 50%; }

/* Comparar estrategias de inicialización */
.home-cmp { margin: 14px 0 0; }
.home-cmp a { font-weight: 700; color: var(--p1-text); }
.cmp-det { display: block; font-weight: 600; margin-top: 2px; }

/* Fase 3: evaluación */
.pv-q.muted { fill: var(--muted); font-weight: 600; }
.pv-q.hit { fill: var(--p2-text); }
.pv-q.best { fill: var(--p1-text); }
.pv-row.cache-hit .pv-gene rect { opacity: 0.55; }
.pv-row.cache-hit .pv-label { fill: var(--p2-text); }
.pv-penarrow { stroke: var(--conflict); stroke-width: 1.8; }
.pv-arrowhead { fill: var(--conflict); }
.pv-fitpt { fill: var(--conflict); stroke: var(--card); stroke-width: 1.5; }
.pv-fitpt.current { fill: var(--p2); stroke: var(--ink); stroke-width: 2; }
.pv-hatch-bg { fill: color-mix(in srgb, var(--conflict) 14%, var(--card)); }
.pv-hatch-line { stroke: var(--conflict); stroke-width: 3; }
.pv-barrow .pv-bar.pen { fill: url(#pvHatch); stroke: var(--conflict); stroke-width: 1.5; stroke-dasharray: none; }
.pv-lline { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: 0.75; }
.pv-lline.bad { stroke: var(--conflict); }
.pv-lline.current { stroke: var(--p2); stroke-width: 3; opacity: 1; }
.pv-lenv { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 1 0; opacity: 0.85; }
.pv-lnow { stroke: var(--focus); stroke-width: 2; }
.pv-lnow-label { fill: var(--ink); font-weight: 700; }
.pv-wheel-empty { fill: var(--band); stroke: var(--line); stroke-width: 2; stroke-dasharray: 6 4; }
.pv-wheel-msg { font-size: 13px; font-weight: 700; fill: var(--conflict-text); }
.pv-sector { fill: var(--p1); stroke: var(--card); stroke-width: 1.5; }
.pv-sector.alt { fill: color-mix(in srgb, var(--p1) 55%, var(--card)); }
.pv-sector.current { fill: var(--p2); }
.pv-sector-label { font-size: 11px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.pv-pointer { fill: var(--ink); }
.pv-share-name { font-size: 13px; font-weight: 700; fill: var(--muted); }
.pv-share.current .pv-share-name { fill: var(--ink); }
.pv-share-seg { fill: var(--p1); stroke: var(--card); stroke-width: 1; }
.pv-share-seg.alt { fill: color-mix(in srgb, var(--p1) 55%, var(--card)); }
.pv-share-seg.best { fill: var(--p2); }
.pv-share-frame { fill: none; stroke: var(--line); stroke-width: 1.5; }
.pv-share.current .pv-share-frame { stroke: var(--focus); stroke-width: 2.5; }
.pv-share-none { fill: var(--band); stroke: var(--line); stroke-dasharray: 5 4; }
.pv-share-note { font-size: 12px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pv-cost-no { fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-dasharray: 6 4; }
.pv-cost-cache { fill: none; stroke: var(--p1); stroke-width: 2.6; }
.pv-cost-dot.no { fill: var(--muted); }
.pv-cost-dot.cache { fill: var(--p1); stroke: var(--card); stroke-width: 1.5; }
.pv-cost-dot.current { fill: var(--p2); stroke: var(--ink); stroke-width: 2; }
.eval-head { margin: 4px 0 8px; font-weight: 700; }
.eval-table th { width: 38%; }
.eval-table td { text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.eval-table tr.bad td { color: var(--conflict-text); }
.eval-table tr.strong td { font-weight: 800; }
.eval-grid { max-width: 820px; }
.eval-grid td, .eval-grid th { white-space: nowrap; }
.eval-grid tbody th { color: var(--ink); }
.eval-grid tr.current th, .eval-grid tr.current td { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.sw-fitpt { background: var(--conflict); transform: rotate(45deg) scale(0.75); border-radius: 2px; }
.sw-penbar { background: repeating-linear-gradient(45deg, var(--conflict) 0 3px, color-mix(in srgb, var(--conflict) 14%, var(--card)) 3px 8px); border: 1.5px solid var(--conflict); }
.sw-lenv { width: 26px; height: 4px; border-radius: 2px; background: var(--ink); }
.sw-lcur { width: 26px; height: 4px; border-radius: 2px; background: var(--p2); }
.sw-lline { width: 26px; height: 3px; border-radius: 2px; background: var(--muted); }
.sw-lline-bad { width: 26px; height: 3px; border-radius: 2px; background: var(--conflict); }
.sw-lstar { width: 4px; height: 20px; border-radius: 0; background: repeating-linear-gradient(180deg, var(--wide) 0 5px, transparent 5px 8px); }
.sw-sector { background: var(--p1); border-radius: 50% 0 0 0; }
.sw-sector-current { background: var(--p2); border-radius: 50% 0 0 0; }
.sw-share-best { background: var(--p2); border-radius: 2px; }
.sw-cachehit { background: var(--card); border: 2px solid var(--p2-text); }
.sw-cost-no { width: 26px; height: 3px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--muted) 0 6px, transparent 6px 10px); }
.sw-cost-cache { width: 26px; height: 4px; border-radius: 2px; background: var(--p1); }
.sw-budget { width: 26px; height: 3px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--conflict) 0 5px, transparent 5px 9px); }

/* Fase 4: evaluación avanzada */
.pv-stem { stroke: var(--muted); stroke-width: 1.5; }
.pv-stem.better { stroke: var(--wide); }
.pv-nb { fill: var(--card); stroke: var(--muted); stroke-width: 2; }
.pv-nb.better { fill: var(--wide); stroke: var(--card); stroke-width: 1.5; }
.pv-nb.best { fill: var(--p2); stroke: var(--ink); stroke-width: 2; }
.pv-nb-label { font-size: 10px; }
.pv-cutline { fill: none; stroke: var(--p1); stroke-width: 2; }
.pv-cutpt { fill: var(--p2); stroke: var(--ink); stroke-width: 2; }
.pv-climb { fill: none; stroke: var(--ink); stroke-width: 1.6; opacity: 0.7; }
.pv-climb.current { stroke: var(--p2); stroke-width: 3; opacity: 1; }
.pv-climb.ok { stroke: var(--wide); opacity: 0.9; stroke-width: 2; }
.pv-climb.local { stroke: var(--conflict); opacity: 0.85; stroke-width: 2; }
.pv-climbpt { fill: var(--ink); stroke: var(--card); stroke-width: 1.5; }
.pv-climbpt.start { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.pv-climbpt.end { fill: var(--conflict); stroke: var(--card); stroke-width: 1.5; }
.pv-climbpt.end.ok { fill: var(--wide); }
.pv-dumb { stroke: var(--conflict); stroke-width: 2; }
.pv-dumb.ok { stroke: var(--wide); }
.pv-sample { fill: var(--muted); opacity: 0.35; }
.pv-fdcpt { fill: var(--ink); stroke: var(--card); stroke-width: 1.5; }
.pv-fdcpt.current { fill: var(--p2); stroke: var(--ink); }
.pv-ci { stroke: var(--p1); stroke-width: 3; opacity: 0.45; stroke-linecap: round; }
.pv-rep { fill: none; stroke: var(--p2-text); stroke-width: 1.5; }
.pv-truetick { stroke: var(--ink); stroke-width: 3; }
.pv-single { fill: var(--p2); stroke: var(--ink); stroke-width: 1; }
.pv-mean { fill: var(--p1); stroke: var(--card); stroke-width: 1.5; }
.pv-slink { stroke: var(--p2-text); stroke-width: 1.2; opacity: 0.6; }
.pv-slink.strong { stroke-width: 2.5; opacity: 1; }
.pv-arch { fill: var(--ink); stroke: var(--card); stroke-width: 1.5; }
.pv-cand-pt { fill: var(--card); stroke: var(--p1); stroke-width: 2; }
.pv-cand-pt.pre { fill: var(--p1); stroke: var(--card); }
.pv-cand-pt.current { fill: var(--p2); stroke: var(--ink); }
.pv-truebest { fill: none; stroke: var(--wide); stroke-width: 3; }
.pv-diag { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.pv-preband { fill: color-mix(in srgb, var(--p1) 10%, transparent); }
.pv-cone.better { fill: color-mix(in srgb, var(--wide) 16%, transparent); }
.pv-cone.worse { fill: color-mix(in srgb, var(--conflict) 12%, transparent); }
.pv-truefront { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 3; }
.pv-truefront-pt { fill: var(--muted); }
.pv-front { fill: none; stroke: var(--p1); stroke-width: 2.5; }
.pv-iso { stroke: var(--p2-text); stroke-width: 2; stroke-dasharray: 7 4; }
.pv-objpt { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.pv-objpt.f1 { fill: var(--p1); stroke: var(--card); stroke-width: 1.5; }
.pv-objpt.fk { fill: var(--card); stroke: var(--muted); }
.pv-objpt.dom-by { fill: var(--wide); stroke: var(--card); }
.pv-objpt.doms { fill: var(--conflict); stroke: var(--card); }
.pv-objpt.current { fill: var(--p2); stroke: var(--ink); stroke-width: 2.5; }
.pv-sup { fill: none; stroke: var(--wide); stroke-width: 2.5; }
.pv-sup.no { stroke: var(--conflict); stroke-dasharray: 4 3; }
.sw-nb-better { border-radius: 50%; background: var(--wide); }
.sw-nb-worse { border-radius: 50%; background: var(--card); border: 2px solid var(--muted); }
.sw-climb { width: 26px; height: 4px; border-radius: 2px; background: var(--p2); }
.sw-end-ok { border-radius: 50%; background: var(--wide); }
.sw-sample { border-radius: 50%; width: 10px; height: 10px; margin: 5px; background: var(--muted); opacity: 0.5; }
.sw-truetick { width: 4px; border-radius: 0; background: var(--ink); }
.sw-single { background: var(--p2); transform: rotate(45deg) scale(0.7); border-radius: 2px; }
.sw-rep { border-radius: 50%; background: transparent; border: 2px solid var(--p2-text); }
.sw-mean { border-radius: 50%; background: var(--p1); }
.sw-ci { width: 26px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--p1) 45%, transparent); }
.sw-arch { border-radius: 50%; background: var(--ink); }
.sw-candpt { background: var(--card); border: 2px solid var(--p1); transform: rotate(45deg) scale(0.75); border-radius: 2px; }
.sw-pre { background: var(--p1); transform: rotate(45deg) scale(0.75); border-radius: 2px; }
.sw-truebest { border-radius: 50%; background: transparent; border: 3px solid var(--wide); }
.sw-objpt-f1 { border-radius: 50%; background: var(--p1); }
.sw-objpt { border-radius: 50%; background: var(--card); border: 2px solid var(--muted); }
.sw-iso { width: 26px; height: 3px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--p2-text) 0 7px, transparent 7px 11px); }
.sw-cone-better { background: color-mix(in srgb, var(--wide) 30%, var(--card)); }
.sw-cone-worse { background: color-mix(in srgb, var(--conflict) 25%, var(--card)); }
.sw-sup { border-radius: 50%; background: transparent; border: 3px solid var(--wide); }
.sw-unsup { border-radius: 50%; background: transparent; border: 3px dashed var(--conflict); }
.sw-truefront { width: 26px; height: 3px; border-radius: 0; background: repeating-linear-gradient(90deg, var(--muted) 0 2px, transparent 2px 5px); }

/* ---------- Practicar: tablas de datos (fase 5) ---------- */
.cmp-table.pr-data { width: auto; font-size: 0.88rem; margin: 2px 0 6px; }
.cmp-table.pr-data th, .cmp-table.pr-data td { padding: 4px 10px; white-space: nowrap; min-width: 0; }
.cmp-table.pr-data thead th { text-transform: none; letter-spacing: 0; font-size: 0.82rem; text-align: right; }
.cmp-table.pr-data tbody th { min-width: 0; }
.cmp-table.pr-data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-table.pr-data td.mono { font-family: var(--mono, ui-monospace, monospace); letter-spacing: 0.03em; }
.pr-type-one { margin: 0; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.practice .pr-num { width: 84px; }
