/* ==========================================================================
   Bifrost · Data & Score Wiki
   Design synthesis: BIFROST_TIER_WIKI calm sidebar wiki layout
   + amiralito.github.io/thesis airy typography & spacing
   ========================================================================== */

:root {
  --cyan: #4cc9f0;
  --sky: #4895ef;
  --blue: #4361ee;
  --indigo: #3f37c9;
  --navy: #3a0ca3;
  --pink: #f72585;
  --magenta: #b5179e;
  --purple: #7209b7;
  --violet: #560bad;

  --ok: #2a9d8f;
  --warn: #c7831e;
  --bad: #dc3f55;

  --side-w: 268px;
  --font: "area-normal", "Figtree", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg2: #f6f7fa;
  --bg3: #eef0f5;
  --ink: #111318;
  --ink2: #454a57;
  --ink3: #83899a;
  --line: #e6e8ef;
  --line-2: #cfd4e0;
  --card: #ffffff;
  --hover: #f1f3f8;
  --shadow: 0 18px 48px -18px rgba(17, 19, 24, 0.2);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0c0e13;
  --bg2: #11141c;
  --bg3: #181c27;
  --ink: #eceff5;
  --ink2: #adb3c4;
  --ink3: #71788c;
  --line: #222736;
  --line-2: #343b50;
  --card: #121620;
  --hover: #181d2a;
  --shadow: 0 22px 54px -16px rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  z-index: 200;
}
.skip-link:focus { left: 12px; }

/* ---------- App Shell ---------- */
#shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
#side {
  border-right: 1px solid var(--line);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 30;
}

.brand { padding: 20px 16px 14px; }
.brand-link { display: block; width: 100%; }
.brand-mark { display: flex; width: 100%; gap: 4px; margin-bottom: 10px; }
.brand-mark i { flex: 1; height: 5px; border-radius: 3px; display: block; }
.brand h1 {
  margin: 0;
  width: 100%;
  font-size: 69px;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0.005em;
  color: var(--ink);
  white-space: nowrap;
}

.side-search {
  margin: 0 16px 14px;
  position: relative;
}
.side-search input {
  width: 100%;
  padding: 8px 34px 8px 31px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.side-search input:focus { border-color: var(--blue); }
.side-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink3);
  pointer-events: none;
}
.side-search kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--ink3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  font-family: var(--font);
  pointer-events: none;
}

.side-results {
  position: absolute;
  left: 0;
  right: -120px;
  top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow-y: auto;
  z-index: 60;
}
.sr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--hover); }
.sr-main { min-width: 0; }
.sr-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: 11.5px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#nav {
  overflow-y: auto;
  padding: 0 10px 24px;
  flex: 1;
  min-height: 0;
}

.nav-sec {
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink3);
  padding: 18px 14px 6px;
}
.nav-sec:first-child { padding-top: 4px; }

.nav-a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--ink2);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}
.nav-a:hover { background: var(--hover); color: var(--ink); }
.nav-a.active {
  background: var(--card);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--line);
}
.nav-a .cnt { margin-left: auto; font-size: 11.5px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.nav-a .caret { width: 12px; color: var(--ink3); transition: transform 0.15s; flex: none; }
.nav-a.open .caret { transform: rotate(90deg); }

.nav-list {
  display: none;
  margin: 2px 0 6px 20px;
  border-left: 1px solid var(--line);
}
.nav-list.open { display: block; }

.nav-c {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 12px;
  font-size: 12.5px;
  color: var(--ink2);
  border-radius: 0 7px 7px 0;
  cursor: pointer;
  white-space: nowrap;
}
.nav-c:hover { background: var(--hover); color: var(--ink); }
.nav-c.active { color: var(--ink); background: var(--hover); box-shadow: inset 2px 0 0 var(--blue); }
.nav-c .ne { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.nav-c .nd { color: var(--ink3); font-size: 11px; flex: none; font-variant-numeric: tabular-nums; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; }

.side-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink3);
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}
.side-foot a:hover { color: var(--ink); }

/* ---------- Main Pane & Topbar ---------- */
#main {
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 clamp(20px, 4vw, 52px);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.crumbs {
  font-size: 13px;
  color: var(--ink3);
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: 0.45; }
.crumbs .cur { color: var(--ink); overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.tb-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.icon-btn {
  height: 32px;
  min-width: 32px;
  flex-shrink: 0;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }

.mobile-only { display: none; }

/* ---------- Article Canvas (Spacious Editorial Rhythm) ---------- */
article#page {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(32px, 5vw, 56px) clamp(20px, 4.5vw, 56px) 120px;
}

