:root {
  --bg: #071018;
  --panel: #0d1824;
  --panel-2: #101f2c;
  --line: #274054;
  --line-strong: #3f6b82;
  --text: #ecf4f8;
  --muted: #8ea1ad;
  --blue: #80c7ff;
  --teal: #67e6d2;
  --amber: #e7c268;
  --coral: #e98973;
  --green: #8de6a5;
  --red: #ff6f7f;
  --steel: #9fb4c0;
  --iridium: #9c8cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 160px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 54px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.light {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --panel-2: #edf5fa;
  --line: #bfd2df;
  --line-strong: #8fb0c3;
  --text: #102433;
  --muted: #527084;
  --blue: #1677c7;
  --teal: #0cae9f;
  --amber: #c99521;
  --coral: #c8644f;
  --green: #20965c;
  --red: #d23d51;
  --steel: #5f7380;
  --iridium: #5c5ad6;
  background:
    linear-gradient(180deg, rgba(22, 119, 199, 0.08), transparent 190px),
    repeating-linear-gradient(90deg, rgba(16, 36, 51, 0.045) 0 1px, transparent 1px 54px),
    var(--bg);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1580px, 96vw);
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar,
.stage-grid,
.bottom-grid,
footer {
  width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.kicker,
.panel-title small {
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 5px;
  font-size: 36px;
  line-height: 1.04;
}

.brand p {
  max-width: 880px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  padding: 12px;
  border: 1px solid rgba(76, 224, 186, 0.32);
  border-radius: 8px;
  background: #0c201f;
}

.theme-toggle {
  margin-left: auto;
  min-width: 58px;
  min-height: 30px;
  border: 1px solid rgba(128, 199, 255, 0.46);
  border-radius: 8px;
  color: var(--text);
  background: rgba(7, 18, 27, 0.72);
  font-size: 11px;
  font-weight: 850;
}

.status-chip strong,
.status-chip small {
  display: block;
}

.status-chip strong {
  font-size: 12px;
}

.status-chip small {
  margin-top: 3px;
  color: #a8dccc;
  font-size: 11px;
}

.live-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px rgba(110, 231, 154, 0.78);
}

.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.cortex-panel,
.command-panel,
.matrix-panel,
.events-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 24, 36, 0.88);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
}

.cortex-panel {
  min-height: 660px;
  padding: 16px;
}

.command-panel {
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title h2 {
  margin-top: 4px;
  font-size: 18px;
}

.panel-title.compact h2 {
  font-size: 15px;
}

#modePill,
#coreBadge,
#fabricDataset,
.rec {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 8px;
  color: #b8ddeb;
  background: #0b1620;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

#coreBadge.ready {
  border-color: rgba(110, 231, 154, 0.5);
  color: var(--green);
}

.brain-map {
  position: relative;
  min-height: 598px;
  margin-top: 8px;
  border: 1px solid rgba(63, 107, 130, 0.42);
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 45%, rgba(231, 194, 104, 0.12), transparent 28%),
    radial-gradient(circle at 72% 42%, rgba(103, 230, 210, 0.13), transparent 30%),
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    #08131d;
  background-size: 42px 42px;
  overflow: hidden;
}

.brain-map:before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(103, 230, 210, 0.09), transparent 36%, rgba(231, 194, 104, 0.09)),
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 42%);
  pointer-events: none;
}

#brainSvg {
  display: none;
}

#cortexCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 568px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.035), transparent 45%);
}

.cortex-labels {
  display: none;
}

