@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --body: 'Inter', sans-serif;
  --display: 'Lora', serif;
  --mono: 'JetBrains Mono', monospace;
  --red: #C41230;
  --text: #333;
  --heading: #111;
  --muted: #555;
  --faint: #666;
  --border: #f0f0f0;
  --bg: #fff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--body);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: rgba(196, 18, 48, 0.1); }

a { color: var(--red); text-decoration: none; }
a:hover { opacity: 0.75; }

/* ── nav ──────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.nav-brand span {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--heading);
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}
.nav-links a {
  font-family: var(--body);
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}
.nav-links a:hover { color: var(--heading); }
.nav-links a.active { color: var(--heading); }

/* ── content ──────────────────────────────────────── */
.content {
  max-width: 45rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}
.content-narrow {
  max-width: 45rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6.25rem;
}
.content-narrow.prose {
  position: relative;
}

/* ── prose ─────────────────────────────────────────── */
.prose p {
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1rem;
}
.prose p a { color: var(--red); }
.prose strong { color: var(--heading); }
.prose em { font-style: italic; }

.prose h2 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.25;
  margin: 1.75rem 0 0.375rem;
}
.prose h3 {
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--heading);
  margin: 2rem 0 0.75rem;
}
.prose h4 {
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--heading);
  margin: 1.5rem 0 0.5rem;
}
.prose ul, .prose ol {
  margin: 0 0 1rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.65;
}
.prose li { margin-bottom: 0.25rem; }

/* ── sparkle bullets ──────────────────────────────── */
.project-list {
  list-style: none;
  margin-left: 0 !important;
  padding-left: 1.25rem;
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 1.5rem;
}
.project-list li {
  position: relative;
  padding-left: 0.25rem;
  margin-bottom: 0.5rem;
}
.project-list li::before {
  content: '\2726';
  color: var(--red);
  font-size: 1em;
  position: absolute;
  left: -1.1rem;
  top: 0;
  line-height: 1.65;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  background: #f5f5f5;
  padding: 0.125rem 0.3125rem;
  border-radius: 3px;
}
.prose pre {
  background: #fafafa;
  border: 1px solid #e2e2e2;
  border-radius: 5px;
  padding: 1rem 1.125rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}
.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.5;
}
.prose blockquote {
  border-left: 3px solid var(--red);
  padding-left: 1rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-style: italic;
}
.prose img {
  max-width: 100%;
  border-radius: 5px;
  margin: 0.5rem 0 1rem;
}
.prose mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── intro (home page) ────────────────────────────── */
.intro {
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.65;
  color: #333;
  margin-bottom: 1rem;
}

/* ── section headings ─────────────────────────────── */
.section-heading {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 0.875rem;
}

/* ── post list ────────────────────────────────────── */
.post-item {
  display: block;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.post-item:hover { opacity: 1; }
.post-description {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}
.post-item:hover .post-title { color: var(--red); }
.post-title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--heading);
  transition: color 0.15s;
}
.post-meta {
  font-family: var(--body);
  font-size: 0.875rem;
  color: var(--faint);
  margin-top: 0.25rem;
}

