/* Tutor de matemática: lectura tranquila, contraste alto, sin distracciones. */

:root {
  --fondo: #f6f4ef;
  --superficie: #ffffff;
  --superficie-2: #f0ede6;
  --texto: #1d2329;
  --texto-suave: #55606b;
  --borde: #dcd7cc;
  --acento: #1f5fbf;
  --acento-fuerte: #164a96;
  --acento-fondo: #e7effb;
  --bien: #1c7a43;
  --bien-fondo: #e5f4ea;
  --mal: #b4461b;
  --mal-fondo: #fcede5;
  --aviso: #8a5a00;
  --aviso-fondo: #fdf3dc;
  /* Colores de las partes de una fórmula (aptos para daltonismo). */
  --ca: #1f5fbf;
  --cb: #c2410c;
  --cc: #15803d;
  --cd: #7e22ce;
  --ce: #0e7490;
  --cf: #be185d;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(0, 0, 0, .05);
  color-scheme: light dark;
  font-size: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #15191d;
    --superficie: #1d2227;
    --superficie-2: #252b31;
    --texto: #e8ebee;
    --texto-suave: #a5afb8;
    --borde: #353d45;
    --acento: #6ea8ff;
    --acento-fuerte: #9cc3ff;
    --acento-fondo: #1d2c42;
    --bien: #5fd08f;
    --bien-fondo: #17301f;
    --mal: #ff9a6b;
    --mal-fondo: #3a2219;
    --aviso: #f3c35b;
    --aviso-fondo: #362b12;
    --ca: #7fb2ff;
    --cb: #ff9f6b;
    --cc: #6fdc93;
    --cd: #d59cff;
    --ce: #5fd3e6;
    --cf: #ff8fc0;
  }
}

* { box-sizing: border-box; }
html { background: var(--fondo); }
body {
  margin: 0;
  color: var(--texto);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.65;
}
main { width: min(860px, calc(100% - 2rem)); margin: 1.5rem auto 4rem; }
h1, h2, h3 { line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.9rem; margin: .3rem 0 .6rem; }
h2 { font-size: 1.35rem; margin: 0 0 .7rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 .5rem; }
a { color: var(--acento); }
a:hover { color: var(--acento-fuerte); }
code { background: var(--superficie-2); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }

.saltar { position: absolute; left: -999px; }
.saltar:focus { left: 1rem; top: 1rem; background: var(--superficie); padding: .5rem; z-index: 10; }

