/* BioTranslate V2 — molecule detail layout
   Plain CSS, no framework, matching the design of the other static apps
   in this monorepo (apps/webapp, apps/biolm-playground). */

:root {
  --navy: #0f1d3a;
  --navy-2: #16274d;
  --page-bg: #f3f5f9;
  --surface: #ffffff;
  --border: #e3e7ef;
  --border-strong: #d3d9e4;

  --ink: #151a2b;
  --ink-2: #5b6478;
  --ink-3: #8891a2;

  --accent: #2f6fed;
  --accent-ink: #1c4fc0;
  --accent-soft: #e8effe;

  --amber: #b45309;
  --amber-soft: #fdecdc;
  --amber-strong: #c2410c;

  --yellow-soft: #fef6dc;
  --yellow-ink: #92400e;

  --green: #15803d;
  --green-soft: #e4f7ea;
  --green-ink: #166534;

  --purple: #6d28d9;
  --purple-soft: #ede9fe;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.lg { width: 20px; height: 20px; }
.icon.sm { width: 14px; height: 14px; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ---------------------------------------------------------------- shell */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0.7rem 1.25rem;
  max-width: 1600px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.brand-text b {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-text span {
  display: block;
  font-size: 0.68rem;
  color: #93a1c2;
  margin-top: 1px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-shrink: 0;
}
.topnav a {
  color: #b7c1da;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}
.topnav a.active {
  color: #fff;
  border-bottom-color: var(--accent);
}
.topnav a:hover { color: #fff; }
.topnav a.topnav-admin { color: #fde68a; }
.topnav a.topnav-admin.active, .topnav a.topnav-admin:hover { color: #fff; border-bottom-color: #fde68a; }

/* static pages (methodology, data release, about) */
.page-intro { color: var(--ink-2); font-size: 0.95rem; max-width: 72ch; margin: 0 0 1rem; }
.page .card p { max-width: 76ch; line-height: 1.55; }
.page .card p + p { margin-top: 0.6rem; }
.page .card ol, .page .card ul { padding-left: 1.2rem; line-height: 1.55; max-width: 76ch; }
.page .card li + li { margin-top: 0.3rem; }
.page .card h3 { font-size: 0.95rem; margin: 1rem 0 0.35rem; }
.page table.kv th { width: 34%; }

.topbar-signout {
  color: #93a1c2;
  font-size: 0.78rem;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}
.topbar-signout:hover { color: #fff; }

.topbar-search {
  flex: 1 1 auto;
  position: relative;
  max-width: 420px;
}
.topbar-search .icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #7c88a8;
}
.topbar-search input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #fff;
  padding: 0.5rem 2.1rem 0.5rem 2.1rem;
  font-size: 0.82rem;
}
.search-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8a96b4;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.search-clear[hidden] { display: none; }
.topbar-search input::placeholder { color: #8a96b4; }
.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
}


/* ---------------------------------------------------------------- body layout */

.body {
  flex: 1;
  display: flex;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- main content */

.content {
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-2);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--ink); }

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.2rem;
}
.title-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.title-main h1 {
  font-size: 1.7rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.title-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
}
.btn:hover { background: var(--page-bg); color: var(--ink); }
.btn.icon-only { padding: 0.45rem; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-ink); }

.subtitle {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin: 0 0 0.9rem;
}

.badge-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
}
.badge.purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }

/* ---------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 1.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab {
  padding: 0.7rem 0.05rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.placeholder-panel {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-3);
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem 1.4rem;
  margin-bottom: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.card-head-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.98rem;
  font-weight: 700;
}
.card-head-left .icon { color: var(--accent); }
.card-head-meta {
  color: var(--ink-3);
  font-size: 0.78rem;
}
.info-dot { color: var(--ink-3); cursor: help; position: relative; display: inline-flex; align-items: center; outline: none; }
.info-dot .tip {
  display: none; position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%);
  width: 300px; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  background: #1f2937; color: #fff; font-size: 0.75rem; font-weight: 400; line-height: 1.4;
  text-align: left; white-space: normal; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.info-dot .tip::before {
  content: ""; position: absolute; left: 50%; top: -5px; margin-left: -5px;
  border: 5px solid transparent; border-top: 0; border-bottom-color: #1f2937;
}
.info-dot:hover .tip, .info-dot:focus .tip, .info-dot:focus-within .tip { display: block; }
.card-head-left .info-dot { margin-left: 0.15rem; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
}

@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* assessment tiles */

.tile {
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tile.amber { background: var(--amber-soft); }
.tile.yellow { background: var(--yellow-soft); }
.tile.green { background: var(--green-soft); }

.tile-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-2);
}
.tile-value {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.tile.amber .tile-value { color: var(--amber-strong); }
.tile-value-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.tile-value-row .icon.danger { color: #dc2626; }
.tile.green .tile-value-row { color: var(--green); font-size: 1.25rem; font-weight: 800; }

.tile-desc {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0;
}
.tile ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.65;
}
.tile-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}
.tile-link:hover { text-decoration: underline; }

