/* Scribe's website is set like the papers Scribe writes: an article in Latin Modern, with
   numbered sections, captioned figures and a booktabs table. The app windows inside it keep
   the app's own dark, warm palette. */

@font-face { font-family: "Latin Modern"; src: url("assets/fonts/LM-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Latin Modern"; src: url("assets/fonts/LM-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Latin Modern"; src: url("assets/fonts/LM-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Latin Modern"; src: url("assets/fonts/LM-bold-italic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --paper: #fffefb;
  --ink: #111;
  --ink-soft: #3a3a3a;
  --rule: #111;
  --hairline: #d8d4cb;
  --link: #8c1d18;          /* hyperref's dark red */
  --app-bg: #111110;        /* the app's own colours, inside the windows */
  --app-panel: #171716;
  --app-border: #2b2a28;
  --app-accent: #d4a556;
  /* code: gruvbox light here, gruvbox dark in the dark theme */
  --code-bg: #fcfbf8;
  --code-fg: #3c3836;
  --syn-cmd: #af3a03;
  --syn-brace: #7c6f64;
  --syn-cmt: #928374;
  --syn-math: #076678;
  --syn-num: #8f3f71;
  --syn-str: #79740e;
  --gutter: #bdae93;
  --caret: #b5832c;
  --desk: #efece5;          /* behind the page on the first screen */
  --sheet-edge: #d9d4c8;
  --dashed: #b8b2a6;
  --button-bg: var(--ink);
  --button-fg: var(--paper);
  --button-hover: #3c3836;
  --button-cmd: #fabd2f;
  --button-brace: #a89984;
  --window-bar: #ece9e3;
  --window-edge: #cbc5b8;
  /* on the white page the first screen's window lifts off it a little; on black it doesn't */
  --window-shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 18px 44px -12px rgba(40, 30, 10, .22);
  color-scheme: light;
  --serif: "Latin Modern", "CMU Serif", "Computer Modern Serif", "Latin Modern Roman", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 36rem;
  --wide: 76rem;
}

/* \pagecolor{black}: the system's dark mode, unless the visitor picked a colour in the menu */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141312;
    --ink: #ebe7de;
    --ink-soft: #b5afa3;
    --rule: #ebe7de;
    --hairline: #34312c;
    --link: #e3a072;
    --code-bg: #1a1917;
    --code-fg: #ebdbb2;
    --syn-cmd: #fe8019;
    --syn-brace: #a89984;
    --syn-cmt: #928374;
    --syn-math: #83a598;
    --syn-num: #d3869b;
    --syn-str: #b8bb26;
    --gutter: #665c54;
    --caret: #d4a556;
    --desk: #0e0d0c;
    --sheet-edge: #3a3732;
    --dashed: #5a554d;
    --button-bg: #ebe7de;
    --button-fg: #141312;
    --button-hover: #d5d0c5;
    --button-cmd: #af3a03;
    --button-brace: #7c6f64;
    --window-bar: #1f1e1c;
    --window-edge: #3a3732;
    --window-shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141312;
  --ink: #ebe7de;
  --ink-soft: #b5afa3;
  --rule: #ebe7de;
  --hairline: #34312c;
  --link: #e3a072;
  --code-bg: #1a1917;
  --code-fg: #ebdbb2;
  --syn-cmd: #fe8019;
  --syn-brace: #a89984;
  --syn-cmt: #928374;
  --syn-math: #83a598;
  --syn-num: #d3869b;
  --syn-str: #b8bb26;
  --gutter: #665c54;
  --caret: #d4a556;
  --desk: #0e0d0c;
  --sheet-edge: #3a3732;
  --dashed: #5a554d;
  --button-bg: #ebe7de;
  --button-fg: #141312;
  --button-hover: #d5d0c5;
  --button-cmd: #af3a03;
  --button-brace: #7c6f64;
  --window-bar: #1f1e1c;
  --window-edge: #3a3732;
  --window-shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }

body {
  font: 1.125rem/1.55 var(--serif);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
code { font: 0.86em var(--mono); }

/* the text column, with figures allowed to run wider */
.article {
  display: grid;
  grid-template-columns: [full-start] minmax(1.25rem, 1fr) [wide-start] minmax(0, calc((var(--wide) - var(--measure)) / 2)) [text-start] min(var(--measure), calc(100% - 2.5rem)) [text-end] minmax(0, calc((var(--wide) - var(--measure)) / 2)) [wide-end] minmax(1.25rem, 1fr) [full-end];
  padding: 4.5rem 0 3rem;
}
.article > *, .article section > * { grid-column: text; }
.article > .wide, .article section > .wide { grid-column: wide; }
/* sections share the article's columns, so their figures can run wide too */
.article > section { grid-column: full; display: grid; grid-template-columns: subgrid; align-content: start; }

/* ── \maketitle ── */
.maketitle { text-align: center; }
.logo { display: block; margin: 0 auto 1.4rem; border-radius: 14px; }
.maketitle h1 { font-size: 3.4rem; font-weight: 400; line-height: 1.05; letter-spacing: -0.005em; }
.subtitle { margin-top: 0.5rem; font-size: 1.55rem; font-style: italic; }
.author { margin-top: 1.6rem; font-size: 1.2rem; }
.date { margin-top: 0.3rem; font-size: 1.05rem; }

.abstract { margin: 2.6rem auto 0; padding: 0 2.2rem; font-size: 0.97rem; }
.abstract h2 { margin-bottom: 0.4rem; font-size: 1rem; text-align: center; }
.abstract p { text-align: justify; hyphens: auto; }

.download { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem 1.2rem; margin-top: 2rem; }
/* a framed box, the way \fbox draws one, filled */
.button {
  display: inline-block;
  padding: 0.5rem 1.15rem 0.55rem;
  color: var(--button-fg);
  background: var(--button-bg);
  border: 1px solid var(--button-bg);
  font-size: 1.05rem;
  transition: background 150ms ease, color 150ms ease;
}
.button:hover { color: var(--ink); background: transparent; text-decoration: none; }
.download-note { font-size: 0.95rem; font-style: italic; color: var(--ink-soft); }

/* ── sections, numbered like \section ── */
section { margin-top: 3.2rem; }
section h2 { margin-bottom: 0.8rem; font-size: 1.44rem; font-weight: 700; line-height: 1.25; }
/* numbered by main.js (data-n): WebKit miscounts CSS counters once the first screen re-renders its page */
section h2[data-n]::before { content: attr(data-n); display: inline-block; min-width: 2.1rem; }
section > p, .feature-text > p { text-align: justify; hyphens: auto; }
section > p + p, .feature-text > p + p { text-indent: 1.5em; }
section.abstract > h2::before, section.appendix > h2::before { content: none; }
.appendix-label { display: inline-block; min-width: 2.1rem; }
.appendix ol { margin: 0.4rem 0 0 1.6rem; }
.appendix li + li { margin-top: 0.3rem; }
.signature { margin-top: 0.8rem; text-align: right; font-style: italic; text-indent: 0 !important; }

/* ── figures ── */
figure { margin: 1.8rem 0 0.4rem; }
figcaption { max-width: var(--measure); margin: 0.75rem auto 0; font-size: 0.95rem; line-height: 1.45; text-align: center; }
.label { font-weight: 700; }

/* an app window: the app's dark chrome on the white page, flat, with a hairline edge */
.window { overflow: hidden; background: var(--app-bg); border: 1px solid #000; border-radius: 10px; }
.window video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; background: var(--app-bg); cursor: pointer; }
.window-bar { display: flex; gap: 8px; height: 30px; align-items: center; padding: 0 12px; background: var(--app-panel); border-bottom: 1px solid var(--app-border); }
.window-bar span { width: 11px; height: 11px; border-radius: 50%; background: #3a3936; }
.window-bar span:nth-child(1) { background: #ec6a5e; }
.window-bar span:nth-child(2) { background: #f4bf4f; }
.window-bar span:nth-child(3) { background: #61c554; }
.demo .window { position: relative; }
.demo .window[data-paused]::after {
  content: "▶";
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  translate: -50% -50%;
  color: #fff;
  font-size: 1.1rem;
  background: rgba(17, 17, 16, .72);
  border-radius: 50%;
  pointer-events: none;
}

/* ── the hero: the whole first screen. LaTeX typed on the left, the page it makes on the right ── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hero { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: calc(100vh - var(--bar-h)); height: calc(100svh - var(--bar-h)); min-height: 30rem; padding: 1.4rem 1.6rem 0; border-bottom: 1px solid var(--hairline); }
/* the first screen is an app window: a title bar with its three buttons, the editor and the page inside */
.hero-window { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--code-bg); border: 1px solid var(--window-edge); border-radius: 12px; box-shadow: var(--window-shadow); transform-origin: 50% 0; }
.hero-window .window-bar { position: relative; flex-shrink: 0; height: 34px; background: var(--window-bar); border-bottom: 1px solid var(--hairline); }
.window-title { position: absolute; left: 50%; translate: -50% 0; font: 500 12.5px var(--mono); color: var(--ink-soft); white-space: nowrap; }

/* ── the menu bar, written as LaTeX: \documentclass{scribe} \usepackage{…} % … \download{macOS} ── */
:root { --bar-h: 3.1rem; }
section[id], .appendix, #download { scroll-margin-top: calc(var(--bar-h) + 1.5rem); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2.2rem;
  height: var(--bar-h);
  padding: 0 1.6rem;
  font: 14.5px/1 var(--mono);
  white-space: nowrap;
  color: var(--code-fg);
  background: var(--code-bg);
  border-bottom: 1px solid var(--hairline);
}
.topbar a { color: inherit; }
.topbar a:hover { text-decoration: none; }
.tex-cmd { color: var(--syn-cmd); }
.tex-brace, .tex-comma { color: var(--syn-brace); }
.tex-comment { margin-left: auto; font-style: italic; color: var(--syn-cmt); }
.brand { display: flex; align-items: center; gap: 0.7rem; }
.pagecolor { padding: 0; font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.pagecolor .tex-arg, .include .tex-arg { border-bottom: 1.5px solid transparent; transition: border-color 150ms ease; }
.pagecolor:hover .tex-arg, .include:hover .tex-arg { border-bottom-color: var(--gutter); }
.include[aria-current="page"] .tex-arg { color: var(--syn-math); border-bottom-color: var(--syn-math); }
.brand .tex-arg { font-weight: 600; color: var(--ink); }
/* each package is a link to its section; the one being read is marked */
.packages .tex-arg { padding-bottom: 2px; border-bottom: 1.5px solid transparent; transition: color 150ms ease, border-color 150ms ease; }
.packages .tex-arg:hover { color: var(--ink); border-bottom-color: var(--gutter); }
.packages .tex-arg[aria-current="true"] { color: var(--syn-math); border-bottom-color: var(--syn-math); }
/* \download{macOS} is the one framed box, like \fbox */
.download-cmd { padding: 0.5rem 0.8rem; border: 1px solid var(--hairline); transition: border-color 150ms ease; }
.download-cmd:hover { border-color: var(--gutter); }
.hero-stage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; }
.source { display: flex; flex-direction: column; min-height: 0; background: var(--code-bg); border-right: 1px solid var(--hairline); }
.source-tab { padding: 0.5rem 1.6rem; font: 13px var(--mono); color: var(--ink-soft); border-bottom: 1px solid var(--hairline); }
.typewriter {
  flex: 1;
  min-height: 0;
  padding: 1.6rem 1.6rem 2rem 0.4rem;
  overflow: hidden;
  font: clamp(13px, 1.05vw, 16px)/1.75 var(--mono);
  color: var(--code-fg);
  white-space: pre;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 40px);
}
.typewriter .ln { display: inline-block; width: 3.4em; padding-right: 1.4em; text-align: right; color: var(--gutter); user-select: none; }
/* gruvbox light, as in the app's light theme */
.typewriter .tw-cmd { color: var(--syn-cmd); }
.typewriter .tw-num { color: var(--syn-num); }
.typewriter .tw-cmt { color: var(--syn-cmt); font-style: italic; }
.typewriter .tw-math { color: var(--syn-math); }
.typewriter .tw-cursor { display: inline-block; width: 2px; height: 1.2em; margin-left: 1px; background: var(--caret); vertical-align: text-bottom; animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.desk { display: grid; place-items: center; min-height: 0; padding: 2rem; background: var(--desk); }
.hero-more { padding: 1.1rem 1.6rem 0.8rem; font-size: 0.95rem; text-align: center; color: var(--ink-soft); }

.sheet {
  container-type: size;
  height: 100%;
  max-height: 64rem;
  aspect-ratio: 1 / 1.414;
  max-width: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--sheet-edge);
}
.sheet-body { padding: 9cqh 11cqw 0; font: 1.62cqh/1.5 var(--serif); color: #26231f; }
.sheet-body .pending { visibility: hidden; }
.sheet-body h1 { font-size: 2.7cqh; font-weight: 400; line-height: 1.25; text-align: center; }
.sheet-body .paper-author { margin-top: 1.4cqh; text-align: center; font-size: 1.8cqh; }
.sheet-body .paper-abstract { margin: 2.6cqh 8cqw 0; font-size: 1.5cqh; text-align: justify; }
.sheet-body .paper-abstract strong { display: block; margin-bottom: 0.5cqh; text-align: center; font-size: 1.5cqh; }
.sheet-body h2 { margin: 2.6cqh 0 0.8cqh; font-size: 2.05cqh; font-weight: 700; }
.sheet-body h2 span { margin-right: 1.6cqh; }
.sheet-body p { text-align: justify; hyphens: auto; }
.sheet-body code { font: 0.9em var(--mono); }
.sheet-body .paper-eq { margin-top: 1.2cqh; text-align: center; font-size: 1.8cqh; }
.sheet-body .paper-eq sup { font-size: 0.7em; }
.sheet-body figure { margin: 1.6cqh 0 0; text-align: center; }
.sheet-body figure svg { display: block; width: 68%; margin: 0 auto; }
.sheet-body figure .axis { stroke: #26231f; stroke-width: 0.8; opacity: 0; transition: opacity 300ms ease-out; }
.sheet-body figure .zero { stroke: #b9b4aa; stroke-width: 0.6; stroke-dasharray: 2 2; opacity: 0; transition: opacity 300ms ease-out; }
.sheet-body figure.in .axis, .sheet-body figure.in .zero { opacity: 1; }
.sheet-body figure .curve { stroke: #b0791f; stroke-width: 1.4; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 80ms linear; }
.sheet-body figcaption { margin-top: 0.8cqh; font-size: 1.45cqh; }

/* ── a feature: its text in one column, its demo in the other ── */
.article > section.feature {
  grid-column: wide;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.55fr);
  gap: 1.4rem 3.2rem;
  align-items: center;
  margin-top: 5.5rem;
}
.article > section.feature.flip { grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.8fr); }
.feature.flip .feature-text { order: 2; }
.article > section.feature > * { grid-column: auto; } /* not the article's text column */
.feature figure { margin: 0; }
.feature figcaption { max-width: none; }

/* ── Theorem 1: the price, the one thing on the page set larger than a heading ── */
.article > .theorem { grid-column: wide; justify-self: center; width: min(100%, 46rem); }
.theorem { margin: 3.6rem 0 0.4rem; padding: 2rem 2.4rem 1.8rem; border: 1.5px solid var(--rule); }
.theorem .statement { font-size: 2.35rem; line-height: 1.25; }
.theorem .statement .label { font-size: 0.62em; vertical-align: 0.18em; }
.theorem .statement .note { font-size: 0.62em; vertical-align: 0.18em; margin-right: 0.15em; }
.theorem .statement em { display: block; margin-top: 0.3rem; }
.theorem .proof { margin-top: 1rem; font-size: 1rem; text-align: justify; hyphens: auto; color: var(--ink-soft); }
.theorem .proof .label { font-weight: 400; font-style: italic; color: var(--ink); margin-right: 0.3em; }
.qed { float: right; margin-left: 1rem; color: var(--ink); }

/* ── Under the hood: a description list in two columns, a listing, the shortcuts ── */
.article > section.tech { grid-column: wide; display: block; }
.article > section.tech > * { max-width: none; }
.tech > p { max-width: var(--measure); }
.tech-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 3rem; margin-top: 1.6rem; }
.tech-list div { text-align: justify; hyphens: auto; }
.tech-list dt { display: inline; font-weight: 700; margin-right: 0.35em; }
.tech-list dd { display: inline; margin: 0; }
.listing { margin: 2.4rem 0 0; }
.listing figcaption { margin: 0 0 0.6rem; text-align: left; }
.listing pre { padding: 1rem 1.2rem; overflow-x: auto; font: 0.86rem/1.65 var(--mono); color: var(--code-fg); background: var(--code-bg); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.listing .c { color: var(--syn-cmt); font-style: italic; }
.listing .s { color: var(--syn-str); }
.listing .n { color: var(--syn-num); }
.listing .k { color: var(--syn-cmd); }
.keys { margin-top: 2rem; }
.keys td:nth-child(odd) { width: 7rem; }
kbd { font: 0.85em var(--mono); padding: 0.05em 0.35em; border: 1px solid var(--hairline); border-radius: 3px; background: var(--code-bg); }

/* ── Appendix A: one box per platform, framed like \fbox ── */
.article > section.appendix { grid-column: wide; display: block; }
.appendix > p, .appendix > ol { max-width: var(--measure); }
.platforms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; margin: 1.6rem 0 1.8rem; }
.platform { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.3rem 1.4rem 1.4rem; border: 1px solid var(--hairline); }
.platform.yours { border: 1.5px solid var(--rule); }
.platform h3 { font-size: 1.25rem; font-weight: 700; }
.platform.yours h3::after { content: " · yours"; font-weight: 400; font-style: italic; font-size: 0.85em; color: var(--ink-soft); }
.platform p { flex: 1; font-size: 0.97rem; line-height: 1.45; }
.platform .button { align-self: flex-start; }
.button.soon { color: var(--ink-soft); background: transparent; border: 1px dashed var(--dashed); cursor: default; }
.button.soon:hover { color: var(--ink-soft); }
.appendix .download-note { margin-top: 1.2rem; }

/* ── the first screen's editor, once it is the visitor's: a transparent textarea over the
   highlighted source, which shows through it ── */
.source { position: relative; }
.source-edit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.6rem 1.6rem 2rem calc(0.4rem + 3.4em);
  font: clamp(13px, 1.05vw, 16px)/1.75 var(--mono);
  white-space: pre;
  color: transparent;
  caret-color: var(--caret);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  overflow: auto;
}
.source-edit::selection { color: transparent; background: color-mix(in srgb, var(--caret) 30%, transparent); }
.source-edit:focus-visible { outline: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--caret) 45%, transparent); }
.source.live .typewriter { -webkit-mask-image: none; mask-image: none; }
.source-hint { color: var(--caret); font-style: italic; }

/* ── Try it: a note and how Scribe shows it ── */
.article > section.playground { grid-column: wide; display: block; }
.playground > p { max-width: var(--measure); }
.pg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1.4rem; border: 1px solid var(--hairline); }
.pg-pane { display: flex; flex-direction: column; min-width: 0; }
.pg-pane + .pg-pane { border-left: 1px solid var(--hairline); }
.pg-tab { padding: 0.45rem 1rem; font: 13px var(--mono); color: var(--ink-soft); background: var(--code-bg); border-bottom: 1px solid var(--hairline); }
.pg-input {
  flex: 1;
  min-height: 22rem;
  padding: 1rem 1.1rem;
  font: 14.5px/1.7 var(--mono);
  color: var(--code-fg);
  background: var(--code-bg);
  caret-color: var(--caret);
  border: none;
  outline: none;
  resize: vertical;
}
.pg-input:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--caret) 45%, transparent); }
.pg-output { flex: 1; padding: 1rem 1.4rem 1.4rem; overflow-x: auto; font-size: 1.05rem; line-height: 1.6; }
.pg-output h3 { font-size: 1.35rem; margin: 0.2rem 0 0.6rem; }
.pg-output h4, .pg-output h5 { font-size: 1.1rem; margin: 0.8rem 0 0.4rem; }
.pg-output p + p, .pg-output ul + p { margin-top: 0.6rem; }
.pg-output ul { margin: 0.5rem 0 0.5rem 1.3rem; }
.pg-display { margin: 0.8rem 0; overflow-x: auto; }

