/* selfscribe.dev: the site chrome. One look, light or dark: Instrument Sans for everything a
   reader scans, Newsreader italic for a word of emphasis, the brand's orange as the only
   strong colour. `data-theme` on <html> (or the system) picks light or dark. Document
   typography for previews is in doc.css; the article's here. */

@font-face { font-family: 'Newsreader Variable'; font-style: italic; font-weight: 200 800; font-display: swap; src: url('fonts/newsreader-italic.woff2') format('woff2'); }
@font-face { font-family: 'Newsreader Variable'; font-style: normal; font-weight: 200 800; font-display: swap; src: url('fonts/newsreader-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/plex-mono-600.woff2') format('woff2'); }
@font-face { font-family: 'Instrument Sans Variable'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('fonts/instrument-sans.woff2') format('woff2'); }

/* ---- tokens, light (every token defined here first) ----------------------------------- */
:root {
  color-scheme: light;
  --bg: #fcfcfa;
  --surface: #ffffff;
  --surface-2: #f5f5f2;
  --fg: #16181d;
  --muted: #5d636d;
  --border: #e7e6e1;
  --border-strong: #d0cfc8;
  --accent: #d9531f;
  --accent-2: #b8448f;
  --accent-fg: #ffffff;
  --link: #c2410c;
  --code-bg: #f7f6f3;
  --code-inline-bg: rgba(120, 112, 96, 0.11);
  --selection: rgba(217, 83, 31, 0.16);
  --active-line: rgba(217, 83, 31, 0.05);
  --mark-bg: #f6e6a4;
  --table-head-bg: #f5f5f2;
  --error: #b42318;
  --warning: #8a5a00;
  --info: #1f5fbf;
  --note-bg: #fdf4ee;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 18px 48px -24px rgba(40, 30, 20, 0.28);
  --serif: 'Newsreader Variable', 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --ui: 'Instrument Sans Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sans: var(--ui);
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  --heading: var(--ui);
  --topbar: 60px;
  --margin: 260px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0f12;
    --surface: #15171b;
    --surface-2: #1b1d22;
    --fg: #eceef2;
    --muted: #9aa0aa;
    --border: #25282e;
    --border-strong: #383c44;
    --accent: #f07a45;
    --accent-2: #e27ab8;
    --accent-fg: #170a04;
    --link: #f5936a;
    --code-bg: #131519;
    --code-inline-bg: rgba(190, 180, 160, 0.13);
    --selection: rgba(240, 122, 69, 0.26);
    --active-line: rgba(240, 122, 69, 0.07);
    --mark-bg: #5a4a14;
    --table-head-bg: #1b1d22;
    --error: #ff8a7a;
    --warning: #e2b34a;
    --info: #7fb2ff;
    --note-bg: #2a1f18;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f12;
  --surface: #15171b;
  --surface-2: #1b1d22;
  --fg: #eceef2;
  --muted: #9aa0aa;
  --border: #25282e;
  --border-strong: #383c44;
  --accent: #f07a45;
  --accent-2: #e27ab8;
  --accent-fg: #170a04;
  --link: #f5936a;
  --code-bg: #131519;
  --code-inline-bg: rgba(190, 180, 160, 0.13);
  --selection: rgba(240, 122, 69, 0.26);
  --active-line: rgba(240, 122, 69, 0.07);
  --mark-bg: #5a4a14;
  --table-head-bg: #1b1d22;
  --error: #ff8a7a;
  --warning: #e2b34a;
  --info: #7fb2ff;
  --note-bg: #2a1f18;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -24px rgba(0, 0, 0, 0.7);
}

*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-padding-top: calc(var(--topbar) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }

