:root {
  --bg-dark: #0b0f17;
  --bg-card: #121826;
  --bg-panel: #182132;
  --border-subtle: #26334d;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-emerald: #34d399;
  --accent-gold: #facc15;
  --accent-crimson: #f87171;
  --accent-violet: #a78bfa;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 12px;
  line-height: 1.32;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #0e1420;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 4px;
}

.brand-titles h1 {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.subtitle {
  font-size: 10.5px;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  gap: 6px;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  color: var(--text-main);
  padding: 4px 9px;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  border-color: var(--accent-cyan);
  background: #1f2b42;
}

.btn-primary {
  background: rgba(52, 211, 153, 0.16);
  border-color: var(--accent-emerald);
  color: #6ee7b7;
  font-weight: 600;
}

.btn-primary[aria-pressed="true"],
.btn-toggle[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.24);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.main-grid {
  display: grid;
  grid-template-columns: 0.96fr 1.04fr;
  gap: 8px;
  padding: 6px 12px 4px;
  flex: 1;
  min-height: 0;
}

.viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.viewport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: #0f1522;
  gap: 8px;
  flex-shrink: 0;
  height: 48px;
}

.viewport-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.viewport-header h2 {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewport-hint {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  max-width: 395px;
}

.pill {
  font-size: 9.5px;
  line-height: 1.15;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
  background: #161f30;
  white-space: nowrap;
}

.pill-info {
  border-color: rgba(52, 211, 153, 0.5);
  color: var(--accent-emerald);
}

.pill-gold {
  border-color: rgba(250, 204, 21, 0.5);
  color: var(--accent-gold);
}

.pill-crimson {
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--accent-crimson);
}

.canvas-stage {
  position: relative;
  background: radial-gradient(circle at 50% 35%, #1a2438 0%, #0b101b 100%);
  flex: 1;
  min-height: 0;
}

#cat-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hud-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
}

.retinal-inset {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(11, 15, 23, 0.9);
  border: 1px solid #334155;
  border-radius: 5px;
  padding: 5px;
  width: 158px;
  pointer-events: none;
  z-index: 2;
}

.inset-title {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  margin-bottom: 3px;
}

#retinal-canvas {
  width: 146px;
  height: 82px;
  border-radius: 3px;
  display: block;
  background: #05070b;
  border: 1px solid #1e293b;
}

.inset-caption {
  font-size: 9px;
  color: #cbd5e1;
  margin-top: 3px;
}

.canvas-legend {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(11, 15, 23, 0.85);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #1e293b;
  font-size: 10px;
  color: #cbd5e1;
  pointer-events: none;
  z-index: 2;
}

.canvas-legend .btn-cam {
  pointer-events: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-hand {
  background: #38bdf8;
}

.dot-ghost {
  background: rgba(250, 204, 21, 0.8);
  border: 1px dashed #ffffff;
}

.dot-f3 {
  background: #34d399;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: #0f1522;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.preset-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-preset,
.btn-cam {
  font-size: 10px;
  padding: 3px 6px;
}

.btn-preset.active,
.btn-cam.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-cyan);
  color: #ffffff;
  font-weight: 600;
}

.brain-stage-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  flex: 1;
  min-height: 0;
}

.brain-canvas-wrap {
  position: relative;
  background: radial-gradient(circle at 50% 45%, #172036 0%, #090d16 100%);
  border-right: 1px solid var(--border-subtle);
  min-height: 0;
}

#brain-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.brain-selected-banner {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  background: rgba(15, 21, 34, 0.92);
  border: 1px solid #334155;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  color: #e2e8f0;
  z-index: 2;
}

.brain-side-inspector {
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #0e1421;
  min-height: 0;
}

.inspector-section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.region-bars-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.region-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 5px;
  border-radius: 3px;
  background: #141d2f;
  border: 1px solid transparent;
  cursor: pointer;
}

.region-row.selected {
  border-color: var(--accent-cyan);
  background: #1a2740;
}

.region-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 600;
}

