.viz-shell {
  --viz-line: #d5dce6;
  --viz-refuse: #a8433a;
}

.viz-shell {
  background: #ffffffd9;
  border: 1px solid var(--viz-line);
  border-radius: 25px;
  padding: 20px;
  margin-top: 20px;
}


.viz-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.viz-controls button {
  appearance: none;
  border: 0;
  background: #fff9;
  box-shadow: inset 0 1px 0 #fff, 0 2px 10px #27362e0f;
  color: var(--ink);
  border-radius: 99px;
  padding: 0.45rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.viz-controls button.primary,
.viz-controls button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on);
}

.viz-controls button:disabled { opacity: 0.45; cursor: not-allowed; }

.viz-step-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: auto;
}

.viz-stage {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viz-shell .cells {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: flex-end;
}

.viz-shell .cell {
  min-width: 2.4rem;
  text-align: center;
  border: 1px solid var(--viz-line);
  border-radius: 8px;
  padding: 0.45rem 0.35rem;
  background: #f6f8fb;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.viz-shell .cell .v { display: block; font-weight: 650; }
.viz-shell .cell .i { display: block; color: var(--muted); font-size: 0.7rem; margin-top: 0.15rem; }

.viz-shell .cell.on { background: var(--tint); border-color: var(--accent); transform: translateY(-2px); }
.viz-shell .cell.win { background: #d6e3f7; border-color: var(--accent); }
.viz-shell .cell.skip { opacity: 0.4; }
.viz-shell .cell.lo { box-shadow: inset 0 -3px 0 #3b82f6; }
.viz-shell .cell.hi { box-shadow: inset 0 -3px 0 var(--viz-refuse); }
.viz-shell .cell.mid { background: #fff3cd; border-color: #c9a227; }

.viz-shell .pointers {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.viz-shell .pointers strong { color: var(--ink); }

.grid2d {
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}

.grid2d .gcell {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--viz-line);
  border-radius: 4px;
  font-size: 0.75rem;
  background: #f6f8fb;
}

.grid2d .gcell.fill { background: var(--tint); border-color: var(--accent); font-weight: 650; }
.grid2d .gcell.pick { background: #fff3cd; border-color: #c9a227; }

.svg-wrap {
  width: 100%;
  overflow-x: auto;
}

.svg-wrap svg { max-width: 100%; height: auto; display: block; }

.node-c {
  fill: #fff;
  stroke: var(--viz-line);
  stroke-width: 2;
}

.node-c.active { fill: #d6e3f7; stroke: var(--accent); }
.node-c.done { fill: #e6eef9; stroke: var(--strong); }
.node-c.visit { fill: #fff3cd; stroke: #c9a227; }

.edge-c { stroke: #aebfd5; stroke-width: 2; fill: none; }
.edge-c.active { stroke: var(--accent); stroke-width: 3; }

.bucket {
  width: 120px;
  height: 160px;
  border: 2px solid var(--accent);
  border-radius: 8px 8px 4px 4px;
  position: relative;
  overflow: hidden;
  background: #fff;
}

.bucket .fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #9fb9e6, var(--strong));
  transition: height 0.25s;
}

.viz-shell .bits {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.viz-shell .bit {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 3px;
  border: 1px solid var(--viz-line);
  background: #fff;
  font-size: 0.65rem;
  display: grid;
  place-items: center;
}

.viz-shell .bit.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.choose-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.choose-list li {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--viz-line);
  background: #fff;
  font-size: 0.92rem;
}

.choose-list li.yes { border-left: 3px solid var(--accent); background: var(--tint); }
.choose-list li.no { border-left: 3px solid var(--viz-refuse); background: #f8eceb; }

.hub-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.hub-grid a {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--viz-line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}

.hub-grid a:hover { border-color: var(--accent); background: var(--tint); }
.hub-grid strong { display: block; margin-bottom: 0.2rem; }
.hub-grid span { color: var(--muted); font-size: 0.88rem; }

.narration {
  margin-top: 0.5rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: #eef3fb;
  border: 1px solid #d3dff2;
  color: var(--ink);
  font-size: 0.95rem;
  min-height: 2.8rem;
}

@media (prefers-reduced-motion: reduce) {
  .viz-shell *,
  .viz-shell *::before,
  .viz-shell *::after {
    transition: none !important;
    animation: none !important;
  }
}
