/* MindBlown · Neural Engine — unified shell.
   One frame for every page: header (top), rail (left: navigation + context), tool column (right), status bar (bottom),
   details panel (right of the stage), page layer (catalog & documents) and the engine canvas underneath.
   engine.css keeps the engine's content styles; this file re-homes its frame pieces into the shared layout. */

:root {
  --top-h: 60px; --rail-w: 240px; --tools-w: 44px; --status-h: 44px; --gap: 12px; --panel-w: 380px;
  --rail-left: var(--gap); --stage-top: calc(var(--top-h) + var(--gap)); --stage-bottom: calc(var(--status-h) + var(--gap));
  --page-left: calc(var(--rail-left) + var(--rail-w) + var(--gap)); --page-right: calc(var(--gap) + var(--tools-w) + var(--gap));
  --glass-soft: rgba(12, 16, 28, 0.6); --accent-2: #fde68a; --ok: #4ade80; --warn: #fbbf24; --info: #60a5fa;
  --focus: 0 0 0 2px rgba(255, 138, 61, 0.55);
}
html { scrollbar-color: rgba(160, 180, 220, 0.28) transparent; }
:focus-visible { outline: none; box-shadow: var(--focus); }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- stage background (the home page shows a live, dimmed starfield instead of an empty canvas) ---------- */
#stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(900px 600px at 70% -10%, rgba(255, 138, 61, 0.09), transparent 60%), radial-gradient(700px 500px at 10% 110%, rgba(96, 165, 250, 0.08), transparent 60%); }
body[data-view="brain"] #stage::before, body[data-view="build"] #stage::before { opacity: 0.4; }

/* ---------- header ---------- */
#top {
  top: 0; left: 0; right: 0; height: var(--top-h); padding: 0 var(--gap) 0 14px; gap: 10px; pointer-events: auto; z-index: 8;
  display: grid; grid-template-columns: auto auto minmax(160px, 1fr) auto auto; align-items: center;
  background: linear-gradient(180deg, rgba(6, 8, 15, 0.92), rgba(6, 8, 15, 0.78)); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; padding: 4px 6px 4px 2px; border-radius: 10px; }
