:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #16213e;
  --muted: #4d5b7a;
  --link: #2f6fd6;
  --warn: #9a4e00;
  --accent: #3b4f71;
  --chip: #edf2ff;
  --border: #e6ebf4;
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #edf3ff 0%, var(--bg) 45%, #fff 100%);
  color: var(--text);
  line-height: 1.5;
}

/* Single, centered reading column — book-like. */
.book {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.6rem 1.2rem 4rem;
}

/* ---- Masthead ---------------------------------------------------------- */
.masthead {
  text-align: center;
  margin: 1.2rem 0 1.6rem;
}
.brand {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.tagline {
  color: var(--muted);
  max-width: 36rem;
  margin: 0.4rem auto 0;
  font-size: 0.98rem;
}

/* ---- Search bar (one box) --------------------------------------------- */
.searchbar { margin: 0 auto; max-width: 640px; }
.searchbar-row {
  display: flex;
  gap: 0.5rem;
}
.search-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 1px solid #ccd4e7;
  border-radius: 10px;
  background: #fff;
}
.search-input:focus {
  outline: none;
  border-color: #2844b5;
  box-shadow: 0 0 0 3px rgba(40, 68, 181, 0.12);
}
.searchbar-row button {
  flex: 0 0 auto;
  padding: 0.7rem 1.3rem;
  font-size: 1rem;
  border-radius: 10px;
  background: #2844b5;
  color: #fff;
  border: 1px solid #2844b5;
  cursor: pointer;
}
.searchbar-row button:disabled { opacity: 0.6; cursor: not-allowed; }

.adv {
  max-width: 640px;
  margin: 0.55rem auto 0;
  font-size: 0.9rem;
}
.adv summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}
.adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.7rem;
  padding: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.adv-grid label { display: grid; gap: 0.25rem; font-size: 0.85rem; }
.adv-grid .row { display: flex; gap: 0.4rem; align-items: center; }
.adv-grid input {
  padding: 0.4rem;
  border: 1px solid #ccd4e7;
  border-radius: 7px;
  width: 100%;
}
.adv-grid .row input[type="checkbox"] { width: auto; }