/* ---- top bar ------------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--ui);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--fg); text-decoration: none; }
.brand .mark { width: 24px; height: 24px; flex: none; }
.wordmark { font: 650 17px/1 var(--ui); letter-spacing: -0.02em; }
.topnav { display: flex; gap: 2px; }
.topnav a,
.top-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 10px;
  transition: color 0.15s;
}
.topnav a:hover,
.top-link:hover { color: var(--fg); }
/* The section you are in: its name in full colour, underlined in the accent. */
.topnav a[aria-current="page"],
.top-link[aria-current="page"] { color: var(--fg); text-decoration: underline 2px var(--accent); text-underline-offset: 9px; }
.topbar-gap { flex: 1; }
.open-app {
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-fg);
  background: var(--accent);
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
}
.open-app:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--fg); border-color: var(--border); }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon .i-sun { display: none; }
#theme-toggle[aria-pressed="true"] .i-sun { display: inline; }
#theme-toggle[aria-pressed="true"] .i-moon { display: none; }
.menu-btn { display: none; }
.brand, .topnav, .topbar > a, .topbar > button { flex: none; }
.topnav a, .top-link { white-space: nowrap; }

/* A narrower window: tighter spacing, then the least-used links fold away (Spec, then the
   Dictionary; layout.ts marks them). The page list keeps them, and pages without
   one show the menu, which leads to it. At 860 and under, the menu takes the rest. */
@media (max-width: 1180px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar [data-fold="1"] { display: none; }
  body:not(:has(.sidebar)) .menu-btn { display: grid; }
}
@media (max-width: 1060px) {
  .topbar [data-fold="2"] { display: none; }
}

/* ---- documentation layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  max-width: 1480px;
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: var(--topbar);
  align-self: start;
  max-height: calc(100vh - var(--topbar));
  overflow: auto;
  padding: 30px 14px 40px 22px;
  font: 14px/1.4 var(--ui);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - var(--topbar));
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.nav-group + .nav-group { margin-top: 24px; }
.nav-title {
  font: 600 11px var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 8px 10px;
}
.sidebar a {
  display: block;
  padding: 5px 10px;
  color: var(--fg);
  text-decoration: none;
  border-radius: 7px;
  transition: background 0.12s, color 0.12s;
}
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { font-weight: 600; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--fg); }
/* The page's own outline, under its entry. */
.sidebar .outline { margin: 4px 0 8px 12px; border-left: 1px solid var(--border); }
.sidebar .outline a { color: var(--muted); font-size: 13px; padding: 3px 10px; border-radius: 0; background: none; }
.sidebar .outline a:hover { color: var(--fg); }
.sidebar .outline .toc-3 a { padding-left: 22px; font-size: 12.5px; }
.sidebar .outline a.on { color: var(--accent); }

.content { min-width: 0; padding: 48px 48px 72px; }
.content > .self-doc { max-width: 74ch; margin: 0 auto; position: relative; }
/* Margin notes are floats: the article holds them, so the last one never runs into the footer. */
.content > .self-doc.proof { display: flow-root; }
.footer {
  max-width: 74ch;
  margin: 64px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font: 13px/1.6 var(--ui);
  color: var(--muted);
}
.footer p { margin: 0 0 8px; }
.footer a { color: inherit; }
.footer code { font-family: var(--mono); font-size: 0.92em; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; }

/* The article with its margin: on wide screens notes stand beside the line they belong to;
   narrower, they gather at the end as footnotes. */
@media (min-width: 1240px) {
  .content > .self-doc.proof { max-width: calc(70ch + var(--margin)); padding-right: var(--margin); }
  .footer { max-width: calc(70ch + var(--margin)); padding-right: var(--margin); }
  .self-doc .self-footnote.has-margin-note { display: none; }
}
@media (max-width: 1239.98px) {
  .self-doc .margin-note { display: none; }
}
@media (max-width: 1060px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .content { padding: 36px 32px 56px; }
  .topnav a { padding: 6px 8px; }
}
/* Narrow: the page list is a menu the top bar's button opens. */
@media (max-width: 860px) {
  .layout { display: block; }
  .topbar { gap: 10px; padding: 0 14px; }
  .topnav, .top-link { display: none; }
  .menu-btn { display: grid; }
  .open-app { padding: 7px 11px; }
  .sidebar {
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 25;
    max-height: none;
    min-height: 0;
    padding: 18px 18px 40px;
    border: 0;
    background: var(--bg);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
  }
  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { opacity: 1; transform: none; visibility: visible; }
  .sidebar a { padding: 9px 10px; font-size: 15px; }
  .content { padding: 26px 18px 48px; }
}
/* A small phone: the mark without the name, so the app's button and the menu keep their room. */
@media (max-width: 400px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .wordmark { display: none; }
}

