/* PIEZAS: marca, botones, cabecera, lámparas piloto, lista de planos, constructor (pedir, tipos, detalles),
   mesa y hoja, barra de estado, avisos, diálogo y menú */

/* ---------- Lámparas piloto: cada familia de planos tiene su color ---------- */
[data-familia="0"] { --lampara: var(--lampara-0); }
[data-familia="1"] { --lampara: var(--lampara-1); }
[data-familia="2"] { --lampara: var(--lampara-2); }
[data-familia="3"] { --lampara: var(--lampara-3); }

.lampara {
  flex: none;
  width: 10px;
  height: 10px;
  border: 1.5px solid color-mix(in srgb, var(--lampara, var(--apagado)) 50%, transparent);
  border-radius: 50%;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.lampara--on {
  border-color: var(--lampara);
  background: var(--lampara);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lampara) 16%, transparent), 0 0 10px color-mix(in srgb, var(--lampara) 65%, transparent);
}

/* ---------- Marca ---------- */
.marca { display: inline-flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: 0.005em; }
.marca__sello {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ambar);
  color: var(--ambar-tinta);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(255, 193, 7, 0.2);
}

/* ---------- Botones ---------- */
.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--riel);
  border-radius: var(--r-campo);
  background: var(--elevado);
  color: var(--texto);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.boton:not(:disabled):hover { background: #2b323e; border-color: #3d4655; }
.boton:not(:disabled):active { transform: translateY(1px); }
.boton:disabled { opacity: 0.5; }
.boton--ancho { width: 100%; }

.boton--primario {
  background: var(--ambar);
  border-color: var(--ambar);
  color: var(--ambar-tinta);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.boton--primario:not(:disabled):hover { background: #ffcd33; border-color: #ffcd33; }

/* Acción secundaria que llama la atención sin gritar (Nuevo plano en la barra superior) */
.boton--suave { height: 38px; background: var(--ambar-velo); border-color: rgba(255, 193, 7, 0.5); color: var(--ambar); }
.boton--suave:not(:disabled):hover { background: rgba(255, 193, 7, 0.18); border-color: var(--ambar); }

.boton--peligro { background: var(--rojo); border-color: var(--rojo); color: #2b0b07; }
.boton--peligro:not(:disabled):hover { background: #ff9588; border-color: #ff9588; }

.boton-icono {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-campo);
  background: transparent;
  color: var(--apagado);
}
.boton-icono:not(:disabled):hover { background: var(--elevado); color: var(--texto); }
.boton-icono:disabled { opacity: 0.35; }

/* Botón que parece un enlace (acciones secundarias, como "copia de todos los planos") */
.boton-enlace {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--apagado);
  text-align: left;
  font-size: 14px;
}
.boton-enlace:hover { color: var(--texto); }

/* ---------- Menú desplegable (Exportar) ---------- */
.menu { position: relative; }
.menu__flecha { margin-right: -4px; }
.menu__lista {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(316px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--riel);
  border-radius: var(--r-dialogo);
  background: var(--panel-alto);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  animation: entra 0.12s ease-out;
}
.menu__item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}
.menu__item .icono { grid-row: span 2; color: var(--ambar); }
.menu__item:hover, .menu__item:focus-visible { background: var(--elevado); }
.menu__item:focus-visible { outline-offset: -2px; }
.menu__titulo { font-weight: 600; }
.menu__detalle { color: var(--apagado); font-size: 13px; line-height: 1.35; }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--riel); }
.menu__lista--izq { right: auto; left: 0; }
.menu__lista--planos { width: min(360px, calc(100vw - 24px)); }
.menu__item--activo { background: color-mix(in srgb, var(--lampara, var(--ambar)) 9%, transparent); }
.menu__lampara { display: grid; place-items: center; grid-row: span 2; width: 20px; }
.menu__nota { padding: 10px 12px; color: var(--tenue); font-size: 13px; }
.menu__lista--planos .menu__titulo, .menu__lista--planos .menu__detalle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .menu__lista--izq { top: calc(100% - 6px); right: 12px; left: 12px; width: auto; }
}

/* Capa del plano para imprimir: en pantalla no se ve (ver print.css) */
#impresion { display: none; }

/* ---------- Barra del plano: el nombre se escribe directamente en el título ---------- */
.nombre { display: flex; align-items: center; gap: 0; min-width: 0; margin-left: -12px; }
/* El campo crece con el texto: una copia invisible (data-valor) le da el ancho y el selector queda pegado al nombre */
.nombre__campo { display: inline-grid; min-width: 0; max-width: 100%; }
.nombre__campo::after {
  content: attr(data-valor) " ";
  grid-area: 1 / 1;
  padding: 0 12px;
  border: 1px solid transparent;
  overflow: hidden;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre;
  visibility: hidden;
}
.cabecera__titulo {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--r-campo);
  background: transparent;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  transition: border-color 0.12s, background 0.12s;
}
.cabecera__titulo::placeholder { color: var(--tenue); }
.cabecera__titulo:hover { border-color: var(--riel); }
.cabecera__titulo:focus { outline: none; border-color: var(--ambar); background: var(--campo); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16); }
.cabecera__estado { display: flex; align-items: center; gap: 9px; margin-top: 2px; color: var(--apagado); font-size: 13px; }

/* Selector rápido de planos: una flecha pegada al nombre */
.selector__boton {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-campo);
  background: transparent;
  color: var(--apagado);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.selector__boton:hover, .selector__boton[aria-expanded="true"] { background: var(--elevado); border-color: var(--riel); color: var(--texto); }
.selector__boton .menu__flecha { margin: 0; }

/* Luz piloto de estado: verde = guardado, ámbar = hay algo sin guardar */
.piloto { flex: none; width: 9px; height: 9px; border-radius: 50%; }
.piloto--ok { background: var(--verde); box-shadow: 0 0 0 3px rgba(95, 208, 138, 0.16), 0 0 9px rgba(95, 208, 138, 0.75); }
.piloto--pendiente { background: var(--ambar); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16), 0 0 9px rgba(255, 193, 7, 0.7); }

