/* A printer's galley proof: warm paper, near-black ink, one proofreader's red. The text is set with
   line numbers, problems get proofreader's marks at the exact token, and the corrections sit in the
   margin, joined to their rows by thin leader lines over a faint drafting grid. DESIGN.md has the
   system. */
:root {
  --paper: #fbfaf5; --ink: #1a1916; --faint: #6b675e; --dim: #77736a; --pen: #c0251b;
  --rule: #dcd8cc; --rule-strong: #b7b2a4; --grid: #f0ede4; --tint: #f2efe5; --active: #f5e6d6;
  --select: #f1d6c6; --ground: var(--paper);
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "Liberation Mono", monospace;
  --size: 15px; --lh: 22px;
  /* The longest line of prose. The page's lines are one or two sentences, so this lets them stay on one
     line when there is room; a real paragraph still wraps near 150 characters. */
  --measure: 62rem;
  color-scheme: light;
}
/* The same proof under a desk lamp: warm dark paper, a pool of light at the top, the same roles. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1915; --ink: #ebe5d6; --faint: #a8a191; --dim: #8b8475; --pen: #ff8a73;
    --rule: #3a362d; --rule-strong: #575146; --grid: #221f1a; --tint: #26231d; --active: #3a2a22;
    --select: #5a3427; --ground: radial-gradient(120% 60% at 50% -12%, #27231b, var(--paper) 62%) var(--paper);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1915; --ink: #ebe5d6; --faint: #a8a191; --dim: #8b8475; --pen: #ff8a73;
  --rule: #3a362d; --rule-strong: #575146; --grid: #221f1a; --tint: #26231d; --active: #3a2a22;
  --select: #5a3427; --ground: radial-gradient(120% 60% at 50% -12%, #27231b, var(--paper) 62%) var(--paper);
  color-scheme: dark;
}
* { box-sizing: border-box; }
::selection { background: var(--select); color: var(--ink); }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--ground); color: var(--ink); font: 16px/1.5 var(--serif); }
main { flex: 1; }
a, .link { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code, kbd, pre { font-family: var(--mono); }
code { font-size: .875em; }
.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 48px); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
.theme:not([data-theme]) { visibility: hidden; }
button { font: inherit; color: inherit; }
/* A control that reads as part of the line it sits in. */
.link { padding: 0; background: none; border: 0; cursor: pointer; }
.link:hover:not(:disabled) { text-decoration-color: currentColor; }
.link:disabled { cursor: default; text-decoration: none; }
/* WCAG 2.2 target size (2.5.8): the text buttons are at least 24px high. */
.link { display: inline-block; min-height: 24px; line-height: 24px; }

/* The caption above the editor (what the text is) and the timing beside the verdict, in small mono,
   parts set off by middle dots (.slug-part: chrome.css). */
.caption { margin-block: 0; }
.caption #name { color: var(--ink); font-weight: 600; }
.note-faint { color: var(--faint); }
.speed { margin-block: 0; color: var(--ink); font: 13px/1.6 var(--mono); }
.speed em { font-style: normal; color: var(--pen); font-variant-numeric: tabular-nums; }
.speed .link, .speed a { color: var(--faint); }

/* The proof stages: the six dialects, each with its verdict on the text. */
main > h1 { margin: 22px 0 0; font-size: 1.25rem; font-weight: 600; line-height: 1.3; text-wrap: balance; }
.lede { margin-top: 6px; }
.stages-row { padding-block: 12px 0; }
.stages { display: flex; border: 1px solid var(--rule); }
.stages button { flex: 1 1 0; display: grid; align-content: start; gap: 1px; min-width: 7.5rem; min-height: 48px; padding: 6px 14px 7px 12px; text-align: left; background: none; border: 0; border-right: 1px solid var(--rule); border-radius: 0; cursor: pointer; color: var(--faint); }
.stages button:hover { background: var(--tint); color: var(--ink); }
.stages button[aria-checked="true"] { color: var(--ink); background: var(--tint); box-shadow: inset 0 -2px var(--ink); }
.stages button:focus-visible { outline-offset: -3px; }
.name { font-size: 1rem; line-height: 1.3; white-space: nowrap; }
.v { display: flex; flex-wrap: wrap; gap: 0 9px; min-height: 1.3em; font: 12.5px/1.4 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--pen); }
.v .ok, .v .none { color: var(--faint); }
.v .none { flex-basis: 100%; }
/* Severity as a printed shape, so it does not hang on colour: a square for an error, a triangle for
   a warning. */
