/* SixOne8 Research: the /research index and the paper pages (`research.py` writes the markup).
 *
 * **The section reads as a journal, not as the product.** Body text is Source Serif 4, set wide and
 * leaded for long reading; figures, tables and labels stay in IBM Plex, as data does in the app. In
 * light mode the ground is a warm paper (#F6F4EF) with white panels, which sets the research apart
 * from the rest of the site's cool whites (Ryan, 2026-10-27: "I like how the research bit has a
 * different paper colour"); dark keeps the site's night ground.
 *
 * Figure colours are named once here (`--r-blue` …) and the SVG reads them by name, so a figure
 * follows the theme and prints correctly. Blue is the measured rule, orange its opposite, grey the
 * baseline — the same meaning on every figure in every paper.
 */

/* Source Serif 4 (Adobe, SIL Open Font License): one variable file per style, 200–900, latin. */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/fonts/source-serif-4-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url('/fonts/source-serif-4-latin-wght-italic.woff2') format('woff2');
}

:root {
  --r-bg: #05080F;
  --r-paper: #0A111E;
  --r-rule: rgba(255, 255, 255, 0.12);
  --r-acc: #8FB2FA;
  --r-blue: #5B95FA;
  --r-orange: #F08A4B;
  --r-teal: #2DD4BF;
  --r-violet: #A78BFA;
  --r-grey: rgba(255, 255, 255, 0.5);
  --r-ink: rgba(255, 255, 255, 0.8);
  --r-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}
:root[data-theme='light'] {
  --r-bg: #F6F4EF;
  --r-paper: #FFFFFF;
  --r-rule: rgba(18, 26, 39, 0.14);
  --r-acc: #1D4ED8;
  --r-blue: #2563EB;
  --r-orange: #C2410C;
  --r-teal: #0F9F8F;
  --r-violet: #7C3AED;
  --r-grey: rgba(18, 26, 39, 0.5);
  --r-ink: rgba(18, 26, 39, 0.8);
}

/* The nav tints itself with `--page-bg`, so pointing that at the paper keeps the bar the colour of
   the page under it. */
body.paper { --page-bg: var(--r-bg); background: var(--r-bg); }
:root:has(body.paper) { background: var(--r-bg); }

.r-page { color: var(--text); }
.r-wrap { max-width: 1240px; margin: 0 auto; padding: 64px 24px 96px; }
.r-wrap--paper { padding-top: 40px; }

.r-label {
  font: 600 11px/1.3 var(--font-mono);
  letter-spacing: 1.8px;
  color: var(--text-dim);
}
.r-kicker { font: 600 12px var(--font-mono); letter-spacing: 2.5px; color: var(--r-acc); }

/* -- Mastheads --------------------------------------------------------------------------------- */

/* `header` carries the page gutter site-wide (`base.css`); here the wrap already does. */
.r-masthead {
  padding-inline: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 28px;
  border-bottom: 3px double var(--r-rule);
}
.r-masthead h1 {
  margin: 0;
  max-width: 900px;
  font: 600 clamp(36px, 5vw, 64px)/1.05 var(--r-serif);
  letter-spacing: -1px;
  text-wrap: balance;
}
.r-intro { margin: 0; max-width: 760px; font: 400 19px/1.6 var(--r-serif); color: var(--text-muted); }
.r-promises { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 6px; font-size: 13px; color: var(--text-dim); }

.r-masthead--paper { gap: 16px; padding: 28px 0 30px; }
.r-masthead--paper h1 { max-width: 980px; font-size: clamp(34px, 4.4vw, 56px); line-height: 1.08; letter-spacing: -0.8px; }
.r-dek { margin: 0; max-width: 820px; font: italic 400 20px/1.55 var(--r-serif); color: var(--text-muted); }

.r-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.r-back:hover { color: var(--text); }
.r-back .i { width: 17px; height: 17px; }