/* ── margin notes: in the margin beside their line on a wide screen, under the paragraph otherwise ── */
.sidenote-ref { font-size: 0.7em; vertical-align: 0.45em; line-height: 0; margin-left: 0.08em; color: var(--link); }
.sidenote { display: block; margin: 0.5rem 0 0.2rem; font-size: 0.85rem; line-height: 1.4; text-align: left; text-indent: 0; color: var(--ink-soft); }
.sidenote-num { font-size: 0.8em; vertical-align: 0.35em; color: var(--link); }
@media (min-width: 1240px) {
  section > p, .abstract > p, .theorem .proof { position: relative; }
  .sidenote { position: absolute; left: calc(100% + 2.6rem); width: 13.5rem; margin: 0; }
}

/* ── Remark 1 ── */
.remark { max-width: var(--measure); margin-top: 1.8rem; text-align: justify; }
.remark .label { font-style: italic; font-weight: 700; margin-right: 0.3em; }

/* ── Table 2, Scribe and Overleaf ── */
.compare td:first-child { font-style: italic; }
.compare td:nth-child(2) { font-weight: 700; }

/* ── Questions, as revision cards ── */
.article > section.faq { grid-column: wide; display: block; }
.faq > p { max-width: var(--measure); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 2.6rem; margin-top: 1.4rem; }
.card { padding: 1rem 0 0.2rem; border-top: 1px solid var(--hairline); }
.card p + p { margin-top: 0.45rem; color: var(--ink-soft); }
.chip { display: inline-block; margin-right: 0.35rem; padding: 0.08rem 0.36rem 0.12rem; font: 700 0.72rem var(--mono); letter-spacing: 0.04em; vertical-align: 0.12em; border-radius: 3px; }
.chip.q { color: var(--paper); background: var(--caret); }
.chip.a { color: var(--ink); background: var(--hairline); }
.soon-tag { display: inline-block; margin-left: 0.3rem; padding: 0.04rem 0.4rem 0.08rem; font: italic 0.82rem var(--serif); color: var(--syn-math); border: 1px dashed currentColor; border-radius: 3px; vertical-align: 0.06em; white-space: nowrap; }

