.crp-product-gallery {
    --crp-gallery-main-height: clamp(420px, 48vw, 760px);
    --crp-gallery-thumb-size: 82px;
    --crp-gallery-gap: 18px;
    --crp-gallery-radius: 14px;
    --crp-gallery-border: #dedede;
    --crp-gallery-active: #111111;
    --crp-gallery-surface: #ffffff;

    display: grid;
    gap: var(--crp-gallery-gap);
    align-items: start;
    width: 100%;
}

.crp-gallery-layout-side.has-thumbnails {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-areas: "thumbs main";
}

.crp-gallery-layout-bottom.has-thumbnails {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "main"
        "thumbs";
    gap: 14px;
}

.crp-product-gallery.no-thumbnails {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
}

.crp-product-gallery .crp-gallery-thumbnails {
    grid-area: thumbs;
    display: flex;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #bdbdbd transparent;
}

.crp-gallery-layout-side .crp-gallery-thumbnails {
    flex-direction: column;
    height: 450px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 2px 6px 2px 2px;
}

.crp-gallery-layout-bottom .crp-gallery-thumbnails {
    flex-direction: row;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 8px;
}

.crp-product-gallery .crp-gallery-thumbnails::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.crp-product-gallery .crp-gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.crp-product-gallery .crp-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 20px;
}

.crp-product-gallery .crp-gallery-thumb {
    flex: 0 0 var(--crp-gallery-thumb-size);
    width: var(--crp-gallery-thumb-size);
    height: var(--crp-gallery-thumb-size);
    padding: 0;
    border: 1px solid var(--crp-gallery-border);
    border-radius: var(--crp-gallery-radius);
    overflow: hidden;
    background: var(--crp-gallery-surface);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.crp-product-gallery .crp-gallery-thumb:hover,
.crp-product-gallery .crp-gallery-thumb.is-active {
    border-color: var(--crp-gallery-active);
}

.crp-product-gallery .crp-gallery-thumb.is-active {
    box-shadow:
        0 0 0 1px var(--crp-gallery-active),
        0 8px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.crp-product-gallery .crp-gallery-thumb:focus-visible {
    outline: 2px solid var(--crp-gallery-active);
    outline-offset: 3px;
}

.crp-product-gallery .crp-gallery-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #ffffff;
}

.crp-product-gallery .crp-gallery-main {
    grid-area: main;
    position: relative;
    height: var(--crp-gallery-main-height);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--crp-gallery-radius);
    background: var(--crp-gallery-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.crp-product-gallery .crp-gallery-main-button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.crp-product-gallery .crp-gallery-main-button:focus-visible {
    outline: 2px solid var(--crp-gallery-active);
    outline-offset: -6px;
    border-radius: var(--crp-gallery-radius);
}

.crp-product-gallery .crp-gallery-main-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.crp-product-gallery .crp-gallery-main:hover .crp-gallery-main-image {
    transform: scale(1.05);
}

.crp-product-gallery .crp-gallery-count {
    position: absolute;
    right: 14px;
    bottom: 14px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
    pointer-events: none;
}

.crp-product-gallery .crp-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: rgba(0, 0, 0, 0.92);
}

.crp-product-gallery .crp-gallery-lightbox.is-open {
    display: flex;
}

.crp-product-gallery .crp-gallery-lightbox img {
    display: block;
    max-width: 94vw;
    max-height: 90vh;
    object-fit: contain;
}

.crp-product-gallery .crp-gallery-lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 767px) {
    .crp-product-gallery {
        --crp-gallery-thumb-size: 72px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "main"
            "thumbs";
        gap: 12px;
    }

    .crp-product-gallery .crp-gallery-main {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .crp-product-gallery .crp-gallery-thumbnails {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 0 6px;
    }
}
