#proofreader { --accent: #f4c887; }
.proof-tools { margin-bottom: .65rem; }
.proof-tools [aria-pressed="true"] { border-color: var(--accent); }
.proof-tools [hidden] { display: none; }
.proof-tools .hint { flex-basis: 100%; min-height: 1.4em; }
.proof-paper {
  --proof-ink: #842841;
  background: #f2e7d3;
  color: #29221f;
  border: 1px solid #d6c1a2;
  border-radius: .5rem;
  padding: clamp(1rem, 4vw, 2.2rem);
  max-width: 68ch;
  font: clamp(1.12rem, 2.4vw, 1.3rem)/1.95 Georgia, serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.proof-paper .proof-word,
.proof-paper .proof-note {
  display: inline;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: .12em;
  background: transparent;
  font: inherit;
  color: inherit;
  vertical-align: baseline;
  max-width: 100%;
  overflow-wrap: anywhere;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.proof-paper .proof-word:hover { background: #e6d0ae; }
.proof-paper .proof-word[aria-pressed="true"] { background: #f3cc79; }
.proof-paper .proof-marked {
  text-decoration: underline wavy var(--proof-ink) 1px;
  text-underline-offset: .2em;
}
.proof-paper .proof-note {
  margin-inline: .35em .14em;
  padding-inline: .16em;
  font-size: .86em;
  font-style: italic;
  color: var(--proof-ink);
  text-decoration: underline dotted;
  text-underline-offset: .15em;
}
.proof-note::before { content: "⌃"; margin-right: .18em; font-style: normal; }
.proof-paper .proof-note:hover { background: #f5d8d8; }
.proof-paper :focus-visible { outline-color: #842841; }
.proof-editor {
  margin-block: .5rem;
  padding: .75rem;
  border-left: 3px solid var(--proof-ink);
  background: #fffaef;
  font: 1rem/1.5 system-ui, sans-serif;
  white-space: normal;
}
.proof-editor textarea {
  color-scheme: light;
  color: #29221f;
  background: #fffdf7;
  border-color: #a58571;
}
.proof-editor button {
  background: #f1e1ca;
  color: #29221f;
  border-color: #a58571;
}
.proof-editor button:hover { background: #e6d0ae; }
#proofreader [data-proof-source] { margin-block: .5rem; }

:root { --subtext-bg: #fff; }
:root[data-subtext-tone="black"] { --subtext-bg: #000; }
:root:has(#subtext:target) { background: var(--subtext-bg); }
:root:has(#subtext:target) footer a { color: #365d80; }
:root[data-subtext-tone="black"]:has(#subtext:target) footer a { color: #b5c9f3; }

#subtext {
  color-scheme: light;
  --ink: #171717;
  --muted: #55595f;
  --rule: #a4a8ad;
  --wash: #f3f4f5;
  --selected: #dbe7f3;
  --note: #335979;
  --reading-font: system-ui, -apple-system, sans-serif;
  --reading-size: 1.125rem;
  --reading-height: 1.65;
  --reading-width: 66ch;
  color: var(--ink);
  background: var(--subtext-bg);
  border: 0;
  border-radius: 0;
  padding: clamp(1rem, 4vw, 2.5rem) max(clamp(.8rem, 4vw, 2rem), env(safe-area-inset-right))
    3rem max(clamp(.8rem, 4vw, 2rem), env(safe-area-inset-left));
  scroll-margin-top: 0;
  min-height: 100svh;
}
:root[data-subtext-tone="black"] #subtext {
  color-scheme: dark;
  --ink: #ebeff4;
  --muted: #b0becd;
  --rule: #626972;
  --wash: #151719;
  --selected: #25364c;
  --note: #b5c9f3;
}
#subtext[data-subtext-style="manuscript"] {
  --reading-font: Georgia, 'Times New Roman', serif;
  --reading-size: 1.28rem;
  --reading-height: 1.8;
  --reading-width: 60ch;
  --note: #80392f;
  --selected: #f2e1da;
}
:root[data-subtext-tone="black"] #subtext[data-subtext-style="manuscript"] {
  --note: #ebb1a2;
  --selected: #38231e;
}
#subtext[data-subtext-style="console"] {
  --reading-font: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --reading-size: 1rem;
  --reading-height: 1.55;
  --reading-width: 74ch;
  --note: #724900;
  --selected: #f4e7c7;
}
:root[data-subtext-tone="black"] #subtext[data-subtext-style="console"] {
  --note: #f1b85b;
  --selected: #382c16;
}
#subtext h2 {
  color: inherit;
  font: 650 1.65rem/1.2 var(--reading-font);
  letter-spacing: normal;
}
#subtext > p, #subtext .hint { color: var(--muted); max-width: 65ch; }
.subtext-appearance {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.35rem;
  padding-block: .6rem;
  border-block: 1px solid var(--rule);
}
.subtext-appearance fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 0 .85rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}
.subtext-appearance legend { padding: 0; color: var(--muted); font-size: .85rem; }
.subtext-appearance label { position: relative; cursor: pointer; }
.subtext-appearance input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.subtext-appearance span {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  border-bottom: 2px solid transparent;
}
.subtext-appearance input:checked + span { border-color: var(--note); font-weight: 650; }
.subtext-appearance input:focus-visible + span { outline: 2px solid var(--note); outline-offset: 2px; }
#subtext :focus-visible { outline-color: var(--note); }
#subtext summary,
#subtext button:not(.proof-word, .proof-note),
#subtext textarea {
  color: inherit;
  background: var(--subtext-bg);
  border-color: var(--rule);
  border-radius: .18rem;
}
#subtext button:not(.proof-word, .proof-note):hover,
#subtext summary:hover { background: var(--wash); }
#subtext [data-proof-show][aria-pressed="true"] { border-color: var(--note); }
#subtext [data-proof-source] { margin-block: .5rem; }

.subtext-paper {
  --proof-ink: var(--note);
  background: transparent;
  color: inherit;
  border: 0;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  padding: 1rem 0;
  max-width: var(--reading-width);
  font: var(--reading-size)/var(--reading-height) var(--reading-font);
}
.subtext-paper .proof-word:hover,
.subtext-paper .proof-word[aria-pressed="true"] { background: var(--selected); }
.subtext-paper .proof-marked { text-decoration: underline solid var(--note) 1px; }
.subtext-paper .proof-note {
  display: block;
  margin: .18rem 0 .7rem;
  padding: .14rem 0;
  text-align: start;
  font: .94rem/1.5 var(--reading-font);
  color: var(--note);
  white-space: pre-wrap;
  text-decoration: none;
}
.subtext-paper .proof-note::before { content: none; }
.subtext-paper .proof-note:hover { background: var(--wash); }
[data-subtext-style="manuscript"] .proof-note { padding-inline-start: 1.25rem; font-size: 1.05rem; font-style: italic; }
[data-subtext-style="console"] .proof-note { padding-inline-start: .75rem; border-inline-start: 1px solid var(--note); }
.subtext-paper .proof-editor { background: transparent; }
.subtext-paper .proof-editor textarea { color-scheme: inherit; }
