:root {
  --blue:  #254eff;
  --cream: #f8ecda;
  --ink:   #1a1a1a;
  --white: #ffffff;
  --muted: #5a554f;
  --rule:  #e2ddd4;
  --panel: #f4f2ee;

  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-md: 5px 5px 0 var(--ink);

  --maxw: 880px;
  --widew: min(1120px, 94vw);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.caution-bar {
  height: 11px;
  background: repeating-linear-gradient(45deg, #f5c518 0 16px, var(--ink) 16px 32px);
}
.page { max-width: var(--maxw); margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }

/* wide breakout for figure */
.bleed, .fig-hover-grid {
  position: relative; left: 50%; transform: translateX(-50%); width: var(--widew);
}

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 3rem; line-height: 1.04; font-weight: 700; color: var(--blue); margin: 0 0 0.6rem; }
h2 { font-size: 1.65rem; font-weight: 600; color: var(--blue); margin: 3.4rem 0 1rem; }
h3 { font-size: 1.2rem; font-weight: 600; color: var(--ink); margin: 2rem 0 0.6rem; }
p { margin: 0 0 1rem; text-wrap: pretty; }
a { color: var(--blue); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--blue); }
strong { font-weight: 500; }
em { font-style: italic; }
.muted { color: var(--muted); }
.brand { font-family: var(--font-heading); font-weight: 600; color: var(--blue); }
section { scroll-margin-top: 1rem; }
.section-label {
  display: inline-block;
  margin-right: 0.45rem;
  margin-bottom: 0.1rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--blue);
  color: var(--white);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.35;
}

/* ---------- Header ---------- */
.letterhead { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 2rem; }
.letterhead img { height: 44px; width: auto; }
.subtitle { font-family: var(--font-heading); font-size: 1.35rem; font-weight: 400; color: var(--ink); margin: 0 0 1.25rem; text-wrap: balance; }
.subtitle .smith { color: var(--blue); font-weight: 600; }
.authors { font-size: 1.05rem; margin: 0 0 0.5rem; }
.authors > a { font-weight: 400; }
.authors .aff { color: var(--muted); font-size: 0.95rem; }
.authors .status { color: var(--muted); font-size: 0.95rem; }
.authors .status-value { font-family: var(--font-body); font-weight: 300; color: var(--blue); }

.top-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.6rem 0 2.6rem; }
.top-links a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem;
  padding: 0.5rem 0.9rem; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink);
  box-shadow: var(--shadow-sm); transition: transform .06s ease, box-shadow .06s ease;
}
.top-links a:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-md); border-bottom-color: var(--ink); }
.top-links a:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.top-links .soon {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem;
  padding: 0.5rem 0.9rem; border: 1.5px dashed var(--muted); background: var(--panel); color: var(--muted);
  cursor: default;
}

/* ---------- Abstract ---------- */
.abstract { font-size: 1.08rem; }
details.abstract-full { margin-top: 1.4rem; }
details.abstract-full summary { cursor: pointer; font-family: var(--font-heading); font-weight: 600; color: var(--blue); list-style: none; }
details.abstract-full summary::-webkit-details-marker { display: none; }
details.abstract-full summary::before { content: "\25B8  "; }
details.abstract-full[open] summary::before { content: "\25BE  "; }
.abstract-box { background: var(--panel); padding: 1.1rem 1.3rem; margin-top: 1rem; }
.abstract-box p { font-size: 0.92rem; line-height: 1.7; color: var(--muted); margin: 0; }

/* ---------- Method figure + Tufte marginalia ---------- */
.method-figure { max-width: 760px; margin: 1.5rem auto 0; }
.method-figure img {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.method-figure figcaption { margin-top: 0.75rem; font-size: 0.9rem; line-height: 1.3; letter-spacing: 0; color: var(--muted); }

.fig-hover-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.75rem; align-items: start; margin-top: 1.5rem; }
.fig-hover-wrap { position: relative; line-height: 0; }
.fig-hover-wrap img { width: 100%; height: auto; display: block; }
.hot { position: absolute; display: block; cursor: help; border-radius: 4px; transition: background .1s ease, box-shadow .1s ease; }
.hot:hover, .hot.is-active { background: rgba(37,78,255,0.10); box-shadow: 0 0 0 2px var(--blue); }
.marginalia { font-size: 0.9rem; line-height: 1.55; border-left: 3px solid var(--blue); padding-left: 1rem; }
.marginalia .hint { color: var(--muted); font-style: italic; margin: 0; }
.marginalia h4 { font-family: var(--font-heading); color: var(--blue); margin: 0 0 0.4rem; font-size: 1.05rem; }
.marginalia .tn-label { font-weight: 700; }
.marginalia p { margin: 0 0 0.6rem; }
.marginalia code { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink); word-break: break-word; }