.shape::before { content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .3em; background: currentColor; }
.warning.shape::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.hint { margin: 8px 0 0; max-width: var(--measure); text-wrap: pretty; color: var(--faint); font-size: 1rem; font-style: italic; line-height: 1.45; }
.hint code { font-style: normal; white-space: nowrap; }

/* Fix and Format: the proofreader's actions, in the slug's small mono, above the proof. */
.editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 32px; margin-top: 14px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px 32px; font: 13px/1.6 var(--mono); color: var(--faint); }
.samples { display: flex; flex-wrap: wrap; gap: 0 14px; margin: 6px 0 0; font: 13px/1.6 var(--mono); color: var(--faint); }
.tool { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.act { padding: 3px 12px; min-height: 32px; font: 600 13px/1.4 var(--mono); color: var(--ink); background: none; border: 1px solid var(--ink); border-radius: 0; cursor: pointer; }
.act:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--tint); }
.act:disabled, .act[aria-disabled="true"] { color: var(--faint); border-color: var(--rule-strong); cursor: default; }
/* Split button: the action, and beside it the part that opens the options. */
.split { display: inline-flex; }
.split .act + .act { margin-left: -1px; padding-inline: 8px; }
.opts .n:not(:empty) { margin-right: 4px; }
.opts .n:not(:empty)::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-right: 4px; background: var(--ink); border-radius: 50%; }
.split:has(+ .pop:popover-open) .opts { background: var(--tint); }
.act:focus-visible { position: relative; z-index: 1; }
/* The options popover: a few rows of label and control, then the real config for them. */
.pop { position: fixed; inset: auto; left: min(var(--x, 8px), calc(100vw - min(25rem, 100vw - 16px) - 8px)); top: var(--y, 8px); width: min(25rem, calc(100vw - 16px)); max-height: calc(100dvh - var(--y, 8px) - 8px); overflow: auto; margin: 0; padding: 12px 14px 10px; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 0; font: 13px/1.6 var(--mono); }
.pop::backdrop { background: none; }
.pop h2 { margin: 0 0 6px; font: 600 13px/1.6 var(--mono); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; border-top: 1px dashed var(--rule-strong); }
.lab { color: var(--faint); }
.seg { display: inline-flex; }
.seg button, .num { min-height: 32px; font: 13px/1.4 var(--mono); color: var(--faint); background: none; border: 1px solid var(--rule-strong); border-radius: 0; }
.seg button { padding: 3px 12px; min-width: 3.2rem; cursor: pointer; }
.seg button + button { margin-left: -1px; }
.seg button:hover { color: var(--ink); background: var(--tint); }
.seg button[aria-checked="true"] { color: var(--ink); background: var(--tint); border-color: var(--ink); box-shadow: inset 0 -2px var(--ink); position: relative; }
.seg button:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.num { width: 8ch; padding: 3px 6px; color: var(--ink); background: var(--paper); }
.num[aria-invalid="true"] { border-color: var(--pen); color: var(--pen); }
.conf { margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--rule); }
.conf-h { margin: 0; color: var(--faint); }
.conf-text { margin: 4px 0 4px; padding: 8px 10px; overflow-x: auto; white-space: pre; background: var(--tint); font-size: 13px; line-height: 1.55; scrollbar-color: var(--rule-strong) transparent; }
.conf-text.none { color: var(--faint); font-style: italic; }
/* The copy icon sits in the code block's top-right corner; the text keeps clear of it. */
.conf-code { position: relative; }
.conf-code .conf-text, .panel .conf-code pre { padding-right: 36px; }
.conf-copy { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; color: var(--faint); background: var(--tint); border: 0; cursor: pointer; }
.conf-copy:hover { color: var(--ink); }
.conf-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.conf-copy .i-done, .conf-copy.done .i-copy { display: none; }
.conf-copy.done .i-done { display: block; }

/* The proof: the set text on the left, the margin with the corrections on the right. */
/* A galley's measure: the text column stops after 80 characters and the margin takes the rest, so notes sit close to their lines. */
/* The text column is sized in ch of the editor's own font, so it shows 80 characters beside the gutter
   (a slot for a correction's number, up to three digits, and its padding) and the text's padding and
   scrollbar. The proof is set in the editor's font for that, and the margin sets its own back. Where
   the screen is narrower the column gives way and the text scrolls inside the editor. */
