/* ============================================================
   GUÍA WEB · styles.css
   Sistema de diseño completo, sin dependencias externas.
   Organización:
     1. Variables y temas (claro / oscuro)
     2. Reset y base
     3. Utilidades
     4. Cabecera fija y navegación
     5. Portada (hero)
     6. Secciones y encabezados
     7. Tarjetas
     8. Bloques de código y resaltado
     9. Demos (estilos específicos de cada demo)
    10. Formularios (sistema completo)
    11. Índice (TOC)
    12. Consejos, prompts y avisos
    13. Formularios de demostración (apps)
    14. Tabla de referencia
    15. Pie y botón subir
    16. Responsive (móvil primero: 600px, 900px)
    17. Movimiento reducido e impresión
============================================================ */

/* ------------------------------------------------------------
   1 · VARIABLES Y TEMAS
------------------------------------------------------------ */
:root {
  /* Tipografía: pila del sistema, cero descargas */
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fuente-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, Menlo, monospace;

  /* Escala de espaciado */
  --esp-1: 0.25rem;
  --esp-2: 0.5rem;
  --esp-3: 0.75rem;
  --esp-4: 1rem;
  --esp-5: 1.5rem;
  --esp-6: 2rem;
  --esp-7: 3rem;
  --esp-8: 4.5rem;

  /* Radios y bordes */
  --radio-s: 6px;
  --radio-m: 10px;
  --radio-l: 16px;

  /* Anchos */
  --ancho-max: 68rem;
  --ancho-texto: 46rem;

  /* Alturas táctiles */
  --tactil: 44px;

  /* Transiciones */
  --trans-rapida: 0.15s ease;
  --trans-media: 0.25s ease;

  /* Colores del código (constantes en ambos temas: bloque siempre oscuro) */
  --code-bg: #211d17;
  --code-text: #e9e3d6;
  --tok-com: #8f8570;
  --tok-tag: #7fc8ba;
  --tok-attr: #d9b878;
  --tok-str: #c9a3e0;
  --tok-kw: #85b8e8;
  --tok-num: #e8a684;
}

/* Tema claro: neutros cálidos + acento verde azulado sobrio */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5f1;
  --bg-alt: #efece5;
  --superficie: #fffefb;
  --superficie-alt: #f2efe8;
  --borde: #e0dbd0;
  --borde-fuerte: #c4bcac;
  --texto: #29241d;
  --texto-suave: #5d564a;
  /* Tono más apagado de la escala, pero por encima de 4.5:1 sobre el fondo:
     lo usan pistas, notas y placeholders, y también deben leerse */
  --texto-tenue: #6b6355;
  --acento: #0e7466;
  --acento-fuerte: #0a5a50;
  --acento-suave: #e0eeea;
  --acento-contraste: #ffffff;
  --rojo: #b3362c;
  --rojo-suave: #f8e9e7;
  --verde: #2c7a3f;
  --verde-suave: #e7f2e9;
  --ambar: #94600f;
  --ambar-suave: #f6eddc;
  --sombra-1: 0 1px 3px rgba(41, 36, 29, 0.08);
  --sombra-2: 0 6px 18px rgba(41, 36, 29, 0.10);
}

/* Tema oscuro: carbón cálido, mismo cuidado que el claro */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16130f;
  --bg-alt: #1c1813;
  --superficie: #211d17;
  --superficie-alt: #282219;
  --borde: #3a332a;
  --borde-fuerte: #55493b;
  --texto: #ece6da;
  --texto-suave: #b5ab98;
  --texto-tenue: #a3978a;
  --acento: #4cbcac;
  --acento-fuerte: #6fd0c1;
  --acento-suave: #15332e;
  --acento-contraste: #0d1f1c;
  --rojo: #e07a70;
  --rojo-suave: #3a201c;
  --verde: #79c48b;
  --verde-suave: #1e3424;
  --ambar: #d6a052;
  --ambar-suave: #362b18;
  --sombra-1: 0 1px 3px rgba(0, 0, 0, 0.4);
  --sombra-2: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* Respaldo sin JavaScript: sigue la preferencia del sistema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #16130f;
    --bg-alt: #1c1813;
    --superficie: #211d17;
    --superficie-alt: #282219;
    --borde: #3a332a;
    --borde-fuerte: #55493b;
    --texto: #ece6da;
    --texto-suave: #b5ab98;
    --texto-tenue: #a3978a;
    --acento: #4cbcac;
    --acento-fuerte: #6fd0c1;
    --acento-suave: #15332e;
    --acento-contraste: #0d1f1c;
    --rojo: #e07a70;
    --rojo-suave: #3a201c;
    --verde: #79c48b;
    --verde-suave: #1e3424;
    --ambar: #d6a052;
    --ambar-suave: #362b18;
    --sombra-1: 0 1px 3px rgba(0, 0, 0, 0.4);
    --sombra-2: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
}

/* ------------------------------------------------------------
   2 · RESET Y BASE
------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--fuente);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--trans-media), color var(--trans-media);
}

/* Los destinos de ancla no quedan tapados por la cabecera fija */
[id] { scroll-margin-top: 84px; }

img, svg { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5 {
  line-height: 1.25;
  margin: 0 0 var(--esp-3);
  font-weight: 700;
  color: var(--texto);
}

p { margin: 0 0 var(--esp-3); }

a {
  color: var(--acento);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--trans-rapida);
}
a:hover { color: var(--acento-fuerte); }
a:visited { color: var(--acento); }

code {
  font-family: var(--fuente-mono);
  font-size: 0.9em;
  background: var(--superficie-alt);
  border: 1px solid var(--borde);
  border-radius: var(--radio-s);
  padding: 0.08em 0.35em;
  overflow-wrap: break-word;
}

/* Selección de texto en color de acento (demo de ::selection incluida) */
::selection {
  background: var(--acento);
  color: var(--acento-contraste);
}

