:root { color-scheme: light dark; --paper: #fff; --ink: #303532; --quiet: #61675d; --line: #d9dcd4; --accent: #315543; --chrome: 54px; background: var(--paper); color: var(--ink); font: 18px/1.5 Georgia, "Times New Roman", serif; }
* { box-sizing: border-box; }
/* The preview summary changes the bar's height. The writer restores scroll explicitly on Back; browser scroll
 * anchoring must not add that height difference to the restored position. CodeMirror still scrolls the caret. */
body { margin: 0; overflow-anchor: none; }
[hidden] { display: none !important; }
/* The topbar: the essay's title over a preview summary or actionable status, the controls at the right. It stays put while the sheet scrolls; problems sit under it. The chrome is assembled by src/editing/layout.ts from the shared template's nodes. */
.toolbar { position: sticky; top: 0; z-index: 4; background: var(--paper); font: .8rem/1.3 system-ui, sans-serif; }
.bar { display: flex; align-items: center; gap: 16px; padding: 9px 22px; min-height: 54px; }
.document { flex: 1; min-width: 0; }
.title { margin: 0; font: 600 .82rem/1.3 system-ui, sans-serif; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state { display: flex; min-width: 0; margin: 0; font-size: .72rem; line-height: 1.4; color: var(--quiet); white-space: nowrap; }
#save-status { flex: none; }
#preview-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#save-status:not([hidden]) + #preview-summary::before { content: "·"; padding: 0 .35em; }
.actions { display: flex; gap: 4px; flex: none; }
button { -webkit-user-select: none; user-select: none; font: .8rem/1.3 system-ui, sans-serif; color: var(--quiet); background: transparent; border: 1px solid transparent; padding: 7px 11px; cursor: pointer; border-radius: 4px; }
button:hover { color: var(--ink); background: color-mix(in srgb, var(--quiet) 8%, var(--paper)); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, .popover:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.alerts { padding: 0 22px; font-size: .85rem; line-height: 1.6; overflow-wrap: anywhere; }
.problem { color: #a14332; margin: 0; padding: 6px 0 12px; }
.notice { color: var(--quiet); margin: 0; padding: 6px 0 12px; }
#recovery-actions { padding: 0 0 12px; }
/* The sheet. */
main { max-width: 740px; margin: 44px auto 150px; padding: 0 28px; }
.cm-editor { background: transparent; min-height: 55vh; }
.cm-editor.cm-focused { outline: none; }
.cm-editor .cm-scroller { font: 1.1rem/1.8 Georgia, "Times New Roman", serif; overflow: visible; }
.cm-editor .cm-content { padding: 0; caret-color: #21abcd; }
.cm-editor .cm-line { padding: 0; }
.cm-editor .cm-placeholder { color: var(--quiet); font-style: italic; }
.cm-editor .cm-cursor { border-left-color: #21abcd; }
#editor .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 13%, transparent); } /* Scoped by id so it outranks CodeMirror's own six-class focused-selection rule (its default lavender left light text on a light tint in the dark scheme). The tint is lighter here than in the dark scheme below: composited over this near-white paper, 25% of the dark accent measured 3.77:1 for the quiet colour of markers and addresses inside a selection; 13% keeps them at about 4.6:1 and prose at about 12:1. A stronger band would push the quiet colour under 4.5:1 again, so this is a measured compromise, not a design choice. */
.cm-editor .cm-selectionMatch { background: transparent; }
/* The writing surface: Markdown shown as the page it will become. The classes come from src/editing/writing-surface.ts; every visual choice below is provisional and reversible. */
.cm-editor .cm-line.tg-heading-line { line-height: 1.25; padding-top: .35em; padding-bottom: .1em; }
.cm-editor .cm-line.tg-heading-1 { font-size: 1.8em; letter-spacing: -.02em; }
.cm-editor .cm-line.tg-heading-2 { font-size: 1.4em; letter-spacing: -.01em; }
.cm-editor .cm-line.tg-heading-3 { font-size: 1.18em; }
.cm-editor .tg-heading, .cm-editor .tg-strong { font-weight: 600; }
.cm-editor .tg-emphasis { font-style: italic; }
.cm-editor .tg-marker, .cm-editor .tg-url { color: var(--quiet); }
.cm-editor .cm-line.tg-fence, .cm-editor .cm-line.tg-fence .tg-marker { color: color-mix(in srgb, var(--quiet) 70%, var(--ink)); } /* A fence line, its ``` marks and its language label sit on the code block's own tint, where the quiet colour measured 4.20:1 light / 4.11:1 dark once that tint lay over a selection (about 5.1:1 / 7.2:1 on the tint alone). Mixed 30% toward the ink they measure 5.62:1 / 4.90:1 selected and 6.83:1 / 8.61:1 unselected, still quieter than the code; the surface harness asserts at least 4.5:1 for each of them in both schemes. Every other marker and address keeps the quiet colour. */
.cm-editor .tg-url { overflow-wrap: anywhere; }
.cm-editor .tg-mono, .cm-editor .tg-code, .cm-editor .cm-line.tg-code-block { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; }
.cm-editor .tg-code { background: color-mix(in srgb, var(--quiet) 12%, transparent); border-radius: 3px; padding: .04em .28em; }
.cm-editor .cm-line.tg-code-block { background: color-mix(in srgb, var(--quiet) 8%, transparent); padding: 0 .75em; line-height: 1.65; }
.cm-editor .tg-link { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--quiet) 60%, transparent); text-underline-offset: .15em; }
.cm-editor .cm-line.tg-quote { border-left: 2px solid var(--line); padding-left: 1em; }
.cm-editor .cm-line.tg-list-item { padding-left: 1.4em; text-indent: -1.4em; } /* The list marker itself stays as quiet text (tg-marker); a drawn bullet is deferred. */
/* The preview: the built pages alone, below the topbar, over the whole page; the sheet stays in place underneath, unseen, so Back finds it as it was. */
#edition-preview { position: fixed; top: var(--chrome); left: 0; right: 0; bottom: 0; z-index: 3; background: var(--paper); }
#edition-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--paper); }
html.previewing { overflow: hidden; }
html.previewing main { visibility: hidden; }
/* Compact document Info, anchored to its quiet control. */
.document-tools { display: flex; align-items: center; border: 1px solid color-mix(in srgb, var(--quiet) 15%, var(--paper)); border-radius: 22px; padding: 1px 4px; background: color-mix(in srgb, var(--quiet) 3%, var(--paper)); }
.document-tools button { padding: 5px 8px; border-radius: 16px; height: 32px; }
button svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
button[aria-expanded="true"] { color: var(--ink); background: color-mix(in srgb, var(--quiet) 10%, var(--paper)); }
.popover { position: fixed; right: 22px; top: calc(var(--chrome) + 6px); z-index: 5; width: min(300px, calc(100vw - 24px)); border: 1px solid color-mix(in srgb, var(--quiet) 28%, var(--paper)); border-radius: 18px; background: var(--paper); box-shadow: 0 5px 18px #0002, 0 1px 3px #0001; padding: 12px 20px 18px; font: 13px/1.45 system-ui, sans-serif; }
.popover::before { content: ""; position: absolute; right: 18px; top: -7px; width: 12px; height: 12px; transform: rotate(45deg); background: var(--paper); border-top: 1px solid color-mix(in srgb, var(--quiet) 28%, var(--paper)); border-left: 1px solid color-mix(in srgb, var(--quiet) 28%, var(--paper)); }
.document-info { display: flex; flex-direction: column; max-height: calc(100dvh - var(--chrome) - 24px); }
.document-info::before { right: 16px; }
.document-info > .popover-head, .document-info > .info-tabs { flex: none; }
#info-statistics { min-height: 0; overflow: auto; }
.popover-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 25px; margin-bottom: 10px; }
.popover-head h2 { margin: 0; color: var(--quiet); font: 600 13px/1.4 system-ui, sans-serif; }
.popover-head > button { position: absolute; right: -12px; top: -4px; padding: 6px; }
.popover-head > button svg { width: 13px; height: 13px; }
.info-tabs { display: flex; border-radius: 6px; background: color-mix(in srgb, var(--quiet) 7%, var(--paper)); margin-bottom: 18px; padding: 1px; }
.info-tabs button { flex: 1; display: flex; justify-content: center; padding: 3px; border-radius: 5px; }
.info-tabs button[aria-selected="true"] { background: var(--paper); border-color: color-mix(in srgb, var(--quiet) 16%, var(--paper)); box-shadow: 0 1px 2px #0001; }
.info-tabs svg { width: 16px; height: 16px; }
.count-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.count-card { border-radius: 11px; background: color-mix(in srgb, var(--quiet) 7%, var(--paper)); padding: 12px; min-width: 0; }
.count-card > span { display: flex; flex-direction: column; gap: 15px; }
.count-card strong { color: var(--ink); font-size: 22px; line-height: 1.2; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.count-card span span { font-size: 11px; color: var(--quiet); text-transform: capitalize; }
.count-note { margin: 12px 0 0; font-size: 10px; color: var(--quiet); }
#info-outline { min-height: 0; max-height: min(65vh, 620px); overflow: auto; overscroll-behavior: contain; margin: -2px -5px -4px; padding: 0 5px; }
#info-outline ol { list-style: none; padding: 0; margin: 0; }
#info-outline ol ol { padding-left: 15px; }
.outline-row { display: flex; position: relative; border-bottom: 1px solid color-mix(in srgb, var(--quiet) 12%, var(--paper)); padding-left: 14px; }
.outline-row .outline-heading { text-align: left; width: 100%; border: 0; border-radius: 3px; padding: 7px 3px; font: 400 13px/1.35 system-ui, sans-serif; overflow-wrap: anywhere; }
.outline-heading[data-depth="1"] { font-weight: 650; color: var(--ink); }
.outline-heading[data-depth="2"] { font-weight: 500; color: var(--ink); }
.outline-row .outline-fold { background: transparent; border: 0; position: absolute; left: -4px; top: 4px; padding: 2px; width: 18px; font-size: 15px; }
.outline-fold[aria-expanded="false"] { transform: rotate(-90deg); background: transparent; }
.outline-empty { color: var(--quiet); margin: 12px 0; }
@media (prefers-color-scheme: dark) { :root { --paper: #181c19; --ink: #e9ece6; --quiet: #afb7ac; --line: #3c443b; --accent: #a8c6ae; } #editor .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 25%, transparent); } /* Measured over the dark paper: quiet markers 4.74:1, prose 8.19:1. */ }
@media (max-width: 600px) { .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 8px 14px; gap: 2px 10px; } .document { display: contents; } .title { grid-column: 1; grid-row: 1; } .actions { grid-column: 2; grid-row: 1; } .state { grid-column: 1 / -1; grid-row: 2; } .alerts { padding: 0 14px; } main { margin-top: 28px; padding: 0 22px; } .popover { right: 12px; } .document-tools button { padding-left: 6px; padding-right: 6px; } }