/* ---- Examples + quick links ------------------------------------------- */
.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin: 0.8rem auto 0;
  max-width: 640px;
}
.examples-label { font-size: 0.8rem; color: var(--muted); }
.example-chip {
  font-size: 0.8rem;
  padding: 3px 10px;
  border: 1px solid #cfd6e4;
  border-radius: 999px;
  background: #f3f6fb;
  color: #234;
  cursor: pointer;
}
.example-chip:hover { background: #e6edf8; }

.quicklinks {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0 0.5rem;
}
.linkpill {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid #dbe4f7;
}
.linkpill:hover { background: #e2eaff; text-decoration: none; }

.home-reviews {
  margin-top: 1.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.home-reviews-tagline {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.review-list-item {
  background: #f8faff;
  border: 1px solid #e5e9f5;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.review-list-title {
  display: block;
  font-weight: 700;
  line-height: 1.25;
}

.review-list-meta {
  margin-top: 0.2rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.review-list-lead {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

.review-list-all {
  margin-top: 0.6rem;
  display: inline-block;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---- Status ------------------------------------------------------------ */
#statusArea {
  min-height: 1.2rem;
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}
#statusArea.warn { color: var(--warn); font-weight: 600; }
#statusArea.loading::before {
  content: '';
  display: inline-block;
  width: 0.8em; height: 0.8em;
  margin-right: 0.45em; vertical-align: -0.1em;
  border: 2px solid #ccd4e7; border-top-color: #2844b5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Section blocks (results, node, welcome) -------------------------- */
#resultsSection, .node, .welcome { margin-top: 1.6rem; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.8rem;
}

h2 { margin: 0; font-size: 1.2rem; }
h3 { margin: 1rem 0 0.5rem; font-size: 1rem; }
.review-title { 
  font-size: clamp(1.65rem, 3vw, 2rem);
  line-height: 1.2;
  margin: 0 0 0.35rem;
}
.review-byline { 
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.review-notice {
  margin: 0.55rem 0 1rem;
  color: var(--accent);
  font-size: 0.92rem;
}
.review-article {
  max-width: 46rem;
  margin: 0 auto;
  padding-top: 0.4rem;
  line-height: 1.7;
}
.review-article p { margin: 0 0 0.9rem; }
.review-article h2 {
  margin: 1.55rem 0 0.55rem;
  font-size: 1.25rem;
}
.review-article h3 {
  margin: 1.2rem 0 0.45rem;
  font-size: 1.05rem;
}
.review-article ul { margin: 0 0 1rem 1.2rem; padding: 0; }
.review-article li { margin: 0.08rem 0 0.35rem; }
.review-citation { font-size: 0.72rem; margin-left: 0.06rem; }
.review-citation a {
  color: var(--link);
  text-decoration: none;
}
.review-citation a:hover { text-decoration: underline; }
.review-references {
  margin-top: 1.8rem;
}
.review-references h2 {
  margin-top: 0;
}
.review-references ol {
  margin: 0.6rem 0 0;
  padding-left: 2rem;
  font-size: 0.9rem;
}
.review-references li {
  margin: 0 0 0.65rem;
  padding-left: 0.2rem;
  line-height: 1.5;
}
.review-references li::marker {
  color: var(--muted);
}

.muted { color: var(--muted); font-size: 0.9rem; }

.entity-header {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.entity-header h2 { font-size: 1.35rem; }

.pill {
  background: var(--chip);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
}
.pill.bad { background: #ffe8d6; color: #7b3f00; }

.searchtext {
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  color: #2a3550;
}

/* 3Dmol needs an explicitly-sized, positioned container. */
.structure-viewer {
  position: relative;
  width: 100%;
  height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

/* Embedding map scatter */
.scatter {
  width: 100%;
  max-width: 760px;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: crosshair;
  display: block;
  margin-top: 0.6rem;
}
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }
.legend-item { font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.3rem; color: var(--text); }
.legend-item .swatch { width: 0.7rem; height: 0.7rem; border-radius: 2px; display: inline-block; }

/* Experimental structures (PDB) + ESM-2 bridge */
.exp-struct { margin-top: 0.6rem; display: grid; gap: 0.3rem; }
.exp-head { font-weight: 600; font-size: 0.88rem; color: var(--accent); }
.exp-item { font-size: 0.88rem; }
.exp-item a { font-weight: 600; }

/* Families & classification (Pfam / InterPro / EC) */
.families { display: grid; gap: 0.5rem; }
.family-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.family-label { font-weight: 600; color: var(--muted); min-width: 6.5rem; }
.family-row a {
  background: var(--chip);
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* ---- Lists ------------------------------------------------------------- */
.results-list,
.edges-list,
.kv-list,
.results-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.results-list li,
.edges-list li,
.kv-list li,
.results-sublist li,
.result-group {
  padding: 0.55rem 0.65rem;
  background: #f8faff;
  border: 1px solid #e5e9f5;
  border-radius: 8px;
}
.result-group { margin: 0; }
.result-group-title { font-weight: 600; margin-bottom: 0.45rem; }
.result-snippet { color: #444; font-size: 0.85rem; margin: 2px 0 0; line-height: 1.35; }
#backToResults { margin-bottom: 0.6rem; }
.backlink { font-weight: 600; font-size: 0.9rem; }
.rollup-toggle { cursor: pointer; color: var(--link); font-size: 0.85rem; white-space: nowrap; }
.rollup-toggle:hover { text-decoration: underline; }
.rollup-items { margin-top: 0.4rem; padding-left: 0.6rem; border-left: 2px solid var(--border); }
.results-sublist .code { color: #777; font-size: 0.8rem; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.code {
  background: #f4f6fb;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.84rem;
}

/* ---- Welcome / three pillars ------------------------------------------ */
.welcome p { color: #2c3654; }
.welcome h2 { margin-top: 1.4rem; }

.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}
.count {
  flex: 1 1 120px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.count .n {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  margin-top: 0.8rem;
}
.pillar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.pillar-icon { font-size: 1.5rem; }
.pillar h3 { margin: 0.4rem 0 0.3rem; }
.pillar p { font-size: 0.86rem; color: var(--muted); flex: 1; margin: 0 0 0.7rem; }
.pillar-link { font-weight: 600; font-size: 0.9rem; }

.docnote { margin-top: 1.4rem; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 680px) {
  .pillars { grid-template-columns: 1fr; }
  .adv-grid { grid-template-columns: 1fr; }
  .searchbar-row { flex-wrap: wrap; }
  .searchbar-row button { width: 100%; }
}
