/* ==========================================================================
   Guía de Probabilidad y Estadística — hoja única.

    1. Tokens
    2. Reset y base
    3. Topbar
    4. Layout
    5. Sidebar
    6. Botones y controles
    7. Componentes de contenido
    8. Fórmulas (KaTeX)
    9. Mapa de dependencias
   10. Inicio y cronograma
   11. Tablas estadísticas
   12. Señal de «esto se toca»
   13. Animaciones
   14. Responsive
   15. Impresión

   Reglas de la casa: nada de style="" en el marcado (los estados van por
   classList), el color nunca es la única señal, y todo lo que se puede
   tocar se puede tocar también con el teclado.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg:            #10141c;
  --bg-elev:       #171d28;
  --bg-sunken:     #0c1017;
  --bg-hover:      #1e2634;

  --text:          #e6ebf2;
  --text-soft:     #a8b3c4;
  --text-faint:    #76828f;

  --border:        #26303f;
  --border-strong: #3a4759;

  --accent:        #4fb3d9;
  --accent-hover:  #6ec7e8;
  --accent-soft:   #14313e;
  --accent-text:   #06222c;

  --ok:            #5fc98a;
  --ok-soft:       #12301f;
  --warn:          #e0b25a;
  --warn-soft:     #322612;
  --bad:           #e8737f;
  --bad-soft:      #33161a;
  --info:          #7aa7e8;
  --info-soft:     #16223a;

  /* Una por unidad. El mapa y el índice leen de acá. */
  --u1: #4fb3d9;
  --u2: #9d8cf0;
  --u3: #5fc98a;
  --u4: #e0b25a;
  --u5: #e8737f;
  --u6: #4fd9c4;
  --u7: #f09a5c;
  --u8: #c98ce0;
  --u-pronto: #6b7688;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 4px 14px rgba(0,0,0,.34), 0 1px 3px rgba(0,0,0,.22);
  --shadow-lg: 0 14px 36px rgba(0,0,0,.46);

  --sidebar-w:   292px;
  --topbar-h:    60px;
  --content-max: 880px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

:root[data-tema="claro"] {
  color-scheme: light;

  --bg:            #f7f8fb;
  --bg-elev:       #ffffff;
  --bg-sunken:     #eceef4;
  --bg-hover:      #e6e9f2;

  --text:          #171b24;
  --text-soft:     #4c5566;
  --text-faint:    #798292;

  --border:        #dde1ea;
  --border-strong: #bcc4d2;

  --accent:        #14657f;
  --accent-hover:  #0f4d61;
  --accent-soft:   #e0f0f6;
  --accent-text:   #ffffff;

  --ok:            #16794f;
  --ok-soft:       #dff3e8;
  --warn:          #8a5b00;
  --warn-soft:     #fbf0d6;
  --bad:           #b0202f;
  --bad-soft:      #fbe8ea;
  --info:          #1a5aa8;
  --info-soft:     #e3ecfa;

  --u1: #14657f;
  --u2: #5b3fbf;
  --u3: #16794f;
  --u4: #8a5b00;
  --u5: #b0202f;
  --u6: #0f6f63;
  --u7: #a2521a;
  --u8: #7c3f9e;
  --u-pronto: #8b93a2;

  --shadow-sm: 0 1px 2px rgba(20,25,45,.06), 0 1px 3px rgba(20,25,45,.05);
  --shadow-md: 0 4px 12px rgba(20,25,45,.09), 0 1px 3px rgba(20,25,45,.06);
  --shadow-lg: 0 12px 32px rgba(20,25,45,.16);
}

/* ---------- 2. Reset y base ---------------------------------------------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.62;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.85rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; margin-top: 2em; }
h3 { font-size: 1.08rem; margin-top: 1.6em; }
p  { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.35rem; }
li { margin: .3em 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .08em .34em;
}

strong { font-weight: 680; color: var(--text); }
em { font-style: italic; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

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

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 650; text-decoration: none;
  transition: top .18s var(--ease);
}
.skip-link:focus { top: 8px; color: var(--accent-text); }

noscript .aviso-nojs {
  max-width: 780px; margin: 40px auto; padding: 0 24px;
}

/* ---------- 3. Topbar ---------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; min-width: 0;
}
.brand-mark {
  flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font-weight: 800; font-size: .82rem; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: .95rem; line-height: 1.2; }
.brand-text small { font-size: .74rem; color: var(--text-faint); line-height: 1.3; }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1.05rem;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.menu-toggle { display: none; }
.burger, .burger::before, .burger::after {
  display: block; width: 17px; height: 2px;
  background: currentColor; border-radius: 2px;
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after  { top:  6px; }

.progreso-caja { display: flex; align-items: center; gap: 8px; }
.progreso-barra {
  width: 92px; height: 7px; border-radius: 99px;
  background: var(--bg-sunken); overflow: hidden;
  border: 1px solid var(--border);
}
.progreso-relleno {
  display: block; height: 100%; width: 0;
  background: var(--ok);
  transition: width .4s var(--ease);
}
.progreso-texto {
  font-size: .78rem; color: var(--text-soft);
  font-variant-numeric: tabular-nums; min-width: 2.6em;
}

/* ---------- 4. Layout ---------------------------------------------------- */

