.gallery-viewer {
    position: fixed;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #071b19;
    color: #fff;
}

.gallery-viewer[open] {
    display: flex;
    flex-direction: column;
}

.gallery-viewer::backdrop {
    background: rgb(0 0 0 / 92%);
}

.gallery-viewer__toolbar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left));
}

.gallery-viewer__navigation {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.gallery-viewer__button {
    display: inline-flex;
    min-width: 2.75rem;
    min-height: 2.75rem;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem;
    border: 1px solid rgb(255 255 255 / 45%);
    border-radius: 9999px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.gallery-viewer__button:hover:not(:disabled),
.gallery-viewer__button:focus-visible {
    background: rgb(255 255 255 / 16%);
}

.gallery-viewer__button:focus-visible {
    outline: 3px solid #b7ec4d;
    outline-offset: 3px;
}

.gallery-viewer__button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.gallery-viewer__button svg {
    width: 1.25rem;
    height: 1.25rem;
}

.gallery-viewer__count {
    min-width: 4.5rem;
    margin: 0 0 0 .5rem;
    color: rgb(255 255 255 / 82%);
    font-size: .875rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.gallery-viewer__figure {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin: 0;
    padding: 0 1rem 1rem;
}

.gallery-viewer__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 9rem);
    max-height: calc(100dvh - 9rem);
    object-fit: contain;
}

@media (max-width: 40rem) {
    .gallery-viewer__toolbar {
        padding-top: max(.75rem, env(safe-area-inset-top));
    }

    .gallery-viewer__figure {
        padding: 0 .5rem max(.75rem, env(safe-area-inset-bottom));
    }

    .gallery-viewer__image {
        max-height: calc(100vh - 8rem);
        max-height: calc(100dvh - 8rem);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .gallery-viewer__image {
        animation: gallery-image-enter 160ms ease-out;
    }

    @keyframes gallery-image-enter {
        from { opacity: 0; transform: scale(.985); }
        to { opacity: 1; transform: scale(1); }
    }
}