/* ── project list ─────────────────────────────────── */
.project-item {
  display: block;
  padding: 1.25rem 0;
  text-decoration: none;
}
.project-item + .project-item {
  border-top: 1px solid var(--border);
}
.project-item:hover { opacity: 1; }
.project-item:hover .project-title { color: var(--red); }
.project-title {
  font-family: var(--display);
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--heading);
  transition: color 0.15s;
}
.project-venue {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--red);
  background: rgba(196, 18, 48, 0.06);
  padding: 0.125rem 0.4375rem;
  border-radius: 3px;
  margin-left: 0.625rem;
  vertical-align: 0.125rem;
  letter-spacing: 0.02em;
}
.project-desc {
  font-family: var(--body);
  font-size: 0.9375rem;
  color: var(--text);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* ── post header ──────────────────────────────────── */
.post-header {
  margin-bottom: 2.25rem;
}
.post-header h1 {
  font-family: var(--display);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.25;
  margin: 1.75rem 0 0.5rem;
}
.post-header .post-meta {
  margin-top: 0;
  font-size: 0.875rem;
}
.back-link {
  font-family: var(--body);
  font-size: 0.875rem;
  color: var(--red);
}

/* ── newsletter signup ────────────────────────────── */
.subscribe {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.875rem 1rem;
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.65;
}
.prose .subscribe { margin: 2.5rem 0 0; }
.subscribe-copy { margin-bottom: 0.625rem; }
.subscribe-fields { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.subscribe input[type="email"] {
  flex: 1 1 14rem;
  min-width: 0;
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.subscribe input[type="email"]:focus { outline: 2px solid rgba(196, 18, 48, 0.3); border-color: var(--red); }
.subscribe button {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
}
.subscribe button:hover { opacity: 0.85; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── footer ───────────────────────────────────────── */
.footer {
  padding: 1.75rem 1.5rem;
  text-align: center;
  font-family: var(--body);
  font-size: 0.8125rem;
  color: #999;
}

/* ── responsive ───────────────────────────────────── */
@media (max-width: 600px) {
  .nav { padding: 0.875rem 1.125rem; flex-wrap: wrap; row-gap: 0.5rem; }
  .nav-links { gap: 1rem; padding: 0; margin: 0; }
  .content { padding: 3rem 1.125rem 3.75rem; }
  .content-narrow { padding: 1.75rem 1.125rem 3.75rem; }
}

/* ── long-form technical posts ───────────────────── */
.prose .tldr {
  display: block;
  margin: 1.5rem 0 2rem;
  padding: 0.875rem 1rem;
  border: 1px solid rgba(196, 18, 48, 0.15);
  border-radius: 6px;
  background: rgba(196, 18, 48, 0.04);
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
}
.prose .query-statement {
  max-width: 42rem;
  margin: 1.5rem auto;
  padding: 1rem 1.25rem;
  border: 1px solid #d8d8d8;
  border-radius: 5px;
  background: #fafafa;
  font-family: var(--display);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--heading);
  text-align: center;
}
.prose figure {
  width: min(70rem, calc(100vw - 3rem));
  margin: 2rem 50%;
  transform: translateX(-50%);
}
.prose figure.figure-medium {
  width: min(50rem, calc(100vw - 3rem));
}
.prose figure.figure-filter-query {
  width: min(64rem, calc(100vw - 3rem));
}
.prose figure.figure-plot-compact {
  width: min(48rem, calc(100vw - 3rem));
}
.prose figure.figure-join-attention {
  width: min(56rem, calc(100vw - 3rem));
}
.prose figure.figure-profile {
  width: min(60rem, calc(100vw - 3rem));
}
.prose figure.figure-architecture {
  width: min(62rem, calc(100vw - 3rem));
}
.prose figure.figure-execution {
  width: min(58rem, calc(100vw - 3rem));
}
.prose figure img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}
.prose figcaption {
  max-width: 50rem;
  margin-top: 0.625rem;
  margin-left: auto;
  margin-right: auto;
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--faint);
  font-style: italic;
}
.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.45;
}
.prose th,
.prose td {
  min-width: 9rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid #d8d8d8;
  text-align: left;
  vertical-align: top;
}
.prose th,
.prose table thead tr td {
  background: #f5f5f5;
  color: var(--heading);
  font-weight: 600;
}
.prose td p {
  margin: 0 0 0.25rem;
  font-size: inherit;
  line-height: inherit;
}
.prose td p:last-child {
  margin-bottom: 0;
}
.prose sup {
  position: relative;
  top: -0.35em;
  font-size: 1em;
  line-height: 0;
  vertical-align: baseline;
}
.prose sub {
  font-size: 0.8em;
}
.prose .space-symbol {
  display: inline-block;
  font-family: var(--mono);
  font-size: 1.3em;
  font-weight: 500;
  line-height: 0.75;
  vertical-align: -0.08em;
}
.prose .sidenote {
  display: none;
}
.prose .sidenote-sql {
  margin-top: 0.5rem;
}
.prose .sidenote-sql summary {
  color: var(--red);
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.75rem;
}
.prose .sidenote-sql .note-1-sql,
.prose .sidenote-sql pre {
  margin: 0.5rem 0 0;
}
.prose .sidenote-sql pre,
.prose .sidenote-sql code {
  font-size: 0.625rem;
  line-height: 1.35;
}
.prose .sidenote-sql pre {
  padding: 0.625rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.prose .note-2-example {
  margin-top: 0.5rem;
}
.prose .note-2-example p {
  margin: 0.5rem 0 0.25rem;
  font-size: inherit;
}
.prose .sidenote .note-2-example p {
  color: inherit;
  line-height: inherit;
}
.prose .note-2-example pre {
  margin: 0.4rem 0;
  padding: 0.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.prose .note-2-example pre,
.prose .note-2-example code {
  font-size: 0.6875rem;
  line-height: 1.35;
}
.prose .copy-bibtex {
  border: 1px solid #c8c8c8;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-family: var(--body);
  font-size: 0.75rem;
  line-height: 1.2;
  cursor: pointer;
}
.prose .bibtex-block {
  position: relative;
}
.prose .bibtex-block pre {
  padding-top: 2.75rem;
}
.prose .copy-bibtex {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  padding: 0.4rem 0.65rem;
}

@media (min-width: 1150px) {
  .prose .sidenote {
    position: absolute;
    left: calc(100% + 2rem);
    display: block;
    width: 15rem;
    font-family: var(--body);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
  }
  .prose .sidenote[hidden] {
    display: none;
  }
.prose .sidenote-number strong {
    color: var(--red);
  }
  .prose .sidenote > code {
    color: var(--red);
    font-size: 0.6875rem;
    padding: 0.0625rem 0.25rem;
  }
  .prose.has-sidenotes > #notes,
  .prose.has-sidenotes > #references,
  .prose.has-sidenotes p:has(> span[id^="note-"]),
  .prose.has-sidenotes > .note-1-sql,
  .prose.has-sidenotes > .note-2-example {
    display: none;
  }
}

/* Between 1150px and 1650px, sidenotes are narrower and the article moves
   left by half the sidenote column, so the text and sidenotes stay centered
   together. The sidenote column starts 2rem right of the text, so a wide
   figure or table may not pass the text's right edge. It keeps its own width
   up to the space between the left gutter and that edge, which is
   50vw + 11rem, and grows leftward from that edge. One no wider than the
   text (42rem) stays centered on the text. */
@media (min-width: 1150px) and (max-width: 1649.98px) {
  .content-narrow.prose.has-sidenotes {
    left: -8.5rem;
  }
  .prose.has-sidenotes figure:not(.figure-full),
  .prose.has-sidenotes figure.figure-full.figure-readable,
  .prose.has-sidenotes #table-3 {
    max-width: calc(50vw + 11rem);
    transform: translateX(-50%) translateX(min(0px, calc(21rem - 50%)));
  }
}
@media (min-width: 1650px) {
  .prose .sidenote {
    left: calc(100% + 8rem);
    width: 20rem;
  }
  .prose .sidenote:has(.sidenote-sql[open]) {
    left: calc(100% + 0.5rem);
    width: 28rem;
  }
}

@media (max-width: 640px) {
  .prose th,
  .prose td {
    min-width: 8rem;
  }
}

.prose .collapsible-section {
  margin: 2rem 0;
}
.prose .collapsible-section summary {
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--heading);
}
.prose .collapsible-section .collapsible-note {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--faint);
}
.prose .collapsible-section[open] summary {
  margin-bottom: 0.875rem;
}
.prose .proof-card {
  margin: 1.25rem 0;
  padding: 1rem 1.125rem;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  background: #fafafa;
}
.prose .proof-card summary {
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 500;
}
.prose .proof-card summary h5 {
  display: inline;
  margin: 0;
  font: inherit;
  color: inherit;
}
.prose .proof-card > p:last-child {
  margin-bottom: 0;
}
.prose .proof-card .table-wrap {
  margin: 0.75rem 0 0;
}
.prose .algorithm-pseudocode {
  margin: 1rem 0;
  padding: 1rem 1.125rem;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  background: #fafafa;
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.8;
}
.prose .algorithm-pseudocode .algorithm-indent {
  padding-left: 1.5rem;
}

