/* Puente de temas para las sub-aplicaciones (--engine-*, --bg/--accent/…, --wiki-*)
   Cargar después de la hoja propia de cada sub-app. */

/* Tema Dark */
body.theme-dark {
  --engine-bg:         #050d17;
  --engine-panel:      rgba(5, 16, 30, 0.9);
  --engine-panel-soft: rgba(64, 196, 255, 0.06);
  --engine-line:       rgba(64, 196, 255, 0.18);
  --engine-text:       #ddeeff;
  --engine-muted:      #6a9fcf;
  --engine-cyan:       #40c4ff;
  --engine-blue:       #2979ff;
  --engine-violet:     #7c4dff;
  --engine-pink:       #ffab40;
  --engine-grad:       linear-gradient(135deg, #40c4ff 0%, #2979ff 25%, #7c4dff 60%, #ffab40 100%);
  --engine-shadow:     0 22px 54px rgba(0, 0, 0, 0.5);

  --bg:           #050d17;
  --panel-bg:     #0d1829;
  --panel-border: rgba(64, 196, 255, 0.18);
  --cell-bg:      #101f33;
  --cell-border:  rgba(64, 196, 255, 0.24);
  --cell-text:    #ddeeff;
  --text-main:    #ddeeff;
  --text-muted:   #6a9fcf;
  --text-dim:     #3f6a94;
  --accent:       #40c4ff;
  --accent-dim:   rgba(64, 196, 255, 0.18);
  --accent-glow:  rgba(64, 196, 255, 0.3);
  --accent2:      #7c4dff;
  --accent2-dim:  rgba(124, 77, 255, 0.16);
  --error:        #ff5470;
  --error-glow:   rgba(255, 84, 112, 0.22);
  --gold:         #ffc94a;
}

/* Tema Light */
body.theme-light {
  --engine-bg:         #f8fafc;
  --engine-panel:      rgba(255, 255, 255, 0.92);
  --engine-panel-soft: rgba(15, 23, 42, 0.04);
  --engine-line:       rgba(15, 23, 42, 0.12);
  --engine-text:       #0f172a;
  --engine-muted:      #475569;
  --engine-cyan:       #0ea5e9;
  --engine-blue:       #6366f1;
  --engine-violet:     #8b5cf6;
  --engine-pink:       #ec4899;
  --engine-grad:       linear-gradient(135deg, #0ea5e9 0%, #6366f1 28%, #8b5cf6 62%, #ec4899 100%);
  --engine-shadow:     0 18px 44px rgba(15, 23, 42, 0.14);

  --bg:           #f8fafc;
  --panel-bg:     #ffffff;
  --panel-border: rgba(15, 23, 42, 0.12);
  --cell-bg:      #f1f5f9;
  --cell-border:  rgba(15, 23, 42, 0.16);
  --cell-text:    #0f172a;
  --text-main:    #0f172a;
  --text-muted:   #475569;
  --text-dim:     #7d8da3;
  --accent:       #6366f1;
  --accent-dim:   rgba(99, 102, 241, 0.14);
  --accent-glow:  rgba(99, 102, 241, 0.24);
  --accent2:      #0ea5e9;
  --accent2-dim:  rgba(14, 165, 233, 0.14);
  --error:        #dc2626;
  --error-glow:   rgba(220, 38, 38, 0.14);
  --gold:         #b45309;
}

/* Fondos y sombras oscuros, atenuados en claro */
body.theme-light .engine-bg,
body.theme-light .engine-blob { opacity: 0.35; }
body.theme-light .engine-grid { opacity: 0.12; }

/* Botones oscuros del reproductor */
body.theme-light .ghost-btn { color: #0f172a; background: rgba(15, 23, 42, 0.05); }
body.theme-light .panel-card,
body.theme-light .leaderboard-panel { background: rgba(255, 255, 255, 0.92); }

/* Tema Pixel */
body.theme-pixel {
  --engine-bg:         #010801;
  --engine-panel:      rgba(0, 20, 2, 0.94);
  --engine-panel-soft: rgba(0, 255, 65, 0.06);
  --engine-line:       rgba(0, 255, 65, 0.45);
  --engine-text:       #e0ffe0;
  --engine-muted:      #55aa55;
  --engine-cyan:       #00ff41;
  --engine-blue:       #33cc44;
  --engine-violet:     #aaff00;
  --engine-pink:       #ff8c00;
  --engine-grad:       linear-gradient(135deg, #00ff41 0%, #33cc44 33%, #aaff00 66%, #ff8c00 100%);
  --engine-shadow:     6px 6px 0 rgba(0, 160, 30, 0.5);

  --bg:           #010801;
  --panel-bg:     #0a1a0a;
  --panel-border: rgba(0, 255, 65, 0.45);
  --cell-bg:      #041404;
  --cell-border:  rgba(0, 255, 65, 0.4);
  --cell-text:    #e0ffe0;
  --text-main:    #e0ffe0;
  --text-muted:   #55aa55;
  --text-dim:     #2f7a34;
  --accent:       #00ff41;
  --accent-dim:   rgba(0, 255, 65, 0.16);
  --accent-glow:  rgba(0, 255, 65, 0.3);
  --accent2:      #aaff00;
  --accent2-dim:  rgba(170, 255, 0, 0.16);
  --error:        #ff5555;
  --error-glow:   rgba(255, 85, 85, 0.22);
  --gold:         #ff8c00;
}

/* Sin esquinas redondeadas */
body.theme-pixel .panel-card,
body.theme-pixel .ghost-btn,
body.theme-pixel .primary-btn,
body.theme-pixel .quiz-card,
body.theme-pixel .cw-cell,
body.theme-pixel .ws-pill,
body.theme-pixel .ws-word-tag,
body.theme-pixel .field input,
body.theme-pixel .field textarea { border-radius: 0 !important; }

/* Tema Synthwave (5º tema, secreto — ver css/nucleo/themes.css) */
body.theme-synthwave {
  --engine-bg:         #0a0118;
  --engine-panel:      rgba(16, 6, 32, 0.88);
  --engine-panel-soft: rgba(217, 70, 239, 0.06);
  --engine-line:       rgba(0, 229, 255, 0.20);
  --engine-text:       #f5e9ff;
  --engine-muted:      #9a7bc4;
  --engine-cyan:       #00e5ff;
  --engine-blue:       #7c3aed;
  --engine-violet:     #d946ef;
  --engine-pink:       #ff8a3d;
  --engine-grad:       linear-gradient(135deg, #00e5ff 0%, #7c3aed 35%, #d946ef 65%, #ff8a3d 100%);
  --engine-shadow:     0 22px 54px rgba(217, 70, 239, 0.22);

  --bg:           #0a0118;
  --panel-bg:     #170a2e;
  --panel-border: rgba(0, 229, 255, 0.18);
  --cell-bg:      #1f0f3d;
  --cell-border:  rgba(217, 70, 239, 0.28);
  --cell-text:    #f5e9ff;
  --text-main:    #f5e9ff;
  --text-muted:   #b79ae0;
  --text-dim:     #6b4f96;
  --accent:       #00e5ff;
  --accent-dim:   rgba(0, 229, 255, 0.16);
  --accent-glow:  rgba(0, 229, 255, 0.35);
  --accent2:      #d946ef;
  --accent2-dim:  rgba(217, 70, 239, 0.16);
  --error:        #ff4d6d;
  --error-glow:   rgba(255, 77, 109, 0.25);
  --gold:         #ffd166;
}

/* Firma 2 (la autopista), versión Engine. Nota: ".engine-grid" se reutiliza
   también como grid de tarjetas en la portada; el selector va acotado a
   .engine-bg .engine-grid para no afectar esa otra. */
body.theme-synthwave .engine-blob-a { background: radial-gradient(circle, rgba(0, 229, 255, 0.24)  0%, transparent 72%); }
body.theme-synthwave .engine-blob-b { background: radial-gradient(circle, rgba(217, 70, 239, 0.20)  0%, transparent 74%); }

body.theme-synthwave .engine-bg .engine-grid {
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.30) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 70, 239, 0.22) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.3) 9%, transparent 16%);
          mask-image: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.3) 9%, transparent 16%);
  transform: perspective(480px) rotateX(66deg) scale(1.8);
  transform-origin: 50% 100%;
  animation: synthGridScroll 2.4s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  body.theme-synthwave .engine-bg .engine-grid { animation: none; }
}