/* ---------------------------------------------------------------- barra */
.barra { background: var(--superficie); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 5; }
.barra-interior { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; align-items: center; padding: .6rem 0; }
.barra a { text-decoration: none; color: var(--texto); font-weight: 550; }
.barra a:hover { color: var(--acento); }
.marca { font-weight: 750 !important; margin-right: auto; }
.insignia { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 1em; background: var(--mal); color: #fff; font-size: .75rem; text-align: center; }
.tamano button { border: 1px solid var(--borde); background: var(--superficie-2); color: var(--texto); border-radius: 6px; padding: .1rem .45rem; font: inherit; font-size: .85rem; cursor: pointer; }
.cuenta { display: flex; align-items: center; gap: .45rem; margin: 0; }
.cuenta-nombre { color: var(--texto-suave); font-size: .9rem; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cuenta button { border: 1px solid var(--borde); background: transparent; color: var(--texto); border-radius: 6px; padding: .1rem .5rem; font: inherit; font-size: .85rem; cursor: pointer; }
.entrar { max-width: 30rem; margin: 3rem auto; text-align: center; }
.entrar .boton { font-size: 1.05rem; padding: .8rem 1.4rem; }
.pie { width: min(860px, calc(100% - 2rem)); margin: 0 auto 2rem; color: var(--texto-suave); font-size: .85rem; }

/* -------------------------------------------------------------- bloques */
.bloque { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.3rem 1.4rem; margin: 1.1rem 0; box-shadow: var(--sombra); }
.bloque > :last-child { margin-bottom: 0; }
.destacado { border-color: var(--acento); background: var(--acento-fondo); }
.intuicion { border-left: 5px solid var(--acento); }
.sutil { color: var(--texto-suave); font-size: .92rem; }
.nota { color: var(--texto-suave); font-size: .92rem; }
.etiqueta { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--texto-suave); margin-right: .35rem; }
.etiqueta-mal { color: var(--mal); }
.etiqueta-bien { color: var(--bien); }
.aviso { border-left: 4px solid var(--aviso); background: var(--aviso-fondo); padding: .7rem 1rem; border-radius: 0; }
.aviso-suave { border-left-color: var(--acento); background: var(--acento-fondo); }
.dos-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.dos-columnas > .bloque { margin: 0; }
/* Sin esto, una tarjeta de la grilla no se achica por debajo de su fórmula más ancha y ensancha la página. */
.dos-columnas > * { min-width: 0; }
.tarjeta { background: var(--superficie-2); border-radius: var(--radio); padding: 1rem 1.1rem; }
.tarjeta h3 { margin-top: .2rem; }
.calculo { margin-top: .5rem; }
/* Las dos situaciones reales van una debajo de la otra: así sus cálculos tienen el ancho completo. */
.ejemplos .dos-columnas { grid-template-columns: minmax(0, 1fr); }
.lista-check { list-style: none; padding: 0; }
.lista-check li { padding-left: 1.6rem; position: relative; margin: .3rem 0; }
.lista-check li::before { content: "✓"; position: absolute; left: 0; color: var(--bien); font-weight: 700; }

/* ------------------------------------------------------------- botones */
.boton, .boton-secundario, .boton-terciario, .boton-peligro {
  display: inline-block; border-radius: 8px; padding: .65rem 1.05rem; font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none; border: 2px solid transparent; line-height: 1.3;
}
.boton { background: var(--acento); color: #fff; }
.boton:hover { background: var(--acento-fuerte); color: #fff; }
@media (prefers-color-scheme: dark) { .boton, .boton:hover { color: #0d1620; } }
.boton-secundario { background: transparent; color: var(--acento); border-color: var(--acento); }
.boton-secundario:hover { background: var(--acento-fondo); }
.boton-terciario { background: transparent; color: var(--texto-suave); border-color: var(--borde); }
.boton-peligro { background: var(--mal); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.acciones { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; }
.siguiente-paso { display: flex; flex-wrap: wrap; gap: .8rem; margin: 2rem 0; }

/* ------------------------------------------------------- cabecera unidad */
.migas { color: var(--texto-suave); font-size: .88rem; margin: 0; }
.estado-linea { display: flex; gap: .8rem; align-items: center; margin: .2rem 0 .8rem; }
.fases ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: .8rem 0 0; }
.fases a { display: flex; align-items: center; gap: .4rem; padding: .4rem .75rem; border-radius: 999px; border: 1px solid var(--borde); background: var(--superficie); text-decoration: none; color: var(--texto); font-size: .92rem; }
.fases .fase-num { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; background: var(--superficie-2); font-size: .78rem; font-weight: 700; }
.fases .hecho .fase-num { background: var(--bien); color: #fff; }
.fases .hecho .fase-num::after { content: ""; }
.fases .actual a { border-color: var(--acento); background: var(--acento-fondo); font-weight: 650; }
.fase-extra { color: var(--texto-suave); font-size: .8rem; }

/* --------------------------------------------------------------- estados */
.estado { display: inline-block; font-size: .75rem; font-weight: 650; padding: .1rem .55rem; border-radius: 999px; background: var(--superficie-2); color: var(--texto-suave); white-space: nowrap; }
.estado-disponible { background: var(--acento-fondo); color: var(--acento); }
.estado-en_curso { background: var(--aviso-fondo); color: var(--aviso); }
.estado-dominada { background: var(--bien-fondo); color: var(--bien); }
.estado-repasar { background: var(--mal-fondo); color: var(--mal); }
.leyenda { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ------------------------------------------------------------------ mapa */
.portada p { max-width: 62ch; }
.barra-progreso { display: block; height: .6rem; background: var(--superficie-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--borde); }
.barra-progreso > span { display: block; height: 100%; background: var(--bien); transition: width .6s ease; }
.barra-progreso.mini { width: 90px; height: .45rem; display: inline-block; vertical-align: middle; }
.tarjeta-accion h2 { margin: .1rem 0 .3rem; }
.repaso-card { border-color: var(--mal); }
.nivel { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); margin: .8rem 0; padding: .3rem 1.1rem; }
.nivel summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; padding: .6rem 0; font-size: 1.08rem; }
.nivel-titulo { font-weight: 700; margin-right: auto; }
.nivel-progreso { color: var(--texto-suave); font-size: .9rem; }
.rama { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-suave); margin: 1rem 0 .4rem; }
.unidades { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; margin: 0 0 .8rem; }
.unidad-card a { display: flex; flex-direction: column; gap: .25rem; height: 100%; padding: .65rem .8rem; border: 1px solid var(--borde); border-left-width: 5px; border-radius: 8px; text-decoration: none; color: var(--texto); background: var(--superficie); }
.unidad-card a:hover { background: var(--superficie-2); }
.unidad-nombre { font-weight: 600; line-height: 1.3; }
.unidad-card .estado { align-self: flex-start; }
.estado-borde-bloqueada a { opacity: .62; }
.estado-borde-disponible a { border-left-color: var(--acento); }
.estado-borde-en_curso a { border-left-color: var(--aviso); }
.estado-borde-dominada a { border-left-color: var(--bien); }
.estado-borde-repasar a { border-left-color: var(--mal); }

/* --------------------------------------------------------------- fórmulas */
.tex-bloque { display: block; overflow-x: auto; overflow-y: hidden; padding: .2rem 0; }
/* El MathML oculto de KaTeX va con position: absolute: sin esto escapa de la caja que se desplaza y ensancha la página. */
/* (también en .katex: así no escapa de las tablas con scroll, que no están posicionadas). */
.tex-bloque, .w-formula, .katex { position: relative; }
/* Las fórmulas en display dentro de un párrafo se desplazan solas en vez de ensanchar la página. */
.katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: .15em 0; }
.formula-grande { font-size: 1.35rem; background: var(--superficie-2); border-radius: var(--radio); padding: .9rem 1rem; text-align: center; }
.lectura, .cuando { margin: .8rem 0; }
.partes { list-style: none; padding: 0; display: grid; gap: .5rem; margin: 1rem 0; }
.parte { display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .9rem; align-items: center; padding: .55rem .8rem; border-radius: 8px; background: var(--superficie-2); border-left: 5px solid var(--borde); }
.parte-a { border-left-color: var(--ca); } .parte-a .parte-simbolo { color: var(--ca); }
.parte-b { border-left-color: var(--cb); } .parte-b .parte-simbolo { color: var(--cb); }
.parte-c { border-left-color: var(--cc); } .parte-c .parte-simbolo { color: var(--cc); }
.parte-d { border-left-color: var(--cd); } .parte-d .parte-simbolo { color: var(--cd); }
.parte-simbolo { font-size: 1.15rem; text-align: center; }
.pedir-ia { margin-top: .8rem; }

/* ----------------------------------------------------------- paso a paso */
.pasos { counter-reset: paso; list-style: none; padding: 0; margin: 1rem 0; }
.paso { counter-increment: paso; position: relative; padding: .6rem .8rem .6rem 2.8rem; margin: .5rem 0; background: var(--superficie-2); border-radius: 8px; }
.paso::before { content: counter(paso); position: absolute; left: .7rem; top: .65rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--acento); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
@media (prefers-color-scheme: dark) { .paso::before { color: #0d1620; } }
.paso p { margin: .2rem 0; }
.paso-formula { font-size: 1.1rem; }
.paso.oculto { display: none; }
.paso.recien { animation: aparecer .45s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.controles-pasos { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.por-que { margin-top: .4rem; }
.por-que summary { cursor: pointer; color: var(--acento); font-size: .92rem; }
.resultado-final { font-size: 1.05rem; }
.paso-clave { background: var(--acento-fondo); padding: .6rem .9rem; border-radius: 8px; }

/* ------------------------------------------------------- errores y ficha */
.lista-errores { list-style: none; padding: 0; display: grid; gap: .7rem; }
.lista-errores li { border: 1px solid var(--borde); border-radius: 8px; padding: .6rem .9rem; }
.lista-errores p { margin: .2rem 0; }
.ficha-encabezado { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ test */
.pregunta { border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.1rem; margin: 1rem 0; background: var(--superficie); }
.pregunta legend { font-weight: 650; padding: 0 .3rem; }
.pregunta-num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--superficie-2); font-size: .85rem; margin-right: .3rem; }
.pregunta-ok { border-color: var(--bien); }
.pregunta-mal { border-color: var(--mal); }
.opcion { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .6rem; margin: .3rem 0; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.opcion:hover { background: var(--superficie-2); }
.opcion input { margin-top: .4rem; }
.opcion-letra { font-weight: 700; color: var(--texto-suave); min-width: 1.1rem; }
.opcion-correcta { background: var(--bien-fondo); border-color: var(--bien); }
.opcion-elegida-mal { background: var(--mal-fondo); border-color: var(--mal); }
.explicacion { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--borde); }
.bien { color: var(--bien); font-weight: 700; }
.mal { color: var(--mal); font-weight: 700; }

/* --------------------------------------------------------- resultados */
.resultado, .resultado-test { border-radius: var(--radio); padding: 1rem 1.2rem; margin: 1rem 0; border: 2px solid; }
.resultado-bien { border-color: var(--bien); background: var(--bien-fondo); }
.resultado-revisar { border-color: var(--mal); background: var(--mal-fondo); }
.resultado h2, .resultado-test h2 { margin-top: 0; }
.festejo { font-weight: 700; font-size: 1.1rem; }
.observacion { color: var(--mal); font-weight: 600; }
.resultado-bien .observacion { color: var(--bien); }

/* ------------------------------------------------------------- ejercicio */
.enunciado { font-size: 1.08rem; }
.campos { display: grid; gap: .9rem; margin-top: 1rem; }
.campo label { display: block; font-weight: 650; margin-bottom: .25rem; }
.campo input[type=text], .campo select, .form-papel input[type=text], textarea {
  font: inherit; font-size: 1.1rem; padding: .55rem .7rem; border: 2px solid var(--borde); border-radius: 8px;
  width: min(100%, 22rem); background: var(--superficie); color: var(--texto);
}
textarea { width: 100%; }
.campo-ok input, .campo-ok select { border-color: var(--bien); }
.campo-mal input, .campo-mal select { border-color: var(--mal); }
.ayuda-formato { display: block; color: var(--texto-suave); font-size: .82rem; margin-top: .2rem; }
.pistas { background: var(--aviso-fondo); border-radius: 8px; padding: .6rem 1rem; margin-top: 1rem; }
.pistas h3 { margin-top: .2rem; }
.ayuda-ia { background: var(--acento-fondo); border-radius: 8px; padding: .6rem 1rem; margin-top: 1rem; }
.solucion { margin-top: 1.2rem; border-top: 1px solid var(--borde); padding-top: .4rem; }
.form-papel label { display: block; font-weight: 600; margin-top: .5rem; }
.subir-foto { border: 2px dashed var(--borde); border-radius: var(--radio); padding: 1rem; }
.subir-foto span { display: block; margin-bottom: .4rem; }
.lectura-foto { background: var(--superficie-2); border-radius: 8px; padding: .6rem 1rem; }
.sugerencias li { margin: .25rem 0; }
.consulta { border-top: 1px solid var(--borde); padding: .8rem 0; }
.consulta-pregunta { font-weight: 600; }
.peligro { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--borde); display: grid; gap: .6rem; justify-items: start; }
.resultados-ubicacion { list-style: none; padding: 0; }
.resultados-ubicacion li { margin: .3rem 0; }

/* --------------------------------------------------------------- tablas */
.tabla-scroll { overflow-x: auto; }
table { border-collapse: collapse; margin: .6rem 0; min-width: 50%; }
th, td { border: 1px solid var(--borde); padding: .4rem .75rem; text-align: center; }
thead th { background: var(--superficie-2); }
tbody th { background: var(--superficie-2); text-align: left; font-weight: 600; }

/* ------------------------------------------------------------- widgets */
.widget { margin: .8rem 0; }
.widget .sin-js { color: var(--texto-suave); }
.widget svg { display: block; width: 100%; height: auto; background: var(--superficie); border: 1px solid var(--borde); border-radius: 8px; touch-action: none; }
/* Los SVG internos de KaTeX (raíz, sombreros, llaves) usan sus propias medidas. */
.widget .katex svg { width: 100%; height: inherit; background: none; border: 0; border-radius: 0; touch-action: auto; }
.w-controles { display: grid; gap: .5rem; margin-top: .7rem; }
.w-control { display: grid; grid-template-columns: 10.5rem 1fr 4.5rem; gap: .7rem; align-items: center; }
.w-control label { font-weight: 600; }
.w-control-nota { font-weight: 450; color: var(--texto-suave); font-size: .92em; }
.w-control output { font-variant-numeric: tabular-nums; text-align: right; font-weight: 650; }
.w-control input[type=range] { width: 100%; accent-color: var(--acento); }
.w-botones { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.w-botones button { border: 1px solid var(--acento); color: var(--acento); background: transparent; border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; }
.w-botones button[aria-pressed=true], .w-botones button.activo { background: var(--acento); color: #fff; }
@media (prefers-color-scheme: dark) { .w-botones button[aria-pressed=true], .w-botones button.activo { color: #0d1620; } }
.w-formula { text-align: center; font-size: 1.2rem; margin: .6rem 0 .2rem; min-height: 2rem; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: .25em 0; }
.w-explicacion { text-align: center; color: var(--texto-suave); margin: .2rem 0; min-height: 1.6rem; }
.w-leyenda { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .9rem; margin-top: .5rem; }
.w-leyenda > span::before { content: ""; display: inline-block; width: .9rem; height: .25rem; margin-right: .35rem; vertical-align: middle; background: currentColor; border-radius: 2px; }
.consigna { margin-top: .5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  .w-control { grid-template-columns: 1fr 3.5rem; }
  .w-control label { grid-column: 1 / -1; }
  .parte { grid-template-columns: 1fr; }
  h1 { font-size: 1.55rem; }
}

/* ---------------------------------------------------------- impresión */
@media print {
  .barra, .pie, .fases, form, .siguiente-paso, .widget, .pedir-ia, button { display: none !important; }
  body { background: #fff; color: #000; }
  .bloque { box-shadow: none; break-inside: avoid; }
  .paso.oculto { display: block !important; }
}

/* ------------------------------------------------- piezas de los widgets */
.ca { color: var(--ca); } .cb { color: var(--cb); } .cc { color: var(--cc); } .cd { color: var(--cd); }
.w-grilla { stroke: var(--borde); stroke-width: 1; opacity: .7; }
.w-eje { stroke: var(--texto-suave); stroke-width: 1.6; }
.w-num { fill: var(--texto-suave); font-size: 12px; font-family: inherit; paint-order: stroke; stroke: var(--superficie); stroke-width: 3px; }
.w-curva { stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.w-curva.a { stroke: var(--ca); } .w-curva.b { stroke: var(--cb); } .w-curva.c { stroke: var(--cc); } .w-curva.d { stroke: var(--cd); }
.w-leyenda > .a { color: var(--ca); } .w-leyenda > .b { color: var(--cb); } .w-leyenda > .c { color: var(--cc); } .w-leyenda > .d { color: var(--cd); }
.w-guia { stroke: var(--texto-suave); stroke-dasharray: 5 4; stroke-width: 1.4; }
.w-punto { fill: var(--cb); stroke: var(--superficie); stroke-width: 2; }
.w-marca { fill: var(--superficie); stroke: var(--texto); stroke-width: 2.5; }
.w-coord { fill: var(--texto); font-size: 13px; font-weight: 650; font-family: inherit; paint-order: stroke; stroke: var(--superficie); stroke-width: 4px; }
.w-parte { fill: var(--superficie); stroke: var(--texto-suave); stroke-width: 1.4; transition: fill .25s; }
.w-parte.fina { stroke-dasharray: 3 3; }
.w-parte.lleno { fill: var(--ca); opacity: .85; }
.w-borde-entero { fill: none; stroke: var(--texto); stroke-width: 2.5; }
.w-universo { fill: var(--superficie); stroke: var(--texto-suave); stroke-width: 1.5; }
.w-zona { fill: var(--cb); opacity: .38; }
.w-zona-suave { fill: var(--cb); opacity: .12; }
.w-velo { fill: var(--fondo); opacity: .8; }
.w-contorno { stroke-width: 3; }
.ca-trazo { stroke: var(--ca); } .cb-trazo { stroke: var(--cc); }
.w-rotulo { font-size: 17px; font-weight: 700; font-family: inherit; }
.ca-relleno { fill: var(--ca); } .cb-relleno { fill: var(--cc); }
.w-conteo { fill: var(--texto); font-size: 24px; font-weight: 750; font-family: inherit; }
.w-conteo-chico { fill: var(--texto-suave); font-size: 13px; font-family: inherit; }
.w-rayo { stroke: var(--ca); stroke-width: 7; stroke-linecap: round; opacity: .75; }
.w-extremo { fill: var(--superficie); stroke: var(--ca); stroke-width: 3; }
.w-extremo.cerrado { fill: var(--ca); }
.w-prueba-ok { fill: var(--bien); } .w-prueba-mal { fill: var(--mal); }
.w-barra { fill: var(--borde); transition: fill .3s; }
.w-barra.activa { fill: var(--ca); }
.w-nodo { fill: var(--texto); }
.w-rama { stroke: var(--texto-suave); stroke-width: 2; }
.w-rotulo-chico { fill: var(--texto); font-size: 14px; font-weight: 600; font-family: inherit; }
.w-hoja { cursor: pointer; }
.w-hoja-fondo { fill: var(--superficie-2); stroke: var(--borde); stroke-width: 1.5; }
.w-hoja.activa .w-hoja-fondo { fill: var(--acento-fondo); stroke: var(--acento); stroke-width: 2.5; }
.w-hoja:focus-visible { outline: none; }
.w-hoja:focus-visible .w-hoja-fondo { stroke: var(--acento); stroke-width: 3; }

/* ----------------------------------------- cálculo, vectores y distribuciones */
.w-area { fill: var(--ca); opacity: .22; }
.w-semiplano { fill: var(--ca); opacity: .2; shape-rendering: crispEdges; }
.w-curva.punteada { stroke-dasharray: 7 5; }
.w-rect { fill: var(--cc); fill-opacity: .25; stroke: var(--cc); stroke-width: 1.2; }
.w-poligonal { fill: none; stroke: var(--cb); stroke-width: 2.4; stroke-linejoin: round; }
.w-residuo { stroke: var(--cb); stroke-width: 2.2; stroke-dasharray: 4 3; }
.w-muestra-guia { stroke: var(--cb); stroke-opacity: .45; stroke-width: 1; stroke-dasharray: 3 3; }
.w-tangente { stroke: var(--cb); stroke-width: 2.4; stroke-dasharray: 8 5; }
.w-marca-b { fill: var(--superficie); stroke: var(--cb); stroke-width: 2.5; }
.w-hueco { fill: var(--superficie); stroke: var(--cb); stroke-width: 2.5; }
.w-vector { stroke-width: 3.2; stroke-linecap: round; }
.w-vector.a { stroke: var(--ca); } .w-vector.b { stroke: var(--cb); } .w-vector.c { stroke: var(--cc); } .w-vector.d { stroke: var(--cd); }
.w-vector.suave { stroke-width: 2; stroke-dasharray: 6 4; opacity: .7; }
.w-punta.a path { fill: var(--ca); } .w-punta.b path { fill: var(--cb); } .w-punta.c path { fill: var(--cc); } .w-punta.d path { fill: var(--cd); } .w-punta.n path { fill: var(--texto); }
.w-rotulo-vector { font-size: 15px; font-weight: 700; font-family: inherit; paint-order: stroke; stroke: var(--superficie); stroke-width: 4px; }
.w-rotulo-vector.a { fill: var(--ca); } .w-rotulo-vector.b { fill: var(--cb); } .w-rotulo-vector.c { fill: var(--cc); } .w-rotulo-vector.d { fill: var(--cd); }
.w-grilla-t { stroke: var(--ca); stroke-width: 1; opacity: .28; }
.w-cuadrado { fill: none; stroke: var(--texto-suave); stroke-width: 1.5; stroke-dasharray: 4 3; }
.w-paralelogramo { fill: var(--cc); opacity: .3; stroke: var(--cc); stroke-width: 2; }
.w-media { stroke: var(--cb); stroke-width: 2.5; stroke-dasharray: 6 4; }
.w-desvio { stroke: var(--cb); stroke-width: 3; opacity: .6; }

/* -------------------------------------- campo (dos variables) y álgebra lineal */
.w-campo { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; align-items: flex-start; }
.w-campo > svg { flex: 1 1 320px; max-width: 480px; }
.w-vista3d { cursor: grab; touch-action: none; }
.w-vista3d:active { cursor: grabbing; }
.w-arrastrable { cursor: crosshair; touch-action: none; }
.w-calor { opacity: .78; }
.w-grilla.tenue { opacity: .35; }
.w-nivel { fill: none; stroke: #fff; stroke-opacity: .85; stroke-width: 1.3; }
.w-restriccion { fill: none; stroke: var(--cd); stroke-width: 3.5; stroke-linecap: round; }
.w-restriccion3d { fill: none; stroke: var(--cd); stroke-width: 3; stroke-linecap: round; }
.w-region { fill: var(--cb); fill-opacity: .28; stroke: var(--cb); stroke-width: 1; }
.w-region-centro { fill: var(--cb); }
.w-nube { fill: var(--ca); fill-opacity: .55; stroke: var(--superficie); stroke-width: .6; }
.w-camino { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.w-camino.a { stroke: var(--ca); } .w-camino.b { stroke: var(--cb); } .w-camino.c { stroke: var(--cc); } .w-camino.d { stroke: var(--cd); }
.w-camino-punto { stroke: var(--superficie); stroke-width: 1.5; }
.w-camino-punto.a { fill: var(--ca); } .w-camino-punto.b { fill: var(--cb); } .w-camino-punto.c { fill: var(--cc); } .w-camino-punto.d { fill: var(--cd); }
.w-corte { stroke: var(--cb); stroke-width: 2; stroke-dasharray: 7 5; }
.w-corte3d { fill: none; stroke: var(--cb); stroke-width: 3.2; stroke-linecap: round; }
.w-base3d { fill: none; stroke: var(--texto-suave); stroke-width: 1.3; stroke-dasharray: 5 4; }
.w-superficie { stroke: rgba(0, 0, 0, .18); stroke-width: .6; }
.w-caja-tapa { fill: var(--cb); fill-opacity: .8; stroke: var(--superficie); stroke-width: .8; }
.w-caja-lado { fill: var(--cb); fill-opacity: .5; stroke: var(--superficie); stroke-width: .8; }
.w-nota { color: var(--texto-suave); font-size: .88rem; margin: .4rem 0 0; }
.w-giro > span { font-weight: 600; } .w-giro input { grid-column: 2 / -1; }
.w-generado { stroke: var(--cd); stroke-width: 2.4; stroke-dasharray: 9 6; opacity: .75; }
.w-generado-plano { fill: var(--cd); opacity: .07; }
.w-rastro { fill: var(--cc); opacity: .55; }
.w-objetivo { fill: none; stroke: var(--cd); stroke-width: 3; stroke-dasharray: 4 3; }
.w-angulo-recto { fill: none; stroke: var(--texto); stroke-width: 1.6; }
.w-autorrecta { stroke: var(--texto); stroke-width: 2; stroke-dasharray: 3 5; opacity: .75; }
.w-rotulo-auto { fill: var(--texto); font-size: 14px; font-weight: 700; font-family: inherit; paint-order: stroke; stroke: var(--superficie); stroke-width: 4px; }
.w-circulo { fill: none; stroke: var(--texto-suave); stroke-width: 1.6; stroke-dasharray: 5 4; }
.w-elipse { fill: var(--cc); fill-opacity: .18; stroke: var(--cc); stroke-width: 2.4; }

/* ------------------------------------------------------------ código Python */
:root { --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; --py-kw: #a626a4; --py-str: #2f7d32; --py-num: #b45309; --py-com: #6b7280; --py-fn: #1f5fbf; --codigo-fondo: #f3f1ec; }
@media (prefers-color-scheme: dark) { :root { --py-kw: #d39cf0; --py-str: #8fd694; --py-num: #f3b36b; --py-com: #8b949e; --py-fn: #7fb2ff; --codigo-fondo: #161a1e; } }
.py-kw { color: var(--py-kw); font-weight: 650; } .py-str { color: var(--py-str); } .py-num { color: var(--py-num); }
.py-com { color: var(--py-com); font-style: italic; } .py-fn { color: var(--py-fn); }
pre.codigo, .w-lineas, .w-salida, .w-editor-texto, .w-error pre { font-family: var(--mono); font-size: .92rem; line-height: 1.55; }
pre.codigo { background: var(--codigo-fondo); border: 1px solid var(--borde); border-radius: 10px; padding: .8rem 1rem; overflow-x: auto; tab-size: 4; }
pre.w-numpy { margin: .7rem 0 0; font-size: .85rem; white-space: pre; }
pre.codigo code, .w-lineas code { background: none; padding: 0; border: 0; border-radius: 0; font-size: inherit; }
code.codigo-linea { font-family: var(--mono); font-size: .92em; background: var(--codigo-fondo); border: 1px solid var(--borde); border-radius: 5px; padding: .05em .35em; }
.w-codigo { outline: none; }
.w-codigo:focus-visible { box-shadow: 0 0 0 3px var(--acento); border-radius: 10px; }
.w-codigo-vista { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .8rem; align-items: start; }
@media (max-width: 760px) { .w-codigo-vista { grid-template-columns: 1fr; } }
.w-lineas { list-style: none; margin: 0; padding: .6rem 0; background: var(--codigo-fondo); border: 1px solid var(--borde); border-radius: 10px; overflow-x: auto; counter-reset: none; }
.w-linea { display: grid; grid-template-columns: 2.4rem 1.4rem auto; align-items: baseline; padding: 0 .6rem 0 0; white-space: pre; border-left: 3px solid transparent; }
.w-linea-n { color: var(--texto-suave); text-align: right; padding-right: .4rem; user-select: none; font-size: .85em; }
.w-linea-marca { color: var(--acento); font-weight: 800; text-align: center; }
.w-linea.actual { background: color-mix(in srgb, var(--acento) 16%, transparent); border-left-color: var(--acento); }
.w-linea.actual .w-linea-marca::before { content: "➜"; }
.w-linea.anterior { background: color-mix(in srgb, var(--cc) 12%, transparent); }
.w-linea.con-error { background: color-mix(in srgb, #dc2626 18%, transparent); border-left-color: #dc2626; }
.w-linea.con-error .w-linea-marca::before { content: "✗"; color: #dc2626; }
.w-estado { border: 1px solid var(--borde); border-radius: 10px; padding: .6rem .8rem; background: var(--superficie); min-height: 8rem; }
.w-estado h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-suave); margin: .2rem 0 .4rem; }
.w-estado h3 + * { margin-top: 0; }
.w-marco { border: 1px solid var(--borde); border-radius: 8px; padding: .35rem .5rem; margin-bottom: .5rem; }
.w-marco.activo { border-color: var(--acento); }
.w-marco-nombre { font-size: .8rem; font-weight: 700; color: var(--texto-suave); margin-bottom: .2rem; }
.w-marco dl { margin: 0; display: grid; gap: .15rem; }
.w-var { display: grid; grid-template-columns: auto 1fr; gap: .5rem; align-items: baseline; border-radius: 5px; padding: .05rem .3rem; transition: background-color .4s; }
.w-var dt { font-family: var(--mono); font-weight: 700; }
.w-var dt::after { content: " ="; font-weight: 400; color: var(--texto-suave); }
.w-var dd { margin: 0; font-family: var(--mono); white-space: pre-wrap; word-break: break-word; }
.w-var.cambio { background: color-mix(in srgb, #f59e0b 26%, transparent); }
.w-devuelve { font-family: var(--mono); font-weight: 650; color: var(--cc); margin: .2rem 0 .5rem; }
.w-vacio { color: var(--texto-suave); font-size: .9rem; margin: 0 0 .5rem; }
.w-salida { background: #10151a; color: #e6edf3; border-radius: 8px; padding: .5rem .7rem; margin: 0; white-space: pre-wrap; word-break: break-word; min-height: 1.6rem; max-height: 18rem; overflow: auto; }
.w-salida.vacia { color: #8b949e; font-style: italic; }
.w-contador { align-self: center; font-variant-numeric: tabular-nums; font-weight: 650; min-width: 7.5rem; text-align: center; }
.w-botones button:disabled { opacity: .4; cursor: default; }
.w-botones button.principal { background: var(--acento); color: #fff; }
@media (prefers-color-scheme: dark) { .w-botones button.principal { color: #0d1620; } }
.w-paso-texto { min-height: 3em; }
.w-editor { margin-top: .8rem; border-top: 1px dashed var(--borde); padding-top: .8rem; }
.w-editor-texto { width: 100%; box-sizing: border-box; background: var(--codigo-fondo); color: var(--texto); border: 1px solid var(--borde); border-radius: 10px; padding: .7rem .9rem; resize: vertical; tab-size: 4; white-space: pre; }
.w-editor-texto:focus { outline: 2px solid var(--acento); outline-offset: 1px; }
.w-editor-estado { color: var(--texto-suave); font-size: .9rem; margin: .4rem 0; min-height: 1.2em; }
.w-atajo { align-self: center; color: var(--texto-suave); font-size: .8rem; }
.w-error { border: 1px solid #dc2626; border-radius: 8px; padding: .5rem .7rem; margin-top: .5rem; background: color-mix(in srgb, #dc2626 8%, transparent); }
.w-error pre { margin: 0 0 .4rem; white-space: pre-wrap; color: #dc2626; }
.w-error p { margin: 0; }
.w-imagenes img { max-width: 100%; margin-top: .6rem; border-radius: 8px; background: #fff; }

/* ---------------------------------------------- datos y modelos (ML clásico) */
.w-fondo-datos { image-rendering: auto; }
.w-dato { --g: var(--texto-suave); fill: var(--g); stroke: var(--superficie); stroke-width: 1.4; }
.w-dato.g0 { --g: var(--ca); } .w-dato.g1 { --g: var(--cb); } .w-dato.g2 { --g: var(--cc); }
.w-dato.g3 { --g: var(--cd); } .w-dato.g4 { --g: var(--ce); } .w-dato.g5 { --g: var(--cf); }
.w-dato.sin { fill: var(--texto-suave); opacity: .7; }
.w-dato.prueba { fill: var(--superficie); stroke: var(--g); stroke-width: 2.4; }
.w-dato-error { fill: none; stroke: var(--texto); stroke-width: 1.6; }
.w-frontera { stroke: var(--texto); stroke-width: 2.6; }
.w-margen { stroke: var(--texto); stroke-width: 1.4; stroke-dasharray: 6 5; opacity: .75; }
.w-neurona { stroke: var(--texto-suave); stroke-width: 1.2; stroke-dasharray: 3 4; opacity: .8; }
.w-optimo { stroke: var(--cd); stroke-width: 2.4; stroke-dasharray: 8 6; }
.w-vecino { stroke: var(--texto); stroke-width: 1.3; opacity: .6; }
.w-radio { fill: none; stroke: var(--texto); stroke-width: 1.3; stroke-dasharray: 4 4; opacity: .7; }
.w-consulta { fill: var(--superficie); stroke-width: 3.5; }
.w-consulta.g0 { stroke: var(--ca); } .w-consulta.g1 { stroke: var(--cb); }
.w-centro { stroke: var(--texto); stroke-width: 2; }
.w-centro.g0 { fill: var(--ca); } .w-centro.g1 { fill: var(--cb); } .w-centro.g2 { fill: var(--cc); }
.w-centro.g3 { fill: var(--cd); } .w-centro.g4 { fill: var(--ce); } .w-centro.g5 { fill: var(--cf); }
.w-rastro { fill: none; stroke-width: 2; stroke-dasharray: 3 3; stroke: var(--texto); opacity: .65; }
.w-modelo { fill: none; stroke: var(--cb); stroke-width: 2.6; }
.w-verdad { fill: none; stroke: var(--texto-suave); stroke-width: 1.8; stroke-dasharray: 7 5; }
.w-proyeccion { stroke: var(--cd); stroke-width: 1.2; opacity: .55; }
.w-pie { fill: var(--cd); }
.w-panel { flex: 1 1 260px; max-width: 340px; }
.w-panel-titulo { font-size: 13px; font-weight: 650; fill: var(--texto); }
.w-panel-linea { fill: none; stroke-width: 2.4; }
.w-panel-linea.a { stroke: var(--ca); } .w-panel-linea.b { stroke: var(--cb); } .w-panel-linea.c { stroke: var(--cc); } .w-panel-linea.d { stroke: var(--cd); }
.w-panel-linea.guia { stroke: var(--texto-suave); stroke-width: 1.2; stroke-dasharray: 4 4; }
.w-panel-marca { stroke: var(--superficie); stroke-width: 2; }
.w-panel-marca.a { fill: var(--ca); } .w-panel-marca.b { fill: var(--cb); } .w-panel-marca.c { fill: var(--cc); } .w-panel-marca.d { fill: var(--cd); }
.w-leyenda > .n { color: var(--texto-suave); }

/* --------------------------------------------------------------- convolución y mapa de calor */
.w-conv svg, .w-calor svg { width: 100%; max-width: 720px; height: auto; display: block; margin: 0 auto; }
.w-calor svg { max-width: 460px; }
.w-celda { fill: var(--superficie); stroke: var(--borde); stroke-width: 1; }
.w-celda.relleno { fill: var(--superficie-2); stroke-dasharray: 2 2; }
.w-celda-valor { stroke: none; pointer-events: none; }
.w-celda-valor.pos { fill: var(--ca); } .w-celda-valor.neg { fill: var(--cb); }
.w-celda-num { font-size: 11px; fill: var(--texto); pointer-events: none; font-variant-numeric: tabular-nums; }
.w-calor .w-celda-num { font-size: 13px; }
.w-celda-num.claro { fill: #fff; }
.w-ventana { fill: none; stroke: var(--texto); stroke-width: 2.6; pointer-events: none; }
.w-celda-sel { cursor: pointer; }
.w-celda-sel:focus-visible { outline: none; }
.w-celda-sel:focus-visible .w-celda { stroke: var(--texto); stroke-width: 2; }
.w-calor-rot { font-size: 14px; fill: var(--texto); }
.w-calor-rot.elegida { font-weight: 700; }

/* --------------------------------------------------------------- grafo de cómputo */
.w-grafo svg { width: 100%; max-width: 640px; height: auto; display: block; margin: 0 auto; }
.w-grafo-nodo rect { fill: var(--superficie); stroke: var(--borde); stroke-width: 1.4; transition: stroke .2s, fill .2s; }
.w-grafo-nodo.hoja rect { fill: var(--superficie-2); }
.w-grafo-nodo.actual rect { stroke: var(--cb); stroke-width: 3; }
.w-grafo-nodo.recibe rect { stroke: var(--ca); stroke-width: 2.4; }
.w-grafo-titulo { font-size: 13px; font-weight: 650; fill: var(--texto); }
.w-grafo-valor { font-size: 13px; fill: var(--texto); font-variant-numeric: tabular-nums; }
.w-grafo-grad { font-size: 12.5px; fill: var(--cb); font-weight: 650; font-variant-numeric: tabular-nums; }
.w-grafo-grad.vacio { fill: var(--texto-suave); font-weight: 400; }
.w-grafo-arista { fill: none; stroke: var(--texto-suave); stroke-width: 1.5; opacity: .7; }
.w-grafo-arista.activa { stroke: var(--cb); stroke-width: 2.6; opacity: 1; stroke-dasharray: 6 4; animation: w-grafo-fluir 0.9s linear infinite reverse; }
.w-grafo-punta { fill: var(--texto-suave); }
@keyframes w-grafo-fluir { to { stroke-dashoffset: 20; } }
@media (prefers-reduced-motion: reduce) { .w-grafo-arista.activa { animation: none; } }
@media (max-width: 520px) { .w-grafo ~ .w-formula .katex { font-size: 1.02em; } }

/* ------------------------------------- geometría, recta numérica y estadística */
.w-nota { text-align: center; color: var(--texto-suave); font-size: .85rem; margin: .1rem 0 .3rem; }
.w-geo-poligono { fill: currentColor; fill-opacity: .14; stroke: currentColor; stroke-width: 2.6; stroke-linejoin: round; }
.w-geo-poligono.sin-relleno { fill: none; }
.w-geo-poligono.cuadrado { fill-opacity: .1; stroke-width: 2; stroke-dasharray: 6 4; }
.w-geo-trazo { stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.w-geo-trazo.fino { stroke-width: 1.8; }
.w-geo-trazo.punteado { stroke-dasharray: 7 5; }
.w-geo-circulo { fill: none; stroke: currentColor; stroke-width: 2.2; }
.w-geo-circulo.relleno { fill: currentColor; fill-opacity: .1; }
.w-geo-sector { fill: currentColor; fill-opacity: .22; stroke: none; }
.w-geo-arco { fill: none; stroke: currentColor; stroke-width: 2; }
.w-geo-punta { fill: currentColor; stroke: none; }
.w-geo-punto { fill: currentColor; stroke: var(--superficie); stroke-width: 2; color: var(--texto); }
.w-geo-punto.manija { stroke-width: 3; filter: drop-shadow(0 0 3px rgba(0, 0, 0, .25)); }
.w-geo-nombre { font-size: 15px; font-style: italic; }
.w-geo-medida { font-size: 12.5px; font-weight: 600; }
.w-geo .a, .w-recta .a, .w-estad .a { color: var(--ca); }
.w-geo .b, .w-recta .b, .w-estad .b { color: var(--cb); }
.w-geo .c, .w-recta .c, .w-estad .c { color: var(--cc); }
.w-geo .d, .w-recta .d, .w-estad .d { color: var(--cd); }
.w-estad .e { color: var(--ce); } .w-estad .f { color: var(--cf); }
text.w-coord.a, text.w-coord.b, text.w-coord.c, text.w-coord.d { fill: currentColor; }
.w-recta-tramo { stroke: currentColor; stroke-width: 7; stroke-linecap: round; opacity: .55; }
.w-recta-menor { stroke: var(--texto-suave); stroke-width: 1; }
.w-recta-punta { fill: var(--texto-suave); }
.w-recta-salto { fill: none; stroke: currentColor; stroke-width: 2.6; }
.w-recta-llave { fill: none; stroke: var(--texto); stroke-width: 1.8; }
.w-recta-objetivo { stroke: var(--cb); stroke-width: 3; }
.w-recta .w-extremo { stroke: currentColor; }
.w-recta .w-extremo.cerrado { fill: currentColor; }
.w-num.entero { font-weight: 700; fill: var(--texto); }
.w-num.grande { font-size: 14px; }
.w-estad-dato { fill: var(--ca); stroke: var(--superficie); stroke-width: 1.5; cursor: grab; }
.w-estad-dato.moda { fill: var(--cd); }
.w-estad-media { fill: var(--cb); }
.w-estad-mediana { stroke: var(--cc); stroke-width: 2.4; stroke-dasharray: 6 4; }
.w-estad-mediana.fuerte { stroke-dasharray: none; stroke-width: 3; }
.w-estad-banda { fill: var(--cd); opacity: .12; }
.w-estad-caja { fill: var(--ca); fill-opacity: .15; stroke: var(--ca); stroke-width: 2.4; }
.w-estad-bigote { stroke: var(--ca); stroke-width: 2.4; }
.w-estad-barra { fill: var(--ca); opacity: .75; }
.w-estad-barra.suceso { fill: var(--cb); }
.w-estad-teorica { stroke: var(--texto); stroke-width: 2; stroke-dasharray: 5 3; }
.w-estad-sector { fill: currentColor; fill-opacity: .8; stroke: var(--superficie); stroke-width: 2; }
.w-azar-ultimo { font-weight: 650; color: var(--texto); }
svg.w-geo { display: block; margin: 0 auto; max-width: 100%; }
