.cbv-gallery {
    display: grid;
    grid-template-columns: repeat(var(--cbv-columns, 3), minmax(0, 1fr));
    gap: 1rem;
    margin-block: 1.25rem;
}

.cbv-gallery .cbv-item {
    min-width: 0;
    margin: 0;
}

.cbv-gallery .cbv-item img {
    display: block;
    max-width: 100%;
    height: auto;
}

.cbv-item figcaption {
    margin-top: .4rem;
    overflow-wrap: anywhere;
}

.cbv-enlarge {
    display: block;
    margin-block: .25rem .5rem;
    min-height: 2rem;
    cursor: pointer;
}

.cbv-dialog {
    box-sizing: border-box;
    width: min(72rem, calc(100% - 1rem));
    max-height: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
    margin: auto;
    padding: .75rem;
    overflow: auto;
    border: 1px solid #65786a;
    border-radius: .75rem;
    background: #141c17;
    color: #fff;
    font: 1rem/1.45 system-ui, sans-serif;
}

.cbv-dialog::backdrop {
    background: rgb(0 0 0 / 80%);
}

html:has(.cbv-dialog[open]) {
    overflow: hidden;
}

.cbv-toolbar,
.cbv-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

.cbv-dialog .cbv-stage {
    margin: .75rem 0;
    text-align: center;
}

.cbv-dialog .cbv-image {
    display: block;
    max-width: 100%;
    max-height: min(72vh, 50rem);
    max-height: min(72dvh, 50rem);
    width: auto;
    height: auto;
    margin: auto;
    object-fit: contain;
}

.cbv-caption {
    margin-top: .5rem;
    overflow-wrap: anywhere;
}

.cbv-dialog button,
.cbv-dialog .cbv-source {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: .4rem .65rem;
    border: 1px solid #879d90;
    border-radius: .35rem;
    background: #26392e;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.cbv-dialog [hidden] {
    display: none;
}

.cbv-dialog :focus-visible,
.cbv-enlarge:focus-visible {
    outline: 3px solid #79bf84;
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .cbv-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