article#page.wide {
  max-width: 1180px;
}

/* Mild fade + subtle vertical glide on page-to-page navigation */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

article#page.page-enter {
  animation: pageEnter 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink3);
  margin: 0 0 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

article h1 {
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.14;
  margin: 0 0 14px;
  word-break: break-word;
}

article h1.mono-title {
  font-family: var(--mono);
  font-size: clamp(19px, 2.2vw, 25px);
  letter-spacing: -0.01em;
}

.lede {
  font-size: 16px;
  color: var(--ink2);
  line-height: 1.68;
  max-width: 64ch;
  margin: 0 0 22px;
}

.meta-line {
  font-size: 13.5px;
  color: var(--ink3);
  font-variant-numeric: tabular-nums;
  margin: 0 0 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}
.meta-line b { color: var(--ink); font-weight: 500; }
.meta-line .sep { opacity: 0.45; }

article h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 52px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  scroll-margin-top: 72px;
}

article h2 small {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink3);
}

article h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 28px 0 10px;
}

article p {
  color: var(--ink2);
  margin: 0 0 16px;
  max-width: 70ch;
}
article p b, article li b { color: var(--ink); font-weight: 600; }
article ul, article ol { color: var(--ink2); padding-left: 20px; margin: 0 0 18px; max-width: 72ch; }
article li { margin: 7px 0; }

.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

code, .mono {
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
code {
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink);
}

.muted { color: var(--ink3); }
.italic { font-style: italic; }

/* ---------- Landing Hero (thesis.html calm editorial elegance) ---------- */
.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 40px;
  align-items: center;
  padding: 10px 0 8px;
}

.landing-logo {
  width: 112px;
  height: auto;
  justify-self: end;
  opacity: 0.96;
}

.hero-cite-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink2);
}
.hero-cite-bar .sep { opacity: 0.4; }

/* ---------- Companion Paper & Citation Card (container-query adaptive) ---------- */
article.cite-card {
  container-type: inline-size;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 22px 24px;
  margin: 26px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 72px;
}
.cite-head {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cite-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.75px;
  text-transform: uppercase;
  color: var(--blue);
}
.cite-paper-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--ink);
}
.cite-authors {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink2);
  max-width: none;
}
.cite-affil {
  font-size: 12px;
  color: var(--ink3);
}
.cite-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.copy-ctrl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.copy-cmd-btn {
  min-inline-size: 24px;
  min-block-size: 30px;
}
.copy-cmd-btn[data-copied] {
  border-color: var(--ok);
  background: var(--ok);
  color: #ffffff;
}
.copy-cmd-btn[data-failed] {
  border-color: var(--bad);
  background: var(--bad);
  color: #ffffff;
}
.copy-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--ok);
  opacity: 0;
  transition: opacity 0.16s ease;
  white-space: nowrap;
}
.copy-cmd-btn[data-copied] + .copy-status {
  opacity: 1;
  color: var(--ok);
}
.copy-cmd-btn[data-failed] + .copy-status {
  opacity: 1;
  color: var(--bad);
}
.cite-snippet {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  padding: 13px 15px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cite-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}
@container (max-width: 560px) {
  .cite-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .copy-ctrl {
    justify-content: flex-start;
  }
}

/* ---------- 3-Column Accent Cards (signature BIFROST_TIER_WIKI) ---------- */
.tier-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 28px 0 12px;
}

.tcard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 22px 20px;
  background: var(--card);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.tcard:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}
