/* Lab: article styling for figure-heavy technical writing.
   Design rules: white paper, one ink, two series colours per figure, mono for
   every label/number, generous vertical rhythm, figures wider than text. */
:root {
  --paper: #ffffff;
  --ink: #14161a;
  --muted: #6a6f78;
  --line: #e4e5e8;
  --wash: #f6f6f4;
  --a: #2f4bd8;      /* series A / primary  */
  --b: #d9482b;      /* series B / contrast */
  --c: #1f8a70;      /* series C            */
  --grid: #dcdde1;
  --sel: #dfe5ff;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --body-w: 720px;
  --fig-w: 920px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101216; --ink: #e9eaee; --muted: #9a9fa9; --line: #262a31; --wash: #171a20;
    --a: #7d93ff; --b: #ff7a5c; --c: #4fd1ad; --grid: #2b3038; --sel: #26305f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.lab {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 18px/1.65 var(--sans); -webkit-font-smoothing: antialiased;
}
body.lab ::selection { background: var(--sel); }
a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }

.site-head { display: flex; justify-content: space-between; align-items: baseline;
  max-width: 1200px; margin: 0 auto; padding: 28px 24px; font: 14px var(--mono); }
.brand { text-decoration: none; font-weight: 600; letter-spacing: .02em; }
.brand-sub { color: var(--muted); font-weight: 400; }
.site-nav a { margin-left: 22px; text-decoration: none; color: var(--muted); }
.site-nav a:hover { color: var(--ink); }

.article-layout { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: grid;
  grid-template-columns: 1fr; }
@media (min-width: 1240px) {
  .article-layout { grid-template-columns: 200px minmax(0, 1fr); column-gap: 32px; }
}
.rail { display: none; font: 13px/1.4 var(--mono); }
@media (min-width: 1240px) { .rail { display: block; position: sticky; top: 24px; align-self: start; max-height: 90vh; overflow: auto; } }
.rail-title { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; margin: 0 0 12px; }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail ul ul { padding-left: 14px; }
.rail li { margin: 0 0 8px; }
.rail a { text-decoration: none; color: var(--muted); display: block; }
.rail a:hover, .rail a.active { color: var(--ink); }
.rail a.active { font-weight: 600; }

.article { min-width: 0; }
.article-head { max-width: var(--body-w); margin: 24px auto 40px; }
.eyebrow { font: 12px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; }
.article-head h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 14px; font-weight: 650; }
.subtitle { font-size: 21px; line-height: 1.4; color: var(--muted); margin: 0 0 20px; }
.byline { font: 13px var(--mono); color: var(--muted); margin: 0; }
.byline .dot { margin: 0 8px; }
.status { border: 1px solid var(--line); padding: 1px 7px; border-radius: 999px; }

.prose { max-width: var(--body-w); margin: 0 auto; }
.prose > * { margin-top: 0; margin-bottom: 1.15em; }
.prose h2 { font-size: 28px; line-height: 1.2; letter-spacing: -.01em; margin-top: 2.4em; margin-bottom: .6em; scroll-margin-top: 24px; }
.prose h3 { font-size: 21px; line-height: 1.3; margin-top: 2em; margin-bottom: .5em; scroll-margin-top: 24px; }
.prose code { font: .86em var(--mono); background: var(--wash); padding: .1em .35em; border-radius: 4px; }
.prose pre { background: var(--wash); padding: 16px 18px; border-radius: 8px; overflow: auto; font: 14px/1.55 var(--mono); }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin-left: 0; padding-left: 18px; border-left: 3px solid var(--line); color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; font: 14px var(--mono); }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; border-bottom-color: var(--ink); }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: 1.4em 0; }

.tldr { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); padding: 18px 0 6px; margin: 0 0 2em; }
.tldr-h { font: 12px var(--mono) !important; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 10px !important; }
.tldr p, .tldr li { font-size: 17px; }
.note { font-size: 15px; color: var(--muted); border-left: 3px solid var(--line); padding: 2px 0 2px 16px; }

/* Figures */
.fig { max-width: var(--fig-w); margin: 2.4em auto; }
.fig-wide { max-width: 1100px; }
figcaption { font-size: 14.5px; line-height: 1.5; color: var(--muted); margin-top: 12px; max-width: var(--body-w); }
.fig-label { font: 600 12px var(--mono); color: var(--ink); text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; }
.fig-fallback { font: 13px var(--mono); color: var(--muted); }
.fig-mount { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--paper); }
.fig-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .fig-grid { grid-template-columns: 1.35fr 1fr; } }
.fig svg { display: block; width: 100%; height: auto; touch-action: none; }
.fig svg text { font: 19px var(--mono); fill: var(--muted); }
.fig .ax { stroke: var(--grid); stroke-width: 1; fill: none; }
.fig .contour { fill: none; stroke: var(--grid); stroke-width: 1; }
.fig .line-a { stroke: var(--a); } .fig .line-b { stroke: var(--b); }
.fig .dot-a { fill: var(--a); } .fig .dot-b { fill: var(--b); }
.fig .drag { cursor: grab; } .fig .drag:active { cursor: grabbing; }

