/* style.css — the whole site's styling.  No framework, no build step. */

/* The faces of the look at the end of this sheet (`the look`). */
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Roboto+Serif:opsz,wght@8..144,600;8..144,700&display=swap");

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  --bg: #fbfbfa;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --fg: #1b1d1e;
  --muted: #5f676e;
  --faint: #8b939b;
  --border: #dcdfe3;
  --border-strong: #c2c7ce;
  --accent: #2f6fd0;
  --accent-soft: #e6eefb;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 20, 26, .07), 0 4px 14px rgba(16, 20, 26, .06);

  --st-absent: #97a0a8;
  --st-missing: #d34b4b;
  --st-stated: #cc8f1c;
  --st-proved: #2c9a62;
  --st-proved_with_axioms: #1f9b9b;
  --st-none: #b6bcc2;

  --lv-error: #d34b4b;
  --lv-warning: #cc8f1c;
  --lv-info: #4d7fc4;

  --graph-node: #ffffff;
  --graph-compound: #f1f3f6;
  --graph-edge: #7b848d;
  --graph-junction: #55606a;
  --graph-hl: #f0a202;
  /* A highlighted arc: its own grey, darkened (toward the text colour, so
     lighter on a dark background), at the same width. */
  --graph-edge-strong: color-mix(in srgb, var(--graph-edge) 40%, var(--fg));

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;

  --radius: 7px;
  /* The top bar's height, for what sits under it (sticky sidebars, scroll
     margins).  It has two rows that wrap, so app.js sets it to the bar's
     measured height (`watchTopbar`); this is a first guess until then. */
  --topbar-h: 96px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131619;
    --panel: #1b1f23;
    --panel-2: #22272c;
    --fg: #e4e7ea;
    --muted: #9aa3ac;
    --faint: #767f88;
    --border: #2b3137;
    --border-strong: #3c444c;
    --accent: #6ea8ff;
    --accent-soft: #1d2a3d;
    --accent-fg: #0d1117;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);

    --st-absent: #7d868e;
    --st-missing: #e06a6a;
    --st-stated: #dda93a;
    --st-proved: #4cba82;
    --st-proved_with_axioms: #3fbdbd;
    --st-none: #4d555c;

    --lv-error: #e06a6a;
    --lv-warning: #dda93a;
    --lv-info: #7ba7e8;

    --graph-node: #1f242a;
    --graph-compound: #191d21;
    --graph-edge: #8c959e;
    --graph-junction: #aab3bb;
    --graph-hl: #f0a202;
  }
}

/* ------------------------------------------------------------------- base */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }

pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7em .9em;
  overflow-x: auto;
}

code:not(pre code) {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .08em .35em;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 1.4em 0 .5em; font-weight: 620; }
h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }

button, select, input[type="text"], input[type="search"] {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: .3em .6em;
}
button { cursor: pointer; }
button:hover { background: var(--panel-2); }
button.active { background: var(--accent-soft); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

input[type="range"] { accent-color: var(--accent); }

label.chk {
  display: inline-flex;
  align-items: center;
  gap: .32em;
  padding: .12em .45em .12em .3em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  font-size: .85rem;
  white-space: nowrap;
}
label.chk input { margin: 0; }

/* ----------------------------------------------------------------- topbar */

/* Two rows: the title, the tabs and, at the right, the style menu and Show
   progress; then the search and Export PDF, at the right too (index.html).
   On the graph the second row is the graph's own toolbar instead, set as this
   one is (below, `html[data-view="graph"]`).  Every row wraps rather than
   overlaps, so a long title, a narrow window or text made larger (Ctrl +)
   moves things down instead of covering the title: the style menu and Show
   progress go under the tabs as a whole, the tabs under the title, the title
   itself onto a second line.
   Fixed to the top of the window, however far the page is scrolled; the
   body makes room for it (`padding-top`, below).  Sticky would not do: it
   sticks only within the body, which is one window tall (the graph fills
   it), so on a longer page the bar left with the body's foot. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 0 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem 1.2rem;
  min-width: 0;
  min-height: 3.25rem;
  padding: .35rem 0;
}

/* The search box and Export PDF, at the right, under the style menu and Show
   progress, one height and one size of text (a style may set the text). */
.topbar-tools {
  --tools-h: 2rem;
  --tools-font: .88rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: .4rem .6rem;
  min-width: 0;
  padding: .45rem 0;
  border-top: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  max-width: 100%;
  color: var(--fg);
  font-weight: 640;
}
/* A title longer than the row wraps, whole words first. */
.brand-text { min-width: 0; overflow-wrap: anywhere; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 15px; height: 15px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px 3px auto auto;
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 1px;
}
/* A project's logo (`project.logo`, app.js `brandLogo`) stands in for the
   mark, in every style: a little taller than the title's letters. */
.brand.has-logo .brand-mark { display: none; }
.brand-logo { width: 1.9em; height: 1.9em; flex: none; }
.brand-logo[hidden] { display: none; }
.brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-logo.ink {
  background-color: currentColor;
  -webkit-mask: var(--brand-logo) center / contain no-repeat;
  mask: var(--brand-logo) center / contain no-repeat;
}

.tabs { display: flex; flex-wrap: wrap; gap: .15rem; }
.tabs a {
  white-space: nowrap;
  color: var(--muted);
  padding: .3em .7em;
  border-radius: var(--radius);
  font-size: .92rem;
}
.tabs a:hover { background: var(--panel-2); text-decoration: none; }
.tabs a.active { color: var(--fg); background: var(--accent-soft); font-weight: 560; }
/* The Blog tab, until blog.json says the site has posts (app.js, `loadBlog`). */
.tabs a[hidden] { display: none; }

.topbar-aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .5rem;
  margin-left: auto;
  font-size: .85rem;
  color: var(--muted);
}

/* Each item keeps its one line ("46%" under its bar read as a second row);
   when the row is short of room the items wrap as wholes. */
.topbar-aside > * { flex: none; white-space: nowrap; }

/* Hide progress / Show progress (app.js).  The Progress tab stays either way. */
.topbar-aside .progress-toggle { font-size: .8rem; padding: .15em .45em; }

/* The graph has no search and Export PDF row: its toolbar is the second row
   there, with the line between the rows the top bar's own (`.toolbar`). */
html[data-view="graph"] .topbar-tools { display: none; }
html[data-view="graph"] .topbar { border-bottom: 0; }

/* Export PDF: the one filled button of the top bar, so it is found without
   looking for it (pdf.js).  Text and icon, never the icon alone. */
.export-pdf {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  flex: none;
  height: var(--tools-h);
  padding: 0 .8em;
  font-size: var(--tools-font);
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.export-pdf:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
.export-pdf:focus-visible, .export-dialog :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.export-pdf:disabled { opacity: .55; }
.export-icon { flex: none; }

/* The search box, before Export PDF: the Stacks project's quick search, a
   magnifier inside the box and no list under it; Enter opens the search page
   (search.js). */
.gsearch {
  position: relative;
  flex: 0 1 18rem;
  min-width: 9rem;
  margin: 0;
}
.gsearch input[type="search"] {
  width: 100%;
  height: var(--tools-h);
  padding-left: 1.9em;
  padding-right: 1.8em;
  font-size: var(--tools-font);
}
.gsearch-icon {
  position: absolute;
  left: .6em;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.gsearch-key {
  position: absolute;
  right: .45em;
  top: 50%;
  transform: translateY(-50%);
  font-size: .72rem;
  line-height: 1.3;
  padding: 0 .35em;
  color: var(--faint);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  pointer-events: none;
}
.gsearch input:focus ~ .gsearch-key,
.gsearch input:not(:placeholder-shown) ~ .gsearch-key { display: none; }

/* ------------------------------------------------------------ search page */

/* The Stacks project's search page: the form and the results on the left,
   the results per page and the tips beside them, below them on a phone. */
.search-page {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr);
  gap: 2.5rem;
  align-items: start;
}
.search-aside {
  position: sticky;
  top: calc(var(--topbar-h) + 1rem);
  font-size: .9rem;
  color: var(--muted);
}
.search-aside .search-perpage { margin-bottom: 1.2rem; }
.search-tips p { margin-top: 0; }
.search-tips ul { padding-left: 1.2em; margin: 0; }
.search-tips li { margin-bottom: .4em; }
.search-tips var { font-family: var(--mono); font-style: normal; font-size: .92em; color: var(--fg); }

.search-field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.search-field input[type="search"] { width: 100%; font-size: 1rem; padding: .45em .7em; }
.search-options {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-top: .8rem;
}
.search-radius { display: flex; align-items: center; gap: .4em; }
.search-radius input { margin: 0; accent-color: var(--accent); }
.search-radius label { cursor: pointer; }
.search-submit {
  font-weight: 600;
  padding: .4em 1.2em;
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}
.search-submit:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }

.search-count { margin: 1rem 0 .8rem; font-size: 1.15rem; }
.search-showing { font-weight: 400; color: var(--muted); font-size: .95rem; }