/* ── the LaTeX logo, set the way \LaTeX sets it ── */
.latex, .tex { white-space: nowrap; }
.latex .a, .latex .e, .tex .e { line-height: 0; } /* the raised A and lowered E don't push lines apart */
.latex .a { font-size: 0.72em; vertical-align: 0.24em; margin-left: -0.33em; margin-right: -0.14em; }
.latex .e, .tex .e { vertical-align: -0.22em; margin-left: -0.14em; margin-right: -0.11em; text-transform: uppercase; }

/* ── Figure 7: the templates, as subfigures (a)–(g) ── */
.article > section.gallery { grid-column: wide; display: block; }
.gallery > p { max-width: var(--measure); }
.templates { margin-top: 1.6rem; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 1.6rem 1.4rem; align-items: start; }
.template { display: flex; flex-direction: column; gap: 0.55rem; color: var(--ink); }
.template:hover { text-decoration: none; }
/* every thumbnail the same size, an A4 page: Letter pages fit inside it, the slides sit in its middle */
.template img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1.414; object-fit: contain; object-position: center; background: #fff; border: 1px solid var(--sheet-edge); transition: translate 200ms var(--ease-out, ease), border-color 200ms ease; }
.template:hover img { translate: 0 -4px; border-color: var(--ink-soft); }
.subcaption { font-size: 0.92rem; text-align: center; }
.templates figcaption { margin-top: 1.4rem; }

