/* Array, bar, stack, and queue visualizations for algorithm simulations. */

.array-row {
  display: flex; justify-content: center; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  min-height: 88px;
}

/* 2D matrix grid */
.matrix-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.matrix-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.matrix-caption .muted-cap { color: var(--muted); font-weight: 500; }
.matrix-grid {
  display: grid; gap: 6px; align-items: center; justify-items: center;
  grid-template-columns: 28px repeat(var(--cols, 3), 52px);
}
.matrix-corner { width: 28px; height: 20px; }
.matrix-colh, .matrix-rowh {
  font: 700 10px/1 var(--mono); color: var(--stone); letter-spacing: .3px; text-transform: uppercase;
}
.matrix-colh { height: 20px; display: grid; place-items: center; }
.matrix-rowh { width: 28px; text-align: center; }
.matrix-colh.active, .matrix-rowh.active { color: var(--brand-tag); }
.matrix-grid .cell { width: 52px; }
.matrix-grid .cell .idx { font-size: 9px; }
.cell.row-band { background: rgba(126,162,255,.1); }
.cell.col-band { background: rgba(242,160,92,.1); }
.cell.visited { border-color: var(--brand-green); background: rgba(95,208,143,.14); }
.output-tray {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center;
  min-height: 34px; max-width: 100%;
}
.output-tray .out-label {
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel); margin-right: 4px;
}
.output-tray .out-chip {
  font: 700 12px/1 var(--mono); padding: 5px 8px; border-radius: var(--r-full);
  background: rgba(126,162,255,.16); color: var(--brand-tag); border: 1px solid rgba(126,162,255,.35);
}
.output-tray .out-chip.latest { background: rgba(95,208,143,.2); color: var(--brand-green); border-color: rgba(95,208,143,.45); box-shadow: 0 0 0 2px rgba(95,208,143,.18); }

.cell {
  width: 56px; text-align: center; position: relative;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-md);
  box-shadow: var(--shadow-soft); transition: transform .25s, border-color .25s, background .25s, box-shadow .25s;
}
.cell .idx {
  display: block; font: 600 10px/1.2 var(--sans); letter-spacing: .4px; text-transform: uppercase;
  color: var(--stone); padding: 6px 0 0;
}
.cell .v {
  font: 600 22px/1 var(--mono); padding: 10px 0 12px; color: var(--ink);
}
.cell.probe { border-color: var(--brand-tag); background: rgba(126,162,255,.16); box-shadow: 0 0 0 3px rgba(126,162,255,.18); }
.cell.match { border-color: var(--brand-green); background: rgba(95,208,143,.16); box-shadow: 0 0 0 3px rgba(95,208,143,.2); }
.cell.discard { opacity: .38; }
.cell.sorted { border-color: var(--brand-green-deep); background: rgba(0,180,138,.08); }
.cell.swap-a { border-color: var(--orange); background: rgba(245,90,60,.08); transform: translateY(-6px); }
.cell.swap-b { border-color: var(--brand-tag); background: rgba(55,114,207,.08); transform: translateY(-6px); }
.cell.min { border-color: var(--brand-green); background: rgba(0,212,164,.1); }
.cell.pivot { border-color: var(--brand-warn); background: rgba(195,125,13,.1); }

.ptr-row {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 28px; margin-bottom: 4px;
}
.ptr {
  font: 600 11px/1 var(--mono); color: var(--on-accent); background: var(--brand-tag); padding: 4px 8px;
  border-radius: var(--r-full); min-width: 56px; text-align: center;
}
.ptr.lo { background: var(--brand-tag); }
.ptr.mid { background: var(--brand-green-deep); color: var(--on-accent); }
.ptr.hi { background: var(--orange); }
.ptr.i { background: var(--brand-tag); }
.ptr.target { background: var(--steel); color: var(--on-accent); }

.bars {
  display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 160px; padding: 8px 0;
}
.bar {
  width: 36px; border-radius: 4px 4px 0 0; background: var(--surface-soft); border: 1px solid var(--hairline);
  display: flex; align-items: flex-end; justify-content: center; position: relative;
  transition: height .35s ease, background .25s, border-color .25s, transform .25s;
}
.bar span {
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  font: 600 12px/1 var(--mono); color: var(--steel);
}
.bar.probe { background: rgba(55,114,207,.55); border-color: var(--brand-tag); }
.bar.swap-a { background: rgba(245,90,60,.65); border-color: var(--orange); transform: translateY(-4px); }
.bar.swap-b { background: rgba(55,114,207,.65); border-color: var(--brand-tag); transform: translateY(-4px); }
.bar.sorted { background: rgba(0,212,164,.55); border-color: var(--brand-green-deep); }
.bar.min { background: rgba(0,212,164,.45); border-color: var(--brand-green); }

.stack-col, .queue-row {
  display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 180px;
}
.stack-col { flex-direction: column-reverse; }
.queue-row { flex-direction: row; }

.slot {
  min-width: 72px; padding: 14px 16px; text-align: center; font: 600 20px/1 var(--mono);
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-md);
  box-shadow: var(--shadow-soft); color: var(--ink); animation: var-pop .35s cubic-bezier(.2,1.3,.4,1);
}
.slot.front, .slot.top { border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(0,212,164,.15); }
.slot.leaving { opacity: .35; transform: scale(.92); }
.ds-labels {
  display: flex; justify-content: space-between; width: min(420px, 100%); margin: 0 auto 8px;
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--stone);
}
.ds-meta {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 8px;
  font: 500 13px/1.4 var(--mono); color: var(--steel);
}
.ds-meta b { color: var(--ink); }

/* Student-driven stack / queue playground */
.ds-play {
  display: grid; gap: 16px;
}
.ds-play-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between;
}
.ds-play-ops {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.ds-play-ops label {
  display: grid; gap: 6px;
  font: 600 12px/1 var(--sans); letter-spacing: .3px; text-transform: uppercase; color: var(--steel);
}
.ds-play-ops input[type="number"] {
  width: 88px; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font: 700 16px/1 var(--mono);
}
.ds-play-ops input[type="number"]:focus {
  outline: 2px solid rgba(126,162,255,.45); outline-offset: 1px; border-color: var(--brand-tag);
}
.ds-play-stage {
  border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--surface);
  min-height: 260px; padding: 20px 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 16px 16px;
}
.ds-play-status {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid rgba(126,162,255,.28); background: rgba(126,162,255,.12);
  font-size: 15px; color: var(--slate);
}
.ds-play-status.warn {
  border-color: rgba(255,138,125,.35); background: rgba(255,138,125,.12);
}
.ds-play-status.good {
  border-color: rgba(95,208,143,.4); background: rgba(95,208,143,.12);
}
.ds-play-status .txt { min-height: 1.4em; }
.ds-play .queue-row, .ds-play .stack-col { min-height: 140px; flex-wrap: wrap; }
.ds-play .stack-col { flex-wrap: nowrap; }

