/* =========================================================
   MathPro · hoja de estilos
   1. Tokens (colores, tipografía, espacios) y temas
   2. Base y accesibilidad
   3. Componentes comunes: botones, insignias, campos, paneles
   4. Cabecera, menú móvil y pie
   5. Portada: hero y gráfica, etapas, herramientas, ejercicios, ventajas, llamada final
   6. Páginas interiores y estados vacíos
   7. Animaciones y movimiento reducido
   Las reglas responsive van junto a cada componente para poder
   modificar una pieza sin buscar en otro archivo.
   ========================================================= */

/* ---------- 1. Tokens ---------- */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter Display", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", Consolas, "Roboto Mono", monospace;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --container: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .2s;

  /* Tema oscuro (por defecto) */
  color-scheme: dark;
  --bg: #070B14;
  --bg-2: #0A1020;
  --surface: #0D1424;
  --surface-2: #141D31;
  --line: rgba(148, 170, 210, .12);
  --line-2: rgba(148, 170, 210, .24);
  --text: #EEF3FB;
  --text-2: #A7B3C7;
  --text-3: #8290A6;
  --accent: #5B9BFF;
  --accent-strong: #2468EE;
  --accent-hover: #3576F5;
  --accent-soft: rgba(59, 130, 246, .14);
  --on-accent: #FFFFFF;
  --success: #3DD598;
  --success-soft: rgba(61, 213, 152, .12);
  --danger: #FF7D7D;
  --danger-soft: rgba(255, 125, 125, .12);
  --warn: #F5C26B;
  --warn-soft: rgba(245, 194, 107, .12);
  --grid: rgba(120, 150, 210, .075);
  --header-bg: rgba(7, 11, 20, .74);
  --glow: 0 0 0 1px rgba(91, 155, 255, .4), 0 0 40px -8px rgba(59, 130, 246, .55);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
}

/* Tema claro: si el sistema lo pide (sin JavaScript) o si el usuario lo elige */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #F6F8FC;
    --bg-2: #EDF1F8;
    --surface: #FFFFFF;
    --surface-2: #F0F3F9;
    --line: rgba(15, 23, 42, .09);
    --line-2: rgba(15, 23, 42, .17);
    --text: #0B1220;
    --text-2: #45526A;
    --text-3: #5D697E;
    --accent: #1A5FD6;
    --accent-strong: #1F63E0;
    --accent-hover: #1A54C0;
    --accent-soft: rgba(31, 99, 224, .09);
    --success: #0E7A4F;
    --success-soft: rgba(14, 122, 79, .09);
    --danger: #C02B2B;
    --danger-soft: rgba(192, 43, 43, .08);
    --warn: #8A5A00;
    --warn-soft: rgba(176, 116, 0, .1);
    --grid: rgba(15, 23, 42, .06);
    --header-bg: rgba(246, 248, 252, .82);
    --glow: 0 0 0 1px rgba(31, 99, 224, .35), 0 18px 40px -18px rgba(31, 99, 224, .35);
    --shadow: 0 24px 50px -30px rgba(15, 23, 42, .35);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F8FC;
  --bg-2: #EDF1F8;
  --surface: #FFFFFF;
  --surface-2: #F0F3F9;
  --line: rgba(15, 23, 42, .09);
  --line-2: rgba(15, 23, 42, .17);
  --text: #0B1220;
  --text-2: #45526A;
  --text-3: #5D697E;
  --accent: #1A5FD6;
  --accent-strong: #1F63E0;
  --accent-hover: #1A54C0;
  --accent-soft: rgba(31, 99, 224, .09);
  --success: #0E7A4F;
  --success-soft: rgba(14, 122, 79, .09);
  --danger: #C02B2B;
  --danger-soft: rgba(192, 43, 43, .08);
  --warn: #8A5A00;
  --warn-soft: rgba(176, 116, 0, .1);
  --grid: rgba(15, 23, 42, .06);
  --header-bg: rgba(246, 248, 252, .82);
  --glow: 0 0 0 1px rgba(31, 99, 224, .35), 0 18px 40px -18px rgba(31, 99, 224, .35);
  --shadow: 0 24px 50px -30px rgba(15, 23, 42, .35);
}

