/* ============================================================
   Microglia Atlas · Rao & Peng Joint Lab
   Light academic stylesheet
   ============================================================ */
:root {
  --navy: #16324f;
  --navy-2: #1f4068;
  --accent: #2f6fae;
  --accent-soft: #eaf1f9;
  --ink: #1c2733;
  --muted: #5b6b7b;
  --line: #e3e8ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --warn: #a15c00;
  --warn-bg: #fff4e2;
  --err: #b3261e;
  --err-bg: #fdecea;
  --shadow: 0 1px 2px rgba(22, 50, 79, .06), 0 8px 24px rgba(22, 50, 79, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 Arial, "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------- top nav ---------------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: stretch; gap: 18px; flex-wrap: wrap;
  background: var(--navy);
  color: #fff;
  padding: 0 26px;
  box-shadow: 0 2px 10px rgba(10, 25, 41, .25);
}
.navbrand { display: flex; flex-direction: column; justify-content: center; padding: 10px 0; }
.brand-lab { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11.5px; color: #b9cde0; letter-spacing: .3px; }
.navlinks { display: flex; align-items: stretch; flex-wrap: wrap; gap: 2px; }
.navlink {
  border: 0; background: transparent; color: #d7e3ef; cursor: pointer;
  font: 600 13.5px/1 Arial, sans-serif;
  padding: 0 15px;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.navlink:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.navlink.active { color: #fff; border-bottom-color: #7fb2e5; background: rgba(255, 255, 255, .08); }

/* ---------------- home ---------------- */
.hero { text-align: center; padding: 56px 20px 8px; }
.hero h1 { margin: 0 0 10px; font-size: 30px; font-weight: 800; letter-spacing: -.3px; color: var(--navy); }
.hero-sub { max-width: 760px; margin: 0 auto 10px; color: var(--muted); font-size: 15.5px; }
.hero-tip { max-width: 760px; margin: 0 auto; color: var(--muted); font-size: 13.5px; }
.hero-tip b { color: var(--ink); background: #fff; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; font-family: Consolas, Menlo, monospace; }

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; max-width: 1180px; margin: 30px auto 10px; padding: 0 24px;
}
.card {
  position: relative; display: flex; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: #c3d4e4; box-shadow: 0 4px 10px rgba(22,50,79,.08), 0 14px 30px rgba(22,50,79,.09); }
.card-num { font-size: 26px; font-weight: 800; color: #c3d4e4; line-height: 1; margin-top: 2px; }
.card-body h3 { margin: 0 0 6px; font-size: 16.5px; color: var(--navy); }
.card-body p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

.btn {
  display: inline-block; border: 0; border-radius: 7px; cursor: pointer;
  background: var(--accent); color: #fff;
  font: 600 14px/1 Arial, sans-serif;
  padding: 10px 18px; transition: background .15s, transform .05s;
}
.btn:hover { background: #275f96; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 8px 14px; font-size: 13px; background: transparent; color: var(--accent); border: 1px solid #bcd2e6; }
.btn-sm:hover { background: var(--accent-soft); }
.btn-block { width: 100%; }

.home-cite { max-width: 1180px; margin: 26px auto 40px; padding: 0 24px; text-align: center; color: var(--muted); font-size: 12.5px; }
.home-cite p { margin: 4px 0; }
.home-cite a { color: var(--accent); }

/* ---------------- atlas layout ---------------- */
.atlas-layout {
  display: grid; grid-template-columns: 322px minmax(0, 1fr); gap: 22px;
  max-width: 1560px; margin: 0 auto; padding: 26px 24px 40px; align-items: start;
}
.atlas-title { margin: 0 0 14px; font-size: 21px; color: var(--navy); line-height: 1.3; }

.sidebar {
  position: sticky; top: 78px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.gene-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.combobox { position: relative; margin-bottom: 10px; }
.gene-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px;
  font: 600 15px Consolas, Menlo, monospace, sans-serif; color: var(--ink);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.gene-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 111, 174, .15); }
.suggest {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 30px rgba(22, 50, 79, .14);
}
.sug-item { padding: 7px 12px; cursor: pointer; font: 13.5px Consolas, Menlo, monospace, sans-serif; }
.sug-item b { color: var(--accent); font-weight: 700; }
.sug-item:hover, .sug-item.sel { background: var(--accent-soft); }

.cite { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.cite-links { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.cite-links a { color: var(--accent); font-weight: 600; }

.main-col { min-width: 0; }
.tabbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; padding: 8px 8px 0;
}
.tab {
  border: 1px solid transparent; border-bottom: 0; background: transparent; cursor: pointer;
  font: 600 13px/1 Arial, sans-serif; color: var(--muted);
  padding: 9px 14px; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--ink); background: #f0f4f8; }
.tab.active {
  color: var(--navy); background: #fff;
  border-color: var(--line);
  box-shadow: 0 -2px 6px rgba(22,50,79,.04);
}
.tabpanels {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 18px;
}
.tabpanel { display: none; }
.tabpanel.active { display: block; }
.panel-head { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 10px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 15.5px; color: var(--navy); }
.panel-gene { font: italic 700 15px Georgia, serif; color: var(--accent); }

.placeholder {
  border: 1.5px dashed #cfdae5; border-radius: 8px; background: #fafbfd;
  color: var(--muted); padding: 46px 20px; text-align: center; font-size: 13.5px;
}
.warn { color: var(--warn); background: var(--warn-bg); border: 1px solid #f0d9ae; border-radius: 6px; padding: 8px 12px; display: inline-block; }
.err { color: var(--err); background: var(--err-bg); border: 1px solid #f3c2be; border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }

/* ---------------- figures ---------------- */
.figwrap { display: flex; flex-wrap: wrap; gap: 18px; }
.figure { min-width: 0; width: 100%; }
.figure.col-third { width: calc(33.333% - 12px); min-width: 320px; }
.figure.col-half { width: calc(50% - 9px); min-width: 340px; }
.figure-title { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.figure-title .n { color: #9aa9b8; font-size: 11.5px; font-weight: 400; margin-left: 6px; }
.figure .plot { width: 100%; height: 430px; }
.figure.col-third .plot { height: 440px; }
.figure.col-half  .plot { height: 360px; }
.figure-note { font-size: 11.5px; color: #9aa9b8; margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 2px 2px; font-size: 12px; color: var(--ink); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.legend-item em { color: var(--muted); font-style: normal; margin-left: 3px; font-size: 11px; }

@media (max-width: 1080px) {
  .atlas-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .figure.col-third { width: 100%; min-width: 0; }
  .figure.col-half { width: 100%; min-width: 0; }
}

/* ---------------- footer / toast / busy ---------------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--line); background: #eef2f6;
  color: var(--muted); font-size: 12px;
  padding: 14px 26px;
}

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(20, 35, 50, .94); color: #fff;
  font-size: 13.5px; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .25); z-index: 100;
  max-width: 86vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#busyOverlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(245, 247, 250, .72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(1.5px);
}
.busy-box {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(22, 50, 79, .15);
  padding: 18px 26px; font-size: 14.5px; color: var(--navy); font-weight: 600;
}
.spinner {
  width: 22px; height: 22px; flex: none;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
