/* =====================================================================
   Piezas interactivas de los temas y máquinas animadas de los ejercicios.
   ===================================================================== */
.iw { display: grid; gap: 14px; }
.iw .widget-tit { margin: 0 !important; }
.iw .segmentado { justify-self: start; flex-wrap: wrap; }
.iw-desc { margin: 0; font-size: 15px; color: var(--suave); }
.iw-desc b { color: var(--texto); }
.iw-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.iw-salida { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 1px solid var(--borde); border-radius: 999px; font: 600 14px var(--mono); color: var(--suave); transition: border-color .15s, color .15s; }
.iw-salida.on { border-color: var(--verde); color: var(--texto); }
.iw-cuenta { margin: 0; font-size: 14px; color: var(--suave); }
.iw-cuenta b { color: var(--texto); font-variant-numeric: tabular-nums; }
.aviso-txt { color: var(--aviso); }

/* Pulsador de mando: solo vale 1 mientras se mantiene */
.ipuls {
  --pc: #3d4250; --pc-sombra: #24272f;
  display: grid; place-items: center; min-width: 64px; height: 52px; padding: 0 16px; border: 0; border-radius: 12px;
  font: 700 14px var(--titulos); letter-spacing: .03em; color: #fff; cursor: pointer;
  background: var(--pc); box-shadow: 0 5px 0 var(--pc-sombra);
  transition: transform .06s, box-shadow .06s; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ipuls.verde { --pc: #1f7a45; --pc-sombra: #14522e; }
.ipuls.rojo { --pc: #c23b33; --pc-sombra: #862822; }
.ipuls.pulsado { transform: translateY(4px); box-shadow: 0 1px 0 var(--pc-sombra); }
.ipuls:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; }

/* Cronograma */
.crono { border: 1px solid var(--borde); border-radius: 10px; background: var(--codigo-fondo); padding: 6px 4px; overflow: hidden; }
.crono svg { display: block; width: 100%; height: auto; }
.crono text { font: 600 12px var(--mono); fill: var(--suave); }
.crono-base { stroke: var(--borde); stroke-width: 1; }
.crono-ahora { stroke: var(--borde-fuerte); stroke-width: 1; stroke-dasharray: 3 3; }
.crono-s { fill: none; stroke-width: 2.4; stroke-linejoin: round; }
.crono-s.c0 { stroke: var(--acento); }
.crono-s.c1 { stroke: var(--verde); }
.crono-s.c2 { stroke: var(--aviso); }
.crono-s.c3 { stroke: var(--rojo); }
:root:not([data-theme="light"]) .crono-s.c0 { stroke: #6f9bff; }

/* Temporizador: barra de ET */
.iw-et { display: flex; align-items: center; gap: 10px; font: 600 14px var(--mono); color: var(--suave); }
.iw-barra { width: 140px; height: 8px; border-radius: 9px; background: var(--superficie-2); overflow: hidden; }
.iw-barra i { display: block; height: 100%; background: var(--aviso); transform-origin: 0 50%; transform: scaleX(0); }
.iw-et code { min-width: 52px; color: var(--texto); }

/* Contador: cinta, fotocélula y caja */
.cinta-escena { position: relative; height: 150px; border-radius: 10px; background: var(--codigo-fondo); border: 1px solid var(--borde); overflow: hidden; }
.cinta { position: absolute; left: 4%; right: 30%; bottom: 34px; height: 16px; border-radius: 8px; background: #2a2d34; overflow: visible; }
.cinta > i { position: absolute; inset: 3px 6px; border-radius: 5px; background: repeating-linear-gradient(90deg, #4a4f59 0 6px, transparent 6px 16px); }
.cinta.mueve > i { animation: cinta-mueve .5s linear infinite; }
@keyframes cinta-mueve { to { background-position: 16px 0; } }
.pieza {
  position: absolute; left: 0; bottom: 16px; width: 34px; height: 30px; border-radius: 4px;
  background: #d8a24a; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .2), inset 0 0 0 2px rgba(0, 0, 0, .15);
  transition: left 2.2s linear, transform .2s;
}
.pieza.va { left: calc(100% + 10px); }
.fotocelula { position: absolute; left: 58%; top: 16px; bottom: 30px; width: 30px; display: grid; justify-items: center; }
.fc-emisor { width: 18px; height: 14px; border-radius: 3px; background: #5b6170; }
.fc-haz { width: 2px; height: 100%; background: linear-gradient(#ef4444, rgba(239, 68, 68, .35)); box-shadow: 0 0 8px #ef4444; transition: opacity .1s; }
.fotocelula.cortado .fc-haz { opacity: .15; }
.fotocelula.cortado .fc-emisor { background: #ef4444; box-shadow: 0 0 10px #ef4444; }
.fc-txt { position: absolute; top: -14px; font: 600 10px var(--mono); color: var(--suave); white-space: nowrap; }
.caja-emb {
  position: absolute; right: 4%; bottom: 10px; width: 24%; min-width: 96px; height: 92px; padding: 8px;
  border: 3px solid #b8894a; border-top: 0; border-radius: 0 0 8px 8px; background: rgba(184, 137, 74, .12);
  transition: transform .4s ease-in, opacity .4s;
}
.caja-emb.llena { border-color: var(--verde); background: rgba(31, 122, 69, .18); }
.caja-emb.sale { transform: translateX(140%); opacity: 0; }
.caja-emb::after { content: attr(data-extra); position: absolute; top: -20px; right: 0; font: 700 11px var(--mono); color: var(--rojo); }
.caja-huecos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; height: 100%; }
.caja-huecos i { border-radius: 3px; background: var(--superficie-2); transition: background .2s, transform .2s; }
.caja-huecos i.on { background: #d8a24a; transform: scale(1.05); }
.caja-txt { position: absolute; top: -16px; left: 0; font: 600 10px var(--mono); color: var(--suave); }
.iw-cv { display: flex; align-items: baseline; gap: 6px; padding: 4px 14px; border-radius: 10px; background: var(--codigo-fondo); border: 1px solid var(--borde); font-family: var(--mono); }
.iw-cv b { font-size: 30px; line-height: 1.1; color: var(--aviso); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.iw-cv small { color: var(--suave); font-size: 12px; }

/* Flancos: bombilla del telerruptor */
.bombilla { width: 22px; height: 22px; border-radius: 50%; background: var(--superficie-2); box-shadow: inset 0 0 0 2px var(--borde-fuerte); transition: background .15s, box-shadow .15s; }
.luz.on .bombilla { background: #ffd56a; box-shadow: 0 0 14px #ffd56a, 0 0 32px rgba(255, 213, 106, .5); }
.luz.on { border-color: #ffd56a; }

/* Contacto físico frente a programa */
.fp { display: flex; align-items: stretch; flex-wrap: wrap; gap: 10px; }
.fp-col { display: grid; align-content: start; justify-items: start; gap: 10px; flex: 1; min-width: 140px; padding: 12px; border: 1px solid var(--borde); border-radius: 10px; background: var(--codigo-fondo); }
.fp-col small { font: 700 11px var(--titulos); letter-spacing: .05em; text-transform: uppercase; color: var(--suave); }
.fp-col .segmentado button { font-size: 13px; }
.fp-flecha { align-self: center; color: var(--suave); font-size: 20px; }
.fp-led { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.fp-corte { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--suave); cursor: pointer; }
.fp-motor { width: 52px; height: 52px; }
.fp-veredicto { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--superficie-2); font-size: 15px; }
@media (max-width: 700px) { .fp-flecha { display: none; } .fp-col { min-width: calc(50% - 5px); } }

/* GRAFCET del taladro */
.gr { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: center; }
.gr-svg { width: 100%; max-width: 360px; height: auto; }
.gr-svg text { font: 600 13px var(--mono); fill: var(--suave); }
.gr-etapa text { font: 700 17px var(--titulos); fill: var(--texto); text-anchor: middle; }
.gr-accion text { text-anchor: middle; font-size: 12px; }
.gr-linea, .gr-flecha { fill: none; stroke: var(--borde-fuerte); stroke-width: 2; }
.gr-etapa rect { fill: var(--superficie); stroke: var(--borde-fuerte); stroke-width: 2; transition: fill .15s, stroke .15s; }
.gr-etapa .gr-doble { fill: none; }
.gr-etapa.on rect:first-child { fill: var(--acento); stroke: var(--acento); }
.gr-etapa.on .gr-doble { stroke: #fff; }
.gr-etapa.on text { fill: #fff; }
.gr-accion rect { fill: none; stroke: var(--borde-fuerte); stroke-width: 1.5; transition: fill .15s, stroke .15s; }
.gr-accion line { stroke: var(--borde-fuerte); stroke-width: 1.5; }
.gr-accion.on rect { fill: rgba(63, 185, 104, .15); stroke: var(--verde); }
.gr-accion.on text { fill: var(--texto); }
.gr-tr line { stroke: var(--texto); stroke-width: 3; }
.gr-tr.ok text { fill: var(--verde); }
.gr-tr.valida line { stroke: var(--aviso); }
.gr-tr.valida.ok line { stroke: var(--verde); }
.taladro { position: relative; height: 230px; max-width: 220px; width: 100%; justify-self: center; --pos: 0; }
.tal-columna { position: absolute; left: 18px; top: 0; bottom: 30px; width: 18px; border-radius: 4px; background: #4c5260; }
.tal-fc { position: absolute; right: -10px; width: 9px; height: 9px; border-radius: 50%; background: var(--e-led-off, #2d3036); }
.tal-fc.arriba { top: 30px; }
.tal-fc.abajo { top: 120px; }
.tal-fc.on { background: var(--led-on); box-shadow: 0 0 8px var(--led-on); }
.tal-cabezal { position: absolute; left: 34px; top: 16px; width: 110px; transform: translateY(calc(var(--pos) * 86px)); }
.tal-motor { display: block; height: 52px; border-radius: 8px 8px 4px 4px; background: #3d5672; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .2); }
.tal-broca {
  display: block; width: 10px; height: 46px; margin: 0 auto; border-radius: 0 0 5px 5px;
  background: repeating-linear-gradient(160deg, #c9ced6 0 4px, #8a909a 4px 8px); background-size: 100% 16px;
}
.taladro.gira .tal-broca { animation: broca .25s linear infinite; }
@keyframes broca { to { background-position: 0 16px; } }
.tal-mesa { position: absolute; left: 0; right: 0; bottom: 0; height: 30px; border-radius: 4px; background: #4c5260; }
.tal-pieza { position: absolute; left: 62px; bottom: 30px; width: 76px; height: 22px; border-radius: 3px; background: #d8a24a; opacity: 0; transform: translateY(-20px); transition: opacity .25s, transform .25s; }
.tal-pieza.on { opacity: 1; transform: none; }
.tal-pieza.taladrada::after { content: ""; position: absolute; left: 33px; top: 0; width: 10px; height: 14px; border-radius: 0 0 5px 5px; background: #1b1d22; }
.gr-bits { display: flex; flex-wrap: wrap; gap: 6px; }
.gr-bit { display: inline-flex; gap: 6px; align-items: center; padding: 3px 8px; border-radius: 6px; background: var(--superficie-2); font: 600 12px var(--mono); color: var(--suave); }
.gr-bit b { color: var(--suave); }
.gr-bit.on { color: var(--texto); }
.gr-bit.on b { color: var(--verde); }
@media (max-width: 640px) { .gr { grid-template-columns: 1fr; } .taladro { height: 200px; } }

/* Neumática */
.neu { width: 100%; max-width: 520px; height: auto; justify-self: center; overflow: visible; }
.neu-cil { fill: var(--superficie-2); stroke: var(--borde-fuerte); stroke-width: 2; }
.neu-camara { fill: transparent; transition: fill .2s; }
.neu-camara.on { fill: rgba(79, 134, 255, .35); }
.neu-piston { fill: #9aa0aa; }
.neu-vastago { fill: #c9ced6; }
.neu-sensor { fill: var(--e-led-off, #2d3036); stroke: var(--borde-fuerte); }
.neu-sensor.on { fill: var(--led-on); stroke: var(--led-on); }
.neu-t { font: 600 12px var(--mono); fill: var(--suave); }
.neu-linea { fill: none; stroke: var(--borde-fuerte); stroke-width: 4; transition: stroke .2s; }
.neu-linea.on { stroke: #4f86ff; stroke-dasharray: 8 6; animation: flujo-aire .5s linear infinite; }
@keyframes flujo-aire { to { stroke-dashoffset: -14; } }
.neu-valv { transition: transform .25s ease-out; }
.neu-cuadro { fill: var(--superficie); stroke: var(--texto); stroke-width: 2; }
.neu-fl { fill: none; stroke: var(--texto); stroke-width: 1.8; }
.neu-pt { fill: none; stroke: var(--texto); stroke-width: 1.8; stroke-linejoin: round; }
.neu-bobina { fill: var(--superficie-2); stroke: var(--texto); stroke-width: 2; transition: fill .15s; }
.neu-bobina.on { fill: var(--aviso); }
.neu-muelle { fill: none; stroke: var(--texto); stroke-width: 1.8; }
.neu-comp { fill: var(--superficie-2); stroke: #4f86ff; stroke-width: 2; }
.neu-y2 { display: none; }
.iw.bi .neu-y2 { display: inline; }
.iw.bi .neu-muelle { display: none; }
.iw:not(.bi) [data-y2] { display: none; }
.neu-msg { margin: 0; min-height: 1.5em; font-size: 15px; color: var(--suave); }

/* HMI con alarma */
.hmi { max-width: 460px; border-radius: 10px; background: #c9cdd3; color: #1b1d22; overflow: hidden; border: 6px solid #2b2e35; }
.hmi-cab { display: flex; justify-content: space-between; padding: 6px 12px; background: #8e949d; font: 600 13px var(--titulos); }
.hmi-cuerpo { display: flex; align-items: center; gap: 22px; padding: 14px 16px; }
.hmi-dep { position: relative; width: 54px; height: 80px; border: 3px solid #4c5260; border-radius: 6px; overflow: hidden; background: #e2e5e9; }
.hmi-dep i { position: absolute; inset: 0; background: #7c8794; transform-origin: 50% 100%; transform: scaleY(.2); transition: transform .1s linear; }
.hmi-valor { font-family: var(--mono); }
.hmi-valor b { font-size: 34px; }
.hmi-valor.alto b { color: #b42318; }
.hmi-alarmas { min-height: 44px; padding: 8px; background: #b6bbc2; }
.hmi-vacio { padding: 6px 8px; font-size: 13px; color: #4c5260; }
.hmi-al { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; font-size: 13px; font-weight: 600; }
.hmi-al em { margin-left: auto; font-style: normal; font-weight: 500; font-size: 12px; }
.hmi-icono { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 3px; font-weight: 800; }
.hmi-al.e0 { background: #d92d20; color: #fff; animation: parpadeo 1s steps(2, jump-none) infinite; }
.hmi-al.e1 { background: #d92d20; color: #fff; }
.hmi-al.e2 { background: #fde68a; color: #1b1d22; animation: parpadeo 1s steps(2, jump-none) infinite; }
.hmi-al .hmi-icono { background: rgba(255, 255, 255, .25); }
@keyframes parpadeo { 50% { opacity: .35; } }
.contenido tr.fila-activa td { background: var(--acento-suave); }
.contenido tr.fila-activa td:first-child { box-shadow: inset 3px 0 0 var(--acento); }

/* Bits con su valor, dentro de código */
.bitv { padding: 0 3px; border-radius: 3px; background: var(--superficie-2); color: var(--suave); }
.bitv.uno { background: rgba(63, 185, 104, .2); color: var(--verde); }

/* IEC: cuatro lenguajes */
.len-vista { min-height: 140px; display: grid; align-items: center; }
.len { width: 100%; max-width: 480px; }
svg.len { height: auto; }
pre.len { margin: 0; }
.len.oculta { display: none; }
.len-h { fill: none; stroke: var(--borde-fuerte); stroke-width: 3; transition: stroke .1s; }
.len-h.on { stroke: var(--verde); }
.len-c path { fill: none; stroke: var(--texto); stroke-width: 3; }
.len-c text, .len-t, .len-bt { font: 600 12px var(--mono); fill: var(--suave); text-anchor: middle; }
.len-t { text-anchor: start; }
.len-bt { font-size: 18px; fill: var(--texto); }
.len-c.on path { stroke: var(--verde); }
.len-c.on text { fill: var(--verde); }
.len-blq { fill: var(--superficie-2); stroke: var(--texto); stroke-width: 2; }

/* ST: histéresis */
.his { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.his-termo { position: relative; width: 34px; height: 170px; flex: none; }
.his-tubo { position: absolute; left: 9px; top: 0; width: 16px; height: 140px; border-radius: 8px; background: var(--superficie-2); overflow: hidden; box-shadow: inset 0 0 0 2px var(--borde-fuerte); }
.his-tubo i { position: absolute; inset: 0; background: #ef4444; transform-origin: 50% 100%; transition: transform .1s; }
.his-bulbo { position: absolute; left: 0; bottom: 0; width: 34px; height: 34px; border-radius: 50%; background: #ef4444; }
.his-der { flex: 1; min-width: 240px; display: grid; gap: 12px; }
.his-rango { display: grid; gap: 6px; font-size: 15px; }
.his-rango input { width: 100%; accent-color: #ef4444; }
.his-cod { margin: 0; font-size: 14px; }
.his-cod span { display: inline-block; opacity: .45; transition: opacity .15s; }
.his-cod span.activa { opacity: 1; color: var(--texto); background: rgba(79, 134, 255, .18); border-radius: 3px; }
.his-vent { flex: none; }
.his-estado { font-size: 15px; color: var(--suave); }
.his-estado b { color: var(--texto); }

/* Inversión de giro */
.inv { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.inv-km { display: grid; gap: 8px; }
.inv-motor { display: flex; align-items: center; gap: 14px; }
.inv-motor.izq .mq-motor.on svg { animation-direction: reverse; }
.inv-motor.corto .mq-motor { border-color: var(--rojo); animation: parpadeo .3s steps(2, jump-none) infinite; }
.inv-txt { font-size: 15px; color: var(--suave); max-width: 280px; }

/* GRAFCET → ST */
.ecu { margin: 0; font-size: 13.5px; line-height: 1.9; white-space: pre-wrap; }
.ecu-r { display: inline-block; min-width: 1.6em; text-align: center; border-radius: 4px; background: var(--superficie-2); color: var(--suave); }
.ecu-r.uno { background: var(--acento); color: #fff; }

/* Modbus */
.mb { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto; align-items: center; gap: 0; }
.mb-eq { display: grid; gap: 2px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--borde-fuerte); background: var(--codigo-fondo); text-align: center; }
.mb-eq small { font-size: 12px; color: var(--suave); }
.mb-mem { display: grid; gap: 3px; margin-top: 8px; text-align: left; }
.mb-reg { display: flex; justify-content: space-between; gap: 10px; padding: 2px 6px; border-radius: 4px; font: 500 11.5px var(--mono); color: var(--suave); transition: background .3s; }
.mb-reg b { color: var(--texto); }
.mb-reg.leida { background: rgba(79, 134, 255, .22); }
.mb-bus { position: relative; height: 40px; }
.mb-cable { position: absolute; left: 0; right: 0; top: 19px; height: 3px; background: var(--borde-fuerte); }
.mb-trama { position: absolute; top: 8px; left: 0; padding: 3px 7px; border-radius: 5px; background: var(--aviso); color: #1b1d22; font: 700 12px var(--mono); opacity: 0; }
.mb.ida .mb-trama { animation: mb-ida 1.1s ease-in-out forwards; }
.mb.vuelta .mb-trama { background: var(--verde); color: #fff; animation: mb-vuelta 1.1s ease-in-out forwards; }
@keyframes mb-ida { 0% { left: 0; opacity: 1; } 90% { opacity: 1; } 100% { left: calc(100% - 34px); opacity: 0; } }
@keyframes mb-vuelta { 0% { left: calc(100% - 34px); opacity: 1; } 90% { opacity: 1; } 100% { left: 0; opacity: 0; } }
.mb-bytes { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; min-height: 54px; }
.mb-lado { align-self: center; margin-right: 4px; font: 700 11px var(--titulos); letter-spacing: .05em; text-transform: uppercase; color: var(--suave); }
.mb-b { display: grid; gap: 2px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--borde); text-align: center; animation: entra .25s ease-out both; }
.mb-b b { font: 700 14px var(--mono); }
.mb-b small { font-size: 11px; color: var(--suave); }
.mb-b.dir { border-color: #6f9bff; } .mb-b.dir b { color: #6f9bff; }
.mb-b.fn { border-color: var(--aviso); } .mb-b.fn b { color: var(--aviso); }
.mb-b.crc b { color: var(--suave); }
.mb-eco { width: 100%; font-size: 13px; color: var(--suave); }
@media (max-width: 560px) { .mb { grid-template-columns: 1fr; } .mb-bus { height: 30px; transform: rotate(90deg); width: 30px; justify-self: center; } }

/* Pirámide */
.pir { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; }
.pir-capas { display: grid; gap: 4px; justify-items: center; }
.pir-capa {
  width: calc(44% + var(--i) * 14%); padding: 9px 6px; border: 0; border-radius: 4px; cursor: pointer;
  font: 600 13px var(--titulos); color: #fff; background: hsl(calc(220 - var(--i) * 18), 55%, 42%);
  transition: transform .15s, filter .15s;
}
.pir-capa:hover, .pir-capa.on { transform: scale(1.04); filter: brightness(1.2); }
.pir-capa.on { box-shadow: 0 0 0 2px var(--texto); }
.pir-info { display: grid; gap: 8px; justify-items: start; }
.pir-info p { margin: 0; color: var(--suave); }
@media (max-width: 640px) { .pir { grid-template-columns: 1fr; } }

/* =====================================================================
   Máquinas de los ejercicios
   ===================================================================== */
#maquina { margin: 14px 0 6px; }
.mq { display: grid; gap: 6px; }
.mq-escena { position: relative; display: grid; place-items: center; min-height: 170px; padding: 14px; border-radius: 12px; background: var(--codigo-fondo); border: 1px solid var(--borde); overflow: hidden; }
.mq-txt { margin: 0; font-size: 13px; color: var(--suave); text-align: center; }
.mq-motor { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--borde-fuerte); color: var(--suave); background: var(--superficie); }
.mq-motor svg { width: 42px; height: 42px; }
.mq-motor.on { color: var(--verde); border-color: var(--verde); }
.mq-motor.on svg { animation: giro .5s linear infinite; }
.mq-piloto, .mq-baliza { width: 22px; height: 22px; border-radius: 50%; background: var(--superficie-2); box-shadow: inset 0 0 0 2px var(--borde-fuerte); }
.mq-piloto.on { background: var(--verde); box-shadow: 0 0 14px var(--verde); }
.mq-baliza { width: 30px; height: 30px; border-radius: 15px 15px 4px 4px; }
.mq-baliza.on { background: #f59e0b; animation: baliza .5s steps(2, jump-none) infinite; }
@keyframes baliza { 0% { box-shadow: 0 0 6px #f59e0b; } 100% { box-shadow: -14px 0 26px #f59e0b, 14px 0 26px #f59e0b; } }
.mq-motorbox { display: flex; align-items: center; gap: 22px; }

/* Pasillo con bombilla */
.mq-pasillo { position: relative; width: 240px; height: 140px; border-bottom: 3px solid var(--borde-fuerte); }
.mq-pasillo.largo { width: 300px; }
.mq-bombilla { position: absolute; left: 50%; top: 0; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; background: var(--superficie-2); box-shadow: inset 0 0 0 2px var(--borde-fuerte); z-index: 1; }
.mq-bombilla::before { content: ""; position: absolute; left: 12px; top: -14px; width: 2px; height: 14px; background: var(--borde-fuerte); }
.mq-bombilla.on { background: #ffd56a; box-shadow: 0 0 18px #ffd56a, 0 0 40px rgba(255, 213, 106, .6); }
.mq-cono { position: absolute; left: 50%; top: 20px; width: 200px; height: 120px; margin-left: -100px; clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%); background: linear-gradient(rgba(255, 213, 106, .45), rgba(255, 213, 106, 0)); opacity: 0; transition: opacity .2s; }
.mq-cono.on { opacity: 1; }

/* Horno con sensores */
.mq-horno { display: flex; align-items: center; gap: 20px; }
.mq-horno-caja { display: flex; gap: 18px; padding: 16px 20px; border-radius: 10px; background: #3a3f4a; box-shadow: inset 0 0 0 3px #555c69; }
.mq-termo { display: grid; justify-items: center; gap: 4px; }
.mq-termo i { width: 12px; height: 60px; border-radius: 6px; background: linear-gradient(to top, #6b7280 30%, #262a31 30%); transition: background .3s; }
.mq-termo.on i { background: linear-gradient(to top, #ef4444 85%, #262a31 85%); box-shadow: 0 0 10px rgba(239, 68, 68, .5); }
.mq-termo small { font: 600 11px var(--mono); color: #c9ced6; }

/* Prensa */
.mq-prensa { display: grid; justify-items: center; gap: 10px; }
.mq-prensa-marco { position: relative; width: 170px; height: 120px; border: 8px solid #4c5260; border-bottom-width: 12px; border-radius: 6px; }
.mq-ariete { position: absolute; left: 40px; top: 0; width: 74px; height: 34px; background: #8e949d; border-radius: 0 0 4px 4px; transition: transform .35s ease-in; }
.mq-ariete::before { content: ""; position: absolute; left: 31px; top: -10px; width: 12px; height: 10px; background: #6b7280; }
.mq-ariete.on { transform: translateY(48px); }
.mq-chapa { position: absolute; left: 30px; right: 30px; bottom: 0; height: 10px; border-radius: 2px; background: #d8a24a; }
.mq-barrera { position: absolute; left: -8px; right: -8px; bottom: 26px; height: 2px; background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.mq-barrera.on { background: repeating-linear-gradient(90deg, #ef4444 0 6px, transparent 6px 18px); box-shadow: none; }
.mq-manos { display: flex; align-items: center; gap: 14px; }
.mq-mano { padding: 4px 10px; border-radius: 6px; background: var(--superficie-2); font: 700 12px var(--mono); color: var(--suave); }
.mq-mano.on { background: var(--verde); color: #fff; }
.mq-seta { width: 26px; height: 26px; border-radius: 50%; background: #c23b33; box-shadow: 0 3px 0 #862822; }
.mq-seta.on { transform: translateY(3px); box-shadow: 0 0 0 3px #f59e0b; }

/* Cintas en enclavamiento */
.mq-cintas { display: grid; gap: 18px; width: min(100%, 320px); }
.mq-cinta { position: relative; height: 34px; border-radius: 17px; background: #2a2d34; overflow: hidden; }
.mq-cinta b { position: absolute; left: 10px; top: 8px; z-index: 1; font: 700 12px var(--mono); color: #c9ced6; }
.mq-cinta i { position: absolute; inset: 6px 10px; border-radius: 10px; background: repeating-linear-gradient(90deg, #4a4f59 0 6px, transparent 6px 16px); }
.mq-caja { position: absolute; top: 4px; left: 20%; width: 26px; height: 26px; border-radius: 3px; background: #d8a24a; }
.mq-cinta.mueve i { animation: cinta-mueve .5s linear infinite; }
.mq-cinta.mueve .mq-caja { animation: caja-viaja 2.4s linear infinite; }
@keyframes caja-viaja { from { left: -10%; } to { left: 100%; } }

/* Inversión de giro */
.mq-motorbox.inv { flex-direction: column; gap: 10px; }
.mq-motorbox.izq .mq-motor.on svg { animation-direction: reverse; }
.mq-sentido { font: 600 14px var(--mono); color: var(--suave); }
.mq-corto { display: none; padding: 4px 12px; border-radius: 6px; background: #c23b33; color: #fff; font-weight: 700; animation: parpadeo .4s steps(2, jump-none) infinite; }
.mq-motorbox.corto .mq-corto { display: block; }

/* Fuga con baliza */
.mq-fuga { position: relative; display: flex; align-items: flex-start; gap: 60px; height: 130px; }
.mq-tubo { width: 160px; height: 22px; margin-top: 10px; border-radius: 4px; background: #6b7280; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .2); }
.mq-gotas { position: absolute; left: 70px; top: 32px; display: none; }
.mq-gotas.on { display: block; }
.mq-gotas i { position: absolute; width: 8px; height: 11px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #4f86ff; animation: gota 1s ease-in infinite; }
.mq-gotas i:nth-child(2) { left: 14px; animation-delay: .33s; }
.mq-gotas i:nth-child(3) { left: -12px; animation-delay: .66s; }
@keyframes gota { from { transform: translateY(0); opacity: 1; } to { transform: translateY(80px); opacity: 0; } }

/* Depósito con boyas */
.mq-dep { position: relative; display: flex; align-items: flex-end; gap: 26px; }
.mq-tanque { position: relative; width: 120px; height: 140px; border: 4px solid #6b7280; border-top: 0; border-radius: 0 0 10px 10px; overflow: hidden; }
.mq-agua { position: absolute; inset: 0; background: linear-gradient(#4f86ff, #2f5fd0); transform-origin: 50% 100%; transform: scaleY(.5); transition: transform .1s linear; }
.mq-boya { position: absolute; right: 4px; display: flex; align-items: center; gap: 5px; }
.mq-boya::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #2d3036; box-shadow: 0 0 0 2px #c9ced6; }
.mq-boya.on::before { background: var(--led-on); box-shadow: 0 0 0 2px #c9ced6, 0 0 10px var(--led-on); }
.mq-boya small { font: 700 9px var(--mono); color: #fff; text-shadow: 0 1px 2px #000; }
.mq-boya.max { top: calc(15% - 6px); }
.mq-boya.min { top: calc(75% - 6px); }
.mq-bomba { display: grid; justify-items: center; gap: 4px; }
.mq-bomba small { font: 600 11px var(--mono); color: var(--suave); }
.mq-bomba .mq-motor { width: 48px; height: 48px; }
.mq-bomba .mq-motor svg { width: 30px; height: 30px; }
.mq-chorro { position: absolute; left: 30px; top: -6px; width: 10px; height: 30px; border-radius: 5px; background: #4f86ff; opacity: 0; transition: opacity .2s; }
.mq-chorro.on { opacity: .8; }
.mq-grifo { position: absolute; left: 46px; bottom: -14px; width: 28px; height: 10px; border-radius: 0 0 4px 4px; background: #6b7280; }

/* Etapa de GRAFCET */
.mq-etapas { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mq-et { display: grid; place-items: center; width: 44px; height: 44px; border: 2px solid var(--borde-fuerte); border-radius: 4px; font: 700 18px var(--titulos); }
.mq-et.on { background: var(--acento); border-color: var(--acento); color: #fff; }
.mq-tr { padding: 3px 8px; border-left: 3px solid var(--texto); font: 600 12px var(--mono); color: var(--suave); }
.mq-tr.on { color: var(--verde); border-left-color: var(--verde); }

/* Entradas que mueve la propia máquina */
.interruptor.auto { opacity: .75; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .pieza { transition: none; }
  .neu-valv, .caja-emb, .mq-ariete { transition: none; }
}
