/* Herramienta «¿Es APTO?»: sala de consulta → laboratorio de 12 tubos → receta sellada.
   Se apoya en tema.css (tokens --sx-*) y styles.css (alias y componentes comunes). */

.herramienta { position: relative; }
.campo__nota { font-weight: 400; font-size: .82rem; color: var(--tinta-suave); }
.ruta__n {
  display: inline-grid; place-items: center; width: 1.55rem; height: 1.55rem; border-radius: 50%;
  font-family: var(--fuente-mono); font-size: .78rem; font-weight: 700; font-style: normal;
  background: var(--liq-verde); color: #06251A;
}

/* =========================================================
   1 · SALA: foto a sangre del consultorio + historia clínica
   ========================================================= */
.sala { position: relative; z-index: 3; isolation: isolate; color: #F4F1EA; background: #0B1C21; }
.sala__foto { display: block; position: absolute; inset: 0; z-index: -2; overflow: hidden; margin: 0; }
.sala__foto img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%;
  animation: sx-revelar 1600ms var(--sx-curva-suave) both;
}
.sala__velo { position: absolute; inset: 0; z-index: -1; background: var(--sx-degradado-velo); }
.sala__velo::after { /* luz de lámpara que cae sobre la historia */
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(40% 60% at 78% 30%, rgba(255, 190, 110, .16), transparent 70%), linear-gradient(180deg, transparent 70%, rgba(6, 18, 22, .7));
}
.sala__rejilla {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 540px); gap: clamp(1.5rem, 4vw, 4.5rem);
  align-items: center; min-height: min(760px, calc(100svh - 3.75rem)); padding: 4.5rem 0 5.5rem;
}
.sala__texto { max-width: 38rem; }
.sala__ante {
  display: inline-flex; align-items: center; gap: .6rem; margin: 0 0 1.1rem;
  font-family: var(--fuente-mono); font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #CFE6E4;
  animation: sx-subir var(--sx-dur-entrada) var(--sx-curva-suave) 150ms both;
}
.sala__cruz { width: 16px; height: 16px; background: var(--sx-efecto-cruz) center/contain no-repeat; }
.titulo-herramienta {
  font-size: var(--sx-tam-hero); line-height: 1.02; margin: 0 0 1.1rem; color: #FFFFFF; max-width: 14ch;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .45);
  animation: sx-subir var(--sx-dur-entrada) var(--sx-curva-suave) 260ms both;
}
.titulo-herramienta .tinta-roja { color: #FF9C8F; font-style: italic; }
.sala__entrada {
  font-size: 1.15rem; max-width: 34rem; color: #E6EEEC;
  animation: sx-subir var(--sx-dur-entrada) var(--sx-curva-suave) 400ms both;
}
.sala__entrada b { color: #FFFFFF; font-family: var(--fuente-mono); font-size: .92em; letter-spacing: .02em; }
.ruta {
  list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 1.8rem 0 0;
  animation: sx-subir var(--sx-dur-entrada) var(--sx-curva-suave) 540ms both;
}
.ruta a {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: .35rem .9rem .35rem .45rem;
  color: #F4F1EA; text-decoration: none; font-weight: 600; border-radius: 999px;
  background: rgba(6, 18, 22, .55); border: 1px solid rgba(233, 242, 240, .3); backdrop-filter: blur(4px);
  transition: background .16s, transform .16s;
}
.ruta li + li a { position: relative; }
.ruta a:hover { background: rgba(23, 101, 111, .7); transform: translateY(-2px); }
.ruta :focus-visible { outline-color: #FF9C8F; }

/* Historia clínica: portapapeles con pinza */
.historia {
  --tabla: #6B4A2E;
  position: relative; color: var(--tinta);
  background: var(--sx-efecto-renglones) 0 3.6rem, var(--sx-recurso-papel), var(--hoja);
  border-radius: var(--sx-radio-hoja); padding: 2.4rem 1.5rem 1.4rem;
  box-shadow: 0 0 0 12px var(--tabla), 0 0 0 13px #3E2A1A, 0 40px 60px -20px rgba(0, 0, 0, .75);
  transform: rotate(-1.4deg); transform-origin: 50% 0;
  animation: sx-posar 1000ms var(--sx-curva-suave) 350ms both;
  scroll-margin-top: 6rem;
}
.historia:focus-within { transform: rotate(0deg); transition: transform .4s var(--sx-curva-suave); }
.historia__pinza {
  position: absolute; left: 50%; top: -30px; width: 132px; height: 46px; transform: translateX(-50%); z-index: 2;
  border-radius: 12px 12px 6px 6px; background: linear-gradient(180deg, #F2F5F6, #A3AEB3 55%, #D3DADC);
  box-shadow: 0 6px 8px rgba(0, 0, 0, .4), inset 0 1px 0 #FFF, inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.historia__pinza::before { content: ''; position: absolute; left: 50%; top: 9px; width: 24px; height: 13px; transform: translateX(-50%); border-radius: 50%; background: #0B1C21; box-shadow: inset 0 2px 2px rgba(0,0,0,.6); }
.historia__pinza::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, .18); }
.historia__membrete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .2rem 1rem; border-bottom: 2px solid var(--cian); padding-bottom: .4rem; margin-bottom: 1rem; }
.historia__titulo { font-family: var(--fuente-titulo); font-style: italic; font-size: 2rem; line-height: 1; margin: 0; color: var(--cian-texto); }
.historia__folio { margin: 0; font-family: var(--fuente-mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--tinta-suave); }

.ficha__fila { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; align-items: end; }
.campo { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.campo__etiqueta { font-weight: 700; font-size: .92rem; }
.historia .campo input, .historia .campo select {
  font: inherit; color: var(--tinta); background: var(--campo); border: 1.5px solid var(--tinta-suave);
  border-radius: var(--radio); padding: .5rem .7rem; min-height: 46px; width: 100%; min-width: 0;
}
.historia #nombre { font-family: var(--fuente-mano); font-size: 1.55rem; font-weight: 700; color: var(--boli); padding-block: .2rem; }
.historia #nombre::placeholder { font-family: var(--fuente); font-size: 1rem; font-weight: 400; color: var(--tinta-suave); }
.ficha__barra { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin-top: .8rem; }
.ficha__botones { display: flex; gap: .6rem; flex-wrap: wrap; margin-left: auto; }
.insignia-ejemplo { margin: 0; font-size: .86rem; color: var(--tinta-suave); flex: 1 1 220px; }
.insignia-ejemplo[hidden] { display: none; }
.etiqueta-ejemplo { display: inline-block; font-family: var(--fuente-mono); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; border: 1.5px solid var(--cian-texto); color: var(--cian-texto); padding: 0 .35rem; margin-right: .3rem; border-radius: 3px; }
.github { margin-top: .9rem; border-top: 1px dashed var(--tinta-suave); padding-top: .4rem; }
.github summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: .5rem; list-style: none; flex-wrap: wrap; }
.github summary::-webkit-details-marker { display: none; }
.github__icono { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--cian); color: var(--sobre-cian); font-family: var(--fuente-mono); }
.github__icono::before { content: '+'; }
.github[open] .github__icono::before { content: '−'; }
.github__fila { display: grid; grid-template-columns: 1fr auto; gap: .7rem; align-items: end; }
.github .pie { margin: .5rem 0; }
.boton--mini { font-size: .85rem; padding: .25rem .6rem; min-height: 36px; white-space: nowrap; }
.cargando { font-family: var(--fuente-mono); font-size: .9rem; }
.cargando::after { content: ''; display: inline-block; width: .8em; height: .8em; margin-left: .5em; border: 2px solid var(--cian); border-right-color: transparent; border-radius: 50%; animation: girar .8s linear infinite; vertical-align: -.1em; }
@keyframes girar { to { transform: rotate(360deg); } }
.error-github { border: 1.5px solid var(--rojo); border-radius: var(--radio); padding: .7rem .8rem; background: var(--hoja); }
.error-github p { margin: 0 0 .6rem; }
.aviso-respaldo { font-family: var(--fuente-mono); font-size: .85rem; font-weight: 600; color: var(--ambar); border: 1px solid currentColor; border-radius: var(--radio); padding: .3rem .6rem; display: inline-block; }
.repo { border: 1px solid var(--linea); border-left: 4px solid var(--cian); padding: .6rem .8rem; margin: .6rem 0; background: var(--hoja); }
.repo__nombre { margin: 0 0 .3rem; font-family: var(--fuente-mono); }
.repo__datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .3rem .8rem; margin: 0; }
.repo__datos dt { font-size: .75rem; color: var(--tinta-suave); }
.repo__datos dd { margin: 0; font-family: var(--fuente-mono); font-weight: 600; }
.sug__aviso { font-size: .88rem; margin: .4rem 0; }
.sugs { display: grid; gap: .45rem; margin-bottom: .7rem; }
.sug { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.sug__texto span { color: var(--tinta-suave); }
.chapa { font-family: var(--fuente-mono); font-weight: 600; font-size: .78rem; padding: .05rem .5rem; border: 1px solid currentColor; border-radius: 999px; }
.chapa--na { color: var(--tinta-suave); }

/* Buscador (combobox) */
.buscador { position: relative; }
.buscador__panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: min(560px, calc(100vw - 2.5rem));
  background: var(--hoja); border: 1px solid var(--tinta-suave); border-radius: var(--radio); box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .55);
  max-height: min(70vh, 460px); overflow-y: auto; overscroll-behavior: contain;
}
.buscador__panel[hidden] { display: none; }
.buscador__lista { list-style: none; margin: 0; padding: 0; }
.buscador__grupo { font-family: var(--fuente-mono); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--tinta-suave); padding: .5rem .7rem .2rem; border-top: 1px dashed var(--linea); }
.buscador__grupo:first-child { border-top: 0; }
.opcion { display: grid; gap: .1rem; padding: .45rem .7rem; cursor: pointer; border-left: 4px solid transparent; }
.opcion[aria-selected="true"], .opcion:hover { background: var(--cian-claro); border-left-color: var(--cian); }
.opcion__fila { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .5rem; }
.opcion__nombre { font-weight: 700; }
.opcion__meta { font-family: var(--fuente-mono); font-size: .75rem; color: var(--tinta-suave); }
.opcion__que { font-size: .84rem; color: var(--tinta-suave); line-height: 1.35; overflow-wrap: anywhere; }
.opcion--accion .opcion__nombre { color: var(--cian-texto); }
.buscador__estado:empty { display: none; }
.buscador__estado { padding: .5rem .7rem; font-size: .85rem; border-top: 1px dashed var(--linea); }
.buscador__estado .aviso-limite { color: var(--rojo-texto); font-weight: 600; margin: 0; }
.buscador__estado p { margin: 0; }

