.paper-page body,
body.paper-page {
  background: var(--white);
}

.paper-main {
  padding-top: 60px;
}

.paper {
  max-width: 680px;
  margin: 0 auto;
  padding: 5rem 2rem 8rem;
}

.paper-header {
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.paper-header h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.paper-subtitle {
  font-size: 0.95rem;
  color: var(--gray);
  margin: 0;
}

.paper-body h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2.75rem;
  margin-bottom: 0.9rem;
}

.paper-body p {
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--prose);
  margin-bottom: 1.25rem;
  max-width: none;
}

.paper-body strong {
  font-weight: 600;
  color: var(--black);
}

/* Lists are body copy, so they take a paragraph's size, rhythm and colour
   rather than the larger browser default. */
.paper-body ul,
.paper-body ol {
  margin: 0 0 1.25rem 1.5rem;
}

.paper-body li {
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--prose);
  margin-bottom: 0.45rem;
}

.paper-body li:last-child {
  margin-bottom: 0;
}

/* One line of takeaway above a figure, so the reader knows what the chart
   claims before reading it rather than after. */
.paper-body .fig-lead {
  margin: 2rem 0 0.75rem;
  font-size: 0.97rem;
  line-height: 1.6;
  font-weight: 600;
  color: var(--black);
}

.bench-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0 1.25rem;
  font-size: 0.9rem;
}

.bench-table th,
.bench-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.bench-table th {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray);
  border-bottom: 1px solid var(--black);
}

.bench-table td {
  color: var(--prose);
}

.bench-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bench-table tbody tr:last-child td {
  border-bottom: 1px solid var(--black);
}

.bench-note {
  font-size: 0.83rem !important;
  line-height: 1.6 !important;
  color: var(--gray) !important;
}

@media (max-width: 640px) {
  .bench-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.paper-body code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: var(--black);
}

/* CONTENTS RAIL

   Built by paper-nav.js and parked in the margin beside the article. Only
   shown when there is genuinely room for it — the article column is 680px
   and centred, so below ~1180px the margin is too narrow and it would
   crowd the prose. */

.paper-toc {
  display: none;
}

@media (min-width: 1180px) {
  .paper-toc {
    display: block;
    position: fixed;
    top: 8.5rem;
    left: 2.5rem;
    width: 15rem;
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
  }
}

.paper-toc-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 0.9rem;
}

.paper-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.paper-toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.85rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  /* The rail is UI, not prose, so it takes the body face. */
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--gray);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.paper-toc a:hover {
  color: var(--black);
}

.paper-toc a[aria-current] {
  color: var(--black);
  border-left-color: var(--black);
}

/* KEEP READING */

.more-research {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 2rem 5rem;
}

.more-research .label {
  margin-bottom: 1.25rem;
}

.more-research .paper-list {
  margin: 0;
}

.more-research-all {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--gray);
  text-decoration: none;
  transition: color 0.2s;
}

.more-research-all:hover {
  color: var(--black);
}

/* FIGURES

   Drawn against the theme tokens rather than baked colours, so they invert
   with the page and need none of the light-panel handling the imported
   charts require. */

.figure {
  margin: 2.75rem 0 2.25rem;
}