.r-byline { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px; margin-top: 6px; }
.r-byline__meta { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-muted); }
.r-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: #fff;
  font: 600 15px var(--font-sans);
  box-shadow: 0 10px 30px rgba(52, 104, 228, 0.3);
}
.r-download:hover { background: var(--brand-deep); }
.r-download .i { width: 20px; height: 20px; }
.r-download__meta { font: 400 12.5px var(--font-mono); color: var(--text-dim); }

/* -- Search (index) ---------------------------------------------------------------------------- */

.r-search { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-width: 760px; }
.r-search[hidden] { display: none; }
.r-search__box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: var(--r-paper);
  border: 1px solid var(--r-rule);
  color: var(--text-dim);
}
.r-search__box:focus-within { border-color: var(--r-acc); }
.r-search__box .i { width: 22px; height: 22px; }
.r-search__box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px var(--font-sans);
}
.r-search__box input::-webkit-search-cancel-button { display: none; }
.r-search__box button { border: 0; background: transparent; color: var(--text-dim); cursor: pointer; display: flex; padding: 0; }
.r-search__box button[hidden] { display: none; }
.r-search__try { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-dim); }
.r-search__try button {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--r-rule);
  background: transparent;
  color: var(--text-muted);
  font: 500 12.5px var(--font-sans);
  cursor: pointer;
}
.r-search__try button:hover { color: var(--text); border-color: var(--r-acc); }

.r-results[hidden], [data-listing][hidden] { display: none; }
.r-results__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 28px 0 8px; border-bottom: 1px solid var(--r-rule); }
.r-results__head strong { font: 600 22px var(--r-serif); }
.r-results__head span { font-size: 13px; color: var(--text-dim); }
.r-hit__snip { font: 400 15.5px/1.6 var(--r-serif); color: var(--text-muted); }
.r-hit__snip mark { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--text); padding: 0 2px; border-radius: 3px; }
.r-hit__where { font-size: 12px; color: var(--text-dim); }
.r-empty { padding: 40px 0; font: 400 17px var(--r-serif); color: var(--text-muted); }

/* -- Index listing ----------------------------------------------------------------------------- */

.r-lead {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  padding: 36px 0;
  border-bottom: 1px solid var(--r-rule);
  color: var(--text);
}
.r-lead__text { display: flex; flex-direction: column; gap: 14px; }
.r-lead h2 { margin: 0; font: 600 38px/1.12 var(--r-serif); letter-spacing: -0.5px; text-wrap: balance; }
.r-lead:hover h2 { color: var(--r-acc); }
.r-lead__dek { font: 400 17px/1.6 var(--r-serif); color: var(--text-muted); }
.r-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.r-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; padding: 3px 9px; border-radius: var(--radius-pill); border: 1px solid var(--r-rule); color: var(--text-muted); }
.r-lead__go { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--r-acc); }
.r-lead__go .i { width: 18px; height: 18px; }

.r-thumb {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--r-rule);
  background: var(--r-paper);
  font-family: var(--font-sans);
}
.r-thumb__title { font: 600 15px/1.35 var(--r-serif); }
.r-thumb__note { font-size: 11.5px; color: var(--text-dim); }
.r-thumb .r-plot--lines { height: 200px; }
.r-thumb .r-plot--hist, .r-thumb .r-plot--cols { height: 190px; }

.r-rule { display: flex; align-items: center; gap: 14px; padding: 32px 0 8px; }
.r-rule span { font: 600 12px var(--font-mono); letter-spacing: 2px; color: var(--text-dim); }
.r-rule::after { content: ''; flex: 1; height: 1px; background: var(--r-rule); }

.r-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 200px;
  gap: 32px;
  padding: 26px 0;
  border-bottom: 1px solid var(--r-rule);
  color: var(--text);
}
a.r-row:hover .r-row__title { color: var(--r-acc); }
.r-row--soon { opacity: 0.6; }
.r-row__no { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.r-row__no strong { font: 600 13px var(--font-mono); color: var(--text); }
.r-row__text { display: flex; flex-direction: column; gap: 8px; }
.r-row__title { font: 600 24px/1.2 var(--r-serif); }
.r-row__dek { font: 400 15.5px/1.6 var(--r-serif); color: var(--text-muted); }
.r-row__meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; text-align: right; font-size: 12.5px; color: var(--text-dim); }
.r-row__meta strong { font-weight: 600; color: var(--r-acc); }
.r-row--soon .r-row__meta strong { color: var(--text-dim); }

