/* ===========================================================================
   Estilos específicos de cada escena animada.
   =========================================================================== */

/* ───────────────────────── Bubble Sort: vaso con gas ─────────────────────── */
.bs-glass {
  min-height: 460px;
  display: block;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.04), rgba(167, 139, 250, 0.08));
}
.bs-water {
  position: absolute;
  inset: auto 18px 18px 18px;
  height: 70%;
  border-radius: 0 0 22px 22px;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(124, 58, 237, 0.16));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 2px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 18px 40px -20px rgba(255, 255, 255, 0.4);
}
.bs-fizz {
  position: absolute;
  inset: 18px;
  overflow: hidden;
  pointer-events: none;
}
.bs-fizz-bit {
  position: absolute;
  bottom: -10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, rgba(255, 255, 255, 0.2));
  opacity: 0.5;
  animation: fizz-rise linear infinite;
}
@keyframes fizz-rise {
  0% {
    transform: translateY(0) scale(0.6);
    opacity: 0;
  }
  15% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-360px) scale(1.1);
    opacity: 0;
  }
}

.bs-bubble {
  position: absolute;
  bottom: 22%;
  transform: translate(-50%, 0);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(
    circle at 32% 28%,
    hsla(var(--h), 90%, 82%, 0.95),
    hsla(var(--h), 85%, 55%, 0.65) 60%,
    hsla(var(--h), 80%, 40%, 0.5)
  );
  border: 1.5px solid hsla(var(--h), 90%, 85%, 0.7);
  box-shadow:
    0 8px 24px -6px hsla(var(--h), 80%, 40%, 0.6),
    inset 0 6px 12px -4px rgba(255, 255, 255, 0.7);
  color: #08121f;
  font-weight: 700;
  transition:
    left 0.5s cubic-bezier(0.34, 1.4, 0.5, 1),
    bottom 0.5s ease,
    transform 0.5s ease,
    box-shadow 0.3s,
    filter 0.3s;
  animation: bob 3.5s ease-in-out infinite;
  will-change: left, transform;
}
.bs-bubble.no-anim {
  transition: none;
}
.bs-val {
  font-size: 15px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}
@keyframes bob {
  50% {
    transform: translate(-50%, -8px);
  }
}
.bs-bubble.compare {
  filter: brightness(1.25);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.85),
    0 10px 30px -4px hsla(var(--h), 90%, 60%, 0.8);
  z-index: 5;
}
.bs-bubble.swapping {
  animation: swirl 0.5s ease;
  z-index: 6;
}
@keyframes swirl {
  50% {
    transform: translate(-50%, -22px) rotate(180deg) scale(1.06);
  }
  100% {
    transform: translate(-50%, 0) rotate(360deg);
  }
}
.bs-bubble.settled {
  bottom: 24%;
  box-shadow:
    0 0 0 2px rgba(52, 211, 153, 0.8),
    0 8px 24px -6px rgba(52, 211, 153, 0.5);
}
.bs-bubble.win {
  animation: pop-win 0.5s ease;
}
@keyframes pop-win {
  40% {
    transform: translate(-50%, -16px) scale(1.12);
  }
}