/* Binary search tree */
.bst-stage { min-height: 340px; gap: 12px; justify-content: flex-start; }
.bst-wrap {
  width: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.bst-canvas {
  width: 100%; overflow: auto; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--canvas);
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 14px 14px;
}
.bst-svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.bst-edge {
  stroke: var(--steel); stroke-width: 2; fill: none; opacity: .55;
  transition: stroke .25s, opacity .25s, stroke-width .25s;
}
.bst-edge.on-path { stroke: var(--brand-tag); opacity: 1; stroke-width: 2.5; }
.bst-edge.gone { opacity: .15; stroke-dasharray: 4 4; }
.bst-node {
  cursor: default; transition: transform .25s;
}
.bst-node circle {
  fill: var(--surface-soft); stroke: var(--hairline); stroke-width: 2;
  transition: fill .25s, stroke .25s, filter .25s;
}
.bst-node text {
  fill: var(--ink); font: 700 14px/1 var(--mono); text-anchor: middle;
  dominant-baseline: central; pointer-events: none;
}
.bst-node.path circle {
  fill: rgba(126,162,255,.18); stroke: var(--brand-tag);
  filter: drop-shadow(0 0 0 3px rgba(126,162,255,.2));
}
.bst-node.focus circle {
  fill: rgba(126,162,255,.28); stroke: var(--brand-tag); stroke-width: 3;
}
.bst-node.visit circle {
  fill: rgba(95,208,143,.22); stroke: var(--brand-green); stroke-width: 2.5;
}
.bst-node.visit text { fill: var(--brand-green); }
.bst-node.successor circle {
  fill: rgba(242,160,92,.22); stroke: var(--brand-warn); stroke-width: 2.5;
}
.bst-node.successor text { fill: var(--brand-warn); }
.bst-node.ghost circle {
  fill: rgba(255,138,125,.18); stroke: var(--brand-error); stroke-width: 2.5;
  stroke-dasharray: 4 3;
}
.bst-node.ghost text { fill: var(--brand-error); }
.bst-node.inserting circle {
  fill: rgba(95,208,143,.28); stroke: var(--brand-green); stroke-width: 3;
  animation: var-pop .4s cubic-bezier(.2,1.3,.4,1);
}
.bst-node.inserting text { fill: var(--brand-green); }
.bst-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center;
  font: 600 11px/1 var(--sans); letter-spacing: .3px; text-transform: uppercase; color: var(--steel);
}
.bst-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 5px; vertical-align: -1px; border: 2px solid;
}
.bst-legend .lg-path i { background: rgba(126,162,255,.3); border-color: var(--brand-tag); }
.bst-legend .lg-visit i { background: rgba(95,208,143,.3); border-color: var(--brand-green); }
.bst-legend .lg-succ i { background: rgba(242,160,92,.3); border-color: var(--brand-warn); }
.bst-legend .lg-gone i { background: rgba(255,138,125,.25); border-color: var(--brand-error); }
.bst-order {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center;
  min-height: 34px; width: 100%;
}
.bst-order .out-label {
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel); margin-right: 4px;
}
.bst-order .chip {
  font: 700 13px/1 var(--mono); padding: 6px 9px; border-radius: var(--r-full);
  background: rgba(126,162,255,.14); color: var(--brand-tag); border: 1px solid rgba(126,162,255,.35);
  animation: var-pop .35s cubic-bezier(.2,1.3,.4,1);
}
.bst-order .chip.latest {
  background: rgba(95,208,143,.2); color: var(--brand-green); border-color: rgba(95,208,143,.45);
  box-shadow: 0 0 0 2px rgba(95,208,143,.18);
}
.ds-play .bst-canvas { min-height: 220px; }
.ds-play-ops .bst-trav {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
}

/* Linked lists */
.ll-stage { min-height: 280px; gap: 12px; justify-content: flex-start; }
.ll-wrap { width: 100%; display: grid; gap: 12px; justify-items: center; }
.ll-legend {
  display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center;
  font: 600 12px/1.2 var(--sans); color: var(--steel);
}
.ll-legend i {
  display: inline-block; width: 12px; height: 12px; border-radius: 4px;
  margin-right: 6px; vertical-align: -1px; border: 1px solid transparent;
}
.ll-legend .lg-head i { background: rgba(126,162,255,.3); border-color: var(--brand-tag); }
.ll-legend .lg-focus i { background: rgba(95,208,143,.3); border-color: var(--brand-green); }
.ll-legend .lg-path i { background: rgba(242,160,92,.25); border-color: var(--brand-warn); }
.ll-scroll {
  width: 100%; overflow-x: auto; padding: 8px 4px 12px;
}
.ll-row {
  display: inline-flex; align-items: center; gap: 0; min-height: 110px;
  padding: 8px 12px;
}
.ll-node {
  position: relative; min-width: 72px; padding: 12px 14px 14px;
  border-radius: 12px; text-align: center;
  background: var(--surface-soft); border: 1px solid var(--hairline);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.ll-node .val {
  font: 700 20px/1 var(--mono); color: var(--ink);
}
.ll-node .tag {
  display: block; margin-top: 6px;
  font: 700 9px/1 var(--sans); letter-spacing: .35px; text-transform: uppercase; color: var(--steel);
}
.ll-node.head {
  border-color: var(--brand-tag); background: rgba(126,162,255,.12);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.ll-node.head .tag { color: var(--brand-tag); }
.ll-node.path {
  border-color: rgba(242,160,92,.55); background: rgba(242,160,92,.12);
}
.ll-node.focus {
  border-color: var(--brand-green); background: rgba(95,208,143,.14);
  box-shadow: 0 0 0 3px rgba(95,208,143,.18);
}
.ll-node.focus .tag { color: var(--brand-green); }
.ll-node.gone {
  opacity: .35; border-color: var(--brand-error); background: rgba(255,138,125,.1);
}
.ll-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 44px; padding: 0 4px;
  font: 700 14px/1 var(--mono); color: var(--brand-tag);
}
.ll-link .next { color: var(--brand-tag); }
.ll-link .prev { color: var(--brand-warn); font-size: 12px; }
.ll-link .lbl {
  font: 700 9px/1 var(--sans); letter-spacing: .3px; text-transform: uppercase; color: var(--steel);
}
.ll-null {
  font: 700 12px/1 var(--mono); color: var(--stone); padding: 0 6px;
}
.ll-wrap-link {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font: 600 12px/1.3 var(--sans); color: var(--brand-warn);
  padding: 6px 10px; border-radius: var(--r-full);
  border: 1px dashed rgba(242,160,92,.45); background: rgba(242,160,92,.08);
}
.ll-wrap-link b { color: var(--brand-warn); font-family: var(--mono); }

/* Circular list drawn as a ring */
.ll-circle-wrap {
  width: 100%; max-width: 520px; margin: 0 auto;
  display: grid; gap: 8px; justify-items: center;
}
.ll-circle-svg {
  display: block; width: min(100%, 480px); height: auto;
  overflow: visible;
}
.ll-circle-svg .ll-edge {
  fill: none; stroke: var(--brand-tag); stroke-width: 2.25;
  opacity: .9;
}
.ll-circle-svg .ll-edge.back-to-head {
  stroke: var(--brand-warn); stroke-width: 2.5;
}
.ll-circle-svg .ll-edge-label {
  fill: var(--steel); font: 700 10px var(--sans); letter-spacing: .3px;
  text-transform: uppercase;
}
.ll-circle-svg .ll-edge-label.back { fill: var(--brand-warn); }
.ll-circle-svg .ll-cnode circle {
  fill: var(--surface-soft); stroke: var(--hairline); stroke-width: 1.5;
}
.ll-circle-svg .ll-cnode text.val {
  fill: var(--ink); font: 700 16px var(--mono); text-anchor: middle; dominant-baseline: central;
}
.ll-circle-svg .ll-cnode text.tag {
  fill: var(--steel); font: 700 9px var(--sans); text-anchor: middle;
  letter-spacing: .35px; text-transform: uppercase;
}
.ll-circle-svg .ll-cnode.head circle {
  stroke: var(--brand-tag); stroke-width: 2.5; fill: rgba(126,162,255,.14);
}
.ll-circle-svg .ll-cnode.head text.tag { fill: var(--brand-tag); }
.ll-circle-svg .ll-cnode.path circle {
  stroke: rgba(242,160,92,.7); fill: rgba(242,160,92,.14);
}
.ll-circle-svg .ll-cnode.focus circle {
  stroke: var(--brand-green); stroke-width: 2.5; fill: rgba(95,208,143,.16);
}
.ll-circle-svg .ll-cnode.focus text.tag { fill: var(--brand-green); }
.ll-circle-svg .ll-cnode.gone { opacity: .35; }
.ll-circle-svg .ll-cnode.gone circle { stroke: var(--brand-error); }
.ds-play-ops select {
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font: 600 14px/1 var(--sans); min-height: 42px;
}
.ds-play-ops select:focus {
  outline: 2px solid rgba(126,162,255,.45); outline-offset: 1px; border-color: var(--brand-tag);
}
.ll-kind-tabs { display: flex; flex-wrap: wrap; gap: 8px; }

.stage-panel .stage.viz-stage { justify-content: center; }
.intro-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: start; }

@media (max-width: 900px) {
  .intro-grid { grid-template-columns: 1fr; }
  .cell { width: 48px; } .cell .v { font-size: 18px; }
  .bar { width: 28px; }
}

/* Infrared door-sensor control system scene */
.ir-stage { min-height: 360px; gap: 10px; }
.ir-wrap { width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }

.ir-corridor {
  position: relative; height: 148px; border-radius: var(--r-md); overflow: hidden;
  background:
    linear-gradient(180deg, #222830 0%, #181c22 58%, #14181e 58%, #12161d 100%);
  border: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(126,162,255,.08);
}
.ir-corridor .scene-caption {
  position: absolute; top: 8px; left: 12px; z-index: 2;
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--slate);
}
.ir-floor-scale {
  position: absolute; left: 14px; right: 88px; bottom: 22px; height: 16px;
  display: flex; justify-content: space-between; align-items: flex-end;
  font: 600 10px/1 var(--mono); color: var(--slate); pointer-events: none; z-index: 2;
}
.ir-floor-scale span { position: relative; }
.ir-floor-scale span::before {
  content: ''; position: absolute; left: 50%; bottom: 11px; width: 1px; height: 6px; background: var(--steel);
}
.ir-threshold-mark {
  position: absolute; bottom: 38px; width: 2px; height: 70px;
  background: repeating-linear-gradient(180deg, var(--brand-warn) 0 4px, transparent 4px 8px);
  transform: translateX(-50%); z-index: 2;
}
.ir-threshold-mark em {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font: 700 10px/1 var(--mono); color: var(--on-accent); white-space: nowrap; font-style: normal;
  background: var(--brand-warn); padding: 2px 6px; border-radius: var(--r-full);
}

.ir-person {
  position: absolute; bottom: 34px; width: 28px; height: 48px;
  transform: translateX(-50%); transition: left .55s cubic-bezier(.2,.8,.2,1); z-index: 4;
}
.ir-person.walking .ir-person-svg { animation: ir-walk-bob .55s ease; }
.ir-person-svg { width: 28px; height: 48px; display: block; overflow: visible; }
.ir-person .dist-tag {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  font: 700 10px/1 var(--mono); color: var(--on-accent); white-space: nowrap;
  background: var(--brand-tag); padding: 2px 6px; border-radius: var(--r-full);
  border: 1px solid transparent; box-shadow: var(--shadow-soft);
}
@keyframes ir-walk-bob {
  0% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

.ir-door-unit {
  position: absolute; right: 10px; bottom: 34px; width: 58px; height: 84px; z-index: 3;
}
.ir-door-frame {
  position: absolute; inset: 0; border: 3px solid #8b9bb3; border-bottom: none;
  border-radius: 6px 6px 0 0; background: rgba(18,22,29,.55); overflow: hidden;
}
.ir-door-leaf {
  position: absolute; top: 0; bottom: 0; width: 50%;
  background: linear-gradient(180deg, #7ea2ff, #5a7fd4);
  border: 1px solid #9bb6ff; transition: transform .55s cubic-bezier(.2,.8,.2,1);
}
.ir-door-leaf.left { left: 0; }
.ir-door-leaf.right { right: 0; }
.ir-door-unit.open .ir-door-leaf.left { transform: translateX(-92%); }
.ir-door-unit.open .ir-door-leaf.right { transform: translateX(92%); }
.ir-door-unit.open .ir-door-frame {
  background: rgba(95,208,143,.18); box-shadow: inset 0 0 0 2px rgba(95,208,143,.45);
}
.ir-beam {
  position: absolute; top: 42px; right: 46px; height: 36px; z-index: 2; pointer-events: none;
  width: 140px; transform-origin: right center;
  background: linear-gradient(90deg, transparent, rgba(242,160,92,.55));
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  opacity: .95; transition: width .45s ease, background .3s;
}
.ir-beam.near { background: linear-gradient(90deg, transparent, rgba(95,208,143,.55)); }

/* Pipeline: Sensor → MCU → Motor */
.ir-pipeline {
  display: grid;
  grid-template-columns: minmax(72px,1fr) minmax(48px,1.1fr) minmax(72px,1fr) minmax(48px,1.1fr) minmax(72px,1fr);
  align-items: center; gap: 2px;
  padding: 8px 6px; border-radius: var(--r-md);
  background: var(--canvas); border: 1px solid var(--hairline);
}
.ir-node {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 2px; border-radius: var(--r-md); text-align: center;
  border: 1px solid transparent; transition: border-color .25s, background .25s, box-shadow .25s;
  min-width: 0;
}
.ir-node .icon {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  border: 1px solid var(--hairline); background: var(--surface-soft); flex: 0 0 auto;
}
.ir-node .icon svg {
  width: 16px !important; height: 16px !important; max-width: 16px; max-height: 16px;
  display: block;
}
.ir-node .name {
  font: 700 10px/1.15 var(--sans); letter-spacing: .15px; color: var(--ink);
}
.ir-node .meta {
  font: 600 9px/1.15 var(--mono); color: var(--slate); min-height: 1.15em;
}
.ir-node.sensor .icon { color: var(--orange); background: rgba(242,160,92,.18); border-color: rgba(242,160,92,.45); }
.ir-node.mcu .icon { color: var(--brand-tag); background: rgba(126,162,255,.18); border-color: rgba(126,162,255,.45); }
.ir-node.motor .icon { color: var(--brand-green); background: rgba(95,208,143,.18); border-color: rgba(95,208,143,.45); }
.ir-node.active {
  background: rgba(126,162,255,.12); border-color: rgba(126,162,255,.4);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.ir-node.sensor.active { background: rgba(242,160,92,.14); border-color: rgba(242,160,92,.5); box-shadow: 0 0 0 3px rgba(242,160,92,.18); }
.ir-node.motor.active.open { background: rgba(95,208,143,.14); border-color: rgba(95,208,143,.5); box-shadow: 0 0 0 3px rgba(95,208,143,.18); }
.ir-node.motor.active.close { background: rgba(255,138,125,.14); border-color: rgba(255,138,125,.45); }
.ir-node.mcu.deciding .icon { animation: val-flash .6s ease; }
.ir-node.sensor.ping .icon { animation: ir-pulse 1s ease-in-out infinite; }
.ir-node.motor.spin .icon svg { animation: ir-spin .8s linear; }

.ir-link {
  position: relative; height: 36px; display: flex; align-items: center; justify-content: center;
  min-width: 0;
}
.ir-link .track {
  position: absolute; left: 2px; right: 2px; top: 50%; height: 3px; margin-top: -1.5px;
  border-radius: 2px; overflow: hidden;
}
.ir-link.data .track { background: linear-gradient(90deg, rgba(242,160,92,.65), rgba(126,162,255,.8)); }
.ir-link.cmd .track { background: linear-gradient(90deg, rgba(126,162,255,.7), rgba(95,208,143,.8)); }
.ir-link .track::after {
  content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: translateX(-100%); opacity: .0;
}
.ir-link.live .track::after { animation: ir-track-shimmer 1s linear infinite; opacity: 1; }
.ir-link .link-label {
  position: absolute; top: 2px; left: 0; right: 0; text-align: center;
  font: 700 9px/1 var(--sans); letter-spacing: .45px; text-transform: uppercase; color: var(--slate);
}
.ir-link .arrow {
  position: absolute; right: 0; top: 50%; width: 0; height: 0; margin-top: -4px;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-left: 6px solid var(--brand-tag);
}
.ir-link.cmd .arrow { border-left-color: var(--brand-green); }

.ir-pkt {
  position: absolute; top: 50%; left: 0; z-index: 2;
  transform: translate(-10%, -50%); opacity: 0; pointer-events: none;
  min-width: 34px; padding: 2px 6px; border-radius: var(--r-full); text-align: center;
  font: 700 10px/1.2 var(--mono); color: var(--on-accent);
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  white-space: nowrap;
}
.ir-pkt.data { background: var(--brand-tag); }
.ir-pkt.cmd { background: var(--brand-green); }
.ir-pkt.cmd.close { background: var(--brand-error); }
.ir-pkt.fly-data { animation: ir-fly-data .7s cubic-bezier(.2,.75,.2,1) forwards; }
.ir-pkt.fly-cmd { animation: ir-fly-cmd .7s cubic-bezier(.2,.75,.2,1) forwards; }
@keyframes ir-fly-data {
  0% { opacity: 0; left: 0; transform: translate(-10%, -50%) scale(.85); }
  12% { opacity: 1; }
  100% { opacity: 1; left: 100%; transform: translate(-90%, -50%) scale(1); }
}
@keyframes ir-fly-cmd {
  0% { opacity: 0; left: 0; transform: translate(-10%, -50%) scale(.85); }
  12% { opacity: 1; }
  100% { opacity: 1; left: 100%; transform: translate(-90%, -50%) scale(1); }
}
@keyframes ir-track-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes ir-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes ir-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ir-stream {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center;
  min-height: 28px;
}
.ir-stream .stream-label {
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--slate); margin-right: 4px;
}
.ir-stream .bit {
  font: 700 11px/1 var(--mono); padding: 4px 8px; border-radius: var(--r-full);
  background: rgba(126,162,255,.18); color: var(--brand-tag); border: 1px solid rgba(126,162,255,.4);
}
.ir-stream .bit.near { background: rgba(95,208,143,.18); color: var(--brand-green); border-color: rgba(95,208,143,.45); }
.ir-stream .bit.latest { box-shadow: 0 0 0 2px rgba(126,162,255,.35); transform: scale(1.06); }

@media (max-width: 700px) {
  .ir-pipeline {
    grid-template-columns: minmax(56px,1fr) minmax(36px,.9fr) minmax(56px,1fr) minmax(36px,.9fr) minmax(56px,1fr);
    padding: 6px 4px;
  }
  .ir-node .name { font-size: 9px; }
  .ir-corridor { height: 140px; }
}

/* Fetch–execute cycle: CPU | buses | vertical RAM */
.fec-panels { grid-template-columns: minmax(220px, .7fr) 1.6fr; }
.fec-stage { min-height: 460px; gap: 12px; justify-content: flex-start; }
.fec-wrap {
  width: 100%; max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}

.fec-phase {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-md);
  background: var(--canvas); border: 1px solid var(--hairline);
}
.fec-phase .phase-pill {
  font: 700 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase;
  padding: 5px 10px; border-radius: var(--r-full); color: var(--on-accent); background: var(--steel);
}
.fec-phase.fetch .phase-pill { background: var(--brand-tag); }
.fec-phase.decode .phase-pill { background: var(--brand-warn); }
.fec-phase.execute .phase-pill { background: var(--brand-green); }
.fec-phase.halt .phase-pill { background: var(--muted); }
.fec-phase .phase-cu {
  font: 500 13px/1.3 var(--mono); color: var(--steel);
  padding: 4px 8px; border-radius: var(--r-sm); border: 1px solid transparent;
}
.fec-phase .phase-cu.on {
  color: var(--ink); background: rgba(126,162,255,.14); border-color: rgba(126,162,255,.35);
}
.fec-phase .phase-cu.flash { animation: val-flash .6s ease; }

.fec-scroll-hint {
  display: none;
  margin: 0;
  font: 600 11px/1.3 var(--sans);
  color: var(--stone);
  text-align: center;
}
/*
  Keep CPU | buses | RAM in one horizontal row on every viewport.
  Narrow screens swipe sideways (same Safari-safe track pattern as page-fetch).
*/
.stage:has(.fec-board-scroll) {
  align-items: stretch;
  min-width: 0;
}
.fec-board-scroll {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.fec-board-track {
  display: block;
  width: 680px;
  max-width: none;
}
.fec-board {
  display: grid;
  grid-template-columns: 240px 140px 220px;
  gap: 10px;
  align-items: stretch;
  width: 680px;
  box-sizing: border-box;
}

.fec-cpu, .fec-ram {
  position: relative; padding: 18px 10px 10px;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  transition: border-color .2s, box-shadow .2s;
}
.fec-cpu {
  background: linear-gradient(180deg, #222830 0%, #1a2029 100%);
}
.fec-ram { background: var(--canvas); }
.fec-cpu-label, .fec-ram-label {
  position: absolute; top: -9px; left: 10px;
  font: 700 10px/1 var(--sans); letter-spacing: .5px; text-transform: uppercase;
  color: var(--slate); background: var(--canvas); padding: 2px 8px;
  border: 1px solid var(--hairline); border-radius: var(--r-full);
}
.fec-regs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}

.fec-reg {
  display: flex; flex-direction: column; gap: 3px; align-items: stretch;
  padding: 7px; border-radius: var(--r-md); background: var(--canvas);
  border: 1px solid var(--hairline); transition: border-color .2s, box-shadow .2s, background .2s;
}
.fec-reg .reg-name {
  font: 700 10px/1 var(--mono); letter-spacing: .3px; color: var(--steel);
}
.fec-reg .reg-val {
  font: 600 14px/1.2 var(--mono); color: var(--ink); min-height: 20px;
  word-break: break-all;
}
.fec-reg .reg-val.empty { color: var(--muted); font-weight: 500; }
.fec-reg.active {
  border-color: var(--brand-tag); background: rgba(126,162,255,.14);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.fec-reg.flash { animation: val-flash .6s ease; }
.fec-reg[data-reg="PC"].active,
.fec-reg[data-reg="MAR"].active { border-color: var(--brand-tag); }
.fec-reg[data-reg="IR"].active,
.fec-reg[data-reg="MDR"].active {
  border-color: var(--brand-warn); box-shadow: 0 0 0 3px rgba(242,160,92,.18);
  background: rgba(242,160,92,.12);
}
.fec-reg[data-reg="ACC"].active,
.fec-reg[data-reg="ALU"].active {
  border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(95,208,143,.18);
  background: rgba(95,208,143,.12);
}

/* Three system buses between CPU and RAM */
.fec-buses {
  display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: 8px 2px; min-width: 0;
}
.fec-bus {
  --bus: #9aa0a6;
  display: flex; flex-direction: column; gap: 4px; opacity: .55;
  transition: opacity .2s;
}
.fec-bus.address { --bus: var(--brand-tag); }
.fec-bus.data { --bus: var(--brand-green-deep); }
.fec-bus.control { --bus: var(--orange); }
.fec-bus.active { opacity: 1; }
.fec-bus-label {
  font: 700 10px/1 var(--sans); letter-spacing: .35px; text-transform: uppercase;
  color: var(--bus); text-align: center;
}
.fec-bus-track {
  position: relative; height: 18px; display: flex; align-items: center;
}
.fec-bus-wire {
  flex: 1; height: 3px; border-radius: var(--r-full);
  background: var(--bus); opacity: .35;
  transition: opacity .2s, box-shadow .2s, height .2s;
}
.fec-bus.active .fec-bus-wire {
  opacity: 1; height: 4px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bus) 22%, transparent);
  animation: fec-bus-pulse 1.1s ease-in-out infinite;
}
.fec-bus-end {
  width: 0; height: 0; border-style: solid; flex-shrink: 0;
}
.fec-bus-end.left {
  border-width: 5px 7px 5px 0;
  border-color: transparent var(--bus) transparent transparent;
  opacity: .35;
}
.fec-bus-end.right {
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--bus);
  opacity: .35;
}
.fec-bus.active .fec-bus-end { opacity: 1; }
/* Address bus is unidirectional: CPU → RAM only (no reverse arrow). */
.fec-bus-origin {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: var(--bus); opacity: .45;
}
.fec-bus.address.active .fec-bus-origin { opacity: 1; }
.fec-bus.address .fec-bus-end.right { opacity: .55; }
.fec-bus.address.active .fec-bus-end.right { opacity: 1; transform: scale(1.15); }
/* Data direction: in = RAM→CPU (flip left arrow emphasis), out = CPU→RAM */
.fec-bus.data.dir-in .fec-bus-end.left { opacity: 1; transform: scale(1.15); }
.fec-bus.data.dir-in .fec-bus-end.right { opacity: .25; }
.fec-bus.data.dir-out .fec-bus-end.right,
.fec-bus.control.active .fec-bus-end.right { opacity: 1; transform: scale(1.15); }
.fec-bus.data.dir-out .fec-bus-end.left,
.fec-bus.control.dir-out .fec-bus-end.left { opacity: .25; }
.fec-bus-chip {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 700 11px/1 var(--mono); color: var(--on-accent); background: var(--bus);
  padding: 3px 7px; border-radius: var(--r-full); white-space: nowrap;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow-soft); animation: var-pop .35s cubic-bezier(.2,1.3,.4,1);
}
@keyframes fec-bus-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