.r-disclaimer { margin: 28px 0 0; max-width: 820px; font: 400 12.5px/1.6 var(--font-sans); color: var(--text-dim); }

/* -- Paper body -------------------------------------------------------------------------------- */

.r-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 760px);
  gap: 64px;
  padding-top: 40px;
}
.r-aside { position: sticky; top: 96px; align-self: start; display: flex; flex-direction: column; gap: 22px; }
.r-toc { display: flex; flex-direction: column; gap: 4px; }
.r-toc .r-label { margin-bottom: 8px; }
.r-toc a {
  display: flex;
  gap: 10px;
  padding: 6px 0 6px 12px;
  font-size: 13.5px;
  color: var(--text-muted);
  border-left: 2px solid var(--r-rule);
}
.r-toc a span { font: 500 12px var(--font-mono); color: var(--text-dim); padding-top: 1px; }
.r-toc a:hover, .r-toc a[aria-current='true'] { color: var(--text); border-left-color: var(--r-acc); }
.r-facts { margin: 0; padding-top: 16px; border-top: 1px solid var(--r-rule); display: flex; flex-direction: column; gap: 10px; }
.r-facts dt { font-size: 10.5px; letter-spacing: 1px; font-weight: 600; color: var(--text-dim); }
.r-facts dd { margin: 1px 0 0; font: 400 12.5px/1.4 var(--font-mono); color: var(--text); }

.r-article { display: flex; flex-direction: column; gap: 30px; font: 400 18px/1.72 var(--r-serif); min-width: 0; }
.r-article p { margin: 0; text-wrap: pretty; }
.r-article a { color: var(--r-acc); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.r-article em { font-style: italic; }

.r-abstract {
  padding: 24px 26px;
  background: var(--r-paper);
  border: 1px solid var(--r-rule);
  border-top: 3px solid var(--r-acc);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 90px;
}
.r-abstract p { font-size: 17px; line-height: 1.7; }

.r-findings { display: flex; flex-direction: column; gap: 14px; }
.r-findings__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--r-rule);
  border: 1px solid var(--r-rule);
}
.r-finding { background: var(--r-paper); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.r-finding__v { font: 600 30px/1.1 var(--r-serif); color: var(--r-acc); letter-spacing: -0.5px; }
.r-finding__t { font: 400 14.5px/1.5 var(--font-sans); color: var(--text-muted); }

.r-section { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 90px; }
.r-section h2 {
  margin: 8px 0 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font: 600 28px/1.2 var(--r-serif);
  letter-spacing: -0.3px;
}
.r-section h2 span { font: 500 14px var(--font-mono); color: var(--text-dim); }
.r-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

.r-defs { margin: 0; }
.r-def { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; padding: 12px 0; border-top: 1px solid var(--r-rule); font-size: 15.5px; line-height: 1.6; }
.r-def dt { font: 600 12px var(--font-mono); letter-spacing: 0.8px; color: var(--text-dim); text-transform: uppercase; padding-top: 3px; }
.r-def dd { margin: 0; }

.r-eq {
  padding: 16px 20px;
  background: var(--r-paper);
  border: 1px solid var(--r-rule);
  display: flex;
  align-items: center;
  gap: 20px;
}
.r-eq span:first-child { flex: 1; text-align: center; font: italic 400 19px var(--r-serif); }
.r-eq__n { font: 500 13px var(--font-mono); color: var(--text-dim); }

.r-cite { padding: 20px 22px; border: 1px solid var(--r-rule); display: flex; flex-direction: column; gap: 8px; }
.r-cite > span:last-child { font: 400 14px/1.6 var(--font-mono); color: var(--text-muted); }

/* "Run it yourself" — the one place a paper points into the product. */
.r-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 28px;
  align-items: end;
  padding: 24px 26px;
  background: var(--r-paper);
  border: 1px solid var(--r-rule);
  border-left: 3px solid var(--r-acc);
  font-family: var(--font-sans);
}
.r-cta__text { display: flex; flex-direction: column; gap: 10px; }
.r-cta h3 { margin: 0; font: 600 22px/1.25 var(--r-serif); }
.r-cta p { font-size: 15px; line-height: 1.6; color: var(--text-muted); }
.r-cta ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; line-height: 1.55; }
.r-cta__actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.r-cta__note { font-size: 12px; color: var(--text-dim); max-width: 240px; }
.r-article .r-cta a.pill { color: var(--cta-fg); text-decoration: none; }

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

