.beams-viz {
  color-scheme: dark;
  --bg: #0b0d2c;
  --panel: #131740;
  --ink: #e1e9ff;
  --muted: #a7b5de;
  --line: rgba(255, 255, 255, 0.1);
  --signal: #84e6cc;
  --alert: #ff8c73;
  --purple: #c4a9ff;
  --sans: "Lato", "Helvetica Neue", sans-serif;
  --mono: "Ubuntu Mono", Consolas, monospace;
}
.beams-viz,
.beams-viz * {
  box-sizing: border-box;
}
.beams-viz {
  position: relative;
  min-width: 0;
  container: beams-viz / inline-size;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
.beams-viz .monitor {
  border: 0;
  background: var(--bg);
  box-shadow: none;
}
.beams-viz .monitor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  font: 11px/1.5 var(--mono);
}
.beams-viz .live-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  background: var(--signal);
  border-radius: 50%;
  box-shadow: 0 0 12px #84e6cc70;
}
.beams-viz .monitor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}
.beams-viz .swarm-field {
  position: relative;
  min-width: 0;
  height: 540px;
  overflow: hidden;
}
.beams-viz canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.beams-viz [data-role="scene-labels"] {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.beams-viz .scene-label {
  position: absolute;
  top: 0;
  left: 0;
  color: #9caec8;
  font: 9px var(--mono);
  white-space: nowrap;
  text-align: center;
  text-shadow:
    0 2px 6px #000,
    0 0 8px var(--bg);
}
.beams-viz .scene-label.agent {
  font-size: 8px;
  color: #7b95b2;
}
.beams-viz .scene-label.denied {
  color: #edc783;
}
.beams-viz .scene-label.flagged {
  color: #ffd0bf;
  padding: 4px 6px;
  background: #2b1724df;
  border: 1px solid #ff8c7370;
}
.beams-viz .scene-label.core {
  font-size: 16px;
  color: #eee5ff;
  letter-spacing: 0.12em;
}
.beams-viz .scene-label.board {
  color: var(--purple);
  font-size: 9px;
}
.beams-viz[data-phase="detected"] .scene-label.board {
  color: var(--alert);
}
.beams-viz [data-role="render-error"] {
  position: absolute;
  top: 30%;
  left: 8%;
  right: 8%;
  padding: 22px;
  background: var(--panel);
  border: 1px solid #ff8c7350;
  color: #ffd0bf;
  font-size: 14px;
  line-height: 1.7;
  z-index: 3;
}
.beams-viz button:disabled {
  opacity: 0.45;
  cursor: default;
}
.beams-viz .evidence {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 26px 24px;
  background: linear-gradient(160deg, var(--panel), var(--bg));
}
.beams-viz .evidence h2 {
  font-size: 20px;
  line-height: 1.4;
  font-weight: 400;
  color: #a7b5ce;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
/* All explanations remain readable without JavaScript. */
.beams-viz .story-steps {
  list-style: none;
  padding: 0;
  margin: 0;
}
.beams-viz .story-steps h3 {
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
  margin: 0 0 5px;
}
.beams-viz .story-steps p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.beams-viz .story-steps .is-active h3 {
  color: var(--purple);
}
.beams-viz[data-phase="blocked"] .story-steps .is-active h3 {
  color: #edc783;
}
.beams-viz[data-phase="detected"] .story-steps .is-active h3 {
  color: var(--alert);
}
.beams-viz [hidden] {
  display: none !important;
}
.beams-viz button {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  padding: 9px 13px;
  font: 11px var(--sans);
  cursor: pointer;
}
.beams-viz button:hover:not(:disabled) {
  color: var(--ink);
  background: #ffffff06;
}
.beams-viz :focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 4px;
}
.beams-viz .sr-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.beams-viz .no-script {
  color: var(--alert);
}
.beams-viz[data-phase="detected"] .live-dot {
  background: var(--alert);
  box-shadow: 0 0 14px #ff8c7360;
}
.beams-viz[data-phase="detected"] [data-role="phase-label"] {
  color: var(--alert);
}
.beams-viz[data-phase="detected"] .evidence {
  background: linear-gradient(150deg, #ff8c7309, var(--bg));
}

@container beams-viz (max-width: 1000px) {
  .beams-viz .monitor-body {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .beams-viz .evidence {
    padding-inline: 20px;
  }
}
@container beams-viz (max-width: 760px) {
  .beams-viz [data-role="phase-label"] {
    min-height: 3em;
    display: flex;
    align-items: center;
  }
  .beams-viz .monitor-body {
    grid-template-columns: 1fr;
  }
  .beams-viz .swarm-field {
    height: 360px;
  }
  .beams-viz .evidence {
    order: -1;
    border-left: none;
    border-bottom: 1px solid var(--line);
    padding: 24px;
  }
}
.beams-viz .story-steps [data-evidence-step] {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
/* Invisible panels still size the shared grid cell, preventing text-driven jumps. */
.beams-viz.scene-ready .story-steps {
  display: grid;
}
.beams-viz.scene-ready .story-steps [data-evidence-step] {
  grid-area: 1 / 1;
  visibility: hidden;
  pointer-events: none;
}
.beams-viz.scene-ready .story-steps .is-active {
  visibility: visible;
  pointer-events: auto;
}

@container beams-viz (max-width: 760px) {
  .beams-viz .monitor-header {
    min-height: 34px;
    padding: 6px 16px;
  }
  .beams-viz [data-role="phase-label"] {
    min-height: 0;
  }
  .beams-viz .evidence {
    padding: 10px 16px;
  }
  .beams-viz .evidence h2 {
    margin-bottom: 8px;
  }
  /* Phones size the explanation to the selected scene, not the longest hidden one. */
  .beams-viz.scene-ready .story-steps {
    display: block;
  }
  .beams-viz .story-steps [data-evidence-step] {
    padding: 8px 0;
  }
  .beams-viz.scene-ready .story-steps [data-evidence-step] {
    display: none;
  }
  .beams-viz.scene-ready .story-steps .is-active {
    display: block;
  }
  .beams-viz .swarm-field {
    height: clamp(220px, 68cqw, 320px);
  }
}

@container beams-viz (min-width: 761px) {
  .beams-viz.scene-ready .monitor {
    height: var(--viz-height, 623px);
    display: flex;
    flex-direction: column;
  }
  .beams-viz.scene-ready .monitor-body {
    flex: 1;
    min-height: 0;
  }
  .beams-viz.scene-ready .swarm-field {
    height: 100%;
  }
  .beams-viz .monitor-header {
    flex-shrink: 0;
    min-height: 30px;
    padding: 6px 16px;
  }
  .beams-viz .evidence {
    min-height: 0;
    padding: 14px 16px;
  }
  .beams-viz .evidence h2 {
    margin-bottom: 8px;
  }
  .beams-viz .story-steps [data-evidence-step] {
    padding: 8px 0;
  }
}
@container beams-viz (max-width: 760px) {
  .beams-viz .monitor {
    padding-bottom: 12px;
  }
}
