/* small print: legal typesetting. A text serif at book measure, marginalia
   in a small sans, highlighter over the clauses, a strip down the page edge.
   Paper white and ink black; the dark theme is a reading lamp. */

:root {
  --serif: "Libre Caslon Text", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Public Sans", "Helvetica Neue", Arial, sans-serif;

  --desk: #eeede9;
  --paper: #fdfdfb;
  --paper-raised: #ffffff;
  --ink: #17171b;
  --muted: #595965;
  --rule: #d9d7d0;
  --rule-strong: #2a2a30;
  --margin-rule: rgba(196, 44, 58, 0.55);
  --focus: #1f4fd6;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 12px 32px -18px rgba(20, 20, 30, 0.28);
  --lamp: none;
  --lamp-glow: rgba(255, 255, 255, 0);
  --sheet-lamp: none;
  --strip: 16px;
  /* Exhibit stickers: the yellow label a court clerk puts on filed evidence. */
  --sticker: #fff1a0;
  --sticker-edge: #c9a93a;
  --sticker-ink: #1d2553;
  --fold: #e4e1d8;

  /* Highlighter inks (quote marks) and the lighter wash over each clause. */
  --mk-them: #ffadc8;
  --mk-you: #b3efb6;
  --mk-unclear: #fff17a;
  --mk-neutral: #dce2eb;
  --mk-none: #d9d7d0;
  --wash-them: rgba(255, 70, 130, 0.1);
  --wash-you: rgba(40, 185, 85, 0.1);
  --wash-unclear: rgba(255, 212, 0, 0.17);
  --wash-neutral: rgba(105, 125, 160, 0.055);
  --on-mark: #17171b;
  --notice: #8a3b00;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #0f0d0a;
    --paper: #1a1611;
    --paper-raised: #221d16;
    --ink: #efe6d6;
    --muted: #c2b6a1;
    --rule: #3b342a;
    --rule-strong: #cfc4b0;
    --margin-rule: rgba(232, 96, 96, 0.45);
    --focus: #8fb4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
    --lamp: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(255, 190, 110, 0.16), transparent 72%);
    --lamp-glow: rgba(255, 196, 120, 0.15);
    --sheet-lamp: radial-gradient(ellipse 46% 60% at 36% 48%, var(--lamp-glow), rgba(255, 196, 120, 0.05) 58%, transparent 82%);
    --sticker: #4a3f14;
    --sticker-edge: #8f7a2e;
    --sticker-ink: #f7eecb;
    --fold: #2c251c;
    --mk-them: #7e2f4d;
    --mk-you: #2e6340;
    --mk-unclear: #6b5814;
    --mk-neutral: #313b49;
    --mk-none: #3b342a;
    --wash-them: rgba(255, 95, 145, 0.13);
    --wash-you: rgba(95, 210, 125, 0.11);
    --wash-unclear: rgba(255, 205, 60, 0.11);
    --wash-neutral: rgba(150, 170, 200, 0.06);
    --on-mark: #fbf5ea;
    --notice: #ffb37a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --desk: #0f0d0a;
  --paper: #1a1611;
  --paper-raised: #221d16;
  --ink: #efe6d6;
  --muted: #c2b6a1;
  --rule: #3b342a;
  --rule-strong: #cfc4b0;
  --margin-rule: rgba(232, 96, 96, 0.45);
  --focus: #8fb4ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
  --lamp: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(255, 190, 110, 0.16), transparent 72%);
  --lamp-glow: rgba(255, 196, 120, 0.15);
  --sheet-lamp: radial-gradient(ellipse 46% 60% at 36% 48%, var(--lamp-glow), rgba(255, 196, 120, 0.05) 58%, transparent 82%);
  --sticker: #4a3f14;
  --sticker-edge: #8f7a2e;
  --sticker-ink: #f7eecb;
  --fold: #2c251c;
  --mk-them: #7e2f4d;
  --mk-you: #2e6340;
  --mk-unclear: #6b5814;
  --mk-neutral: #313b49;
  --mk-none: #3b342a;
  --wash-them: rgba(255, 95, 145, 0.13);
  --wash-you: rgba(95, 210, 125, 0.11);
  --wash-unclear: rgba(255, 205, 60, 0.11);
  --wash-neutral: rgba(150, 170, 200, 0.06);
  --on-mark: #fbf5ea;
  --notice: #ffb37a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--lamp), var(--desk);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 0.5rem 0.8rem; text-decoration: none;
}
.skip:focus { top: 1rem; }
.muted { color: var(--muted); }
kbd {
  font: 600 0.78em/1 var(--sans);
  border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 3px;
  padding: 0.1em 0.35em; background: var(--paper);
}

