.sgba-gallery {
    --sgba-radius: 18px;
    --sgba-bg: #071a2d;
    position: relative;
    width: 100%;
    margin: 1.7em auto;
    box-sizing: border-box;
    font-family: inherit;
}

.sgba-gallery *,
.sgba-gallery *::before,
.sgba-gallery *::after {
    box-sizing: border-box;
}

.sgba-gallery__stage {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--sgba-radius);
    background: var(--sgba-bg);
    box-shadow: 0 16px 42px rgba(4, 18, 32, .18);
    outline: none;
    isolation: isolate;
    touch-action: pan-y;
}

.sgba-gallery--16-9 .sgba-gallery__stage { aspect-ratio: 16 / 9; }
.sgba-gallery--4-3 .sgba-gallery__stage { aspect-ratio: 4 / 3; }
.sgba-gallery--1-1 .sgba-gallery__stage { aspect-ratio: 1 / 1; }
.sgba-gallery--4-5 .sgba-gallery__stage { aspect-ratio: 4 / 5; }

.sgba-gallery__stage:focus-visible {
    box-shadow: 0 0 0 3px rgba(19, 117, 191, .35), 0 16px 42px rgba(4, 18, 32, .18);
}

.sgba-gallery__slides,
.sgba-gallery__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
}

.sgba-gallery__slide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .42s ease, visibility .42s ease;
    background: #0a1f34;
    cursor: zoom-in;
}

.sgba-gallery__slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 55%, rgba(2, 10, 18, .6) 100%);
    pointer-events: none;
}

.sgba-gallery__slide.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}

.sgba-gallery__slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

.sgba-gallery__caption {
    position: absolute;
    z-index: 2;
    left: 20px;
    right: 80px;
    bottom: 18px;
    margin: 0;
    color: #fff;
    font-size: clamp(12px, 1.5vw, 15px);
    line-height: 1.4;
    text-shadow: 0 2px 10px rgba(0,0,0,.55);
}

.sgba-gallery__counter {
    position: absolute;
    z-index: 4;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 4px;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: rgba(4, 17, 29, .62);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.sgba-gallery__arrow {
    appearance: none;
    position: absolute;
    z-index: 5;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 50%;
    background: rgba(4, 17, 29, .58);
    backdrop-filter: blur(10px);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .18s ease, transform .18s ease, opacity .18s ease;
}

.sgba-gallery__arrow span {
    display: block;
    line-height: 1;
    font-size: 34px;
    font-family: Arial, sans-serif;
    margin-top: -3px;
}

.sgba-gallery__arrow:hover,
.sgba-gallery__arrow:focus-visible {
    background: rgba(4, 17, 29, .86);
    outline: none;
}

.sgba-gallery__arrow:hover { transform: translateY(-50%) scale(1.05); }
.sgba-gallery__arrow--prev { left: 14px; }
.sgba-gallery__arrow--next { right: 14px; }

.sgba-gallery__progress {
    position: absolute;
    z-index: 6;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(255,255,255,.12);
    overflow: hidden;
}

.sgba-gallery__progress span {
    display: block;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.86);
    transform: scaleX(0);
    transform-origin: left center;
}

.sgba-gallery.is-running .sgba-gallery__progress span {
    animation: sgbaProgress var(--sgba-interval, 1500ms) linear forwards;
}

@keyframes sgbaProgress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.sgba-gallery__thumbs {
    display: flex;
    gap: 8px;
    width: 100%;
    padding: 10px 2px 2px;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}

.sgba-gallery__thumb {
    appearance: none;
    flex: 0 0 62px;
    width: 62px;
    height: 45px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 9px;
    overflow: hidden;
    background: #e5e9ed;
    cursor: pointer;
    opacity: .56;
    transition: opacity .18s ease, border-color .18s ease, transform .18s ease;
    scroll-snap-align: start;
}

.sgba-gallery__thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.sgba-gallery__thumb:hover { opacity: .86; transform: translateY(-1px); }
.sgba-gallery__thumb.is-active {
    opacity: 1;
    border-color: #0b3154;
}

.sgba-gallery__thumb:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Lightbox */
.sgba-lightbox {
    position: fixed;
    z-index: 999999;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 9, 15, .94);
    backdrop-filter: blur(8px);
}

.sgba-lightbox.is-open { display: flex; }
body.sgba-lightbox-open { overflow: hidden; }

.sgba-lightbox__image {
    max-width: min(94vw, 1500px);
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 20px 70px rgba(0,0,0,.45);
}

.sgba-lightbox__close,
.sgba-lightbox__nav {
    appearance: none;
    position: absolute;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.1);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.sgba-lightbox__close {
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 25px;
}

.sgba-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 54px;
    border-radius: 14px;
    font-size: 34px;
}

.sgba-lightbox__prev { left: 18px; }
.sgba-lightbox__next { right: 18px; }

.sgba-lightbox__count {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 11px;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 12px;
}

@media (max-width: 640px) {
    .sgba-gallery { --sgba-radius: 13px; margin: 1.25em auto; }
    .sgba-gallery__arrow { width: 38px; height: 38px; opacity: .88; }
    .sgba-gallery__arrow--prev { left: 8px; }
    .sgba-gallery__arrow--next { right: 8px; }
    .sgba-gallery__counter { top: 9px; right: 9px; }
    .sgba-gallery__caption { left: 14px; right: 65px; bottom: 13px; }
    .sgba-gallery__thumb { flex-basis: 54px; width: 54px; height: 40px; }
    .sgba-lightbox { padding: 10px; }
    .sgba-lightbox__nav { width: 42px; height: 48px; }
    .sgba-lightbox__prev { left: 8px; }
    .sgba-lightbox__next { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .sgba-gallery__slide,
    .sgba-gallery__arrow,
    .sgba-gallery__thumb {
        transition: none !important;
    }
    .sgba-gallery__progress { display: none; }
}