/* ── Listing 2: the BibTeX entry, with a copy button ── */
.bibtex figcaption { display: flex; align-items: baseline; gap: 0.8rem; }
.copy-bib { margin-left: auto; padding: 0.15rem 0.6rem; font: 0.85rem var(--mono); color: var(--ink); background: none; border: 1px solid var(--hairline); border-radius: 3px; cursor: pointer; }
.copy-bib:hover { border-color: var(--ink-soft); }
.appendix .listing { max-width: var(--measure); }

/* ── Table 1, booktabs: thick top and bottom rules, a thin one under the head, no verticals ── */
.table-wrap { margin-top: 1.4rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
caption { margin-bottom: 0.6rem; font-size: 0.95rem; text-align: center; }
thead th { padding: 0.45rem 0.6rem 0.4rem; text-align: left; font-weight: 700; border-top: 1.4px solid var(--rule); border-bottom: 0.8px solid var(--rule); }
tbody td { padding: 0.3rem 0.6rem; vertical-align: top; line-height: 1.4; }
tbody tr:first-child td { padding-top: 0.55rem; }
tbody tr:last-child td { padding-bottom: 0.55rem; border-bottom: 1.4px solid var(--rule); }
tbody td:first-child { white-space: nowrap; padding-right: 1.4rem; }

.colophon { padding: 2rem 1.25rem 3rem; font-size: 0.95rem; text-align: center; color: var(--ink-soft); }

/* phones: one column; the welcome window shows the source only, as the app does when narrow */
@media (max-width: 1000px) {
  .article > section.feature, .article > section.feature.flip { grid-column: text; grid-template-columns: minmax(0, 1fr); margin-top: 3.2rem; }
  .feature.flip .feature-text { order: 0; }
  .hero-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr); }
  .hero { padding: 0.8rem 0.8rem 0; }
  .window-title { display: none; }
  .source { border-right: none; border-bottom: 1px solid var(--hairline); }
  .desk { padding: 1rem; }
}