/* Foco visible SIEMPRE, en todo el documento */
:focus-visible {
  outline: 3px solid var(--acento);
  outline-offset: 2px;
  border-radius: var(--radio-s);
}

/* ------------------------------------------------------------
   3 · UTILIDADES
------------------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--esp-4);
  z-index: 200;
  padding: var(--esp-2) var(--esp-4);
  background: var(--acento);
  color: var(--acento-contraste);
  border-radius: 0 0 var(--radio-m) var(--radio-m);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus-visible {
  top: 0;
  outline-offset: -3px;
}

.empty-note {
  padding: var(--esp-4);
  background: var(--superficie-alt);
  border: 1px dashed var(--borde-fuerte);
  border-radius: var(--radio-m);
  color: var(--texto-suave);
}

/* ------------------------------------------------------------
   4 · CABECERA FIJA Y NAVEGACIÓN
------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--superficie) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}

.topbar-inner {
  max-width: var(--ancho-max);
  margin: 0 auto;
  padding: var(--esp-2) var(--esp-4);
  display: flex;
  align-items: center;
  gap: var(--esp-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--esp-2);
  text-decoration: none;
  color: var(--texto);
  font-weight: 700;
  margin-right: auto;
  min-height: var(--tactil);
}
.brand:visited { color: var(--texto); }
.brand-logo { border-radius: 8px; flex-shrink: 0; }
.brand-name { white-space: nowrap; }

/* Navegación: panel desplegable en móvil, fila en escritorio */
.main-nav {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  box-shadow: var(--sombra-2);
  display: none;
}
.main-nav.is-open { display: block; }

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: var(--esp-2) var(--esp-4);
  display: flex;
  flex-direction: column;
}
.main-nav a {
  display: flex;
  align-items: center;
  min-height: var(--tactil);
  padding: var(--esp-1) var(--esp-3);
  text-decoration: none;
  color: var(--texto-suave);
  font-weight: 500;
  border-radius: var(--radio-s);
  transition: background var(--trans-rapida), color var(--trans-rapida);
}
.main-nav a:visited { color: var(--texto-suave); }
.main-nav a:hover { background: var(--superficie-alt); color: var(--texto); }
.main-nav a.is-current { color: var(--acento); background: var(--acento-suave); }

/* Botones de la cabecera */
.nav-toggle,
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tactil);
  min-height: var(--tactil);
  padding: var(--esp-1) var(--esp-2);
  background: transparent;
  color: var(--texto-suave);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: background var(--trans-rapida), color var(--trans-rapida), border-color var(--trans-rapida);
}
.nav-toggle:hover,
.ctrl-btn:hover {
  background: var(--superficie-alt);
  color: var(--texto);
  border-color: var(--borde-fuerte);
}
.nav-toggle:active,
.ctrl-btn:active { transform: scale(0.96); }

/* Iconos de hamburguesa/cierre y sol/luna: se alternan por estado */
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-burger { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }

.topbar-controls {
  display: flex;
  gap: var(--esp-2);
  align-items: center;
}

/* ------------------------------------------------------------
   5 · PORTADA (HERO)
------------------------------------------------------------ */
.hero {
  max-width: var(--ancho-max);
  margin: 0 auto;
  padding: var(--esp-7) var(--esp-4) var(--esp-6);
}

.hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.7rem);
  letter-spacing: -0.02em;
  max-width: 26ch;
}

.hero-sub {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--texto-suave);
  max-width: var(--ancho-texto);
}

.hero-intro {
  max-width: var(--ancho-texto);
  color: var(--texto-suave);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--esp-2);
  margin-top: var(--esp-4);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--superficie-alt);
  border: 1px solid var(--borde);
  color: var(--texto-suave);
}
.badge-html { background: var(--acento-suave); border-color: transparent; color: var(--acento-fuerte); }
.badge-css  { background: var(--ambar-suave);  border-color: transparent; color: var(--ambar); }
.badge-js   { background: var(--verde-suave);  border-color: transparent; color: var(--verde); }

/* ------------------------------------------------------------
   6 · SECCIONES Y ENCABEZADOS
------------------------------------------------------------ */
.section {
  max-width: var(--ancho-max);
  margin: 0 auto;
  padding: var(--esp-6) var(--esp-4);
  border-top: 1px solid var(--borde);
}

.section h2 {
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  display: flex;
  align-items: baseline;
  gap: var(--esp-3);
}

.sec-num {
  font-family: var(--fuente-mono);
  font-size: 0.8em;
  color: var(--acento);
  background: var(--acento-suave);
  border-radius: var(--radio-s);
  padding: 0.1em 0.5em;
  flex-shrink: 0;
}

.section h3 {
  font-size: 1.25rem;
  margin-top: var(--esp-7);
  padding-bottom: var(--esp-2);
  border-bottom: 2px solid var(--acento-suave);
}
.section h3:first-of-type { margin-top: var(--esp-5); }

.sec-lead {
  font-size: 1.05rem;
  color: var(--texto-suave);
  max-width: var(--ancho-texto);
}

.sec-note {
  color: var(--texto-suave);
  max-width: var(--ancho-texto);
}

.section-featured {
  background: linear-gradient(180deg, var(--acento-suave) 0, transparent 240px);
}

/* ------------------------------------------------------------
   7 · TARJETAS
------------------------------------------------------------ */
.card {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-l);
  padding: var(--esp-5);
  margin: var(--esp-4) 0;
  box-shadow: var(--sombra-1);
  /* min-width: 0 permite que el contenido ancho (código) se encoja
     dentro de contenedores grid y flex en vez de desbordar la página */
  min-width: 0;
  transition: box-shadow var(--trans-media), transform var(--trans-media);
}
.card:hover { box-shadow: var(--sombra-2); }