.cortex-chip {
  position: absolute;
  min-width: 132px;
  padding: 8px 10px;
  border: 1px solid rgba(142, 188, 211, 0.32);
  border-radius: 8px;
  background: rgba(6, 16, 24, 0.78);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
  transform: translate(-50%, -50%);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.cortex-chip b,
.cortex-chip span {
  display: block;
  text-align: center;
}

.cortex-chip b {
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.cortex-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.cortex-chip.active {
  border-color: var(--blue);
  background: rgba(17, 42, 63, 0.86);
  box-shadow: 0 0 26px rgba(128, 199, 255, 0.4);
}

.cortex-chip.complete {
  border-color: var(--green);
  box-shadow: 0 0 22px rgba(141, 230, 165, 0.28);
}

.cortex-chip.error {
  border-color: var(--red);
  box-shadow: 0 0 22px rgba(255, 111, 127, 0.3);
}

.local-chip { left: 19%; top: 52%; }
.qwen-chip { left: 31%; top: 32%; }
.govern-chip { left: 30%; top: 70%; }
.docker-chip { left: 43%; top: 76%; }
.strands-chip { left: 50%; top: 49%; }
.cognee-chip { left: 69%; top: 52%; }
.brightdata-chip { left: 84%; top: 27%; }
.bridge-chip { left: 50%; top: 88%; }

.brain-title-overlay {
  position: absolute;
  z-index: 2;
  top: 56px;
  color: #d8eef4;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brain-backdrop {
  opacity: 0.98;
}

.brain-main-shell {
  fill: rgba(9, 20, 31, 0.9);
  stroke: url(#brainShell);
  stroke-width: 4;
  filter: url(#softGlow);
}

.local-shell {
  stroke: url(#localShell);
}

.shared-shell {
  stroke: url(#brainShell);
}

.brain-fold {
  fill: none;
  stroke: rgba(210, 237, 246, 0.18);
  stroke-width: 2;
  stroke-linecap: round;
}

.brain-title {
  fill: #d8eef4;
  font-size: 16px;
  font-weight: 900;
  text-anchor: middle;
  letter-spacing: 0.08em;
}

.flow-rails path {
  fill: none;
  stroke: rgba(196, 222, 231, 0.28);
  stroke-width: 2;
  stroke-dasharray: 6 10;
  stroke-linecap: round;
}

.flow-rails path.flowing {
  stroke: var(--teal);
  stroke-width: 4;
  filter: url(#hardGlow);
  animation: dash 0.85s linear infinite;
}

.flow-rails path.complete-flow {
  stroke: rgba(141, 230, 165, 0.72);
  stroke-width: 3;
  filter: url(#softGlow);
}

.brain-segment path,
.brain-segment circle {
  stroke-width: 3;
  stroke: rgba(236, 244, 248, 0.35);
  transition: 0.2s ease;
}

.brain-segment path {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.22));
}

.memory-segment path {
  fill: url(#memoryFill);
  fill-opacity: 0.72;
  stroke: #86f3e6;
}

.memory-segment circle {
  fill: rgba(7, 19, 30, 0.72);
  stroke: rgba(236, 244, 248, 0.45);
}

.local-segment path {
  fill: url(#localFill);
  fill-opacity: 0.68;
  stroke: #f1cf83;
}

.observe-segment path {
  fill: url(#observeFill);
  fill-opacity: 0.7;
  stroke: #9bdcff;
}

.strands-segment path {
  fill: url(#strandsFill);
  fill-opacity: 0.7;
  stroke: #c9c0ff;
}

.strands-segment circle {
  fill: rgba(10, 21, 36, 0.75);
  stroke: rgba(236, 244, 248, 0.46);
}

.reason-segment path {
  fill: url(#reasonFill);
  fill-opacity: 0.72;
  stroke: #b8adff;
}

.govern-segment path {
  fill: rgba(126, 111, 204, 0.74);
  stroke: #d2cbff;
}

.action-segment path {
  fill: url(#actionFill);
  fill-opacity: 0.72;
  stroke: #f2b3a4;
}

.bridge-segment path {
  fill: none;
  stroke: url(#bridgeFill);
  stroke-width: 4;
  stroke-linecap: round;
  filter: url(#softGlow);
}

.bridge-segment .bridge-track {
  stroke-width: 2;
  stroke-dasharray: 5 8;
  opacity: 0.72;
}

.brain-segment text,
.bridge-segment text,
.outer-connectors text {
  fill: var(--text);
  font-size: 18px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
}

.brain-segment .sub,
.bridge-segment .sub {
  fill: #bdd0db;
  font-size: 12px;
  font-weight: 800;
}

.brain-segment .micro {
  fill: rgba(236, 244, 248, 0.86);
  font-size: 10px;
  font-weight: 850;
}

.outer-connectors rect {
  fill: rgba(7, 16, 24, 0.88);
  stroke: rgba(142, 188, 211, 0.35);
  stroke-width: 1.5;
}

.outer-connectors path {
  fill: none;
  stroke: rgba(142, 188, 211, 0.42);
  stroke-width: 1.8;
  stroke-dasharray: 4 7;
}

.outer-connectors text {
  fill: #d7e6ed;
  font-size: 12px;
}

.ready path,
.ready rect,
.ready circle {
  stroke: var(--green);
}

.pending path,
.pending rect,
.pending circle {
  stroke: var(--amber);
}

.blocked path,
.blocked rect,
.blocked circle,
.error path,
.error rect,
.error circle {
  stroke: var(--red);
}

.active path,
.active rect,
.active circle {
  stroke: var(--blue);
  filter: url(#hardGlow) saturate(1.15);
}

.complete path,
.complete rect,
.complete circle {
  stroke: var(--green);
  filter: url(#softGlow);
}

.brain-segment.active text,
.brain-segment.complete text,
.bridge-segment.active text,
.bridge-segment.complete text {
  text-shadow: 0 0 12px currentColor;
}

.brain-legend {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-width: 720px;
}

.brain-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(142, 188, 211, 0.28);
  border-radius: 8px;
  background: rgba(7, 16, 24, 0.82);
  color: #d6e5eb;
  font-size: 10px;
  font-weight: 850;
}

.brain-legend span:before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.legend-memory:before {
  background: #44e3bd;
}

.legend-local:before {
  background: #ffd26a;
}

.legend-observe:before {
  background: #57c7ff;
}

.legend-reason:before {
  background: #8d7aff;
}

.legend-action:before {
  background: #ff8f6f;
}

.pipeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding: 11px;
  border: 1px solid rgba(128, 199, 255, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(128, 199, 255, 0.08), rgba(7, 18, 27, 0.84)),
    #07121b;
}

.pipeline:before {
  content: "";
  position: absolute;
  left: 34px;
  right: 34px;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, rgba(103, 230, 210, 0), rgba(128, 199, 255, 0.55), rgba(103, 230, 210, 0));
  transform: translateY(-50%);
  pointer-events: none;
}

.pipeline > div {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 62px;
  padding: 10px;
  border: 1px solid rgba(63, 107, 130, 0.68);
  border-radius: 8px;
  background:
    radial-gradient(circle at 22px 50%, rgba(128, 199, 255, 0.12), transparent 42px),
    rgba(8, 20, 31, 0.94);
  box-shadow: inset 0 0 0 1px rgba(236, 244, 248, 0.02);
}

.pipeline > div.active {
  border-color: var(--blue);
  background:
    radial-gradient(circle at 22px 50%, rgba(128, 199, 255, 0.32), transparent 48px),
    #10253a;
  box-shadow: 0 0 20px rgba(128, 199, 255, 0.22), inset 0 0 0 1px rgba(128, 199, 255, 0.16);
}

.pipeline > div.complete {
  border-color: rgba(103, 230, 210, 0.86);
  background:
    radial-gradient(circle at 22px 50%, rgba(103, 230, 210, 0.34), transparent 48px),
    linear-gradient(180deg, rgba(12, 45, 54, 0.96), rgba(9, 27, 32, 0.96));
  box-shadow: 0 0 22px rgba(103, 230, 210, 0.22), inset 0 0 0 1px rgba(103, 230, 210, 0.18);
}

.pipeline b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(128, 199, 255, 0.72);
  color: var(--teal);
  font-size: 12px;
  background: rgba(3, 12, 18, 0.82);
  box-shadow: 0 0 13px rgba(128, 199, 255, 0.12);
}

.pipeline > div.complete b {
  color: #041116;
  border-color: #80c7ff;
  background: #80c7ff;
  box-shadow: 0 0 20px rgba(128, 199, 255, 0.78), 0 0 42px rgba(103, 230, 210, 0.3);
  font-size: 0;
}

.pipeline > div.complete b:after {
  content: "✓";
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
}

.pipeline span {
  min-width: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
}

.pipeline small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 124px;
  margin-top: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07121b;
  color: var(--text);
  padding: 12px;
  line-height: 1.45;
  outline: none;
}

textarea:focus {
  border-color: var(--blue);
}

.input-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.input-tools button,
.file-tool {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #0a1722;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.input-tools button.selected {
  color: #041111;
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 0 16px rgba(103, 230, 210, 0.24);
}

.file-tool input {
  display: none;
}

.attachment-summary {
  margin-top: 8px;
  min-height: 18px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.button-row,
.route-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.button-row button,
.route-controls button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #102132;
  font-size: 12px;
  font-weight: 850;
}

.route-controls {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.route-controls button {
  min-height: 34px;
  padding: 6px 4px;
  color: #b7ccd7;
  background: #0a1722;
  font-size: 10px;
}

.route-controls button.selected {
  color: #041111;
  background: var(--green);
  border-color: var(--green);
}

.button-row .primary {
  color: #041111;
  background: var(--teal);
  border-color: var(--teal);
}

.button-row .secondary {
  color: #130a04;
  background: var(--amber);
  border-color: var(--amber);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.answer-box {
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07121b;
  color: #c0d1da;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 14px;
  margin-top: 14px;
}

.matrix-panel,
.events-panel {
  min-height: 232px;
  padding: 14px;
}

.fabric-matrix,
.route-matrix {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.fabric-row,
.route-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1722;
  color: var(--text);
  text-align: left;
}

.fabric-row span,
.route-row span {
  min-width: 0;
  font-size: 12px;
  font-weight: 850;
}

.fabric-row b,
.route-row b {
  color: #c8d9e1;
  font-size: 10px;
  text-transform: uppercase;
}

.fabric-row small,
.route-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.fabric-row.ready,
.route-row.ready {
  border-color: rgba(110, 231, 154, 0.38);
}

.fabric-row.pending,
.route-row.pending {
  border-color: rgba(242, 193, 95, 0.42);
}

.fabric-row.blocked,
.route-row.blocked {
  border-color: rgba(255, 111, 127, 0.42);
}

.event-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 146px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 2px;
}

.event {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 8px 9px;
  border-left: 3px solid var(--line-strong);
  border-radius: 0 8px 8px 0;
  background: #0a1722;
}

.event > span {
  color: #87a6b8;
  font-size: 11px;
  font-weight: 850;
}

.event b {
  display: block;
  font-size: 12px;
}

.event small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.event.active {
  border-color: var(--blue);
}

.event.complete {
  border-color: var(--green);
}

.event.error {
  border-color: var(--red);
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.metrics span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 7px;
  color: #b7ccd7;
  background: #091621;
  font-size: 10px;
  font-weight: 850;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
  color: #8aa0ad;
  font-size: 12px;
}

footer strong {
  color: #c9d9e0;
  text-align: right;
}

body.light .status-chip {
  border-color: rgba(32, 150, 92, 0.24);
  background: #eaf8f2;
}

body.light .theme-toggle,
body.light .button-row button,
body.light .route-controls button,
body.light .input-tools button,
body.light .file-tool {
  background: #f6fbff;
  color: var(--text);
}

body.light .cortex-panel,
body.light .command-panel,
body.light .matrix-panel,
body.light .events-panel {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 44px rgba(47, 78, 96, 0.12);
}

body.light .brain-map {
  background:
    radial-gradient(circle at 31% 48%, rgba(201, 149, 33, 0.13), transparent 28%),
    radial-gradient(circle at 72% 42%, rgba(12, 174, 159, 0.13), transparent 30%),
    linear-gradient(rgba(16, 36, 51, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 36, 51, 0.06) 1px, transparent 1px),
    #f7fbff;
  background-size: 42px 42px;
}

body.light #cortexCanvas {
  background: radial-gradient(circle at 50% 50%, rgba(22, 119, 199, 0.07), transparent 48%);
}

body.light textarea,
body.light .answer-box,
body.light .fabric-row,
body.light .route-row,
body.light .event,
body.light .pipeline,
body.light .pipeline > div {
  background-color: #f8fbfe;
  color: var(--text);
}

body.light .answer-box {
  border-color: #bfd2df;
  color: #233d50;
}

body.light .pipeline {
  background:
    linear-gradient(180deg, rgba(22, 119, 199, 0.07), rgba(255, 255, 255, 0.88)),
    #ffffff;
}

body.light .pipeline > div.active {
  background:
    radial-gradient(circle at 22px 50%, rgba(22, 119, 199, 0.19), transparent 48px),
    #eef7ff;
}

body.light .pipeline > div.complete {
  background:
    radial-gradient(circle at 22px 50%, rgba(12, 174, 159, 0.22), transparent 48px),
    #edf9f7;
}

body.light footer strong,
body.light .status-chip small,
body.light .brand p {
  color: var(--muted);
}

@keyframes dash {
  to {
    stroke-dashoffset: -36;
  }
}

@media (max-width: 1260px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .command-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .command-panel > .answer-box {
    grid-column: 1 / -1;
  }

  .bottom-grid {
    grid-template-columns: 1fr 1fr;
  }

  .events-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: 94vw;
  }

  .topbar,
  .command-panel,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .status-chip {
    width: 100%;
  }

  .cortex-panel,
  .command-panel,
  .matrix-panel,
  .events-panel {
    border-radius: 8px;
  }

  .brain-map {
    min-height: 0;
  }

  #cortexCanvas {
    height: 390px;
  }

  .cortex-labels {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 8px 10px 0;
  }

  .brain-legend {
    position: static;
    padding: 10px;
    max-width: none;
  }

  .cortex-chip {
    position: static;
    min-width: 0;
    transform: none;
    padding: 7px 6px;
  }

  .cortex-chip b {
    font-size: 9px;
  }

  .cortex-chip span {
    font-size: 8px;
  }

  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pipeline {
    margin-top: 10px;
  }

  .pipeline > div {
    min-height: 58px;
  }

  .route-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .input-tools {
    grid-template-columns: 1fr;
  }

  footer {
    flex-direction: column;
  }

  footer strong {
    text-align: left;
  }
}
