:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.97);
  --panel-border: rgba(71, 85, 105, 0.14);
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-2: #059669;
  --log-bg: #111827;
  --log-ink: #e5eefc;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --run-panel-height: 720px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.1), transparent 26%),
    radial-gradient(circle at top right, rgba(5, 150, 105, 0.08), transparent 22%),
    var(--bg);
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-brand {
  display: flex;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: #2563eb;
}

.eyebrow-subtitle {
  margin-left: 0.7rem;
  text-transform: none;
  letter-spacing: 0.08em;
  font-size: 0.62rem;
  color: #64748b;
  white-space: nowrap;
}

.hero h1 {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1;
}

.lede {
  max-width: none;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.docs-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.grid,
.plots {
  display: grid;
  gap: 18px;
}

.grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.grid > .panel {
  height: 660px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grid > .panel.hidden {
  display: none;
}

.plots {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.differential-plots {
  grid-template-columns: minmax(0, 3fr) minmax(320px, 1fr);
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(8px);
}

#upload-panel {
}

#reference-preview-panel {
  grid-column: span 3;
  min-height: 0;
  padding: 8px;
}

#job-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

#qc-panel,
#qc-live-panel,
#results-panel,
#differential-panel {
  min-height: 0;
}

#qc-form,
#results-form,
#differential-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-copy {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.differential-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.differential-head-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.differential-head-download-row {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.field-group-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.reference-study-link {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--accent);
  text-decoration: none;
}

.reference-study-link span {
  font: inherit;
  color: inherit;
}

.reference-study-link .reference-study-marker {
  flex: none;
  font-size: 0.7em;
}

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

.differential-group-label {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

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

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(100, 116, 139, 0.22);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

select[multiple] {
  min-height: 156px;
}

#differential-group1,
#differential-group2 {
  min-height: 104px;
  max-height: 104px;
  overflow-y: auto;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.65);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

input:disabled,
select:disabled {
  background: rgba(226, 232, 240, 0.75);
  color: rgba(100, 116, 139, 0.95);
  cursor: not-allowed;
}

.sample-row {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(29, 78, 216, 0.28);
  background: rgba(255, 255, 255, 0.7);
  margin-bottom: 10px;
  display: grid;
  gap: 8px;
}

.sample-inline-field {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 0;
  margin-bottom: 0;
}

.sample-inline-label {
  margin: 0;
  white-space: nowrap;
}

.sample-inline-field input {
  min-width: 0;
}

.sample-inline-field input[type="file"] {
  padding: 8px 12px;
}

.sample-field {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

#sample-container {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 280px;
  overflow-y: auto;
  padding: 10px;
  padding-right: 8px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.88);
}

#job-form > .primary-btn {
  margin-top: auto;
}

.progress-shell {
  margin-top: 16px;
  flex: 0 0 auto;
}

.log-view {
  flex: 1 1 auto;
  min-height: 0;
}

.sample-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.download-btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.primary-btn {
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: #fff;
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.18);
}

.secondary-btn {
  background: rgba(59, 130, 246, 0.08);
  color: var(--ink);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.86);
  color: #0f766e;
  border: 1px solid rgba(5, 150, 105, 0.22);
  padding: 6px 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.display-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
}

.compact-field {
  margin-bottom: 0;
}

#viz1-filter1-values,
#viz1-filter2-values,
#viz2-filter1-values,
#viz2-filter2-values {
  min-height: 0;
  max-height: none;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(29, 78, 216, 0.08);
  color: #1d4ed8;
}

#upload-job-id-display {
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hidden {
  display: none;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.12);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #2563eb);
  transition: width 0.25s ease;
}

.progress-label {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.log-view {
  margin: 14px 0 0;
  min-height: 96px;
  padding: 12px;
  border-radius: 14px;
  background: var(--log-bg);
  color: var(--log-ink);
  overflow-y: auto;
  font-size: 0.8rem;
}

#job-log {
  flex: 0 0 120px;
  max-height: 120px;
}

.downloads {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

#differential-archive-link,
#differential-log-link {
  margin-top: 8px;
}

.download-btn {
  background: rgba(29, 78, 216, 0.08);
  color: #1e40af;
}

.plot-area {
  min-height: 420px;
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
}

.morpheus-frame {
  width: 100%;
  min-height: 640px;
  height: 100%;
  border: 0;
  border-radius: 14px;
  background: #fff;
}

