/* ==========================================================================
   AB RESEARCH — a quiet, developer-oriented research index.
   Warm white, graphite, monospace navigation, and terracotta pixel details.
   ========================================================================== */

:root {
  --paper: #faf9f5;
  --paper-2: #f0efe9;
  --paper-3: #e7e6df;
  --card: #fdfcf9;
  --ink: #141413;
  --ink-2: #4d4c46;
  --muted: #77766e;
  --faint: #89887f;
  --rule: #deddd6;
  --rule-2: #b8b7ae;
  --accent: #c66b4a;
  --accent-2: #a64f33;
  --teal: #1e5a55;
  --gold: #a47a3f;
  --night: #141311;
  --night-2: #1c1a17;
  --night-3: #26231f;
  --night-ink: #eeede7;
  --night-ink-2: #cccbc3;
  --night-muted: #9b9a92;
  --night-rule: #373732;
  --serif: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "SF Mono", "Menlo", "Consolas", monospace;
  --latin: var(--mono);
  --reading: 17px;
  --sidebar: 286px;
  --article: 760px;
  --header: 112px;
  --ease: cubic-bezier(.2, .7, .25, 1);
}

[data-theme="night"] {
  --paper: #141311;
  --paper-2: #1c1a17;
  --paper-3: #26231f;
  --card: #1d1b18;
  --ink: #eeede7;
  --ink-2: #cccbc3;
  --muted: #9b9a92;
  --faint: #756b5c;
  --rule: #373732;
  --rule-2: #51483b;
  --accent: #e18a67;
  --accent-2: #efa380;
  --teal: #6aa9a1;
  --gold: #c8a266;
  --night: #0d0c0b;
  --night-2: #141311;
  --night-3: #1d1b18;
  --night-ink: #eeede7;
  --night-ink-2: #cccbc3;
  --night-muted: #9b9a92;
  --night-rule: #373732;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 24px); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: var(--reading);
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--card); }

a { color: inherit; }
img { max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100; height: var(--header);
  display: flex; align-items: center; gap: 36px; padding: 0 36px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; text-decoration: none; color: var(--accent); flex: 0 0 14%; }
