.ds-demo {
  --ds-surface: var(--quote-bg);
  --ds-border: var(--table-border-color);
  --ds-active: color-mix(in srgb, var(--links) 22%, var(--bg));
  --ds-active-border: var(--links);
  margin: 1.5rem 0 2.25rem;
  padding: 1rem;
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  background: var(--ds-surface);
}

.ds-demo-stage {
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 1rem 0.25rem;
  overflow: hidden;
}

.ds-demo-visual {
  width: 100%;
  text-align: center;
  transition: transform 180ms ease, opacity 180ms ease;
}

.ds-demo-visual.is-changing {
  transform: translateY(-4px);
  opacity: 0.55;
}

.ds-row,
.ds-cells,
.ds-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin: 0.55rem 0;
}

.ds-node,
.ds-cell,
.ds-range {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--ds-border);
  border-radius: 7px;
  background: var(--bg);
  font-family: var(--mono-font);
  font-variant-numeric: tabular-nums;
}

.ds-node.active,
.ds-cell.active,
.ds-range.active {
  border-color: var(--ds-active-border);
  background: var(--ds-active);
  font-weight: 600;
}

.ds-cell.empty { color: var(--icons); }
.ds-arrow { color: var(--icons); font-size: 1.25rem; }
.ds-label { margin: 0.35rem 0; color: var(--icons); font-family: var(--mono-font); }

.ds-demo-status {
  min-height: 1.5rem;
  margin: 0.5rem 0;
  text-align: center;
  color: var(--icons);
}

.ds-demo-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.ds-demo-controls button {
  min-height: 40px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--ds-border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  font: inherit;
}

.ds-demo-controls button:hover:not(:disabled) { background: var(--table-header-bg); }
.ds-demo-controls button:disabled { opacity: 0.5; cursor: not-allowed; }
.ds-demo-progress { margin-top: 0.65rem; text-align: center; color: var(--icons); font-size: 0.85em; }

@media (max-width: 480px) {
  .ds-demo { padding: 0.75rem; }
  .ds-node, .ds-cell { min-width: 36px; min-height: 36px; padding: 0.25rem; }
  .ds-demo-controls button { flex: 1 1 28%; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-demo-visual { transition: none; }
}
