/* Herbario de impacto · composición de la matriz ambiental.
   La identidad (colores, letras, sellos, cinta, regla, lupa) está en tema.css;
   aquí va la composición de la página y el aspecto de lo que pinta js/. */

/* Nombres que usan las gráficas SVG de /proceso/ (js/graficas.js) */
:root {
  --tinta: var(--sx-color-tinta);
  --tinta-suave: var(--sx-color-tinta-suave);
  --cian: var(--sx-color-musgo);
  --rojo: var(--sx-color-cinta);
  --rojo-texto: var(--sx-color-carmin);
  --fuente: var(--sx-familia-texto);
  --fuente-num: var(--sx-familia-maquina);
}

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overflow-x: hidden; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { text-wrap: balance; }

.saltar {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  padding: .6rem 1rem; background: var(--sx-color-musgo-hondo); color: var(--sx-color-crema) !important;
  font: 700 .85rem var(--sx-familia-maquina); text-decoration: none;
}
.saltar:focus { top: 1rem; }
.visual-oculto {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ═══════════ Portada: foto del cuaderno fundida con la mesa ═══════════ */
.portada {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  min-height: clamp(560px, 46vw, 680px);
  isolation: isolate;
}
.portada-foto {
  grid-column: 2; grid-row: 1 / span 2;
  position: relative; margin: 0 0 0 -12vw; z-index: -1;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 30%), linear-gradient(180deg, #000 72%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent 0, #000 30%), linear-gradient(180deg, #000 72%, transparent 100%);
  mask-composite: intersect;
}
.portada-foto img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 60% 50%; }
:root[data-theme="dark"] .portada-foto img { filter: brightness(.72) saturate(.9); }
/* de noche, la mesa sin fibras: solo grano y la luz de la linterna */
:root[data-theme="dark"] .sx-raiz { background-image: var(--sx-degradado-luz-tarde), var(--sx-recurso-grano); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sx-raiz { background-image: var(--sx-degradado-luz-tarde), var(--sx-recurso-grano); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .portada-foto img { filter: brightness(.72) saturate(.9); } }

.barra {
  position: absolute; top: 1rem; right: clamp(1rem, 3vw, 2.5rem); left: clamp(1rem, 3vw, 2.5rem);
  display: flex; justify-content: flex-end; gap: .6rem; z-index: var(--sx-z-cabecera);
}
.marca {
  margin: 0 auto 0 0; display: flex; align-items: center; gap: .55rem;
  font: 400 1.05rem/1 var(--sx-familia-rotulo); letter-spacing: .06em; color: var(--sx-color-tinta);
}
.marca b { font: 700 .78rem/1 var(--sx-familia-maquina); color: var(--sx-color-carmin); letter-spacing: .08em; }
.marca-hoja { width: 18px; height: 32px; background: var(--sx-recurso-hoja) center/contain no-repeat; rotate: -24deg; }

.portada-texto {
  grid-column: 1; grid-row: 1;
  align-self: center;
  padding: 6.5rem 0 3rem clamp(1rem, 5vw, 5rem);
  max-width: 40rem;
  position: relative;
}
.antetitulo { margin-bottom: 1.1rem; max-width: 38ch; }
.portada-texto .sx-titulo { font-size: clamp(2.6rem, 5.4vw, 5.4rem); }
.bajada {
  max-width: 31rem; margin: 1.4rem 0 0;
  font-size: 1.12rem; line-height: 1.5; color: var(--sx-color-tinta-suave);
}
.pistas {
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin: 1.8rem 0 0; padding: 0; list-style: none;
  font: 400 .8rem/1.2 var(--sx-familia-maquina); color: var(--sx-color-tinta-suave);
}
.pistas li { display: flex; align-items: center; gap: .55rem; }
.pista-sello { width: 30px; height: 30px; font-size: .85rem; --giro: -8deg; }
.pista-cinta { padding: .25rem .9rem .22rem .45rem; font-size: .62rem; animation: none; }
.pista-hoja { width: 16px; height: 30px; background: var(--sx-recurso-hoja) center/contain no-repeat; rotate: 18deg; }

.portada-etiqueta {
  position: absolute; top: -6px; left: calc(42.5% - 40px); z-index: 2;
  --ancho-etq: clamp(150px, 15vw, 210px);
}
.portada-etiqueta .sx-etiqueta { width: var(--ancho-etq); animation-delay: 450ms; }

/* ═══════════ Mesa: cuaderno + ficha apoyada encima ═══════════ */
.mesa {
  width: min(var(--sx-ancho-max), 100% - 2rem);
  margin: -1.5rem auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  align-items: start;
  position: relative;
}
.cuaderno { min-width: 0; }
.pagina { position: relative; z-index: 1; padding: 2.2rem 1.6rem 2.6rem 2.9rem; }
.pagina::before { left: 1.7rem !important; }
.sx-cuaderno__marcapaginas { top: auto !important; bottom: -52px; height: 90px !important; z-index: 0 !important; left: 30% !important; }
.sx-cuaderno__elastico { right: -3px !important; z-index: 2; }
.pagina::before { opacity: .55; }
.folio {
  margin: 0 0 .4rem; font: 400 .74rem/1 var(--sx-familia-maquina); letter-spacing: .14em; text-transform: uppercase;
  color: var(--sx-color-ocre);
}
.matriz-cab { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .8rem 1.5rem; }
.matriz-cab h2 { margin: 0; }
.acciones { display: flex; flex-wrap: wrap; gap: .5rem; }

.mini {
  min-height: 40px; padding: .45rem .8rem;
  background: var(--sx-color-ficha); color: var(--sx-color-tinta);
  border: 1px solid var(--sx-color-linea); border-radius: 2px;
  font: 700 .74rem/1 var(--sx-familia-maquina); letter-spacing: .05em; text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--sx-color-linea); cursor: pointer;
  transition: transform var(--sx-dur-corta) var(--sx-curva-suave), box-shadow var(--sx-dur-corta);
}
.mini:hover { transform: translate(-1px, -1px) rotate(-.8deg); box-shadow: 3px 3px 0 var(--sx-color-linea); color: var(--sx-color-carmin); }
.mini:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--sx-color-linea); }
.mini[aria-pressed="true"] { background: var(--sx-color-musgo-hondo); color: var(--sx-color-crema); border-color: var(--sx-color-musgo-hondo); }

