/* Modern CSS Variables for consistent theming */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --accent-color: #0ea5e9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --background-primary: #ffffff;
  --background-secondary: #f8fafc;
  --background-accent: #f1f5f9;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #2a78d6 0%, #f97316 100%);
  --gradient-subtle: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth scrolling for better UX */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  background-color: var(--background-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* Modern Button Styles */
.button {
  border-radius: var(--border-radius) !important;
  font-weight: 600 !important;
  transition: var(--transition) !important;
  border: 2px solid transparent !important;
  position: relative;
  overflow: hidden;
}

.button.is-dark {
  background: var(--text-primary) !important;
  border: none !important;
  color: white !important;
  box-shadow: var(--shadow-md);
}

.button.is-dark:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--primary-color) !important;
}

.button.is-dark:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.footer .icon-link {
    font-size: 25px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.footer .icon-link:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.link-block a {
    margin: 8px 4px;
}

.dnerf {
  font-variant: small-caps;
}


/* Hero Section Modernization */
.hero {
  position: relative;
  overflow: hidden;
}

.hero.is-light {
  background: var(--background-secondary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.hero-body {
  padding: 4rem 1.5rem;
}

.teaser .hero-body {
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.teaser {
  font-family: 'Inter', sans-serif;
}


/* Publication Content Styling */
.publication-title {
    font-family: 'Inter', sans-serif !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    margin-bottom: 2rem !important;
    line-height: 1.1 !important;
}

.publication-banner {
  max-height: 70vh;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  margin: 2rem 0;
}

.publication-banner video {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  object-fit: cover;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-lg);
}

.publication-header .hero-body {
  padding: 6rem 1.5rem 4rem;
}

.publication-authors {
    font-family: 'Inter', sans-serif !important;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.publication-venue {
    color: var(--text-secondary);
    width: fit-content;
    font-weight: 600;
    background: var(--background-accent);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    display: inline-block;
}

.publication-awards {
    color: #ef4444;
    width: fit-content;
    font-weight: 700;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    border-left: 4px solid #ef4444;
    margin-top: 1rem;
}

.publication-authors a {
   color: var(--primary-color) !important;
   text-decoration: underline;
   text-decoration-color: rgba(37, 99, 235, 0.35);
   text-decoration-thickness: 1.5px;
   text-underline-offset: 4px;
   font-weight: 600;
   transition: var(--transition);
}

.publication-authors a:hover {
    color: var(--primary-hover) !important;
    text-decoration-color: currentColor;
}

.author-block {
  display: inline-block;
  margin-right: 0.5rem;
}

.publication-banner img {
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.publication-banner img:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-xl);
}

/* Modern Video and Carousel Styling */
.publication-video {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    overflow: hidden;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--shadow-xl);
    transition: var(--transition);
}

.publication-video:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.publication-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius-lg);
}

.publication-body img {
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.publication-body img:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.results-carousel {
  overflow: hidden;
  padding: 1rem 0;
}

.results-carousel .item {
  margin: 1rem;
  overflow: hidden;
  padding: 1.5rem;
  font-size: 0;
  background: var(--background-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.results-carousel .item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.results-carousel .item img,
.results-carousel video {
  margin: 0;
  border-radius: var(--border-radius);
  width: 100%;
  height: auto;
}

.results-carousel .subtitle {
  font-size: 1rem !important;
  color: var(--text-secondary);
  margin-top: 1rem;
  font-weight: 500;
}

/* Pagination and Misc Improvements */
.slider-pagination .slider-page {
  background: var(--primary-color);
  border-radius: 50%;
  transition: var(--transition);
}

.slider-pagination .slider-page.is-active {
  background: var(--primary-hover);
  transform: scale(1.2);
}

.eql-cntrb { 
  font-size: 0.875rem;
  color: var(--text-light);
  font-style: italic;
}

/* Section Titles */
.title.is-3 {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  color: var(--text-primary);
  margin-bottom: 2rem !important;
  position: relative;
  padding-bottom: 1rem;
}

.title.is-3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: var(--gradient-accent);
  border-radius: 2px;
}

/* Content Improvements */
.content.has-text-justified {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.content.has-text-justified p {
  margin-bottom: 1.5rem;
}

/* Footer Improvements */
.footer {
  background: var(--background-secondary);
  border-top: 1px solid var(--border-color);
  padding: 3rem 1.5rem;
}

.footer .content {
  color: var(--text-secondary);
  line-height: 1.7;
}

.footer a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

.footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* BibTeX Styling */
pre {
  background: var(--background-accent) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius) !important;
  padding: 1.5rem !important;
  font-size: 0.9rem !important;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

code {
  background: var(--background-accent) !important;
  color: var(--text-primary) !important;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace !important;
}

/* BibTeX Section Improvements */
.bibtex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.copy-bibtex-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-bibtex-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.copy-bibtex-btn.copied {
  background: #10b981;
}

.copy-bibtex-btn.copied .copy-text::after {
  content: "ied!";
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-lg);
}

.scroll-to-top:hover {
  background: var(--primary-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}


/* More Works Dropdown */
.more-works-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1000;
}

.more-works-btn {
  background: var(--background-primary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Inter', sans-serif;
}

.more-works-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--background-secondary);
  border-color: var(--primary-color);
}

.more-works-btn .dropdown-arrow {
  transition: var(--transition);
  font-size: 0.8rem;
}

.more-works-btn.active .dropdown-arrow {
  transform: rotate(180deg);
}

.more-works-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: var(--transition);
  max-height: 70vh;
  overflow-y: auto;
}