.card-title {
  font-size: 1.08rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4em;
}
.card-title code {
  background: var(--acento-suave);
  border-color: transparent;
  color: var(--acento-fuerte);
}

.card-what {
  color: var(--texto-suave);
}
.card-what code { white-space: nowrap; }

/* Rejilla de tarjetas compactas (tipos de input) */
.mini-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--esp-4);
}
.card-mini { margin: 0; padding: var(--esp-4); }
.card-mini .card-title { font-size: 1rem; }
.card-mini .card-what { font-size: 0.93rem; }

/* ------------------------------------------------------------
   8 · BLOQUES DE CÓDIGO Y RESALTADO
------------------------------------------------------------ */
.code {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--fuente-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  border-radius: var(--radio-m);
  padding: var(--esp-4);
  /* El código largo se desplaza dentro de su bloque: la página nunca
     debe desplazarse en horizontal (clave en móvil) */
  overflow-x: auto;
  max-width: 100%;
  margin: var(--esp-3) 0;
  tab-size: 2;
}
.code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

/* Etiqueta del lenguaje en la esquina del bloque */
.code { position: relative; }
.code::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.35rem;
  right: 0.7rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tok-com);
}

/* Fichas del resaltado (las aplica el mini-resaltador de script.js) */
.tok-com  { color: var(--tok-com); font-style: italic; }
.tok-tag  { color: var(--tok-tag); }
.tok-attr { color: var(--tok-attr); }
.tok-str  { color: var(--tok-str); }
.tok-kw   { color: var(--tok-kw); }
.tok-num  { color: var(--tok-num); }

/* ------------------------------------------------------------
   9 · DEMOS
------------------------------------------------------------ */
.demo { margin: var(--esp-4) 0; }

.demo-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--acento);
  margin-bottom: var(--esp-2);
}

.demo-frame {
  background: var(--bg);
  border: 1px dashed var(--borde-fuerte);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
}
.demo-tight { margin: var(--esp-3) 0 0; }
.demo-tight label,
.demo-group-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: var(--esp-1);
}

.demo-note {
  font-size: 0.88rem;
  color: var(--texto-tenue);
  margin: var(--esp-2) 0 0;
}

.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--esp-3);
}
.demo-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--esp-3);
}

/* — Demos de estructura semántica — */
.mini-header {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
}
.mini-h1 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.mini-h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 var(--esp-2); }
.mini-h3 { font-weight: 700; margin: 0 0 var(--esp-1); }
.mini-sub { color: var(--texto-suave); margin: 0; font-size: 0.92rem; }

.mini-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--esp-2);
  margin: 0;
  padding: 0;
}
.mini-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 var(--esp-3);
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
}

.mini-layout { display: grid; gap: var(--esp-2); }
.mini-zone {
  border: 1.5px dashed var(--borde-fuerte);
  border-radius: var(--radio-s);
  padding: var(--esp-2) var(--esp-3);
  font-family: var(--fuente-mono);
  font-size: 0.85rem;
  color: var(--texto-suave);
  text-align: center;
}
.mini-zone-main {
  padding: var(--esp-5) var(--esp-3);
  background: var(--acento-suave);
  border-color: var(--acento);
  color: var(--acento-fuerte);
  font-weight: 600;
}

.mini-section { margin: 0; }
.mini-article {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3);
  margin-bottom: var(--esp-2);
}
.mini-article:last-child { margin-bottom: 0; }

.mini-aside {
  background: var(--ambar-suave);
  border-left: 4px solid var(--ambar);
  border-radius: var(--radio-s);
  padding: var(--esp-3);
  margin: var(--esp-2) 0 0;
}
.mini-aside p { margin: 0; font-size: 0.92rem; }

.mini-footer {
  background: var(--superficie-alt);
  border-top: 2px solid var(--borde);
  padding: var(--esp-3);
  border-radius: 0 0 var(--radio-m) var(--radio-m);
  font-size: 0.92rem;
  color: var(--texto-suave);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--esp-2);
}
.mini-footer p { margin: 0; }

.mini-figure {
  display: inline-block;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3);
  margin: 0;
}
.mini-figure figcaption {
  font-size: 0.85rem;
  color: var(--texto-suave);
  margin-top: var(--esp-2);
}

.mini-details {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  margin-bottom: var(--esp-2);
  padding: 0;
}
.mini-details summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--esp-3) var(--esp-4);
  border-radius: var(--radio-m);
  min-height: var(--tactil);
  display: flex;
  align-items: center;
}
.mini-details summary:hover { background: var(--superficie-alt); }
.mini-details[open] summary { border-bottom: 1px solid var(--borde); }
.mini-details p { padding: var(--esp-3) var(--esp-4); margin: 0; color: var(--texto-suave); }

/* — Demos de texto — */
.mini-outline p { margin: 0 0 var(--esp-1); }
.demo-h1 { font-size: 1.5rem; font-weight: 700; }
.demo-h2 { font-size: 1.2rem; font-weight: 700; padding-left: 1rem; }
.demo-h3 { font-size: 1rem; font-weight: 600; padding-left: 2rem; color: var(--texto-suave); }

.demo-list { margin: 0; padding-left: 1.4rem; }
.demo-list li { margin-bottom: var(--esp-1); }

.demo-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 26rem;
  background: var(--superficie);
  border-radius: var(--radio-m);
  overflow: hidden;
}
.demo-table caption {
  font-weight: 700;
  text-align: left;
  padding: var(--esp-2) 0;
}
.demo-table th, .demo-table td {
  border: 1px solid var(--borde);
  padding: var(--esp-2) var(--esp-3);
  text-align: left;
}
.demo-table thead th { background: var(--superficie-alt); }

.kv-list {
  list-style: none;
  margin: var(--esp-2) 0 0;
  padding: 0;
}
.kv-list li { padding: var(--esp-1) 0; }
.kv-list output { font-family: var(--fuente-mono); color: var(--acento); }