.origen-fila { margin: 1rem 0 .4rem; }
.chip {
  display: inline-block; padding: .3rem .6rem;
  background: var(--sx-color-ficha); border: 1px dashed var(--sx-color-ocre);
  font: 400 .8rem/1.35 var(--sx-familia-maquina); color: var(--sx-color-tinta);
  rotate: -.4deg;
}
.chip-propio { border-style: solid; border-color: var(--sx-color-musgo); box-shadow: 3px 3px 0 var(--sx-color-salvia); }
.leyenda-niveles { max-width: 62rem; margin: .4rem 0; font-size: .92rem; color: var(--sx-color-tinta-suave); }
.criterios-det { margin: .3rem 0 1.2rem; max-width: 62rem; }
.criterios-det summary {
  display: inline-block; cursor: pointer; padding: .2rem 0;
  font: 700 1.25rem/1.1 var(--sx-familia-mano); color: var(--sx-color-musgo);
}
.criterios-det summary::marker { color: var(--sx-color-carmin); }
.criterios-det dl {
  display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: .6rem 0 0;
  padding: 1rem 1.2rem; background: var(--sx-color-ficha); border: var(--sx-borde-fino);
  font-size: .88rem;
}
.criterios-det dt { font: 400 .95rem/1.3 var(--sx-familia-rotulo); color: var(--sx-color-musgo-hondo); }
.criterios-det dd { margin: 0; color: var(--sx-color-tinta-suave); }

/* ═══════════ Registro: cada fila es una muestra prensada ═══════════ */
.tabla-matriz-scroll { overflow-x: auto; margin: 0 -.4rem 0 -3.2rem; padding: 0 .4rem 0 3.2rem; }
.tabla-matriz-scroll:focus-visible { outline: var(--sx-borde-foco); outline-offset: 2px; }
.matriz { min-width: 940px; table-layout: fixed; font-size: .86rem; }
.matriz th:nth-child(1) { width: 50px; } .matriz th:nth-child(3) { width: 98px; }
.matriz th:nth-child(n+4):nth-child(-n+8) { width: 50px; padding-inline: 0; }
.matriz th:nth-child(9) { width: 70px; } .matriz th:nth-child(10) { width: 128px; } .matriz th:nth-child(11) { width: 186px; }
.matriz th:nth-child(2) { white-space: normal; }
.matriz th { white-space: nowrap; font-size: .86rem; vertical-align: bottom; }
.matriz th abbr { text-decoration: none; cursor: help; }
.matriz th:nth-child(n+4):nth-child(-n+8) { text-align: center; }
.matriz td { padding: .85rem .4rem; position: relative; }
.matriz tbody tr { transition: background-color var(--sx-dur-corta); }
.matriz tbody tr:hover { background: color-mix(in srgb, var(--sx-color-ocre-claro) 18%, transparent); }

/* número de colección */
.c-num { text-align: center; }
.c-num .n {
  display: block; margin: 0 auto .35rem;
  font: 700 .82rem/1 var(--sx-familia-maquina); color: var(--sx-color-ocre);
}
.c-num .n::before { content: "N.º "; font-weight: 400; }
.icono {
  width: 30px; height: 30px; margin: 1px; padding: 0;
  border: 1px solid var(--sx-color-linea); border-radius: 50%;
  background: var(--sx-color-ficha); color: var(--sx-color-tinta-suave);
  font: 700 .95rem/1 var(--sx-familia-texto); cursor: pointer;
}
.icono:hover { color: var(--sx-color-musgo); border-color: var(--sx-color-musgo); }
.icono.quitar:hover { color: var(--sx-color-carmin); border-color: var(--sx-color-carmin); }

/* la cinta roja: atraviesa el margen del cuaderno en las muestras significativas */
.matriz tr.sig .c-num::before {
  content: ""; position: absolute; left: -2.9rem; top: .95rem; width: 2.6rem; height: 14px;
  background: var(--sx-degradado-cinta);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 7px 50%);
  box-shadow: 0 2px 0 var(--sx-color-cinta-honda);
}

