@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif/regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif/italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #172d35;
  --teal: #116c66;
  --rule: #d1dcd9;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: ui-monospace, Consolas, monospace;
  --page-width: 1100px;
  --blue: var(--teal);
}

body { color: var(--ink); background: #fbfcfa; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.topbar a:last-child { font: .86rem var(--mono); }
a:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

.paper-header {
  max-width: none;
  padding: clamp(36px, 5.5vw, 80px) 0 26px;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
.paper-venue { margin: 0 0 18px; font: .88rem/1.5 var(--mono); color: var(--teal); }
.paper-venue abbr { text-decoration: none; }
.paper-header h1 {
  margin: 0;
  font: 400 clamp(3.8rem, 7.4vw, 6rem)/.95 var(--serif);
  letter-spacing: -.035em;
}
.paper-header h1 em { color: var(--teal); }
.paper-header .subtitle {
  max-width: 48ch;
  margin: 18px auto 24px;
  color: #354e53;
  font-size: clamp(1.2rem, 2.25vw, 1.55rem);
  line-height: 1.25;
  text-wrap: balance;
}
.paper-header .authors { font-size: 1rem; }
.authors strong { color: var(--ink); }
.paper-header .affiliation { margin: 4px 0 0; font-size: .92rem; }
.paper-links { justify-content: center; align-items: center; gap: 4px 12px; margin-top: 22px; }
.paper-links a { min-width: 0; padding: 8px 5px; background: none; color: var(--ink); font-size: .94rem; }
.paper-links a:first-child { margin-right: 5px; padding: 9px 19px; border-radius: 6px; background: var(--ink); color: white; }
.paper-links a:is(:hover,:focus-visible) { background: #e5eeeb; color: var(--teal); }
.paper-links a:first-child:is(:hover,:focus-visible) { background: var(--teal); color: white; }

.benchmark-plot {
  --acr-bar: #86e8cf;
  --baseline-bar: #a6b6d6;
  padding: clamp(22px, 3vw, 36px);
  color: #edf7f5;
  background: linear-gradient(120deg, #143a3b, #172b3b 85%);
  border-radius: 14px;
  margin: 18px 0 22px;
}
.benchmark-plot figcaption { margin: 0; color: #cfdfdf; text-align: left; font-size: .91rem; }
.benchmark-plot figcaption a { color: var(--acr-bar); text-decoration: underline; }
.benchmark-plot figcaption a:focus-visible { outline-color: var(--acr-bar); }
.benchmark-plot figcaption strong { display: block; margin-bottom: 6px; color: white; font: 400 clamp(2rem, 3.1vw, 2.65rem)/1.05 var(--serif); }
.plot-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 18px 0; font-size: .84rem; }
.plot-legend span::before { content: ""; display: inline-block; width: .65em; height: .65em; margin-right: 6px; background: var(--acr-bar); }
.plot-legend span:last-child::before { background: var(--baseline-bar); }
.plot-series { padding-right: 2ch; font: .85rem/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.plot-group { margin-block: 15px; }
.plot-group > span { display: block; margin-bottom: 6px; }
.plot-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 19px;
  background: linear-gradient(to right, #ffffff24 1px, transparent 1px) left / 50% 100%;
}
.plot-bar::before {
  content: "";
  flex: none;
  width: calc(100% * var(--count) / 60);
  height: 7px;
  background: var(--acr-bar);
  border-radius: 0 3px 3px 0;
}
.plot-bar.baseline::before { background: var(--baseline-bar); }
.plot-bar b { margin-left: 6px; line-height: 1; font-weight: 500; }
.plot-scale { display: flex; justify-content: space-between; border-top: 1px solid #718589; padding-top: 3px; color: #c0cfd4; font-size: .76rem; }
@media (min-width: 741px) {
  .benchmark-plot { display: grid; grid-template-columns: 1fr 1.3fr; column-gap: 8%; align-content: center; }
  .benchmark-plot figcaption { align-self: end; }
  .plot-series { grid-area: 1 / 2 / span 2; }
  .plot-legend { align-self: start; }
}
@media (prefers-reduced-motion: no-preference) {
  .benchmark-plot { animation: show-benchmark .45s ease-out; }
  @keyframes show-benchmark { from { opacity: .8; transform: translateY(6px); } }
}

main > section:not(.routing-demo) { padding-block: clamp(36px, 5vw, 62px); }
main > section > h2 {
  margin: 0 0 22px;
  color: var(--ink);
  font: 400 clamp(2.5rem, 4.8vw, 3.7rem)/1 var(--serif);
  letter-spacing: -.025em;
  text-align: left;
}
.paper-summary {
  display: grid;
  grid-template-columns: minmax(145px, .55fr) minmax(0, 2fr);
  column-gap: 5%;
  border-bottom: 1px solid var(--rule);
}
.paper-summary p, #results p { line-height: 1.65; }
.paper-summary p:last-child { margin-bottom: 0; }
#method .figure-wide { overflow: hidden; border: 1px solid var(--rule); border-radius: 10px; background: white; }
#method .figure-wide a { display: block; padding: clamp(6px, 1vw, 16px); }
#method figcaption { padding: 12px 18px; border-top: 1px solid var(--rule); margin: 0; background: #f3f7f5; text-align: left; }
.method-list { list-style-position: inside; margin: 0; padding: 0; gap: 18px 32px; }
.method-list li { border-top: 1px solid var(--rule); padding: 12px 0 0; }
.method-list li::marker { color: var(--teal); font-family: var(--mono); }

#results h3 { font-size: clamp(1.2rem, 2.6vw, 1.45rem); line-height: 1.3; }
#results > p { max-width: 80ch; }
.incline-example { display: grid; grid-template-columns: 1.6fr 1fr; align-items: center; gap: 24px; border-left: 3px solid var(--teal); padding: 8px 0 8px 20px; margin-top: 42px; }
.incline-example h3 { margin: 0; }
.incline-example p { margin: 8px 0 0; }
.incline-example math { font-size: 2rem; color: var(--teal); }
#bibtex { border-top: 1px solid var(--rule); }
#bibtex pre { color: #d9eeea; border: 0; background: #19343a; border-radius: 9px; }

@media (max-width: 740px) {
  .paper-header h1 { font-size: clamp(2.8rem, 14.6vw, 4.6rem); }
  .paper-summary, .incline-example { grid-template-columns: 1fr; }
  .incline-example figure { justify-self: start; }
}
@media (max-width: 460px) {
  .paper-links { gap: 3px 8px; }
  .paper-links a { padding-inline: 3px; font-size: .88rem; }
  .paper-links a:first-child { margin-right: 2px; padding-inline: 12px; }
}

.routing-demo {
  max-width: var(--page-width);
  padding: 8px 0 20px;
}

.routing-panel {
  --aqua: #79e4db;
  padding: clamp(18px, 3.4vw, 36px);
  color: #f1f7ff;
  background: radial-gradient(ellipse at 0 45%, #193949 0%, transparent 54%),
              linear-gradient(120deg, #102335, #131d36);
  border: 1px solid #223b4e;
  border-radius: 18px;
  box-shadow: 0 14px 36px -24px #15304f;
}

.routing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.routing-toolbar h2 {
  margin: 0;
  text-align: left;
  font-size: clamp(1.45rem, 3.4vw, 2.15rem);
  letter-spacing: -.035em;
}

.routing-panel button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.routing-panel button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.routing-play {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 6.5rem;
  padding: 6px 12px;
  border: 1px solid #5a7289;
  border-radius: 20px;
  background: #20334a;
}

.routing-play:hover { background: #2d445c; }

.routing-play::before {
  content: "";
  width: 0;
  height: 0;
  border-block: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.routing-play[data-action="pause"]::before {
  width: 4px;
  height: 10px;
  border: 0;
  border-inline: 3px solid currentColor;
  box-sizing: content-box;
}

.routing-prompt {
  margin: 9px 0 22px;
  color: #e3ecf7;
}

.routing-prompt span,
.routing-paths button span {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .8rem;
  letter-spacing: .035em;
}

.routing-prompt span {
  margin-right: 6px;
  color: var(--aqua);
}

.layer-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 0;
  border-block: 1px solid #35495d;
}

.layer-controls label {
  color: #d9e5f2;
  font: .88rem ui-monospace, Consolas, monospace;
  white-space: nowrap;
}

.layer-controls input {
  flex: 1;
  min-width: 0;
  margin: 0;
  accent-color: var(--aqua);
  cursor: pointer;
}

.routing-board {
  display: grid;
  grid-template-columns: clamp(100px, 18%, 165px) minmax(0, 1fr);
  gap: 8px;
  margin-block: 12px 20px;
}

.routing-field { position: relative; }
.routing-field canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.routing-paths {
  display: grid;
  min-width: 0;
  grid-template-rows: repeat(4, 1fr);
  padding-top: 32px;
}

.routing-paths button {
  position: relative;
  min-width: 0;
  min-height: 73px;
  padding: 8px 12px;
  text-align: left;
  line-height: 1.2;
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 4px;
}

.routing-paths button:nth-child(1) { --route: #78e5da; }
.routing-paths button:nth-child(2) { --route: #c3adff; }
.routing-paths button:nth-child(3) { --route: #ffcc82; }
.routing-paths button:nth-child(4) { --route: #ff9cb7; }
.routing-paths button:is(:hover, [aria-pressed="true"]) { border-left-color: var(--route); background: #ffffff0d; }
.routing-paths button span { display: block; color: var(--route); }
.routing-paths button strong { display: none; margin-top: 4px; font-size: .95rem; }
.agent-allocation { display: block; margin-top: 4px; font-size: .85rem; color: #c1d0de; }
.pass-complete .agent-allocation { display: none; }
.pass-complete .routing-paths button strong { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .pass-complete .routing-paths button strong { animation: show-proof .4s ease-out; }
  @keyframes show-proof {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.routing-inspector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  border-top: 1px solid #405064;
  padding-top: 17px;
}

#routing-experts {
  display: grid;
  grid-template-columns: clamp(76px, 10vw, 104px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.expert-map {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);
  gap: 1px;
  aspect-ratio: 1;
}

.expert-map i { background: #60748b; }
.expert-map i.masked, .masked-key { background: #2c3d50; }
.expert-map i.active, .active-key { background: var(--route); box-shadow: 0 0 4px var(--route); }
.eligible-key { background: #60748b; }
.expert-heading, .routing-readout strong { color: var(--route); }
#routing-experts p { margin: 3px 0; color: #e2ebf6; font-size: .86rem; }
#routing-experts .expert-ids { color: #b3c5d7; font: .8rem/1.5 ui-monospace, Consolas, monospace; }

.routing-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  color: #c2d1e1;
  font-size: .85rem;
}

.routing-legend span { display: inline-flex; align-items: center; gap: 6px; }
.routing-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.routing-readout p { margin: 4px 0 0; color: #e2ebf6; }
.routing-caption { max-width: 790px; margin: 12px auto 0; color: #526171; font-size: .91rem; text-align: center; }

@media (max-width: 740px) {
  .routing-inspector { grid-template-columns: 1fr; gap: 15px; }
}

@media (max-width: 620px) {
  .routing-board { grid-template-columns: minmax(74px, 26%) minmax(0, 1fr); gap: 2px; }
  .routing-paths button { padding-inline: 5px; }
  .routing-paths button span { letter-spacing: normal; white-space: nowrap; }
  .routing-paths button strong { font-size: .86rem; }
  .routing-play { min-width: 0; font-size: .86rem; }
}