.char-count {
  font-size: 0.85rem;
  color: var(--texto-tenue);
  text-align: right;
  margin: var(--esp-1) 0 0;
}

.meter-row, .range-row, .calc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--esp-3);
}
.calc-row input[type="number"] { width: 6rem; }
.calc-row output { font-weight: 700; color: var(--acento); }
.range-row input[type="range"] { flex: 1; min-width: 140px; }
.range-row output {
  font-family: var(--fuente-mono);
  font-weight: 700;
  min-width: 2ch;
  color: var(--acento);
}
progress { accent-color: var(--acento); width: min(100%, 280px); }
meter { min-width: 120px; }

/* — Demos de CSS — */
.anatomy {
  font-family: var(--fuente-mono);
  font-size: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--esp-2);
  margin-bottom: var(--esp-4);
}
.anatomy-part {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: var(--esp-1) var(--esp-2);
  border-radius: var(--radio-s);
  border: 1.5px solid;
}
.anatomy-sel  { border-color: var(--acento); background: var(--acento-suave); }
.anatomy-prop { border-color: var(--ambar); background: var(--ambar-suave); }
.anatomy-val  { border-color: var(--verde); background: var(--verde-suave); }
.anatomy-tag {
  font-family: var(--fuente);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--texto-tenue);
}
.anatomy-brace, .anatomy-colon { align-self: center; color: var(--texto-tenue); }

.demo-rule-btn {
  background-color: #0e7466;
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font: inherit;
  font-weight: 600;
  min-height: var(--tactil);
  cursor: pointer;
}

.spec-demo-p { color: #7c756a; margin-bottom: var(--esp-2); font-weight: 500; }
.spec-demo-aviso { color: var(--ambar); }
#spec-demo-urgente { color: var(--rojo); }

/* Zonas de juego de selectores: el resaltado .hl lo pone JS */
.sel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--esp-2);
  margin-bottom: var(--esp-3);
}
.sel-playground {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
}
.sel-playground p { margin: 0 0 var(--esp-2); }
.sel-playground .hl {
  background: var(--acento-suave);
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: var(--radio-s);
}
.sel-result { min-height: 1.4em; }

.demo-tree {
  border: 1.5px dashed var(--borde-fuerte);
  border-radius: var(--radio-s);
  padding: var(--esp-3);
}
.demo-tree-inner { margin-top: var(--esp-2); }
.demo-tree-tag {
  font-family: var(--fuente-mono);
  font-size: 0.75rem;
  color: var(--texto-tenue);
  margin: 0 0 var(--esp-2);
}
.demo-tree-h { font-weight: 700; }

.func-item {
  background: var(--superficie-alt);
  border-radius: var(--radio-s);
  padding: var(--esp-2) var(--esp-3);
}
.func-item em {
  font-style: normal;
  background: var(--verde-suave);
  color: var(--verde);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.05em 0.5em;
  border-radius: 999px;
}

/* Estados de interacción (demo) */
.demo-states-btn {
  font: inherit;
  font-weight: 600;
  min-height: var(--tactil);
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: var(--radio-m);
  background: var(--acento);
  color: var(--acento-contraste);
  cursor: pointer;
  transition: background var(--trans-rapida), transform var(--trans-rapida);
}
.demo-states-btn:hover { background: var(--acento-fuerte); }
.demo-states-btn:active { transform: scale(0.95); }
.demo-states-link { font-weight: 600; }

/* Estados de formulario en vivo (:valid / :invalid tras escribir) */
.fs-live:invalid:not(:placeholder-shown) { border-color: var(--rojo); }
.fs-live:valid:not(:placeholder-shown) { border-color: var(--verde); }
.fs-check input:checked + span { font-weight: 700; }

.nth-demo {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 26rem;
}
.nth-demo li {
  padding: var(--esp-2) var(--esp-3);
  border-bottom: 1px solid var(--borde);
}
.nth-demo li:first-child { font-weight: 700; }
.nth-demo li:nth-child(even) { background: var(--superficie-alt); }
.nth-demo li:last-child { border-bottom: none; }

/* Pseudo-elementos (demo) */
.pe-nuevo::before { content: "✦ "; color: var(--acento); font-weight: 700; }
.pe-oferta::after { content: " — 20 %"; font-weight: 700; color: var(--rojo); }
.pe-markers { padding-left: 1.4rem; margin: 0; }
.pe-markers li::marker { color: var(--acento); }

/* Variables CSS (demo interactiva con --acento local) */
.vars-stage { --acento-demo: #0e7466; }
.vars-card {
  border: 2px solid var(--acento-demo);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
  max-width: 20rem;
  background: var(--superficie);
  transition: border-color var(--trans-media);
}
.vars-title { color: var(--acento-demo); font-weight: 700; transition: color var(--trans-media); }
.vars-btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--radio-s);
  min-height: var(--tactil);
  padding: 0.5rem 1.1rem;
  background: var(--acento-demo);
  color: #fff;
  cursor: pointer;
  transition: background var(--trans-media);
}

/* Playgrounds de flexbox y grid */
.play-controls { margin-bottom: var(--esp-3); }
.play-prop {
  font-family: var(--fuente-mono);
  font-size: 0.8rem;
  color: var(--texto-tenue);
  margin: var(--esp-2) 0 var(--esp-1);
}
.play-stage {
  display: flex;
  gap: 0.75rem;
  min-height: 130px;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3);
  transition: gap var(--trans-media);
}
.play-stage-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.play-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 42px;
  padding: var(--esp-2);
  background: var(--acento-suave);
  color: var(--acento-fuerte);
  border: 1.5px solid var(--acento);
  border-radius: var(--radio-s);
  font-weight: 700;
  font-family: var(--fuente-mono);
}
.play-item-alto { min-height: 74px; }
#grid-item-1.is-span { grid-column: span 2; background: var(--ambar-suave); border-color: var(--ambar); color: var(--ambar); }
.play-css {
  font-family: var(--fuente-mono);
  font-size: 0.8rem;
  background: var(--superficie-alt);
  border-radius: var(--radio-s);
  padding: var(--esp-2) var(--esp-3);
}