/* evidence definition table */

.deftable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.deftable tr { border-bottom: 1px solid var(--border); }
.deftable tr:last-child { border-bottom: none; }
.deftable th, .deftable td {
  text-align: left;
  padding: 0.5rem 0;
  vertical-align: top;
  font-weight: 400;
}
.deftable th {
  color: var(--ink-3);
  width: 42%;
  font-weight: 500;
}
.deftable td { color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.pill.green { background: var(--green-soft); color: var(--green-ink); }

.up-value {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--accent-ink);
  font-weight: 600;
}

.card-footer-link {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.why-text {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.65;
  margin: 0 0 1rem;
}
.why-text b { color: var(--ink); }

.info-box {
  display: flex;
  gap: 0.6rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  color: var(--accent-ink);
  line-height: 1.55;
}
.info-box .icon { color: var(--accent); margin-top: 0.1rem; }

/* ---------------------------------------------------------------- seven stage map */

.stage-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.7rem;
}
@media (max-width: 1080px) {
  .stage-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .stage-grid { grid-template-columns: repeat(2, 1fr); }
}

.stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.stage.has-evidence { background: var(--green-soft); border-color: #cdeedb; }

.stage-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.stage.has-evidence .stage-icon { background: var(--green); }
.stage:not(.has-evidence) .stage-icon { background: var(--border-strong); color: #fff; }

.stage-id {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stage-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.stage-status {
  font-size: 0.72rem;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- research evidence table */

.filters {
  display: grid;
  grid-template-columns: repeat(6, 1fr) auto;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 1.1rem;
}
@media (max-width: 1080px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
}
.field label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-bottom: 0.3rem;
  font-weight: 600;
}
.field select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
}
.reset-btn {
  padding: 0.42rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.reset-btn:hover { background: var(--page-bg); }

.table-wrap { overflow-x: auto; }

table.evidence {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 760px;
}
table.evidence th {
  text-align: left;
  padding: 0.6rem 0.7rem;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.evidence td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  white-space: nowrap;
}
table.evidence a { color: var(--accent-ink); font-weight: 600; }
table.evidence a:hover { text-decoration: underline; }

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.76rem;
  background: var(--surface);
}
.view-btn:hover { background: var(--accent-soft); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.9rem;
  color: var(--ink-3);
  font-size: 0.8rem;
}
.page-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-3);
}
.page-btn:disabled { opacity: 0.45; cursor: default; }
.page-btn:not(:disabled):hover { background: var(--page-bg); color: var(--ink); }

/* ---------------------------------------------------------------- annotations & literature */

.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.kv tr { border-bottom: 1px solid var(--border); }
.kv tr:last-child { border-bottom: none; }
.kv th, .kv td { text-align: left; padding: 0.5rem 0; font-weight: 400; vertical-align: top; }
.kv th { color: var(--ink-3); width: 55%; font-weight: 500; }
.kv td { color: var(--ink); text-align: right; }