.pixel-mark { width: 46px; height: 46px; display: block; }
.topnav { display: flex; justify-content: space-between; align-items: center; flex: 1; gap: 28px; }
.topnav a { color: var(--muted); font-family: var(--mono); font-size: 12px; text-decoration: none; white-space: nowrap; transition: color .2s; }
.topnav a span { color: var(--faint); margin-right: 5px; }
.topnav a:hover, .topnav a.active { color: var(--ink); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-left: 40px; }
.download-link { padding: 7px 16px; font-size: 13px; text-decoration: none; background: var(--ink); color: var(--paper); white-space: nowrap; transition: background .2s; }
.download-link span { margin-left: 14px; }
.download-link:hover { background: var(--accent); color: #fff; }
.icon-btn { width: 34px; height: 34px; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.icon-btn svg { width: 17px; height: 17px; }
.menu-toggle { display: none; }
.progress { position: fixed; left: 0; top: 0; z-index: 130; width: 100%; height: 2px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- shell / sidebar ---------- */
.shell {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr);
  max-width: 1560px; margin: 0 auto;
}
.sidebar { border-right: 1px solid var(--rule); }
.side-inner {
  position: sticky; top: var(--header);
  height: calc(100vh - var(--header));
  overflow-y: auto; padding: 30px 20px 54px;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.side-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em;
  color: var(--faint); text-transform: uppercase; margin: 0 10px 12px;
}
.side-label span { letter-spacing: .06em; color: var(--faint); }
.chapter-nav { display: flex; flex-direction: column; gap: 1px; }
.chapter-link {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: baseline;
  padding: 8px 10px; text-decoration: none;
  border-left: 2px solid transparent; color: var(--muted);
  transition: color .18s, background .18s, border-color .18s;
}
.chapter-link .num { font-family: var(--latin); font-size: 13px; color: var(--faint); }
.chapter-link .t { font-size: 12.5px; line-height: 1.5; }
.chapter-link:hover { color: var(--ink); background: var(--card); }
.chapter-link.active { color: var(--ink); background: var(--card); border-left-color: var(--accent); }
.chapter-link.active .num { color: var(--accent); }
.side-divider { height: 1px; background: var(--rule); margin: 24px 10px; }
.toc { display: flex; flex-direction: column; border-left: 1px solid var(--rule); margin-left: 10px; }
.toc a {
  display: block; padding: 5px 0 5px 12px; margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 12px; line-height: 1.55;
  transition: color .18s, border-color .18s;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc a.lvl3 { padding-left: 24px; font-size: 11.5px; color: var(--faint); }
.side-meta {
  margin: 26px 10px 0; padding-top: 16px; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 9.5px; line-height: 1.8;
  color: var(--faint); letter-spacing: .04em;
}
.nav-scrim { display: none; }
@media (min-width: 921px) {
  .shell-full .sidebar { display: none; }
}
.shell-full { display: block; max-width: none; }
.shell-full .main { width: 100%; }
.skip-link:focus { position: fixed; z-index: 999; top: 10px; left: 10px; width: auto; height: auto; clip: auto; margin: 0; padding: 8px 12px; background: var(--ink); color: var(--paper); font-size: 12px; }

/* ---------- research index ---------- */
.research-home { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 38px; max-width: 1600px; margin: 0 auto; padding: 58px 36px 100px; }
.intro-inner { position: sticky; top: calc(var(--header) + 35px); }
.research-intro h1 { margin: -9px 0 14px; font-family: var(--mono); font-weight: 500; font-size: clamp(24px, 2.2vw, 34px); letter-spacing: -.06em; line-height: 1.5; }
.cursor { color: var(--accent); }
.intro-description { font-size: 17px; line-height: 1.8; color: var(--ink-2); margin: 0; }
.intro-edition { display: flex; align-items: center; gap: 9px; margin-top: 34px; font: 11px var(--mono); color: var(--muted); letter-spacing: .02em; }
.status-dot { width: 6px; height: 6px; background: var(--accent); }
.intro-stats { max-width: 230px; margin: 25px 0 0; }
.intro-stats div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 12px; color: var(--muted); }
.intro-stats dd { font: 13px var(--mono); color: var(--ink-2); margin: 0; }
.intro-link { display: inline-flex; align-items: center; gap: 20px; color: var(--ink-2); font-size: 12px; text-decoration: none; padding: 5px 0; }
.intro-link:hover { color: var(--accent); }
.research-feed { min-width: 0; }
.feed-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 34px; padding-bottom: 13px; border-bottom: 1px solid var(--rule); }
.feed-filters { display: flex; gap: 22px; flex-wrap: wrap; }
.feed-filter, .feed-search { background: transparent; border: 0; padding: 0; font-family: var(--mono); font-size: 11px; line-height: 1.8; color: var(--muted); white-space: nowrap; }
.feed-filter.active, .feed-filter:hover, .feed-search:hover { color: var(--ink); }
.feed-filter.active { text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--accent); }
.feed-search span { color: var(--faint); }
.research-row { display: grid; grid-template-columns: 40px 112px minmax(0,1fr) 78px; gap: 18px; align-items: center; min-height: 69px; padding: 16px 0; text-decoration: none; border-bottom: 1px solid var(--rule); transition: background .2s; }
.research-row[hidden] { display: none; }
.research-row:hover { background: var(--paper-2); }
.row-icon { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--rule-2); font: 12px var(--mono); }
.row-category { font: 11px var(--mono); color: var(--muted); }
.row-number { color: var(--faint); }
.row-copy { display: block; min-width: 0; }
.row-title { display: block; font-size: 16px; line-height: 1.65; letter-spacing: -.02em; }
.row-time { font: 11px var(--mono); color: var(--muted); text-align: right; white-space: nowrap; }
.row-arrow { display: none; }
.research-row:hover .row-arrow { display: inline; color: var(--accent); margin-left: 6px; }
.research-row:hover .row-time > span:first-child { display: none; }
.research-row.featured { min-height: 182px; align-items: start; padding: 18px 0 24px; }
.featured .row-icon { width: 112px; height: 112px; background: var(--accent); border: 0; color: #faf9f5; }
.featured .row-icon .pixel-mark { width: 64px; height: 64px; }
.featured .row-category { visibility: hidden; }
.feature-label { display: flex; align-items: center; font: 10px var(--mono); margin-bottom: 10px; }
.feature-label b { padding: 3px 8px; background: var(--ink); color: var(--paper); font-weight: 400; }
.feature-label > span { padding: 2px 8px; border: 1px solid var(--rule); color: var(--muted); }
.featured .row-title { font-size: 30px; line-height: 1.35; font-weight: 500; margin-bottom: 10px; letter-spacing: -.04em; }
.row-description { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.8; }
.featured .row-time { padding-top: 4px; }
.feed-foot { display: flex; justify-content: space-between; gap: 20px; padding-top: 18px; color: var(--faint); font: 10px var(--mono); }
.feed-foot a { text-decoration: none; color: var(--muted); }
.feed-foot a:hover { color: var(--accent); }
.research-conclusions, .research-paths { margin-top: 86px; }
.feed-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.feed-section-head h2 { margin: 0; font-size: 23px; font-weight: 500; letter-spacing: -.03em; }
.feed-section-head > span { font: 9px var(--mono); color: var(--muted); white-space: nowrap; }
.research-note { border-bottom: 1px solid var(--rule); }
.research-note summary { display: flex; align-items: baseline; gap: 18px; cursor: pointer; list-style: none; padding: 18px 0; font-size: 14px; line-height: 1.7; }
.research-note summary::-webkit-details-marker { display: none; }
.note-number { flex: none; font: 10px var(--mono); color: var(--muted); }
.note-plus { margin-left: auto; color: var(--muted); }
.research-note[open] .note-plus { transform: rotate(45deg); }
.research-note p { margin: 0 25px 24px 34px; color: var(--ink-2); font-size: 13px; line-height: 1.95; }
.research-conclusions > .intro-link { margin-top: 18px; }
.research-paths > a { display: flex; justify-content: space-between; gap: 20px; padding: 18px 0; border-top: 1px solid var(--rule); text-decoration: none; font-size: 13px; }
.research-paths > a > span:last-child { color: var(--muted); font-size: 11px; }
.research-paths > a:hover { color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; height: 42px; text-decoration: none; font-size: 12px; border: 1px solid var(--ink); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }

/* ---------- article ---------- */
.main { min-width: 0; }
.article {
  max-width: calc(var(--article) + 120px);
  margin: 0 auto; padding: 0 52px 100px;
}
.chapter-head {
  position: relative; padding: 68px 0 36px;
  border-bottom: 1px solid var(--rule-2); margin-bottom: 44px;
}
.chapter-ghost { display: none; }

.chapter-kicker {
  position: relative; z-index: 1;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em;
  color: var(--accent); text-transform: uppercase;
}
.chapter-head h1 {
  position: relative; z-index: 1;
  margin: 14px 0 0; max-width: 740px;
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(38px, 5vw, 58px); line-height: 1.25; letter-spacing: -.045em;
}
.standfirst {
  position: relative; z-index: 1;
  max-width: 680px; margin: 20px 0 0;
  font-family: var(--serif); font-size: 19px; line-height: 1.85; color: var(--ink-2);
}
.chapter-meta {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  margin-top: 24px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .06em; color: var(--muted);
}
.chapter-meta .sep { width: 1px; height: 12px; background: var(--rule); }
.text-size { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.text-size button {
  width: 26px; height: 24px; border: 1px solid var(--rule); background: transparent;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.text-size button:hover { color: var(--ink); border-color: var(--rule-2); background: var(--card); }

.prose { overflow-wrap: anywhere; max-width: var(--article); font-size: var(--reading); line-height: 1.95; }
.prose > :first-child { margin-top: 0; }
.prose h2 {
  position: relative; margin: 64px 0 20px; padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif); font-weight: 700;
  font-size: 29px; line-height: 1.3; letter-spacing: -.025em;
}
.prose h2::before {
  content: ""; position: absolute; top: -1px; left: 0; width: 56px; height: 2px;
  background: var(--accent);
}
.prose h3 {
  margin: 36px 0 10px; font-family: var(--serif); font-weight: 700;
  font-size: 21px; line-height: 1.45; letter-spacing: -.015em;
}
.prose h4 { margin: 26px 0 8px; font-size: 16px; line-height: 1.5; }
.prose p { margin: 0 0 1.08em; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose em { font-style: italic; }
.prose a {
  color: var(--accent-2); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: background .15s, color .15s;
}
.prose a:hover { background: var(--accent); color: var(--card); text-decoration: none; }
.prose ul, .prose ol { margin: 0 0 1.2em 1.35em; padding: 0; }
.prose li { margin: .34em 0; }
.prose li > p { margin: 0 0 .4em; }
.prose blockquote {
  margin: 28px 0; padding: 18px 22px;
  background: var(--card); border-left: 3px solid var(--accent);
  color: var(--ink-2); font-size: 15px; line-height: 1.85;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 46px 0; }
.prose img { display: block; margin: 24px auto; }
.prose .btn {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--paper);
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .05em;
}
.prose .btn-primary { color: var(--paper); background: var(--ink); border: 1px solid var(--ink); }
.prose .btn-primary:hover { color: var(--card); background: var(--accent); border-color: var(--accent); text-decoration: none; }
.prose .ext-arrow { display: none; }
.prose .anchor {
  position: absolute; left: -1.15em; top: 0;
  color: var(--accent); opacity: 0; text-decoration: none;
  font-family: var(--mono); font-size: .62em; font-weight: 400;
  transition: opacity .15s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: .7; }

.table-wrap {
  max-width: 100%; margin: 28px 0 34px; overflow-x: auto;
  border: 1px solid var(--rule); background: var(--card);
  scrollbar-width: auto; scrollbar-color: var(--rule-2) var(--paper-2);
  overscroll-behavior-x: contain;
}
.table-wrap.table-wide {
  width: max(100%, min(1120px, calc(100vw - var(--sidebar) - 100px)));
  max-width: none; margin-left: 50%; transform: translateX(-50%);
}
.prose table {
  width: 100%; border-collapse: collapse; margin: 0;
  font-size: max(17px, var(--reading)); line-height: 1.8;
  overflow-wrap: normal; word-break: normal;
}
.prose th, .prose td {
  min-width: 10em; max-width: 24em; padding: 14px 18px;
  text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.prose thead th {
  background: var(--paper-2); border-bottom-color: var(--rule-2);
  font-family: var(--sans); font-size: inherit; font-weight: 600;
  color: var(--ink); line-height: 1.6;
}
.prose tbody td:first-child { color: var(--ink); font-weight: 500; }
.prose table.table-label-column tr > :first-child {
  min-width: 0; white-space: nowrap;
}
.prose table.table-description-column tr > :first-child {
  min-width: 13em; max-width: 20em;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) { background: color-mix(in srgb, var(--paper-2) 28%, transparent); }
.prose tbody tr:hover { background: var(--paper-2); }
.prose td strong { font-weight: 700; }
.prose table code { font-size: 1em; }
.prose code {
  font-family: var(--mono); font-size: .84em;
  background: var(--paper-2); border: 1px solid var(--rule);
  padding: .1em .34em; overflow-wrap: anywhere;
}
.prose pre {
  position: relative; margin: 24px 0; padding: 18px 20px;
  overflow-x: auto; background: var(--ink); color: #efe7da;
  border: 1px solid var(--ink); font-size: 12.5px; line-height: 1.7;
}
.prose pre code { overflow-wrap: normal; background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  border: 1px solid rgba(239, 231, 218, .25); background: rgba(239, 231, 218, .06);
  color: rgba(239, 231, 218, .72); font-family: var(--mono); font-size: 9px;
  padding: 4px 7px; opacity: 0; transition: opacity .18s, background .18s;
}
.prose pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(239, 231, 218, .14); color: #fff; }
.diagram {
  width: min(1040px, calc(100vw - var(--sidebar) - 100px));
  margin: 30px 0 30px 50%; padding: 18px 18px 12px;
  transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--rule);
}
.diagram-zoom {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  background: transparent; cursor: zoom-in;
}
.diagram img { width: auto; max-width: 100%; height: auto; display: block; margin: 0 auto; }
.zoom-hint {
  position: absolute; right: 10px; bottom: 10px;
  padding: 4px 8px; background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .08em;
  opacity: 0; transition: opacity .18s;
}
.diagram-zoom:hover .zoom-hint, .diagram-zoom:focus-visible .zoom-hint { opacity: 1; }
.diagram figcaption {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 9px; letter-spacing: .06em; color: var(--faint);
}
.diagram .dark-only { display: none; }
[data-theme="night"] .diagram .light-only { display: none; }
[data-theme="night"] .diagram .dark-only { display: block; }

.lightbox { position: fixed; inset: 0; z-index: 300; display: none; }
.lightbox.open { display: block; }
body.lightbox-open { overflow: hidden; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(10, 9, 8, .88); backdrop-filter: blur(4px); }
.lightbox-panel {
  position: relative; width: min(96vw, 1440px); height: 92vh; margin: 4vh auto;
  display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--rule-2); box-shadow: 0 40px 120px rgba(0,0,0,.4);
}
.lightbox-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 9px 14px; border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: var(--muted);
}
.lightbox-actions { display: flex; align-items: center; gap: 14px; }
.lightbox-actions a, .lightbox-actions button {
  border: 0; background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 9px; letter-spacing: .06em;
  text-decoration: none;
}
.lightbox-actions a:hover, .lightbox-actions button:hover { color: var(--accent); }
.lightbox-stage { flex: 1; overflow: auto; padding: 20px; background: var(--paper); }
.lightbox-stage img { max-width: none; height: auto; display: block; margin: 0 auto; }

