/* ==========================================================================
   Ética en la Inteligencia Artificial — hoja de estilos única
   Sin dependencias externas: ni CDN, ni fuentes remotas, ni frameworks.
   Eso es lo que permite servir el sitio con una CSP estricta y sin conexión.
   --------------------------------------------------------------------------
   1. Tokens y tema          6. Componentes de contenido
   2. Reset y base           7. Quiz y ejercicios
   3. Estructura (shell)     8. Interactivos y SVG
   4. Barra superior         9. Mapa y glosario
   5. Barra lateral         10. Responsive / print / motion
   ========================================================================== */

/* == 1. Tokens y tema ===================================================== */

:root {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-sunken: #e9ecf5;
  --bg-hover: #e3e7f4;

  --text: #171a2b;
  --text-soft: #4a4f68;
  --text-faint: #5f6580; /* era #767c96: 3,5:1 sobre --bg-sunken, no llegaba a WCAG AA */

  --border: #dde1ee;
  --border-strong: #bfc6dc;

  --accent: #4338ca;
  --accent-hover: #372fae;
  --accent-soft: #ecebfa;
  --accent-text: #ffffff;

  --ok: #0f7355;
  --ok-soft: #dcf3ea;
  --warn: #94590a;
  --warn-soft: #fbeed4;
  --bad: #b02230;
  --bad-soft: #fce9eb;
  --info: #145f9e;
  --info-soft: #e2eefb;

  /* Un color por unidad: se usa en fichas, mapa, chips y bordes. */
  --u1: #4338ca;
  --u2: #0d7a86;
  --u3: #a8501d;
  --u4: #7b3a99;
  --u5: #1d6640;
  --u6: #a11e3c;
  --u-hito: #64697f;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(18, 21, 45, .06), 0 1px 3px rgba(18, 21, 45, .04);
  --shadow-md: 0 4px 12px rgba(18, 21, 45, .08), 0 1px 3px rgba(18, 21, 45, .05);
  --shadow-lg: 0 12px 32px rgba(18, 21, 45, .14);

  --sidebar-w: 288px;
  --topbar-h: 58px;
  --content-max: 880px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1119;
  --bg-elev: #171a26;
  --bg-sunken: #1e2231;
  --bg-hover: #262b3c;

  --text: #e9ebf5;
  --text-soft: #b0b6cc;
  --text-faint: #848aa3;

  --border: #2a2f42;
  --border-strong: #3d4459;

  --accent: #8b83ff;
  --accent-hover: #a49dff;
  --accent-soft: #232144;
  --accent-text: #14121f;

  --ok: #4ad6a4;
  --ok-soft: #10322a;
  --warn: #ecb54a;
  --warn-soft: #33270f;
  --bad: #ff7b8a;
  --bad-soft: #35161d;
  --info: #63b0f0;
  --info-soft: #12283c;

  --u1: #8b83ff;
  --u2: #3fc2ce;
  --u3: #e5934f;
  --u4: #c48ae0;
  --u5: #55c184;
  --u6: #f0708f;
  --u-hito: #9aa0b8;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);
}

/* == 2. Reset y base ====================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.6rem); margin-top: 2.2em; letter-spacing: -.01em; }
h3 { font-size: 1.12rem; margin-top: 1.8em; }
h4 { font-size: 1rem; margin-top: 1.4em; }
h2:first-child, h3:first-child { margin-top: 0; }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.4em; }
li { margin-bottom: .4em; }
li > ul, li > ol { margin-top: .4em; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

code, kbd { font-family: var(--mono); font-size: .9em; }
code {
  background: var(--bg-sunken);
  padding: .12em .38em;
  border-radius: 4px;
}

strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: var(--accent-text);
  padding: .6em 1em;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

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

/* == 3. Estructura ======================================================== */

.layout { display: flex; min-height: 100vh; padding-top: var(--topbar-h); }

main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 2.2rem 2rem 6rem;
}

.wrap { max-width: var(--content-max); margin: 0 auto; }
.wrap-wide { max-width: 1180px; margin: 0 auto; }

/* == 4. Barra superior ==================================================== */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 1rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: .98rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 30px; height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: .95rem;
  font-weight: 800;
}
.brand-sub {
  color: var(--text-faint);
  font-weight: 500;
  font-size: .82rem;
}

