:root {
  --bg: #f4efe4;
  --panel: #fffaf1;
  --ink: #1f1d1a;
  --muted: #6a6256;
  --line: #d9cdb9;
  --accent: #174a7e;
  --accent-2: #8c3b2a;
  --accent-3: #146c43;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(23, 74, 126, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(140, 59, 42, 0.14), transparent 32%),
    var(--bg);
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.hero {
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
}

.panel-head p,
.stat-label {
  color: var(--muted);
}

.panel,
.stat-box {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.9);
  backdrop-filter: blur(4px);
}

.panel {
  position: relative;
  z-index: 0;
  padding: 18px;
  border-radius: 22px;
  margin-bottom: 22px;
}

.panel:hover,
.panel:focus-within {
  z-index: 20;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head p {
  margin: 4px 0 0;
  max-width: 720px;
}

.panel-subhead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  margin-bottom: 10px;
}

.panel-subhead h3 {
  margin: 0;
  font-size: 18px;
}

.panel-subhead p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.collapse-toggle-row {
  align-items: center;
}

.collapse-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.collapse-toggle {
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fffdf7;
  overflow: visible;
}

.card:hover,
.card:focus-within {
  z-index: 60;
}

.card.active {
  border-color: rgba(23, 74, 126, 0.55);
  box-shadow: 0 0 0 2px rgba(23, 74, 126, 0.08);
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.card .kind {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.card .meta {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 12px;
}

.metric {
  border-top: 1px solid rgba(217, 205, 185, 0.7);
  padding-top: 8px;
}

.metric-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-value {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf7;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
}

.filter-layout {
  display: grid;
  gap: 14px;
}

.filter-cluster {
  position: relative;
  display: grid;
  gap: 8px;
  overflow: visible;
}

.filter-cluster:hover,
.filter-cluster:focus-within {
  z-index: 80;
}

.filter-sections {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-section {
  position: relative;
  border: 1px solid rgba(217, 205, 185, 0.85);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 253, 247, 0.72);
  overflow: visible;
}

.filter-section:hover,
.filter-section:focus-within {
  z-index: 40;
}

.filter-section-display {
  background: rgba(231, 241, 251, 0.52);
  border-color: rgba(23, 74, 126, 0.18);
}

.filter-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-section-head h3 {
  margin: 0;
  font-size: 18px;
}

.filter-section-head p {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 14px;
}

.cluster-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.help-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 1;
}

.help-wrap:hover,
.help-wrap:focus-within {
  z-index: 200;
}

.help-badge {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(23, 74, 126, 0.3);
  background: rgba(23, 74, 126, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.help-badge:hover,
.help-badge:focus-visible {
  border-color: rgba(23, 74, 126, 0.55);
  background: rgba(23, 74, 126, 0.14);
}

.help-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  min-width: 220px;
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid rgba(217, 205, 185, 0.95);
  border-radius: 12px;
  background: rgba(31, 29, 26, 0.96);
  color: #fffaf1;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
}

.help-wrap:hover .help-tooltip,
.help-wrap:focus-within .help-tooltip {
  opacity: 1;
  visibility: visible;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf7;
  color: var(--ink);
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.toggle-btn:hover {
  border-color: rgba(23, 74, 126, 0.38);
  transform: translateY(-1px);
}

.toggle-btn:disabled,
.toggle-btn:disabled:hover {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  border-color: var(--line);
}

.toggle-btn.active {
  background: #e7f1fb;
  border-color: rgba(23, 74, 126, 0.5);
  color: var(--accent);
}

.filter-cluster.preset-dimmed {
  opacity: 0.35;
  pointer-events: none;
}

.drawer-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.76);
  overflow: hidden;
}

.drawer-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(217, 205, 185, 0.7);
}

.drawer-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.drawer-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-page-label {
  min-width: 104px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.table-shell {
  max-height: 560px;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fffdf7;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(217, 205, 185, 0.7);
  text-align: left;
  font-size: 14px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8f1e4;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background: rgba(23, 74, 126, 0.05);
}

.pdb-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.pdb-link:hover,
.pdb-link:focus-visible {
  text-decoration: underline;
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  border: 1px solid rgba(217, 205, 185, 0.9);
  background: #f7efe0;
}

.pill.adna {
  color: #8c3b2a;
  background: rgba(140, 59, 42, 0.08);
}

.pill.bdna {
  color: #174a7e;
  background: rgba(23, 74, 126, 0.08);
}

.pill.zdna {
  color: #146c43;
  background: rgba(20, 108, 67, 0.08);
}

.pill.quadruplex {
  color: #6f2dbd;
  background: rgba(111, 45, 189, 0.08);
}

.pill.triplex {
  color: #c46b00;
  background: rgba(196, 107, 0, 0.08);
}

.pill.double_other {
  color: #3f6f8a;
  background: rgba(63, 111, 138, 0.08);
}

.pill.annotated_other {
  color: #6c4f35;
  background: rgba(108, 79, 53, 0.08);
}

.pill.parallel_other {
  color: #b24c63;
  background: rgba(178, 76, 99, 0.08);
}

.pill.unannotated {
  color: #7a756c;
  background: rgba(122, 117, 108, 0.08);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  position: relative;
  padding: 12px 14px;
  border-radius: 16px;
  overflow: visible;
}

.stat-box:hover,
.stat-box:focus-within {
  z-index: 80;
}

.stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.stat-value {
  font-size: 26px;
}

.plot-panel {
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,250,241,0.72));
  padding: 12px 12px 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
  font-size: 16px;
}

.plot-panel .js-plotly-plot,
.plot-panel .plot-container,
.plot-panel .svg-container {
  width: 100% !important;
  max-width: 100%;
}

.small-multiple-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mini-panel {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
  padding: 12px;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.mini-panel:hover {
  border-color: rgba(23, 74, 126, 0.45);
  transform: translateY(-1px);
}

.mini-panel.active {
  border-color: rgba(23, 74, 126, 0.7);
  box-shadow: 0 10px 22px rgba(23, 74, 126, 0.08);
}

.mini-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.mini-title {
  margin: 0;
  font-size: 18px;
}

.mini-meta {
  font-size: 13px;
  color: var(--muted);
}

.mini-plot {
  height: 220px;
  overflow: hidden;
  border-radius: 12px;
}

.mini-plot .js-plotly-plot,
.mini-plot .plot-container,
.mini-plot .svg-container {
  width: 100% !important;
  max-width: 100%;
}

.joint-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.joint-plot-panel {
  width: min(100%, 860px);
  aspect-ratio: 1 / 1;
  min-height: 0;
  margin: 0 auto;
}

.joint-plot-panel .js-plotly-plot,
.joint-plot-panel .plot-container,
.joint-plot-panel .svg-container {
  height: 100% !important;
}

.joint-plot-panel .empty-state {
  min-height: 100%;
}

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

@media (max-width: 820px) {
  .help-tooltip {
    left: 0;
    transform: none;
  }
}

@media (max-width: 700px) {
  .small-multiple-grid {
    grid-template-columns: 1fr;
  }
}