.figure .fig {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.figure figcaption {
  margin-top: 1.1rem;
  font-size: 0.83rem;
  line-height: 1.6;
  color: var(--gray);
}

.fig-head {
  font-size: 10px;
  letter-spacing: 0.1em;
  fill: var(--gray);
}

.fig-case {
  font-size: 14px;
  font-weight: 600;
  fill: var(--fg);
}

.fig-gloss {
  font-size: 11.5px;
  fill: var(--gray);
}

.fig-mech {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  fill: var(--fg);
}

.fig-track {
  fill: none;
  stroke: var(--fg);
  stroke-opacity: 0.45;
  stroke-width: 1.5;
}

/* The barrier is the point of the figure, so it is the heaviest mark. */
.fig-barrier {
  stroke: var(--fg);
  stroke-width: 3;
  stroke-linecap: round;
}

.fig-blocked,
.fig-ghost {
  fill: none;
  stroke: var(--gray);
  stroke-opacity: 0.4;
  stroke-width: 1.2;
  stroke-dasharray: 3 4;
}

.fig-x {
  fill: none;
  stroke: var(--gray);
  stroke-opacity: 0.65;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.fig-none {
  font-size: 12px;
  font-style: italic;
  fill: var(--gray);
}

.cap-table td:first-child {
  white-space: nowrap;
}

/* BAR CHART (inside .figure, so it themes with the page) */

.bar {
  fill: var(--fg);
  fill-opacity: 0.72;
}

/* The one result that came out faster reads as an outline, so it is legible
   as the exception without implying it is a win. */
.bar-neg {
  fill: none;
  stroke: var(--fg);
  stroke-opacity: 0.5;
  stroke-width: 1.2;
}

.bar-grid {
  stroke: var(--fg);
  stroke-opacity: 0.12;
  stroke-width: 1;
}

.bar-zero {
  stroke: var(--fg);
  stroke-opacity: 0.55;
  stroke-width: 1.4;
}

.bar-sep {
  stroke: var(--fg);
  stroke-opacity: 0.14;
  stroke-width: 1;
}

.bar-label {
  font-size: 11.5px;
  fill: var(--fg);
  fill-opacity: 0.85;
}

.bar-val,
.bar-tick {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 10.5px;
  fill: var(--gray);
}

/* ARTICLE FIGURES — callouts, legends and chart furniture, all on tokens */

.fig-callout {
  margin: 2rem 0;
  padding: 1.4rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.fig-callout-title {
  display: block;
  margin-bottom: 0.7rem;
  font-weight: 600;
  color: var(--accent);
}

.fig-callout p {
  margin: 0 0 0.6rem;
  font-size: 0.92rem !important;
  color: var(--prose) !important;
}

.fig-callout p:last-child {
  margin-bottom: 0;
}

.fig-callout .warn {
  color: var(--accent) !important;
}

.epss {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: center;
}

.epss-score {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.epss-score span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.12em;
}

.epss-gloss {
  margin: 0 !important;
  font-size: 0.9rem !important;
  color: var(--gray) !important;
}

/* Percentile strip. The whole point is the needle sitting hard against the
   left edge, so the track carries the "everything above" shading rather than
   the other way round. */
.epss-strip {
  display: block;
  width: 100%;
  height: auto;
  margin: 1.5rem 0 0.25rem;
}

.epss-track {
  fill: var(--fg);
  fill-opacity: 0.09;
}

.epss-above {
  fill: var(--fg);
  fill-opacity: 0.16;
}

.epss-needle {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.epss-here {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 10.5px;
  fill: var(--accent);
}

.epss-axis,
.epss-above-label {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 10px;
  fill: var(--gray);
}

.epss-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1.4rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.epss-col p {
  margin: 0.45rem 0 0 !important;
  font-size: 0.92rem !important;
  color: var(--prose) !important;
}

.epss-tag {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
}

.epss-col-actual .epss-tag,
.epss-col-actual p {
  color: var(--accent) !important;
}

.epss-foot {
  margin: 1.2rem 0 0 !important;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.88rem !important;
  color: var(--gray) !important;
}

@media (max-width: 620px) {
  .epss-split { grid-template-columns: 1fr; }
}

.fig-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.6rem;
  margin-top: 1.1rem;
  font-size: 0.86rem;
  color: var(--gray);
}

.fig-legend span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fig-legend i {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.key-1 { color: var(--s1); }
.key-2 { color: var(--s2); }
.key-3 { color: var(--s3); }

.ser-1, .ser-2, .ser-3 { fill: none; }

.ser-1 { stroke: var(--s1); }
.ser-2 { stroke: var(--s2); }
.ser-3 { stroke: var(--s3); }

.ser-fill-1 { fill: var(--s1); }
.ser-fill-2 { fill: var(--s2); }
.ser-fill-3 { fill: var(--s3); }

.fig-axis {
  fill: none;
  stroke: var(--fg);
  stroke-opacity: 0.25;
  stroke-width: 1;
}

.fig-rule {
  fill: none;
  stroke: var(--fg);
  stroke-opacity: 0.1;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.fig-tick {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 10.5px;
  fill: var(--gray);
}

.fig-rowlabel {
  font-size: 12px;
  font-weight: 600;
  fill: var(--fg);
}

.fig-note {
  font-size: 11px;
  fill: var(--gray);
}

.band-patch {
  fill: var(--s2);
  fill-opacity: 0.82;
}

.band-dev {
  fill: var(--fg);
  fill-opacity: 0.18;
}

.mark-exploit {
  stroke: var(--s3);
  stroke-width: 3;
  stroke-linecap: round;
}

.exploit-label {
  fill: var(--s3);
}

.key-patch { color: var(--s2); }
.key-dev { color: var(--gray); }

/* The Fil-C reference bar. Held apart from our own measurements so the
   chart cannot be misread as a head-to-head run on a common suite. */
.bar-alt {
  fill: var(--fg);
  fill-opacity: 0.26;
}

.bar-alt-val {
  fill: var(--gray);
}

.bar-neg-val {
  fill: var(--gray);
}

/* Axis break. Painted in the page background so it reads as a cut through
   the bar rather than a mark drawn on top of it. */
.bar-break {
  stroke: var(--bg);
  stroke-width: 5;
  fill: none;
}

/* Timeline rows. The ground strip gives each row a body so the coloured
   bands read as segments of one track rather than as free-floating blocks. */
.row-ground {
  fill: var(--fg);
  fill-opacity: 0.05;
}

.fig-rowsub {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 9.5px;
  fill: var(--gray);
  letter-spacing: 0.08em;
}

.band-text {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  fill: var(--bg);
}

.band-text-dim {
  fill: var(--fg);
  fill-opacity: 0.75;
}

.zone-safe {
  fill: var(--s1);
  fill-opacity: 0.13;
  stroke: var(--s1);
  stroke-opacity: 0.4;
  stroke-dasharray: 3 3;
}

.zone-exposed {
  fill: var(--s3);
  fill-opacity: 0.13;
  stroke: var(--s3);
  stroke-opacity: 0.45;
  stroke-dasharray: 3 3;
}

.zone-label {
  font-family: "SF Mono", "Fira Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.zone-label-safe { fill: var(--s1); }
.zone-label-exposed { fill: var(--s3); }

.mark-exploit-dot {
  fill: var(--s3);
}