@media (max-width: 1560px) {
  .tex-comment { display: none; }
  .include[href$="manual.html"] { margin-left: auto; } /* the right-hand group starts here */
}

@media (max-width: 1380px) {
  .packages { display: none; }
}

@media (max-width: 900px) {
  .platforms { grid-template-columns: minmax(0, 1fr); }
  .pg { grid-template-columns: minmax(0, 1fr); }
  .pg-pane + .pg-pane { border-left: none; border-top: 1px solid var(--hairline); }
  .article > section.playground { grid-column: text; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .article > section.faq { grid-column: text; }
  .article > section.appendix { grid-column: text; }
  .tech-list { grid-template-columns: minmax(0, 1fr); }
  .article > section.tech { grid-column: text; }
}

@media (max-width: 760px) {
  body { font-size: 1.06rem; }
  /* a phone shows scribe  manual  changelog  \download; its colours follow the phone */
  .brand-cmd, .brand-brace, .pagecolor, .include .tex-cmd, .include-arg .tex-brace { display: none; }
  .topbar { gap: 0.9rem; padding: 0 1rem; font-size: 13px; }
  .article { padding-top: 3rem; }
  .maketitle h1 { font-size: 2.7rem; }
  .subtitle { font-size: 1.3rem; }
  .abstract { padding: 0; }
  .theorem { padding: 1.2rem 1.2rem 1.1rem; }
  .theorem .statement { font-size: 1.55rem; }
  section > p { text-align: left; }
  tbody td:first-child { white-space: normal; }
}

/* ────────────────────────────── motion ──────────────────────────────
   motion.js adds .motion to <html> (plus .motion-full, or .motion-reduced when the visitor
   asks for less movement) and marks what should appear. Without it, nothing here applies. */

html:not(.lenis) { scroll-behavior: smooth; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-stopped { overflow: clip; }

:root { --ease-out: cubic-bezier(.2, .7, .2, 1); --ease-spring: cubic-bezier(.34, 1.4, .64, 1); }

/* things that appear as they scroll into view */
.motion .reveal {
  opacity: 0;
  transition: opacity 900ms var(--ease-out) var(--d, 0ms), translate 1000ms var(--ease-out) var(--d, 0ms);
}
.motion-full .reveal-rise { translate: 0 28px; }
.motion-full .reveal-left { translate: -56px 0; }
.motion-full .reveal-right { translate: 56px 0; }
.motion .reveal.in { opacity: 1; translate: 0 0; }

/* headings and the theorem arrive a word at a time: the block stays, its words rise and sharpen */
.motion .reveal.split { opacity: 1; translate: none; }
.motion .split .w {
  display: inline-block;
  opacity: 0;
  transition:
    opacity 650ms var(--ease-out) calc(var(--d, 0ms) + var(--i) * 55ms),
    translate 800ms var(--ease-out) calc(var(--d, 0ms) + var(--i) * 55ms),
    filter 700ms var(--ease-out) calc(var(--d, 0ms) + var(--i) * 55ms);
}
.motion-full .split .w { translate: 0 0.45em; filter: blur(6px); }
.motion .split.in .w, .motion .in .split .w { opacity: 1; translate: 0 0; filter: none; }

/* Theorem 1: the frame draws itself, then the words, the proof and the ∎ */
.motion .theorem { position: relative; border-color: transparent; }
.motion .theorem::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border: 1.5px solid var(--rule);
  clip-path: inset(0 100% 100% 0);
  transition: clip-path 1100ms cubic-bezier(.65, 0, .35, 1);
  pointer-events: none;
}
.motion .theorem.reveal-frame { opacity: 1; }
.motion .theorem.in::before { clip-path: inset(0 0 0 0); }
.motion .theorem .qed { display: inline-block; opacity: 0; scale: 0.2; transition: opacity 300ms ease 2100ms, scale 600ms var(--ease-spring) 2100ms; }
.motion .theorem.in .qed { opacity: 1; scale: 1; }

/* the first screen arrives: the bar from above, the editor and the page from their sides */
@keyframes from-above { from { opacity: 0; transform: translateY(-14px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-36px); } }
@keyframes from-right { from { opacity: 0; transform: translateX(36px); } }
@keyframes fade { from { opacity: 0; } }
.motion-full .topbar { animation: from-above 800ms var(--ease-out) backwards; }
@keyframes window-in { from { opacity: 0; transform: translateY(28px) scale(0.97); } }
.motion-full .hero-window { animation: window-in 1100ms var(--ease-out) 80ms backwards; }
.motion-full .desk .sheet { animation: from-right 1100ms var(--ease-out) 380ms backwards; }
.motion-full .hero-more { animation: fade 900ms ease 900ms backwards; }
.motion-reduced .hero-window { animation: fade 700ms ease backwards; }

/* ...and as you scroll away from it, the editor and the page drift apart and step back */
.motion-full .hero-window { scale: calc(1 - var(--out, 0) * 0.07); opacity: calc(1 - var(--out, 0) * 0.55); }
/* the arrow under the first screen bobs downward, inviting a click (it runs under Reduce
   Motion too: a few pixels of movement, like the typing above it) */
.hero-more .arrow { display: inline-block; margin-left: 0.15em; animation: bob 1.5s ease-in-out infinite; }
.hero-more:hover .arrow { animation-duration: 0.8s; }
@keyframes bob { 0%, 100% { translate: 0 -1px; } 50% { translate: 0 6px; } }

/* a demo window rises and grows into place as it comes up the screen */
.motion-full .demo .window {
  transform-origin: 50% 100%;
  translate: 0 calc((1 - var(--in, 1)) * 90px);
  scale: calc(0.88 + var(--in, 1) * 0.12);
  opacity: calc(0.15 + var(--in, 1) * 0.85);
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .typewriter .tw-cursor { animation: none; }
}

/* ── the changelog page ── */
.changelog-page .article { padding-top: 4rem; }
.maketitle { text-align: center; }
.maketitle h1 { font-size: 2.8rem; font-weight: 400; }
.subtitle { margin-top: 0.4rem; font-size: 1.25rem; font-style: italic; color: var(--ink-soft); }
.release-note { margin-left: 0.5rem; font-size: 0.7em; font-weight: 400; font-style: italic; color: var(--ink-soft); }
.entry { margin-top: 2rem; }
.entry h3 { font-size: 1.12rem; font-weight: 700; }
.entry ul { margin: 0.6rem 0 0 1.3rem; }
.entry li { line-height: 1.5; }
.entry li + li { margin-top: 0.45rem; }

/* ── the manual ── */
.toc { margin-top: 2.6rem; }
.toc h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }
.toc ol { margin-left: 1.5rem; }
.toc li { line-height: 1.7; }
.manual-page .article > section.tech-wide, .manual-page .listing { grid-column: text; }
.tech-list.single { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; margin-top: 1.2rem; }
.manual-page .listing { margin-top: 1.6rem; }
.manual-page .listing pre { font-size: 0.8rem; }
.manual-page .keys td:nth-child(odd) { white-space: nowrap; }