/* ------------------------------------------------------------ masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }
.masthead-inner {
  max-width: 72rem; margin: 0 auto; padding: 2.2rem 1rem 1.6rem;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  border-top: 3px double var(--rule-strong);
}
.masthead { padding-top: 0.9rem; }
.wordmark {
  margin: 0; font: 400 clamp(2.6rem, 7vw, 4.2rem)/0.95 var(--serif);
  letter-spacing: -0.015em;
}
.wm-mark {
  color: inherit;
  background: linear-gradient(101deg, transparent 0.08em, var(--mk-them) 0.2em, var(--mk-them) calc(100% - 0.22em), transparent calc(100% - 0.06em));
  border-radius: 0.12em 0.4em 0.18em 0.5em / 0.3em 0.2em 0.4em 0.25em;
  padding: 0 0.12em 0.04em;
}
.tagline { margin: 0.8rem 0 0; max-width: 36rem; font: 400 1.05rem/1.5 var(--serif); color: var(--muted); }
.lamp {
  flex: none; font: 600 0.82rem/1 var(--sans); letter-spacing: 0.02em;
  color: var(--ink); background: none; border: 1px solid var(--rule-strong); border-radius: 2px;
  padding: 0.55rem 0.75rem; cursor: pointer;
}
.lamp .lamp-state { font-weight: 400; color: var(--muted); }
.lamp[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.lamp[aria-pressed="true"] .lamp-state { color: inherit; }

/* -------------------------------------------------------------- intake */
main { max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
.section-h, .side-h {
  font: 700 0.74rem/1.2 var(--sans); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 0.9rem;
}
.intake {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem;
  padding: 2.4rem 0 2.8rem;
}
@media (min-width: 900px) {
  .intake { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 3.5rem; }
}
.field-label { display: block; font: 400 1.35rem/1.3 var(--serif); margin-bottom: 0.7rem; }
textarea {
  display: block; width: 100%; min-height: 17rem; resize: vertical;
  font: 400 1rem/1.75rem var(--serif); color: var(--ink);
  padding: 0.55rem 1rem 0.55rem 3.1rem; border: 1px solid var(--rule-strong); border-radius: 1px;
  background:
    linear-gradient(90deg, transparent 2.2rem, var(--margin-rule) 2.2rem, var(--margin-rule) calc(2.2rem + 1px), transparent calc(2.2rem + 1px), transparent calc(2.2rem + 4px), var(--margin-rule) calc(2.2rem + 4px), var(--margin-rule) calc(2.2rem + 5px), transparent calc(2.2rem + 5px)),
    repeating-linear-gradient(180deg, transparent 0, transparent calc(1.75rem - 1px), var(--rule) calc(1.75rem - 1px), var(--rule) 1.75rem) 0 0.55rem,
    var(--paper);
  background-attachment: local, local, local;
  box-shadow: var(--shadow);
}
textarea::placeholder { color: var(--muted); font-style: italic; }
.plan { margin: 0.7rem 0 0; font-size: 0.86rem; color: var(--muted); min-height: 1.3em; }
.plan.over, .form-error { color: var(--notice); font-weight: 600; }
.form-error { margin: 0.5rem 0 0; font-size: 0.9rem; }
.intake-row { margin-top: 1.1rem; display: flex; gap: 1rem; align-items: center; }
.primary {
  font: 700 0.95rem/1 var(--sans); letter-spacing: 0.01em;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 2px;
  padding: 0.85rem 1.3rem; cursor: pointer;
}
.primary:hover { background: transparent; color: var(--ink); }
.primary:disabled { opacity: 0.55; cursor: progress; }

.service-status {
  margin: 1.6rem 0 0; padding: 0.8rem 0 0; border-top: 1px solid var(--rule);
  font-size: 0.88rem; color: var(--muted); max-width: 44rem;
}
.service-status strong { color: var(--ink); }
.service-status[data-state="live"] strong::before,
.service-status[data-state="rules"] strong::before,
.service-status[data-state="demo"] strong::before,
.service-status[data-state="offline"] strong::before {
  content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%;
  margin-right: 0.45rem; vertical-align: 0.05em; background: var(--mk-you); border: 1px solid var(--rule-strong);
}
.service-status[data-state="demo"] strong::before { background: var(--mk-unclear); }
.service-status[data-state="offline"] strong::before { background: var(--mk-them); }

.progress { margin-top: 1.2rem; padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--rule); }
.progress-lead { margin: 0 0 0.6rem; font: 400 1rem/1.4 var(--serif); }
.progress-parts { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.progress-parts li { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: 0.6rem; padding: 0.3rem 0; border-top: 1px solid var(--rule); }
.pp-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-parts li[data-state="reading"] .pp-state { font-weight: 700; }
.progress-parts li[data-state="done"] .pp-state::before { content: "\2713\00a0"; }
.progress-parts li[data-state="failed"] .pp-state { color: var(--notice); font-weight: 700; }
.progress-clock { margin: 0.6rem 0 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-parts.local li { grid-template-columns: 8.5rem minmax(0, 1fr) auto; }
/* The runtime download, drawn as a highlighter stroke going across. */
.meter {
  height: 0.62rem; margin: 0.8rem 0 0.1rem; background: var(--rule); overflow: hidden;
  border-radius: 0.15rem 0.45rem 0.2rem 0.5rem / 0.35rem 0.2rem 0.4rem 0.25rem; transform: skewX(-12deg);
}
.meter-fill { display: block; height: 100%; width: 0; background: var(--mk-unclear); transition: width 160ms linear; }

.exhibits, .history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.exhibits { gap: 1.1rem; padding-right: 6px; }
/* Each exhibit is a filed document: a sheet on a second sheet, one corner
   folded down, with the clerk's exhibit sticker on it. */
.exhibits li { position: relative; }
.exhibits li:not(.muted)::before {
  content: ""; position: absolute; inset: 5px -5px -5px 5px;
  background: var(--paper); border: 1px solid var(--rule);
}
.exhibit {
  position: relative; width: 100%; text-align: left; cursor: pointer; color: var(--ink); font: inherit;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; align-items: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 0;
  padding: 0.8rem 1.6rem 0.85rem 0.85rem; box-shadow: var(--shadow);
}
.exhibit::after {
  /* the folded corner */
  content: ""; position: absolute; top: -1px; right: -1px; width: 1.05rem; height: 1.05rem;
  background: linear-gradient(to bottom left, var(--desk) 50%, var(--fold) 50%);
  box-shadow: -1px 1px 0 var(--rule);
}
.exhibit:hover { border-color: var(--rule-strong); }
.exhibit:disabled { cursor: progress; opacity: 0.7; }
.ex-sticker {
  display: grid; justify-items: center; gap: 0.15rem; width: 3.7rem; padding: 0.4rem 0.3rem 0.45rem;
  background: var(--sticker); border: 1.5px solid var(--sticker-edge); border-radius: 3px;
  color: var(--sticker-ink); transform: rotate(-3deg); transition: transform 160ms ease;
}
.exhibit:hover .ex-sticker { transform: rotate(-1deg); }
.ex-word { font: 700 0.54rem/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; }
.ex-letter {
  font: 400 1.55rem/1 var(--serif); min-width: 2rem; text-align: center;
  border-bottom: 1px solid currentColor; padding-bottom: 0.08rem;
}
.ex-body { display: grid; gap: 0.2rem; }
.ex-name { font: 400 1.3rem/1.2 var(--serif); }
.ex-kind { font-size: 0.82rem; color: var(--muted); }
.history-item {
  width: 100%; text-align: left; cursor: pointer; color: var(--ink); font: inherit;
  background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong);
  border-radius: 1px; display: grid; gap: 0.15rem;
}
.history-item:hover { border-color: var(--rule-strong); }
.history { margin-top: 1.8rem; }
.history-item { grid-template-columns: 1fr auto; align-items: baseline; padding: 0.6rem 0.8rem; box-shadow: none; }
.hi-title { font: 400 1rem/1.3 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-when { font-size: 0.78rem; color: var(--muted); }
.fine { font-size: 0.8rem; color: var(--muted); margin: 0.9rem 0 0; max-width: 30rem; }

/* -------------------------------------------------------------- result */
.result { padding: 0.5rem 0 4rem; border-top: 3px double var(--rule-strong); }
.not-advice {
  margin: 1.6rem 0 0; padding: 0.8rem 1rem; max-width: 50rem;
  border: 1px solid var(--rule-strong); background: var(--paper);
  font: 400 0.95rem/1.5 var(--serif);
}
.not-advice p { margin: 0; }
.not-advice-label {
  font: 700 0.7rem/1.2 var(--sans) !important; letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 0.35rem !important;
}
.result-head { margin: 2rem 0 1.6rem; max-width: 50rem; }
.doc-title { margin: 0 0 0.5rem; font: 400 clamp(1.7rem, 4vw, 2.4rem)/1.15 var(--serif); }
.doc-title:focus { outline: none; }
.provenance, .verification { margin: 0.25rem 0; font-size: 0.88rem; color: var(--muted); max-width: 46rem; }
.verification { color: var(--ink); }
.notices { margin: 0.8rem 0; }
.notice { margin: 0.35rem 0; padding: 0.55rem 0.8rem; border-left: 3px solid var(--notice); background: var(--paper); font-size: 0.9rem; }
.notice.subtle { border-left-color: var(--rule-strong); color: var(--muted); }
.notice.caveat { border-left-color: var(--rule-strong); }
.tally { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.1rem 0 0.7rem; }
.tally-btn {
  display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer;
  font: 600 0.85rem/1 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 2px; padding: 0.5rem 0.7rem;
}
.tally-btn:hover:not(:disabled):not(.static) { border-color: var(--rule-strong); }
.tally-btn:disabled { opacity: 0.55; cursor: default; }
.tally-btn.static { cursor: default; }
.tally-n { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Rule readings: what the rules found, and what they looked for in vain. */
.checklist { margin: 0.2rem 0 0.9rem; padding: 0.85rem 0 0; border-top: 1px solid var(--rule); }
.check-h { margin-bottom: 0.55rem; }
.check-row { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 0.2rem 0.6rem; align-items: baseline; padding: 0.3rem 0; }
.check-group { font: 700 0.72rem/1.9 var(--sans); color: var(--muted); }
.check-found { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.check-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; text-align: left;
  font: 600 0.76rem/1.2 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 2px; padding: 0.32rem 0.5rem;
}
.check-btn .sw { width: 0.95rem; height: 0.5rem; }
.check-btn:hover { border-color: var(--rule-strong); }
.check-where { font-weight: 400; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.check-missing { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--muted); max-width: 46rem; }
.check-missing-lead { font-weight: 700; color: var(--ink); }
.keys-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.2rem; margin: 0.6rem 0 0; }
.keys { margin: 0; font-size: 0.8rem; color: var(--muted); }
.offsets {
  font: 600 0.78rem/1 var(--sans); color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 2px; padding: 0.42rem 0.6rem;
}
.offsets:hover { border-color: var(--rule-strong); }
.offsets[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
@media (max-width: 700px) and (pointer: coarse) { .keys { display: none; } }

/* A short highlighter stroke, used in the tally, the notes and the legend. */
.sw {
  display: inline-block; width: 1.25rem; height: 0.62rem; flex: none;
  background: var(--sw, var(--mk-none));
  border-radius: 0.15rem 0.45rem 0.2rem 0.5rem / 0.35rem 0.2rem 0.4rem 0.25rem;
  transform: skewX(-12deg);
}
[data-fav="them"] { --sw: var(--mk-them); --mk: var(--mk-them); --wash: var(--wash-them); }
[data-fav="you"] { --sw: var(--mk-you); --mk: var(--mk-you); --wash: var(--wash-you); }
[data-fav="unclear"] { --sw: var(--mk-unclear); --mk: var(--mk-unclear); --wash: var(--wash-unclear); }
[data-fav="neutral"] { --sw: var(--mk-neutral); --mk: var(--mk-neutral); --wash: var(--wash-neutral); }
[data-fav="none"] { --sw: transparent; --mk: var(--mk-none); --wash: transparent; }
.tally-btn[data-fav="none"] .sw, .note[data-fav="none"] .sw { border: 1px dashed var(--muted); }

/* ------------------------------------------------------------ the sheet */
.sheet {
  position: relative; box-shadow: var(--shadow);
  /* In the dark theme a reading lamp lights the sheet where you read: the
     pool is fixed to the viewport, so it stays over the page as you scroll. */
  background: var(--sheet-lamp), var(--paper);
  background-attachment: fixed, scroll;
  padding: 2.2rem 1rem 3rem 2.4rem; margin: 0 -1rem;
}
.sheet::before {
  /* the double margin rule of legal paper */
  content: ""; position: absolute; top: 0; bottom: 0; left: 1.2rem; width: 4px;
  border-left: 1px solid var(--margin-rule); border-right: 1px solid var(--margin-rule);
}
.doc {
  position: relative; max-width: 68ch;
  font: 400 1.075rem/1.8 var(--serif); color: var(--ink);
  font-variant-numeric: oldstyle-nums;
  hyphens: manual; overflow-wrap: break-word;
}
.doc:focus { outline: none; }
.ln { margin: 0; }
.ln.para, .hd.para { margin-top: 1.05em; }
.hd {
  margin: 1.7em 0 0.35em; font: 700 0.86rem/1.4 var(--serif);
  letter-spacing: 0.09em; text-transform: uppercase;
}
.hd:first-child { margin-top: 0; }

.cl {
  background: var(--wash);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  border-radius: 2px; padding: 0.08em 0; cursor: pointer;
  transition: box-shadow 120ms ease;
}
.cl[data-fav="none"] {
  text-decoration: underline dotted var(--muted); text-decoration-thickness: 1px; text-underline-offset: 0.3em;
}
/* In a rule reading an unmarked clause simply matched no rule. */
.doc.rules .cl[data-fav="none"] { text-decoration: none; }
.cl.hot, .cl.active { box-shadow: inset 0 -2px 0 var(--ink); }
.cl.active { outline: none; }
.num {
  font: 600 0.62em/1 var(--sans); color: var(--muted); vertical-align: 0.55em;
  margin: 0 0.2em 0 0.1em; font-variant-numeric: lining-nums tabular-nums;
}
mark.q {
  color: var(--on-mark);
  background: linear-gradient(100deg, transparent 0, var(--mk) 0.18em, var(--mk) calc(100% - 0.18em), transparent 100%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  border-radius: 0.15em 0.45em 0.2em 0.5em / 0.35em 0.2em 0.45em 0.25em;
  padding: 0.04em 0.16em;
}

/* Marginalia: inline under each clause on narrow screens, in the right
   margin beside the clause on wide ones (positioned by app.js). */
.note {
  display: block; margin: 0.35rem 0 0.95rem; padding: 0.15rem 0 0.15rem 0.75rem;
  border-left: 3px solid var(--mk);
  font: 400 0.82rem/1.45 var(--sans); color: var(--ink); font-variant-numeric: lining-nums;
}
.note-body { display: block; }
/* Run-in head: the label leads into the reading on the same line. */
.note-head { display: inline; }
.note-head .sw { width: 0.95rem; height: 0.52rem; margin-right: 0.35rem; vertical-align: 0.02em; }
.note-label { font-weight: 700; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; }
.note-conf { font-size: 0.74rem; color: var(--muted); }
.note-topic { font-weight: 700; }
.note-also { display: block; margin-top: 0.2rem; font-size: 0.76rem; color: var(--muted); }
.note-also-lead { font-weight: 700; }
.note-also-item .sw { width: 0.8rem; height: 0.45rem; margin-right: 0.3rem; vertical-align: 0.02em; }
.note-ref { display: none; margin-top: 0.2rem; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.show-refs .note-ref, .note.active .note-ref { display: block; }
.note.hot, .note.active { background: var(--paper-raised); box-shadow: -3px 0 0 var(--ink); }

/* Where one part of a long document ends and the next begins. */
.part-rule {
  margin: 2rem 0 0.7rem; padding: 0.55rem 0 0; border-top: 1px dashed var(--rule-strong);
  font: 400 0.8rem/1.45 var(--sans); color: var(--muted);
}
.part-rule:first-child { margin-top: 0; }
.part-rule:focus { outline: none; }
.part-rule:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.part-label { margin: 0; font-weight: 600; letter-spacing: 0.02em; }
.part-rule.failed { border-top: 2px solid var(--notice); }
.part-error { margin: 0.3rem 0 0; color: var(--notice); font-weight: 600; max-width: 36rem; }
.retry {
  margin-top: 0.55rem; font: 600 0.82rem/1 var(--sans); color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0.5rem 0.75rem;
}
.retry:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.retry:disabled { cursor: progress; opacity: 0.7; }
.part-text summary { margin-top: 0.55rem; cursor: pointer; }
.part-text p { margin: 0.6rem 0 0; font: 400 0.98rem/1.7 var(--serif); color: var(--muted); max-width: 38rem; }

@media (min-width: 1100px) {
  main { max-width: 76rem; }
  .sheet { margin: 0; padding: 3rem 24rem 4rem 3.4rem; }
  .doc { max-width: 38rem; }
  .sheet::before { left: 1.6rem; }
  .note {
    position: absolute; left: calc(100% + 2.6rem); width: 20.5rem; margin: 0;
    padding: 0.12rem 0.4rem 0.22rem 0.7rem; transition: background-color 120ms ease;
  }
  /* The selected note shows its offsets over the note below it. */
  .note.active { z-index: 2; box-shadow: -3px 0 0 var(--ink), 0 10px 24px -14px rgba(0, 0, 0, 0.45); }
}
body.has-result { padding-right: var(--strip); }

/* ------------------------------------------------------- the edge strip */
/* A minimap of the whole document by colour, down the right edge. */
.minimap {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--strip); z-index: 5;
  background: var(--paper); border-left: 1px solid var(--rule); cursor: pointer;
}
.mm-caption {
  position: absolute; top: 0.55rem; left: 0; width: 100%;
  writing-mode: vertical-rl; line-height: var(--strip); text-align: start;
  font-family: var(--sans); font-weight: 700; font-size: 0.56rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap; pointer-events: none;
}
.mm-track { position: absolute; top: 7.1rem; bottom: 0.5rem; left: 0; right: 0; border-top: 1px solid var(--rule); }
.mm-blocks { position: absolute; inset: 0; }
.mm-block { position: absolute; left: 3px; right: 3px; display: block; background: var(--mk); min-height: 2px; }
.mm-block[data-fav="none"] { background: var(--mk-none); }
.mm-view {
  position: absolute; left: -1px; right: 0; pointer-events: none;
  border: 1px solid var(--ink); border-right: 0; box-shadow: 0 0 0 1px var(--paper);
}
/* The selected clause: a bar across the strip and a pointer beside it. */
.mm-tick { position: absolute; left: 0; right: 0; height: 2px; margin-top: -1px; background: var(--ink); pointer-events: none; }
.mm-tick::before {
  content: ""; position: absolute; left: -8px; top: -4px;
  border: 5px solid transparent; border-left: 7px solid var(--ink); border-right: 0;
}
@media (max-width: 1099px) {
  :root { --strip: 14px; }
  .mm-caption { font-size: 0.52rem; }
}

/* ------------------------------------------------------------ colophon */
.colophon { border-top: 3px double var(--rule-strong); background: var(--paper); margin-top: 1rem; }
.colophon-inner {
  max-width: 72rem; margin: 0 auto; padding: 2.2rem 1rem 3rem;
  display: grid; gap: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
.colophon p { margin: 0; font: 400 0.92rem/1.6 var(--serif); color: var(--muted); max-width: 34rem; }
.colophon p + p { margin-top: 0.7rem; }
.colophon a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

@media (max-width: 520px) {
  .check-row { grid-template-columns: minmax(0, 1fr); }
  .progress-parts.local li { grid-template-columns: minmax(0, 1fr) auto; }
  .progress-parts.local .pp-size { grid-column: 1 / -1; grid-row: 2; }
  .masthead-inner { flex-direction: column; align-items: flex-start; padding-top: 1.6rem; }
  .lamp { align-self: flex-start; }
  textarea { padding-left: 2.6rem; background-position: -0.5rem 0, 0 0.55rem, 0 0; }
  .doc { font-size: 1.02rem; }
  .sheet { padding-left: 1.9rem; }
  .sheet::before { left: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .masthead .lamp, .intake, .minimap, .keys-row, .tally, .skip, .retry { display: none !important; }
  .note-ref { display: block !important; }
  body { background: #fff; }
  .sheet { box-shadow: none; padding: 0; }
  .sheet::before { display: none; }
  .note { position: static !important; width: auto !important; }
}
