:root {
  --bg: #eeeeee;
  --bg-deep: #e8e8e8;
  --bg-wash: #f8ecec;
  --card: #ffffff;
  --ink: #15202b;
  --muted: #5b6b7a;
  --brand: #b42318;
  --brand-2: #d64545;
  --brand-soft: #fde8e6;
  --accent: #d97706;
  --accent-soft: #fff4e5;
  --line: #d5e0e8;
  --shadow: 0 8px 24px rgba(21, 32, 43, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  /* FarmGTEx-like soft pastel wash over light gray */
  background-color: var(--bg);
  background-image:
    url("/static/img/farmgtex_bg_gradient.png"),
    linear-gradient(180deg, var(--bg-wash) 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  background-attachment: fixed, fixed;
  background-position: center top, center;
  min-height: 100%;
}
a { color: inherit; text-decoration: none; }
.container { width: min(1140px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  background: linear-gradient(90deg, #7a1414 0%, #b42318 55%, #d64545 100%);
  color: #fff5f4;
  font-size: 13px;
  letter-spacing: 0.01em;
}
.topbar-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.topbar a { color: #fff; opacity: 0.95; }
.topbar a:hover { text-decoration: underline; }

.nav {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.logo {
  font-family: "Fraunces", Georgia, serif;
  font-size: 30px;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.menu { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.menu a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
}
.menu a.active, .menu a:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 30;
}
.dropdown:hover .dropdown-menu { display: grid; gap: 2px; }
.dropdown-menu a {
  border-radius: 8px;
  padding: 10px 12px;
}

.hero {
  padding: 52px 0 30px;
}
.hero h1 {
  margin: 0 0 14px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: #5c1510;
}
.hero p {
  margin: 0;
  max-width: 740px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 92, 99, 0.22);
}
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn:hover { transform: translateY(-1px); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 28px 0 36px;
}
.stat, .card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat {
  padding: 18px;
  border-top: 3px solid var(--brand);
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat .value {
  margin-top: 8px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--brand);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-bottom: 36px;
}
.card { padding: 22px; }
.card h2, .panel h2 {
  margin: 0 0 10px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.card p, .muted { color: var(--muted); line-height: 1.65; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  padding: 7px 11px;
  border-radius: 8px;
  background: #fde8e6;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  border: 1px solid #f3cfc9;
}
.chip a:hover { color: var(--brand); }

.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 16px;
}
.search-bar input,
.search-bar select,
.hero-search input {
  flex: 1;
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 16px;
  outline: none;
  background: #fff;
}
.search-bar input:focus,
.search-bar select:focus,
.hero-search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 92, 99, 0.14);
}
.hero-search {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
  max-width: 740px;
  padding: 10px;
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.hero-search input {
  border: none;
  box-shadow: none;
  background: transparent;
  min-width: 180px;
}
.hero-search input:focus { box-shadow: none; }
.sc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}
.sc-tabs a {
  padding: 8px 12px;
  border-radius: 8px;
  background: #fde8e6;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid transparent;
}
.sc-tabs a.active, .sc-tabs a:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #f3cfc9;
}
.feature-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.75;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 18px;
}
.footer h4 { margin: 0 0 10px; color: var(--ink); font-family: "Fraunces", Georgia, serif; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--brand); }
.ext { color: var(--brand-2); font-weight: 700; }
.image-box, .umap-grid {
  min-height: 220px;
  border: 1px dashed #c9d8e2;
  border-radius: 10px;
  padding: 12px;
  background: #f4f8fa;
}
.image-box img, .umap-grid img, .plot-card img {
  width: 100%;
  border-radius: 10px;
  background: #fff;
}
.umap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.panel-head h2 {
  margin: 0;
}
.btn-download {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
}
.plot-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plot-card .btn-download {
  align-self: flex-end;
}
.contact-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.author-card {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.author-card img {
  width: 150px;
  height: 180px;
  object-fit: cover;
  border-radius: 10px;
  background: #fde8e6;
}
.author-card h2 {
  margin: 0 0 8px;
  font-family: "Fraunces", Georgia, serif;
}
.overview-figure {
  margin-bottom: 16px;
}
.stage-overview {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 14px 0 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.stage-grouping {
  margin: 12px 0 14px;
  color: var(--ink, #15202b);
  line-height: 1.65;
  font-size: 14.5px;
}
.publication-card .publication-cite {
  margin: 0;
  line-height: 1.7;
  font-size: 14.5px;
  color: var(--ink, #15202b);
}
.publication-card .publication-cite em {
  font-style: italic;
}
.publication-card .publication-note {
  margin-top: 10px;
}
.spatial-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}
.spatial-card { display: block; transition: transform .15s ease; }
.spatial-card:hover { transform: translateY(-2px); }
.spatial-card-media {
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
  background: #fde8e6;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spatial-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.he-image {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.histology-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.histology-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.histology-frame {
  position: relative;
  height: 360px;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1a1f;
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.histology-frame .he-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.histology-frame .muted {
  padding: 16px;
  text-align: center;
}
.ssdna-cta-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
  color: #e8f0f3;
  background: linear-gradient(180deg, transparent, rgba(8, 18, 22, 0.78));
  pointer-events: none;
}
.ssdna-card {
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ssdna-card:hover {
  transform: translateY(-2px);
}
.ssdna-card.disabled {
  pointer-events: none;
  opacity: 0.7;
}
.ssdna-mask-wrap {
  position: relative;
  height: min(72vh, 720px);
  min-height: 420px;
  background: #0b1a1f;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.ssdna-mask-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.ssdna-mask-wrap canvas:active {
  cursor: grabbing;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.viewer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.viewer-head h2 { margin-bottom: 4px; }
.viewer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  justify-content: flex-end;
}
.point-size-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.point-size-ctrl input[type="range"] {
  width: 120px;
  accent-color: var(--brand, #b42318);
}
#pointSizeValue,
#sampleRateValue,
#transparencyValue {
  min-width: 2.8em;
  color: var(--ink, #15202b);
  font-weight: 700;
}
.viewer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
  align-items: stretch;
}
.viewer-wrap {
  position: relative;
  height: 640px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #f7fbfc;
}
#spatialCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.viewer-legend {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px 12px;
  overflow: auto;
  max-height: 640px;
}
.viewer-legend h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.legend-hint {
  margin: 0 0 10px;
  font-size: 12px;
}
.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-list li,
.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 12.5px;
  line-height: 1.35;
}
.legend-item {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  user-select: none;
}
.legend-item:hover {
  background: rgba(13, 92, 99, 0.06);
}
.legend-item.is-off {
  opacity: 0.38;
}
.legend-item.is-off .swatch {
  background: #c5ced3 !important;
}
.legend-list .swatch {
  margin: 3px 0 0;
}
.legend-name { color: var(--ink, #15202b); }
.legend-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.spatial-tooltip {
  position: fixed;
  z-index: 50;
  background: rgba(21, 32, 43, 0.92);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.spatial-tooltip .muted-tip {
  opacity: 0.8;
  font-size: 12px;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.panel {
  padding: 18px;
  margin-bottom: 18px;
  border-left: 4px solid var(--brand);
}
.chart {
  width: 100%;
  height: 580px;
}
.chart-heatmap {
  height: 620px;
}
.chart-sm { height: 420px; }
.note {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #8a4b08;
  font-size: 13px;
  line-height: 1.5;
}
.footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  padding: 32px 0 42px;
  color: var(--muted);
  font-size: 13px;
}
.status {
  min-height: 22px;
  margin: 4px 0 10px;
  color: var(--brand-2);
  font-weight: 700;
}
.error { color: #b42318; }

@media (max-width: 900px) {
  .stats, .grid-2, .footer-grid, .umap-grid, .contact-info-grid, .spatial-grid, .histology-pair { grid-template-columns: 1fr 1fr; }
  .author-card { grid-template-columns: 120px 1fr; }
  .viewer-wrap { height: 480px; }
  .viewer-layout { grid-template-columns: 1fr; }
  .viewer-legend { max-height: none; }
}
@media (max-width: 640px) {
  .stats, .grid-2, .footer-grid, .umap-grid, .contact-info-grid, .spatial-grid, .histology-pair { grid-template-columns: 1fr; }
  .author-card { grid-template-columns: 1fr; }
  .author-card img { width: 120px; height: 140px; }
  .chart, .chart-sm { height: 360px; }
  .viewer-wrap { height: 420px; }
  .viewer-layout { grid-template-columns: 1fr; }
  .histology-frame { height: 280px; min-height: 280px; }
}
