/* ==========================================================================
   ALGORITMIA INTERACTIVA - SISTEMA DE DISEÑO Y ESTILOS
   Inspirado en la dirección technical-glow y educational-stepper de zz-skills
   Sin dependencias externas - 100% Nativo, Responsivo y Accesible
   ========================================================================== */

:root {
  /* Tipografías con fallbacks robustos */
  --font-sans: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, Consolas, monospace;

  /* Paleta Técnica Slate & Glow */
  --bg-deep: #070b14;
  --bg-main: #0c1220;
  --bg-card: #131c31;
  --bg-card-alt: #18243e;
  --bg-glass: rgba(19, 28, 49, 0.75);
  
  --border-dim: #1e2e4f;
  --border-light: #2d426e;
  --border-glow: #38bdf8;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-accent: #38bdf8;

  /* Acentos de estado y flujo */
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.35);
  --coral: #f43f5e;
  --coral-glow: rgba(244, 63, 94, 0.35);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.35);
  --indigo: #6366f1;

  /* Espaciado */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3.5rem;
  --space-2xl: 5rem;

  /* Bordes y Sombras */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px var(--cyan-glow);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset y Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-deep);
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(168, 85, 247, 0.07) 0%, transparent 45%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-main) 100%);
  color: var(--text-main);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Barra de lectura / progreso superior */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  z-index: 1000;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--emerald), var(--purple));
  transition: width 0.1s ease;
  box-shadow: 0 0 10px var(--cyan);
}

/* Barra de Navegación */
.navbar {
  position: sticky;
  top: 4px;
  z-index: 900;
  background: rgba(12, 18, 32, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
  text-decoration: none;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--cyan), var(--indigo));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 0 14px var(--cyan-glow);
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition-fast);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--emerald);
  border-radius: var(--radius-full);
}

/* Contenedor Principal */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header Hero */
.hero-section {
  padding: var(--space-xl) 0 var(--space-lg);
  text-align: center;
  position: relative;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 1rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--cyan);
  border-radius: var(--radius-full);
  margin-bottom: 1.25rem;
  animation: pulsePill 3s infinite alternate ease-in-out;
}

@keyframes pulsePill {
  from { box-shadow: 0 0 6px rgba(56, 189, 248, 0.2); }
  to { box-shadow: 0 0 16px rgba(56, 189, 248, 0.5); }
}

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.text-gradient {
  background: linear-gradient(135deg, #ffffff 30%, var(--cyan) 75%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto 2.5rem;
  font-weight: 400;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-primary {
  background: var(--cyan);
  color: #070b14;
  box-shadow: 0 0 18px var(--cyan-glow);
}

.btn-primary:hover {
  background: #7dd3fc;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--cyan);
  transform: translateY(-2px);
}

.btn-icon-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Secciones de Contenido */
.section-block {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border-dim);
}

.section-header {
  margin-bottom: var(--space-lg);
  max-width: 800px;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
}

/* Tarjetas y Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-highlight {
  border-left: 4px solid var(--cyan);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Características de un Algoritmo */
.feature-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Simulación Cotidiana Interactiva */
.cotidiano-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.cotidiano-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cotidiano-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cotidiano-step-item {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.cotidiano-step-item.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--cyan);
  color: var(--text-main);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.cotidiano-step-item.completed {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--emerald);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
}

.cotidiano-step-item.active .step-num {
  background: var(--cyan);
  color: #070b14;
}

.cotidiano-step-item.completed .step-num {
  background: var(--emerald);
  color: #070b14;
}

/* Laboratorio de Variables y Constantes */
.lab-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

@media (max-width: 900px) {
  .lab-container {
    grid-template-columns: 1fr;
  }
}

.memory-rack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memory-slot {
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.memory-slot:hover {
  border-color: var(--border-light);
}

.memory-slot.is-constant {
  border-left: 4px solid var(--amber);
}

.memory-slot.is-variable {
  border-left: 4px solid var(--cyan);
}

.slot-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.slot-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
}

.slot-type-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  width: fit-content;
}