/* actividad · aspecto → impacto, con su hoja prensada */
.c-asp { padding-left: 3.3rem !important; }
.c-asp::before {
  content: ""; position: absolute; left: .55rem; top: .7rem; width: 34px; height: 62px;
  background: var(--sx-recurso-hoja) center/contain no-repeat;
  rotate: var(--giro, -8deg);
  filter: grayscale(.9) sepia(.35) opacity(.42);
}
.matriz tr.sig .c-asp::before { filter: drop-shadow(0 2px 1px rgba(40, 30, 10, .35)); }
.matriz tr:nth-child(3n+1) .c-asp::before { --giro: -14deg; }
.matriz tr:nth-child(3n+2) .c-asp::before { --giro: 9deg; }
.matriz tr:nth-child(4n) .c-asp::before { --giro: -3deg; }
.matriz tr:nth-child(5n) .c-asp::before { --giro: 16deg; }
.c-asp b {
  display: block; margin-bottom: .15rem;
  font: italic 700 1.14rem/1.1 var(--sx-familia-display); color: var(--sx-color-tinta);
}
.c-asp .asp { display: block; color: var(--sx-color-tinta); }
.c-asp .imp { display: block; margin-top: .15rem; color: var(--sx-color-ocre); font-size: .84rem; }
.c-asp .imp::before { content: "→ "; }

/* condición: selector mecanografiado */
.matriz select {
  font: inherit; color: var(--sx-color-tinta); cursor: pointer;
}
.matriz select.cond {
  -webkit-appearance: none; appearance: none;
  width: 100%; max-width: 6.1rem; min-height: 34px; padding: .3rem 1.3rem .3rem .4rem;
  background: var(--sx-color-ficha) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23835211'/%3E%3C/svg%3E") right .45rem center no-repeat;
  border: 1px solid var(--sx-color-linea); border-radius: 0;
  font: 400 .78rem/1.2 var(--sx-familia-maquina);
}

/* criterios: sellos de tinta (data-v = nivel que pinta js/) */
.matriz td:nth-child(n+4):nth-child(-n+8) { text-align: center; padding-inline: 0; padding-top: 1.1rem; }
.matriz select[data-v] {
  --tinta: var(--sx-color-musgo);
  -webkit-appearance: none; appearance: none;
  width: 42px; height: 42px; padding: 0; border-radius: 50%;
  background: transparent;
  border: 2px solid var(--tinta);
  box-shadow: inset 0 0 0 3px var(--sx-color-papel), inset 0 0 0 4.5px var(--tinta);
  color: var(--tinta);
  font: 700 1.1rem/1 var(--sx-familia-maquina);
  text-align: center; text-align-last: center;
  transform: rotate(var(--giro, -6deg));
  transition: transform var(--sx-dur-corta) var(--sx-curva-sello);
}
.matriz select[data-v]:not(:focus-visible) { -webkit-mask: var(--sx-recurso-tinta) center / 90px; mask: var(--sx-recurso-tinta) center / 90px; }
.matriz select[data-v="2"] { --tinta: var(--sx-color-ocre); }
.matriz select[data-v="3"] { --tinta: var(--sx-color-carmin); background: color-mix(in srgb, var(--sx-color-carmin) 9%, transparent); }
.matriz select[data-v]:hover { transform: rotate(0deg) scale(1.08); }
.matriz select[data-v]:focus-visible { outline: var(--sx-borde-foco); outline-offset: 3px; }
.matriz select option { color: #1F2A1E; background: #FFFBF0; }
.matriz td:nth-child(4) select { --giro: -7deg; }
.matriz td:nth-child(5) select { --giro: 5deg; }
.matriz td:nth-child(6) select { --giro: -3deg; }
.matriz td:nth-child(7) select { --giro: 8deg; }
.matriz td:nth-child(8) select { --giro: -10deg; }
.matriz select.estampado { animation: sx-sellar var(--sx-dur-sello) var(--sx-curva-sello) both; }
.matriz tr.recien { animation: tocado 900ms var(--sx-curva-suave); }
@keyframes tocado { from { background-color: color-mix(in srgb, var(--sx-color-ocre-claro) 55%, transparent); } }

/* puntaje: cifra y regla en miniatura */
.c-pts { }
.pts { display: block; font: 700 1.9rem/1 var(--sx-familia-display); color: var(--sx-color-tinta); }
.matriz tr.sig .pts { color: var(--sx-color-carmin); }
.barrita {
  position: relative; height: 12px; margin-top: .4rem;
  background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--sx-color-tinta) 40%, transparent) 0 1px, transparent 1px 10%) bottom / 100% 5px no-repeat,
              color-mix(in srgb, var(--sx-color-linea) 45%, transparent);
  border-bottom: 1px solid var(--sx-color-tinta-suave);
}
.barrita i { position: absolute; left: 0; top: 0; height: 7px; background: var(--sx-color-musgo); }
.matriz tr.sig .barrita i { background: var(--sx-color-cinta); }
.barrita b { position: absolute; top: -4px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--sx-color-tinta); }