.tcard::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--tc, var(--blue));
}
.tcard .tn {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--tc, var(--blue));
  font-weight: 600;
}
.tcard .tt {
  font-size: 15.5px;
  font-weight: 600;
  margin: 8px 0 14px;
  color: var(--ink);
  line-height: 1.3;
}
.tcard .big {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.6px;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tcard .big small {
  font-size: 12.5px;
  color: var(--ink3);
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 5px;
}
.tcard .desc {
  font-size: 13px;
  color: var(--ink2);
  margin: 14px 0 18px;
  line-height: 1.55;
}
.tcard .cta {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- Unified Hairline Facts Grid (BIFROST_TIER_WIKI) ---------- */
.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 18px 0 12px;
  background: var(--card);
}
.facts.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.fact {
  padding: 15px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.fact:nth-child(4n) { border-right: none; }
.facts.cols-5 .fact:nth-child(4n) { border-right: 1px solid var(--line); }
.facts.cols-5 .fact:nth-child(5n) { border-right: none; }
.facts.cols-5 .fact { border-bottom: none; }
.fact.primary-fact {
  background: color-mix(in srgb, var(--pink) 5%, var(--card));
}
.fact .k { font-size: 11px; color: var(--ink3); letter-spacing: 0.3px; }
.fact .v {
  font-size: 14.5px;
  font-weight: 500;
  margin-top: 4px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.fact .v.big-num { font-size: 21px; letter-spacing: -0.02em; }
.fact .v small { display: block; font-size: 12px; color: var(--ink3); font-weight: 400; margin-top: 3px; }

/* Pair page header, stacked subscores, two-row partners & collapsible Dataverse box */
.pair-title {
  font-size: clamp(22px, 2.6vw, 30px);
  margin-top: 2px;
}
.pair-actions {
  margin: 2px 0 20px;
}

.subscore-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-variant-numeric: tabular-nums;
}
.subscore-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 48%, transparent);
}
.subscore-item:first-child { padding-top: 0; }
.subscore-item:last-child { padding-bottom: 0; border-bottom: none; }
.subscore-item .sk { font-size: 13px; color: var(--ink2); }
.subscore-item .sv {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.pair-partner-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0 0;
}

.pair-collapse {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  margin: 48px 0 0;
  overflow: hidden;
  scroll-margin-top: 72px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.pair-collapse:hover,
.pair-collapse[open] {
  border-color: var(--line-2);
}
.pair-collapse-sum {
  display: block;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  list-style-type: none;
  user-select: none;
  transition: background 0.14s ease;
}
.pair-collapse-sum::-webkit-details-marker {
  display: none;
}
.pair-collapse-sum::marker {
  display: none;
  content: "";
}
.pair-collapse-sum:hover { background: var(--hover); }
.pair-collapse-sum:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
.pair-collapse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.pair-collapse-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pair-collapse-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--ink3);
}
.pair-collapse-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.3;
}
.pair-collapse-sub {
  font-size: 13px;
  color: var(--ink3);
  line-height: 1.5;
}
.pair-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.pair-collapse-sum:hover .pair-collapse-toggle {
  border-color: var(--line-2);
  background: var(--bg3);
  color: var(--ink);
}
.pair-collapse-toggle .lbl-open { display: none; }
.pair-collapse[open] .pair-collapse-toggle .lbl-closed { display: none; }
.pair-collapse[open] .pair-collapse-toggle .lbl-open { display: inline; }
.pair-collapse-chev {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.pair-collapse[open] .pair-collapse-chev {
  transform: rotate(180deg);
}
.pair-collapse-body {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg2);
}
.pair-dv-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--ink2);
}
.pair-dv-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 14px;
  align-items: baseline;
}
.pair-dv-k {
  font-size: 12px;
  color: var(--ink3);
  font-weight: 500;
}
.pair-dv-v {
  color: var(--ink2);
  line-height: 1.5;
  min-width: 0;
}
.pair-cmd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 12px;
}
.pair-collapse .code-block {
  background: var(--card);
  margin: 0;
  padding: 15px 18px;
}
.pair-terms-callout {
  margin-top: 32px;
}
.pair-partner-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pair-partner-card .p-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.35;
}
.pair-partner-card .p-meta {
  font-size: 13px;
  color: var(--ink2);
  line-height: 1.6;
}

/* ---------- Composition Bars & Funnel (BIFROST_TIER_WIKI) ---------- */
.comp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin: 14px 0 8px;
}

.stack {
  display: flex;
  height: 11px;
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0 14px;
  background: var(--bg3);
}
.stack i { display: block; height: 100%; }

