/* Selfscribe document styles (D79, 04 §6): the looks that `set style WORD ...` asks for.

   One host stylesheet for every host (the editor, the site, the `self` CLI). A host wraps a
   rendered document as `.self-page.self-s-WORD > .self-doc > blocks`, or with each block in a
   `div.self-block` (the editor's preview). Styles set document tokens on `.self-page`; a
   host's own document typography reads them, with its defaults as fallbacks. Colours reach
   elements only through tokens, and alignment and fonts are inherited from `.self-doc`, so a
   rule's own `{ css }` still shows. The element rules below set sizes, margins, indents and
   alignment of headings and paragraphs, never colours.

   Words: dark light paper | wide compact | serif sans mono justified | numbered dropcap
   columns | newspaper academic. Exclusive groups (dark light paper) and (serif sans mono) are
   resolved by the host (the last word wins); a single word written with a look overrides it
   because it comes later in this file.

   packages/selfscribe/src/styles-css.ts is generated from this file
   (`pnpm --filter selfscribe styles`); the `self` CLI compiles it in. */

/* ------------------------------------------------------------------ page and base */

/* Every host: the page paints the document palette, and holds its document's margins (a
   paper sheet's) inside it (a hidden page stays hidden). */
:where(.self-page) {
  background-color: var(--doc-bg, transparent);
  color: var(--doc-fg, inherit);
}

/* Faces a rule's `{ css }` can use (D131): a sans-serif for labels and badges, and code.
   Hosts with their own faces (the editor) set these to theirs. */
:where(.self-page, .self-palette) {
  --doc-font-ui: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --doc-font-mono: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
}
:where(.self-page:not([hidden])) {
  display: flow-root;
}

/* `.self-base`: typography for hosts that have none of their own (the CLI's standalone page,
   thumbnails). Zero specificity, so any host or document rule wins. */
