:root {
    --sand: #f4efe7;
    --paper: #fffaf2;
    --ink: #1b2430;
    --muted: #5e6a74;
    --accent: #d86f45;
    --accent-dark: #a74925;
    --line: rgba(27, 36, 48, 0.12);
    --card-shadow: 0 24px 60px rgba(59, 41, 26, 0.12);

    /* Level colours */
    --basico-hue:       #0369a1;
    --basico-bg:        #e0f2fe;
    --basico-border:    rgba(3, 105, 161, 0.22);
    --basico-glow:      rgba(3, 105, 161, 0.08);

    --intermedio-hue:   #854d0e;
    --intermedio-bg:    #fef9c3;
    --intermedio-border:rgba(133, 77, 14, 0.22);
    --intermedio-glow:  rgba(133, 77, 14, 0.06);

    --avanzado-hue:     #9d174d;
    --avanzado-bg:      #fce7f3;
    --avanzado-border:  rgba(157, 23, 77, 0.22);
    --avanzado-glow:    rgba(157, 23, 77, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Source Sans 3', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(216, 111, 69, 0.18), transparent 32%),
        radial-gradient(circle at right 20%, rgba(255, 214, 153, 0.32), transparent 24%),
        linear-gradient(180deg, #f8f1e6 0%, #f3ede2 48%, #fdfbf7 100%);
}

body::before,
body::after {
    content: '';
    position: fixed;
    inset: auto;
    pointer-events: none;
    z-index: -1;
    filter: blur(14px);
}

body::before {
    top: 14%;
    left: -120px;
    width: 260px;
    height: 58vh;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(216, 111, 69, 0.16), rgba(216, 111, 69, 0));
}

body::after {
    top: 9%;
    right: -80px;
    width: 240px;
    height: 62vh;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 214, 153, 0.28), rgba(255, 214, 153, 0));
}

a {
    color: inherit;
}

.page-header,
main,
.page-footer {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 0 18px;
}

main {
    padding-bottom: 48px;
}

.brand img {
    width: 160px;
    max-width: 100%;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    font-weight: 600;
}

.page-nav a {
    text-decoration: none;
    color: var(--muted);
}

.page-nav a:hover,
.page-nav a:focus-visible {
    color: var(--accent-dark);
}

/* ─── Hero ─────────────────────────────────────────────────── */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 28px;
    align-items: stretch;
    padding: 18px 0 34px;
}

.hero-copy,
.hero-card {
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 250, 242, 0.82);
    backdrop-filter: blur(14px);
    box-shadow: var(--card-shadow);
}

.hero-copy {
    border-radius: 30px;
    padding: 46px;
}

.eyebrow {
    margin: 0 0 14px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-dark);
}

.hero h1,
.section-heading h2,
.hero-card h2,
.level-title {
    margin: 0;
    font-family: 'Outfit', sans-serif;
}

.hero h1 {
    font-size: clamp(2.5rem, 5vw, 4.6rem);
    line-height: 0.98;
}

.hero-text,
.section-copy,
.hero-note,
.audio-description,
.meta-chip,
.library-status,
.page-footer a,
.page-footer p {
    color: var(--muted);
}

.hero-text {
    margin: 20px 0 0;
    max-width: 640px;
    font-size: 1.15rem;
    line-height: 1.55;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-top: 26px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.hero-card {
    border-radius: 26px;
    padding: 30px;
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: '';
    position: absolute;
    inset: auto -40px -30px auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(216, 111, 69, 0.25) 0%, rgba(216, 111, 69, 0) 72%);
}

.hero-card h2 {
    font-size: 1.5rem;
    margin-bottom: 14px;
}

.hero-card ol {
    margin: 0;
    padding-left: 20px;
    position: relative;
    z-index: 1;
    line-height: 1.7;
}

/* ─── Library wrapper ───────────────────────────────────────── */
.library-section {
    padding: 38px;
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    background: rgba(255, 250, 242, 0.64);
    backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    animation: fadeSlideIn 0.4s ease both;
}