.region-bar-track {
  height: 4px;
  background: #090d16;
  border-radius: 2px;
  overflow: hidden;
}

.region-bar-fill {
  height: 100%;
  width: 10%;
  border-radius: 2px;
  transition: width 0.08s linear;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.telemetry-cell {
  background: #141d2f;
  border: 1px solid #22304a;
  border-radius: 3px;
  padding: 3px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.telemetry-label {
  font-size: 9px;
  color: var(--text-muted);
}

.telemetry-val {
  font-size: 10.5px;
  font-weight: 700;
  color: #f8fafc;
}

.bottom-deck {
  display: grid;
  grid-template-columns: 1.42fr 0.88fr;
  gap: 8px;
  padding: 2px 12px 8px;
  flex-shrink: 0;
  height: 214px;
}

.scrubber-panel,
.ablation-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
}

.scrubber-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.scrubber-header > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.scrubber-header h3,
.ablation-panel h3 {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
}

.checkpoint-summary {
  font-size: 9.5px;
  color: var(--accent-emerald);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.milestone-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-milestone {
  font-size: 9.5px;
  padding: 3px 6px;
  white-space: nowrap;
}

.btn-milestone.active {
  background: rgba(52, 211, 153, 0.22);
  border-color: var(--accent-emerald);
  color: #ffffff;
  font-weight: 600;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-label {
  font-size: 10.5px;
  font-weight: 600;
  min-width: 175px;
}

#age-slider {
  flex: 1;
  accent-color: var(--accent-emerald);
}

.training-visuals-row {
  display: grid;
  grid-template-columns: 245px 1fr;
  gap: 8px;
}

.litter-box,
.emergence-charts-box {
  background: #0d1320;
  border: 1px solid #1e293b;
  border-radius: 5px;
  padding: 4px 6px;
}

.subpanel-title {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

#litter-canvas,
#emergence-canvas {
  width: 100%;
  height: 92px;
  display: block;
}

.ablation-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin: 1px 0 4px;
}

.ablation-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 10px;
  color: #cbd5e1;
  margin-bottom: 4px;
  cursor: pointer;
}

.ablation-row input {
  margin-top: 2px;
  accent-color: var(--accent-cyan);
}

/* ---------- Homeostasis / circadian panel ---------- */
.drive-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drive-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drive-clock { font: 700 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-main); min-width: 64px; }
.drive-spacer { flex: 1; }
.drive-meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.drive-meter-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.drive-meter-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.drive-meter-fill { height: 100%; width: 0%; border-radius: 3px; transition: width 0.2s linear; }
.ethogram canvas { width: 100%; height: 34px; display: block; border-radius: 6px; background: rgba(255, 255, 255, 0.03); }
.ethogram-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; font-size: 11px; color: var(--text-muted); }
.ethogram-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.drive-panel.disabled .drive-meters, .drive-panel.disabled .ethogram { opacity: 0.35; }

.preset-label-push { margin-left: auto; }

/* ---------- Learning & memory tab ---------- */
.ablation-panel { justify-content: flex-start; gap: 4px; }
.panel-tabs { display: flex; gap: 4px; }
.panel-tab {
  font: inherit; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 6px;
  border: 1px solid var(--border-subtle); background: transparent; color: var(--text-muted); cursor: pointer;
}
.panel-tab.active { color: var(--text-main); border-color: var(--accent-cyan); background: rgba(56, 189, 248, 0.08); }
.ablations-pane { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: auto; }
.learning-pane { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.learning-pane[hidden], .ablations-pane[hidden] { display: none; }
.learning-controls { display: flex; flex-wrap: wrap; gap: 4px; }
.learning-controls .btn-preset, .learning-controls .btn-toggle { font-size: 10.5px; padding: 2px 7px; }
.learning-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 6px; min-height: 0; }
.learning-plot canvas { width: 100%; height: 70px; display: block; border-radius: 5px; background: rgba(255, 255, 255, 0.03); }
.learning-status { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
