:root {
  color-scheme: light;
  --bg: #fbfafc;
  --bg-deep: #f4f2f8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --panel-soft: #f8f7fc;
  --stroke: #e2e8f0;
  --stroke-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.10);
  --accent-line: rgba(139, 92, 246, 0.42);
  --red: #b91c1c;
  --therapy: #1f7a5a;
  --cancer: #0f172a;
  --radius: 16px;
  --shadow: 0 22px 60px rgba(20, 18, 26, 0.12);
  --shadow-lift: 0 12px 32px -18px rgba(123, 79, 196, 0.45);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif;
  --serif: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

::selection {
  color: var(--ink);
  background: rgba(139,92,246, 0.32);
}

/* quiet, thin scrollbars that match the dark chrome */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(15,23,42, 0.24) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(15,23,42, 0.22);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(15,23,42, 0.36);
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* keyboard skip-link: hidden until focused, then pinned above the header */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 8px 14px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  background: var(--panel-solid);
  box-shadow: var(--shadow-lift);
  transform: translateY(-64px);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

#researcherApp {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(90% 66% at 48% 112%, rgba(139, 92, 246, 0.07), transparent 58%),
    radial-gradient(54% 48% at 72% 30%, rgba(139, 92, 246, 0.035), transparent 70%),
    var(--bg);
}

#stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: grab;
  touch-action: none;
}

#stage.dragging {
  cursor: grabbing;
}

#graph {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 26px;
  right: 26px;
  left: 30px;
  z-index: 9;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, min(360px, 30vw)) minmax(0, 1fr);
  column-gap: 18px;
  align-items: start;
  pointer-events: none;
}

.masthead {
  width: min(430px, 100%);
  pointer-events: none;
}

.kicker,
.passport-mode,
.sheet-head p {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(21px, 1.9vw, 26px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.masthead h1 span {
  color: var(--accent);
}

.lede {
  max-width: 38ch;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 540;
  line-height: 1.55;
}

.scope {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  margin-top: 16px;
}

.scope .stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 1px 16px;
  border-left: 1px solid var(--stroke-strong);
}

.scope .stat:first-child {
  padding-left: 0;
  border-left: none;
}

.scope .stat strong {
  color: var(--ink);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.scope .stat em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.search-wrap {
  position: relative;
  width: 100%;
  pointer-events: auto;
}

.search-wrap label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 15px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  color: var(--ink);
  font-size: 13.5px;
  background: rgba(255,255,255,.88);
  box-shadow: inset 0 1px 0 rgba(255,255,255, 0.06), 0 8px 26px rgba(20,18,26, 0.10);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}

.search-wrap input::placeholder {
  color: #94a3b8;
}

.search-results {
  position: absolute;
  top: 49px;
  left: 0;
  width: 100%;
  max-height: 330px;
  overflow-y: auto;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius);
  background: rgba(255,255,255,.97);
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid rgba(15,23,42, 0.10);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  background: rgba(15,23,42, 0.08);
}

.search-result strong {
  font-size: 13px;
}

.search-result small {
  color: var(--muted);
  font-size: 10px;
}

.search-result span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  gap: 7px;
  justify-self: end;
  pointer-events: auto;
}

