/* NeuroExplorer — UI theme.
   Dark "wet lab at night" palette; glass panels float over the 3D stage. */

:root {
  --bg-0: #0a0e1a;
  --bg-1: #0e1424;
  --panel: rgba(18, 24, 42, 0.82);
  --panel-edge: rgba(120, 160, 230, 0.16);
  --ink: #e8edf7;
  --ink-dim: #9aa6c2;
  --ink-faint: #6b7798;
  --accent: #36d4ff;       /* electric cyan */
  --accent-2: #ff5db1;     /* synapse magenta */
  --good: #5ff0a8;
  --warn: #ffcf5b;
  --bad: #ff6b6b;

  /* lobe palette (kept in sync with cortex.js) */
  --frontal:   #4f8cff;
  --parietal:  #46d39a;
  --temporal:  #ffa14a;
  --occipital: #b36bff;
  --cerebellum:#2fd6c6;
  --brainstem: #c8b08a;

  --shadow: 0 10px 40px rgba(0,0,0,0.5);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 50% 38%, #131b30 0%, var(--bg-0) 70%);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; outline: none; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 58px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(8,11,20,0.85), rgba(8,11,20,0));
  z-index: 20; pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 22px; filter: drop-shadow(0 0 8px rgba(255,93,177,.5)); }
.brand-name { font-size: 18px; letter-spacing: .3px; color: var(--ink); }
.brand-name strong { color: var(--accent); font-weight: 800; }

.modes { display: flex; gap: 4px; margin: 0 auto; padding: 4px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 12px; backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.mode-tab {
  appearance: none; border: 0; background: transparent; color: var(--ink-dim);
  font: 600 13.5px/1 "Inter", system-ui; letter-spacing: .2px;
  padding: 9px 16px; border-radius: 9px; cursor: pointer; transition: .16s;
}
.mode-tab:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.mode-tab.is-active { color: #04121a; background: linear-gradient(180deg, #5fe0ff, var(--accent));
  box-shadow: 0 4px 16px rgba(54,212,255,.35); }

.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--ink-dim);
  font-size: 16px; font-weight: 700; backdrop-filter: blur(10px); transition: .16s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- docks ---------- */
.dock {
  position: absolute; z-index: 15;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: var(--radius); backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.dock-left  { top: 74px; left: 16px; width: 270px; max-height: calc(100% - 230px); overflow-y: auto; }
.dock-right { top: 74px; right: 16px; width: 330px; max-height: calc(100% - 230px); overflow-y: auto; padding: 16px; }

.dock-left  { padding: 14px; }
.dock::-webkit-scrollbar { width: 9px; }
.dock::-webkit-scrollbar-thumb { background: rgba(120,150,220,.25); border-radius: 9px; }

.panel-close {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
  border-radius: 8px; border: 1px solid var(--panel-edge); background: rgba(255,255,255,.04);
  color: var(--ink-dim); font-size: 18px; cursor: pointer; line-height: 1; z-index: 2;
}
.panel-close:hover { color: var(--ink); border-color: var(--accent-2); }

/* dock section headers */
.dock h2 { margin: 2px 0 10px; font-size: 12px; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent); font-weight: 700; }
.dock .hint { font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; margin: 0 0 12px; }

/* list items (diseases, senses, legend) */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 11px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; background: rgba(255,255,255,.03);
  color: var(--ink); font: 500 13.5px/1.25 "Inter", system-ui; transition: .14s; width: 100%;
}
.list-item:hover { background: rgba(255,255,255,.07); border-color: var(--panel-edge); }
.list-item.is-active { border-color: var(--accent); background: rgba(54,212,255,.12); }
.list-item .dot { width: 11px; height: 11px; border-radius: 50%; flex: none;
  box-shadow: 0 0 8px currentColor; }