.logo:hover { background: rgba(255, 255, 255, 0.04); }
.logo .mark { width: 28px; height: 28px; flex: none; }
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -0.01em; }
/* Brand rule: "Blown" in the wordmark always carries the rainbow of the logo's spokes. */
.logo-blown, .mb-blown {
  background: linear-gradient(90deg, #f4897b 0%, #f4db7b 25%, #bdf47b 45%, #7bf4db 65%, #7bbcf4 80%, #dc7bf4 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
@media (forced-colors: active) { .logo-blown, .mb-blown { background: none; color: CanvasText; -webkit-text-fill-color: CanvasText; } }
.logo-tag { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-top: 3px; }

.switcher {
  display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px 0 10px; border-radius: 999px; cursor: pointer; min-width: 0; max-width: 360px;
  border: 1px solid var(--line); background: var(--glass); color: var(--text); margin-left: 6px;
}
.switcher:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.06); }
.switcher[aria-expanded="true"] { border-color: var(--accent); }
.sw-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; box-shadow: 0 0 8px currentColor; color: var(--text-3); }
.switcher .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.05; min-width: 0; color: var(--text); }
.switcher .brand .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.switcher .brand .sub { font-size: 11px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.sw-caret { color: var(--text-3); flex: none; transition: transform .2s; }
.switcher[aria-expanded="true"] .sw-caret { transform: rotate(180deg); }

.search { position: relative; justify-self: stretch; width: auto; max-width: 560px; min-width: 0; display: flex; align-items: center; margin: 0 auto; width: 100%; }
.search > svg { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 44px 0 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--glass-strong); box-shadow: none; }
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-key { position: absolute; right: 12px; font: 11px/1 var(--font-body); color: var(--text-3); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; pointer-events: none; }
.search:focus-within .search-key { opacity: 0; }
body[data-view="brain"] #cq, body[data-view="brain"] #cresults, body[data-view="build"] #cq, body[data-view="build"] #cresults { display: none; }
body:not([data-view="brain"]):not([data-view="build"]) #q, body:not([data-view="brain"]):not([data-view="build"]) #results { display: none !important; }
.results { position: absolute; left: 0; right: 0; top: 44px; max-height: min(60vh, 520px); overflow: auto; margin: 0; padding: 6px; list-style: none; z-index: 20;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.results li .rk { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-left: 6px; }

/* Ask: its own header button (not a menu entry); the label hides on narrow phones */
.ask-btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px 0 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.ask-btn svg { flex: none; }
.ask-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); }
.ask-btn.on { border-color: var(--accent); color: var(--accent); }
.ask-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stats { text-align: right; line-height: 1.45; white-space: nowrap; }
.icon-btn { display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); color: var(--text); cursor: pointer; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- left rail ---------- */
#rail { position: absolute; left: var(--rail-left); top: var(--stage-top); bottom: var(--stage-bottom); width: var(--rail-w); display: flex; flex-direction: column; gap: 10px; z-index: 5; pointer-events: none; }
#rail > * { pointer-events: auto; }
.nav-primary { display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); flex: none; }
.nav-primary a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--text-2); text-decoration: none; }
.nav-primary a svg { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.nav-primary a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-primary a.on { background: rgba(255, 138, 61, 0.12); color: var(--text); }
.nav-primary a.on svg { color: var(--accent); }

.rail-section { position: static; width: auto; max-height: none; padding: 12px 12px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; flex-direction: column; min-height: 0; }
#facets, #lobes { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
#lobes, #connectome.connectome { position: static; left: auto; top: auto; bottom: auto; width: auto; max-height: none; transform: none; }
#connectome.connectome { max-height: min(58vh, 620px); }
.rail-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin: 0 0 8px 4px; user-select: none; flex: none; }
.rail-head + .rail-head, .switches + .rail-head, .rail-list + .rail-head { margin-top: 14px; }
.rail-count { letter-spacing: 0; font-variant-numeric: tabular-nums; }
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li a, .rail-list li button { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 7px 8px; border-radius: 8px; border: 0; background: none; color: var(--text-2); text-decoration: none; font-size: 13px; cursor: pointer; text-align: left; }
.rail-list li a:hover, .rail-list li button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.rail-list li a.on { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.rail-list .sw { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.rail-list .n { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
#lobes .lobes-head { cursor: pointer; }
#lobes.folded { flex: none; padding: 10px 12px; }
#lobes.folded .lobes-head { margin: 0 0 0 4px; }
#lobes.folded #lobe-list, #lobes.folded .switches, #lobes.folded .members { display: none; }
.members { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.members .rail-head { margin-top: 0; }

.connectome { position: static; left: auto; top: auto; bottom: auto; width: auto; transform: none !important; flex: none; max-height: min(58vh, 620px); border-radius: var(--radius); margin-top: auto; }
.connectome .cx-head { padding: 10px 12px 10px 14px; }
.connectome .cx-body-wrap { max-height: 50vh; }

#rail-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 6; }

/* ---------- right tool column ---------- */
#tools-col { position: absolute; right: var(--gap); top: var(--stage-top); bottom: var(--stage-bottom); width: var(--tools-w); display: flex; flex-direction: column; gap: 14px; z-index: 5; }
#tools-col .zoom-ctl { position: static; right: auto; bottom: auto; gap: 6px; display: flex; flex-direction: column; }
#tools-col .zoom-ctl.tools { bottom: auto; }
#tools-col #zoom-ctl { margin-top: auto; }
#tools-col .zoom-ctl button { width: var(--tools-w); height: var(--tools-w); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
#tools-col .zoom-ctl button svg { width: 20px; height: 20px; display: block; }
#tools-col .zoom-ctl button:disabled { opacity: 0.35; cursor: not-allowed; }
#tools-col .zoom-ctl button:disabled:hover { background: var(--glass); }
#tools-col .zoom-ctl button.on { background: var(--text); color: #0b0e14; }
#tools-col .zoom-ctl button.active { background: rgba(255, 138, 61, 0.18); border-color: var(--accent); color: var(--accent); }

/* ---------- status bar ---------- */
#status { position: absolute; left: 0; right: 0; bottom: 0; height: var(--status-h); display: flex; align-items: center; justify-content: center; padding: 0 var(--gap); z-index: 5; pointer-events: none; }
#status .level { position: static; left: auto; bottom: auto; transform: none; pointer-events: auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#status .level .hint { overflow: hidden; text-overflow: ellipsis; }
#status .level.catalog .dot { background: var(--info); box-shadow: 0 0 12px var(--info); }

/* ---------- page layer ---------- */
#page { position: absolute; left: var(--page-left); right: var(--page-right); top: var(--stage-top); bottom: var(--stage-bottom); overflow: auto; overscroll-behavior: contain; z-index: 4; outline: none; scrollbar-width: thin; }
body[data-view="brain"] #page, body[data-view="build"] #page { display: none; }
body[data-view="brain"] #facets, body[data-view="build"] #facets { display: none; }
body:not([data-view="brain"]) #lobes, body:not([data-view="brain"]) #connectome { display: none; }
body:not([data-view="brain"]):not([data-view="build"]) #brain { opacity: 0.55; }
/* Build: the builder owns the canvas and the details column; its categories section (#cats) takes the lobes slot in the rail */
body:not([data-view="build"]) #cats, body:not([data-view="build"]) #actions, body:not([data-view="build"]) #interview { display: none !important; }
.page-inner { max-width: 1160px; margin: 0 auto; padding: 4px 4px 40px; }
.page-inner.narrow { max-width: 860px; }

.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 28px; align-items: end; padding: 28px 28px 24px; border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.14), rgba(12, 16, 28, 0.55) 45%, rgba(96, 165, 250, 0.1)); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); margin-bottom: 26px; }
.eyebrow { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin: 0 0 10px; }
.hero h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 12px; }
.hero p { font-size: 15px; line-height: 1.55; color: var(--text-2); margin: 0 0 18px; max-width: 56ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.totals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.totals div { padding: 12px 14px; border-radius: 12px; background: rgba(6, 8, 15, 0.45); border: 1px solid var(--line); }
.totals b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.totals span { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase; }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font-size: 13.5px; font-weight: 500; text-decoration: none; cursor: pointer; }
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; }
.btn.primary:hover { background: #ff9d5c; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.connectome .btn.sm { height: auto; border-radius: 8px; font-size: 11px; padding: 5px 10px; margin: 2px 6px; align-self: flex-start; color: var(--text-2); }

.sec { margin: 0 0 28px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.sec-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; margin: 0; }
.sec-head .more { font-size: 13px; color: var(--text-3); text-decoration: none; }
.sec-head .more:hover { color: var(--text); }
.sec-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.select { height: 30px; padding: 0 28px 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--glass) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23a7b2cc' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center / 12px; color: var(--text); font-size: 12.5px; appearance: none; -webkit-appearance: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 12px; }
.card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); text-decoration: none; color: var(--text); min-height: 132px; transition: border-color .15s, transform .15s, background .15s; }
.card:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.05); transform: translateY(-1px); }
.card.on { border-color: var(--accent); }
.card .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card .sw { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; flex: none; }
.card .cname { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card h3 { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.2; margin: 0; letter-spacing: -0.005em; }
.card p { font-size: 12.5px; line-height: 1.45; color: var(--text-2); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; flex-wrap: wrap; row-gap: 6px; }
.card .foot .badges { display: flex; gap: 5px; margin: 0 0 0 auto; flex-wrap: nowrap; }
.card .foot .badges:empty { display: none; }
.card .info { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.card:hover .info, .card .info:focus-visible { opacity: 1; }
.card .info:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--line); }
.card.network::after { content: ''; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 0 3px rgba(255, 255, 255, 0.02); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--line); color: var(--text-3); line-height: 1.4; white-space: nowrap; }
.badge.published { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); }
.badge.preview { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.badge.draft { color: var(--text-3); }
.badge.fiction { color: #f472b6; border-color: rgba(244, 114, 182, 0.35); }
.badge.network { color: var(--info); border-color: rgba(96, 165, 250, 0.35); }

.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.coll { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); text-decoration: none; color: var(--text); transition: border-color .15s, background .15s; }
.coll:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.05); }
.coll .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coll h3 { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px; }
.coll h3 .sw { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.coll p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.coll .dots { display: flex; gap: 4px; flex-wrap: wrap; }
.coll .dots i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.coll .nums { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.sentinel { height: 1px; }
.more-row { display: flex; justify-content: center; padding: 16px 0 4px; color: var(--text-3); font-size: 12.5px; gap: 10px; align-items: center; }
.empty { padding: 28px; border-radius: 14px; border: 1px dashed var(--line); color: var(--text-3); text-align: center; font-size: 13.5px; }

/* documents (community, build, api, about) */
.doc { padding: 26px 28px 30px; border-radius: 18px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.doc h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 3.4vw, 36px); letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 8px; }
.doc .lede { font-size: 15.5px; line-height: 1.55; color: var(--text-2); margin: 0 0 22px; max-width: 64ch; }
.doc h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; margin: 26px 0 8px; letter-spacing: -0.01em; }
.doc p, .doc li { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.doc p { margin: 0 0 10px; }
.doc ul, .doc ol { margin: 0 0 12px; padding-left: 20px; }
.doc a { color: var(--accent); text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc code, .doc pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.doc code { background: rgba(255, 255, 255, 0.06); padding: 2px 6px; border-radius: 6px; color: var(--text); }
.doc pre { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow: auto; color: var(--text-2); line-height: 1.55; margin: 8px 0 14px; }
.doc pre code { background: none; padding: 0; }
.doc .note { padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.06); color: var(--text-2); font-size: 13.5px; margin: 12px 0; }
.doc .steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0 14px; }
.doc .step { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(6, 8, 15, 0.4); }
.doc .step b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.doc .step span { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.doc table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 14px; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: top; }
.doc th { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 500; }
.doc td code { white-space: nowrap; }
.doc .frame-map { display: grid; grid-template-columns: 120px 1fr 44px; grid-template-rows: 40px 1fr 32px; gap: 6px; height: 200px; margin: 10px 0 14px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.doc .frame-map div { border: 1px dashed var(--line-strong); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; }
.doc .frame-map .t { grid-column: 1 / -1; } .doc .frame-map .b { grid-column: 1 / -1; }

/* ---------- panel ---------- */
.panel { right: var(--page-right); top: var(--stage-top); bottom: var(--stage-bottom); width: var(--panel-w); z-index: 7; }
.panel .lobe-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; color: var(--text-2); }
.panel .lobe-row .sw { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.panel .lobe-row .n { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.panel .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.panel .tags span { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--text-2); }
.panel .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel .actions .btn { width: auto; flex: 1 1 auto; justify-content: center; }
.panel .members-list a { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: center; padding: 5px 0; color: var(--text-2); text-decoration: none; font-size: 13px; }
.panel .members-list a:hover { color: var(--text); }

/* ---------- switcher palette ---------- */
.palette { position: fixed; inset: 0; z-index: 40; background: rgba(2, 4, 10, 0.55); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 0; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.palette-box { width: min(640px, 100%); border-radius: 16px; border: 1px solid var(--line-strong); background: var(--glass-strong); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-box input { height: 52px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font-size: 16px; outline: none; }
.palette-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.palette-list { overflow: auto; padding: 6px; scrollbar-width: thin; }
.palette-list .grp { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px 4px; }
.palette-list .row { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 14px; text-decoration: none; }
.palette-list .row .sw { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.palette-list .row .meta { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.palette-list .row b { font-weight: 500; color: var(--text); }
.palette-list .row:hover, .palette-list .row.active { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.palette-list .row.active { box-shadow: inset 2px 0 0 var(--accent); }
.palette-list .empty { margin: 6px; }
.palette-foot { display: flex; justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-3); }

/* ---------- keyboard help ---------- */
.keys { position: absolute; left: 50%; bottom: calc(var(--status-h) + 14px); transform: translateX(-50%); z-index: 9; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass-strong); font-size: 12.5px; color: var(--text-2); display: grid; grid-template-columns: auto auto; gap: 6px 18px; }
.keys kbd { font: 11px/1 var(--font-body); color: var(--text); border: 1px solid var(--line-strong); border-radius: 5px; padding: 3px 6px; margin-right: 6px; }

/* loading overlay: below the header so the frame is visible while a brain wakes up */
/* A modal sits above body-level add-ons without changing the canvas or rail geometry. */
#brain-wake[open] { position: fixed; inset: 0; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; box-sizing: border-box; border: 0; background: #06080f; color: #c6ccd7; display: grid; place-items: center; text-align: center; font: 14px system-ui,sans-serif; }
#brain-wake::backdrop { background: #06080f; }
#brain-wake .wake-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #ff8a3d; }
#brain-wake a { color: #a8b0c0; font-size: 12px; padding: 8px; }
.loading { top: var(--top-h); z-index: 6; background: rgba(6, 8, 15, 0.9); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .switcher .brand .sub { display: none; } .hero { grid-template-columns: 1fr; } .totals { grid-template-columns: repeat(4, 1fr); } }
/* At 1100 px and below the header can squeeze the switcher; let the title shrink with it so the ellipsis applies. */
@media (max-width: 1100px) { .switcher .brand .title { max-width: min(260px, 100%); } }
@media (max-width: 1100px) and (min-width: 901px) { #top { grid-template-columns: auto auto minmax(140px, 1fr) auto auto; } .stats { font-size: 11px; max-width: 200px; white-space: normal; } .logo-text { display: none; } }

@media (max-width: 900px) {
  :root { --top-h: 104px; --rail-w: 272px; --status-h: 40px; --tools-w: 36px; --page-left: var(--gap); --page-right: var(--gap); --stage-bottom: calc(var(--status-h) + var(--tools-w) + var(--gap) * 2); }
  #top { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 52px 44px; height: var(--top-h); padding: 0 10px; gap: 0 8px; }
  .logo { grid-row: 1; } .logo-text { display: none; }
  .switcher { grid-row: 1; grid-column: 2; max-width: 100%; justify-self: start; margin-left: 2px; }
  .switcher .brand .sub { display: none; }
  #top { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .ask-btn { grid-row: 1; grid-column: 3; }
  #menu-btn { display: inline-flex; grid-row: 1; grid-column: 4; }
  .search { grid-row: 2; grid-column: 1 / -1; max-width: none; margin: 0; }
  .search input { height: 36px; }
  .stats { display: none; }
  #rail { left: 0; top: 0; bottom: 0; padding: 12px; width: min(var(--rail-w), 86vw); background: var(--bg-2); border-right: 1px solid var(--line); transform: translateX(-104%); transition: transform .25s ease; z-index: 30; pointer-events: auto; }
  #rail.open { transform: none; }
  #rail .nav-primary { padding-top: 6px; }
  .rail-section { background: rgba(255, 255, 255, 0.03); }
  #lobes { top: auto; bottom: auto; left: auto; width: auto; padding: 12px; max-height: none; }
  #lobes .lobes-head::after { content: none !important; }
  #lobes:not(.open) #lobe-list, #lobes:not(.open) .switches { display: block; }
  #lobes:not(.open) .switches { display: flex; }
  .connectome { display: flex; }
  #tools-col { left: var(--gap); right: var(--gap); top: auto; bottom: calc(var(--status-h) + var(--gap)); width: auto; flex-direction: row; justify-content: space-between; gap: 6px; }
  #tools-col .zoom-ctl { flex-direction: row; display: flex; right: auto; bottom: auto; gap: 5px; }
  #tools-col #zoom-ctl { margin-top: 0; margin-left: auto; }
  #tools-col .zoom-ctl button { min-width: var(--tools-w); min-height: var(--tools-w); width: var(--tools-w); height: var(--tools-w); }
  #status { height: var(--status-h); }
  #status .level { left: auto; right: auto; bottom: auto; justify-content: center; }
  #status .level .hint { display: none; }
  .panel { left: var(--gap); right: var(--gap); width: auto; top: auto; bottom: 0; border-radius: 16px 16px 0 0; z-index: 31; }
  /* the brain's details sheet sizes itself by detent (peek, half, full: engine.css + app.js); only other panels keep the 56vh cap */
  .panel:not([data-detent]) { max-height: 56vh; }
  .page-inner { padding: 0 0 20px; }
  .hero { padding: 20px 18px; gap: 16px; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .doc { padding: 20px 16px; }
  .doc .frame-map { grid-template-columns: 70px 1fr 36px; height: 160px; font-size: 9px; }
  .palette { padding: 12px 10px 0; }
  .keys { display: none; }
  .toast { bottom: calc(var(--status-h) + var(--tools-w) + 28px); }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { min-width: 0; padding: 12px; min-height: 120px; }
  .card h3 { font-size: 15px; overflow-wrap: anywhere; }
  .card .foot { white-space: normal; }
  .card .foot .badges { flex-wrap: wrap; }
  .card p { display: none; }
  .coll-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { #rail, .card, .sw-caret { transition: none; } }
/* The primer's documentation-only engine has no links into editable brains. */
body.teaching-sample .logo,
body.teaching-sample #switcher,
body.teaching-sample .nav-primary,
body.teaching-sample #members { display:none !important; }
@media (max-width:480px) {
  body.teaching-sample #tools button:not(.tool-mode) { display:none; }
}

/* ===== Add-ons from the standalone mindblown-neural pages (Don't Panic, Entangler, the mice, origin dock) =====
   They stack themselves above the topmost tool group and sit at the stage's bottom-left; the frame gives them that room. */
/* the engine's brain-tools group (Log, Modifiers, origin) floats above the tool column, or beside it when there is no room; the engine sets bottom/right */
#tools-col #brain-tools { position: absolute; flex-direction: column; }
#tools-col #layout-tools, #tools-col #layout-placeholder { position: absolute; flex-direction: column; }
#tools-col #layout-placeholder { bottom: calc(100% + 10px); right: 0; }
@media (min-width: 901px) {
  body[data-view] #tools-col { --tools-w: 36px; top: auto; padding-top: 0; bottom: calc(var(--stage-bottom) + 12px); gap: 14px; }
  #tools-col #zoom-ctl { margin-top: 0; }
}
@media (min-width: 901px) and (max-height: 800px) {
  body[data-view] #tools-col { --tools-w: 28px; }
  #tools-col .zoom-ctl { gap: 4px; }
  #tools-col .zoom-ctl button { width: var(--tools-w); height: var(--tools-w); }
}
@media (min-width: 901px) {
  /* room above the tool column for the brain-tools group, the Drive and the Entangler (and the Guide's cheese); shorter screens use the engine's beside/fallback spots */
  @media (min-height: 850px) { .has-improbability-drive #tools-col { padding-top: 276px; gap: 8px; } }
  @media (min-height: 900px) { .has-improbability-drive body.brain-guide #tools-col { padding-top: 324px; } }
  @media (max-height: 899.98px) { .has-improbability-drive body.brain-guide #tools-col { padding-top: 0; gap: 14px; } }
  /* bottom-left add-ons start at the stage edge, right of the rail, above the status bar */
  .mice-chat, .mice-dock, .origin-dock { left: var(--page-left); bottom: calc(var(--stage-bottom) + 10px); }
  body:has(.mice-chat:not([hidden])) .origin-dock { left: calc(var(--page-left) + 420px); max-width: calc(100vw - var(--page-left) - 420px - var(--page-right) - 70px); }
  .mice-chat { max-width: calc(100vw - var(--page-left) - var(--page-right) - 70px); }
}
/* phones: the engine's options bar (#mbar: lobes, switches, level, ⋯ tools) owns the bottom edge, as on the standalone pages;
   the tool column becomes the standalone right-hand stack above it (zoom, with the brain group, Entangler, Drive and cheese stacking on top).
   It stays that stack while a details sheet replaces the bar (#mbar hidden): --mbar-h then carries the sheet's height, so the stack rides above the sheet */
@media (max-width: 900px) {
  body:has(#mbar:not([hidden])) #status { display: none; }
  body:has(#mbar) #tools-col { left: auto; right: var(--gap); top: auto; bottom: calc(var(--mbar-h) + var(--gap)); width: var(--tools-w); flex-direction: column; justify-content: flex-end; gap: 8px; }
  body:has(#mbar) #tools-col .zoom-ctl { flex-direction: column; }
  body:has(#mbar) #tools-col #tools { display: none; }
  body:has(#mbar) #tools-col #zoom-ctl { margin: 0; }
  body.sheet-full #tools-col { opacity: 0; pointer-events: none; }
}

/* parity follow-ups: the synced engine hides #lobes on phones (its options bar replaces the box), but here #lobes
   lives in the off-canvas rail and also carries the network members / back-to-Build links, so keep it there */
@media (max-width: 900px) { body[data-view="brain"] #rail #lobes { display: flex; } }
/* the Randonaut dock (z 55) sits under the search bar on phones; step aside while search results are open */
body:has(#results:not([hidden])) #mb-rando-dock, body:has(#results:not([hidden])) #mb-rando-panel { visibility: hidden; }
/* the off-canvas rail opens over the stage, so the engine's phone options bar steps aside while it is open */
/* a full-height details sheet reaches the header on phones; the Randonaut dock steps aside like the other docks */
@media (max-width: 900px) { body.sheet-full #mb-rando-dock, body.sheet-full #mb-rando-panel { visibility: hidden; pointer-events: none; } }
/* an open bar sheet (the lobe list, Customize) is modal: the Randonaut dock (z 55) steps aside instead of floating over it */
@media (max-width: 900px) { body:has(.mbar-sheet:not([hidden])) #mb-rando-dock, body:has(.mbar-sheet:not([hidden])) #mb-rando-panel { visibility: hidden; pointer-events: none; } }
@media (max-width: 900px) { body:has(#rail.open) .mbar, body:has(#rail.open) .mbar-pop, body:has(#rail.open) .mbar-sheet, body:has(#rail.open) #mb-rando-dock, body:has(#rail.open) #mb-rando-panel { visibility: hidden; pointer-events: none; } }
/* desktop: the header's menu button hides or shows the left rail (shell.js setRailHidden); the stage and bottom-left add-ons take its room */
@media (min-width: 901px) {
  #top { grid-template-columns: auto auto auto minmax(160px, 1fr) auto auto; }
  #top:has(#ask-btn) { grid-template-columns: auto auto auto minmax(160px, 1fr) auto auto auto; }
  #menu-btn { display: inline-flex; grid-row: 1; grid-column: 1; }
  body.rail-hidden { --page-left: var(--gap); }
  body.rail-hidden #rail { display: none; }
  body.rail-hidden #mb-rando-dock.mb-shell, body.rail-hidden #mb-rando-panel.mb-shell { left: calc(var(--gap) + 4px); }
}
/* Phones: Ask is icon-only so the brain name has room (its name comes from aria-label="Ask Tom", set by companion.js). */
@media (max-width: 600px) { .ask-btn { width: 38px; justify-content: center; padding: 0; } .ask-btn span { display: none; } }

/* Phone presentation controls: retain the engine's handlers and label state. */
#phone-tools-toggle { display: none; }
@media (max-width: 900px) {
  #phone-tools-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; right: var(--gap); bottom: calc(var(--status-h) + var(--gap));
    width: 40px; height: 40px; z-index: 60; pointer-events: auto;
    border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2);
    color: var(--text); cursor: pointer;
  }
  #phone-tools-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  body[data-view] #tools-col { bottom: calc(var(--status-h) + var(--gap) + 48px); }
  body:has(#mbar) #phone-tools-toggle { bottom: calc(var(--mbar-h) + var(--gap)); }
  body:has(#mbar) #tools-col { bottom: calc(var(--mbar-h) + var(--gap) + 48px); }
  body:has(#mbar) #tools-col #tools { display: flex; }
  body:has(#mbar) #tools-col #tools > button:not(#labels-toggle):not(#shot) { display: none; }
  #tools-col #labels-toggle[aria-pressed="false"] { opacity: .65; }
  body.phone-tools-collapsed #phone-tools-toggle { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--gap)) !important; }
  body.phone-tools-collapsed #phone-tools-toggle svg { transform: rotate(180deg); }
  body.phone-tools-collapsed :is(
    #tools-col, #mb-drive, #mb-entangler, #mb-rando-dock, #mb-rando-panel,
    .mice-dock, .mice-chat, .origin-dock, .origin-panel,
    #modifier-panel, #modifier-overlay, #modifiers-open-phone,
    #nnccg-drawer, #mbar, .mbar-pop, .mbar-sheet, .mbar-scrim
  ) { visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }
  body.sheet-full:not(.phone-tools-collapsed) #phone-tools-toggle { display: none; }
  body:has(#rail.open) #phone-tools-toggle { visibility: hidden; }
}

/* The right rail paints once. A brain's tools arrive in stages (engine, then each add-on's button), so the rail and the
   controls stacked on it stay hidden, still laid out and measurable, until shell.js has loaded the last add-on.
   Catalog pages drop the class as soon as they render. No fade: the rail simply appears, complete. */
body.rail-pending #tools-col, body.rail-pending #tools-col *, body.rail-pending #phone-tools-toggle,
body.rail-pending #brain-tools, body.rail-pending #layout-tools, body.rail-pending #mb-rando-dock,
body.rail-pending #mb-drive, body.rail-pending .mb-drive-out, body.rail-pending #mb-entangler,
body.rail-pending #mbar { visibility: hidden !important; }
/* while hidden the rail settles instantly (the phone .zoom-ctl slide would otherwise still be running when it appears) */
body.rail-pending #tools-col, body.rail-pending #tools-col *, body.rail-pending #mb-rando-dock, body.rail-pending #mb-drive { transition: none !important; }

/* reduced-motion note (app.js): a quiet pill just above the status bar; on phones it sits above the options bar, clear of the tools */
.motion-note { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--status-h) + 4px); z-index: 6; display: flex; align-items: center; gap: 8px; max-width: min(640px, calc(100vw - 2 * var(--gap))); padding: 4px 4px 4px 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--text-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.motion-note[hidden] { display: none; }
body:not([data-view="brain"]) .motion-note { display: none; }
.motion-note .mn-text { flex: 1 1 auto; min-width: 0; }
.motion-note .mn-short { display: none; }
.motion-note button { flex: none; min-height: 32px; min-width: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.motion-note .mn-x { padding: 0; border-color: transparent; color: var(--text-2); font-size: 16px; }
.motion-note button:hover { border-color: var(--text-3); }
.motion-note button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 900px) {
  .motion-note { left: var(--gap); right: calc(var(--tools-w) + var(--gap) * 2); transform: none; max-width: none; border-radius: 14px; }
  .motion-note .mn-long { display: none; } .motion-note .mn-short { display: inline; }
  body:has(#mbar) .motion-note { bottom: calc(var(--mbar-h) + var(--gap)); }
  body:has(#mbar-lobes:not([hidden])) .motion-note, body:has(.mbar-sheet:not([hidden])) .motion-note, body:has(#rail.open) .motion-note, body:has(#panel:not([hidden])) .motion-note { visibility: hidden; }
}