/* ---------- 2. Base y accesibilidad ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.menu-open { overflow: hidden; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.12;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

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

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 300;
  padding: 10px 16px;
  border-radius: var(--radius-s);
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.icon { width: 20px; height: 20px; flex: none; }

.math {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 .12em;
  font-size: .82em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.frac__n { padding: 0 .22em .08em; border-bottom: 1.5px solid currentColor; }
.frac__d { padding: .08em .22em 0; }

.noscript {
  padding: 120px 24px 40px;
  text-align: center;
  color: var(--text-2);
}

/* ---------- 3. Componentes comunes ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform .15s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn .icon { width: 18px; height: 18px; transition: transform .25s var(--ease); }
.btn:hover .icon--arrow { transform: translateX(3px); }

.btn--primary { background: var(--accent-strong); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); box-shadow: 0 8px 24px -10px var(--accent-strong); }

.btn--ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn--ghost:hover { border-color: var(--line-2); background: var(--surface); }

.btn--text { background: none; color: var(--text-2); padding-inline: 12px; }
.btn--text:hover { color: var(--text); }

.btn--lg { min-height: 52px; padding: 0 28px; font-size: 1rem; min-width: 220px; }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: .875rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--ok { background: var(--success-soft); color: var(--success); }
.badge--muted { background: var(--surface-2); color: var(--text-3); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  padding: clamp(20px, 3vw, 32px);
}

.field { display: grid; grid-template-rows: subgrid; grid-row: span 3; gap: 6px; align-content: start; }
.field label { font-size: .875rem; font-weight: 600; line-height: 1.35; align-self: end; }
.field__help { font-size: .8125rem; color: var(--text-3); }
.field__error {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--danger);
}
.field__error[hidden] { display: none; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  background: var(--bg);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--text-3); opacity: .8; }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.feedback {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.45;
}
.feedback .icon { width: 18px; height: 18px; margin-top: 1px; }
.feedback--ok { background: var(--success-soft); color: var(--success); }
.feedback--bad, .feedback--error { background: var(--danger-soft); color: var(--danger); }
.feedback--warn { background: var(--warn-soft); color: var(--warn); }

.steps {
  counter-reset: step;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  font-size: .9375rem;
  line-height: 1.5;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.steps li::before {
  content: counter(step);
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow__num { color: var(--accent); font-family: var(--mono); letter-spacing: .04em; }

.icon-tile {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}
.icon-tile .icon { width: 22px; height: 22px; }

/* ---------- 4. Cabecera, menú móvil y pie ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.site-header.is-scrolled,
body.menu-open .site-header {
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom-color: var(--line);
}

.header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1;
}
.logo__mark { width: 30px; height: 30px; color: var(--text); }
.logo__pro { color: var(--accent); }

.nav { margin-inline: auto; }
.nav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav a {
  position: relative;
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-size: .9375rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.header__tools { display: flex; align-items: center; gap: 8px; }

.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lang-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.flag { width: 18px; height: 12px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn--sm { width: 32px; height: 32px; }

.menu-toggle { display: none; }

@media (max-width: 1020px) {
  .nav { display: none; }
  .menu-toggle { display: inline-grid; }
  .header__tools { margin-left: auto; }
  .header__tools .lang-switch { display: none; }
}

.mobile-menu {
  position: fixed;
  inset: var(--header-h) 0 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 16px var(--gutter) 40px;
  overflow-y: auto;
  background: var(--bg);
  animation: menu-in .28s var(--ease);
}
.mobile-menu[hidden] { display: none; }
.mobile-menu ul { list-style: none; margin: 0; padding: 0; }
.mobile-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.mobile-menu a[aria-current="page"] { color: var(--accent); }
.mobile-menu a .icon { color: var(--text-3); }
.mobile-menu__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-3); font-size: .875rem; }

@keyframes menu-in { from { opacity: 0; transform: translateY(-8px); } }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 72px 0 32px;
  background: var(--bg);
  font-size: .9375rem;
}
.footer__grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 40px;
}
.footer__brand p { margin-top: 14px; max-width: 22rem; color: var(--text-2); }
.footer__tagline { color: var(--accent) !important; font-weight: 500; }
.footer__col h2 {
  margin-bottom: 16px;
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.footer__col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.footer__col a { color: var(--text-2); transition: color var(--dur) var(--ease); }
.footer__col a:hover { color: var(--text); }
.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--text-3);
}
.footer__bottom p:last-child { max-width: 36rem; }

@media (max-width: 860px) { .footer__grid { grid-template-columns: 1fr 1fr; } .footer__brand { grid-column: 1 / -1; } }
@media (max-width: 460px) { .footer__grid { grid-template-columns: 1fr; } }

.i18n-notice {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 120;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: .875rem;
  color: var(--text-2);
}
.i18n-notice p { flex: 1; }

/* ---------- 5. Portada ---------- */

