.jg-gallery {
    display: grid;
    /* grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
    gap: clamp(10px, 1.4vw, 20px);
    margin: 3rem 0;
}

.jg-gallery__item {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    aspect-ratio: 1;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #e9e9e9;
    cursor: zoom-in
}

.jg-gallery__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease, filter .3s ease
}

@media(hover:hover) {
    .jg-gallery__item:hover img {
        transform: scale(1.055);
        filter: brightness(.9)
    }
}

.jg-gallery__item:focus-visible,
.jg-lightbox button:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 3px
}

.jg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483640;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 10, 16, .96);
    color: #fff
}

.jg-lightbox[aria-hidden="false"] {
    display: flex
}

.jg-lightbox__stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 65px 58px 50px;
    box-sizing: border-box;
    touch-action: pan-y
}

.jg-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 160px);
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none
}

.jg-lightbox__caption {
    margin: 14px auto 0;
    max-width: 80ch;
    font-size: .95rem;
    text-align: center;
    line-height: 1.5;
    color: #e7e7e7
}

.jg-lightbox__control {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    background: rgba(45, 45, 50, .8);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer
}

.jg-lightbox__control:hover {
    background: rgba(95, 95, 105, .9)
}

.jg-lightbox__close {
    top: max(12px, env(safe-area-inset-top));
    right: 16px
}

.jg-lightbox__prev {
    left: 12px;
    top: 50%;
    transform: translateY(-50%)
}

.jg-lightbox__next {
    right: 12px;
    top: 50%;
    transform: translateY(-50%)
}

.jg-lightbox__count {
    position: absolute;
    top: max(22px, env(safe-area-inset-top));
    left: 20px;
    font-size: .9rem;
    color: #ddd
}

body.jg-lightbox-open {
    overflow: hidden
}

@media(max-width:600px) {
    .jg-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px
    }

    .jg-gallery__item {
        border-radius: 8px
    }

    .jg-lightbox__stage {
        padding: 70px 12px 85px
    }

    .jg-lightbox__image {
        max-height: calc(100dvh - 185px)
    }

    .jg-lightbox__prev,
    .jg-lightbox__next {
        top: auto;
        bottom: 18px;
        transform: none
    }

    .jg-lightbox__prev {
        left: calc(50% - 66px)
    }

    .jg-lightbox__next {
        right: calc(50% - 66px)
    }

    .jg-lightbox__caption {
        font-size: .85rem
    }
}

@media(prefers-reduced-motion:reduce) {
    .jg-gallery__item img {
        transition: none
    }
}