.sources-title { font-size: 22px !important; }
.sources-title + p, .sources-title + ol, .sources-title + ul { font-size: 12.5px; }

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  margin-top: 70px; border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule);
}
.pager a {
  display: block; padding: 24px 26px; text-decoration: none;
  transition: background .2s;
}
.pager a:hover { background: var(--card); }
.pager a.next { text-align: right; border-left: 1px solid var(--rule); }
.pager .plabel { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--faint); }
.pager .ptitle { display: block; margin-top: 7px; font-family: var(--serif); font-size: 19px; line-height: 1.35; }
.pager a:hover .ptitle { color: var(--accent); }

.note-strip {
  display: flex; gap: 14px; align-items: baseline;
  margin: 34px 0 0; padding: 14px 0 0; border-top: 1px solid var(--rule);
  font-size: 11.5px; line-height: 1.8; color: var(--muted);
}
.note-strip b { color: var(--accent); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }

/* ---------- search ---------- */
.search-modal { position: fixed; inset: 0; z-index: 200; display: none; }
.search-modal.open { display: block; }
.search-backdrop {
  position: absolute; inset: 0; background: rgba(20, 19, 17, .58);
  backdrop-filter: blur(7px);
}
.search-panel {
  position: relative; width: min(800px, calc(100vw - 28px));
  margin: 10vh auto 0; background: var(--card);
  border: 1px solid var(--rule-2);
  box-shadow: 0 36px 100px rgba(0, 0, 0, .34);
  animation: search-in .22s var(--ease);
}
@keyframes search-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.search-top { display: flex; align-items: center; gap: 14px; padding: 0 20px; border-bottom: 1px solid var(--rule); }
.search-top svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.search-input {
  flex: 1; height: 68px; border: 0; background: transparent; outline: none;
  font-family: var(--serif); font-size: 23px; color: var(--ink);
}
.search-input::placeholder { color: var(--faint); }
.search-input::-webkit-search-cancel-button,
.ref-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-esc {
  border: 1px solid var(--rule); background: transparent; color: var(--faint);
  font-family: var(--mono); font-size: 9px; padding: 3px 6px;
}
.search-hint {
  padding: 10px 20px; border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: var(--faint);
  display: flex; justify-content: space-between; gap: 12px;
}
.search-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.search-result {
  display: block; padding: 13px 15px; border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit; transition: background .15s;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result.active { background: var(--paper-2); }
.search-result .sr-chapter {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .12em;
  color: var(--accent); text-transform: uppercase;
}
.search-result .sr-title { margin: 4px 0; font-family: var(--serif); font-size: 17px; line-height: 1.4; }
.search-result .sr-snippet { font-size: 11.5px; line-height: 1.7; color: var(--muted); }
.search-result mark { background: var(--accent); color: var(--card); padding: 0 2px; }
.search-empty { padding: 34px 20px; text-align: center; font-family: var(--serif); font-size: 17px; color: var(--muted); }

/* ---------- about / references ---------- */
.subpage { max-width: 1120px; margin: 0 auto; padding: 64px 52px 100px; }
.subpage-head { border-bottom: 1px solid var(--rule-2); padding-bottom: 28px; margin-bottom: 38px; }
.subpage-head h1 { margin: 12px 0 0; font-family: var(--serif); font-size: clamp(38px, 5vw, 60px); line-height: 1.06; letter-spacing: -.04em; }
.subpage-head p { max-width: 700px; margin: 16px 0 0; font-family: var(--serif); font-size: 18px; line-height: 1.8; color: var(--ink-2); }
.about-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 52px; align-items: start; }
.about-grid h2 { margin: 34px 0 10px; font-family: var(--serif); font-size: 25px; }
.about-grid h2:first-child { margin-top: 0; }
.about-grid p, .about-grid li { font-size: 14px; line-height: 1.9; color: var(--ink-2); }
.about-grid ul { padding-left: 1.2em; }
.about-card { background: var(--card); border: 1px solid var(--rule); padding: 22px; position: sticky; top: 88px; }
.about-card .mono { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: var(--faint); }
.about-card dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px 10px; margin: 14px 0 0; font-size: 12px; }
.about-card dt { color: var(--muted); }
.about-card dd { margin: 0; color: var(--ink-2); }
.confidence { display: grid; gap: 10px; margin-top: 20px; }
.confidence div { display: flex; gap: 10px; align-items: baseline; font-size: 11.5px; color: var(--muted); }
.confidence b { font-family: var(--mono); font-size: 9px; color: var(--accent); border: 1px solid var(--accent); padding: 1px 4px; flex: none; }