.section { padding: clamp(80px, 10vw, 128px) 0; }
.section--alt { background: var(--bg-2); border-block: 1px solid var(--line); }

.section__head { max-width: 46rem; margin-bottom: clamp(36px, 5vw, 56px); }
.section__head h2 { margin-top: 14px; font-size: clamp(2rem, 4.2vw, 3.1rem); letter-spacing: -.035em; }
.section__lead { margin-top: 16px; font-size: 1.0625rem; color: var(--text-2); }

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: calc(var(--header-h) + clamp(56px, 10vh, 112px)) 0 clamp(64px, 8vw, 104px);
}
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(55% 45% at 50% 0%, rgba(59, 130, 246, .2), transparent 70%),
    radial-gradient(40% 35% at 85% 70%, rgba(59, 130, 246, .08), transparent 70%);
}
.hero__bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 25%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse 75% 60% at 50% 25%, #000 25%, transparent 75%);
}

.hero__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero__title {
  margin-top: 22px;
  font-size: clamp(2.6rem, 7.4vw, 5.9rem);
  font-weight: 650;
  letter-spacing: -.048em;
  line-height: .98;
}
.hero__title span { display: block; }
.hero__title-muted {
  background: linear-gradient(90deg, var(--accent), var(--text-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: .06em;
}
.hero__lead {
  max-width: 39rem;
  margin-top: 26px;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--text-2);
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 36px;
}
.hero__shortcuts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}
.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.shortcut .icon { width: 16px; height: 16px; color: var(--accent); }
.shortcut:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 520px) {
  .hero__actions { flex-direction: column; align-self: stretch; }
  .hero__actions .btn { width: 100%; min-width: 0; }
}

/* Gráfica interactiva */
.graph {
  max-width: 980px;
  margin: clamp(48px, 7vw, 80px) auto 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-l);
  background: linear-gradient(180deg, var(--surface), var(--bg));
  box-shadow: var(--glow), var(--shadow);
  overflow: hidden;
}
.graph__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--text-3);
}
.graph__fn { font-family: var(--mono); font-size: .875rem; color: var(--text); }
.graph__svg { width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.graph__svg .g-grid line { stroke: var(--grid); stroke-width: 1; }
.graph__svg .g-axis { stroke: var(--line-2); stroke-width: 1.25; }
.graph__svg .g-ticks text { fill: var(--text-3); font-size: 13px; font-family: var(--mono); }
.graph__svg .g-curve {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  animation: draw-curve 1.8s .3s var(--ease) both;
}
.graph__svg .g-tangent { stroke: var(--accent); stroke-width: 2.25; stroke-linecap: round; }
.graph__svg .g-guide { stroke: var(--accent); stroke-opacity: .45; stroke-width: 1; stroke-dasharray: 3 5; }
.graph__svg .g-halo { fill: var(--accent); opacity: .18; }
.graph__svg .g-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 3; }

