.sp-cover.sp-project-gallery {
    position: relative;
    width: 100%;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(20, 23, 41, 0.98), rgba(13, 15, 29, 0.99));
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 22px 48px rgba(2, 6, 23, 0.34);
}

.sp-project-gallery__stage {
    position: relative;
    aspect-ratio: 16 / 9;
    min-height: 280px;
    overflow: hidden;
    border-radius: 17px;
    background:
        radial-gradient(circle at 20% 0%, rgba(108, 99, 255, 0.16), transparent 35%),
        #090b16;
    touch-action: pan-y;
}

.sp-project-gallery:not(.is-single) .sp-project-gallery__stage {
    border-radius: 17px 17px 0 0;
}

.sp-project-gallery__open {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.sp-project-gallery.is-video-active .sp-project-gallery__open {
    cursor: pointer;
}

.sp-project-gallery__video-play {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0.08), rgba(2, 6, 23, 0.48));
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.01em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.sp-project-gallery__video-play[hidden] {
    display: none !important;
}

.sp-project-gallery__video-play > span {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 50%;
    color: #fff;
    background: #ef4444;
    box-shadow: 0 16px 38px rgba(2, 6, 23, 0.44);
    font-size: 1.05rem;
    transition: transform 0.18s ease, background 0.18s ease;
}

.sp-project-gallery__open:hover .sp-project-gallery__video-play > span {
    background: #dc2626;
    transform: scale(1.05);
}

.sp-project-gallery .sp-project-gallery__stage img,
.sp-project-gallery:hover .sp-project-gallery__stage img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover;
    object-position: center;
    transform: none !important;
    filter: none;
    transition: opacity 0.18s ease;
}

.sp-project-gallery__open:focus-visible,
.sp-project-gallery__nav:focus-visible,
.sp-project-gallery__thumb:focus-visible,
.sp-gallery-lightbox button:focus-visible {
    outline: 3px solid #a78bfa;
    outline-offset: 3px;
}

.sp-project-gallery__nav,
.sp-gallery-lightbox__nav,
.sp-gallery-lightbox__close {
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.17);
    color: #fff;
    background: rgba(5, 7, 18, 0.7);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.25);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.sp-project-gallery__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border-radius: 13px;
    line-height: 1;
    transform: translateY(-50%);
}

.sp-project-gallery__nav i,
.sp-gallery-lightbox__nav i,
.sp-gallery-lightbox__close i {
    display: block;
    width: 1em;
    height: 1em;
    line-height: 1;
    text-align: center;
}

.sp-project-gallery__nav--prev {
    left: 14px;
}

.sp-project-gallery__nav--next {
    right: 14px;
}

.sp-project-gallery__nav:hover,
.sp-gallery-lightbox__nav:hover,
.sp-gallery-lightbox__close:hover {
    border-color: rgba(167, 139, 250, 0.5);
    background: rgba(108, 99, 255, 0.82);
}

.sp-project-gallery__nav:hover {
    transform: translateY(-50%) scale(1.04);
}

.sp-gallery-lightbox__nav:hover,
.sp-gallery-lightbox__close:hover {
    transform: scale(1.04);
}

.sp-project-gallery__counter,
.sp-gallery-lightbox__counter {
    position: absolute;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    color: #fff;
    background: rgba(5, 7, 18, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.sp-project-gallery__counter {
    right: 14px;
    bottom: 14px;
}

.sp-project-gallery__expand {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    color: #fff;
    background: rgba(5, 7, 18, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.14);
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.sp-project-gallery__thumbs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 116px;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 125, 255, 0.56) rgba(148, 163, 184, 0.08);
}

.sp-project-gallery__thumbs::-webkit-scrollbar {
    height: 7px;
}

.sp-project-gallery__thumbs::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.08);
    border-radius: 999px;
}

.sp-project-gallery__thumbs::-webkit-scrollbar-thumb {
    background: rgba(139, 125, 255, 0.56);
    border-radius: 999px;
}

.sp-project-gallery__thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.04);
    opacity: 0.66;
    cursor: pointer;
    transition: opacity 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sp-project-gallery__thumb:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.sp-project-gallery__thumb.is-active {
    border-color: #8b7dff;
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.13);
}

.sp-project-gallery .sp-project-gallery__thumb img,
.sp-project-gallery:hover .sp-project-gallery__thumb img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
    transform: none !important;
}

.sp-project-gallery__thumb-video {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    color: #fff;
    background: rgba(220, 38, 38, 0.92);
    box-shadow: 0 7px 18px rgba(2, 6, 23, 0.34);
    transform: translate(-50%, -50%);
    font-size: 0.68rem;
}

.sp-project-gallery__thumb[data-type="video"]::after {
    position: absolute;
    inset: 0;
    content: "";
    background: rgba(2, 6, 23, 0.18);
}

