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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Evita scroll horizontal por desbordes puntuales (p.ej. un grid que no
     encoge del todo en movil). clip (no hidden) NO crea contenedor de scroll,
     asi que no rompe el position:sticky del indice lateral ni de las
     herramientas. El scroll vertical se conserva. */
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  overflow-x: clip;   /* mismo guard que en html, por si el scroller es el body */
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--color-accent-hover); }

button {
  font: inherit;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl);  }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: var(--space-6);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}

code:not(pre code) {
  background: var(--color-accent-light);
  color: var(--color-accent-700);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

::selection {
  background: var(--color-accent-200);
  color: var(--color-text);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

@media (max-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl);  }
}

@media (max-width: 480px) {
  h1 { font-size: var(--text-3xl); }
}