.comp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink2);
  transition: background 0.12s;
}
.comp-row:hover { background: var(--hover); color: var(--ink); }
.comp-row .left { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.comp-row .right { font-variant-numeric: tabular-nums; color: var(--ink3); font-size: 12.5px; white-space: nowrap; }
.comp-row b { color: var(--ink); font-weight: 500; }

/* Step-by-step curation pipeline diagram */
.pipe {
  margin: 18px 0 24px;
  display: flex;
  flex-direction: column;
}
.pipe-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) repeat(4, 102px);
  gap: 10px;
  padding: 0 16px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink3);
}
.pipe-head .ph-num {
  text-align: right;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.pipe-step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) repeat(4, 102px);
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.pipe-step.pipe-final {
  border-color: color-mix(in srgb, var(--pink) 42%, var(--line));
  background: color-mix(in srgb, var(--pink) 5%, var(--card));
}
.pipe-idx {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pipe-step.pipe-final .pipe-idx {
  background: var(--pink);
  border-color: var(--pink);
  color: #ffffff;
}
.pipe-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}
.pipe-label small {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink3);
  margin-top: 2px;
}
.pipe-val {
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pipe-val.pipe-tot {
  font-weight: 600;
  color: var(--ink);
}
.pipe-step.pipe-final .pipe-val.pipe-tot {
  color: var(--pink);
}
.pipe-conn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 16px 4px 28px;
  min-height: 28px;
}
.pipe-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink3);
  flex-shrink: 0;
  width: 14px;
}
.pipe-op {
  font-size: 11.5px;
  color: var(--ink3);
  line-height: 1.35;
}

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 22px 0;
  background: var(--bg2);
  font-size: 13.5px;
  color: var(--ink2);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.callout.warn { border-left-color: var(--warn); }
.callout.pink { border-left-color: var(--pink); }
.callout b { color: var(--ink); font-weight: 600; }

/* ---------- Buttons, Chips, Segmented Controls, Badges ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.btn:hover { border-color: var(--line-2); background: var(--hover); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-back { padding: 0 13px; line-height: 1; }
.btn-back svg { display: block; flex-shrink: 0; }
.btn.copied { border-color: var(--ok); color: var(--ok); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.seg button {
  border: none;
  background: transparent;
  color: var(--ink2);
  font-size: 12.5px;
  padding: 6px 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 500; }

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 14px;
}
.tools input[type="search"],
.tools input[type="text"] {
  flex: 1;
  min-width: 220px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.tools input:focus { border-color: var(--blue); }

.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink2);
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}
.chip.on-soft {
  border-color: var(--blue);
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 7%, transparent);
}

/* Collapsible Advanced Filters Drawer */
.adv-drawer {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 18px 20px;
  margin: 0 0 16px;
}
.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--blue); }
.field textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  min-height: 140px;
  resize: vertical;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  color: var(--ink2);
  white-space: nowrap;
}
.badge-ID1 { border-color: color-mix(in srgb, var(--cyan) 50%, transparent); color: #0b7299; background: color-mix(in srgb, var(--cyan) 12%, transparent); }
.badge-ID2 { border-color: color-mix(in srgb, var(--purple) 40%, transparent); color: #7209b7; background: color-mix(in srgb, var(--purple) 10%, transparent); }
.badge-ID3 { border-color: color-mix(in srgb, var(--pink) 42%, transparent); color: #c41263; background: color-mix(in srgb, var(--pink) 10%, transparent); }
[data-theme="dark"] .badge-ID1 { color: #7ce0ff; }
[data-theme="dark"] .badge-ID2 { color: #d396ff; }
[data-theme="dark"] .badge-ID3 { color: #ff7ab5; }

.badge-warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.badge-bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }

/* Score pill + micro bar */
.score-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.score-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-weight: 600;
  min-width: 52px;
  text-align: right;
  background: color-mix(in srgb, var(--sc, var(--blue)) 13%, transparent);
  color: var(--ink);
}
.score-pill.score-zero {
  background: var(--bg2);
  color: var(--ink3);
  font-weight: 400;
}

.score-bar-track {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg3);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.score-bar-fill { display: block; height: 100%; border-radius: 2px; }

/* ---------- Clean Tables (BIFROST_TIER_WIKI .dt & .ev) ---------- */
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink3);
  margin: 6px 0 10px;
}
.table-meta b { color: var(--ink); font-weight: 500; }

.tblwrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  background: var(--card);
}

table.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dt th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  text-align: left;
  font-weight: 500;
  color: var(--ink3);
  font-size: 11.5px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
.dt th.sortable { cursor: pointer; }
.dt th.sortable:hover { color: var(--ink); }
.dt th.sorted { color: var(--ink); box-shadow: inset 0 -2px 0 var(--blue); }
.dt td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--ink2);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.dt td:first-child { white-space: nowrap; }
.dt tr:last-child td { border-bottom: none; }
.dt tbody tr.clickable { cursor: pointer; }
.dt tbody tr:hover td { background: var(--hover); }
.dt td.num, .dt th.num { text-align: right; white-space: nowrap; }

