/* Shared segmented control for gallery browsing, independent of tenant color. */
body.shop-ui main .shop-gallery-switch {
    display: flex; flex-wrap: nowrap; gap: 4px;
    width: fit-content; max-width: 100%; padding: 6px;
    border-radius: 14px; background: #f1f2f4;
}
body.shop-ui main .shop-gallery-switch > button {
    flex: 1 1 0; min-width: 0; min-height: 40px; padding: 7px 12px;
    border: 1px solid transparent; border-radius: 10px;
    background: transparent; color: #4b5563;
    font-size: 13px; font-weight: 600; line-height: 20px;
    text-align: center; white-space: normal; cursor: pointer;
}
body.shop-ui main .shop-gallery-switch > button.active {
    background: #fff; color: #202530; border-color: #d6d9df;
    box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}
body.shop-ui main .shop-gallery-switch > button:hover { color: #202530; }
body.shop-ui main .shop-gallery-switch > button:focus-visible {
    outline: 2px solid var(--tenant-primary-color, var(--bs-primary)); outline-offset: 2px;
}
@media (min-width: 768px) {
    body.shop-ui main .shop-gallery-switch > button { flex: 0 0 auto; white-space: nowrap; }
}
@media (max-width: 767px) {
    body.shop-ui main .shop-gallery-switch > button { display: flex; align-items: center; justify-content: center; gap: 5px; }
    body.shop-ui main .shop-gallery-switch-heart { font-size: 15px; line-height: 1; color: #6b7280; flex-shrink: 0; }
    body.shop-ui main .shop-gallery-switch { width: 100%; }
    body.shop-ui main .shop-gallery-switch > button { padding-inline: 6px; }
}
/* Keep favorite actions and download status badges in the same photo corner. */
#galleryGrid .gallery-fav-btn {
    top: auto;
    right: auto;
    bottom: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    background: rgb(255 255 255 / 95%);
    box-shadow: 0 1px 5px rgb(0 0 0 / 16%);
}

/* Keep a 44px hit area around the compact 28px button. */
#galleryGrid .gallery-fav-btn::before {
    content: '';
    position: absolute;
    inset: -8px;
    background: transparent;
}

/* Style the embedded document's scrollbar, not the surrounding shop page. */
.shop-gallery-embedded .gallery-photo-scroll {
    color-scheme: light;
    scrollbar-gutter: stable;
}
@media (forced-colors: none) {
    .shop-gallery-embedded .gallery-photo-scroll::-webkit-scrollbar { width: 12px; }
    .shop-gallery-embedded .gallery-photo-scroll::-webkit-scrollbar-track { background: var(--bs-white, white); }
    .shop-gallery-embedded .gallery-photo-scroll::-webkit-scrollbar-thumb {
        min-height: 44px;
        border: 3px solid var(--bs-white, white);
        border-radius: 999px;
        background: var(--bs-gray-500, #adb5bd);
        background-clip: padding-box;
    }
    .shop-gallery-embedded .gallery-photo-scroll::-webkit-scrollbar-thumb:hover {
        background-color: var(--bs-gray-600, #6c757d);
    }
    .shop-gallery-embedded .gallery-photo-scroll::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
    @supports not selector(::-webkit-scrollbar) {
        .shop-gallery-embedded .gallery-photo-scroll {
            scrollbar-width: thin;
            scrollbar-color: var(--bs-gray-500, #adb5bd) var(--bs-white, white);
        }
    }
}

/* Only the photos scroll inside the overlay; its toolbar stays in normal flow. */
html:has(.shop-gallery-embedded), body:has(.shop-gallery-embedded) { height: 100%; overflow: hidden; }
body.shop-ui main.shop-gallery-embedded { height: 100dvh; min-height: 0; flex: none !important; }
.shop-gallery-embedded > .container { height: 100%; }
.shop-gallery-embedded .shop-gallery-content { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.shop-gallery-embedded .gallery-tools { flex: 0 0 auto; }
.shop-gallery-embedded .gallery-photo-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }

.gallery-inline-viewer .gclose { display: none !important; }
.gallery-inline-viewer .download-viewer-header { padding-top: 64px; }
body .gallery-inline-viewer .gallery-viewer-back {
    position: absolute; top: 16px; left: 20px; z-index: 99999;
    pointer-events: auto; touch-action: manipulation;
    display: inline-flex; align-items: center; justify-content: center;
    width: auto; min-height: 44px; height: 44px; padding: 0 18px;
    border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
    background: rgba(255,255,255,.06); color: var(--bs-white, white);
    font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1;
    box-shadow: none; cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
}
body .gallery-inline-viewer .gallery-viewer-back:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.3); }
body .gallery-inline-viewer .gallery-viewer-back:focus:not(:focus-visible) { outline: none; }
body .gallery-inline-viewer .gallery-viewer-back:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { body .gallery-inline-viewer .gallery-viewer-back { transition: none; } }

.gallery-inline-viewer .download-viewer-header { top: 72px !important; padding-top: 0 !important; }

.gallery-standalone-return { flex: 0 0 auto; }
.gallery-standalone-return[hidden] { display: none !important; }

.shop-gallery-embedded .gallery-embedded-heading { grid-area: title; display: flex; align-items: center; gap: 12px; }
body.shop-ui main.shop-gallery-embedded .gallery-embedded-heading .gallery-embedded-title { margin: 0; font-size: 30px !important; }
.shop-gallery-embedded .gallery-standalone-return { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--bs-border-color); border-radius: 50%; background: var(--bs-gray-100); color: var(--bs-gray-700); text-decoration: none; }
.shop-gallery-embedded .gallery-standalone-return:hover { background: var(--bs-gray-200); color: var(--bs-gray-900); }
.shop-gallery-embedded .gallery-standalone-return:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 3px; }
@media (max-width: 575.98px) {
    body.shop-ui main.shop-gallery-embedded .gallery-embedded-heading .gallery-embedded-title { font-size: 26px !important; }
}

/* Read-only favorite status shared by product thumbnails and large previews. */
body.shop-ui .shop-favorite-indicator {
    position: absolute; bottom: 8px; left: 8px; z-index: 5;
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 5px;
    background: rgb(255 255 255 / 55%); color: #e74c3c;
    box-shadow: 0 1px 5px rgb(0 0 0 / 12%); font-size: 16px; pointer-events: none;
}
body.shop-ui .shop-favorite-indicator[hidden] { display: none !important; }
