/* PyRUA-Lean: the MHLA page's styles (index.css) in the paper's colours, Figure 2's grey #596675 and red #8C0000. */
:root {
  --primary-color: #8C0000;
  --primary-hover: #6B0000;
  --secondary-color: #596675;
  --accent-color: #B03030;
  --text-secondary: #596675;
  --gradient-primary: linear-gradient(135deg, #8C0000 0%, #B03030 100%);
  /* heading underlines and author-link hover lines (pink in MHLA's page) */
  --gradient-accent: linear-gradient(135deg, #8C0000 0%, #596675 100%);
}

.publication-title {
  line-height: 1.25;
}

.accent-text {
  color: var(--primary-color);
  text-shadow: none;
  padding: 0;
}

.title-highlight {
  font-size: inherit;
  text-shadow: none;
  padding: 0;
}

.metric-highlight {
  background: rgba(140, 0, 0, 0.06);
}

.performance-section {
  background: linear-gradient(135deg, rgba(89, 102, 117, 0.05) 0%, rgba(140, 0, 0, 0.03) 100%);
}

.performance-card:hover {
  transform: none;
}

.performance-card-title {
  margin-bottom: 0.75rem;
}

.metric-value {
  font-size: 1.6rem;
  line-height: 1.2;
  white-space: nowrap;
}

.metric-label {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.benchmarks-note {
  margin-top: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.figure-caption {
  text-align: left;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.pipeline-section {
  padding-top: 0.5rem;
}

.split-row {
  margin-top: 1.5rem;
}

pre#bibtex-code {
  white-space: pre-wrap;
  word-break: break-word;
}

/* the arXiv button until the paper is on arXiv */
.button.is-soon {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* ---- sections added for readers who have not read the paper ---- */
.tldr {
  max-width: 820px;
  margin: 1.25rem auto 0;
  text-align: left;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.6;
  background: rgba(140, 0, 0, 0.04);
  border-left: 3px solid var(--primary-color);
  padding: 0.9rem 1.1rem;
  border-radius: 0 8px 8px 0;
}

.video-section {
  padding-top: 0.5rem;
  padding-bottom: 1.5rem;
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.video-frame video {
  width: 100%;
  height: 100%;
  display: block;
}

.code-block {
  background: #F7F6F2;
  border: 1px solid #D9DCD2;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-x: auto;
  color: #1e293b;
}

.code-block.small {
  font-size: 0.72rem;
  max-height: 22rem;
  overflow: auto;
}

.code-note,
.speed-note {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 0.6rem;
  text-align: center;
}

.clip-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.clip {
  margin: 0;
  position: relative;
}

.clip video {
  width: 100%;
  display: block;
  border-radius: 10px;
  background: #111;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.clip figcaption {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.45rem;
  line-height: 1.4;
}

.agent-tag {
  display: inline-block;
  font-weight: 700;
  margin-right: 0.45rem;
}

.agent-tag.tool {
  color: #596675;
}

.agent-tag.code {
  color: #8C0000;
}

.habit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.habit-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.habit-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}

.habit-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.habit-card .share {
  font-size: 0.8rem;
  font-weight: 600;
  color: #8C0000;
  background: rgba(140, 0, 0, 0.06);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.habit-card p {
  font-size: 0.93rem;
  line-height: 1.5;
}

.habit-card .source {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: auto;
}

.case {
  margin-top: 2rem;
}

.case-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.case-task {
  color: var(--text-secondary);
  font-style: italic;
  margin: 0.2rem 0 0.6rem;
}

.case-code {
  margin-top: 0.6rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gallery-item figcaption {
  font-size: 0.86rem;
}

.gallery-item .bench {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
}

.speed-tag {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.setup-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.setup-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.setup-card .setup-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: #8C0000;
  margin: 0.25rem 0 0.4rem;
}

.setup-card p {
  font-size: 0.93rem;
  line-height: 1.5;
}

.setup-text {
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .clip-pair,
  .habit-grid,
  .setup-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ---- syntax highlighting, in the colours of the paper's listings ---- */
.code-block .k { font-weight: 700; color: #1e293b; }
.code-block .s { color: #3F6B3F; }
.code-block .c { color: #8A9099; font-style: italic; }
.code-block .robo { color: #8C0000; font-weight: 700; }
.code-block .nf { color: #1e293b; font-weight: 700; }
.code-block .nb { color: #3E5C76; }
.code-block .m { color: #7A4E13; }

/* ---- one task, two agents ---- */
.duel {
  margin-top: 1rem;
  outline: none;
}

.duel:focus-visible {
  box-shadow: 0 0 0 3px rgba(140, 0, 0, 0.25);
  border-radius: 12px;
}

.duel-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.duel-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #D3D9DE;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
}

.duel-btn:hover:not(:disabled) { border-color: #8C0000; color: #8C0000; }
.duel-btn:disabled { opacity: 0.4; cursor: default; }
.duel-btn.play { background: #8C0000; border-color: #8C0000; color: #fff; }
.duel-btn.play:hover { background: #6B0000; color: #fff; }
.duel-btn:focus-visible, .callbox:focus-visible, .code-btn:focus-visible { outline: 2px solid #8C0000; outline-offset: 2px; }

.duel-k {
  margin-left: auto;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.duel-strips {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.strip {
  display: grid;
  grid-template-columns: 11.5rem 1fr;
  align-items: center;
  gap: 0.5rem;
}

.strip-label { font-size: 0.88rem; font-weight: 700; }
.strip.tool .strip-label { color: #596675; }
.strip.code .strip-label { color: #8C0000; }

.strip-boxes { display: flex; gap: 4px; }

.callbox {
  font: inherit;
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 auto;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border: 1px solid #C6CCD2;
  background: #EEF0F2;
  color: #596675;
}

.strip.code .callbox { border-color: #E2C2C2; background: #F7ECEC; color: #8C0000; }
.strip.tool .callbox.img { background: #596675; border-color: #596675; color: #fff; }
.strip.code .callbox.img { background: #8C0000; border-color: #8C0000; color: #fff; }
.callbox.solved { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1e293b; }
.callbox.current { transform: translateY(-3px); box-shadow: 0 3px 0 0 #F5B700; }
.callbox.solved.current { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1e293b, 0 7px 0 0 #F5B700; }

.duel-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.duel-panel {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.duel-panel.tool { border-top: 3px solid #596675; }
.duel-panel.code { border-top: 3px solid #8C0000; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.panel-k { font-size: 0.88rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.panel-views {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.4rem;
}

.panel-views img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: #EEF0F2;
}

.panel-meter { display: grid; gap: 0.25rem; }
.meter-bar { height: 8px; border-radius: 999px; background: #EEF0F2; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }
.duel-panel.tool .meter-fill { background: #8A96A3; }
.duel-panel.code .meter-fill { background: #8C0000; }
.meter-text { font-size: 0.85rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.panel-status { font-size: 0.88rem; font-weight: 600; min-height: 1.3em; }
.panel-status.solved { color: #1F6F3A; }
.panel-status.done { color: var(--text-secondary); font-weight: 500; }

.panel-action { display: grid; gap: 0.45rem; min-width: 0; }
.panel-action .code-block.small { max-height: 18rem; margin: 0; }

.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.tool-list li { font-size: 0.88rem; line-height: 1.4; overflow-wrap: anywhere; }
.tool-list code { background: #EEF0F2; color: #1e293b; padding: 0.05rem 0.35rem; border-radius: 4px; }
.tool-list .times { font-weight: 700; color: #596675; }
.tool-list .args { color: var(--text-secondary); font-size: 0.82rem; }

.returned { font-size: 0.85rem; font-weight: 600; color: #596675; }
.note { font-size: 0.88rem; color: var(--text-secondary); font-style: italic; line-height: 1.45; }
.cell-head { font-size: 0.85rem; font-weight: 600; color: #8C0000; }

.printed summary { cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); }
.printed pre {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  line-height: 1.4;
  background: #fff;
  border: 1px dashed #D9DCD2;
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  max-height: 14rem;
  overflow: auto;
  white-space: pre;
}
.more-note { font-size: 0.78rem; color: var(--text-secondary); }

/* ---- gallery code viewer ---- */
.code-btn {
  font: inherit;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #D3D9DE;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
}

.code-btn:hover { border-color: #8C0000; color: #8C0000; }
.gallery-item.active video { box-shadow: 0 0 0 3px #8C0000; }
.gallery-item.active .code-btn { background: #8C0000; border-color: #8C0000; color: #fff; }

.viewer {
  margin-top: 1.5rem;
  background: #fff;
  border: 1px solid var(--border-color);
  border-top: 3px solid #8C0000;
  border-radius: 12px;
  padding: 1rem;
  scroll-margin-top: 1rem;
}

.viewer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.8rem;
  margin-bottom: 0.8rem;
}

.viewer-head .bench { font-weight: 700; }
.viewer-head .task { color: var(--text-primary); }
.viewer-head .count { margin-left: auto; font-size: 0.88rem; color: var(--text-secondary); }

.viewer-body {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1rem;
  align-items: start;
}

.viewer-video video {
  width: 100%;
  display: block;
  border-radius: 10px;
  background: #111;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.viewer-cells { display: grid; gap: 0.8rem; min-width: 0; }
.viewer-cell .code-block.small { margin: 0.3rem 0 0; }
.final { font-size: 0.9rem; line-height: 1.5; color: var(--text-primary); }

@media (max-width: 768px) {
  .duel-panels,
  .viewer-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .strip { grid-template-columns: 1fr; }
  .duel-k { margin-left: 0; width: 100%; }
}

/* the paper's code box: warm ground and rule (the template's pre rule would paint it blue-grey) */
pre.code-block {
  background: #F7F6F2;
  border: 1px solid #D9DCD2;
  padding: 0.85rem 1rem;
}

/* gallery viewer: one cell at a time */
.cell-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.cell-tab {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #E2C2C2;
  background: #F7ECEC;
  color: #8C0000;
  cursor: pointer;
}

.cell-tab.active { background: #8C0000; border-color: #8C0000; color: #fff; }
.cell-tab:focus-visible { outline: 2px solid #8C0000; outline-offset: 2px; }
.cell-pane .code-block.small { max-height: 20rem; margin: 0.3rem 0 0; }
.cell-pane { display: grid; gap: 0.5rem; min-width: 0; }
.cell-nav { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

/* the template's pre and code rules are !important; the paper's code box wins them back */
pre.code-block {
  background: #F7F6F2 !important;
  border: 1px solid #D9DCD2 !important;
  padding: 0.85rem 1rem !important;
  font-size: 0.8rem !important;
  box-shadow: none !important;
}

pre.code-block.small {
  font-size: 0.72rem !important;
}

pre.code-block code {
  background: transparent !important;
  padding: 0 !important;
  font-size: inherit !important;
}

.printed pre {
  background: #fff !important;
  border: 1px dashed #D9DCD2 !important;
  padding: 0.6rem 0.7rem !important;
  font-size: 0.72rem !important;
  box-shadow: none !important;
}

/* gallery: a tab per benchmark */
.bench-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}

.bench-tab {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid #D3D9DE;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
}

.bench-tab:hover { border-color: #8C0000; color: #8C0000; }
.bench-tab.active { background: #8C0000; border-color: #8C0000; color: #fff; }
.bench-tab:focus-visible { outline: 2px solid #8C0000; outline-offset: 2px; }
.gallery-grid[hidden] { display: none; }
.gallery-item figcaption { min-height: 2.6em; }

/* contents bar: sticks to the top of the window, one row, scrolls sideways on a phone */
.toc {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-color);
}

.toc-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  gap: 0.25rem;
  padding: 0.45rem 1rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.toc-inner::-webkit-scrollbar { display: none; }

.toc a {
  flex: 0 0 auto;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
}

.toc a:hover { color: #8C0000; background: rgba(140, 0, 0, 0.06); }
.toc a.active { color: #fff; background: #8C0000; }
.toc a:focus-visible { outline: 2px solid #8C0000; outline-offset: 2px; }

/* jumping to a section leaves room for the bar */
section[id] { scroll-margin-top: 3.2rem; }
