/* Reserve the existing media width plus one control lane on each side. */
.image-inline-ad--affiliate:has(> .fanza-gallery) {
    width: min(100%, 808px, calc(100vw - 24px));
}
/* Inline media controls must stay independent of the affiliate link. */
.fanza-gallery {
    --fanza-arrow-width: 44px;
    width: 100%;
    margin: 12px 0;
    background: #000;
}
.fanza-gallery--single { --fanza-arrow-width: 0px; }
.fanza-gallery [hidden] { display: none !important; }
.fanza-gallery__stage {
    display: grid;
    grid-template-columns: var(--fanza-arrow-width) minmax(0, 1fr) var(--fanza-arrow-width);
    align-items: center;
    touch-action: pan-y pinch-zoom;
}
.fanza-gallery__viewport {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    /* Keep arrows and following content stationary when media proportions change. */
    aspect-ratio: 4 / 3;
    overflow: hidden;
}
.fanza-gallery__slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.fanza-gallery__slide > a {
    display: block;
    width: 100%;
    height: 100%;
}
.image-inline-ad .fanza-gallery__slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
}
.fanza-gallery__video {
    width: 100%;
    aspect-ratio: var(--fanza-video-ratio);
    overflow: hidden;
}
.fanza-gallery__video iframe {
    display: block;
    max-width: none;
    border: 0;
    transform-origin: top left;
}
.fanza-gallery__arrow {
    grid-row: 1;
    display: grid;
    place-items: center;
    width: var(--fanza-arrow-width);
    height: 52px;
    padding: 0;
    border: 0;
    margin: 0;
    background: #000;
    color: #fff;
    line-height: 1;
    cursor: pointer;
}
/* Symmetric vector bounds keep the chevrons centered regardless of font metrics. */
.fanza-gallery__arrow svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}
.fanza-gallery__arrow--previous { grid-column: 1; }
.fanza-gallery__arrow--next { grid-column: 3; }
.fanza-gallery__arrow:hover { background: #222; }
.fanza-gallery__counter {
    display: none;
    padding: 8px 0 4px;
    color: #fff;
    text-align: center;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}
.fanza-gallery__thumbs {
    position: relative;
    margin: 0 var(--fanza-arrow-width);
    display: flex;
    gap: 5px;
    padding: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    background: #333;
}
.fanza-gallery__thumb {
    position: relative;
    flex: 0 0 clamp(56px, 14%, 88px);
    height: 60px;
    padding: 2px;
    overflow: hidden;
    border: 3px solid transparent;
    background: #111;
    opacity: .5;
    cursor: pointer;
}
.fanza-gallery__thumb[aria-pressed="true"] { border-color: #fff; opacity: 1; }
.fanza-gallery__thumb:hover { opacity: 1; }
.image-inline-ad .fanza-gallery__thumb img { display: block; width: 100%; height: 100%; margin: 0; object-fit: contain; }
.fanza-gallery__thumb-play { position: absolute; inset: 0; display: grid; place-items: center; background: #0008; color: #fff; font-size: 24px; }
.fanza-gallery button:focus-visible,
.fanza-gallery__stage:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
@media (max-width: 768px) {
    /* Extend equally into the surrounding content gutter without including the
       browser scrollbar in the available width. */
    .image-inline-ad--affiliate:has(> .fanza-gallery) {
        width: calc(100% + 8px);
        margin-left: -4px;
        margin-right: -4px;
        padding-left: 6px;
        padding-right: 6px;
    }
    .fanza-gallery { --fanza-arrow-width: 28px; }
    .fanza-gallery__viewport { aspect-ratio: 1; }
    .fanza-gallery--single { --fanza-arrow-width: 0px; }
    .fanza-gallery__thumbs { display: none; }
    .fanza-gallery__counter { display: block; }
}
