.cms-gallery {
    --gallery-height: 480px;
    position: relative;
    width: 100%;
    min-width: 0;
}

.cms-gallery button {
    cursor: pointer;
}

.cms-gallery__stage {
    position: relative;
    height: var(--gallery-height);
    min-height: 220px;
    overflow: hidden;
    border-radius: .35rem;
    background: #151515;
}

.cms-gallery__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .85s ease;
    background: #151515;
}

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

.cms-gallery__slide img,
.cms-gallery__main img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cms-gallery__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    margin-top: .6rem;
}

.cms-gallery__arrow,
.cms-gallery__dialog-arrow,
.cms-gallery__close {
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(12, 12, 12, .78);
    color: #fff;
    line-height: 1;
}

.cms-gallery__arrow {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.75rem;
}

.cms-gallery__dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .42rem;
}

.cms-gallery__dots button {
    width: .72rem;
    height: .72rem;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: transparent;
}

.cms-gallery__dots button.is-active {
    background: currentColor;
}

.cms-gallery__main {
    position: relative;
    width: 100%;
    height: var(--gallery-height);
    min-height: 220px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: .35rem;
    background: #151515;
}

.cms-gallery__main span {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 2.5rem 1rem .8rem;
    color: #fff;
    text-align: left;
    background: linear-gradient(transparent, rgba(0, 0, 0, .78));
}

.cms-gallery__filmstrip {
    display: flex;
    gap: .5rem;
    margin-top: .65rem;
    padding-bottom: .3rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}

.cms-gallery__filmstrip button {
    flex: 0 0 7rem;
    height: 4.6rem;
    padding: .16rem;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: .3rem;
    background: transparent;
    scroll-snap-align: start;
}

.cms-gallery__filmstrip button.is-active {
    border-color: currentColor;
}

.cms-gallery__filmstrip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cms-gallery__masonry {
    columns: 4 13rem;
    column-gap: .7rem;
}

.cms-gallery__masonry button {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 0 0 .7rem;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: .35rem;
    background: #151515;
    break-inside: avoid;
}

.cms-gallery__masonry img {
    display: block;
    width: 100%;
    height: auto;
}

.cms-gallery__masonry span {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1.8rem .65rem .45rem;
    color: #fff;
    text-align: left;
    background: linear-gradient(transparent, rgba(0, 0, 0, .8));
}

.cms-gallery__dialog {
    box-sizing: border-box;
    width: min(calc(100vw - 1rem), 92rem);
    max-width: none;
    height: min(calc(100vh - 1rem), 70rem);
    height: min(calc(100dvh - 1rem), 70rem);
    max-height: none;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: .4rem;
    color: #fff;
    background: #101010;
}

.cms-gallery__dialog::backdrop {
    background: rgba(0, 0, 0, .88);
}

.cms-gallery__dialog-shell {
    position: relative;
    display: grid;
    height: 100%;
    place-items: center;
}

.cms-gallery__dialog figure {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
}

.cms-gallery__dialog-image-frame {
    display: grid;
    min-width: 0;
    min-height: 0;
    padding: .5rem;
    overflow: hidden;
    place-items: center;
}

.cms-gallery__dialog-image-frame > img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cms-gallery__dialog figcaption {
    max-height: 32vh;
    padding: .9rem 4.5rem 1.1rem;
    overflow: auto;
    color: #fff;
    background: #202020;
}

.cms-gallery__dialog figcaption h3 {
    margin: 0 0 .4rem;
    color: inherit;
}

.cms-gallery__close {
    position: absolute;
    z-index: 3;
    top: .75rem;
    right: .75rem;
    width: 2.8rem;
    height: 2.8rem;
    font-size: 2rem;
}

.cms-gallery__dialog-arrow {
    position: absolute;
    z-index: 3;
    top: 45%;
    width: 3rem;
    height: 3rem;
    font-size: 2.3rem;
}

.cms-gallery__dialog-arrow.is-previous {
    left: .75rem;
}

.cms-gallery__dialog-arrow.is-next {
    right: .75rem;
}

@media (max-width: 39.9375em) {
    .cms-gallery__stage,
    .cms-gallery__main {
        height: min(var(--gallery-height), 70vh);
    }

    .cms-gallery__dialog figcaption {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .cms-gallery__dialog-arrow {
        top: 40%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cms-gallery__slide {
        transition: none;
    }
}
