.cat-section {
    padding-top: 20px;
}

@media (min-width: 768px) {
    .cat-section {
        padding-top: 28px;
    }
}

.cat-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--home-card-border);
}

@media (min-width: 768px) {
    .cat-head {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
        gap: 24px;
        padding-bottom: 20px;
        margin-bottom: 26px;
    }
}

.cat-title {
    margin: 0;
    font-family: 'Helvetica Neue', Arial, system-ui, sans-serif;
    font-size: clamp(22px, 6vw, 26px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--home-text-primary);
    text-align: left;
}

@media (min-width: 768px) {
    .cat-title {
        font-size: 36px;
    }
}

.cat-sub {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.45;
    max-width: 560px;
    color: var(--home-text-secondary);
    text-wrap: pretty;
}

@media (min-width: 768px) {
    .cat-sub {
        font-size: 15px;
    }
}

.cat-head-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .cat-head-side {
        align-items: flex-end;
    }
}

.cat-count {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--home-text-tertiary);
}

.cat-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cat-shuffle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
}

.cat-shuffle svg {
    flex-shrink: 0;
}

.cat-shuffle.cat-shuffle-active svg {
    color: var(--home-accent);
}

@media (min-width: 768px) {
    .cat-genres {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Колонки подобраны так, чтобы самое длинное название народа помещалось
   в строку на минимальной ширине каждого диапазона, а лишние чипы скрывались:
   везде две строки, на мобильной — четыре. */
.cat-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.cat-chips .cat-chip:nth-child(n+9) {
    display: none;
}

@media (min-width: 768px) {
    .cat-chips {
        grid-template-columns: repeat(5, 1fr);
    }

    .cat-chips .cat-chip:nth-child(n+9) {
        display: flex;
    }

    .cat-chips .cat-chip:nth-child(n+11) {
        display: none;
    }
}

@media (min-width: 1200px) {
    .cat-chips {
        grid-template-columns: repeat(7, 1fr);
    }

    .cat-chips .cat-chip:nth-child(n+11) {
        display: flex;
    }

    .cat-chips .cat-chip:nth-child(n+15) {
        display: none;
    }
}

@media (min-width: 1400px) {
    .cat-chips {
        grid-template-columns: repeat(8, 1fr);
    }

    .cat-chips .cat-chip:nth-child(n+15) {
        display: flex;
    }
}

.cat-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 100px;
    background: var(--home-card-bg);
    border: 1px solid var(--home-card-border);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--home-text-primary);
    text-align: center;
    text-decoration: none;
    text-wrap: balance;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .cat-chip:hover {
        border-color: var(--home-accent);
        transform: translateY(-1px);
    }
}

.cat-chip:active {
    transform: translateY(0);
    border-color: var(--home-accent);
}

.cat-seo-rule {
    border-top: 1px solid var(--home-card-border);
}

.cat-seo {
    max-width: 760px;
}

.cat-seo-title {
    margin: 18px 0 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--home-text-primary);
}

.cat-seo-p {
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--home-text-secondary);
    text-wrap: pretty;
}

/* описание может прийти без заголовка — тогда первый абзац отбиваем от линейки */
.cat-seo-p:first-child {
    margin-top: 18px;
}