.sp-gallery-lightbox {
    position: fixed !important;
    inset: 0 !important;
    z-index: 12000 !important;
    display: grid;
    place-items: center;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
    padding: clamp(58px, 7vh, 82px) clamp(20px, 6vw, 86px) !important;
    overflow: hidden !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    isolation: isolate;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.sp-gallery-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sp-gallery-lightbox__backdrop {
    position: absolute !important;
    inset: 0 !important;
    z-index: 0;
    background: rgba(2, 4, 12, 0.92);
    backdrop-filter: blur(16px);
}

.sp-gallery-lightbox__dialog {
    position: relative !important;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 100% !important;
    max-width: min(1440px, calc(100vw - 40px)) !important;
    height: 100% !important;
    max-height: calc(100dvh - clamp(116px, 14vh, 164px)) !important;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.sp-gallery-lightbox__dialog > img {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    margin: auto !important;
    object-fit: contain !important;
    object-position: center !important;
    border-radius: 14px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
    transform: none !important;
    filter: none !important;
    user-select: none;
    -webkit-user-drag: none;
}

.sp-gallery-lightbox__dialog > img[hidden],
.sp-gallery-lightbox__video[hidden] {
    display: none !important;
}

.sp-gallery-lightbox__video {
    position: relative;
    display: block;
    width: min(100%, 1280px, calc((100dvh - 164px) * 1.7778));
    max-width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 14px;
    background: #000;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.sp-gallery-lightbox__video iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.sp-gallery-lightbox__close {
    position: fixed !important;
    top: max(16px, env(safe-area-inset-top)) !important;
    right: max(16px, env(safe-area-inset-right)) !important;
    z-index: 12005 !important;
    display: grid !important;
    place-items: center !important;
    width: 46px !important;
    height: 46px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 14px;
    opacity: 1 !important;
    visibility: visible !important;
    font-size: 1.15rem;
}

.sp-gallery-lightbox__nav {
    position: fixed !important;
    top: 50% !important;
    z-index: 12004 !important;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin: 0;
    padding: 0;
    border-radius: 15px;
    line-height: 1;
    transform: translateY(-50%);
}

.sp-gallery-lightbox__nav:hover {
    transform: translateY(-50%) scale(1.04);
}

.sp-gallery-lightbox__nav--prev {
    left: max(22px, env(safe-area-inset-left));
}

.sp-gallery-lightbox__nav--next {
    right: max(22px, env(safe-area-inset-right));
}

.sp-gallery-lightbox__counter {
    position: fixed;
    left: 50%;
    bottom: max(22px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
}

body.project-gallery-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

html[data-theme="light"] body.projects-showproject-page .sp-cover.sp-project-gallery {
    border-color: rgba(148, 163, 184, 0.22) !important;
    background: linear-gradient(180deg, #ffffff, #f7f9fc) !important;
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.11) !important;
}

html[data-theme="light"] body.projects-showproject-page .sp-project-gallery__stage {
    background:
        radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.1), transparent 35%),
        #e9eef5;
}

html[data-theme="light"] body.projects-showproject-page .sp-project-gallery__thumbs {
    background: rgba(248, 250, 252, 0.84);
}

html[data-theme="light"] body.projects-showproject-page .sp-project-gallery__thumb {
    background: #e2e8f0;
}

html[data-theme="light"] body.projects-showproject-page .sp-project-gallery__thumb.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

@media (max-width: 768px) {
    .sp-project-gallery__stage {
        min-height: 230px;
    }

    .sp-project-gallery__nav {
        width: 38px;
        height: 38px;
        margin: 0;
    }

    .sp-project-gallery__nav--prev {
        left: 10px;
    }

    .sp-project-gallery__nav--next {
        right: 10px;
    }

    .sp-project-gallery__thumbs {
        grid-auto-columns: 96px;
        gap: 8px;
        padding: 10px;
    }

    .sp-project-gallery__video-play > span {
        width: 54px;
        height: 54px;
    }

    .sp-gallery-lightbox {
        padding: 64px 14px 76px !important;
    }

    .sp-gallery-lightbox__dialog {
        width: 100% !important;
        height: 100% !important;
        max-height: calc(100dvh - 140px) !important;
    }

    .sp-gallery-lightbox__nav {
        top: auto !important;
        bottom: max(20px, env(safe-area-inset-bottom));
        width: 46px;
        height: 46px;
        margin: 0;
        transform: none;
    }

    .sp-gallery-lightbox__nav:hover {
        transform: scale(1.04);
    }

    .sp-gallery-lightbox__nav--prev {
        left: 18px;
    }

    .sp-gallery-lightbox__nav--next {
        right: 18px;
    }
}

@media (max-width: 480px) {
    .sp-project-gallery__stage {
        min-height: 205px;
    }

    .sp-project-gallery__counter {
        right: 10px;
        bottom: 10px;
    }

    .sp-project-gallery__expand {
        left: 10px;
        bottom: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sp-project-gallery__nav,
    .sp-project-gallery__thumb,
    .sp-gallery-lightbox,
    .sp-gallery-lightbox__nav,
    .sp-gallery-lightbox__close {
        transition: none;
    }
}

@media print {
    .sp-project-gallery__nav,
    .sp-project-gallery__counter,
    .sp-project-gallery__expand,
    .sp-project-gallery__thumbs,
    .sp-gallery-lightbox {
        display: none !important;
    }
}