/* Vertical RAM: address | value rows */
.fec-ram.active {
  border-color: var(--brand-tag); box-shadow: 0 0 0 3px rgba(55,114,207,.1);
}
.fec-ram.flash { animation: val-flash .6s ease; }
.fec-ram-head {
  display: grid; grid-template-columns: 56px 1fr; gap: 6px;
  padding: 0 8px 6px; margin-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
  font: 700 10px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--stone);
}
.fec-ram-list { display: flex; flex-direction: column; gap: 3px; }
.fec-row {
  display: grid; grid-template-columns: 56px 1fr; gap: 6px; align-items: center;
  padding: 5px 8px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--surface-soft);
  transition: border-color .2s, background .2s, box-shadow .2s, transform .2s;
}
.fec-row .addr {
  font: 600 12px/1 var(--mono); color: var(--steel); text-align: right;
}
.fec-row .content {
  font: 600 13px/1.2 var(--mono); color: var(--ink);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fec-row.empty .content { color: var(--muted); font-weight: 500; }
.fec-row.instr .content { font-size: 12px; }
.fec-row.focus {
  border-color: var(--brand-tag); background: rgba(55,114,207,.08);
  transform: translateX(-2px);
}
.fec-row.active { box-shadow: 0 0 0 2px rgba(55,114,207,.15); }
.fec-row.data.focus {
  border-color: var(--brand-green-deep); background: rgba(0,212,164,.1);
  box-shadow: 0 0 0 2px rgba(0,212,164,.12);
}

.var[data-name="PC"], .var[data-name="MAR"] { --c: var(--brand-tag); }
.var[data-name="IR"], .var[data-name="MDR"] { --c: var(--brand-warn); }
.var[data-name="ACC"], .var[data-name="ALU"] { --c: var(--brand-green-deep); }

@media (max-width: 900px) {
  .fec-panels { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .fec-scroll-hint { display: block; }
  .fec-board-scroll {
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--canvas);
    padding: 8px 4px 10px;
  }
  .fec-stage { min-height: 0; }
  .fec-wrap { max-width: 100%; }
}

/* Parallel arrays — two aligned rows linked by a shared index */
.pa-stage { min-height: 320px; gap: 14px; }
.pa-wrap {
  width: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 6px;
}
.pa-row {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center;
}
.pa-label {
  font: 700 12px/1.2 var(--mono); color: var(--steel); text-align: right;
  letter-spacing: .2px;
}
.pa-row .array-row {
  justify-content: flex-start; min-height: 72px; flex-wrap: nowrap;
}
.pa-row .cell { width: 64px; }
.pa-row .cell .v { font-size: 16px; padding: 10px 2px 12px; }
.pa-row .cell.linked {
  border-color: var(--brand-green-deep);
  background: rgba(0,212,164,.14);
  box-shadow: 0 0 0 3px rgba(0,212,164,.18);
}

.pa-link {
  position: relative; height: 28px; margin: 0 0 0 74px;
  display: flex; align-items: center; justify-content: flex-start;
}
.pa-link.idle { justify-content: center; margin-left: 64px; opacity: .7; }
.pa-link-tag {
  font: 700 11px/1 var(--mono); color: var(--brand-tag);
  background: rgba(55,114,207,.1); border: 1px solid rgba(55,114,207,.25);
  padding: 4px 8px; border-radius: var(--r-full); z-index: 1;
}
.pa-link-tag.muted { color: var(--stone); background: var(--surface-soft); border-color: var(--hairline); font-weight: 600; }
.pa-link-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  left: calc(var(--i, 0) * 72px + 32px);
  background: var(--brand-tag);
  border-radius: var(--r-full);
  box-shadow: 0 0 0 3px rgba(55,114,207,.12);
}
.pa-link .pa-link-tag {
  position: absolute;
  left: calc(var(--i, 0) * 72px + 32px);
  transform: translateX(-50%);
  white-space: nowrap;
}
.pa-link.on .pa-link-line {
  background: var(--brand-green-deep);
  box-shadow: 0 0 0 3px rgba(0,212,164,.18);
}
.pa-link.on .pa-link-tag {
  color: var(--brand-green-deep);
  background: rgba(0,212,164,.12);
  border-color: rgba(0,180,138,.35);
}