/* Qué es (ficha del paciente) */
.que-es { margin-top: .9rem; border: 1px solid var(--linea); border-left: 4px solid var(--cian); border-radius: var(--radio); background: var(--cian-claro); padding: .6rem .8rem; }
.que-es[hidden] { display: none; }
.que-es__cab { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .6rem; margin: 0 0 .2rem; }
.que-es__etq { font-family: var(--fuente-mono); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--rojo-texto); }
.que-es__nombre { font-family: var(--fuente-titulo); font-size: 1.2rem; }
.que-es__texto { margin: 0 0 .35rem; font-size: .95rem; }
.que-es__datos { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin: 0; font-size: .84rem; }
.que-es__datos div { display: flex; gap: .3rem; align-items: baseline; }
.que-es__datos dt { color: var(--tinta-suave); }
.que-es__datos dd { margin: 0; font-family: var(--fuente-mono); font-weight: 600; overflow-wrap: anywhere; }
.que-es__aviso { margin: .45rem 0 0; font-size: .85rem; border-left: 4px solid var(--ambar); padding-left: .5rem; }
.que-es__nota { margin: .35rem 0 0; font-size: .8rem; color: var(--tinta-suave); }
.que-es__origen { font-family: var(--fuente-mono); font-size: .7rem; border: 1px solid currentColor; border-radius: 999px; padding: 0 .4rem; color: var(--cian-texto); }

