/* ============================================================
   EL COLAPSO — Sistema de diseño editorial financiero
   Tema oscuro premium · Tipografía serif de exhibición
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #07090f;
  --bg-2: #0b0e17;
  --bg-3: #10141f;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-strong: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --ink: #eef1f7;
  --ink-2: #b9c0cf;
  --ink-3: #949db0;
  --gold: #e8b84b;
  --gold-soft: #f3d189;
  --red: #ff5d6c;
  --green: #3ddc97;
  --blue: #5aa7ff;
  --cyan: #3ee0d4;
  --amber: #ffb454;
  --ease-fast: 140ms cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Fraunces", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --w: 1120px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-2: 0 18px 60px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 150px;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 85% -5%, rgba(90, 167, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(232, 184, 75, 0.05), transparent 55%),
    radial-gradient(1000px 700px at 50% 110%, rgba(255, 93, 108, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: rgba(232, 184, 75, 0.28); color: #fff; }

img { max-width: 100%; display: block; }

a { color: var(--gold-soft); text-decoration: none; transition: color 0.2s; }
a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.container { width: min(var(--w), calc(100% - 48px)); margin-inline: auto; }

/* ============ Barra de progreso de lectura ============ */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  z-index: 1000;
  transition: width 0.08s linear;
}

/* ============ Navegación ============ */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 990;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(7, 9, 15, 0.72);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  height: 64px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  background: rgba(7, 9, 15, 0.92);
  padding-right: 12px;
}
.brand .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 14px var(--red);
  animation: pulse-dot 2.4s infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--red); }
  50% { box-shadow: 0 0 20px var(--red); }
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(62, 224, 212, 0.45) transparent;
  scroll-snap-type: x proximity;
  position: relative;
  z-index: 1;
}
.nav-links::-webkit-scrollbar { display: block; height: 4px; }
.nav-links::-webkit-scrollbar-track { background: transparent; }
.nav-links::-webkit-scrollbar-thumb {
  background: rgba(62, 224, 212, 0.4);
  border-radius: 999px;
}
.nav-links a {
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 999px;
  white-space: nowrap;
  flex: 0 0 auto;
  scroll-snap-align: start;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
#nav-links a:hover,
#nav-links a:focus-visible {
  color: var(--ink);
  background: rgba(62, 224, 212, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
}
.nav-links a.active { color: #0b0e17; background: var(--gold); font-weight: 700; }

/* ============ Héroe ============ */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 160px 0 70px;
  overflow: hidden;
}
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, var(--bg) 98%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 2; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(232, 184, 75, 0.35);
  background: rgba(232, 184, 75, 0.07);
  padding: 8px 16px;
  border-radius: 999px;
  margin-bottom: 26px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(42px, 7.2vw, 88px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 22px;
  max-width: 15ch;
}
.hero h1 .accent {
  background: linear-gradient(100deg, var(--red) 10%, var(--amber) 55%, var(--gold) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1 .accent {
    color: var(--gold);
    background: none;
    -webkit-text-fill-color: unset;
  }
}
.hero .lede {
  font-size: clamp(17px, 2vw, 21px);
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0 0 38px;
}
.hero-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 40px;
}
.kpi {
  background: linear-gradient(160deg, var(--panel-strong), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.kpi .v {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 700;
  line-height: 1.15;
}
.kpi.kpi-wide .v { font-size: clamp(18px, 2vw, 26px); letter-spacing: -0.01em; }
.kpi .v.red { color: var(--red); }
.kpi .v.gold { color: var(--gold); }
.kpi .v.green { color: var(--green); }
.kpi .l {
  font-size: 12.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--ease-fast), box-shadow var(--ease-fast), background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast);
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.btn-primary:focus-visible {
  outline: 3px solid #07090f;
  outline-offset: 3px;
}
.btn-primary:focus-visible {
  box-shadow: 0 0 0 5px rgba(232,184,75,.55);
}
.btn-primary {
  background: linear-gradient(100deg, var(--gold), #f6cd6e);
  color: #0b0e17;
  box-shadow: 0 10px 30px rgba(232, 184, 75, 0.25);
}
.btn-ghost {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink);
}
.scroll-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 3;
}
.scroll-hint .mouse {
  width: 22px; height: 36px;
  border: 1.5px solid var(--ink-3);
  border-radius: 12px;
  position: relative;
}
.scroll-hint .mouse::after {
  content: "";
  position: absolute;
  top: 7px; left: 50%;
  width: 3px; height: 7px;
  border-radius: 2px;
  background: var(--gold);
  transform: translateX(-50%);
  animation: wheel 1.8s infinite;
}
@keyframes wheel {
  0% { opacity: 0; transform: translate(-50%, 0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 12px); }
}

/* ============ Secciones y cabeceras ============ */
section.chapter {
  padding: 96px 0 40px;
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: auto 900px;
}
.ch-head { margin-bottom: 42px; max-width: 780px; }
.ch-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.ch-num::after {
  content: "";
  height: 1px;
  width: 90px;
  background: linear-gradient(90deg, rgba(232, 184, 75, 0.6), transparent);
}
h2.ch-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 50px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.ch-lede { font-size: 18.5px; color: var(--ink-2); margin: 0; }

h3.sub {
  font-family: var(--font-display);
  font-size: clamp(21px, 2.6vw, 28px);
  font-weight: 600;
  margin: 54px 0 16px;
}
p { margin: 0 0 18px; color: var(--ink-2); }
p strong, li strong { color: var(--ink); }
em { color: var(--gold-soft); }

/* ============ Tarjetas y rejillas ============ */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

.card {
  background: linear-gradient(165deg, var(--panel-strong), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  position: relative;
  overflow: hidden;
  transition: transform 0.28s var(--ease), border-color 0.28s, box-shadow 0.28s;
}
.card:hover,
.card:focus-within {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-2);
}
.card .icon { font-size: 30px; line-height: 1; margin-bottom: 14px; display: block; }
.card p { margin: 0; font-size: 15px; color: var(--ink-2); }
.card .tag {
  position: absolute;
  top: 14px; right: 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(0, 0, 0, 0.25);
}

.callout {
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(232, 184, 75, 0.08), transparent 70%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 20px 24px;
  margin: 26px 0;
}
.callout.red { border-color: var(--red); background: linear-gradient(90deg, rgba(255, 93, 108, 0.09), transparent 70%); }
.callout.green { border-color: var(--green); background: linear-gradient(90deg, rgba(61, 220, 151, 0.08), transparent 70%); }
.callout.blue { border-color: var(--blue); background: linear-gradient(90deg, rgba(90, 167, 255, 0.09), transparent 70%); }
.callout .co-title { font-weight: 700; color: var(--ink); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.callout p:last-child { margin-bottom: 0; }

/* ============ Tablas ============ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 620px;
}
table.data th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.02);
}
table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255, 255, 255, 0.025); }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* Semáforo fact-check */
.semaforo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.semaforo.ok { background: rgba(61, 220, 151, 0.12); color: var(--green); border: 1px solid rgba(61, 220, 151, 0.35); }
.semaforo.warn { background: rgba(255, 180, 84, 0.12); color: var(--amber); border: 1px solid rgba(255, 180, 84, 0.35); }
.semaforo.bad { background: rgba(255, 93, 108, 0.12); color: var(--red); border: 1px solid rgba(255, 93, 108, 0.35); }

/* ============ Cronología ============ */
.timeline {
  position: relative;
  margin: 40px 0 10px;
  padding-left: 34px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 9px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--gold), var(--red) 60%, var(--blue));
  opacity: 0.5;
}
.tl-item {
  position: relative;
  padding: 0 0 34px 18px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -33px; top: 5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(232, 184, 75, 0.15);
  transition: transform 0.3s var(--ease), border-color 0.3s;
}
.tl-item.crash::before { border-color: var(--red); box-shadow: 0 0 0 4px rgba(255, 93, 108, 0.15); }
.tl-item.rebound::before { border-color: var(--green); box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.15); }
.tl-item:hover::before,
.tl-item:focus-within::before { transform: scale(1.35); }
.tl-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tl-item.crash .tl-date { color: var(--red); }
.tl-item.rebound .tl-date { color: var(--green); }
.tl-item p { margin: 0; font-size: 15px; max-width: 70ch; }