.plot-caption {
  min-height: 18px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.grn-description {
  margin: 12px 0 4px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

#reference-preview-plot {
  min-height: 100%;
}

.static-plot-shell {
  min-height: 420px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.static-plot {
  display: block;
  width: 100%;
  height: auto;
}

.interactive-plot-shell {
  min-height: 640px;
  max-height: 760px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.24);
  overflow: auto;
  position: relative;
}

.interactive-plot-area {
  min-height: 640px;
  width: 100%;
}

.differential-primary-panel,
.differential-secondary-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.differential-secondary-panel .panel-head {
  align-items: flex-start;
}

.selected-gene-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
}

.lr-toggle {
  display: inline-flex;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
}

.lr-toggle-btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f766e;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lr-toggle-btn + .lr-toggle-btn {
  border-left: 1px solid rgba(15, 118, 110, 0.35);
}

.lr-toggle-btn:hover {
  background: rgba(15, 118, 110, 0.12);
}

.lr-toggle-btn.active {
  background: #0f766e;
  color: #fff;
}

.gene-detail-shell {
  min-height: 420px;
  max-height: 560px;
}

#differential-gene-plot {
  min-height: 420px;
}

.gene-stats {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(241, 245, 249, 0.82);
  color: var(--ink);
  display: grid;
  gap: 8px;
}

.gene-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gene-stat {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
}

.gene-stat-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gene-stat-value {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
}

.empty-state {
  padding: 32px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.compact-select {
  max-width: 220px;
}

#differential-result-population {
  min-width: 280px;
}

/* Differential gene filter: one gene restricts every view to that gene and the genes it
   interacts with in the selected cell state. It sits beside the cell-state select. */
.compact-input {
  max-width: 190px;
  padding: 8px 10px;
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.9rem;
  font-family: inherit;
}

.compact-input:focus {
  outline: none;
  border-color: #1f19c7;
  box-shadow: 0 0 0 3px rgba(31, 25, 199, 0.16);
}

.compact-input.filter-active {
  border-color: #1f19c7;
  background: #eef2ff;
}

.compact-input.filter-unmatched {
  border-color: #dc2626;
  background: #fef2f2;
}

.differential-filter-note {
  font-size: 0.78rem;
  color: #475569;
  justify-content: flex-end;
  text-align: right;
  max-width: 520px;
}

@media (max-width: 1100px) {
  .grid,
  .plots {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero-brand {
    align-items: flex-start;
  }

  .grid > .panel {
    height: auto;
    overflow: visible;
  }

  #upload-panel {
    height: auto;
  }

  #reference-preview-panel {
    grid-column: auto;
    height: auto;
  }

  #sample-container {
    max-height: 360px;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 18px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .gene-stat-grid {
    grid-template-columns: 1fr;
  }

  .sample-inline-field {
    grid-template-columns: 1fr;
    row-gap: 6px;
  }
}

.compact-shell {
  min-height: 100vh;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.compact-hero {
  max-width: 100%;
  margin: 0;
  align-items: center;
  gap: 16px;
  position: relative;
  display: flex;
  justify-content: space-between;
}

.compact-hero .hero-copy {
  min-width: 0;
}

.compact-hero h1 {
  font-size: 2.4rem;
}

.sandbox-main {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
}

.sandbox-run-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sandbox-run-grid.preupload-mode {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.sandbox-run-grid > .panel {
  height: var(--run-panel-height);
  min-height: 0;
  overflow: hidden;
}

.sandbox-run-grid.preupload-mode #qc-panel {
  display: none !important;
}

.sandbox-run-grid.preupload-mode #qc-live-panel {
  display: none !important;
}

.sandbox-run-grid.preupload-mode #reference-preview-panel {
  grid-column: 2;
}

.sandbox-run-grid.workflow-mode #reference-preview-panel {
  display: none;
}

.sandbox-preview-panel {
  min-height: 0;
  height: var(--run-panel-height);
  padding: 8px;
}

.sandbox-preview-panel.hidden {
  display: none;
}

#qc-live-panel {
  min-height: 0;
}

#qc-live-plot {
  min-height: 320px;
}

/* Keep the QC key on one row independently of Plotly's legend wrapping. */
.qc-live-legend {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  margin: 14px 0 4px;
  font-size: 12px;
  color: #444;
}
.qc-live-legend[hidden], .qc-legend-item[hidden] { display: none; }
.qc-legend-item {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.qc-legend-item i { width: 12px; height: 12px; flex: 0 0 12px; }
.qc-swatch-filtered { background: rgba(59, 130, 246, 0.35); }
.qc-swatch-retained { background: rgba(5, 150, 105, 0.85); }
.qc-swatch-mapped { background: #065f46; }

#qc-live-caption {
  min-height: 36px;
  margin-top: 8px;
}

#ambient-live-plot {
  min-height: 180px;
  margin-top: 10px;
}