.more-works-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.dropdown-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.close-btn:hover {
  background: var(--background-accent);
  color: var(--text-primary);
}

.works-list {
  padding: 1rem;
}

.work-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  margin-bottom: 0.5rem;
}

.work-item:hover {
  background: var(--background-accent);
  transform: translateX(4px);
}

.work-info h5 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.work-info p {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.work-venue {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
}

.work-item .fas {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 0.2rem;
  flex-shrink: 0;
}


/* Mobile Responsive Improvements */
@media screen and (max-width: 768px) {
  .hero-body {
    padding: 2rem 1rem;
  }
  
  .publication-header .hero-body {
    padding: 3rem 1rem 2rem;
  }
  
  .publication-title {
    font-size: 2.5rem !important;
    line-height: 1.2 !important;
    margin-bottom: 1.5rem !important;
  }
  
  .publication-authors {
    font-size: 1rem !important;
  }
  
  .button {
    margin: 0.25rem !important;
    font-size: 0.875rem !important;
    padding: 0.75rem 1rem !important;
  }
  
  .more-works-container {
    bottom: 2rem;
    right: 1rem;
    top: auto;
  }
  
  .more-works-btn {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
  }
  
  .more-works-dropdown {
    width: calc(100vw - 2rem);
    right: -1rem;
    bottom: calc(100% + 0.5rem);
    top: auto;
  }
  
  .results-carousel .item {
    margin: 0.5rem;
    padding: 1rem;
  }
  
  .teaser .hero-body {
    padding: 1rem;
  }
  
  .content.has-text-justified {
    font-size: 1rem;
  }
}

@media screen and (max-width: 480px) {
  .publication-title {
    font-size: 2rem !important;
  }
  
  .hero-body {
    padding: 1.5rem 0.75rem;
  }
  
  .more-works-container {
    position: fixed;
    bottom: 2rem;
    right: 1rem;
    z-index: 1000;
  }
  
  .more-works-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
  
  .more-works-dropdown {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: calc(100vw - 2rem);
    max-width: 90vw;
  }
  
  .link-block {
    display: block;
    margin-bottom: 0.5rem;
  }
  
  .button {
    width: 100%;
    justify-content: center;
  }
}

/* Tablet Responsive */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .hero-body {
    padding: 3rem 2rem;
  }
  
  .publication-header .hero-body {
    padding: 4rem 2rem 3rem;
  }
}

/* Animation for page load */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero, .section {
  animation: fadeInUp 0.6s ease-out;
}

/* Improved focus states for accessibility */
.button:focus,
.related-works-btn:focus,
a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}


/* Print styles */
@media print {
  .more-works-container {
    display: none;
  }
  
  .hero, .section {
    animation: none;
  }
  
  .button {
    background: transparent !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
  }
}





/* ==========================================================================
   Project-specific styles
   ========================================================================== */