@media (max-width: 640px) {
  .pa-row { grid-template-columns: 48px 1fr; gap: 6px; }
  .pa-row .cell { width: 52px; }
  .pa-row .cell .v { font-size: 13px; }
  .pa-link { margin-left: 54px; }
  .pa-link-line,
  .pa-link .pa-link-tag { left: calc(var(--i, 0) * 60px + 26px); }
}

/* Sets — unordered bag of unique elements */
.set-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.set-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.set-pair {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; width: 100%;
}
.set-panel {
  flex: 1 1 180px; max-width: 280px;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.set-panel .set-name {
  font: 700 12px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel);
}
.set-bag {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-content: center;
  min-height: 88px; width: 100%; padding: 14px;
  border-radius: var(--r-md); border: 1px dashed var(--hairline);
  background: var(--surface-soft);
}
.set-bag.empty::after {
  content: '∅'; font: 600 22px/1 var(--mono); color: var(--muted);
}
.set-chip {
  min-width: 40px; padding: 10px 12px; text-align: center;
  font: 700 16px/1 var(--mono); color: var(--ink);
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-full);
  box-shadow: var(--shadow-soft); transition: transform .25s, border-color .25s, background .25s, opacity .25s;
}
.set-chip.probe { border-color: var(--brand-tag); background: rgba(55,114,207,.1); box-shadow: 0 0 0 3px rgba(55,114,207,.12); }
.set-chip.match { border-color: var(--brand-green); background: rgba(0,212,164,.14); box-shadow: 0 0 0 3px rgba(0,212,164,.12); }
.set-chip.add { border-color: var(--brand-green-deep); background: rgba(0,180,138,.12); transform: translateY(-3px); }
.set-chip.remove { opacity: .35; transform: scale(.9); border-color: var(--orange); }
.set-chip.ghost { opacity: .4; border-style: dashed; }
.set-op {
  align-self: center; font: 700 22px/1 var(--mono); color: var(--brand-tag); padding: 0 4px;
}
.set-result-label {
  font: 600 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel);
}

/* Hash table — buckets with chaining */
.hash-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hash-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.hash-table {
  display: flex; flex-direction: column; gap: 6px; width: min(420px, 100%);
}
.hash-row {
  display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center;
}
.hash-idx {
  font: 700 12px/1 var(--mono); color: var(--stone); text-align: right;
}
.hash-idx.active { color: var(--brand-tag); }
.hash-bucket {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 40px; padding: 6px 8px;
  border-radius: var(--r-md); border: 1px solid var(--hairline);
  background: var(--surface-soft);
  transition: border-color .25s, background .25s, box-shadow .25s;
}
.hash-bucket.probe {
  border-color: var(--brand-tag); background: rgba(55,114,207,.08);
  box-shadow: 0 0 0 2px rgba(55,114,207,.12);
}
.hash-bucket.collide {
  border-color: var(--orange); background: rgba(245,90,60,.12);
  box-shadow: 0 0 0 3px rgba(245,90,60,.2);
  animation: hash-bucket-shake .55s ease;
  position: relative;
}
.hash-bucket.collide::after {
  content: 'COLLISION';
  position: absolute; top: -11px; right: 8px;
  font: 800 9px/1 var(--sans); letter-spacing: .6px;
  color: #fff; background: var(--orange);
  padding: 3px 7px; border-radius: var(--r-full);
  box-shadow: 0 2px 6px rgba(245,90,60,.35);
  animation: hash-badge-pop .4s cubic-bezier(.2,1.4,.4,1);
}
.hash-empty {
  font: 500 12px/1 var(--mono); color: var(--muted);
}
.hash-entry {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: var(--r-full);
  font: 700 13px/1 var(--mono); color: var(--ink);
  background: var(--canvas); border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft); transition: transform .25s, border-color .25s, background .25s;
}
.hash-entry .hk { color: var(--brand-tag); }
.hash-entry .hv { color: var(--brand-green-deep); }
.hash-entry.probe { border-color: var(--brand-tag); background: rgba(55,114,207,.12); }
.hash-entry.match { border-color: var(--brand-green); background: rgba(0,212,164,.14); }
.hash-entry.add {
  border-color: var(--brand-green-deep); background: rgba(0,180,138,.14);
  animation: hash-entry-land .45s cubic-bezier(.2,1.3,.4,1);
}
.hash-entry.incoming {
  border-color: var(--orange); background: rgba(245,90,60,.16); color: var(--ink);
  border-style: dashed;
  animation: hash-entry-bounce .7s ease infinite;
  box-shadow: 0 0 0 3px rgba(245,90,60,.18);
}
.hash-entry.resident {
  border-color: var(--brand-tag); background: rgba(55,114,207,.1);
}
.hash-entry.scan {
  border-color: var(--brand-tag); background: rgba(55,114,207,.16);
  box-shadow: 0 0 0 3px rgba(55,114,207,.2);
  animation: hash-entry-scan .55s ease;
  transform: scale(1.06);
}
.hash-entry.checked {
  opacity: .45; border-style: dashed;
  text-decoration: line-through;
  text-decoration-color: var(--stone);
}
.hash-entry.checked .hk, .hash-entry.checked .hv { color: var(--stone); }
.hash-arrow { color: var(--stone); font-weight: 600; }
.hash-arrow.flash { color: var(--orange); animation: hash-arrow-pulse .6s ease; }
.hash-arrow.walk { color: var(--brand-tag); animation: hash-arrow-pulse .6s ease; }
.hash-formula {
  font: 500 13px/1.4 var(--mono); color: var(--steel); text-align: center;
}
.hash-formula b { color: var(--ink); }
.hash-formula.collide-note {
  color: var(--orange); font-weight: 700;
}
.hash-incoming-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 36px; margin-bottom: 2px;
}
.hash-incoming-label {
  font: 700 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--orange);
}
@keyframes hash-bucket-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes hash-badge-pop {
  0% { transform: scale(.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes hash-entry-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.04); }
}
@keyframes hash-entry-land {
  0% { transform: translateX(-18px) scale(.85); opacity: .2; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes hash-entry-scan {
  0% { transform: scale(.92); box-shadow: 0 0 0 0 rgba(55,114,207,.35); }
  60% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(55,114,207,.12); }
  100% { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(55,114,207,.2); }
}
@keyframes hash-arrow-pulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}
.hash-load {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  width: min(420px, 100%);
}
.hash-load-bar {
  flex: 1 1 160px; height: 10px; border-radius: var(--r-full);
  background: var(--surface-soft); border: 1px solid var(--hairline); overflow: hidden;
}
.hash-load-bar > i {
  display: block; height: 100%; width: 0%; background: var(--brand-tag);
  transition: width .35s ease, background .25s;
}
.hash-load-bar.hot > i { background: var(--orange); }
.ds-play-ops input[type="text"] {
  width: 88px; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font: 700 16px/1 var(--mono);
}
.ds-play-ops input[type="text"]:focus {
  outline: 2px solid rgba(126,162,255,.45); outline-offset: 1px; border-color: var(--brand-tag);
}