/* Pages and results per page: a row of boxes, the current one filled.  An
   arrow with nowhere to go keeps its place, so the numbers do not move. */
.search-pages {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  list-style: none;
  padding: 0;
  margin: .6rem 0;
}
.search-pages li { font-size: .9rem; }
.search-pages a, .search-pages .ellipsis {
  display: block;
  min-width: 2.2rem;
  padding: .3em .55em;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
}
.search-pages .ellipsis { border-color: transparent; background: none; color: var(--muted); }
.search-pages a:hover { text-decoration: none; background: var(--panel-2); }
.search-pages li.active a { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.search-pages li.inactive { visibility: hidden; }

/* The results as the document's tree (jquery-bonsai on the Stacks project):
   a triangle folds what is under an entry, a magnifier shows a statement in
   place of its line. */
.search-expand { display: flex; gap: 1rem; margin-bottom: .4rem; font-size: .88rem; }
button.linklike {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
}
button.linklike:hover { background: none; text-decoration: underline; }
.search-expand .all::before { content: "\25be\25be  "; white-space: pre; }
.search-expand .none::before { content: "\25b8\25b8  "; white-space: pre; }
.search-tree, .search-tree ul { list-style: none; margin: 0; padding: 0; }
.search-tree ul { padding-left: 1.4rem; }
.search-tree li { position: relative; padding: .2rem 0 .2rem 1.3rem; }
.search-tree li.elsewhere > .preview-title { color: var(--muted); font-style: italic; }
.search-tree ul[hidden] { display: none; }
.search-tree .thumb {
  position: absolute;
  left: 0;
  top: .2rem;
  width: 1.2rem;
  height: 1.55em;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  line-height: 1.55;
}
.search-tree .thumb::before { content: "\25be"; }
.search-tree li.collapsed > .thumb::before { content: "\25b8"; }
.search-tree .thumb:hover { color: var(--fg); background: none; }
.previewable {
  float: left;
  width: 1.1rem;
  height: 1.1rem;
  margin: .2em .35rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--accent);
}
.previewable::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: currentColor;
  -webkit-mask: var(--lens) center / contain no-repeat;
  mask: var(--lens) center / contain no-repeat;
}
.previewable { --lens: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M10.3 10.3 14 14' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }
.previewable:hover { background: var(--accent-soft); }
.previewable.previewing { color: var(--fg); }
.previewable:focus-visible, .search-tree .thumb:focus-visible, button.linklike:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.preview-title[hidden] { display: none; }
.search-preview {
  display: flow-root; /* beside the floated magnifier, as on the Stacks project */
  margin: 0 0 .3rem;
  padding: .55rem .8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-preview[hidden] { display: none; }
.search-preview .body-prose > :first-child { margin-top: 0; }
.search-preview .body-prose > :last-child { margin-bottom: 0; }

/* ----------------------------------------------------------------- banner */

.banner {
  padding: .5em 1rem;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.banner.warn { background: color-mix(in srgb, var(--lv-warning) 18%, var(--panel)); }
/* `display: flex` above beats the user agent's `[hidden] { display: none }`,
   so without this the *empty* banner still laid out its padding and border: a
   15px strip under the top bar on every page, and 15px of the graph page —
   whose height is measured from the viewport — pushed off the bottom, which
   clipped the legend and the status line. */
.banner[hidden] { display: none; }

/* -------------------------------------------------------------- app frame */

/* The shell is a column — room for the top bar (fixed to the window, above:
   the body's `padding-top`), the banner when there is one, then the page
   filling exactly what is left.  Pages that measure themselves from the
   viewport instead (the graph did: `calc(100vh - var(--topbar-h))`) cannot
   know whether the banner is there, and while a historical snapshot was on
   screen the graph ran 47px off the bottom, taking the status line and the
   legend with it.
   The top bar and the banner keep their own height: a flex item shrinks by
   default, and on any page taller than the window the column squeezed the
   52px top bar to the 33px of its tallest child, so the tabs sat cramped on
   every page but the graph, the one page that fits the window exactly. */
body { display: flex; flex-direction: column; padding-top: var(--topbar-h); }
.topbar, .banner { flex: none; }
.app { flex: 1 1 auto; min-height: 0; }

.page {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.6rem 1.25rem 5rem;
}
.page.wide { max-width: 78rem; }

.loading, .empty {
  padding: 3rem 1.25rem;
  color: var(--muted);
  text-align: center;
}

.error-box {
  max-width: 40rem;
  margin: 3rem auto;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.error-box h1 { font-size: 1.2rem; }
.error-box .detail {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--muted);
  word-break: break-all;
  margin: .6em 0 1.2em;
}

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  font-size: .76rem;
  font-weight: 560;
  line-height: 1.5;
  padding: .1em .5em;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: .5em; height: .5em; border-radius: 50%; background: currentColor; flex: none; }

.badge.status-absent { color: var(--st-absent); border-color: var(--st-absent); }
.badge.status-missing { color: var(--st-missing); border-color: var(--st-missing); }
.badge.status-stated { color: var(--st-stated); border-color: var(--st-stated); }
.badge.status-proved { color: var(--st-proved); border-color: var(--st-proved); }
.badge.status-proved_with_axioms { color: var(--st-proved_with_axioms); border-color: var(--st-proved_with_axioms); }
.badge.status-none { color: var(--faint); border-color: var(--border-strong); }

.badge.kind {
  color: var(--muted);
  border-color: var(--border-strong);
  background: var(--panel-2);
  font-family: var(--mono);
  font-weight: 500;
}

.chip {
  display: inline-block;
  font-size: .74rem;
  padding: .05em .45em;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* --------------------------------------------------------- progress bars */

.bar {
  position: relative;
  height: 8px;
  min-width: 60px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--st-proved);
  transition: width .25s ease;
}
.bar.mix { display: flex; }
.bar.mix > span { flex: none; }
.bar-row { display: flex; align-items: center; gap: .6rem; }
.bar-row .bar { flex: 1; }
.bar-row .num { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ----------------------------------------------------------------- tables */

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table.grid th, table.grid td {
  text-align: left;
  padding: .45em .6em;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.grid th {
  font-weight: 580;
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.grid tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }

/* ------------------------------------------------------------ graph page */

.graph-page {
  display: grid;
  grid-template-columns: 1fr 22rem;
  grid-template-rows: auto 1fr;
  height: 100%;
  overflow: hidden;
}

/* The graph's toolbar is the top bar's second row on the graph (index.html):
   the same padding, the line above it inset as the line between the top
   bar's rows is, and its controls the size and colour of the top bar's. */
.toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .4rem .6rem;
  flex-wrap: wrap;
  /* The line above is drawn in the padding: 1px more, for the border it is
     between the top bar's rows. */
  padding: calc(.45rem + 1px) 1rem .45rem;
  font-size: .86rem;
  background:
    linear-gradient(var(--border), var(--border)) no-repeat 1rem 0 / calc(100% - 2rem) 1px,
    var(--panel);
  border-bottom: 1px solid var(--border);
}
/* The height of the top bar's search box and Export PDF, so the row is as
   tall as the top bar's own. */
.toolbar button { color: var(--muted); height: 2rem; padding: 0 .8em; }
.toolbar button:hover { color: var(--fg); }
.toolbar input[type="search"] { font-size: .88rem; height: 2rem; }
.toolbar .group { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.toolbar .group > .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--border); }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { width: 12rem; }
/* Everything but Collapse all, the search and the zoom folds behind the
   Filters button (graph.js, `renderToolbar`).  Unfolded on a wide screen, the
   wrapper lays its groups out as the toolbar's own items; on a phone it is a
   row of its own (see the responsive section). */
.toolbar .tb-filters { display: none; }
.toolbar.open .tb-filters { display: contents; }
.toolbar .tb-toggle { display: inline-flex; align-items: center; gap: .35em; }
.toolbar .tb-toggle::after { content: "\25be"; font-size: .8em; }
.toolbar.open .tb-toggle::after { content: "\25b4"; }
.toolbar .tb-toggle.filtered::before {
  content: ""; width: .45em; height: .45em; border-radius: 50%; background: var(--accent);
}

.graph-stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 22px 22px;
  cursor: grab;
}
.graph-stage.panning { cursor: grabbing; }
/* The child combinator matters: the stage also contains the legend, whose
   sample lines and arrowheads are tiny `svg` elements of their own.  As a
   descendant selector this rule blew each of them up to the width of the
   legend and ~90px tall, which made the legend 455px high at 1400x900 — it
   covered nodes and ran off the bottom of the stage. */
.graph-stage > svg { display: block; width: 100%; height: 100%; touch-action: none; }

/* Inside a section, the level the reader came from is faded as a selection
   fades the rest, but stays in reach; what a selection brings forward comes
   forward here too (graph.js, `applyLevel`). */
.glayer .gnode.outside:not(.focus) { opacity: .28; }
.glayer .gnode.compound.outside:not(.focus), .glayer .gtitle.outside:not(.focus) { opacity: .45; }
.glayer .gedge.outside:not(.focus) { opacity: .12; }
.graph-back {
  position: absolute;
  top: .6rem;
  left: .75rem;
  max-width: calc(100% - 1.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.graph-back[hidden] { display: none; }
.graph-status {
  position: absolute;
  left: .75rem;
  bottom: .6rem;
  font-size: .78rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  padding: .2em .5em;
  border-radius: 4px;
  pointer-events: none;
}

/* Hidden unless the reader shows the statistics (graph.js, `statsToggle`),
   but never while a layout runs: then it says how much is being laid out. */
.graph-stage.stats-hidden:not(.laying-out) .graph-status { display: none; }

/* Layout gave up: said in the pane itself, not only in the status line. */
.graph-error {
  position: absolute;
  left: .75rem;
  right: .75rem;
  top: .6rem;
  font-size: .8rem;
  color: var(--lv-error);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--lv-error);
  border-radius: 4px;
  padding: .35em .6em;
  pointer-events: none;
}

/* While ELK is thinking — in a worker, so panning and zooming still work, but
   the drawing on screen is the previous view until it answers. */
.graph-stage.laying-out .glayer { opacity: .55; }
.graph-stage.laying-out .graph-status {
  color: var(--fg);
  border: 1px solid var(--border);
}
.graph-stage.laying-out .graph-status::after {
  content: "";
  display: inline-block;
  width: .55em;
  height: .55em;
  margin-left: .45em;
  vertical-align: baseline;
  border-radius: 50%;
  background: currentColor;
  animation: bp-pulse 1s ease-in-out infinite;
}
@keyframes bp-pulse {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .graph-stage.laying-out .graph-status::after { animation: none; opacity: .7; }
}

.legend {
  position: absolute;
  right: .75rem;
  bottom: .6rem;
  font-size: .74rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4em .6em;
  display: grid;
  gap: .18em;
  pointer-events: none;
  max-width: 15rem;
}
.legend b { color: var(--fg); font-weight: 560; }
.legend .row { display: flex; align-items: center; gap: .4em; }
.legend .sw { width: 1.1em; height: .62em; border-radius: 2px; border: 1.5px solid currentColor; flex: none; }

/* graph svg internals */
.gnode .shape {
  fill: var(--graph-node);
  stroke: var(--border-strong);
  stroke-width: 1.5;
  transition: stroke .15s, stroke-width .15s;
}
.gnode.compound > .shape { fill: var(--graph-compound); stroke-dasharray: none; }
.gnode .label { fill: var(--fg); font-size: 12px; font-weight: 550; pointer-events: none; }
.gnode .sub { fill: var(--muted); font-size: 10px; pointer-events: none; }
.gnode { cursor: pointer; }
.gnode:hover .shape { stroke-width: 2.2; }
.gnode.selected .shape { stroke: var(--accent); stroke-width: 2.6; }
.gnode.dim { opacity: .22; }
/* What is hidden inside a box matches: a count on its top left corner
   (graph.js, `insideBadge`); the box's own match is its outline. */
.gnode .search-inside rect { fill: var(--graph-hl); stroke: var(--panel); stroke-width: 1.5; }
.gnode .search-inside text { fill: #1b1d1e; font-size: 11px; font-weight: 650; pointer-events: none; }

.gnode .statusbar { stroke: none; }
.gnode .junction-dot { fill: var(--graph-junction); stroke: var(--panel); stroke-width: 1.5; }

.gedge path {
  fill: none;
  stroke: var(--graph-edge);
  stroke-width: 1.3;
}
.gedge.state-derived-only path { stroke-dasharray: 5 4; }
.gedge.unwitnessed path { stroke-dasharray: 3 2; }
.gedge.kind-refines path { stroke-dasharray: 2 3; }
.gedge.dim { opacity: .18; }
.gedge .elabel { fill: var(--muted); font-size: 9.5px; pointer-events: none; }
.gedge.hover path, .gedge.selected path { stroke: var(--graph-edge-strong); }

.glayer { transition: transform .28s cubic-bezier(.3, .7, .3, 1); }
.glayer.no-anim { transition: none; }

/* side panel */
.side {
  border-left: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 1rem;
  font-size: .9rem;
}
.side h2 { margin-top: 0; font-size: 1.05rem; }
/* The title, a link into the document, and beside it the kind (graph.js). */
.side .side-head { display: flex; align-items: baseline; gap: .3rem .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.side .side-head h2 { flex: 1 1 10rem; margin-bottom: 0; }
.side .side-head .badge.kind { flex: none; }
/* Under the title, the same link spelt out. */
.side .side-open { margin: -.2rem 0 .6rem; font-size: .85rem; }
.side .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.side .excerpt { color: var(--fg); font-size: .88rem; max-height: 16rem; overflow: auto; }
.side section { margin-top: 1.1rem; }
.side section > h3 {
  margin: 0 0 .35rem;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}
/* A long listing behind a disclosure: the summary reads as the other sections'
   headings, with the browser's own marker in front saying it opens. */
.side section.fold > details > summary {
  cursor: pointer;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}
.side section.fold > details > summary:hover { color: var(--fg); }
.side section.fold > details[open] > summary { margin-bottom: .35rem; }
.side ul { margin: 0; padding-left: 1.05rem; }
.side li { margin: .12em 0; }
.side .hint { color: var(--faint); font-size: .84rem; }
/* The bar that minimises and closes the panel when it is a sheet on a phone. */
.side .sheet-bar { display: none; }
/* Hidden by the toolbar's Show sidebar button, the panel leaves its column
   to the graph.  Not on a phone, where it is a sheet that comes and goes with
   the selection, and the button is not offered. */
@media (min-width: 901px) {
  .graph-page.side-hidden { grid-template-columns: 1fr; }
  .graph-page.side-hidden > .side { display: none; }
}

/* ---------------------------------------------------------- object page */

.obj-head { display: flex; gap: .6rem; align-items: flex-start; flex-wrap: wrap; }
.obj-head h1 { flex: 1 1 18rem; }
.obj-id {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--muted);
  word-break: break-all;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 1rem 0;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

/* A panel behind a disclosure (the object page's long listings): its heading
   is the summary, with the browser's own marker in front saying it opens, and
   a shut panel is that one line. */
details.panel > summary { cursor: pointer; }
details.panel > summary > h3 { display: inline; margin: 0; }
details.panel > summary:hover > h3 { color: var(--accent); }
details.panel[open] > summary { margin-bottom: .6rem; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25em .9em; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.body-prose { overflow-wrap: break-word; }
.body-prose p:first-child { margin-top: 0; }
.body-prose img { max-width: 100%; }
/* Where an in-page link (`#name`, app.js `watchAnchors`) lands: below the top bar. */
.body-prose [id] { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.body-prose blockquote {
  margin: 1em 0;
  padding: .1em 1em;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.body-prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: .2em 0; }

a.objlink { font-weight: 500; }
a.objlink.broken { color: var(--lv-missing, var(--st-missing)); text-decoration: line-through dotted; cursor: help; }

/* A quiet link, `[text](@slug)` (app.js `quietLinks`): set as the words
   around it, underlined only under the pointer, and the pointer a hand only
   while Ctrl or ⌘ is held, which a click needs to follow it. */
a.quietlink, a.quietlink:hover { color: inherit; text-decoration: none; cursor: text; }
a.quietlink[data-href]:hover { text-decoration: underline; }
html.quiet-follow a.quietlink[data-href]:hover { cursor: pointer; }

/* The card a link to an object shows while the pointer rests on it
   (preview.js): its head, the prose, scrolling when it is long, and a foot.
   Placed by the script, against the window. */
.preview {
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  width: min(32rem, calc(100vw - 16px));
  max-height: min(26rem, 45vh);
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .94rem;
  line-height: 1.5;
  text-align: left;
  animation: preview-in .12s ease-out;
}
@keyframes preview-in { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .preview { animation: none; } }
.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2em .5em;
  padding: .55rem .85rem .45rem;
  border-bottom: 1px solid var(--border);
}
.preview-lead { font-weight: 650; }
.preview-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.preview-head .badge { margin-left: auto; align-self: center; }
.preview-ends { padding: .4rem .85rem 0; font-size: .86rem; }
.preview-ends .role { color: var(--muted); font-size: .8rem; }
.preview-body {
  flex: 1 1 auto;
  min-height: 2.5em;
  overflow: auto;
  overscroll-behavior: contain;
  padding: .55rem .85rem;
}
.preview-body > :last-child { margin-bottom: 0; }
.preview-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2em .9em;
  padding: .4rem .85rem;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: .8rem;
  color: var(--muted);
}
.preview-id { font-family: var(--mono); font-size: .8rem; overflow-wrap: anywhere; }
.preview-open { margin-left: auto; white-space: nowrap; }

/* The card of Lean names that the document's "object" link beside a heading
   opens (preview.js). */
.preview.lean-card { width: max-content; min-width: min(18rem, calc(100vw - 16px)); max-width: min(32rem, calc(100vw - 16px)); }
ul.lean-names { list-style: none; margin: 0; padding: 0; }
ul.lean-names li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25em .5em;
  padding: .3em 0;
  border-bottom: 1px solid var(--border);
}
ul.lean-names li:last-child { border-bottom: 0; }
ul.lean-names code { font-family: var(--mono); font-size: .85rem; overflow-wrap: anywhere; }
ul.lean-names .lean-docs { margin-left: auto; font-size: .78rem; white-space: nowrap; }

/* Each declaration of the object page's Lean panel: its number, then what it
   says in words (its docstring), set left as prose is, with the Lean name,
   kind and status small beneath; the signature and the rest follow. */
.lean-decl {
  margin: .8rem 0;
  padding: .75rem .9rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.lean-decl:first-child { margin-top: 0; }
.lean-decl:last-child { margin-bottom: 0; }
.lean-decl-head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .45rem; }
.lean-num {
  flex: none;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 .3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font: 600 .8rem/1 var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
}
.lean-decl-title { flex: 1; min-width: 0; text-align: left; }
.lean-notation { font-size: 1.12rem; line-height: 1.45; color: var(--fg); }
.lean-notation > :last-child { margin-bottom: 0; }
.lean-notation.is-name code { font-size: .95rem; overflow-wrap: anywhere; }
.lean-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: .25em .5em;
  margin-top: .3em;
  font-size: .8rem;
  color: var(--muted);
}
.lean-meta code { font-size: .78rem; overflow-wrap: anywhere; }
.lean-meta a { color: var(--muted); }
.lean-meta a:hover { color: var(--accent); }
.lean-decl pre { margin: .25em 0; white-space: pre-wrap; }
/* "depends on N declarations", folded when the list is long. */
details.lean-deps { font-size: .82rem; color: var(--muted); margin-top: .15em; }
details.lean-deps > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: baseline;
  gap: .35em;
}
details.lean-deps > summary::-webkit-details-marker { display: none; }
details.lean-deps > summary::before {
  content: "▸";
  font-size: .8em;
  transition: transform .15s;
}
details.lean-deps[open] > summary::before { transform: rotate(90deg); }
details.lean-deps > summary:hover { color: var(--fg); }
details.lean-deps[open] > .where { margin-top: .25em; }
/* The axiom and dependency lists are runs of `code` chips with nothing but a
   margin between them, and a margin is not a break opportunity: on a theorem
   with forty Lean dependencies the row became one unbreakable 14,000px line
   and the whole site grew a horizontal scrollbar.  A wrapping flex row gives
   the browser somewhere to break and keeps the spacing. */
.lean-decl .where {
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .15em .45em;
  min-width: 0;
}
.lean-decl .where code { overflow-wrap: anywhere; }

ul.objlist { list-style: none; margin: 0; padding: 0; }
ul.objlist li { padding: .2em 0; display: flex; gap: .45rem; align-items: baseline; flex-wrap: wrap; }
ul.objlist .role {
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--muted);
  min-width: 3.2em;
}