.fig-controls { display: flex; flex-wrap: wrap; gap: 14px 22px; margin-top: 14px; font: 13px var(--mono); align-items: center; }
.fig-controls label { display: flex; flex-direction: column; gap: 4px; min-width: 150px; color: var(--muted); }
.fig-controls output { color: var(--ink); font-weight: 600; }
.fig-controls input[type=range] { width: 100%; accent-color: var(--a); }
.fig-btn { font: 13px var(--mono); background: var(--paper); color: var(--ink); border: 1px solid var(--ink);
  padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.fig-btn:hover { background: var(--ink); color: var(--paper); }
.fig-btn:focus-visible, .fig input:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.fig-legend { display: flex; gap: 18px; font: 12px var(--mono); color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.fig-legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; }
.fig-readout { font: 12.5px/1.6 var(--mono); color: var(--muted); margin-top: 10px; }
.fig-readout b { color: var(--ink); font-weight: 600; }
.fig-warn { color: var(--b) !important; }

.cite { max-width: var(--body-w); margin: 4em auto 2em; border-top: 1px solid var(--line); padding-top: 24px; }
.cite h2 { font: 12px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.cite-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.cite-tabs button { font: 12px var(--mono); border: 1px solid var(--line); background: none; color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.cite-tabs button[aria-selected=true] { color: var(--ink); border-color: var(--ink); }
.cite-tabs .cite-copy { margin-left: auto; }
.cite-body { background: var(--wash); padding: 14px 16px; border-radius: 8px; font: 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; margin: 0; }

.listing { max-width: var(--body-w); margin: 0 auto; padding: 0 24px 60px; }
.listing h1 { font-size: 36px; letter-spacing: -.02em; }
.entries { list-style: none; padding: 0; margin: 32px 0; }
.entries li { border-top: 1px solid var(--line); }
.entries a { display: block; padding: 22px 0; text-decoration: none; }
.entry-meta { display: block; font: 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.entry-title { display: block; font-size: 24px; font-weight: 600; margin: 6px 0 4px; }
.entry-sub { display: block; color: var(--muted); }
.site-foot { max-width: 1200px; margin: 80px auto 0; padding: 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font: 12px var(--mono); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Writing (older posts) in the Lab frame: content written for the previous theme. */
.tag-row { font: 12px var(--mono); margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag-row a { color: var(--muted); text-decoration: none; }
.tag-row a:hover { color: var(--ink); }
.prose img, .prose video, .prose iframe { max-width: 100%; height: auto; }
.prose table { display: block; overflow-x: auto; }
.prose mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; }
.prose pre[style] { border: 1px solid var(--line); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* Home, listings, tags */
.home-intro { margin: 8px 0 8px; }
.home-intro p { font-size: 19px; }
.list-h { font: 12px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 48px 0 0; }
.year { font: 600 14px var(--mono); color: var(--muted); margin: 32px 0 0; }
.entries.compact { margin: 8px 0 0; }
.entries.compact a { padding: 14px 0; }
.entries.compact .entry-title { font-size: 19px; margin: 4px 0 2px; }
.entries.compact .entry-sub { font-size: 15px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.filters button { font: 12px var(--mono); border: 1px solid var(--line); background: none; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; cursor: pointer; }
.filters button[aria-pressed=true] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.filters button:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.tag-cloud { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 18px; font: 14px var(--mono); }
.tag-cloud a { text-decoration: none; }
.tag-cloud span { color: var(--muted); }
.listing .eyebrow a { text-decoration: none; }
@media (max-width: 640px) {
  .site-head { flex-direction: column; gap: 10px; padding: 20px 16px; }
  .site-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
  .site-nav a { margin-left: 0; }
  .listing, .article-layout { padding-left: 16px; padding-right: 16px; }
}

/* Folded proofs/derivations, numbered statements, numbered tables (HYPERSTITION_STYLE.md §3) */
.fold { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 1.6em 0; }
.fold + .fold { border-top: 0; margin-top: -1.6em; }
.fold > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 0; font: 14px/1.4 var(--mono); color: var(--ink); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; }
.fold[open] > summary::after { content: "−"; }
.fold > summary:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.fold-body { padding: 4px 0 14px; font-size: 16.5px; }
.fold-body > *:last-child, .thm-body > *:last-child { margin-bottom: 0; }
.table-scroll { overflow-x: auto; padding-bottom: 14px; }
.table-scroll table { display: table; }
.thm { margin: 1.6em 0; padding: 14px 18px; background: var(--wash); border-radius: 8px; }
.thm-head { margin: 0 0 .4em; font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.thm-head a { text-decoration: none; }
.thm-name { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }
.thm-definition { background: none; border-left: 3px solid var(--ink); border-radius: 0; }
.thm-theorem .thm-body, .thm-proposition .thm-body, .thm-lemma .thm-body, .thm-corollary .thm-body { font-style: italic; }
.thm .katex { font-style: normal; }

/* Pages without a contents rail (no headings to list): keep the article in the main column. */
@media (min-width: 1240px) { .article-layout > .article { grid-column: 2; } }