@keyframes draw-curve { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.graph__foot {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items: center;
  gap: 14px 28px;
  padding: 16px 20px 18px;
  border-top: 1px solid var(--line);
}
.graph__slider { display: grid; gap: 6px; font-size: .8125rem; color: var(--text-3); }
.graph__slider input { width: 100%; accent-color: var(--accent-strong); cursor: pointer; }
.readout { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; font-family: var(--mono); font-size: .9375rem; }
.readout div { display: flex; gap: 8px; }
.readout dt { color: var(--text-3); }
.readout dd { margin: 0; min-width: 4.5ch; color: var(--text); font-variant-numeric: tabular-nums; }
.graph__note { grid-column: 1 / -1; font-size: .8125rem; color: var(--text-3); }

@media (max-width: 640px) {
  .graph__foot { grid-template-columns: 1fr; }
  .graph__svg .g-ticks { display: none; }
}

/* Etapas */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stage-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.stage-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 60% at 100% 0%, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity .3s var(--ease);
  pointer-events: none;
}
.stage-card:hover { border-color: var(--line-2); transform: translateY(-4px); box-shadow: var(--shadow); }
.stage-card:hover::after { opacity: 1; }
.stage-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-card__meta { font-size: .8125rem; font-weight: 500; color: var(--text-3); }
.stage-card__num {
  margin: 36px 0 auto;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 5.5vw, 4.6rem);
  font-weight: 300;
  letter-spacing: -.06em;
  line-height: 1;
  color: var(--text);
  transition: color .3s var(--ease);
}
.stage-card:hover .stage-card__num { color: var(--accent); }
.stage-card__title { margin-top: 28px; font-size: 1.375rem; }
.stage-card__desc { margin-top: 8px; font-size: .9375rem; color: var(--text-2); }
.stage-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--accent);
}
.stage-card__cta .icon { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.stage-card:hover .stage-card__cta .icon { transform: translateX(4px); }
.stage-card--accent { border-color: rgba(91, 155, 255, .35); box-shadow: var(--glow); }
.stage-card--accent .icon-tile { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); }

@media (max-width: 1080px) { .stage-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .stage-grid { grid-template-columns: 1fr; }
  .stage-card { min-height: 0; }
  .stage-card__num { margin: 24px 0 0; }
}

/* Herramientas */
.tools-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 920px) { .tools-layout { grid-template-columns: 1fr; } }

.calc { box-shadow: var(--glow); border-color: rgba(91, 155, 255, .35); }
.calc__head h3 { margin-top: 14px; font-size: 1.5rem; }
.calc__head p { margin-top: 8px; color: var(--text-2); }
.calc__form { margin-top: 24px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 16px;
  row-gap: 16px;
}
.calc__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.calc__result:not(:empty) { margin-top: 20px; }