.ref-tools {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
}
.ref-search {
  flex: 1; min-width: 220px; height: 40px; border: 1px solid var(--rule);
  background: var(--card); padding: 0 12px; font-size: 13px; outline: none;
}
.ref-search:focus { border-color: var(--accent); }
.ref-count { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: var(--muted); }
.ref-group { margin: 34px 0 0; }
.ref-group h2 {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--rule);
  font-family: var(--serif); font-size: 22px;
}
.ref-group h2 span { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: var(--faint); }
.ref-item {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--rule); align-items: baseline;
}
.ref-item .rn { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.ref-item a { text-decoration: none; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.ref-item a:hover { color: var(--accent); text-decoration: underline; }
.ref-item .domain { font-family: var(--mono); font-size: 8.5px; color: var(--faint); letter-spacing: .04em; white-space: nowrap; }
.ref-empty { padding: 30px 0; font-family: var(--serif); font-size: 18px; color: var(--muted); display: none; }

/* ---------- back to top ---------- */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 38px; height: 38px; border: 1px solid var(--rule);
  background: var(--card); color: var(--muted); display: grid; place-items: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, color .2s, transform .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); transform: translateY(-2px); }
.to-top svg { width: 15px; height: 15px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  :root { --sidebar: 250px; }
  .article { padding-left: 36px; padding-right: 36px; }
}
@media (max-width: 920px) {
  :root { --header: 72px; }
  .topbar { padding: 0 18px; gap: 14px; }
  .topnav { display: none; }
  .menu-toggle { display: grid; }
  .shell { display: block; }
  .sidebar {
    position: fixed; z-index: 150; top: var(--header); bottom: 0; left: 0;
    width: min(320px, 86vw); background: var(--paper);
    border-right: 1px solid var(--rule-2);
    transform: translateX(-102%); transition: transform .28s var(--ease);
    box-shadow: 18px 0 50px rgba(0, 0, 0, .12);
  }
  .side-inner { position: static; height: 100%; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim {
    display: block; position: fixed; inset: var(--header) 0 0 0; z-index: 140;
    background: rgba(20, 19, 17, .4); backdrop-filter: blur(3px);
  }
  body.nav-open { overflow: hidden; }
  .article { padding: 0 26px 76px; }
  .chapter-head { padding-top: 48px; }
  .diagram, .table-wrap.table-wide { width: 100%; max-width: 100%; margin-left: 0; transform: none; }
  .standfirst { font-size: 17px; }
  .prose h2 { font-size: 25px; margin-top: 50px; }
  .prose h3 { font-size: 19px; }
  .about-grid { grid-template-columns: 1fr; gap: 30px; }
  .about-card { position: static; }
  .subpage { padding: 44px 24px 80px; }
  .to-top { right: 14px; bottom: 14px; }
}
@media (max-width: 560px) {
  .search-trigger { width: 36px; padding: 0; justify-content: center; }
  .article { padding: 0 18px 64px; }
  .chapter-head h1 { font-size: 38px; }
  .chapter-meta { gap: 10px; }
  .chapter-meta .sep { display: none; }
  .text-size { margin-left: 0; }
  .prose { font-size: var(--reading); line-height: 1.9; }
  .prose h2 { font-size: 23px; }
  .prose h3 { font-size: 18px; }
  .prose blockquote { padding: 15px 16px; font-size: 14px; }
  .prose th, .prose td { padding: 12px 15px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { border-left: 0; border-top: 1px solid var(--rule); text-align: left; }
  .subpage { padding: 36px 18px 64px; }
  .ref-item { grid-template-columns: 30px minmax(0, 1fr); }
  .ref-item .domain { display: none; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .sidebar, .pager, .to-top, .progress, .search-modal, .text-size, .nav-scrim { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body::before { display: none; }
  .shell { display: block; }
  .article { max-width: none; padding: 0; }
  .chapter-head { padding-top: 0; }
  .chapter-ghost { display: none; }
  .prose a { color: #000; text-decoration: underline; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
  .table-wrap { overflow: visible; }
  .prose pre, .diagram, .table-wrap { break-inside: avoid; }
  .prose h2, .prose h3 { break-after: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* appendix */
.appendix-callout {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin: 24px 0; padding: 20px 22px; background: var(--card);
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
}
.appendix-callout strong { display: block; font-family: var(--serif); font-size: 19px; line-height: 1.4; }
.appendix-callout p { margin: 6px 0 0; font-size: 12.5px; line-height: 1.75; color: var(--muted); }
.appendix-callout .btn { flex: none; height: 38px; }
.appendix-raw { margin: 20px 0; border: 1px solid var(--rule); background: var(--card); }
.appendix-raw summary {
  cursor: pointer; padding: 12px 14px; background: var(--paper-2);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; color: var(--muted);
}
.appendix-raw ol { max-height: 440px; overflow: auto; margin: 0; padding: 14px 22px 18px 40px; }
.appendix-raw li { margin: 2px 0; font-size: 10.5px; line-height: 1.75; word-break: break-all; }
.appendix-raw a { font-size: 10.5px; color: var(--muted); }
.appendix-raw a:hover { color: var(--accent); }
@media (max-width: 560px) {
  .appendix-callout { display: block; }
  .appendix-callout .btn { margin-top: 14px; }
}

/* Index adapts from an editorial spread to one continuous mobile feed. */
@media (max-width: 1180px) {
  .research-home { grid-template-columns: minmax(240px, .8fr) minmax(0, 2fr); gap: 30px; padding-left: 28px; padding-right: 28px; }
  .research-row { grid-template-columns: 34px 70px minmax(0,1fr) 66px; gap: 12px; }
  .featured .row-icon { width: 95px; height: 95px; }
  .top-actions { margin-left: 15px; }
  .feed-filters { gap: 18px; }
}
@media (max-width: 920px) {
  .brand { flex-basis: auto; margin-right: auto; }
  .research-home { grid-template-columns: 1fr; padding: 28px 24px 70px; gap: 36px; }
  .intro-inner { position: static; }
  .research-intro h1 { font-size: 29px; }
  .intro-description { font-size: 15px; }
  .intro-edition { margin-top: 18px; }
  .intro-stats { display: flex; gap: 24px; max-width: none; margin-top: 15px; flex-wrap: wrap; }
  .intro-stats div { gap: 9px; }
  .research-conclusions, .research-paths { margin-top: 60px; }
}
@media (max-width: 560px) {
  .download-link { font-size: 11px; padding: 7px 10px; }
  .download-link span { margin-left: 4px; }
  .top-actions { gap: 4px; margin-left: 0; }
  .pixel-mark { width: 36px; height: 36px; }
  .research-home { padding: 24px 18px 54px; }
  .intro-stats { gap: 6px 20px; }
  .intro-stats div { font-size: 11px; }
  .feed-toolbar { gap: 8px; align-items: baseline; }
  .feed-filters { gap: 10px; }
  .feed-filter, .feed-search { font-size: 10px; }
  .feed-search span { display: none; }
  .research-row { grid-template-columns: 30px minmax(0,1fr) 54px; gap: 12px; min-height: 74px; }
  .row-category { display: none; }
  .row-title { font-size: 14px; }
  .row-icon { width: 26px; height: 26px; font-size: 10px; }
  .row-time { font-size: 10px; }
  .research-row.featured { grid-template-columns: 66px minmax(0,1fr); gap: 14px; min-height: 170px; }
  .featured .row-icon { width: 64px; height: 64px; }
  .featured .row-icon .pixel-mark { width: 42px; height: 42px; }
  .featured .row-time { display: none; }
  .featured .row-title { font-size: 25px; }
  .row-description { font-size: 12px; }
  .feature-label { font-size: 9px; }
  .feed-section-head { display: block; }
  .feed-section-head h2 { font-size: 21px; }
  .feed-section-head > span { display: block; margin-top: 8px; }
  .research-paths > a { font-size: 12px; gap: 12px; }
  .research-paths > a > span:last-child { font-size: 10px; white-space: nowrap; }
  .search-input { min-width: 0; font-size: 17px; }
}
