/* ==================================================================
   Personal site stylesheet
   - Colors are tokens on :root; dark mode overrides them via
     <html data-theme="dark"> (toggled by script.js).
   - Change --accent to recolor the whole site.
   ================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --text: #000000;
  --text-muted: #525252;
  --text-faint: #868686;
  --accent: #c2571a;
  --accent-fill: #e8892f;
  --accent-soft: #fbe4d3;
  --card: #fafafa;
  --border: #e5e5e5;
  --border-strong: #cfcfcf;
  --sans: 'Geist', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 2px;
  --max-width: 880px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-alt: #0f0f0f;
  --text: #ffffff;
  --text-muted: #a6a6a6;
  --text-faint: #7a7a7a;
  --accent-soft: #1f0e04;
  --card: #0f0f0f;
  --border: #262626;
  --border-strong: #3d3d3d;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  font-size: 15px;
  letter-spacing: 0.003em;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
}

/* ---------- Fixed buttons (theme toggle, back to top) ---------- */
.fab {
  position: fixed;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-right-width: 2px;
  border-bottom-width: 2px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 0;
}
.fab:hover { color: var(--accent); border-color: var(--border-strong); }
.fab svg { width: 18px; height: 18px; }

#theme-toggle { top: 1rem; }
#icon-moon { display: none; }
[data-theme="dark"] #icon-sun { display: none; }
[data-theme="dark"] #icon-moon { display: block; }

#back-to-top {
  bottom: 1rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
#back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ---------- Hero (home page) ---------- */
.hero {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}

.hero-text { flex: 1 1 auto; min-width: 0; }

.hero-text h1,
.blog-header h1 {
  font-size: 42px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.blog-header { margin-bottom: 2.5rem; }
.blog-header h1 a { color: var(--text); text-decoration: none; }
.blog-header h1 a:hover { color: var(--accent); }

.blog-link {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--accent);
  text-decoration: none;
  vertical-align: middle;
  margin-left: 0.5rem;
}
.blog-link:hover { text-decoration: underline; }

.tagline {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 13px;
}

.intro {
  font-size: 15px;
  line-height: 22px;
  max-width: 60ch;
  margin: 0 0 1.25rem;
}
.intro a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.intro a:hover { text-decoration: underline; }


.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}
.links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-right-width: 2px;
  border-bottom-width: 2px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.links a:hover { color: var(--accent); border-color: var(--border-strong); }
.links .soon {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
}

.hero-photo { flex: 0 0 auto; }
.hero-photo img {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

/* ---------- Sections ---------- */
section { margin-bottom: 3rem; }

h1, h2, h3 { font-weight: 500; }

h2 {
  font-size: 24px;
  line-height: 32px;
  letter-spacing: -0.017em;
  margin: 0 0 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-strong);
}

p { margin: 0 0 1rem; }

/* ---------- Publications ---------- */
.pub {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.pub:last-child { border-bottom: none; }

.pub-thumb {
  flex: 0 0 auto;
  width: 128px;
  height: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pub-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.pub-body { min-width: 0; }
.pub-body h3 {
  margin: 0 0 0.35rem;
  font-size: 15px;
  line-height: 22px;
  letter-spacing: -0.003em;
}
.pub-authors, .pub-venue { margin: 0 0 0.3rem; font-size: 13px; line-height: 20px; }
.pub-authors strong { font-weight: 600; }
.pub-venue { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }
.pub-abstract { font-size: 13px; line-height: 20px; color: var(--text-muted); margin-bottom: 0.5rem; }
.pub-links a { color: var(--accent); text-decoration: none; font-family: var(--mono); font-size: 12px; }
.pub-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.pub-links .pub-sep { color: var(--border-strong); font-size: 12px; margin: 0 0.2rem; }

/* ---------- Blog index ---------- */
.post {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.post:last-child { border-bottom: none; padding-bottom: 0; }

.post-date {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
.post h3 { margin: 0 0 0.3rem; font-size: 15px; line-height: 22px; }
.post h3 a { color: var(--text); text-decoration: none; }
.post h3 a:hover { color: var(--accent); }
.post-excerpt {
  margin: 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-muted);
}

.post-card-authors { margin-top: 0.75rem; gap: 1rem; }
.post-card-authors .post-meta-avatar { width: 26px; height: 26px; }
.post-card-authors .post-meta-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- Post page ---------- */
.post-page {
  max-width: 700px;
  margin: 0 auto;
  counter-reset: figure;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
}
.back-link:hover { text-decoration: underline; }

.post-title {
  font-size: 42px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
}

.post-meta { margin: 0 0 2rem; }

.post-meta-authors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}
.post-meta-author {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
}
.post-meta-author:hover .post-meta-name { color: var(--accent); }
.post-meta-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  display: block;
}
.post-meta-avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.post-card-authors .post-meta-avatar--initials { font-size: 9px; }

.post-meta-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.post-page .post-date { margin: 0.75rem 0 0; font-size: 12px; color: var(--text-faint); }
.post-readtime { margin-left: 0.6rem; }

.post-eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 0.75rem;
}
.post-page .post-dek {
  font-size: 19px;
  line-height: 28px;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}