/* Static / dynamic array (contiguous block) */
.arr-stage {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.arr-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.arr-meta {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font: 500 13px/1.3 var(--mono); color: var(--steel);
}
.arr-meta b { color: var(--ink); }
.arr-meta .warn-meta { color: var(--orange); font-weight: 700; }
.arr-block {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%; padding: 10px 8px; border-radius: var(--r-md);
  border: 1px dashed transparent;
}
.arr-block.old {
  border-color: rgba(245,90,60,.35); background: rgba(245,90,60,.06);
  opacity: .72;
}
.arr-block.new {
  border-color: rgba(95,208,143,.4); background: rgba(95,208,143,.08);
}
.arr-block-label {
  font: 700 10px/1 var(--sans); letter-spacing: .5px; text-transform: uppercase; color: var(--stone);
}
.arr-block.old .arr-block-label { color: var(--orange); }
.arr-block.new .arr-block-label { color: var(--brand-green); }
.arr-stage .array-row { min-height: 72px; }
.cell.cap {
  border-style: dashed; background: transparent; box-shadow: none; opacity: .55;
}
.cell.cap .v { color: var(--muted); font-size: 16px; }
.cell.shift {
  border-color: var(--brand-warn); background: rgba(195,125,13,.12);
  animation: arr-shift .45s ease;
}
.cell.insert {
  border-color: var(--brand-green-deep); background: rgba(0,180,138,.14);
  animation: hash-entry-land .45s cubic-bezier(.2,1.3,.4,1);
}
.cell.remove {
  border-color: var(--orange); background: rgba(245,90,60,.14);
  opacity: .55; text-decoration: line-through;
}
.cell.copy {
  border-color: var(--brand-tag); background: rgba(55,114,207,.14);
  box-shadow: 0 0 0 3px rgba(55,114,207,.16);
  animation: arr-shift .4s ease;
}
.cell.gap {
  border-style: dashed; border-color: var(--orange); background: rgba(245,90,60,.08);
}
@keyframes arr-shift {
  0% { transform: translateX(-10px); opacity: .4; }
  100% { transform: translateX(0); opacity: 1; }
}

/* Call stack frames (stacks simulation) */
.cs-wrap {
  width: 100%; max-width: 420px; margin: 0 auto;
  display: grid; gap: 12px;
}
.cs-panel {
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 16px 12px 12px; position: relative;
}
.cs-panel-label {
  position: absolute; top: -9px; left: 12px;
  font: 700 10px/1 var(--sans); letter-spacing: .5px; text-transform: uppercase;
  color: var(--slate); background: var(--surface); padding: 2px 8px;
  border: 1px solid var(--hairline); border-radius: var(--r-full);
}
.cs-arrow {
  text-align: center; font: 700 11px/1 var(--sans); letter-spacing: .4px;
  text-transform: uppercase; color: var(--steel); margin-bottom: 8px;
}
.cs-arrow span { color: var(--brand-tag); }
.cs-stack {
  display: flex; flex-direction: column-reverse; gap: 8px; min-height: 100px;
}
.cs-empty {
  text-align: center; color: var(--stone); font-size: 14px; padding: 24px 12px;
}
.cs-frame {
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-soft); padding: 10px 12px;
  display: grid; gap: 6px;
  transition: border-color .2s, background .2s, box-shadow .2s, transform .25s, opacity .2s;
  animation: hash-entry-land .4s cubic-bezier(.2,1.3,.4,1);
}
.cs-frame.active {
  border-color: var(--brand-tag);
  background: rgba(126,162,255,.12);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.cs-frame.waiting {
  border-color: var(--brand-warn);
  background: rgba(242,160,92,.1);
}
.cs-frame.returning {
  border-color: var(--brand-green);
  background: rgba(95,208,143,.12);
  box-shadow: 0 0 0 3px rgba(95,208,143,.16);
}
.cs-frame.leaving {
  opacity: .4; transform: translateY(-8px) scale(.96);
}
.cs-frame-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.cs-frame-title { font: 700 14px/1.2 var(--mono); color: var(--ink); }
.cs-frame-title .fn { color: var(--brand-tag); }
.cs-frame-title .arg { color: var(--brand-warn); }
.cs-pill {
  font: 700 10px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-full); white-space: nowrap;
  background: var(--surface); color: var(--steel); border: 1px solid var(--hairline);
}
.cs-pill.active { background: rgba(126,162,255,.2); color: var(--brand-tag); border-color: transparent; }
.cs-pill.waiting { background: rgba(242,160,92,.2); color: var(--brand-warn); border-color: transparent; }
.cs-pill.returning { background: rgba(95,208,143,.2); color: var(--brand-green); border-color: transparent; }
.cs-frame-meta {
  display: grid; gap: 3px;
  font: 500 12px/1.35 var(--mono); color: var(--slate);
}
.cs-frame-meta b { color: var(--ink); font-weight: 700; }
.cs-frame-meta .muted { color: var(--steel); }