/* ---------- Trajectory viewer ---------- */
.toggle-block { display: flex; align-items: center; gap: 0.75rem; margin: 0.4rem 0; flex-wrap: wrap; }
.toggle-label { font-family: var(--font-heading); font-weight: 600; font-size: 0.85rem; color: var(--muted); min-width: 118px; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn {
  font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem;
  padding: 0.4rem 0.8rem; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .06s ease, box-shadow .06s ease;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn.is-active { background: var(--blue); color: var(--white); }

.traj-seed { font-size: 0.95rem; background: var(--cream); border: 1.5px solid var(--ink); padding: 0.75rem 1rem; margin: 1.1rem 0 1rem; box-shadow: var(--shadow-sm); }
.traj-seed .label { font-family: var(--font-heading); font-weight: 700; color: var(--blue); }
.traj-source { display: block; margin-top: 0.35rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.traj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.traj-panel { border: 1.5px solid var(--ink); box-shadow: var(--shadow-md); background: var(--white); display: flex; flex-direction: column; min-width: 0; }
.traj-panel h3 { margin: 0; padding: 0.6rem 0.9rem; border-bottom: 1.5px solid var(--ink); font-family: var(--font-heading); color: var(--blue); background: var(--white); }
.traj-scroll { padding: 0.9rem; max-height: 560px; overflow-y: auto; }

.step { border: 1px solid var(--ink); margin-bottom: 0.6rem; }
.step-title { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 700; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--ink); }
.step-body { padding: 0.55rem 0.7rem; font-size: 0.86rem; white-space: pre-wrap; word-break: break-word; }
.step.thinking .step-title { background: var(--cream); color: var(--ink); }
.step.tool-call .step-title { background: var(--blue); color: var(--white); }
.step.tool-call .step-body { font-family: var(--font-mono); font-size: 0.8rem; color: var(--blue); }
.step.tool-result .step-title { background: #ece8e1; color: var(--ink); }

.msg { max-width: 88%; padding: 0.55rem 0.85rem; margin-bottom: 0.55rem; border-radius: 16px; font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--blue); color: var(--white); margin-left: auto; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--cream); color: var(--blue); margin-right: auto; border-bottom-left-radius: 4px; }

/* ---------- Results tables ---------- */
.table-scroll { overflow-x: auto; margin: 1.4rem 0; width: 100%; }
table.results {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
table.results caption {
  caption-side: top;
  text-align: left;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.7rem;
}
table.results th, table.results td {
  border: 0;
  padding: 0.34rem 0.42rem;
  text-align: center;
  white-space: nowrap;
}
table.results thead th {
  background: transparent;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
table.results thead th:first-child, table.results tbody td:first-child { text-align: left; }
table.results tr.ours { background: rgba(37,78,255,0.09); }

/* ---------- Charts (no box) ---------- */
.chart-panel { width: 100%; }
.chart-panel.chart-panel-narrow { max-width: 760px; margin: 0 auto; }
.chart-panel.chart-panel-square { max-width: 560px; margin: 0 auto; aspect-ratio: 1.08 / 1; }
.chart-panel.chart-panel-square .chart-mount { height: 100%; }
.chart-mount { width: 100%; height: 430px; }
.chart-mount.chart-mount-heatmap { height: 100%; }
.wrapfig-right {
  float: right;
  width: min(46%, 420px);
  margin: 0.1rem 0 0.8rem 1.2rem;
}
.wrapfig-right .chart-mount { height: 360px; }
.wrapfig-right .chart-caption { margin: 0.5rem 0 0.2rem; font-size: 0.86rem; }
.clear-float { clear: both; }
.chart-note {
  max-width: 760px;
  margin: 0.2rem auto 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.chart-caption { font-size: 0.9rem; color: var(--muted); margin: 0.6rem 0 2.2rem; }

/* ---------- Citation ---------- */
.citation { position: relative; }
.citation pre {
  background: var(--panel); color: var(--ink);
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.55;
  padding: 1.1rem; overflow-x: auto; border: 1.5px solid var(--ink); box-shadow: var(--shadow-sm); margin: 0;
}
.copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.8rem;
  padding: 0.3rem 0.7rem; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink); cursor: pointer;
}
.copy-btn:hover { background: var(--blue); color: var(--white); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: 0.9rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .fig-hover-grid { grid-template-columns: 1fr; }
  .wrapfig-right { float: none; width: 100%; margin: 0.6rem 0; }
  .wrapfig-right .chart-mount { height: 320px; }
}
@media (max-width: 720px) {
  h1 { font-size: 2.2rem; }
  .traj-grid { grid-template-columns: 1fr; }
  .page { padding: 2rem 1.1rem 4rem; }
}