.job-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.row-ext-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 26px;
  min-block-size: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--ink3);
  flex-shrink: 0;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.row-ext-btn:hover {
  color: var(--blue);
  border-color: var(--line);
  background: var(--card);
}
.row-ext-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  color: var(--blue);
}
@media (pointer: coarse) {
  .row-ext-btn {
    min-inline-size: 32px;
    min-block-size: 32px;
  }
}

.prot-link {
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid transparent;
}
.prot-link:hover { color: var(--blue); border-bottom-color: var(--blue); }

.ext-link {
  color: var(--ink);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
}
.dt .ext-link { white-space: nowrap; }
.ext-link:hover { color: var(--blue); border-bottom-color: var(--blue); }

.cell-trunc {
  max-width: 215px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

/* Evidence / Glossary Table (BIFROST_TIER_WIKI .ev) */
table.ev {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 8px 0 16px;
}
.ev td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink2);
}
.ev td:first-child { padding-left: 0; color: var(--ink); width: 28%; font-weight: 500; }
.ev td:last-child { padding-right: 0; }
.ev tr:last-child td { border-bottom: none; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink3);
}

/* Progress bar */
.load-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--ink2);
}
.prog-track { width: 180px; height: 5px; border-radius: 99px; background: var(--bg3); overflow: hidden; }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue), var(--pink)); transition: width 0.2s; }

/* ---------- Sequence Viewer & Code Blocks ---------- */
.seq-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  overflow: hidden;
  margin: 14px 0 8px;
}
.seq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  flex-wrap: wrap;
}
.seq-body {
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.8;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre;
  color: var(--ink2);
}
.seq-pos {
  color: var(--ink3);
  user-select: none;
  display: inline-block;
  width: 5ch;
  text-align: right;
  margin-right: 1.5ch;
}
.seq-hl-id { background: rgba(247, 37, 133, 0.2); color: var(--ink); border-radius: 3px; font-weight: 600; }
.seq-hl-match { background: rgba(76, 201, 240, 0.3); color: var(--ink); border-radius: 3px; font-weight: 600; }

.code-block, .aln-pre {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  margin: 10px 0 0;
  color: var(--ink2);
}

/* ---------- Inline SVG Charts ---------- */
.chart-box {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--card);
  margin: 12px 0 18px;
}
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--line-2); stroke-width: 1; }
.chart-tick { fill: var(--ink3); font-family: var(--mono); font-size: 10px; }
.chart-axis-title { fill: var(--ink2); font-size: 11px; font-weight: 500; }
.chart-ref-line { stroke: var(--ink3); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.chart-ref-label { fill: var(--ink3); font-family: var(--mono); font-size: 10px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink2); margin-bottom: 10px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 14px; height: 3px; border-radius: 2px; }
.chart-hover-band { fill: var(--blue); fill-opacity: 0.09; transition: opacity 0.1s; }
.chart-hit { cursor: crosshair; }
.schematic-svg .chart-hit { cursor: default; }
.schematic-svg a .sch-sib-rect { cursor: pointer; }

/* Instant styled hover tooltip for charts & schematics */
.chart-tooltip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  min-width: 175px;
  max-width: 280px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--ink);
  line-height: 1.45;
}
.chart-tooltip .ct-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  word-break: break-word;
}
.chart-tooltip .ct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 1.5px 0;
  color: var(--ink2);
}

/* Instant floating score-header explanation tooltip */
.th-tip {
  text-decoration: underline dotted color-mix(in srgb, var(--ink3) 70%, transparent);
  text-underline-offset: 3px;
  cursor: help;
}
.dt th.sortable .th-tip {
  cursor: pointer;
}
.score-tip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  max-width: min(280px, calc(100vw - 24px));
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--card) 97%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink2);
}
.score-tip .st-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 3px;
}
.score-tip .st-body {
  color: var(--ink2);
}
.fasta-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink3);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}
.chart-tooltip .ct-row.ct-bold {
  margin-top: 3px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
}
.chart-tooltip .ct-k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chart-tooltip .ct-v {
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-word;
}