/* How a page is fetched — user · browser · DNS · web server */
.pf-stage {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 420px; justify-content: flex-start;
}
.pf-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.pf-phase {
  font: 700 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel);
}
.pf-msg {
  min-height: 36px; max-width: 420px; text-align: center;
  font: 600 13px/1.35 var(--mono); color: var(--ink);
  padding: 8px 12px; border-radius: var(--r-md);
  border: 1px dashed var(--hairline); background: var(--surface-soft);
}
.pf-msg.on {
  border-color: rgba(126,162,255,.45); background: rgba(126,162,255,.12); color: var(--brand-tag);
  animation: hash-entry-land .4s cubic-bezier(.2,1.3,.4,1);
}
.pf-msg.reply {
  border-color: rgba(95,208,143,.45); background: rgba(95,208,143,.12); color: var(--brand-green);
}
.pf-scroll-hint {
  display: none;
  margin: 0;
  font: 600 11px/1.3 var(--sans);
  color: var(--stone);
  text-align: center;
}
/*
  Scrollport must stay viewport-wide (not grow to 560px). min-width:0 lets it shrink inside
  flex/grid parents; the 560px track inside is what actually scrolls on iOS Safari.
*/
.stage:has(.pf-diagram-scroll) {
  align-items: stretch;
  min-width: 0;
}
.pf-diagram-scroll {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
/*
  Track is in-flow at a fixed 560px. Safari often collapses abspos-only boxes inside
  overflow scrollers; the track (and .pf-diagram-sizer) keep width/height real so
  pixel-placed nodes and the SVG stay aligned.
*/
.pf-diagram-track {
  display: block;
  position: relative;
  width: 560px;
  height: 320px;
  max-width: none;
}
.pf-diagram {
  position: absolute;
  top: 0;
  left: 0;
  width: 560px;
  height: 320px;
  margin: 0;
}
.pf-diagram-sizer {
  display: block;
  width: 560px;
  height: 320px;
  pointer-events: none;
  visibility: hidden;
}
.pf-edges {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 560px;
  height: 320px;
  pointer-events: none;
  overflow: visible;
}
.pf-edge {
  fill: none; stroke: var(--hairline); stroke-width: 2.5;
  stroke-linecap: round; transition: stroke .25s, stroke-width .25s, opacity .25s;
  opacity: .55;
}
.pf-edge.on {
  stroke: var(--brand-tag); stroke-width: 3.5; opacity: 1;
  filter: drop-shadow(0 0 4px rgba(126,162,255,.35));
}
.pf-edge.on.reply {
  stroke: var(--brand-green);
  filter: drop-shadow(0 0 4px rgba(95,208,143,.3));
}
.pf-edge-label {
  font: 700 10px/1 var(--sans); letter-spacing: .2px;
  fill: var(--steel); opacity: 0; transition: opacity .25s;
}
.pf-edge-label.on { opacity: 1; fill: var(--brand-tag); }
.pf-edge-label.on.reply { fill: var(--brand-green); }
.pf-node {
  position: absolute; z-index: 1;
  width: 148px;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-soft); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .25s, background .25s, box-shadow .25s;
  box-sizing: border-box;
  /* Pixel slots match the 560×320 SVG viewBox — avoid % / translateX (unreliable in iOS overflow). */
}
.pf-node[data-role="user"] { left: 12px; top: 58px; }
.pf-node[data-role="browser"] { left: 196px; top: 12px; width: 168px; }
.pf-node[data-role="dns"] { left: 388px; top: 58px; width: 160px; }
.pf-node[data-role="server"] { left: 196px; top: 186px; width: 168px; }
.pf-node.on {
  border-color: var(--brand-tag); background: rgba(126,162,255,.12);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.pf-node.sending {
  border-color: var(--brand-warn); background: rgba(242,160,92,.12);
  box-shadow: 0 0 0 3px rgba(242,160,92,.14);
}
.pf-node.recv {
  border-color: var(--brand-green); background: rgba(95,208,143,.12);
  box-shadow: 0 0 0 3px rgba(95,208,143,.14);
}
.pf-role {
  font: 700 10px/1 var(--sans); letter-spacing: .5px; text-transform: uppercase; color: var(--stone);
}
.pf-node.on .pf-role, .pf-node.sending .pf-role { color: var(--brand-tag); }
.pf-node.recv .pf-role { color: var(--brand-green); }
.pf-title { font: 700 14px/1.2 var(--sans); color: var(--ink); }
.pf-detail {
  font: 500 12px/1.35 var(--mono); color: var(--steel); min-height: 1.3em;
}
.pf-detail b { color: var(--ink); }
.pf-browser-chrome {
  display: flex; align-items: center; gap: 6px;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: 6px;
  padding: 4px 8px; font: 600 11px/1.2 var(--mono); color: var(--steel);
}
.pf-browser-chrome .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--stone); }
.pf-browser-chrome .url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.pf-browser-chrome .url.empty { color: var(--muted); }
.pf-page {
  margin-top: 2px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--canvas); padding: 6px 8px; font: 600 11px/1.3 var(--sans); color: var(--steel);
  opacity: .35;
}
.pf-page.show {
  opacity: 1; border-color: rgba(95,208,143,.45); background: rgba(95,208,143,.1); color: var(--brand-green);
  animation: hash-entry-land .45s cubic-bezier(.2,1.3,.4,1);
}
.pf-page .pf-hero {
  font: 800 12px/1.2 var(--sans); color: var(--ink); margin-bottom: 2px;
}
.pf-dns-book {
  margin-top: 2px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--canvas); padding: 6px 8px;
  font: 600 10px/1.35 var(--mono); color: var(--steel);
}
.pf-dns-book .pf-dns-row {
  display: flex; justify-content: space-between; gap: 6px; align-items: baseline;
}
.pf-dns-book .pf-dns-row + .pf-dns-row { margin-top: 3px; opacity: .55; }
.pf-dns-book.on {
  border-color: rgba(242,160,92,.5); background: rgba(242,160,92,.1);
}
.pf-dns-book.on .pf-dns-hit { color: var(--brand-warn); }
.pf-dns-book .ip { color: var(--brand-green); }
.pf-files {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.pf-files span {
  font: 700 10px/1 var(--mono); padding: 3px 6px; border-radius: var(--r-full);
  background: var(--canvas); border: 1px solid var(--hairline); color: var(--steel);
}
.pf-files span.on {
  border-color: rgba(95,208,143,.5); color: var(--brand-green); background: rgba(95,208,143,.14);
}
.pf-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center;
  font: 600 11px/1 var(--sans); color: var(--steel);
}
.pf-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px;
}
.pf-legend .on i { background: var(--brand-tag); }
.pf-legend .send i { background: var(--brand-warn); }
.pf-legend .recv i { background: var(--brand-green); }
.pf-legend .flow i {
  width: 16px; height: 3px; border-radius: 2px; background: var(--brand-tag); vertical-align: 2px;
}

.pf-order {
  display: grid; gap: 12px;
}
.pf-order-pool, .pf-order-chosen {
  display: flex; flex-direction: column; gap: 8px; min-height: 48px;
}
.pf-order-btn {
  text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font: 500 14px/1.35 var(--sans);
}
.pf-order-btn:hover { border-color: var(--brand-tag); }
.pf-order-chosen .pf-order-btn {
  border-color: rgba(126,162,255,.4); background: rgba(126,162,255,.1);
}
.pf-order-empty {
  font: 500 13px/1.4 var(--sans); color: var(--muted); padding: 8px 0;
}

@media (max-width: 600px) {
  .pf-scroll-hint { display: block; }
  .pf-diagram-scroll {
    max-width: 100%;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--canvas);
    padding-bottom: 4px;
  }
  .pf-stage {
    min-height: 0;
    align-items: stretch;
    width: 100%;
  }
  .pf-msg { max-width: 100%; }
}