/* ---- the article ----------------------------------------------------------------------- */

.content > .self-doc.proof { font: 16.5px/1.7 var(--ui); }
.self-doc.proof h1 { font: 680 2.4em/1.06 var(--heading); letter-spacing: -0.035em; margin: 0 0 0.6em; }
.self-doc.proof h2 { font: 650 1.45em/1.2 var(--heading); letter-spacing: -0.02em; border-bottom: 0; padding-bottom: 0; margin-top: 2.1em; }
.self-doc.proof h3 { font: 620 1.15em/1.3 var(--heading); letter-spacing: -0.01em; }
.self-doc.proof h4 { font-weight: 600; }
.self-doc.proof a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; }
.self-doc.proof a:hover { text-decoration-color: currentColor; }
.self-doc.proof code { font-size: 0.86em; }
.self-doc.proof table { font-size: 0.9em; }
.self-doc.proof blockquote { border-left-color: var(--accent); color: var(--fg); }
.self-doc.proof .self-fnref a { color: var(--accent); text-decoration: none; font-family: var(--mono); font-weight: 600; font-size: 0.85em; }
.self-doc.proof .self-footnote { font-size: 0.88em; color: var(--muted); }

/* Margin notes: footnotes drawn beside their line. */
.self-doc .margin-note {
  float: right;
  clear: right;
  width: calc(var(--margin) - 44px);
  margin: 0.35em calc(-1 * var(--margin)) 1em 0;
  padding-left: 0.9em;
  border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  font: 0.8em/1.5 var(--ui);
  color: var(--muted);
}
.self-doc .margin-note a { color: inherit; }
.mn-num {
  display: inline-grid;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  margin-right: 0.45em;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: normal 600 0.72em/1 var(--mono);
  vertical-align: 0.1em;
}

/* ---- buttons ---------------------------------------------------------------------------- */

/* Two kinds: the one thing to do (the accent, filled) and the rest (a hairline). One radius, no
   lift, no glow. */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 15px/1 var(--ui);
  text-decoration: none;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.cta-primary { color: var(--accent-fg); background: var(--accent); }
.cta-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.cta-ghost { color: var(--fg); background: transparent; border-color: var(--border-strong); }
.cta-ghost:hover { border-color: var(--fg); }
.cta-big { font-size: 16px; padding: 14px 22px; }

/* ---- the front page and the examples: showcase.css ------------------------------------- */

/* ---- downloads ------------------------------------------------------------------------ */

.downloads { margin: 1.4em 0 2.4em; font-family: var(--ui); }
.dl-status { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.dl-card { position: relative; padding: 18px 20px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; }
.dl-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 0 0 22px; }
.dl-main-note { font-size: 14px; color: var(--muted); }
.self-doc.proof .cta { text-decoration: none; }
.self-doc.proof .cta-primary { color: var(--accent-fg); }
.self-doc.proof .cta-ghost { color: var(--fg); }
.dl-card.dl-mine { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* The donate page's button, or its line while donations are not open (donate.ts). */
.self-doc .donate { margin: 22px 0 28px; }
.self-doc .donate-soon { margin: 22px 0 28px; padding: 12px 16px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; color: var(--muted); font-family: var(--ui); }
.dl-badge { position: absolute; top: -10px; right: 12px; font: 600 10.5px var(--ui); letter-spacing: 0.06em; text-transform: uppercase; background: var(--accent); color: var(--accent-fg); padding: 3px 8px; border-radius: 99px; }
.self-doc.proof .dl-os { font: 650 19px/1.2 var(--heading); letter-spacing: -0.015em; margin: 0; border: 0; padding: 0; }
.self-doc .dl-note { margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.self-doc .dl-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.self-doc .dl-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--border); margin: 0; }
.dl-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.dl-missing { opacity: 0.45; }