.schematic-backbone {
  stroke: var(--line-2);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.schematic-pill-text {
  fill: #ffffff;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.sch-other-rect {
  fill: #949eb3;
}
[data-theme="dark"] .sch-other-rect {
  fill: #555f75;
}
.sch-sib-rect {
  fill: #f9cde1;
  transition: fill 0.15s;
}
.sch-sib-link:hover .sch-sib-rect,
.sch-sib-link:focus-visible .sch-sib-rect {
  fill: #f49ec6;
}
[data-theme="dark"] .sch-sib-rect {
  fill: #4f1c38;
}
[data-theme="dark"] .sch-sib-link:hover .sch-sib-rect,
[data-theme="dark"] .sch-sib-link:focus-visible .sch-sib-rect {
  fill: #70264f;
}
.schematic-sib-text {
  fill: #9b1252;
  font-size: 10px;
  font-weight: 600;
}
[data-theme="dark"] .schematic-sib-text {
  fill: #ff99c8;
}
.dot-sib {
  background: #f49ec6;
}
[data-theme="dark"] .dot-sib {
  background: #8a3160;
}
.schematic-callout {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.schematic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink2);
}
.sch-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sch-item b {
  font-weight: 500;
  color: var(--ink);
}
.sch-item.sch-id b {
  color: var(--pink);
  font-weight: 600;
}
.sch-item.sch-sib {
  opacity: 0.62;
  transition: opacity 0.14s, color 0.14s;
}
.sch-item.sch-sib:hover {
  opacity: 1;
  color: var(--pink);
}
.sch-item.sch-sib:hover b {
  color: var(--pink);
}
.schematic-sib-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
}
.sib-bar-label {
  font-size: 11.5px;
  color: var(--ink3);
  margin-right: 2px;
}
.sib-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink2);
  font-size: 11.5px;
  opacity: 0.68;
  max-width: 100%;
  transition: opacity 0.14s, border-color 0.14s, color 0.14s;
}
.sib-chip .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.sib-chip .sib-sub {
  color: var(--ink3);
  white-space: nowrap;
}
.sib-chip:hover {
  opacity: 1;
  border-color: color-mix(in srgb, var(--pink) 50%, var(--line));
  color: var(--pink);
}

/* ---------- Inline Panel Drop-in Select Bar ---------- */
.select-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px 12px;
  margin: 0 0 16px;
}
.select-bar .field {
  gap: 4px;
}
.select-bar select {
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
}

/* ---------- Manuscript Figure Plates & Zoom Lightbox ---------- */
figure.fig-plate {
  margin: 16px 0 28px;
}
.fig-frame {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 0.15s;
}
.fig-frame:hover { border-color: var(--line-2); }
.fig-frame img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.fig-zoom-pill {
  position: absolute;
  top: 12px;
  right: 12px;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #e6e8ef;
  background: rgba(255, 255, 255, 0.94);
  color: #454a57;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.fig-frame:hover .fig-zoom-pill { opacity: 1; }
figure.fig-plate figcaption {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink2);
  max-width: 78ch;
}
figure.fig-plate figcaption b { color: var(--ink); font-weight: 600; }

/* Lightbox dialog */
dialog.fig-dialog {
  width: min(1240px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.fig-dialog::backdrop {
  background: rgba(12, 14, 19, 0.62);
  backdrop-filter: blur(4px);
}
.fig-dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 30px);
}
.fig-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.fig-dialog-stage {
  overflow: auto;
  padding: 20px;
  background: #ffffff;
  text-align: center;
}
.fig-dialog-stage img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}
.fig-dialog-cap {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink2);
}

/* AlphaFold 3 JSON Input Generator Dialog */
dialog.af3-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.af3-dialog::backdrop {
  background: rgba(12, 14, 19, 0.56);
  backdrop-filter: blur(4px);
}
.af3-dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 30px);
}
.af3-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.af3-dialog-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.af3-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.af3-form-row .seg {
  width: 100%;
}
.af3-form-row .seg button {
  flex: 1;
  text-align: center;
}
.af3-preview {
  max-height: 220px;
  overflow: auto;
  margin-top: 0;
  font-size: 11.5px;
}
.af3-err {
  margin-top: 6px;
  font-size: 12px;
  color: var(--bad);
}
.af3-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg2);
}

/* Host Institution Banner Card (TSL) */
.host-card {
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  margin: 16px 0 8px;
  transition: border-color 0.16s, transform 0.16s;
}
.host-card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}
.host-logo-stage {
  background: #ffffff;
  padding: 20px 26px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.host-logo-stage img {
  height: 36px;
  width: auto;
  max-width: 240px;
  display: block;
}
.host-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
  padding: 12px 0;
}
.host-ext {
  font-size: 12.5px;
  color: var(--ink3);
  padding-right: 20px;
  white-space: nowrap;
}
.host-card:hover .host-ext { color: var(--blue); }

