/* Root variables */
:root {
  --bg-color: #fafbfd;
  --bg-elevated: #ffffff;
  --bg-alt: #f4f6f9;
  --text-primary: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: #8896a6;
  --border-color: #e8ecf2;
  --brand-color: #1a6b7a;
  --brand-light: #e8f4f6;
  --accent-color: #c0392b;

  --m-maskrcnn: #2563eb;
  --m-pointrend: #0891b2;
  --m-condinst: #059669;
  --m-solov2: #d97706;
  --m-yolov8: #dc2626;
  --m-stardist: #7c3aed;
  --m-mask2former: #db2777;

  /* ONLY TWO FONTS FOR THE ENTIRE WEBSITE */
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  color-scheme: light;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg-color: #0f1219;
  --bg-elevated: #1a1f2e;
  --bg-alt: #151a25;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #64748b;
  --border-color: #2d3748;
  --brand-color: #38bdf8;
  --brand-light: rgba(56, 189, 248, 0.1);
  --accent-color: #f87171;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -2px rgba(0,0,0,0.2);

  color-scheme: dark;
}

/* Base reset and typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

a {
  color: var(--brand-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

strong {
  font-weight: 600;
  color: var(--text-primary);
}

em {
  font-style: italic;
}

sup {
  font-size: 0.75em;
  vertical-align: super;
}

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

/* Layout */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container.narrow {
  max-width: 820px;
}

/* Left Floating Navigation Sidebar (Strict Margin Positioning - Zero Overlap) */
.sidebar-toc {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: calc(50vw - 740px);
  width: 160px;
  z-index: 90;
  display: flex;
  flex-direction: column;
}

/* Semi-translucent Academic Tab Bar for Tablet & Mobile (visible < 1460px after abstract) */
.mobile-section-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(250, 251, 253, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(232, 236, 242, 0.85);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  z-index: 900;
  padding: 0;
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.03);
}

.mobile-section-nav.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.mobile-section-nav__inner {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  overflow-x: auto;
  padding: 0 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mobile-section-nav__inner::-webkit-scrollbar {
  display: none;
}

.mobile-nav__link {
  flex-shrink: 0;
  padding: 0.65rem 0.15rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mobile-nav__link:hover,
.mobile-nav__link.active {
  color: var(--brand-color);
  background: transparent;
  border-bottom-color: var(--brand-color);
  font-weight: 600;
}

.toc__title {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-weight: 600;
  padding-left: 0.75rem;
}

.toc__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-left: 2px solid var(--border-color);
  padding-left: 0;
  margin: 0;
}

.toc__link {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  margin-left: -2px;
  border-left: 2px solid transparent;
  line-height: 1.35;
  text-align: left;
}

.toc__link:hover,
.toc__link.active {
  color: var(--brand-color);
  border-left-color: var(--brand-color);
  font-weight: 600;
}

/* Navigation Header */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(250, 251, 253, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease, padding 0.3s ease;
  padding: 1.2rem 0;
}

.nav.scrolled {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-color);
}

.nav__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav__logo {
  height: 24px;
  width: auto;
}

.nav__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav__links a {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.nav__links a:hover,
.nav__links a.active {
  color: var(--brand-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--brand-color);
  color: #ffffff;
  font-weight: 500;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn:hover {
  background-color: #134e5a;
  color: #ffffff;
}

.btn--small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.nav__burger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

/* Hero section */
.hero {
  padding: 3.5rem 0 1rem;
  text-align: center;
}

.hero__inner {
  max-width: 900px;
  margin: 0 auto;
}

.eyebrow {
  display: inline-block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-color);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero__title {
  font-size: 2.8rem;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  line-height: 1.25;
}

.hero__venue {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.hero__stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat__num {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat__label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero__scroll {
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 1.5rem;
  display: inline-block;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  60% { transform: translateY(-4px); }
}

/* Sections */
.section {
  padding: 4rem 0;
}

#abstract.section {
  padding-top: 1.25rem;
}

.section--alt {
  background-color: var(--bg-alt);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.section--tldr {
  padding: 3.5rem 0;
}

.section__head {
  text-align: center;
  margin-bottom: 2.5rem;
}

.kicker {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brand-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.section__head h2 {
  font-size: 2.1rem;
  margin-bottom: 0.75rem;
}

.section__lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 720px;
  margin: 0 auto;
}

.prose {
  max-width: 800px;
  margin: 0 auto;
}

.prose p {
  margin-bottom: 1.25rem;
  font-size: 1.02rem;
  line-height: 1.68;
}

.prose h3 {
  font-size: 1.3rem;
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
}

.keywords {
  margin-top: 2rem;
  font-size: 0.9rem;
}

/* Key findings cards (Compact 4-column) */
.tldr-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  width: 100%;
}

.tldr-card {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--c, var(--brand-color));
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.tldr-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}

.tldr-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c, var(--brand-color));
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.tldr-card h3 {
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 0;
  line-height: 1.35;
  color: var(--text-primary);
}

.tldr-card p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.48;
  margin-bottom: 0.85rem;
}