#ambient-live-caption {
  min-height: 24px;
  margin-top: 8px;
}

.ambient-plot-area {
  flex: 0 0 auto;
}

.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-centered-tabs {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.hero-links {
  margin-left: auto;
}

.workspace-tab-btn {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
}

.workspace-tab-btn.active {
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.12), rgba(15, 118, 110, 0.12));
  color: var(--ink);
  border-color: rgba(29, 78, 216, 0.28);
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.08);
}

.workspace-panel {
  display: none;
  min-height: 0;
}

.workspace-panel.active {
  display: block;
  min-height: 0;
}

.explore-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
}

.explore-controls-panel,
.explore-results-column,
.differential-controls-panel,
.differential-results-column {
  min-height: 0;
}

.explore-controls-panel {
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.explore-controls-panel.hidden {
  display: none;
}

.explore-controls-panel #results-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head-stack {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.panel-head-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  /* .panel-head adds 14px below the head. The controls sit directly above the
     figure, so the figure started 14px lower for no reason. */
  margin-bottom: 4px;
}

.panel-head-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head-stack h2 {
  margin: 0;
}

.expression-head-stack {
  flex: 1 1 auto;
}

.expression-head-stack #gene-query {
  max-width: 240px;
}

/* Three columns of a full-width panel are ~500px each, so a 220px select left
   ~280px empty beside it and five controls needed two rows. Tracks the width of
   a control pack every visible control onto one row. */
.viz-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  /* .panel-head-stack centres its items. The level list is 173px tall and the
     selects are 63px, so the selects floated in the middle of a tall row with
     ~55px of blank above and below each one. */
  align-items: start;
  gap: 8px 10px;
}

/* `select[multiple]` above gives every multi-select a 156px floor, which set the
   height of the whole control row. A floor beats a ceiling in CSS, so the floor
   is removed here and the `size` attribute sets the height. The list scrolls to
   every level.
   The bottom padding is 0 because the browser paints scrolled rows through the
   padding, so a 10px bottom padding showed a fourth row cut in half. */
.viz-controls-grid select[multiple] {
  min-height: 0;
  padding-top: 8px;
  padding-bottom: 0;
  overflow-y: auto;
}

.viz-controls-grid .inline-field {
  min-width: 0;
}

/* Two controls read badly in one track: the level list holds long cell-state
   names and the gene box takes a pasted column. Both get two tracks, which
   still leaves every visible control on a single row at full width. */
@media (min-width: 760px) {
  #viz1-association-x-field,
  #viz2-association-x-field,
  #viz1-groups-field,
  #viz2-groups-field,
  #viz1-geneset-field,
  #viz2-geneset-field {
    grid-column: span 2;
  }
}

/* Annotation 1 / Values and Annotation 2 / Values shared one row instead of a
   full-width row each. The heading keeps the whole width. */
.viz-filter-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
}

.viz-filter-stack > .field-group-label {
  grid-column: 1 / -1;
}

/* The Windows label sat above its select, which made the top row 63px tall for
   one control. A row puts the label beside it. */
#viz-window-count-field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  min-width: 180px;
}

.inline-field.hidden {
  display: none;
}

.compact-inline-field {
  min-width: 190px;
}

.inline-field span {
  font-size: 0.72rem;
}

.explore-results-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.differential-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.differential-controls-panel {
  display: flex;
  flex-direction: column;
  overflow: auto;
  min-height: 860px;
}

.differential-controls-panel.hidden {
  display: none;
}

.differential-results-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.explorer-empty {
  min-height: 560px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.explorer-empty.hidden {
  display: none;
}

.plots {
  margin-top: 0;
}

#baseline-results-view.hidden,
#differential-results-view.hidden {
  display: none;
}

#baseline-results-view {
  min-height: 560px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#differential-results-view {
  min-height: 860px;
}

#reference-preview-plot {
  min-height: 100%;
}

#baseline-results-view > .panel,
#differential-results-view > .panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#upload-panel,
#qc-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#qc-form .primary-btn {
  margin-top: 8px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

#qc-panel > .progress-shell {
  margin-top: 0;
  flex: 0 0 auto;
}

