:root {
  color-scheme: dark;
  --bg: #050711;
  --panel: rgba(12, 19, 35, 0.66);
  --line: rgba(139, 210, 255, 0.18);
  --text: #eef7ff;
  --muted: #92a8c0;
  --dim: #61758d;
  --cyan: #67d7ff;
  --green: #8dffca;
  --violet: #ad8cff;
  --pink: #ff7ad9;
  --amber: #ffd166;
  --orange: #ff9f66;
  --blue: #6fa8ff;
  --indigo: #7887ff;
  --silver: #d7e7f6;
  --radius: 24px;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body { min-height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  position: relative;
  overflow-x: hidden;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -5;
  background:
    radial-gradient(circle at 12% 0%, rgba(103, 215, 255, 0.16), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(173, 140, 255, 0.12), transparent 32%),
    radial-gradient(circle at 50% 100%, rgba(141, 255, 202, 0.08), transparent 30%),
    linear-gradient(115deg, rgba(4, 7, 17, 0.94), rgba(6, 13, 29, 0.92)),
    repeating-linear-gradient(90deg, rgba(103, 215, 255, 0.04) 0 1px, transparent 1px 58px),
    repeating-linear-gradient(0deg, rgba(141, 255, 202, 0.025) 0 1px, transparent 1px 58px);
}

/* Low-GPU HUD mode: the dashboard texture is baked into static gradients instead of animated blur/noise layers. */
.noise,
.aurora {
  display: none;
}

.shell {
  min-height: 100vh;
  width: min(calc(100vw - 24px), 1600px);
  max-width: calc(100vw - 24px);
  margin: 0 auto;
  padding: 12px 0;
}

.diagram-card {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.09), rgba(255,255,255,.025)), rgba(12, 19, 35, 0.88);
  box-shadow: 0 14px 42px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.08);
}

.diagram-card::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(circle at 16% 10%, rgba(103, 215, 255, 0.16), transparent 22%),
    radial-gradient(circle at 82% 14%, rgba(173, 140, 255, 0.14), transparent 24%),
    radial-gradient(circle at 50% 92%, rgba(141, 255, 202, 0.10), transparent 26%);
  pointer-events: none;
}

.diagram-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.045), transparent 18%, transparent 82%, rgba(103,215,255,.035));
}

.corner-label {
  position: fixed;
  top: 28px;
  left: max(36px, calc((100vw - 1600px) / 2 + 36px));
  right: max(36px, calc((100vw - 1600px) / 2 + 36px));
  z-index: 50;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(135deg, #182338 0%, #0b1220 58%, #11162a 100%);
  box-shadow: 0 14px 42px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.08);
  font-weight: 900;
  letter-spacing: -0.04em;
}

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

.brand-copy { min-width: 0; }
.brand-copy h1,
.brand-copy span {
  display: block;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-copy h1 {
  font-size: 1rem;
  line-height: 1.15;
}

.brand-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid rgba(139, 210, 255, 0.16);
  flex: 0 0 auto;
}

.mark {
  width: 40px;
  height: 40px;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(139, 210, 255, 0.26);
  border-radius: 50%;
  background: #07111f;
  box-shadow: 0 0 30px rgba(103,215,255,.30);
}

.mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.diagram-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - 52px);
  overflow: auto;
  contain: layout paint;
  border-radius: 24px;
  border: 1px solid rgba(139, 210, 255, 0.14);
  padding: 48px 22px 28px;
  background: rgba(5, 9, 20, 0.28);
  scrollbar-color: rgba(103, 215, 255, 0.45) rgba(2, 6, 23, 0.4);
}

.tree-wrap {
  width: min(100%, 1400px);
  margin: 0 auto;
}

.toolbar-button {
  appearance: none;
  border: 1px solid rgba(124,236,255,.28);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  background: rgba(124,236,255,.08);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.toolbar-button:hover,
.toolbar-button:focus-visible {
  outline: none;
  border-color: rgba(103, 215, 255, 0.82);
  background: rgba(124,236,255,.12);
  box-shadow: 0 0 20px rgba(103,215,255,.18);
}

.trace-panel {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(139, 210, 255, 0.16);
  border-radius: 20px;
  background: rgba(5, 10, 22, 0.46);
}

.trace-copy {
  min-width: min(100%, 260px);
  display: grid;
  gap: 2px;
  text-align: left;
}

.trace-copy h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
}

