:root {
  --ink: #e8eee7;
  --muted: #8b9b93;
  --dim: #53635b;
  --bg: #07110f;
  --panel: rgba(10, 24, 21, 0.88);
  --line: rgba(166, 193, 178, 0.16);
  --amber: #f1a84a;
  --mint: #a9c8b6;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: "Manrope", sans-serif; overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }

.shell { min-height: 100vh; background: radial-gradient(circle at 55% 44%, #14251f 0%, #091411 36%, #060e0d 74%); }
.topbar { height: 66px; display: grid; grid-template-columns: 340px 1fr 340px; align-items: center; border-bottom: 1px solid var(--line); position: relative; z-index: 10; }
.brand { height: 100%; display: flex; align-items: center; gap: 13px; padding: 0 28px; color: var(--ink); text-decoration: none; border-right: 1px solid var(--line); font-size: 13px; font-weight: 700; letter-spacing: .16em; }
.brand > span:last-child { display: grid; gap: 3px; }
.brand small { color: var(--muted); font: 500 8px "DM Mono", monospace; letter-spacing: .12em; }
.brand-mark { width: 24px; height: 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; transform: rotate(-18deg); }
.brand-mark i { display: block; border: 1px solid var(--amber); border-radius: 50%; }
.brand-mark i:nth-child(2) { transform: translateY(-3px); }
.dataset-status { justify-self: center; display: flex; align-items: center; gap: 10px; color: var(--mint); font: 500 10px "DM Mono", monospace; letter-spacing: .14em; }
.dataset-id { color: var(--dim); margin-left: 10px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: #8bd4a7; box-shadow: 0 0 0 5px rgba(139, 212, 167, .08); }
.info-button { justify-self: end; height: 100%; width: 170px; border: 0; border-left: 1px solid var(--line); background: transparent; font: 500 10px "DM Mono", monospace; letter-spacing: .14em; cursor: pointer; transition: background .2s; }
.info-button:hover { background: rgba(255,255,255,.04); }

.workspace { height: calc(100vh - 66px); display: grid; grid-template-columns: 340px minmax(420px, 1fr); }
.workspace.focus-layout { grid-template-columns: 340px minmax(420px, 1fr) 340px; }
.control-panel { padding: 34px 28px 26px; position: relative; z-index: 3; background: linear-gradient(180deg, rgba(8,19,17,.88), rgba(6,15,13,.94)); }
.control-panel { border-right: 1px solid var(--line); overflow-y: auto; }
.detail-panel { min-width: 0; padding: 28px 22px 24px; border-left: 1px solid var(--line); background: linear-gradient(180deg, rgba(8,19,17,.91), rgba(6,15,13,.96)); overflow: hidden; }
.region-panel { display: flex; flex-direction: column; }
.region-panel[hidden] { display: none; }
.region-panel-header { flex: 0 0 auto; padding: 2px 4px 18px; border-bottom: 1px solid var(--line); }
.region-panel-header > span { color: var(--amber); font: 500 8px "DM Mono", monospace; letter-spacing: .16em; }
.region-panel-header h2 { margin: 9px 0 8px; color: var(--ink); font: 400 27px/1.05 Georgia, serif; }
.region-panel-header p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.region-panel > .region-tree { flex: 1 1 auto; max-height: none; margin: 15px -4px 0; min-height: 0; }

.eyebrow { color: var(--amber); font: 500 9px "DM Mono", monospace; letter-spacing: .18em; }
h1 { margin: 15px 0 14px; font-size: clamp(39px, 4vw, 58px); line-height: .9; letter-spacing: -.055em; font-weight: 500; }
h1 em { color: var(--amber); font-family: Georgia, serif; font-weight: 400; }
.intro { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0 0 28px; max-width: 260px; }
.control-group { border-top: 1px solid var(--line); padding-top: 14px; }
.control-group.compact { margin-top: 26px; }
.group-title { display: flex; justify-content: space-between; color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .14em; margin-bottom: 15px; }
.group-title span:last-child { color: var(--amber); }
label { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin: 0 0 14px; color: var(--muted); font-size: 11px; }
output { font: 500 10px "DM Mono", monospace; color: var(--ink); }
input[type="range"] { grid-column: 1 / -1; width: 100%; height: 2px; appearance: none; background: linear-gradient(90deg, var(--amber), var(--amber)) 0/var(--fill, 50%) 100% no-repeat, rgba(255,255,255,.12); outline: none; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 10px; height: 10px; border: 2px solid var(--bg); border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 1px var(--amber); cursor: ew-resize; }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 2px solid var(--bg); border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 1px var(--amber); cursor: ew-resize; }
.preset-row { display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--line); }
.preset { padding: 10px 4px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .08em; cursor: pointer; }
.preset:last-child { border-right: 0; }
.preset.active { background: rgba(241,168,74,.12); color: var(--amber); }
.render-mode { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0 0 12px; border: 1px solid var(--line); }
.render-mode button { padding: 9px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .12em; cursor: pointer; }
.render-mode button:last-child { border-right: 0; }
.render-mode button.active { background: rgba(241,168,74,.12); color: var(--amber); }
.lobe-toggle { position: relative; display: grid; grid-template-columns: 1fr 28px auto; gap: 8px; margin: 0 0 18px; padding: 10px 11px; border: 1px solid var(--line); color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .1em; cursor: pointer; }
.lobe-toggle[hidden] { display: none; }
.lobe-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.lobe-toggle i { position: relative; width: 28px; height: 14px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; background: rgba(255,255,255,.05); }
.lobe-toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); transition: transform .18s, background .18s; }
.lobe-toggle input:checked + i { border-color: rgba(241,168,74,.52); background: rgba(241,168,74,.12); }
.lobe-toggle input:checked + i::after { transform: translateX(14px); background: var(--amber); }
.lobe-toggle output { color: var(--amber); font-size: 8px; }
.lobe-toggle:focus-within { border-color: rgba(241,168,74,.55); }
.cut-plane-toggle { margin-bottom: 17px; }
.plane-options {
  max-height: 260px;
  opacity: 1;
  overflow: hidden;
  transform: translateY(0) scaleY(1);
  transform-origin: top;
  visibility: visible;
  transition: max-height .34s cubic-bezier(.22,.8,.28,1), opacity .2s ease .07s, transform .32s cubic-bezier(.22,.8,.28,1);
}
.plane-options.is-disabled {
  max-height: 0;
  opacity: 0;
  transform: translateY(-9px) scaleY(.97);
  visibility: hidden;
  pointer-events: none;
  transition: max-height .3s cubic-bezier(.55,0,.78,.2), opacity .14s ease, transform .25s ease, visibility 0s linear .3s;
}
.plane-options input:disabled, .plane-options button:disabled { cursor: not-allowed; }
.focus-controls { margin: -4px 0 18px; padding: 12px; border: 1px solid rgba(241,168,74,.2); background: rgba(241,168,74,.045); }
.focus-controls[hidden], .focus-badge[hidden] { display: none; }
.focus-label { display: block; margin: 0 0 7px; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.region-tree { max-height: 252px; overflow: auto; margin: 0 -4px; padding: 2px 4px 4px; scrollbar-width: thin; scrollbar-color: rgba(241,168,74,.32) transparent; }
.region-tree-section + .region-tree-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.region-tree-heading { padding: 4px 7px 5px; color: var(--dim); font: 500 7px "DM Mono", monospace; letter-spacing: .14em; text-transform: uppercase; }
.region-node { position: relative; width: 100%; min-height: 27px; display: flex; align-items: center; gap: 7px; padding: 5px 7px 5px calc(7px + var(--depth, 0) * 13px); border: 0; background: transparent; color: var(--muted); text-align: left; font: 500 9px/1.25 "DM Mono", monospace; cursor: pointer; }
.region-node::before { content: ""; width: 5px; height: 5px; flex: 0 0 auto; border: 1px solid currentColor; border-radius: 50%; opacity: .55; }
.region-node[data-parent="true"] { color: var(--ink); font-weight: 600; }
.region-node[data-parent="true"]::before { border-radius: 1px; transform: rotate(45deg); }
.region-node:hover { color: var(--ink); background: rgba(255,255,255,.035); }
.region-node.preview { color: #ffc173; background: rgba(241,168,74,.055); }
.region-node.active { color: var(--amber); background: rgba(241,168,74,.10); }
.region-node.active::before { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 8px rgba(241,168,74,.65); }
.region-node:focus-visible { outline: 1px solid rgba(241,168,74,.7); outline-offset: -1px; }
.focus-opacity { margin: 0 1px; }
.focus-opacity span { color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .06em; text-transform: uppercase; }
.viewer { position: relative; min-width: 0; overflow: hidden; background: radial-gradient(circle at 50% 48%, rgba(78,113,94,.16), transparent 47%); }
#brainCanvas { display: block; width: 100%; height: 100%; cursor: grab; }
#brainCanvas.focus-picking { cursor: crosshair; }
#brainCanvas:active { cursor: grabbing; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 9px; background: #07110f; z-index: 5; transition: opacity .6s, visibility .6s; }
.loading.hidden { opacity: 0; visibility: hidden; }
.loading strong { font: 500 10px "DM Mono", monospace; letter-spacing: .16em; }
.loading small { color: var(--dim); font: 9px "DM Mono", monospace; }
.loading-ring { width: 54px; height: 54px; border: 1px solid rgba(255,255,255,.08); border-top-color: var(--amber); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.view-label { position: absolute; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .18em; pointer-events: none; }
.view-label-top { top: 22px; left: 50%; transform: translateX(-50%); }
.view-label-left { top: 50%; left: 19px; }
.view-label-right { top: 50%; right: 19px; }
.viewer::before, .viewer::after { content: ""; position: absolute; pointer-events: none; border-color: rgba(151,181,165,.2); }
.viewer::before { inset: 40px; border: 1px solid transparent; border-top-color: rgba(151,181,165,.13); border-bottom-color: rgba(151,181,165,.13); }
.viewer::after { top: 40px; bottom: 40px; left: 50%; border-left: 1px dashed rgba(151,181,165,.1); }
.viewer-help { position: absolute; left: 24px; bottom: 25px; display: flex; gap: 22px; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .08em; }
.viewer-help span { display: flex; gap: 7px; align-items: center; }
.sources-button { position: absolute; right: 24px; bottom: 22px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); background: rgba(6,15,13,.76); backdrop-filter: blur(10px); color: var(--muted); font: 500 8px "DM Mono", monospace; letter-spacing: .12em; cursor: pointer; transition: color .18s, border-color .18s, background .18s; }
.sources-button span { color: var(--amber); font-size: 11px; }
.sources-button:hover, .sources-button:focus-visible { color: var(--ink); border-color: rgba(241,168,74,.5); background: rgba(241,168,74,.08); outline: none; }
.lobe-legend { position: absolute; top: 24px; right: 24px; width: 220px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 14px 16px; border: 1px solid var(--line); background: rgba(6, 15, 13, .78); backdrop-filter: blur(10px); color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .04em; transition: opacity .2s, visibility .2s; }
.lobe-legend.hidden { opacity: 0; visibility: hidden; }
.lobe-legend strong { grid-column: 1 / -1; margin-bottom: 3px; color: var(--ink); font-size: 8px; letter-spacing: .13em; }
.lobe-legend span { display: flex; align-items: center; gap: 7px; }
.lobe-legend span::before { content: ""; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--region); box-shadow: 0 0 9px color-mix(in srgb, var(--region) 65%, transparent); }
.region-leader { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.region-leader.hidden { display: none; }
.region-leader path { fill: none; stroke: rgba(241,168,74,.74); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.region-leader circle { vector-effect: non-scaling-stroke; }
#regionLeaderHalo { fill: rgba(241,168,74,.08); stroke: rgba(241,168,74,.32); stroke-width: 1; }
#regionLeaderPoint { fill: var(--amber); stroke: #fff1d9; stroke-width: 1; filter: drop-shadow(0 0 5px rgba(241,168,74,.9)); }
.focus-badge { position: absolute; top: 24px; right: 24px; z-index: 3; width: 268px; padding: 14px 16px 15px; border: 1px solid rgba(241,168,74,.35); background: rgba(6,15,13,.88); backdrop-filter: blur(10px); }
.focus-badge::before { content: ""; display: block; width: 24px; height: 3px; margin-bottom: 11px; background: var(--amber); box-shadow: 0 0 14px rgba(241,168,74,.55); }
.focus-badge span, .focus-badge small { display: block; color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .13em; }
.focus-badge strong { display: block; margin: 6px 0 8px; color: var(--ink); font: 500 15px/1.25 "Manrope", sans-serif; }
.focus-badge small { color: var(--amber); }
.focus-badge p { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.55; }
.mouse-icon { width: 10px; height: 14px; border: 1px solid var(--dim); border-radius: 5px; }
.pick-icon { width: 11px; height: 11px; border: 1px solid var(--amber); border-radius: 50%; box-shadow: inset 0 0 0 3px var(--bg); background: var(--amber); }
.wheel-icon { width: 12px; height: 12px; border: 1px solid var(--dim); border-radius: 50%; position: relative; }
.wheel-icon::after { content: ""; position: absolute; inset: 4px 2px; border-top: 1px solid var(--dim); }
.slice-readout { position: absolute; right: 24px; bottom: 22px; text-align: right; font: 500 8px "DM Mono", monospace; letter-spacing: .08em; color: var(--dim); }
.slice-index { display: block; margin-bottom: 5px; color: var(--muted); }
.slice-index b { color: var(--amber); font-weight: 500; }

.detail-number { height: 104px; display: flex; align-items: center; border-bottom: 1px solid var(--line); color: rgba(232,238,231,.1); font: 400 54px Georgia, serif; }
.detail-content { padding-top: 28px; }
.detail-content h2 { font: 400 32px/1.05 Georgia, serif; margin: 12px 0 6px; }
.detail-content > p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.plane-diagram { height: 150px; position: relative; margin: 10px 0 5px; perspective: 300px; }
.orbit { position: absolute; width: 112px; height: 112px; left: 50%; top: 50%; margin: -56px; border: 1px solid rgba(169,200,182,.25); border-radius: 50%; }
.orbit-a { transform: rotateX(62deg); }
.orbit-b { transform: rotateY(64deg); }
.axis-line { position: absolute; height: 128px; left: 50%; top: 11px; border-left: 1px dashed rgba(169,200,182,.22); transform: rotate(19deg); }
.diagram-plane { position: absolute; width: 128px; height: 66px; top: 43px; left: calc(50% - 64px); background: rgba(241,168,74,.09); border: 1px solid rgba(241,168,74,.58); transform: rotateX(64deg) rotateZ(-17deg); box-shadow: 0 0 28px rgba(241,168,74,.08); }
.plane-diagram span { position: absolute; width: 8px; height: 8px; background: var(--amber); border-radius: 50%; left: calc(50% - 4px); top: calc(50% - 4px); box-shadow: 0 0 15px var(--amber); }
.future-card { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 16px 0; margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.future-icon { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--amber); }
.future-card span { display: block; color: var(--amber); font: 500 8px "DM Mono", monospace; letter-spacing: .13em; margin-bottom: 5px; }
.future-card strong { font-size: 12px; font-weight: 600; }
.future-card p { color: var(--dim); font-size: 9px; line-height: 1.5; margin: 4px 0 0; }
.scale-marker { margin-top: auto; display: flex; align-items: center; gap: 8px; color: var(--dim); font: 8px "DM Mono", monospace; }
.scale-marker i { height: 6px; border-left: 1px solid var(--dim); }
.scale-marker i:first-child { width: 70px; border-bottom: 1px solid var(--dim); }

dialog { width: min(520px, calc(100vw - 32px)); color: var(--ink); background: #0c1a17; border: 1px solid rgba(241,168,74,.35); padding: 38px; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(2,8,7,.76); backdrop-filter: blur(8px); }
dialog h2 { margin: 12px 0 20px; font: 400 36px/1.05 Georgia, serif; }
dialog p { color: var(--muted); font-size: 12px; line-height: 1.8; }
dialog a { display: inline-block; margin-top: 10px; color: var(--amber); font: 500 9px "DM Mono", monospace; letter-spacing: .12em; text-decoration: none; }
.dialog-close { position: absolute; top: 13px; right: 15px; border: 0; background: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.data-sources-dialog { position: relative; padding: 34px 36px 30px; }
.data-sources-dialog h2 { margin-bottom: 10px; }
.data-sources-dialog > p { margin: 0; }
.source-links { display: grid; margin-top: 22px; border-top: 1px solid var(--line); }
.source-links a { display: grid; gap: 5px; margin: 0; padding: 15px 4px; border-bottom: 1px solid var(--line); color: inherit; transition: background .18s, padding-left .18s; }
.source-links a:hover, .source-links a:focus-visible { padding-left: 10px; background: rgba(241,168,74,.055); outline: none; }
.source-links span, .source-links small { color: var(--dim); font: 500 8px "DM Mono", monospace; letter-spacing: .11em; }
.source-links strong { color: var(--ink); font-size: 12px; font-weight: 600; letter-spacing: 0; }
.source-links a:hover strong { color: var(--amber); }
.source-links small { letter-spacing: .03em; line-height: 1.4; }
.data-sources-dialog .source-note { margin-top: 18px; color: var(--dim); font-size: 9px; }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 290px 1fr 160px; }
  .workspace, .workspace.focus-layout { grid-template-columns: 290px minmax(0, 1fr); }
  .detail-panel { position: fixed; z-index: 8; top: 66px; right: 0; bottom: 0; width: 290px; box-shadow: -18px 0 42px rgba(0,0,0,.28); }
  .brand { padding-left: 22px; }
}
@media (max-width: 720px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: 1fr auto; height: 58px; }
  .brand { border-right: 0; }
  .dataset-status { display: none; }
  .info-button { width: 116px; }
  .workspace, .workspace.focus-layout { height: auto; min-height: calc(100vh - 58px); display: flex; flex-direction: column; }
  .viewer { height: 58vh; min-height: 400px; }
  .control-panel { border-right: 0; border-top: 1px solid var(--line); }
  .detail-panel { position: static; width: 100%; height: min(64vh, 560px); order: 3; border-left: 0; border-top: 1px solid var(--line); box-shadow: none; }
  h1 { font-size: 46px; }
  .intro { max-width: 100%; }
  .viewer-help { display: none; }
  .sources-button { right: 14px; bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