.chain { font-size: .88rem; }
.chain .sep { color: var(--faint); margin: 0 .35em; }

/* -------------------------------------------------------- document page */

.doc-entry { margin: 0 0 1.6rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.doc-entry .head { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.doc-entry .head h2, .doc-entry .head h3, .doc-entry .head h4, .doc-entry .head h5 { margin: 0; }
/* The number is the size of the title it leads, as a statement's is (below). */
.doc-entry .head .num { color: var(--faint); font-family: var(--mono); font-size: 1em; }
.doc-entry.depth-0 { border-top: 2px solid var(--border-strong); padding-top: 1.2rem; margin-top: 2.2rem; }
.doc-entry.depth-0:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.doc-entry .prose { margin-top: .5rem; }
.doc-entry.dup { opacity: .75; }

/* A proof follows its statement as in a paper: "Proof." run in, its prose,
   and an end mark at the right (`proofDisclosure` in app.js, which also
   makes it fold; see "Proofs fold" below). */
.proof { margin: .6rem 0 1rem; }
.proof-word { font-style: italic; font-weight: 700; color: inherit; }
.proof-prose > p:first-child { margin-top: 0; }
.proof-body > :last-child { margin-bottom: .3em; }
.proof-end { text-align: right; line-height: 1; color: var(--muted); }

.step {
  margin: .8rem 0 .8rem 1.2rem;
  padding: .55rem .9rem;
  border-left: 3px solid var(--accent);
  background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.step .step-head {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  gap: .45rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + .8rem);
  font-size: .86rem;
  max-height: calc(100vh - var(--topbar-h) - 3rem);
  overflow-y: auto;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .15em 0; }
/* The sidebar one level at a time (`levelSidebar` in document.js): the chain
   above the opened entry as headings, each the way back up, and the opened
   entry among its siblings with its own entries under it; an entry with
   entries of its own says so, and the opened one points down. */
.toc-levels .num { color: var(--muted); font-variant-numeric: tabular-nums; }
/* The whole row is the link, wrapped lines and the gap between them too. */
.toc-levels li > a { display: block; }
.toc-levels ul { list-style: none; margin: .15em 0 .3em .3rem; padding-left: .6rem; border-left: 1px solid var(--border); }
.toc-levels li.toc-up > a { font-weight: 600; }
.toc-levels li.toc-up > a::before { content: '‹'; color: var(--faint); margin-right: .35em; font-weight: 400; }
.toc-levels li.has-kids > a::after { content: '›'; display: inline-block; color: var(--faint); margin-left: .35em; }
.toc-levels li.toc-entry.open.has-kids > a::after { transform: rotate(90deg); }
.toc-levels li.toc-up.has-kids > a::after { content: none; }
.toc-levels li.on-path > a { font-weight: 600; }
.toc-levels li.current > a { color: var(--fg); }
.doc-layout { display: grid; grid-template-columns: 15rem 1fr; gap: 2rem; align-items: start; }

/* The blog (blog.js): the posts in the document's sidebar, a post's words,
   then its PDF read in the page. */
.blog-toc .toc-head a { color: inherit; }
.blog-list { list-style: none; margin: 0; padding: 0; }
.blog-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.blog-list .blog-title { font-weight: 560; }
.blog-date { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.blog-head { margin-bottom: 1.2rem; }
.blog-head h1 { margin: 0; }
.blog-author { font-size: .92rem; }
.blog-head .blog-author { margin: .3rem 0 0; font-size: 1rem; }
.blog-head .blog-date { margin: .3rem 0 0; }
.blog-head .blog-visits { margin: .2rem 0 0; color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.blog-tag {
  font-size: .72rem; color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 .4em;
}
.blog-pdf { margin: 1.4rem 0; }
.blog-pdf-links { font-size: .88rem; margin: 0 0 .5rem; }
.blog-pdf iframe {
  display: block; width: 100%; height: calc(100vh - var(--topbar-h) - 6rem); min-height: 24rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel);
}
.blog-pager { margin-top: 2rem; }

/* The split document: where a page sits, and its neighbours. */
.doc-crumbs { font-size: .86rem; color: var(--muted); margin: 0 0 .6rem; }
.doc-crumbs .sep { color: var(--faint); margin: 0 .4em; }
.doc-crumbs .here { color: var(--fg); }
.doc-pager {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: baseline;
  font-size: .88rem; margin: .8rem 0 1.4rem; padding: .5rem 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.doc-pager .up { text-align: center; }
.doc-pager .next { text-align: right; }
.doc-pager .num { color: var(--faint); font-family: var(--mono); font-size: .85em; }
.doc-entry.page-head { margin-bottom: 1.4rem; }
.doc-entry.page-head .head h1 { margin: 0; }
.doc-entry.page-head.is-statement { border-left: 0; padding-left: 0; }
/* On a section's page its statements are the first level; the rule between
   top-level parts is for parts, not for statements set one after another. */
.doc-entry.depth-0.is-statement { border-top: 0; padding-top: 0; margin-top: 1.1rem; }
/* The heading, kind, number and title, is one link to the entry's level; the
   kind and number keep their own colours inside it. */
.doc-entry .head a.doc-title .kindword { color: var(--fg); }
.doc-entry .head a.doc-title .doc-title-text { font-weight: 500; }
.doc-entry .head a.doc-open { font-size: .9rem; font-weight: 400; white-space: nowrap; }
.doc-entry .head a.doc-object { font-size: .78rem; font-weight: 400; color: var(--muted); white-space: nowrap; }
.doc-entry .head a.doc-object:hover { color: var(--accent); }

/* The table of contents, a page of its own (contents.js): the document as a
   tree, a row per entry, a link to where it is read, and beside a row with
   entries below it a triangle that unfolds them. */
.contents-tree, .contents-tree ol { list-style: none; margin: 0; padding: 0; }
.contents-tree { margin: .4rem 0 1.6rem; border-top: 1px solid var(--border); }
.contents-tree > li { border-bottom: 1px solid var(--border); }
.contents-tree ol { margin: 0 0 .4rem 1.05rem; padding-left: .6rem; border-left: 1px solid var(--border); }
.contents-row { display: flex; align-items: baseline; gap: .15rem; }
.contents-toggle {
  flex: none;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.contents-toggle:hover { color: var(--fg); background: var(--panel-2); }
.contents-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The triangle: pointing right when folded, down when unfolded. */
.contents-toggle::before {
  content: "";
  border-style: solid;
  border-width: .3rem 0 .3rem .45rem;
  border-color: transparent transparent transparent currentColor;
  transition: transform .15s ease;
}
.contents-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.contents-toggle.none { cursor: default; }
.contents-toggle.none::before { content: none; }
.contents-link {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) minmax(0, 12rem);
  gap: .6rem;
  align-items: baseline;
  padding: .45rem .5rem .45rem .2rem;
  color: var(--fg);
  border-radius: var(--radius);
}
.contents-tree > li > .contents-row > .contents-link { padding-top: .65rem; padding-bottom: .65rem; }
.contents-link:hover { background: var(--panel-2); text-decoration: none; }
.contents-link .num { color: var(--faint); font-family: var(--mono); font-size: .85em; }
.contents-title { color: var(--accent); }
.contents-tree > li > .contents-row .contents-title { font-size: 1.08rem; }
.contents-title .kindword { font-weight: 700; color: var(--fg); }
.contents-meta { justify-self: end; width: 100%; display: flex; justify-content: flex-end; }
.contents-meta .bar-row { width: 100%; }
.contents-meta:empty { display: none; }
.contents-tree li.dup > .contents-row { opacity: .75; }
@media (max-width: 640px) {
  .contents-link { grid-template-columns: max-content minmax(0, 1fr); gap: .5rem; }
  .contents-meta { grid-column: 2; justify-content: flex-start; }
  .contents-tree ol { margin-left: .8rem; padding-left: .4rem; }
}

/* -------------------------------------------------------- progress page */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .7rem;
  margin: 1rem 0 1.6rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--st-none);
  border-radius: var(--radius);
  padding: .6rem .8rem;
}
.stat .n { font-size: 1.5rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .78rem; color: var(--muted); }
.stat.s-absent { border-left-color: var(--st-absent); }
.stat.s-missing { border-left-color: var(--st-missing); }
.stat.s-stated { border-left-color: var(--st-stated); }
.stat.s-proved { border-left-color: var(--st-proved); }
.stat.s-proved_with_axioms { border-left-color: var(--st-proved_with_axioms); }
.stat.visits { border-left-color: var(--accent); }
/* One box, as wide as one of the five status boxes above it. */
.visit-row { grid-template-columns: minmax(9rem, calc((100% - 4 * .7rem) / 5)); }

.stackbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.stackbar > span { display: block; }

.chart { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .tick { fill: var(--muted); font-size: 10px; }
.chart .line-total { fill: none; stroke: var(--st-none); stroke-width: 2; }
.chart .line-proved { fill: none; stroke: var(--st-proved); stroke-width: 2; }
.chart .area-proved { fill: var(--st-proved); opacity: .12; }
.chart .pt { fill: var(--panel); stroke-width: 2; cursor: pointer; }
.chart .pt.sel { fill: var(--accent); stroke: var(--accent); }

.slider-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .8rem 0; }
.slider-row input[type="range"] { flex: 1; min-width: 12rem; }

/* The progress listing's search and filters. */
.listing-filters { display: flex; gap: .5rem .9rem; flex-wrap: wrap; align-items: center; margin: .6rem 0 .4rem; }
.listing-filters label { display: inline-flex; align-items: center; gap: .4em; }
.listing-filters .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.listing-filters select { max-width: 16rem; }
.listing-search { flex: 1 1 16rem; min-width: 12rem; max-width: 26rem; }
.listing-count { margin: .2rem 0 .5rem; }

/* -------------------------------------------------------------- utility */

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: .5rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------- export dialog */

.export-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  background: rgba(10, 14, 20, .42);
  overflow-y: auto;
}
.export-dialog {
  width: min(36rem, 100%);
  padding: 1.1rem 1.25rem 1rem;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.export-dialog h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.export-from { margin: 0 0 .8rem; }
/* A fieldset is as wide as its widest content unless told otherwise, which
   pushed the dialog off a phone's screen. */
.export-scope { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .75rem .6rem; margin: 0 0 .75rem; }
.export-scope legend { padding: 0 .3em; font-size: .82rem; color: var(--muted); font-weight: 600; }
/* The radio, then its text, then (below the text) the menu or the note. */
.export-choice { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .5rem; row-gap: .2rem; align-items: baseline; padding: .3rem 0; cursor: pointer; }
.export-choice input { margin: 0; grid-column: 1; }
.export-choice > span, .export-choice > select { grid-column: 2; min-width: 0; }
.export-part-title { font-weight: 600; overflow-wrap: anywhere; }
.export-other { width: 100%; max-width: 100%; }
.export-options { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; margin-bottom: .4rem; }
.export-field { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; }
.export-field > span { color: var(--muted); font-weight: 600; font-size: .82rem; }
.export-field select { max-width: 100%; }
.export-check { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; cursor: pointer; }
.export-hint { margin: .2rem 0 .6rem; line-height: 1.45; }
.export-summary { margin: .4rem 0 .8rem; font-size: .9rem; overflow-wrap: anywhere; }
.export-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.export-go {
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
  padding: .45em 1.1em;
}
.export-go:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
.export-status:empty { display: none; }
.export-status { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.export-busy { display: flex; align-items: center; gap: .55rem; margin: 0; color: var(--muted); }
.export-spinner {
  width: 1em; height: 1em; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: export-spin .8s linear infinite;
}
@keyframes export-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .export-spinner { animation-duration: 2.4s; } }
.export-done { margin: 0 0 .6rem; font-weight: 600; }
.export-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.button-link {
  display: inline-flex; align-items: center;
  padding: .4em .85em;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  font-size: .9rem;
}
.button-link:hover { background: var(--panel-2); text-decoration: none; }
.button-link.primary { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.export-error {
  margin: 0 0 .6rem;
  padding: .55rem .75rem;
  border: 1px solid var(--lv-error);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--lv-error) 9%, var(--panel));
}
.export-error p { margin: .2rem 0; }
.export-warnings { margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.export-warnings ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------------------------------------------------------- responsive */

@media (max-width: 900px) {
  /* The graph keeps the whole window below the top bar.  The toolbar is one
     row, its filters folded behind a button, and the side panel is a sheet
     over the bottom of the graph that is there only while something is
     selected, can be shrunk to its title, and closed. */
  .graph-page {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .toolbar { gap: .4rem; flex-wrap: wrap; }
  .toolbar .spacer { display: none; }
  .toolbar .tb-side { display: none; }
  .toolbar .tb-search { flex: 1 1 6rem; min-width: 0; }
  .toolbar .tb-search input[type="search"] { width: 100%; min-width: 0; }
  .toolbar .tb-zoom { flex-wrap: nowrap; }
  .toolbar .tb-filters { display: none; }
  .toolbar.open .tb-filters {
    order: 1;
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem .75rem;
    max-height: 45vh;
    overflow-y: auto;
    padding-top: .4rem;
    border-top: 1px solid var(--border);
  }
  .toolbar .tb-filters .sep { display: none; }
  .graph-status { right: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .side {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    max-height: 50%;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, .14);
    padding-top: 0;
    overscroll-behavior: contain;
  }
  .side.unselected { display: none; }
  .side .sheet-bar {
    display: flex;
    align-items: center;
    gap: .4rem;
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 -1rem .5rem;
    padding: .15rem .6rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .side .sheet-bar button {
    border: 0;
    background: none;
    color: var(--muted);
    font-size: .8rem;
    padding: .3rem .5rem;
  }
  .side .sheet-grip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
  }
  .side .grip-mark { width: 2.4rem; height: 4px; border-radius: 2px; background: var(--border-strong); }
  .side .sheet-close { font-size: 1rem; }
  .side.min > :not(.sheet-bar):not(.side-head):not(.sheet-keep) { display: none; }
  .side.min > .side-head { margin-bottom: .2rem; }
  .side.min > .sheet-keep { margin: .4rem 0 .6rem; }
  .doc-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; border-bottom: 1px solid var(--border); padding-bottom: .8rem; }
  /* The box takes what the row has to spare. */
  .gsearch { flex: 1 1 12rem; }
  .search-page { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .search-aside { position: static; }
  .legend { display: none; }
}

@media (max-width: 560px) {
  .page { padding: 1rem .8rem 4rem; }
  .tabs a { padding: .3em .5em; font-size: .85rem; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { margin-top: .5em; }
  /* the height of the title's line, so the logo does not make the bar taller */
  .brand-logo { width: 1.5em; height: 1.5em; }
}

@media (prefers-reduced-motion: reduce) {
  .glayer, .bar > span { transition: none; }
}

/* ============================================================== graph svg */

.gnode { transition: transform .3s cubic-bezier(.3, .7, .3, 1), opacity .2s ease; }
.glayer.no-anim .gnode { transition: opacity .2s ease; }
@media (prefers-reduced-motion: reduce) { .gnode { transition: none; } }

.gnode .kindmark {
  fill: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .02em;
  pointer-events: none;
}
.gnode .expander {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}
.gnode .ptrack { fill: var(--panel-2); }
.gnode .pfill { fill: var(--st-proved); }
.gnode:focus { outline: none; }
.gnode:focus-visible .shape { stroke: var(--accent); stroke-width: 2.6; }
.gnode.hovered .shape { stroke-width: 2.2; }

/* fill / outline by derived status */
.gnode.status-none    .shape { fill: var(--graph-node); stroke: var(--border-strong); }
.gnode.status-absent  .shape { fill: color-mix(in srgb, var(--st-absent) 12%, var(--graph-node)); stroke: var(--st-absent); }
.gnode.status-missing .shape { fill: color-mix(in srgb, var(--st-missing) 10%, var(--graph-node)); stroke: var(--st-missing); stroke-dasharray: 5 3; }
.gnode.status-stated  .shape { fill: color-mix(in srgb, var(--st-stated) 16%, var(--graph-node)); stroke: var(--st-stated); }
.gnode.status-proved  .shape { fill: color-mix(in srgb, var(--st-proved) 18%, var(--graph-node)); stroke: var(--st-proved); }
.gnode.status-proved_with_axioms .shape { fill: color-mix(in srgb, var(--st-proved_with_axioms) 18%, var(--graph-node)); stroke: var(--st-proved_with_axioms); }

.gnode.compound > .shape {
  fill: var(--graph-compound);
  stroke: var(--border-strong);
  stroke-dasharray: 4 3;
}
.gnode.compound .label { fill: var(--muted); font-size: 12.5px; }

/* A box that matches the search itself: its outline, over the status
   outlines above, which would otherwise keep it grey, and a glow, which tells
   it from a stated box when the progress is shown. */
.gnode.match > .shape {
  stroke: var(--graph-hl); stroke-width: 2.6;
  filter: drop-shadow(0 0 4px var(--graph-hl));
}
.legend .shp { width: 1.6em; height: .9em; flex: none; border: 1.5px solid currentColor; color: var(--muted); }
.graph-stage:not(.inner-arcs):not(.derived-arcs) .legend .lg-derived { display: none; }
.graph-stage:not(.searching) .legend .lg-search { display: none; }
.legend .shp.hit { color: var(--graph-hl); border-width: 2.5px; border-radius: 2px; box-shadow: 0 0 4px var(--graph-hl); }
.legend .lg-badge {
  min-width: 1.6em; flex: none; border-radius: 999px; text-align: center;
  background: var(--graph-hl); color: #1b1d1e; font-size: .78em; font-weight: 650; line-height: 1.35;
}

/* A title with maths: KaTeX's HTML in a <foreignObject> (see graph.js,
   `measureMathTitles`).  The same font as the SVG labels, the colour from
   `color` since HTML has no `fill`, and every line on one line: the lines were
   broken when the node was measured, and must not be broken again. */
/* Not selectable either: a drag that pans across it would paint it as a text
   selection, which SVG text in the graph never shows. */
.gnode foreignObject.label { overflow: visible; pointer-events: none; -webkit-user-select: none; user-select: none; }
.gmath { font-size: 12px; font-weight: 550; line-height: 15px; color: var(--fg); text-align: center; }
.gmath.section { font-size: 12.5px; color: var(--muted); text-align: left; }
.gmath .gm-line, .gmath .gm-tok { white-space: nowrap; }
.gmath .katex { font-size: 1.1em; }
.gmath .katex-html { white-space: nowrap; }
.gmath-measure {
  position: absolute; left: -100000px; top: 0;
  visibility: hidden; pointer-events: none; contain: layout style;
}
.gmath-measure .gm-tok { display: inline-block; }
.gmath-measure .gm-line { width: max-content; }
.gnode.junction .shape { fill: var(--graph-junction); stroke: var(--bg); stroke-width: 2; }
.gnode.junction.selected .shape { fill: var(--accent); stroke: var(--accent); }

.arrowhead { fill: none; stroke: var(--graph-edge); stroke-linecap: round; stroke-linejoin: round; }

.gedge .hit { stroke: transparent; stroke-width: 12; fill: none; cursor: pointer; }
.gtitle .title-hit { fill: transparent; cursor: pointer; }
.gedge.hovered path:not(.hit) { stroke: var(--graph-edge-strong); }
.gedge.synthetic path:not(.hit) { opacity: .8; }
.gedge.spoke path:not(.hit) { stroke-width: 1.1; }
.edges.fade-in { opacity: 0; }
.edges { transition: opacity .25s ease; }

/* a selected node's neighbourhood: its edges and their far ends stay, the rest fades */
.gtitle, .gedge { transition: opacity .2s ease; }
.glayer.focusing .gnode:not(.focus) { opacity: .28; }
.glayer.focusing .gnode.compound:not(.focus) { opacity: .45; }
.glayer.focusing .gedge:not(.focus) { opacity: .12; }
.glayer.focusing .gedge.focus path:not(.hit) { stroke: var(--graph-edge-strong); }
.glayer.focusing .gedge.focus .elabel { fill: var(--graph-edge-strong); font-weight: 600; }
.glayer.focusing .gnode.selected:not(.compound) .shape { stroke-width: 3.2; }
.glayer.focusing .gnode.selected .label { font-weight: 700; }
.arrowhead.focus { stroke: var(--graph-edge-strong); }

.legend .sw.status-none { color: var(--border-strong); background: var(--graph-node); }
.legend .sw.status-absent { color: var(--st-absent); background: color-mix(in srgb, var(--st-absent) 25%, transparent); }
.legend .sw.status-missing { color: var(--st-missing); background: color-mix(in srgb, var(--st-missing) 20%, transparent); }
.legend .sw.status-stated { color: var(--st-stated); background: color-mix(in srgb, var(--st-stated) 28%, transparent); }
.legend .sw.status-proved { color: var(--st-proved); background: color-mix(in srgb, var(--st-proved) 30%, transparent); }
.legend .sw.status-proved_with_axioms { color: var(--st-proved_with_axioms); background: color-mix(in srgb, var(--st-proved_with_axioms) 30%, transparent); }
.legend .lgsvg { flex: none; }

/* status filter chips pick up the status colour */
label.chk.st-chip.status-absent { border-color: var(--st-absent); }
label.chk.st-chip.status-missing { border-color: var(--st-missing); }
label.chk.st-chip.status-stated { border-color: var(--st-stated); }
label.chk.st-chip.status-proved { border-color: var(--st-proved); }
label.chk.st-chip.status-proved_with_axioms { border-color: var(--st-proved_with_axioms); }

/* ========================================================= document extras */

.toc-head {
  margin: 0 0 .4rem;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}
.doc-progress { margin: .45rem 0; max-width: 22rem; }
.doc-entry .head .role {
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--faint);
}
.doc-entry > p.muted.small .role { margin-right: .2em; }

.step .step-head { align-items: center; }
.step .step-head > span:first-child {
  font-family: var(--mono);
  color: var(--accent);
}
.step .step-target { text-transform: none; letter-spacing: 0; font-weight: 400; }
.step .step-link { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; }
.step .step-title { margin: .3rem 0 0; font-weight: 560; }
.step .step-prose { margin-top: .3rem; }
.step .step-prose > p:first-child { margin-top: .2em; }
.step .step-prose > p:last-child { margin-bottom: .2em; }

/* --- document view: statements set like a paper ------------------------ */
/* A statement is a numbered block under its section, not a heading of its
   own: the kind is the lead word, the title follows in parentheses style, and
   the prose is indented by a rule so consecutive statements read as blocks. */
.doc-entry.is-statement { margin: 1.1rem 0 1.1rem; padding-left: .9rem; border-left: 2px solid var(--border); }
.doc-entry.is-statement .head { gap: .4rem; }
.doc-entry.is-statement .head h2, .doc-entry.is-statement .head h3,
.doc-entry.is-statement .head h4, .doc-entry.is-statement .head h5 {
  font-size: 1rem; font-weight: 600;
}
.doc-entry .head .kindword { font-weight: 700; }
/* The kind and number are the size of the title they lead ("Definition 3.1
   Relative Picard functor"), whatever the heading's level, as a section's
   number is. */
.doc-entry.is-statement .head .num { font-family: inherit; font-size: 1em; font-weight: 700; color: var(--fg); }
.doc-entry.is-statement .head .badge { font-size: .72rem; }
/* Headings inside a body ("## Proof") are run-in labels, never larger than
   the statement they belong to. */
.body-prose h1, .body-prose h2, .body-prose h3, .body-prose h4, .body-prose h5, .body-prose h6 {
  font-size: 1rem; font-weight: 600; font-style: italic; margin: .9em 0 .25em; line-height: 1.3;
}
.body-prose h1::after, .body-prose h2::after, .body-prose h3::after { content: '.'; }
.doc-entry.is-section .prose { margin-top: .6rem; }
.doc-entry.is-text { margin: 1.1rem 0; }
.doc-entry.is-text > .prose { margin-top: 0; }
/* A bibliography entry, as a paper sets one: the label in a column of its
   own, the entry beside it, consecutive entries close together. */
.doc-entry.is-reference { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: .8em; margin: .35rem 0; }
.doc-entry.is-reference > .bib-label { min-width: 4.5em; font-variant-numeric: tabular-nums; }
.doc-entry.is-reference > .bib-text > p { margin: 0; }
.doc-entry.is-reference > .bib-text > p + p { margin-top: .35em; }
.cite > a.cite-label { white-space: nowrap; text-decoration: none; }
.cite > a.cite-label:hover { text-decoration: underline; }
/* A grid track sized 1fr still has min-width:auto, so one wide formula or an
   unbreakable token pushes the prose column past the viewport. */
.doc-layout > * { min-width: 0; }

/* ===================================================== search, proofs, comments */

.row > .spacer { flex: 1; }
textarea {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: .45em .6em;
  width: 100%;
  resize: vertical;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover { background: var(--accent); filter: brightness(1.08); }

/* The entry a focus link led to, or a proof's, marked briefly. */
@keyframes doc-flash {
  from { background: var(--accent-soft); }
  to { background: transparent; }
}
.doc-entry.flash, .step.flash, .proof.flash, .lean-decl.flash, .panel.flash { animation: doc-flash 1.6s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .doc-entry.flash, .step.flash, .proof.flash, .lean-decl.flash, .panel.flash { animation: none; outline: 2px solid var(--accent-soft); }
}

/* Proofs fold under their "Proof." heading. */
details.proof > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: .35em;
}
details.proof > summary::-webkit-details-marker { display: none; }
details.proof > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: .8em;
  transition: transform .15s;
}
details.proof[open] > summary::before { transform: rotate(90deg); }
details.proof > summary > :is(h1, h2, h3, h4, h5, h6) { margin: .9em 0 .25em; }
/* "Proof." is bold in every style, a `## Proof` heading as much as a proof
   object's lead: it is what a reader clicks to fold or unfold the proof. */
details.proof > summary.proof-head > :is(h1, h2, h3, h4, h5, h6) { font-weight: 700; }
details.proof:not([open]) > summary::after {
  content: "(folded: click to show)";
  color: var(--faint);
  font-size: .82rem;
}
details.proof > summary:hover > :is(h1, h2, h3, h4, h5, h6) { color: var(--accent); }

/* Comments, at the foot of an object's page. */
.comments h3 { margin-top: 0; }
.comment-list { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1.2rem; }
.comment { border-left: 2px solid var(--border); padding-left: .8rem; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin-bottom: .2rem; }
/* A comment's title, above its name. */
.comment-title-row { margin-bottom: .15rem; }
.comment-title { font-weight: 650; font-size: 1.02em; }
.comment-anchor { margin-left: auto; font-family: var(--mono); }
.comment-form { border-top: 1px solid var(--border); padding-top: .9rem; }
.comment-form h4 { margin: 0 0 .6rem; }
.comment-field { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .6rem; font-size: .88rem; }
.comment-field > span { color: var(--muted); }
.comment-field input[type="text"] { max-width: 22rem; }
.comment-preview {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: .6em .8em;
  margin-bottom: .6rem;
  min-height: 7.5em;
}
.comment-preview[hidden], .comment-field textarea[hidden], .comment-field[hidden] { display: none; }

/* ---------------------------------------------------------------- intro */

/* The project's intro (`intro.js`): one node, drawn as the graph draws one,
   in the middle of an empty screen while the graph is laid out under it.  It
   fades and shrinks into the graph; the reveal is the layer's opacity. */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 16px;
  background: var(--bg);
  cursor: pointer;
  transition: opacity .7s ease;
}
.intro:focus { outline: none; }
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-node {
  position: relative;
  box-sizing: border-box;
  width: min(36rem, 100%);
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1.4rem 1.6rem 1.6rem;
  background: var(--graph-node);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--fg);
  text-align: center;
  animation: intro-in .5s cubic-bezier(.3, .7, .3, 1) backwards;
  transition: transform .7s cubic-bezier(.5, 0, .7, .4);
}
.intro.leaving .intro-node { transform: scale(.55); }
.intro-body > :first-child { margin-top: 0; }
.intro-body > :last-child { margin-bottom: 0; }
.intro-body :is(img, video, svg, iframe, canvas, object, embed) {
  display: block;
  max-width: 100%;
  height: auto;
  margin: .6rem auto;
  border-radius: 4px;
}
.intro-body iframe { border: 0; }
/* How much of its time the intro has left, along the node's foot, as the
   graph's nodes show their progress. */