.post-meta-name sup { font-size: 10px; color: var(--text-faint); margin-left: 1px; }
.post-page .post-affil {
  margin: 0.75rem 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-faint);
}
.post-affil sup { font-size: 10px; }
.post-affil span { white-space: nowrap; }
.post-affil a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.post-affil a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.post-links { margin-top: 1rem; }

/* One-sentence kicker under a section heading */
.post-page .kicker {
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
  margin: -0.25rem 0 1.25rem;
}

/* Display math without a math library */
.post-page .math {
  text-align: center;
  font-size: 17px;
  margin: 1.25rem 0;
  overflow-x: auto;
}
.post-page .katex-display { margin: 0; }
.post-page .katex { font-size: 1.08em; }
@media (max-width: 480px) {
  .post-page .math .katex { font-size: 0.92em; }
}
.post-page var { font-style: italic; font-family: inherit; }

/* Notation, folded under the formula until the reader opens it */
.post-page .notation {
  margin: 0.25rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.post-page .notation summary {
  padding: 0.55rem 1.1rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
}
.post-page .notation summary::-webkit-details-marker { display: none; }
.post-page .notation summary::before { content: "+"; display: inline-block; width: 1rem; color: var(--accent); }
.post-page .notation[open] summary::before { content: "\2212"; }
.post-page .notation summary:hover { color: var(--text); }
.post-page .notation summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.post-page .notation dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.1rem;
  margin: 0;
  padding: 0.2rem 1.1rem 0.9rem;
  font-size: 14px;
  line-height: 20px;
}
.post-page .notation dt { margin: 0; color: var(--text); white-space: nowrap; }
.post-page .notation dd { margin: 0; color: var(--text-muted); }
@media (max-width: 520px) {
  .post-page .notation dl { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .post-page .notation dd { margin-bottom: 0.45rem; }
}

/* Body text */
.post-page p { font-size: 16px; line-height: 1.65; }
.post-page p > a,
.post-page li > a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.post-page p > a:hover,
.post-page li > a:hover { text-decoration: underline; }

.post-page ul, .post-page ol {
  font-size: 16px;
  line-height: 1.65;
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}
.post-page li { margin: 0.3rem 0; }

.post-page h2 { font-size: 24px; margin: 3rem 0 1rem; }
.post-page h3 { font-size: 16px; margin: 1.75rem 0 0.75rem; }

.post-page blockquote {
  margin: 1.5rem 0;
  padding: 0.3rem 1.25rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
}
.post-page blockquote p:last-child { margin-bottom: 0; }

/* Code */
.post-page code { font-family: var(--mono); font-size: 0.92em; }
.post-page :not(pre) > code {
  padding: 0.1em 0.35em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.post-page pre {
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 20px;
}
.post-page pre code { padding: 0; background: none; border: none; font-size: inherit; }

/* Figures */
.post-page figure {
  margin: 2.5rem 0;
  counter-increment: figure;
}
/* Headline figure, placed right after the table of contents */
.post-page figure.figure--lead { margin: 0 0 2.5rem; }
.post-page .figure-card {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fafafa;
}
[data-theme="dark"] .post-page .figure-card {
  background: #f2f2f2;
  border-color: var(--border-strong);
}
.post-page figure svg { width: 100%; height: auto; display: block; }
.figure-card--scroll { overflow-x: auto; }
@media (max-width: 640px) {
  .figure-card--scroll svg { min-width: 640px; }
}
.post-page figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}
.post-page figcaption {
  margin-top: 0.75rem;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-muted);
}
.post-page figcaption::before {
  content: "Figure " counter(figure) " ";
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin-right: 0.35rem;
}

