/* ==========================================================================
   Research blog — nikolaosroufas.me/blog/
   Loaded only by pages under /blog/. The homepage keeps assets/css/styles.css.
   Theme values mirror the homepage (same --bg / --text / --accent and the same
   localStorage "theme" key), so switching modes carries across the whole site.
   ========================================================================== */

:root {
  --bg: #fbfaf8;
  --text: #1c1b1a;
  --text-soft: #4a4643;
  --text-muted: #6b6560;
  --border: #e4e0da;
  --rule: #ece8e2;
  --accent: #6e3b3b;
  --accent-soft: #b98a8a;
  --tint: #f4eeeb;            /* title band, TL;DR panel */
  --tint-border: #e8dcd7;
  --panel: #ffffff;
  --code-bg: #f2efeb;
  --figure-bg: #ffffff;       /* raster figures are drawn on white */

  /* charts: validated categorical slots 1–3 (light surface #fbfaf8) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --bar-muted: #b9b2aa;
  --grid: #e6e2dc;

  /* entity highlight colours (pastel, legible in both modes) */
  --ent-law: #d6e8f2;
  --ent-org: #f8eeb4;
  --ent-date: #f6d3dc;
  --ent-person: #dcefd9;
  --ent-loc: #e7def6;
  --ent-case: #f8dcc6;
  --ent-ink: #1c1b1a;

  --measure: 760px;
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --text: #eae6e0;
    --text-soft: #b4ada4;
    --text-muted: #948c83;
    --border: #322e28;
    --rule: #2a2621;
    --accent: #d99a9a;
    --accent-soft: #8f6666;
    --tint: #1e1a16;
    --tint-border: #352e28;
    --panel: #1b1814;
    --code-bg: #221e19;
    --figure-bg: #f7f5f2;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --bar-muted: #5d5750;
    --grid: #2e2a24;
    --ent-law: #2c4552;
    --ent-org: #4d4422;
    --ent-date: #533340;
    --ent-person: #2f4a2d;
    --ent-loc: #3f3556;
    --ent-case: #553a27;
    --ent-ink: #f1ede7;
  }
}