.quiet-button,
.solid-button,
.sheet-close,
.path-button,
.index-button,
.use-row,
.add-button,
.remove-button {
  border-radius: 11px;
  cursor: pointer;
  transition: transform 150ms ease, color 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.quiet-button,
.solid-button {
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--stroke);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.quiet-button {
  color: var(--ink-soft);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.solid-button {
  border-color: rgba(139,92,246, 0.48);
  color: #ffffff;
  background: #8b5cf6;
}

.quiet-button:hover,
.sheet-close:hover {
  border-color: var(--stroke-strong);
  color: var(--ink);
  background: rgba(241,245,249,.95);
}

.solid-button:hover {
  background: #7c3aed;
}

.quiet-button:active,
.solid-button:active,
.sheet-close:active,
.path-button:active,
.index-button:active,
.use-row:active,
.add-button:active,
.remove-button:active {
  transform: translateY(1px) scale(0.985);
}

.passport {
  position: absolute;
  /* clear the fixed site header + the top-action buttons (来源领域目录 / 核对清单), which the
     patient-shell header reshape pushed down onto the passport's old top (82px) → overlap. */
  top: calc(var(--header-h, 58px) + 68px);
  right: 26px;
  bottom: 98px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  width: min(390px, 32vw);
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  /* no backdrop blur here: scrolling long content inside a backdrop-filtered panel
     repaint-flickers over the animated canvas. Near-opaque bg keeps the glassy read. */
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255, 0.05);
}

/* overview is short onboarding, not a scroll column → hug content instead of stretching
   the full viewport height (drill states keep the fixed-height + internal scroll below). */
.passport.is-overview {
  bottom: auto;
  max-height: calc(100dvh - var(--header-h, 58px) - 68px - 26px);
}

.passport-head {
  display: grid;
  grid-template-columns: 1fr 132px;
  align-items: center;
  gap: 14px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--stroke);
}

.passport-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

#finder {
  width: 132px;
  height: 82px;
  border: 1px solid rgba(15,23,42, 0.13);
  border-radius: 10px;
  background: rgba(255,255,255,.75);
}

.passport-body {
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.overview-copy {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.68;
}

.overview-foot {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.principle {
  margin: 16px 0;
  padding: 13px 14px;
  border-left: 2px solid var(--accent);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.6;
  background: var(--accent-soft);
}

.micro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.micro-grid div {
  min-height: 78px;
  padding: 11px;
  border: 1px solid rgba(15,23,42, 0.12);
  border-radius: 12px;
  background: #ffffff;
}

.micro-grid strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
}

.micro-grid span {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.section-label {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
}

.story-summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 13px;
}

.story-glyph {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(139,92,246, 0.33);
  border-radius: 13px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-soft);
}

.story-summary h3 {
  margin: 1px 0 5px;
  font-size: 15px;
  line-height: 1.25;
}

.story-summary p,
.cancer-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.warning-note {
  margin: 12px 0 14px;
  padding: 10px 11px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 11px;
  color: var(--red);
  font-size: 10.5px;
  line-height: 1.55;
  background: rgba(220, 38, 38, 0.05);
}

.use-list {
  display: grid;
  /* minmax(0,1fr): the single column must stay inside the container — a plain implicit
     track sizes to the widest row's max-content and pushes rows past the passport edge */
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.use-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(15,23,42, 0.12);
  color: var(--ink);
  text-align: left;
  background: #ffffff;
}

.use-row:hover,
.use-row.on {
  border-color: rgba(139,92,246, 0.35);
  background: rgba(139,92,246, 0.08);
}

.use-row strong {
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.use-row .status {
  color: var(--ink-soft);
  font-size: 9.5px;
  white-space: nowrap;
}

.use-row small {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.path-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 5px;
  margin: 4px 0 15px;
  color: var(--muted);
  font-size: 9px;
}

.path-line strong {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9.5px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-line span {
  color: var(--accent);
}

.passport-section {
  padding: 13px 0 2px;
  border-top: 1px solid rgba(15,23,42, 0.12);
}

.passport-section h3 {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.passport a {
  color: #7c3aed;
  text-decoration-color: rgba(15,23,42, 0.42);
  text-underline-offset: 2px;
}

.passport a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink-soft);
}

.fact-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.fact-list div {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
}

.fact-list dt {
  color: var(--muted);
  font-size: 10px;
}

.fact-list dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.45;
}

.china-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.china-grid div {
  min-height: 64px;
  padding: 9px;
  border: 1px solid rgba(15,23,42, 0.11);
  border-radius: 10px;
  background: #ffffff;
}

.china-grid span {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
}

.china-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.35;
}

.china-grid strong.no {
  color: #b91c1c;
}

.china-grid strong.unknown {
  color: #64748b;
}

.source-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.next-question {
  margin: 0 0 11px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.add-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(139,92,246, 0.42);
  color: #ffffff;
  font-size: 11px;
  font-weight: 720;
  background: #8b5cf6;
}

