#image-gallery {
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    width: min(60rem, calc(100% - 1.5rem));
    max-height: calc(100% - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    margin: auto;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
    color: #f8fafc;
    background: #171d29;
    border: 1px solid #495569;
    border-radius: 1rem;
    box-shadow: 0 1.25rem 4rem #0009;
    font: 1rem/1.45 system-ui, sans-serif;
}

#image-gallery::backdrop {
    background: #080b12e8;
}

html:has(#image-gallery[open]) {
    overflow: hidden;
}

#image-gallery .gallery-bar,
#image-gallery .gallery-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

#image-gallery .gallery-bar,
#image-gallery .gallery-footer {
    padding: .625rem clamp(.625rem, 3vw, 1.25rem);
}

#image-gallery #gallery-title {
    margin: 0;
    color: inherit;
    font: 600 1rem/1.4 system-ui, sans-serif;
}

#image-gallery .gallery-stage {
    display: grid;
    place-items: center;
    height: min(65vh, 42rem);
    height: clamp(8rem, calc(100dvh - 16rem), 42rem);
    background: #080b12;
}

#image-gallery .gallery-image {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
}

#image-gallery .gallery-caption {
    max-height: 5em;
    overflow: auto;
    overflow-wrap: anywhere;
    margin: 0 0 .25rem;
    white-space: pre-line;
}

#image-gallery .gallery-links {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-bottom: .5rem;
}

#image-gallery .gallery-links a {
    color: #c3dbff;
    text-decoration: underline;
}

#image-gallery .gallery-count {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#image-gallery button {
    min-height: 2.75rem;
    padding: .4rem .65rem;
    color: inherit;
    background: #303e54;
    border: 1px solid #65748c;
    border-radius: .65rem;
    font: inherit;
    cursor: pointer;
}

#image-gallery button:not([aria-disabled="true"]):hover {
    background: #435673;
}

#image-gallery button[aria-disabled="true"] {
    opacity: .5;
    cursor: default;
}

#image-gallery .gallery-close {
    min-width: 2.75rem;
    font-size: 1.5rem;
    line-height: 1;
}

#image-gallery :focus-visible {
    outline: 2px solid #c3dbff;
    outline-offset: 2px;
}