.proof { position: relative; display: grid; grid-template-columns: minmax(0, calc(80ch + 8ch + 32px)) minmax(18.5rem, 1fr); margin-top: 18px; font: var(--size)/var(--lh) var(--mono); }
.margin { font: 1rem/1.5 var(--serif); }
.proof.listed { grid-template-columns: minmax(0, 1fr); }
.editor { position: relative; display: flex; min-width: 0; height: 248px; border-right: 1px solid var(--rule); }
.proof.listed .editor { border-right: 0; }
.editor.drop { outline: 2px dashed var(--ink); outline-offset: 4px; }
.gutter, .layer, textarea { margin: 0; font: var(--size)/var(--lh) var(--mono); white-space: pre; tab-size: 4; }
.gutter { flex: none; padding: 8px 0 40px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; user-select: none; }
/* Inset, so the focus mark shows even when a big text hides the gutter, and the text never moves. */
.editor:focus-within { box-shadow: inset 2px 0 var(--ink); }
.gutter div { padding-inline: 0 14px; }
/* A slot for a correction's number on every row, so the text never moves when one comes or goes. */
.gutter div::before { content: ""; display: inline-block; width: 3.4ch; padding-right: .6ch; text-align: right; color: var(--pen); font-size: 12px; }
.gutter div[data-n]::before { content: attr(data-n); }
.text { position: relative; flex: 1; min-width: 0; }
.caret-measure { position: absolute; width: 0; height: 0; overflow: hidden; visibility: hidden; font: var(--size)/var(--lh) var(--mono); white-space: pre; tab-size: 4; }
.caret-measure span { display: inline-block; }
.layer, textarea { position: absolute; inset: 0; width: 100%; height: 100%; overflow: auto; }
.layer { padding: 8px 0 40px; color: transparent; pointer-events: none; overflow: hidden; forced-color-adjust: none; }
/* Room for the textarea's scrollbar, so the layers scroll as far as it does. */
.layer div { width: max-content; min-width: 100%; padding-inline: 6px 8px; }
.layer div, .gutter div { min-height: var(--lh); }
.layer div.active, .gutter div.active { background: var(--active); }
.gutter div.active { color: var(--faint); }
/* Proofreader's marks: a caret under the line where the token starts, the token struck out (or,
   where checking stopped, underlined), and the place a problem names, such as a first copy,
   ringed. */
.layer mark { position: relative; color: transparent; background: none; text-decoration-color: var(--pen); text-decoration-thickness: 1.5px; }
.layer mark:not(.rel)::before { content: "‸"; position: absolute; left: -.42ch; top: .05em; color: var(--pen); font: 700 16px/1 var(--mono); }
.layer mark.dele { text-decoration-line: line-through; }
.layer mark.at { text-decoration-line: underline; text-underline-offset: 3px; }
.layer mark.rel { border-radius: 45%; box-shadow: 0 0 0 1.5px var(--pen); }
/* A byte order mark has no width: a bar stands in for it. */
.layer mark.zero::after { content: ""; position: absolute; top: 2px; bottom: 2px; left: -1px; width: 3px; background: var(--pen); }
textarea, textarea:focus-visible { padding: 8px 8px 8px 6px; border: 0; resize: none; background: transparent; color: var(--ink); caret-color: var(--pen); outline: none; scrollbar-color: var(--rule-strong) transparent; }

/* The margin: a very faint drafting grid, and the corrections in italic red. */
.margin { position: relative; overflow: hidden; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: var(--lh) var(--lh); background-position: -1px -1px; }
.sheet { position: relative; }
.margin ol { margin: 0; padding: 0; list-style: none; }
.note { color: var(--pen); font: italic 16px/var(--lh) var(--serif); }
.proof:not(.listed) .note { position: absolute; left: 30px; right: 10px; padding: 0 4px; background: var(--paper); }
.note > button { all: unset; box-sizing: border-box; display: block; min-height: 24px; cursor: pointer; overflow-wrap: anywhere; }
.note button:hover .msg { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.note button:focus-visible { outline-offset: 2px; outline: 2px solid var(--ink); }
.note .msg code { font-style: normal; font-size: .82em; }
.note .n { display: none; }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; font: normal 12.5px/1.5 var(--mono); color: var(--faint); }
/* An item never breaks inside, so its own dot cannot be left behind on the line above. */
.meta > * { white-space: nowrap; }
.meta .rule { display: inline-block; padding-block: 3.5px; color: var(--faint); }
.meta .rule:hover { color: var(--ink); }
/* A correction with a fix: apply it from the margin. */
.meta .apply { padding: 3.5px 0; font: inherit; color: var(--ink); }
.meta .unsafe { color: var(--faint); }
.note.rel { pointer-events: none; }
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; fill: none; stroke: var(--pen); stroke-width: 1; stroke-opacity: .3; }
.leaders path.lit { stroke-width: 1.5; stroke-opacity: 1; }
.leaders marker path { fill: var(--pen); stroke: none; }

