.network-ecosystem-intro {
  margin: 20px 0 14px;
}

.network-ecosystem-intro p {
  max-width: 920px;
  margin-bottom: 0;
  color: var(--text-secondary);
}

.network-ecosystem-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--text-secondary);
  list-style: none;
}

.network-ecosystem-summary li {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.network-ecosystem-summary strong {
  color: var(--text-primary);
  font-weight: 600;
}

.network-ecosystem-demo-shell {
  margin: 24px 0 28px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: rgba(12, 12, 16, 0.94);
}

.network-ecosystem-demo-shell > p {
  margin: 0;
  padding: 18px;
  color: var(--text-muted);
  font-size: 14px;
}

.ecosystem-demo {
  --ecosystem-node: #60a5fa;
  --ecosystem-data: #34d399;
  --ecosystem-module: #f59e0b;
  --ecosystem-evidence: #f472b6;
  --ecosystem-focus: #f5f5f7;
  --ecosystem-panel-rule: rgba(134, 134, 139, 0.22);

  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.72fr);
  grid-template-areas:
    "toolbar toolbar"
    "graph details"
    "legend events";
  color: var(--text-primary);
}

.ecosystem-demo,
.ecosystem-demo * {
  box-sizing: border-box;
}

.ecosystem-demo section {
  padding: 0;
}

.ecosystem-demo h2 {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
}

.ecosystem-demo p,
.ecosystem-demo li,
.ecosystem-demo dt,
.ecosystem-demo dd,
.ecosystem-demo input,
.ecosystem-demo button {
  font-size: 13px;
}

.ecosystem-demo__toolbar {
  grid-area: toolbar;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--ecosystem-panel-rule);
  background: rgba(22, 22, 27, 0.82);
}

.ecosystem-demo__mode-controls,
.ecosystem-demo__scenario-controls,
.ecosystem-demo__module-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ecosystem-demo__mode-controls,
.ecosystem-demo__scenario-controls {
  flex: 0 1 auto;
}

.ecosystem-demo__module-controls {
  flex: 1 1 300px;
  justify-content: flex-end;
}

.ecosystem-demo__module-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 320px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.3;
}

.ecosystem-demo button,
.ecosystem-demo input {
  min-height: 34px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  font-family: var(--font-sans);
  line-height: 1.2;
}

.ecosystem-demo button {
  min-width: 0;
  padding: 0 12px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ecosystem-demo button:hover {
  color: var(--text-primary);
  border-color: rgba(134, 134, 139, 0.55);
  background: rgba(255, 255, 255, 0.09);
}

.ecosystem-demo button[aria-pressed="true"] {
  color: var(--text-primary);
  border-color: rgba(96, 165, 250, 0.72);
  background: rgba(96, 165, 250, 0.18);
}

.ecosystem-demo input {
  width: 100%;
  min-width: 150px;
  padding: 0 10px;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.28);
}

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

.ecosystem-demo__graph-panel {
  grid-area: graph;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px;
  border-right: 1px solid var(--ecosystem-panel-rule);
  border-bottom: 1px solid var(--ecosystem-panel-rule);
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(8, 9, 13, 0.46);
  background-size: 34px 34px;
}

.ecosystem-demo__graph-panel svg {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-sans);
}

.ecosystem-demo__edges {
  color: rgba(148, 163, 184, 0.72);
}