/* Indicador de breakpoint (pintado 100% por media queries) */
.mq-indicator { display: flex; flex-wrap: wrap; gap: var(--esp-2); align-items: center; }
.mq-badge {
  display: inline-block;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  background: var(--acento-suave);
  color: var(--acento-fuerte);
}
.mq-badge::after { content: "📱 Móvil (menos de 600px)"; }
html[lang="en"] .mq-badge::after { content: "📱 Mobile (under 600px)"; }

.unit-bars { display: grid; gap: var(--esp-2); }
.unit-bar {
  background: var(--acento-suave);
  border: 1px solid var(--acento);
  border-radius: var(--radio-s);
  padding: var(--esp-1) var(--esp-2);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}
.unit-bar code { background: transparent; border: 0; font-weight: 700; }

/* @supports (demo): verde solo si el navegador pasa la prueba */
.supports-badge {
  padding: var(--esp-3);
  border-radius: var(--radio-m);
  background: var(--superficie-alt);
  border: 1.5px solid var(--borde-fuerte);
  margin: 0;
}
@supports selector(:has(a)) {
  .supports-badge {
    background: var(--verde-suave);
    border-color: var(--verde);
  }
  .supports-badge::before { content: "✓ "; font-weight: 700; color: var(--verde); }
}

/* @keyframes (demos) */
@keyframes latido {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
.kf-heart {
  font-size: 1.8rem;
  color: var(--rojo);
  animation: latido 1.2s ease-in-out infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.kf-spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--acento-suave);
  border-top-color: var(--acento);
  border-radius: 50%;
  animation: girar 0.9s linear infinite;
}
@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kf-fade { opacity: 0; }
.kf-fade.is-visible { animation: aparecer 0.6s ease forwards; }

/* Transiciones (demo comparativa) */
.trans-card {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
  box-shadow: var(--sombra-1);
  cursor: default;
  max-width: 15rem;
}
.trans-card p { margin: 0; font-size: 0.92rem; }
.trans-suave { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.trans-suave:hover, .trans-brusca:hover {
  transform: translateY(-5px);
  box-shadow: var(--sombra-2);
}

/* Accesibilidad visual (demo) */
.contrast-row { display: grid; gap: var(--esp-2); margin-bottom: var(--esp-3); }
.contrast-good {
  background: var(--superficie);
  color: var(--texto);
  padding: var(--esp-2) var(--esp-3);
  border-radius: var(--radio-s);
  border: 1px solid var(--borde);
  margin: 0;
  font-weight: 500;
}
.contrast-bad {
  background: #d5d2cb;
  color: #a5a29b;
  padding: var(--esp-2) var(--esp-3);
  border-radius: var(--radio-s);
  margin: 0;
  font-weight: 500;
}
.btn-tiny-bad {
  min-height: 22px !important;
  min-width: 0 !important;
  padding: 0 0.4rem !important;
  font-size: 0.7rem !important;
}

/* Salidas de las demos de JS */
.js-out {
  font-family: var(--fuente-mono);
  font-size: 0.85rem;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radio-m);
  padding: var(--esp-3);
  margin: var(--esp-3) 0 0;
  min-height: 2.4em;
  white-space: pre-wrap;
  overflow-x: auto;
}
.js-out:empty::before {
  content: "· · ·";
  color: var(--tok-com);
}

.cl-box {
  padding: var(--esp-3) var(--esp-4);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-m);
  transition: background var(--trans-media), border-color var(--trans-media), transform var(--trans-media);
}
.cl-box.destacada {
  background: var(--acento-suave);
  border-color: var(--acento);
  transform: scale(1.03);
  font-weight: 600;
}

.live-region { font-weight: 600; color: var(--verde); margin: 0; min-height: 1.4em; }

.a11y-panel {
  margin-top: var(--esp-3);
  background: var(--superficie);
  border: 1.5px solid var(--acento);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
  display: grid;
  gap: var(--esp-2);
  justify-items: start;
}

.fetch-estado { font-weight: 600; min-height: 1.4em; margin: var(--esp-2) 0 0; }
.fetch-estado.is-loading { color: var(--ambar); }
.fetch-estado.is-ok { color: var(--verde); }
.fetch-estado.is-error { color: var(--rojo); }

/* ------------------------------------------------------------
   10 · FORMULARIOS (SISTEMA COMPLETO)
------------------------------------------------------------ */
.field { margin-bottom: var(--esp-4); }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--esp-1);
}
.field-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--esp-2);
  margin-bottom: var(--esp-3);
}
.field-inline label { margin: 0; }
.field-inline input { flex: 1; min-width: 140px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]),
select,
textarea {
  width: 100%;
  max-width: 32rem;
  font: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-s);
  padding: 0.55rem 0.75rem;
  min-height: var(--tactil);
  transition: border-color var(--trans-rapida), background var(--trans-rapida);
}
textarea { min-height: auto; resize: vertical; }

input:hover, select:hover, textarea:hover { border-color: var(--texto-tenue); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--acento);
  outline-offset: 0;
}

input::placeholder, textarea::placeholder {
  color: var(--texto-tenue);
  font-style: italic;
  opacity: 1;
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--superficie-alt);
  color: var(--texto-tenue);
  border-style: dashed;
  cursor: not-allowed;
}
input:read-only:not(:disabled) { background: var(--superficie-alt); }

/* Casillas y radios: color de marca y tamaño táctil */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--acento);
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}
input[type="color"] {
  min-height: var(--tactil);
  min-width: 60px;
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-s);
  background: var(--superficie);
  padding: 4px;
}
input[type="range"] { accent-color: var(--acento); }