.library-section.is-hidden {
    display: none;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.section-heading h2 {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.section-copy {
    margin: 0;
    max-width: 440px;
    font-size: 1rem;
    line-height: 1.55;
}

/* ─── Level quick-nav ───────────────────────────────────────── */
.level-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.level-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.level-nav-btn:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
}

.level-nav-basico {
    background: var(--basico-bg);
    color: var(--basico-hue);
}

.level-nav-intermedio {
    background: var(--intermedio-bg);
    color: var(--intermedio-hue);
}

.level-nav-avanzado {
    background: var(--avanzado-bg);
    color: var(--avanzado-hue);
}

/* ─── Status box ────────────────────────────────────────────── */
.library-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 20px;
    border-radius: 20px;
    border: 1px dashed var(--line);
    background: rgba(255, 255, 255, 0.44);
}

.status-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.02rem;
    color: var(--ink);
}

.status-note {
    margin: 0;
    line-height: 1.5;
}

.library-status.is-hidden {
    display: none;
}

.library-status.is-error {
    color: #8d3014;
    border-color: rgba(141, 48, 20, 0.25);
    background: rgba(255, 239, 231, 0.88);
}

.library-status.is-info {
    color: #1f4b7c;
    border-color: rgba(31, 75, 124, 0.16);
    background: rgba(239, 247, 255, 0.92);
}

/* ─── Level sections ────────────────────────────────────────── */
#audioGrid {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.level-section {
    border-radius: 24px;
    padding: 26px 28px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.54);
    backdrop-filter: blur(8px);
}

.level-section.level-basico {
    border-color: var(--basico-border);
    background: color-mix(in srgb, var(--basico-bg) 18%, rgba(255,255,255,0.56));
}

.level-section.level-intermedio {
    border-color: var(--intermedio-border);
    background: color-mix(in srgb, var(--intermedio-bg) 18%, rgba(255,255,255,0.56));
}

.level-section.level-avanzado {
    border-color: var(--avanzado-border);
    background: color-mix(in srgb, var(--avanzado-bg) 18%, rgba(255,255,255,0.56));
}

.level-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.level-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.level-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 14px;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.level-basico .level-icon {
    background: var(--basico-bg);
    color: var(--basico-hue);
}

.level-intermedio .level-icon {
    background: var(--intermedio-bg);
    color: var(--intermedio-hue);
}

.level-avanzado .level-icon {
    background: var(--avanzado-bg);
    color: var(--avanzado-hue);
}

.level-title {
    font-size: 1.5rem;
    line-height: 1.1;
    margin-bottom: 4px;
}

.level-basico .level-title    { color: var(--basico-hue); }
.level-intermedio .level-title { color: var(--intermedio-hue); }
.level-avanzado .level-title   { color: var(--avanzado-hue); }

.level-description {
    margin: 0;
    font-size: 0.96rem;
    color: var(--muted);
    line-height: 1.45;
}

.level-count {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.level-basico .level-count {
    background: var(--basico-bg);
    color: var(--basico-hue);
}

.level-intermedio .level-count {
    background: var(--intermedio-bg);
    color: var(--intermedio-hue);
}

.level-avanzado .level-count {
    background: var(--avanzado-bg);
    color: var(--avanzado-hue);
}

.level-empty {
    padding: 18px 20px;
    border-radius: 14px;
    border: 1px dashed var(--line);
    background: rgba(255,255,255,0.42);
    color: var(--muted);
    font-size: 0.96rem;
    margin: 0;
}

/* ─── Audio grid & cards ────────────────────────────────────── */
.audio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.audio-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    background: rgba(255, 250, 242, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 28px rgba(59, 41, 26, 0.09);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.audio-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 38px rgba(59, 41, 26, 0.14);
}

.audio-card-unit {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(216, 111, 69, 0.12);
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.audio-card-body {
    flex: 1;
}

.audio-card-title {
    margin: 0 0 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    line-height: 1.2;
    color: var(--ink);
}

.audio-description {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.audio-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.88rem;
    font-weight: 600;
}

.audio-player {
    width: 100%;
    accent-color: var(--accent-dark);
}

.player-note {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ─── Footer ────────────────────────────────────────────────── */
.page-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 34px;
}

.page-footer p,
.page-footer a {
    margin: 0;
    text-decoration: none;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 860px) {
    .hero {
        grid-template-columns: 1fr;
    }

    .hero-copy {
        padding: 32px 24px;
    }

    .library-section {
        padding: 22px 18px;
    }

    .level-section {
        padding: 20px 18px;
    }
}

@media (max-width: 640px) {
    .page-header,
    .page-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-nav {
        gap: 14px;
        flex-wrap: wrap;
    }

    .audio-grid {
        grid-template-columns: 1fr;
    }

    .level-section-header {
        flex-wrap: wrap;
    }
}
