.gallery-section {
    margin-top: 28px;
}

.gallery-toolbar {
    padding: clamp(20px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(160deg, #ffffff, rgba(235, 246, 255, 0.78));
}

.gallery-toolbar-copy {
    max-width: 760px;
}

.gallery-toolbar-copy h2 {
    margin: 8px 0 10px;
    color: var(--brand-900);
    font-size: clamp(1.45rem, 3vw, 2rem);
    line-height: 1.2;
}

.gallery-toolbar-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.gallery-filters {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gallery-filter-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--brand-700);
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.gallery-filter-btn:hover,
.gallery-filter-btn:focus-visible {
    background: rgba(43, 126, 191, 0.1);
    color: var(--brand-900);
    border-color: rgba(43, 126, 191, 0.22);
    transform: translateY(-1px);
    outline: none;
}

.gallery-filter-btn.is-active {
    background: var(--brand-700);
    color: #fff;
    border-color: var(--brand-700);
}

.gallery-masonry {
    margin-top: 18px;
    column-count: 3;
    column-gap: 14px;
}

.gallery-item {
    break-inside: avoid;
    margin: 0 0 14px;
    transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.gallery-item.is-hidden {
    opacity: 0;
    transform: scale(0.98);
    visibility: hidden;
    pointer-events: none;
    height: 0;
    margin: 0;
    overflow: hidden;
}

.gallery-card {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    position: relative;
    cursor: pointer;
    padding: 0;
    display: block;
    box-shadow: 0 10px 24px rgba(15, 58, 95, 0.08);
}

.gallery-card img {
    width: 100%;
    display: block;
    object-fit: cover;
    transition: transform 220ms ease;
}

.gallery-item .gallery-card img {
    min-height: 240px;
}

.gallery-item.is-tall .gallery-card img {
    min-height: 420px;
}

.gallery-item.is-wide .gallery-card img {
    min-height: 280px;
}

.gallery-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8, 24, 39, 0.02), rgba(8, 24, 39, 0.72));
    opacity: 0.9;
    transition: opacity 220ms ease;
}

.gallery-card figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 18px 16px 16px;
    color: #fff;
    text-align: left;
}

.gallery-item-category {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.84);
}

.gallery-card strong {
    display: block;
    font-size: 1rem;
    line-height: 1.35;
}

.gallery-card:hover img,
.gallery-card:focus-visible img {
    transform: scale(1.04);
}

.gallery-card:hover::after,
.gallery-card:focus-visible::after {
    opacity: 1;
}

.gallery-card:focus-visible {
    outline: 2px solid rgba(43, 126, 191, 0.3);
    outline-offset: 3px;
}

.gallery-lightbox[hidden] {
    display: none;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 17, 28, 0.82);
    backdrop-filter: blur(3px);
}

.gallery-lightbox-dialog {
    position: relative;
    z-index: 2;
    width: min(1100px, calc(100vw - 32px));
    height: min(86vh, 760px);
    margin: min(6vh, 40px) auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
}

.gallery-lightbox-figure {
    margin: 0;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.gallery-lightbox-figure img {
    width: 100%;
    max-height: calc(86vh - 90px);
    display: block;
    object-fit: contain;
    background: #f6fbff;
}

.gallery-lightbox-figure figcaption {
    padding: 14px 18px;
    color: var(--brand-900);
    font-weight: 700;
    line-height: 1.5;
    background: #fff;
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transition: background-color 180ms ease, transform 180ms ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-close:focus-visible,
.gallery-lightbox-nav:hover,
.gallery-lightbox-nav:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.03);
    outline: none;
}

.gallery-lightbox-close {
    position: absolute;
    top: -8px;
    right: 4px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    font-size: 1.8rem;
    line-height: 1;
    z-index: 3;
}

.gallery-lightbox-nav {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    font-size: 1.5rem;
}

@media (max-width: 960px) {
    .gallery-masonry {
        column-count: 2;
    }

    .gallery-lightbox-dialog {
        width: min(920px, calc(100vw - 20px));
        grid-template-columns: auto minmax(0, 1fr) auto;
    }
}

@media (max-width: 620px) {
    .gallery-masonry {
        column-count: 1;
    }

    .gallery-lightbox-dialog {
        width: calc(100vw - 16px);
        height: auto;
        margin: 18px auto;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .gallery-lightbox-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 3;
        width: 44px;
        height: 44px;
    }

    .gallery-lightbox-nav.prev {
        left: 8px;
    }

    .gallery-lightbox-nav.next {
        right: 8px;
    }

    .gallery-lightbox-figure img {
        max-height: 72vh;
    }

    .gallery-lightbox-close {
        top: 8px;
        right: 8px;
        background: rgba(6, 17, 28, 0.55);
    }
}