/* ---------- Barra superior: marca y pestañas ---------- */
.barra {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: stretch;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--riel);
}
.barra .marca { align-self: center; }
.barra__division { align-self: center; width: 1px; height: 26px; margin: 0 16px 0 22px; background: var(--riel); }
.barra__acciones { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.pestanas { display: flex; align-items: stretch; gap: 2px; }
.pestana {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--apagado);
  font-size: 15px;
  font-weight: 600;
  transition: color 0.12s;
}
.pestana:hover, .pestana[aria-selected="true"] { color: var(--texto); }
.pestana[aria-selected="true"] .icono { color: var(--ambar); }
.pestana:focus-visible { outline-offset: -5px; border-radius: var(--r-campo); }
/* La pestaña activa se enciende como una luz piloto: línea ámbar apoyada en el borde de la barra */
.pestana::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ambar);
  box-shadow: 0 0 14px rgba(255, 193, 7, 0.55);
  opacity: 0;
  transform: scaleX(0.4);
  transition: opacity 0.15s, transform 0.2s;
}
.pestana[aria-selected="true"]::after { opacity: 1; transform: none; }
.pestana__conteo {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--elevado);
  color: var(--apagado);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pestana[aria-selected="true"] .pestana__conteo { background: var(--ambar-velo); color: var(--ambar); }

/* ---------- Navegación inferior (pantallas angostas) ---------- */
.navegacion {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel);
  border-top: 1px solid var(--riel);
}
.navegacion__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  border: 0;
  background: none;
  color: var(--tenue);
  font-size: 12px;
  font-weight: 600;
}
.navegacion__item[aria-current="page"] { color: var(--texto); }
.navegacion__item[aria-current="page"] .icono { color: var(--ambar); }
.navegacion__item::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 28%;
  right: 28%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--ambar);
  box-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
}
.navegacion__item[aria-current="page"]::before { opacity: 1; }

