/* SPDX-License-Identifier: MIT
 * Copyright (c) 2026 The Regents of the University of California */
/* RhizoFunc — Rhizosphere Metabolite Function Atlas
 *
 * Plain CSS, no build step.
 * Type: IBM Plex Sans (text) + IBM Plex Mono (labels, identifiers, data).
 * Mono is used deliberately for anything machine-ish — formulas, CIDs, section
 * labels, counts — and never for prose.
 */

:root {
  /* Neutrals: warm off-white paper, near-black ink */
  --paper:      #f4f4f2;
  --surface:    #ffffff;
  --surface-2:  #ececeA;
  --ink:        #202120;
  --ink-2:      #444444;
  --ink-3:      #8f8f8f;
  --line:       #dcdcd8;
  --line-soft:  #e8e8e4;

  /* Accents */
  --green:      #338a3c;
  --green-deep: #23682b;
  --green-wash: #eef5ef;
  --highlight:  #edff77;   /* marker used to make the function read first */

  /* Confidence */
  --conf-high:  #23682b;
  --conf-med:   #8a6a12;
  --conf-low:   #8f8f8f;

  /* Low-confidence card treatment: muted, unmistakably different paper */
  --low-surface: #f6f4ec;
  --low-line:    #e0dcc8;
  --low-ink:     #6f6849;

  --radius: 4px;
  --wrap: 980px;

  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only hides via the UA stylesheet's `display: none`,
   which ANY author `display` rule silently beats — as .unmatched-list (flex)
   once did, leaving a toggle that did nothing. Enforce it once, globally. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

a { color: var(--green-deep); text-underline-offset: 2px; }
a:hover { color: var(--green); }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }

/* Mono label: the recurring "technical caption" device */
.label,
.section h2,
.meta-grid dt,
.result-meta,
.badge,
.hit-formula,
.l2-count,
.tier,
.ident-row code {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

/* Header ------------------------------------------------------------ */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; min-height: 68px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }

/* Wordmark. Intrinsic width/height are on the <img> so the header reserves the
   right box before the PNG loads and nothing shifts. */
.brand-logo {
  height: 26px; width: auto;
  display: block;
}

/* The tagline sits to the right of the wordmark, separated by a hairline. */
.brand-text {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.brand-text em {
  display: block; font-style: normal; font-size: 11px; color: var(--ink-3);
  font-family: var(--mono); letter-spacing: 0.02em; margin-top: 1px;
}
.site-header nav { display: flex; gap: 22px; font-size: 13px; font-family: var(--mono); }
.site-header nav a { text-decoration: none; color: var(--ink-2); }
.site-header nav a:hover { color: var(--green); }

main { min-height: 72vh; padding: 44px 24px 80px; }
.loading { color: var(--ink-3); font-family: var(--mono); font-size: 14px; }

/* Hero + search ----------------------------------------------------- */
.hero { text-align: center; padding: 16px 0 4px; }
.hero h1 {
  font-size: clamp(28px, 4.4vw, 42px);
  max-width: 760px; margin: 0 auto 16px;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(transparent 62%, var(--highlight) 62%);
  padding: 0 2px;
}
.lede { color: var(--ink-2); margin: 0 auto 30px; max-width: 600px; font-size: 16px; }

.searchbox { position: relative; max-width: 640px; margin: 0 auto; }
.searchbox input {
  width: 100%; padding: 15px 46px 15px 18px;
  font: 400 16px var(--sans); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink); border-radius: var(--radius);
}
.searchbox input::placeholder { color: var(--ink-3); }
.searchbox input:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-wash);
}
#clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--ink-3);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 6px;
}
#clear:hover { color: var(--ink); }

.examples {
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  margin-top: 14px; line-height: 2;
}
.linkish {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--green-deep); cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.linkish:hover { color: var(--green); border-bottom-color: var(--green); }

