/* =====================================================
   SimFoundry — research page styles
   ===================================================== */

:root {
  --color-text: #1a1a1a;
  --color-text-muted: #5c5c5c;
  --color-bg: #ffffff;
  --color-bg-alt: #f7f7f8;
  --color-border: #e5e5e7;
  --color-accent: #2563eb;
  --color-accent-dark: #1d4ed8;
  --color-accent-red: #8C1515;
  --color-accent-red-dark: #6e1010;
  --color-card: #ffffff;
  --color-card-shadow: rgba(15, 23, 42, 0.06);

  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --container-max: clamp(760px, 50vw, 1280px);
  --container-narrow: clamp(680px, 40vw, 900px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 21px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

img { max-width: 100%; height: auto; }
canvas { max-width: 100%; }

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { color: var(--color-accent-dark); text-decoration: underline; }

/* ----------- Hero ----------- */
.hero {
  padding: 64px 24px 32px;
  text-align: center;
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--color-border);
}
.hero-inner {
  max-width: var(--container-max);
  margin: 0 auto;
}
.publication-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 20px;
  color: var(--color-accent-red);
  /* Break out wider than the hero column and cap the font so the explicit
     <br> split renders as a clean two lines across desktop widths. */
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(1320px, 94vw);
  max-width: none;
}
.publication-authors {
  font-size: 1.05rem;
  margin: 0 auto 8px;
  line-height: 1.7;
  max-width: 900px;
}
.publication-authors .author-block { margin: 0 4px; }
.affiliation {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0 auto 4px;
  max-width: 900px;
}
.affiliation-note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0 auto 12px;
  max-width: 900px;
}
.publication-venue {
  display: inline-block;
  color: var(--color-accent-red);
  font-size: 1rem;
  font-weight: 600;
  margin: 8px 0 24px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: #1a1a1a;
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid #1a1a1a;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover {
  background: #333;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

/* ----------- Sections ----------- */
.section {
  padding: 56px 24px;
}
.container {
  max-width: var(--container-max);
  margin: 0 auto;
}
.container.narrow {
  max-width: var(--container-narrow);
}
.container.wide {
  max-width: var(--container-max);
}
.section-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  text-align: center;
  margin: 0 0 16px;
  /* Allow titles to be wider than the (narrow) body container so long
     headings wrap less. Centered in the viewport via the 50%/translate trick. */
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(1200px, 92vw);
  max-width: none;
}
.section-lead {
  text-align: center;
  color: var(--color-text-muted);
  max-width: 720px;
  margin: 0 auto 28px;
}
.content p {
  margin: 0 0 1em;
  text-align: justify;
}

/* ----------- Teaser ----------- */
.teaser {
  padding-top: 36px;
  padding-bottom: 36px;
}
.teaser-figure { margin: 0; }
.teaser-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
.teaser-placeholder,
.video-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
.figure-caption {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 14px auto 0;
  max-width: 800px;
}

.figure-tldr {
  color: var(--color-text);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.6;
  max-width: 760px;
  margin: 22px auto 0;
  padding: 18px 26px;
  background: var(--color-bg-alt);
  border-left: 4px solid var(--color-accent);
  border-radius: 8px;
}

.tldr-label {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* ----------- Video embed ----------- */
.video-embed {
  width: 100%;
  margin: 0 auto;
}
.pipeline-video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

/* Pipeline section: enlarge the figure and its heading ~1.3x. The figure
   extends 15% past the container on each side (centered); body overflow-x is
   clipped so this never adds a horizontal scrollbar. */
#walkthrough .video-embed {
  width: 130%;
  margin: 0 -15%;
}
#walkthrough .section-title {
  font-size: clamp(1.95rem, 3.12vw, 2.47rem);
}