.result {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.result--ok { border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.result--warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.result__headline { font-size: 1.0625rem; font-weight: 500; }
.result__headline strong { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result--ok .result__headline strong { color: var(--success); }
.result--warn .result__headline strong { color: var(--warn); }
.result__note { display: block; margin-top: 2px; font-size: .8125rem; color: var(--text-3); }
.result__formula {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  margin: 16px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: .875rem;
}
.result__formula span { font-weight: 600; color: var(--text-3); }
.result__formula code { font-family: var(--mono); color: var(--text); }

.tool-list__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.tool-list__head h3 { font-size: 1.125rem; }
.tool-list { list-style: none; margin: 0; padding: 0; }
.tool-list a {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-s);
  transition: background-color var(--dur) var(--ease);
}
.tool-list li:last-child a { border-bottom: 0; }
.tool-list a:hover { background: var(--surface-2); }
.tool-list .icon-tile { font-family: var(--mono); font-size: .9rem; font-weight: 600; color: var(--accent); }
.tool-list strong { display: block; font-size: .9375rem; font-weight: 600; }
.tool-list small { display: block; font-size: .8125rem; color: var(--text-3); }

/* Ejercicios */
.ex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1040px) { .ex-grid { grid-template-columns: 1fr; max-width: 640px; } }

.ex-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
}
.ex-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .8125rem; color: var(--text-3); }
.ex-card__level { font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.ex-card__topic { font-size: 1.125rem; }
.ex-card__statement {
  min-height: 3.2em;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
.ex-card__form label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 600; }
.answer-row { display: flex; gap: 8px; }
.answer-row .input { flex: 1; min-width: 0; }
.answer-row .btn { flex: none; }
.ex-card { container-type: inline-size; }
@container (max-width: 400px) {
  .answer-row { flex-direction: column; }
}
.solution__answer:focus { outline: none; }
.ex-card__live:empty { display: none; }
.solution { padding-top: 16px; border-top: 1px solid var(--line); }
.solution[hidden] { display: none; }
.solution__answer { font-weight: 600; font-variant-numeric: tabular-nums; }
.solution__title { margin: 14px 0 10px; font-family: var(--font); font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.ex-card__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.ex-card__actions [hidden] { display: none; }


.diff { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.diff__bars { display: inline-flex; gap: 3px; }
.diff__bars i { width: 6px; height: 12px; border-radius: 2px; background: var(--line-2); }
.diff[data-level="1"] .diff__bars i:nth-child(-n+1),
.diff[data-level="2"] .diff__bars i:nth-child(-n+2),
.diff[data-level="3"] .diff__bars i:nth-child(-n+3) { background: var(--accent); }

/* Ventajas */
.why-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.why-item {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
}
.why-item .icon-tile { color: var(--accent); }
.why-item h3 { margin-top: 20px; font-size: 1.125rem; }
.why-item p { margin-top: 8px; font-size: .9375rem; color: var(--text-2); }
@media (max-width: 1000px) { .why-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .why-grid { grid-template-columns: 1fr; } }

/* Llamada final */
.cta-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(88px, 12vw, 152px) 0;
  text-align: center;
  border-top: 1px solid var(--line);
}
.cta-band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(50% 70% at 50% 100%, rgba(59, 130, 246, .2), transparent 70%);
}
.cta-band h2 { font-size: clamp(2.2rem, 5.5vw, 4.2rem); letter-spacing: -.045em; }
.cta-band p { max-width: 34rem; margin: 18px auto 0; color: var(--text-2); font-size: 1.0625rem; }
.cta-band .hero__actions { margin-top: 32px; }

/* ---------- 6. Páginas interiores ---------- */

.page-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: calc(var(--header-h) + clamp(48px, 8vw, 88px)) 0 clamp(48px, 6vw, 72px);
  border-bottom: 1px solid var(--line);
}
.page-hero .hero__bg::before { -webkit-mask-image: radial-gradient(ellipse 70% 80% at 20% 0%, #000 20%, transparent 70%); mask-image: radial-gradient(ellipse 70% 80% at 20% 0%, #000 20%, transparent 70%); }
.page-hero__title { display: flex; align-items: center; gap: 18px; }
.page-hero__title .icon-tile { width: 56px; height: 56px; border-radius: 16px; color: var(--accent); }
.page-hero__title .icon-tile .icon { width: 28px; height: 28px; }
.page-hero h1 { font-size: clamp(2.2rem, 5.5vw, 4.2rem); letter-spacing: -.045em; }
.page-hero__lead { max-width: 44rem; margin-top: 20px; font-size: 1.125rem; color: var(--text-2); }

.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0 0 28px; padding: 0; font-size: .875rem; color: var(--text-3); }
.breadcrumb li + li::before { content: "/"; margin-right: 8px; opacity: .6; }
.breadcrumb a:hover { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 32px 0 0; padding: 0; list-style: none; }
.chip {
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
}

.empty-state {
  max-width: 42rem;
  margin-inline: auto;
  padding: clamp(36px, 6vw, 56px) clamp(20px, 4vw, 40px);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-l);
  text-align: center;
}
.empty-state .icon-tile { width: 56px; height: 56px; margin: 0 auto 20px; border-radius: 16px; color: var(--accent); }
.empty-state h2 { margin-top: 16px; font-size: clamp(1.5rem, 3vw, 2rem); }
.empty-state p { margin-top: 12px; color: var(--text-2); }
.empty-state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 28px; }

.subsection { margin-top: clamp(48px, 7vw, 80px); }
.subsection .section__head { margin-bottom: 0; }

.section--tight { padding-top: clamp(40px, 6vw, 64px); }

/* Temario: pestañas de cursos y temas */
.course-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.course-tab {
  min-width: 56px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.course-tab:hover { color: var(--text); border-color: var(--accent); }
.course-tab[aria-selected="true"] {
  background: var(--accent-strong);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: 0 10px 24px -12px var(--accent-strong);
}
.course-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; margin-bottom: 20px; }
.course-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.03em; }
.course-meta { font-size: .9375rem; color: var(--text-3); }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.topic-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
a.topic-card:hover { border-color: rgba(91, 155, 255, .45); transform: translateY(-3px); box-shadow: var(--glow); }
.topic-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topic-card .icon-tile { color: var(--accent); }
.topic-card h3 { font-size: 1.125rem; }
.topic-card p { font-size: .9375rem; color: var(--text-2); }
.topic-card .stage-card__cta { margin-top: auto; }
.topic-card--soon { background: transparent; border-style: dashed; }
.topic-card--soon h3 { color: var(--text-2); font-weight: 500; }
.topic-card--soon .icon-tile { color: var(--text-3); background: transparent; }