/* Selector flotante (inyectado por theme-switcher.js) */
.theme-picker.is-floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 930;
}

.theme-picker.is-floating .theme-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--pl-border, rgba(255, 255, 255, 0.16));
  background: var(--pl-panel, rgba(17, 10, 26, 0.82));
  backdrop-filter: blur(12px);
  color: var(--pl-soft, #d8c9ff);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.theme-picker.is-floating .theme-picker-btn:hover {
  border-color: var(--pl-lilac, #a96ae7);
  transform: translateY(-2px);
}

.theme-picker.is-floating .theme-dropdown {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border-radius: 14px;
  border: 1px solid var(--pl-border, rgba(255, 255, 255, 0.16));
  background: var(--pl-deep, #15071f);
  box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.75);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.theme-picker.is-floating .theme-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.theme-picker.is-floating .theme-option {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--pl-soft, #d8c9ff);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-picker.is-floating .theme-option:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--pl-text, #f8f2ff);
}

.theme-picker.is-floating .theme-option.is-active {
  color: var(--pl-cyan, #8deeff);
  font-weight: 800;
}

body.theme-light .theme-picker.is-floating .theme-dropdown { background: #fff; }
body.theme-pixel .theme-picker.is-floating .theme-picker-btn,
body.theme-pixel .theme-picker.is-floating .theme-dropdown,
body.theme-pixel .theme-picker.is-floating .theme-option { border-radius: 0; }

/* Transición al cambiar de tema */
body.is-theme-changing,
body.is-theme-changing * {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

@media (max-width: 640px) {
  .theme-picker.is-floating { top: auto; bottom: 1rem; right: 1rem; }
  .theme-picker.is-floating .theme-dropdown { top: auto; bottom: calc(100% + 0.45rem); }
}

@media (prefers-reduced-motion: reduce) {
  body.is-theme-changing, body.is-theme-changing * { transition: none; }
}

/* Fichas de miembros (--wiki-*) */

body.theme-dark {
  --wiki-bg:        #050d17;
  --wiki-surface:   #0d1829;
  --wiki-surface-2: #132338;
  --wiki-text:      #ddeeff;
  --wiki-muted:     #6a9fcf;
  --wiki-border:    rgba(64,196,255,0.22);
  --wiki-accent:    #40c4ff;
  --wiki-accent-2:  #7c4dff;
  --wiki-link:      #7cc4ff;
}

body.theme-light {
  --wiki-bg:        #f8fafc;
  --wiki-surface:   #ffffff;
  --wiki-surface-2: #f1f5f9;
  --wiki-text:      #0f172a;
  --wiki-muted:     #475569;
  --wiki-border:    rgba(15,23,42,0.12);
  --wiki-accent:    #8b5cf6;
  --wiki-accent-2:  #0ea5e9;
  --wiki-link:      #4f46e5;
}

body.theme-pixel {
  --wiki-bg:        #010801;
  --wiki-surface:   #0a1a0a;
  --wiki-surface-2: #0f2410;
  --wiki-text:      #e0ffe0;
  --wiki-muted:     #55aa55;
  --wiki-border:    rgba(0,255,65,0.45);
  --wiki-accent:    #00ff41;
  --wiki-accent-2:  #aaff00;
  --wiki-link:      #7cff7c;
}

body.theme-synthwave {
  --wiki-bg:        #0a0118;
  --wiki-surface:   #170a2e;
  --wiki-surface-2: #1f0f3d;
  --wiki-text:      #f5e9ff;
  --wiki-muted:     #b79ae0;
  --wiki-border:    rgba(0,229,255,0.22);
  --wiki-accent:    #00e5ff;
  --wiki-accent-2:  #d946ef;
  --wiki-link:      #7ce7ff;
}

/* Legibilidad en tema claro para las sub-aplicaciones */

/* Desplegables <select> */
body.theme-light option,
body.theme-light optgroup {
  background-color: #ffffff;
  color: #0f172a;
}

/* Reproductor de quiz (engine/styles.css) */
body.theme-light .answer-btn {
  color: var(--engine-text, #0f172a);
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.14);
}
body.theme-light .answer-btn:hover:not(:disabled) {
  border-color: rgba(15, 23, 42, 0.30);
}
body.theme-light .answer-btn.is-correct {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(14, 165, 233, 0.55);
}
body.theme-light .answer-btn.is-wrong {
  background: rgba(236, 72, 153, 0.14);
  border-color: rgba(236, 72, 153, 0.55);
}
body.theme-light .player-feedback.is-good { color: #0f766e; }
body.theme-light .player-feedback.is-bad  { color: #be123c; }
body.theme-light .inline-status.is-error   { color: #be123c; }
body.theme-light .inline-status.is-success { color: #0f766e; }

/* Píldora "Quiz/Crucigrama" del topbar */
body.theme-light .engine-topbar .engine-brand-mini {
  color: #6d28d9;
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.40);
}

/* Engine / constructor (engine/styles.css) */
body.theme-light .mode-switch-btn:not(.active) {
  color: var(--engine-text, #0f172a);
  background: rgba(15, 23, 42, 0.04);
}
body.theme-light .audio-summary { color: var(--engine-text, #0f172a); }
body.theme-light .output-label,
body.theme-light .output-block code,
body.theme-light .json-preview {
  color: var(--engine-text, #0f172a);
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.10);
}

/* Reproductor de crucigrama (actividades/crossword/play.html) */
body.theme-light .cw-board-wrap { background: rgba(15, 23, 42, 0.04); }
body.theme-light .cw-grid {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.08) 1px, transparent 1px);
}
body.theme-light .cw-cell { background: var(--cell-bg, #f1f5f9); }
body.theme-light .cw-input { color: var(--cell-text, #0f172a); }
body.theme-light .cw-clue-list li b { color: var(--engine-text, #0f172a); }
body.theme-light .cw-clue-group.v h4 { color: #0f766e; }
body.theme-light .cw-clue-group.d h4 { color: #b45309; }
body.theme-light .cw-cell.correct .cw-input { color: #0f766e; }
body.theme-light .cw-win { color: #0f766e; }

/* Reproductor de sopa de letras (actividades/wordsearch/play.html). .ws-fog no se toca. */
body.theme-light .ws-board-wrap { background: rgba(15, 23, 42, 0.04); }
body.theme-light .ws-win { color: #0f766e; }

/* ── CONSTRUCTOR DE CRUCIGRAMA (actividades/crossword/builder.html): dorado de las
   pistas diagonales, ilegible sobre el panel blanco en claro ── */
body.theme-light #group-d .panel-section-label,
body.theme-light #group-d .clue-num { color: #b45309; }

/* ── GALERÍA / "MIS PUZZLES" (play/index.html) ── */
/* El nombre de la actividad era color:#fff en el cuerpo claro de la
   tarjeta → invisible. Lo pintamos oscuro en claro. */
body.theme-light .quiz-title { color: #0f172a; }
body.theme-light .quiz-desc  { color: #334155; }
/* Botón "Sorpréndeme" dorado */
body.theme-light .surprise-btn {
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(255, 204, 51, 0.16);
}
body.theme-light .surprise-btn:hover { background: rgba(255, 204, 51, 0.26); }

/* ── PERFIL PÚBLICO (profile-view.html): píldoras de rol ── */
body.theme-light .pv-role.moderator {
  color: #be185d; background: rgba(236, 72, 153, 0.12); border-color: rgba(236, 72, 153, 0.40);
}
body.theme-light .pv-role.creator {
  color: #6d28d9; background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.40);
}
body.theme-light .pv-role.player {
  color: #0369a1; background: rgba(14, 165, 233, 0.12); border-color: rgba(14, 165, 233, 0.40);
}

/* ── MODERACIÓN (moderation.html): etiquetas y mensajes ── */
body.theme-light .md-tag.level  { color: #7c3aed; }
body.theme-light .md-tag.banned { color: #dc2626; }

/* ── Mensajes de estado (error/ok) legibles en claro ── */
body.theme-light .md-msg.is-error,
body.theme-light .md-bc-msg.is-error,
body.theme-light .pf-msg.is-error,
body.theme-light .auth-msg.is-error { color: #be123c; }
body.theme-light .md-msg.is-ok,
body.theme-light .md-bc-msg.is-ok,
body.theme-light .pf-msg.is-ok,
body.theme-light .auth-msg.is-ok { color: #0f766e; }

/* ════════════════════════════════════════════════════════════════════════════════
   TEMAS PRIVADOS — puente a las sub-aplicaciones
   --------------------------------------------------------------------------------
   Los cuatro temas de la cuenta dueña, traducidos a los tres vocabularios
   que usan las sub-apps: --engine-* (Engine y reproductores), --bg/--accent/…
   (constructores y diccionario) y --wiki-* (fichas de miembros).

   Sin esto, elegir uno de estos temas cambiaría la portada y dejaría el
   Engine, los constructores y los reproductores exactamente igual que
   antes — que es lo que pasaba con cualquier tema nuevo hasta que se
   añadía aquí.
   ════════════════════════════════════════════════════════════════════════════════ */

/* ── ALMA MONOCROMA ──────────────────────────────────────────────────
   Blanco sobre negro, sin sombras y sin curvas. `--engine-shadow` en
   `none` es deliberado: en un tema sin profundidad, una sombra suelta en
   un panel del Engine canta muchísimo. El rojo queda solo en --error. */
body.theme-mono {
  --engine-bg:         #000000;
  --engine-panel:      #000000;
  --engine-panel-soft: #000000;
  --engine-line:       #ffffff;
  --engine-text:       #ffffff;
  --engine-muted:      #9a9a9a;
  --engine-cyan:       #ffffff;
  --engine-blue:       #ffffff;
  --engine-violet:     #ffffff;
  --engine-pink:       #ff0000;
  --engine-grad:       linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
  --engine-shadow:     none;

  --bg:           #000000;
  --panel-bg:     #000000;
  --panel-border: #ffffff;
  --cell-bg:      #000000;
  --cell-border:  #ffffff;
  --cell-text:    #ffffff;
  --text-main:    #ffffff;
  --text-muted:   #9a9a9a;
  --text-dim:     #6b6b6b;
  --accent:       #ffffff;
  --accent-dim:   rgba(255, 255, 255, 0.14);
  --accent-glow:  rgba(255, 255, 255, 0.30);
  --accent2:      #ffffff;
  --accent2-dim:  rgba(255, 255, 255, 0.10);
  --error:        #ff0000;
  --error-glow:   rgba(255, 0, 0, 0.28);
  --gold:         #ffffff;
}
body.theme-mono {
  --wiki-bg:        #000000;
  --wiki-surface:   #000000;
  --wiki-surface-2: #0a0a0a;
  --wiki-text:      #ffffff;
  --wiki-muted:     #9a9a9a;
  --wiki-border:    #ffffff;
  --wiki-accent:    #ffffff;
  --wiki-accent-2:  #ff0000;
  --wiki-link:      #ffffff;
}

/* Las sub-apps pintan sus tarjetas con bordes de 1px y esquinas
   redondeadas escritas a mano, no con variables. Aquí se igualan al
   resto del tema: 2px rígidos y sin redondear. */
body.theme-mono .panel-card,
body.theme-mono .engine-topbar,
body.theme-mono .quiz-card,
body.theme-mono .leaderboard-panel {
  border-width: 2px !important;
  box-shadow: none !important;
}


/* ── AURORA CRISTALINA ───────────────────────────────────────────────
   Los paneles de las sub-apps sí llevan cristal: --engine-panel va en
   rgba y las hojas de cada app ya aplican backdrop-filter sobre él. Ojo
   con --cell-bg: los constructores lo usan para CASILLAS de crucigrama y
   sopa, que necesitan un fondo bastante más sólido que un panel o las
   letras no se leen sobre la aurora. */
body.theme-aurora {
  --engine-bg:         #ece5f9;
  --engine-panel:      rgba(255, 255, 255, 0.30);
  --engine-panel-soft: rgba(255, 255, 255, 0.16);
  --engine-line:       rgba(255, 255, 255, 0.55);
  --engine-text:       #2c2740;
  --engine-muted:      #6d6489;
  --engine-cyan:       #5eb3e4;
  --engine-blue:       #7f8ff4;
  --engine-violet:     #9d7cf0;
  --engine-pink:       #e488c8;
  --engine-grad:       linear-gradient(135deg, #9d7cf0 0%, #7f8ff4 34%, #5eb3e4 68%, #e488c8 100%);
  --engine-shadow:     0 18px 48px rgba(110, 90, 170, 0.18);

  --bg:           #ece5f9;
  --panel-bg:     rgba(255, 255, 255, 0.42);
  --panel-border: rgba(255, 255, 255, 0.60);
  --cell-bg:      rgba(255, 255, 255, 0.72);
  --cell-border:  rgba(140, 120, 190, 0.30);
  --cell-text:    #2c2740;
  --text-main:    #2c2740;
  --text-muted:   #6d6489;
  --text-dim:     #948cab;
  --accent:       #9d7cf0;
  --accent-dim:   rgba(157, 124, 240, 0.16);
  --accent-glow:  rgba(157, 124, 240, 0.28);
  --accent2:      #5eb3e4;
  --accent2-dim:  rgba(94, 179, 228, 0.16);
  --error:        #e0526e;
  --error-glow:   rgba(224, 82, 110, 0.18);
  /* Sobre pastel claro el dorado desaparece: se baja a un ámbar tostado. */
  --gold:         #b8791a;
}
body.theme-aurora {
  --wiki-bg:        #ece5f9;
  --wiki-surface:   rgba(255, 255, 255, 0.55);
  --wiki-surface-2: rgba(255, 255, 255, 0.35);
  --wiki-text:      #2c2740;
  --wiki-muted:     #6d6489;
  --wiki-border:    rgba(255, 255, 255, 0.60);
  --wiki-accent:    #9d7cf0;
  --wiki-accent-2:  #5eb3e4;
  --wiki-link:      #7c3aed;
}

/* Las sub-apps no tienen la capa `body::before` de la portada (su fondo
   lo pinta cada hoja), así que la aurora se recrea aquí como un fondo
   fijo. Quieto y no girando: en el Engine o a mitad de una partida, un
   fondo en movimiento detrás del tablero distrae de lo que importa. */
body.theme-aurora .engine-bg,
body.theme-aurora #app,
body.theme-aurora #cn-app {
  background-image:
    radial-gradient(circle at 22% 24%, rgba(186, 160, 250, 0.55), transparent 52%),
    radial-gradient(circle at 78% 18%, rgba(150, 205, 248, 0.50), transparent 52%),
    radial-gradient(circle at 54% 86%, rgba(248, 183, 226, 0.45), transparent 52%);
  background-attachment: fixed;
}
body.theme-aurora .engine-blob { display: none; }

/* El cristal, allí donde las hojas de cada app ponen paneles sólidos. */
body.theme-aurora .panel-card,
body.theme-aurora .engine-topbar,
body.theme-aurora .quiz-card,
body.theme-aurora .leaderboard-panel {
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}


/* ── PLANO TÁCTICO ───────────────────────────────────────────────────
   Cianotipo. Las sombras son planas y desplazadas también aquí, para que
   el Engine se sienta la misma mesa de trabajo que la portada. */
body.theme-blueprint {
  --engine-bg:         #0a2138;
  --engine-panel:      rgba(9, 32, 53, 0.90);
  --engine-panel-soft: rgba(127, 219, 255, 0.06);
  --engine-line:       rgba(127, 219, 255, 0.38);
  --engine-text:       #eaf6ff;
  --engine-muted:      #86aec9;
  --engine-cyan:       #7fdbff;
  --engine-blue:       #48a9e6;
  --engine-violet:     #9fd8ff;
  --engine-pink:       #ffd166;
  --engine-grad:       linear-gradient(135deg, #7fdbff 0%, #48a9e6 45%, #ffd166 100%);
  --engine-shadow:     5px 5px 0 rgba(0, 229, 255, 0.26);

  --bg:           #0a2138;
  --panel-bg:     #0c2a45;
  --panel-border: rgba(127, 219, 255, 0.38);
  --cell-bg:      #103352;
  --cell-border:  rgba(127, 219, 255, 0.34);
  --cell-text:    #eaf6ff;
  --text-main:    #eaf6ff;
  --text-muted:   #86aec9;
  --text-dim:     #55809b;
  --accent:       #7fdbff;
  --accent-dim:   rgba(127, 219, 255, 0.16);
  --accent-glow:  rgba(127, 219, 255, 0.30);
  --accent2:      #ffd166;
  --accent2-dim:  rgba(255, 209, 102, 0.16);
  --error:        #ff6b6b;
  --error-glow:   rgba(255, 107, 107, 0.22);
  --gold:         #ffd166;
}
body.theme-blueprint {
  --wiki-bg:        #0a2138;
  --wiki-surface:   #0c2a45;
  --wiki-surface-2: #103352;
  --wiki-text:      #eaf6ff;
  --wiki-muted:     #86aec9;
  --wiki-border:    rgba(127,219,255,0.38);
  --wiki-accent:    #7fdbff;
  --wiki-accent-2:  #ffd166;
  --wiki-link:      #9fd8ff;
}

/* El papel milimetrado, también detrás de las sub-apps. */
body.theme-blueprint .engine-bg,
body.theme-blueprint #app,
body.theme-blueprint #cn-app {
  background-color: #0a2138;
  background-image:
    repeating-linear-gradient(0deg,  rgba(127,219,255,0.26) 0 1.4px, transparent 1.4px 120px),
    repeating-linear-gradient(90deg, rgba(127,219,255,0.26) 0 1.4px, transparent 1.4px 120px),
    repeating-linear-gradient(0deg,  rgba(127,219,255,0.11) 0 1px,   transparent 1px 24px),
    repeating-linear-gradient(90deg, rgba(127,219,255,0.11) 0 1px,   transparent 1px 24px);
}
body.theme-blueprint .engine-blob,
body.theme-blueprint .engine-grid { display: none; }

body.theme-blueprint .panel-card,
body.theme-blueprint .engine-topbar,
body.theme-blueprint .quiz-card {
  border-radius: 3px !important;
  box-shadow: 5px 5px 0 rgba(0, 229, 255, 0.22) !important;
}


/* ── ATARDECER CÁLIDO ────────────────────────────────────────────────
   Claro y mate. Mismo cuidado que en `light`: sobre crema, los dorados y
   los cianes de los temas oscuros se vuelven ilegibles, así que bajan a
   tonos tostados con contraste suficiente. */
body.theme-sunset {
  --engine-bg:         #f7ecdc;
  --engine-panel:      rgba(255, 250, 243, 0.94);
  --engine-panel-soft: rgba(196, 112, 63, 0.06);
  --engine-line:       rgba(160, 120, 90, 0.20);
  --engine-text:       #3d2f26;
  --engine-muted:      #8a7460;
  --engine-cyan:       #c4703f;
  --engine-blue:       #b25c35;
  --engine-violet:     #a9643f;
  --engine-pink:       #d9834f;
  --engine-grad:       linear-gradient(135deg, #d9834f 0%, #c4703f 40%, #a9643f 75%, #8c5a3c 100%);
  --engine-shadow:     0 22px 56px rgba(196, 112, 63, 0.16);

  --bg:           #f7ecdc;
  --panel-bg:     #fffaf3;
  --panel-border: rgba(160, 120, 90, 0.20);
  --cell-bg:      #fdf4e8;
  --cell-border:  rgba(160, 120, 90, 0.26);
  --cell-text:    #3d2f26;
  --text-main:    #3d2f26;
  --text-muted:   #8a7460;
  --text-dim:     #a89684;
  --accent:       #c4703f;
  --accent-dim:   rgba(196, 112, 63, 0.14);
  --accent-glow:  rgba(196, 112, 63, 0.24);
  --accent2:      #b25c35;
  --accent2-dim:  rgba(178, 92, 53, 0.12);
  --error:        #c0392b;
  --error-glow:   rgba(192, 57, 43, 0.16);
  --gold:         #a86a12;
}
body.theme-sunset {
  --wiki-bg:        #f7ecdc;
  --wiki-surface:   #fffaf3;
  --wiki-surface-2: #fdf4e8;
  --wiki-text:      #3d2f26;
  --wiki-muted:     #8a7460;
  --wiki-border:    rgba(160,120,90,0.20);
  --wiki-accent:    #c4703f;
  --wiki-accent-2:  #b25c35;
  --wiki-link:      #b25c35;
}

body.theme-sunset .engine-bg,
body.theme-sunset #app,
body.theme-sunset #cn-app {
  background-image:
    radial-gradient(circle at 14% 8%,  rgba(255, 214, 165, 0.55), transparent 46%),
    radial-gradient(circle at 86% 18%, rgba(255, 183, 148, 0.38), transparent 46%),
    radial-gradient(circle at 50% 96%, rgba(238, 199, 160, 0.34), transparent 52%);
  background-attachment: fixed;
}
body.theme-sunset .engine-blob { display: none; }
body.theme-sunset .engine-grid { opacity: 0.04; }

/* La luz cálida de lado: sombra ancha, suave y teñida de naranja. */
body.theme-sunset .panel-card,
body.theme-sunset .engine-topbar,
body.theme-sunset .quiz-card,
body.theme-sunset .leaderboard-panel {
  box-shadow: 0 18px 44px rgba(196, 112, 63, 0.13),
              0 3px 10px rgba(196, 112, 63, 0.07) !important;
}
body.theme-sunset .primary-btn,
body.theme-sunset .btn-primary {
  border-radius: 50px !important;
}

/* ════════════════════════════════════════════════════════════════
   SELECTOR DE IDIOMA (js/nucleo/i18n.js) — 🇲🇽 ES | 🇺🇸 EN
   ----------------------------------------------------------------
   Va aquí porque esta hoja la cargan las 32 páginas. Tres sitios:
   en la barra de navegación (.is-nav), en el pie (.is-footer) y,
   en las páginas que no tienen ninguno de los dos, flotante abajo a
   la izquierda (.is-floating), lejos del «Tema» y de Publicar.
   ════════════════════════════════════════════════════════════════ */
.lang-toggle {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 999px; border: 1px solid var(--pl-border, rgba(255, 255, 255, 0.16));
  background: var(--pl-panel, rgba(17, 10, 26, 0.82));
  font: inherit; font-size: 0.78rem; line-height: 1;
}
.lang-toggle-op {
  display: inline-flex; align-items: center; gap: 0.3rem; min-height: 30px; padding: 0.3rem 0.65rem;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  color: var(--pl-soft, #d8c9ff); font: inherit; font-weight: 800; letter-spacing: 0.03em;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-toggle-op:hover { color: var(--pl-text, #f8f2ff); background: rgba(255, 255, 255, 0.07); }
.lang-toggle-op.is-on { background: rgba(141, 238, 255, 0.16); color: var(--pl-cyan, #8deeff); }
.lang-toggle-op:focus-visible { outline: 2px solid var(--pl-cyan, #8deeff); outline-offset: 1px; }
.lang-toggle.is-nav { margin-left: auto; margin-right: 0.6rem; flex: none; }
.footer-lang { margin-top: 0.8rem; }
.lang-toggle.is-floating {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 925;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.7);
}
/* La sopa de letras tiene sus botones redondos abajo a la izquierda:
   el selector se sube encima de ellos */
body:has(#fab-container) .lang-toggle.is-floating { bottom: calc(1.5rem + 64px); }
/* …y los lienzos de Crono y Carto, su etiqueta de zoom en la esquina */
body:has(.cn-zoom-label, .ct-zoom-label) .lang-toggle.is-floating { bottom: 3rem; }
body.theme-light .lang-toggle { background: rgba(255, 255, 255, 0.92); }
body.theme-pixel .lang-toggle, body.theme-pixel .lang-toggle-op { border-radius: 0; }
@media (max-width: 760px) {
  .lang-toggle.is-nav { margin-right: 0.35rem; }
  .lang-toggle.is-nav .lang-toggle-op { padding: 0.3rem 0.45rem; }
  .lang-toggle.is-nav .lang-toggle-op span { display: none; }
}
@media print { .lang-toggle { display: none !important; } }

/* Mientras llega el diccionario de frases en inglés (js/nucleo/i18n.js lo carga
   solo si hace falta, y como mucho 2 s), la página no se enseña a medias
   en español. */
html.i18n-cargando body { opacity: 0; }

/* ════════════════════════════════════════════════════════════════
   BARRA EN TELÉFONOS ESTRECHOS (360 px, el ancho más común en Android)
   ════════════════════════════════════════════════════════════════
   Logo + idioma + tema + menú pedían ~364 px donde caben ~305: el botón
   del menú (☰) se encogía a la mitad y se salía por la derecha de la
   barra. Ahora no se encoge, y lo demás se compacta lo justo. */
.nav-toggle { flex-shrink: 0; }
@media (max-width: 400px) {
  .site-header { padding-inline: 0.6rem; }
  .site-nav { gap: 0.35rem; padding-inline: 0.65rem; }
  .nav-logo-text { font-size: 0.74rem; letter-spacing: 0.04em; }
  .lang-toggle.is-nav { margin-right: 0.1rem; }
  .lang-toggle.is-nav .lang-toggle-op { padding: 0.3rem 0.38rem; min-height: 28px; }
  .theme-picker-btn { padding: 0.4rem 0.55rem; }
  .nav-toggle { width: 2.7rem; height: 2.7rem; }
}
@media (max-width: 340px) {
  .nav-logo-text { font-size: 0.64rem; letter-spacing: 0.02em; }
  .site-nav { gap: 0.25rem; padding-inline: 0.5rem; }
}