/* Botón interno del input de archivo */
input[type="file"] {
  width: 100%;
  max-width: 32rem;
  font: inherit;
  color: var(--texto-suave);
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  color: var(--acento-fuerte);
  background: var(--acento-suave);
  border: 1px solid var(--acento);
  border-radius: var(--radio-s);
  padding: 0.45rem 0.9rem;
  margin-right: var(--esp-3);
  min-height: 38px;
  cursor: pointer;
  transition: background var(--trans-rapida);
}
input[type="file"]::file-selector-button:hover { background: var(--acento); color: var(--acento-contraste); }

/* Opción marcable con etiqueta táctil completa */
.choice {
  display: flex;
  align-items: center;
  gap: var(--esp-2);
  min-height: 38px;
  padding: var(--esp-1) 0;
  cursor: pointer;
  font-weight: 500;
}

.demo-fieldset {
  border: 1.5px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
  margin: 0 0 var(--esp-4);
  min-width: 0;
}
.demo-fieldset legend {
  font-weight: 700;
  padding: 0 var(--esp-2);
}

/* Botones del sistema */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--esp-2);
  font: inherit;
  font-weight: 600;
  min-height: var(--tactil);
  padding: 0.5rem 1.1rem;
  color: var(--texto);
  background: var(--superficie);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-m);
  cursor: pointer;
  transition: background var(--trans-rapida), border-color var(--trans-rapida), color var(--trans-rapida), transform var(--trans-rapida);
}
.btn:hover { background: var(--superficie-alt); border-color: var(--texto-tenue); }
.btn:active { transform: scale(0.97); }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-contraste);
}
.btn-primary:hover {
  background: var(--acento-fuerte);
  border-color: var(--acento-fuerte);
  color: var(--acento-contraste);
}

.btn-chip {
  min-height: 36px;
  padding: 0.25rem 0.8rem;
  font-size: 0.85rem;
  font-family: var(--fuente-mono);
  border-radius: 999px;
}
.btn-chip.is-active {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-contraste);
}

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--superficie-alt); }

.btn-copy { flex-shrink: 0; }
.btn-copy.is-copied {
  background: var(--verde-suave);
  border-color: var(--verde);
  color: var(--verde);
}

/* Indicador de carga dentro de botones de envío */
.btn-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2.5px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
.is-loading .btn-spinner { display: inline-block; }

/* Ayudas y errores de campo */
.field-hint {
  font-size: 0.85rem;
  color: var(--texto-tenue);
  margin: var(--esp-1) 0 0;
}
.field-error {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--rojo);
  margin: var(--esp-1) 0 0;
  min-height: 1.3em;
}
.field-error:not(:empty)::before { content: "⚠ "; }

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--rojo);
}

/* Mensajes de estado de formulario (carga / éxito / error) */
.form-status {
  min-height: 1.6em;
  font-weight: 600;
  margin: var(--esp-3) 0 0;
  border-radius: var(--radio-s);
}
.form-status.is-loading { color: var(--ambar); }
.form-status.is-ok {
  color: var(--verde);
  background: var(--verde-suave);
  padding: var(--esp-2) var(--esp-3);
}
.form-status.is-error {
  color: var(--rojo);
  background: var(--rojo-suave);
  padding: var(--esp-2) var(--esp-3);
}

.msg {
  display: flex;
  gap: var(--esp-2);
  align-items: baseline;
  font-weight: 600;
  border-radius: var(--radio-s);
  padding: var(--esp-2) var(--esp-3);
  margin: var(--esp-2) 0 0;
}
.msg-error { color: var(--rojo); background: var(--rojo-suave); }
.msg-ok { color: var(--verde); background: var(--verde-suave); }

.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--esp-4);
  margin-top: var(--esp-4);
}
.sim-error {
  font-size: 0.85rem;
  color: var(--texto-tenue);
  font-weight: 500;
}

.form-echo {
  display: block;
  font-family: var(--fuente-mono);
  font-size: 0.85rem;
  color: var(--acento);
  margin-top: var(--esp-2);
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 var(--esp-4);
}

/* Mostrar/ocultar contraseña */
.pass-wrap {
  display: flex;
  gap: var(--esp-2);
  align-items: stretch;
  max-width: 32rem;
}
.pass-wrap input { flex: 1; max-width: none; }
.pass-toggle { border: 1.5px solid var(--borde-fuerte); border-radius: var(--radio-s); }
.pass-toggle[aria-pressed="true"] { background: var(--acento-suave); border-color: var(--acento); }

.strength-row {
  display: flex;
  align-items: center;
  gap: var(--esp-3);
  margin-top: var(--esp-1);
}
.strength-label { font-size: 0.85rem; font-weight: 600; color: var(--texto-suave); }

/* ------------------------------------------------------------
   11 · ÍNDICE (TOC)
------------------------------------------------------------ */
.toc-search { max-width: 30rem; margin-bottom: var(--esp-4); }
.toc-search label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--esp-1);
}

.toc {
  columns: 1;
  column-gap: var(--esp-5);
}
.toc-group {
  break-inside: avoid;
  margin-bottom: var(--esp-4);
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
}
.toc-group > a {
  font-weight: 700;
  font-size: 1.02rem;
  text-decoration: none;
  display: inline-block;
  margin-bottom: var(--esp-1);
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--esp-3);
  border-left: 2px solid var(--acento-suave);
}
.toc li { margin: 0; }
.toc ul a {
  display: inline-block;
  padding: 0.18rem 0;
  text-decoration: none;
  color: var(--texto-suave);
  font-size: 0.93rem;
}
.toc ul a:hover { color: var(--acento); text-decoration: underline; }
.toc ul ul { border-left: none; padding-left: var(--esp-4); }
.toc ul ul a { font-size: 0.88rem; color: var(--texto-tenue); }
.toc .is-hidden { display: none; }