#qc-form {
  flex: 0 0 auto;
}

#qc-panel {
  overflow-y: auto;
}

#qc-panel > h2 {
  flex: 0 0 auto;
}

#qc-cell-status {
  flex: 0 0 auto;
  min-height: 48px;
  line-height: 1.3;
}

#sample-container {
  max-height: 280px;
}

#job-log {
  flex: 1 1 148px;
  min-height: 48px;
  max-height: 148px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre;
}

#qc-panel[data-analysis-mode="both"] #job-log {
  flex-basis: 96px;
  max-height: 96px;
}

.download-btn {
  padding: 14px 16px;
  font-size: 0.92rem;
}

.network-hover-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 280px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  pointer-events: none;
}

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

  .explore-workspace,
  .differential-workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .compact-shell {
    height: auto;
  }

  .compact-hero {
    position: static;
    flex-direction: column;
    align-items: flex-start;
  }

  .sandbox-run-grid,
  .explore-workspace,
  .differential-workspace,
  #baseline-results-view,
  .differential-plots {
    grid-template-columns: 1fr;
  }

  .sandbox-run-grid.preupload-mode #reference-preview-panel {
    grid-column: auto;
  }

  .sandbox-run-grid > .panel,
  .sandbox-preview-panel,
  #reference-preview-panel {
    height: auto;
  }

  .hero-centered-tabs,
  .hero-links {
    position: static;
    transform: none;
    margin-left: 0;
  }
}

/* --- Window count, gene set and Chat ------------------------------------ */
/* One window: the results grid drops to a single column and panel 2 is taken
   out of the layout, so panel 1 spans the full width. */
#baseline-results-view.single-window {
  grid-template-columns: minmax(0, 1fr);
}
#baseline-results-view.single-window > .panel:nth-of-type(2) {
  display: none;
}

#viz1-geneset, #viz2-geneset {
  width: 100%;
  /* A 200px floor overflowed the grid track on a narrow panel. The two tracks
     the field spans already keep the box wide enough to paste into. */
  min-width: 0;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

