/* Keep the page's scrollbar space while locking its root scroller; body overflow would reflow the article. */
html.diagram-viewer-is-open {
    overflow: hidden;
    overflow-anchor: none;
    scrollbar-gutter: stable;
}

.diagram-viewer {
    box-sizing: border-box;
    width: min(96vw, 1500px);
    max-width: none;
    height: min(94dvh, 1000px);
    max-height: none;
    padding: 1rem;
    border: 1px solid #554d43;
    background: #fffdf8;
    color: #24211d;
}

.diagram-viewer:not([open]) {
    display: none;
}

.diagram-viewer[open] {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.diagram-viewer::backdrop {
    background: rgb(0 0 0 / 75%);
}

.diagram-viewer__header,
.diagram-viewer__controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .6rem;
}

.diagram-viewer__header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.15rem;
}

.diagram-viewer p {
    margin: 0;
    font-size: .9rem;
}

.diagram-viewer button,
.diagram-viewer__controls a {
    min-height: 44px;
    padding: .5rem .85rem;
    border: 1px solid #554d43;
    background: #fff;
    color: #24211d;
    font: inherit;
    cursor: pointer;
}

.diagram-viewer :focus-visible {
    outline: 3px solid #1262ad;
    outline-offset: 2px;
}

.diagram-viewer__viewport {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: #e7e5df;
    touch-action: none;
    cursor: grab;
    overscroll-behavior: contain;
}

.diagram-viewer__viewport.is-dragging {
    cursor: grabbing;
}

.diagram-viewer__viewport img {
    display: block;
    max-width: none;
    height: auto;
    margin: 0 auto;
    user-select: none;
}