/* ============ Gráficos ============ */
.chart-card {
  background: linear-gradient(165deg, var(--panel-strong), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 26px 0;
}
.chart-card .chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.chart-card .chart-sub { font-size: 13px; color: var(--ink-3); }
.chart-box { width: 100%; height: 420px; }
.chart-box.tall { height: 500px; }
.chart-box.short { height: 400px; }
.chart-note { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }
.chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast), transform var(--ease-fast), box-shadow var(--ease-fast);
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip:active { transform: scale(0.97); }
.chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; color: var(--ink); }
.chip.active { background: var(--gold); color: #0b0e17; border-color: var(--gold); font-weight: 700; }

/* ============ Simulador de apalancamiento ============ */
.sim-panel h3 { margin-top: 0; font-size: 20px; }
.sim-panel {
  background: linear-gradient(165deg, rgba(255, 93, 108, 0.05), var(--panel-strong) 40%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 30px;
  margin: 26px 0;
}
.sim-row { display: flex; gap: 34px; flex-wrap: wrap; align-items: center; }
.sim-controls { flex: 1 1 300px; min-width: 280px; }
.sim-output { flex: 1 1 320px; min-width: 280px; }
.sim-readout {
  font-family: var(--font-display);
  font-size: clamp(38px, 5vw, 60px);
  font-weight: 700;
  line-height: 1;
  margin: 6px 0 2px;
}
.sim-label { font-size: 13px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; }
.sim-verdict { font-weight: 700; font-size: 15px; margin-top: 10px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green), var(--amber) 55%, var(--red));
  margin: 14px 0 6px;
}
input[type="range"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--gold);
  cursor: grab;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--gold);
  cursor: grab;
}
.range-vals { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }

/* ============ Contadores animados ============ */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 30px 0;
}
.stat-cell {
  background: var(--bg-2);
  padding: 26px 24px;
  text-align: center;
}
.stat-cell .n {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.stat-cell .d { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* ============ 3D ============ */
.scene-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(700px 400px at 50% 0%, rgba(90, 167, 255, 0.08), var(--bg-2));
  margin: 26px 0;
}
#scene3d { width: 100%; height: 560px; display: block; cursor: grab; touch-action: pan-y; }
#scene3d:active { cursor: grabbing; }
.scene-hud {
  position: absolute;
  left: 16px; top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.hud-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(7, 9, 15, 0.75);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.scene-controls {
  position: absolute;
  right: 16px; bottom: 16px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.scene-tip {
  position: absolute;
  left: 16px; bottom: 16px;
  font-size: 12px;
  color: var(--ink-3);
  z-index: 5;
}

/* ============ Glosario ============ */
.glossary-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.25s;
}
.glossary-item:hover { border-color: var(--line-strong); }
.glossary-item summary {
  cursor: pointer;
  list-style: none;
  padding: 17px 22px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  user-select: none;
}
.glossary-item summary::-webkit-details-marker { display: none; }
.glossary-item summary .chev { margin-left: auto; color: var(--ink-3); transition: transform 0.3s var(--ease); }
.glossary-item[open] summary .chev { transform: rotate(180deg); }
.glossary-body { padding: 0 22px 20px; color: var(--ink-2); font-size: 15.5px; }
.glossary-body p { margin-bottom: 10px; }

/* ============ Quiz ============ */
.quiz-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 30px;
  margin-top: 20px;
}
.quiz-q { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin-bottom: 18px; color: var(--ink); }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt {
  text-align: left;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--ink-2);
  font-size: 15.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast), transform var(--ease-fast);
}
.quiz-opt:hover { border-color: var(--gold); color: var(--ink); }
.quiz-opt:active { transform: scale(0.992); }
.quiz-opt:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-color: var(--gold); }
.quiz-opt.correct { border-color: var(--green); background: rgba(61, 220, 151, 0.1); color: var(--green); }
.quiz-opt.wrong { border-color: var(--red); background: rgba(255, 93, 108, 0.1); color: var(--red); }
.quiz-opt:disabled { cursor: default; opacity: 0.85; }
.quiz-explain {
  margin-top: 16px;
  padding: 14px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(232, 184, 75, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14.5px;
  color: var(--ink-2);
}
.quiz-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 13.5px; color: var(--ink-3); }
.quiz-score { font-family: var(--font-mono); font-weight: 700; color: var(--gold); }

/* ============ Micro-checks por acto (R-D10) ============ */
.act-check {
  margin-top: 36px;
  padding: 22px 24px 20px;
  border: 1px solid rgba(232, 184, 75, 0.32);
  border-radius: var(--radius);
  background: var(--panel);
}
.act-check-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
}
.act-check-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  margin: 0 0 18px;
}
.act-check fieldset.act-q {
  border: 0;
  margin: 0 0 18px;
  padding: 0;
}
.act-check legend {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink);
  margin: 0 0 10px;
  padding: 0;
}
.act-check .act-opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
  font-size: 14.5px;
  cursor: pointer;
  transition: background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast);
}
.act-check .act-opt:hover { border-color: var(--gold); color: var(--ink); }
.act-check .act-opt:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-color: var(--gold);
}
.act-check .act-opt input {
  margin-top: 3px;
  flex: 0 0 auto;
  accent-color: var(--gold);
}
.act-check .act-opt.correct {
  border-color: var(--green);
  background: rgba(61, 220, 151, 0.1);
  color: var(--green);
}
.act-check .act-opt.wrong {
  border-color: var(--red);
  background: rgba(255, 93, 108, 0.1);
  color: var(--red);
}
.act-check-grade {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0b0e17;
  background: var(--gold);
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
}
.act-check-grade:hover { filter: brightness(1.06); }
.act-check-grade:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.act-check-feedback {
  min-height: 1.4em;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gold);
}