/* Heading anchors. */
.h-wrap { position: relative; }
.h-link {
  position: absolute;
  left: -1.15em;
  top: 0;
  padding-right: 0.3em;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.12s;
}
.h-wrap:has(h2) .h-link { top: 2.2rem; font-size: 1.35em; line-height: 1.3; }
.h-wrap:has(h3) .h-link { top: 1.65rem; font-size: 1.1em; line-height: 1.35; }
.h-wrap:hover .h-link,
.h-link:focus { opacity: 1; }
.self-doc a.xref { text-decoration-style: dotted; }
.part { margin-top: 3.5em; padding-top: 1.5em; border-top: 3px double var(--border); }
.part > h1:first-child { font-size: 1.8em; }

/* ---- code blocks --------------------------------------------------------------------- */

.codeblock {
  margin: 0 0 1.3em;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--code-bg);
}
.cb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 3px 6px 3px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1;
}
.cb-label { font-family: var(--mono); color: var(--muted); }
.codeblock[data-live] .cb-label { color: var(--link); font-weight: 600; }
.cb-actions { display: flex; gap: 6px; }
.cb-btn {
  font: 500 12px var(--sans);
  line-height: 1.2;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.cb-btn:hover { border-color: var(--border-strong); }
.cb-btn:disabled { opacity: 0.6; cursor: progress; }
.cb-try { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.cb-try:hover { filter: brightness(1.08); border-color: var(--accent); }
.cb-try[aria-pressed="true"] { background: var(--surface); color: var(--fg); border-color: var(--border); font-weight: 500; }
/* Opened from disk the engine cannot start (client/engine.ts), so nothing offers to run it. */
.is-file .cb-try { display: none; }
.self-doc .codeblock pre { margin: 0; border-radius: 0; background: transparent; }

/* ---- live examples ------------------------------------------------------------------- */

.live-note { margin: 0 !important; padding: 7px 12px; font-size: 13px; background: var(--note-bg); border-bottom: 1px solid var(--border); }
.live-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 150px; }
.live-editor { min-width: 0; max-height: 520px; overflow: auto; border-right: 1px solid var(--border); }
.live-editor .cm-editor { min-height: 100%; }
.live-out { min-width: 0; max-height: 520px; overflow: auto; background: var(--surface); padding: 10px 16px 14px; }
.live-caption,
.tpl-caption {
  font: 700 10.5px var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.preview-host { display: block; }
.live-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 8px 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
}
.live-links { display: flex; gap: 6px; }
.codeblock .diag-list:empty { display: none; }
.codeblock .diag-list { border-top: 1px solid var(--border); background: var(--surface); }
@media (max-width: 900px) {
  .live-grid { grid-template-columns: minmax(0, 1fr); }
  .live-editor { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Diagnostics (live examples, templates, playground). */
.diag-list,
.self-doc .diag-list { list-style: none; margin: 0; padding: 0; font: 12.5px/1.45 var(--mono); }
.self-doc .diag-list li { margin: 0; }
.diag { padding: 3px 12px; }
.diag-sev { font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.05em; }
.diag-error .diag-sev { color: var(--error); }
.diag-warning .diag-sev { color: var(--warning); }
.diag-info .diag-sev { color: var(--info); }
.diag-pos { color: var(--muted); }
.diag-jump {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  border-radius: 4px;
}
.diag-jump:hover,
.diag-jump:focus-visible { background: var(--active-line); outline: none; text-decoration: underline; }
.diag:has(.diag-jump) { padding: 0; }
.diag-jump { padding: 3px 12px; box-sizing: border-box; }

/* ---- templates page ------------------------------------------------------------------ */

.tpl { margin-bottom: 3em; }
.tpl-use { font-size: 0.6em !important; vertical-align: 0.25em; margin-left: 0.4em; font-weight: 500; }
.tpl-links { margin: -0.3em 0 1em; }
.btn-link { font-size: 14px; font-weight: 600; }
.tpl-sample { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tpl-sample .codeblock { margin: 0; }
.tpl-sample-out .preview-host {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 18px;
  background: var(--surface);
}
.tpl-sample-out .diag-list { margin-top: 8px; }
@media (max-width: 900px) {
  .tpl-sample { grid-template-columns: minmax(0, 1fr); }
}

/* ---- playground ---------------------------------------------------------------------- */

body.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.pg { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.pg-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}
.pg-field { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.pg-field select,
.btn {
  font: 500 13.5px var(--sans);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
}
.btn:hover,
.pg-field select:hover { border-color: var(--border-strong); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: 500 13px var(--sans);
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 5px 13px;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.spacer { flex: 1; }
.pg-status { color: var(--muted); font-size: 13px; }
a.btn { display: inline-block; text-decoration: none; }

.pg-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; }
.pg[data-mode="source"] .pg-main,
.pg[data-mode="hybrid"] .pg-main,
.pg[data-mode="preview"] .pg-main { grid-template-columns: minmax(0, 1fr); }
.pg[data-mode="source"] .pg-right,
.pg[data-mode="hybrid"] .pg-right,
.pg[data-mode="preview"] .pg-editor { display: none; }
.pg-editor { position: relative; min-height: 0; border-right: 1px solid var(--border); }
.pg-editor-host { position: absolute; inset: 0; }
.pg-editor-host .cm-editor { height: 100%; }
.pg-editor-host .cm-editor .cm-content { padding-bottom: 30vh; }
.pg[data-mode="hybrid"] .pg-editor-host .cm-content,
.pg[data-mode="source"] .pg-editor-host .cm-content { max-width: 920px; }
.pg-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tabs button {
  font: 500 13px var(--sans);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  padding: 8px 12px 7px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.pg-pane { position: relative; flex: 1; min-height: 0; }
.pg-preview { background: var(--surface); }
.pg-ast { overflow: auto; background: var(--code-bg); }
.pg-ast-note { margin: 0; padding: 8px 16px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--border); }
.pg-ast-note code { font-family: var(--mono); }
.pg-ast pre { margin: 0; padding: 12px 16px; font: 12.5px/1.5 var(--mono); tab-size: 2; }
.pg-diags { max-height: 24vh; overflow: auto; border-top: 1px solid var(--border); background: var(--surface-2); }
.pg-diags-head { position: sticky; top: 0; padding: 6px 16px; font-size: 13px; background: var(--surface-2); }
.pg-diags-title { font-weight: 600; }
.pg-diags .diag-list { padding-bottom: 4px; }
.noscript { padding: 2em; }
/* Opened from disk: the preview says why it stays empty (bodies.ts). */
.pg-file-note { display: none; }
.is-file .pg-file-note { display: block; max-width: 34em; margin: 0; padding: 24px; font: 15px/1.6 var(--ui); color: var(--muted); }
@media (max-width: 820px) {
  .pg-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .pg-editor { border-right: 0; border-bottom: 1px solid var(--border); }
  .pg[data-mode="preview"] .pg-main,
  .pg[data-mode="source"] .pg-main,
  .pg[data-mode="hybrid"] .pg-main { grid-template-rows: minmax(0, 1fr); }
}

/* ---- dictionary page (v1.2 track H) ---------------------------------------------------- */

.dict-lead { font-size: 1.08em; color: var(--muted); }
.dict-index {
  display: grid;
  gap: 8px;
  margin: 1.2em 0 2em;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13.5px;
  line-height: 1.7;
}
.dict-index-title { font-weight: 700; margin-right: 6px; }
.dict-cat-summary { margin-top: -0.4em; }
.dict-entry { margin: 0 0 2.4em; padding-top: 0.2em; }
.dict-entry h3 { display: flex; align-items: baseline; gap: 10px; }
.dict-word { font-family: var(--mono); font-weight: 650; }
.dict-kind {
  font: 600 11px/1 var(--sans);
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  letter-spacing: 0.02em;
}
.dict-summary { font-size: 1.05em; color: var(--muted); margin-top: -0.3em; }
.dict-syntax pre { margin: 0 0 1em; }
.dict-example { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; margin: 0.6em 0 1em; }
.dict-example .codeblock { margin: 0; }
.dict-note { margin: 8px 0 0; font-size: 13px; color: var(--warning); }
.dict-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }
.dict-see { margin-left: 4px; }
.dict-spec a { font-family: var(--mono); font-size: 12px; }
@media (max-width: 900px) {
  .dict-example { grid-template-columns: minmax(0, 1fr); }
}
.dict-index a { text-decoration: none; }
.dict-index a:hover { text-decoration: underline; }
.dict-index .dict-index-title { color: var(--fg); }
