:root {
  color-scheme: dark;
  --night: #101018;
  --surface: #1a1926;
  --edge: #353343;
  --soft: #b1adbf;
  --type: #f3f2f9;
  --iris: #baabff;
  --mint: #96f4d6;
  --mono: "Cascadia Code", Consolas, monospace;
  font:
    16px/1.5 "Inter",
    "Segoe UI",
    sans-serif;
  background: var(--night);
  color: var(--type);
}
.brand[href] { color:inherit; text-decoration:none; }
.algorithmIntro p { white-space: pre-line; }
.graphView :is(#scroll,#overviewBox,.sizeControl,.field .tools,.gestureHint) { display:none !important; }
.graphView .sceneInputs:empty { display:none; }
#graphScene { display:flex; flex-direction:column; min-height:0; flex:1; gap:6px; }
#graphTools { flex-wrap:wrap; margin:0; }
#graphTools button { min-height:36px; }
#graphCanvas {
  display:flex; flex-direction:column; width:100%; min-height:0; flex:1 1 auto; height:clamp(210px,28vw,355px);
}
.inspectEdgeHit { fill:transparent; pointer-events:all; cursor:pointer; }
#graphMap :is(.inspectEdgeHit,.bfsEdgeHit,.graphWeight):focus { outline:none; }
.inspectedLine { stroke:var(--iris); stroke-opacity:.38; stroke-width:8; pointer-events:none; }
.inspectionCorners { display:none; fill:none; stroke:#c3f2ff; stroke-width:2; stroke-linecap:round; pointer-events:none; }
.bfsNode[data-probe]:focus { outline:none; }
.bfsNode:is([aria-pressed="true"],:focus-visible) .inspectionCorners { display:inline; }
.bfsNode[aria-pressed="true"] .nodeDisk { filter:drop-shadow(0 0 5px #87d9ff); }
.bfsNode[aria-pressed="false"]:focus-visible .inspectionCorners { stroke-dasharray:2 3; }
.graphEdge:has(.inspectEdgeHit:focus-visible) :is(.bfsEdge,.graphArrow,.bfsDirection) { filter:brightness(1.8); }
#graphMap .graphWeight[data-probe] { cursor:pointer; }
.graphWeight[data-probe]:is(:hover,:focus-visible,[aria-pressed="true"]) rect { fill:#352d46; stroke:var(--iris); }
#overflowWeights [aria-pressed="true"] { outline:1px solid var(--iris); outline-offset:-1px; }
.inspectionNumber { color:#185a4a; font-weight:700; font-variant-numeric:tabular-nums; }
#inspectionText { white-space:pre-line; }
#graphMap {
  width:100%; min-height:0; flex:1 1 0; 
  border-radius:12px; touch-action:none;
  background:radial-gradient(ellipse at center,#30284044,transparent 75%),radial-gradient(circle,#81709e3b 1px,transparent 1px);
  background-size:auto,16px 16px;
}
.bfsEdge, .graphArrow, .bfsDirection { stroke:var(--edge-stroke,var(--edge-neutral,#978aa9)); }
.bfsEdge { stroke-width:2; }
.graphEdge.incident { --edge-neutral:#ded2fb; }
.graphEdge.incident:not(.active,.resultEdge) .bfsEdge { stroke-width:3; }
.bfsEdgeHit { stroke:transparent; stroke-width:26px; vector-effect:non-scaling-stroke; pointer-events:stroke; cursor:pointer; }
.graphEdge:has(> .bfsEdgeHit:is(:hover,:focus-visible)) { --edge-stroke:#ffa2ad; }
.graphEdge:has(> .bfsEdgeHit:is(:hover,:focus-visible)) .bfsEdge { stroke-width:4; }
.bfsEdgePreview { stroke:#ffce9d; stroke-width:3; stroke-dasharray:6 4; pointer-events:none; }
#graphMap:is([data-tool="start"],[data-tool="add"]) .bfsNode { cursor:grab; }
#graphMap[data-tool="link"] { cursor:crosshair; }
#graphMap[data-tool="link"] .bfsNode { cursor:crosshair; }
.graphEdge.active { --edge-stroke:#ffce9d; }
.graphEdge.active .bfsEdge { stroke-width:4; stroke-dasharray:7 4; }
.graphEdge.resultEdge { --edge-stroke:var(--mint); }
.graphEdge.resultEdge .bfsEdge { stroke-width:4; }
.graphEdge.conflict { --edge-stroke:#ff839b; }
.goalRing { fill:none; stroke:#ffce9d; stroke-width:2; stroke-dasharray:4 3; }
.graphArrow { fill:none; stroke-width:2.5; pointer-events:none; }
.graphWeight rect { fill:transparent; stroke:none; }
.graphWeight text { fill:#dbd1e8; stroke:none; font:500 13px var(--mono); font-variant-numeric:tabular-nums; }
.graphWeight:is(:focus-visible,[data-weight]:hover) rect { fill:#342d46; stroke:var(--iris); }
.graphWeight[data-weight] { cursor:pointer; }
#overflowWeights:not([hidden]) { display:flex; align-items:center; gap:6px; flex:none; overflow-x:auto; padding:3px 2px; scrollbar-width:thin; }
#overflowWeights > * { flex:none; display:inline-flex; align-items:center; gap:6px; padding:3px 6px; color:var(--soft); font:12px var(--mono); }
#overflowWeights svg { width:auto; height:20px; }
.legendSample svg:has(.graphWeight) { width:auto; max-width:100%; }
#graphWeightEditor { display:flex; align-items:center; gap:8px; color:var(--soft); }
#graphWeightEditor input { width:70px; background:var(--surface); }
.matrixScroll { max-height:clamp(76px,18vh,190px); overflow:auto; }
.graphMatrix { border-collapse:collapse; font:12px var(--mono); }
.graphMatrix td { padding:2px 6px; text-align:center; border:1px solid var(--edge); }
.graphMatrix .matrixAxis { color:var(--iris); }
.graphMatrix .matrixFocus { background:var(--mint); color:#193029; }
.bfsDirection { fill:none; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }
#graphMap .graphEdge :is(.graphArrow,.bfsDirection) {
  fill:var(--edge-stroke,var(--edge-neutral,#978aa9)); stroke-width:1; stroke-linejoin:round; pointer-events:none;
}
.bfsNode { cursor:pointer; }
#graphMap { --node-surface:url(#graphNodeFace); }
.nodeDisk { fill:var(--node-surface,#292438); stroke:#ab9bbc; stroke-width:2; }
.bfsNode text { fill:#f4eefc; font:600 15px var(--mono); }
@media (max-width:600px) {
  #graphMap .bfsNode > text:not(.bfsRole) { font-size:18px; }
}
.startRing { fill:none; stroke:#bba7ff; stroke-width:2; }
.bfsNode.seen .nodeDisk { fill:#645683; stroke:#cbbaed; }
#legendToggle, #legendClose {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  color: var(--iris); background: transparent;
}
#legendToggle:hover, #legendClose:hover { color: var(--type); background: #373045; }
#legendToggle svg { width: 20px; height: 20px; }
#sceneLegend {
  width: min(430px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  box-sizing: border-box; margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain;
  color: var(--type); background: var(--surface); border: 1px solid #675a81;
  border-radius: 16px; box-shadow: 0 16px 60px #09081099;
}
#sceneLegend::backdrop { background: #090810aa; }
#sceneLegend header {
  position: sticky; top: 0; z-index: 1; padding: 10px 14px 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: #201e2c; border-bottom: 1px solid var(--edge);
}
#legendItems { list-style: none; margin: 0; padding: 4px 18px 10px; }
#legendItems li {
  display: grid; grid-template-columns: 48px 1fr; align-items: center;
  gap: 12px; padding: 8px 0; font-size: .92rem; line-height: 1.4;
}
#legendItems li + li { border-top: 1px solid var(--edge); }
.legendSample { display: grid; place-items: center; color: var(--soft); font: 600 .82rem var(--mono); }
.legendSample svg { display: block; width: 44px; pointer-events: none; }
.legendSample .visitMark { width: 14px; }
.legendSample [data-symbol] { text-align: center; }
.legendSample :is([data-symbol="edge"],[data-symbol="swap"]) { font: 28px/1 var(--mono); }
.legendSample [data-symbol="swap"] { color: #ffce9d; }
.legendSample :is([data-symbol="weight"],[data-symbol="cost"],[data-symbol="flow"],[data-symbol="cell"],[data-symbol="held"],[data-symbol="faded"],[data-symbol="picked"]) {
  min-width: 25px; padding: 2px 4px; border: 1px solid #766989; border-radius: 5px; background: #30293e; color: var(--type);
}
.legendSample [data-symbol="picked"] { color: #143a32; background: var(--mint); }
.legendSample [data-symbol="held"] { color: #352315; background: #ffcc9c; }
.legendSample [data-symbol="faded"] { opacity: .44; }
.legendSample :is([data-symbol="bar"],[data-symbol="activeBar"],[data-symbol="wrong"])::before {
  content: "4"; display: block; margin-bottom: 2px; padding: 3px 4px; color: #191523;
  border-radius: 2px 2px 0 0; background: #aa96f5; border-right: 3px solid #5846a6;
}
.legendSample [data-symbol="activeBar"]::before { background: var(--mint); border-color: #368f83; }
.legendSample [data-symbol="wrong"]::before { background: #ce7789; border-color: #984e62; }
@media (pointer: coarse) {
  #legendToggle, #legendClose { width: 44px; height: 44px; }
}
.visitHatch {fill:none;stroke:#d0c1e6;stroke-width:6.5;pointer-events:none}
.bfsNode.current .visitHatch {stroke:#427565}
.visitMark {pointer-events:none;flex:none}
.visitMark circle {fill:#d4c6ef;stroke:var(--night)}
.visitMark path {fill:none;stroke:#30213e;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.visitKey {display:inline-flex;align-items:center;gap:4px;margin-inline-start:auto;white-space:nowrap;color:var(--soft);font-family:var(--mono)}
.bfsNode.taken .nodeDisk { fill:#355049; stroke:#87b3a5; }
.bfsNode.current .nodeDisk { fill:#abf5d8; stroke:#dbfff0; }
.bfsNode.current text { fill:#18332c; }
.bfsNode text.bfsRole { font:600 12px var(--mono); fill:#f4eefc; stroke:#211d2d; stroke-width:3; paint-order:stroke; }
.bfsNode:is(.neighbor,.endpoint,:not([data-probe]):focus-visible) .nodeDisk { stroke:#ffce9d; stroke-width:4; }
#graphHelp { font-size:.84rem; color:var(--soft); margin:4px 0; }
#graphStats { flex:none; display:grid; gap:4px; }
[data-mode="run"] #graphStats {max-height:45%;overflow:auto;scrollbar-width:thin}
.bfsNode.current .nodeDisk[style] ~ text:not(.bfsRole) {fill:white}
.bfsNode.current .nodeDisk[style] ~ .visitHatch {stroke:#d0c1e6}
.graphRow { display:flex; gap:6px; align-items:center; font: .79rem var(--mono); }
.graphRow > button { min-width:74px; text-align:start; border:0; background:none; color:var(--soft); padding:4px; }
.graphChips { min-width:0; display:flex; gap:4px; align-items:center; overflow:auto; scrollbar-width:thin; color:var(--soft); }
.graphChips button { padding:3px 6px; background:#352e45; color:#d4c4ee; }
[data-list="queue"] button:first-child { background:var(--mint); color:#14332a; }
.bfsLayer { margin-inline-start:auto; flex:none; color:var(--mint); }
@media (max-width:920px) {
  .graphView .sceneInputs { justify-content:flex-end; }
  #graphTools button { padding:5px 8px; }
  #graphCanvas { height:100px; }
  #graphStats { gap:1px; }
}
.algorithmIntro p:empty { display: none; }
#algorithm { min-width: 0; text-overflow: ellipsis; }
.rowPicker { display: flex; align-items: center; gap: 3px; padding: 3px; margin: 0 0 6px; align-self: flex-start; width: fit-content; border: 1px solid var(--edge); border-radius: 10px; }
.rowPicker button { padding: 5px 12px; border: 0; background: transparent; color: var(--soft); }
.rowPicker button[aria-pressed="true"] { color: #181521; background: var(--iris); }
.bandCaption { font: 600 12px var(--mono); fill: var(--mint); }
#bars .gapBar :is(.front,.side,.lid,.num,.barVariable) { opacity: .12; }
#bars .gapBar .front { stroke: var(--mint); stroke-dasharray: 4 3; }
.mergeView :is(#scroll,#overviewBox,#sceneVars) { display: none !important; }
#arrayLanes { min-height: 0; overflow: auto; scrollbar-width: thin; }
.laneCell.pendingWrite .laneNumber { border-style: dashed; opacity: .68; }
.lisPath { stroke:var(--mint); fill:none; stroke-width:2; stroke-dasharray:6 3; }
.fractionScene { flex:1; display:flex; flex-direction:column; justify-content:safe center; gap:10px; }
.fractionList { overflow:auto; min-height:0; scrollbar-width:thin; }
.fractionRow { display:grid; grid-template-columns:.7fr 1fr 1fr 1.3fr 1.4fr; align-items:center; gap:4px; padding:6px 3px; border-bottom:1px solid var(--edge); }
.fractionRow .laneNumber,.fractionRow .laneName,.fractionStatus .laneName { min-width:0; max-width:100%; padding:2px; white-space:normal; font:600 13px var(--mono); text-align:center; }
.fractionRow.chosen .laneName:first-child { color:var(--mint); }
.fractionRow.current { outline:2px dashed var(--iris); outline-offset:-2px; }
.fractionHeading { position:sticky; top:0; background:#221f31; z-index:1; }
.fractionPiece,.fractionLoad { position:relative; border:1px solid var(--edge); border-radius:4px; overflow:hidden; background:repeating-linear-gradient(130deg,transparent 0 5px,#3c354c 5px 6px); }
.fractionPiece { height:26px; }
.fractionPiece span { display:block; height:100%; background:#37564f; border-inline-end:1px solid var(--mint); }
.fractionPiece strong { position:absolute; inset:0; display:grid; place-items:center; color:white; font:600 12px var(--mono); }
.fractionLoad { display:flex; height:clamp(22px,4vh,36px); flex:none; }
.fractionLoad span { min-width:0; overflow:hidden; display:grid; place-items:center; border-inline-end:2px solid #222031; color:#152821; background:var(--mint); font:600 13px var(--mono); }
.fractionLoad span:nth-child(even) { background:#bcafff; }
.fractionStatus { display:flex; justify-content:space-between; }
@media (max-width:920px) {
  .fractionScene { gap:3px; }
  .fractionRow { padding:2px; }
  .fractionRow .laneNumber,.fractionRow .laneName,.fractionStatus .laneName { font-size:11px; }
}
.queensView :is(#scroll,#overviewBox,.field .tools,.gestureHint) { display:none !important; }
.scalarView :is(#scroll,#overviewBox,.sceneInputs .sizeControl,.field .tools,.gestureHint) { display:none !important; }
.scalarLayout,.scalarPlot { display:flex; flex-direction:column; justify-content:safe center; gap:8px; min-height:0; }
.scalarLayout { flex:1; padding:6px; }
.scalarFields { display:flex; flex-wrap:wrap; gap:8px; }
.scalarFields[hidden] { display:none; }
.scalarFields label { display:flex; align-items:center; gap:5px; font:600 15px var(--mono); }
.scalarFields input { width:5.4em; max-width:100%; padding:4px; font:inherit; }
.euclidFormula { color:var(--mint); font:600 clamp(17px,2.4vw,27px) var(--mono); }
.euclidRow { display:grid; grid-template-columns:minmax(56px,auto) 1fr; align-items:center; gap:6px; direction:ltr; font:600 13px var(--mono); }
.euclidTrack { display:flex; align-items:center; width:100%; height:27px; background:#282333; border-radius:4px; }
.euclidMeasure,.euclidGroups { display:flex; height:100%; }
.euclidGroups,.euclidSolid,.euclidRest { min-width:0; white-space:nowrap; overflow:hidden; background:#786399; color:white; border-radius:3px; align-content:center; text-align:center; }
.euclidSolid { width:100%; }
.euclidGroups { align-items:center; justify-content:center; }
.euclidGroups i { flex:1; min-width:0; border-inline-end:1px solid #211b2b; overflow:hidden; font-style:normal; }
.euclidRest { background:repeating-linear-gradient(45deg,#b8edd9 0 5px,#9edbc3 5px 9px); color:#172d26; }
.euclidNext { color:var(--mint); font:600 14px var(--mono); direction:ltr; }
.euclidHistory { display:flex; flex-wrap:wrap; gap:4px; max-height:72px; overflow:auto; direction:ltr; }
.euclidHistory button { padding:2px 6px; font:600 12px var(--mono); }
.euclidHistory [aria-current] { outline:2px solid var(--mint); outline-offset:-2px; }
.powerFormula,.powerWork,.powerBits,.powerFactors { direction:ltr; }
.powerFormula { color:var(--mint); font:650 clamp(20px,3vw,32px) var(--mono); overflow-wrap:anywhere; }
.powerRaised { white-space:nowrap; }
.powerRaised sup { font-size:.65em; }
.bezoutFormula,.bezoutOp { direction:ltr; color:var(--mint); font:600 clamp(14px,2.4vw,25px) var(--mono); overflow-wrap:anywhere; }
.bezoutOp { font-size:clamp(13px,1.8vw,18px); }
.bezoutTable { direction:ltr; border-spacing:3px; table-layout:fixed; max-width:540px; width:100%; text-align:center; font:600 clamp(14px,2vw,20px) var(--mono); }
.bezoutTable th,.bezoutTable td { padding:3px; border-radius:3px; }
.bezoutTable tbody td { background:#312b3c; }
.bezoutArithmetic { display:block; font-size:clamp(10px,1.3vw,14px); font-weight:400; }
.bezoutTable th:first-child { width:10%; }
.bezoutTable .current td { background:#284238; box-shadow:inset 0 -2px #81cfb3; color:#c1fae3; }
.bezoutHistory button { min-height:26px; }
.geometryLayout { min-height:0; }
.geometryLayout .scalarPlot { align-items:center; gap:4px; min-height:0; }
.geometryLayout .scalarFields { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:repeat(2,auto); grid-auto-flow:column; gap:3px 6px; }
.geometryLayout .scalarFields[hidden] { display:none; }
.geometryLayout .scalarFields label { font-size:12px; }
.geometryLayout .scalarFields input { width:3.6em; padding:2px; }
.geometryPlane { display:block; min-height:0; max-height:min(47vh,410px); width:min(100%,580px); }
.geometryPlane.editable { touch-action:none; }
.geometryPlane .geoGrid { stroke:#4a4157; stroke-width:.7; }
.geometryPlane .geoAxis { stroke:#8f839e; stroke-width:1; }
.geoAxisLabel,.geoPointLabel { fill:#dcd4e8; font:600 10px var(--mono); paint-order:stroke; stroke:#24202e; stroke-width:2px; pointer-events:none; }
.geoPointLabel { fill:white; font-size:12px; }
.geoFirst,.geoSecond,.geoComponent,.geoReference { fill:none; stroke-width:2.4; }
.geoFirst { stroke:#b7a8ff; }
.geoSecond { stroke:#8ee4c0; }
.geoComponent { stroke:#ffc480; stroke-dasharray:3 2; }
.geoReference { stroke:#a99bae; stroke-width:1; stroke-dasharray:4 3; }
.geoArea { fill:#7dc8ac; fill-opacity:.16; }
.geoExtension { stroke:#fae3b4; stroke-width:1; stroke-dasharray:2 2; }
.geoTurn { fill:none; stroke:#ffc480; stroke-width:1.8; }
.segmentsLayout .scalarFields { grid-template-columns:repeat(4,minmax(0,1fr)); }
.segmentHistory { display:flex; flex-wrap:wrap; justify-content:center; gap:4px; }
.segmentHistory button { padding:2px 6px; min-height:24px; font:600 12px var(--mono); }
.segCommonPoint { fill:none; stroke:#ffd792; stroke-width:2.5; }
.segCommonLine { stroke:#ffd792; stroke-width:5; stroke-linecap:round; }
.hullLayout .scalarFields:empty { display:none; }
.hullEditor { display:flex; flex-wrap:wrap; justify-content:center; gap:4px; align-items:center; }
.hullEditor label { display:flex; align-items:center; gap:2px; font:600 13px var(--mono); }
.hullEditor input { width:3.3em; padding:3px; }
.hullEditor :is(button,input,select) { min-height:28px; }
.hullEditor :is(button,select) { padding:2px 6px; }
.hullCandidate,.hullVertex,.hullRemoved { fill:none; stroke:#ffc480; stroke-width:2; }
.hullVertex { stroke:#9ce7c9; }
.hullRemoved { stroke:#ffa3a7; stroke-dasharray:3 2; }
.hullLayout .geometryResult { overflow-wrap:anywhere; }
.hullHistory { max-height:56px; overflow:auto; }
@media (max-width:920px) {
  .hullLayout .geometryPlane { max-height:19vh; }
  .hullHistory { flex:none; }
  .hullHistory button { min-width:28px; min-height:28px; }
}
@media (max-width:920px) {
  .segmentsLayout .geometryPlane { max-height:22vh; }
}
.geoPoint { fill:#fff; stroke:#26222e; stroke-width:1.5; }
.geoTouch { fill:transparent; cursor:grab; }
.geoTouch:active { cursor:grabbing; }
.geometryResult { text-align:center; font:600 clamp(13px,1.9vw,22px) var(--mono); color:var(--mint); }
@media (max-width:920px) {
  .geometryPlane { max-height:26vh; }
  .geometryLayout .scalarFields { gap:1px 5px; }
  .geometryLayout .scalarFields input { height:24px; }
}
.inverseLayout { display:flex; align-items:center; gap:clamp(7px,2vw,20px); }
.inverseDial { width:clamp(100px,32%,210px); flex:none; }
.inverseRing,.inverseTick { fill:none; stroke:#a99abd; stroke-width:2; }
.inverseGoal { fill:none; stroke:#ffc480; stroke-width:3; }
.inverseHand { stroke:#9ce7c9; stroke-width:3; }
.inverseCenter,.inverseTickLabel { text-anchor:middle; dominant-baseline:middle; fill:#f3eef9; font:600 10px var(--mono); }
.inverseCenter { font-size:17px; paint-order:stroke; stroke:#252031; stroke-width:4px; }
.inverseInfo { display:grid; min-width:0; gap:7px; }
.inverseTitle,.inverseEquation,.inverseGcd { font:600 clamp(12px,1.8vw,20px) var(--mono); overflow-wrap:anywhere; }
.inverseTitle { color:var(--mint); }
.inverseEquation { direction:ltr; }
.inverseGcd { font-size:13px; }
.inverseControls { display:flex; flex-wrap:wrap; gap:4px; }
.inverseControls button { min-height:28px; padding:3px 6px; font-size:12px; }
@media (max-width:920px) {
  .inverseDial { width:43%; }
  .inverseTickLabel { font-size:13px; }
}
.powerCaption { color:var(--muted); font:600 13px var(--sans, sans-serif); }
.powerBits,.powerFactors { display:flex; align-items:center; flex-wrap:wrap; gap:5px; }
.powerBit { display:grid; min-width:38px; min-height:46px; place-content:center; text-align:center; border:1px solid #736882; border-radius:5px; background:#332e3d; color:#f0ebf9; padding:3px 6px; font-family:var(--mono); }
.powerBit small { font-size:11px; }
.powerBit strong { font-size:19px; }
@media (min-width:921px) {
  .powerBit { min-width:58px; min-height:65px; }
  .powerBit strong { font-size:25px; }
  .powerBit small,.powerCaption { font-size:14px; }
}
.powerBit.taken { color:#b9f4dc; background:#284337; border-color:#81cfb3; }
.powerBit.skipped { border-style:dashed; }
.powerBit[aria-current] { outline:2px solid #ffc480; outline-offset:1px; }
.powerWork { align-self:stretch; background:#302a3a; padding:6px 9px; border-inline-start:3px solid var(--iris); font:600 clamp(13px,1.7vw,18px) var(--mono); overflow-wrap:anywhere; }
.powerFactors { font:600 clamp(12px,1.4vw,16px) var(--mono); }
.powerFactors button { color:var(--mint); min-height:30px; padding:2px 6px; }
.scalarPlot:has(.sieveGrid) { flex:1; min-height:0; }
.sieveHead { display:flex; justify-content:space-between; align-items:center; gap:5px; font:600 14px var(--mono); }
.sieveHead strong { color:var(--mint); }
.sieveScroll { overflow:auto; max-height:min(46vh,410px); min-height:0; padding:2px; scrollbar-width:thin; }
.sieveGrid { display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); gap:3px; max-width:540px; margin:auto; direction:ltr; }
.sieveGrid button { min-width:0; padding:4px 1px; border:1px solid #5b506b; border-radius:4px; background:#393241; color:#efeaf7; font:600 clamp(12px,1.8vw,18px) var(--mono); }
.sieveGrid button:not([data-step]) { cursor:default; }
.sieveGrid .crossed { text-decoration:line-through; color:#c7bdd0; background:#27232f; }
.sieveGrid .neither { border-style:dotted; color:#aba2b3; background:transparent; }
.sieveGrid .prime { color:#b8f5de; background:#264237; border-color:#81cfb3; }
.sieveGrid .factor { border-bottom:3px solid #ffc480; }
.sieveGrid .current { outline:2px dashed var(--iris); outline-offset:-2px; }
@media (max-width:920px) {
  .sieveGrid { gap:2px; }
  .sieveGrid button { padding:4px 0; min-height:26px; }
}
.queenLayout { flex:1; display:grid; grid-template-columns:minmax(0,3fr) minmax(84px,2fr); align-items:center; gap:10px; min-height:0; container-type:size; }
body.queensView[data-mode="setup"]:not(.lessonPreview) .queenLayout { height:clamp(170px,35vh,360px); }
.queenGrid { direction:ltr; width:min(100%,94cqh); aspect-ratio:1; justify-self:center; display:grid; grid-template-columns:repeat(var(--squares),1fr); grid-template-rows:repeat(var(--squares),1fr); background:#343046; border:1px solid #786f90; border-radius:4px; overflow:hidden; }
.queenSquare { position:relative; border:0; padding:0; margin:0; border-radius:0; min-height:0; min-width:0; display:grid; place-items:center; color:#272336; background:#d5cde5; font:600 clamp(13px,calc(73cqh / var(--squares)),55px)/1 Georgia,serif; }
.queenSquare.dark { background:#9586a7; color:#272336; }
.queenSquare.clue { box-shadow:inset 0 0 0 2px #ad7500; }
.queenSquare.trial,.queenSquare:focus-visible { outline:2px dashed #241b37; outline-offset:-3px; background:#9aecd6; color:#231a30; }
.queenSquare.attack { background:repeating-linear-gradient(45deg,#f8afa4 0 4px,#f9c4af 4px 8px); color:#391922; }
.queenSquare small { position:absolute; font:600 clamp(8px,2.4cqh,12px)/1 var(--mono); }
.queenSquare .queenRank { inset:2px auto auto 2px; }
.queenSquare .queenFile { inset:auto 2px 2px auto; }
.queenSide { min-height:0; max-height:96%; display:flex; flex-direction:column; gap:6px; overflow:auto; }
.queenSide strong { color:var(--mint); }
.queenSide span { color:var(--soft); }
.queenSolutions { display:flex; flex-direction:column; align-items:start; gap:4px; overflow:auto; }
.queenSolutions button { direction:ltr; text-align:start; font:600 clamp(11px,1.5vw,16px) var(--mono); padding:3px 6px; }
.queenSolutions [aria-current] { outline:1px solid var(--mint); outline-offset:-2px; }
.subsetScene { display:flex; flex:1; flex-direction:column; justify-content:safe center; gap:clamp(4px,1.5vh,16px); min-height:0; }
.subsetTreeBox { min-height:0; flex:0 1 32%; }
.subsetTree { display:block; width:100%; height:100%; max-height:220px; overflow:visible; font:600 11px var(--mono); }
.subsetTree line { stroke:#65577f; stroke-width:1.5; }
.subsetTree line.selected { stroke:var(--mint); stroke-width:2.4; stroke-dasharray:5 2; }
.subsetTree :is(circle,rect) { fill:#312a40; stroke:#8b7baf; }
.subsetTree .onPath :is(circle,rect),.subsetTree .saved rect { stroke:var(--mint); }
.subsetTree .saved { cursor:pointer; }
.subsetTree text { text-anchor:middle; fill:#f4f0fa; }
.subsetTree .edgeLabel { fill:var(--soft); paint-order:stroke; stroke:#211e2c; stroke-width:3px; }
.permStrip { position:relative; margin:0 6px; padding-top:34px; }
.permCards { display:flex; gap:4px; justify-content:center; }
.permCard { flex:1 1 0; min-width:0; max-width:none; padding:9px 2px; background:#362e49; color:inherit; border:1px solid var(--edge); border-radius:6px; font:600 clamp(14px,2.1vw,25px) var(--mono); cursor:pointer; }
.permCard small { display:block; font-size:11px; color:var(--soft); }
.permCard.fixed { border-bottom:3px solid var(--mint); background:#29433b; }
.permCard.slot { outline:2px dashed var(--iris); outline-offset:-2px; }
.permCard.candidate small::before { content:"◆ "; color:var(--mint); }
.permArc { position:absolute; inset:0 0 auto; height:32px; }
.permBracket { position:absolute; bottom:0; min-width:12px; height:17px; color:var(--mint); border:2px solid currentColor; border-bottom:0; border-radius:8px 8px 0 0; font:600 16px var(--mono); text-align:center; }
.permPair { margin-inline-start:auto; }
.permStatus { display:flex; align-items:center; gap:7px; color:var(--mint); font:600 13px var(--mono); }
@media (max-width:920px) { .permCard { padding:3px 1px; } .permStrip { padding-top:25px; } .permArc { height:24px; } }
.subsetCards { display:flex; justify-content:center; flex-wrap:wrap; gap:5px; }
.subsetCard,.subsetResult { padding:5px 9px; border:1px solid var(--edge); border-radius:6px; background:#322a44; color:inherit; font:600 14px var(--mono); cursor:pointer; }
.subsetCard small { display:block; font-size:10px; color:var(--soft); }
.subsetCard.current { outline:2px dashed var(--iris); outline-offset:1px; }
.subsetCard.omitted { text-decoration:line-through; opacity:.65; }
.subsetCard.kept { background:#29473e; border-bottom:3px solid var(--mint); }
.subsetBranch { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px 10px; justify-items:center; font:600 14px var(--mono); color:var(--soft); }
.subsetFork { grid-column:1/-1; border:1px solid var(--iris); border-radius:18px; padding:2px 12px; }
.subsetBranch span { padding:2px 8px; border-radius:5px; }
.subsetBranch .active,.subsetResult[aria-current] { outline:2px solid var(--mint); color:var(--mint); background:#29403a; }
.subsetPath,.subsetSummary { display:flex; align-items:center; justify-content:space-between; gap:8px; font:600 14px var(--mono); }
.subsetPath[hidden] { display:none; }
.subsetResults { display:flex; flex-wrap:wrap; align-content:start; gap:4px; max-height:40%; overflow:auto; min-height:22px; scrollbar-width:thin; }
@media (max-width:920px) {
  .subsetScene { gap:3px; }
  .subsetTreeBox { flex:0 1 auto; }
  .subsetTree { height:auto; max-height:110px; font-size:14px; }
  .subsetBranch:empty { display:none; }
  .subsetCard,.subsetResult,.subsetPath,.subsetSummary,.subsetBranch { font-size:12px; }
  .subsetCard,.subsetResult { padding:2px 6px; }
}
.intervalScene { flex:1; display:flex; flex-direction:column; justify-content:safe center; gap:8px; }
.intervalHeader,.intervalRow { display:grid; grid-template-columns:clamp(72px,20%,128px) minmax(0,1fr); align-items:center; gap:8px; padding:2px 6px; }
.intervalHeader > div,.intervalFooter { display:flex; justify-content:space-between; color:var(--soft); font:12px var(--mono); }
.intervalHeader > div { direction:ltr; position:relative; height:1.3em; }
.intervalHeader > div span { position:absolute; transform:translateX(-50%); }
.intervalHeader > div span:first-child { transform:none; }
.intervalHeader > div span:last-child:not(:first-child) { transform:translateX(-100%); }
.intervalList { overflow:auto; min-height:0; scrollbar-width:thin; }
.intervalRow { min-height:clamp(27px,5vh,52px); border-bottom:1px solid var(--edge); }
.intervalId { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:2px 5px; background:none; color:var(--soft); border:0; font:600 12px var(--mono); cursor:pointer; padding:0; }
.intervalRange { font-size:12px; white-space:nowrap; }
.intervalScale { position:relative; border-bottom:1px solid var(--edge); height:24px; }
.intervalBar { position:absolute; top:4px; bottom:2px; min-width:3px; border:1px solid var(--iris); border-radius:4px; background:#594780; }
.intervalRow.current { outline:2px dashed var(--iris); outline-offset:-2px; }
.intervalRow.chosen .intervalBar { background:var(--mint); border-color:var(--mint); }
.intervalRow.excluded .intervalBar,.intervalBar.invalid { background:repeating-linear-gradient(130deg,transparent 0 4px,#76698a 4px 6px); border-style:dashed; }
.intervalMarker { position:absolute; top:0; bottom:-2px; border-left:2px dashed #fff; pointer-events:none; }
.intervalRow.chosen .intervalId { color:var(--mint); }
@media (max-width:920px) {
  .intervalScene { gap:3px; }
  .intervalHeader,.intervalRow { grid-template-columns:98px minmax(0,1fr); }
  .intervalRange { font-size:10px; }
  .intervalRow { min-height:23px; }
  .intervalScale { height:18px; }
  .intervalHeader .laneName,.intervalFooter .laneName { font-size:11px; }
}
.lisLane { flex-direction:column; }
.recoveryScene { flex:1; display:flex; flex-direction:column; justify-content:safe center; gap:clamp(4px,1vh,12px); }
.recoveryCaption,.recoveryStatus { display:flex; justify-content:space-between; align-items:center; gap:8px; color:var(--soft); font:600 12px var(--mono); }
.recoveryStatus strong { color:var(--mint); }
.recoveryScroll { overflow:auto; min-height:0; scrollbar-width:thin; }
.recoveryGrid { width:100%; table-layout:auto; border-spacing:3px; font:600 clamp(12px,1.3vw,19px) var(--mono); text-align:center; }
.recoveryGrid td,.recoveryGrid th { min-width:33px; height:clamp(27px,5vh,52px); padding:3px; border-radius:5px; }
.recoveryGrid th { background:var(--panel); color:var(--soft); }
.recoveryGrid thead th { position:sticky; top:0; z-index:2; }
.recoveryGrid tr th:first-child { position:sticky; left:0; z-index:1; min-width:65px; }
.recoveryGrid thead th:first-child { z-index:3; max-width:110px; font-size:.8em; }
.recoveryGrid th small { display:block; font-size:.8em; }
.recoveryGrid th.chosen::before { content:"✓ "; color:var(--mint); }
.recoveryGrid td { position:relative; border:1px solid var(--edge); background:#29243c; }
.recoveryGrid td.route { background:#413559; border-bottom:3px solid var(--iris); }
.recoveryGrid td[data-arrow]::before { content:attr(data-arrow); position:absolute; inset:0 auto auto 2px; color:var(--mint); font-size:.75em; }
.recoveryGrid .above,.recoveryGrid .reading { outline:2px dashed var(--iris); outline-offset:-2px; }
.recoveryGrid td.current { background:var(--mint); color:#172a27; outline:2px solid var(--mint); }
@media (prefers-reduced-motion:no-preference) {
  .recoveryGrid td.current { transition:background-color .18s ease, outline-color .18s ease; }
  .recoveryGrid th.chosen::before { display:inline-block; animation:recoverTick .2s ease-out; }
  @keyframes recoverTick { from { opacity:.2; transform:translateY(-3px); } to { opacity:1; transform:none; } }
}
@media (max-width:920px) {
  .recoveryGrid { border-spacing:2px; }
  .recoveryGrid td,.recoveryGrid th { min-width:27px; height:25px; padding:1px; }
  .recoveryGrid th small { display:inline; margin-left:3px; }
  .recoveryScene .laneName,.recoveryCaption,.recoveryStatus { font-size:11px; }
}
.lisLane .laneTrack { width:100%; }
.lisLane .lisCell { flex:1 0 34px; min-width:34px; }
.lisCell .laneNumber { width:100%; }
.lisCell.read .laneNumber { outline:2px dashed var(--iris); outline-offset:-2px; }
.lisCell.write .laneNumber { outline:2px solid var(--mint); outline-offset:-2px; }
.lisCell.outside { opacity:.64; }
.lisCell small { color:var(--soft); font:11px var(--mono); }
.pivotOutline { fill: none; stroke: var(--mint); stroke-width: 2; stroke-dasharray: 4 2; pointer-events: none; }
.mergeLanes { display: flex; flex: 1; flex-direction: column; justify-content: safe center; gap: clamp(4px,2vh,20px); }
.heapSortLanes { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 8px; }
.heapSortTree { width: 100%; min-height: 0; max-height: 75%; }
.heapSortTree [role="button"] { cursor: pointer; }
.heapSortTree [role="button"]:focus-visible circle { stroke: var(--mint); stroke-width: 3; }
.heapSortIndex { fill: var(--soft); text-anchor: middle; font: 11px var(--mono); paint-order: stroke; stroke: #201d2d; stroke-width: 3px; }
.heapSortRow .laneCell small { color: var(--soft); font: 11px var(--mono); }
.heapSortRow .heapSorted small { color: var(--mint); }
.heapSortRow .heapSorted .laneNumber { border-style: dashed; }
.counterRow .laneName { white-space: normal; max-width: 6rem; }
.counterRow .laneTrack { align-items: center; padding: 2px; }
.counterCell { flex: none; display: grid; justify-items: center; min-width: 36px; padding: 3px 5px;
  border: 1px solid #695a95; border-radius: 6px; background: #302745; color: #eee9ff; font: 14px var(--mono); }
.counterCell span { color: #d3c7ef; font-size: 11px; }
.counterCell.current { outline: 2px solid var(--mint); outline-offset: -2px; background: #29433f; }
.counterGap { color: var(--soft); }
#rangeInputs:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; padding: 3px 8px; }
#rangeInputs label { display: flex; gap: 6px; align-items: center; font-size: .8rem; }
#rangeInputs input { width: 4.1em; padding: 4px; background: var(--panel); color: inherit; border: 1px solid var(--edge); border-radius: 5px; font: inherit; }
.bagScene { display: flex; flex: 1; flex-direction: column; justify-content: safe center; gap: clamp(10px,4vh,36px); }
.bagItems { display: flex; align-items: flex-end; gap: 8px; }
.bagLabels { display: grid; align-items: center; gap: 4px; }
.bagLabels { flex: none; padding-bottom: 5px; }
.bagLabels .laneName { min-height: 27px; padding: 2px; text-align: start; }
.bagItems .laneTrack { padding: 3px; }
.bagItems .bagCard { display: grid; align-items: stretch; gap: 4px; flex: 0 0 58px; padding: 4px; border: 1px solid var(--edge); border-radius: 8px; text-align: center; }
.bagCard small { color: var(--soft); font: 11px var(--mono); }
.bagCard .laneNumber { min-height: 27px; }
.bagCard.current { outline: 2px solid var(--mint); outline-offset: -1px; }
.bagCard.chosen { border-color: var(--mint); }
.bagLoad { position: relative; flex: none; height: 23px; overflow: hidden; border: 1px solid var(--edge);
  border-radius: 5px; background: repeating-linear-gradient(120deg, transparent 0 5px, #514761 5px 6px); }
.bagLoad > span { display: block; height: 100%; background: #355a52; border-inline-end: 2px solid var(--mint); box-sizing: border-box; }
.bagLoad strong { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 600 12px var(--mono); text-shadow: 0 1px 3px #201d2d; }
@media (min-width: 921px) {
  .bagItems .bagCard { flex-basis: 84px; padding: 8px; }
  .bagLabels .laneName, .bagCard .laneNumber { min-height: 36px; }
}
@media (max-width: 920px) {
  .bagScene { gap: 6px; }
  .bagLoad { height: 18px; }
}
.bagCard.chosen small { color: var(--mint); }
.bagScene .dpTable, .extraLanes .dpTable { flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 4px 2px; }
.dpTable .laneTrack { padding: 2px 0; }
.dpTable .coinCell { flex: 1 0 34px; min-width: 34px; }
.coinCell .laneNumber { width: 100%; min-height: 32px; }
.coinCell .coinPointer { color: var(--mint); }
.coinCaption { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.coinCaption .laneName { padding-inline: 0; white-space: normal; text-align: start; }
.coinCaption strong { color: var(--mint); font: 600 12px var(--mono); overflow-wrap: anywhere; }
.coinCell small { color: var(--soft); font: 11px var(--mono); }
.coinSource .laneNumber { border: 2px dashed var(--mint); }
.coinDestination .laneNumber { box-shadow: inset 0 0 0 2px var(--mint); }
@media (min-width: 921px) {
  .extraLanes .dpTable { padding: 12px 5px 5px; gap: 8px; }
  .coinCaption strong { font-size: 15px; }
  .coinCell .laneNumber { min-height: 42px; font-size: 17px; }
}
.prefixCell { flex: none; min-width: 34px; }
.prefixCell small { color: var(--soft); font: 11px var(--mono); white-space: nowrap; }
.prefixCell.prefixStart .laneNumber { border: 2px dashed var(--mint); }
.prefixCell.prefixStop .laneNumber { box-shadow: inset 0 0 0 2px var(--mint); }
.radixBuckets { border-top: 1px solid var(--edge); padding: 3px 4px; }
.radixGrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.radixGroup { display: flex; align-items: center; min-width: 0; gap: 4px; padding: 4px; border: 1px solid var(--edge); border-radius: 4px;
  background: #282439; color: var(--soft); font: 12px var(--mono); }
.radixGroup b { color: #cabbff; padding-inline-end: 4px; border-inline-end: 1px solid #655c7b; }
.radixGroup.current { outline: 2px solid var(--mint); outline-offset: -2px; }
.radixValues { display: flex; gap: 4px; min-width: 0; overflow-x: auto; position: relative; scrollbar-width: thin; }
.radixValues span { flex: none; color: #f1ecff; }
.radixCurrentCard { text-decoration: underline 2px var(--mint); }
.radixDigitCue { display: inline-block; margin-inline-start: 10px; color: var(--soft); font: 13px var(--mono); }
.radixDigitCue u { color: var(--mint); font-weight: bold; text-decoration-thickness: 2px; }
.arrayLane { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-top: 1px solid var(--edge); }
.mergeLanes .arrayLane { align-items: flex-start; flex-direction: column; }
.laneName { padding: 2px 6px; border: 0; background: transparent; color: var(--soft); font-size: .77rem; white-space: nowrap; }
.laneTrack { display: flex; align-items: flex-start; gap: 4px; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.laneCell { display: inline-flex; align-items: center; flex-direction: column; gap: 1px; }
.laneNumber, .transferNumber { min-width: 34px; padding: 4px 7px; border: 1px solid #695a95; border-radius: 6px; background: #3a3152; color: #ece6ff; text-align: center; font: 600 .87rem var(--mono); }
.mergeLanes .laneNumber { min-width: clamp(32px,4vw,58px); padding-block: clamp(4px,1.2vh,14px); }
.taken .laneNumber { opacity: .44; }
.current .laneNumber, .newCell .laneNumber, .transferNumber { background: var(--mint); color: #143a32; border-color: var(--mint); }
[data-row="saved"] .laneNumber { background: #ffcc9c; border-color: #ffcc9c; color: #352315; }
.lanePointer { background: transparent; color: var(--mint); border: 0; padding: 1px; font: .71rem var(--mono); }
.emptyLane { padding: 1px 7px; font: 1rem var(--mono); color: var(--soft); }
.transferNumber { position: fixed; z-index: 20; pointer-events: none; }
@media (max-width: 920px) {
  .mergeLanes { gap: 2px; }
  .mergeLanes .arrayLane { flex-direction: row; align-items: center; padding-block: 3px; }
  .mergeLanes .laneName { width: 65px; white-space: normal; flex: none; }
  .extraLanes { flex-shrink: 0; max-height: 35%; }
  .extraLanes .arrayLane { padding-block: 1px; }
  .extraLanes .laneNumber { padding-block: 2px; }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 82% 45%, #211c331c, transparent 65%),
    var(--night);
}
[hidden] {
  display: none !important;
}
body[data-mode="setup"] [data-for="run"],
body[data-mode="run"] [data-for="setup"],
body[data-mode="setup"] .hintSlot,
body[data-mode="run"] .grip {
  display: none !important;
}
body[data-mode="setup"] .instruction .codeVar:disabled {
  opacity: 1;
  cursor: text;
}
body[data-mode="run"] #chart,
body[data-mode="run"] #bars g,
body[data-mode="run"] .capHit,
body[data-mode="run"] .bodyHit {
  touch-action: pan-x pan-y;
  cursor: auto;
}
#editArray {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  font: 600 0.84rem "Segoe UI", sans-serif;
}
.panel.pinned {
  position: sticky;
  top: var(--pin-gap);
}
.program.pinned {
  top: calc(var(--pin-gap) + var(--code-offset));
}
.stage.pinned {
  z-index: 1;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button,
select {
  cursor: pointer;
}
button {
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: #282635;
  font-weight: 600;
  line-height: 1.2;
}
button:disabled {
  opacity: 0.38;
  cursor: default;
}
button:hover:not(:disabled),
select:hover {
  border-color: #827692;
  background: #322e42;
}
:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
::selection {
  background: #bcabff;
  color: #211834;
}
button svg,
[data-icon] svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wrap {
  width: min(1436px, 94%);
  margin: auto;
}
.mast {
  border-bottom: 1px solid #2e2a39;
}
.nav,
.brand,
.panelhead,
.tools,
.controls,
.timeline,
.gestureHint,
.annotationHead,
.bindings {
  display: flex;
  align-items: center;
}
.nav {
  min-height: 66px;
  gap: 20px;
}
#algorithm, #target {
  min-width: 0;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--type);
}
#algorithm { max-width: 100%; }
#stackStatus {
  margin: 3px 8px 0;
  color: var(--soft);
  font: 0.85rem var(--mono);
}
.numberListView :is(#scroll, .sizeControl, .field .tools, .gestureHint) {
  display: none !important;
}
.numberListView .sceneInputs:empty { display: none; }
#stackScene {
  container-type: size;
  position: relative;
  overflow: auto;
  scrollbar-color: #675988 #211c30;
  scrollbar-width: thin;
  height: clamp(280px, 48vh, 500px);
  min-height: 0;
  background: radial-gradient(ellipse at 50% 65%, #a985fd15, transparent 65%);
}
.stackView[data-mode="run"] #stackScene,
.stackView[data-mode="setup"] #stackScene { flex: 1; }
@media (min-width: 921px) {
  .stackView[data-mode="setup"] #stackScene { flex: none; }
}
body.lessonPreview.stackView #stackScene { flex: 1; }
#structureSetup { flex: none; padding: 4px 8px; }
#structureHelp { margin: 0 0 7px; color: var(--soft); font-size: .78rem; }
body.lessonPreview #structureHelp { display: none; }
#structureActions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
#structureSetup button { min-height: 38px; padding: 4px 9px; }
#structureSetup button b { color: var(--iris); }
.stack-cell[data-edit-index],
.ring-cell[data-edit-index] { cursor: pointer; }
.stack-cell[data-edit-index]:is(:hover, :focus-visible) .stack-face {
  border-color: #d8c7ff;
  box-shadow: inset 0 0 8px #a985fd35;
}
.ring-cell[data-edit-index]:is(:hover, :focus-visible) .ring-slot {
  fill: #51446a;
  stroke: #e4d4ff;
  stroke-width: 2;
}
#ringScene {
  display: grid;
  place-items: center;
  height: clamp(250px, 43vh, 420px);
  min-height: 0;
  background: radial-gradient(ellipse at center, #a985fd13, transparent 70%);
}
body.lessonPreview #ringScene,
body[data-mode="run"] #ringScene { flex: 1; }
#ringScene svg { display: block; width: 100%; height: 100%; min-height: 0; max-width: 490px; }
.ring-track { fill: none; stroke: #7867a3; stroke-dasharray: 2 5; }
.ring-slot { fill: #252036; stroke: #766690; }
.ring-occupied .ring-slot { fill: #393052; stroke: #b19bdc; }
.ring-active .ring-slot { fill: #554567; stroke: #ede2ff; stroke-width: 2; }
.ring-read-border, .ring-write-border { fill: none; stroke: transparent; stroke-width: 1.8; }
.ring-head .ring-read-border { stroke: #a2f9ed; }
.ring-tail .ring-write-border { stroke: #c9adff; stroke-dasharray: 4 3; }
.ring-head-arrow { color: #a2f9ed; pointer-events: none; }
.ring-arrow-editable { cursor: grab; pointer-events: auto; touch-action: none; outline: none; }
.ring-arrow-dragging { cursor: grabbing; }
.ring-arrow-hit, .ring-slot-index circle { fill: transparent; }
.ring-arrow-line, .ring-arrow-grip-lines {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ring-arrow-line { stroke-width: 2.6; }
.ring-arrow-grip { fill: #223638; stroke: currentColor; stroke-width: 1.3; }
.ring-arrow-grip-lines { stroke-width: 1.5; }
.ring-head-arrow:not(.ring-arrow-editable) :is(.ring-arrow-grip, .ring-arrow-grip-lines) { visibility: hidden; }
.ring-arrow-editable:is(:hover, :focus-visible, .ring-arrow-dragging) .ring-arrow-grip { fill: #395752; }
.ring-arrow-editable:focus-visible .ring-arrow-grip { stroke-width: 2.6; }
.ring-slot-index { pointer-events: none; }
.ring-index-editable { cursor: pointer; pointer-events: auto; }
.ring-index-editable:hover circle { fill: #a2f9ed22; }
.ring-legend, .ring-value, .ring-index {
  font-family: var(--mono);
  text-anchor: middle;
  dominant-baseline: central;
}
.ring-value { fill: #b3a5c7; font-size: 17px; }
.ring-occupied .ring-value { fill: #fff3ff; font-weight: 700; }
.ring-editing .ring-value { visibility: hidden; }
.ring-inline-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0 2px;
  border: 1px solid #a2f9ed;
  border-radius: 6px;
  outline: none;
  background: #211b32;
  color: #fff3ff;
  caret-color: #a2f9ed;
  text-align: center;
  font: 700 15px/1 var(--mono);
  appearance: textfield;
}
.ring-inline-input::-webkit-inner-spin-button,
.ring-inline-input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.ring-inline-input:invalid { border-color: #ffb5bc; }
.ring-departing { fill: #a2f9ed; font-weight: 700; pointer-events: none; }
.ring-index { fill: #d3c7e5; font-size: 11px; }
.ring-legend { font-size: 14px; font-weight: 600; }
.ring-read { fill: #a2f9ed; }
.ring-write { fill: #c9adff; }
.ring-motion { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke: #a2f9ed; }
.ring-motion[data-kind="write"] { stroke: #c9adff; }
#listScene {
  display: grid;
  place-items: center;
  height: clamp(220px, 42vh, 410px);
  min-height: 0;
  background: radial-gradient(ellipse at 50% 44%, #ad8afd15, transparent 70%);
}
body.lessonPreview #listScene,
body[data-mode="run"] #listScene { flex: 1; }
#listScene svg { display: block; width: 100%; height: 100%; max-width: 740px; }
.list-node-card { fill: #302745; stroke: #a690cb; stroke-width: 1.5; }
.list-divider { stroke: #766693; stroke-width: 1; }
.list-dot { fill: #b49edb; }
.list-link { fill: none; stroke: #9987be; stroke-width: 1.9; }
.list-link-active { stroke: #a2f9ed; stroke-width: 2.4; }
.list-current .list-node-card { fill: #273f42; stroke: #a2f9ed; stroke-width: 2.4; }
.list-previous .list-node-card { stroke: #dfbd8b; stroke-width: 2.2; }
.list-current.list-previous .list-node-card { stroke: #a2f9ed; }
.list-head, .list-value, .list-end { font-family: var(--mono); text-anchor: middle; dominant-baseline: central; }
.list-head { fill: #a2f9ed; font-size: 13px; font-weight: 700; }
.list-value { fill: #f4ecff; font-size: 16px; font-weight: 700; pointer-events: none; }
.list-end { fill: #baacd2; font-size: 21px; }
.list-departing { fill: #a2f9ed; }
.list-node[data-edit-index] { cursor: pointer; }
.list-node[data-edit-index]:focus-visible { outline: none; }
.list-node[data-edit-index]:is(:hover, :focus-visible) .list-node-card { stroke: #f2e8ff; stroke-width: 2.6; }
.list-editing .list-value { visibility: hidden; }
@media (max-width: 420px) {
  body.lessonPreview #listScene:not([hidden]) + #structureSetup button { padding-inline: 5px; font-size: .87rem; }
}

#heapScene {
  display: grid;
  place-items: center;
  height: clamp(245px, 46vh, 455px);
  min-height: 0;
  background: radial-gradient(ellipse at 50% 43%, #ad8afd13, transparent 68%);
}
body.lessonPreview #heapScene,
body[data-mode="run"] #heapScene { flex: 1; }
#heapScene svg { display: block; width: 100%; height: 100%; min-height: 0; max-width: 650px; }
@media (max-width: 420px) {
  body.lessonPreview #heapScene:not([hidden]) + #structureSetup button {
    padding-inline: 6px;
    font-size: .9rem;
  }
}
.heap-edge { stroke: #8e7aac; stroke-width: 2; }
.heap-link-active { stroke: #a2f9ed; stroke-width: 2.8; }
.heap-link-next { stroke: #756790; stroke-dasharray: 4 5; }
.heap-node-disc { fill: #302745; stroke: #a690cb; stroke-width: 1.5; }
.heap-min .heap-node-disc { fill: #243a3d; stroke: #a2f9ed; stroke-width: 2.4; }
.heap-next .heap-node-disc { fill: #262137; stroke: #a690cb; stroke-dasharray: 4 4; }
.heap-plus {
  display: none;
  fill: none;
  stroke: #d9c5f7;
  stroke-width: 2;
  stroke-linecap: round;
}
.heap-next .heap-plus { display: block; }
.heap-node[data-edit-index] { cursor: pointer; }
.heap-node[data-edit-index]:focus-visible { outline: none; }
.heap-node[data-edit-index]:is(:hover, :focus-visible) .heap-node-disc {
  stroke: #f2e8ff;
  stroke-width: 2.6;
}
.heap-active .heap-node-disc, .heap-slot.heap-active rect { fill: #304741; stroke: #a2f9ed; stroke-width: 2.5; }
.heap-slot rect { fill: #292237; stroke: #7f6c9b; }
.heap-value, .heap-array-label, .heap-empty { font-family: var(--mono); fill: #f4ecff; }
.heap-value, .heap-empty { text-anchor: middle; dominant-baseline: central; }
.heap-value { font-size: 15px; font-weight: 700; pointer-events: none; }
.heap-array-label, .heap-empty { fill: #c3b5d7; font-size: 13px; }
.heap-min .heap-value, .heap-departing { fill: #a2f9ed; }
.heap-editing :is(.heap-value, .heap-plus) { visibility: hidden; }
:is(.heap-inline-input, .list-inline-input) {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0 1px;
  border: 1px solid #a2f9ed;
  border-radius: 6px;
  outline: none;
  background: #211b32;
  color: #fff3ff;
  caret-color: #a2f9ed;
  text-align: center;
  font: 700 14px/1 var(--mono);
  appearance: textfield;
}
:is(.heap-inline-input, .list-inline-input)::-webkit-inner-spin-button,
:is(.heap-inline-input, .list-inline-input)::-webkit-outer-spin-button { appearance: none; margin: 0; }
:is(.heap-inline-input, .list-inline-input):invalid { border-color: #ffb5bc; }
.stack-book-illustration { height: clamp(210px, 32vh, 290px); margin-top: 12px; }
html:lang(ru) .stack-book-illustration:lang(en),
html:lang(en) .stack-book-illustration:lang(ru) { display: none; }
.stack-track {
  --stack-clearance: clamp(76px, 19cqh, 110px);
  --cube: clamp(32px, calc((100cqh - var(--stack-clearance)) / var(--levels)), 88px);
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 100%;
}
.stack-tower {
  position: relative;
  inline-size: var(--cube);
  block-size: calc(var(--levels) * var(--cube) + var(--stack-clearance));
}
.stack-world {
  position: absolute;
  inset: 0 0 30px;
  transform: rotateX(-19deg) rotateY(-29deg);
  transform-origin: center calc(100% - var(--levels, 4) * var(--cube));
  transform-style: preserve-3d;
}
.stack-floor {
  position: absolute;
  width: 150%;
  aspect-ratio: 1;
  left: -25%;
  bottom: 0;
  transform: translateY(50%) rotateX(90deg);
  border: 1px solid #9a83cc60;
  border-radius: 12%;
  background: radial-gradient(ellipse, #120e22b0 25%, #62528435 70%);
}
.stack-cell {
  --half: calc(var(--cube) / 2);
  --glass: #ac98f7;
  position: absolute;
  bottom: calc(var(--index) * var(--cube));
  width: var(--cube);
  height: var(--cube);
  transform-style: preserve-3d;
}
.stack-top, .stack-departing { --glass: #a2f9ed; }
.stack-face {
  position: absolute;
  inset: 0;
  border: 1px solid color-mix(in srgb, var(--glass) 60%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--glass) 16%, transparent), transparent 54%, color-mix(in srgb, var(--glass) 9%, transparent));
}
.stack-face-front {
  transform: translateZ(var(--half));
  background:
    linear-gradient(126deg, transparent 16%, #f6eaff19 16% 24%, transparent 24% 30%, #f6eaff0d 30% 33%, transparent 33%),
    linear-gradient(160deg, #b7b8ff06, #d9c6ff13);
  box-shadow: inset 0 0 0 1px #e0daff22;
}
.stack-face-back { transform: rotateY(180deg) translateZ(var(--half)); }
.stack-face-left { transform: rotateY(-90deg) translateZ(var(--half)); }
.stack-face-right { transform: rotateY(90deg) translateZ(var(--half)); }
.stack-face-top { transform: rotateX(90deg) translateZ(var(--half)); }
.stack-face-bottom { transform: rotateX(-90deg) translateZ(var(--half)); }
.stack-peek .stack-face {
  border-color: #c8fff5;
  box-shadow: inset 0 0 9px #a7ffdf45;
}
.stack-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: rotateY(29deg) rotateX(19deg);
  color: #faf6ff;
  text-shadow: 0 2px 6px #101020, 0 0 10px #171027;
  font: 700 calc(var(--cube) * .35)/1 var(--mono);
  user-select: none;
}
.stack-editing .stack-face { pointer-events: none; }
.stack-inline-input {
  box-sizing: border-box;
  width: 86%;
  min-width: 0;
  height: 55%;
  padding: 0 2px;
  border: 1px solid #cbb6ff;
  border-radius: 5px;
  color: #fff7ff;
  background: #26213a;
  font: 700 calc(var(--cube) * .30)/1 var(--mono);
  text-align: center;
  appearance: textfield;
}
.stack-inline-input::-webkit-inner-spin-button,
.stack-inline-input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.stack-inline-input:focus { outline: 2px solid #a2f9ed; outline-offset: 1px; }
.stack-top .stack-value { color: #cdfff3; }
.stack-empty .stack-floor { border-style: dashed; }
.stack-action {
  /* Keep the indicator flat while following the projected height of the top face. */
  --surface: calc(var(--stack-clearance) - 30px + (var(--levels) - var(--shown-levels)) * var(--cube) * cos(19deg));
  position: absolute;
  z-index: 1;
  top: var(--surface);
  left: 50%;
  width: clamp(40px, calc(var(--cube) * .83), 64px);
  transform: translate(-50%, -94%);
  overflow: visible;
  pointer-events: none;
  color: #a2f9ed;
  filter: drop-shadow(0 0 5px color-mix(in srgb, currentColor 54%, transparent));
}
.stack-action path,
.stack-action circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stack-action[data-action="pop"] { color: #ffcc95; }
.stack-action[data-action="pop"] .stack-action-vertical {
  transform-origin: 32px 25px;
  transform: rotate(180deg);
}
.stack-action[data-action="peek"] {
  top: calc(var(--surface) + .45 * var(--cube));
  left: calc(50% + .66 * var(--cube));
  transform: translateY(-72%);
  color: #dbc6ff;
}
.stack-empty .stack-action[data-action="peek"] {
  top: var(--surface);
}
.stack-action:not([data-action="peek"]) .stack-action-peek,
.stack-action[data-action="peek"] .stack-action-vertical {
  display: none;
}
.stack-action-peek circle {
  fill: #302247;
  stroke-width: 2;
}
.stack-action-peek text {
  fill: currentColor;
  font: 700 15px var(--sans, sans-serif);
}
@keyframes stack-lift-fade {
  0%, 45% { opacity: 1; }
  100% { opacity: 0; }
}
.stack-departing :is(.stack-face, .stack-value) { animation: stack-lift-fade .34s ease-in both; }
#targetControl, #searchStatus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 8px;
  font-size: .85rem;
}
#target { width: 6.5em; }
#sortNotice { margin: 0 8px 5px; font-size: .8rem; color: var(--soft); }
#sortNotice.orderWarning, #bars .outOfOrder .num { color: #ffb5bc; fill: #ffb5bc; }
#bars .outOfOrder .front { fill: #ce7789; }
#bars .outOfOrder .lid { fill: #ffc0c7; }
#bars .outOfOrder .side { fill: #984e62; }
#inspectTarget { padding: 4px 9px; color: var(--mint); }
#searchMessage { font-weight: 600; }
.searchBand { fill: #93f4cf0b; }
.selectGroup, .selectRank { fill: none; stroke: var(--mint); stroke-width: 2; }
.selectGroup.equal { stroke-width: 4; }
.selectGroup.pending { stroke-dasharray: 6 4; stroke: var(--muted); }
.selectGroup.greater { stroke-dasharray: 2 2; }
.selectRank { stroke-dasharray: 4 3; }
.searchBracket { fill: none; stroke: var(--mint); stroke-width: 2; }
.boundFence { stroke: var(--mint); stroke-width: 2; }
.bestWindowBracket { fill: none; stroke: var(--mint); stroke-width: 2; stroke-dasharray: 4 3; }
.boundFence.endFence { stroke-dasharray: 4 3; }
.boundFence.insertionFence { fill: var(--mint); stroke-width: 3; }
.boundRelation { fill: var(--soft); font: 12px var(--mono); paint-order: stroke; stroke: #201d2d; stroke-width: 3px; }
#bars .excludedBar { opacity: .32; }
#bars .scannedBar { opacity: .76; }
#bars .boundResolved { opacity: .78; }
#bars .scannedBar .front { fill: #625a78; }
#bars .foundBar .front { fill: #b0ef77; }
@media (max-width: 480px) {
  #algorithm { flex: 1; width: 0; font-size: .78rem; }
}
.brand {
  font:
    700 1.35rem/1 "Bahnschrift",
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.035em;
  gap: 9px;
}
.brand svg {
  width: 34px;
  height: 34px;
}
.lab {
  border-left: 1px solid #4b4657;
  padding-left: 20px;
  color: #bbb6c8;
  font-size: 0.87rem;
}
#languages {
  margin-inline-start: auto;
  max-inline-size: min(11rem, 36vw);
  min-block-size: 2.75rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background-color: #282635;
  font-size: 0.875rem;
}
main {
  padding: clamp(26px, 4vw, 58px) 0 40px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font:
    650 clamp(2.25rem, 4.35vw, 4.32rem)/1.06 "Bahnschrift",
    "Inter",
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.04em;
}
.algorithmIntro {
  max-width: 74ch;
  color: #bcb8c8;
  margin: 10px 0 clamp(23px, 2.5vw, 38px);
  font-size: clamp(0.92rem, 1.1vw, 1.07rem);
}
.algorithmIntro p + p { margin-top: 0.55em; }
.workspace {
  display: grid;
  --split-size: 18px;
  --stage-size: calc((100% - var(--split-size)) * var(--stage-share, 0.512));
  grid-template-columns: minmax(0, var(--stage-size)) var(--split-size) minmax(0, 1fr);
  align-items: start;
}
#splitter {
  display: grid;
  place-items: center;
  align-self: stretch;
  position: relative;
  z-index: 2;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}
#splitter::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}
#splitter::after {
  content: "";
  width: 4px;
  height: 44px;
  border-radius: 4px;
  background: #796a92;
}
#splitter:hover::after, #splitter:focus-visible::after,
.workspace[data-resizing] #splitter::after { background: var(--iris); }
.workspace[data-resizing] { user-select: none; }
.workspace[data-resizing] #bars > g { transition: none; }
.panel {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 16px;
  overflow: hidden;
  min-width: 0;
}
.panelhead {
  min-height: 60px;
  padding: 12px 19px;
  gap: 10px;
  border-bottom: 1px solid #383446;
  background: #201e2c;
}
.panelIcon {
  color: var(--iris);
  display: grid;
  place-items: center;
}
.panelIcon svg {
  width: 21px;
  height: 21px;
}
#descriptionToggle { flex:none; width:36px; min-height:36px; padding:0; border:0; background:transparent; color:var(--iris); }
#descriptionToggle:is(:hover,:focus-visible,[aria-pressed="true"]) { background:#393446; }
#sceneDescription { flex:1; min-height:0; overflow:auto; padding:18px 20px; line-height:1.55; }
#sceneDescription h3 { margin:0 0 12px; line-height:1.25; }
#sceneDescription p { max-width:66ch; margin:0 0 .75em; white-space:pre-line; }
#sceneDescription p:empty { display:none; }
h2 {
  font-size: 1.05rem;
  font-weight: 625;
}
.codeNav {
  display: none;
  gap: 5px;
}
#launch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border: 0;
  background: #c3fa7c;
  color: #182510;
  font-weight: 700;
}
#launch:hover {
  background: #d7ffa5;
}
#launch svg {
  width: 15px;
  fill: currentColor;
}
body[data-mode="setup"] .program .panelhead {
  flex-wrap: wrap;
}
.codeNav button {
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
}
#count,
#implementation,
#runningLanguage {
  margin-inline-start: auto;
  color: #d1cbdc;
  font: 0.78rem var(--mono);
}
#implementation {
  min-height: 40px;
  max-width: 100%;
  padding: 0 8px;
  color: var(--iris);
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #282635;
}
.field {
  position: relative;
  padding: 14px 13px 10px;
  background:
    radial-gradient(ellipse at 45% 95%, #342650 0, transparent 67%), #1c192b;
}
#scroll {
  overflow-x: auto;
  scrollbar-color: #675988 #211c30;
  scrollbar-width: thin;
}
#chart {
  display: block;
  user-select: none;
  touch-action: none;
  overflow: visible;
  font-family: var(--mono);
}
#grid .axis {
  stroke: #70657f;
  stroke-width: 1;
}
#grid .guide {
  stroke: #51475e;
  stroke-dasharray: 2 5;
  stroke-width: 0.8;
}
.tick,
.index {
  fill: #b0a4c2;
  font-size: 11px;
}
.num {
  font-size: 16px;
  font-weight: 650;
  fill: #f7f4ff;
}
.empty {
  font:
    14px "Segoe UI",
    sans-serif;
  fill: #c7bed7;
}
#bars > g {
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
.front {
  fill: url(#front);
}
.lid {
  fill: #c6b8ff;
}
.side {
  fill: #5846a6;
}
.grip {
  stroke: #e5dcff;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.activeBar .front,
.selectedBar .front {
  fill: url(#hot);
}
.activeBar .lid,
.selectedBar .lid {
  fill: #d1ffec;
}
.activeBar .side,
.selectedBar .side {
  fill: #368f83;
}
.activeBar .num,
.selectedBar .num {
  fill: var(--mint);
}
#bars g:hover .lid,
#bars g:focus-visible .lid {
  stroke: white;
  stroke-width: 1.8;
}
.bodyHit,
.capHit {
  fill: transparent;
  touch-action: none;
  cursor: grab;
}
.capHit {
  cursor: ns-resize;
}
#bars g {
  touch-action: none;
}
.dropLine {
  stroke: #b6ffe0;
  stroke-width: 3;
  stroke-dasharray: 5 4;
}
.tools {
  padding: 10px 5px 0;
  justify-content: space-between;
  gap: 10px;
}
.tool {
  min-height: 42px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  font-size: 0.84rem;
}
#add {
  background: #322844;
  border: 1px dashed #8a77aa;
  color: #e1d2ff;
  touch-action: none;
  cursor: grab;
}
#bin {
  border: 1px dashed #62566e;
  background: #272132;
  color: #d3c8dc;
}
#bin.target {
  background: #5c344a;
  border-color: #ffa8bd;
  color: #fff;
}
.gestureHint {
  align-items: flex-start;
  gap: 10px;
  padding: 12px 19px;
  border-block: 1px solid #353040;
  color: #c0b9cc;
  font-size: 0.8rem;
  line-height: 1.45;
}
.gestureHint [data-icon] {
  color: #b7a6db;
  flex: none;
  margin-top: 2px;
}
.gestureHint svg {
  width: 16px;
  height: 16px;
}
.player {
  padding: 17px 19px 19px;
}
.timeline {
  gap: 13px;
  color: #cdc7d9;
  font: 0.78rem var(--mono);
  font-variant-numeric: tabular-nums;
}
#seek {
  min-width: 0;
  flex: 1;
  appearance: none;
  height: 22px;
  margin: 0;
  cursor: pointer;
  background: transparent;
}
#seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 5px;
  background: linear-gradient(
    var(--seek-direction, to right),
    var(--iris) var(--pct),
    #494252 var(--pct)
  );
}
#seek::-webkit-slider-thumb {
  appearance: none;
  background: var(--iris);
  border: 2px solid #211c2c;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
}
#seek::-moz-range-track {
  height: 4px;
  background: #494252;
}
#seek::-moz-range-progress {
  background: var(--iris);
}
#seek::-moz-range-thumb {
  background: var(--iris);
}
.controls {
  margin-top: 12px;
  gap: 7px;
  flex-wrap: wrap;
}
.controls button,
.controls select {
  height: 43px;
}
.controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
}
.controls .primary {
  gap: 8px;
  background: var(--iris);
  border-color: transparent;
  color: #211931;
  min-width: 108px;
}
.controls .primary:hover {
  background: #cbbfff;
}
#play svg {
  fill: currentColor;
  stroke-width: 1.4;
  width: 15px;
}
.controls select {
  margin-inline-start: auto;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #262431;
  padding: 0 9px;
  font: 0.83rem var(--mono);
}
#source {
  container-type: inline-size;
  overflow: auto;
  padding: 13px 0 17px;
  background: #171620;
}
#listing {
  width: max-content;
  min-width: 100%;
}
.instruction {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  align-items: baseline;
  gap: 4px;
  padding: 6px 16px 6px 5px;
}
.lineno {
  text-align: center;
  font: 0.7rem var(--mono);
  color: #928b9f;
}
.instructionContent {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: max-content;
}
.pinnedValue {
  display: inline-flex;
  align-items: center;
  padding-left: 7px;
  border: 1px solid #71618e;
  border-radius: 6px;
  background: #342b46;
  color: #e6dcff;
}
.pinnedValue samp {
  max-width: min(40ch, 57cqi);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  font: 0.76rem/1.5 var(--mono);
}
.pinnedValue .unpin {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}
.unpin svg { width: 12px; height: 12px; }
.codeVar[aria-pressed="true"] { text-decoration: underline dotted; }
.instruction code {
  color: #e0d8ea;
  font: clamp(0.79rem, 0.95vw, 0.94rem)/1.65 var(--mono);
  white-space: pre;
  tab-size: 2;
}
#source :is(code, samp) {
  font-variant-ligatures: none;
}
.keyword {
  color: #c6a1ff;
}
.fn {
  color: #a4dfed;
}
.literal {
  color: #f6c396;
}
.active .instruction {
  background: #322b45;
}
.active .lineno {
  color: #e0d0ff;
}
mark {
  background: #c3acff;
  color: #201930;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #c3acff;
  font-weight: 650;
}
.hintSlot {
  position: sticky;
  left: 0;
  width: 100cqi;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 170ms ease-in-out;
}
.hintSlot.open {
  grid-template-rows: 1fr;
}
.hintClip {
  min-height: 0;
  overflow: hidden;
}
.annotation {
  padding: 14px clamp(14px, 3%, 24px);
  background: #b9efdc;
  color: #16392e;
}
.annotationHead {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.annotationHead strong {
  font-size: 0.9rem;
  color: #133b2e;
}
.result {
  font: 0.77rem/1.45 var(--mono);
  color: #154532;
}
.annotation p {
  margin: 6px 0 10px;
  font-size: 0.88rem;
  line-height: 1.52;
}
.bindings {
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.binding {
  font: 0.74rem/1.5 var(--mono);
  color: #34594c;
  max-width: 100%;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  background: #d8f7e9;
  border: 1px solid #8ecbb2;
  border-radius: 5px;
  padding: 3px 7px;
  overflow-wrap: anywhere;
}
.binding b {
  color: #1f4c3b;
  font-weight: 600;
}
.binding samp {
  font: inherit;
  color: #123628;
}
#valueEditor {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px;
  background: #302b40;
  border: 1px solid #8d7fa5;
  border-radius: 10px;
  box-shadow: 0 9px 22px #0a071766;
}
#valueEditor label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}
#exact {
  width: 6ch;
  font: 1rem var(--mono);
  background: #151220;
  border: 1px solid #716381;
  border-radius: 4px;
  padding: 5px;
}
#valueEditor button {
  min-height: 36px;
  padding: 5px 8px;
  font-size: 0.8rem;
}
#ghost {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  transform: translate(-50%, -125%);
  background: var(--mint);
  border-radius: 6px;
  color: #162d24;
  font: 600 1rem var(--mono);
  padding: 6px 12px;
}
@media (min-width: 1550px) {
  .wrap {
    width: 90%;
  }
}
@media (max-width: 920px) {
  .workspace {
    --split-size: 22px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, var(--stage-size)) var(--split-size) minmax(0, 1fr);
    align-items: stretch;
  }
  body[data-mode="setup"] .workspace { height: max(900px, 100svh); }
  body[data-mode="setup"] :is(.panel, .field) {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  body[data-mode="setup"] :is(.field, #scroll, #source) { flex: 1; min-height: 0; }
  body[data-mode="setup"] #source { overflow: auto; }
  body[data-mode="setup"] #scroll { overflow-y: hidden; }
  #splitter { cursor: row-resize; }
  #splitter::before { inset: -5px 0; }
  #splitter::after { width: 44px; height: 4px; }
  .program :is(button, input, select, summary, [data-code-part]) {
    scroll-margin-top: calc(var(--code-offset) + var(--pin-gap));
  }
  .wrap {
    width: min(94%, 740px);
  }
  main {
    padding-top: 29px;
  }
  .instruction code {
    font-size: 0.89rem;
  }
  .field {
    padding-top: 8px;
  }
  .nav {
    min-height: 58px;
  }
}
@media (max-width: 480px) {
  .wrap {
    width: 94%;
  }
  .nav {
    gap: 10px;
  }
  .lab {
    font-size: 0.72rem;
    padding-left: 10px;
  }
  .brand {
    font-size: 1.12rem;
    gap: 5px;
  }
  .brand svg {
    width: 26px;
  }
  h1 {
    font-size: clamp(1.95rem, 8.65vw, 2.6rem);
  }
  .panelhead {
    min-height: 50px;
    padding: 10px 13px;
  }
  .field {
    padding-inline: 4px;
  }
  .tools {
    padding-inline: 8px;
  }
  .player,
  .gestureHint {
    padding-inline: 12px;
  }
  .instruction {
    grid-template-columns: 25px minmax(0, 1fr);
    padding-right: 16px;
  }
  .instruction code {
    font-size: 0.78rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  #bars > g,
  .hintSlot {
    transition: none;
  }
}
@media (max-width: 920px) {
  .codeNav {
    display: flex;
  }
}

.sizeControl {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 6px;
  font-size: 0.79rem;
  color: var(--soft);
}
#size, #windowSize {
  flex: 1;
  min-width: 0;
  height: 32px;
  cursor: pointer;
  accent-color: var(--iris);
  margin: 0;
}
#count, #windowSizeValue {
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tools {
  flex-wrap: wrap;
  justify-content: flex-start;
}
#bin {
  margin-inline-start: auto;
}
.swapArc {
  fill: none;
  stroke: #ffcc9c;
  stroke-width: 2.25;
  stroke-linecap: round;
}
.actionGuide {
  stroke: #ffcc9c;
  stroke-opacity: 0.55;
  stroke-dasharray: 2 4;
}
#chart [data-code-name] {
  pointer-events: all;
  pointer-events: bounding-box;
  cursor: pointer;
}
#chart [data-code-name]:hover,
#chart [data-code-name]:focus-visible {
  text-decoration: underline;
}
.actionCaption {
  font:
    600 12px "Segoe UI",
    sans-serif;
  fill: #ffce9d;
  paint-order: stroke;
  stroke: #211b30;
  stroke-width: 4px;
  stroke-linejoin: round;
}
.indexRole {
  font: 600 11px var(--mono);
  fill: #d4c8fb;
  pointer-events: none;
}
.barVariable {
  font: 600 10.5px var(--mono);
  fill: #191828;
  pointer-events: none;
}
.barVariable.outside {
  fill: #dbd3f1;
}
.annotation p:last-child { margin-bottom: 0; }
.stage .panelhead {
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .controls button {
    padding-inline: 9px;
  }
  .controls .primary {
    min-width: 86px;
  }
}
@media (max-width: 365px) {
  .controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
  }
  .controls #next {
    grid-column: span 2;
  }
  .controls #play {
    grid-column: span 2;
  }
}
#sceneVars {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 3px 8px 7px;
}
#sceneVars [data-scalar] {
  background: #332b45;
  color: #e6ddff;
  border-radius: 5px;
  padding: 3px 8px;
  font: 0.78rem var(--mono);
}
.instruction .codeVar {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  line-height: inherit;
  cursor: pointer;
}
.instruction .codeVar:hover,
.instruction .codeVar:focus-visible {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  background: #b997f733;
}
mark .keyword,
mark .fn,
mark .literal {
  color: inherit;
}
.hintSettings {
  border-bottom: 1px solid var(--edge);
  background: #211e2d;
}
#hintSettings, #share {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  color: #d7caee;
}
.program .panelhead { position: relative; }
#shareStatus:not(:empty) {
  position: absolute;
  z-index: 5;
  right: 10px;
  top: calc(100% + 4px);
  padding: 5px 10px;
  border-radius: 6px;
  color: #182510;
  background: #c3fa7c;
  pointer-events: none;
}
#shareStatus:empty { position: absolute; }
#hintSettings[aria-expanded="true"] {
  color: var(--iris);
  border-color: currentColor;
}
.settingsBody {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 18px;
  padding: 10px 17px;
  font-size: 0.84rem;
}
.settingsBody label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}
.settingsBody select {
  font: inherit;
  background: #332e41;
  color: var(--type);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 5px;
}
.settingsBody input {
  width: 17px;
  height: 17px;
  accent-color: var(--iris);
}
.functionNote {
  margin-top: 9px;
  border-top: 1px solid #8ccbb3;
  padding-top: 7px;
  color: #1d4538;
  font-size: 0.84rem;
}
.functionNote code {
  font: 600 0.84rem var(--mono);
  margin-right: 4px;
}
.annotationHead + .bindings {
  margin-top: 7px;
}
#overviewBox {
  margin: 4px 6px;
  background: #201c2d;
  border: 1px solid #524960;
  border-radius: 5px;
}
#overview {
  display: block;
  width: 100%;
  height: 32px;
  cursor: ew-resize;
  touch-action: none;
}
#miniBars {
  fill: #9c8dc7;
}
#viewWindow {
  fill: #c5bcff24;
  stroke: #d8cfff;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}
@media (max-width: 480px) {
  .tools {
    gap: 5px;
  }
  .tool {
    padding-inline: 8px;
    gap: 4px;
    font-size: 0.76rem;
  }
}

body[data-mode="run"] {
  min-height: 0;
  overflow: hidden;
}
body[data-mode="run"] :is(.mast, #title) {
  display: none;
}
body[data-mode="run"] main.wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}
#runbar {
  display: flex;
  align-items: center;
  flex: none;
  gap: clamp(12px, 2.4vw, 40px);
  padding: 9px clamp(12px, 1.6vw, 28px);
  border-bottom: 1px solid var(--edge);
  background: #201e2c;
}
#runbar :is(#languages, .controls) {
  margin: 0;
  flex: none;
}
#runbar .player {
  display: flex;
  align-items: center;
  flex: 1;
  gap: clamp(12px, 2.4vw, 40px);
  padding: 0;
  min-width: 0;
}
#runbar .timeline {
  flex: 1;
  min-width: 0;
}
#step {
  white-space: nowrap;
}
body[data-mode="run"] .workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  flex: 1;
  min-height: 0;
  padding: 12px;
}
body[data-mode="run"] .panel,
body[data-mode="run"] .field {
  display: flex;
  flex-direction: column;
  position: relative;
  top: auto;
  min-height: 0;
}
body[data-mode="run"] :is(.field, #scroll, #source) {
  flex: 1;
  min-height: 0;
}
body[data-mode="run"] #scroll {
  overflow-y: hidden;
}
body[data-mode="run"] #source {
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #675988 #171620;
  scrollbar-width: thin;
}
body[data-mode="run"] :is(.panelhead, .hintSettings, .stage .player) {
  flex: none;
}
body[data-mode="run"] .hintSettings {
  max-height: 38%;
  overflow-y: auto;
}
body[data-mode="run"] .program :is(button, input, select, summary, [data-code-part]) {
  scroll-margin-top: 6px;
}
@media (max-width: 920px) {
  #runbar { display: none; }
  .stage .panelhead, .program .panelhead :is(h2, .panelIcon) { display: none; }
  body[data-mode="setup"]:not(.lessonPreview) .stage .panelhead { display:flex; min-height:44px; padding:3px 10px; }
  .sceneInputs { display: flex; align-items: center; gap: 8px; }
  .sceneInputs .sizeControl { flex: 1; min-width: 0; }
  .sceneInputs #launch { flex: none; }
  .program :is(#implementation, #runningLanguage) { margin-inline-start: 0; }
  .program .codeNav { margin-inline-start: auto; }
  body[data-mode="setup"] .program .panelhead { min-height: 0; padding-block: 6px; }
  body[data-mode="run"] .workspace {
    grid-template-rows: minmax(0, var(--stage-size)) var(--split-size) minmax(0, 1fr);
    padding: 6px;
  }
  body[data-mode="run"] .panelhead {
    min-height: 44px;
    padding: 4px 10px;
    gap: 6px;
  }
  body[data-mode="run"] .field { padding: 2px 4px; }
  .stage .player {
    padding: 4px 10px 8px;
    border-top: 1px solid var(--edge);
  }
  .stage .controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 2px;
  }
  .stage .controls button { padding: 0 9px; font-size: 0.87rem; }
  .stage .controls .primary { min-width: 0; }
  .stage .controls select { padding: 0 4px; }
}
@media (min-width: 600px) and (max-width: 920px) and (max-height: 520px) {
  body[data-mode="run"] .stage {
    display: grid;
    grid-template: auto minmax(0, 1fr) / minmax(0, 1fr) auto;
  }
  body[data-mode="run"] .stage :is(.field,#sceneDescription) { grid-area: 2 / 1 / 3 / -1; }
  .stage .player { display: contents; }
  .stage .timeline { grid-area: 1 / 1; padding: 4px 8px; min-width: 0; }
  .stage .controls { grid-area: 1 / 2; margin: 0; padding: 0 6px; }
}
@media (max-width: 480px) {
  body[data-mode="run"] .instruction { padding-block: 4px; }
}
@media (max-width: 600px) and (max-height: 660px) {
  body[data-mode="run"] #sceneVars { margin-block: 0; }
  body[data-mode="run"] #overview { height: 22px; }
}
@media (max-width: 365px) {
  body[data-mode="setup"] .workspace { height: max(1040px, 100svh); }
}
.treeSide {fill:#c4fadf;font:600 12px system-ui;paint-order:stroke;stroke:#201d2a;stroke-width:3px;pointer-events:none}
.graphEdge.residualArrow {--edge-stroke:#c695fd}
.graphEdge.residualArrow .bfsEdge {stroke-dasharray:5 4}
.condensation {margin:0;overflow:auto;max-width:100%;padding:4px}
.condensation figcaption {font-weight:600;margin-bottom:4px}
.condensation svg {display:block}
.condensation text {fill:white;font:600 12px monospace}
.componentLink {fill:none;stroke:#b1b2cb;stroke-width:1.8}
.partitionLine {stroke:#8d88a8;stroke-width:1;stroke-dasharray:4 7}
.rankHalo {fill:#7cf3c9;opacity:.42}
#graphCostEditor {display:flex;align-items:center;gap:8px;color:var(--soft)}
#graphCostEditor input {width:70px;background:var(--surface)}
.parentLink {fill:none;stroke:#f7bc7c;stroke-width:2.5;pointer-events:none}
#graphHelp.invalidGraph {color:#ffa9a8}

/* The catalog embeds the same setup scene and its controls in a bounded tile. */
body.lessonPreview { margin:0; min-height:0; background:#1b1927; }
.lessonPreview > .mast, .lessonPreview main > :is(h1,.algorithmIntro,#runbar),
.lessonPreview .workspace > :is(.program,#splitter), .lessonPreview .stage > :is(.panelhead,.gestureHint,.player),
.lessonPreview #legendToggle { display:none !important; }
.lessonPreview main.wrap { width:100%; max-width:none; margin:0; padding:0; height:100dvh; display:flex; flex-direction:column; }
body.lessonPreview .workspace { order:0; display:block; width:100%; height:auto; flex:1; min-height:0; margin:0; }
body.lessonPreview .stage { display:flex; flex-direction:column; position:static; height:100%; width:100%; border:0; border-radius:0; }
body.lessonPreview .field { display:flex; flex-direction:column; min-height:0; height:100%; overflow:auto; padding:6px 12px; }
.lessonPreview.graphView .sceneInputs { display:none; }
.lessonPreview #graphTools { margin:0; }
.lessonPreview #graphTools button { min-height:30px; padding:4px 9px; }
.lessonPreview #graphCanvas { min-height:90px; }
.lessonPreview #graphHelp { line-height:1.3; font-size:12px; }
.lessonPreview #tileActions { order:1; display:flex; align-items:center; justify-content:space-between; flex:none; gap:8px; padding:9px 15px; border-top:1px solid #383346; background:#211e2d; }
.lessonPreview #tileActions select { width:auto; margin:0; min-height:36px; }
.lessonPreview #launch { min-height:38px; color:#e1d9f5; background:#373142; border:1px solid #665974; font-weight:600; }
.lessonPreview #launch:hover:not(:disabled) { color:#fff; background:#463c53; border-color:#9985af; }
.lessonPreview #scroll { flex:1; min-height:65px; }
.lessonPreview .tools { flex:none; margin:0; padding:5px 0; }
.stringView :is(#scroll,#overviewBox,.sizeControl,.field .tools,.gestureHint),
.lessonPreview.stringView .sceneInputs { display:none !important; }
#stringInputs { display:grid; gap:14px; padding:8px; }
#stringInputs label { display:grid; gap:6px; color:var(--soft); }
#stringInputs :is(input,textarea) {
  box-sizing:border-box; width:100%; min-width:0; padding:8px 10px;
  background:var(--surface); color:var(--type); border:1px solid var(--edge);
  border-radius:6px; font:15px/1.4 var(--mono);
}
#stringInputs textarea { resize:vertical; }
#stringRun { flex:1; min-width:0; min-height:0; overflow:auto; padding:6px 10px; }
#stringRun.alignmentScene { display:flex; flex-direction:column; justify-content:safe center; gap:10px; overflow:auto; }
.alignViewport { overflow-x:auto; scrollbar-width:thin; direction:ltr; padding:4px 2px; }
.alignGrid { width:max-content; margin-inline:auto; display:grid; grid-template-columns:repeat(var(--columns),clamp(28px,4vw,47px)); gap:4px 2px; direction:ltr; }
.alignIndex { text-align:center; font:600 11px var(--mono); color:var(--soft); }
.alignCell { display:grid; place-items:center; height:clamp(30px,5vh,48px); border-radius:5px; font:600 clamp(17px,2.4vw,27px) var(--mono); }
.alignText { background:#40384e; }
.alignNeedle { background:#575071; border-bottom:3px solid var(--iris); }
.alignCell.matched { color:var(--mint); background:#294239; }
.alignCell.same,.alignCell.different { outline:2px dashed currentColor; outline-offset:-3px; }
.alignCell.same { background:#b9efdc; color:#173b2f; }
.alignCell.different { background:#f6c2b5; color:#4e251c; }
.alignCell.source,.alignText.shiftKey { border-bottom:4px solid #ffc480; }
.alignText.shiftKey::before { content:"▼"; position:absolute; inset:auto 2px 0 auto; font-size:9px; color:#ffbb70; }
.alignText.shiftKey { position:relative; }
.alignBook { display:flex; align-items:center; flex:none; gap:4px; overflow-x:auto; scrollbar-width:thin; direction:ltr; padding:2px; }
.alignBook > * { flex:none; }
.boyerPrep { max-width:100%; overflow:auto; flex:none; direction:ltr; }
.boyerTable { width:max-content; margin:auto; border-spacing:2px; font:600 14px var(--mono); text-align:center; }
.boyerTable th { text-align:start; position:sticky; left:0; z-index:1; background:var(--panel,#211d2b); color:var(--soft); }
.boyerTable td { min-width:28px; background:#393147; border-radius:3px; }
.boyerValue { display:inline-block; padding:2px 6px; min-width:24px; font:600 13px var(--mono); color:inherit; }
.boyerValue[aria-current],.boyerTable .boyerCurrent { outline:2px solid var(--mint); outline-offset:-2px; border-radius:3px; }
.boyerRules { display:flex; flex-wrap:wrap; gap:4px; max-height:34%; overflow:auto; }
.boyerRules .boyerValue { overflow-wrap:anywhere; }
.boyerExpression { color:var(--mint); font:600 14px var(--mono); }
.alignBook strong { color:var(--soft); margin-inline-end:4px; }
.alignBook button,.alignDefault { padding:2px 5px; font:600 12px var(--mono); white-space:nowrap; }
.alignBook [aria-current] { outline:2px solid #ffc480; outline-offset:-2px; border-radius:4px; }
.alignmentScene .alignViewport { flex:none; }
.alignmentScene .alignResults:empty { display:none; }
@media (max-width:920px) {
  #stringRun.alignmentScene { gap:3px; padding:2px 4px; }
  .alignmentScene .alignViewport { padding:2px; }
  .alignmentScene .alignCell { height:30px; }
}
.alignStatus { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.alignStatus strong { color:var(--mint); }
.alignResults { display:flex; gap:4px; flex-wrap:wrap; max-height:34%; overflow:auto; min-height:20px; direction:ltr; }
.alignResults button { padding:2px 6px; font:600 13px var(--mono); }
.alignResults [aria-current] { outline:2px solid var(--mint); outline-offset:-2px; }
#stringRun.huffmanScene { display:flex; flex-direction:column; gap:5px; overflow:hidden; }
.huffText,.huffBook,.huffOutput,.huffCounts { display:flex; align-items:center; gap:5px; }
.huffText,.huffBook { white-space:nowrap; overflow-x:auto; min-width:0; flex:none; scrollbar-width:thin; }
.huffText { position:relative; font:600 16px var(--mono); }
.huffText mark { color:#172a27; background:var(--mint); border-radius:3px; padding:0 2px; box-shadow:none; }
.huffViewport { flex:1; min-height:0; overflow:auto; scrollbar-width:thin; }
.huffViewport svg { display:block; width:100%; height:100%; min-width:var(--huff-min-width); min-height:var(--huff-min-height); }
.huffBranch { stroke:#8977b7; stroke-width:2; }
.huffBranch.active { stroke:var(--mint); stroke-width:3; stroke-dasharray:6 3; }
@media (prefers-reduced-motion:no-preference) {
  .huffBranch.joining { animation:huffJoin .32s ease-out; }
  @keyframes huffJoin { from { opacity:.15; stroke-dasharray:1 6; } to { opacity:1; } }
}
.huffNode { cursor:pointer; }
.huffNode :is(circle,rect) { fill:#372d4b; stroke:#9784c3; stroke-width:1.6; }
.huffNode.current :is(circle,rect),.huffNode:focus-visible :is(circle,rect) { stroke:var(--mint); stroke-width:3; stroke-dasharray:6 2; }
.huffNode text,.huffBit { text-anchor:middle; fill:#f5f2fa; font:600 16px var(--mono); }
.huffBit,.huffNode .huffWeight { fill:var(--mint); font-size:12px; }
.huffChip { border:1px solid var(--edge); border-radius:5px; color:var(--ink); background:#31293f; padding:3px 6px; white-space:pre; }
.huffBook button { cursor:pointer; }
.huffCounts { flex-wrap:wrap; justify-content:center; min-height:100%; align-content:center; }
.huffFooter { display:grid; gap:4px; font:600 13px var(--mono); }
.huffGroups { display:flex; gap:3px; align-items:center; }
.huffGroups .huffChunk { flex:none; padding:2px 6px; border:1px solid var(--edge); border-radius:4px; background:#29243c; color:inherit; font:inherit; cursor:pointer; }
.huffChunk[aria-current] { outline:2px solid var(--mint); outline-offset:-2px; }
.huffOutput strong { color:var(--mint); white-space:nowrap; }
.huffOutput code { overflow-x:auto; direction:ltr; scrollbar-width:thin; }
@media (max-width:920px) {
  #stringRun.huffmanScene { gap:2px; padding:2px 4px; }
  .huffText,.huffFooter { font-size:12px; }
  .huffChip { padding:1px 5px; }
}
#stringRun.wordGridScene { display:flex; flex-direction:column; justify-content:safe center; gap:8px; overflow:hidden; }
.wordGridSummary:has(> div) { display:flex; flex-wrap:wrap; gap:4px 18px; }
.wordGridSummary > div { color:var(--soft); letter-spacing:.12em; }
.wordGridSummary mark { box-shadow:none; border-radius:0; background:transparent; color:var(--mint); border-bottom:2px solid currentColor; }
.wordGridSummary { color:var(--mint); font:600 16px var(--mono); overflow:auto; white-space:pre; flex:none; }
.wordGridScroll { width:100%; max-width:100%; min-height:0; overflow:auto; scrollbar-width:thin; align-self:flex-start; direction:ltr; }
.wordGrid { width:100%; border-collapse:separate; border-spacing:2px; font:14px var(--mono); text-align:center; }
.wordGrid th { color:var(--soft); background:var(--surface); padding:3px; position:sticky; }
.wordGrid thead th { top:0; z-index:2; }
.wordGrid th:first-child { left:0; width:6%; z-index:1; min-width:24px; }
.wordGrid thead th:first-child { z-index:3; }
.wordGrid td { padding:0; }
.wordGrid button { position:relative; min-width:44px; width:100%; min-height:clamp(34px,5vh,50px); border:1px solid var(--edge); border-radius:4px; background:var(--panel); font:inherit; }
.wordGrid button:disabled { opacity:.48; }
.wordGrid button.read { outline:2px dashed var(--iris); outline-offset:-2px; }
.wordGrid button[data-direction]::before { content:attr(data-direction); position:absolute; inset-inline-start:2px; top:0; font-size:10px; }
.wordGrid button.route { border-bottom:3px solid var(--iris); }
.wordGrid button.write { background:var(--mint); color:#172723; outline:2px solid var(--mint); opacity:1; }
.wordGridOperation { display:flex; flex-wrap:wrap; gap:4px; align-items:center; min-height:22px; max-height:27%; flex:none; overflow:auto; font:13px var(--mono); }
.wordGridOperation strong { margin-inline-end:6px; }
.wordGridOperation span { padding:2px 6px; border:1px solid var(--edge); border-radius:4px; }
.wordGridOperation .edited { color:var(--mint); border-style:dashed; }
@media (max-width:920px) {
  #stringRun.wordGridScene { gap:3px; padding:2px 4px; }
  .wordGridSummary { font-size:13px; }
  .wordGrid button { min-width:33px; min-height:24px; padding:1px 3px; }
  .wordGrid th { padding:1px; }
}
.trieGoal { display:flex; align-items:baseline; gap:9px; margin:0 0 6px; font-size:.9rem; }
.trieGoal strong { flex:none; }
.trieGoal span { overflow:auto; white-space:pre; color:var(--mint); }
.trieRowLabel { display:flex; flex-wrap:wrap; align-items:baseline; gap:1px 9px; margin-bottom:3px; color:var(--soft); font-size:.84rem; font-weight:650; }
.trieRowLabel span { font-size:.78rem; font-weight:400; }
.stringStepRow { margin:6px 0 10px; min-width:0; }
.stringStepValues,.stringStepList { display:flex; flex-wrap:wrap; gap:4px; max-height:13rem; overflow:auto; align-content:start; }
.stringStepList { display:grid; grid-template-columns:minmax(0,1fr); }
.stringStepList .stringStepCell { text-align:start; white-space:pre-wrap; overflow-wrap:anywhere; }
.stringStepCell { min-width:28px; padding:3px 7px; font: .88rem/1.4 var(--mono); }
.stringStepCell.compared { color:#231c36; background:var(--iris); }
.stringStepCell.compared small { color:#42375d; }
.stringStepCell.inspectedCell { outline:2px solid #ffca98; outline-offset:-2px; }
.stringStructureMap { max-height:15rem; overflow:auto; background:#211d2c; border:1px solid var(--edge); border-radius:8px; }
.stringStructureMap svg { display:block; width:min(100%,360px); margin:auto; }
.stringMapEdge { cursor:pointer; }
.stringMapEdge:is(:hover,:focus-visible) rect { stroke:var(--iris); stroke-width:3; }
.stringMapTip { stroke:#aa9fbd; fill:none; }
details.stringStepRow > summary { display:list-item; cursor:pointer; }
.sceneInspector .stringStepJump { padding:5px 8px; justify-self:start; font:inherit; text-decoration:underline; }
.trieStages { display:flex; flex-wrap:wrap; gap:4px; margin:2px 0 12px; }
.trieStages button { font-size:.82rem; line-height:1.25; min-height:30px; padding:4px 9px; }
.trieStage[aria-current] { background:var(--iris); color:#21192e; }
.stringTape { display:flex; position:relative; overflow-x:auto; gap:3px; padding:2px 0; }
.stringCell { display:grid; flex:none; min-width:30px; padding:2px 4px; text-align:center; font:16px/1.25 var(--mono); background:#262232; }
.stringCell small { color:var(--soft); font-size:10px; }
.stringCell.matched { background:#324b46; }
.stringCell.palCenter { box-shadow:inset 0 -3px var(--mint); }
.stringCell.palGap { box-shadow:inset 3px 0 var(--mint); }
.stringCell.palMirror { border:2px dashed var(--iris); }
.stringCell.palPair { border:2px solid #ffca98; color:#fff1dd; }
.stringGoal { display:block; font-size:.95rem; }
.stringChoices { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin:5px 0; }
.stringChoices button,.stringWhy summary { min-height:36px; padding:6px 10px; cursor:pointer; }
.stringFeedback,.stringWhy { font-size:.88rem; line-height:1.4; }
#lessonHelp { flex:none; margin-top:4px; }
#lessonHelp > button { max-width:100%; padding:5px 10px; min-height:32px; text-align:start; color:var(--iris); line-height:1.25; }
#lessonExplanation .stringWhy summary { color:#504064; padding-left:0; }
#lessonExplanation .stringChoices button { width:auto; height:auto; min-height:36px; padding:6px 12px; font:inherit; border:1px solid #ae997b; border-radius:7px; }
.stringWhy summary { display:list-item; width:fit-content; color:var(--iris); }
.stringWhy p { margin:0 0 8px; padding:4px 10px; border-inline-start:2px solid var(--iris); }
.stringCell[aria-current] { border-color:var(--mint); color:var(--mint); }
.trieCaption { margin:9px 0; font-size:.95rem; line-height:1.4; overflow-wrap:anywhere; }
.trieViewport { overflow:auto; max-height:clamp(180px,40vh,480px); background:#211d2c; border:1px solid var(--edge); border-radius:8px; }
.trieViewport svg { display:block; margin:auto; height:auto; }
.trieEdge,.trieSuffix { fill:none; }
.trieEdge { stroke:#9b91ae; stroke-width:1.5; }
.trieEdge.active { stroke:var(--mint); stroke-width:2.8; }
.trieLetter,.trieCheck { font:600 12px var(--mono); fill:#d3c8e1; stroke:#211d2c; stroke-width:4; paint-order:stroke; }
.trieLetter.active,.trieCheck { fill:var(--mint); }
.trieSuffix { stroke:#ffca98; stroke-width:2; stroke-dasharray:5 3; pointer-events:none; }
.trieNode { cursor:pointer; }
.trieNode rect { fill:#302a3e; stroke:#9b8aaa; stroke-width:1.5; }
.triePrefix { font:600 14px var(--mono); fill:#f5f0fb; }
.trieNode.current rect { fill:var(--mint); stroke:#ccffe8; }
.trieNode.current .triePrefix { fill:#14362b; }
.trieNode:is(:hover,:focus-visible,[aria-pressed="true"]) rect { stroke:var(--iris); stroke-width:3; }
.trieArrow { cursor:pointer; }
.trieArrowTarget { fill:none; stroke:transparent; stroke-width:24; pointer-events:stroke; }
.trieArrow[data-part="suffix"] .trieArrowTarget { stroke-width:14; }
.trieArrow:is(:hover,:focus-visible,[aria-pressed="true"]) :is(.trieEdge,.trieSuffix) { stroke:var(--iris); stroke-width:3; }
.trieArrow:is(:hover,:focus-visible,[aria-pressed="true"]) .trieLetter { fill:var(--iris); }
.trieArrow:focus,.trieNode:focus { outline:none; }
.inspectorDetails { grid-column:1/-1; display:grid; gap:7px; overflow:auto; padding:0 16px 14px; }
.trieExamples { display:flex; flex-wrap:wrap; gap:4px 8px; }
.trieExamples code { white-space:pre-wrap; }
.trieExamples b { color:#185a4a; text-decoration:underline; text-underline-offset:2px; }
.sceneInspector {
  position:fixed; z-index:12; display:grid; grid-template-columns:1fr 44px;
  grid-template-rows:40px minmax(0,auto); width:min(310px,calc(100vw - 20px));
  max-height:calc(100dvh - 20px); box-sizing:border-box; overflow:hidden;
  background:#f5e7cc; color:#382d23; border-radius:12px;
  box-shadow:0 7px 24px #100b1c55; font-size:.94rem; line-height:1.4; overflow-wrap:anywhere;
}
.inspectorGrip { cursor:grab; touch-action:none; user-select:none; display:grid; align-items:center; padding-left:16px; }
.inspectorGrip:active { cursor:grabbing; }
.inspectorGrip::before { content:""; width:32px; height:4px; border-radius:3px; background:#9f896c; }
.sceneInspector button {
  min-width:0; min-height:0; margin:0; padding:0; background:transparent; border:0;
  color:#544330; font-size:21px; box-shadow:none;
}
.sceneInspector button:is(:hover,:focus-visible) { background:#e7d4b6; color:#35291e; }
.stringMatches { display:flex; flex-wrap:wrap; gap:5px 10px; margin:8px 0 12px; max-height:6em; overflow:auto; }
.stringMatches { align-items:center; }
.trieHit { padding:3px 7px; font:13px var(--mono); overflow-wrap:anywhere; }
.trieHit[aria-current] { border-color:var(--mint); color:var(--mint); }
@media (max-width:600px) {
  .trieStages { margin-bottom:5px; }
  .trieStages button { font-size:.76rem; padding:3px 7px; }
  .trieCaption { margin:5px 0; font-size:.85rem; }
}


/* These views use indices or coordinates that increase from left to right. */
html[dir="rtl"] :is(#source, code, samp, .result, .binding, input[type="number"],
  #scroll, #graphMap, #ringScene, #heapScene, #listScene, .laneTrack, .graphMatrix, .graphChips, .trieViewport, .stringStructureMap svg) {
  direction: ltr;
  unicode-bidi: isolate;
}
html[dir="rtl"] #source .annotation {
  direction: rtl;
  text-align: start;
}
html[dir="rtl"] :is([data-icon="next"], [data-icon="prev"], [data-icon="forward"], [data-icon="back"]) svg {
  transform: scaleX(-1);
}
html[dir="rtl"] [data-algorithm="postfix-expression"] .stringStepValues { direction: ltr; }
.stringTape:dir(rtl) .stringCell.palGap { box-shadow: inset -3px 0 var(--mint); }
html[dir="rtl"] #seek { --seek-direction: to left; }

.hashLayout .scalarFields:empty { display:none; }
.hashHeading,.hashOperations,.commandEditor { display:flex; align-items:center; flex-wrap:wrap; gap:5px 10px; }
.hashHeading { justify-content:space-between; color:var(--mint); font:600 clamp(13px,1.8vw,20px) var(--mono); }
.hashGrid { border-spacing:2px; width:100%; table-layout:fixed; text-align:center; font:600 clamp(12px,1.5vw,17px) var(--mono); }
.hashScroll { min-height:0; max-height:min(45vh,380px); overflow:auto; }
.hashGrid th:first-child { width:13%; }
.hashGrid th.home { color:#ffcb86; }
.hashGrid td { border:1px solid #574c64; background:#322b3c; border-radius:4px; padding:2px; }
.hashGrid td.current { outline:2px solid #ffc480; outline-offset:-2px; }
.hashGrid td.tomb { background:repeating-linear-gradient(45deg,#39313c 0 4px,#302933 4px 8px); color:#ffbfaf; }
.hashGrid td button { display:block; width:100%; padding:0 2px; color:inherit; font:inherit; border:0; background:transparent; }
.hashOperations,.commandEditor { gap:4px; }
.hashOperations { flex-wrap:nowrap; overflow:auto; padding-bottom:2px; }
.hashOperations button,.commandEditor select,.commandEditor button,.commandEditor input { min-height:27px; padding:2px 6px; font:600 12px var(--mono); }
.hashOperations button { flex:none; }
.hashOperations [aria-current] { border-color:#81cfb3; }
.hashCompared { background:#ffc480; color:#272031; border-radius:2px; padding:0 2px; }
.commandEditor input[type=number] { width:3.8em; }
.commandEditor label { display:flex; align-items:center; gap:4px; font:600 12px var(--mono); }
.commandEditor select { min-width:0; max-width:100%; }
@media (max-width:920px) {
  .hashScroll { max-height:22vh; }
  .hashHeading { font-size:12px; }
  .hashGrid td { padding:1px; }
  .hashGrid button { min-height:20px; }
}

.searchTreePlot { align-items:stretch; }
.searchTreePanel { display:grid; grid-template-rows:auto minmax(0,1fr) auto auto; width:100%; min-height:0; gap:5px; }
.searchTreeHeading { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:4px; font:600 clamp(13px,1.9vw,20px) var(--mono); color:var(--mint); }
.searchTreeExpression { color:#e7d6a5; direction:ltr; }
.treeInvariants { display:flex; flex-wrap:wrap; gap:2px 8px; font:600 11px var(--mono); }
.treeInvariants .met { color:#a0dec3; }
.treeInvariants .pending { color:#ffd18d; }
.searchTreeViewport { overflow:auto; max-height:min(41vh,350px); min-height:40px; direction:ltr; scrollbar-width:thin; }
.searchTreeViewport svg { display:block; margin-inline:auto; }
.searchTreeNode .treeBody { fill:#353048; stroke:#a99bc8; stroke-width:1.5; }
.searchTreeNode.red .treeBody { fill:#8e354a; stroke:#ffc4ce; }
.searchTreeNode.black .treeBody { fill:#201e29; stroke:#d7cce6; }
.treeKey,.treeEmpty { fill:#fff; font:600 10px var(--mono); text-anchor:middle; dominant-baseline:central; }
.treeHeight { fill:#c6f4df; font:600 7px var(--mono); paint-order:stroke; stroke:#26212c; stroke-width:2px; }
.treeEdge { stroke:#897d9a; stroke-width:1.7; }
.treeEdge.visited { stroke:#b6a4e8; stroke-width:2.4; }
.treeHalo { fill:none; stroke:#ffc77f; stroke-width:2; }
.searchTreeNode.related .treeHalo { stroke:#a2e8cf; stroke-dasharray:3 2; }
.searchTreeNode[role=button] { cursor:pointer; }
.searchTreeNode:focus-visible { outline:none; }
.searchTreeNode:focus-visible .treeBody { stroke:#ffc77f; stroke-width:3; }
.searchTreeOps { display:flex; overflow-x:auto; gap:3px; padding:2px; scrollbar-width:thin; }
.searchTreeOps button,.searchTreeEdit button { min-height:26px; min-width:27px; padding:2px 6px; font:600 12px var(--mono); white-space:nowrap; }
.searchTreeOps [aria-current] { outline:2px solid #a2e8cf; outline-offset:-2px; }
.searchTreeEdit { display:flex; align-items:center; flex-wrap:wrap; gap:4px; }
.searchTreeEdit input { width:4.5em; }
.searchTreeEdit :is(select,input) { min-height:27px; padding:2px 4px; }
@media(max-width:920px) {
  .searchTreeViewport { max-height:21vh; }
  .treeKey { font-size:11.5px; }
  .treeHeight { font-size:8px; }
  .searchTreePanel { gap:3px; }
  .searchTreeHeading { font-size:12px; }
  .searchTreeOps button { min-height:26px; }
}

.linearLayout .scalarFields:empty {display:none;}
.linearLayout .scalarPlot {display:flex;flex-direction:column;justify-content:center;align-items:stretch;gap:8px;min-height:0;}
.linearCanvas {display:grid;align-content:center;gap:8px;min-width:0;}
.linearMetrics,.linearOps,.linearEdit {display:flex;align-items:center;justify-content:center;gap:5px;flex-wrap:wrap;}
.linearMetrics {font:600 clamp(12px,1.3vw,16px) var(--mono);color:#e4ddf2;}
.linearMetric {padding:2px 6px;border-bottom:1px solid #8271aa;}
.linearOps {max-height:68px;overflow:auto;align-content:flex-start;}
.linearOps button,.linearEdit button,.linearEdit select,.linearEdit input {min-height:28px;padding:2px 5px;font:600 12px var(--mono);}
.linearOps button[aria-current] {color:var(--mint);outline:1px solid var(--mint);}
.linearOps button:disabled {opacity:.55;}
.linearEdit label {display:flex;align-items:center;gap:2px;font:600 11px var(--mono);}
.linearEdit input {width:3.6em;}
.linearEdit select {max-width:13em;}
.linearCaption {margin:0;color:var(--mint);font:600 clamp(12px,1.6vw,19px) var(--mono);text-align:center;overflow-wrap:anywhere;}
@media (max-width:920px) {
  .linearCanvas,.linearLayout .scalarPlot {gap:4px;}
  .linearOps {max-height:34px;flex-wrap:nowrap;justify-content:safe center;overflow-x:auto;}
  .linearOps button {white-space:nowrap;flex:none;}
  .linearEdit {gap:3px;}
  .linearEdit select {max-width:10em;}
}

.dynPane {display:grid;grid-template-columns:clamp(54px,15%,96px) minmax(0,1fr);align-items:center;gap:6px;}
.dynName {font:600 clamp(11px,1.3vw,16px) var(--mono);color:#e8e2f5;max-width:10em;overflow-wrap:anywhere;}
.dynGrid {display:grid;grid-template-columns:repeat(var(--columns),minmax(0,1fr));gap:3px;}
.dynCell {display:grid;place-items:center;min-height:36px;border:1px dashed #7e718b;border-radius:4px;}
.dynCell small {font:500 10px var(--mono);color:#b9acca;}
.dynCell b {font:650 clamp(14px,2.1vw,25px) var(--mono);color:#aaa0ba;}
.dynCell.occupied {border:1px solid #9a8eb8;background:#393047;}
.dynCell.occupied b {color:#f4eefb;}
.dynCell.current {outline:2px solid #ffd08a;outline-offset:-2px;}
.dynPane:has(+.linearCaption) .dynCell.current {outline-color:var(--mint);}
@media(max-width:920px){.dynCell {min-height:27px;}.dynName {max-width:7em;}.dynCell small {font-size:9px;}}

.dllScroll {max-width:100%;overflow:auto;}
.dllDiagram {display:block;width:100%;max-height:clamp(100px,18vh,210px);}
.dllDiagram text {font-family:var(--mono);text-anchor:middle;fill:#f4eef9;}
.dllNode rect {fill:#383045;stroke:#ab9dc4;stroke-width:1.5;}
.dllNode.current rect {stroke:#ffd08a;stroke-width:2.5;}
.dllId {font-size:8px;}
.dllValue {font-weight:700;font-size:15px;}
.dllPointer {fill:none;stroke-width:1.7;}
.dllPointer.next {stroke:#a99af0;}
.dllPointer.prev {stroke:#90dfc1;}
.dllPointer.active {stroke:#ffd08a;stroke-width:2.5;}
.dllLegend {display:flex;justify-content:center;gap:12px;font:600 12px var(--mono);}
.dllLegend .forward {color:#b9aaf7;}.dllLegend .backward {color:#9ce7c9;}
@media(max-width:920px){.dllDiagram {max-height:11vh;}}

.deqRing {display:block;width:100%;height:clamp(100px,27vh,255px);}
.deqTrack {fill:none;stroke:#70647f;stroke-width:2;stroke-dasharray:3 3;}
.deqCell rect {fill:#282233;stroke:#81728d;stroke-width:1;}
.deqCell.filled rect {fill:#3d3549;stroke:#b7aad0;}
.deqCell.current rect {stroke:#ffce85;stroke-width:2.5;}
.deqRing text {text-anchor:middle;font-family:var(--mono);fill:#f4edf9;}
.deqIndex {font-size:9px;}.deqValue {font-size:15px;font-weight:bold;}.deqCenter {font-size:12px;}
.deqFront,.deqBack {fill:none;stroke-width:3;}
.deqFront {stroke:#a392f4;}.deqBack {stroke:#8be3bd;}
.deqMetrics .front {border-color:#a392f4;}.deqMetrics .back {border-color:#8be3bd;}
.deqFresh {display:flex;justify-content:center;flex-wrap:wrap;gap:2px;}
.deqFresh span {border:1px dashed #81728d;min-width:16px;text-align:center;font:600 12px var(--mono);}
.deqFresh .active {outline:1px solid #ffd08a;}
.deqBfs {align-self:center;justify-self:center;color:#b9aaf7;font:600 12px var(--mono);}
@media(max-width:920px){.deqRing{height:clamp(80px,15vh,122px);}}

.wordTrieLayout .scalarFields:empty { display:none; }
.wordTrieScroll { overflow:auto; max-height:min(45vh,360px); min-height:0; scrollbar-width:thin; padding:2px; }
.wordTrieDrawing { display:block; min-width:155px; min-height:72px; margin:auto; overflow:visible; }
.trieEdge { fill:none; stroke:#847792; stroke-width:1.6px; }
.trieEdge.path { stroke:#9ce7c9; stroke-width:2.5px; }
.wordTrieNode circle { fill:#322d40; stroke:#b0a2be; stroke-width:1.5px; }
.wordTrieNode .trieEnd { fill:none; stroke:#9ce7c9; stroke-width:1.3px; }
.wordTrieNode.current circle:first-child { fill:#43372d; stroke:#ffca86; stroke-width:2.4px; }
.wordTrieNode text { fill:#fff; dominant-baseline:middle; text-anchor:middle; font:600 12px var(--mono); pointer-events:none; }
.wordTrieNode[role=button] { cursor:pointer; }
.wordTrieSummary { display:flex; gap:10px; align-items:center; flex-wrap:wrap; font:600 clamp(13px,1.8vw,22px) var(--mono); }
.trieYes { color:var(--mint); }
.trieNo { color:#ffb6a8; }
.wordTrieLayout .commandValue { width:7em; }
@media (max-width:920px) { .wordTrieScroll { max-height:20vh; } }
@media (min-width:921px) { .wordTrieDrawing { zoom:1.5; } }

.rangeCanvas { display:grid; gap:5px; width:min(100%,660px); min-width:0; align-self:center; font-family:var(--mono); }
.scalarLayout:has(.rangeCanvas) > .scalarFields:empty { display:none; }
.rangeCanvas * { box-sizing:border-box; }
.rangeEditor,.rangeParams { display:flex; flex-wrap:wrap; align-items:center; gap:5px; }
.rangeEditor { flex-direction:column; align-items:stretch; }
.rangeEditorHead { display:flex; align-items:center; justify-content:space-between; }
.rangeEditorHead strong,.rangeCaption { font-size:clamp(12px,1.3vw,16px); }
.rangeSize { display:flex; gap:4px; }
.rangeSize button { min-width:28px; min-height:25px; padding:2px; }
.rangeNumberRow,.rangeBoard { display:grid; grid-template-columns:repeat(var(--range-count),minmax(0,1fr)); gap:3px; direction:ltr; }
.rangeReadRow .rangeItem,.rangeNumberRow .rangeEditField { display:grid; text-align:center; gap:1px; min-width:0; }
.rangeItem small,.rangeEditField span { color:#c8bfd7; font-size:11px; }
.rangeItem strong { background:#312b3c; border-radius:3px; padding:2px 0; font-size:clamp(13px,1.6vw,19px); }
.rangeItem.selected strong { background:#443b56; box-shadow:inset 0 -2px #c2abff; }
.rangeEditField { display:flex; align-items:center; gap:4px; }
.rangeEditField input,.rangeEditField select { min-width:0; max-width:100%; min-height:26px; padding:2px; font:inherit; border:1px solid #736882; border-radius:4px; color:inherit; background:#282433; }
.rangeEditField input { width:3.9em; text-align:center; }
.rangeNumberRow input { width:100%; }
.rangeReadRow { margin-bottom:3px; }
.rangeBoard { gap:3px; }
.rangeBlock { display:flex; align-items:center; justify-content:center; min-width:0; min-height:25px; padding:1px 2px; border:1px solid #736783; border-radius:4px; font:600 clamp(12px,1.5vw,19px) var(--mono); color:#e7e0f0; background:#332c3d; overflow:hidden; }
.rangeBlock.used { background:#254438; border-color:#84d5b5; color:#c5f9e3; }
.rangeBlock.current { outline:2px solid #ffca8d; outline-offset:-2px; color:#fff1df; }
.rangeAnswer { font-weight:650; color:var(--mint); font-size:clamp(13px,1.75vw,22px); overflow-wrap:anywhere; }
.rangeTrail { display:flex; align-items:center; flex-wrap:wrap; gap:4px; font-size:13px; }
.rangeTrail button { padding:2px 5px; min-height:24px; }
@media (max-width:920px) {
  body[data-mode="setup"]:not(.lessonPreview) .scalarLayout:has(.rangeCanvas) { justify-content:flex-start; padding-top:12px; }
  .rangeCanvas { gap:3px; }
  .rangeBlock { min-height:19px; font-size:12px; }
  .rangeItem small,.rangeEditField span { font-size:10px; }
  .rangeParams { gap:3px 6px; }
  .rangeEditField input { min-height:24px; }
}

.fenwickCanvas .rangeBoard { align-content:start; }
.fenwickCanvas .rangeTrail { justify-content:flex-start; }

.segmentCanvas .rangeBlock.padding { border-style:dashed; color:#aba2b3; opacity:.6; }
.segmentCanvas .rangeBoard { align-content:start; }
.segmentIndices { display:grid; grid-template-columns:repeat(var(--range-count),minmax(0,1fr)); gap:3px; direction:ltr; text-align:center; }
.segmentIndices small { font-size:11px; color:#bfb5cd; }
.segmentIndices .inside { color:#b9f4d8; border-top:2px solid #78bc9e; }
@media (max-width:920px) {
  .segmentCanvas .rangeParams { row-gap:2px; }
  .segmentCanvas .rangeEditor { gap:3px; }
}

.sparseGrid { display:grid; grid-template-columns:24px repeat(var(--range-count),minmax(0,1fr)); gap:2px; direction:ltr; }
.sparseWidth { align-self:center; font-size:11px; color:#d5c7e4; }
.sparseCanvas .rangeReadRow,.sparseCoverage { margin-inline-start:26px; }
.sparseCoverage { display:grid; grid-template-columns:repeat(var(--range-count),minmax(0,1fr)); gap:2px; direction:ltr; }
.sparseLeft { border-color:#a1e5c9; background:#254438; }
.sparseRight { border-color:#c3aff5; background:#3d3252; }
@media (max-width:920px) {
  .sparseCanvas .rangeBlock { min-height:17px; }
  .sparseCanvas .rangeReadRow { margin-bottom:0; }
  .sparseCoverage .rangeBlock { font-size:11px; }
}