/* =========================================================
   2 · LABORATORIO: gradilla de 12 tubos de ensayo
   ========================================================= */
.sala:has(#buscador-panel:not([hidden])) { z-index: 10; }
.laboratorio {
  position: relative; padding: 0 0 4rem;
  background:
    linear-gradient(var(--trama) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--trama) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--papel);
}
.laboratorio__rejilla { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }
.laboratorio__cab { display: grid; grid-template-columns: auto 1fr; gap: 1.2rem; align-items: end; margin: -3.2rem 0 1.6rem; position: relative; z-index: 4; }
.laboratorio__figura img { display: block; width: clamp(130px, 14vw, 200px); height: auto; filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .35)); }
.laboratorio__ante { display: flex; align-items: center; gap: .5rem; margin: 0 0 .3rem; font-family: var(--fuente-mono); font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--cian-texto); }
.laboratorio__titulo { font-size: var(--sx-tam-titulo); margin: 0 0 .3rem; }
.laboratorio__nota { margin: 0; color: var(--tinta-suave); max-width: 52ch; }

.tablero { border: 0; padding: 0; margin: 0; min-width: 0; scroll-margin-top: 5rem; }
.tablero__leyenda { font-family: var(--fuente-mono); font-size: .74rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; padding: 0; margin-bottom: 1rem; color: var(--tinta); }
.tablero__leyenda .campo__nota { font-family: var(--fuente); display: block; text-transform: none; letter-spacing: 0; font-size: .86rem; margin-top: .15rem; }

/* Gradilla: sin hueco entre columnas para que las placas se vean continuas */
.tablero__lista { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 0; row-gap: 2.2rem; }

