.sh2-gallery {
    width: min(1100px, calc(100% - 32px));
    height: min(860px, calc(100vh - 32px));
    height: min(860px, calc(100dvh - 32px));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    color: var(--sh2-ink, #211914);
    background: var(--sh2-paper, #fbf6ed);
    border: 1px solid var(--sh2-line, #cbb9a2);
    box-shadow: 0 24px 80px rgba(33, 25, 20, .3);
    font-family: var(--sh2-sans, Arial, sans-serif);
}
.sh2-gallery:not([open]) { display: none; }
.sh2-gallery[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.sh2-gallery::backdrop { background: rgba(22, 14, 10, .78); }
.sh2-gallery [hidden] { display: none !important; }
.sh2-gallery > header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sh2-line, #cbb9a2);
}
.sh2-gallery #sh2-gallery-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    color: var(--sh2-ink, #211914);
    font: 500 clamp(24px, 3vw, 36px)/1.1 var(--sh2-serif, Georgia, serif);
    overflow-wrap: anywhere;
}
.sh2-gallery [data-sh2-gallery-count] {
    flex: none;
    color: var(--sh2-muted, #6f6257);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.sh2-gallery button {
    display: grid;
    place-items: center;
    flex: none;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    color: var(--sh2-red, #8d1815);
    background: var(--sh2-paper, #fbf6ed);
    border: 1px solid var(--sh2-line, #cbb9a2);
    border-radius: 0;
    box-shadow: none;
    font: 400 26px/1 var(--sh2-sans, Arial, sans-serif);
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
/* The page resets button fonts/colors with a more specific body selector. */
body.sh2-page .sh2-gallery button {
    color: var(--sh2-red, #8d1815);
    font: 400 26px/1 var(--sh2-sans, Arial, sans-serif);
}
.sh2-gallery button:hover { background: var(--sh2-cream, #f4eadb); border-color: var(--sh2-red, #8d1815); }
.sh2-gallery button:focus-visible { outline: 3px solid var(--sh2-red, #8d1815); outline-offset: 3px; }
.sh2-gallery-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    overflow: hidden;
    background: var(--sh2-ink, #211914);
    touch-action: pan-y pinch-zoom;
}
.sh2-gallery-stage > [data-sh2-gallery-image] {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    object-fit: contain;
}
.sh2-gallery [data-sh2-gallery-status] {
    max-width: 520px;
    margin: 0;
    padding: 28px 72px;
    color: var(--sh2-paper, #fbf6ed);
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}
.sh2-gallery [data-sh2-gallery-prev],
.sh2-gallery [data-sh2-gallery-next] {
    position: absolute;
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
}
.sh2-gallery [data-sh2-gallery-prev] { left: 14px; }
.sh2-gallery [data-sh2-gallery-next] { right: 14px; }
.sh2-gallery-stage button:focus-visible { outline-color: var(--sh2-paper, #fbf6ed); }
.sh2-gallery-thumbs {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 14px 20px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--sh2-gold, #9c673e) var(--sh2-cream, #f4eadb);
}
.sh2-gallery-thumbs button {
    width: 84px;
    height: 68px;
    padding: 2px;
    border-width: 2px;
    border-color: transparent;
}
.sh2-gallery-thumbs button[aria-current="true"] { border-color: var(--sh2-red, #8d1815); }
.sh2-gallery-thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 600px) {
    .sh2-gallery {
        width: calc(100% - 16px);
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
    }
    .sh2-gallery > header { gap: 10px; padding: 12px; }
    .sh2-gallery [data-sh2-gallery-prev], .sh2-gallery [data-sh2-gallery-next] { width: 44px; height: 44px; }
    .sh2-gallery [data-sh2-gallery-prev] { left: 8px; }
    .sh2-gallery [data-sh2-gallery-next] { right: 8px; }
    .sh2-gallery [data-sh2-gallery-status] { padding-inline: 60px; font-size: 14px; }
    .sh2-gallery-thumbs { gap: 10px; padding: 12px; }
    .sh2-gallery-thumbs button { width: 72px; height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
    .sh2-gallery button { transition: none; }
    .sh2-gallery-thumbs { scroll-behavior: auto; }
}
