* {
    box-sizing: border-box;
}

body {
    /* Correcciones locales de los tokens actuales */
    --font-display: "Space Grotesk", sans-serif;
    --text-xl: var(--texr-xl);
    --text-3xl: clamp(2rem, 1.4rem + 2vw, 3rem);

    margin: 0;
    padding: clamp(1rem, 4vw, 3rem);

    background: var(--color-bg);
    color: var(--color-text);

    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-body);
    letter-spacing: var(--letter-spacing-normal);

    text-align: left;
}

/* Ancho del laboratorio */

body > header,
body > main,
body > footer {
    width: 100%;
    max-width: 64rem;
    margin-inline: auto;
}

/* Encabezado del laboratorio */

body > header {
    margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

body > header > h1 {
    margin: 0 0 1rem;
    font-size: var(--text-2xl);
}

/* Navegación */

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;

    margin: 0;
    padding: 0;
    list-style: none;
}

nav a {
    color: var(--color-accent);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
}

nav a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
}

/* Secciones y subsecciones */

main > section + section {
    margin-top: clamp(3rem, 6vw, 4.5rem);
}

main section > h2 {
    margin-bottom: 1.5rem;
}

main section > section {
    margin-top: 2rem;
}

main section > section + section {
    margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

main section > section > h3 {
    margin-bottom: 1.5rem;
}

/* Muestras de color */

.color-test {
    width: 100%;
    max-width: 20rem;
    padding: 1.5rem;
    margin: 0 0 1rem;

    border: 1px solid var(--color-border);
    border-radius: 0.5rem;

    overflow-wrap: anywhere;
}

.color-test:last-child {
    margin-bottom: 0;
}

.color-bg {
    background: var(--brand-charcoal);
}

.color-surface {
    background: var(--brand-slate);
}

.color-accent {
    background: var(--brand-blue);
    color: var(--brand-charcoal);
}

.color-white {
    background: var(--brand-white);
    color: var(--brand-charcoal);
}

/* Encabezados semánticos del documento */

h1,
h2,
h3 {
    margin: 0;

    font-family: var(--font-display);
    line-height: var(--line-heading);
    letter-spacing: var(--letter-spacing-normal);

    overflow-wrap: anywhere;
}

h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-weight-bold);
}

h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-semibold);
}

h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-semibold);
}

/* Texto base y descripciones técnicas */

p {
    margin: 0 0 0.5rem;

    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-body);
    letter-spacing: var(--letter-spacing-normal);

    overflow-wrap: anywhere;
}

small {
    color: var(--color-text-muted);

    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-body);
}

/* Separación entre muestras del laboratorio */

#tipografia .type-label,
#tipografia .type-body-small,
#tipografia .type-body,
#tipografia .type-body-large,
#tipografia .type-h3,
#tipografia .type-h2,
#tipografia .type-h1,
#tipografia .type-display {
    margin: 0 0 2rem;
}

#tipografia section > p:last-child {
    margin-bottom: 0;
}

/* Muestras de texto */

.type-label {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-body);
    letter-spacing: var(--letter-spacing-label);
    text-transform: uppercase;
}

.type-body-small {
    max-width: 65ch;
    font-size: var(--text-sm);
}

.type-body {
    max-width: 65ch;
    font-size: var(--text-base);
}

.type-body-large {
    max-width: 60ch;
    font-size: var(--text-lg);
}

/* Muestras visuales de títulos */

.type-h3,
.type-h2,
.type-h1,
.type-display {
    font-family: var(--font-display);
    line-height: var(--line-heading);
    letter-spacing: var(--letter-spacing-normal);

    overflow-wrap: anywhere;
    word-break: normal;
}

.type-h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-semibold);
}

.type-h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-semibold);
}

.type-h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-weight-bold);
}

.type-display {
    max-width: 100%;

    font-size: var(--text-display);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-tight);
}

/* Pie del laboratorio */

body > footer {
    margin-top: clamp(3rem, 6vw, 4.5rem);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

body > footer p {
    margin: 0;
    color: inherit;
    font-size: inherit;
}

/* Visualización del sistema de espaciado */

#espaciado > p {
    max-width: 65ch;
    margin-bottom: var(--space-6);
}

.spacing-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);

    margin: 0;
    padding: 0;
    list-style: none;
}

.spacing-item {
    min-width: 0;
}

.spacing-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2) var(--space-4);

    margin: 0 0 var(--space-2);
}

.spacing-info code {
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

.spacing-visual {
    display: block;
    max-width: 100%;
    height: var(--space-3);

    background: var(--color-accent);
}

.spacing-visual--1 {
    width: var(--space-1);
}

.spacing-visual--2 {
    width: var(--space-2);
}

.spacing-visual--3 {
    width: var(--space-3);
}

.spacing-visual--4 {
    width: var(--space-4);
}

.spacing-visual--5 {
    width: var(--space-5);
}

.spacing-visual--6 {
    width: var(--space-6);
}

.spacing-visual--7 {
    width: var(--space-7);
}

.spacing-visual--8 {
    width: var(--space-8);
}

.spacing-visual--9 {
    width: var(--space-9);
}

.spacing-visual--10 {
    width: var(--space-10);
}

/* Bases reutilizables de layout */

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

.layout-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--grid-gap);
}

.layout-grid > * {
    min-width: 0;
}

/* Demostración del contenedor y del grid */

#grid > p {
    max-width: 65ch;
    margin-bottom: var(--space-6);
}

.container-demo {
    padding-block: var(--space-5);
    border: 1px dashed var(--color-border);
}

.container-demo > p {
    margin: 0;
    font-size: var(--text-sm);
}

.container-demo > p + p {
    margin-top: var(--space-2);
}

.grid-demo {
    margin-top: var(--space-5);
}

.grid-column {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: var(--space-8);
    padding-block: var(--space-3);

    border: 1px solid var(--color-border);
    background: var(--color-accent-soft);
    color: var(--color-text);

    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    overflow-wrap: anywhere;
}

/* Tablet: hasta 64rem, aproximadamente 1024px */

@media (max-width: 64rem) {
    .layout-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

/* Mobile: hasta 48rem, aproximadamente 768px */

@media (max-width: 48rem) {
    .layout-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}