/* ------------------------------------------------------------
   12 · CONSEJOS, PROMPTS Y AVISOS
------------------------------------------------------------ */
.tip-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--esp-4);
  margin: var(--esp-4) 0;
}
.tip {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-left: 4px solid var(--acento);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
}
.tip h4 { font-size: 1rem; }
.tip p { margin: 0; color: var(--texto-suave); font-size: 0.95rem; }

.avoid-list {
  list-style: none;
  margin: var(--esp-4) 0;
  padding: 0;
  display: grid;
  gap: var(--esp-2);
}
.avoid-list li {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-left: 4px solid var(--rojo);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
  color: var(--texto-suave);
  font-size: 0.95rem;
}

.starter-grid, .prompt-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--esp-4);
  margin: var(--esp-4) 0;
}
.starter-card, .prompt-card {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-l);
  padding: var(--esp-4) var(--esp-5);
  box-shadow: var(--sombra-1);
  display: flex;
  flex-direction: column;
}
.prompt-card h3 {
  margin-top: 0 !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
  font-size: 1.1rem;
}
.prompt-tags { display: flex; gap: var(--esp-1); margin-bottom: var(--esp-2); }
.starter-text, .prompt-text {
  color: var(--texto-suave);
  font-size: 0.95rem;
  flex: 1;
  border-left: 3px solid var(--acento-suave);
  padding-left: var(--esp-3);
}
.starter-card .btn-copy, .prompt-card .btn-copy { align-self: flex-start; }

/* Frase 🗣 para pedírselo a la IA */
.ask {
  display: flex;
  align-items: flex-start;
  gap: var(--esp-3);
  background: var(--acento-suave);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
  margin-top: var(--esp-3);
}
.ask-text {
  margin: 0;
  flex: 1;
  font-size: 0.95rem;
}
.ask-icon { margin-right: 0.35em; }
.ask-phrase { font-style: italic; color: var(--texto); }

/* ------------------------------------------------------------
   13 · FORMULARIOS DE DEMOSTRACIÓN (APPS)
------------------------------------------------------------ */
.demo-app {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-l);
  padding: var(--esp-5);
  margin: var(--esp-5) 0;
  box-shadow: var(--sombra-1);
}
.demo-app > h3 {
  margin-top: 0 !important;
  border-bottom: none !important;
  font-size: 1.3rem;
}
.demo-app-lead { color: var(--texto-suave); max-width: var(--ancho-texto); }

.app-form {
  background: var(--bg);
  border: 1px dashed var(--borde-fuerte);
  border-radius: var(--radio-m);
  padding: var(--esp-5);
  max-width: 40rem;
}
.app-subtitle {
  font-size: 1.02rem;
  margin: var(--esp-4) 0 var(--esp-3);
  color: var(--acento-fuerte);
}
.app-form .app-subtitle:first-child { margin-top: 0; }

.code-view {
  margin-top: var(--esp-4);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  overflow: hidden;
}
.code-view summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--esp-3) var(--esp-4);
  min-height: var(--tactil);
  display: flex;
  align-items: center;
  color: var(--texto-suave);
}
.code-view summary:hover { background: var(--superficie-alt); }
.code-view .code { margin: 0; border-radius: 0; max-height: 420px; overflow: auto; }

/* Carrito del checkout */
.table-scroll { overflow-x: auto; }
.cart-table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--esp-4);
  background: var(--superficie);
  border-radius: var(--radio-m);
}
.cart-table th, .cart-table td {
  border: 1px solid var(--borde);
  padding: var(--esp-2) var(--esp-3);
  text-align: left;
  vertical-align: middle;
}
.cart-table thead th { background: var(--superficie-alt); font-size: 0.9rem; }
.cart-qty { width: 5.5rem; min-height: 40px !important; }
.cart-subtotal { font-family: var(--fuente-mono); white-space: nowrap; }
.cart-total {
  font-family: var(--fuente-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--acento);
  white-space: nowrap;
}

/* Zona de arrastre de archivos */
.dropzone {
  border: 2px dashed var(--borde-fuerte);
  border-radius: var(--radio-m);
  padding: var(--esp-4);
  text-align: center;
  background: var(--superficie);
  transition: border-color var(--trans-rapida), background var(--trans-rapida);
}
.dropzone p { color: var(--texto-tenue); margin: 0 0 var(--esp-2); }
.dropzone.is-over {
  border-color: var(--acento);
  background: var(--acento-suave);
}

.preview-list {
  list-style: none;
  margin: 0 0 var(--esp-4);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--esp-3);
}
.preview-item {
  position: relative;
  width: 110px;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-1);
  text-align: center;
}
.preview-item img {
  width: 100%;
  height: 74px;
  object-fit: cover;
  border-radius: var(--radio-s);
  display: block;
}
.preview-name {
  font-size: 0.7rem;
  color: var(--texto-tenue);
  margin: var(--esp-1) 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 50%;
  background: var(--rojo);
  color: #fff;
  border: 2px solid var(--superficie);
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  padding: 0;
}

/* Autocompletado del buscador */
.autocomplete-wrap { position: relative; max-width: 32rem; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  list-style: none;
  margin: 4px 0 0;
  padding: var(--esp-1);
  background: var(--superficie);
  border: 1px solid var(--borde-fuerte);
  border-radius: var(--radio-m);
  box-shadow: var(--sombra-2);
  max-height: 260px;
  overflow-y: auto;
}
.autocomplete-list li {
  padding: var(--esp-2) var(--esp-3);
  border-radius: var(--radio-s);
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--esp-2);
}
.autocomplete-list li:hover { background: var(--superficie-alt); }
.autocomplete-list li[aria-selected="true"] {
  background: var(--acento-suave);
  color: var(--acento-fuerte);
  font-weight: 600;
}
.autocomplete-list mark {
  background: transparent;
  color: var(--acento);
  font-weight: 700;
}