.r-fig {
  margin: 8px 0;
  padding: 22px 22px 16px;
  background: var(--r-paper);
  border: 1px solid var(--r-rule);
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--font-sans);
  break-inside: avoid;
}
.r-fig__head { display: flex; flex-direction: column; gap: 3px; }
.r-fig__title { font: 600 17px/1.35 var(--r-serif); }
.r-fig__sub { font-size: 13px; line-height: 1.45; color: var(--text-muted); }
.r-fig figcaption { padding-top: 10px; border-top: 1px solid var(--r-rule); font-size: 12px; line-height: 1.55; color: var(--text-dim); }
.r-fig figcaption a { color: inherit; }

.r-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-muted); }
.r-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.r-key { width: 16px; height: 3px; display: inline-block; }
.r-key--dash { height: 0; border-top: 2px dashed; background: transparent; }
.r-key--band { height: 10px; opacity: 0.25; }
.r-key--box { width: 10px; height: 10px; }

.r-fig__body { position: relative; }
.r-plot { position: relative; }
.r-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.r-plot--lines { height: 280px; margin: 6px 52px 0 0; }
.r-grid { stroke: var(--r-rule); fill: none; vector-effect: non-scaling-stroke; }
.r-zero { stroke: var(--r-ink); stroke-opacity: 0.55; fill: none; vector-effect: non-scaling-stroke; }
.r-line { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.r-yticks span {
  position: absolute;
  right: -52px;
  transform: translateY(-50%);
  font: 400 11px var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}

.r-xticks { position: relative; height: 16px; margin-top: 6px; font: 400 11px var(--font-mono); color: var(--text-dim); }
.r-xticks--lines { margin-right: 52px; }
.r-xticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.r-xticks span:first-child { transform: none; }
.r-xticks span:last-child { transform: translateX(-100%); }

.r-plot--hist {
  height: 240px;
  margin-top: 22px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  border-bottom: 1px solid var(--r-ink);
}
.r-bar { flex: 1; min-width: 0; }
.r-mark { position: absolute; top: 0; bottom: 0; border-left: 1.5px solid; }
.r-mark--dashed { border-left-style: dashed; }
.r-mark span { position: absolute; top: -20px; left: 0; transform: translateX(-50%); font: 500 11px var(--font-mono); white-space: nowrap; }
/* Two marks close together label outward, one to each side of its line. */
.r-mark--left span { transform: translateX(calc(-100% - 5px)); }
.r-mark--right span { transform: translateX(5px); }

.r-plot--cols {
  height: 240px;
  margin: 26px 0 0 44px;
  display: flex;
  gap: 28px;
  align-items: flex-end;
  border-bottom: 1px solid var(--r-ink);
}
.r-cols__tick { position: absolute; left: -44px; transform: translateY(50%); font: 400 11px var(--font-mono); color: var(--text-dim); }
.r-cols__ref { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--r-grey); }
.r-cols__ref span { position: absolute; right: 0; bottom: 2px; font: 500 11px var(--font-mono); color: var(--text-muted); }
.r-cols__group { flex: 1; height: 100%; display: flex; gap: 6px; align-items: flex-end; justify-content: center; }
.r-cols__bar { position: relative; width: 28%; max-width: 54px; }
.r-cols__bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font: 500 11px var(--font-mono); color: var(--text-muted); white-space: nowrap; }
.r-cols__labels { display: flex; gap: 28px; margin-left: 44px; font-size: 12.5px; color: var(--text-muted); }
.r-cols__labels span { flex: 1; text-align: center; }

