#stage,
#playground {
  --neo-emerald-300: #6ee7b7;
  --neo-emerald-400: #49c799;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(52, 183, 127, 0.4);
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Sora', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --text-white: #ffffff;
  --text-secondary: #94a3b8;
  --stage-bg: linear-gradient(180deg, #091325 0%, #060b14 100%);
  --stage-shadow: 0 25px 60px -20px rgba(0, 0, 0, 0.85);
  --stage-chip: rgba(255, 255, 255, 0.05);
  --stage-bar: rgba(12, 23, 42, 0.75);
  --stage-bar-border: rgba(255, 255, 255, 0.06);
  --stage-pill: rgba(255, 255, 255, 0.03);
  --stage-canvas: #070e1b;
  --stage-canvas-border: rgba(255, 255, 255, 0.05);
  --stage-node-hover: #12213a;
  --stage-node-fire: #183354;
  --stage-node-pull-hover: #0c233c;
  --stage-node-pull-fire: #0e2a47;
  --play-bg: #060b14;
  --play-box: #050912;
  --play-top: #0b1322;
  --play-lang: rgba(6, 11, 20, 0.7);
  --play-lang-active: rgba(255, 255, 255, 0.1);
  --play-code: #03070f;
  --play-preview: #060b14;
  --code-text: #cbd5e1;
  --code-k: #6ee7b7;
  --code-s: #fde047;
  --code-n: #93c5fd;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

#playground {
  background: var(--play-bg);
  border-radius: 24px;
}

.stage-section {
  margin-top: 0;
  background: var(--stage-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.5rem 2rem;
  box-shadow: var(--stage-shadow);
  position: relative;
}

.stage-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.stage-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-white);
}

.stage-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stage-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.stage-btn {
  padding: 0.4rem 0.8rem;
  background: var(--stage-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-white);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.stage-btn:hover {
  background: rgba(52, 183, 127, 0.15);
  border-color: var(--border-glow);
  color: var(--neo-emerald-300);
}

.stage-btn.is-active {
  background: rgba(52, 183, 127, 0.22);
  border-color: var(--neo-emerald-400);
  color: var(--neo-emerald-300);
}

/* Stage Sub Bar & Multi-Destination Selection */
.stage-sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.95rem;
  background: var(--stage-bar);
  border: 1px solid var(--stage-bar-border);
  border-radius: var(--radius-md);
}

.stage-dest-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.stage-dest-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 0.35rem;
}

.dest-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--stage-pill);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.18s ease;
}

.dest-pill:hover {
  border-color: var(--neo-emerald-400);
  color: var(--text-white);
}

.dest-pill.is-active {
  background: rgba(52, 183, 127, 0.16);
  border-color: var(--neo-emerald-400);
  color: var(--neo-emerald-300);
  box-shadow: 0 0 10px rgba(52, 183, 127, 0.25);
}

.dest-pill .pill-check {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--neo-emerald-400);
}

.dest-pill:not(.is-active) .pill-check {
  opacity: 0.25;
}

.stage-dest-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.fanout-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  background: rgba(94, 234, 212, 0.12);
  border: 1px solid rgba(94, 234, 212, 0.35);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #5eead4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

path.wire-dimmed {
  opacity: 0.12 !important;
  stroke-dasharray: 4 4;
}

.node-group.node-dimmed {
  opacity: 0.25;
  filter: grayscale(80%);
}

/* Vector Stage Container */
.svg-stage-container {
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--stage-canvas);
  border: 1px solid var(--stage-canvas-border);
}

.svg-stage-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
}

/* SVG Interactive Elements Styling */
.node-group {
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.node-group:hover rect.node-box {
  stroke: var(--neo-emerald-400);
  fill: var(--stage-node-hover);
}

.dest-pill.is-pull {
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}

.dest-pill.is-pull:hover {
  border-color: #38bdf8;
  color: #bae6fd;
}

.dest-pill.is-pull.is-active {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.dest-pill.is-pull .pill-check {
  color: #38bdf8;
}

.node-group.is-firing rect.node-box {
  stroke: #6ee7b7;
  fill: var(--stage-node-fire);
  filter: drop-shadow(0 0 12px rgba(52, 183, 127, 0.8));
}

.node-group.node-pull rect.node-box {
  stroke: rgba(56, 189, 248, 0.35);
}

.node-group.node-pull:hover rect.node-box {
  stroke: #38bdf8;
  fill: var(--stage-node-pull-hover);
}

.node-group.is-pulling rect.node-box {
  stroke: #38bdf8;
  fill: var(--stage-node-pull-fire);
  filter: drop-shadow(0 0 14px rgba(56, 189, 248, 0.85));
}

.section-wrap {
  padding: 5rem 0 3.5rem;
}

.section-head {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 3rem;
}

.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neo-emerald-400);
  margin-bottom: 0.65rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-white);
  line-height: 1.2;
}

.section-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-top: 0.9rem;
  line-height: 1.65;
}

.playground-box {
  margin-top: 2rem;
  background: var(--play-box);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
}