.add-button[disabled] {
  border-color: var(--stroke);
  color: var(--muted);
  background: rgba(241,245,249,.9);
  cursor: default;
}

.story-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  z-index: 8;
  display: flex;
  gap: 6px;
  max-width: min(780px, 64vw);
  padding: 7px;
  overflow-x: auto;
  border: 1px solid var(--stroke);
  border-radius: 15px;
  transform: translateX(-50%);
  background: rgba(255,255,255,.95);
  box-shadow: inset 0 1px 0 rgba(255,255,255, 0.05), 0 12px 34px rgba(20,18,26, 0.16);
  scrollbar-width: none;
}

.story-dock::-webkit-scrollbar {
  display: none;
}

.path-button {
  min-width: 112px;
  padding: 9px 12px;
  border: 1px solid transparent;
  color: var(--muted);
  text-align: left;
  background: transparent;
}

.path-button:hover,
.path-button.on {
  border-color: rgba(139,92,246, 0.27);
  color: var(--ink);
  background: var(--accent-soft);
}

.path-button strong,
.path-button span {
  display: block;
}

.path-button strong {
  color: inherit;
  font-family: var(--mono);
  font-size: 12px;
}

.path-button span {
  margin-top: 3px;
  font-size: 10.5px;
  white-space: nowrap;
}

.map-key {
  position: absolute;
  bottom: 23px;
  left: 28px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 16px;
  max-width: 280px;
  padding: 11px 13px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  color: var(--muted);
  font-size: 11px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(20,18,26, 0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
}

.map-key div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-key p {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  color: var(--faint);
  line-height: 1.45;
}

.mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
}

.cancer-mark {
  border: 1px solid var(--cancer);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(15,23,42, 0.15);
  background: var(--cancer);
}

.use-mark {
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  background: transparent;
}

.therapy-mark {
  border: 1px solid var(--therapy);
  border-radius: 50%;
  background: var(--therapy);
}

.target-mark {
  border: 1px solid var(--accent);
  transform: rotate(45deg);
  background: var(--accent);
}

.corner-tools {
  position: absolute;
  right: 30px;
  bottom: 25px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.interaction-hint {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: 11px;
  color: var(--faint);
  font-size: 11px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.interaction-hint b {
  color: var(--muted);
  font-weight: 650;
}

/* day/night style theme switch: sun in dark mode, moon in light */
.theme-fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(20,18,26, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms var(--ease-out);
}

.theme-fab:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-lift);
}

.theme-fab:active {
  transform: scale(0.94);
}

.theme-fab svg {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: opacity 220ms ease, transform 340ms var(--ease-out);
}

.theme-fab .icon-sun {
  opacity: 0;
  transform: rotate(-100deg) scale(0.4);
}

.theme-fab .icon-moon {
  opacity: 1;
  transform: none;
}

[data-map-theme="dark"] .theme-fab {
  color: #fbbf24;
}

[data-map-theme="dark"] .theme-fab .icon-sun {
  opacity: 1;
  transform: none;
}

[data-map-theme="dark"] .theme-fab .icon-moon {
  opacity: 0;
  transform: rotate(100deg) scale(0.4);
}

.tooltip {
  position: fixed;
  z-index: 20;
  width: max-content;
  max-width: 270px;
  padding: 9px 11px;
  border: 1px solid var(--stroke-strong);
  border-radius: 11px;
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.45;
  background: rgba(255,255,255,.97);
  box-shadow: 0 16px 42px rgba(20,18,26, 0.46);
  pointer-events: none;
}

.tooltip strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 11.5px;
}

.tooltip span {
  color: var(--muted);
}

.toast {
  position: absolute;
  /* below the search row (which the header reshape pushed to ~112px); the old 78px landed on it */
  top: calc(var(--header-h, 58px) + 64px);
  left: 50%;
  z-index: 30;
  padding: 9px 13px;
  border: 1px solid rgba(139,92,246, 0.32);
  border-radius: 10px;
  color: var(--ink);
  font-size: 11px;
  background: rgba(255,255,255,.97);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  justify-items: end;
  visibility: hidden;
  opacity: 0;
  transition: opacity 180ms ease, visibility 180ms step-end;
}