.prose .post-toc {
  margin: 0 0 2.25rem;
  padding: 1rem 1.125rem;
  border: 1px solid #d8d8d8;
  border-radius: 5px;
}
.prose .post-toc > strong {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--display);
  font-size: 1.125rem;
  color: var(--heading);
}
.prose .post-toc ol {
  margin-bottom: 0;
}
.prose .post-toc ol ol {
  margin: 0.25rem 0 0.375rem 1.25rem;
}
.prose .post-toc li {
  margin-bottom: 0.2rem;
}

.prose figure {
  text-align: center;
}
.prose figure img {
  width: auto;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.prose figcaption,
.prose .table-caption {
  text-align: left;
}
.prose .table-wrap {
  width: 100%;
  margin: 2rem auto;
  overflow-x: auto;
}
.prose .table-wrap table {
  display: table;
  width: auto;
  min-width: min(100%, 32rem);
  margin: 0 auto;
  overflow: visible;
}
.prose #table-5 table,
.prose #table-7 table {
  width: 100%;
}
.prose #table-5 th,
.prose #table-5 td,
.prose #table-7 th,
.prose #table-7 td {
  min-width: 0;
  padding: 0.625rem 0.5rem;
}
.prose #table-3,
.prose #table-8 {
  width: min(58rem, calc(100vw - 3rem));
  margin: 2rem 50%;
  transform: translateX(-50%);
}
.prose #table-3,
.prose #table-8 {
  width: min(46rem, calc(100vw - 3rem));
}
.prose #table-8 {
  width: 100%;
  margin: 2rem auto;
  transform: none;
}
.prose #table-3 table,
.prose #table-8 table {
  width: 100%;
  table-layout: fixed;
}
.prose #table-3 th,
.prose #table-3 td,
.prose #table-8 th,
.prose #table-8 td {
  min-width: 0;
}
.prose #table-3 th,
.prose #table-3 td {
  text-align: center;
}
.prose #table-3 th:first-child,
.prose #table-3 td:first-child {
  text-align: left;
}
.prose #table-3 th:nth-child(1),
.prose #table-3 td:nth-child(1),
.prose #table-8 th:nth-child(1),
.prose #table-8 td:nth-child(1) {
  width: 21%;
}
.prose #table-3 th:nth-child(2),
.prose #table-3 td:nth-child(2),
.prose #table-8 th:nth-child(2),
.prose #table-8 td:nth-child(2) {
  width: 21%;
}
.prose #table-3 th:nth-child(3),
.prose #table-3 td:nth-child(3),
.prose #table-8 th:nth-child(3),
.prose #table-8 td:nth-child(3) {
  width: 21%;
}
.prose #table-3 th:nth-child(4),
.prose #table-3 td:nth-child(4),
.prose #table-8 th:nth-child(4),
.prose #table-8 td:nth-child(4) {
  width: 16%;
}
.prose #table-3 th:nth-child(5),
.prose #table-3 td:nth-child(5),
.prose #table-8 th:nth-child(5),
.prose #table-8 td:nth-child(5) {
  width: 21%;
}
.prose .table-caption {
  margin: 0.625rem auto 0;
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--faint);
  font-style: italic;
}