.r-heat { display: flex; gap: 10px; align-items: stretch; }
.r-heat__ytitle { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11.5px; color: var(--text-muted); text-align: center; }
.r-heat__grid { flex: 1; display: grid; gap: 2px; font: 400 11px var(--font-mono); }
.r-heat__row { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; color: var(--text-dim); white-space: nowrap; }
.r-heat__col { text-align: center; color: var(--text-dim); padding-top: 4px; }
.r-heat__cell { height: 34px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.r-heat__cell--strong { color: #fff; }
.r-heat__cell--empty { background: transparent; }
.r-heat__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: 11.5px; color: var(--text-muted); padding-left: 96px; }
.r-heat__key { margin-left: auto; display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); color: var(--text-dim); }
.r-heat__ramp { width: 140px; height: 8px; background: linear-gradient(90deg, var(--r-orange), color-mix(in srgb, var(--r-grey) 15%, transparent), var(--r-blue)); }

/* -- Tables: journal rules, figures in mono, right-aligned ------------------------------------- */

.r-table { display: flex; flex-direction: column; gap: 8px; font-family: var(--font-sans); break-inside: avoid; }
.r-table__title { font: 600 15px var(--r-serif); letter-spacing: 0; color: var(--text); }
.r-table__scroll { overflow-x: auto; border-top: 2px solid var(--r-ink); border-bottom: 2px solid var(--r-ink); }
.r-table__row { display: grid; column-gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--r-rule); font: 400 13.5px var(--font-mono); }
.r-table__row:last-child { border-bottom: 0; }
/* Figures never wrap mid-value ("+21.2 to" / "+57.2"); headings may. On a phone the table scrolls. */
.r-table__row > span { white-space: nowrap; }
.r-table__row--head > span { white-space: normal; }
.r-table__row--head { font: 600 11.5px var(--font-sans); color: var(--text-muted); }
.r-table__row--foot { font-weight: 600; }
.r-t--l { text-align: left; font-family: var(--font-sans); }
.r-t--r { text-align: right; }
.r-t--pos { color: var(--r-blue); }
.r-t--neg { color: var(--r-orange); }
.r-table__note { font-size: 12px; line-height: 1.5; color: var(--text-dim); }

/* -- Narrow screens ---------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .r-wrap { padding: 40px 16px 72px; }
  .r-lead { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .r-lead h2 { font-size: 30px; }
  .r-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 22px 0; }
  .r-row__no { flex-direction: row; gap: 10px; align-items: baseline; }
  .r-row__meta { flex-direction: row; justify-content: space-between; align-items: baseline; text-align: left; }
  .r-row__title { font-size: 21px; }
  .r-body { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 28px; }
  .r-aside { position: static; }
  .r-toc { display: none; }
  .r-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 0; padding-top: 0; }
  .r-byline__meta { margin-left: 0; }
  .r-dek { font-size: 18px; }
  .r-article { font-size: 17px; line-height: 1.68; gap: 26px; }
  .r-findings__grid { grid-template-columns: minmax(0, 1fr); }
  .r-finding { flex-direction: row; align-items: baseline; gap: 14px; }
  .r-finding__v { font-size: 24px; min-width: 96px; }
  .r-section h2 { font-size: 23px; }
  .r-def { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .r-fig { padding: 16px 14px 12px; margin: 4px -4px; }
  .r-plot--lines { height: 200px; margin-right: 40px; }
  .r-xticks--lines { margin-right: 40px; }
  .r-yticks span { right: -40px; font-size: 10px; }
  .r-xticks { font-size: 10px; }
  /* Every other label, so dates and bands do not collide at phone width; the last always shows. */
  .r-xticks span:nth-child(even):not(:last-child) { display: none; }
  .r-plot--hist, .r-plot--cols { height: 190px; }
  .r-plot--cols { gap: 12px; margin-left: 36px; }
  .r-cols__labels { gap: 12px; margin-left: 36px; font-size: 11.5px; }
  .r-cols__tick { left: -36px; font-size: 10px; }
  .r-cols__bar span { font-size: 9.5px; }
  .r-heat__ytitle { display: none; }
  .r-heat__grid { font-size: 9.5px; gap: 1px; }
  .r-heat__cell { height: 26px; }
  .r-heat__foot { padding-left: 0; }
  .r-cta { grid-template-columns: minmax(0, 1fr); padding: 20px; }
}