.sheet.on {
  visibility: visible;
  opacity: 1;
  transition: opacity 180ms ease;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  cursor: default;
}

.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(620px, 86vw);
  height: 100dvh;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--stroke-strong);
  background: #ffffff;
  box-shadow: -24px 0 80px rgba(20,18,26, 0.5);
  transform: translateX(24px);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet.on .sheet-panel {
  transform: translateX(0);
}

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

.sheet-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sheet-close {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--stroke);
  color: var(--ink-soft);
  font-size: 11px;
  background: rgba(241,245,249,.85);
}

.sheet-intro {
  max-width: 58ch;
  margin: 18px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.overview-index-button {
  width: 100%;
  margin: 12px 0 2px;
  border-color: rgba(139,92,246, 0.5);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  background: #8b5cf6;
  box-shadow: 0 8px 22px -10px rgba(124,58,237, 0.55);
}

.overview-index-button:hover {
  border-color: rgba(124,58,237, 0.6);
  color: #ffffff;
  background: #7c3aed;
}

.cancer-index {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 12px;
}

.index-group h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.index-buttons {
  display: grid;
  gap: 3px;
}

.collection-card {
  margin: 2px 0 5px;
  padding: 10px;
  border: 1px solid rgba(139,92,246, 0.28);
  border-radius: 11px;
  background: rgba(139,92,246, 0.06);
}

.collection-card.on {
  border-color: rgba(139,92,246, 0.62);
  box-shadow: 0 0 0 2px rgba(139,92,246, 0.10);
}

.collection-card > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.collection-card strong {
  color: var(--ink);
  font-size: 11px;
}

.collection-card span,
.collection-card p {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.collection-card p {
  margin: 7px 0;
}

.collection-children {
  display: flex;
  gap: 6px;
}

.collection-children button {
  flex: 1;
  min-height: 30px;
  padding: 6px 8px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 9.5px;
  background: rgba(248,250,252,.9);
}

.collection-children button:hover {
  border-color: rgba(139,92,246, 0.4);
  color: var(--ink);
}

.index-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 10.5px;
  text-align: left;
  background: transparent;
}

.index-button:hover,
.index-button.on {
  border-color: var(--stroke);
  color: var(--ink);
  background: rgba(241,245,249,.85);
}

.index-button span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.empty-shortlist {
  min-height: 55vh;
  display: grid;
  align-content: center;
  justify-items: start;
}

.empty-shortlist h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.empty-shortlist p {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.shortlist-items {
  display: grid;
  gap: 11px;
  margin-top: 22px;
}

.shortlist-item {
  padding: 14px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: #ffffff;
}

.shortlist-item h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.shortlist-item .meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 10px;
}

.shortlist-item .question {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.6;
}

.remove-button {
  margin-top: 11px;
  padding: 7px 9px;
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 10px;
  background: transparent;
}

.remove-button:hover {
  color: var(--ink);
  background: rgba(241,245,249,.9);
}

@media (max-width: 1180px) {
  .masthead {
    width: 100%;
  }

  .lede,
  .scope {
    display: none;
  }

  .passport {
    width: 360px;
  }

  /* below this width the centered story-dock would cross the bottom-left legend — hide the
     legend here (same tier as lede/scope/hint already hidden), the dock keeps a scroll rail */
  .map-key,
  .interaction-hint {
    display: none;
  }
}

@media (max-width: 1100px) and (min-width: 901px) {
  #resetView {
    display: none;
  }
}