.type-int { background: rgba(56, 189, 248, 0.15); color: var(--cyan); }
.type-string { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.type-bool { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.type-const { background: rgba(245, 158, 11, 0.15); color: var(--amber); }

.slot-value-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slot-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  min-width: 70px;
  text-align: center;
  color: #fff;
  transition: all 0.2s ease;
}

.slot-value.flash-updated {
  animation: flashUpdate 0.5s ease-out;
}

@keyframes flashUpdate {
  0% { transform: scale(1.15); border-color: var(--emerald); color: var(--emerald); box-shadow: 0 0 15px var(--emerald); }
  100% { transform: scale(1); }
}

.slot-controls {
  display: flex;
  gap: 0.35rem;
}

.btn-ctrl {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 700;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
}

.btn-ctrl:hover {
  background: var(--cyan);
  color: #070b14;
  border-color: var(--cyan);
}

.btn-ctrl.btn-const-locked:hover {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}

.lab-output {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  justify-content: space-between;
}

.calc-display {
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-dim);
  padding-bottom: 0.5rem;
  font-size: 0.9rem;
}

.calc-row.total-row {
  border-bottom: none;
  padding-top: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--emerald);
}

.toast-box {
  min-height: 48px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: all var(--transition-normal);
  opacity: 0;
  transform: translateY(6px);
}

.toast-box.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

/* ==========================================================================
   ESTRUCTURAS DE CONTROL: SELECTOR DE PESTAÑAS Y DIAGRAMAS
   ========================================================================== */

.tabs-wrapper {
  margin-top: 1.5rem;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-dim);
  scrollbar-width: thin;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--cyan);
  color: #070b14;
  border-color: var(--cyan);
  box-shadow: 0 0 15px var(--cyan-glow);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
  margin-top: 2rem;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Vista Dividida: Diagrama SVG + Explicación Interactiva */
