:root {
  color-scheme: dark;
  --bg: #071118;
  --bg-2: #0d1721;
  --bg-3: #111e2a;
  --panel: rgba(13, 23, 33, 0.86);
  --panel-strong: rgba(18, 31, 44, 0.94);
  --line: rgba(179, 204, 224, 0.18);
  --line-strong: rgba(183, 220, 240, 0.34);
  --text: #ecf7ff;
  --muted: #93aabd;
  --soft: #5e7386;
  --cyan: #59e0ff;
  --mint: #5ef2c2;
  --rose: #ff5cab;
  --amber: #f6c55f;
  --green: #78ff9c;
  --violet: #b48cff;
  --danger: #ff8a66;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.shell {
  position: fixed;
  inset: 0;
  height: auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 25% 20%, rgba(89, 224, 255, 0.14), transparent 30%),
    radial-gradient(circle at 72% 12%, rgba(255, 92, 171, 0.12), transparent 30%),
    radial-gradient(circle at 58% 90%, rgba(120, 255, 156, 0.09), transparent 30%),
    var(--bg);
}

.topbar {
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 24, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand svg {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 0 18px rgba(89, 224, 255, 0.42));
}

.brand circle:nth-child(1) {
  fill: var(--mint);
}

.brand circle:nth-child(2) {
  fill: var(--amber);
}

.brand circle:nth-child(3) {
  fill: var(--rose);
}

.brand path {
  fill: none;
  stroke: rgba(236, 247, 255, 0.78);
  stroke-width: 2;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.totals,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill,
.action,
.icon-button,
.section-title button,
.prompt button {
  border: 1px solid var(--line);
  background: rgba(17, 30, 42, 0.88);
  color: var(--text);
  min-height: 34px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.pill {
  padding: 0 11px;
  color: var(--muted);
  font-size: 12.5px;
}

.pill.live {
  color: var(--mint);
  border-color: rgba(94, 242, 194, 0.34);
  background: rgba(94, 242, 194, 0.09);
}

.pill.offline {
  color: var(--amber);
  border-color: rgba(246, 197, 95, 0.32);
  background: rgba(246, 197, 95, 0.08);
}

.action {
  padding: 0 14px;
}

.action.primary {
  color: #061118;
  border-color: transparent;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  font-weight: 700;
}

.action[aria-pressed="true"],
.icon-button[aria-pressed="true"] {
  border-color: rgba(255, 92, 171, 0.42);
  background: rgba(255, 92, 171, 0.14);
  color: #ffd8e9;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-family: var(--mono);
  font-weight: 700;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 360px;
  position: relative;
  transition: grid-template-columns 220ms ease;
}

.sidebar,
.inspector {
  z-index: 5;
  overflow: auto;
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.sidebar {
  border-right: 1px solid var(--line);
}

.inspector {
  border-left: 1px solid var(--line);
}

.panel-section,
.detail {
  padding: 0 0 16px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child,
.detail:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.section-title h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title span,
.section-title button {
  color: var(--soft);
  font-size: 12px;
}

.section-title button {
  min-height: 26px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.04);
}

.search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.search span {
  color: var(--soft);
  font-size: 12px;
}

.search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search input::placeholder {
  color: var(--soft);
}

.results,
.filters {
  display: grid;
  gap: 3px;
  margin-top: 10px;
}

.result,
.filter {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 6px 7px;
  cursor: pointer;
}

.result:hover,
.filter:hover {
  background: rgba(255, 255, 255, 0.055);
}

.result[aria-current="true"] {
  background: rgba(89, 224, 255, 0.12);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--node-color, var(--cyan));
  box-shadow: 0 0 12px var(--node-color, var(--cyan));
}

.result b,
.filter b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 620;
}

.result span,
.filter span {
  color: var(--soft);
  font-size: 12px;
  white-space: nowrap;
}

.filter input {
  accent-color: var(--node-color, var(--cyan));
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meter {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.meter span {
  display: block;
  color: var(--soft);
  font-size: 12px;
  margin-bottom: 6px;
}

.meter b {
  display: block;
  height: 7px;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--mint), var(--rose));
  transition: width 120ms linear;
}

#cameraPreview {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  background: #02060a;
}

.stage {
  min-width: 0;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(126, 92, 255, 0.18), transparent 30%),
    radial-gradient(circle at 46% 62%, rgba(255, 92, 171, 0.12), transparent 34%),
    radial-gradient(circle at 64% 48%, rgba(94, 242, 194, 0.1), transparent 28%),
    #050b11;
}

#brainCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#brainCanvas:active {
  cursor: grabbing;
}

.stage-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 116px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.stage-tools {
  position: absolute;
  z-index: 4;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}

.stage-hud > div {
  min-width: 0;
  max-width: 48%;
  padding: 8px 10px;
  border: 1px solid rgba(183, 220, 240, 0.2);
  border-radius: 8px;
  background: rgba(5, 11, 17, 0.42);
  backdrop-filter: blur(12px);
}

.hud-label {
  display: block;
  color: var(--soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-hud strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.prompt {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(183, 220, 240, 0.22);
  border-radius: 10px;
  background: rgba(5, 11, 17, 0.62);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.prompt input {
  min-width: 0;
  height: 38px;
  border: 0;
  outline: 0;
  border-radius: 7px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.prompt input::placeholder {
  color: var(--soft);
}

.prompt button {
  min-width: 86px;
  padding: 0 13px;
  color: #061118;
  border-color: transparent;
  background: var(--amber);
  font-weight: 750;
}

.detail p {
  margin: 0;
  color: #cfdeeb;
}

.node-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.node-stats div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.node-stats dt {
  color: var(--soft);
  font-size: 11px;
  margin: 0 0 4px;
}

.node-stats dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

.route {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

.route li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.route i {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #071118;
  background: var(--node-color, var(--cyan));
  font-style: normal;
  font: 700 11px var(--mono);
}

.route span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  display: grid;
  gap: 7px;
  max-height: 310px;
  overflow: auto;
}

.event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.event time {
  color: var(--soft);
  font: 11px var(--mono);
}

.event b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.event span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell.panels-hidden .sidebar,
.shell.panels-hidden .inspector,
.shell.cinema .sidebar,
.shell.cinema .inspector,
.shell.cinema .topbar,
.shell.cinema .stage-hud,
.shell.cinema .prompt {
  display: none;
}

.shell.panels-hidden .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.shell.panels-hidden .stage {
  grid-column: 1;
}

.shell.cinema {
  grid-template-rows: minmax(0, 1fr);
}

.shell.cinema .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.shell.cinema .stage {
  grid-column: 1;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .inspector {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 44vw);
    box-shadow: -18px 0 60px rgba(0, 0, 0, 0.28);
  }

  .shell.panels-hidden .inspector {
    display: none;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    position: static;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

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

  .totals,
  .actions {
    justify-content: flex-start;
  }

  .workspace {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(520px, 64vh) auto auto;
  }

  .stage {
    grid-row: 1;
  }

  .stage-hud {
    right: 14px;
    top: 58px;
  }

  .stage-tools {
    top: 10px;
  }

  .sidebar,
  .inspector {
    position: static;
    width: auto;
    max-height: none;
    border: 0;
    border-top: 1px solid var(--line);
  }

  .sidebar {
    grid-row: 2;
  }

  .inspector {
    grid-row: 3;
  }
}