/* Result list ------------------------------------------------------- */
#results { margin-top: 34px; }
.result-meta {
  font-size: 12px; color: var(--ink-3); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.hit {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 8px;
  transition: border-color .12s ease;
}
.hit:hover { border-color: var(--ink); }
.hit.is-low { background: var(--low-surface); border-color: var(--low-line); }
.hit.is-low:hover { border-color: var(--low-ink); }

.hit-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hit-name { font-weight: 500; font-size: 16px; }
.hit-formula { font-size: 12px; color: var(--ink-3); }
.hit-fn { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.hit-fn strong { font-weight: 500; color: var(--ink); }
.hit-why {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 4px;
}

/* Badges ------------------------------------------------------------ */
.badge {
  display: inline-block; font-size: 10px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 2px;
  border: 1px solid currentColor; white-space: nowrap;
}
.badge.high   { color: var(--conf-high); }
.badge.medium { color: var(--conf-med); }
.badge.low    { color: var(--low-ink); background: #efeada; border-color: var(--low-line); }
.badge.none   { color: var(--ink-3); }

/* Species chips: colors are set inline per species (see SPECIES in app.js),
   same pattern as batch.js's L1_COLORS applied via style.background. */
.species-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
.species-chip {
  display: inline-block; font-size: 11px; font-family: var(--mono);
  padding: 2px 7px; border-radius: var(--radius);
  white-space: nowrap; text-decoration: none;
}
.species-chip:hover { filter: brightness(0.94); text-decoration: underline; }

/* Compound card ----------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
/* Low confidence: the whole card sits on different paper. */
.card.is-low { background: var(--low-surface); border-color: var(--low-line); }
.card.is-low .card-head { border-bottom-color: var(--low-line); }
.card.is-low .structure { border-color: var(--low-line); }

.card-head { display: flex; gap: 28px; padding: 28px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.structure {
  width: 190px; height: 190px; flex: 0 0 190px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.structure img { max-width: 100%; max-height: 100%; }
.structure .placeholder {
  color: var(--ink-3); font-family: var(--mono); font-size: 11px;
  text-align: center; padding: 14px;
}
.card-ident { flex: 1 1 340px; min-width: 0; }
.card-ident h1 { font-size: 26px; margin: 0 0 10px; word-break: break-word; }
.ident-row { font-size: 13px; color: var(--ink-2); margin: 3px 0; }
.ident-row code { font-size: 12px; color: var(--ink); }
.synonyms { font-size: 13px; color: var(--ink-3); margin-top: 12px; line-height: 1.5; }

.card-body { padding: 28px; }
.section { margin-bottom: 30px; }
.section:last-child { margin-bottom: 0; }
.section h2 {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-3); margin: 0 0 12px;
}

/* ── The function is the headline of the card ── */
.fn-block {
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px 24px;
}
.card.is-low .fn-block { border-color: var(--low-ink); background: #fffdf6; }

.fn-l1 {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-3); margin-bottom: 8px;
}
.fn-primary {
  font-size: clamp(24px, 3.4vw, 34px); font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.15; margin: 0;
}
.fn-primary .mark {
  background: linear-gradient(transparent 60%, var(--highlight) 60%);
  padding: 0 3px; margin: 0 -3px;
}
/* Low confidence gets no highlighter — it must not read as a settled fact. */
.card.is-low .fn-primary .mark { background: none; padding: 0; margin: 0; }

.fn-secondary {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
  font-size: 14px; color: var(--ink-2);
}
.fn-secondary strong { font-weight: 500; color: var(--ink); }

/* Low-confidence caveat, directly under the function */
.low-note {
  margin-top: 16px; padding: 12px 14px;
  background: #efeada; border: 1px solid var(--low-line);
  border-radius: var(--radius);
  font-size: 13px; color: var(--low-ink); line-height: 1.5;
}
.low-note strong { font-weight: 700; }

.callout {
  background: var(--surface-2); border-left: 2px solid var(--ink);
  padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px;
}
.card.is-low .callout { background: #efeada; border-left-color: var(--low-ink); }
.callout.muted { border-left-color: var(--ink-3); color: var(--ink-2); }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 18px; }
.meta-grid dt {
  color: var(--ink-3); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 3px;
}
.meta-grid dd { margin: 0; font-size: 14px; }

/* References -------------------------------------------------------- */
/* Numbered so the evidence summary's "(Ref 4, 6, 8)" can be followed. The
   number sits in a gutter rather than inline, so titles stay flush-left and
   scanning the list for a cited number is a straight vertical read. */
.ref {
  padding: 14px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
  display: grid; grid-template-columns: 30px 1fr; column-gap: 10px;
}
.ref > *:not(.ref-num) { grid-column: 2; }
.ref:last-child { border-bottom: 0; }
.ref-num {
  grid-column: 1; grid-row: 1 / -1;
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums;
}
/* Brief highlight when arrived at via #ref-N, so the cited row is findable. */
.ref:target .ref-num { color: var(--green-deep); font-weight: 500; }
.ref:target { background: var(--highlight-soft, rgba(237, 255, 119, 0.35)); }
.ref-title { font-weight: 500; line-height: 1.45; }
.ref-src { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.ref-finding {
  font-size: 13px; color: var(--ink-2); margin-top: 8px; line-height: 1.55;
  padding-left: 14px; border-left: 2px solid var(--line);
}
.tier { font-size: 10px; color: var(--ink-3); }

/* Browse ------------------------------------------------------------ */
.browse-l1 { margin-bottom: 38px; }
.browse-l1 h2 { font-size: 20px; margin: 0 0 2px; }
.browse-l1 .count {
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase;
}
.browse-l2 {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 13px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 6px; background: var(--surface); text-decoration: none; color: inherit;
}
.browse-l2:hover { border-color: var(--ink); }
.browse-l2 .l2-name { font-weight: 500; font-size: 15px; }
.browse-l2 .l2-count { font-size: 13px; color: var(--ink-3); }
/* Secondary line under a row's name — the source experiment on the species list. */
.browse-l2 .l2-sub {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 3px;
}

/* Empty / request state --------------------------------------------- */
.empty { text-align: center; padding: 44px 20px; }
.empty h2 { font-size: 22px; margin: 0 0 10px; }
.empty p { color: var(--ink-2); max-width: 540px; margin: 0 auto 20px; }

.btn {
  display: inline-block; padding: 12px 22px; border-radius: var(--radius);
  background: var(--ink); color: var(--paper); text-decoration: none;
  font-weight: 500; font-size: 15px; border: 1px solid var(--ink); cursor: pointer;
}
.btn:hover { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--ink); color: var(--paper); }

.pending {
  background: var(--green-wash); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-top: 18px; font-size: 14px;
}

.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--ink);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Prose (about) ------------------------------------------------------ */
.prose { max-width: 700px; }
.prose h1 { font-size: 30px; margin-bottom: 14px; }
.prose h2 { font-size: 15px; margin-top: 32px; margin-bottom: 8px; }
.prose p { color: var(--ink-2); }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 2px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 14px 0; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.prose th {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
}

/* Batch search ------------------------------------------------------ */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.batch-input { margin: 24px 0 8px; }
.dropzone {
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 32px 24px; text-align: center;
}
.dropzone.is-over { border-color: var(--green); background: var(--green-wash); }
.dropzone strong { display: block; font-size: 16px; margin-bottom: 4px; }
.dropzone span { display: block; font-size: 13px; color: var(--ink-3); }
.dropzone-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn.small { padding: 7px 13px; font-size: 13px; }

.col-map { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.col-field { display: flex; flex-direction: column; gap: 5px; }
.col-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
}
.col-field select {
  font: 400 14px var(--sans); padding: 7px 10px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}

.batch-summary { margin: 26px 0 18px; }
.summary-line { font-size: 15px; font-weight: 500; margin: 0 0 8px; }
.summary-buckets { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.summary-buckets li { margin-bottom: 3px; }
.unmatched-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 -18px; }
.unmatched-chip {
  font-family: var(--mono); font-size: 11px; padding: 3px 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 2px;
  /* An anchor (so it can be opened in a new tab) styled as a chip, not a link. */
  color: var(--ink-2); text-decoration: none;
}
.unmatched-chip:hover { border-color: var(--green); color: var(--green-deep); }

/* A drill-down row listed under a compound's SECONDARY function. Marked with a
   left rule rather than a tint, so it does not collide with the low-confidence
   tint that .hit.is-low already applies. */
.hit.is-secondary { border-left: 2px solid var(--line); padding-left: 10px; }

/* Separator before the secondary block. Deliberately loud: it is the boundary
   between "this IS the compound's function" and "this is a second-order
   membership", and a reader who misses it misreads every row below. Uses the
   same highlight marker the card uses to make the function read first. */
.drill-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
}
.drill-divider span {
  background: var(--highlight); color: var(--ink);
  font-weight: 700; padding: 5px 10px; border-radius: 2px;
  border: 1px solid rgba(32, 33, 32, 0.14);
}
.drill-divider::before, .drill-divider::after {
  content: ""; flex: 1; height: 2px; background: var(--ink);
}

/* Controls ----------------------------------------------------------- */
.chart-controls {
  display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
}
.segmented { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-btn {
  font: 400 13px var(--sans); padding: 7px 13px; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 0;
  border-right: 1px solid var(--line);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.is-on { background: var(--ink); color: var(--paper); }
.seg-btn:disabled { color: var(--ink-3); background: var(--surface); cursor: default; }
.export-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* Chart -------------------------------------------------------------- */
/* Wider container on the batch and atlas routes so a chart and its side panel fit. */
body[data-route="batch"] .wrap,
body[data-route="atlas"] .wrap { max-width: 1240px; }

.chart-layout { display: flex; gap: 24px; align-items: flex-start; }
.chart-main { flex: 1 1 auto; min-width: 0; }

/* Below this width the panel drops beneath the chart. Must stay in sync with
   SIDE_BY_SIDE_MIN in batch.js, which reserves the space when sizing the SVG. */
@media (max-width: 919px) {
  .chart-layout { flex-direction: column; }
  .drilldown-side { width: 100%; position: static !important; max-height: none !important; }
}

.chart-figure { margin: 0; }
/* Transparent: the chart sits directly on the page, no card behind it. */
.chart-box { overflow-x: auto; background: transparent; padding: 4px 0; }
.bubble-svg { display: block; }
.bubble-svg text { fill: var(--ink); }
.bubble-svg .facet-strip { font: 700 13px var(--sans); fill: var(--ink); }
.bubble-svg .y-label { font: 400 13px var(--sans); fill: var(--ink-2); }
.bubble-svg .x-label { font: 400 13px var(--sans); fill: var(--ink); }
.bubble-svg .facet-panel { fill: none; }
.bubble-svg .grid-line { stroke: var(--line); stroke-width: 1; }
.bubble-svg .grid-vertical { stroke: var(--line-soft); }
.bubble-svg .axis-line { stroke: var(--ink); stroke-width: 1; }
.bubble-svg .bubble-hit { fill: transparent; }
/* Stroke matches the page, not a white card, so bubbles separate cleanly
   against the transparent background. */
.bubble-svg .bubble-mark { stroke: var(--paper); stroke-width: 1; transition: opacity .12s; }
.bubble-svg .bubble-ring { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.bubble-svg .bubble { cursor: pointer; outline: none; }
.bubble-svg .bubble:hover .bubble-mark { opacity: 0.75; }
.bubble-svg .bubble:focus-visible .bubble-mark { stroke: var(--ink); stroke-width: 2; }

.chart-legend { display: flex; gap: 36px; flex-wrap: wrap; padding: 16px 4px 0; }
.legend-title {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 8px;
}
.legend-items { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: 0 0 11px; }
.legend-bubble { fill: var(--ink-3); }
.chart-caption { font-size: 12px; color: var(--ink-3); margin-top: 14px; line-height: 1.5; }

/* Table view --------------------------------------------------------- */
.table-view { overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); }
.count-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.count-table th, .count-table td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.count-table th {
  font-family: var(--mono); font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3); position: sticky; top: 0; background: var(--surface);
}
.count-table .num { text-align: right; font-family: var(--mono); }
.count-table .total-row td { font-weight: 700; border-top: 1px solid var(--ink); }

/* Tooltip ------------------------------------------------------------ */
.chart-tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--paper);
  padding: 9px 12px; border-radius: var(--radius); max-width: 280px;
  box-shadow: 0 3px 12px rgba(0,0,0,.18);
}
.tip-title { font-weight: 700; font-size: 13px; }
.tip-l2 { font-size: 13px; margin-top: 2px; }
.tip-l1 { font-family: var(--mono); font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.tip-value { font-size: 12px; margin-top: 6px; }
.tip-hint { font-size: 11px; opacity: .6; margin-top: 5px; }

/* Drill-down (side panel) -------------------------------------------- */
.drilldown-side {
  flex: 0 0 300px; width: 300px;
  position: sticky; top: 84px;
  max-height: calc(100vh - 110px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.drill-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.drill-l2 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.drill-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.45; }
.drilldown-side .hit { padding: 11px 12px; }
.drilldown-side .hit-name { font-size: 14px; }

.drill-placeholder { color: var(--ink-3); }
.drill-placeholder-title {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 8px;
}
.drill-placeholder p { font-size: 13px; margin: 0; line-height: 1.5; }

/* Atlas (beta): chemical-space map --------------------------------- */
/* Built by chemspace.js. Reuses the batch page's controls, legend and side
   panel; only what the map adds is defined here. */
.badge.beta {
  color: var(--green-deep); background: var(--green-wash);
  margin-left: 12px; vertical-align: 6px;
}
.cs-head { max-width: 760px; }
.cs-stats { margin-top: 4px; }

.cs-controls { gap: 18px 26px; }
.cs-select, .cs-input {
  font: 400 14px var(--sans); padding: 7px 10px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.cs-select { max-width: 260px; }
.cs-input { width: 200px; }
.cs-select:focus, .cs-input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-wash);
}

/* Legend on the left, the layout's faithfulness scores on the right. */
.cs-topline {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 10px 24px; flex-wrap: wrap; margin-bottom: 12px;
}
.legend-ramp { display: inline-block; width: 140px; height: 10px; border-radius: 2px; }
.cs-scores {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  text-align: right; line-height: 1.6;
}

.cs-plot {
  height: clamp(420px, 72vh, 800px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.cs-plot .modebar { background: transparent !important; }

.drilldown-side.cs-side { flex-basis: 330px; width: 330px; }
.cs-side a.drill-l2 { color: var(--ink); text-decoration: none; display: block; }
.cs-side a.drill-l2:hover { color: var(--green-deep); text-decoration: underline; }
.cs-id { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.cs-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3); margin: 18px 0 8px;
}
.cs-agree { margin: -2px 0 10px; }
.cs-siblings { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.5; }
.cs-siblings li { margin-bottom: 4px; }
.cs-siblings .linkish { font: inherit; text-align: left; }
.cs-sibling-this { font-weight: 500; }
.cs-facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 7px 12px;
  margin: 18px 0 0; font-size: 13px; line-height: 1.45;
}
.cs-facts dt {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3); padding-top: 2px;
}
.cs-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.cs-notes { margin-top: 44px; max-width: 760px; }
.cs-notes h2 { margin-top: 0; }
.cs-notes p { font-size: 14px; }
.cs-layouts { margin: -4px 0 16px; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.cs-layouts li { margin-bottom: 8px; }
.cs-layouts strong { color: var(--ink); font-weight: 500; }

/* Stacked under the side panel's breakpoint, the column must be told to fill
   the width: .chart-layout aligns to flex-start, which collapses the plot to 0. */
@media (max-width: 919px) {
  .cs-main { width: 100%; }
  /* In a column, flex-basis is a height: drop the desktop 330px width. */
  .drilldown-side.cs-side { flex-basis: auto; width: 100%; }
}
@media (max-width: 620px) {
  .cs-plot { height: 62vh; }
  .cs-scores { text-align: left; }
  .cs-input, .cs-select { width: 100%; max-width: none; }
  .cs-controls .control-group { flex: 1 1 100%; }
  .cs-controls .segmented { flex-wrap: wrap; }
}

/* Print: PDF export of the figure ------------------------------------ */
@media print {
  @page { size: landscape; margin: 12mm; }
  .site-header, .site-footer, .chart-controls, .drilldown-side, .batch-input,
  .batch-summary, .back, .chart-tooltip { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .prose h1 { font-size: 16pt; }
  .prose p { display: none; }
  .chart-layout { display: block; }
  .chart-box { border: 0; padding: 0; overflow: visible; }
  .chart-figure { break-inside: avoid; }
  .bubble-svg .facet-panel { fill: none; }
  .bubble-svg .bubble-mark { stroke: #fff; }
  .table-view { border: 0; }
  a[href]:after { content: ""; }   /* no URL footnotes on the figure */
}

/* Footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line); background: var(--paper);
  padding: 26px 0 34px; font-size: 12px; color: var(--ink-3);
}
.site-footer p { margin: 0 0 8px; }
#footer-meta { font-family: var(--mono); letter-spacing: 0.02em; }
.disclaimer { max-width: 640px; line-height: 1.6; }
.footer-license { margin-top: 14px; line-height: 1.6; }
.footer-license a { color: var(--ink-2); }
.footer-license a:hover { color: var(--green); }

.back {
  display: inline-block; font-family: var(--mono); font-size: 12px;
  margin-bottom: 20px; text-decoration: none; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.back:hover { color: var(--green); }

@media (max-width: 620px) {
  main { padding: 28px 20px 60px; }
  .card-head { padding: 20px; gap: 18px; }
  .structure { flex-basis: 130px; width: 130px; height: 130px; }
  .card-body { padding: 20px; }
  .fn-block { padding: 18px; }
  /* Below ~620px the tagline crowds the nav — the wordmark carries the brand. */
  .brand-text { display: none; }
  .brand-logo { height: 22px; }
  /* Five tabs no longer fit beside the wordmark: the nav takes its own line. */
  .site-header .wrap { flex-wrap: wrap; gap: 8px 20px; padding-block: 12px; }
  .site-header nav { flex-wrap: wrap; gap: 4px 16px; }
}