.structure-workbench {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

@media (max-width: 992px) {
  .structure-workbench {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   SISTEMA DE NODOS DE DIAGRAMAS SVG - CONTRASTE DIRIGIDO
   Nodos inactivos: atenuados y en reposo (bajo contraste)
   Nodos corriendo/activos: máximo resplandor neón y contraste visual
   ========================================================================== */

.flowchart-viewport {
  background: #050811;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  position: relative;
  overflow: hidden;
}

.flowchart-viewport::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 20px 20px;
  pointer-events: none;
}

.flowchart-svg {
  width: 100%;
  max-width: 500px;
  height: auto;
  z-index: 2;
}

/* 1. Nodos Inactivos / En Reposo (Muted & Dimmed) */
.node-shape {
  stroke-width: 1.6;
  fill: #080d18;
  stroke: #1e2c45;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.node-oval,
.node-rect,
.node-diamond {
  fill: #080d18;
  stroke: #1e2c45;
}

.node-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  fill: #62748e;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  transition: fill 0.25s ease, font-weight 0.25s ease, filter 0.25s ease;
}

.node-subtext {
  font-family: var(--font-sans);
  font-size: 9.5px;
  fill: #415168;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* 2. Conectores y flechas */
.flow-arrow {
  stroke: #1e2c45;
  stroke-width: 1.8;
  fill: none;
  transition: stroke 0.25s ease, filter 0.25s ease;
  marker-end: url(#arrow-default);
}

.flow-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  user-select: none;
}

.label-true { fill: var(--emerald); }
.label-false { fill: var(--coral); }

/* 3. NODO EN EJECUCIÓN (EL QUE ESTÁ CORRIENDO ACTUALMENTE) - MÁXIMO CONTRASTE */
.node-shape.node-active,
.node-shape.node-running {
  fill: #0c2f59 !important;
  stroke: #38bdf8 !important;
  stroke-width: 3.2px !important;
  filter: drop-shadow(0 0 14px #38bdf8) drop-shadow(0 0 28px rgba(56, 189, 248, 0.6)) !important;
  animation: nodeRunningPulse 1.2s infinite ease-in-out;
}

@keyframes nodeRunningPulse {
  0%, 100% {
    filter: drop-shadow(0 0 12px #38bdf8) drop-shadow(0 0 22px rgba(56, 189, 248, 0.5));
    stroke: #38bdf8;
  }
  50% {
    filter: drop-shadow(0 0 20px #7dd3fc) drop-shadow(0 0 38px rgba(56, 189, 248, 0.85));
    stroke: #bae6fd;
    fill: #0f3d73;
  }
}

/* 4. NODO RAMA VERDADERA ACTIVA (ESMERALDA VIVO) */
.node-shape.node-true-branch {
  fill: #06452e !important;
  stroke: #10b981 !important;
  stroke-width: 3.2px !important;
  filter: drop-shadow(0 0 16px #10b981) drop-shadow(0 0 32px rgba(16, 185, 129, 0.6)) !important;
  animation: nodeTruePulse 1.2s infinite ease-in-out;
}

@keyframes nodeTruePulse {
  0%, 100% { filter: drop-shadow(0 0 12px #10b981); stroke: #10b981; }
  50% { filter: drop-shadow(0 0 22px #34d399) drop-shadow(0 0 38px rgba(16, 185, 129, 0.8)); stroke: #6ee7b7; fill: #085a3c; }
}

/* 5. NODO RAMA FALSA ACTIVA (CORAL VIVO) */
.node-shape.node-false-branch {
  fill: #470919 !important;
  stroke: #f43f5e !important;
  stroke-width: 3.2px !important;
  filter: drop-shadow(0 0 16px #f43f5e) drop-shadow(0 0 32px rgba(244, 63, 94, 0.6)) !important;
  animation: nodeFalsePulse 1.2s infinite ease-in-out;
}

@keyframes nodeFalsePulse {
  0%, 100% { filter: drop-shadow(0 0 12px #f43f5e); stroke: #f43f5e; }
  50% { filter: drop-shadow(0 0 22px #fb7185) drop-shadow(0 0 38px rgba(244, 63, 94, 0.8)); stroke: #fda4af; fill: #5c0c20; }
}

/* 6. NODO VISITADO / YA COMPLETADO (Rastro claro del camino, pero subordinado) */
.node-shape.node-visited {
  fill: #0a182d !important;
  stroke: #2563eb !important;
  stroke-width: 1.8px !important;
  filter: none !important;
  animation: none !important;
}

/* 7. TEXTO DE NODOS ACTIVOS (Blanco brillante de alto contraste) */
.node-shape.node-active ~ .node-text,
.node-shape.node-running ~ .node-text,
.node-shape.node-true-branch ~ .node-text,
.node-shape.node-false-branch ~ .node-text,
.text-active {
  fill: #ffffff !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.7));
}

.node-shape.node-visited ~ .node-text {
  fill: #94a3b8 !important;
  font-weight: 600 !important;
}

/* 8. FLECHAS ACTIVAS ANIMADAS */
.flow-arrow.flow-active {
  stroke: #38bdf8 !important;
  stroke-width: 2.8px !important;
  stroke-dasharray: 8 5;
  animation: flowDash 0.7s linear infinite;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.9));
  marker-end: url(#arrow-cyan) !important;
}

.flow-arrow.flow-active-true {
  stroke: #10b981 !important;
  stroke-width: 2.8px !important;
  stroke-dasharray: 8 5;
  animation: flowDash 0.7s linear infinite;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.9));
  marker-end: url(#arrow-emerald) !important;
}

.flow-arrow.flow-active-false {
  stroke: #f43f5e !important;
  stroke-width: 2.8px !important;
  stroke-dasharray: 8 5;
  animation: flowDash 0.7s linear infinite;
  filter: drop-shadow(0 0 8px rgba(244, 63, 94, 0.9));
  marker-end: url(#arrow-coral) !important;
}

@keyframes flowDash {
  to { stroke-dashoffset: -26; }
}

/* Panel interactivo al lado del diagrama */
.structure-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
}

.syntax-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.interactive-test-bench {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bench-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bench-inputs {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.bench-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.input-styled {
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  color: #fff;
  font-family: var(--font-mono);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
}

.input-styled:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.execution-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
}

.execution-badge.is-true {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
}

.execution-badge.is-false {
  border-color: var(--coral);
  color: var(--coral);
  background: rgba(244, 63, 94, 0.1);
}

/* ==========================================================================
   DEPURADOR PASO A PASO (PSEUDOCÓDIGO VS DIAGRAMA)
   ========================================================================== */

.stepper-container {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.stepper-header {
  padding: 1rem 1.5rem;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.algorithm-select-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.select-styled {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: #fff;
  font-family: inherit;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.select-styled:focus {
  border-color: var(--cyan);
}

.mode-toggle-group {
  display: flex;
  background: var(--bg-card);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  gap: 0.25rem;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--cyan);
  color: #070b14;
}

/* Barra de Controles de Ejecución */
.stepper-toolbar {
  padding: 0.75rem 1.5rem;
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.control-buttons {
  display: flex;
  gap: 0.5rem;
}

.step-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.step-btn:hover:not(:disabled) {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
}

.step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.step-btn.play-btn {
  background: var(--emerald);
  color: #070b14;
  border-color: var(--emerald);
}

.step-btn.play-btn:hover:not(:disabled) {
  background: #34d399;
}

.step-btn.pause-btn {
  background: var(--amber);
  color: #070b14;
  border-color: var(--amber);
}

.stepper-status-pill {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
}

/* Área de Ejecución Dividida (Pseudocódigo + Diagrama Sincronizado) */
.debugger-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 480px;
}

@media (max-width: 992px) {
  .debugger-grid {
    grid-template-columns: 1fr;
  }
}

/* Panel de Pseudocódigo */
.pseudocode-panel {
  background: #090e1a;
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.65rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.code-editor {
  flex: 1;
  padding: 1rem 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
  overflow-x: auto;
}

.code-line {
  display: flex;
  padding: 0.1rem 1rem;
  border-left: 4px solid transparent;
  transition: background 0.15s ease;
}

.code-line.active {
  background: rgba(56, 189, 248, 0.15);
  border-left-color: var(--cyan);
}

.code-line.active .line-num {
  color: var(--cyan);
  font-weight: 700;
}

.line-num {
  width: 32px;
  color: var(--text-dim);
  user-select: none;
  font-size: 0.8rem;
}

.line-content {
  flex: 1;
  white-space: pre;
}

/* Sintaxis Pseudocódigo */
.kw { color: #f43f5e; font-weight: 700; } /* Palabras clave: SI, ENTONCES, MIENTRAS */
.id { color: #38bdf8; }                   /* Identificadores: edad, i, saldo */
.num { color: #fbbf24; }                  /* Números: 18, 0, 10 */
.str { color: #34d399; }                  /* Strings: "Aprobado" */
.com { color: #64748b; font-style: italic; } /* Comentarios */

/* Panel Sincronizado: Diagrama o Watch */
.sync-panel {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

.sync-viewport {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg-deep);
}

/* Footer del Depurador: Watch Variables y Consola */
.debugger-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border-dim);
  background: var(--bg-deep);
}

@media (max-width: 768px) {
  .debugger-footer {
    grid-template-columns: 1fr;
  }
}

.watch-panel, .console-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.watch-panel {
  border-right: 1px solid var(--border-dim);
}

.watch-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.watch-table th {
  text-align: left;
  color: var(--text-dim);
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-dim);
}

.watch-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.watch-val {
  color: var(--emerald);
  font-weight: 700;
}

.console-output {
  background: #060911;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #38bdf8;
  height: 90px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.console-msg {
  display: flex;
  gap: 0.5rem;
}

.console-msg::before {
  content: '>';
  color: var(--text-dim);
}

/* Explicación didáctica contextual */
.step-explanation-box {
  background: rgba(56, 189, 248, 0.06);
  border-left: 3px solid var(--cyan);
  padding: 0.75rem 1rem;
  margin: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* ==========================================================================
   MINI EVALUADOR / QUIZ RÁPIDO
   ========================================================================== */
.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.quiz-option-btn {
  text-align: left;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quiz-option-btn:hover {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.05);
}

.quiz-option-btn.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: var(--emerald) !important;
  color: var(--emerald) !important;
}

.quiz-option-btn.incorrect {
  background: rgba(244, 63, 94, 0.2) !important;
  border-color: var(--coral) !important;
  color: var(--coral) !important;
}

.quiz-feedback {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-dim);
  background: var(--bg-deep);
  padding: var(--space-lg) 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-credits {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Media Queries para Responsividad Completa */
@media (max-width: 640px) {
  .nav-links {
    display: none; /* Simplificado para móviles */
  }
  
  .hero-section {
    padding: var(--space-lg) 0 var(--space-md);
  }

  .lab-container, .structure-workbench {
    padding: 1.25rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