.playground-top {
  background: var(--play-top);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.workflow-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.workflow-btn {
  background: var(--stage-chip);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.workflow-btn:hover {
  color: var(--text-white);
  border-color: var(--border-glow);
}

.workflow-btn.is-active {
  background: rgba(52, 183, 127, 0.18);
  color: var(--neo-emerald-300);
  border-color: var(--neo-emerald-400);
  font-weight: 600;
}

.lang-tabs {
  display: flex;
  background: var(--play-lang);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover { color: var(--text-white); }
.lang-btn.is-active {
  background: var(--play-lang-active);
  color: var(--text-white);
  font-weight: 600;
}

.playground-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 380px;
}

.playground-code {
  padding: 1.5rem;
  border-right: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  background: var(--play-code);
  position: relative;
  overflow-x: auto;
}

.playground-preview {
  padding: 1.5rem;
  background: var(--play-preview);
  display: flex;
  flex-direction: column;
}

.copy-pill {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.copy-pill:hover {
  background: rgba(52, 183, 127, 0.2);
  border-color: var(--neo-emerald-400);
  color: var(--neo-emerald-300);
}

#playground .json-code { white-space: pre-wrap; color: var(--code-text); }
#playground .k { color: var(--code-k); }
#playground .s { color: var(--code-s); }
#playground .n { color: var(--code-n); }

html[data-theme="light"] #stage,
html[data-theme="light"] #playground {
  --neo-emerald-300: #1a6344;
  --neo-emerald-400: #279a69;
  --text-white: hsl(222 47% 11%);
  --text-secondary: hsl(215 16% 38%);
  --border-subtle: hsl(214 32% 86%);
  --border-glow: rgba(39, 154, 105, 0.45);
  --stage-bg: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
  --stage-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.28);
  --stage-chip: hsl(210 40% 96%);
  --stage-bar: hsl(210 40% 97%);
  --stage-bar-border: hsl(214 32% 88%);
  --stage-pill: #ffffff;
  --stage-canvas: #f8fafc;
  --stage-canvas-border: hsl(214 32% 88%);
  --stage-node-hover: #f8fafc;
  --stage-node-fire: #f4fbf7;
  --stage-node-pull-hover: #e0f2fe;
  --stage-node-pull-fire: #bae6fd;
  --play-bg: transparent;
  --play-box: #ffffff;
  --play-top: hsl(210 40% 97%);
  --play-lang: hsl(210 40% 96%);
  --play-lang-active: #ffffff;
  --play-code: #f8fafc;
  --play-preview: #ffffff;
  --code-text: #334155;
  --code-k: #047857;
  --code-s: #a16207;
  --code-n: #1d4ed8;
}

html[data-theme="light"] #stage .stage-btn.is-active,
html[data-theme="light"] #stage .stage-btn:hover,
html[data-theme="light"] #stage .dest-pill.is-active:not(.is-pull),
html[data-theme="light"] #playground .workflow-btn.is-active,
html[data-theme="light"] #playground .workflow-btn:hover {
  background: color-mix(in srgb, #279a69 8%, #ffffff);
  border-color: color-mix(in srgb, #279a69 32%, #dbe3ee);
  color: #134e35;
  box-shadow: none;
}

html[data-theme="light"] #stage .dest-pill .pill-check {
  color: #279a69;
}

html[data-theme="light"] #stage .node-group.is-firing rect.node-box {
  stroke: #279a69;
  filter: none;
}

html[data-theme="light"] #stage text[fill="#34b77f"],
html[data-theme="light"] #stage text[fill="#6ee7b7"],
html[data-theme="light"] #stage text[fill="#5eead4"] {
  fill: #134e35;
}

html[data-theme="light"] #stage [stroke="#34b77f"],
html[data-theme="light"] #stage [stroke="#6ee7b7"],
html[data-theme="light"] #stage [stroke="#5eead4"] {
  stroke: #1f7d54;
}

html[data-theme="light"] #stage .fanout-badge {
  color: #134e35;
  background: color-mix(in srgb, #279a69 8%, #ffffff);
  border-color: color-mix(in srgb, #279a69 28%, #dbe3ee);
}

html[data-theme="light"] #stage .stage-dest-label {
  color: #134e35 !important;
}

html[data-theme="light"] #stage .stage-dest-pills .stage-dest-label:nth-of-type(2) {
  color: #0369a1 !important;
}

html[data-theme="light"] #btn-pull-sim {
  color: #0369a1 !important;
  border-color: rgba(3, 105, 161, 0.35) !important;
}

html[data-theme="light"] #stage rect.node-box,
html[data-theme="light"] #stage rect[fill="#091426"] {
  fill: #ffffff;
  stroke: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] #stage rect[fill="#08182b"] {
  fill: #f0f9ff;
  stroke: rgba(3, 105, 161, 0.35);
}

html[data-theme="light"] #stage text[fill="#ffffff"],
html[data-theme="light"] #stage text[fill="#f1f5f9"] {
  fill: #0f172a;
}

html[data-theme="light"] #stage text[fill="#94a3b8"] {
  fill: #475569;
}

html[data-theme="light"] #stage svg > g[fill="none"] {
  stroke: rgba(15, 23, 42, 0.16);
}

html[data-theme="light"] #wf-btn-transfers {
  color: #0369a1 !important;
}


@media (max-width: 1100px) {
  .playground-split { grid-template-columns: 1fr; }
  .playground-code { border-right: none; border-bottom: 1px solid var(--border-subtle); }
}
