.stage-document-active > .visual-canvas,
.stage-document-active > .stage-help,
.stage-document-active > .pane-header > .template-selector,
.stage-document[hidden] {
    display: none;
}

.stage-document {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    color: var(--text-main);
}

.stage-document-toolbar {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    padding: 0.65em 1em;
    border-bottom: 1px solid var(--border-color);
}

.stage-document-toolbar button {
    padding: 0.3em 0.75em;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-editor);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.stage-document-toolbar button[aria-pressed="true"] {
    border-color: currentColor;
    font-weight: 600;
}

.stage-document-body {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.stage-document-body textarea {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 100%;
    padding: 1em;
    resize: none;
    border: 0;
    color: inherit;
    background: var(--bg-editor);
    font: 1em/1.55 ui-monospace, monospace;
}

.stage-document-preview {
    max-width: 75ch;
    margin: auto;
    padding: 1em 1.5em;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.stage-diagram {
    max-width: none;
    text-align: center;
    white-space: pre-wrap;
}

.stage-image {
    max-width: none;
    text-align: center;
}

.stage-document-preview img {
    max-width: 100%;
    height: auto;
}

.stage-document-preview pre {
    overflow: auto;
    padding: 0.75em;
    background: var(--bg-editor);
}

.stage-document-preview th,
.stage-document-preview td {
    padding: 0.25em 0.6em;
    border: 1px solid var(--border-color);
}