@media (max-width: 900px) {
  #researcherApp {
    min-height: auto;
    overflow: visible;
    background: var(--bg);
  }

  #stage {
    position: relative;
    height: 58dvh;
    min-height: 420px;
  }

  /* the topbar stacks here (search drops to a 2nd row ~193px), so keep the toast below it */
  .toast {
    top: calc(var(--header-h, 58px) + 150px);
  }

  .topbar {
    top: 18px;
    right: 18px;
    left: 18px;
    z-index: 46;
    grid-template-areas:
      "masthead actions"
      "search search";
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 12px 18px;
  }

  .masthead {
    grid-area: masthead;
    width: 100%;
  }

  .search-wrap {
    grid-area: search;
    width: min(360px, 100%);
    justify-self: start;
  }

  .top-actions {
    grid-area: actions;
  }

  #resetView,
  #openIndex {
    display: none;
  }

  .passport {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    z-index: 3;
    width: auto;
    max-height: none;
    margin: -1px 12px 96px;
    border-radius: var(--radius);
    background: var(--panel-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .story-dock {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 40;
    max-width: none;
    transform: none;
  }

  .map-key,
  .interaction-hint {
    display: none;
  }

  /* keep the theme fab reachable above the fixed dock (the hint pill is hidden here) */
  .corner-tools {
    position: fixed;
    right: 12px;
    bottom: 84px;
    z-index: 45;
  }
}

@media (max-width: 620px) {
  #stage {
    min-height: 390px;
    height: 54dvh;
  }

  .topbar {
    top: 15px;
    right: 14px;
    left: 14px;
    gap: 10px 12px;
  }

  .solid-button {
    height: 36px;
    padding: 0 10px;
  }

  .search-wrap {
    width: 100%;
  }

  .passport {
    margin: -1px 8px 92px;
  }

  .passport-head {
    grid-template-columns: 1fr 104px;
    padding: 13px;
  }

  #finder {
    width: 104px;
    height: 66px;
  }

  .passport-body {
    padding: 14px;
  }

  .story-dock {
    right: 8px;
    bottom: 8px;
    left: 8px;
  }

  .path-button {
    min-width: 94px;
  }

  .sheet-panel {
    width: 100vw;
    padding: 18px;
  }

  .cancer-index {
    grid-template-columns: 1fr;
  }

  .china-grid,
  .micro-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .search-wrap input,
  .top-actions button,
  .passport,
  .story-dock {
    background: var(--panel-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ============================================================
   Dark star map — researcher view only.
   The attribute lives on <html> (set by app.js + an inline boot script);
   patient-facing views (#home, #cancerMain, sheets) intentionally stay light.
   Variable swap themes every var-driven component inside #researcherApp
   (including the cancer.css passport components); explicit overrides below
   cover the hard-coded light colors.
   ============================================================ */
[data-map-theme="dark"] #researcherApp {
  /* note: --bg is deliberately NOT swapped — it backs #researcherApp's own light gradient
     (shell.css) and must stay light while patient layers cover the map (see below) */
  --panel: rgba(23, 20, 38, 0.82);
  --panel-solid: #17141f;
  --panel-soft: rgba(30, 27, 50, 0.62);
  --stroke: rgba(148, 163, 184, 0.18);
  --stroke-strong: rgba(167, 139, 250, 0.34);
  --ink: #eef2f9;
  --ink-soft: #b6c0d2;
  --muted: #8b93a8;
  --faint: #64748b;
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-line: rgba(167, 139, 250, 0.45);
  --red: #f87171;
  --therapy: #34d399;
  --cancer: #e6ebf5;
  color: var(--ink);   /* body's inherited color stays light-theme; restate it here */
}

/* the dark backdrop applies only while the researcher view is ACTIVE — when the map is
   covered by patient layers, a near-black underlay can flash through scroll/repaint gaps */
[data-map-theme="dark"] body[data-view="researcher"] #researcherApp {
  background:
    radial-gradient(90% 66% at 48% 112%, rgba(139, 92, 246, 0.20), transparent 60%),
    radial-gradient(54% 48% at 72% 30%, rgba(99, 102, 241, 0.10), transparent 70%),
    radial-gradient(120% 90% at 50% -10%, rgba(76, 29, 149, 0.22), transparent 62%),
    #0b0a14;
}

/* masthead + stats */
[data-map-theme="dark"] .masthead h1 span { color: #c4b5fd; }

/* search */
[data-map-theme="dark"] .search-wrap input {
  border-color: rgba(167, 139, 250, 0.30);
  color: #e2e8f0;
  background: rgba(17, 15, 28, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
[data-map-theme="dark"] .search-wrap input::placeholder { color: #64748b; }
[data-map-theme="dark"] .search-results {
  border-color: rgba(167, 139, 250, 0.28);
  background: rgba(17, 15, 28, 0.97);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}
[data-map-theme="dark"] .search-result { border-bottom-color: rgba(226, 232, 240, 0.08); }
[data-map-theme="dark"] .search-result:hover,
[data-map-theme="dark"] .search-result:focus-visible { background: rgba(167, 139, 250, 0.12); }

/* top actions */
[data-map-theme="dark"] .quiet-button {
  border-color: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
  background: rgba(17, 15, 28, 0.66);
}
[data-map-theme="dark"] .quiet-button:hover {
  border-color: rgba(167, 139, 250, 0.45);
  color: #f1f5f9;
  background: rgba(30, 27, 50, 0.85);
}
[data-map-theme="dark"] .solid-button {
  border-color: rgba(139, 92, 246, 0.65);
  background: #8b5cf6;
  box-shadow: 0 8px 24px -8px rgba(139, 92, 246, 0.5);
}
[data-map-theme="dark"] .solid-button:hover { background: #7c3aed; }

/* passport */
[data-map-theme="dark"] .passport {
  background: rgba(23, 20, 38, 0.94);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(167, 139, 250, 0.10);
}
[data-map-theme="dark"] #finder { background: rgba(11, 10, 20, 0.6); }
[data-map-theme="dark"] .principle { background: rgba(139, 92, 246, 0.16); }
[data-map-theme="dark"] .micro-grid div,
[data-map-theme="dark"] .china-grid div { background: rgba(30, 27, 50, 0.5); }
[data-map-theme="dark"] .china-grid strong.no { color: #f87171; }
[data-map-theme="dark"] .china-grid strong.unknown { color: #8b93a8; }
[data-map-theme="dark"] .warning-note {
  border-color: rgba(248, 113, 113, 0.30);
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.08);
}
[data-map-theme="dark"] .use-row { background: rgba(30, 27, 50, 0.5); }
[data-map-theme="dark"] .use-row:hover,
[data-map-theme="dark"] .use-row.on {
  border-color: rgba(167, 139, 250, 0.40);
  background: rgba(139, 92, 246, 0.14);
}
[data-map-theme="dark"] .passport a { color: #c4b5fd; }
[data-map-theme="dark"] .passport a:hover { color: #ede9fe; }
[data-map-theme="dark"] .add-button[disabled] {
  border-color: var(--stroke);
  color: var(--muted);
  background: rgba(30, 27, 50, 0.6);
}
[data-map-theme="dark"] .evidence-boundaries {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(23, 20, 38, 0.5);
}
[data-map-theme="dark"] .boundary-item {
  border-color: rgba(148, 163, 184, 0.14);
  background: rgba(30, 27, 50, 0.5);
}
[data-map-theme="dark"] .role-standard { color: #34d399; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); }
[data-map-theme="dark"] .role-agnostic { color: #7ea6d8; background: rgba(126, 166, 216, 0.12); border-color: rgba(126, 166, 216, 0.35); }
[data-map-theme="dark"] .role-investigational { color: #e8b06a; background: rgba(232, 176, 106, 0.12); border-color: rgba(232, 176, 106, 0.35); }
[data-map-theme="dark"] .role-theoretical { color: #a78bfa; background: rgba(167, 139, 250, 0.14); border-color: rgba(167, 139, 250, 0.38); }
[data-map-theme="dark"] .role-negative { color: #f87171; background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.32); }
[data-map-theme="dark"] .role-selected { color: #2dd4bf; background: rgba(45, 212, 191, 0.12); border-color: rgba(45, 212, 191, 0.35); }
[data-map-theme="dark"] .role-off_label { color: #f0ab6e; background: rgba(240, 171, 110, 0.12); border-color: rgba(240, 171, 110, 0.35); }
[data-map-theme="dark"] .role-dot.role-standard { color: #34d399; }
[data-map-theme="dark"] .role-dot.role-agnostic { color: #7ea6d8; }
[data-map-theme="dark"] .role-dot.role-investigational { color: #e8b06a; }
[data-map-theme="dark"] .role-dot.role-theoretical { color: #a78bfa; }
[data-map-theme="dark"] .role-dot.role-negative { color: #f87171; }
[data-map-theme="dark"] .role-dot.role-selected { color: #2dd4bf; }
[data-map-theme="dark"] .role-dot.role-off_label { color: #f0ab6e; }
[data-map-theme="dark"] .overview-index-button {
  border-color: rgba(139, 92, 246, 0.6);
  background: #8b5cf6;
  color: #ffffff;
}
[data-map-theme="dark"] .overview-index-button:hover { background: #7c3aed; }

/* legend + hint (var-driven now, glass tint only) */
[data-map-theme="dark"] .map-key,
[data-map-theme="dark"] .interaction-hint {
  background: rgba(23, 20, 38, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
[data-map-theme="dark"] .theme-fab {
  background: rgba(23, 20, 38, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
[data-map-theme="dark"] .cancer-mark { box-shadow: 0 0 0 2px rgba(230, 235, 245, 0.22); }

/* scrollbars readable on the dark chrome */
[data-map-theme="dark"] #researcherApp * {
  scrollbar-color: rgba(226, 232, 240, 0.32) transparent;
}
[data-map-theme="dark"] #researcherApp *::-webkit-scrollbar-thumb {
  background: rgba(226, 232, 240, 0.28);
}
[data-map-theme="dark"] #researcherApp *::-webkit-scrollbar-thumb:hover {
  background: rgba(226, 232, 240, 0.45);
}

/* dock */
[data-map-theme="dark"] .story-dock {
  background: rgba(23, 20, 38, 0.93);
  box-shadow: inset 0 1px 0 rgba(167, 139, 250, 0.08), 0 12px 34px rgba(0, 0, 0, 0.5);
}

/* body-level researcher chrome: tooltip / toast / loading / site header */
[data-map-theme="dark"] .tooltip {
  border-color: rgba(167, 139, 250, 0.30);
  color: #b6c0d2;
  background: rgba(17, 15, 28, 0.96);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.55);
}
[data-map-theme="dark"] .tooltip strong { color: #f1f5f9; }
[data-map-theme="dark"] .tooltip span { color: #8b93a8; }
[data-map-theme="dark"] .toast {
  border-color: rgba(167, 139, 250, 0.35);
  color: #e2e8f0;
  background: rgba(23, 20, 38, 0.96);
}
[data-map-theme="dark"] #mapLoading { background: #0b0a14; color: #94a3b8; }
[data-map-theme="dark"] body[data-view="researcher"] #siteHeader {
  background: rgba(11, 10, 20, 0.88);
  border-bottom-color: rgba(167, 139, 250, 0.16);
}
[data-map-theme="dark"] body[data-view="researcher"] .brand-title { color: #f1f5f9; }
[data-map-theme="dark"] body[data-view="researcher"] .brand-sub { color: #8b93a8; }
[data-map-theme="dark"] body[data-view="researcher"] .site-btn {
  border-color: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
  background: rgba(23, 20, 38, 0.7);
}
[data-map-theme="dark"] body[data-view="researcher"] .site-btn:hover {
  border-color: rgba(167, 139, 250, 0.45);
  color: #f1f5f9;
}

@media (max-width: 900px) {
  [data-map-theme="dark"] body[data-view="researcher"] #researcherApp { background: #0b0a14; }
  [data-map-theme="dark"] .passport { background: rgba(23, 20, 38, 0.94); }
}

/* theme crossfade: the whole researcher chrome dims, the palette swaps,
   then it fades back in (driven by setMapTheme in app.js). Dims to a
   partial opacity — a full fade-out would flash the page background. */
#researcherApp {
  transition: opacity .18s ease-in-out;
}
html.theme-switching #researcherApp,
html.theme-switching body[data-view="researcher"] #siteHeader {
  opacity: .28;
}
/* keep the page behind the researcher view on-theme (dip backdrop, overscroll) */
[data-map-theme="dark"] body[data-view="researcher"] {
  background: #0b0a14;
}