/* significancia: cinta roja o anotación a lápiz */
.sello-sig {
  display: inline-block; padding: .32rem 1rem .3rem .5rem;
  background: var(--sx-degradado-cinta); color: var(--sx-color-sobre-cinta);
  font: 700 .66rem/1 var(--sx-familia-maquina); letter-spacing: .05em; text-transform: uppercase;
  clip-path: var(--sx-efecto-muesca-cinta);
  box-shadow: 0 2px 0 var(--sx-color-cinta-honda);
}
.sello-sig.sello-no {
  padding: 0; background: none; box-shadow: none; clip-path: none;
  font: 700 1.3rem/1 var(--sx-familia-mano); letter-spacing: 0; text-transform: none; color: var(--sx-color-tinta-suave);
}
.motivo-txt { display: block; margin-top: .35rem; font-size: .76rem; line-height: 1.3; color: var(--sx-color-tinta-suave); max-width: 9rem; }

/* control propuesto */
.c-ctrl { padding-left: .7rem !important; font-size: .8rem; line-height: 1.4; color: var(--sx-color-tinta); }
.tipo {
  display: inline-block; margin: 0 .35rem .3rem 0; padding: .14rem .4rem;
  border: 1px solid currentColor; font: 700 .66rem/1.2 var(--sx-familia-maquina); letter-spacing: .06em; text-transform: uppercase;
}
.tipo-1, .tipo-2 { color: var(--sx-color-musgo); }
.tipo-3 { color: var(--sx-color-ocre); }
.tipo-4 { color: var(--sx-color-tinta-suave); border-style: dashed; }
.normas-fila { display: flex; flex-wrap: wrap; gap: .2rem .5rem; margin-top: .35rem; }
.normas-fila a { font: 400 .74rem/1.3 var(--sx-familia-maquina); }
.nota-fila { display: block; margin-top: .3rem; font-style: italic; font-size: .76rem; color: var(--sx-color-tinta-suave); }
.vacio { padding: 2.5rem 1rem !important; text-align: center; font: 700 1.5rem/1.2 var(--sx-familia-mano); color: var(--sx-color-tinta-suave); }