/* Abstract & Acknowledgements editorial styling */
.abstract-text {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink2);
  max-width: 68ch;
  margin: 0;
}
.author-list {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  max-width: 72ch;
  margin: 0 0 14px;
}
.author-list sup {
  font-size: 10.5px;
  color: var(--ink3);
  margin-left: 1px;
}
.affil-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink2);
}
.affil-list li { margin-bottom: 4px; }
.affil-list sup { color: var(--ink3); margin-right: 5px; font-weight: 600; }

/* Funder logo plates */
.funder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 10px;
}
.funder-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  transition: border-color 0.16s, transform 0.16s;
}
.funder-card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}
.funder-logo-stage {
  height: 92px;
  padding: 16px 22px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}
.funder-logo-stage img {
  max-width: 100%;
  max-height: 52px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.funder-meta {
  padding: 11px 14px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.funder-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.funder-role {
  font-size: 11.5px;
  color: var(--ink3);
  line-height: 1.4;
}

/* Horizontal bars */
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: flex; flex-direction: column; gap: 4px; color: inherit; }
.hbar-link:hover .hbar-label { color: var(--blue); }
.hbar-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-val { font-family: var(--mono); font-size: 12px; color: var(--ink3); flex-shrink: 0; }
.hbar-track { height: 7px; border-radius: 4px; background: var(--bg3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; }

/* ---------- Most Similar Sequence Card (Paralogs / Orthologs) ---------- */
.nn-card {
  margin: 22px 0 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
  border-radius: 12px;
  background: var(--card);
  padding: 15px 18px;
}
.nn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding-bottom: 11px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.nn-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nn-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: var(--ink3);
}
.nn-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 22px;
  flex-wrap: wrap;
}
.nn-target {
  min-width: 0;
  flex: 1 1 280px;
}
.nn-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.nn-name {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-word;
}
.nn-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink2);
  line-height: 1.45;
}
.nn-stats {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: 8px 18px;
  font-variant-numeric: tabular-nums;
}
.nn-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nn-stat .k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: var(--ink3);
}
.nn-stat .v {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.nn-drawer {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
}

/* ---------- Custom Heatmap Tool (#/heatmap) ---------- */
.hm-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}
.hm-presets-lbl {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--ink3);
  margin-right: 2px;
}
.hm-builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.hm-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.hm-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.hm-ac-wrap {
  position: relative;
}
.hm-ac-wrap input[type="search"] {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.hm-ac-wrap input[type="search"]:focus {
  border-color: var(--blue);
  background: var(--card);
}
.hm-ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 270px;
  overflow-y: auto;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 4px;
}
.hm-ac-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.hm-ac-item:hover { background: var(--hover); }
.hm-ac-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.hm-ac-main small {
  color: var(--ink3);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hm-batch-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
.hm-batch-row select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  min-width: 0;
}
.hm-paste-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hm-paste-box textarea {
  width: 100%;
  min-height: 76px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
}
.hm-paste-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.hm-chip-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 112px;
  overflow-y: auto;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg2);
  align-content: flex-start;
}
.hm-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 230px;
  height: 24px;
  padding: 0 5px 0 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink2);
  font-size: 11.5px;
}
.hm-pill-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hm-pill-x {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink3);
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.hm-pill-x:hover {
  background: var(--hover);
  color: var(--ink);
}
.hm-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  margin-bottom: 12px;
}
.hm-ctrl-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hm-ctrl-field label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink3);
}
.hm-ctrl-field select {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}
.hm-ctrl-toggles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.hm-stage-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.hm-stage {
  overflow: auto;
  padding: 18px 20px;
  max-height: 78vh;
}
.hm-svg {
  display: block;
}
.hm-cell {
  transition: stroke 0.08s;
}
.hm-cell.hm-clickable {
  cursor: pointer;
}
.hm-cell:hover {
  stroke: var(--ink);
  stroke-width: 1.5;
}
.hm-lbl-link:hover .hm-axis-lbl {
  fill: var(--blue);
  text-decoration: underline;
}
.hm-empty {
  text-align: center;
  padding: 56px 18px;
  color: var(--ink3);
  font-size: 13.5px;
}

/* ---------- Loading ---------- */
.center-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 72px 16px;
  color: var(--ink3);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
.side-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 19, 0.4);
  z-index: 25;
}