.trace-copy span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.35;
}

.trace-actions {
  flex: 1 1 560px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.trace-button {
  appearance: none;
  border: 1px solid rgba(139, 210, 255, 0.22);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--text);
  background: rgba(103, 215, 255, 0.06);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

.trace-button:hover,
.trace-button:focus-visible,
.trace-button.active {
  outline: none;
  border-color: rgba(141, 255, 202, 0.74);
  background: rgba(141, 255, 202, 0.11);
  color: var(--green);
  box-shadow: 0 0 18px rgba(141, 255, 202, 0.14);
}

.tree-panel {
  position: relative;
  padding: 16px;
  border: 1px solid rgba(139, 210, 255, 0.16);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.018)), rgba(8, 14, 28, 0.54);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06), 0 12px 30px rgba(0, 0, 0, 0.22);
}

.tree-panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 0%, rgba(103, 215, 255, 0.08), transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(173, 140, 255, 0.07), transparent 30%);
}


.tree,
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  min-width: max-content;
  padding: 2px 6px 12px;
}

.tree li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 4px;
}

.tree ul {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  margin-top: 5px;
  padding-top: 10px;
}

.tree ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 10px;
  border-left: 2px solid rgba(139, 210, 255, 0.20);
  transform: translateX(-1px);
}

.tree ul > li {
  padding-top: 8px;
}

.tree ul > li::before,
.tree ul > li::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 8px;
  border-top: 2px solid rgba(139, 210, 255, 0.20);
}

.tree ul > li::before {
  right: 50%;
}

.tree ul > li::after {
  left: 50%;
  border-left: 2px solid rgba(139, 210, 255, 0.20);
}

.tree ul > li:first-child:not(:only-child)::before {
  border-top: none;
}

.tree ul > li:last-child:not(:only-child)::after {
  border-top: none;
  border-left: none;
}

.tree ul > li:only-child::before {
  display: none;
}

.tree ul > li:only-child::after {
  left: 50%;
  width: 0;
  border-top: none;
  border-left: 2px solid rgba(139, 210, 255, 0.20);
  transform: translateX(-1px);
}

.tree > li {
  padding-top: 0;
}

.tree > li::before,
.tree > li::after {
  display: none;
}

.tree.signal-spine,
.tree .signal-spine,
.tree .hub-flow-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.tree.signal-spine > li::before,
.tree.signal-spine > li::after,
.tree .signal-spine > li::before,
.tree .signal-spine > li::after,
.tree .hub-flow-row > li::before,
.tree .hub-flow-row > li::after {
  display: none;
}

.tree.signal-spine > .pipeline-stage,
.tree.signal-spine > .pipeline-input,
.tree.signal-spine > .pipeline-hub,
.tree .signal-spine > .pipeline-stage,
.tree .signal-spine > .pipeline-input,
.tree .signal-spine > .pipeline-hub,
.tree .hub-flow-row > .pipeline-input,
.tree .hub-flow-row > .pipeline-hub {
  padding-top: 0;
}

.tree.signal-spine > .pipeline-stage > .node,
.tree.signal-spine > .pipeline-input > .node,
.tree .signal-spine > .pipeline-stage > .node,
.tree .signal-spine > .pipeline-input > .node,
.tree .hub-flow-row > .pipeline-input > .node {
  min-width: 240px;
  max-width: 300px;
}

.tree.signal-spine > .pipeline-hub > .hub,
.tree .signal-spine > .pipeline-hub > .hub,
.tree .hub-flow-row > .pipeline-hub > .hub {
  min-width: min(78vw, 380px);
}

.flow-bridge {
  min-width: auto;
  min-height: 28px;
  padding: 0;
  pointer-events: none;
}