.layout { display: flex; align-items: flex-start; }

.contenido {
  flex: 1; min-width: 0;
  padding: 30px 32px 90px;
  max-width: calc(var(--content-max) + 64px);
  margin: 0 auto;
}
.contenido:focus { outline: none; }

#vista > * { animation: entrar .22s var(--ease) both; }

/* ---------- 5. Sidebar --------------------------------------------------- */

.sidebar {
  flex: none;
  width: var(--sidebar-w);
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 16px 12px 40px;
}

.buscador { padding: 0 4px 12px; }
.buscador input {
  width: 100%;
  font: inherit; font-size: .9rem;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}
.buscador input::placeholder { color: var(--text-faint); }

.nav-grupo { margin-bottom: 18px; }
.nav-grupo > h3 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); margin: 0 0 6px 8px; font-weight: 700;
}
.nav-lista, .nav-temas { list-style: none; margin: 0; padding: 0; }
.nav-lista a, .nav-temas a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--text-soft); text-decoration: none;
}
.nav-lista a:hover, .nav-temas a:hover { background: var(--bg-hover); color: var(--text); }
.nav-lista a.activo, .nav-temas a.activo {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 620;
}

.unidad-bloque { margin-bottom: 4px; }
.unidad-btn {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: .875rem; font-weight: 620;
  text-align: left; cursor: pointer;
}
.unidad-btn:hover { background: var(--bg-hover); }
.unidad-btn[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.unidad-btn[disabled] { color: var(--text-faint); cursor: default; }
.unidad-btn[disabled]:hover { background: transparent; }

.chevron {
  flex: none; width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .18s var(--ease);
  opacity: .6;
}
.romano {
  flex: none; width: 26px;
  font-size: .68rem; font-weight: 800; letter-spacing: .04em;
  color: var(--u); text-align: center;
}
.unidad-btn .titulin { flex: 1; min-width: 0; }
.avance-mini {
  flex: none; font-size: .68rem; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.insignia {
  flex: none;
  font-size: .6rem; font-weight: 750; text-transform: uppercase;
  letter-spacing: .05em; padding: 2px 6px; border-radius: 99px;
  border: 1px solid var(--border-strong); color: var(--text-faint);
}
.insignia.pronto { color: var(--u-pronto); }
.insignia.nueva  { background: var(--ok); border-color: var(--ok); color: #06241a; }

.nav-temas { margin: 2px 0 8px; padding: 0 0 0 8px; }
.nav-temas a { padding-left: 12px; font-size: .845rem; line-height: 1.35; }

/* El punto de estado: color + FORMA, para que no dependa del color solo. */
.punto {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
}
.punto.leido    { border-color: var(--info); background: var(--info); }
.punto.aprobado { border-color: var(--ok);   background: var(--ok); }
.punto.dominado {
  border-color: var(--ok); background: var(--ok);
  box-shadow: 0 0 0 2px var(--ok-soft);
  border-radius: 2px;                       /* cuadrado: distinto en forma */
}

.sidebar-pie {
  margin-top: 22px; padding: 12px 10px 0;
  border-top: 1px solid var(--border);
}

/* ---------- 6. Botones y controles --------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  font: inherit; font-size: .88rem; font-weight: 620;
  color: var(--accent-text); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s var(--ease);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn[disabled] { opacity: .5; cursor: default; }

.btn.suave {
  background: transparent; color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn.suave:hover { background: var(--bg-hover); color: var(--text); }

.fila-btn { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

/* ---------- 7. Componentes de contenido ---------------------------------- */

.tema-cabecera { margin-bottom: 26px; }
.migas {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: .78rem; color: var(--text-faint); margin-bottom: 10px;
}
.migas a { color: var(--text-soft); text-decoration: none; }
.migas a:hover { color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 650;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border-strong); color: var(--text-soft);
  background: var(--bg-elev);
}
.chip.unidad { color: var(--u); border-color: var(--u); }

.bajada { font-size: 1.06rem; color: var(--text-soft); margin-bottom: 4px; }

.callout {
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--info);
  background: var(--info-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 20px 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout .rotulo {
  display: block; font-size: .72rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--info); margin-bottom: 5px;
}
.callout.ojo   { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.ojo   .rotulo { color: var(--warn); }
.callout.clave { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.clave .rotulo { color: var(--ok); }
.callout.error { border-left-color: var(--bad); background: var(--bad-soft); }
.callout.error .rotulo { color: var(--bad); }

.analogia {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 20px 0;
  background: var(--bg-elev);
}
.analogia .rotulo {
  display: block; font-size: .72rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: 5px;
}

.conceptos { display: grid; gap: 12px; margin: 20px 0; }
.concepto {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 12px 14px;
}
.concepto dt { font-weight: 680; margin-bottom: 3px; }
.concepto dd { margin: 0; color: var(--text-soft); font-size: .94rem; }

.grid3 { display: grid; gap: 14px; margin: 20px 0; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid3 .celda {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 13px 15px;
}
.grid3 .celda h4 { margin: 0 0 5px; font-size: .95rem; }
.grid3 .celda p { margin: 0; font-size: .9rem; color: var(--text-soft); }

.compare { display: grid; gap: 14px; margin: 20px 0; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.compare .lado {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; background: var(--bg-elev);
}
.compare .lado.si { border-left: 4px solid var(--ok); }
.compare .lado.no { border-left: 4px solid var(--bad); }
.compare .lado h4 { margin: 0 0 6px; font-size: .95rem; }

.tabla-envoltura { overflow-x: auto; margin: 20px 0; }
table.datos {
  border-collapse: collapse; width: 100%; font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
/* Alineación a la izquierda: la mayoría de estas tablas mezclan prosa con
   números, y con prosa el alineado a la derecha se lee pésimo. Los números
   igual quedan prolijos por `tabular-nums` en la tabla. */
table.datos th, table.datos td {
  border: 1px solid var(--border);
  padding: 7px 11px; text-align: left; vertical-align: top;
}
table.datos th {
  background: var(--bg-sunken); font-weight: 680; color: var(--text);
}
table.datos tr.total td { font-weight: 700; background: var(--bg-sunken); }
table.datos caption {
  caption-side: bottom; font-size: .78rem; color: var(--text-faint);
  padding-top: 8px; text-align: left;
}

.fuente {
  font-size: .78rem; color: var(--text-faint);
  border-top: 1px solid var(--border);
  margin-top: 30px; padding-top: 10px;
}

.aviso-origen {
  border: 1px solid var(--warn); border-left: 4px solid var(--warn);
  background: var(--warn-soft); border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 20px; font-size: .88rem;
}

.deps { display: grid; gap: 12px; margin: 26px 0; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.caja-dep {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; background: var(--bg-elev);
}
.caja-dep h4 {
  margin: 0 0 8px; font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint);
}
.caja-dep ul { list-style: none; margin: 0; padding: 0; }
.caja-dep li { margin: 4px 0; }
.caja-dep a { font-size: .875rem; text-decoration: none; }
.caja-dep a:hover { text-decoration: underline; }

.paginacion {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border);
}
.paginacion a {
  flex: 1; max-width: 46%;
  display: block; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none; color: inherit; background: var(--bg-elev);
}
.paginacion a:hover { border-color: var(--accent); }
.paginacion .dir { display: block; font-size: .72rem; color: var(--text-faint); }
.paginacion .tit { display: block; font-size: .9rem; font-weight: 620; }
.paginacion .siguiente { text-align: right; margin-left: auto; }

.notas-tema { margin: 30px 0 0; }
.notas-tema label {
  display: block; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: 6px;
}
.notas-tema textarea {
  width: 100%; min-height: 90px; resize: vertical;
  font: inherit; font-size: .9rem; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}

.esqueleto { color: var(--text-faint); font-size: .9rem; padding: 24px 0; }

/* ---------- 8. Fórmulas (KaTeX) ------------------------------------------ */

.katex { font-size: 1.05em; }
.katex-bloque {
  margin: 18px 0; padding: 4px 0;
  overflow-x: auto; overflow-y: hidden;
}

figure.formula {
  margin: 22px 0; padding: 14px 16px;
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  overflow-x: auto;
}
figure.formula .ref {
  float: right; font-size: .68rem; font-weight: 750;
  color: var(--text-faint); font-family: var(--mono);
}
figure.formula figcaption {
  margin-top: 8px; font-size: .84rem; color: var(--text-soft);
}

.derivacion { margin: 22px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.derivacion .paso {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px; align-items: center;
  padding: 11px 15px; border-bottom: 1px solid var(--border);
}
.derivacion .paso:last-child { border-bottom: 0; }
.derivacion .paso:nth-child(odd) { background: var(--bg-elev); }
.derivacion .porque { font-size: .88rem; color: var(--text-soft); }
.derivacion .lado-tex { overflow-x: auto; }

/* ---------- 9. Mapa de dependencias -------------------------------------- */

.mapa-envoltura {
  overflow-x: auto; overflow-y: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); padding: 12px;
  margin: 22px 0;
}
/* El SVG conserva su ancho natural y el contenedor scrollea. Si se lo
   clampa, el navegador lo escala y los nodos quedan ilegibles. */
.mapa-envoltura svg { display: block; }

.nodo { cursor: pointer; }
.nodo rect {
  fill: var(--bg-sunken);
  stroke: var(--u, var(--border-strong));
  stroke-width: 1.6;
  transition: fill .15s var(--ease);
}
.nodo:hover rect { fill: var(--bg-hover); }
.nodo:focus-visible rect { stroke-width: 3; }
.nodo text { fill: var(--text); font-size: 11px; pointer-events: none; }
.nodo.leido    rect { stroke: var(--info); stroke-width: 2.2; }
.nodo.aprobado rect { stroke: var(--ok);   stroke-width: 2.2; }
.nodo.dominado rect { stroke: var(--ok);   stroke-width: 2.8; fill: var(--ok-soft); }
.nodo.pronto   rect { stroke-dasharray: 4 3; opacity: .62; }
.nodo.actual   rect { fill: var(--accent-soft); stroke-width: 3; }
.arista { stroke: var(--border-strong); stroke-width: 1.3; fill: none; opacity: .75; }
.arista.resaltada { stroke: var(--accent); stroke-width: 2.2; opacity: 1; }

.leyenda-mapa {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: .8rem; color: var(--text-soft); margin-top: 12px;
}
.leyenda-mapa span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 10. Inicio y cronograma -------------------------------------- */

.hero { margin-bottom: 30px; }
.hero h1 { margin-bottom: .2em; }
.hero .sub { font-size: 1.04rem; color: var(--text-soft); }
.hero .meta { font-size: .85rem; color: var(--text-faint); margin-top: 6px; }

.tarjetas { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); margin: 24px 0; }
.tarjeta {
  position: relative; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); padding: 17px 18px;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), border-color .16s var(--ease);
  overflow: hidden;
}
.tarjeta::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--u, var(--accent));
}
.tarjeta:hover { transform: translateY(-3px); border-color: var(--u, var(--accent)); }
.tarjeta.inerte { opacity: .62; }
.tarjeta.inerte:hover { transform: none; border-color: var(--border); }
/* La insignia va en la esquina, no como bloque al pie de la tarjeta. */
.tarjeta > .insignia { position: absolute; top: 13px; right: 13px; }
.tarjeta h3 { padding-right: 62px; }
.tarjeta .rom { font-size: .7rem; font-weight: 800; letter-spacing: .07em; color: var(--u); }
.tarjeta h3 { margin: 3px 0 6px; font-size: 1.02rem; }
.tarjeta p { margin: 0 0 12px; font-size: .875rem; color: var(--text-soft); flex: 1; }
.tarjeta .pie {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: .76rem; color: var(--text-faint);
}
.barra-mini {
  flex: 1; height: 5px; border-radius: 99px;
  background: var(--bg-sunken); overflow: hidden; border: 1px solid var(--border);
}
.barra-mini span { display: block; height: 100%; background: var(--u, var(--accent)); }

.panel-proxima {
  border: 1px solid var(--border-strong); border-left: 4px solid var(--accent);
  border-radius: var(--radius); background: var(--bg-elev);
  padding: 16px 18px; margin: 22px 0;
}
.panel-proxima h2 { margin: 0 0 4px; font-size: 1rem; }
.cuenta-regresiva {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px;
}
.cuenta-regresiva div { font-size: .84rem; color: var(--text-soft); }
.cuenta-regresiva strong {
  display: block; font-size: 1.5rem; line-height: 1.1;
  color: var(--accent); font-variant-numeric: tabular-nums;
}

table.crono { border-collapse: collapse; width: 100%; font-size: .875rem; }
table.crono th, table.crono td {
  border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left;
}
table.crono th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
table.crono tr.parcial td { background: var(--bad-soft); font-weight: 650; }
table.crono tr.repaso td  { background: var(--warn-soft); }
table.crono tr.final td   { background: var(--accent-soft); font-weight: 650; }
table.crono tr.dictada td { color: var(--text-faint); }
table.crono tr.dictada td.n::after { content: " ✓"; color: var(--ok); }
table.crono td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Los temas que toca cada bloque del plan. El punto es el mismo del índice,
   así que el estado de progreso se lee sin cambiar de página. */
table.crono p.plan-temas { margin: 8px 0 0; line-height: 2; }
table.crono p.plan-temas a {
  display: inline-block; margin-right: 4px; padding: 1px 7px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: .8rem; text-decoration: none;
}
table.crono p.plan-temas a:hover { border-color: var(--accent); }
table.crono p.plan-temas .punto { margin-right: 3px; vertical-align: baseline; }
table.crono tr.parcial td strong { display: block; }

/* ---------- 11. Tablas estadísticas -------------------------------------- */

.tarjeta-z {
  display: grid; gap: 12px; margin: 20px 0;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.z-clave {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 12px 14px; text-align: center;
}
.z-clave b {
  display: block; font-size: 1.5rem; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.z-clave span { font-size: .8rem; color: var(--text-soft); }

table.tabla-z { border-collapse: collapse; font-size: .78rem; font-variant-numeric: tabular-nums; }
table.tabla-z th, table.tabla-z td {
  border: 1px solid var(--border); padding: 3px 6px; text-align: right;
}
table.tabla-z thead th, table.tabla-z tbody th {
  background: var(--bg-sunken); font-weight: 700; position: sticky;
}
table.tabla-z thead th { top: 0; }
table.tabla-z td.resaltada { background: var(--accent); color: var(--accent-text); font-weight: 700; }
table.tabla-z tr.resaltada th, table.tabla-z col.resaltada { background: var(--accent-soft); }

/* ---------- 12. Señal de «esto se toca» ---------------------------------- */

.attn {
  animation: latido 2.4s var(--ease) infinite;
  animation-delay: calc(var(--attn-i, 0) * .12s);
}
.tocado .attn { animation: none; }

/* ---------- 13. Animaciones ---------------------------------------------- */

@keyframes entrar {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
@keyframes latido {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50%      { box-shadow: 0 0 0 5px var(--accent-soft); }
}

/* La señal no se elimina: se vuelve estática. Sacar el anillo dejaría al
   usuario sin saber qué se puede tocar. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .attn { box-shadow: 0 0 0 2px var(--accent); }
}

/* ---------- 14. Responsive ----------------------------------------------- */

@media (max-width: 980px) {
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 45;
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.abierta { transform: none; }
  #scrim {
    position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 44;
    background: rgba(0, 0, 0, .5);
  }
  #scrim[hidden] { display: none; }
  .contenido { padding: 24px 20px 80px; }
}

@media (max-width: 720px) {
  .brand-text small { display: none; }
  .progreso-barra { width: 60px; }
  .derivacion .paso { grid-template-columns: 1fr; gap: 6px; }
  .paginacion { flex-direction: column; }
  .paginacion a { max-width: none; }
}

@media (max-width: 520px) {
  body { font-size: 15px; }
  .contenido { padding: 20px 14px 70px; }
  .progreso-caja { display: none; }
  h1 { font-size: 1.5rem; }
}

/* ---------- 15. Impresión ------------------------------------------------ */

@media print {
  :root {
    --bg: #fff; --bg-elev: #fff; --bg-sunken: #f4f4f4;
    --text: #000; --text-soft: #333; --text-faint: #555;
    --border: #bbb; --border-strong: #888; --accent: #000;
  }
  .topbar, .sidebar, #scrim, .btn, .fila-btn, .notas-tema,
  .paginacion, .buscador, .sidebar-pie { display: none !important; }
  .layout { display: block; }
  .contenido { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  .callout, .analogia, figure.formula, .concepto, .tarjeta,
  .derivacion .paso, table.datos tr { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  .mapa-envoltura { overflow: visible; }
  .katex-bloque, figure.formula, .tabla-envoltura { overflow: visible; }
  /* Lo desplegable se imprime abierto */
  details:not([open]) > *:not(summary) { display: revert !important; }
  details { break-inside: avoid; }
  .aviso-origen { border: 1.5px solid #000; background: #fff; }
  table.tabla-z { font-size: 8pt; }
  table.tabla-z td.resaltada { background: #ddd; color: #000; }
  .z-clave { border: 1px solid #000; }
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