.intro-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  animation: intro-timer linear both;
}
@keyframes intro-in { from { opacity: 0; transform: scale(.94); } }
@keyframes intro-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .intro { transition-duration: .2s; }
  .intro-node { animation: none; }
  .intro.leaving .intro-node { transform: none; }
  .intro-timer { display: none; }
}

/* The zooming intro (`playZoom` in intro.js).  The title and its flight
   into the top bar sit above the top bar; the background and the pictures
   below it, so the top bar fades in over them.  The page itself
   is there all along: what the intro has not yet shown is transparent. */
html.intro-pending .topbar,
html.intro-pending .banner,
html.intro-pending .app { visibility: hidden; opacity: 0; }
html.intro-playing .loading { visibility: hidden; }
html.intro-playing .topbar,
html.intro-playing .banner,
html.intro-playing .graph-page > :not(.graph-stage),
html.intro-playing .graph-stage > :not(svg) {
  opacity: 0;
  transition: opacity var(--intro-step, 1s) ease;
}
html.intro-chrome .topbar,
html.intro-chrome .banner,
html.intro-chrome .graph-page > :not(.graph-stage),
html.intro-chrome .graph-stage > :not(svg) { opacity: 1; }
html.intro-playing .brand { opacity: 0; transition: opacity calc(var(--intro-step, 1s) * .3) ease; }
html.intro-landed .brand { opacity: 1; }
/* A title landing on the logo (`intro-logo`): the top bar's title comes with
   the bar, and its logo only when the title lands there. */