.flow-bridge span {
  width: 2px;
  height: 28px;
  display: block;
  opacity: 0;
}

.tree.spotlight-active .flow-bridge {
  opacity: 0.46;
}

.trace-bridge-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.flow-bridge-line,
.trace-bridge-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.flow-bridge-line {
  stroke: rgba(141, 255, 202, 0.30);
}

.trace-bridge-line {
  stroke: rgba(103, 215, 255, 0.94);
}

.js-pending .tree-item:not([data-open="true"]) > ul,
.tree-item.collapsed > ul {
  display: none;
}

.tree-item.keeps-next-stage.collapsed > .signal-spine {
  display: flex;
}

.tree.spotlight-active .tree-item.path-active > .node {
  position: relative;
  z-index: 2;
  border-color: color-mix(in srgb, var(--box-stroke) 88%, white 12%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24), 0 0 8px color-mix(in srgb, var(--box-stroke) 22%, transparent);
}

.tree.spotlight-active .tree-item.selected-item > .node {
  transform: translateY(-2px) scale(1.015);
}

.tree.spotlight-active .tree-item.flow-parent > ul::before,
.tree.spotlight-active .tree-item.level-flow-parent > ul::before {
  border-left-color: rgba(103, 215, 255, 0.94);
}

.tree.spotlight-active .tree-item.flow-child::after,
.tree.spotlight-active .tree-item.level-flow-child::after {
  border-left: 2px solid rgba(103, 215, 255, 0.94);
}

.tree.spotlight-active .tree-item.flow-child.signal-left::after,
.tree.spotlight-active .tree-item.flow-child.signal-right::before,
.tree.spotlight-active .tree-item.flow-child.signal-only::after,
.tree.spotlight-active .tree-item.signal-before::before,
.tree.spotlight-active .tree-item.signal-after::after {
  border-top-color: rgba(103, 215, 255, 0.94);
}

.tree.spotlight-active .tree-item.level-flow-child::before,
.tree.spotlight-active .tree-item.level-flow-child::after {
  border-top-color: rgba(103, 215, 255, 0.94);
}

.node {
  --box-fill: rgba(103, 215, 255, 0.10);
  --box-stroke: var(--cyan);
  position: relative;
  isolation: isolate;
  min-width: 138px;
  max-width: 260px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--box-stroke) 54%, rgba(255,255,255,.10));
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.016)), var(--box-fill);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.20);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  cursor: default;
  transition: transform 120ms ease, border-color 120ms ease;
}

.node.has-children {
  cursor: pointer;
}

.stage-badge {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--box-stroke) 58%, white 6%);
  border-radius: 999px;
  color: var(--box-stroke);
  background: color-mix(in srgb, var(--box-stroke) 16%, rgba(5, 9, 20, 0.82));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
}

.node-label {
  min-width: 0;
}

.disclosure-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--box-stroke) 42%, transparent);
  border-radius: 999px;
  color: var(--box-stroke);
  background: color-mix(in srgb, var(--box-stroke) 12%, transparent);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-1px);
}

.disclosure-icon::before {
  content: "▾";
}

.tree-item.collapsed > .node.has-children > .disclosure-icon::before {
  content: "▸";
}

.node:hover,
.node:focus-visible {
  outline: none;
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--box-stroke) 86%, white 8%);
  box-shadow: 0 8px 18px rgba(0,0,0,.28), 0 0 8px color-mix(in srgb, var(--box-stroke), transparent 86%);
}

.root {
  --box-fill: rgba(103, 215, 255, 0.14);
  --box-stroke: var(--cyan);
  min-width: min(100%, 370px);
  min-height: 46px;
  font-size: 0.9rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.30), 0 0 26px rgba(103,215,255,.13), inset 0 1px rgba(255,255,255,.09);
}

.root::after {
  content: "";
  position: absolute;
  inset: -13px;
  z-index: -1;
  border-radius: 24px;
  border: 1px solid rgba(103,215,255,.18);
  box-shadow: 0 0 24px rgba(103,215,255,.10), inset 0 0 18px rgba(103,215,255,.05);
  pointer-events: none;
}

