.gallery-ad {
    display: none;
    position: absolute;
    z-index: 20;
    pointer-events: none;
    background: transparent;
    color: #bbb;
    text-align: center;
}
.gallery-ad.is-filled { background: #181818; pointer-events: auto; }
.gallery-ad:not(.is-filled) .gallery-ad__label { visibility: hidden; }
/* Hide ads immediately without changing the photo geometry during closing. */
.has-gallery-ads.is-closing .gallery-ad { visibility: hidden; pointer-events: none; }
.gallery-ad__label { height: 18px; font-size: 10px; line-height: 18px; }
.gallery-ad.is-unfilled { display: none !important; }
/* Clip adjacent slides to the photo area, keeping the outer navigation visible. */
.has-gallery-ads .fancybox__viewport { overflow: hidden; }
/* Desktop ads overlay the photo; mobile ads reserve space only when filled. */
@media (min-width: 1100px) and (min-height: 800px) {
    .gallery-ad--left, .gallery-ad--right {
        display: block;
        top: 50%;
        width: 160px;
        height: 618px;
        transform: translateY(-50%);
    }
    .gallery-ad--left { left: 16px; }
    .gallery-ad--right { right: 16px; }
    .gallery-ad--left.is-filled { animation: gallery-ad-enter-left 250ms ease-out; }
    .gallery-ad--right.is-filled { animation: gallery-ad-enter-right 250ms ease-out; }
    .gallery-ad-filled-left .fancybox__nav .carousel__button.is-prev { left: 192px; }
    .gallery-ad-filled-right .fancybox__nav .carousel__button.is-next { right: 192px; }
}
@media (max-width: 1099px), (max-height: 799px) {
    .has-gallery-ads.gallery-ad-filled-top { padding-top: calc(126px + env(safe-area-inset-top, 0px)); }
    .gallery-ad--top { display: block; width: 320px; height: 68px; top: calc(52px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); }
}
@media (max-width: 1099px) and (min-height: 650px) {
    .has-gallery-ads.gallery-ad-filled-bottom { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
    .gallery-ad--bottom { display: block; width: 320px; height: 68px; bottom: calc(4px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); }
}
@media (max-width: 359px), (max-height: 399px) {
    .has-gallery-ads.gallery-ad-filled-top { padding-top: env(safe-area-inset-top, 0px); }
    .has-gallery-ads.gallery-ad-filled-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
    .gallery-ad { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-ad--left.is-filled, .gallery-ad--right.is-filled { animation: none; }
}

@keyframes gallery-ad-enter-left {
    from { transform: translate(calc(-100% - 16px), -50%); }
    to { transform: translate(0, -50%); }
}
@keyframes gallery-ad-enter-right {
    from { transform: translate(calc(100% + 16px), -50%); }
    to { transform: translate(0, -50%); }
}
