.sbm-gallery {
    position: relative;
    isolation: isolate;
    width: 100%;
    min-width: 0;
}

.sbm-gallery__stage {
    position: relative;
}

.sbm-gallery__image {
    display: block;
    width: 100%;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
}

.sbm-gallery--card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sbm-gallery--card .sbm-gallery__stage {
    flex: 1 1 0;
    min-height: 0;
}

.sbm-gallery--card .sbm-gallery__image {
    height: 100%;
}

.sbm-gallery__controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sbm-gallery__controls button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line, #e5e5e5);
    border-radius: 50%;
    color: var(--ink, #373a36);
    background: #fff;
    box-shadow: 0 1px 6px #0002;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
}

.sbm-gallery__controls [data-sbm-gallery-step="-1"] { left: 6px; }
.sbm-gallery__controls [data-sbm-gallery-step="1"] { right: 6px; }

.sbm-gallery__controls button:hover {
    background: var(--soft, #f5f5f5);
}

.sbm-gallery__controls button:focus-visible,
.sbm-gallery__selectors button:focus-visible {
    outline: 2px solid var(--sbm-brand-blue, #3186b6);
    outline-offset: -2px;
}

.sbm-gallery__selectors {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.sbm-gallery__selectors[hidden] {
    display: none;
}

.sbm-gallery__selectors button {
    display: grid;
    place-items: center;
    padding: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
}

.sbm-gallery__selectors--strips {
    flex: none;
    gap: 4px;
    padding-inline: 4px;
}

.sbm-gallery__selectors--strips button {
    flex: 1 0 24px;
    min-width: 0;
    min-height: 28px;
    border: 0;
    border-radius: 4px;
}

.sbm-gallery__selectors--strips span {
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: #d4d6d6;
}

.sbm-gallery__selectors--strips [aria-pressed="true"] span {
    background: var(--ink, #373a36);
}

.sbm-gallery__selectors--thumbs {
    gap: 8px;
    margin-top: 8px;
    padding: 2px;
}

.sbm-gallery__selectors--thumbs button {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    padding: 3px;
    border: 1px solid var(--line, #e5e5e5);
    border-radius: 6px;
    box-sizing: border-box;
    overflow: hidden;
}

.sbm-gallery__selectors--thumbs [aria-pressed="true"] {
    border-color: var(--ink, #373a36);
    box-shadow: inset 0 0 0 1px var(--ink, #373a36);
}

.sbmpp-page .sbmpp-buying .card .pic .sbm-gallery__selectors--thumbs img,
.sbmpp-page .sbmpp-unavailable-photo .sbm-gallery__selectors--thumbs img {
    display: block;
    width: 48px;
    height: 48px;
    max-width: none;
    max-height: none;
    margin: 0;
    object-fit: contain;
}

@media (hover: hover) and (pointer: fine) {
    .sbm-gallery__controls button { opacity: 0; }

    .sbm-gallery[data-sbm-gallery-edge="-1"] [data-sbm-gallery-step="-1"],
    .sbm-gallery[data-sbm-gallery-edge="1"] [data-sbm-gallery-step="1"],
    .sbm-gallery__controls button:hover,
    .sbm-gallery__controls button:focus-visible { opacity: 1; }

    .sbm-gallery__selectors--strips [aria-pressed="false"]:hover span { background: #969a9a; }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .sbm-gallery__controls button { transition: opacity 140ms ease-out; }
    .sbm-gallery:not(.sbm-gallery--card) .sbm-gallery__image img { transition: transform 160ms ease-out; }
    .sbm-gallery:not(.sbm-gallery--card)[data-sbm-gallery-edge="-1"] .sbm-gallery__image img { transform: translateX(8px); }
    .sbm-gallery:not(.sbm-gallery--card)[data-sbm-gallery-edge="1"] .sbm-gallery__image img { transform: translateX(-8px); }
}

.coffee-dialog .sbm-gallery--preview {
    float: left;
    width: 260px;
    margin: 0 25px 20px 0;
}

.coffee-dialog .dialog-close { z-index: 1; }

.coffee-dialog .sbm-gallery--preview .detail-photo {
    float: none;
    width: 100%;
    margin: 0;
}

.sbm-gallery--detail .sbm-gallery__image {
    height: clamp(260px, 34vw, 520px);
}

.sbm-gallery--unavailable .sbm-gallery__image {
    aspect-ratio: 4 / 3;
    max-height: 480px;
}

.sbmpp-page .sbmpp-buying .card .pic .sbm-gallery--detail .sbm-gallery__image img,
.sbmpp-page .sbmpp-unavailable-photo .sbm-gallery--unavailable .sbm-gallery__image img {
    height: 100%;
    object-fit: contain;
}

@media (max-width: 600px) {
    .sbm-gallery__selectors--strips button { min-height: 34px; }

    .coffee-dialog .sbm-gallery--preview {
        float: none;
        width: 100%;
        margin: 0 0 20px;
    }
}