:root[data-theme="dark"] {
  --bg: #15130f;
  --text: #eae6e0;
  --text-soft: #b4ada4;
  --text-muted: #948c83;
  --border: #322e28;
  --rule: #2a2621;
  --accent: #d99a9a;
  --accent-soft: #8f6666;
  --tint: #1e1a16;
  --tint-border: #352e28;
  --panel: #1b1814;
  --code-bg: #221e19;
  --figure-bg: #f7f5f2;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --bar-muted: #5d5750;
  --grid: #2e2a24;
  --ent-law: #2c4552;
  --ent-org: #4d4422;
  --ent-date: #533340;
  --ent-person: #2f4a2d;
  --ent-loc: #3f3556;
  --ent-case: #553a27;
  --ent-ink: #f1ede7;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 24px;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body.blog {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.blog a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.blog a:hover { text-decoration-color: var(--accent); }

.blog a:focus-visible,
.blog button:focus-visible,
.blog summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--text);
  color: var(--bg) !important;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Site header (shared with the homepage's look) ---------- */

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

/* The wordmark itself is styled in /assets/css/wordmark.css (shared with the homepage). */

.site-nav .nav-links {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 26px;
}

.site-nav .nav-links a {
  color: var(--text-soft);
  text-decoration: none;
}
.site-nav .nav-links a:hover,
.site-nav .nav-links a[aria-current="page"] { color: var(--accent); }

.theme-toggle {
  font: inherit;
  font-size: 13px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 640px) {
  .site-nav { flex-wrap: wrap; row-gap: 10px; }
  .site-nav .nav-links {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
    gap: 20px;
  }
  .theme-toggle { margin-left: auto; }
}

/* ---------- Generic column ---------- */

.col {
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Blog index ---------- */

.blog-head {
  padding: 56px 0 24px;
}
.blog-head h1 {
  margin: 0 0 10px;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.blog-head p {
  margin: 0;
  max-width: 62ch;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.55;
}

.post-list {
  list-style: none;
  margin: 12px 0 64px;
  padding: 0;
  border-top: 1px solid var(--border);
}

.post-item {
  position: relative;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 26px 0;
  border-bottom: 1px solid var(--border);
}

.post-item__figure {
  margin: 0;
  align-self: start;
  background: var(--figure-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-item__figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.post-item__meta {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.post-item__kicker {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.post-item__title {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.005em;
}
.post-item__title a {
  color: var(--text);
  text-decoration: none;
}
.post-item__title a::after {          /* the whole row opens the post */
  content: "";
  position: absolute;
  inset: 0;
}
.post-item:hover .post-item__title a { color: var(--accent); }
.post-item:focus-within { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }
.post-item__title a:focus-visible { outline: none; }

.post-item__summary {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 16.5px;
  line-height: 1.55;
}
.post-item__paper {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .blog-head { padding-top: 36px; }
  .blog-head h1 { font-size: 32px; }
  .post-item { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .post-item__figure { max-width: 420px; }
}

/* ---------- Article: title band ---------- */

.post-title {
  background: var(--tint);
  border-bottom: 1px solid var(--tint-border);
  padding: 56px 0 40px;
}

.post-kicker {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.post-kicker a { text-decoration: none; }

.post-title h1 {
  margin: 0;
  font-size: 44px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text);
}

.post-dek {
  margin: 16px 0 0;
  max-width: 64ch;
  font-size: 21px;
  font-weight: 300;
  line-height: 1.45;
  color: var(--text-soft);
}

@media (max-width: 640px) {
  .post-title { padding: 36px 0 28px; }
  .post-title h1 { font-size: 31px; }
  .post-dek { font-size: 18.5px; }
}

/* ---------- Article: byline ---------- */

.post-byline {
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
  font-size: 15px;
  line-height: 1.6;
}

.byline-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr 1fr;
  gap: 18px 24px;
}

.byline-grid h2 {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.byline-grid p { margin: 0; color: var(--text-soft); }
.byline-grid p + p { margin-top: 2px; }
.byline-grid .who { color: var(--text); }

@media (max-width: 720px) {
  .byline-grid { grid-template-columns: 1fr 1fr; }
  .byline-grid > div:nth-child(2) { grid-column: 1 / -1; order: 3; }
}

/* ---------- Article: body ---------- */

.post-body {
  padding-top: 36px;
  padding-bottom: 24px;
  font-size: 18px;
  line-height: 1.62;
}

@media (max-width: 640px) {
  .post-body { font-size: 17px; }
}

.post-body p,
.post-body ul,
.post-body ol { margin: 0 0 1.05em; }

.post-body li { margin-bottom: 0.35em; }
.post-body li::marker { color: var(--text-muted); }

.post-body strong { font-weight: 600; }

.post-body h2 {
  margin: 2.4em 0 0.7em;
  padding-bottom: 0.45em;
  font-size: 30px;
  font-weight: 300;
  line-height: 1.22;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--tint-border);
}

.post-body h3 {
  margin: 1.8em 0 0.5em;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.3;
}

@media (max-width: 640px) {
  .post-body h2 { font-size: 25px; }
}

/* An experiment's title: a small label, then the question */
.exp-head { margin: 2.6em 0 0.8em; }
.exp-num {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.post-body .exp-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

/* Inline code and code blocks */
.post-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 1px 5px;
  background: var(--code-bg);
  border-radius: 4px;
}

.post-body pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}
.post-body pre code { padding: 0; background: none; font-size: inherit; }
.tok-key { color: #8a3b6b; }
.tok-str { color: #3a6b2f; }
.tok-num { color: #2c5f99; }
:root[data-theme="dark"] .tok-key { color: #e4a4c8; }
:root[data-theme="dark"] .tok-str { color: #a8d49a; }
:root[data-theme="dark"] .tok-num { color: #94bdf0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tok-key { color: #e4a4c8; }
  :root:not([data-theme="light"]) .tok-str { color: #a8d49a; }
  :root:not([data-theme="light"]) .tok-num { color: #94bdf0; }
}

/* ---------- TL;DR and contents ---------- */

.tldr {
  margin: 0 0 28px;
  padding: 16px 22px 18px;
  background: var(--tint);
  border: 1px solid var(--tint-border);
  border-radius: 10px;
  font-size: 17px;
  line-height: 1.58;
}
.tldr-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.tldr p { margin: 0 0 8px; }
.tldr p:last-child { margin-bottom: 0; }

.toc {
  margin: 0 0 32px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 15.5px;
}
.toc summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after {
  content: "+";
  float: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.toc[open] summary::after { content: "\2212"; }
.toc ol {
  margin: 0 0 14px;
  padding-left: 1.3em;
  columns: 2;
  column-gap: 32px;
}
.toc li { break-inside: avoid; margin-bottom: 4px; }
.toc a { text-decoration: none; color: var(--text-soft); }
.toc a:hover { color: var(--accent); }
@media (max-width: 640px) { .toc ol { columns: 1; } }

/* ---------- Notes and callouts ---------- */

.note {
  margin: 1.4em 0;
  padding: 12px 16px 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
  font-size: 16.5px;
  line-height: 1.55;
}
.note > :last-child { margin-bottom: 0; }
.note-label {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.takeaways {
  margin: 1.2em 0 1.6em;
  padding: 0;
  list-style: none;
  counter-reset: tk;
}
.takeaways li {
  position: relative;
  padding: 10px 0 10px 40px;
  border-bottom: 1px solid var(--rule);
  counter-increment: tk;
}
.takeaways li::before {
  content: counter(tk);
  position: absolute;
  left: 0;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--tint);
  border: 1px solid var(--tint-border);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 24px;
  text-align: center;
  color: var(--accent);
}

/* ---------- Figures ---------- */

.post-body figure {
  margin: 2em 0 2.2em;
}

.fig-frame {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.fig-frame.is-raster {
  background: var(--figure-bg);
  padding: 14px;
}
.fig-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.post-body figcaption {
  margin: 12px auto 0;
  max-width: 700px;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text-soft);
}
.post-body figcaption b { color: var(--text); font-weight: 600; }
.fig-source {
  display: block;
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* A figure's setup, behind a small toggle at its top right */
.fig-setup {
  margin: 0 0 10px;
  font-size: 15px;
}
.fig-setup > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--text-soft);
  list-style: none;
}
.fig-setup > summary::-webkit-details-marker { display: none; }
.fig-setup > summary::before { content: "+"; }
.fig-setup[open] > summary::before { content: "\2212"; }
.fig-setup > summary:hover { color: var(--accent); border-color: var(--accent); }
.fig-setup-body {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--tint);
  border: 1px solid var(--tint-border);
  border-radius: 8px;
}
.fig-setup-body ul { margin: 0; padding-left: 1.1em; }
.fig-setup-body li { margin-bottom: 3px; }

/* ---------- Charts (inline SVG) ---------- */

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); fill: var(--text-soft); font-size: 13px; }
.chart .t-strong { fill: var(--text); font-weight: 600; }
.chart .t-mono { font-family: var(--font-mono); font-size: 11.5px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--text-muted); stroke-width: 1; }
.chart .bar-ours { fill: var(--accent); }
.chart .bar-base { fill: var(--bar-muted); }
.chart .bar-hit { fill: transparent; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln-1 { stroke: var(--s1); }
.chart .ln-2 { stroke: var(--s2); }
.chart .ln-3 { stroke: var(--s3); }
.chart .mk { stroke: var(--panel); stroke-width: 2; }
.chart .mk-1 { fill: var(--s1); }
.chart .mk-2 { fill: var(--s2); }
.chart .mk-3 { fill: var(--s3); }
.chart .hit:hover + .mk,
.chart g.pt:hover .mk { stroke: var(--text); }
.chart g.row:hover .bar-base { fill: var(--text-muted); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--text-soft);
}
.legend li { display: inline-flex; align-items: center; gap: 7px; margin: 0; }
.legend .key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; position: relative; }
.legend .key::after {
  content: "";
  position: absolute;
  left: 5px; top: -5px;
  width: 8px; height: 8px;
  background: currentColor;
}
.legend .k1 { color: var(--s1); }
.legend .k1::after { border-radius: 50%; }
.legend .k2 { color: var(--s2); }
.legend .k3 { color: var(--s3); }
.legend .k3::after { transform: rotate(45deg); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend .sw-ours { background: var(--accent); }
.legend .sw-base { background: var(--bar-muted); }

.chart-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

details.data-view { margin-top: 10px; font-size: 14.5px; }
details.data-view > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
details.data-view table { margin-top: 8px; }

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0 1.8em;
  -webkit-overflow-scrolling: touch;
}
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
table.results caption {
  caption-side: bottom;
  padding-top: 10px;
  text-align: left;
  font-size: 14.5px;
  color: var(--text-soft);
}
table.results th,
table.results td {
  padding: 7px 14px 7px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
table.results thead th {
  font-weight: 600;
  color: var(--text);
  border-bottom: 1.5px solid var(--text-muted);
  white-space: nowrap;
}
table.results .num { text-align: right; white-space: nowrap; }
table.results th.num { text-align: right; }
table.results tr > :first-child { white-space: nowrap; }
table.results tr.is-ours td { font-weight: 600; background: var(--tint); }
table.results tr.is-ours td:first-child { padding-left: 8px; }
table.results td.dim { color: var(--text-muted); }

/* ---------- Entity highlighting (recreated Fig. 1, examples) ---------- */

.ent-demo {
  font-size: 18px;
  line-height: 2.25;
  color: var(--text);
}
.ent {
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--ent-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  white-space: nowrap;
}
.ent::after {
  content: attr(data-label);
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  vertical-align: 1px;
  opacity: 0.75;
}
.ent-law { background: var(--ent-law); }
.ent-org { background: var(--ent-org); }
.ent-date { background: var(--ent-date); }
.ent-person { background: var(--ent-person); }
.ent-loc { background: var(--ent-loc); }
.ent-case { background: var(--ent-case); }
.ent-mask {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px dashed var(--text-muted);
  white-space: nowrap;
}
@media (max-width: 640px) { .ent { white-space: normal; } }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.compare > div {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 16.5px;
  line-height: 1.95;
}
.compare h4 {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }

/* WordPiece tokens */
.tokens { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tok {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.tok.cont { border-style: dashed; color: var(--accent); }
.tok-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) 2fr;
  gap: 8px 16px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15.5px;
}
.tok-row:last-child { border-bottom: none; }
.tok-row .src { color: var(--text); }
@media (max-width: 560px) { .tok-row { grid-template-columns: 1fr; gap: 6px; } }

/* Small numeric table inside a figure */
.leak-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
}
.leak-grid div {
  padding: 12px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.leak-grid .n { display: block; font-size: 13px; color: var(--text-muted); }
.leak-grid .p { display: block; font-size: 24px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .leak-grid { grid-template-columns: repeat(2, 1fr); } }

/* Schematic diagram */
.schematic { display: block; width: 100%; height: auto; }
.schematic text { font-family: var(--font-sans); fill: var(--text); font-size: 14px; }
.schematic .sub { fill: var(--text-muted); font-size: 12px; }
.schematic .box { fill: var(--bg); stroke: var(--border); stroke-width: 1.5; }
.schematic .box-acc { fill: var(--tint); stroke: var(--accent); stroke-width: 1.5; }
.schematic .arrow { stroke: var(--text-muted); stroke-width: 1.5; fill: none; }
.schematic .arrowhead { fill: var(--text-muted); }
.schematic-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  background: var(--bg);
}

/* ---------- Math ---------- */

.math-block {
  margin: 1em 0 1.3em;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.katex { font-size: 1.06em; }

/* ---------- Citations and end matter ---------- */

.cite {
  font-size: 0.78em;
  vertical-align: 0.35em;
  line-height: 0;
  text-decoration: none !important;
  font-variant-numeric: tabular-nums;
}

.endmatter {
  margin-top: 3em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-soft);
}
.endmatter h2 {
  margin: 1.6em 0 0.6em;
  padding: 0;
  border: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.endmatter h2:first-child { margin-top: 0; }
.endmatter p { margin: 0 0 0.8em; }

.paper-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.paper-card .paper-title { margin: 0 0 4px; font-weight: 600; color: var(--text); font-size: 16.5px; }
.paper-card .paper-authors { margin: 0 0 4px; }
.paper-card .paper-venue { margin: 0 0 10px; font-style: italic; }
.paper-card .paper-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.paper-card .paper-links a {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  text-decoration: none;
  color: var(--text);
}
.paper-card .paper-links a:hover { border-color: var(--accent); color: var(--accent); }

.bibtex { position: relative; }
.bibtex pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

ol.references {
  margin: 0;
  padding-left: 1.6em;
  font-size: 14.5px;
}
ol.references li { margin-bottom: 0.5em; padding-left: 0.2em; }
ol.references li:target { background: var(--tint); border-radius: 4px; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: calc(var(--measure) + 48px);
  margin: 40px auto 0;
  padding: 20px 24px 44px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-soft);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-soft); }

/* ---------- Print ---------- */

@media print {
  .site-nav, .theme-toggle, .toc, .copy-btn, .skip-link { display: none !important; }
  .post-title { background: none; border: none; }
  .fig-setup:not([open]) > .fig-setup-body { display: block; }
  body.blog { font-size: 11pt; }
}

.ent[data-label=""]::after { display: none; }

/* Charts ship in two variants: a wide one for desktop and a compact one for phones */
.chart-compact { display: none; }
@media (max-width: 560px) {
  .chart-wide { display: none; }
  .chart-compact { display: block; }
  .chart-compact text { font-size: 12px; }
  .chart-compact .t-mono { font-size: 10.5px; }
  .fig-frame { padding: 14px 12px; }
  table.results { font-size: 14px; }
  table.results th, table.results td { padding-right: 9px; }
}

/* Two schematic panels side by side (stack on phones) */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .panel-grid { grid-template-columns: 1fr; } }

/* Vertical pipeline schematic */
.pipeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.pipeline > li {
  position: relative;
  width: min(100%, 420px);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  text-align: center;
  margin: 0;
}
.pipeline > li + li::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -21px;
  height: 18px;
  border-left: 1.5px solid var(--text-muted);
}
.pipeline > li + li::after {
  content: "";
  position: absolute;
  left: calc(50% - 4px);
  top: -9px;
  border: 4px solid transparent;
  border-top: 6px solid var(--text-muted);
}
.pipeline .pl-acc { border-color: var(--accent); background: var(--tint); }
.pipeline .pl-name { display: block; font-weight: 600; font-size: 15.5px; color: var(--text); }
.pipeline .pl-sub { display: block; font-size: 13.5px; color: var(--text-muted); line-height: 1.4; }
.pipeline .pl-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0;
  border: none;
  background: none;
  width: min(100%, 560px);
}
.pipeline .pl-split > div {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
@media (max-width: 480px) { .pipeline .pl-split { grid-template-columns: 1fr; } }

/* Keep the "Schematic" tag clear of the figure content */
.fig-frame:has(> .schematic-tag) { padding-top: 38px; }
