.sg-gallery {
    display: grid;
    grid-template-columns: repeat(var(--sg-cols-desktop, 4), minmax(0, 1fr));
    gap: var(--sg-gap, 12px);
    margin: 1.25rem 0;
}

.sg-gallery .sg-item {
    min-width: 0;
    margin: 0;
}

.sg-gallery .sg-image-link {
    display: block;
    overflow: hidden;
    border-radius: 8px;
    background: #f2f2f2;
    line-height: 0;
}

.sg-gallery .sg-image-link img {
    display: block;
    width: 100%;
    aspect-ratio: var(--sg-ratio, 4 / 3);
    object-fit: cover;
    transition: transform .22s ease;
}

.sg-gallery.sg-original .sg-image-link img {
    aspect-ratio: auto;
    height: auto;
}

@media (hover: hover) and (pointer: fine) {
    .sg-gallery a.sg-image-link:hover img {
        transform: scale(1.025);
    }
}

.sg-gallery figcaption {
    padding-top: 7px;
    font-size: .9rem;
    line-height: 1.35;
    color: #666;
}

.sg-error {
    margin: 1rem 0;
    padding: .75rem 1rem;
    border: 1px solid #d7d7d7;
    border-radius: 6px;
    background: #fafafa;
    color: #555;
}

@media (max-width: 900px) {
    .sg-gallery {
        grid-template-columns: repeat(var(--sg-cols-tablet, 3), minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .sg-gallery {
        grid-template-columns: repeat(var(--sg-cols-mobile, 2), minmax(0, 1fr));
    }
}

.sg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 48px 64px 72px;
    background: rgba(0, 0, 0, .9);
}

.sg-lightbox.is-open {
    display: flex;
}

.sg-lightbox__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
}

.sg-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 130px);
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
}

.sg-lightbox__close,
.sg-lightbox__prev,
.sg-lightbox__next {
    position: absolute;
    z-index: 2;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.sg-lightbox__close {
    top: 12px;
    right: 12px;
}

.sg-lightbox__prev,
.sg-lightbox__next {
    top: 50%;
    transform: translateY(-50%);
}

.sg-lightbox__prev { left: 12px; }
.sg-lightbox__next { right: 12px; }

.sg-lightbox__caption,
.sg-lightbox__counter {
    position: absolute;
    bottom: 20px;
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
}

.sg-lightbox__caption {
    left: 50%;
    max-width: min(70vw, 760px);
    transform: translateX(-50%);
    text-align: center;
}

.sg-lightbox__counter {
    right: 20px;
}

.sg-lightbox button:focus-visible,
.sg-gallery a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .sg-lightbox {
        padding: 54px 12px 72px;
    }

    .sg-lightbox__prev { left: 6px; }
    .sg-lightbox__next { right: 6px; }
    .sg-lightbox__image { max-height: calc(100vh - 140px); }
}