/* ---------- Mis planos: la biblioteca ---------- */
.biblioteca {
  min-height: 0;
  overflow-y: auto;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0, rgba(255, 255, 255, 0.03), transparent),
    var(--grafito);
}
.biblioteca:focus { outline: none; }
.biblioteca__interior { display: flex; flex-direction: column; gap: 22px; max-width: 1280px; margin: 0 auto; padding: 34px 36px 56px; }
.biblioteca__cabecera { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.biblioteca__cabecera h1 { font-size: 28px; font-weight: 600; line-height: 1.15; }
.biblioteca__subtitulo { margin-top: 4px; color: var(--apagado); font-variant-numeric: tabular-nums; }
.biblioteca__acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.biblioteca__nuevo { display: none; }
.biblioteca__nota { color: var(--tenue); font-size: 13px; }
.biblioteca__nota--alerta { color: var(--rojo); }

/* Filtros por familia (con su lámpara) y buscador */
.biblioteca__filtros { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; }
.filtro {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--riel);
  border-radius: 999px;
  background: transparent;
  color: var(--apagado);
  font-size: 14px;
  font-weight: 600;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.filtro:hover { border-color: #3d4655; color: var(--texto); }
.filtro[aria-pressed="true"] { border-color: color-mix(in srgb, var(--lampara, var(--ambar)) 55%, transparent); background: color-mix(in srgb, var(--lampara, var(--ambar)) 11%, transparent); color: var(--texto); }
.filtro:not([data-familia])[aria-pressed="true"] { border-color: rgba(255, 193, 7, 0.55); background: var(--ambar-velo); }
.filtro__conteo { color: var(--tenue); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.filtro[aria-pressed="true"] .filtro__conteo { color: var(--apagado); }

.buscador { position: relative; display: block; width: min(320px, 100%); }
.buscador .icono { position: absolute; top: 50%; left: 13px; color: var(--tenue); transform: translateY(-50%); pointer-events: none; }
.buscador__campo {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 40px;
  border: 1px solid var(--riel);
  border-radius: var(--r-campo);
  background: var(--campo);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.buscador__campo::placeholder { color: #5f6875; }
.buscador__campo:hover { border-color: #3d4655; }
.buscador__campo:focus { outline: none; border-color: var(--ambar); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16); }

/* Tarjetas: la miniatura sobre una mesa de dibujo en pequeño, y debajo el nombre con la lámpara de su familia */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr)); gap: 20px; }
.tarjeta { position: relative; }
.tarjeta__abrir {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 10px 10px 14px;
  border: 1px solid var(--riel);
  border-radius: var(--r-tarjeta);
  background: var(--panel);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tarjeta__abrir:hover {
  border-color: color-mix(in srgb, var(--lampara) 55%, var(--riel));
  background: var(--panel-alto);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}
.tarjeta__abrir:active { transform: translateY(0); }
.tarjeta--activa .tarjeta__abrir { border-color: color-mix(in srgb, var(--lampara) 70%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--lampara) 35%, transparent); }
.tarjeta__mesa {
  display: block;
  padding: 14px;
  border-radius: 9px;
  background-color: var(--mesa);
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1.3px);
  background-size: 16px 16px;
}
.tarjeta__hoja {
  display: block;
  aspect-ratio: 1100 / 760;
  overflow: hidden;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 8px 18px rgba(0, 0, 0, 0.5);
  opacity: 0.9;
  transition: opacity 0.25s;
}
.tarjeta__hoja--lista { opacity: 1; }
.tarjeta__imagen { display: block; width: 100%; height: 100%; object-fit: cover; }
.tarjeta__texto { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 0 6px; }
.tarjeta__nombre { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tarjeta__titulo { overflow: hidden; font-size: 16px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta__meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-left: 20px; color: var(--tenue); font-size: 13px; }
.tarjeta__meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta__meta time { flex: none; font-variant-numeric: tabular-nums; }
.tarjeta__abierto {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: rgba(14, 17, 22, 0.86);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--lampara) 55%, transparent);
  color: var(--texto);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.tarjeta__abierto .icono { color: var(--lampara); stroke-width: 2.6; }
.tarjeta__borrar { position: absolute; top: 20px; right: 20px; width: 34px; height: 34px; background: rgba(14, 17, 22, 0.86); color: var(--apagado); box-shadow: 0 0 0 1px var(--riel); opacity: 0; transition: opacity 0.12s, background 0.12s, color 0.12s; }
.tarjeta:hover .tarjeta__borrar, .tarjeta:focus-within .tarjeta__borrar { opacity: 1; }
.tarjeta__borrar:hover { background: var(--rojo) !important; color: #2b0b07 !important; }
@media (hover: none) { .tarjeta__borrar { opacity: 1; } }

/* Sin planos / sin resultados */
.biblioteca__vacio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 28px auto 0;
  padding: 44px 28px;
  border: 1px dashed #3a4351;
  border-radius: 18px;
  color: var(--apagado);
  text-align: center;
}
.biblioteca__vacio strong { color: var(--texto); font-size: 19px; font-weight: 600; }
.biblioteca__vacio p { max-width: 42ch; }
.biblioteca__vacio-icono { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 4px; border-radius: 50%; background: var(--ambar-velo); color: var(--ambar); box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.3); }
.biblioteca__vacio-acciones { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.biblioteca__vacio--filtro { margin-top: 8px; padding: 32px 24px; }
.biblioteca__vacio--filtro strong { font-size: 16px; }

/* Aviso al arrastrar un archivo sobre la página */
#soltar { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(10, 12, 16, 0.78); pointer-events: none; }
.soltar__caja {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 56px;
  border: 2px dashed var(--ambar);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ambar);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.soltar__caja strong { color: var(--texto); font-size: 20px; font-weight: 600; }
.soltar__caja span { color: var(--apagado); }

@media (max-width: 720px) {
  .biblioteca__interior { gap: 18px; padding: 22px 16px 28px; }
  .biblioteca__cabecera h1 { font-size: 24px; }
  .biblioteca__nuevo { display: inline-flex; }
  .biblioteca__acciones { width: 100%; }
  .biblioteca__acciones .boton { flex: 1 1 auto; }
  .tarjetas { gap: 16px; }
  /* Los filtros se deslizan de lado en vez de ocupar tres filas */
  .filtros { flex-wrap: nowrap; margin-inline: -16px; padding-inline: 16px; overflow-x: auto; scrollbar-width: none; }
  .filtros::-webkit-scrollbar { display: none; }
  .filtro { flex: none; }
  .biblioteca__filtros, .buscador { width: 100%; }
}

/* ---------- Constructor: secciones ---------- */
.seccion { display: flex; flex-direction: column; gap: 14px; padding: 22px 22px 24px; border-bottom: 1px solid var(--riel-suave); }
.seccion__cabecera { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.seccion__titulo { font-size: 17px; font-weight: 600; }
.seccion__nota { color: var(--tenue); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- Campos ---------- */
.campo { display: flex; flex-direction: column; gap: 8px; }
.campo label, .campo__titulo { font-size: 14px; font-weight: 600; }
.campo__ayuda { color: var(--apagado); font-size: 13px; line-height: 1.45; }

.campo__control {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--riel);
  border-radius: var(--r-campo);
  background: var(--campo);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.campo__control:hover { border-color: #3d4655; }
.campo__control:focus { outline: none; border-color: var(--ambar); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16); }
textarea.campo__control { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select.campo__control {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2399a2b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.campo__control--corto { width: 120px; }
.campo__control::placeholder { color: #5f6875; }

/* Pedir un circuito con palabras */
.pedido { display: flex; flex-direction: column; gap: 12px; }
.pedido__fila { display: flex; gap: 8px; }
.pedido__fila .campo__control { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--riel);
  border-radius: 999px;
  background: transparent;
  color: var(--apagado);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.chip:hover { border-color: rgba(255, 193, 7, 0.55); background: var(--ambar-velo); color: var(--texto); }
.chips__mas { padding: 6px 6px; border: 0; background: none; color: var(--ambar); font-size: 13px; font-weight: 600; }
.chips__mas:hover { text-decoration: underline; text-underline-offset: 3px; }
.pedido__resultado { padding: 10px 12px; border-radius: var(--r-campo); font-size: 13.5px; line-height: 1.45; }
.pedido__resultado p + p { margin-top: 4px; }
.pedido__resultado--ok { border: 1px solid rgba(95, 208, 138, 0.45); background: rgba(95, 208, 138, 0.08); }
.pedido__resultado--ok strong { color: var(--verde); }
.pedido__resultado--error { border: 1px solid rgba(255, 125, 110, 0.5); background: rgba(255, 125, 110, 0.08); color: var(--texto); }
.pedido__aviso { color: var(--ambar); }

/* ---------- Tipo de plano: familias (pestañas) + filas compactas ---------- */
.tipos__tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--riel-suave);
  border-radius: 11px;
  background: var(--campo);
}
.tipos__tab {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--apagado);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.tipos__tab:hover { color: var(--texto); }
.tipos__tab[aria-selected="true"] { background: var(--elevado); color: var(--texto); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 3px rgba(0, 0, 0, 0.45); }
.tipos__nombre { overflow: hidden; text-overflow: ellipsis; }

.tipos__lista { display: flex; flex-direction: column; gap: 3px; }
.tipo {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  column-gap: 13px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-fila);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tipo:hover { background: var(--panel-alto); }
.tipo--activo, .tipo--activo:hover { background: color-mix(in srgb, var(--lampara) 8%, var(--campo)); border-color: color-mix(in srgb, var(--lampara) 50%, transparent); }
.tipo:has(input:focus-visible) { outline: 2px solid var(--ambar); outline-offset: 2px; }
/* El botón de radio se dibuja como una lámpara piloto: se enciende en el color de su familia */
.tipo input {
  appearance: none;
  width: 12px;
  height: 12px;
  margin: 4px 0 0;
  border: 1.5px solid color-mix(in srgb, var(--lampara) 50%, transparent);
  border-radius: 50%;
  transition: background 0.15s, box-shadow 0.15s;
}
.tipo input:checked {
  border-color: var(--lampara);
  background: var(--lampara);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lampara) 16%, transparent), 0 0 10px color-mix(in srgb, var(--lampara) 65%, transparent);
}
.tipo__texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tipo__texto strong { font-weight: 600; }
.tipo__texto span { color: var(--apagado); font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tipo--activo .tipo__texto span { white-space: normal; }

/* ---------- Ajustes del circuito ---------- */
.receta { padding: 14px; border: 1px solid var(--riel); border-radius: var(--r-fila); background: var(--campo); gap: 10px; }
.receta__fila { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 8px; }
.receta .campo__control { background: var(--panel); }
.opcion { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 400; cursor: pointer; }
.opcion input { width: 18px; height: 18px; flex: none; accent-color: var(--ambar); cursor: pointer; }
.campo__ayuda--aviso { color: var(--ambar); }

/* Tiempo del temporizador: − 8 + s */
.paso-fila { display: flex; align-items: center; gap: 10px; }
.paso { display: inline-flex; align-items: center; height: 42px; border: 1px solid var(--riel); border-radius: var(--r-campo); background: var(--campo); overflow: hidden; }
.paso:focus-within { border-color: var(--ambar); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16); }
.paso button { display: grid; place-items: center; width: 42px; height: 100%; border: 0; background: transparent; color: var(--apagado); }
.paso button:not(:disabled):hover { background: var(--elevado); color: var(--texto); }
.paso button:disabled { opacity: 0.35; cursor: default; }
.paso input {
  width: 64px;
  height: 100%;
  padding: 0;
  border: 0;
  border-inline: 1px solid var(--riel);
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.paso input:focus { outline: none; }
.paso input::-webkit-inner-spin-button, .paso input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.paso-fila__unidad { color: var(--apagado); }

.comps { display: flex; flex-direction: column; gap: 8px; }
.comp { display: grid; grid-template-columns: 92px minmax(0, 1fr) 36px; gap: 8px; align-items: center; }

/* ---------- JSON ---------- */
.json { margin: 0; }
.json summary { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; color: var(--apagado); font-weight: 600; cursor: pointer; list-style: none; }
.json summary::-webkit-details-marker { display: none; }
.json summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-right: 2px solid var(--tenue);
  border-bottom: 2px solid var(--tenue);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.json[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.json summary:hover { color: var(--texto); }
.json__texto {
  max-height: 260px;
  margin: 0 22px 12px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--riel-suave);
  border-radius: var(--r-campo);
  background: var(--campo);
  color: var(--apagado);
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}
.json > .boton { margin: 0 22px 22px; }

/* ---------- Mesa de dibujo y hoja ---------- */
.mesa {
  display: flex;
  overflow: auto;
  padding: 28px; /* si cambia, cambiar MARGEN en js/plano/visor.js */
  background-color: var(--mesa);
  background-image:
    radial-gradient(ellipse at 50% 38%, rgba(255, 255, 255, 0.035), transparent 62%),
    radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1.3px);
  background-size: 100% 100%, 22px 22px;
}
.mesa:focus-visible { outline-offset: -3px; }
.mesa--ampliada { cursor: grab; }
.mesa--arrastrando { cursor: grabbing; user-select: none; }

.hoja {
  flex: none;
  margin: auto;
  background: #fff;
  line-height: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 2px 4px rgba(0, 0, 0, 0.35), 0 26px 60px rgba(0, 0, 0, 0.6);
}
.hoja__svg { display: block; width: 100%; height: auto; -webkit-tap-highlight-color: transparent; }

/* Piezas interactivas: al pasar el ratón se ilumina todo lo que lleva el mismo nombre
   (por ejemplo la bobina, los contactos y los polos de -KM1). Lo que no es una pieza
   (cables, rótulos) deja pasar el ratón hacia la zona invisible que hay debajo. */
.hoja__svg > :not([data-pieza]) { pointer-events: none; }
.hoja__svg .zona.activa { fill: rgba(255, 193, 7, 0.26); }
.hoja__svg :is(line, polyline, rect, circle):not(.zona).activa { stroke: #d17a00; }
.hoja__svg text.activa { fill: #a85a00; }

/* ---------- Barra de estado: hoja · pieza señalada · zoom ---------- */
.estado {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 52px;
  padding: 8px 16px 8px 22px;
  border-top: 1px solid var(--riel);
  background: var(--grafito);
  color: var(--apagado);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.estado__posicion { min-width: 110px; color: var(--tenue); white-space: pre; }
.estado__ayuda { margin-left: auto; margin-right: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado__ayuda--pieza { color: var(--ambar); font-weight: 600; }

/* Cambio de hoja: el dibujo (hoja 1) o su leyenda (hoja 2). Misma píldora que el zoom, para que la barra quede pareja. */
.hojas { display: flex; gap: 2px; flex: none; padding: 2px; border: 1px solid var(--riel); border-radius: 10px; background: var(--panel); }
.hojas__boton {
  min-width: 78px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--apagado);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}
.hojas__boton:hover { color: var(--texto); background: var(--panel-alto); }
.hojas__boton[aria-selected="true"] { border-color: rgba(255, 193, 7, 0.45); background: var(--ambar-velo); color: var(--ambar); }

.zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--riel);
  border-radius: 10px;
  background: var(--panel);
}
.zoom .boton-icono { width: 32px; height: 32px; border-radius: 8px; }
.zoom__valor { min-width: 54px; color: var(--texto); text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 720px) {
  /* En el móvil sobra espacio: se esconde lo accesorio y el nombre de la pieza tocada puede ocupar dos líneas. */
  .estado { gap: 12px; padding: 8px 12px; }
  .estado__posicion, .estado__ayuda:not(.estado__ayuda--pieza) { display: none; }
  .hojas__boton { min-width: 0; flex: 1; }
  .zoom { margin-left: auto; }
  /* El nombre de la pieza tocada flota sobre la mesa, justo encima de la barra: así la barra no cambia de alto ni mueve el plano. */
  .estado__ayuda--pieza {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 8px);
    z-index: 5;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--riel);
    border-radius: 10px;
    background: var(--panel-alto);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    white-space: normal;
    font-size: 13px;
    line-height: 1.3;
    pointer-events: none;
  }
  .seccion { padding: 20px 16px 22px; }
  .json summary { padding: 16px; }
  .json__texto { margin-inline: 16px; }
  .json > .boton { margin-inline: 16px; }
}

/* ---------- Avisos ---------- */
#avisos {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 460px);
  transform: translateX(-50%);
  pointer-events: none;
}
.aviso {
  padding: 12px 16px;
  border: 1px solid var(--riel);
  border-left: 4px solid var(--verde);
  border-radius: 8px;
  background: var(--panel-alto);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  animation: entra 0.18s ease-out;
}
.aviso--error { border-left-color: var(--rojo); }
.aviso--info { border-left-color: var(--ambar); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Diálogo ---------- */
dialog.dialogo {
  width: min(92vw, 440px);
  padding: 0;
  border: 1px solid var(--riel);
  border-radius: var(--r-dialogo);
  background: var(--panel);
  color: var(--texto);
}
dialog.dialogo::backdrop { background: rgba(0, 0, 0, 0.62); }
.dialogo__cuerpo { padding: 22px; }
.dialogo__cuerpo h2 { font-size: 18px; font-weight: 600; }
.dialogo__cuerpo p { margin-top: 8px; color: var(--apagado); }
.dialogo__acciones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Pantallas táctiles: los botones de icono miden al menos 40 px para acertarles con el dedo */
@media (pointer: coarse) {
  .boton-icono,
  .zoom .boton-icono { width: 40px; height: 40px; }
  .hojas__boton { height: 40px; }
}

/* ---------- Práctica de cableado ---------- */
.boton--chico { height: 34px; padding: 0 12px; gap: 6px; font-size: 13px; }
.boton--activo { background: var(--ambar-velo); border-color: rgba(255, 193, 7, 0.5); color: var(--ambar); }

.practica-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--riel);
  background: var(--panel);
}
.practica-barra__estado { display: flex; align-items: center; gap: 12px; flex: none; }
.practica-barra__titulo { font-size: 14px; font-weight: 600; color: var(--texto); }
.practica-barra__cuenta { min-width: 112px; color: var(--apagado); font-size: 13px; font-variant-numeric: tabular-nums; }
.practica-barra__progreso { width: 120px; height: 6px; overflow: hidden; border-radius: 3px; background: var(--riel); }
.practica-barra__relleno { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--ambar); transition: width 0.25s ease; }
.practica-barra--completo .practica-barra__relleno { background: var(--verde); }
.practica-barra--completo .practica-barra__cuenta { color: var(--verde); font-weight: 600; }
.practica-barra__mensaje { order: 5; flex: 1 1 300px; min-width: 0; margin: 0; color: var(--apagado); font-size: 13px; line-height: 1.35; }
.practica-barra__mensaje[data-tono="ok"] { color: var(--verde); }
.practica-barra__mensaje[data-tono="error"] { color: var(--rojo); }
.practica-barra__mensaje[data-tono="pista"] { color: var(--ambar); font-weight: 600; }
.practica-barra__mensaje[data-tono="aviso"] { color: #f3b562; }
.practica-barra__acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }

/* Cablear | Probar */
.modo { display: flex; flex: none; gap: 2px; padding: 2px; border: 1px solid var(--riel); border-radius: 10px; background: var(--campo); }
.modo__boton {
  height: 30px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--apagado);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.modo__boton:hover { color: var(--texto); background: var(--panel-alto); }
.modo__boton[aria-pressed="true"] { border-color: rgba(255, 193, 7, 0.45); background: var(--ambar-velo); color: var(--ambar); }
.practica-barra[data-modo="probar"] .modo__boton[aria-pressed="true"] { border-color: rgba(95, 208, 138, 0.5); background: rgba(95, 208, 138, 0.1); color: var(--verde); }

/* Probar: la ficha de cada motor (estado, velocidad y corriente con su pico de arranque) */
.practica-barra__motores { display: flex; flex: 0 1 auto; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.motor-ficha {
  --tono: #6b7482;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 5px 14px 5px 11px;
  border: 1px solid color-mix(in srgb, var(--tono) 45%, var(--riel));
  border-radius: 14px;
  background: color-mix(in srgb, var(--tono) 8%, var(--campo));
  font-size: 13px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.motor-ficha__cab { display: flex; flex-direction: column; gap: 1px; min-width: 64px; }
.motor-ficha__id { display: inline-flex; align-items: center; gap: 7px; color: var(--texto); font-weight: 700; }
.motor-ficha__id::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--tono); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tono) 22%, transparent); }
.motor-ficha__estado { color: var(--tono); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.motor-ficha[data-tono="marcha"] { --tono: #5fd08a; }
.motor-ficha[data-tono="arranque"] { --tono: #ffc107; }
.motor-ficha[data-tono="freno"] { --tono: #ff7d6e; }
.motor-ficha[data-tono="inercia"] { --tono: #8aa0c0; }
.motor-ficha[data-tono="aviso"] { --tono: #ff9d4d; }
.practica-barra__motores--falla .motor-ficha { opacity: 0.8; }

.medidor { --medida: var(--tono); display: inline-flex; align-items: center; gap: 7px; }
.medidor--amp[data-nivel="1"] { --medida: #5fd08a; }
.medidor--amp[data-nivel="2"] { --medida: #ffc107; }
.medidor--amp[data-nivel="3"] { --medida: #ff9d4d; }
.medidor--amp[data-nivel="4"] { --medida: #ff5d4d; }
.medidor__texto { display: flex; flex-direction: column; min-width: 64px; line-height: 1.15; }
.medidor__etiqueta { color: var(--tenue); font-size: 10.5px; font-weight: 600; }
.medidor__cifra { display: flex; align-items: baseline; gap: 3px; }
.medidor__valor { color: var(--texto); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.medidor__unidad { color: var(--apagado); font-size: 11px; font-weight: 600; }
.medidor__pico { min-height: 12px; color: #ff8a7a; font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dial { display: block; width: 58px; height: 36px; flex: none; }
.dial__fondo { fill: none; stroke: var(--riel); stroke-width: 5; stroke-linecap: round; }
.dial__relleno { fill: none; stroke: var(--medida); stroke-width: 5; stroke-linecap: round; transition: stroke 0.2s ease; }
.dial__aguja { stroke: var(--texto); stroke-width: 1.8; stroke-linecap: round; }
.dial__eje { fill: var(--texto); }
.dial__pico { stroke: #ff5d4d; stroke-width: 2.4; stroke-linecap: round; opacity: 0; }

.boton--alerta { background: var(--rojo); border-color: var(--rojo); color: #2b0b07; animation: alerta-pulso 1.2s ease-in-out infinite; }
.boton--alerta:not(:disabled):hover { background: #ff9a8d; }
@keyframes alerta-pulso { 50% { box-shadow: 0 0 0 4px rgba(255, 125, 110, 0.28); } }

.velocidad { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--riel); border-radius: 9px; background: var(--campo); }
.velocidad__boton { height: 28px; min-width: 36px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--apagado); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.velocidad__boton:hover { color: var(--texto); background: var(--panel-alto); }
.velocidad__boton[aria-pressed="true"] { border-color: rgba(255, 193, 7, 0.45); background: var(--ambar-velo); color: var(--ambar); }

/* Control del tiempo: pausa · velocidades · paso · reloj */
.tiempo { display: flex; align-items: center; gap: 6px; }
.tiempo__boton { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--riel); border-radius: 9px; background: var(--campo); color: var(--apagado); cursor: pointer; }
.tiempo__boton:hover { color: var(--texto); background: var(--panel-alto); }
.tiempo__boton[aria-pressed="true"] { border-color: rgba(255, 193, 7, 0.55); background: var(--ambar-velo); color: var(--ambar); }
.tiempo__reloj { display: inline-flex; align-items: baseline; gap: 3px; min-width: 66px; padding: 0 2px; color: var(--apagado); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tiempo__t { font-style: italic; opacity: 0.7; }
.tiempo__valor { min-width: 3.1ch; color: var(--texto); font-size: 14px; font-weight: 600; text-align: right; }
.tiempo__estado { color: var(--ambar); font-size: 11.5px; font-weight: 600; }
.tiempo--pausa .tiempo__valor { color: var(--ambar); }
.tiempo__estado:empty { display: none; }

/* En pausa los cables y los motores se quedan quietos (el mando sigue respondiendo) */
.hoja__svg--pausa * { animation-play-state: paused !important; }

/* Botonera: los pulsadores y demás entradas del mando */
.botonera { order: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 0 1 auto; }
.botonera__titulo { color: var(--tenue); font-size: 12.5px; font-weight: 600; margin-right: 2px; }
.entrada-boton {
  --color: #4da3ff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--riel);
  border-bottom-width: 3px;
  border-radius: 10px;
  background: var(--elevado);
  color: var(--texto);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.entrada-boton:hover { border-color: color-mix(in srgb, var(--color) 60%, var(--riel)); }
.entrada-boton__luz { width: 11px; height: 11px; border-radius: 50%; background: color-mix(in srgb, var(--color) 28%, var(--campo)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--color) 70%, transparent); }
.entrada-boton__id { color: var(--tenue); font-size: 11.5px; font-weight: 600; }
.entrada-boton--marcha { --color: #5fd08a; }
.entrada-boton--paro { --color: #ff7d6e; }
.entrada-boton--proteccion { --color: #ffc107; }
.entrada-boton[aria-pressed="true"] {
  border-color: var(--color);
  border-bottom-width: 1px;
  margin-top: 2px;
  background: color-mix(in srgb, var(--color) 16%, var(--elevado));
}
.entrada-boton[aria-pressed="true"] .entrada-boton__luz { background: var(--color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color) 30%, transparent), 0 0 10px var(--color); }

.consigna { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; color: var(--apagado); font-size: 12.5px; font-weight: 600; }
.consigna input { width: 120px; accent-color: var(--ambar); }

/* Sobre la hoja: bornes, rieles y los cables que traza la persona */
.hoja__svg .practica .borne__area { fill: transparent; pointer-events: all; cursor: crosshair; }
.hoja__svg .practica .borne__anillo { fill: #fff; stroke: #2455a4; stroke-width: 1.8; pointer-events: none; transition: r 0.1s ease; }
.hoja__svg .practica .borne:hover .borne__anillo,
.hoja__svg .practica .borne:focus-visible .borne__anillo { r: 6.2; fill: #cfe1ff; }
.hoja__svg .practica .borne:focus { outline: none; }
.hoja__svg .practica .borne--conectado .borne__anillo { stroke-width: 2.6; } /* el color lo pone el cable que llega */
.hoja__svg .practica .borne--origen .borne__anillo { r: 7; fill: #ffe08a; stroke: #e6a700; stroke-width: 2.4; }
.hoja__svg .practica .borne--pista .borne__anillo { r: 7; fill: #ffe08a; stroke: #e6a700; stroke-width: 2.4; }

.hoja__svg .practica .riel__area { stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: crosshair; }
.hoja__svg .practica .riel:hover .riel__area,
.hoja__svg .practica .riel:focus-visible .riel__area { stroke: rgba(255, 193, 7, 0.34); stroke-linecap: round; }
.hoja__svg .practica .riel:focus { outline: none; }
.hoja__svg .practica .riel.borne--origen .riel__area,
.hoja__svg .practica .riel.borne--pista .riel__area { stroke: rgba(255, 193, 7, 0.5); stroke-linecap: round; }

.hoja__svg .practica .cable__area { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.hoja__svg .practica .cable:hover .cable__trazo { stroke-width: 3.4; }
.hoja__svg .practica .cable:focus-visible .cable__trazo { stroke-width: 3.4; }
.hoja__svg .practica .cable:focus-visible .cable__area { stroke: rgba(255, 193, 7, 0.45); stroke-linecap: round; stroke-linejoin: round; }
.hoja__svg .practica .cable:focus { outline: none; }
.hoja__svg .practica .cable__trazo, .hoja__svg .practica .cable__punto, .hoja__svg .practica .cable__error { pointer-events: none; }

.hoja__svg .practica .previa { fill: none; stroke: #d17a00; stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; pointer-events: none; }
.hoja__svg .practica .pista { fill: none; stroke: #e6a700; stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; opacity: 0.9; }
.hoja__svg .practica__solucion { pointer-events: none; opacity: 0.55; filter: drop-shadow(0 0 2.5px #2e9d4f); }

/* Probar: cables con corriente, zonas de toque, motores y cuentas de tiempo */
.hoja__svg .practica .cable--vivo .cable__trazo { transition: stroke 0.12s ease; }
.hoja__svg .practica .cable__flujo { stroke-width: 2.2; stroke-dasharray: 2.5 11; stroke-linecap: round; pointer-events: none; animation: flujo 0.55s linear infinite; }
.hoja__svg .practica .cable__flujo--L1 { stroke: #ffe3e0; }
.hoja__svg .practica .cable__flujo--L2 { stroke: #b6c4dc; }
@keyframes flujo { to { stroke-dashoffset: -13.5; } }
.hoja__svg .practica .cable--corto .cable__trazo { stroke-dasharray: 6 4; animation: corto-parpadeo 0.5s steps(2) infinite; }
@keyframes corto-parpadeo { 50% { opacity: 0.35; } }

.hoja__svg .practica .entrada { cursor: pointer; touch-action: none; }
.hoja__svg .practica .entrada:focus { outline: none; }
.hoja__svg .practica .entrada__area { fill: transparent; pointer-events: all; }
.hoja__svg .practica .entrada__aro { fill: rgba(36, 85, 164, 0.05); stroke: #2455a4; stroke-opacity: 0.5; stroke-width: 1.4; stroke-dasharray: 3 3; pointer-events: none; }
.hoja__svg .practica .entrada:hover .entrada__aro,
.hoja__svg .practica .entrada:focus-visible .entrada__aro { fill: rgba(36, 85, 164, 0.14); stroke-opacity: 1; stroke-width: 2; }
.hoja__svg .practica .entrada--activa .entrada__aro { stroke-dasharray: none; stroke-opacity: 1; stroke-width: 2.4; stroke: #2e9d4f; fill: rgba(46, 157, 79, 0.16); }
.hoja__svg .practica .entrada--paro.entrada--activa .entrada__aro { stroke: #d32f2f; fill: rgba(211, 47, 47, 0.14); }
.hoja__svg .practica .entrada--proteccion.entrada--activa .entrada__aro { stroke: #e65100; fill: rgba(230, 81, 0, 0.16); }
.hoja__svg--probar .practica__motores,
.hoja__svg--probar .practica__tiempos { pointer-events: none; }

.hoja__svg .motor-vivo { color: #9aa3af; }
.hoja__svg .motor-vivo__caja { fill: #fff; fill-opacity: 0.95; stroke-width: 1.4; }
.hoja__svg .motor-vivo__caja--rpm { stroke: #c4cbd6; stroke-width: 1; }
.hoja__svg .motor-vivo__texto { font-size: 10.5px; font-weight: 700; }
.hoja__svg .motor-vivo__rpm { fill: #4a5568; font-size: 8.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hoja__svg .motor-vivo__aspas line { stroke: currentColor; stroke-linecap: round; }
.hoja__svg .motor-vivo__campo path { stroke-width: 3.2; stroke-linecap: round; fill: none; }
.hoja__svg .motor-vivo__campo { transition: opacity 0.25s ease; }
.hoja__svg .motor-vivo__aspas { transition: opacity 0.25s ease; }

/* La fuerza en vivo: tensión (halo), corriente (puntitos que corren), polos, luz de bobina y relé que se calienta */
.hoja__svg .practica__fuerza { pointer-events: none; }
.hoja__svg .fz__halo { stroke-width: 6.5; stroke-linecap: round; fill: none; opacity: 0; transition: opacity 0.18s ease; }
.hoja__svg .fz__halo--viva { opacity: 0.2; }
.hoja__svg .fz__halo--corto { stroke: #ff3b30; opacity: 0.55; }
.hoja__svg .fz__flujo { stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 2.4 10; fill: none; opacity: 0; }
.hoja__svg .fz__flujo--1 { opacity: 0.8; animation: fz-flujo 1.1s linear infinite; }
.hoja__svg .fz__flujo--2 { opacity: 0.9; animation: fz-flujo 0.72s linear infinite; }
.hoja__svg .fz__flujo--3 { opacity: 1; stroke-width: 3; animation: fz-flujo 0.46s linear infinite; }
.hoja__svg .fz__flujo--4 { opacity: 1; stroke-width: 3.4; animation: fz-flujo 0.3s linear infinite; }
.hoja__svg .fz__flujo--corto { stroke: #fff2f0; stroke-dasharray: 4 4; }
@keyframes fz-flujo { to { stroke-dashoffset: -12.4; } }
.hoja__svg .fz__hoja { stroke-width: 3.4; stroke-linecap: round; fill: none; opacity: 0; transition: opacity 0.12s ease; }
.hoja__svg .fz__hoja--on { opacity: 0.95; }
.hoja__svg .fz__punta { fill: #ffd34d; stroke: #b07a00; stroke-width: 0.8; opacity: 0; transition: opacity 0.15s ease; }
.hoja__svg .fz__punta--on { opacity: 1; }
.hoja__svg .fz__calor { fill: #ff7a00; opacity: 0; transition: opacity 0.4s ease; }
.hoja__svg .fz__led { fill: #d3d8e0; stroke: #8a94a6; stroke-width: 0.9; transition: fill 0.12s ease; }
.hoja__svg .fz__led--on { fill: #35d36a; stroke: #14803a; filter: drop-shadow(0 0 2.5px #35d36a); }
.hoja__svg .fz__disparo { fill: rgba(255, 59, 48, 0.08); stroke: #ff3b30; stroke-width: 1.8; stroke-dasharray: 5 3; opacity: 0; }
.hoja__svg .fz__disparo--on { opacity: 1; animation: corto-parpadeo 0.6s steps(2) infinite; }
.hoja__svg .fz__chispa { transform-origin: 0 0; animation: fz-chispa 0.5s ease-out forwards; }
.hoja__svg .fz__chispa line { stroke: #ffb300; stroke-width: 1.6; stroke-linecap: round; }
@keyframes fz-chispa { from { opacity: 1; transform: scale(0.5); } to { opacity: 0; transform: scale(1.5); } }
.hoja__svg .reloj__aguja { stroke: #111; stroke-width: 1.3; stroke-linecap: round; }
.hoja__svg .reloj__aguja--hecha { stroke: #1b8a3a; }
.hoja__svg .reloj__texto { fill: #111; font-size: 9.5px; font-variant-numeric: tabular-nums; }
.hoja__svg .reloj__texto--cuenta { fill: #8a5a00; font-weight: 700; }
.hoja__svg .reloj__texto--hecho { fill: #1b8a3a; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .hoja__svg .practica .cable__flujo { animation: none; stroke-dasharray: 1 8; }
  .hoja__svg .fz__flujo--1, .hoja__svg .fz__flujo--2, .hoja__svg .fz__flujo--3, .hoja__svg .fz__flujo--4 { animation: none; stroke-dasharray: 1.6 7; }
  .hoja__svg .fz__disparo--on { animation: none; }
  .boton--alerta { animation: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .hoja__svg .practica .borne--origen .borne__anillo,
  .hoja__svg .practica .borne--pista .borne__anillo { animation: borne-pulso 1.1s ease-in-out infinite; }
  @keyframes borne-pulso { 50% { r: 9; } }
}

@media (max-width: 720px) {
  .practica-barra { gap: 8px 12px; padding: 8px 12px; }
  .modo { flex: 1 1 auto; }
  .modo__boton { flex: 1; padding: 0 10px; }
  .practica-barra__estado { flex: 1 1 100%; justify-content: space-between; }
  .practica-barra__progreso { flex: 1; width: auto; }
  .practica-barra__mensaje { order: 5; flex: 1 1 100%; font-size: 12.5px; }
  .practica-barra__acciones { margin-left: 0; width: 100%; }
  .practica-barra__acciones .boton { flex: 1 1 0; justify-content: center; padding: 0 8px; }
  .practica-barra__acciones .boton__texto { display: none; }
  /* Probar: el motor al lado del selector de modo, los botones en una fila y las entradas de tres en tres */
  .practica-barra__motores { flex: 1 1 auto; justify-content: flex-start; }
  .motor-ficha { flex: 1 1 100%; justify-content: space-between; gap: 8px; padding: 6px 12px 6px 10px; }
  .motor-ficha__cab { min-width: 0; }
  .dial, .medidor__etiqueta { display: none; }
  .medidor__texto { min-width: 0; }
  .medidor__valor { font-size: 15px; }
  .tiempo { flex: 1 1 100%; }
  .velocidad { flex: 1 1 auto; }
  .velocidad__boton { flex: 1; min-width: 0; padding: 0 4px; }
  .tiempo__reloj { min-width: 0; font-size: 12px; }
  .tiempo__estado { display: none; }
  .practica-barra[data-modo="probar"] .practica-barra__acciones { flex-wrap: wrap; }
  .botonera { order: 3; flex: 1 1 100%; gap: 6px; }
  .botonera__titulo { display: none; }
  .entrada-boton { flex: 1 1 calc(33% - 6px); min-width: 0; justify-content: flex-start; padding: 0 8px; gap: 6px; font-size: 12.5px; }
  .entrada-boton__nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .entrada-boton__id { display: none; }
  .consigna { flex: 1 1 100%; margin: 0; }
  .consigna input { flex: 1; width: auto; }
  /* Con tres hojas (Plano, Leyenda, Practicar) y el zoom, la barra de abajo tiene que caber en 360 px:
     la píldora de hojas se encoge y los botones de zoom bajan a 36 px. */
  .estado { gap: 8px; }
  .hojas { flex: 1 1 auto; min-width: 0; }
  .hojas__boton { padding: 0 4px; font-size: 12px; white-space: nowrap; }
  .zoom { margin-left: 0; flex: none; }
  .zoom .boton-icono { width: 36px; height: 36px; }
  .zoom__valor { min-width: 36px; }
}