@media (max-width: 960px) {
  #shell { grid-template-columns: minmax(0, 1fr); }
  #side {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  #side.open { transform: translateX(0); }
  .brand h1 { font-size: clamp(44px, 13vw, 66px); }
  .mobile-only { display: inline-flex; }
  .side-results { right: 0; }
  .topbar { padding: 0 16px; gap: 10px; }
  article#page { padding: 24px 18px 96px; }
  .landing-hero { grid-template-columns: 1fr; gap: 16px; }
  .landing-logo { display: none; }
  .tier-cards, .comp, .hm-builder { grid-template-columns: 1fr; }
  .nn-stats { grid-template-columns: repeat(3, auto); }
  .funder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts, .facts.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact:nth-child(2n), .facts.cols-5 .fact:nth-child(2n) { border-right: none; }
  .facts.cols-5 .fact { border-bottom: 1px solid var(--line); }
  .facts.cols-5 .fact:last-child { grid-column: 1 / -1; border-right: none; border-bottom: none; }
  .pipe-head { display: none; }
  .pipe-step { grid-template-columns: 28px minmax(0, 1fr); gap: 6px 10px; }
  .pipe-val { grid-column: 2; text-align: left; font-size: 12px; display: flex; justify-content: space-between; }
  .pipe-val::before { content: attr(data-lbl); color: var(--ink3); font-family: var(--font); }
}

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; height: 52px; }
  .tb-right a.icon-btn span:first-child { display: none; }
  .tb-right a.icon-btn { padding: 0 9px; }
  article#page { padding: 20px 14px 88px; }
  article h1 { font-size: clamp(22px, 6.5vw, 30px); }
  article h1.mono-title { font-size: clamp(16px, 4.6vw, 22px); }
  article h2 { flex-wrap: wrap; gap: 8px 12px; margin-top: 32px; font-size: 16.5px; }
  .page-head-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head-row .btn-group { width: 100%; }
  .tools { gap: 6px; }
  .tools input[type="search"],
  .tools input[type="text"] { flex: 1 1 100%; min-width: 0; width: 100%; }
  .chip { height: 30px; padding: 0 10px; font-size: 12px; }
  .select-bar, .adv-grid { grid-template-columns: 1fr; gap: 10px; }
  .adv-drawer { padding: 14px; }
  .fact { padding: 12px 13px; }
  .fact .v { font-size: 13.5px; }
  .fact .v.big-num { font-size: 18px; }
  .seg { max-width: 100%; flex-wrap: wrap; }
  .seg button { font-size: 12px; padding: 6px 10px; }
  .chart-box { padding: 12px; }
  .fig-frame { padding: 10px; }
  .dt th, .dt td { padding: 8px 9px; font-size: 12.5px; }
  .cell-trunc { max-width: 155px; }
  .ev tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .ev tr:last-child { border-bottom: none; }
  .ev td { display: block; width: 100% !important; padding: 2px 0; border-bottom: none; }
  .ev td:first-child { font-size: 12px; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
  .pair-collapse { margin-top: 36px; }
  .pair-collapse-sum { padding: 16px; }
  .pair-collapse-bar { flex-wrap: wrap; gap: 12px; }
  .pair-collapse-body { padding: 16px; }
  .pair-dv-row { grid-template-columns: 1fr; gap: 2px; }
  .host-card { flex-direction: column; align-items: stretch; gap: 0; }
  .host-logo-stage { border-right: none; border-bottom: 1px solid var(--line); padding: 18px; }
  .host-meta { padding: 12px 16px 6px; }
  .host-ext { padding: 0 16px 12px; }
  .funder-grid { grid-template-columns: 1fr; }
  .af3-form-row { grid-template-columns: 1fr; }
  .hm-batch-row { grid-template-columns: 1fr; }
  .hm-ctrl-toggles { margin-left: 0; }
  .hm-stage { padding: 12px; }
  .nn-card { padding: 13px 14px; }
  .nn-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .sib-chip .mono { max-width: 190px; }
  .pagination { flex-direction: column; align-items: flex-start; gap: 8px; }
  .seq-head { padding: 10px 12px; }
  .seq-body { padding: 12px; font-size: 11.5px; }
}

@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; }
  .fact { border-right: none !important; }
  .fact:last-child { border-bottom: none; }
  .facts.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts.cols-5 .fact:nth-child(odd) { border-right: 1px solid var(--line) !important; }
  .facts.cols-5 .fact:last-child { grid-column: 1 / -1; border-right: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