/* ----------- 3D Viewers ----------- */
#scene-viewer,
#object-viewer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.viewer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.viewer-label {
  font-weight: 600;
  color: var(--color-text);
}
.viewer-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 36px 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231a1a1a' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 12px center;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  cursor: pointer;
}
.viewer-select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.viewer-grid {
  display: grid;
  gap: 20px;
}
.viewer-grid--single { grid-template-columns: 1fr; }
.viewer-grid--dual { grid-template-columns: 1fr 1fr; }
.viewer-grid--triple { grid-template-columns: 1fr 1fr 1fr; }
.viewer-grid--triple .viewer-container { aspect-ratio: 4 / 3; }
@media (max-width: 960px) {
  .viewer-grid--triple { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .viewer-grid--dual { grid-template-columns: 1fr; }
  .viewer-grid--triple { grid-template-columns: 1fr; }
}

.viewer-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 18px var(--color-card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.viewer-card-title {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--color-border);
  background: #fafafb;
}
.viewer-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(135deg, #eef1f6 0%, #d9dee7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viewer-container--image {
  background: var(--color-bg-alt);
}
.viewer-container--image .viewer-loading {
  color: var(--color-text-muted);
}
.viewer-container--image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ----------- Interactive object picker ----------- */
.io-scene.io-hovering { cursor: pointer; }
.io-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.io-tooltip {
  position: absolute;
  z-index: 3;
  transform: translate(12px, -50%);
  padding: 3px 9px;
  background: rgba(15, 18, 25, 0.9);
  color: #fff;
  font-size: 0.82rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
}
.io-hint-inline,
.io-selected-label {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.viewer-preview-video {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 44%;
  max-width: 480px;
  min-width: 280px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  z-index: 5;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  background: #000;
  pointer-events: none;
}
.viewer-loading {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.viewer-hint {
  padding: 8px 16px 12px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}
.viewer-note {
  margin-top: 20px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.sam3d-summary {
  max-width: 820px;
  margin: 0 auto 28px;
}
.sam3d-summary p {
  text-align: left;
  margin: 0;
}

/* ----------- Qualitative results ----------- */
.qualitative-results {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.qualitative-group[hidden] {
  display: none;
}
.qualitative-video-toggle {
  display: inline-flex;
  align-self: center;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
}
.qualitative-toggle-button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-right: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  min-width: 96px;
  padding: 9px 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.qualitative-toggle-button:last-child {
  border-right: 0;
}
.qualitative-toggle-button:hover,
.qualitative-toggle-button:focus-visible {
  color: var(--color-accent);
}
.qualitative-toggle-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.qualitative-toggle-button.is-active {
  background: var(--color-text);
  color: #ffffff;
}
.qualitative-pair {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.qualitative-pair--dual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 720px) {
  .qualitative-pair,
  .qualitative-pair--dual { grid-template-columns: 1fr; }
}
.qualitative-panel {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.qualitative-media {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-alt);
  overflow: hidden;
}
.qualitative-media img,
.qualitative-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qualitative-media--image img {
  object-fit: contain;
}
.qualitative-panel figcaption {
  order: -1;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
  background: #fafafb;
  border-bottom: 1px solid var(--color-border);
}
.qualitative-panel figcaption .success-rate {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--color-muted);
}
.real2sim-policy {
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-text);
  margin: 0 0 16px 0;
}
.qualitative-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}
#sam3d-scene-tabs {
  margin-top: 0;
}
.qualitative-tab {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  padding: 10px 16px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.qualitative-tab:hover,
.qualitative-tab:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.qualitative-tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.qualitative-tab.is-active {
  background: var(--color-text);
  border-color: var(--color-text);
  color: #ffffff;
}

/* ----------- Sim-to-Real Policy Training ----------- */
.accent-red { color: var(--color-accent-red); }
.subsection-title {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 1.7vw, 1.4rem);
  font-weight: 600;
  text-align: center;
  margin: 0 0 26px;
  color: var(--color-text);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(1200px, 92vw);
  max-width: none;
}
.policy-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
@media (max-width: 720px) {
  .policy-row { grid-template-columns: 1fr; }
}
.policy-col { margin: 0; }
.policy-col-header {
  text-align: center;
  font-weight: 600;
  font-size: 1.02rem;
  margin-bottom: 10px;
  color: var(--color-text);
  line-height: 1.25;
  /* Reserve two lines so a wrapping header (e.g. "Real World Eval (Unseen
     Objects)") on narrow screens doesn't push its video out of line with the
     others. */
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.policy-media {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}
.policy-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.policy-success {
  text-align: center;
  margin-top: 12px;
  color: var(--color-text-muted);
  font-size: 0.98rem;
}
.policy-success strong {
  color: var(--color-text);
  font-size: 1.15rem;
}
.policy-success--highlight {
  color: var(--color-accent-red);
  font-weight: 600;
}
.policy-success--highlight strong {
  color: var(--color-accent-red);
}

/* Cousins generalization: image (left) + eval video (right) */
.policy-row + .subsection-title {
  margin-top: 48px;
}
/* Video spans the section width (16:9). The image floats as a picture-in-
   picture window over the LEFT of the video, matching (almost) its height. */
.cousin-row {
  position: relative;
}
.cousin-row .policy-media {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}
.cousin-row .policy-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cousin-fig {
  position: absolute;
  top: 28px;
  bottom: 28px;
  left: 12px;
  margin: 0;
  z-index: 2;
}
.cousin-fig img {
  display: block;
  height: 100%;
  width: auto;
  /* transparent cutout floats over the video; shadow follows the object shapes */
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}
@media (max-width: 720px) {
  .cousin-fig { top: 16px; bottom: 16px; left: 8px; }
}

/* ----------- Stat cards (task-cousins section) ----------- */
.stat-lead {
  text-align: center;
  font-size: clamp(1rem, 1.9vw, 1.45rem);
  font-weight: 600;
  margin: 0 0 18px;
}
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  max-width: 940px;
  margin: 0 auto;
}
.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px var(--color-card-shadow);
  padding: 18px 24px 22px;
  text-align: center;
}
.stat-card-title {
  font-weight: 600;
  /* Keep titles like "On 7 held-out tasks (unseen even in sim)" on one line:
     no wrapping, font scales down with the viewport instead. */
  white-space: nowrap;
  font-size: clamp(0.72rem, 1.15vw, 1rem);
}
.stat-card-note { font-size: 0.8em; color: var(--color-text-muted); font-weight: 500; }
.stat-compare {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 14px;
}
.stat-from {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
}
.stat-arrow { font-size: 1.5rem; color: var(--color-text-muted); }
.stat-to {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-accent-red);
}
.stat-bar-row {
  display: grid;
  grid-template-columns: 8.2em 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.stat-bar-label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-align: right;
  white-space: nowrap;
}
.stat-bar-track {
  height: 12px;
  background: #eef0f3;
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar {
  height: 100%;
  width: calc(var(--v) * 1%);
  min-width: 4px; /* keep the 0% baseline visible as a sliver */
  border-radius: inherit;
  transition: width 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.stat-bar--base { background: #b9bec7; }
.stat-bar--boost { background: var(--color-accent-red); }
@media (max-width: 720px) {
  .stat-cards { grid-template-columns: 1fr; }
}

/* Keep the Task Cousins heading on one line (override base wrap/width). */
#task-cousins .section-title {
  white-space: nowrap;
  width: max-content;
  max-width: 96vw;
  font-size: clamp(0.9rem, 2.2vw, 1.9rem);
}
@media (max-width: 720px) {
  #task-cousins .section-title { white-space: normal; width: min(1200px, 92vw); }
}

/* ----------- Two videos side by side (task cousins) ----------- */
.video-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 720px) {
  .video-duo { grid-template-columns: 1fr; }
}
.duo-col { margin: 0; }
.duo-caption {
  text-align: center;
  font-weight: 600;
  font-size: 1.02rem;
  margin-top: 10px;
  color: var(--color-text);
}
.stat-block {
  margin: 0 0 28px;
}

/* ----------- Highlighted stat sentences ----------- */
.stat-line {
  text-align: center;
  font-size: clamp(0.8rem, 1.7vw, 1.4rem);
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 16px;
  color: var(--color-text);
  /* Keep each sentence on a single line, breaking out wider than the body
     container (centered in the viewport). */
  white-space: nowrap;
  width: max-content;
  max-width: 96vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
.stat-line:last-child { margin-bottom: 0; }
.stat-line .accent-red { font-weight: 700; }
@media (max-width: 720px) {
  .stat-line {
    white-space: normal;
    width: auto;
    left: auto;
    transform: none;
  }
}

/* ----------- Co-training bar chart (generated, not an image) ----------- */
.barchart { margin: 0 auto; max-width: 940px; }
.barchart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 20px;
  font-weight: 600;
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-swatch { width: 16px; height: 16px; border-radius: 3px; }
.swatch-sim { background: #3b9aff; }
.swatch-real { background: #5cd65c; }
.swatch-cotrain { background: #ff6f61; }

.barchart-body {
  display: grid;
  grid-template-columns: auto auto 1fr;
  column-gap: 10px;
  align-items: start;
}
.barchart-ylabel {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.barchart-yaxis {
  height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}
.barchart-col3 { min-width: 0; }
.barchart-plot {
  position: relative;
  height: 260px;
  border-left: 2px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
}
.barchart-gridlines {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.barchart-gridlines span { border-top: 1px solid #eef0f3; }
.barchart-cols { position: absolute; inset: 0; display: flex; }
.bar-group { flex: 1; height: 100%; }
.bar-cluster {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}
.bar {
  position: relative;
  width: 28px;
  max-width: 28%;
  height: calc(var(--v) * 1%);
  border-radius: 3px 3px 0 0;
  transition: height 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.bar-sim { background: #3b9aff; }
.bar-real { background: #5cd65c; transition-delay: 0.15s; }
.bar-cotrain { background: #ff6f61; transition-delay: 0.3s; }
.bar-val {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  transition: opacity 0.35s ease 0.9s;
}

/* First-view grow animation: JS marks `[data-chart-grow]` charts as pending
   on load and releases them when they scroll into view, so bars rise from
   zero to their real values. Without JS the static rules above apply. */
.chart-grow-pending .bar { height: 0; }
.chart-grow-pending .bar-val { opacity: 0; transition: none; }
.chart-grow-pending .stat-bar { width: 0; min-width: 0; }
.chart-grow-pending .mbar { height: 0; }
.chart-grow-pending .mbar span { opacity: 0; transition: none; }
.barchart-xlabels { display: flex; margin-top: 8px; }
.barchart-xlabels span {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  color: var(--color-text);
}
@media (max-width: 720px) {
  .bar { width: 16px; }
  .bar-val { font-size: 0.78rem; top: -18px; }
  .barchart-xlabels span { font-size: 0.82rem; }
}

/* ----------- SAM3D metric charts (3 panels, generated) ----------- */
.metric-charts { max-width: 1150px; margin: 36px auto 0; }
.metric-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
@media (max-width: 820px) {
  .metric-panels { grid-template-columns: 1fr; max-width: 540px; margin: 0 auto; }
}
.metric-panel-title {
  text-align: center;
  font-weight: 600;
  font-size: 0.98rem;
  margin-bottom: 12px;
  color: var(--color-text);
}
.metric-plot {
  display: flex;
  gap: 16px;
  height: 230px;
  align-items: flex-end;
  border-bottom: 2px solid var(--color-border);
}
.metric-cluster {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}
.mbar {
  position: relative;
  flex: 1;
  max-width: 34px;
  height: calc(var(--v) * 1%);
  border-radius: 3px 3px 0 0;
  transition: height 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.mbar span {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  white-space: nowrap;
  color: var(--color-text);
  transition: opacity 0.35s ease 0.9s;
}
.mbar-sam { background: #3b9aff; }
.mbar-zs { background: #5cd65c; }
.mbar-tuned { background: #ff6f61; }
.metric-xrow { display: flex; gap: 16px; margin-top: 10px; }
.metric-xrow span {
  flex: 1;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.3;
  color: var(--color-text-muted);
}
.metric-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 24px;
  font-weight: 600;
  font-size: 0.92rem;
}
.swatch-sam { background: #3b9aff; }
.swatch-zs { background: #5cd65c; }
.swatch-tuned { background: #ff6f61; }

/* ----------- BibTeX ----------- */
.bibtex-block {
  background: #0f1219;
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ----------- Real2Sim Scatter Chart ----------- */
.real2sim-chart-wrapper {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
}
.chart-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--color-text);
}
.chart-subtitle {
  text-align: center;
  font-size: 1rem;
  color: var(--color-muted);
  margin: 0 0 20px 0;
}
.chart-hint {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-muted);
  margin: -12px 0 20px 0;
}
.chart-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}
.chart-toggle {
  padding: 8px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.chart-toggle:hover {
  background: var(--color-bg-alt);
}
.chart-toggle.is-active {
  background: var(--color-text);
  color: #fff;
  border-color: var(--color-text);
}
.chart-container {
  position: relative;
  max-width: 650px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
#scatter-svg {
  display: block;
  width: 100%;
  height: auto;
}
.scatter-point {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.scatter-point:hover {
  transform: scale(1.3);
  filter: brightness(1.1);
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(30, 30, 30, 0.95);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
  max-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.chart-tooltip .tooltip-method {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}
.chart-tooltip .tooltip-method.simfoundry {
  background: #3182bd;
}
.chart-tooltip .tooltip-method.polaris {
  background: #e6550d;
}
.chart-tooltip .tooltip-metrics {
  display: block;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 0.8rem;
  color: #adf;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
}

/* Metrics Comparison Bar Charts */
.metrics-comparison {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
}
.metrics-title {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--color-text);
}
.metrics-subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin: 0 0 24px 0;
}
.metrics-bars {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}
.metric-chart {
  flex: 1;
  max-width: 320px;
  min-width: 260px;
}
.metric-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 12px;
  text-align: center;
}
.metric-arrow {
  font-weight: 700;
  margin-left: 4px;
}
.metric-arrow--up {
  color: #2e7d32;
}
.metric-arrow--down {
  color: #2e7d32;
}
.metric-bar-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.metric-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 50px;
  align-items: center;
  gap: 10px;
}
.metric-bar-name {
  font-size: 0.85rem;
  color: var(--color-muted);
  text-align: right;
}
.metric-bar-track {
  height: 28px;
  background: var(--color-bg-alt);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.metric-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 0;
}
.metric-bar--sf {
  background: linear-gradient(90deg, #6baed6, #3182bd);
}
.metric-bar--pol {
  background: linear-gradient(90deg, #fdae6b, #e6550d);
}
.metric-bar-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
}
@media (max-width: 600px) {
  .metrics-bars {
    flex-direction: column;
    align-items: center;
  }
  .metric-chart {
    width: 100%;
  }
}
.chart-legends {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.legend-group {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 140px;
}
.legend-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}
.legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--color-muted);
}
.legend-item svg {
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .chart-legends {
    flex-direction: column;
    align-items: center;
  }
  .legend-group {
    width: 100%;
    max-width: 280px;
  }
  .legend-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ----------- Footer ----------- */
.site-footer {
  padding: 32px 24px 48px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}