html.intro-playing.intro-logo .brand { opacity: 1; }
html.intro-playing.intro-logo .brand-logo {
  opacity: 0;
  transition: opacity calc(var(--intro-step, 1s) * .3) ease;
}
html.intro-playing.intro-logo.intro-landed .brand-logo { opacity: 1; }
html.intro-playing .graph-stage > svg { opacity: 0; }

.intro.zoom {
  display: block;
  z-index: 25;
  padding: 0;
  background: none;
  overflow: hidden;
  transition: opacity .3s ease;
}
.intro-backdrop { position: absolute; inset: 0; background: var(--bg); }
.intro-bg { position: fixed; inset: 0; will-change: transform, opacity; }
.intro-bg img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* a manuscript, faded into the page: its paper goes the page's colour */
  opacity: .16;
  filter: grayscale(1) contrast(1.1);
  mix-blend-mode: multiply;
}
.intro-pic {
  position: fixed;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  visibility: hidden;
}
.intro-pic svg { display: block; overflow: visible; }
.intro-pic .gnode { cursor: inherit; }
.intro-title {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 16px;
  color: var(--fg);
  font-size: clamp(2.4rem, 7.5vw, 6rem);
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
  transition: opacity .3s ease;
}
.intro-line {
  pointer-events: auto;
  cursor: pointer;
  animation: intro-title-in .7s cubic-bezier(.2, .7, .2, 1) backwards;
}
/* A title that moves (an animated <svg>) shows itself, without growing in. */
.intro-line.film { animation: none; }
.intro-words { display: inline-block; }
.intro-words :is(h1, h2, h3, h4, h5, h6, p) { font: inherit; margin: 0; }
.intro-wait {
  width: 9rem;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 50% 100% no-repeat,
              var(--border);
  opacity: 0;
  transition: opacity .6s ease;
}
.intro-title.waiting .intro-wait { opacity: .8; animation: intro-wait 1.4s ease-in-out infinite; }
.intro.zoom.leaving, .intro-title.leaving { opacity: 0; pointer-events: none; }
@keyframes intro-title-in { from { opacity: 0; transform: scale(.55); } }
@keyframes intro-wait { from { background-position: -100% 0, 0 0; } to { background-position: 200% 0, 0 0; } }
@media (prefers-color-scheme: dark) {
  .intro-bg img { filter: grayscale(1) invert(1) contrast(1.1); mix-blend-mode: screen; opacity: .12; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-line { animation: none; }
  .intro-title.waiting .intro-wait { animation: none; }
}

/* ================================================================ the look */

/* The site's look, over everything above, which it overrides where the two
   differ: after Kiran Kedlaya's notes on prismatic cohomology, a PreTeXt
   book, Open Sans and Roboto Serif and one deep blue, with the document's
   contents sidebar drawn as an outline (`toc-outline`, below).  It was the
   Outline style when the site still had a style menu; it is set after the
   rest, in the order the two sheets of that style were, so that it wins as
   it did then. */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f2f2;
  --fg: #000000;
  --muted: #555555;
  --faint: #8a8a8a;
  --border: #d9d9d9;
  --border-strong: #b3b3b3;
  --accent: #195684;
  --accent-soft: #e4edf4;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .08);

  --ptx-blue: #195684;
  --ptx-blue-text: #195684;
  --ptx-red: #932c1c;
  --ptx-rule: #6087a9;
  --ptx-head-bg: #fafafa;
  --ptx-nav-bg: #ededed;

  --sans: "Open Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "Roboto Serif", "Noto Serif", Georgia, serif;
  --radius: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1f21;
    --panel: #1e1f21;
    --panel-2: #2a2c2f;
    --fg: #e8e8e8;
    --muted: #b0b0b0;
    --faint: #85888c;
    --border: #3a3c40;
    --border-strong: #55585d;
    --accent: #8ab8e0;
    --accent-soft: #23384b;
    --accent-fg: #1e1f21;

    --ptx-blue: #23527a;     /* bars and blocks */
    --ptx-blue-text: #8ab8e0; /* text on the dark ground */
    --ptx-red: #8a3324;
    --ptx-rule: #5a7c9b;
    --ptx-head-bg: #26282b;
    --ptx-nav-bg: #2e3034;
  }
}