.chat-ask { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.chat-ask textarea { flex: 1; font: 13px/1.4 inherit; resize: vertical; min-height: 44px; }
.chat-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.chat-examples .ghost-btn { font-size: 11px; padding: 3px 8px; }
.chat-summary-action { margin: 18px 0 24px; }
.ai-summary-btn { zoom: .7; display: inline-flex; align-items: center; gap: 10px; padding: 10px 20px; border-radius: 12px; border: 1px solid #243dc9; background: linear-gradient(110deg,#243dc9,#6b3fa5); color: #fff; font: inherit; font-weight: 750; cursor: pointer; box-shadow: 0 4px 14px #243dc933; }
.ai-summary-btn:hover:not(:disabled) { box-shadow: 0 5px 18px #243dc955; }
.ai-summary-btn:focus-visible { outline: 3px solid #7eaaff; outline-offset: 3px; }
.ai-summary-btn:disabled { opacity: .65; cursor: default; }
.ai-summary-btn picture,.ai-summary-btn img { display: block; width: 32px; height: 32px; }
.summary-program { margin: 16px 0; padding: 14px 18px; background: #f6f8ff; border-left: 3px solid #5267c9; border-radius: 8px; }
.summary-design-limit { color: #664d12; background: #fff8e7; border-radius: 8px; padding: 10px 14px; }
.summary-patterns { border-collapse: collapse; font-size: 13px; width: 100%; }
.summary-patterns td,.summary-patterns th { padding: 8px; text-align: left; border-bottom: 1px solid #e0e6f0; vertical-align: top; }
.summary-patterns th { background: #f6f8ff; }
.chat-views { display: flex; gap: 6px; margin: 8px 0; }
.chat-views .ghost-btn.active { font-weight: 600; text-decoration: underline; }
#chat-plot { min-height: 320px; }
#chat-table { max-height: 420px; overflow: auto; }
#chat-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
#chat-table th, #chat-table td { text-align: left; padding: 3px 8px; border-bottom: 1px solid #e6e6e6; white-space: nowrap; }
#chat-table thead th { position: sticky; top: 0; background: #fff; }


/* One control per row, full width. The Differential panel puts Cell state and Modality
   on separate rows so neither select clips its option text. */
.one-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* Discover integrated views */
.integrated-view { min-width: 0; width:100%; }
.integrated-view [hidden] {display:none !important;}
.integrated-controls button:disabled {opacity:.5;cursor:default;}
.integrated-controls {display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin:12px 0;}
.integrated-controls label {display:flex;gap:6px;align-items:center;}
.integrated-controls select {max-width:360px; padding:6px;}
.integrated-view .dsc-cy {width:100%;border:1px solid #dbe2ea;}
.integrated-view .dsc-legend {display:flex;flex-wrap:wrap;gap:8px;align-items:center;font-size:12px;color:#657487;margin:12px 0;}
.integrated-view .dsc-legend-bar {display:inline-block;width:120px;height:10px;}
.integrated-view .dsc-legend-lab i {display:inline-block;width:10px;height:10px;margin-right:4px;}
.integrated-view .dsc-scroll-xy {overflow:auto;max-height:720px;width:100%;}
.integrated-view .dsc-zoom {display:flex;align-items:center;gap:8px;margin:10px 0;}
.integrated-view .dsc-scroll svg {max-width:none;}

#differential-results-view.show-integrated {grid-template-columns:minmax(0,1fr);}
#differential-results-view.show-integrated .differential-secondary-panel {display:none;}
.integrated-controls button:not(.ghost-btn),.integrated-view .dsc-zoom-b {border:1px solid #dbe2ea;background:#fff;color:#334155;border-radius:6px;padding:6px 10px;cursor:pointer;}

/* Author layout rules must not reveal controls marked hidden. */
[hidden] { display: none !important; }

.chat-result-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 12px 0; }
.chat-result-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #64748b; }
.chat-result-field input, .chat-result-field select { width: auto; min-width: 100px; padding: 7px 10px; font-size: 13px; border: 1px solid #d8dde6; border-radius: 8px; background: white; color: #0f172a; }
.chat-result-field input[type=number] { width: 110px; }
.chat-result-pages { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.chat-sort-button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; padding: 4px 0; cursor: pointer; }
.chat-sort-button:hover { color: #0f807c; }
.chat-result-controls button:disabled { opacity: .45; cursor: default; }
.chat-result-controls.hidden { display: none; }

.chat-modality-filters { border:1px solid #dce4ed; border-radius:10px; padding:8px 12px; }
.chat-modality-filters label { display:inline-flex; align-items:center; gap:5px; margin-right:12px; }
.chat-modality-filters input { width:auto; }

.dsc-legend.cross-modality-legend { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:8px 16px; }
.cross-modality-legend .modality-colorbar { display:block; width:100%; max-width:350px; height:auto; }
.unaligned-view-btn {
  display: block;
  margin-top: 0.5rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  color: #0f766e;
  background: #fff;
  cursor: pointer;
  font-size: inherit;
}

.summary-modality { margin: 18px 0; padding: 12px 16px; border: 1px solid #dce4ed; border-radius: 12px; }
.summary-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.summary-evidence-link { display: block; overflow-wrap: anywhere; margin: 4px 0; }
#chat-answer details { margin: 12px 0; }
#chat-answer pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; font-size: 12px; }
#chat-views.hidden { display: none; }

.biology-summary-section { margin: 12px 0; padding: 10px 14px; border: 1px solid #dfe5ed; border-radius: 10px; min-width: 0; }
.biology-summary-section > summary { font-weight: 700; cursor: pointer; }
.biology-summary-section pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85em; max-height: 440px; overflow: auto; }
.biology-summary-section a { display: block; overflow-wrap: anywhere; margin: 6px 0; }
.drug-chat-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.drug-chat-controls select,.drug-chat-controls input { width: auto; max-width: 300px; }
.drug-table-scroll { max-width: 100%; overflow-x: auto; }
.drug-chat-table { min-width: 1100px; }

.summary-methods-body { font-family: inherit; line-height: 1.55; font-size: .95em; }
.summary-methods-body p { margin: 14px 0; }
.summary-methods-table-wrap { overflow-x: auto; margin: 16px 0; }
.summary-methods-body table { border-collapse: collapse; width: 100%; font-size: .92em; }
.summary-methods-body th, .summary-methods-body td { padding: 10px 12px; border: 1px solid #dfe5ed; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.summary-methods-body th { background: #f0f4f8; font-weight: 700; }
.summary-methods-body tbody tr:nth-child(even) { background: #f8fafc; }
.summary-methods-body a { display: inline; margin: 0; }
.summary-methods-body code { font-size: .9em; overflow-wrap: anywhere; }
.summary-methods-body pre { background: #f8fafc; padding: 12px; border-radius: 6px; }