.crit {
  --cab: 3.3rem;      /* alto fijo de la etiqueta del tubo */
  --marca: 34px;      /* alto de cada marca de la escala (área táctil) */
  --boca: 30px;       /* vidrio por encima de la marca 5 */
  --tubo-x: 10px;     /* posición del tubo dentro de .niveles */
  --tubo-w: 44px;
  position: relative; min-width: 0; padding: 0 .75rem 0; scroll-margin: 6rem;
  border-radius: 10px;
  animation: sx-colocar 600ms var(--sx-curva-suave) both;
}
/* Placa superior de la gradilla (el tubo la atraviesa por un hueco) */
.crit::before {
  content: ''; position: absolute; left: 0; right: 0; z-index: 5; pointer-events: none;
  top: calc(var(--cab) + 7px); height: 15px;
  background: var(--gradilla);
  -webkit-mask: linear-gradient(90deg, #000 0 calc(.75rem + var(--tubo-x) - 3px), transparent calc(.75rem + var(--tubo-x) - 3px) calc(.75rem + var(--tubo-x) + var(--tubo-w) + 3px), #000 calc(.75rem + var(--tubo-x) + var(--tubo-w) + 3px));
          mask: linear-gradient(90deg, #000 0 calc(.75rem + var(--tubo-x) - 3px), transparent calc(.75rem + var(--tubo-x) - 3px) calc(.75rem + var(--tubo-x) + var(--tubo-w) + 3px), #000 calc(.75rem + var(--tubo-x) + var(--tubo-w) + 3px));
  box-shadow: 0 4px 0 rgba(16, 40, 58, .14);
  filter: drop-shadow(0 3px 2px rgba(16, 40, 58, .18));
}
/* Base de la gradilla */
.crit::after {
  content: ''; position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none;
  top: calc(var(--cab) + var(--boca) + 5 * var(--marca) - 8px); height: 18px;
  background: var(--gradilla); border-bottom: 4px solid var(--cian);
  box-shadow: 0 10px 16px -10px rgba(16, 40, 58, .5);
}
.crit:nth-child(4n+1)::before, .crit:nth-child(4n+1)::after { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.crit:nth-child(4n)::before, .crit:nth-child(4n)::after { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.crit--foco { animation: sx-resaltar 1.2s ease; }

.crit__cab {
  height: var(--cab); display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto auto; align-content: end;
  column-gap: .4rem; row-gap: .1rem; align-items: center;
}
.crit__nombre { grid-column: 1 / -1; grid-row: 1; font-weight: 700; font-size: 1rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crit__id { grid-row: 2; font-family: var(--fuente-mono); font-weight: 600; font-size: .74rem; color: var(--cian-texto); border: 1.5px solid currentColor; padding: 0 .35rem; border-radius: 3px; background: var(--hoja); }
.crit__peso { grid-row: 2; grid-column: 2; font-family: var(--fuente-mono); font-size: .74rem; color: var(--tinta-suave); white-space: nowrap; }
.crit__peso--max { color: var(--rojo-texto); font-weight: 700; }
.crit__peso--max::after { content: ' ▲'; font-size: .65rem; }
.crit__chip {
  grid-row: 2; grid-column: 3; justify-self: end; font-family: var(--fuente-mono); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--sobre-cian); background: var(--cian); padding: .05rem .4rem; border-radius: 3px; white-space: nowrap;
}
.crit__chip[hidden] { display: none; }

/* El tubo: .niveles es la escala graduada; ::before el vidrio, ::after el líquido */
.niveles {
  --n: 0; --liq: var(--liq-ambar);
  position: relative; display: flex; flex-direction: column-reverse;
  padding-top: var(--boca); margin: 0;
}
.niveles[data-v="1"] { --n: 1; --liq: var(--liq-rojo); }
.niveles[data-v="2"] { --n: 2; --liq: var(--liq-rojo); }
.niveles[data-v="3"] { --n: 3; }
.niveles[data-v="4"] { --n: 4; --liq: var(--liq-verde); }
.niveles[data-v="5"] { --n: 5; --liq: var(--liq-verde); }
.niveles::before {
  content: ''; position: absolute; z-index: 3; pointer-events: none;
  left: var(--tubo-x); top: 0; bottom: 0; width: var(--tubo-w);
  border: 2px solid var(--vidrio-borde); border-top: 0; border-radius: 0 0 22px 22px;
  background: var(--vidrio);
  box-shadow: inset 0 -8px 12px rgba(16, 40, 58, .12), 0 0 0 0 transparent;
}
.niveles::after {
  content: ''; position: absolute; z-index: 2; pointer-events: none;
  left: calc(var(--tubo-x) + 4px); bottom: 4px; width: calc(var(--tubo-w) - 8px);
  height: max(0px, calc(var(--n) * var(--marca) - 6px));
  border-radius: 3px 3px 18px 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.7) 0 1.5px, transparent 2px) 0 0 / 18px 26px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.55) 0 1.2px, transparent 1.7px) 6px 10px / 22px 30px,
    linear-gradient(90deg, rgba(0,0,0,.14), transparent 35%, rgba(255,255,255,.28) 68%, rgba(0,0,0,.1)),
    var(--liq);
  border-top: 3px solid rgba(255, 255, 255, .45);
  box-shadow: 0 0 22px -6px var(--liq);
  transform-origin: 50% 100%;
  transition: height var(--sx-dur-llenado) var(--sx-curva-muelle), background-color var(--sx-dur-llenado), box-shadow var(--sx-dur-llenado);
  animation: sx-llenar var(--sx-dur-llenado) var(--sx-curva-muelle) both, burbujear 3.4s linear infinite;
}
@keyframes burbujear { to { background-position: 0 -26px, 6px -50px, 0 0, 0 0; } }

