/* The page fills the window: toolbar at the top, source and rendered notation side by side, status at the bottom. */
:root {
    --highlight: light-dark(#2563eb, #60a5fa);
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    margin: 0;
}

body > nav { flex: none; padding-inline: var(--space-6); }

main {
    flex: 1;
    min-height: 20rem;
    display: flex;
    flex-direction: column;
    padding: var(--space-4) var(--space-6);
}

/* --- Toolbar */

.toolbar { margin-bottom: var(--space-4); }
.toolbar menu.buttons { margin: 0; }
.toolbar menu.buttons button { width: 2.25rem; height: 2.25rem; }

.toolbar svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Source and preview, one half each */

.panels {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.panels > section { min-width: 0; min-height: 0; margin: 0; padding: 0; }

@media (max-width: 48rem) {
    .panels { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* The notation is drawn in black, so it always sits on white, like a page. */
.preview {
    height: 100%;
    padding: var(--space-4);
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
}

/* Shown at its natural size until it's too wide for the panel, then scaled down to fit. */
.preview img { display: block; max-width: 100%; height: auto; }
.preview.stale img { opacity: 0.4; }
.preview img[hidden] { display: none; }

/* --- CodeMirror, themed to match Oat */

.CodeMirror {
    height: 100%;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
}

.CodeMirror-focused { border-color: var(--ring); }

.CodeMirror-gutters {
    background: var(--faint);
    border-right: 1px solid var(--border);
}

.CodeMirror-linenumber { color: var(--muted-foreground); }
.CodeMirror-cursor { border-left-color: var(--foreground); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: color-mix(in srgb, var(--highlight) 25%, transparent); }
.CodeMirror .error-line { background: color-mix(in srgb, var(--danger) 15%, transparent); }

/* --- Status */

#message {
    margin: var(--space-3) 0 0;
    min-height: 1.4em;
    font-size: 0.85rem;
    text-align: right;
    color: var(--muted-foreground);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#message.error { color: var(--danger); }
