main {
    padding: 2em 2em;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, calc(260px + 2 * .5em));
    gap: 1em;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    position: relative;
}

#gallery .card {
    padding: .5em;
    text-decoration: none;
    color: black;
    transition: .3s;
}

#gallery .card img {
    display: inline-block;
}

#gallery .card h3,
#gallery .card p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#gallery .card:hover {
    background-color: var(--gray-bg);
}

#filters {
    grid-column: 1 / -1;
    align-self: start;
    padding: .5em .4em 0 .5em;
    display: flex;
    justify-content: flex-end;
    gap: 1em;

    font-size: 1.3em;
}

#filters select {
    font-size: 0.9em;
    background-color: var(--white);
    border: none;
    border-radius: 0;
    padding: 3px;
    outline: none;
    cursor: pointer;
    border: 1px solid var(--border-outline);
}

#pagination {
    grid-column: 1 / -1;
    margin-top: 1em;
    padding: 0 0.6em;
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
}

#pagination a {
    color: var(--black-text) !important;
    text-decoration: none;
}

#pagination span {
    width: 78px;
}

#pagination span:nth-of-type(3) {
    text-align: center;
}

#pagination span:nth-of-type(4),
#pagination span:nth-of-type(5) {
    text-align: right;
}

#pagination span.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    main {
        padding: 1em;
    }

    #gallery {
        grid-template-columns: repeat(auto-fill, calc(160px + 2 * .5em));
    }

    #gallery>.card>img {
        width: 160px;
    }
}