.icon-btn {
  width: 36px; height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

#nav-toggle { display: none; }

.topbar-progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}
.progress-track {
  width: 130px; height: 7px;
  background: var(--bg-sunken);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width .5s var(--ease);
}
.progress-label {
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  white-space: nowrap;
}

/* == 5. Barra lateral ===================================================== */

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 1rem .75rem 2rem;
}

.nav-group { margin-bottom: 1.4rem; }
.nav-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 .6rem;
  margin-bottom: .45rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .44rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .9rem;
  text-decoration: none;
  transition: background .13s var(--ease), color .13s var(--ease);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
}

.nav-num {
  flex: none;
  width: 22px;
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  text-align: right;
}
.nav-link[aria-current="page"] .nav-num { color: var(--accent); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Punto de estado: gris = sin ver, azul = leído, verde = quiz aprobado */
.dot {
  flex: none;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
}
.dot.leido { background: var(--info); border-color: var(--info); }
.dot.aprobado { background: var(--ok); border-color: var(--ok); }
.dot.dominado {
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--ok) 28%, transparent);
}

.nav-link.es-hito .nav-text { color: var(--u6); font-weight: 620; }
.nav-link.pendiente .nav-text { color: var(--text-faint); font-style: italic; }

.sidebar-foot {
  margin-top: 1.5rem;
  padding: 0 .35rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* == Botones ============================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .52rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: .9rem;
  font-weight: 560;
  text-decoration: none;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { padding: .34rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* Sin esto, un SVG dentro de un botón se estira hasta el ancho disponible. */
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0; }

/* == 6. Componentes de contenido ========================================== */

.page-head { margin-bottom: 2rem; }
.page-head h1 { margin-bottom: .3rem; }
.page-lead {
  font-size: 1.06rem;
  color: var(--text-soft);
  max-width: 62ch;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .7rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .18rem .6rem;
  border-radius: 99px;
  font-size: .76rem;
  font-weight: 620;
  background: var(--bg-sunken);
  color: var(--text-soft);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-u1 { background: color-mix(in srgb, var(--u1) 13%, transparent); color: var(--u1); }
.chip-u2 { background: color-mix(in srgb, var(--u2) 15%, transparent); color: var(--u2); }
.chip-u3 { background: color-mix(in srgb, var(--u3) 15%, transparent); color: var(--u3); }
.chip-u4 { background: color-mix(in srgb, var(--u4) 15%, transparent); color: var(--u4); }
.chip-u5 { background: color-mix(in srgb, var(--u5) 15%, transparent); color: var(--u5); }
.chip-u6 { background: color-mix(in srgb, var(--u6) 15%, transparent); color: var(--u6); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-info { background: var(--info-soft); color: var(--info); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
}

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

/* Fichas de clase en el índice */
.clase-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--borde-unidad, var(--border-strong));
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
}
.clase-card:hover {
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.clase-card.es-stub { opacity: .72; }
.clase-card.es-hito {
  border-left-color: var(--u6);
  background: color-mix(in srgb, var(--u6) 5%, var(--bg-elev));
}
.clase-card h3 { margin: 0; font-size: 1.02rem; }
.clase-card .meta { font-size: .8rem; color: var(--text-faint); }
.clase-card .desc { font-size: .875rem; color: var(--text-soft); margin: 0; }

/* Cajas destacadas */
.callout {
  border-left: 3px solid var(--info);
  background: var(--info-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .9rem 1.1rem;
  margin: 1.4rem 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout-titulo {
  font-weight: 680;
  font-size: .82rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--info);
  margin-bottom: .35rem;
}
.callout.clave { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.clave .callout-titulo { color: var(--ok); }
.callout.ojo { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.ojo .callout-titulo { color: var(--warn); }
.callout.examen { border-left-color: var(--bad); background: var(--bad-soft); }
.callout.examen .callout-titulo { color: var(--bad); }

/* Definición de término */
.definicion {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1.15rem;
  margin: 1.2rem 0;
}
.definicion dt {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .25rem;
}
.definicion dd { margin: 0 0 1rem; color: var(--text-soft); }
.definicion dd:last-child { margin-bottom: 0; }

/* Tablas */
.tabla-wrap { overflow-x: auto; margin: 1.4rem 0; border-radius: var(--radius); border: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; background: var(--bg-elev); }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunken); font-weight: 660; font-size: .82rem; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Ficha de caso jurisprudencial */
.caso {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.5rem 0;
}
.caso-head {
  padding: .85rem 1.15rem;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.caso-head h4 { margin: 0; font-size: 1rem; }
.caso-head .meta { font-size: .78rem; color: var(--text-faint); margin-top: .15rem; }
.caso-body { padding: 1rem 1.15rem; }
.caso-body > :last-child { margin-bottom: 0; }
.caso-body dt { font-weight: 660; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-top: .8rem; }
.caso-body dt:first-child { margin-top: 0; }
.caso-body dd { margin: .15rem 0 0; }

/* Repaso rápido: toggle breve/completo, aplicado por js/repaso.js */
.rp-full { display: none; margin-top: .4rem; }
body.modo-completo .rp-breve { display: none; }
body.modo-completo .rp-full { display: block; }
.rp-termino { margin: 0; }
.rp-termino strong { display: block; margin-bottom: .3rem; }
.repaso-anclas { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.6rem; }
.repaso-anclas a { text-decoration: none; cursor: pointer; }

/* Marca de contenido que no viene de la clase */
.ampliacion {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 620;
  color: var(--warn);
  background: var(--warn-soft);
  padding: .1rem .5rem;
  border-radius: 99px;
}

/* Acordeón */
details.acordeon {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  margin: .7rem 0;
}
details.acordeon > summary {
  padding: .7rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .93rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
details.acordeon > summary::-webkit-details-marker { display: none; }
details.acordeon > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid var(--text-faint);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .18s var(--ease);
  flex: none;
}
details.acordeon[open] > summary::before { transform: rotate(90deg); }
details.acordeon > div { padding: 0 1rem 1rem; }
details.acordeon > div > :last-child { margin-bottom: 0; }

/* Barra de acción "marcar como estudiada" */
.marcar-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .8rem;
  margin: 2.5rem 0 1rem;
  padding: 1rem 1.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.marcar-barra .estado { font-size: .87rem; color: var(--text-soft); }
.marcar-barra.hecho { border-color: var(--ok); background: var(--ok-soft); }
.marcar-barra.hecho .estado { color: var(--ok); font-weight: 600; }

/* Paginación entre clases */
.paginacion {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.paginacion a {
  max-width: 46%;
  font-size: .88rem;
  text-decoration: none;
  color: var(--text-soft);
}
.paginacion a:hover { color: var(--accent); }
.paginacion .dir { display: block; font-size: .74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.paginacion .sig { text-align: right; margin-left: auto; }

/* == 7. Quiz y ejercicios ================================================= */

.quiz {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin: 1.5rem 0;
}
.quiz-cab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
  font-size: .8rem;
  color: var(--text-faint);
}
.quiz-pregunta { font-weight: 620; font-size: 1.02rem; margin-bottom: 1rem; }

.opciones { display: flex; flex-direction: column; gap: .5rem; }
.opcion {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  width: 100%;
  padding: .7rem .85rem;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .93rem;
  line-height: 1.5;
  transition: background .13s var(--ease), border-color .13s var(--ease);
}
.opcion:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.opcion .letra {
  flex: none;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--bg-sunken);
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-soft);
}
.opcion.elegida { border-color: var(--accent); background: var(--accent-soft); }
.opcion.elegida .letra { background: var(--accent); color: var(--accent-text); }
.opcion.correcta { border-color: var(--ok); background: var(--ok-soft); }
.opcion.correcta .letra { background: var(--ok); color: #fff; }
.opcion.incorrecta { border-color: var(--bad); background: var(--bad-soft); }
.opcion.incorrecta .letra { background: var(--bad); color: #fff; }
.opcion.faltante { border-color: var(--warn); background: var(--warn-soft); }
.opcion.faltante .letra { background: var(--warn); color: #fff; }
.opcion:disabled { cursor: default; opacity: 1; }

.feedback {
  margin-top: .9rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  border-left: 3px solid var(--info);
  background: var(--info-soft);
}
.feedback.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.feedback.mal { border-left-color: var(--bad); background: var(--bad-soft); }
.feedback.falta { border-left-color: var(--warn); background: var(--warn-soft); }
.feedback .fb-titulo { font-weight: 680; margin-bottom: .2rem; }
.feedback .fuente { display: block; margin-top: .5rem; font-size: .78rem; color: var(--text-faint); }

.puntaje-grande {
  font-size: 2.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.puntaje-grande.aprobado { color: var(--ok); }
.puntaje-grande.desaprobado { color: var(--bad); }

/* Ejercicios: fichas arrastrables / clicables */
.fichas { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.ficha {
  padding: .45rem .8rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  font-size: .87rem;
  transition: background .13s var(--ease), transform .1s var(--ease);
}
.ficha:hover { background: var(--bg-hover); }
.ficha.activa {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.ficha.usada { opacity: .35; pointer-events: none; }

.cubos { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 1rem 0; }
.cubo {
  background: var(--bg-sunken);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: .8rem;
  min-height: 110px;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.cubo.destino { border-color: var(--accent); background: var(--accent-soft); }
.cubo h4 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.cubo .puestas { display: flex; flex-wrap: wrap; gap: .4rem; }
.cubo .puesta {
  padding: .3rem .6rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .82rem;
}
.cubo .puesta.bien { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.cubo .puesta.mal { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* Emparejar: dos columnas */
.emparejar { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; margin: 1rem 0; }
.emparejar h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin: 0 0 .5rem; }
.emparejar .col { display: flex; flex-direction: column; gap: .45rem; }
.emparejar .item {
  padding: .55rem .8rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .87rem;
  text-align: left;
  line-height: 1.45;
}
.emparejar .item:hover:not(:disabled) { background: var(--bg-hover); }
.emparejar .item.activa { border-color: var(--accent); background: var(--accent-soft); }
.emparejar .item.usada { opacity: .4; pointer-events: none; }

.pares { display: flex; flex-direction: column; gap: .4rem; margin: 1rem 0; }
.par {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .7rem;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  font-size: .85rem;
}
.par.bien { background: var(--ok-soft); color: var(--ok); }
.par.mal { background: var(--bad-soft); color: var(--bad); }
.par .flecha { color: var(--text-faint); flex: none; }
.par .quitar { margin-left: auto; background: none; border: 0; color: var(--text-faint); font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }

/* Temporizador */
.temporizador {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  padding: .4rem .8rem;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
}
.temporizador.urgente { background: var(--bad-soft); color: var(--bad); }

/* == 8. Interactivos y SVG ================================================ */

.interactivo {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin: 1.8rem 0;
  box-shadow: var(--shadow-sm);
}
.interactivo > h3 { margin-top: 0; }
.interactivo .intro { font-size: .92rem; color: var(--text-soft); margin-bottom: 1.1rem; }

.controles {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin: 1.1rem 0;
  padding: 1rem;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
}
.control label {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.control .valor {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
}
.control input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.control .pista { font-size: .76rem; color: var(--text-faint); margin-top: .25rem; }

/* Tarjetas de métrica */
.metricas { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 1.1rem 0; }
.metrica {
  padding: .85rem 1rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.metrica.cumple { border-left-color: var(--ok); background: var(--ok-soft); }
.metrica.falla { border-left-color: var(--bad); background: var(--bad-soft); }
.metrica .nombre { font-size: .8rem; font-weight: 680; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); }
.metrica .cifra { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: .15rem 0; }
.metrica .detalle { font-size: .78rem; color: var(--text-soft); line-height: 1.45; }
.metrica .veredicto { font-size: .78rem; font-weight: 700; margin-top: .3rem; }
.metrica.cumple .veredicto { color: var(--ok); }
.metrica.falla .veredicto { color: var(--bad); }

svg { max-width: 100%; height: auto; display: block; }
.svg-wrap { overflow-x: auto; margin: 1.1rem 0; }

/* Pirámide de riesgo */
.piramide { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 1.2rem 0; }
.nivel-riesgo {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem 1rem;
  text-align: left;
  background: var(--bg-sunken);
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}
.nivel-riesgo:hover { transform: scale(1.015); }
.nivel-riesgo[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.nivel-riesgo .titulo { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: .5rem; }
.nivel-riesgo .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.nivel-riesgo .resumen { font-size: .82rem; color: var(--text-soft); margin-top: .15rem; }
.nivel-detalle {
  padding: 1rem 1.2rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: .5rem;
  font-size: .9rem;
}
.nivel-detalle > :last-child { margin-bottom: 0; }

/* Línea de tiempo */
.timeline { position: relative; margin: 1.5rem 0; padding-left: 1.6rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: .5rem; bottom: .5rem;
  width: 2px;
  background: var(--border);
}
.hito-t { position: relative; margin-bottom: 1.3rem; }
.hito-t::before {
  content: "";
  position: absolute;
  left: -1.6rem; top: .45rem;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--accent);
}
.hito-t.hard::before { background: var(--accent); }
.hito-t .fecha { font-size: .76rem; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.hito-t h4 { margin: .1rem 0 .2rem; font-size: .96rem; }
.hito-t p { font-size: .87rem; color: var(--text-soft); margin: 0; }

/* == 9. Mapa y glosario =================================================== */

.mapa-wrap {
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
/* El grafo conserva su tamaño natural y se desplaza dentro de su caja: si lo
   dejáramos encogerse hasta entrar, las etiquetas quedarían ilegibles. */
.mapa-wrap svg { max-width: none; }
.nodo rect {
  fill: var(--bg-sunken);
  stroke: var(--border-strong);
  stroke-width: 1.5;
  transition: fill .15s var(--ease), stroke .15s var(--ease);
}
.nodo:hover rect { fill: var(--bg-hover); }
.nodo text { fill: var(--text); font-size: 11px; font-family: var(--font); pointer-events: none; }
.nodo.leido rect { stroke: var(--info); }
.nodo.aprobado rect { stroke: var(--ok); stroke-width: 2.5; }
.arista { stroke: var(--border-strong); stroke-width: 1.5; fill: none; }

.buscador {
  width: 100%;
  padding: .6rem .9rem;
  font-size: .93rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.buscador::placeholder { color: var(--text-faint); }

.glosario-lista { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.2rem; }
.termino {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
}
.termino h3 { margin: 0 0 .25rem; font-size: 1rem; }
.termino p { margin: 0; font-size: .9rem; color: var(--text-soft); }
.termino .origen { display: inline-block; margin-top: .5rem; font-size: .75rem; color: var(--text-faint); }
.termino[hidden] { display: none; }

.vacio {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-faint);
}

/* == 10. Responsive / print / motion ====================================== */

@media (max-width: 960px) {
  :root { --sidebar-w: 270px; }
  #nav-toggle { display: grid; }
  main { margin-left: 0; padding: 1.6rem 1.1rem 5rem; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.abierta { transform: translateX(0); }
  .overlay {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(10, 12, 22, .45);
    z-index: 45;
    border: 0;
    width: 100%;
  }
  .brand-sub { display: none; }
  .emparejar { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .topbar-progress .progress-track { width: 74px; }
  .progress-label { display: none; }
  .paginacion { flex-direction: column; }
  .paginacion a { max-width: 100%; }
  .paginacion .sig { text-align: left; }
  .controles { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .sidebar, .overlay, .btn-row, .marcar-barra,
  .paginacion, .skip-link, .quiz .opciones, .controles,
  .repaso-toggle, .repaso-anclas { display: none !important; }
  .layout { padding-top: 0; }
  main { margin-left: 0; padding: 0; }
  body { background: #fff; color: #000; font-size: 11.5pt; }
  .rp-breve { display: none !important; }
  .rp-full { display: block !important; }
  .card, .interactivo, .caso, .definicion { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  details.acordeon > div { display: block !important; }
  h2 { break-after: avoid; }
  a { text-decoration: none; color: #000; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* == Práctica a desarrollo (desarrollo.html) ============================== */

.consigna-desarrollo { margin: 1.2rem 0 1.8rem; }
.consigna-texto { display: block; font-weight: 600; margin-bottom: .5rem; line-height: 1.5; }
textarea.respuesta {
  width: 100%; min-height: 9rem; resize: vertical;
  padding: .8rem .9rem; font: inherit; line-height: 1.55;
  color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea.respuesta:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.guia-lista { list-style: none; padding: 0; margin: .4rem 0 0; }
.guia-lista li { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; }
.guia-lista input { margin-top: .3rem; flex-shrink: 0; }
.total-desarrollo { margin-top: 2rem; }