/* ============ Fuentes / bibliografía ============ */
.src-list { list-style: none; padding: 0; margin: 0; counter-reset: src; }
.src-list li {
  counter-increment: src;
  padding: 16px 20px 16px 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  position: relative;
  background: var(--panel);
  font-size: 14.5px;
  scroll-margin-top: 110px;
}
.src-list li::before {
  content: "[" counter(src) "]";
  position: absolute;
  left: 20px; top: 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 700;
}
.src-list .src-meta { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
sup.src-ref {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold);
  cursor: help;
  margin: 0 0.12em;
  padding: 0;
  line-height: 1.2;
}

/* ============ Mapa de contagio ============ */
.contagion-map { width: 100%; height: auto; margin: 26px 0; }
.contagion-map .node { cursor: pointer; outline: none; }
.contagion-map .node rect { transition: filter var(--ease-fast), stroke var(--ease-fast), stroke-width var(--ease-fast); }
.contagion-map .node:hover rect,
.contagion-map .node:focus rect,
.contagion-map .node:focus-visible rect,
.contagion-map .node.is-active rect,
.contagion-map .node:active rect { filter: brightness(1.35); }
.contagion-map .node:focus-visible rect,
.contagion-map .node.is-active rect {
  stroke: var(--gold);
  stroke-width: 3;
}
.contagion-map .node-title { font-family: var(--font-body); font-weight: 700; fill: var(--ink); font-size: 14px; }
.contagion-map .node-sub { font-family: var(--font-body); fill: var(--ink-3); font-size: 10.5px; }
.contagion-map .flow { stroke-dasharray: 7 9; animation: flowdash 1.4s linear infinite; }
@keyframes flowdash { to { stroke-dashoffset: -16; } }

/* ============ Aparición al hacer scroll ============ */
html.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
html.js .reveal.visible { opacity: 1; transform: none; }
.reveal.visible { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }

/* ============ Footer ============ */
footer {
  margin-top: 110px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35));
  padding: 56px 0 70px;
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; }
footer h3 { font-family: var(--font-display); font-size: 17px; margin: 0 0 14px; color: var(--ink); font-weight: 600; }
footer p, footer li { font-size: 14px; color: var(--ink-3); }
footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.disclaimer {
  margin-top: 44px;
  padding: 18px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-3);
}

/* ============ Aviso de metodología flotante ============ */
.methodology-note {
  font-size: 13px;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding-top: 18px;
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  section.chapter { padding: 72px 0 30px; }
  #scene3d { height: 440px; }
}
@media (max-width: 640px) {
  .kicker { font-size: 10.5px; letter-spacing: 0.12em; padding: 7px 12px; }
  body { font-size: 16px; }
  .chart-box { height: 340px; }
  .chart-box.tall { height: 400px; }
  .chart-box.short { height: 380px; }
  .nav-links a { padding: 8px 6px; font-size: 12px; }
  .hero { padding-top: 156px; }
}

/* ============ Accesibilidad / movimiento reducido ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  html.js .reveal { opacity: 1; transform: none; }
  .contagion-map .flow { animation: none; stroke-dasharray: none; }
  .ticker-track { animation: none !important; }
  .brand .dot { animation: none; }
  .scroll-hint .mouse::after { animation: none; }
  .term .term-row .v.alarm { animation: none; }
  .act-check .act-opt,
  .act-check-grade {
    transition: none !important;
    filter: none;
  }
}

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

/* ============ Correcciones ronda de auditoría ============ */

/* Medida tipográfica en párrafos de capítulo */
section.chapter .container > p:not(.ch-lede),
.callout p { max-width: 78ch; }
.ch-lede { max-width: 70ch; }

/* Enlaces de referencia */
sup.src-ref a.src-link { color: var(--gold); text-decoration: none; border-bottom: 1px dotted rgba(232,184,75,0.5); }
sup.src-ref a.src-link:hover { color: #fff; border-bottom-style: solid; }
sup.src-ref a.src-link:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; border-radius: 2px; }

/* Mapa de contagio legible en móvil */
.contagion-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}
@media (min-width: 1024px) {
  .contagion-scroll { -webkit-mask-image: none; mask-image: none; }
}
.contagion-scroll .contagion-map { min-width: 760px; }

/* Botones de zoom de la escena 3D */
.scene-controls .chip.zoom { min-width: 44px; text-align: center; }