.card-note {
  font-size: 0.72rem;
  color: var(--ink-3);
  line-height: 1.6;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.tool-row:last-of-type { border-bottom: none; }
.tool-name { font-weight: 700; }
.tool-version { color: var(--ink-3); font-weight: 500; font-size: 0.75rem; margin-left: 0.35rem; }
.tool-desc { color: var(--ink-2); font-size: 0.78rem; }
.tool-link { color: var(--accent-ink); font-weight: 700; font-size: 0.78rem; }
.tool-link.disabled { color: var(--ink-3); }

.lit-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.lit-item:last-of-type { border-bottom: none; margin-bottom: 0.9rem; }
.lit-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lit-body a.lit-cite { font-weight: 700; color: var(--accent-ink); font-size: 0.84rem; }
.lit-title { font-size: 0.8rem; color: var(--ink-2); margin: 0.2rem 0; line-height: 1.4; }
.lit-journal { font-size: 0.76rem; color: var(--ink-3); font-style: italic; }
.lit-doi { font-size: 0.76rem; color: var(--accent-ink); display: inline-flex; align-items: center; gap: 0.25rem; }

.block-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.82rem;
}
.block-btn:hover { background: var(--accent-soft); }

/* ==========================================================================
   Additions for the data-driven views (search list, new tabs, empty states).
   Everything above this line is the original static layout; these rules only
   add what the rendered views need.
   ========================================================================== */

/* Tabs are anchors now (they carry the route), not buttons. */
.tabs a.tab { display: inline-block; text-decoration: none; }
.tabs a.tab:hover { color: var(--ink); }

/* ---- search / molecule list ---- */
.search-head { margin-bottom: 1.4rem; }
.search-head h1 { font-size: 1.55rem; margin: 0 0 0.25rem; }
.search-head .subtitle { margin: 0; }

/* ---- shared text tones ---- */
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.small { font-size: 0.76rem; }

code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

/* ---- direction / status ---- */
.down-value {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--amber-strong);
  font-weight: 600;
}
.pill.grey {
  background: var(--page-bg);
  color: var(--ink-2);
  border: 1px solid var(--border-strong);
}