/* Interrupt handling — sources · queue · processor · stack · ISR */
.ih-stage {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 480px; justify-content: flex-start;
}
.ih-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.ih-phase {
  font: 700 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel);
}
.ih-msg {
  min-height: 36px; max-width: 420px; text-align: center;
  font: 600 13px/1.35 var(--mono); color: var(--ink);
  padding: 8px 12px; border-radius: var(--r-md);
  border: 1px dashed var(--hairline); background: var(--surface-soft);
}
.ih-msg.on {
  border-color: rgba(126,162,255,.45); background: rgba(126,162,255,.12); color: var(--brand-tag);
  animation: hash-entry-land .4s cubic-bezier(.2,1.3,.4,1);
}
.ih-msg.reply {
  border-color: rgba(95,208,143,.45); background: rgba(95,208,143,.12); color: var(--brand-green);
}
.ih-scroll-hint {
  display: none;
  margin: 0;
  font: 600 11px/1.3 var(--sans);
  color: var(--stone);
  text-align: center;
}
.ih-scroll-hint.on { display: block; }
.stage:has(.ih-diagram-scroll) {
  align-items: stretch;
  min-width: 0;
}
.ih-diagram-scroll {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.ih-diagram-track {
  display: block;
  position: relative;
  width: 630px;
  height: 420px;
  max-width: none;
}
.ih-diagram {
  position: absolute;
  top: 0; left: 0;
  width: 630px;
  height: 420px;
  margin: 0;
}
.ih-diagram-sizer {
  display: block;
  width: 630px;
  height: 420px;
  pointer-events: none;
  visibility: hidden;
}
.ih-edges {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 630px;
  height: 420px;
  pointer-events: none;
  overflow: visible;
}
.ih-edge {
  fill: none; stroke: var(--hairline); stroke-width: 2.5;
  stroke-linecap: round; transition: stroke .25s, stroke-width .25s, opacity .25s;
  opacity: .55;
}
.ih-edge.on {
  stroke: var(--brand-tag); stroke-width: 3.5; opacity: 1;
  filter: drop-shadow(0 0 4px rgba(126,162,255,.35));
}
.ih-edge.on.reply {
  stroke: var(--brand-green);
  filter: drop-shadow(0 0 4px rgba(95,208,143,.3));
}
.ih-edge-label {
  font: 700 10px/1 var(--sans); letter-spacing: .2px;
  fill: var(--steel); opacity: 0; transition: opacity .25s;
}
.ih-edge-label.on { opacity: 1; fill: var(--brand-tag); }
.ih-edge-label.on.reply { fill: var(--brand-green); }
.ih-node {
  position: absolute; z-index: 1;
  width: 148px;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-soft); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .25s, background .25s, box-shadow .25s;
  box-sizing: border-box;
}
.ih-node[data-role="printer"] { left: 4px; top: 8px; width: 136px; }
.ih-node[data-role="keyboard"] { left: 4px; top: 200px; width: 136px; }
.ih-node[data-role="queue"] { left: 152px; top: 64px; width: 168px; }
.ih-node[data-role="processor"] { left: 336px; top: 8px; width: 152px; min-height: 176px; }
.ih-node[data-role="stack"] { left: 336px; top: 248px; width: 152px; }
.ih-node[data-role="isr"] { left: 500px; top: 64px; width: 124px; }
.ih-node.on {
  border-color: var(--brand-tag); background: rgba(126,162,255,.12);
  box-shadow: 0 0 0 3px rgba(126,162,255,.16);
}
.ih-node.sending {
  border-color: var(--brand-warn); background: rgba(242,160,92,.12);
  box-shadow: 0 0 0 3px rgba(242,160,92,.14);
}
.ih-node.recv {
  border-color: var(--brand-green); background: rgba(95,208,143,.12);
  box-shadow: 0 0 0 3px rgba(95,208,143,.14);
}
.ih-role {
  font: 700 10px/1 var(--sans); letter-spacing: .5px; text-transform: uppercase; color: var(--stone);
}
.ih-node.on .ih-role, .ih-node.sending .ih-role { color: var(--brand-tag); }
.ih-node.recv .ih-role { color: var(--brand-green); }
.ih-title { font: 700 14px/1.2 var(--sans); color: var(--ink); }
.ih-detail {
  font: 500 12px/1.35 var(--mono); color: var(--steel); min-height: 1.3em;
}
.ih-detail b { color: var(--ink); }
.ih-keycap {
  align-self: flex-start;
  min-width: 36px; padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  font: 800 16px/1 var(--mono); color: var(--steel);
  text-align: center;
}
.ih-keycap.hit {
  border-color: rgba(242,160,92,.55);
  background: rgba(242,160,92,.14);
  color: var(--brand-warn);
  animation: hash-entry-land .4s cubic-bezier(.2,1.3,.4,1);
}
.ih-chiprow { display: flex; flex-wrap: wrap; gap: 4px; }
.ih-chip {
  font: 700 10px/1 var(--mono); padding: 3px 6px; border-radius: var(--r-full);
  background: var(--canvas); border: 1px solid var(--hairline); color: var(--steel);
}
.ih-chip b, .ih-chip strong { color: var(--ink); font-weight: 700; }
.ih-code {
  font: 600 12px/1.3 var(--mono); color: var(--steel);
  background: var(--canvas); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 6px 8px;
}
.ih-code .hot { color: var(--brand-tag); }
.ih-code .dim { opacity: .45; }
.ih-slots { display: flex; flex-direction: column; gap: 6px; }
.ih-queue { display: flex; flex-direction: column; gap: 6px; min-height: 44px; }
.ih-qitem {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: 1px solid var(--hairline); border-radius: 6px;
  background: var(--canvas); padding: 6px 8px;
}
.ih-qitem .name { font: 700 13px/1.2 var(--sans); color: var(--ink); }
.ih-qitem .pri { font: 700 11px/1.25 var(--mono); color: var(--steel); }
.ih-qitem.check, .ih-qitem.source {
  border-color: rgba(126,162,255,.5); background: rgba(126,162,255,.12);
}
.ih-qitem.higher {
  border-color: rgba(95,208,143,.55); background: rgba(95,208,143,.14);
}
.ih-qitem.lower {
  border-color: rgba(242,160,92,.55); background: rgba(242,160,92,.14);
}
.ih-qempty {
  font: 600 12px/1.3 var(--mono); color: var(--stone);
  border: 1px dashed var(--hairline); border-radius: 6px;
  background: var(--canvas); padding: 8px;
}
.ih-slot {
  border: 1px solid var(--hairline); border-radius: 6px;
  background: var(--canvas); padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.ih-slot .k {
  font: 700 9px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--stone);
}
.ih-slot .v {
  font: 700 12px/1.2 var(--mono); color: var(--steel);
}
.ih-slot.on {
  border-color: rgba(126,162,255,.45); background: rgba(126,162,255,.1);
}
.ih-slot.on .v { color: var(--brand-tag); }
.ih-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center;
  font: 600 11px/1 var(--sans); color: var(--steel);
}
.ih-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px;
}
.ih-legend .send i { background: var(--brand-warn); }
.ih-legend .recv i { background: var(--brand-green); }
.ih-legend .flow i {
  width: 16px; height: 3px; border-radius: 2px; background: var(--brand-tag); vertical-align: 2px;
}

@media (max-width: 600px) {
  .ih-scroll-hint { display: block; }
  .ih-diagram-scroll {
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--canvas);
    padding-bottom: 4px;
  }
  .ih-stage { min-height: 0; align-items: stretch; width: 100%; }
  .ih-msg { max-width: 100%; }
}

/* How sound is sampled — wave vs sample rectangles */
.ss-panels { grid-template-columns: minmax(220px, .75fr) 1.45fr; }
.ss-stage { min-height: 360px; justify-content: flex-start; gap: 10px; }
.ss-wrap {
  width: 100%; max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.ss-phase {
  font: 700 11px/1 var(--sans); letter-spacing: .4px; text-transform: uppercase; color: var(--steel);
  text-align: center;
}
.ss-caption {
  font: 600 12px/1.3 var(--mono); color: var(--brand-tag); min-height: 1.3em; text-align: center;
}
.ss-diagram-scroll {
  width: 100%; max-width: 100%; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--canvas);
}
.ss-svg { display: block; max-width: none; }
.ss-axis { stroke: var(--hairline); stroke-width: 1.5; }
.ss-axis-label {
  fill: var(--stone); font: 600 10px/1 var(--sans);
}
.ss-wave {
  fill: none; stroke: var(--brand-tag); stroke-width: 2.25;
  stroke-linecap: round; stroke-linejoin: round; opacity: .95;
}
.ss-bar {
  fill: rgba(95,208,143,.28); stroke: var(--brand-green); stroke-width: 1.25;
  transition: fill .2s, stroke .2s;
}
.ss-bar.on {
  fill: rgba(242,160,92,.35); stroke: var(--brand-warn);
}
.ss-dot {
  fill: var(--brand-green); stroke: var(--canvas); stroke-width: 1;
}
.ss-dot.on { fill: var(--brand-warn); }
.ss-level {
  stroke: rgba(126,162,255,.18); stroke-width: 1; stroke-dasharray: 3 4;
}
.ss-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center;
  font: 600 11px/1 var(--sans); color: var(--steel);
}
.ss-legend i {
  display: inline-block; width: 14px; height: 3px; border-radius: 2px;
  margin-right: 4px; vertical-align: 2px;
}
.ss-legend .wave i { background: var(--brand-tag); }
.ss-legend .bar i { width: 10px; height: 10px; background: rgba(95,208,143,.35); border: 1px solid var(--brand-green); vertical-align: -1px; }
.ss-legend .meta { color: var(--stone); font-family: var(--mono); font-weight: 500; }

.ss-controls {
  display: grid; gap: 12px;
  padding: 14px 16px; margin-top: 4px;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface);
}
.ss-slider { display: grid; gap: 6px; }
.ss-slider-label {
  font: 600 13px/1.3 var(--sans); color: var(--ink);
}
.ss-slider-label b { color: var(--brand-tag); font-family: var(--mono); }
.ss-slider-hint {
  font: 500 12px/1.3 var(--sans); color: var(--steel);
}
.ss-slider input[type="range"] {
  width: 100%; accent-color: var(--brand-tag);
}
.ss-play-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.ss-stats {
  font: 500 13px/1.4 var(--mono); color: var(--steel);
  padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--canvas); border: 1px solid var(--hairline);
}
.ss-stats.warn {
  color: var(--brand-warn);
  border-color: rgba(242,160,92,.45);
  background: rgba(242,160,92,.1);
}
.ss-stats code { font-size: 12px; }

.ss-takeaways {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
@media (max-width: 900px) {
  .ss-panels { grid-template-columns: 1fr; }
  .ss-takeaways { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .ss-stage { min-height: 0; }
}