.search-results { margin-top: var(--esp-3); }
.search-result {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: var(--esp-3) var(--esp-4);
  margin-bottom: var(--esp-2);
}
.search-result h4 { margin: 0 0 var(--esp-1); font-size: 1rem; }
.search-result p { margin: 0; color: var(--texto-suave); font-size: 0.92rem; }
.search-result .badge { margin-left: var(--esp-2); }

/* Multi-paso */
.ms-progress { margin-bottom: var(--esp-5); }
.ms-bar {
  height: 8px;
  background: var(--superficie-alt);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--esp-3);
}
.ms-bar-fill {
  height: 100%;
  width: 33.33%;
  background: var(--acento);
  border-radius: 999px;
  transition: width var(--trans-media);
}
.ms-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  gap: var(--esp-2);
  counter-reset: paso;
}
.ms-step {
  counter-increment: paso;
  display: flex;
  align-items: center;
  gap: var(--esp-1);
  font-size: 0.85rem;
  color: var(--texto-tenue);
  font-weight: 600;
}
.ms-step::before {
  content: counter(paso);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--superficie-alt);
  border: 1.5px solid var(--borde-fuerte);
  font-family: var(--fuente-mono);
  flex-shrink: 0;
}
.ms-step.is-active { color: var(--acento-fuerte); }
.ms-step.is-active::before {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-contraste);
}
.ms-step.is-done { color: var(--verde); }
.ms-step.is-done::before {
  content: "✓";
  background: var(--verde-suave);
  border-color: var(--verde);
  color: var(--verde);
}

.ms-panel { margin-bottom: 0; }
.ms-resumen {
  margin: 0 0 var(--esp-3);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--esp-1) var(--esp-4);
}
.ms-resumen dt { font-weight: 700; }
.ms-resumen dd { margin: 0; color: var(--texto-suave); }

/* ------------------------------------------------------------
   14 · TABLA DE REFERENCIA
------------------------------------------------------------ */
.ref-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--esp-4);
  margin-bottom: var(--esp-4);
}
.ref-controls .field-inline { margin: 0; }
.ref-controls input, .ref-controls select { max-width: 18rem; }

.ref-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 56rem;
  background: var(--superficie);
  font-size: 0.9rem;
}
.ref-table th, .ref-table td {
  border: 1px solid var(--borde);
  padding: var(--esp-2) var(--esp-3);
  text-align: left;
  vertical-align: top;
}
.ref-table thead th {
  background: var(--superficie-alt);
  position: sticky;
  top: 64px;
}
.ref-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--superficie-alt) 50%, transparent); }
.ref-table code { white-space: nowrap; }
.ref-table .ref-ask { font-style: italic; color: var(--texto-suave); }
.ref-table .ref-warn { color: var(--texto-suave); font-size: 0.85rem; }
.ref-cat {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-block;
  margin-top: var(--esp-1);
}
.ref-cat-html { color: var(--acento); }
.ref-cat-css { color: var(--ambar); }
.ref-cat-js { color: var(--verde); }
.ref-cat-bp { color: var(--texto-tenue); }

/* ------------------------------------------------------------
   15 · PIE Y BOTÓN SUBIR
------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--borde);
  background: var(--bg-alt);
  margin-top: var(--esp-6);
}
.footer-inner {
  max-width: var(--ancho-max);
  margin: 0 auto;
  padding: var(--esp-6) var(--esp-4);
  color: var(--texto-suave);
  font-size: 0.92rem;
}
.footer-title { font-weight: 700; color: var(--texto); font-size: 1rem; }

.scroll-top {
  position: fixed;
  right: var(--esp-4);
  bottom: var(--esp-4);
  z-index: 90;
  width: var(--tactil);
  height: var(--tactil);
  border-radius: 50%;
  border: 1px solid var(--borde-fuerte);
  background: var(--superficie);
  color: var(--texto-suave);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sombra-2);
  transition: background var(--trans-rapida), color var(--trans-rapida), transform var(--trans-rapida);
}
.scroll-top:hover { background: var(--acento); color: var(--acento-contraste); }
.scroll-top:active { transform: scale(0.92); }

/* ------------------------------------------------------------
   16 · RESPONSIVE (MÓVIL PRIMERO)
------------------------------------------------------------ */
/* Tablet: desde 600px */
@media (min-width: 600px) {
  .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prompt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .toc { columns: 2; }

  .mq-badge::after { content: "💻 Tablet (600–899px)"; }
  html[lang="en"] .mq-badge::after { content: "💻 Tablet (600–899px)"; }
}

/* Escritorio: desde 900px */
@media (min-width: 900px) {
  .toc { columns: 3; }

  .mq-badge::after { content: "🖥 Escritorio (900px o más)"; }
  html[lang="en"] .mq-badge::after { content: "🖥 Desktop (900px and up)"; }
}

/* Navegación en fila a partir de 1020px */
@media (min-width: 1020px) {
  .nav-toggle { display: none; }
  .main-nav {
    position: static;
    display: block;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .main-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    gap: 2px;
  }
  .main-nav a {
    min-height: 40px;
    padding: 0 var(--esp-2);
    font-size: 0.92rem;
    white-space: nowrap;
  }
}

/* Pantallas muy pequeñas: compactar cabecera */
@media (max-width: 380px) {
  .brand-name { display: none; }
}

/* ------------------------------------------------------------
   17 · MOVIMIENTO REDUCIDO E IMPRESIÓN
------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .topbar, .scroll-top, .btn-copy, .nav-toggle, .sim-error { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .demo-app, .tip, .prompt-card, .starter-card { box-shadow: none; break-inside: avoid; }
  .code-view[open] .code { max-height: none; }
  a { color: inherit; }
}