/* ──────────────────── Binary Search: pasillo de puertas ──────────────────── */
.bsr-stage {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.bsr-target {
  align-self: center;
  font-size: 15px;
  color: var(--ink-dim);
  padding: 8px 18px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--panel);
}
.bsr-target .mono {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 16px;
}
.bsr-hall {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 10px 6px 64px; /* banda inferior libre para que el narrador no pise los #n */
  perspective: 900px;
}
.bsr-door {
  position: relative;
  width: 52px;
  height: 180px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #1b1b2e, #131322);
  border: 1px solid var(--stroke);
  display: grid;
  place-items: center;
  transition:
    transform 0.5s cubic-bezier(0.3, 0.8, 0.3, 1),
    opacity 0.5s,
    filter 0.4s,
    box-shadow 0.4s,
    border-color 0.4s;
  transform-style: preserve-3d;
}
.bsr-door-frame {
  position: absolute;
  inset: 6px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(251, 191, 36, 0.18), transparent 70%);
}
.bsr-treasure {
  font-size: 26px;
  opacity: 0;
  transform: scale(0.4);
  transition: 0.4s 0.25s;
}
.bsr-door-leaf {
  position: absolute;
  inset: 6px;
  border-radius: 5px;
  background: linear-gradient(180deg, #2a2a44, #20203a);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  transform-origin: left center;
  transition:
    transform 0.55s cubic-bezier(0.3, 0.8, 0.3, 1),
    background 0.4s;
  backface-visibility: hidden;
}
.bsr-door-leaf span {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink-dim);
}
.bsr-idx {
  position: absolute;
  bottom: -22px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
}
.bsr-door.in-range {
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 0 22px -6px rgba(52, 211, 153, 0.45);
}
.bsr-door.in-range .bsr-door-leaf {
  background: linear-gradient(180deg, #243a33, #1b2f2a);
}
.bsr-door.in-range .bsr-door-leaf span {
  color: #c9ffe9;
}
.bsr-door.probing {
  z-index: 4;
  border-color: var(--amber);
  box-shadow: 0 0 30px -4px rgba(251, 191, 36, 0.6);
}
.bsr-door.probing .bsr-door-leaf {
  transform: rotateY(-115deg);
}
.bsr-door.collapsed {
  transform: translateY(260px) rotateZ(14deg);
  opacity: 0;
  filter: blur(2px);
}
.bsr-door.found {
  z-index: 5;
  border-color: var(--amber);
  box-shadow: 0 0 44px -2px rgba(251, 191, 36, 0.85);
  transform: translateY(-12px);
}
.bsr-door.found .bsr-door-leaf {
  transform: rotateY(-120deg);
}
.bsr-door.found .bsr-treasure {
  opacity: 1;
  transform: scale(1.15);
}
.bsr-door.fail {
  filter: grayscale(0.7) brightness(0.7);
}

/* ──────────────────── Quick Sort: alumnos por altura + foco ──────────────── */
.qs-stage {
  min-height: 460px;
}
.qs-floor {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 64px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
}
.qs-band {
  position: absolute;
  bottom: 66px;
  top: 40px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  opacity: 0;
  transition:
    left 0.45s cubic-bezier(0.3, 0.8, 0.3, 1),
    width 0.45s,
    opacity 0.3s;
  pointer-events: none;
}
.qs-bar {
  position: absolute;
  bottom: 66px;
  width: 46px;
  transform: translateX(-50%);
  border-radius: 9px 9px 4px 4px;
  background: linear-gradient(180deg, #3a3a5c, #26263f);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  transition:
    left 0.5s cubic-bezier(0.34, 1.3, 0.5, 1),
    filter 0.3s,
    box-shadow 0.3s,
    background 0.3s,
    transform 0.3s;
  will-change: left;
}
.qs-bar.no-anim {
  transition: none;
}
.qs-cap {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.qs-spot {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  opacity: 0;
}
.qs-bar.qs-scan {
  background: linear-gradient(180deg, #155e6b, #0e3f49);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.7);
  z-index: 3;
}
.qs-bar.qs-pivot {
  background: linear-gradient(180deg, #b8860b, #7a5a06);
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.9),
    0 0 36px -4px rgba(251, 191, 36, 0.7);
  z-index: 4;
}
/* cono de foco sobre el pivote */
.qs-bar.qs-pivot .qs-spot {
  opacity: 1;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-bottom: 220px solid rgba(251, 191, 36, 0.12);
  filter: blur(2px);
}
.qs-bar.qs-settled {
  background: linear-gradient(180deg, #1f7a5a, #14543d);
  box-shadow: 0 0 0 1.5px rgba(52, 211, 153, 0.7);
}
.qs-bar.qs-win {
  animation: qs-pop 0.5s ease;
}
@keyframes qs-pop {
  40% {
    transform: translateX(-50%) translateY(-14px) scale(1.05);
  }
}

/* ──────────────────── Merge Sort: cartas de casino ───────────────────────── */
.ms-stage {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding-bottom: 64px; /* aire para que el narrador no quede pegado a las cartas */
}
.ms-row {
  position: relative;
  height: 96px;
  margin: 0 8px;
}
.ms-row-label {
  position: absolute;
  top: -20px;
  left: 0;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ms-ghost {
  opacity: 0.4;
  filter: saturate(0.5);
}
.ms-band {
  position: absolute;
  top: -6px;
  bottom: -6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0;
  transition:
    left 0.45s cubic-bezier(0.3, 0.8, 0.3, 1),
    width 0.45s,
    opacity 0.3s;
}
.ms-divider {
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 2px;
  background: repeating-linear-gradient(180deg, var(--amber) 0 6px, transparent 6px 12px);
  opacity: 0;
  transform: translateX(-50%);
  transition:
    left 0.4s,
    opacity 0.3s;
}
.ms-card {
  position: absolute;
  top: 50%;
  width: 60px;
  height: 84px;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #08121f;
  font-weight: 800;
  font-size: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  box-shadow:
    0 8px 20px -8px rgba(0, 0, 0, 0.7),
    inset 0 2px 8px rgba(255, 255, 255, 0.45);
  transition:
    left 0.5s cubic-bezier(0.34, 1.25, 0.5, 1),
    transform 0.3s,
    box-shadow 0.3s,
    filter 0.3s;
  will-change: left;
}
.ms-card span {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}
.ms-card.no-anim {
  transition: none;
}
.ms-left {
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.85),
    0 8px 20px -8px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%) translateY(-6px);
}
.ms-right {
  box-shadow:
    0 0 0 2px rgba(167, 139, 250, 0.9),
    0 8px 20px -8px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%) translateY(6px);
}
.ms-merged {
  box-shadow:
    0 0 0 2px rgba(52, 211, 153, 0.9),
    0 10px 26px -6px rgba(52, 211, 153, 0.5);
  z-index: 3;
}
.ms-card.ms-done {
  animation: ms-pop 0.45s ease;
}
@keyframes ms-pop {
  40% {
    transform: translate(-50%, -50%) translateY(-12px) scale(1.06);
  }
}

/* ───────────────────────── Stack: pila de platos ─────────────────────────── */
.stk-stage {
  min-height: 460px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.stk-column {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  margin-bottom: 40px;
}
.stk-base {
  width: 210px;
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2a2a44, #15152a);
  border: 1px solid var(--stroke);
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.7);
}
.stk-pile {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.stk-plate {
  height: 30px;
  border-radius: 16px / 50%;
  display: grid;
  place-items: center;
  color: #08121f;
  font-weight: 700;
  font-size: 14px;
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.5),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.stk-plate span {
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}
.stk-plate.drop {
  animation: plate-drop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes plate-drop {
  0% {
    transform: translateY(-340px) scaleY(0.8);
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  75% {
    transform: translateY(0) scaleY(1.18) scaleX(0.9);
  }
  100% {
    transform: translateY(0) scaleY(1) scaleX(1);
  }
}
.stk-plate.eject {
  animation: plate-eject 0.55s cubic-bezier(0.4, 0, 0.7, 0.4) forwards;
}
@keyframes plate-eject {
  to {
    transform: translate(360px, -60px) rotate(38deg);
    opacity: 0;
  }
}
.stk-lifo {
  position: absolute;
  top: 26px;
  right: 30px;
  text-align: right;
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.1);
  letter-spacing: 2px;
}
.stk-lifo small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-faint);
}
.stk-lifo.shake {
  animation: shake 0.45s;
  color: rgba(251, 113, 133, 0.5);
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* ── Bounded Stack (pila acotada) ─────────────────────────────────── */
.bstk-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bstk-frame {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 2px dashed var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}
.bstk-frame.shake {
  animation: shake 0.45s;
}
.bstk-slot {
  width: 190px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px dashed var(--stroke);
  color: var(--ink-faint);
  transition:
    transform 0.18s,
    box-shadow 0.18s;
}
.bstk-slot.is-filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.3);
  color: #08121f;
  font-weight: 700;
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}
.bstk-slot.is-top {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}
.bstk-slot.pulse {
  animation: bstk-pulse 0.4s ease;
}
@keyframes bstk-pulse {
  0% {
    transform: scale(0.9);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}
.bstk-idx {
  font-family: var(--mono, monospace);
  font-size: 11px;
  opacity: 0.7;
  min-width: 30px;
}
.bstk-slot.is-filled .bstk-idx {
  color: rgba(8, 18, 31, 0.6);
}
.bstk-val {
  margin-left: auto;
  font-size: 15px;
}
.bstk-cap {
  position: absolute;
  top: 16px;
  right: 18px;
  font-family: var(--mono, monospace);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  color: var(--ink-faint);
  transition:
    color 0.2s,
    border-color 0.2s,
    background 0.2s;
}
.bstk-cap.is-hot {
  color: #fff;
  background: #e11d48;
  border-color: #e11d48;
}

/* ── Queue (cola FIFO) ────────────────────────────────────────────── */
.q-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-track {
  display: flex;
  align-items: center;
  gap: 14px;
}
.q-end {
  font-family: var(--mono, monospace);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.q-lane {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  min-height: 72px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px dashed var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.q-card {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #08121f;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}
.q-card.enter {
  animation: q-enter 0.4s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.q-card.leave {
  animation: q-leave 0.4s ease forwards;
}
@keyframes q-enter {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
@keyframes q-leave {
  to {
    opacity: 0;
    transform: translateX(-46px) scale(0.85);
    margin-right: -60px;
  }
}

/* ── Circular Buffer (ring buffer) ────────────────────────────────── */
.cb-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cb-ring {
  position: relative;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 1px dashed var(--stroke);
}
.cb-ring.shake {
  animation: shake 0.45s;
}
/* Slots are centred on their computed (left, top) via negative margin, leaving
   `transform` free for the pulse animation. */
.cb-slot {
  position: absolute;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px dashed var(--stroke);
  color: var(--ink-faint);
}
.cb-slot.is-filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.3);
  color: #08121f;
  font-weight: 700;
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.45);
}
.cb-slot.pulse {
  animation: cb-pulse 0.4s ease;
}
@keyframes cb-pulse {
  0% {
    transform: scale(0.8);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}
.cb-slot__i {
  font-family: var(--mono, monospace);
  font-size: 9px;
  opacity: 0.65;
}
.cb-slot.is-filled .cb-slot__i {
  color: rgba(8, 18, 31, 0.6);
}
.cb-slot__v {
  font-size: 15px;
  line-height: 1;
}
.cb-ptr {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--mono, monospace);
  font-size: 12px;
  font-weight: 700;
  color: #06122e;
  box-shadow: 0 4px 10px -3px rgba(0, 0, 0, 0.6);
}
.cb-ptr--head {
  background: #34d399;
}
.cb-ptr--tail {
  background: #fbbf24;
}
.cb-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}
.cb-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.cb-dot--head {
  background: #34d399;
}
.cb-dot--tail {
  background: #fbbf24;
}

/* ── Hash Table (encadenamiento separado) ─────────────────────────── */
.ht-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ht-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 460px;
}
.ht-bucket {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  transition:
    border-color 0.2s,
    background 0.2s;
}
.ht-bucket.is-flash {
  border-color: var(--accent, #fbbf24);
  background: rgba(251, 191, 36, 0.08);
}
.ht-idx {
  font-family: var(--mono, monospace);
  font-size: 12px;
  color: var(--ink-faint);
  min-width: 28px;
}
.ht-chain {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ht-empty {
  color: var(--ink-faint);
  opacity: 0.4;
}
.ht-arrow {
  color: var(--ink-faint);
  opacity: 0.5;
}
.ht-entry {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid var(--stroke);
  background: var(--bg-elev, #16162c);
  font-family: var(--mono, monospace);
  animation: ht-pop 0.3s ease;
}
.ht-entry.is-hot {
  border-color: var(--accent, #fbbf24);
  box-shadow: 0 0 0 1px var(--accent, #fbbf24);
}
@keyframes ht-pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.ht-key {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}
.ht-val {
  font-size: 12px;
  color: var(--ink-faint);
}

/* ── Priority Queue (min-heap: árbol + arreglo) ───────────────────── */
.pq-stage {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
}
.pq-tree {
  position: relative;
  width: 480px;
  max-width: 100%;
}
.pq-links {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pq-links path {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 1.5;
}
.pq-node {
  position: absolute;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #04122e;
  font-family: var(--mono, monospace);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.6);
}
.pq-node.is-root {
  background: linear-gradient(180deg, #34d399, #059669);
  outline: 2px solid #34d399;
  outline-offset: 2px;
}
.pq-node.pulse,
.pq-cell.pulse {
  animation: cb-pulse 0.4s ease;
}
.pq-array {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.pq-arr-label {
  font-family: var(--mono, monospace);
  font-size: 12px;
  color: var(--ink-faint);
  margin-right: 4px;
}
.pq-arr-empty {
  color: var(--ink-faint);
  opacity: 0.4;
}
.pq-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 30px;
  border: 1px solid var(--border, var(--stroke));
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-elev, #16162c);
}
.pq-cell.is-root {
  border-color: #34d399;
  box-shadow: 0 0 0 1px #34d399;
}
.pq-cell__i {
  width: 100%;
  text-align: center;
  font-size: 9px;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.05);
  font-variant-numeric: tabular-nums;
}
.pq-cell__v {
  padding: 4px 8px;
  font-family: var(--mono, monospace);
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ── Deque (dos extremos) — reusa .q-track / .q-end de la cola ─────── */
.dq-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dq-lane {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  min-height: 72px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px dashed var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}
.dq-card {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #08121f;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}
.dq-card.enter-left {
  animation: dq-enter-left 0.38s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.dq-card.enter-right {
  animation: dq-enter-right 0.38s cubic-bezier(0.3, 1.3, 0.5, 1);
}
@keyframes dq-enter-left {
  from {
    opacity: 0;
    transform: translateX(-44px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
@keyframes dq-enter-right {
  from {
    opacity: 0;
    transform: translateX(44px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
.dq-transport .spacer {
  flex: 0 1 24px;
}

/* ── Set (miembros únicos, dedup) ─────────────────────────────────── */
.set-stage {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.set-members {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-content: center;
  max-width: 520px;
}
.set-empty {
  font-family: var(--mono, monospace);
  font-size: 28px;
  color: var(--ink-faint);
  opacity: 0.5;
}
.set-chip {
  padding: 10px 18px;
  border-radius: 22px;
  color: #08121f;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.6);
}
.set-chip.enter {
  animation: set-pop 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.set-chip.bounce {
  animation: set-bounce 0.5s ease;
  outline: 2px solid #fff;
  outline-offset: 2px;
}
@keyframes set-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes set-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  30% {
    transform: translateY(-10px) scale(1.08);
  }
  60% {
    transform: translateY(0) scale(0.96);
  }
}

/* ── Graph (nodos + ejes, lista de adyacencia) ────────────────────── */
.gr-stage {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
}
.gr-board {
  position: relative;
  width: 300px;
  height: 300px;
}
.gr-links {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.gr-links line {
  stroke: var(--stroke);
  stroke-width: 2;
}
.gr-links line.is-hot {
  stroke: #fbbf24;
  stroke-width: 3;
}
.gr-node {
  position: absolute;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #04122e;
  font-family: var(--mono, monospace);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.6);
  transition:
    transform 0.15s,
    outline-color 0.15s;
}
.gr-node:hover {
  transform: scale(1.08);
}
.gr-node.is-selected {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  transform: scale(1.1);
}
.gr-node.is-neighbor {
  outline: 2px solid #34d399;
  outline-offset: 2px;
}
.gr-adj {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--mono, monospace);
  font-size: 13px;
  min-width: 200px;
}
.gr-adj-label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.gr-adj-empty {
  color: var(--ink-faint);
  opacity: 0.4;
}
.gr-adj-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gr-adj-key {
  font-weight: 700;
  color: var(--ink);
  min-width: 16px;
}
.gr-adj-arrow {
  color: var(--ink-faint);
  opacity: 0.6;
}
.gr-adj-vals {
  color: var(--ink-faint);
}