.nivel { position: relative; z-index: 4; display: block; height: var(--marca); cursor: pointer; border-radius: 6px; }
.nivel__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
/* marca de la escala sobre el vidrio */
.nivel::before {
  content: ''; position: absolute; left: var(--tubo-x); top: 0; width: 15px; z-index: 4; pointer-events: none;
  border-top: 1.5px solid var(--vidrio-borde);
}
.nivel[data-n="5"]::before { width: 22px; }
.nivel::after { /* guía de pipeta al pasar el cursor */
  content: ''; position: absolute; left: calc(var(--tubo-x) - 6px); width: calc(var(--tubo-w) + 12px); top: -1px; z-index: 5; pointer-events: none;
  border-top: 2px dashed var(--tinta); opacity: 0; transition: opacity .16s;
}
.nivel:hover::after { opacity: .8; }
.nivel__pip {
  position: absolute; left: calc(var(--tubo-x) + var(--tubo-w) + 10px); right: 0; top: 0; height: 100%;
  display: flex; align-items: center; gap: .45rem; padding-left: .2rem;
  font-family: var(--fuente-mono); font-size: .8rem; font-weight: 600; color: var(--tinta-suave);
  transition: color .16s, transform .16s;
}
.nivel__pip::after { font-family: var(--fuente); font-size: .74rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nivel[data-n="1"] .nivel__pip::after { content: 'Crítico'; }
.nivel[data-n="2"] .nivel__pip::after { content: 'Deficiente'; }
.nivel[data-n="3"] .nivel__pip::after { content: 'Aceptable'; }
.nivel[data-n="4"] .nivel__pip::after { content: 'Bueno'; }
.nivel[data-n="5"] .nivel__pip::after { content: 'Excelente'; }
.nivel:hover .nivel__pip { color: var(--tinta); transform: translateX(3px); }
.nivel:has(input:checked) .nivel__pip { color: var(--tinta); font-weight: 700; }
.nivel:has(input:checked) .nivel__pip::before {
  content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--liq); box-shadow: 0 0 0 2px var(--hoja), 0 0 0 3.5px var(--tinta-suave);
  order: -1; margin-left: -.15rem;
}
.nivel:has(input:checked) .nivel__pip::after { font-weight: 700; }
.nivel:has(input:focus-visible) { outline: 3px solid var(--rojo); outline-offset: -1px; }

.crit__desc {
  position: relative; z-index: 2; margin: 1.6rem 0 0; min-height: 5.6em;
  font-size: .8rem; line-height: 1.4; color: var(--tinta-suave);
}
.crit__desc b { color: var(--tinta); font-family: var(--fuente-mono); font-size: .78rem; }
.crit__desc--previa { color: var(--tinta); }
.crit__desc--previa b { color: var(--cian-texto); }

/* =========================================================
   3 · RECETA: recetario de bloque con el veredicto
   ========================================================= */