/* ═══════════ Ficha de resultados ═══════════ */
.ficha {
  position: sticky; top: 1rem; z-index: var(--sx-z-ficha);
  margin: 5.5rem 0 0 -1rem;
  padding: 2rem 1.3rem 1.4rem;
  max-height: calc(100vh - 2rem); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.ficha-num { margin: 0; font: 400 .7rem/1 var(--sx-familia-maquina); letter-spacing: .16em; text-transform: uppercase; color: var(--sx-color-ocre); }
.etiqueta { margin: .35rem 0 .6rem; font: 400 1.18rem/1.15 var(--sx-familia-rotulo); letter-spacing: .03em; color: var(--sx-color-musgo-hondo); }
.marcador { display: flex; align-items: baseline; gap: .6rem; margin: .2rem 0 .4rem; }
#n-sig { font: italic 700 var(--sx-tam-cifra)/.85 var(--sx-familia-display); color: var(--sx-color-carmin); }
.marcador small { font: 400 1rem/1.25 var(--sx-familia-texto); color: var(--sx-color-tinta-suave); }
.marcador small span { font-family: var(--sx-familia-maquina); font-weight: 700; color: var(--sx-color-tinta); }

.bloques { gap: 0 3px; margin: .4rem 0 .9rem; padding: .5rem .3rem .3rem; border-top: var(--sx-borde-fino); border-bottom: var(--sx-borde-fino); }
.bloques li {
  position: relative; width: 19px; height: 36px;
  background: var(--sx-recurso-hoja) center/contain no-repeat;
  filter: grayscale(.95) sepia(.35) opacity(.36);
  rotate: -12deg;
  transition: filter 400ms var(--sx-curva-suave), rotate 400ms var(--sx-curva-suave);
}
.bloques li:nth-child(2n) { rotate: 10deg; }
.bloques li:nth-child(3n) { rotate: -4deg; }
.bloques li.on, .bloques li.veto { filter: drop-shadow(0 1px 1px rgba(30, 20, 5, .4)); }
.bloques li.veto::after {
  content: ""; position: absolute; left: -3px; right: -3px; top: 48%; height: 5px;
  background: var(--sx-color-cinta); rotate: -14deg; box-shadow: 0 1px 0 var(--sx-color-cinta-honda);
}
.hud-linea { margin: 0 0 .45rem; font-size: .86rem; line-height: 1.4; color: var(--sx-color-tinta); }
.hud-linea:empty { display: none; }
#hud-control { padding-left: .7rem; border-left: 3px solid var(--sx-color-ocre); }

.umbral { margin: 1.3rem 0 1rem; padding-top: .9rem; border-top: var(--sx-borde-cosido); }
.umbral-fila { position: relative; padding: 76px 4px 0; }
.umbral-fila .lupa { top: 2px; left: calc(4px + var(--pos, .5) * (100% - 8px - 6px) + 3px); }
.umbral-fila .sx-regla { display: block; position: relative; z-index: 1; }
.regla-cifras {
  display: flex; justify-content: space-between; margin-top: .15rem; padding: 0 1px;
  font: 700 .72rem/1 var(--sx-familia-maquina); color: var(--sx-color-tinta-suave);
}
.regla-cifras i { font-style: normal; }
.ayuda { margin: .7rem 0 0; font-size: .8rem; line-height: 1.45; color: var(--sx-color-tinta-suave); }

.ranking { margin: 0 0 1.1rem; padding: 0; list-style: none; counter-reset: puesto; }
.ranking li {
  counter-increment: puesto;
  display: flex; align-items: baseline; gap: .4rem; padding: .32rem 0;
  border-bottom: 1px dotted var(--sx-color-linea); font-size: .84rem; line-height: 1.3;
}
.ranking li::before { content: counter(puesto, upper-roman) "."; min-width: 1.9rem; font: 400 .9rem/1 var(--sx-familia-rotulo); color: var(--sx-color-ocre); }
.ranking li span { flex: 1; min-width: 0; }
.ranking li b { font: 700 .95rem/1 var(--sx-familia-maquina); color: var(--sx-color-carmin); }
.ficha .acciones { margin-top: .6rem; }

/* ═══════════ Editor: etiqueta de colección ═══════════ */
.editor {
  width: min(44rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem);
  margin: auto; overflow-y: auto; z-index: var(--sx-z-modal);
}
.editor form { display: grid; gap: .9rem; }
.editor h2 { margin: 0 0 .3rem; }
.editor small { font-family: var(--sx-familia-texto); font-size: .78rem; letter-spacing: 0; }
.editor .dos { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .8rem 1.2rem; }
#editor-criterios label { display: grid; gap: .2rem; font: 400 .95rem/1.2 var(--sx-familia-rotulo); color: var(--sx-color-tinta-suave); }
.editor select, .editor input[type="text"], .editor textarea {
  width: 100%; min-height: 40px; padding: .35rem .2rem;
  border: 0; border-bottom: 1.5px solid var(--sx-color-tinta-suave); border-radius: 0;
  background: transparent; color: var(--sx-color-tinta); font: 500 .95rem/1.3 var(--sx-familia-texto);
}
.editor option { color: #1F2A1E; background: #FFFBF0; }
.editor fieldset { margin: 0; padding: .8rem 1rem 1rem; border: var(--sx-borde-fino); }
.editor legend { padding: 0 .4rem; font: 400 1rem/1 var(--sx-familia-rotulo); color: var(--sx-color-musgo-hondo); }
.normas-lista { display: grid; gap: .35rem; max-height: 13rem; overflow-y: auto; font-size: .84rem; }
.normas-lista label { display: flex; gap: .5rem; align-items: flex-start; }
.normas-lista input { margin-top: .2rem; accent-color: var(--sx-color-musgo); }
.errores { margin: 0; min-height: 1.2em; color: var(--sx-color-carmin); font-weight: 600; }
.pie-dialogo { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }

/* ═══════════ Pie: sobre la mesa ═══════════ */
.pie {
  position: relative; overflow: hidden;
  width: min(var(--sx-ancho-max), 100% - 2rem); margin: 4rem auto 0; padding: 2.4rem 0 2.6rem 5.5rem;
  border-top: var(--sx-borde-cosido);
  font-size: .88rem; color: var(--sx-color-tinta-suave);
}
.pie::before {
  content: ""; position: absolute; left: .4rem; top: 1.4rem; width: 58px; height: 140px;
  background: var(--sx-recurso-helecho) center/contain no-repeat; opacity: .5; rotate: -12deg;
}
.pie p { max-width: 62rem; margin: 0 0 1rem; }
.creditos { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; font: 700 .86rem/1.3 var(--sx-familia-maquina); color: var(--sx-color-tinta); }

/* ═══════════ Entrada orquestada ═══════════ */
@keyframes colgar { from { opacity: 0; transform: translateY(-140px); } to { opacity: 1; transform: none; } }
@keyframes renglon { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.entrando .portada-foto img { animation: sx-revelar-foto 1400ms var(--sx-curva-suave) both; }
.entrando .barra { animation: sx-aparicion 700ms var(--sx-curva-suave) 100ms both; }
.entrando .portada-texto > * { animation: sx-aparicion var(--sx-dur-entrada) var(--sx-curva-suave) both; }
.entrando .portada-texto > :nth-child(1) { animation-delay: 150ms; }
.entrando .portada-texto > :nth-child(2) { animation-delay: 250ms; }
.entrando .portada-texto > :nth-child(3) { animation-delay: 400ms; }
.entrando .portada-texto > :nth-child(4) { animation-delay: 520ms; }
.entrando .portada-etiqueta { animation: colgar 700ms var(--sx-curva-suave) 350ms both; }
.portada-etiqueta .sx-etiqueta { animation-delay: 700ms; }
.entrando .cuaderno { animation: sx-abrir-cuaderno 1100ms var(--sx-curva-suave) 600ms both; }
.entrando .ficha { animation: sx-posar 900ms var(--sx-curva-suave) 1150ms both; }
.entrando .ficha .lupa { animation: sx-posar 800ms var(--sx-curva-suave) 1650ms both; }
.entrando #filas tr { animation: renglon 600ms var(--sx-curva-suave) both; animation-delay: calc(1000ms + var(--n, 0) * 70ms); }
.entrando #filas tr .c-asp::before { animation: sx-prensar 700ms var(--sx-curva-suave) both; animation-delay: calc(1050ms + var(--n, 0) * 70ms); }
.entrando #filas tr.sig .sello-sig, .entrando #filas tr.sig .c-num::before { animation: sx-cinta var(--sx-dur-cinta) var(--sx-curva-suave) both; animation-delay: calc(1650ms + var(--n, 0) * 50ms); }
.entrando .bloques li { animation: sx-prensar 600ms var(--sx-curva-suave) both; animation-delay: calc(1500ms + var(--n, 0) * 45ms); }
#filas tr:nth-child(2), .bloques li:nth-child(2) { --n: 1; } #filas tr:nth-child(3), .bloques li:nth-child(3) { --n: 2; }
#filas tr:nth-child(4), .bloques li:nth-child(4) { --n: 3; } #filas tr:nth-child(5), .bloques li:nth-child(5) { --n: 4; }
#filas tr:nth-child(6), .bloques li:nth-child(6) { --n: 5; } #filas tr:nth-child(7), .bloques li:nth-child(7) { --n: 6; }
#filas tr:nth-child(8), .bloques li:nth-child(8) { --n: 7; } #filas tr:nth-child(9), .bloques li:nth-child(9) { --n: 8; }
#filas tr:nth-child(10), .bloques li:nth-child(10) { --n: 9; } #filas tr:nth-child(11), .bloques li:nth-child(11) { --n: 10; }
#filas tr:nth-child(12), .bloques li:nth-child(12) { --n: 11; } #filas tr:nth-child(n+13), .bloques li:nth-child(n+13) { --n: 12; }
@media (prefers-reduced-motion: reduce) {
  .sx-raiz *, .sx-raiz *::before, .sx-raiz *::after { animation: none !important; transition: none !important; }
}

/* ═══════════ Tableta: la ficha baja ═══════════ */
@media (max-width: 1080px) {
  .portada { grid-template-columns: 1fr; min-height: 0; }
  .portada-foto { grid-column: 1; grid-row: 1; margin: 0; height: clamp(260px, 52vw, 440px);
    -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 100%); mask-image: linear-gradient(180deg, #000 70%, transparent 100%); }
  .portada-texto { grid-row: 2; padding: 0 clamp(1rem, 5vw, 3rem) 2.5rem; max-width: 46rem; margin-top: -2.5rem; }
  .portada-etiqueta { left: auto; right: clamp(.5rem, 6vw, 4rem); top: 3.2rem; --ancho-etq: clamp(110px, 20vw, 170px); }
  .mesa { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
  .ficha { position: relative; top: 0; max-height: none; overflow: visible; margin: -1rem auto 0; width: min(100%, 40rem); }
}

/* ═══════════ Móvil: cada muestra es un pliego ═══════════ */
@media (max-width: 760px) {
  .barra { top: .7rem; gap: .4rem; }
  .barra .sx-boton { min-height: 40px; padding: .45rem .7rem .45rem 1.6rem; font-size: .7rem; }
  .marca { display: none; }
  .portada-foto { height: 300px; }
  .portada-texto { margin-top: -1.5rem; }
  .portada-etiqueta { top: 3.6rem; right: .6rem; --ancho-etq: 112px; }
  .bajada { font-size: 1rem; }
  .mesa { width: calc(100% - 1rem); }
  .cuaderno { padding: 6px 6px 8px; }
  .sx-cuaderno__elastico { right: 18px; }
  .sx-cuaderno__marcapaginas { left: auto; right: 64px; }
  .pagina { padding: 1.6rem .9rem 1.8rem 1.6rem; }
  .pagina::before { left: .8rem; }
  .tabla-matriz-scroll { overflow: visible; margin: 0; padding: 0; }
  .matriz { min-width: 0; display: block; }
  .matriz thead { display: none; }
  .matriz tbody { display: block; }
  .matriz tbody tr {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem 0;
    padding: .9rem 0 1rem; border-bottom: 1.5px solid var(--sx-color-linea);
  }
  .matriz td { display: block; border: 0; padding: .2rem 0; }
  .matriz td:not(:nth-child(n+4):nth-child(-n+8)) { grid-column: 1 / -1; }
  .c-num { position: absolute !important; right: 0; top: .6rem; width: auto; display: flex !important; align-items: center; gap: .2rem; z-index: 1; }
  .c-num .n { margin: 0 .3rem 0 0; }
  .matriz tr.sig .c-num::before { display: none; }
  .matriz tbody tr { position: relative; }
  .matriz tr.sig { box-shadow: inset 4px 0 0 var(--sx-color-cinta); padding-left: .6rem; }
  .c-asp { min-width: 0; padding: .2rem 0 .2rem 3.2rem !important; margin-top: 2.2rem; min-height: 70px; }
  .c-asp::before { left: .3rem; top: .1rem; }
  .matriz td:nth-child(n+4):nth-child(-n+8)::before {
    display: block; margin-bottom: .25rem;
    font: 400 .78rem/1 var(--sx-familia-rotulo); color: var(--sx-color-tinta-suave);
  }
  .matriz td:nth-child(4)::before { content: "Frec."; }
  .matriz td:nth-child(5)::before { content: "Sev."; }
  .matriz td:nth-child(6)::before { content: "Alc."; }
  .matriz td:nth-child(7)::before { content: "Legal"; }
  .matriz td:nth-child(8)::before { content: "Partes"; }
  .c-pts { width: auto; display: flex !important; align-items: center; gap: .8rem; margin-top: .4rem; }
  .c-pts .barrita { flex: 1; margin: 0; }
  .motivo-txt { max-width: none; }
  .ficha { margin-top: -.5rem; padding: 1.8rem 1.1rem 1.3rem; rotate: .4deg; }
  .pie { padding-left: 0; }
  .pie::before { display: none; }
  .criterios-det dl { grid-template-columns: 1fr; }
}

/* ═══════════════════════ /proceso/ ═══════════════════════ */
.portada--proceso { min-height: clamp(380px, 32vw, 460px); }
.portada--proceso .portada-texto { padding-top: 5.5rem; }
.portada--proceso .sx-titulo { font-size: clamp(2.6rem, 6vw, 5.2rem); }
.articulo {
  width: min(var(--sx-ancho-max), 100% - 2rem); margin: 0 auto;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0; align-items: start;
}
.indice {
  position: sticky; top: 1rem; z-index: var(--sx-z-ficha);
  margin: 3rem -1.4rem 0 0; padding: 1.6rem 1.3rem 1.3rem;
  rotate: -1deg;
}
.indice ol { margin: .4rem 0 0; padding: 0; list-style: none; counter-reset: cap; }
.indice li { counter-increment: cap; border-bottom: 1px dotted var(--sx-color-linea); }
.indice a { display: flex; gap: .5rem; padding: .38rem 0; text-decoration: none; color: var(--sx-color-tinta); font-size: .9rem; }
.indice a::before { content: counter(cap) "."; min-width: 1.4rem; font: 700 .8rem/1.5 var(--sx-familia-maquina); color: var(--sx-color-ocre); }
.indice a:hover { color: var(--sx-color-carmin); }
.indice-t { margin: 0; font: 400 1.1rem/1 var(--sx-familia-rotulo); color: var(--sx-color-musgo-hondo); }
.cuaderno--proceso .pagina { padding-bottom: 3rem; }
.bloque { max-width: 58rem; padding: 1.2rem 0 1.6rem; border-bottom: var(--sx-borde-cosido); scroll-margin-top: 1rem; }
.bloque:last-of-type { border-bottom: 0; }
.bloque h2 { margin: .4rem 0 1rem; font: 700 var(--sx-tam-h2)/1.05 var(--sx-familia-display); color: var(--sx-color-tinta); }
.bloque h3 { margin: 1.4rem 0 .5rem; font: italic 700 1.3rem/1.15 var(--sx-familia-display); color: var(--sx-color-musgo-hondo); }
.bloque p, .bloque li { line-height: 1.6; }
.bloque ul { padding-left: 1.2rem; }
.bloque ul li::marker { color: var(--sx-color-musgo); }
.dos-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem 2rem; align-items: start; }
.nota-fuente { font-size: .82rem; font-style: italic; color: var(--sx-color-tinta-suave); }
.aviso {
  padding: .8rem 1rem; background: var(--sx-color-ficha); border-left: 4px solid var(--sx-color-cinta);
  box-shadow: var(--sx-sombra-papel); font-size: .92rem;
}
.figura, .errata {
  position: relative; margin: 1.4rem 0; padding: 1.4rem 1.3rem 1rem;
  background: var(--sx-color-ficha); box-shadow: var(--sx-sombra-papel); border: var(--sx-borde-fino);
}
.figura::before, .errata::before {
  content: ""; position: absolute; top: -10px; left: 1.6rem; width: 84px; height: 20px;
  background: color-mix(in srgb, var(--sx-color-ocre-claro) 80%, transparent); rotate: -4deg;
}
.figura h3 { margin-top: 0; }
.figura figcaption { margin-top: .6rem; font-size: .84rem; color: var(--sx-color-tinta-suave); }
figure.figura, .boceto figure { margin-inline: 0; }
.tabla-scroll { overflow-x: auto; }
.tabla { width: 100%; min-width: 620px; border-collapse: collapse; font-size: .86rem; }
.tabla caption { caption-side: bottom; padding-top: .6rem; text-align: left; font-size: .8rem; color: var(--sx-color-tinta-suave); }
.tabla th { padding: .5rem .45rem; border-bottom: 1.5px solid var(--sx-color-tinta); text-align: left; font: 400 .9rem/1.1 var(--sx-familia-rotulo); color: var(--sx-color-musgo-hondo); }
.tabla td { padding: .55rem .45rem; border-bottom: 1px solid var(--sx-color-linea); vertical-align: top; }
.tabla .num { font-family: var(--sx-familia-maquina); white-space: nowrap; }
.tabla .difiere { color: var(--sx-color-carmin); font-weight: 700; }
.calculado {
  display: inline-block; padding: .12rem .45rem; vertical-align: middle;
  border: 1.5px solid var(--sx-color-musgo); color: var(--sx-color-musgo); rotate: -3deg;
  font: 700 .62rem/1.2 var(--sx-familia-maquina); letter-spacing: .1em; text-transform: uppercase;
}
.tuberia { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0 1.4rem; padding: 0; list-style: none; counter-reset: none; }
.tuberia li {
  position: relative; flex: 1 1 9.5rem; display: grid; gap: .15rem; padding: .7rem .8rem .8rem 1.4rem;
  background: var(--sx-color-ficha); border: var(--sx-borde-fino);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}
.tuberia li::before { content: ""; position: absolute; left: 10px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--sx-color-laton); }
.paso { font: 700 .66rem/1 var(--sx-familia-maquina); letter-spacing: .12em; text-transform: uppercase; color: var(--sx-color-ocre); }
.tuberia strong { font: italic 700 1.15rem/1.1 var(--sx-familia-display); }
.tuberia small { font-size: .8rem; color: var(--sx-color-tinta-suave); line-height: 1.35; }
.formula {
  display: inline-block; margin: .3rem 0 1rem; padding: .7rem 1.1rem;
  background: var(--sx-color-ficha); border: var(--sx-borde-doble);
  font: 700 clamp(.85rem, 2.4vw, 1.05rem)/1.4 var(--sx-familia-maquina); color: var(--sx-color-tinta);
}
.glosario dt { margin-top: .6rem; font: 400 1rem/1.2 var(--sx-familia-rotulo); color: var(--sx-color-musgo-hondo); }
.glosario dd { margin: .15rem 0 0; font-size: .9rem; color: var(--sx-color-tinta-suave); }
.tag {
  display: inline-block; margin: .1rem 0; padding: .1rem .45rem;
  border: 1px solid var(--sx-color-musgo); font: 700 .74rem/1.4 var(--sx-familia-maquina); color: var(--sx-color-musgo);
}
.g-caja { min-height: 120px; }
.grafica { display: block; width: 100%; height: auto; }
.g-reji { stroke: var(--tinta); stroke-opacity: .12; }
.g-base { stroke: var(--tinta); stroke-width: 1.5; }
.g-eje { font: 12px var(--fuente-num); fill: var(--tinta-suave); }
.g-barra { fill: var(--sx-color-salvia); stroke: var(--sx-color-musgo); stroke-width: 1.2; }
.g-dest { fill: var(--sx-color-cinta); stroke: var(--sx-color-cinta-honda); }
.g-rotulo { font: 600 13px var(--fuente); fill: var(--tinta); }
.g-num { font: 700 12px var(--fuente-num); }
.g-num.claro { fill: #FFF4E2; }
.g-num.oscuro { fill: #1F2A1E; }
.g-num.tinta { fill: var(--tinta); }
#g-pesos { min-height: 0; }
.g-linea { fill: none; stroke-width: 2.5; }
.g-punto { stroke: var(--tinta); stroke-width: 1; }
.g-ref { stroke: var(--sx-color-cinta); stroke-width: 2; stroke-dasharray: 5 4; }
.g-ref-t { fill: var(--sx-color-carmin); }
.decisiones li { margin-bottom: .45rem; }
.paleta { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.paleta span {
  display: grid; align-content: end; min-height: 76px; padding: .5rem .6rem;
  background: var(--c); color: var(--sobre, #1F2A1E); border: 1px solid rgba(0, 0, 0, .18);
  font: 700 .8rem/1.3 var(--sx-familia-texto); box-shadow: var(--sx-sombra-papel);
}
.paleta code { font: 400 .74rem/1.2 var(--sx-familia-maquina); }
.boceto .grafica { max-width: 320px; color: var(--sx-color-tinta); }
.boceto figcaption { font-size: .84rem; color: var(--sx-color-tinta-suave); }
.errata ul { padding-left: 1.1rem; }
.errata li { margin-bottom: .6rem; }
.errata b { color: var(--sx-color-ocre); }
.hermano {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem;
  padding: 1.1rem 1.3rem; background: var(--sx-color-ficha); border: var(--sx-borde-doble);
}
.hermano p { flex: 1 1 22rem; margin: 0; }
.fuentes { padding-left: 1.3rem; font-size: .88rem; }
.fuentes li { margin-bottom: .45rem; overflow-wrap: anywhere; }
.volver { margin-top: 2rem; }
@media (max-width: 1080px) {
  .articulo { grid-template-columns: minmax(0, 1fr); }
  .indice { position: relative; top: 0; margin: 0 auto -1rem; width: min(100%, 34rem); rotate: -.6deg; }
}
@media (max-width: 760px) {
  .portada--proceso .portada-foto { height: 220px; }
  .portada--proceso .portada-etiqueta { display: none; }
  .articulo { width: calc(100% - 1rem); }
}
