/* ── 3D Connectome modal ───────────────────────────────────────────────
   Sits at 10770: above the patients overlays (10600) and the metrics /
   inference cluster (10750-10760) it can be opened over, below AppDialog
   (10800) so confirmations and alerts still stack on top of it. */
#connectome-modal { z-index: 10770; }

/* Opaque card on the standard .modal-overlay scrim. A translucent one let the
   dashboard bleed through the control rails, which are the busiest part of the
   dialog and the hardest place to read text over a moving background. */
.cx-card {
  width: 96vw; height: 92vh; max-width: 1800px;
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "header header header" "left viewport right" "footer footer footer";
  position: relative;
  background: #0b1119;
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  border-radius: 14px;
  overflow: hidden;
  color: var(--text-primary);
}
[data-theme="light"] .cx-card { background: #f6f7fb; }

.cx-header {
  grid-area: header; display: flex; align-items: center; gap: 16px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.cx-title { font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
.cx-modes, .cx-actions, .cx-seg { display: flex; gap: 6px; }
.cx-actions { margin-left: auto; align-items: center; }

.cx-btn {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 7px; padding: 5px 11px;
  font-size: 0.76rem; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.cx-btn:hover { background: rgba(99, 102, 241, 0.28); color: #fff; border-color: var(--accent-indigo); }
.cx-btn.on { background: var(--accent-indigo); border-color: var(--accent-indigo); color: #fff; }
[data-theme="light"] .cx-btn { background: rgba(0, 0, 0, 0.04); color: #333; }

.cx-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.cx-close:hover { color: var(--text-primary); }

.cx-rail {
  padding: 12px 14px; overflow-y: auto; font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.16);
}
[data-theme="light"] .cx-rail { background: rgba(0, 0, 0, 0.03); }
.cx-rail-left { grid-area: left; border-right: 1px solid var(--border); }
.cx-rail-right { grid-area: right; border-left: 1px solid var(--border); }
.cx-rail h4 {
  margin: 14px 0 6px; font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600;
}
.cx-rail h4:first-child { margin-top: 0; }
.cx-rail select, .cx-rail input[type="range"] { width: 100%; }
.cx-rail select {
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 5px; padding: 5px 7px; font-size: 0.76rem;
}
.cx-row {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--text-muted); margin: 7px 0 3px; font-size: 0.72rem;
}
.cx-chk { display: flex; align-items: center; gap: 7px; margin: 5px 0; cursor: pointer; }
.cx-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.cx-seg { display: flex; flex-wrap: wrap; gap: 4px; }
/* Band tabs with nothing to act on: greyed, not hidden, so the reason next to them is read. */
.cx-seg.inert .cx-btn { opacity: 0.45; cursor: not-allowed; }
.cx-seg.inert .cx-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); border-color: var(--border); }
#cx-band-note { flex-basis: 100%; }

.cx-viewport { grid-area: viewport; position: relative; overflow: hidden; }
.cx-viewport canvas { display: block; width: 100%; height: 100%; }
.cx-message { padding: 40px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.cx-message code {
  display: inline-block; margin-top: 8px; padding: 5px 9px; border-radius: 5px;
  background: rgba(0, 0, 0, 0.3); font-size: 0.74rem;
}

.cx-tip {
  position: fixed; z-index: 10790; pointer-events: none;
  background: rgba(10, 16, 24, 0.94); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 9px; font-size: 0.74rem; white-space: nowrap;
}

/* The source badge is permanent by design: it names what is on screen, and the
   same text is written into every export. */
.cx-badge {
  position: absolute; left: 14px; top: 12px; max-width: 46ch; z-index: 5;
  padding: 5px 10px; border-radius: 6px; font-size: 0.7rem; line-height: 1.35;
  pointer-events: none;
}
.cx-badge.theory { background: rgba(232, 176, 75, 0.16); color: #e8b04b; border: 1px solid rgba(232, 176, 75, 0.4); }
.cx-badge.measured { background: rgba(63, 211, 155, 0.14); color: #3fd39b; border: 1px solid rgba(63, 211, 155, 0.4); }

/* Floating view controls on the canvas, top-right: reset plus a five-way pad
   (front / left / top / right / back), the same arrangement as the sLORETA 3D
   viewer so the two feel alike, without sharing its classes. */
.cx-viewtools {
  position: absolute; top: 12px; right: 14px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.cx-viewtool-btn {
  background: rgba(30, 30, 50, 0.75); border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8); border-radius: 8px; padding: 6px 14px;
  font-size: 0.75rem; cursor: pointer; transition: all 0.2s; backdrop-filter: blur(4px);
  letter-spacing: 0.3px; white-space: nowrap;
}
.cx-viewtool-btn:hover { background: rgba(99, 102, 241, 0.5); border-color: var(--accent-indigo); color: #fff; }
.cx-viewpad {
  display: grid; grid-template-columns: repeat(3, 28px); grid-template-rows: repeat(3, 28px);
  gap: 2px; justify-items: center; align-items: center;
}
.cx-viewpad-btn {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: rgba(30, 30, 50, 0.75); border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7); border-radius: 6px; font-size: 0.7rem; cursor: pointer;
  transition: all 0.2s; backdrop-filter: blur(4px); padding: 0;
}
.cx-viewpad-btn:hover { background: rgba(99, 102, 241, 0.5); border-color: var(--accent-indigo); color: #fff; }
.cx-viewpad-btn[data-view="ant"]   { grid-column: 2; grid-row: 1; }
.cx-viewpad-btn[data-view="left"]  { grid-column: 1; grid-row: 2; }
.cx-viewpad-btn[data-view="sup"]   { grid-column: 2; grid-row: 2; }
.cx-viewpad-btn[data-view="right"] { grid-column: 3; grid-row: 2; }
.cx-viewpad-btn[data-view="post"]  { grid-column: 2; grid-row: 3; }
[data-theme="light"] .cx-viewtool-btn, [data-theme="light"] .cx-viewpad-btn { background: rgba(255, 255, 255, 0.85); border-color: rgba(0, 0, 0, 0.2); color: #333; }
[data-theme="light"] .cx-viewtool-btn:hover, [data-theme="light"] .cx-viewpad-btn:hover { background: rgba(99, 102, 241, 0.2); border-color: var(--accent-indigo); color: var(--accent-indigo); }

.cx-legend {
  position: absolute; left: 14px; bottom: 30px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 60ch;
  font-size: 0.68rem; color: var(--text-secondary); pointer-events: none;
}
.cx-lg { display: flex; align-items: center; gap: 5px; }
.cx-lg i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.cx-hud {
  position: absolute; left: 14px; bottom: 8px; z-index: 5;
  font-size: 0.66rem; color: var(--text-muted); pointer-events: none;
}

.cx-footer {
  grid-area: footer; padding: 7px 14px; border-top: 1px solid var(--border);
  font-size: 0.72rem; color: var(--text-muted);
}

.cx-empty { color: var(--text-muted); font-size: 0.74rem; line-height: 1.5; padding-top: 4px; }
#cx-panel h3 { font-size: 0.95rem; margin: 0 0 3px; }
.cx-sub { color: var(--text-muted); font-size: 0.72rem; margin-bottom: 10px; }
.cx-kv { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--border); }
.cx-inherit {
  margin-top: 12px; padding: 9px; border-radius: 7px;
  background: rgba(99, 102, 241, 0.1); border: 1px solid rgba(99, 102, 241, 0.28);
}
.cx-inherit h4 { margin: 0 0 4px; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; }
.cx-inherit p { margin: 0; font-size: 0.72rem; line-height: 1.45; color: var(--text-secondary); }

/* Under ~1100px the two rails would leave no viewport worth rotating, so they
   collapse to scrollable strips above and below it. */
@media (max-width: 1100px) {
  .cx-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas: "header" "left" "viewport" "right" "footer";
  }
  .cx-rail { max-height: 26vh; }
  .cx-rail-left, .cx-rail-right { border: none; border-bottom: 1px solid var(--border); }

}

.cx-note { border-radius: 7px; padding: 9px 10px; margin-bottom: 10px; font-size: 0.74rem; line-height: 1.45; }
.cx-note p { margin: 5px 0 0; }
.cx-note code { display: inline-block; margin-top: 6px; font-size: 0.7rem; opacity: 0.85; }
.cx-note.block { background: rgba(224, 87, 107, 0.12); border: 1px solid rgba(224, 87, 107, 0.4); color: #f0a0ac; }
.cx-note.warn { background: rgba(232, 176, 75, 0.12); border: 1px solid rgba(232, 176, 75, 0.38); color: #e8b04b; }
.cx-note.ok { background: rgba(63, 211, 155, 0.1); border: 1px solid rgba(63, 211, 155, 0.32); color: #6fdcb4; }
.cx-badge.projected { background: rgba(139, 126, 240, 0.16); color: #b0a6ff; border: 1px solid rgba(139, 126, 240, 0.45); }
.cx-panel-h4 { margin: 14px 0 4px; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }

/* Region reading panel: header stripe in the group colour, then one block per
   dictionary field, then the visible links with clickable partner rows. */
.cx-phead { border-left: 3px solid var(--border); padding: 2px 0 6px 10px; margin-bottom: 4px; }
.cx-plobe { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; margin-bottom: 3px; }
.cx-phead h3 { font-size: 1.05rem; margin: 0 0 4px; }
.cx-phead .cx-sub { margin-bottom: 6px; }
.cx-zbadge {
  display: inline-block; color: #fff; font-family: ui-monospace, monospace; font-size: 0.74rem;
  padding: 3px 8px; border-radius: 5px; margin-top: 2px;
}
.cx-zbadge span { opacity: 0.85; font-size: 0.66rem; }
.cx-block { padding: 9px 0; border-bottom: 1px solid var(--border); }
.cx-block h4 { margin: 0 0 4px; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.12em; color: #e8b04b; font-weight: 600; }
.cx-block h4 .dim { color: var(--text-muted); font-weight: 400; letter-spacing: 0; }
.cx-block p { margin: 0 0 4px; font-size: 0.76rem; line-height: 1.5; color: var(--text-primary); }
.cx-block .mono, .cx-block p.mono { font-family: ui-monospace, monospace; font-size: 0.72rem; color: var(--text-secondary); }
.cx-connrow {
  display: flex; align-items: center; gap: 7px; padding: 4px 2px; font-size: 0.74rem;
  border-radius: 5px; cursor: pointer;
}
.cx-connrow:hover { background: rgba(99, 102, 241, 0.16); }
.cx-connrow i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cx-connrow span { flex: 1; color: var(--text-primary); }
.cx-connrow b { font-family: ui-monospace, monospace; font-weight: 600; color: #e8b04b; }

/* ── Landing page: the same connectome as a hero card ─────────────────────
   The landing page has its own palette, so the variables the .cx-* rules
   rely on are pinned here rather than assumed. */
.lb-card {
  --border: rgba(255, 255, 255, 0.12);
  --text-primary: #e8e8f0;
  --text-secondary: #c4c4d8;
  --text-muted: #9898b8;
  --accent-indigo: #8b7ef0;
  display: grid; grid-template-columns: 1fr 340px; grid-template-areas: "viewport rail";
  height: 600px; max-width: 1100px; margin: 64px auto 0;
  background: #0b1119; border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 0 60px rgba(139, 126, 240, 0.18), 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: left; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.lb-viewport { grid-area: viewport; position: relative; overflow: hidden; min-height: 320px; }
.lb-viewport canvas { display: block; width: 100%; height: 100%; }
.lb-rail {
  grid-area: rail; overflow-y: auto; padding: 12px 14px; font-size: 0.78rem;
  border-left: 1px solid var(--border); background: rgba(0, 0, 0, 0.16); color: var(--text-primary);
}
.lb-atlas { display: block; margin-bottom: 12px; }
.lb-atlas span {
  display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 6px;
}
.lb-atlas select {
  width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 5px; padding: 5px 7px; font-size: 0.76rem; font-family: inherit;
}
.lb-card .cx-message { padding: 40px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
@media (max-width: 900px) {
  .lb-card { grid-template-columns: 1fr; grid-template-areas: "viewport" "rail"; height: auto; }
  .lb-viewport { height: 380px; }
  .lb-rail { max-height: 360px; border-left: none; border-top: 1px solid var(--border); }
}
/* The landing page's root font is larger than the app's, and the .cx-* sizes
   are rem-based, so the card pins its own pixel sizes. */
.lb-card #cx-panel h3 { font-size: 15px; }
.lb-card .cx-phead h3 { font-size: 16px; }
.lb-card .cx-plobe { font-size: 10px; }
.lb-card .cx-sub { font-size: 11.5px; }
.lb-card .cx-block h4 { font-size: 10px; }
.lb-card .cx-block p { font-size: 12.5px; line-height: 1.5; }
.lb-card .cx-block .mono, .lb-card .cx-block p.mono { font-size: 11.5px; }
.lb-card .cx-connrow { font-size: 12px; }
.lb-card .cx-inherit h4 { font-size: 10px; }
.lb-card .cx-inherit p { font-size: 11.5px; }
.lb-card .cx-empty { font-size: 12px; }
.lb-card .cx-legend { font-size: 11px; }
.lb-card .cx-hud { font-size: 10.5px; }
.lb-card .cx-badge { font-size: 11px; }
.lb-card .cx-tip { font-size: 11.5px; }
.lb-card .cx-viewtool-btn { font-size: 11.5px; }
.lb-card .cx-viewpad-btn { font-size: 11px; }
.lb-card .lb-atlas span { font-size: 10.5px; }
.lb-card .lb-atlas select { font-size: 12px; }
.lb-card .cx-zbadge { font-size: 11.5px; }

/* ── Landing page skin ────────────────────────────────────────────────────
   The card takes the home page's own palette (its surface, pink and teal)
   and its sans type, so the brain reads as part of that page rather than a
   window into the app. Group colours stay: they are data. */
.lb-card {
  --border: rgba(232, 121, 160, 0.28);
  --accent-indigo: #e879a0;
  --text-primary: #e8e8f0;
  --text-secondary: #c9c9dc;
  --text-muted: #9898b8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1e1e2e; border-radius: 12px; border: 1px solid var(--border);
  box-shadow: 0 0 0 1px rgba(232, 121, 160, 0.08), 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 90px rgba(232, 121, 160, 0.10);
}
.lb-rail { background: #252538; border-left-color: rgba(232, 121, 160, 0.18); }
.lb-atlas span { font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--text-muted); font-weight: 500; }
.lb-atlas select {
  background: #323250; border: 1px solid rgba(232, 121, 160, 0.35); color: var(--text-primary);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; font-family: inherit;
}
.lb-atlas select:focus { outline: 2px solid #e879a0; outline-offset: 1px; }

/* Canvas chrome */
.lb-card .cx-badge.theory {
  background: #323250; border: 1px solid #b5527a; color: #f4a0c0;
  border-radius: 999px; padding: 4px 12px; font-size: 11px; letter-spacing: 0.02em; max-width: none;
}
.lb-card .cx-viewpad-btn {
  background: rgba(50, 50, 80, 0.85); border: 1.5px solid #b5527a; color: #f4a0c0;
  border-radius: 8px; width: 30px; height: 30px; font-size: 11px; backdrop-filter: none;
}
.lb-card .cx-viewpad-btn:hover, .lb-card .cx-viewpad-btn:focus-visible { background: rgba(232, 121, 160, 0.18); color: #fff; border-color: #e879a0; outline: none; }
.lb-card .cx-viewpad-btn[data-view="home"] { color: #7dd3c8; border-color: #7dd3c8; }
.lb-card .cx-viewpad-btn[data-view="home"]:hover { background: rgba(125, 211, 200, 0.16); border-color: #7dd3c8; color: #fff; }
.lb-card .cx-legend { font-size: 11.5px; color: var(--text-secondary); font-family: inherit; }
.lb-card .cx-lg i { border-radius: 50%; }
.lb-card .cx-hud { font-size: 11px; font-family: inherit; color: var(--text-muted); }
.lb-card .cx-tip { font-family: inherit; font-size: 12px; background: #323250; border-color: #b5527a; border-radius: 8px; }

/* Region reading */
.lb-card .cx-phead { border-left-width: 3px; padding-left: 12px; }
.lb-card .cx-plobe { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.lb-card .cx-phead h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }
.lb-card .cx-sub { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--text-muted); }
.lb-card .cx-block { border-bottom: 1px solid rgba(232, 121, 160, 0.14); padding: 10px 0; }
.lb-card .cx-block h4 { font-size: 12px; text-transform: none; letter-spacing: 0; color: #7dd3c8; font-weight: 600; margin-bottom: 4px; }
.lb-card .cx-block h4 .dim { color: var(--text-muted); font-weight: 400; }
.lb-card .cx-block p { font-size: 13px; line-height: 1.55; color: var(--text-primary); }
.lb-card .cx-block .mono, .lb-card .cx-block p.mono { font-size: 12px; }
.lb-card .cx-inherit { background: rgba(125, 211, 200, 0.08); border: 1px solid rgba(125, 211, 200, 0.3); border-radius: 8px; }
.lb-card .cx-inherit h4 { font-size: 12px; text-transform: none; letter-spacing: 0; color: #7dd3c8; }
.lb-card .cx-inherit p { font-size: 12px; }
.lb-card .cx-connrow { font-size: 12.5px; border-radius: 8px; padding: 5px 6px; }
.lb-card .cx-connrow:hover { background: rgba(232, 121, 160, 0.12); }
.lb-card .cx-connrow b { color: #f4a0c0; }
.lb-card .cx-empty { font-size: 13px; }
.lb-card .cx-message { font-family: inherit; }

/* Caption under the card, in the page's voice */
.lb-caption { margin: 14px auto 0; max-width: 60ch; text-align: center; font-size: 13px; color: #9898b8; }

@media (prefers-reduced-motion: no-preference) {
  .lb-card .cx-viewpad-btn, .lb-card .cx-connrow { transition: background 0.15s, border-color 0.15s, color 0.15s; }
}
.lb-card .cx-viewpad-btn[data-view="home"] { grid-column: 2; grid-row: 2; }
.hero p.lb-caption { margin: 14px auto 0; max-width: 60ch; font-size: 13px; line-height: 1.5; color: #9898b8; }