:where(.self-base) {
  margin: 0;
  min-height: 100vh;
  background-color: var(--doc-bg, #ffffff);
  color: var(--doc-fg, #1f2328);
}
:where(.self-base) :where(.self-doc) {
  box-sizing: border-box;
  max-width: calc(var(--doc-measure, 72ch) + 4rem);
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  font-family: var(--doc-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
  font-size: 17px;
  line-height: var(--doc-leading, 1.65);
  overflow-wrap: break-word;
}
:where(.self-base) :where(.self-doc) :where(h1, h2, h3, h4, h5, h6) {
  font-family: var(--doc-font-heading, inherit);
  color: var(--doc-heading, inherit);
  line-height: 1.25;
  margin: var(--doc-heading-gap, 1.6em) 0 0.5em;
}
:where(.self-base) :where(.self-doc) :where(h1) { font-size: 2em; }
/* Only what opens the page loses its top margin; a title under a kicker keeps its own. */
:where(.self-base) :where(.self-doc) > :where(:first-child),
:where(.self-base) :where(.self-doc) > :where(.self-block:first-child) > :where(:first-child) { margin-top: 0; }
:where(.self-base) :where(.self-doc) :where(h2) { font-size: 1.45em; }
:where(.self-base) :where(.self-doc) :where(h3) { font-size: 1.18em; }
:where(.self-base) :where(.self-doc) :where(p, ul, ol, table, blockquote, pre, details, figure, label) {
  margin: 0 0 var(--doc-gap, 1em);
}
:where(.self-base) :where(.self-doc) :where(ul, ol) { padding-left: 1.5em; }
/* A checklist item's box stands where a bullet would, with a gap before its text (as in the
   editor's preview): without the pull it sits inside the list's indent, further in than the
   bullets beside it. */
:where(.self-base) :where(.self-doc) :where(li.task) { list-style: none; margin-left: -1.3em; }
:where(.self-base) :where(.self-doc) :where(li.task > input) { margin: 0 0.5em 0 0; }
:where(.self-base) :where(.self-doc) :where(a) { color: var(--doc-link, #0b5cc7); }
:where(.self-base) :where(.self-doc) :where(code, pre, kbd, samp) {
  font-family: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 0.86em;
  color: var(--doc-code-fg, inherit);
  background: var(--doc-code-bg, rgba(127, 127, 127, 0.12));
  border-radius: 4px;
}
:where(.self-base) :where(.self-doc) :where(code) { padding: 0.1em 0.3em; }
:where(.self-base) :where(.self-doc) :where(pre) { padding: 0.8em 1em; overflow-x: auto; line-height: 1.5; text-align: start; }
:where(.self-base) :where(.self-doc) :where(pre code) { padding: 0; font-size: inherit; background: none; }
:where(.self-base) :where(.self-doc) :where(blockquote) {
  margin-inline: 0;
  padding-left: 1em;
  border-left: 3px solid var(--doc-quote-bar, #c4ccd6);
  color: var(--doc-muted, #59636e);
}
:where(.self-base) :where(.self-doc) :where(hr) { border: 0; border-top: 1px solid var(--doc-border, #d5dbe1); margin: 2em 0; }
:where(.self-base) :where(.self-doc) :where(mark) { background: var(--doc-mark-bg, #fff0a6); color: inherit; }
:where(.self-base) :where(.self-doc) :where(img) { max-width: 100%; }
:where(.self-base) :where(.self-doc) :where(table) { border-collapse: collapse; }
:where(.self-base) :where(.self-doc) :where(td, th) {
  border: 1px solid var(--doc-border, #d5dbe1);
  padding: 0.35em 0.7em;
  text-align: start;
}
:where(.self-base) :where(.self-doc) :where(th, thead td, table:not(:has(thead)) tr:first-child > td) { background: var(--doc-table-head, rgba(127, 127, 127, 0.07)); }
:where(.self-base) :where(.self-doc) :where(details) { border: 1px solid var(--doc-border, #d5dbe1); border-radius: 6px; padding: 0.4em 0.8em; }

/* Alignment and hyphenation are inherited from the document column (a rule's own
   `text-align` on its element wins). */
:where(.self-page) :where(.self-doc) {
  text-align: var(--doc-align, start);
  hyphens: var(--doc-hyphens, manual);
}

/* ------------------------------------------------------------------ page: dark, light, paper */

/* The palettes of static hosts. The editor paints `dark`, `light` and `paper` with the
   user's matching theme instead (its tokens, set on the page element, win over these). */
.self-page.self-s-dark {
  --doc-bg: #16181d;
  --doc-fg: #d7dbe2;
  --doc-muted: #9aa2ae;
  --doc-heading: #eff2f6;
  --doc-link: #85b4ff;
  --doc-code-bg: #22252c;
  --doc-code-fg: #e3e6eb;
  --doc-border: #343944;
  --doc-quote-bar: #4b5262;
  --doc-mark-bg: #56461a;
  --doc-table-head: #1e2127;
  color-scheme: dark;
}
.self-page.self-s-light {
  --doc-bg: #ffffff;
  --doc-fg: #1f2328;
  --doc-muted: #59636e;
  --doc-heading: #121418;
  --doc-link: #0b5cc7;
  --doc-code-bg: #f1f3f6;
  --doc-code-fg: #1f2328;
  --doc-border: #d5dbe1;
  --doc-quote-bar: #c4ccd6;
  --doc-mark-bg: #fff0a6;
  --doc-table-head: #f3f5f8;
  color-scheme: light;
}
.self-page.self-s-paper {
  --doc-bg: #fdfbf6;
  --doc-fg: #27231e;
  --doc-muted: #6a6257;
  --doc-heading: #1a1714;
  --doc-link: #7b3f14;
  --doc-code-bg: #f2ede2;
  --doc-code-fg: #2a251f;
  --doc-border: #ddd4c4;
  --doc-quote-bar: #cdbfa6;
  --doc-mark-bg: #f4e3a3;
  --doc-table-head: #f4efe4;
  color-scheme: light;
}

/* Paper: a printed sheet on a desk. */
.self-page.self-s-paper {
  background-color: color-mix(in srgb, var(--doc-bg, #fdfbf6) 88%, var(--doc-fg, #27231e));
}
.self-page.self-s-paper .self-doc {
  background-color: var(--doc-bg, #fdfbf6);
  margin: 2.5rem auto;
  padding: 3.4rem 3.8rem;
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 10px 30px rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------------------ width and spacing */

.self-page.self-s-academic {
  --doc-measure: calc(var(--measure, 72ch) * 0.9);
}
.self-page.self-s-wide {
  --doc-measure: calc(var(--measure, 72ch) * 1.6);
}
.self-page:is(.self-s-columns, .self-s-newspaper) {
  --doc-measure: calc(var(--measure, 72ch) * 1.7);
}
.self-page:is(.self-s-compact, .self-s-newspaper) {
  --doc-leading: 1.45;
  --doc-gap: 0.6em;
  --doc-heading-gap: 1.1em;
}

/* ------------------------------------------------------------------ type */

.self-page:is(.self-s-serif, .self-s-paper, .self-s-newspaper, .self-s-academic) {
  --doc-font: 'Source Serif 4 Variable', 'Source Serif 4', Charter, 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --doc-font-heading: 'Source Serif 4 Variable', 'Source Serif 4', Charter, 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
}
.self-page.self-s-sans {
  --doc-font: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --doc-font-heading: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.self-page.self-s-mono {
  --doc-font: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  --doc-font-heading: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
}
.self-page:is(.self-s-justified, .self-s-newspaper, .self-s-academic) {
  --doc-align: justify;
  --doc-hyphens: auto;
}

/* ------------------------------------------------------------------ numbered headings */

/* h2 1, h3 1.1, h4 1.1.1; an h1 restarts the numbers. Static pages count top-level headings
   with counters; the editor writes the same numbers as `data-self-num` (virtualised views). */
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc {
  counter-reset: self-h2 self-h3 self-h4;
}
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h1 { counter-set: self-h2 0 self-h3 0 self-h4 0; }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h2 { counter-increment: self-h2; counter-set: self-h3 0 self-h4 0; }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h3 { counter-increment: self-h3; counter-set: self-h4 0; }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h4 { counter-increment: self-h4; }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h2::before { content: counter(self-h2); }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h3::before { content: counter(self-h2) '.' counter(self-h3); }
.self-page:is(.self-s-numbered, .self-s-academic) .self-doc > h4::before { content: counter(self-h2) '.' counter(self-h3) '.' counter(self-h4); }
.self-page:is(.self-s-numbered, .self-s-academic) [data-self-num]::before { content: attr(data-self-num); }
.self-page:is(.self-s-numbered, .self-s-academic) :is(.self-doc > :is(h2, h3, h4), [data-self-num])::before {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 0.5em;
  color: var(--doc-muted, currentColor);
  font-weight: inherit;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ drop cap */

.self-page:is(.self-s-dropcap, .self-s-newspaper) :is(.self-doc > p:first-of-type, [data-self-lead])::first-letter {
  float: left;
  font-family: var(--doc-font-heading, inherit);
  font-size: 3.35em;
  font-weight: 700;
  line-height: 0.82;
  margin: 0.06em 0.09em 0 0;
  color: var(--doc-heading, inherit);
}

/* ------------------------------------------------------------------ columns */

.self-page:is(.self-s-columns, .self-s-newspaper) .self-doc {
  /* Two columns of at least 20em: a narrow window gets one. */
  columns: 2 20em;
  column-gap: 2.4em;
  column-rule: 1px solid var(--doc-border, rgba(127, 127, 127, 0.35));
}
.self-page:is(.self-s-columns, .self-s-newspaper) .self-doc :is(pre, table, figure, img, blockquote, details) {
  break-inside: avoid;
}
.self-page:is(.self-s-columns, .self-s-newspaper) .self-doc :is(h2, h3, h4, h5, h6) {
  break-after: avoid;
}
.self-page:is(.self-s-columns, .self-s-newspaper) :is(.self-doc > h1, .self-doc > .self-block > h1:first-child) {
  column-span: all;
}
.self-page:is(.self-s-columns, .self-s-newspaper) .self-doc > .self-block:has(> h1:first-child) {
  column-span: all;
}

/* ------------------------------------------------------------------ looks */

/* Newspaper: a masthead and tight, indented paragraphs. */
.self-page.self-s-newspaper :is(.self-doc > h1, .self-doc > .self-block > h1:first-child) {
  margin: 0 0 0.6em;
  padding: 0.25em 0 0.2em;
  border-top: 3px double var(--doc-fg, currentColor);
  border-bottom: 1px solid var(--doc-fg, currentColor);
  font-size: 2.7em;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-align: center;
}
.self-page.self-s-newspaper .self-doc :is(h2, h3) {
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-align: start;
}
.self-page.self-s-newspaper .self-doc h2 { font-size: 1.4em; }

/* Academic: a centred title, quiet section headings, indented paragraphs. */
.self-page.self-s-academic :is(.self-doc > h1, .self-doc > .self-block > h1:first-child) {
  margin: 0.4em 0 1.3em;
  font-size: 1.85em;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.self-page.self-s-academic .self-doc h2 { font-size: 1.28em; font-weight: 650; }
.self-page.self-s-academic .self-doc h3 { font-size: 1.08em; font-weight: 650; font-style: italic; }

.self-page:is(.self-s-newspaper, .self-s-academic) :is(.self-doc > p, .self-doc > .self-block > p:only-child) {
  margin-bottom: 0.35em;
}
.self-page:is(.self-s-newspaper, .self-s-academic) :is(.self-doc > p + p, .self-doc > .self-block:has(> p:only-child) + .self-block > p:only-child) {
  text-indent: 1.4em;
}

/* ------------------------------------------------------------------ data views (D82) */

/* The static output of data views for every host (CLI, site, print, the editor before the
   client half takes over). Zero specificity, colours only through document tokens. It has the
   client view's measures (`client/view/styles.ts`): its type, row height, tiles and chart
   card, so the client draws over it without the page moving. */
:where(.self-view) {
  --self-v-fg: var(--doc-fg, currentColor);
  --self-v-muted: var(--doc-muted, color-mix(in srgb, currentColor 60%, transparent));
  --self-v-border: var(--doc-border, color-mix(in srgb, currentColor 16%, transparent));
  --self-v-bg: var(--doc-bg, Canvas);
  --self-v-panel: color-mix(in srgb, var(--self-v-bg) 96%, var(--self-v-fg));
  --self-v-head: var(--doc-table-head, color-mix(in srgb, var(--self-v-bg) 92%, var(--self-v-fg)));
  --self-v-soft: color-mix(in srgb, var(--doc-link, #3b6fd8) 14%, transparent);
  display: block;
  margin: 1.35em 0;
  font: 13.5px/1.45 var(--doc-font-ui, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
/* The client keeps a line under every view for what it says (`v-status`), and one under a
   chart for the value under the pointer: the static page keeps the room. */
:where(.self-view:not(.selfp-view)) {
  padding-bottom: 12px;
}
:where(.self-view-chart:not(.selfp-view)) {
  padding-bottom: calc(12px + 4px + 1.45 * 12px);
}
:where(.self-view) :where(.self-view-title) {
  font-weight: 600;
  margin: 0 0 8px;
}
:where(.self-view) :where(.self-view-note, .self-view-totals) {
  font-size: 12px;
  color: var(--self-v-muted);
  margin: 8px 0 0;
}
:where(.self-view-missing) {
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace);
  font-size: 0.9em;
  color: var(--doc-muted, #59636e);
}
:where(.self-view) :where(table.self-table) {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 0;
  font-size: 13px;
  border: 1px solid var(--self-v-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--self-v-bg);
}
:where(.self-view) :where(.self-table th, .self-table td) {
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid var(--self-v-border);
  padding: 0 10px;
  height: 34px;
  text-align: start;
  vertical-align: middle;
}
:where(.self-view) :where(.self-table thead th) {
  background: var(--self-v-head);
  font-size: 12px;
  font-weight: 600;
}
:where(.self-view) :where(.self-table tfoot td) {
  background: var(--self-v-head);
  font-size: 12px;
  font-weight: 600;
}
:where(.self-view) :where(.self-table tr.self-group th) {
  background: var(--self-v-panel);
  font-size: 12px;
  font-weight: 650;
  padding-top: 10px;
}
:where(.self-view) :where(.self-table tr.self-group .self-count) {
  margin-left: 8px;
  font-weight: 400;
}
:where(.self-view) :where(.self-table .self-num) {
  text-align: end;
  font-variant-numeric: tabular-nums;
}
:where(.self-view) :where(.self-table td.self-num) {
  white-space: nowrap;
}
:where(.self-view) :where(.self-table .self-calc) {
  color: var(--self-v-muted);
  font-style: italic;
}
:where(.self-view) :where(.self-chip) {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  background: var(--self-v-soft);
}
:where(.self-view) :where(.self-bad) {
  text-decoration: underline wavy;
  text-decoration-color: #c62828;
}
/* Highlights (D259): a row or a card in its colour, a cell in it, bold, faded, struck, marked. */
:where(.self-view) :where(tr.self-look > td) {
  background: color-mix(in srgb, var(--self-look) 9%, var(--self-v-bg));
}
:where(.self-view) :where(tr.self-look > td:first-child) {
  box-shadow: inset 3px 0 0 var(--self-look);
}
:where(.self-view) :where(td.self-look) {
  color: var(--self-look);
  font-weight: 600;
}
:where(.self-view) :where(.self-card.self-look) {
  border-left: 4px solid var(--self-look);
  background: color-mix(in srgb, var(--self-look) 7%, var(--self-v-bg));
}
:where(.self-view) :where(li.self-look) {
  color: var(--self-look);
}
:where(.self-view) :where(.self-is-bold) {
  font-weight: 700;
}
:where(.self-view) :where(.self-is-faded) {
  opacity: 0.55;
}
:where(.self-view) :where(.self-is-strike) {
  text-decoration: line-through;
}
:where(.self-view) :where(.self-mark) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--self-look, #c62828);
  color: #fff;
  font: 700 10.5px/1 var(--doc-font-ui, system-ui, sans-serif);
  vertical-align: 1px;
}
/* Tiles (D186): a large figure each, a ring for a share, bars for the last two weeks. */
:where(.self-view) :where(.self-stats) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
:where(.self-view) :where(.self-stat) {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--self-v-border);
  border-radius: 12px;
  background: var(--self-v-bg);
}
:where(.self-view) :where(.self-stat-figure) {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
:where(.self-view) :where(.self-stat-caption) {
  color: var(--self-v-muted);
  font-size: 12.5px;
}
:where(.self-view) :where(.self-stat.self-has-ring) {
  position: relative;
  padding-right: 68px;
}
:where(.self-view) :where(.self-stat-ring) {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  transform: rotate(-90deg);
}
:where(.self-view) :where(.self-stat-ring circle) {
  fill: none;
  stroke-width: 5;
}
:where(.self-view) :where(.self-stat-ring-track) {
  stroke: var(--self-v-soft);
}
:where(.self-view) :where(.self-stat-ring-fill) {
  stroke: var(--doc-link, #3b6fd8);
  stroke-linecap: round;
}
:where(.self-view) :where(.self-stat-bars) {
  display: block;
  width: 84px;
  height: 24px;
  margin-top: 8px;
}
:where(.self-view) :where(.self-stat-bar) {
  fill: var(--doc-link, #3b6fd8);
  opacity: 0.45;
}
:where(.self-view) :where(.self-stat-bar.self-is-full) {
  opacity: 1;
}
:where(.self-view) :where(.self-stat-bar.self-is-none) {
  fill: var(--self-v-soft);
  opacity: 1;
}
:where(.self-view) :where(.self-cards) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13em, 1fr));
  gap: 0.75em;
}
:where(.self-view) :where(.self-card) {
  border: 1px solid var(--doc-border, #d5dbe1);
  border-radius: 8px;
  padding: 0.6em 0.8em;
  background: var(--doc-bg, transparent);
}
:where(.self-view) :where(.self-card-title) {
  font-weight: 600;
  margin: 0 0 0.25em;
}
:where(.self-view) :where(.self-card dl) {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1em 0.7em;
  margin: 0;
  font-size: 0.92em;
}
:where(.self-view) :where(.self-card dt) {
  color: var(--doc-muted, #59636e);
}
:where(.self-view) :where(.self-card dd) {
  margin: 0;
}
:where(.self-view) :where(.self-board) {
  display: flex;
  gap: 0.75em;
  overflow-x: auto;
  align-items: flex-start;
}
:where(.self-view) :where(.self-board-col) {
  flex: 0 0 15em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  padding: 0.5em;
  border-radius: 10px;
  background: var(--doc-table-head, #f3f5f7);
}
:where(.self-view) :where(.self-group-title) {
  font-weight: 600;
  margin: 0.2em 0;
}
:where(.self-view) :where(.self-count) {
  color: var(--doc-muted, #59636e);
  font-weight: 400;
}
:where(.self-view) :where(.self-list) {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--self-v-border);
  border-radius: 8px;
}
:where(.self-view) :where(.self-list > li) {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 12px;
  border-bottom: 1px solid var(--self-v-border);
}
:where(.self-view) :where(.self-list > li:last-child) {
  border-bottom: 0;
}
:where(.self-view) :where(.self-list .self-card-title) {
  margin: 0;
  font-weight: 700;
}
:where(.self-view) :where(.self-meta) {
  color: var(--self-v-muted);
  font-size: 12.5px;
}
:where(.self-view) :where(.self-list .self-meta) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:where(.self-view) :where(.self-calendar) {
  display: grid;
  gap: 1em;
}
:where(.self-view) :where(table.self-cal) {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}
:where(.self-view) :where(.self-cal caption) {
  text-align: start;
  font-weight: 600;
  padding-bottom: 0.3em;
}
:where(.self-view) :where(.self-cal th, .self-cal td) {
  border: 1px solid var(--doc-border, #d5dbe1);
  padding: 0.25em;
  vertical-align: top;
  height: 3.2em;
  font-size: 0.88em;
}
:where(.self-view) :where(.self-cal th) {
  height: auto;
  background: var(--doc-table-head, #f3f5f7);
}
:where(.self-view) :where(.self-day) {
  display: block;
  color: var(--doc-muted, #59636e);
}
:where(.self-view) :where(.self-event) {
  display: block;
  min-height: 1.35em;
  margin: 1px 0;
  padding: 0 0.3em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 0.3em;
  background: color-mix(in srgb, var(--doc-accent, #0b6bcb) 13%, transparent);
}
/* A date range (D104): one bar across its days, a piece per day. */
:where(.self-view) :where(.self-event-start, .self-event-mid, .self-event-end) {
  margin-inline: calc(-0.25em - 1px);
  padding-inline: calc(0.55em + 1px);
}
:where(.self-view) :where(.self-event-start) {
  margin-inline-start: 0;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}
:where(.self-view) :where(.self-event-mid) {
  border-radius: 0;
}
:where(.self-view) :where(.self-event-end) {
  margin-inline-end: 0;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
:where(.self-view) :where(.self-event-gap) {
  background: none;
}
/* A gantt chart (D104): a label column and a track; bars placed in percent of the range. */
:where(.self-view) :where(.self-gantt) {
  position: relative;
  display: grid;
  gap: 0.3em;
  font-size: 0.9em;
  --self-gantt-label: minmax(7em, 22%);
}
:where(.self-view) :where(.self-gantt-axis, .self-gantt-row) {
  display: grid;
  grid-template-columns: var(--self-gantt-label) 1fr;
  align-items: center;
  gap: 0.8em;
}
:where(.self-view) :where(.self-gantt-axis) {
  height: 1.6em;
  border-bottom: 1px solid var(--doc-border, #d5dbe1);
  color: var(--doc-muted, #59636e);
  font-size: 0.85em;
}
:where(.self-view) :where(.self-gantt-label) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:where(.self-view) :where(.self-gantt-track) {
  position: relative;
  height: 1.7em;
}
:where(.self-view) :where(.self-gantt-tick) {
  position: absolute;
  top: 0.2em;
  padding-inline-start: 0.35em;
  border-inline-start: 1px solid var(--doc-border, #d5dbe1);
  white-space: nowrap;
}
:where(.self-view) :where(.self-gantt-bar) {
  position: absolute;
  top: 0.2em;
  bottom: 0.2em;
  min-width: 0.4em;
  border-radius: 0.35em;
  background: var(--doc-accent, #0b6bcb);
  opacity: 0.85;
}
:where(.self-view) :where(.self-gantt-milestone) {
  position: absolute;
  top: 50%;
  width: 0.8em;
  height: 0.8em;
  translate: -50% -50%;
  rotate: 45deg;
  border-radius: 0.12em;
  background: var(--doc-accent, #0b6bcb);
}
:where(.self-view) :where(.self-gantt-group) {
  margin-top: 0.5em;
  font-weight: 600;
  font-size: 0.9em;
  color: var(--doc-muted, #59636e);
}
:where(.self-view) :where(.self-gantt-today) {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: calc(var(--self-gantt-offset, 0px) + var(--at));
  width: 2px;
  background: #e5484d;
  opacity: 0.7;
  pointer-events: none;
}
:where(.self-view) :where(.self-form) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14em, 1fr));
  gap: 0.6em 1em;
}
:where(.self-view) :where(.self-field) {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  font-size: 0.9em;
}
/* A form with a layout (D170): lines of fields side by side, under their group's heading. */
:where(.self-view) :where(.self-form:has(> .self-row, > .self-group)) {
  display: flex;
  flex-direction: column;
  gap: 0.7em;
}
:where(.self-view) :where(.self-row) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em 1em;
}
:where(.self-view) :where(.self-row > .self-field) {
  flex: 1 1 10em;
  min-width: 0;
}
/* A form's group of fields; a table's group row and a list's group are not boxes. */
:where(.self-view) :where(fieldset.self-group) {
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  margin: 0;
  padding: 0.6em 0.9em 0.9em;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 0.5em;
}
:where(.self-view) :where(div.self-group + div.self-group) {
  margin-top: 14px;
}
:where(.self-view) :where(.self-group > legend) {
  padding: 0 0.4em;
  font-size: 0.85em;
  font-weight: 600;
}
/* A form's lines on a page (D172): an empty table to fill in by hand. */
:where(.self-view) :where(.self-lines) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
:where(.self-view) :where(.self-lines th) {
  padding: 0.3em 0.5em;
  border-bottom: 1px solid currentColor;
  text-align: left;
  font-weight: 600;
}
:where(.self-view) :where(.self-lines td) {
  height: 2em;
  border-bottom: 1px solid color-mix(in srgb, currentColor 25%, transparent);
}
:where(.self-view) :where(.self-field > small) {
  opacity: 0.7;
}
/* Chart views (D134): the engine's SVG in the client chart's card, a legend and the numbers
   behind it for screen readers. The colours are the client's theme palette. */
:where(.self-view) :where(.self-chart) {
  --self-chart-1: var(--ui-accent, #4c6ef5);
  --self-chart-2: var(--ui-success, #2e9d5b);
  --self-chart-3: var(--ui-warning, #d9901a);
  --self-chart-4: var(--syn-directive, #8e5cc2);
  --self-chart-5: var(--syn-style, #1f8a9e);
  --self-chart-6: var(--ui-danger, #d64545);
  --self-chart-7: var(--ui-info, #2f80ed);
  --self-chart-8: var(--syn-attr, #a07c2c);
  --self-chart-bg: color-mix(in srgb, var(--self-v-bg) 96.5%, var(--self-v-fg));
  position: relative;
  margin: 0;
  padding: 18px 20px 14px;
  border: 1px solid var(--self-v-border);
  border-radius: 12px;
  background: var(--self-chart-bg);
  font-family: var(--doc-font-blocks, var(--doc-font-ui, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif));
}
:where(.self-view) :where(.self-chart-plot) {
  margin-top: 6px;
}
:where(.self-view) :where(.self-chart-svg) {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: inherit;
}
:where(.self-view) :where(.self-chart-pie-row) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 36px;
}
:where(.self-view) :where(.self-chart-pie-wrap) {
  flex: 0 1 260px;
  min-width: 180px;
}
:where(.self-view) :where(.self-chart-axis text) {
  font-size: 11px;
  fill: var(--self-v-muted);
  font-variant-numeric: tabular-nums;
}
:where(.self-view) :where(.self-chart-axis-title) {
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--self-v-muted);
}
:where(.self-view) :where(.self-chart-grid) {
  stroke: var(--self-v-border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}
:where(.self-view) :where(.self-chart-zero) {
  stroke: color-mix(in srgb, var(--self-v-fg) 38%, transparent);
  stroke-width: 1;
}
:where(.self-view) :where(.self-chart-value) {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--self-v-fg);
  font-variant-numeric: tabular-nums;
}
:where(.self-view) :where(.self-chart-value-in) {
  fill: var(--doc-bg, #fff);
}
:where(.self-view) :where(.self-chart-slice-label) {
  font-size: 12px;
  font-weight: 700;
  fill: var(--doc-bg, #fff);
}
:where(.self-view) :where(.self-chart-donut-total) {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  fill: var(--doc-heading, var(--self-v-fg));
}
:where(.self-view) :where(.self-chart-donut-label) {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  fill: var(--self-v-muted);
}
:where(.self-view) :where(.self-chart-s1) { --self-c: var(--self-chart-1); }
:where(.self-view) :where(.self-chart-s2) { --self-c: var(--self-chart-2); }
:where(.self-view) :where(.self-chart-s3) { --self-c: var(--self-chart-3); }
:where(.self-view) :where(.self-chart-s4) { --self-c: var(--self-chart-4); }
:where(.self-view) :where(.self-chart-s5) { --self-c: var(--self-chart-5); }
:where(.self-view) :where(.self-chart-s6) { --self-c: var(--self-chart-6); }
:where(.self-view) :where(.self-chart-s7) { --self-c: var(--self-chart-7); }
:where(.self-view) :where(.self-chart-s8) { --self-c: var(--self-chart-8); }
:where(.self-view) :where(.self-chart-bar, .self-chart-slice, .self-chart-dot) {
  fill: var(--self-c);
}
:where(.self-view) :where(.self-chart-slice) {
  stroke: var(--self-chart-bg);
  stroke-width: 2.5;
  stroke-linejoin: round;
  paint-order: stroke;
}
:where(.self-view) :where(.self-chart-dot) {
  stroke: var(--self-chart-bg);
  stroke-width: 2;
}
:where(.self-view) :where(.self-chart-line) {
  fill: none;
  stroke: var(--self-c);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}
:where(.self-view) :where(.self-chart-area) {
  fill: var(--self-c);
  fill-opacity: 0.18;
}
/* The legend, over the chart (beside a pie): the client's buttons, as still labels. */
:where(.self-view) :where(.self-chart-legend) {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
:where(.self-view) :where(.self-chart-legend > li) {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 9px 5px 7px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
}
:where(.self-view) :where(.self-chart-legend-pie) {
  flex-direction: column;
  flex: 0 1 260px;
  gap: 2px;
}
:where(.self-view) :where(.self-chart-legend-pie > li) {
  box-sizing: border-box;
  width: 100%;
}
:where(.self-view) :where(.self-chart-legend-value) {
  margin-left: auto;
  padding-left: 10px;
  color: var(--self-v-muted);
  font-variant-numeric: tabular-nums;
}
:where(.self-view) :where(.self-chart-swatch) {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--self-c);
}
/* The numbers behind the chart, for screen readers: in the page, out of sight. */
:where(.self-view) :where(.self-chart-table) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ notes, citations, equations, terms, progress (D86-D91) */

/* The static output of the built-in cross-reference plugins, for every host. Zero
   specificity, colours only through document tokens. */
:where(details) > :where(summary) {
  cursor: pointer;
  font-weight: 600;
}
:where(.self-fnref) {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}
:where(.self-fnref) :where(a) {
  padding: 0 0.12em;
  text-decoration: none;
}
:where(.self-footnote) {
  display: flex;
  gap: 0.55em;
  margin: 0 0 0.4em;
  font-size: 0.9em;
  color: var(--doc-muted, inherit);
}
:where(.self-footnote) :where(.self-fn-num) {
  flex: none;
  min-width: 1.5em;
  text-align: end;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
:where(.self-footnote) :where(.self-fn-body) {
  flex: 1;
  min-width: 0;
}
:where(.self-footnote) :where(.self-fn-body > :last-child) {
  margin-bottom: 0;
}
:where(.self-fn-unused) :where(.self-fn-num) {
  opacity: 0.6;
}
:where(.self-footnote:target, .self-fnref:target, .self-bibliography li:target, .self-equation:target) {
  background: var(--doc-mark-bg, #fff0a6);
  border-radius: 3px;
}
:where(.self-cite) :where(a) {
  text-decoration: none;
}
:where(.self-cite) :where(.self-bad) {
  text-decoration: underline wavy;
  opacity: 0.7;
}
:where(.self-bibliography) {
  list-style: none;
  padding-left: 2em;
}
:where(.self-bibliography) :where(li) {
  margin: 0 0 0.55em;
  text-indent: -2em;
}
:where(.self-bibliography-empty, .self-bibliography-missing) {
  color: var(--doc-muted, inherit);
  font-style: italic;
}
:where(.self-equation) {
  display: flex;
  align-items: center;
  gap: 1em;
  margin: 1em 0;
}
:where(.self-equation) :where(.self-math-display) {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  text-align: center;
}
:where(.self-eqno) {
  flex: none;
  color: var(--doc-muted, inherit);
  font-variant-numeric: tabular-nums;
}
:where(.self-eqref) {
  white-space: nowrap;
  text-decoration: none;
}
/* Numbered blocks and references (D140): figures and tables with a caption, theorems with a
   run-in head. */
:where(figure.self-numbered) {
  margin: 1.2em 0;
}
:where(figure.self-numbered) :where(img, svg) {
  display: block;
  margin-inline: auto;
}
:where(.self-num-caption) {
  margin: 0.5em 0;
  font-size: 0.92em;
  color: var(--doc-muted, inherit);
  text-align: center;
}
/* The label of a numbered block; a data view's number cell (`td.self-num`) is not one. */
:where(span.self-num) {
  font-weight: 600;
  color: var(--doc-fg, inherit);
}
:where(div.self-numbered) {
  margin: 1em 0;
}
:where(div.self-numbered) :where(.self-num-head) {
  font-style: normal;
}
:where(.self-kind-theorem, .self-kind-lemma, .self-kind-corollary, .self-kind-proposition) > :where(p) {
  font-style: italic;
}
:where(.self-num-title) {
  font-weight: 400;
}
:where(.self-ref) {
  white-space: nowrap;
  text-decoration: none;
}
:where(.self-numbered:target) {
  background: var(--doc-mark-bg, #fff0a6);
  border-radius: 3px;
}
:where(abbr.self-term) {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  cursor: help;
}
:where(.self-term-def) {
  display: grid;
  grid-template-columns: minmax(7em, max-content) 1fr;
  gap: 0.2em 1.2em;
  margin: 0 0 0.45em;
}
:where(.self-term-def) :where(dt) {
  font-weight: 600;
}
:where(.self-term-def) :where(dd) {
  margin: 0;
}
:where(.self-progress) {
  display: grid;
  grid-template-columns: auto minmax(4em, 1fr) auto;
  align-items: center;
  gap: 0.4em 0.9em;
  margin: 0 0 var(--doc-gap, 1em);
  font-size: 0.92em;
}
:where(.self-progress) :where(.self-progress-label) {
  font-weight: 600;
}
:where(.self-progress) :where(.self-progress-track) {
  display: block;
  height: 0.5em;
  border-radius: 99px;
  background: color-mix(in srgb, currentColor 13%, transparent);
  overflow: hidden;
}
:where(.self-progress) :where(.self-progress-fill) {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--doc-link, #0b5cc7);
}
:where(.self-progress) :where(.self-progress-count) {
  color: var(--doc-muted, inherit);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ print */

@media print {
  .self-page.self-s-dark {
    --doc-bg: #ffffff !important;
    --doc-fg: #111111 !important;
    --doc-muted: #555555 !important;
    --doc-heading: #000000 !important;
    --doc-link: #1a3f8f !important;
    --doc-code-bg: #f2f2f2 !important;
    --doc-code-fg: #111111 !important;
    --doc-border: #bbbbbb !important;
    --doc-quote-bar: #bbbbbb !important;
    --doc-mark-bg: #f3e6a0 !important;
    --doc-table-head: #f2f2f2 !important;
    color-scheme: light;
  }
  .self-page {
    background: none !important;
  }
  .self-page.self-s-paper .self-doc {
    margin: 0 auto !important;
    padding: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }

  /* Where pages break, for every printed page: the app's PDF export and `self pdf` alike. All
     of it is :where(), so a document's own print rules win. */
  /* A heading is never the last thing on a page, and is never cut. */
  :where(.self-doc) :where(h1, h2, h3, h4, h5, h6) { break-after: avoid; break-inside: avoid; }
  /* Small things stay whole where they fit on a page: a picture and its caption, code, a quote,
     a callout, a drawn block (a chart, a diagram, a score), a box at the foot of the page. One
     taller than a page runs on. */
  :where(.self-doc) :where(figure, img, svg, video, pre, blockquote, aside, footer, details, .self-callout, [data-self-plugin]) {
    break-inside: avoid;
  }
  /* So does a box the document draws around a drawn block, so no empty box is left at the foot
     of a page while what it holds moves to the next. */
  :where(.self-doc) :where(:is(div, section, article):has(> :is(figure, [data-self-plugin]:not(.self-view), .self-view-chart, .self-view-stats, .self-view-heat, .self-view-map))) {
    break-inside: avoid;
  }
  /* Tables, data views and lists run on to the next page between rows and items; a table's
     header row is printed again at the top of each page. Totals are printed once, at the end.
     Charts and tiles drawn from data stay whole. */
  :where(.self-doc) :where(table, ul, ol, dl, .self-view) { break-inside: auto; }
  :where(.self-doc) :where(.self-view-chart, .self-view-stats, .self-view-heat, .self-view-map) { break-inside: avoid; }
  :where(.self-doc) :where(thead) { display: table-header-group; }
  :where(.self-doc) :where(tfoot) { display: table-row-group; }
  :where(.self-doc) :where(tr, li, dt, dd) { break-inside: avoid; }
  /* A page break line starts a new page and takes no room. */
  :where(.self-doc) :where(.self-pagebreak) { break-after: page; border: 0; margin: 0; height: 0; visibility: hidden; }
}

/* ------------------------------------------------------------------ data: ratings and switches (D109) */
:where(.self-base) :where(.self-rating) { white-space: nowrap; letter-spacing: 0.05em; }
:where(.self-base) :where(.self-star) { color: color-mix(in srgb, currentColor 30%, transparent); }
:where(.self-base) :where(.self-star.self-on) { color: #e8a317; }
:where(.self-base) :where(input.self-switch) { appearance: none; -webkit-appearance: none; position: relative; width: 30px; height: 17px; margin: 0; border-radius: 99px; background: color-mix(in srgb, currentColor 25%, transparent); vertical-align: middle; }
:where(.self-base) :where(input.self-switch)::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; }
:where(.self-base) :where(input.self-switch:checked) { background: var(--doc-link, #0b5cc7); }
:where(.self-base) :where(input.self-switch:checked)::after { left: 15px; }