body { font-size: 16.5px; line-height: 1.55; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; color: var(--fg); }
a.objlink { font-weight: 600; }

/* ------------------------------------------------------- the head */

/* The book's title in blue serif over a light band, the controls in a grey
   one below it — here in one band, the title set as the book's. */
.topbar { background: var(--ptx-head-bg); border-bottom: 1px solid var(--border-strong); }
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; color: var(--ptx-blue-text); }
.brand-mark { display: none; }
.tabs a { border-radius: 0; color: var(--fg); }
.tabs a:hover { background: var(--ptx-nav-bg); }
.tabs a.active { background: var(--ptx-nav-bg); color: var(--fg); box-shadow: inset 0 -2px 0 var(--ptx-blue); }
button, select, input[type="text"], input[type="search"] { border-radius: 0; }
.badge { border-radius: 2px; }

/* ------------------------------------------------------- contents */

/* The contents as PreTeXt draws them: one blue block per entry, white text,
   a white rule between; deeper entries on white under a steel rule.  The
   document's sidebar is drawn as an outline over these (below); the blog's
   list of posts keeps the rows on white under a steel rule. */
/* Wide screens only: below 901px the document is set in one column (above). */
@media (min-width: 901px) {
  .doc-layout { grid-template-columns: 15rem minmax(0, 40rem); gap: 3rem; justify-content: center; }
}
.toc-head { display: none; }
.toc ul { border-top: 1px solid var(--ptx-blue); }
.toc li { margin: 0; }
.toc-levels ul { margin: 0; padding: 0; border-left: 0; border-top: 0; }
.toc-levels li.toc-up > a {
  display: block;
  padding: .35em .7em;
  background: var(--ptx-blue);
  color: #fff;
  border-bottom: 1px solid #fff;
  font-size: .92rem;
  line-height: 1.3;
}
.toc-levels li.toc-up > a .num, .toc-levels li.toc-up > a::before { color: #fff; opacity: .85; }
.toc-levels li.toc-up > a:hover { background: var(--ptx-red); text-decoration: none; }
.toc-levels li:not(.toc-up) > a {
  display: block;
  padding: .3em .7em .3em 1.6em;
  background: var(--bg);
  color: var(--fg);
  font-size: .85rem;
  border-bottom: 1px solid var(--ptx-rule);
}
.toc-levels li:not(.toc-up) > a:hover { background: var(--accent-soft); text-decoration: none; }
.toc-levels li.open > a { font-weight: 600; }
.toc-levels li.open > ul > li > a { padding-left: 2.4em; }

/* ------------------------------------------------------- the text */

/* Headings: black serif, a steel rule under them, the number in the same
   face as the title. */
.doc-entry .head .num { font-family: var(--serif); color: var(--fg); font-weight: 700; }
.doc-entry .head :is(h1, h2, h3, h4, h5) .num { font-size: 1em; }
.doc-entry .head a:not(.num):not(.doc-open):not(.doc-object) { color: var(--fg); }
.doc-entry.is-section > .head, .doc-entry.page-head > .head {
  border-bottom: 2px solid var(--ptx-rule);
  padding-bottom: .25rem;
}
.doc-entry.depth-0 { border-top: 0; }

/* Statements: a thin rule down the left, the head in bold serif
   ("Definition 4.1.1."), the title after it, the text upright. */
.doc-entry.is-statement { border-left: 1px solid var(--fg); padding-left: .8rem; }
.doc-entry.is-statement .head .kindword,
.doc-entry.is-statement .head .num { font-family: var(--serif); font-size: 1em; font-weight: 700; color: var(--fg); }
.doc-entry.is-statement .head .num::after { content: "."; }
.doc-entry.is-statement .head :is(h2, h3, h4, h5) { font-family: var(--sans); font-size: 1rem; font-weight: 600; }
.doc-entry.is-statement .head .badge.kind { display: none; }
.doc-entry.is-statement:has(> .head .status-proved) { border-left-color: var(--fg); }

/* Proofs: "Proof." in italics, as PreTeXt sets it, and bold, as it folds. */
.proof-word { font-family: var(--sans); font-style: italic; font-weight: 700; }

.step { border-left-color: var(--ptx-rule); background: var(--bg); }
.doc-pager { border-color: var(--ptx-rule); }

/* ------------------------------------------------------- elsewhere */

.toolbar { background: var(--ptx-nav-bg); }
.side { background: var(--bg); }
.panel { border-radius: 0; }
.stat .n { font-family: var(--serif); }

/* ------------------------------------------------------- the outline */

/* ------------------------------------------------------- contents */

/* Kiran's sidebar without its colours (`levelSidebar` in document.js, which
   marks it `toc-outline`): the contents unfolded down to the
   page, each entry on its own line under a hairline, each level indented, a
   blue bar beside the chain down to the level and the entry opened, that
   entry's entries indented below it, this page shaded.  The selectors name
   `toc-up` and `toc-entry` so that they outrank PreTeXt's blocks above. */
/* The page's margins are the ones at the top of this sheet, not PreTeXt's
   narrow column in the middle: the sidebar at the left of the page and the
   text across the rest of it.  Wide screens only: below 901px the document
   is set in one column (above). */
@media (min-width: 901px) {
  .doc-layout { grid-template-columns: 15rem minmax(0, 1fr); gap: 2rem; justify-content: normal; }
}
.toc-outline .toc-head { display: none; }
.toc-outline .toc-levels, .toc-outline .toc-levels ul { margin: 0; padding: 0; border: 0; }
.toc-outline .toc-levels { border-top: 1px solid var(--border); }
.toc-outline .toc-levels ul { padding-left: .9em; }
.toc-outline .toc-levels li.toc-up > a,
.toc-outline .toc-levels li.toc-entry > a {
  display: block;
  padding: .4em .6em .4em .75em;
  background: none;
  color: var(--fg);
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-size: .93rem;
  font-weight: 400;
  line-height: 1.3;
}
.toc-outline .toc-levels li.toc-up > a:hover,
.toc-outline .toc-levels li.toc-entry > a:hover { background: var(--panel-2); text-decoration: none; }
.toc-outline .toc-levels a .num { color: var(--muted); margin-right: .2em; opacity: 1; }
/* The chain and the entry opened: the way down, in blue. */
.toc-outline .toc-levels li.toc-up > a,
.toc-outline .toc-levels li.toc-entry.open > a { color: var(--ptx-blue-text); font-weight: 600; border-left-color: var(--ptx-blue-text); }
.toc-outline .toc-levels li.toc-up > a .num,
.toc-outline .toc-levels li.toc-entry.open > a .num,
.toc-outline .toc-levels li.toc-up > a::before { color: var(--ptx-blue-text); opacity: 1; }
/* The opened entry's own entries: smaller, no hairlines, the last one closing it. */
.toc-outline .toc-levels li.open > ul { border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.toc-outline .toc-levels li.open > ul > li > a { border-bottom: 0; font-size: .87rem; padding-top: .3em; padding-bottom: .3em; }
.toc-outline .toc-levels li.current > a { background: var(--accent-soft); color: var(--fg); border-left-color: var(--ptx-blue-text); }
/* The chain stands among its siblings, not above them: it points down where
   it is unfolded, as an opened entry does, not back up; the page's own entry,
   folded by a click, points across again. */
.toc-outline .toc-levels li.toc-up > a::before { content: none; }
.toc-outline .toc-levels li.toc-up.has-kids > a::after {
  content: '\203a'; display: inline-block; color: var(--faint); margin-left: .35em; transform: rotate(90deg);
}
.toc-outline .toc-levels li.toc-up.shut.has-kids > a::after { transform: none; }