.list-item .li-sub { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.list-item .li-main { display: block; }

/* region search (issue #17) */
.search-wrap { position: relative; margin: 0 0 11px; }
.search-wrap .search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .55; pointer-events: none; }
#region-search {
  width: 100%; box-sizing: border-box; padding: 9px 11px 9px 30px;
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-edge);
  border-radius: 10px; color: var(--ink); font: 500 13px "Inter", system-ui; outline: none; transition: .14s;
}
#region-search::placeholder { color: var(--ink-faint); }
#region-search:focus { border-color: var(--accent); background: rgba(54,212,255,.08); box-shadow: 0 0 0 3px rgba(54,212,255,.12); }
.list-item .dot.dot-ctx  { color: #7fb0ff; }
.list-item .dot.dot-deep { color: #c792ea; }
.list-item .dot.dot-lobe { color: var(--accent); }

/* cross-section toolbar (issue #18) */
.slicebar {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 12px;
  padding: 7px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.slicebar[hidden] { display: none; }   /* class display:flex would otherwise override the hidden attribute */
.slicebar .slice-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.slicebar #slice-pos { width: 150px; --fill: 50%; }

/* guided tour + quiz (issue #19) */
.tour-row { display: flex; gap: 8px; margin: 0 0 12px; }
.tour-btn {
  flex: 1; padding: 9px 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--panel-edge); background: rgba(255,255,255,.04);
  color: var(--ink); font: 600 12.5px "Inter", system-ui; transition: .14s;
}
.tour-btn:hover { border-color: var(--accent); background: rgba(54,212,255,.10); color: #fff; }
.tourcard {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 7; width: min(560px, 70vw);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 14px;
  padding: 15px 18px; backdrop-filter: blur(12px); box-shadow: 0 16px 44px rgba(0,0,0,.45);
  color: var(--ink);
}
.tourcard .tc-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); font-weight: 700; }
.tourcard .tc-title { font-size: 17px; font-weight: 700; margin: 4px 0 6px; }
.tourcard .tc-body { font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.tourcard .tc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
.tourcard .tc-actions { display: flex; gap: 8px; }
.tourcard .tc-progress { font-size: 12px; color: var(--ink-faint); }
.tourcard button {
  font: 600 13px "Inter", system-ui; padding: 7px 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--panel-edge); background: rgba(255,255,255,.05); color: var(--ink); transition: .14s;
}
.tourcard button:hover:not(:disabled) { border-color: var(--accent); }
.tourcard button:disabled { opacity: .4; cursor: default; }
.tourcard button.primary { background: linear-gradient(180deg, #5fe0ff, var(--accent)); color: #04121a; border-color: transparent; font-weight: 700; }
.tourcard .tc-correct { color: #46e0a0; font-weight: 700; }
.tourcard .tc-wrong { color: #ff6b6b; font-weight: 700; }

/* ---------- detail panel ---------- */
.detail-eyebrow { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--accent-2); font-weight: 700; }
.detail-title { font-size: 20px; font-weight: 800; margin: 4px 0 2px; line-height: 1.15; }
.detail-sub { font-size: 12.5px; color: var(--ink-dim); margin: 0 0 12px; }
.detail-body { font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.detail-body p { margin: 0 0 10px; }
.detail-section { margin-top: 14px; }
.detail-section h3 { font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 7px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--panel-edge); color: var(--ink-dim); }
.chip.warn { color: var(--warn); border-color: rgba(255,207,91,.35); }
.factline { display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,.08); font-size: 12.5px; }
.factline span:first-child { color: var(--ink-faint); }
.factline span:last-child { color: var(--ink); font-weight: 600; text-align: right; }
.cite { font-size: 11px; color: var(--ink-faint); line-height: 1.5; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- bottom dock ---------- */
#bottomdock {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 18; display: flex; align-items: stretch; gap: 18px;
  padding: 13px 18px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}
.ctrl { display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.ctrl-label { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.ctrl-head { display: flex; align-items: baseline; justify-content: space-between; }
.ctrl-head label { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
#age-readout { font-size: 13px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.ctrl-age { width: 320px; }
.age-ticks { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--ink-faint); margin-top: -2px; }

/* range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill,28%), rgba(255,255,255,.12) var(--fill,28%));
  outline: none; cursor: pointer; width: 100%;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #eaf7ff; border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: grab;
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }

/* segmented control */
.segmented { display: flex; background: rgba(255,255,255,.05); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  appearance: none; border: 0; background: transparent; color: var(--ink-dim);
  font: 600 12.5px/1 "Inter", system-ui; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: .14s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { color: #04121a; background: linear-gradient(180deg,#ff8ac9,var(--accent-2)); }

.view-toggles { display: flex; gap: 6px; }
.toggle {
  appearance: none; border: 1px solid var(--panel-edge); background: rgba(255,255,255,.04);
  color: var(--ink-dim); font: 600 12px/1 "Inter", system-ui; padding: 8px 11px;
  border-radius: 9px; cursor: pointer; transition: .14s;
}
.toggle:hover { color: var(--ink); border-color: var(--accent); }
.toggle.is-on { color: #04121a; background: var(--accent); border-color: var(--accent); }

/* dividers between bottom-dock groups */
.ctrl + .ctrl { border-left: 1px solid rgba(255,255,255,.08); padding-left: 18px; }

/* ---------- tooltip ---------- */
.tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  background: rgba(8,12,22,.92); border: 1px solid var(--panel-edge);
  color: var(--ink); font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow);
  transform: translate(-50%, -140%); white-space: nowrap;
}
.tooltip .tip-sub { display: block; font-weight: 400; font-size: 11px; color: var(--ink-dim); }

/* ---------- loading ---------- */
.loading {
  position: absolute; inset: 0; z-index: 40; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg-0); transition: opacity .6s ease;
}
.loading.is-hidden { opacity: 0; pointer-events: none; }
.loading-brain { font-size: 60px; animation: pulse 1.4s ease-in-out infinite; filter: drop-shadow(0 0 22px rgba(255,93,177,.6)); }
.loading-text { color: var(--ink-dim); font-size: 14px; letter-spacing: .4px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .8 } 50% { transform: scale(1.12); opacity: 1 } }

/* ---------- evidence chip ---------- */
.evidence-chip {
  position: absolute; bottom: 16px; right: 16px; z-index: 16;
  font-size: 11px; color: var(--ink-faint); background: var(--panel);
  border: 1px solid var(--panel-edge); padding: 7px 11px; border-radius: 9px;
  backdrop-filter: blur(8px); cursor: default;
}

/* model picker "coming soon" + busy toast */
.is-soon { opacity: .5; }
.busy {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 35;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--accent); color: var(--ink);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow); backdrop-filter: blur(10px);
}

/* small helper */
.kbd { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.08);
  border: 1px solid var(--panel-edge); color: var(--ink-dim); }

/* floating structure labels + leader lines */
#labelLayer { position: absolute; inset: 0; z-index: 14; pointer-events: none; }
#labelLayer svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.neuro-label {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font: 600 12px/1 "Inter", system-ui; color: var(--ink);
  background: rgba(8, 12, 22, 0.85); border: 1px solid var(--panel-edge);
  padding: 4px 9px; border-radius: 7px; box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  #bottomdock { flex-wrap: wrap; gap: 12px; }
  .ctrl + .ctrl { border-left: 0; padding-left: 0; }
  .dock-left, .dock-right { width: 230px; }
}