.group { --box-fill: rgba(215, 231, 246, 0.055); --box-stroke: var(--silver); }
.entry { --box-fill: rgba(103, 215, 255, 0.09); --box-stroke: var(--cyan); }
.pi { --box-fill: rgba(173, 140, 255, 0.12); --box-stroke: var(--violet); }

.hub {
  --box-fill: rgba(141, 255, 202, 0.13);
  --box-stroke: var(--green);
  min-width: min(86vw, 380px);
  min-height: 58px;
  padding: 10px 18px;
  border-radius: 23px;
  font-size: 1rem;
  letter-spacing: -0.035em;
  box-shadow: 0 8px 22px rgba(0,0,0,.30), 0 0 14px rgba(141,255,202,.12);
}

.hub::after {
  content: "";
  position: absolute;
  inset: -14px;
  z-index: -1;
  border-radius: 30px;
  border: 1px solid rgba(141,255,202,.22);
  box-shadow: 0 0 16px rgba(141,255,202,.10);
  pointer-events: none;
}
.tool { --box-fill: rgba(103, 215, 255, 0.11); --box-stroke: var(--cyan); }
.script { --box-fill: rgba(141, 255, 202, 0.085); --box-stroke: #70ead8; }
.service { --box-fill: rgba(103, 215, 255, 0.095); --box-stroke: var(--cyan); }
.ai { --box-fill: rgba(141, 255, 202, 0.10); --box-stroke: var(--green); }
.external { --box-fill: rgba(173, 140, 255, 0.12); --box-stroke: var(--violet); }
.device { --box-fill: rgba(111, 168, 255, 0.12); --box-stroke: var(--blue); }
.plug { --box-fill: rgba(255, 159, 102, 0.12); --box-stroke: var(--orange); }
.compute { --box-fill: rgba(215, 231, 246, 0.07); --box-stroke: var(--silver); }

.diagram-tooltip {
  --tooltip-x: 12px;
  --tooltip-y: 12px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  max-width: 380px;
  padding: 12px 14px;
  border: 1px solid rgba(103, 215, 255, 0.42);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,.09), rgba(255,255,255,.025)), rgba(8, 14, 28, 0.94);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.36), 0 0 18px rgba(103, 215, 255, 0.10);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(var(--tooltip-x), calc(var(--tooltip-y) + 6px), 0);
  transition: opacity 100ms ease;
}

.diagram-tooltip.visible {
  opacity: 1;
  transform: translate3d(var(--tooltip-x), var(--tooltip-y), 0);
}

@media (max-width: 760px) {
  .shell { width: min(calc(100vw - 20px), 1500px); max-width: calc(100vw - 20px); padding: 10px 0; }
  .corner-label { top: 18px; left: 20px; right: 20px; min-height: 54px; flex-wrap: wrap; border-radius: 20px; padding: 8px 10px; }
  .brand { flex: 1 1 min(100%, 280px); }
  .mark { width: 34px; height: 34px; }
  .header-actions { flex: 0 0 auto; margin-left: auto; padding-left: 10px; }
  .toolbar-button { padding: 8px 10px; font-size: 0.75rem; }
  .trace-panel { align-items: stretch; }
  .trace-actions { justify-content: flex-start; }
  .trace-button { flex: 1 1 160px; }
  .stage-badge { width: 22px; height: 22px; font-size: 0.75rem; }
  .diagram-card { min-height: calc(100vh - 20px); border-radius: 24px; padding: 10px; }
  .diagram-frame { min-height: calc(100vh - 40px); border-radius: 18px; padding: 124px 12px 18px; }
  .tree-panel { padding: 14px; }
  .tree { padding-inline: 6px; }
  .tree ul { gap: 6px; padding-top: 20px; }
  .tree ul::before { height: 20px; }
  .tree ul > li { padding-inline: 4px; padding-top: 16px; }
  .tree ul > li::before,
  .tree ul > li::after { height: 16px; }
  .node { min-width: 124px; max-width: 230px; font-size: 0.8rem; padding: 8px; }
}