.note {
  display: flex;
  gap: 14px;
  margin: 40px 0 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  font-size: .9rem;
  color: var(--text-2);
}
.note > span:first-child { flex: none; color: var(--accent); margin-top: 1px; }
.note strong { display: block; margin-bottom: 4px; color: var(--text); }
#pau-list > .note { margin: 0 0 20px; }

/* Página de tema */
.topic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.topic-main { display: grid; gap: 24px; }
.topic-side { position: sticky; top: calc(var(--header-h) + 20px); display: grid; gap: 14px; }
.topic-side__head h2 { font-size: 1.5rem; }
.topic-side__head p { margin-top: 4px; font-size: .9375rem; color: var(--text-2); }
.topic-side .ex-card__topic { display: none; }
@media (max-width: 960px) {
  .topic-layout { grid-template-columns: 1fr; }
  .topic-side { position: static; }
}

.prose h2 { margin-bottom: 14px; font-size: 1.5rem; }
.prose h3 { margin: 24px 0 12px; font-family: var(--font); font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.prose > p { font-size: 1.0625rem; color: var(--text-2); }
.prose .steps { margin-top: 18px; }
.points { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.points li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.points li::before { content: ""; width: 8px; height: 8px; margin-top: .6em; border-radius: 2px; background: var(--accent); }
.formula {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.formula span { display: block; margin-bottom: 6px; font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.formula code { font-family: var(--mono); font-size: 1.05rem; color: var(--text); }
.example__answer {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.topic-nav { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.topic-nav__link {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.topic-nav__link:hover { border-color: var(--accent); background: var(--surface); }
.topic-nav__link small { font-size: .8125rem; color: var(--text-3); }
.topic-nav__link strong { font-weight: 600; }
.topic-nav__all { text-align: center; }
.topic-nav__next { text-align: right; }

/* Notación matemática y respuestas con varias casillas */
.answer-fields { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.answer-row:has(.answer-fields) { align-items: flex-start; }
.ex-card__form .answer-field { display: flex; align-items: center; gap: 8px; flex: 1 1 110px; min-width: 0; margin: 0; }
.answer-field span { font-weight: 600; white-space: nowrap; }
.answer-field .input { min-width: 0; }
.ex-card__label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 600; }
.ex-card__form .field__help { margin-top: 8px; }
.math-block { display: block; margin-top: 6px; }
.math-block > span { display: block; }
.matrix {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 2px 14px;
  margin: 4px 0;
  padding: 4px 10px;
  border-inline: 2px solid currentColor;
  border-radius: 6px;
  vertical-align: middle;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.int, .lim-wrap { display: inline-flex; align-items: center; vertical-align: middle; }
.int__sign { font-size: 1.7em; font-weight: 300; line-height: 1; }
.int__lims { display: inline-flex; flex-direction: column; justify-content: space-between; align-self: stretch; margin: 0 .25em 0 .05em; font-size: .62em; line-height: 1.1; }
.lim { display: inline-flex; flex-direction: column; align-items: center; margin-right: .35em; line-height: 1.1; }
.lim small { font-size: .62em; }

/* Problemas tipo PAU */
.pau-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.pau-card h3 { margin-top: 12px; font-size: 1.2rem; }
.pau-card__statement { margin-top: 10px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pau-card details { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.pau-card summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.pau-card summary::-webkit-details-marker { display: none; }
.pau-card summary::before { content: "+"; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: .9rem; line-height: 1; }
.pau-card details[open] summary::before { content: "−"; }
.pau-card .steps { margin-top: 12px; }
.pau-answer { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--success-soft); color: var(--success); font-weight: 500; }

/* ---------- 7. Animaciones ---------- */

.js .hero__inner > *,
.js .hero .graph {
  animation: rise .9s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  transition-delay: calc(var(--d, 0) * 80ms);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* Transición suave al cambiar de tema (solo durante el cambio) */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease), fill .3s var(--ease), stroke .3s var(--ease) !important;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