@media (max-width: 640px) {
  .prose #table-3,
  .prose #table-8 {
    width: calc(100vw - 3rem);
  }
  .prose #table-3 table,
  .prose #table-8 table {
    width: 40rem;
    min-width: 40rem;
  }
}

/* Rouge syntax highlighting */
.prose .highlight .c,
.prose .highlight .c1,
.prose .highlight .cm { color: #6a737d; font-style: italic; }
.prose .highlight .k,
.prose .highlight .kc,
.prose .highlight .kd,
.prose .highlight .kn,
.prose .highlight .kp,
.prose .highlight .kr,
.prose .highlight .kt { color: #a31545; font-weight: 500; }
.prose .highlight .s,
.prose .highlight .s1,
.prose .highlight .s2,
.prose .highlight .se { color: #287a4d; }
.prose .highlight .mi,
.prose .highlight .mf { color: #7b4da1; }
.prose .highlight .nf,
.prose .highlight .nc { color: #245f9e; }
.prose .highlight .o { color: #8a3b12; }
.prose .highlight .map-planning-call,
.prose .highlight .map-execution-call {
  color: #245f9e;
  text-decoration: none;
}
.prose .map-algorithm code { white-space: normal; }
.prose .map-algorithm .algorithm-line {
  display: block;
  min-width: max-content;
  white-space: pre;
  scroll-margin-top: 5rem;
}
.prose .map-algorithm .algorithm-line::before {
  content: attr(data-line);
  display: inline-block;
  width: 2ch;
  margin-right: 1.5ch;
  color: var(--faint);
  text-align: right;
  user-select: none;
}
.prose .map-algorithm .algorithm-line:target { background: #fff4ce; }


.prose figure.figure-full {
  width: 100%;
  margin: 2rem 0;
  transform: none;
}
.prose figure.figure-full img {
  width: 100%;
  max-width: 100%;
}
.prose figure.figure-full.figure-readable {
  width: min(48rem, calc(100vw - 3rem));
  margin: 2rem 50%;
  transform: translateX(-50%);
}

/* ── filter-chain playground ─────────────────────── */
.prose .pg {
  --pg-line: #d8d8d8;
  --pg-soft: #f7f7f7;
  --pg-cols: 3.125rem minmax(8.5rem, 1.5fr) minmax(7.5rem, 1fr) 3.5rem 4.75rem 3.25rem;
  width: 100%;
  margin: 2rem 0;
  overflow: hidden;
  border: 1px solid var(--red);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 14px 32px -16px rgba(0, 0, 0, 0.16);
  font-family: var(--body);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text);
}
.prose .pg * { box-sizing: border-box; }
.prose .pg ol,
.prose .pg ul { list-style: none; margin: 0; padding: 0; }
.prose .pg li { margin: 0; }
.prose .pg i { font-style: italic; }
.prose .pg sub { line-height: 0; }
.prose .pg button,
.prose .pg select,
.prose .pg input { font-family: var(--body); }

/* bar */
.prose .pg-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--pg-line);
  background: var(--pg-soft);
}
.prose .pg-title { font-family: var(--display); font-size: 0.9375rem; font-weight: 600; color: var(--heading); }
.prose .pg-sub { margin-left: 0.375rem; font-family: var(--body); font-size: 0.6875rem; font-weight: 400; color: var(--faint); }
.prose .pg-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.prose .pg-select,
.prose .pg-btn {
  padding: 0.3125rem 0.625rem;
  border: 1px solid #d0d0cd;
  border-radius: 6px;
  background: #fff;
  font-size: 0.75rem;
  color: var(--text);
}
.prose .pg-select { padding-right: 1.5rem; color: var(--heading); }
.prose .pg-btn { cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.prose .pg-btn:hover { border-color: var(--red); color: var(--red); }
.prose .pg-btn-primary { border-color: var(--red); background: var(--red); color: #fff; }
.prose .pg-btn-primary:hover { border-color: #a30f27; background: #a30f27; color: #fff; }
.prose .pg-select:focus-visible,
.prose .pg-btn:focus-visible,
.prose .pg-preset:focus-visible,
.prose .pg-icon:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.prose .pg-body { padding: 0.875rem; }

/* inputs */
.prose .pg-num,
.prose .pg-name {
  min-width: 0;
  padding: 0.25rem 0.4375rem;
  border: 1px solid #d6d6d3;
  border-radius: 6px;
  background: #fff;
  font-size: 0.8125rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prose .pg-num { width: 100%; text-align: right; }
.prose .pg-num { -moz-appearance: textfield; appearance: textfield; }
.prose .pg-num::-webkit-outer-spin-button,
.prose .pg-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.prose .pg-num:hover,
.prose .pg-name:hover { border-color: #b9b9b6; }
.prose .pg-num:focus,
.prose .pg-name:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(196, 18, 48, 0.13); }
.prose .pg-num.is-invalid { border-color: var(--red); background: rgba(196, 18, 48, 0.05); }
.prose .pg-workload { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; margin-bottom: 1rem; }
.prose .pg-field { display: flex; flex-direction: column; gap: 0.1875rem; font-size: 0.6875rem; font-weight: 500; color: var(--muted); }
.prose .pg-field .pg-num { text-align: left; }

.prose .pg-label-row { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 0.375rem; }
.prose .pg-h { font-family: var(--display); font-size: 0.9375rem; font-weight: 600; color: var(--heading); }
.prose .pg-h-small { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.prose .pg-mt { margin-top: 0.75rem; }

/* chain rows */
.prose .pg-cols,
.prose .pg-row { display: grid; grid-template-columns: var(--pg-cols); align-items: center; column-gap: 0.5rem; }
.prose .pg-cols { padding: 0 0.625rem 0.25rem 0.75rem; font-size: 0.625rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--faint); }
.prose .pg-cols span:nth-child(3) { padding-left: 0; }
.prose .pg-cols span:nth-child(4) { text-align: right; }
.prose .pg-rows { display: flex; flex-direction: column; gap: 0.375rem; padding: 0.375rem; border: 1px dashed #d4d4d0; border-radius: 10px; background: var(--pg-soft); transition: border-color 0.15s, background 0.15s; }
.prose .pg.is-dragging .pg-rows { border-color: var(--red); background: rgba(196, 18, 48, 0.03); }
.prose .pg-row {
  padding: 0.4375rem 0.5rem 0.4375rem 0.625rem;
  border: 1px solid var(--c);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s;
}
.prose .pg-row:hover { box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.18); }
.prose .pg-handle { display: inline-flex; align-items: center; gap: 0.375rem; }
.prose .pg.has-dnd .pg-handle { cursor: grab; }
.prose .pg-grip {
  flex: none;
  width: 0.5rem;
  height: 0.875rem;
  background-image: radial-gradient(circle, #a8a8a5 1.1px, transparent 1.5px);
  background-size: 4.5px 4.5px;
}
.prose .pg-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--c);
  font-size: 0.625rem;
  font-weight: 600;
  color: #fff;
}
.prose .pg-name { width: 100%; border-color: transparent; background: transparent; font-weight: 600; text-overflow: ellipsis; }
.prose .pg-name:hover { background: #fff; }
.prose .pg-name:focus { background: #fff; }
.prose .pg-s { display: grid; grid-template-columns: 1fr 3.875rem; align-items: center; gap: 0.5rem; }
.prose .pg-io { display: flex; flex-direction: column; gap: 0.1875rem; font-size: 0.6875rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose .pg-io-bar { position: relative; display: block; height: 4px; overflow: hidden; border-radius: 999px; background: #eeeeec; }
.prose .pg-io-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--c); transition: width 0.4s cubic-bezier(.2, .8, .2, 1); }
.prose .pg-io-bar .pg-io-in { opacity: 0.28; }
.prose .pg-tools { display: flex; justify-content: flex-end; gap: 0.0625rem; opacity: 0.35; transition: opacity 0.15s; }
.prose .pg-row:hover .pg-tools,
.prose .pg-row:focus-within .pg-tools { opacity: 1; }
.prose .pg-icon {
  width: 1rem;
  height: 1.375rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 1rem;
  line-height: 1;
  color: var(--faint);
  cursor: pointer;
}
.prose .pg-icon:hover:not(:disabled) { background: #efefed; color: var(--heading); }
.prose .pg-remove:hover:not(:disabled) { color: var(--red); }
.prose .pg-icon:disabled { opacity: 0.3; cursor: default; }

/* sliders */
.prose .pg-range {
  --fill: var(--c, var(--red));
  --p: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1.125rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.prose .pg-range::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: linear-gradient(to right, var(--fill) var(--p), #e4e4e1 var(--p)); }
.prose .pg-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border: 2px solid var(--fill);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}
.prose .pg-range:hover::-webkit-slider-thumb { transform: scale(1.15); }
.prose .pg-range::-moz-range-track { height: 5px; border-radius: 999px; background: #e4e4e1; }
.prose .pg-range::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--fill); }
.prose .pg-range::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid var(--fill); border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.prose .pg-range:focus-visible { outline: 2px solid var(--fill); outline-offset: 3px; border-radius: 4px; }

/* drag states (SortableJS) */
.prose .pg .is-ghost { opacity: 0.4; border-style: dashed; box-shadow: none; }
.prose .pg .is-chosen { box-shadow: 0 10px 26px -8px rgba(0, 0, 0, 0.3); }
.prose .pg .is-drag { transform: rotate(1deg); box-shadow: 0 14px 32px -8px rgba(0, 0, 0, 0.34); }

/* library */
.prose .pg-library { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.625rem; margin: 0.625rem 0 1rem; }
.prose .pg-presets { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.prose .pg-preset {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem 0.25rem 0.5rem;
  border: 1px dashed #b9b9b6;
  border-radius: 999px;
  background: #fff;
  font-size: 0.75rem;
  color: var(--heading);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prose .pg.has-dnd .pg-preset { cursor: grab; }
.prose .pg-preset:hover { border-color: var(--red); box-shadow: 0 3px 8px -4px rgba(196, 18, 48, 0.4); }
.prose .pg-preset.is-custom { border-style: solid; border-color: rgba(196, 18, 48, 0.35); background: rgba(196, 18, 48, 0.04); padding-left: 0.625rem; }
.prose .pg-presets.is-full .pg-preset { opacity: 0.4; pointer-events: none; }

/* results */
.prose .pg-error { padding: 0.5rem 0.75rem; border: 1px solid rgba(196, 18, 48, 0.3); border-radius: 6px; background: rgba(196, 18, 48, 0.05); color: var(--red); }
.prose .pg .pg-chain { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0 0 0.875rem; }
.prose .pg-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.25rem 0.6875rem 0.25rem 0.3125rem;
  border: 1px solid var(--pg-line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.prose .pg-chip:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -1rem;
  top: 50%;
  width: 0.75rem;
  height: 0.875rem;
  margin-top: -0.4375rem;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a5a5a0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4'/%3E%3C/svg%3E");
}
.prose .pg-chip-name { font-size: 0.8125rem; font-weight: 600; color: var(--heading); }
.prose .pg-chip-was { font-size: 0.6875rem; font-weight: 500; color: var(--red); }
.prose .pg-chip.is-moved { border-color: rgba(196, 18, 48, 0.4); }
.prose .pg-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.prose .pg-tile { display: flex; flex-direction: column; gap: 0.0625rem; min-width: 0; padding: 0.625rem 0.875rem; border: 1px solid var(--pg-line); border-radius: 10px; background: var(--pg-soft); }
.prose .pg-tile-main { border-color: rgba(196, 18, 48, 0.28); background: rgba(196, 18, 48, 0.045); }
.prose .pg-tile-label { font-size: 0.6875rem; font-weight: 500; color: var(--muted); }
.prose .pg-tile-value { min-height: 2.25rem; font-family: var(--display); font-size: 1.875rem; font-weight: 600; line-height: 1.2; color: var(--heading); font-variant-numeric: tabular-nums; }
.prose .pg-verdict { font-size: 0.75rem; color: var(--faint); }
.prose .pg-verdict.is-gain { color: var(--red); font-weight: 500; }
.prose .pg-plot { margin-top: 0.75rem; padding: 0.625rem 0.875rem 0.5rem; border: 1px solid var(--pg-line); border-radius: 10px; }
.prose .pg-plot-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 0.75rem; }
.prose .pg-keys { display: inline-flex; gap: 0.75rem; font-size: 0.6875rem; color: var(--muted); }
.prose .pg-keys span { display: inline-flex; align-items: center; gap: 0.3125rem; }
.prose .pg-key { display: inline-block; width: 0.5625rem; height: 0.5625rem; border-radius: 50%; }
.prose .pg-key-yours { border: 2px solid var(--heading); }
.prose .pg-key-rule { background: var(--red); }
.prose .pg-key-best { background: var(--heading); }
.prose .pg-plot-svg { display: block; width: 100%; height: auto; }
.prose .pg-axis { stroke: #d0d0cd; stroke-width: 1; }
.prose .pg-axis-label { fill: #77777a; font-size: 10.5px; font-family: var(--body); }
.prose .pg-dot,
.prose .pg-dot-yours,
.prose .pg-dot-rule,
.prose .pg-dot-best {
  cursor: pointer;
  transition: r 0.12s, opacity 0.12s;
}
.prose .pg-dot { fill: #b7b7b3; }
.prose .pg-dot-yours { fill: none; stroke: var(--heading); stroke-width: 2; }
.prose .pg-dot-rule { fill: var(--red); }
.prose .pg-dot-best { fill: var(--heading); }
.prose .pg-dot:hover,
.prose .pg-dot:focus-visible { r: 5; opacity: 0.85; }
.prose .pg-dot-yours:hover,
.prose .pg-dot-rule:hover,
.prose .pg-dot-best:hover,
.prose .pg-dot-yours:focus-visible,
.prose .pg-dot-rule:focus-visible,
.prose .pg-dot-best:focus-visible { opacity: 0.75; }
.prose .pg-dot:focus-visible,
.prose .pg-dot-yours:focus-visible,
.prose .pg-dot-rule:focus-visible,
.prose .pg-dot-best:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.prose .pg-plot-msg { font-size: 0.75rem; color: var(--muted); }
.prose .pg-details { margin-top: 0.75rem; }
.prose .pg-details summary { cursor: pointer; font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.prose .pg-details summary:hover { color: var(--red); }
.prose .pg-scroll { overflow-x: auto; }
.prose .pg-table { display: table; width: 100%; margin: 0.25rem 0 0; border-collapse: collapse; font-size: 0.75rem; white-space: nowrap; overflow: visible; }
.prose .pg-table th,
.prose .pg-table td { min-width: 0; padding: 0.3125rem 0.5rem; border: 1px solid var(--pg-line); text-align: right; vertical-align: middle; font-variant-numeric: tabular-nums; }
.prose .pg-table th { background: var(--pg-soft); color: var(--heading); font-weight: 600; }
.prose .pg-table th.pg-left,
.prose .pg-table td.pg-left { text-align: left; white-space: normal; }
.prose .pg-table tr.is-best td { background: rgba(196, 18, 48, 0.06); font-weight: 600; }
.prose .pg-table tr.pg-total td { background: var(--pg-soft); }
.prose .pg-dot-c { display: inline-block; width: 0.4375rem; height: 0.4375rem; margin-right: 0.375rem; border-radius: 50%; background: var(--c); }
.prose .pg-tag { display: inline-block; padding: 0 0.25rem; border-radius: 3px; background: #ececea; font-size: 0.5625rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
.prose .pg-note { margin-top: 0.5rem; font-size: 0.6875rem; color: var(--faint); }

@media (hover: none) {
  .prose .pg-tools { opacity: 1; }
}
@media (max-width: 600px) {
  .prose .pg-cols { display: none; }
  .prose .pg-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 'handle name tools' 's s q' 'io io io';
    row-gap: 0.375rem;
  }
  .prose .pg-handle { grid-area: handle; }
  .prose .pg-row .pg-name { grid-area: name; }
  .prose .pg-row .pg-tools { grid-area: tools; opacity: 1; }
  .prose .pg-row .pg-s { grid-area: s; }
  .prose .pg-row .pg-q { grid-area: q; width: 4.5rem; }
  .prose .pg-row .pg-io { grid-area: io; }
  .prose .pg-tiles { grid-template-columns: 1fr; }
  .prose .pg-workload { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .prose .pg *, .prose .pg-io-bar i { transition: none !important; }
}

/* ── hybrid-models playgrounds ─────────────────────── */
.prose .hp-models { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.prose .hp-model { padding: 0.625rem; border: 1px solid var(--pg-line); border-radius: 10px; background: var(--pg-soft); }
.prose .hp-model-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.prose .hp-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.prose .hp-desc { margin: 0 0 0.875rem; font-size: 0.8125rem; line-height: 1.55; color: var(--muted); }
.prose .hp-hint { font-size: 0.625rem; font-weight: 400; color: var(--faint); }
.prose .hp-grid { margin-bottom: 1rem; }
.prose .hp-work4 { grid-template-columns: repeat(4, 1fr); }
.prose .pg-error[hidden] { display: none; }
.prose .hp-controls { display: grid; grid-template-columns: 1fr 7rem 7rem; gap: 0.625rem 1rem; align-items: end; margin-bottom: 1rem; }
.prose .hp-slider .pg-range { width: 100%; margin: 0.375rem 0; }
.prose .hp-tiles { margin-bottom: 0.875rem; }
.prose .hp-split { margin: 0 0 0.25rem; }
.prose .hp-bar { display: flex; height: 0.875rem; overflow: hidden; border-radius: 999px; background: #eeeeec; }
.prose .hp-bar-ckpt { background: var(--red); transition: width 0.3s cubic-bezier(.2, .8, .2, 1); }
.prose .hp-bar-kv { background: #9aa0a6; transition: width 0.3s cubic-bezier(.2, .8, .2, 1); }
.prose .hp-bar-key { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.375rem; font-size: 0.6875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.prose .hp-bar-key span { display: inline-flex; align-items: center; gap: 0.3125rem; }
.prose .hp-sw { display: inline-block; width: 0.5625rem; height: 0.5625rem; border-radius: 2px; }
.prose .hp-sw-ckpt { background: var(--red); }
.prose .hp-sw-kv { background: #9aa0a6; }
.prose .hp-sw-line-h { width: 0.875rem; height: 3px; border-radius: 2px; background: var(--red); }
.prose .hp-sw-line-d { width: 0.875rem; height: 3px; border-radius: 2px; background: var(--heading); }
.prose .hp-line-h,
.prose .hp-line-d { fill: none; stroke-width: 2.25; stroke-linejoin: round; }
.prose .hp-line-h { stroke: var(--red); }
.prose .hp-line-d { stroke: var(--heading); }
.prose .hp-marker { stroke: #b9b9b6; stroke-width: 1; stroke-dasharray: 3 3; }
.prose .hp-dot-h { fill: var(--red); stroke: #fff; stroke-width: 1.5; }
.prose .hp-dot-d { fill: var(--heading); stroke: #fff; stroke-width: 1.5; }
@media (max-width: 600px) {
  .prose .hp-controls { grid-template-columns: 1fr; }
  .prose .hp-work4 { grid-template-columns: 1fr 1fr; }
  .prose .hp-models { grid-template-columns: 1fr; }
}

/* ── key-theme dashboard (agent-text-at-scale) ─────────────────────── */
.prose figure.figure-themes {
  width: min(45.25rem, calc(100vw - 3rem));
}
.prose .td {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  font-family: var(--body);
  font-size: 11px;
  line-height: 1.32;
  color: #344054;
  text-align: left;
}
@media (max-width: 640px) {
  .prose .td { grid-template-columns: 1fr; }
}
.prose .td-head {
  margin-bottom: 0.375rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--heading);
  text-align: center;
}
.prose .td-card {
  display: block;
  width: 100%;
  margin: 0 0 0.375rem;
  padding: 0.5rem;
  border: 1px solid #d0d5dd;
  border-radius: 5px;
  background: #fff;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.prose .td-row { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; }
.prose .td-th { font-weight: 600; color: var(--heading); }
.prose .td-n { color: #475467; font-weight: 500; white-space: nowrap; }
.prose .td-sum { display: block; }
.prose .td-sub { margin: 0.625rem 0 0.25rem; font-weight: 600; color: var(--heading); }
.prose .td-bars { display: grid; gap: 0.0625rem; }
.prose .td-bar {
  display: grid;
  grid-template-columns: 12rem 1fr 1.5rem;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.0625rem 0.125rem;
  border: 0;
  border-radius: 3px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.prose .td-track { height: 0.5rem; border-radius: 2px; background: #f2f4f7; }
.prose .td-fill { display: block; height: 100%; border-radius: 2px; background: #98a2b3; }
.prose .td-bn { text-align: right; color: #475467; font-weight: 500; }
.prose .td-card.is-active { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.prose .td-bar.is-active { background: #fff1f2; }
.prose .td-bar.is-active .td-fill { background: var(--red); }

/* ── questions ─────────────────────────────────────────── */
.questions h3 a { color: inherit; text-decoration: none; }
.questions h3 a:hover { color: var(--red); }
.question-item { margin-bottom: 1.75rem; }
.prose .question-sources { font-size: 0.875rem; color: var(--muted); }
.question-breadcrumb { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.5rem; }
.prose .question-guide { font-size: 0.875rem; }