/* Detection strings are free text from the source papers and can be long. */
.pill {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ---- empty states ---- */
.empty-inline {
  padding: 1rem 1.2rem;
  color: var(--ink-2);
  font-size: 0.84rem;
  background: var(--page-bg);
  border-radius: var(--radius-sm);
  margin: 0.2rem 0 0;
}
.empty-cell {
  text-align: center;
  color: var(--ink-3);
  padding: 1.4rem 0;
}

/* ---- layout helpers ---- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

.plain-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.plain-list li { margin-bottom: 0.3rem; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ---- seven-stage detail rows ---- */
.stage-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.stage-row:last-child { border-bottom: none; }
.stage-disc {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--page-bg);
  color: var(--ink-3);
  border: 1px solid var(--border-strong);
}
.stage-row.reached .stage-disc {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.stage-sub {
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-top: 0.1rem;
}

/* ---- brand link ---- */
a.brand { text-decoration: none; }

/* Long free-text cells shouldn't stretch the evidence table. */
table.evidence td { vertical-align: top; }
table.evidence td.soft { max-width: 240px; }

/* Evidence table: fixed layout so free-text cells truncate instead of pushing
   the numeric columns off the right edge. */
table.evidence { table-layout: auto; width: 100%; }
table.evidence td.cmp {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.evidence th, table.evidence td { padding-right: 0.9rem; }
/* provenance file names run to 80+ characters; truncate instead of overlapping Role */
table.evidence td.file { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detection strings are long free text; cap them so the trailing numeric
   columns of the evidence table stay on screen at 1440px. */
table.evidence .pill { max-width: 150px; }

/* ==========================================================================
   Share menu, feedback widget, and the print report.
   ========================================================================== */

/* ---- share menu ---- */
.share-wrap { position: relative; }
.share-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 40;
  min-width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  padding: 0.3rem;
}
.share-menu[hidden] { display: none; }
.share-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  background: none;
  border-radius: 6px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.share-menu button:hover { background: var(--page-bg); }

/* ---- feedback widget ---- */
.fb-button {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.22);
}
.fb-button:hover { background: var(--navy-2); }
.fb-button .icon { color: #fff; }

.fb-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 4.6rem;
  z-index: 61;
  width: min(380px, calc(100vw - 2.5rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(16, 24, 40, 0.2);
}
.fb-panel[hidden] { display: none; }
.fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.fb-close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-3);
  padding: 0.2rem;
  line-height: 0;
}
.fb-close:hover { color: var(--ink); }
.fb-body { padding: 0.9rem 1rem 1rem; }
.fb-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: 0.6rem 0 0.3rem;
}
.fb-body select,
.fb-body textarea,
.fb-body input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--surface);
}
.fb-body textarea { resize: vertical; min-height: 84px; }
.fb-context {
  margin: 0.7rem 0 0;
  font-size: 0.74rem;
  color: var(--ink-3);
  font-family: var(--font-mono);
  word-break: break-all;
}
.fb-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.8rem;
}
.fb-msg { font-size: 0.78rem; color: var(--ink-2); }
.fb-msg.err { color: var(--amber-strong); }
.fb-thanks {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0;
}
.fb-thanks .icon { color: var(--green); flex-shrink: 0; margin-top: 2px; }
.fb-thanks p { margin: 0; font-size: 0.86rem; color: var(--ink-2); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-ink); }
.btn.primary .icon { color: #fff; }
.btn.primary:disabled { opacity: 0.6; cursor: default; }

/* ---- print report ----
   The app renders one tab at a time; the report renders all of them into
   #print-report and this block swaps which of the two the printer sees. */
#print-report { display: none; }

@media print {
  body.printing .shell,
  body.printing .fb-button,
  body.printing .fb-panel { display: none !important; }
  body.printing #print-report { display: block; }

  html, body { background: #fff; color: #111; font-size: 10.5pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* cover */
  .pr-cover { padding: 0 0 0.9rem; border-bottom: 3px solid #1f3864; margin-bottom: 1rem; }
  .pr-brand { font-size: 8.5pt; letter-spacing: 0.08em; text-transform: uppercase; color: #1f3864; margin-bottom: 0.5rem; }
  .pr-cover h1 { font-size: 24pt; margin: 0 0 0.15rem; letter-spacing: -0.01em; }
  .pr-sub { margin: 0 0 0.8rem; color: #444; font-size: 10.5pt; }
  .pr-facts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.45rem; margin: 0.4rem 0 0.7rem; }
  .pr-fact { border: 1px solid #d9dee8; border-radius: 6px; padding: 0.45rem 0.55rem; background: #f6f8fc; break-inside: avoid; }
  .pr-fact-label { font-size: 7.5pt; text-transform: uppercase; letter-spacing: 0.05em; color: #5b6478; }
  .pr-fact-value { font-size: 12.5pt; font-weight: 700; color: #1f3864; margin-top: 0.1rem; }
  .pr-fact-sub { font-size: 7.5pt; color: #6b7386; margin-top: 0.1rem; }
  .pr-meta { font-size: 8pt; color: #666; margin: 0; word-break: break-all; }

  /* sections */
  .pr-section { margin: 0 0 1.1rem; }
  .pr-section.pr-break { break-before: page; }
  .pr-section h2 { font-size: 13.5pt; color: #1f3864; margin: 0.6rem 0 0.55rem; padding-bottom: 0.25rem;
    border-bottom: 1.5px solid #c9d1e0; break-after: avoid; display: flex; align-items: baseline; gap: 0.5rem; }
  .pr-num { display: inline-block; min-width: 1.4em; font-size: 9pt; color: #fff; background: #1f3864; border-radius: 4px;
    text-align: center; padding: 0.05rem 0.25rem; }
  .pr-note { font-size: 9pt; color: #555; margin: 0 0 0.5rem; }
  .pr-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

  /* cards flatten to plain blocks; screen chrome does not belong in a report */
  .card { box-shadow: none; border: 1px solid #d9dee8; border-radius: 6px; break-inside: avoid; margin-bottom: 0.6rem; background: #fff; }
  /* a card holding a long table or list (evidence, stage detail, source files,
     literature) is taller than a page: with break-inside: avoid Chrome pushes
     the whole card to the next page and leaves the current one empty below
     the section heading. Let those cards break between rows instead. */
  .card:has(table.evidence), .card:has(table.kv), .card:has(.stage-row), .card:has(.lit-item), .card:has(.qa-item) { break-inside: auto; }
  .card-head { padding: 0.45rem 0.7rem; border-bottom: 1px solid #e6eaf2; break-after: avoid; break-inside: avoid; }
  .lit-item, .qa-item, .tile, .stage { break-inside: avoid; }
  .card-head-left { font-size: 10pt; }
  .card-head-meta { font-size: 8pt; color: #666; }
  .card-note, .stage-sub, .stage-evidence, .tile-desc, .verdict-text { font-size: 8.5pt; }
  .grid-3, .grid-2 { display: grid; gap: 0.6rem; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .tile { padding: 0.55rem 0.65rem; }
  .tile-value { font-size: 12pt; }
  .stage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .stage { font-size: 8.5pt; }
  .stage-row { break-inside: avoid; }

  /* tables: full width, repeated headers, no row splits */
  .table-wrap { overflow: visible; }
  table { width: 100%; font-size: 8.5pt; border-collapse: collapse; }
  /* auto layout on purpose: a fixed-layout table cannot start mid-page in Chrome's
     print engine, which left the page under the section heading empty */
  table.evidence { table-layout: auto; font-size: 8pt; }
  table.evidence th, table.evidence td { padding: 0.28rem 0.3rem; vertical-align: top; white-space: normal; overflow-wrap: break-word; }
  table.evidence td.cmp { max-width: none; white-space: normal; }
  table.evidence td a, table.evidence td b { white-space: normal; }
  /* Study · Comparison · Compartment · Platform · Detection · Direction · Effect · p value · Type */
  table.evidence th:nth-child(1), table.evidence td:nth-child(1) { width: 18%; }
  table.evidence th:nth-child(2), table.evidence td:nth-child(2) { width: 16%; }
  table.evidence th:nth-child(3), table.evidence td:nth-child(3) { width: 12%; }
  table.evidence th:nth-child(4), table.evidence td:nth-child(4) { width: 12%; }
  table.evidence th:nth-child(5), table.evidence td:nth-child(5) { width: 17%; }
  table.evidence th:nth-child(6), table.evidence td:nth-child(6) { width: 9%; }
  table.evidence th:nth-child(7), table.evidence td:nth-child(7) { width: 8%; }
  table.evidence th:nth-child(8), table.evidence td:nth-child(8) { width: 8%; }
  /* the record-type column ("differential expression" on almost every row) is
     not worth a column on paper; the explorer keeps it */
  table.evidence th:nth-child(9), table.evidence td:nth-child(9) { display: none; }
  table.evidence .pill { display: block; box-sizing: border-box; width: 100%; padding: 0.1rem 0.3rem; line-height: 1.25;
    font-size: 7pt; white-space: normal; overflow-wrap: break-word; word-break: normal; text-align: left; }
  table.kv th { width: 34%; font-size: 8.5pt; }
  table.kv td { font-size: 8.5pt; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .pill { max-width: none; white-space: normal; font-size: 7.5pt; }
  code, code.wrap { font-size: 8pt; white-space: pre-wrap; word-break: break-all; }

  /* never in a report */
  .card-footer-link, .tile-link, .block-btn, .view-btn, .pagination, .pager, .filters, #evidence-filters,
  .class-filter, .info-dot, .share-wrap, .title-actions, .tabs, .back-link, .empty-inline .view-btn { display: none !important; }
  a { color: #111; text-decoration: none; }

  @page { size: A4; margin: 14mm 12mm 16mm; }
}

/* ---- live data additions (seven-stage calls, client verdicts, tools) ---- */
.stage-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.stage-dots i {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--border-strong, #d3d9e4);
}
.stage-dots i.on { background: var(--green, #1a9e5c); }
.stage.conflict .stage-status::after { content: " \26A0"; color: var(--amber-strong, #c2410c); }
.stage-evidence { font-size: 0.78rem; color: var(--ink-2, #5b6478); margin-top: 0.3rem; }
.stage-evidence .icon { vertical-align: -2px; opacity: 0.7; }
.stage-verdicts { margin-top: 0.55rem; border-left: 2px solid var(--border, #e3e7ef); padding-left: 0.7rem; }
.stage-verdicts-head { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; color: var(--ink-3, #8891a2); margin-bottom: 0.35rem; }
.verdict { margin: 0.3rem 0 0.45rem; font-size: 0.8rem; }
.verdict-drug { font-weight: 600; margin-left: 0.3rem; }
.verdict-src { color: var(--ink-3, #8891a2); margin-left: 0.3rem; font-size: 0.74rem; }
.verdict-text { color: var(--ink-2, #5b6478); margin-top: 0.15rem; line-height: 1.4; }
.pill.yellow { background: #fff4d6; color: #8a5a00; }
.pill.red { background: #fde8e8; color: #a12a2a; }
.placeholder-panel.loading { opacity: 0.75; }
code.wrap { white-space: pre-wrap; word-break: break-all; font-size: 0.72rem; }

/* ---------------------------------------------------------------- search table (paged index) */
.table-note {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.75rem 1.1rem 0.25rem;
  color: var(--ink-3);
  font-size: 0.8rem;
  line-height: 1.45;
}
.table-note .icon { flex: none; margin-top: 0.15rem; }
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem 0.9rem;
  font-size: 0.8rem;
}
.pager .view-btn { cursor: pointer; font: inherit; }

/* class filter in the search table head */
.class-filter select { font: inherit; margin-left: 0.3rem; padding: 0.15rem 0.35rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.tile.blue { border-color: #9ec5e8; }
.tile.grey { opacity: 0.9; }

.tile.red { background: #fbe9e7; }
.tile.red .tile-value { color: #b3261e; }
.tile.blue { background: #e8f1fb; }
.tile.blue .tile-value { color: #1d4f91; }
.tile.grey { background: var(--page-bg); }

/* ---- "searching / opening" overlay with a filling test tube (landing page and explorer) ---- */
.searching { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 18, 45, 0.92); animation: fade-in 0.25s ease-out; }
.searching[hidden] { display: none; }
.searching-box { text-align: center; padding: 2rem 2.5rem; border-radius: 16px; background: rgba(13, 28, 66, 0.9); border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
.tube { width: 64px; height: 120px; display: block; margin: 0 auto 1rem; }
.tube .glass { fill: none; stroke: #c9d6f5; stroke-width: 2.5; }
.tube .rim { stroke: #c9d6f5; stroke-width: 3; stroke-linecap: round; }
.tube .liquid { fill: #5b8cff; animation: fill 2.4s ease-in-out infinite; }
.tube .bubble { fill: rgba(255,255,255,0.75); animation: rise 1.8s linear infinite; }
.tube .b2 { animation-delay: 0.5s; animation-duration: 2.2s; }
.tube .b3 { animation-delay: 1.1s; animation-duration: 1.6s; }
.searching-text { color: #fff; font-size: 1.05rem; font-weight: 600; }
.searching-text b { color: #a9c2ff; }
.searching-sub { margin-top: 0.35rem; color: #8ea0cc; font-size: 0.85rem; }
.is-searching .landing { visibility: hidden; pointer-events: none; }
@keyframes fill { 0% { transform: translateY(78px); } 50% { transform: translateY(6px); } 100% { transform: translateY(78px); } }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-70px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tube .liquid, .tube .bubble { animation-duration: 6s; } }

/* ---- molecule suggestions under a search box (suggest.js) ---- */
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; background: #fff; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 16px 40px rgba(21, 26, 43, 0.18); overflow: hidden; text-align: left; }
.suggest[hidden] { display: none; }
.suggest-row { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; gap: 0 0.7rem; align-items: baseline; padding: 0.55rem 0.9rem; cursor: pointer; font-size: 0.9rem; }
.suggest-row + .suggest-row { border-top: 1px solid var(--border); }
.suggest-row.active { background: var(--accent-soft); }
.suggest-row .s-name { font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.suggest-row .s-sub { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-row .s-meta { color: var(--ink-3); font-size: 0.75rem; white-space: nowrap; }
.suggest-empty { padding: 0.6rem 0.9rem; color: var(--ink-2); font-size: 0.85rem; }
@media (max-width: 640px) { .suggest-row { grid-template-columns: minmax(0, 1fr) auto; } .suggest-row .s-sub { display: none; } }

/* product version badge in the header brand (.brand-text span is the block
   subtitle rule, so the badge needs its own display and sizing) */
.brand-text b { display: flex; align-items: center; gap: 0.35rem; }
.brand-text .brand-ver { display: inline-block; width: auto; margin: 0; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em;
  line-height: 1.2; color: #fff; background: var(--accent); border-radius: 999px; padding: 0.1rem 0.4rem; opacity: 1; }