.publication-affiliations {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.publication-affiliations .author-block {
  margin: 0 0.75rem;
}

.publication-venues {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.publication-venues .publication-venue {
  margin: 0;
}

.venue-badge {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: 0.1em;
  color: #fff;
}

.venue-badge.is-oral {
  background: #b91c1c;
}

.venue-badge.is-spotlight {
  background: #b45309;
}

/* Rollout videos */
.teaser .hero-body {
  padding-top: 0;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.video-card {
  margin: 0;
  background: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.video-card.is-ours {
  border-color: #2a78d6;
  box-shadow: 0 0 0 1px #2a78d6, var(--shadow-md);
}

.video-card video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  cursor: pointer;
}

.video-card figcaption {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.75rem 1rem 0.9rem;
  line-height: 1.35;
}

.outcome {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.3rem;
}

.outcome.is-success {
  color: #006300;
  background: #e7f4e7;
}

.outcome.is-failure {
  color: #a32020;
  background: #fbeaea;
}

.video-condition {
  font-weight: 600;
  color: var(--text-primary);
}

.video-method {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.teaser-caption {
  max-width: 52rem;
  margin: 1.5rem auto 0;
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-secondary);
}

/* Figures from the paper */
.paper-figure {
  margin: 0 0 2rem;
}

.paper-figure img {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem;
}

.paper-figure figcaption {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Method */
.method-text {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.method-text a {
  color: var(--primary-color);
}

.method-text .title.is-5 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.site-cards {
  margin: 0.5rem 0 1rem;
}

.site-card {
  height: 100%;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--background-secondary);
  color: var(--text-secondary);
}

.site-card .title.is-5 {
  margin-bottom: 0.75rem;
}

/* Results */
.rq-block {
  margin-bottom: 4rem;
}

.rq-block:last-child {
  margin-bottom: 0;
}

.rq-block > p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.rq-block > p + p {
  margin-top: 1rem;
}

.rq-block > .viz-root + p {
  margin-top: 2rem;
}

.rq-label {
  font-size: 0.8rem !important;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-color) !important;
  margin-bottom: 0.25rem;
}

.rq-block .title.is-4 {
  margin-bottom: 0.75rem;
}

.results-table {
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

.results-table caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.results-table th {
  color: var(--text-primary);
  font-weight: 600;
  vertical-align: bottom;
}

.results-table td + td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.results-table tr.group-row td {
  background: var(--background-accent);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.results-table tr.is-ours td {
  background: #eef4fc;
}

.results-table.is-compact {
  font-size: 0.9rem;
}

.results-table.is-compact td,
.results-table.is-compact th {
  padding: 0.35em 0.75em;
}

.ablation-tables {
  margin-top: 1rem;
}

.table-note {
  font-size: 0.85rem !important;
  margin-top: 1.5rem;
}

/* Setup photo next to the setup text */
.setup-row {
  align-items: flex-start;
}

.setup-photo {
  margin: 0;
}

/* Flow diagram (training procedure) */
.flow-figure {
  --flow-gap: 1.75rem;
  margin: 1.75rem 0 2rem;
}

.flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--flow-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-step {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  min-height: 5.5rem;
  padding: 0.85rem 0.75rem;
  text-align: center;
  background: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.flow-step strong {
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.flow-step .flow-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flow-step.is-phase {
  background: #fff4ec;
  border-color: #f5b48a;
}

.flow-step.is-phase .flow-kicker {
  color: #c2410c;
}

/* Arrow between consecutive steps */
.flow-step + .flow-step::before {
  content: "\2192";
  position: absolute;
  top: 50%;
  left: calc(-1 * var(--flow-gap));
  width: var(--flow-gap);
  transform: translateY(-50%);
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* Return path from the last step back to the first, drawn under the row */
.flow-return {
  --cols: 5;
  position: relative;
  height: 1.4rem;
  margin: 0 calc((100% - (var(--cols) - 1) * var(--flow-gap)) / (2 * var(--cols)));
  border: 2px solid #94a3b8;
  border-top: none;
  border-radius: 0 0 10px 10px;
}

.flow-return::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -7px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid #94a3b8;
}

.flow-return span {
  position: absolute;
  left: 50%;
  bottom: -0.7rem;
  transform: translateX(-50%);
  padding: 0 0.6rem;
  background: var(--background-primary);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.flow-figure figcaption {
  margin-top: 1.6rem;
  font-size: 0.95rem;
  text-align: center;
  color: var(--text-secondary);
}

/* Hero sections are flex containers; keep their container full width even with short content */
.hero > .container {
  width: 100%;
}

/* Result bar charts */
.viz-root {
  --surface: #ffffff;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --series-highlight: #2a78d6;
  --series-muted: #a3a19a;
  position: relative;
  margin-top: 2rem;
  padding: 1.5rem 1.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--surface);
}

.viz-title {
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 0.25rem;
}

.viz-subtitle {
  font-size: 0.875rem;
  color: var(--ink-2);
  margin-bottom: 1rem;
}

.bar-chart {
  --max: 100;
  --ticks: 4;
  display: grid;
  grid-template-columns: minmax(7rem, 13rem) 1fr auto;
}

.bar-chart.is-max-30 {
  --max: 30;
  --ticks: 3;
}

/* Small multiples: one panel per condition, side by side */
.bc-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
}

.bc-panels .bar-chart {
  grid-template-columns: auto 1fr auto;
}

.bc-panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 0.25rem;
}

.bc-label,
.bc-group {
  display: flex;
  justify-content: flex-end;
  text-align: right;
  padding-right: 0.75rem;
  line-height: 1.2;
}

.bc-label {
  align-items: center;
  min-height: 32px;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.bc-label strong {
  color: var(--ink-1);
}

.bc-group {
  align-items: flex-end;
  padding-top: 0.75rem;
  padding-bottom: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.bc-track {
  position: relative;
  min-height: 32px;
  border-left: 1px solid var(--baseline);
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: calc(100% / var(--ticks)) 100%;
  background-repeat: repeat-x;
  box-shadow: inset -1px 0 0 var(--grid);
}

.bc-hit {
  position: absolute;
  inset: 0;
  outline: none;
}

.bc-hit:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
  border-radius: 4px;
}

.bc-bar {
  position: absolute;
  left: 0;
  top: 50%;
  height: 16px;
  width: calc(var(--v) / var(--max) * 100%);
  transform: translateY(-50%);
  background: var(--series-muted);
  border-radius: 0 4px 4px 0;
  transition: filter 0.15s ease;
}

.bc-hit.is-highlight .bc-bar {
  background: var(--series-highlight);
}

.bc-hit:hover .bc-bar,
.bc-hit:focus .bc-bar {
  filter: brightness(1.12);
}

.bc-err {
  position: absolute;
  top: 50%;
  left: calc((var(--v) - var(--s)) / var(--max) * 100%);
  width: calc(var(--s) * 2 / var(--max) * 100%);
  height: 1.5px;
  transform: translateY(-50%);
  background: var(--ink-2);
}

.bc-err::before,
.bc-err::after {
  content: '';
  position: absolute;
  top: -4px;
  width: 1.5px;
  height: 9.5px;
  background: var(--ink-2);
}

.bc-err::before {
  left: 0;
}

.bc-err::after {
  right: 0;
}

.bc-num {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-left: 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bc-num.is-bold {
  font-weight: 600;
  color: var(--ink-1);
}

.bc-axis {
  position: relative;
  height: 1.75rem;
}

.bc-axis span {
  position: absolute;
  top: 0.3rem;
  left: calc(var(--t) / var(--max) * 100%);
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.viz-tooltip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.65rem;
  background: var(--surface);
  border: 1px solid rgba(11, 11, 11, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

.viz-tooltip[hidden] {
  display: none;
}

.viz-tooltip-value {
  font-size: 0.9rem;
  color: var(--ink-1);
}

.viz-tooltip-name {
  font-size: 0.8rem;
  color: var(--ink-2);
}

@media screen and (max-width: 768px) {
  .video-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .setup-photo {
    max-width: 22rem;
    margin: 0 auto;
  }

  /* Flow diagram stacks vertically; the return path becomes a label */
  .flow-figure {
    --flow-gap: 1.4rem;
  }

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

  .flow-step {
    min-height: 0;
  }

  .flow-step + .flow-step::before {
    content: "\2193";
    top: calc(-1 * var(--flow-gap));
    left: 0;
    width: 100%;
    height: var(--flow-gap);
    line-height: var(--flow-gap);
    transform: none;
  }

  .flow-return {
    height: auto;
    margin: 0.75rem 0 0;
    border: none;
    text-align: center;
  }

  .flow-return::before {
    display: none;
  }

  .flow-return span {
    position: static;
    transform: none;
    padding: 0;
  }

  .flow-return span::before {
    content: "\21BB\00a0";
    font-weight: 400;
  }

  .viz-root {
    padding: 1.25rem 1rem 0.75rem;
  }

  .bar-chart,
  .bc-panels .bar-chart {
    grid-template-columns: minmax(0, 6rem) 1fr auto;
  }

  .bc-panels {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .bc-label,
  .bc-group {
    padding-right: 0.5rem;
  }

  .bc-label {
    font-size: 0.75rem;
  }

  .bc-num {
    font-size: 0.7rem;
    padding-left: 0.5rem;
  }

  /* Keep only the major ticks on narrow axes */
  .bc-axis span.is-minor {
    display: none;
  }
}

@media screen and (max-width: 480px) {
  .content.has-text-justified {
    text-align: left !important;
  }
}