/* Too many corrections for the margin, or a narrow screen: a numbered list under the proof, keyed
   to the numbers in the gutter. */
.proof.listed .margin { overflow: visible; background: none; border-top: 1px solid var(--rule); margin-top: 6px; }
.proof.listed .note.rel { display: none; }
.proof.listed ol { padding-top: 6px; }
.proof.listed li { position: relative; padding: 5px 0 5px 4.4ch; }
.proof.listed .note .n { display: block; position: absolute; left: 0; width: 3.4ch; font: normal 12.5px/var(--lh) var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.more { padding: 5px 0 5px 4.4ch; color: var(--faint); font-style: italic; }

.verdict { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 20px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); }
#status { margin: 0; font-size: 1.125rem; }
#status b { color: var(--pen); font-weight: 700; }
#status.ok b { color: var(--ink); }
#status code { font-size: .82em; }
#verdict-problem { display: none; margin-top: 4px; text-align: start; overflow-wrap: anywhere; }
.scope { margin: 4px 0 0; color: var(--faint); font-size: .9375rem; }
#drop-error { color: var(--pen); overflow-wrap: anywhere; }
.aside { margin: 6px 0 0; max-width: var(--measure); text-wrap: pretty; color: var(--faint); font-size: 1rem; font-style: italic; }
.aside code, .aside kbd { font-style: normal; }
kbd { padding: 0 4px; font-size: .8em; border: 1px solid var(--rule-strong); border-bottom-width: 2px; }
.keys-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 32px; margin-top: 14px; }
#keys { margin: 6px 0 0; }
.note .why { margin: 0; font: normal 12.5px/1.45 var(--mono); color: var(--faint); }

/* Use this check: closed until asked for. */
.use { margin-top: 22px; }
.use > summary { display: inline-block; cursor: pointer; color: var(--ink); font-size: 1rem; }
.use > summary::before { content: "▸"; content: "▸" / ""; display: inline-block; width: 1.1em; color: var(--faint); font-size: .9em; }
.use[open] > summary::before { content: "▾"; content: "▾" / ""; }
.use > summary::-webkit-details-marker { display: none; }
.use summary:hover { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: .22em; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 12px; border-bottom: 1px solid var(--rule); }
.tabs button { padding: 4px 0 6px; background: none; border: 0; cursor: pointer; color: var(--faint); font-size: 1rem; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px var(--ink); }
.tabs button:focus-visible { outline-offset: -1px; }
.panel { max-width: 46rem; margin-top: 12px; }
.panel .aside { margin: 0 0 6px; }
.cli-edits { margin-top: 8px; }
.cli-edits summary { cursor: pointer; }
.cli-edits .conf-code + .conf-code { margin-top: 6px; }
.panel pre { margin: 0; padding: 10px 12px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; background: var(--tint); scrollbar-color: var(--rule-strong) transparent; }

.quiet { margin-block: 0 4px; color: var(--faint); font-size: .9375rem; font-style: italic; }

@media (max-width: 800px) {
  .stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stages button { min-width: 0; }
  .stages button:nth-child(3n) { border-right: 0; }
  .stages button:nth-child(n + 4) { border-top: 1px solid var(--rule); }
}
@media (max-width: 560px) {
  .stages button { padding-inline: 8px 6px; }
  .v { overflow-wrap: anywhere; white-space: normal; }
}
@media (width < 860px) {
  .verdict { margin-top: 8px; padding-top: 6px; }
  #verdict-problem { display: inline-block; }
  .keys-row { margin-top: 6px; }
  .proof { margin-top: 12px; }
}
@media (max-width: 560px) {
  .num { font-size: 16px; }
  /* A bottom sheet, so it cannot run off the screen. */
  .pop { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 80dvh; border-width: 1px 0 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  /* 16px, or iOS zooms in when the text area gets focus. */
  :root { --size: 16px; --lh: 22px; }
  .stages button { padding-inline: 8px; }
  .gutter div { padding-right: 8px; }
  .gutter div::before { width: 2.6ch; }
}
@media (forced-colors: active) {
  :root { --pen: Highlight; --ink: CanvasText; --faint: CanvasText; --dim: GrayText; --rule: GrayText; --active: Canvas; }
  .stages button[aria-checked="true"] { border-bottom: 2px solid CanvasText; }
  .tabs button[aria-selected="true"] { border-bottom: 2px solid CanvasText; }
  .margin .note { background: Canvas; }
  .act, .seg button, .num, .pop { border-color: CanvasText; }
  .seg button[aria-checked="true"] { border-bottom: 2px solid CanvasText; }
  .act:disabled, .act[aria-disabled="true"] { border-color: GrayText; color: GrayText; }
}