.ecosystem-demo__edge line {
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.ecosystem-demo__edge text {
  fill: var(--text-muted);
  paint-order: stroke;
  stroke: rgba(8, 9, 13, 0.96);
  stroke-linejoin: round;
  stroke-width: 4px;
}

.ecosystem-demo__item {
  cursor: pointer;
}

.ecosystem-demo__item circle,
.ecosystem-demo__item rect,
.ecosystem-demo__item polygon {
  transition: fill 0.15s ease, filter 0.15s ease, stroke 0.15s ease, stroke-width 0.15s ease;
  vector-effect: non-scaling-stroke;
}

.ecosystem-demo__item text {
  fill: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  paint-order: stroke;
  pointer-events: none;
  stroke: rgba(8, 9, 13, 0.96);
  stroke-linejoin: round;
  stroke-width: 4px;
}

.ecosystem-demo__item[data-item-kind="node"] circle {
  fill: rgba(96, 165, 250, 0.14);
  stroke: var(--ecosystem-node);
}

.ecosystem-demo__item[data-item-kind="data"] polygon {
  fill: rgba(52, 211, 153, 0.14);
  stroke: var(--ecosystem-data);
}

.ecosystem-demo__item[data-item-kind="module"] rect {
  fill: rgba(245, 158, 11, 0.15);
  stroke: var(--ecosystem-module);
}

.ecosystem-demo__item[data-item-kind="evidence"] polygon {
  fill: rgba(244, 114, 182, 0.14);
  stroke: var(--ecosystem-evidence);
}

.ecosystem-demo__item:hover circle,
.ecosystem-demo__item:hover rect,
.ecosystem-demo__item:hover polygon {
  filter: drop-shadow(0 0 8px currentColor);
  stroke-width: 3px;
}

.ecosystem-demo__item:focus-visible {
  outline: none;
}

.ecosystem-demo__item:focus-visible circle,
.ecosystem-demo__item:focus-visible rect,
.ecosystem-demo__item:focus-visible polygon {
  filter: drop-shadow(0 0 10px rgba(245, 245, 247, 0.58));
  stroke: var(--ecosystem-focus);
  stroke-width: 4px;
}

.ecosystem-demo__item[data-selected="true"] circle,
.ecosystem-demo__item[data-selected="true"] rect,
.ecosystem-demo__item[data-selected="true"] polygon {
  filter: drop-shadow(0 0 12px rgba(245, 245, 247, 0.42));
  stroke: var(--ecosystem-focus);
  stroke-width: 4px;
}

.ecosystem-demo__legend {
  grid-area: legend;
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--ecosystem-panel-rule);
}

.ecosystem-demo__legend ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0;
  padding: 0;
  color: var(--text-secondary);
  list-style: none;
}

.ecosystem-demo__legend li {
  min-width: 0;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(134, 134, 139, 0.16);
}

.ecosystem-demo__legend strong {
  display: block;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.35;
}

.ecosystem-demo__legend span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ecosystem-demo__legend span:first-of-type {
  color: var(--text-secondary);
}

.ecosystem-demo__details {
  grid-area: details;
  min-width: 0;
  padding: 14px;
  border-bottom: 1px solid var(--ecosystem-panel-rule);
}

.ecosystem-demo__details p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.ecosystem-demo__details dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
}

.ecosystem-demo__details dt {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
}

.ecosystem-demo__details dd {
  min-width: 0;
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ecosystem-demo__events {
  grid-area: events;
  min-width: 0;
  padding: 14px;
}

.ecosystem-demo__events ol {
  max-height: 260px;
  margin: 0;
  padding-left: 22px;
  overflow-y: auto;
  color: var(--text-muted);
}

.ecosystem-demo__events li {
  margin: 0 0 10px;
  padding-left: 4px;
}

.ecosystem-demo__events li:last-child {
  margin-bottom: 0;
}

.ecosystem-demo__events strong,
.ecosystem-demo__events span {
  display: block;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ecosystem-demo__events strong {
  color: var(--text-primary);
  font-size: 13px;
}

.ecosystem-demo__events span {
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .ecosystem-demo {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "toolbar"
      "graph"
      "legend"
      "details"
      "events";
  }

  .ecosystem-demo__toolbar,
  .ecosystem-demo__module-controls {
    justify-content: flex-start;
  }

  .ecosystem-demo__graph-panel,
  .ecosystem-demo__legend {
    border-right: 0;
  }

  .ecosystem-demo__legend,
  .ecosystem-demo__details {
    border-bottom: 1px solid var(--ecosystem-panel-rule);
  }
}

@media (max-width: 560px) {
  .network-ecosystem-demo-shell {
    margin-right: -2px;
    margin-left: -2px;
  }

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

  .ecosystem-demo__toolbar {
    gap: 8px;
    padding: 10px;
  }

  .ecosystem-demo__mode-controls,
  .ecosystem-demo__scenario-controls,
  .ecosystem-demo__module-controls {
    width: 100%;
  }

  .ecosystem-demo button {
    flex: 1 1 auto;
    min-height: 36px;
    white-space: normal;
  }

  .ecosystem-demo__module-controls label {
    width: 100%;
    max-width: none;
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }

  .ecosystem-demo input {
    min-width: 0;
  }

  .ecosystem-demo__graph-panel {
    padding: 10px;
  }

  .ecosystem-demo__graph-panel svg {
    min-width: 640px;
  }

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

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

  .ecosystem-demo__details dt {
    margin-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ecosystem-demo button,
  .ecosystem-demo__item circle,
  .ecosystem-demo__item rect,
  .ecosystem-demo__item polygon {
    transition: none;
  }
}