.hud { position: sticky; top: 4.8rem; margin-top: 1.4rem; scroll-margin-top: 5rem; }
.receta { filter: drop-shadow(0 26px 30px rgba(16, 40, 58, .22)); --diag: var(--verde); }
.receta:has(#sello[data-clase="CONDICIONAL"]) { --diag: var(--ambar); }
.receta:has(#sello[data-clase="NO APTO"]) { --diag: var(--rojo-texto); }
.receta__lomo {
  display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 1.1rem .75rem;
  background: linear-gradient(180deg, #17393F, #0E2A30); color: #DDEBE8; border-radius: 8px 8px 0 0;
  font-family: var(--fuente-mono); font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3);
}
.receta__hoja {
  position: relative; overflow: hidden;
  background: var(--sx-degradado-lampara), var(--sx-recurso-papel), var(--hoja);
  padding: 1.1rem 1.3rem 1.2rem;
  box-shadow: 0 2px 0 #E9E2D2, 0 4px 0 #DCD3BF, 0 6px 0 #CFC5AE, 0 8px 0 #C2B79F;
  animation: sx-arrancar var(--sx-dur-entrada) var(--sx-curva-suave) 500ms both;
}
:root[data-theme="dark"] .receta__hoja { box-shadow: 0 2px 0 #1D3138, 0 4px 0 #182A30, 0 6px 0 #132328, 0 8px 0 #0F1D21; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .receta__hoja { box-shadow: 0 2px 0 #1D3138, 0 4px 0 #182A30, 0 6px 0 #132328, 0 8px 0 #0F1D21; } }
.receta__hoja::before { /* perforado */
  content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 8px;
  background: radial-gradient(circle at 7px 0, var(--papel) 3px, transparent 3.5px) 0 0 / 14px 8px repeat-x;
}
.hud__kanji {
  position: absolute; right: .9rem; top: .3rem; font-family: var(--fuente-titulo); font-size: 5.2rem; line-height: 1;
  color: var(--cian-texto); opacity: .16; pointer-events: none; user-select: none;
}
.receta__membrete { border-bottom: 2px solid var(--cian); padding-bottom: .45rem; margin-bottom: .7rem; }
.receta__consultorio { margin: 0; font-family: var(--fuente-titulo); font-style: italic; font-size: 1.25rem; line-height: 1.1; color: var(--cian-texto); }
.hud__titulo { font-family: var(--fuente-mono); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: .15rem 0 0; color: var(--rojo-texto); }
.receta__renglon { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: baseline; border-bottom: 1px dashed var(--tinta-suave); padding-bottom: .15rem; }
.receta__etq { font-family: var(--fuente-mono); font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tinta-suave); }
.hud__software { margin: 0; font-family: var(--fuente-mano); font-weight: 700; font-size: 1.45rem; line-height: 1.15; color: var(--boli); overflow-wrap: anywhere; }

.receta__diagnostico { display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: center; margin: .6rem 0 .2rem; }
.hud__sello-caja { position: relative; width: 132px; height: 132px; display: grid; place-items: center; }
.sello--grande {
  width: 132px; margin: 0; font-size: 1.15rem; color: var(--diag);
  animation: sx-sellar var(--sx-dur-sello) var(--sx-curva-golpe) 1100ms both;
}
.sello--grande[data-clase="CONDICIONAL"] { font-size: .8rem; }
.sello--grande[data-clase="NO APTO"] { font-size: 1rem; }
.onomatopeya {
  position: absolute; right: -.6rem; top: -.2rem; font-family: var(--fuente-mano); font-weight: 700; font-size: 1.3rem; color: var(--rojo-texto);
  transform: rotate(12deg); opacity: 0; pointer-events: none;
}
.golpe .sello--grande { animation: golpe-sello var(--sx-dur-sello) var(--sx-curva-golpe) both; }
.golpe .onomatopeya { animation: tac .9s ease-out both; }
@keyframes golpe-sello { 0% { opacity: 0; transform: scale(2.3) rotate(-22deg); } 55% { opacity: 1; transform: scale(.9) rotate(-6deg); } 100% { opacity: 1; transform: scale(1) rotate(-9deg); } }
@keyframes tac { 0%, 30% { opacity: 0; transform: rotate(12deg) scale(.6); } 45% { opacity: 1; transform: rotate(12deg) scale(1.15); } 100% { opacity: 0; transform: rotate(12deg) scale(1); } }

.receta__valor { min-width: 0; }
.hud__ptotal { font-family: var(--fuente-titulo); font-size: var(--sx-tam-cifra); line-height: .95; margin: 0; display: flex; align-items: baseline; gap: .3rem; flex-wrap: wrap; }
.hud__ptotal output { color: var(--tinta); }
.hud__etiqueta { font-family: var(--fuente-mono); font-size: .82rem; color: var(--tinta-suave); }
.hud__max { font-size: 1.1rem; color: var(--tinta-suave); }
.pulso { display: block; width: 100%; max-width: 220px; height: 40px; margin-top: .35rem; color: var(--diag); overflow: visible; }
.pulso__linea { display: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 222 38; animation: sx-pulso calc(var(--sx-dur-pulso) * 2) linear infinite; filter: drop-shadow(0 0 3px currentColor); }
.receta:has(#sello[data-clase="APTO"]) .pulso__linea--apto,
.receta:has(#sello[data-clase="CONDICIONAL"]) .pulso__linea--cond,
.receta:has(#sello[data-clase="NO APTO"]) .pulso__linea--no { display: inline; }
.pulso__linea--cond { animation-duration: 4200ms; }
.pulso__linea--no { animation-duration: 8000ms; }

.medidor { margin: .7rem 0 1rem; }
.medidor__barra {
  position: relative; height: 12px; border-radius: 999px; overflow: visible;
  background: linear-gradient(90deg, rgba(216,71,63,.25) 0 37.5%, rgba(227,164,42,.28) 37.5% 68.75%, rgba(47,163,107,.28) 68.75%);
  box-shadow: inset 0 0 0 1px var(--linea);
}
.medidor__relleno { height: 100%; border-radius: 999px; background: var(--diag); transition: width .6s var(--sx-curva-muelle), background-color .4s; }
.medidor__umbral { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--tinta); transform: translateX(-50%); }
.medidor__marcas { position: relative; height: 1.2rem; font-family: var(--fuente-mono); font-size: .72rem; color: var(--tinta-suave); }
.medidor__marcas span { position: absolute; top: .25rem; transform: translateX(-50%); }
.medidor__marcas span:first-child { transform: none; }
.medidor__marcas span:last-child { transform: translateX(-100%); }

.metricas { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 0 0 .9rem; }
.metricas div { border: 1px dashed var(--tinta-suave); border-radius: 4px; padding: .4rem .6rem; }
.metricas dt { font-size: .8rem; color: var(--tinta-suave); }
.metricas__def { display: block; font-size: .7rem; line-height: 1.3; }
.metricas dd { margin: 0; font-family: var(--fuente-mono); font-weight: 600; font-size: 1.15rem; }

.freno { position: relative; border-left: 4px solid var(--diag); background: var(--cian-claro); border-radius: 0 6px 6px 0; padding: .55rem .75rem .55rem .85rem; margin-bottom: .5rem; }
.freno p { margin: 0 0 .2rem; }
.freno__titulo { font-family: var(--fuente-mono); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--rojo-texto); }
.freno__nombre { font-weight: 700; font-size: 1.02rem; }
.freno__nombre .crit__id { margin-right: .2rem; }
.freno__dato { font-family: var(--fuente-mono); font-size: .8rem; font-weight: 400; color: var(--tinta-suave); }
.freno__efecto { font-size: .9rem; }
.freno__mas { font-family: var(--fuente-mono); font-weight: 700; color: var(--verde); }
.freno__salto { font-weight: 700; border: 1.5px solid currentColor; border-radius: 999px; padding: 0 .45rem; white-space: nowrap; display: inline-block; font-size: .85rem; }
.freno__salto[data-clase="APTO"] { color: var(--verde); }
.freno__salto[data-clase="CONDICIONAL"] { color: var(--ambar); }
.freno__ir { font: inherit; font-size: .88rem; font-weight: 700; background: none; border: 0; border-bottom: 2px solid var(--diag); color: var(--tinta); padding: .2rem 0; cursor: pointer; min-height: 32px; }
.freno__ir::after { content: ' ↓'; }
.aportes summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; font-size: .95rem; }
.aportes .tabla thead th { background: var(--cian); color: var(--sobre-cian); }
.aportes .tabla th, .aportes .tabla td { border-color: var(--linea); }

.receta__firma { display: grid; justify-items: end; margin-top: .4rem; }
.receta__firma svg { width: 170px; height: 44px; fill: none; stroke: var(--boli); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 420; animation: sx-firmar 1400ms ease-in-out 1.6s both; }
.receta__firma-linea { width: 62%; padding-top: .3rem; text-align: center; font-family: var(--fuente-mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--tinta-suave); border-top: 1px dashed var(--tinta-suave); }
.hud__enlace { display: inline-block; margin-top: .8rem; font-weight: 700; font-size: .9rem; color: var(--cian-texto); text-underline-offset: 3px; }

/* Barra mini (solo pantallas estrechas) */
.hud-mini { display: none; }

/* Entrada del laboratorio: cada tubo baja a su hueco y luego se llena, en orden */
.crit:nth-child(1) { --i: 0; } .crit:nth-child(2) { --i: 1; } .crit:nth-child(3) { --i: 2; } .crit:nth-child(4) { --i: 3; }
.crit:nth-child(5) { --i: 4; } .crit:nth-child(6) { --i: 5; } .crit:nth-child(7) { --i: 6; } .crit:nth-child(8) { --i: 7; }
.crit:nth-child(9) { --i: 8; } .crit:nth-child(10) { --i: 9; } .crit:nth-child(11) { --i: 10; } .crit:nth-child(12) { --i: 11; }
.crit { animation-delay: calc(700ms + var(--i, 0) * 60ms); }
.crit .niveles::after { animation-delay: calc(1100ms + var(--i, 0) * 90ms), 0s; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1180px) {
  .laboratorio__rejilla { grid-template-columns: 1fr; }
  .hud { position: relative; top: auto; max-width: 560px; margin: 2.5rem auto 0; }
  .tablero__lista { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sala__rejilla { grid-template-columns: 1fr; min-height: 0; padding: 0 0 3.5rem; gap: 2.2rem; }
  .sala__foto { position: relative; inset: auto; height: 260px; z-index: 0; }
  .sala__foto::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,28,33,.1) 40%, #0B1C21); }
  .sala__velo { display: none; }
  .sala__texto { margin-top: -4.5rem; position: relative; }
  .titulo-herramienta { max-width: 16ch; }
  .historia { transform: none; margin-top: 1rem; animation-name: sx-subir; }
  .tablero__lista { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crit:nth-child(n)::before, .crit:nth-child(n)::after { border-radius: 0; }
  .crit:nth-child(3n+1)::before, .crit:nth-child(3n+1)::after { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
  .crit:nth-child(3n)::before, .crit:nth-child(3n)::after { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
  .laboratorio__cab { margin-top: -2.4rem; }
  .hud-mini {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 40; display: flex; align-items: center; gap: .7rem;
    background: var(--hoja); color: var(--tinta); border-top: 4px solid var(--consultorio); border-radius: 6px; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .55);
    padding: .45rem .75rem; text-decoration: none; transition: transform .2s, opacity .2s;
  }
  .hud-mini--oculto { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .hud-mini__sello { font-family: var(--fuente-mono); font-weight: 700; font-size: .78rem; border: 2px solid currentColor; border-radius: 999px; padding: .05rem .55rem; transform: rotate(-4deg); white-space: nowrap; }
  .hud-mini__sello[data-clase="APTO"] { color: var(--verde); }
  .hud-mini__sello[data-clase="CONDICIONAL"] { color: var(--ambar); }
  .hud-mini__sello[data-clase="NO APTO"] { color: var(--rojo-texto); }
  .hud-mini__p { font-family: var(--fuente-titulo); font-size: 1.4rem; }
  .hud-mini__etq { font-family: var(--fuente-mono); font-size: .75rem; margin-right: .2rem; color: var(--tinta-suave); }
  .hud-mini__freno { font-size: .8rem; color: var(--tinta-suave); margin-left: auto; text-align: right; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .laboratorio { padding-bottom: 6rem; }
}
@media (max-width: 640px) {
  .sala__foto { height: 220px; }
  .titulo-herramienta { font-size: clamp(2.3rem, 10.5vw, 3rem); }
  .sala__entrada { font-size: 1.02rem; }
  .historia { padding: 2.2rem 1rem 1rem; box-shadow: 0 0 0 8px var(--tabla), 0 0 0 9px #3E2A1A, 0 30px 40px -20px rgba(0, 0, 0, .75); }
  .historia__titulo { font-size: 1.7rem; }
  .ficha__fila { grid-template-columns: 1fr; gap: .7rem; }
  .ficha__botones { margin-left: 0; }
  .tablero__lista { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 1.8rem; }
  .crit { padding: 0 .55rem; --tubo-x: 6px; --tubo-w: 40px; }
  .crit::before {
    -webkit-mask: linear-gradient(90deg, #000 0 calc(.55rem + var(--tubo-x) - 3px), transparent calc(.55rem + var(--tubo-x) - 3px) calc(.55rem + var(--tubo-x) + var(--tubo-w) + 3px), #000 calc(.55rem + var(--tubo-x) + var(--tubo-w) + 3px));
            mask: linear-gradient(90deg, #000 0 calc(.55rem + var(--tubo-x) - 3px), transparent calc(.55rem + var(--tubo-x) - 3px) calc(.55rem + var(--tubo-x) + var(--tubo-w) + 3px), #000 calc(.55rem + var(--tubo-x) + var(--tubo-w) + 3px));
  }
  .crit:nth-child(n)::before, .crit:nth-child(n)::after { border-radius: 0; }
  .crit:nth-child(odd)::before, .crit:nth-child(odd)::after { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
  .crit:nth-child(even)::before, .crit:nth-child(even)::after { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
  .crit__nombre { font-size: .92rem; }
  .nivel__pip { left: calc(var(--tubo-x) + var(--tubo-w) + 6px); gap: .3rem; }
  .laboratorio__cab { grid-template-columns: 96px 1fr; gap: .8rem; }
  .laboratorio__figura img { width: 96px; }
  .receta__diagnostico { grid-template-columns: 112px 1fr; gap: .6rem; }
  .hud__sello-caja, .sello--grande { width: 112px; height: 112px; }
  .sug { grid-template-columns: auto 1fr; }
  .sug .boton--mini { grid-column: 2; justify-self: start; }
  .enlace-proceso { padding: .3rem .55rem; font-size: .88rem; }
  .marca__texto { font-size: 1.2rem; }
}

/* Guardia nocturna: tabla del portapapeles más oscura */
:root[data-theme="dark"] .historia { --tabla: #3A2A1C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .historia { --tabla: #3A2A1C; } }

@media (prefers-reduced-motion: reduce) {
  .niveles::after { transform: none; }
  .pulso__linea { stroke-dasharray: none; }
  .receta__firma svg { stroke-dasharray: none; }
}