/* Several images side by side inside one figure card */
.figure-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.post-page .figure-grid img { width: 100%; height: auto; }
@media (max-width: 560px) {
  .figure-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------
   Interactive charts, tooltips, and animation controls (figures.js).
   Figure cards stay light in both themes, so chart colours are fixed.
   ------------------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.chart { color: #1a1a1a; font-family: var(--sans); }
.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.6rem;
}
.chart-ylabel { font-size: 12px; font-weight: 500; color: #525252; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.15rem 0.35rem; margin-left: auto; }
.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem;
  font: 500 12px/1 var(--sans);
  color: #1a1a1a;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.chart-key:hover { border-color: #cfcfcf; background: #ffffff; }
.chart-key:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-key[aria-pressed="false"] { color: #8a8a8a; text-decoration: line-through; }
.chart-key[aria-pressed="false"] .chart-swatch { opacity: 0.3; }
.post-page figure .chart-swatch,
.chart-swatch { width: 22px; height: 12px; flex: none; display: inline-block; }
.chart-stage { position: relative; }
.chart-stage > svg { display: block; width: 100%; height: auto; overflow: visible; }
.post-page .chart-note, .chart-note { margin: 0.6rem 0 0; font-size: 12px; line-height: 18px; color: #6a6a6a; }

.chart text { font-family: var(--sans); }
.chart-tick { font-size: 11px; fill: #5c5c5c; font-variant-numeric: tabular-nums; }
.chart-xlab { font-size: 11.5px; fill: #333333; }
.chart-title { font-size: 12.5px; font-weight: 600; fill: #1a1a1a; }
.chart-sub { font-size: 11.5px; fill: #5c5c5c; }
.chart-axis-label { font-size: 11.5px; fill: #5c5c5c; }
.chart-val { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-gain { font-size: 13px; font-weight: 600; fill: #3a62ad; }
.chart-end { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-grid { stroke: #dcdcdc; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-base { stroke: #1a1a1a; stroke-width: 1; }
.chart-err { fill: none; stroke: #1a1a1a; stroke-width: 1.3; }
.chart-ref { stroke: #8a8a8a; stroke-width: 1.2; stroke-dasharray: 2 3; }
.chart-guide { stroke: #1a1a1a; stroke-width: 1; opacity: 0; }
.chart-guide.is-on { opacity: 0.3; }
.chart-hit { fill: transparent; outline: none; }
.chart-hit:focus-visible { stroke: var(--accent); stroke-width: 1.5; }
.chart-band { fill: #000000; opacity: 0; transition: opacity 0.12s ease; }
.chart-group.is-active .chart-band { opacity: 0.05; }
.chart-bar, .chart-err, .chart-val { transition: opacity 0.12s ease; }
svg.is-hovering .chart-group:not(.is-active) .chart-bar,
svg.is-hovering .chart-group:not(.is-active) .chart-err,
svg.is-hovering .chart-group:not(.is-active) .chart-val { opacity: 0.4; }
.chart-line--thin { opacity: 0.55; }
.chart-frontier { fill: none; stroke: #1a1a1a; stroke-width: 1.2; stroke-dasharray: 5 4; opacity: 0.45; }
.chart-pt-tag { font-size: 10.5px; font-weight: 600; }
.chart-dot, .chart-raw {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.chart-dot.is-active { transform: scale(1.5); }
.chart-raw { opacity: 0.38; }
.chart-raw.is-active { opacity: 1; transform: scale(1.45); }

.chart--enter .chart-bar {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: chart-grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.chart--enter .chart-err,
.chart--enter .chart-val,
.chart--enter .chart-gain { animation: chart-fade 0.4s 0.55s both; }
.chart--enter .chart-line,
.chart--enter .chart-dot,
.chart--enter .chart-raw,
.chart--enter .chart-frontier,
.chart--enter .chart-pt-tag { animation: chart-fade 0.7s both; }
@keyframes chart-grow { from { transform: scaleY(0); } }
@keyframes chart-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .chart--enter * { animation: none !important; }
}

.chart-tip {
  position: absolute;
  left: 0; top: 0;
  z-index: 5;
  min-width: 150px;
  max-width: 270px;
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.4;
  color: #ffffff;
  background: #1b1c1f;
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.chart-tip-title { font-weight: 600; margin-bottom: 0.3rem; }
.chart-tip-note { margin: -0.2rem 0 0.35rem; font-size: 11.5px; color: #b9bcc2; }
.chart-tip-row { display: flex; align-items: center; gap: 0.45rem; }
.chart-tip-label { color: #d9dbdf; }
.chart-tip-value { margin-left: auto; padding-left: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip-detail { margin: 0 0 0.25rem 1.85rem; font-size: 11px; color: #a4a8af; }
.chart-tip-line { color: #d9dbdf; }
.chart-tip-foot { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid #3a3c41; font-weight: 600; }

/* Steps chart: the panel that walks through the run, one batch of evaluations at a time */
.chart-batch-band { fill: #2f5fa8; opacity: 0.09; pointer-events: none; }
.chart-batches { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid #e3e3e3; }
.chart-batches-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}
.chart-batches-title { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.chart-batches-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chart-batch-btn {
  min-width: 1.9rem;
  padding: 0.35rem 0.3rem;
  font: 500 11.5px/1 var(--mono);
  color: #525252;
  background: #ffffff;
  border: 1px solid #d6d6d6;
  border-radius: var(--radius);
  cursor: pointer;
}
.chart-batch-btn:hover { color: #1a1a1a; border-color: #8a8a8a; }
.chart-batch-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-batch-btn[aria-pressed="true"] { color: #ffffff; background: #2f5fa8; border-color: #2f5fa8; }
.chart-batches-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; align-items: start; }
@media (max-width: 640px) {
  .chart-batches-body { grid-template-columns: 1fr; }
}
.post-page .chart-arm-title, .chart-arm-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
  font-size: 12.5px;
  font-weight: 600;
  color: #1a1a1a;
}
.chart-arm-title small { font-size: 11.5px; font-weight: 400; color: #6a6a6a; }
.hcard {
  margin-bottom: 0.45rem;
  padding: 0.6rem 0.7rem;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
}
.hcard.is-best { border-color: #1f8f4e; box-shadow: inset 3px 0 0 #1f8f4e; }
.hcard-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.hcard-score { font-size: 15px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: #1a1a1a; }
.hcard-badge {
  display: inline-block;
  padding: 0.22rem 0.42rem;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  color: #525252;
  background: #ffffff;
  border: 1px solid #cfcfcf;
  border-radius: 999px;
  white-space: nowrap;
}
.hcard-badge--pick { color: #ffffff; background: #2f5fa8; border-color: #2f5fa8; }
.hcard-badge--adapted { color: #2f5fa8; background: #eef3fb; border-color: #9fb7dd; }
.hcard-badge--best { color: #ffffff; background: #1f8f4e; border-color: #1f8f4e; }
.hcard-name { margin-top: 0.45rem; font: 500 12px/1.3 var(--mono); color: #1a1a1a; overflow-wrap: anywhere; }
.post-page .hcard-what, .hcard-what { margin: 0.25rem 0 0; font-size: 12.5px; line-height: 1.45; color: #333333; }
.hcard-parent { margin-top: 0.3rem; font-size: 11.5px; line-height: 1.4; color: #6a6a6a; overflow-wrap: anywhere; }
.post-page .chart-batches-key, .chart-batches-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.6rem 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: #5c5c5c;
}

/* Tabs above a figure card: one panel at a time */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-bottom: 0.5rem; }
.tabs-label { margin-right: 0.35rem; font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.tabs [role="tab"] {
  padding: 0.4rem 0.85rem;
  font: 500 12.5px/1 var(--sans);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.tabs [role="tab"]:hover { color: var(--text); border-color: var(--border-strong); }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabs [role="tab"][aria-selected="true"] { color: #ffffff; background: #2f5fa8; border-color: #2f5fa8; }
.tabpanel[hidden] { display: none; }

/* Animated figures: playback controls sit under the card; details appear on hover. */
.post-page figure.has-tips { position: relative; }
svg.has-player { cursor: pointer; }
svg[data-dur] [data-tip] { cursor: default; }
svg[data-dur] .tip-hit { stroke: transparent; stroke-width: 12; fill: none; }
svg[data-dur] .is-tipped > rect { stroke: #2f5fa8; stroke-width: 2; }
svg[data-dur] .is-tipped > line:not(.tip-hit) { stroke: #2f5fa8; stroke-width: 2.2; }
.player {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--card);
}
[data-theme="dark"] .player { border-color: var(--border-strong); }
.player-row { display: flex; align-items: center; gap: 0.6rem; }
.player-btn {
  min-width: 4rem;
  padding: 0.4rem 0.6rem;
  font: 500 12px/1 var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.player-btn:hover { color: var(--accent); border-color: var(--accent); }
.player-btn:focus-visible,
.player-chip:focus-visible,
.player-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.player-range { flex: 1; min-width: 0; accent-color: var(--accent); }
.player-clock {
  min-width: 5.8rem;
  text-align: right;
  white-space: nowrap;
  font: 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.player-stages { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; }
.player-stages:first-child { margin-top: 0; }
.player-chip {
  padding: 0.35rem 0.65rem;
  font: 500 11.5px/1 var(--sans);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.player-chip:hover { color: var(--text); border-color: var(--border-strong); }
.player-chip.is-current { color: #ffffff; background: #2f5fa8; border-color: #2f5fa8; }
@media (max-width: 480px) {
  .player-row { flex-wrap: wrap; }
  .player-range { order: 3; flex-basis: 100%; }
  .player-clock { margin-left: auto; }
}

/* Tables */
.post-page .table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.post-page table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 420px;
}
.post-page th, .post-page td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.post-page thead th {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--text-faint);
  font-size: 12px;
  background: var(--bg-alt);
}
.post-page td:last-child, .post-page th:last-child { text-align: right; }
.post-page tr:last-child td { border-bottom: none; }
.post-page .table-num td:not(:first-child),
.post-page .table-num th:not(:first-child) { text-align: right; }
.post-page .table-num-2 td:nth-child(n+3),
.post-page .table-num-2 th:nth-child(n+3) { text-align: right; }
.post-page td.c, .post-page th.c { text-align: center; }
.post-page tr.highlight td {
  color: var(--accent);
  font-weight: 500;
  background: var(--accent-soft);
}

/* BibTeX block with a copy button */
.bibtex { position: relative; }
.post-page .bibtex-label {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
.post-page .bibtex-label + .bibtex pre { margin-top: 0; }
.bibtex pre { padding-right: 4.5rem; }
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--mono);
  font-size: 11px;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-right-width: 2px;
  border-bottom-width: 2px;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.copy-btn:hover { color: var(--accent); border-color: var(--border-strong); }

/* Table of contents */
.post-toc {
  margin: 0 0 2.5rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.post-toc-title {
  margin: 0 0 0.6rem;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-faint);
}
.post-page .post-toc ol {
  margin: 0;
  padding: 0 0 0 1.2rem;
  font-size: 15px;
}
.post-toc li { margin: 0.35rem 0; }
.post-toc li::marker { font-family: var(--mono); font-size: 13px; color: var(--text-faint); }
.post-page .post-toc a { color: var(--text); text-decoration: none; font-weight: 400; }
.post-page .post-toc a:hover { color: var(--accent); text-decoration: underline; }

/* Citations and the reference list */
.post-page .cite { font-size: 0.8em; color: var(--text-muted); white-space: nowrap; }
.post-page .cite a { color: var(--accent); text-decoration: none; font-weight: 500; }
.post-page .cite a:hover { text-decoration: underline; }
.post-page .references { padding-left: 1.6rem; font-size: 13.5px; line-height: 21px; color: var(--text-muted); }
.post-page .references li { margin: 0 0 0.5rem; padding-left: 0.2rem; }
.post-page .references li::marker { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.post-page .references li:target { background: var(--accent-soft); color: var(--text); }
.post-page .references em { font-style: normal; color: var(--text); }
.post-page .references a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.post-page .references a:hover { text-decoration: underline; }

/* Sidenotes (expand inline; float to the right margin on wide screens) */
.sidenote-wrap { position: relative; }

.post-page .sidenote-ref {
  all: unset;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent-fill);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  border-radius: var(--radius);
  padding: 0 1px;
  transition: background 0.2s ease, color 0.2s ease;
}
.post-page .sidenote-ref::after {
  content: "+";
  display: inline-block;
  margin-left: 2px;
  font-family: var(--mono);
  font-size: 0.7em;
  font-weight: 500;
  vertical-align: super;
  line-height: 0;
  color: var(--accent);
  transition: transform 0.25s ease;
}
.post-page .sidenote-ref:hover,
.post-page .sidenote-ref[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.post-page .sidenote-ref[aria-expanded="true"]::after { transform: rotate(45deg); }
.post-page .sidenote-ref:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sidenote {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.35s ease, opacity 0.3s ease, margin 0.35s ease;
}
.sidenote.open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-bottom: 1.25rem;
}
.sidenote-inner { overflow: hidden; }
.sidenote-body {
  padding: 0.9rem 1.1rem;
  border-left: 2px solid var(--accent);
  background: var(--card);
  color: var(--text-muted);
}
.sidenote-label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}
.post-page .sidenote-body p { margin: 0; font-size: 13px; line-height: 20px; }
.post-page .sidenote-body p + p { margin-top: 0.7rem; }
.post-page .sidenote-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0.4rem 0 0;
  font-size: 13px;
  line-height: 20px;
}
.post-page .sidenote-body dt { font-weight: 600; color: var(--text); }
.post-page .sidenote-body dd { margin: 0; }

@media (min-width: 1240px) {
  .sidenote {
    position: absolute;
    top: 0;
    left: calc(100% + 2rem);
    width: 230px;
    transform: translateX(-8px);
    transition: grid-template-rows 0.35s ease, opacity 0.3s ease, transform 0.35s ease;
  }
  .sidenote.open { transform: none; margin-bottom: 0; }
  .sidenote-body { border-left: none; border-top: 2px solid var(--accent); }

  /* Long notes stay inline even on wide screens */
  .sidenote.sidenote--wide { position: static; width: auto; transform: none; }
  .sidenote.sidenote--wide.open { margin-bottom: 1.25rem; }
  .sidenote--wide .sidenote-body { border-top: none; border-left: 2px solid var(--accent); }
}

/* Author card at the end of a post */
.post-author-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 3.5rem 0 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.post-author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  display: block;
}
.post-author-name { margin: 0 0 0.25rem; font-size: 15px; font-weight: 500; }
.post-page .post-author-bio {
  margin: 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-muted);
}
.post-author-bio a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.post-author-bio a:hover { text-decoration: underline; }
.post-author-bio a + a { margin-left: 0.6rem; }

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 20;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding-top: 4.5rem; }
  .hero { flex-direction: column-reverse; align-items: flex-start; }
  .hero-photo img { width: 140px; height: 140px; }
  .hero-text h1, .blog-header h1, .post-title { font-size: 32px; }
  .pub { flex-direction: column; }
  .pub-thumb { width: 100%; height: 96px; justify-content: flex-start; }
  .post { flex-direction: column; }
  .post-author-card { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidenote, .post-page .sidenote-ref::after, #back-to-top, body { transition: none; }
}