.tldr-card__tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background-color: var(--brand-light);
  color: var(--brand-color);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  align-self: flex-start;
}

/* Figures (Clean, non-card presentation) */
.figure {
  margin: 2.5rem 0;
  text-align: center;
}

.figure__media {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  background-color: var(--bg-alt);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 180px;
  transition: background-color 0.3s ease;
}

.figure__media.is-loading {
  background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.figure__media.is-loaded-parent {
  background-color: transparent;
  min-height: auto;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.figure__media img {
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.35s ease-in-out;
}

.figure__media img.is-loaded {
  opacity: 1;
}

.figure__media--contain img {
  max-width: 720px;
}

.figure__media--small img {
  max-width: 440px;
}

.figure__media--small-fig2 img {
  max-width: 320px;
}

.figure__media--tiny img {
  max-width: 300px;
}

.figure__cap {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
  text-align: center;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.figure--full {
  max-width: 100%;
}

/* Side-by-side & Parallel Layouts */
.side-by-side {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin: 2rem 0;
  width: 100%;
}

.side-by-side > .prose-col,
.side-by-side > .media-col,
.side-by-side > .table-col {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.side-by-side--bsd {
  align-items: flex-start;
  gap: 2.5rem;
}

@media (min-width: 1024px) {
  .side-by-side--fig12 {
    gap: 3rem;
  }
  .side-by-side--fig12 > .prose-col {
    flex: 1;
  }
  .side-by-side--fig12 > .media-col {
    flex: 1.65;
  }
  .side-by-side--fig12 .figure__media img {
    max-height: 840px !important;
  }
}

.figures-parallel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
  align-items: start;
  width: 100%;
}

.figures-parallel .figure {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.figures-parallel .figure__media {
  width: 100%;
  max-width: 100%;
}

.figures-parallel .figure__media img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* 2-column layout that stays side-by-side even on small mobile screens */
.figures-parallel-2col-always {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0;
  align-items: start;
  width: 100%;
}

.figures-parallel-2col-always .figure {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.figures-parallel-2col-always .figure__media {
  width: 100%;
}

.figures-parallel-2col-always .figure__media img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1180px) {
  .side-by-side {
    flex-direction: column;
    align-items: stretch;
    gap: 1.75rem;
  }
  .side-by-side > .table-col,
  .side-by-side > .media-col,
  .side-by-side > .prose-col {
    width: 100%;
    flex: none;
  }
}

@media (max-width: 900px) {
  .figures-parallel {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

/* Specs grid (Compact Parameter Grid) */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1.5rem 0;
  width: 100%;
}

.spec {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.75rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.spec__k {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spec__v {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.spec__v small {
  display: block;
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.25;
}

/* Model cards (Collapsible) */
.models-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 2rem;
}

details.model-card {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--mc, var(--brand-color));
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

details.model-card:hover {
  box-shadow: var(--shadow-md);
}

summary.model-card__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background-color: var(--bg-elevated);
}

summary.model-card__summary::-webkit-details-marker {
  display: none;
}

.model-card__summary-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.model-card__name-wrap {
  display: flex;
  flex-direction: column;
}

.model-card__name {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.1rem;
}

.model-card__sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.model-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.model-card__tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  background-color: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.model-card__chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

details.model-card[open] summary.model-card__summary .model-card__chevron {
  transform: rotate(180deg);
}

.model-card__content {
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
}

.model-card__body {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

.model-card__body p {
  margin-bottom: 0;
}

.model-card__arch {
  width: 100%;
  background-color: #fafbfc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.model-card__arch img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: contain;
  display: block;
}

.model-card__arch .svg-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.model-card__arch-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  text-align: center;
}

/* Tables (Compact Academic Style) */
.table-wrap {
  width: 100%;
  max-width: 820px;
  margin: 1.75rem auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

thead th {
  background-color: var(--bg-alt);
  font-weight: 600;
  padding: 0.7rem 0.85rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.84rem;
  white-space: nowrap;
}

tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.88rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

.num {
  font-family: var(--font-sans);
  font-weight: 500;
  text-align: right;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background-color: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--mc, var(--text-secondary));
  border: 1px solid color-mix(in srgb, var(--mc, var(--border-color)) 25%, transparent);
}

tr.best td {
  font-weight: 600;
  background-color: rgba(26, 107, 122, 0.03);
}

tr.best td:first-child {
  border-left: 3px solid var(--brand-color);
}

/* Formulas */
.formula {
  padding: 1.5rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
  margin: 2rem 0;
  overflow-x: auto;
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

/* Callout */
.callout {
  padding: 1.5rem;
  background-color: var(--brand-light);
  border-left: 4px solid var(--brand-color);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 2rem 0;
  color: var(--text-primary);
}

/* Discussion grid */
.discuss-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.discuss {
  padding: 1.5rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--mc, var(--brand-color));
  border-radius: var(--radius-md);
}

.discuss h4 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.discuss p {
  font-size: 0.92rem;
  margin-bottom: 0;
}

/* Footer with Author & Institution Information */
.footer {
  background-color: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  padding: 4rem 0 2.5rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.8fr 1.3fr 1.1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}

.footer__brand h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.footer h4 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.footer p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}

.footer__bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}

/* Image Preview Modal (Light Backdrop showing page bg) */
.img-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.img-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.img-modal__overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(250, 251, 253, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.img-modal__content {
  position: relative;
  z-index: 1001;
  width: 92vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.img-modal__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-color);
  border-bottom: none;
  color: var(--text-primary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.img-modal__caption {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.img-modal__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.img-modal__btn {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.img-modal__btn:hover {
  background: var(--brand-light);
  color: var(--brand-color);
  border-color: var(--brand-color);
}

.img-modal__btn--close {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.6rem;
  margin-left: 0.5rem;
}

.img-modal__stage {
  flex: 1;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  position: relative;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  user-select: none;
  box-shadow: var(--shadow-lg);
}

.img-modal__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(26, 107, 122, 0.18);
  border-top-color: var(--brand-color);
  border-radius: 50%;
  animation: spin-modal-loader 0.75s linear infinite;
  z-index: 10;
  pointer-events: none;
  display: none;
}

.img-modal__spinner.active {
  display: block;
}

@keyframes spin-modal-loader {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.img-modal__stage img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  transition: transform 0.15s ease-out, opacity 0.25s ease-in-out;
  transform-origin: center center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

/* ===== DARK MODE OVERRIDES FOR HARDCODED COLORS ===== */
[data-theme="dark"] .nav {
  background-color: rgba(15, 18, 25, 0.92);
}

[data-theme="dark"] .mobile-section-nav {
  background-color: rgba(15, 18, 25, 0.85);
  border-bottom-color: rgba(45, 55, 72, 0.85);
}

[data-theme="dark"] .img-modal__overlay {
  background-color: rgba(15, 18, 25, 0.85);
}

[data-theme="dark"] .img-modal__toolbar {
  background-color: rgba(26, 31, 46, 0.95);
}

[data-theme="dark"] .img-modal__stage {
  background-color: rgba(26, 31, 46, 0.92);
}

[data-theme="dark"] .model-card__content {
  background-color: var(--bg-elevated);
}

[data-theme="dark"] .model-card__arch {
  background-color: var(--bg-alt);
}

[data-theme="dark"] .btn:hover {
  background-color: #0c4a5a;
}

[data-theme="dark"] .figure__media.is-loading {
  background: linear-gradient(90deg, #1a1f2e 25%, #252d3f 50%, #1a1f2e 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

[data-theme="dark"] tr.best td {
  background-color: rgba(56, 189, 248, 0.05);
}

[data-theme="dark"] .img-modal__spinner {
  border-color: rgba(56, 189, 248, 0.18);
  border-top-color: var(--brand-color);
}

/* ===== FIXED DARK MODE TOGGLE SWITCH (Top Right) ===== */
.theme-switch {
  position: fixed;
  top: 1.1rem;
  right: 1.5rem;
  z-index: 999;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
}

.theme-switch__track {
  position: relative;
  display: flex;
  align-items: center;
  width: 52px;
  height: 28px;
  background-color: var(--border-color);
  border-radius: 14px;
  padding: 0 4px;
  transition: background-color 0.3s ease;
}

.theme-switch:hover .theme-switch__track {
  background-color: var(--text-muted);
}

.theme-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background-color: var(--bg-elevated);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

[data-theme="dark"] .theme-switch__thumb {
  transform: translateX(24px);
  background-color: #1e293b;
}

[data-theme="dark"] .theme-switch__track {
  background-color: #38bdf8;
}

[data-theme="dark"] .theme-switch:hover .theme-switch__track {
  background-color: #7dd3fc;
}

.theme-switch__icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  transition: opacity 0.25s ease;
}

.theme-switch__icon--moon {
  right: 6px;
  color: #64748b;
  opacity: 1;
}

.theme-switch__icon--sun {
  left: 6px;
  color: #ffffff;
  opacity: 0;
}

[data-theme="dark"] .theme-switch__icon--moon {
  opacity: 0;
}

[data-theme="dark"] .theme-switch__icon--sun {
  opacity: 1;
}


/* Mobile inline theme toggle (inside mobile section nav) */
.mobile-theme-btn {
  flex-shrink: 0;
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.mobile-theme-btn:hover,
.mobile-theme-btn:active {
  color: var(--brand-color);
  border-color: var(--brand-color);
  background-color: var(--brand-light);
}

.mobile-theme-btn svg {
  width: 16px;
  height: 16px;
}

.mobile-nav__sep {
  flex-shrink: 0;
  width: 1px;
  height: 18px;
  background-color: var(--border-color);
}

@media (max-width: 1460px) {
  .sidebar-toc { display: none; }
  .mobile-section-nav { display: block; }
  .theme-switch { display: none; }
}

@media (max-width: 1024px) {
  .tldr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
  .hero__title { font-size: 2.2rem; }
  .spec-grid { grid-template-columns: 1fr; }
  .bsd-grid { grid-template-columns: 1fr; }
  .discuss-grid { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr; }
  .side-by-side { flex-direction: column; gap: 1.5rem; }
  .figures-parallel { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .figures-parallel {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
  .spec-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  html, body {
    overflow-x: hidden;
  }
  
  .container {
    padding: 0 1rem;
  }
  
  .figure__media img,
  .media-col img {
    max-width: 100% !important;
    max-height: 65vh !important;
    height: auto !important;
    width: auto !important;
  }

  .figure__media--small-fig2 img {
    max-width: 200px !important;
    margin: 0 auto;
  }

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

  .spec {
    padding: 0.45rem 0.55rem;
  }

  .spec__k {
    font-size: 0.68rem;
  }

  .spec__v {
    font-size: 0.8rem;
  }

  .nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
  }
  .nav__links.open { display: flex; }
  .nav__burger { display: block; }
  .hero__title { font-size: 1.75rem; }
  .hero__stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 0.75rem;
    padding-top: 1.25rem;
    margin-top: 1.5rem;
  }
  .stat__num { font-size: 1.6rem; }
  .stat__label { font-size: 0.7rem; }
  .tldr-grid { grid-template-columns: 1fr; }
}