/* KPIs en móvil */
@media (max-width: 760px) {
  .hero-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .hero-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* Impresión */
@media print {
  body { background: #fff; color: #111; font-size: 12pt; }
  .topnav, #progress-bar, .scroll-hint, #hero-canvas, .scene-wrap,
  .scene-controls, .scene-hud, .btn, .skip, .contagion-scroll, .sim-panel,
  .quiz-box, .chart-box { display: none !important; }
  section.chapter { padding: 24px 0; break-inside: avoid-page; }
  .card, .chart-card, .callout, table.data { border: 1px solid #ccc; background: #fff; }
  p, .card p, .tl-item p, td, th, .tl-date, em, .chart-note, footer li, .src-meta,
  h1, h2, h3, summary, .co-title, .tl-title, .chart-title, .card-title,
  .stat-cell .n, .stat-cell .d, .kpi .v, .kpi .l, .ch-num, .kicker, .pos, .neg,
  .sim-label, .quiz-q, .quiz-meta, .methodology-note, .disclaimer,
  .card .tag, .chart-sub { color: #111 !important; }
  .semaforo { background: #fff !important; color: #111 !important; border: 2px solid #111 !important; }
  .tl-item::before { background: #fff !important; border-color: #111 !important; }
  .glossary-item { border-color: #ccc !important; }
  .timeline::before { opacity: 0.3; }
  .src-list li::before { color: #333 !important; }
  .hero h1 .accent { background: none; color: inherit; -webkit-text-fill-color: initial; }
  a { color: #0645ad; }
  sup.src-ref a.src-link { color: #0645ad !important; border-bottom-color: #0645ad !important; }
  .kpi, .stat-strip, .stat-cell, .src-list li { border-color: #ccc !important; background: #fff !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* ============ Correcciones ronda 3 ============ */

/* Skip-link accesible */
.skip {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 1100;
  background: var(--gold);
  color: #0b0e17;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  transition: top 0.2s;
}
.skip:focus { top: 12px; text-decoration: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Foco sin mutar el radio del elemento (regla única arriba) */


/* Área táctil de referencias y chips */
sup.src-ref a.src-link { padding: 1px 3px; margin: 0; line-height: 1.2; border-radius: 4px; display: inline-block; }
.chip { min-height: 40px; display: inline-flex; align-items: center; }

/* HUD y controles 3D sin solaparse en móvil */
@media (max-width: 640px) {
  .scene-tip { display: none; }
  .scene-scrub { bottom: 76px; }
  .scene-controls { flex-wrap: wrap; justify-content: flex-end; max-width: 70%; }
  .sim-panel { padding: 20px 16px; }
  .sim-controls { min-width: 0; }
}

/* Impresión: los canvas oscuros no imprimen bien; la nota los resume */


/* Títulos de hitos y gráficos en h3 (jerarquía) */
.tl-title { margin: 0 0 6px; font-size: 18.5px; color: var(--ink); font-weight: 700; font-family: var(--font-body); }
.chart-card .chart-title { margin: 0; font-size: 17px; color: var(--ink); font-weight: 700; }

/* ============ Fase 2: ticker Bloomberg, presentación, terminal ============ */

/* Ticker cinta */
.ticker {
  position: fixed;
  top: 64px; left: 0; right: 0;
  z-index: 985;
  background: rgba(7, 9, 15, 0.92);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  height: 30px;
  display: flex;
  align-items: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  animation: ticker-scroll 46s linear infinite;
  width: max-content;
  will-change: transform;
}
.ticker-track .tk { margin-right: 34px; }
.ticker-track:hover { animation-play-state: paused; }
.ticker-track .tk { color: var(--ink-2); }
.ticker-track .tk b { color: var(--gold); font-weight: 700; }
.ticker-track .tk .up { color: var(--green); }
.ticker-track .tk .dn { color: var(--red); }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
html { scroll-padding-top: 150px; }
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

/* Barra de presentación */
.presenter-bar {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(11, 14, 23, 0.95);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  max-width: min(92vw, 640px);
}
.presenter-bar[hidden] { display: none; }
.pres-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
}
.pres-count { font-family: var(--font-mono); font-size: 11px; color: var(--gold); letter-spacing: 0.1em; }
.pres-title { font-size: 12.5px; color: var(--ink-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.presenting .reveal { transition-duration: 0.28s !important; }
@media (prefers-reduced-motion: reduce) {
  body.presenting .reveal { transition-duration: 0.001s !important; }
}

/* Terminal Bloomberg para el simulador */
.term {
  background: #05070d;
  border: 1px solid rgba(232, 184, 75, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #d9cba3;
  position: relative;
  overflow: hidden;
}
.term::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.term .term-head { color: var(--gold); letter-spacing: 0.14em; font-size: 11px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.term .term-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.term .term-row .k { color: #8a94a8; }
.term .term-row .v { color: #ffd98a; font-weight: 700; }
.term .term-row .v.alarm { color: #ff5d6c; animation: term-blink 1s steps(2) infinite; }
.term .term-row .v.ok { color: #3ddc97; }
@keyframes term-blink { 50% { opacity: 0.35; } }
.term canvas { width: 100%; height: 110px; display: block; margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .term .term-row .v.alarm { animation: none; } }

/* Scrubber del 3D */
.scene-scrub {
  position: absolute;
  left: 16px; right: 16px; bottom: 60px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.scene-scrub input[type="range"] { flex: 1; margin: 0; }


/* Títulos de tarjeta en h3 (jerarquía sin saltos) */
.card h3.card-title, .sim-panel h3.card-title { margin: 0 0 10px; font-size: 18px; font-weight: 700; color: var(--ink); font-family: var(--font-body); }

/* ============================================================
   B2 — Terminal Bloomberg: tooltips, HUD, scrollbars, 2D
   ============================================================ */

/* Scrollbars finas oscuras (Firefox + Chromium) */
* { scrollbar-width: thin; scrollbar-color: rgba(232, 184, 75, 0.35) rgba(7, 9, 15, 0.85); }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(7, 9, 15, 0.85); }
*::-webkit-scrollbar-thumb {
  background: rgba(232, 184, 75, 0.32);
  border-radius: 999px;
  border: 2px solid rgba(7, 9, 15, 0.85);
}
*::-webkit-scrollbar-thumb:hover { background: rgba(232, 184, 75, 0.55); }
.table-wrap, .contagion-scroll, .nav-links {
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 184, 75, 0.28) transparent;
}

/* Tooltip ECharts / caja monoespaciada */
.bbg-tip {
  font-family: var(--font-mono);
  min-width: 196px;
  max-width: 320px;
  padding: 10px 12px 11px;
  background: #05070d;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.bbg-tip-k {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.bbg-tip-date {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.bbg-tip-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.2;
}
.bbg-tip-unit {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.bbg-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  padding: 1px 0;
  color: var(--ink-3);
}
.bbg-tip-row .up { color: var(--green); font-weight: 700; }
.bbg-tip-row .dn { color: var(--red); font-weight: 700; }
.bbg-tip-row .flat { color: var(--ink-2); }
.bbg-tip-meta {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  color: var(--gold-soft);
  line-height: 1.45;
  white-space: normal;
}

/* CSV por gráfico */
.chart-head { align-items: center; }
.chart-csv {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.08em;
  min-height: 32px;
  padding: 4px 12px;
}
.chart-csv:hover,
.chart-csv:focus-visible {
  background: rgba(232, 184, 75, 0.14);
  color: var(--gold);
  border-color: var(--gold);
}

/* HUD 3D tipo terminal */
.scene-hud {
  gap: 6px;
}
.hud-pill {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  border-radius: 8px;
  padding: 7px 12px;
}
.hud-clock-pill { color: var(--gold); }
#scrub-label {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  min-width: 11.5rem;
  text-align: right;
  white-space: nowrap;
}
.scene-fallback-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
  background: rgba(255, 180, 84, 0.08);
  border-bottom: 1px solid rgba(255, 180, 84, 0.28);
  padding: 10px 16px;
}
.cascade-2d {
  height: 420px;
  background: radial-gradient(700px 400px at 50% 0%, rgba(90, 167, 255, 0.08), var(--bg-2));
}
.cascade-bars-css { padding: 28px 22px; display: grid; gap: 14px; }
.cascade-bars-css .cb-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}
.cascade-bars-css i {
  display: block;
  height: 14px;
  border-radius: 3px;
}

/* Live region del mapa de contagio */
.contagion-live {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  background: rgba(5, 7, 13, 0.72);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0 4px;
  min-height: 2.8em;
}

/* Inputs de calidad */
input[type="range"] {
  transition: box-shadow var(--ease-fast), filter var(--ease-fast);
}
input[type="range"]:hover { filter: brightness(1.08); }
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
.glossary-item:focus-within { border-color: var(--gold); }
.glossary-item summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.nav-links a {
  transition: background var(--ease-fast), color var(--ease-fast), transform var(--ease-fast);
}
.nav-links a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* Tablas de datos sr-only no deben romper el layout */
.chart-data-table.sr-only { position: absolute; }

@media (max-width: 640px) {
  #scrub-label { min-width: 0; font-size: 10px; }
  .cascade-2d { height: 340px; }
}

@media print {
  .chart-csv, .contagion-live, .scene-fallback-note, #chart-cascade-2d { display: none !important; }
}

/* ============================================================
   B-S1 — Sistema de iconos SVG propios (terminal premium)
   Sustituye emoji-as-icon en span.icon / cards / KPIs.
   ============================================================ */
.icon {
  color: inherit;
  line-height: 0;
}
.icon svg {
  width: 1.25em;
  height: 1.25em;
  display: block;
  flex-shrink: 0;
  overflow: visible;
}
.card .icon svg {
  width: 1.25em;
  height: 1.25em;
}
.icon-gold,
.icon.icon-gold {
  color: var(--gold);
}
.icon-gold svg,
.icon.icon-gold svg {
  color: var(--gold);
}

/* ============================================================
   F1 — A-V1 defectos visuales (P1-01..03, P2 CSS)
   ============================================================ */

/* P1-01: gana al <style id="b-s2-act-nav"> (html {142px} en el body). */
html:root { scroll-padding-top: 150px; }

/* P1-03: H1 + ≥2 KPIs en el primer viewport 390×844 / 768×1024. */
@media (max-width: 900px), (max-height: 900px) {
  .hero {
    min-height: 0;
    justify-content: flex-start;
    padding: 156px 0 36px;
  }
  .hero h1 {
    font-size: clamp(28px, 7vw, 48px);
    margin: 0 0 12px;
    line-height: 1.08;
  }
  .hero .lede {
    font-size: 16px;
    line-height: 1.45;
    margin: 0 0 14px;
  }
  .kicker { margin-bottom: 12px; }
  .hero-kpis { margin-bottom: 14px; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .v { font-size: clamp(18px, 4.4vw, 26px); }
  .hero-cta { gap: 8px; }
  .hero-cta .btn { padding: 10px 16px; font-size: 14px; }
  .scroll-hint { display: none; }
}
@media (max-height: 844px) {
  .hero {
    min-height: 0;
    justify-content: flex-start;
    padding-top: 156px;
    padding-bottom: 24px;
  }
  .hero .lede {
        -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    max-height: 6.2em;
  }
}
@media (max-width: 640px) {
  .hero { padding-top: 156px; padding-bottom: 28px; }
  .hero h1 { font-size: clamp(26px, 8.2vw, 36px); }
}

/* P2-01: charts/cards por encima del chip de acto. */
.chart-card,
.chart-box,
.sim-panel,
.scene-wrap,
.card {
  position: relative;
  z-index: 5;
}

/* P2-02: refs adyacentes [52][53] sin solape. */
sup.src-ref a.src-link {
  padding: 1px 3px;
  margin: 0;
  line-height: 1.25;
  display: inline-block;
  vertical-align: super;
}

/* P2-03: hover/focus-visible con delta cian (refuerzo). */
#nav-links a:hover,
#nav-links a:focus-visible {
  background: rgba(62, 224, 212, 0.12);
  color: var(--ink);
  transform: translateY(-1px);
  text-decoration: none;
}

/* P2-05: primer ítem del glosario no nace fantasma. */
html.js #glossary .glossary-item:first-child,
#glossary .glossary-item:first-child {
  opacity: 1;
  transform: none;
}

/* P2-06: 5 act-chips con label visible <1024. */
#act-nav .act-chip {
  white-space: nowrap;
  overflow: visible;
  flex: 0 0 auto;
  max-width: none;
}
@media (max-width: 1023px) {
  #act-nav .act-chip {
    font-size: 10.5px;
    padding: 5px 8px;
    min-height: 32px;
    letter-spacing: 0;
    white-space: nowrap;
  }
}

/* P2-08: range 3D y Reiniciar no se pisan en 390. */
@media (max-width: 479px) {
  .scene-scrub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    left: 12px;
    right: 12px;
    bottom: 112px;
    max-width: calc(100% - 24px);
  }
  .scene-scrub input#scrub-seq {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }
  .scene-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    justify-content: flex-start;
  }
}



/* Masthead editorial */
.masthead-line {
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold, #e8b84b);
  margin: 0 0 4px 0;
  opacity: 0.9;
}
@media (max-width: 480px) {
  .masthead-line { font-size: 9px; letter-spacing: 0.24em; }
  .byline { font-size: 12px; line-height: 1.35; max-width: 34ch; color: var(--ink-3); }
}

/* Hero 390: masthead + H1 + byline + 6/6 KPIs en primer viewport */
@media (max-width: 480px) {
  .hero .masthead { gap: 1px 8px; margin: 0 0 3px; }
  .hero .masthead__wordmark { font-size: 8.5px; letter-spacing: 0.16em; padding-bottom: 1px; margin-bottom: 1px; }
  .hero   .hero h1 { font-size: 27px; line-height: 1.12; margin-bottom: 6px; }
  .hero .lede { font-size: 13px; line-height: 1.4; max-height: 3.9em; margin-bottom: 8px; }
  .hero-kpis { gap: 6px; margin-bottom: 6px; }
  .kpi { padding: 8px; }
  .kpi .l { line-height: 1.2; }
  .byline { margin-top: -4px; font-size: 11.5px; }
}

/* Hero 390 ajuste fino: fila 3 KPI dentro de 844px */
@media (max-width: 480px) {
  .hero { padding-top: 138px !important; }
  .hero .kicker { font-size: 10px; padding: 4px 9px; margin-bottom: 6px; }
  .hero h1 { font-size: 25px; line-height: 1.08; margin-bottom: 5px; }
  .hero .lede { font-size: 12.5px; line-height: 1.35; max-height: 3.7em; margin-bottom: 6px; }
  .hero-kpis { gap: 5px; }
  .kpi { padding: 7px 8px; }
  .kpi .v { font-size: 15px; }
  .kpi .l { font-size: 9.5px; line-height: 1.18; }
}

/* Hero 390 compresión final: 2 filas de KPI visibles + fila 3 indicada */
@media (max-width: 480px) {
  .hero .kicker { font-size: 9.5px; padding: 3px 8px; margin-bottom: 4px; letter-spacing: 0.02em; }
  .hero h1 { font-size: 23px; line-height: 1.06; margin-bottom: 4px; }
  .hero .masthead { margin: 0 0 2px; }
  .hero .masthead__wordmark { font-size: 8px; margin-bottom: 0; padding-bottom: 1px; }
  .hero   .hero .byline { font-size: 11px; margin-top: -3px; margin-bottom: 4px; }
  .hero .lede { font-size: 12px; line-height: 1.3; max-height: 3.5em; margin-bottom: 5px; }
  .hero-kpis { gap: 4px; }
  .kpi { padding: 6px 7px; }
  .kpi .v { font-size: 14px; }
  .kpi .l { font-size: 9px; line-height: 1.15; }
}

/* Hero 390: cards KPI compactas (etiqueta clamp 3 líneas) */
@media (max-width: 480px) {
  .hero .kpi .l {
        -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .hero .kpi .v { font-size: 13.5px; }
}

/* Tablet 768: 6/6 KPIs en primer viewport tras quitar duplicado */
@media (min-width: 481px) and (max-width: 900px) {
  .hero .masthead { margin: 0 0 3px; }
  .hero h1 { font-size: 30px; line-height: 1.1; }
  .hero .lede { font-size: 13.5px; max-height: 4em; }
  .hero-kpis { gap: 7px; }
  .kpi { padding: 8px; }
  .kpi .v { font-size: 16px; }
  .kpi .l { font-size: 10px; line-height: 1.2; }
}

/* Desktop: 2 filas de 3 KPIs dentro del primer viewport (1440x900) */
@media (min-width: 1024px) {
  .hero .kicker { margin-bottom: 8px; }
  .hero h1 { font-size: 44px; line-height: 1.08; }
  .hero .lede { font-size: 15px; max-height: 4.4em; }
  .hero-kpis { gap: 8px; }
  .kpi { padding: 9px 10px; }
  .kpi .l { line-height: 1.22; }
}

/* Lede corto: sin clamp ahora que el dek cabe */
.hero .lede { max-height: none; -webkit-line-clamp: unset; overflow: visible; }
@media (max-width: 480px) {
  .hero .lede { font-size: 13px; line-height: 1.42; }
}

/* 390: fila 3 KPI 1px dentro tras quitar clamp del lede (ahora lede completo ~86px) */
@media (max-width: 480px) {
  .hero .lede { font-size: 12.5px; line-height: 1.35; }
  .hero-kpis { gap: 4px; }
  .kpi { padding: 6px; }
  .kpi .l { font-size: 8.5px; line-height: 1.12; }
}

/* Sistema visual UCI: badge constante de constantes vitales */
.icu-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #e8c063; background: rgba(232,192,99,0.07);
  border: 1px solid rgba(232,192,99,0.28); border-radius: 3px;
  padding: 3px 8px; margin: 0 0 10px;
}
.icu-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #e8c063; animation: icu-pulse 2.2s infinite; }
@keyframes icu-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Enlace interno en micro-checks */
.why-link { color: #00e5ff; text-decoration: underline; text-decoration-color: rgba(0,229,255,0.45); text-underline-offset: 2px; }
.why-link:hover { text-decoration-color: #00e5ff; }
/* Aire fila 3 KPI 390 */
@media (max-width: 480px) {
  .hero-kpis { gap: 6px; margin-top: 10px; }
}