/* -- Print, and the PDF `tools/make_research_pdfs.py` prints from this page --------------------- */

@media print {
  @page {
    size: A4;
    margin: 16mm 16mm 18mm;
    @bottom-left { content: 'SixOne8 Research · sixone8.app/research'; font: 8pt 'IBM Plex Sans', sans-serif; color: #5E687B; }
    @bottom-right { content: counter(page) ' / ' counter(pages); font: 8pt 'IBM Plex Mono', monospace; color: #5E687B; }
  }
  :root, :root[data-theme] {
    --r-bg: #FFFFFF; --r-paper: #FFFFFF; --r-rule: rgba(18, 26, 39, 0.18); --r-acc: #1D4ED8;
    --r-blue: #2563EB; --r-orange: #C2410C; --r-teal: #0F9F8F; --r-violet: #7C3AED;
    --r-grey: rgba(18, 26, 39, 0.5); --r-ink: rgba(18, 26, 39, 0.8);
    --text: #121A27; --text-muted: #3B4558; --text-dim: #5E687B; --ink: 18, 26, 39;
  }
  body.paper, :root:has(body.paper) { background: #fff; }
  .skip-link, .nav, .nav__drawer, .footer, .to-top, .r-back, .r-toc, .r-download, .r-download__meta, .r-cta__actions { display: none !important; }
  .r-wrap { padding: 0; max-width: none; }
  .r-masthead--paper { padding-top: 0; }
  .r-masthead--paper h1 { font-size: 30pt; }
  .r-dek { font-size: 14pt; }
  .r-body { display: block; padding-top: 18px; }
  .r-aside { position: static; margin-bottom: 18px; }
  .r-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 0; padding-top: 0; }
  .r-article { font-size: 10.5pt; line-height: 1.6; gap: 16px; }
  .r-abstract p { font-size: 10.5pt; }
  .r-section h2 { font-size: 16pt; break-after: avoid; }
  .r-fig, .r-table, .r-abstract, .r-findings, .r-cta, .r-eq, .r-def { break-inside: avoid; }
  .r-fig, .r-abstract, .r-finding, .r-cta { background: #fff; }
  .r-cta { grid-template-columns: minmax(0, 1fr); }
  /* A4 is narrower than the phone breakpoint, so undo the stacking the page can afford. */
  .r-findings__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .r-finding { flex-direction: column; align-items: stretch; gap: 6px; }
  .r-finding__v { font-size: 20pt; min-width: 0; }
  .r-def { grid-template-columns: 150px minmax(0, 1fr); gap: 14px; }
  .r-heat__ytitle { display: inline; }
  /* A PDF cannot scroll: the table drops its scroll box and minimum width and sets tighter, so
     every column fits the A4 measure instead of being clipped behind a printed scrollbar. */
  .r-table__scroll { overflow: visible; }
  .r-table__inner { min-width: 0 !important; }
  .r-table__row { column-gap: 6px; padding: 6px 2px; font-size: 7.5pt; }
  .r-table__row--head { font-size: 7pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* -- Figure kinds beyond lines and bars (Paper No. 3 onwards) ---------------------------------- */

/* Small multiples: panels side by side, one above the other on a phone. */
.r-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px 28px; }
.r-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.r-panel__title { font: 600 13px var(--font-sans); color: var(--text); }
.r-panel__sub { font-size: 12px; color: var(--text-dim); margin-top: -4px; }
.r-axis-titles { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--text-muted); }

/* Waffle: ten by ten, each square one in a hundred. */
.r-waffle { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; max-width: 280px; }
.r-waffle span { aspect-ratio: 1; border-radius: 2px; }
.r-waffle__tally { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-muted); }
.r-waffle__tally strong { font: 600 15px var(--font-mono); }

/* Density map. */
.r-plot--density { height: 240px; margin: 4px 46px 0 0; border-left: 1px solid var(--r-rule); border-bottom: 1px solid var(--r-rule); }
.r-guide { stroke: var(--r-ink); stroke-dasharray: 5 4; stroke-opacity: 0.6; fill: none; vector-effect: non-scaling-stroke; }
.r-density__note { position: absolute; transform: translate(-50%, -50%); font: 500 10.5px var(--font-mono); color: var(--text-muted); white-space: nowrap; background: color-mix(in srgb, var(--r-paper) 80%, transparent); padding: 1px 4px; }
.r-density__note--start { transform: translate(0, -50%); }
.r-plot--density + .r-xticks--lines { margin-right: 46px; }
.r-plot--density .r-yticks span { right: -46px; }

/* 100% stacked bars. */
.r-stack { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
.r-stack__group { margin-top: 8px; font: 600 11px var(--font-mono); letter-spacing: 1px; color: var(--text-dim); }
.r-stack__row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: center; }
.r-stack__label { font-size: 12.5px; color: var(--text-muted); text-align: right; }
.r-stack__bar { display: flex; height: 24px; border-radius: 3px; overflow: hidden; }
.r-stack__bar span { display: flex; align-items: center; justify-content: center; min-width: 0; }
.r-stack__bar em { font: 500 10.5px var(--font-mono); font-style: normal; color: #fff; }

/* Dumbbells: one compact row per market. */
.r-db { display: flex; flex-direction: column; }
.r-db__rows { position: relative; display: flex; flex-direction: column; margin-left: 76px; }
.r-db__grid { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--r-rule); }
.r-db__row { position: relative; height: 13px; }
.r-db__label { position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%); font: 400 9.5px var(--font-mono); white-space: nowrap; }
.r-db__track { position: absolute; inset: 0; }
.r-db__line { position: absolute; top: 50%; height: 2px; transform: translateY(-50%); opacity: 0.7; }
.r-db__dot { position: absolute; top: 50%; width: 7px; height: 7px; border-radius: 50%; transform: translate(-50%, -50%); }
.r-db__dot--b { background: var(--r-paper); border: 1.5px solid var(--r-grey); }
.r-db__axis { margin-left: 76px; }

/* Annotated candles. */
.r-plot--candles { height: 210px; }
.r-wick { fill: none; vector-effect: non-scaling-stroke; stroke-width: 1.2; }
.r-pt { position: absolute; transform: translate(-50%, -50%); }
.r-pt i { display: block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--r-blue); background: var(--r-paper); }
.r-pt--touch i { border-color: var(--r-orange); }
.r-pt b { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font: 600 10.5px var(--font-mono); color: var(--r-blue); white-space: nowrap; }
.r-pt--touch b { color: var(--r-orange); bottom: auto; top: 14px; }
.r-split { display: flex; flex-direction: column; gap: 5px; }
.r-split__bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.r-split__text { font: 400 11.5px var(--font-mono); color: var(--text-muted); }

@media (max-width: 900px) {
  .r-stack__row { grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
  .r-stack__label { font-size: 11px; }
  .r-plot--density { height: 200px; margin-right: 40px; }
  .r-plot--candles { height: 180px; }
}
@media print {
  .r-waffle { max-width: 200px; }
  .r-db__row { height: 10px; }
  .r-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
