:root {
  --bg: #fbfaf7; --panel: #ffffff; --soft: #f3f1ea; --text: #1f1e1c; --muted: #6b6a64;
  --border: #d9d6cc; --accent: #534ab7; --accent-soft: #eeedfe;
  --frame-bg: #e8eef8; --frame-border: #b5c6e3;
  --obj-bg: #fff7d6; --obj-border: #d9c77a; --obj-head: #7a6a1f;
  --arrow: #1f4e8c; --prev: #137333; --next: #2e7d32;
  --cur-line: #eff8ee; --prev-line: #d8f0d5;
  --err-bg: #fcebeb; --err: #a32d2d; --warn-bg: #faeeda; --warn: #854f0b;
  --hot: #137333; --hot-soft: rgba(19, 115, 51, 0.2); --hot-glow: rgba(19, 115, 51, 0.8); --chg-bg: #eaf6eb; --ghost: #b4b2a9;
  --stack-arrow: #7048e8; --stack-arrow-soft: #f3f0ff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b19; --panel: #232321; --soft: #2b2b28; --text: #ecebe6; --muted: #a3a29b;
    --border: #44443f; --accent: #afa9ec; --accent-soft: #2f2a5c;
    --frame-bg: #1f2a3b; --frame-border: #3b5378;
    --obj-bg: #332d14; --obj-border: #6b5f2a; --obj-head: #e5d58a;
    --arrow: #85b7eb; --prev: #56d364; --next: #86efac;
    --cur-line: #152917; --prev-line: #1f4124;
    --err-bg: #501313; --err: #f09595; --warn-bg: #412402; --warn: #fac775;
    --hot: #56d364; --hot-soft: rgba(86, 211, 100, 0.25); --hot-glow: rgba(86, 211, 100, 0.8); --chg-bg: #15331c; --ghost: #6b6a64;
    --stack-arrow: #b197fc; --stack-arrow-soft: #381e72;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.grow { flex: 1; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.logo { font-family: var(--mono); font-size: 22px; letter-spacing: -0.5px; }
.logo b { color: var(--accent); }
.tag { color: var(--muted); font-size: 14px; }
.gh { margin-left: auto; font-size: 14px; }

.workspace { display: grid; grid-template-columns: minmax(300px, var(--left-w, 42%)) 14px minmax(0, 1fr); gap: 2px;
  padding: 14px 16px; max-width: 1700px; margin: 0 auto; align-items: start; }
.workspace > * { min-width: 0; }
@media (max-width: 900px) { .workspace { grid-template-columns: minmax(0, 1fr); } .splitter { display: none; } }
/* Drag handle between the code and the drawing: a small grip, no full-height line. */
.splitter { align-self: stretch; cursor: col-resize; position: relative; touch-action: none; }
.splitter::after { content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 44px;
  transform: translate(-50%, -50%); border-radius: 4px; background: var(--border); opacity: .7;
  transition: background .15s, opacity .15s, height .15s; }
.splitter:hover::after, .splitter:focus-visible::after { opacity: 1; background: var(--muted); }
.splitter.dragging::after { opacity: 1; background: var(--accent); height: 64px; }
.splitter:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing .viz { pointer-events: none; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; min-height: 34px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

button, select { font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; }
button:hover:not(:disabled) { background: var(--soft); }
button:disabled { opacity: .5; cursor: default; }
.snippet-btn { font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.snippet-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#delete-code:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }

/* editor: a transparent textarea over a layer that paints the current-line highlights */
.editor-wrap { --lh: 21px; --pad: 12px; display: flex; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); overflow: hidden; height: min(58vh, 640px); min-height: 260px; resize: vertical; }
.gutter { flex: none; width: 58px; background: var(--soft); overflow: hidden; padding: var(--pad) 0;
  font-family: var(--mono); font-size: 14px; line-height: var(--lh); color: var(--muted); user-select: none; }
.gutter-inner { will-change: transform; }
.gl { display: flex; height: var(--lh); }
.gl .mark { width: 20px; text-align: center; }
.gl .num { flex: 1; text-align: right; padding-right: 10px; }
.gl.prev .mark { color: var(--prev); }
.gl.next .mark { color: var(--next); }
.gl.error .num { color: var(--err); font-weight: 600; }
.code-area { position: relative; flex: 1; min-width: 0; }
.hl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hl-inner { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.hl-line { position: absolute; left: 0; right: 0; height: var(--lh); }
.hl-line.prev { background: var(--prev-line); }
.hl-line.next { background: var(--cur-line); }
.hl-line.error { background: var(--err-bg); }
#editor { position: relative; width: 100%; height: 100%; border: 0; outline: none; resize: none; margin: 0;
  padding: var(--pad); font-family: var(--mono); font-size: 14px; line-height: var(--lh); background: transparent;
  color: var(--text); white-space: pre; overflow: auto; tab-size: 4; }

.controls { margin-top: 10px; }
.stepper { display: flex; gap: 6px; justify-content: center; }
#slider { width: 100%; margin: 10px 0 2px; accent-color: var(--accent); }
.step-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.legend { color: var(--muted); }
.legend .prev-mark { color: var(--prev); }
.legend .next-mark { color: var(--next); margin-left: 8px; }
.step-label { color: var(--muted); }
.banner { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.banner.error { background: var(--err-bg); color: var(--err); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.out-title { margin-top: 14px; font-size: 13px; }
.stdout { margin: 4px 0 0; min-height: 38px; max-height: 160px; overflow: auto; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-family: var(--mono); font-size: 13px; }

.placeholder { padding: 40px 20px; text-align: center; line-height: 1.7; }
.placeholder .muted { font-size: 13px; }

.viz-col { overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); min-height: 300px; max-height: calc(100vh - 150px); }
.viz { position: relative; display: flex; gap: 56px; padding: 16px; min-width: max-content; }
.arrows { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.frames { display: flex; flex-direction: column; gap: 14px; flex: none; }
.heap { position: relative; flex: none; margin-top: 26px; }  /* room for arrows that arc over the top row */

.frame { background: var(--frame-bg); border: 1px solid var(--frame-border); border-radius: 8px; min-width: 150px; }
.frame.active { border-width: 2px; }
.frame-name { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border-bottom: 1px solid var(--frame-border); }
.vrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 5px 10px;
  font-family: var(--mono); font-size: 13px; }
.vrow .vname { color: var(--text); }
.vrow.ret .vname { color: var(--next); }
.val { font-family: var(--mono); font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--arrow); vertical-align: middle; }
.ptr { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; min-height: 18px; }

.obj { position: absolute; background: var(--obj-bg); border: 1px solid var(--obj-border); border-radius: 6px;
  font-family: var(--mono); font-size: 13px; transition: left .15s, top .15s; }
.obj { cursor: move; cursor: grab; touch-action: none; user-select: none; }
.obj:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.obj-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--obj-head); padding: 3px 8px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: .2px; }
.obj-head .obj-actions { display: inline-flex; align-items: center; margin-left: auto; margin-right: 4px; }
.obj-head::after { content: "⠿"; color: var(--muted); opacity: .45; font-size: 12px; line-height: 1; flex: none; }
.obj:hover .obj-head::after { opacity: 1; color: var(--accent); }
.obj.dragging { cursor: grabbing; transition: none; z-index: 5; outline: 2px solid var(--accent); outline-offset: 1px; }
.obj.dragging * { cursor: grabbing; }

.orient-btn { font-family: var(--mono); font-size: 10px; line-height: 1.2; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; transition: all .15s; }
.orient-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.obj table { border-collapse: collapse; }
.obj td { border-top: 1px solid var(--obj-border); padding: 4px 8px; white-space: nowrap; }
.obj td.k { color: var(--muted); border-right: 1px solid var(--obj-border); }
.obj .cells { display: flex; border-top: 1px solid var(--obj-border); }
.obj .cell { display: flex; flex-direction: column; align-items: center; border-right: 1px solid var(--obj-border); min-width: 36px; }
.obj .cell:last-child { border-right: 0; }
.obj .cell .idx { font-size: 10px; color: var(--muted); padding: 2px 4px 0; display: flex; align-items: center; gap: 3px; }
.obj .cell .v { padding: 2px 6px 5px; display: flex; align-items: center; justify-content: center; }
.obj .plain { padding: 5px 9px; border-top: 1px solid var(--obj-border); }
.obj.empty .cells { padding: 5px 9px; color: var(--muted); }

/* Vertical list layout: stack grows upward with index 0 at the bottom */
.obj .cells.vertical { display: flex; flex-direction: column-reverse; min-width: 100px; }
.obj .cells.vertical .cell { display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  border-right: 0; border-bottom: 1px solid var(--obj-border); min-width: auto; min-height: 27px; padding: 3px 8px; gap: 14px; }
.obj .cells.vertical .cell:first-child { border-bottom: 0; }
.obj .cells.vertical .cell .idx { padding: 0; display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; }
.obj .cells.vertical .cell .v { padding: 0; display: flex; align-items: center; justify-content: flex-end; }
.obj .cells.vertical.muted { padding: 5px 9px; font-size: 12px; }

.pop-orient-btn { font-size: 12px; padding: 4px 10px; }

.stack-badge { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 0 3px; border-radius: 3px; line-height: 1.3; }
.stack-badge.top { background: var(--accent-soft); color: var(--accent); }
.stack-badge.front { background: var(--soft); color: var(--muted); }

.ptr.in-col { display: inline-flex; align-items: center; gap: 4px; min-height: 20px; }
.ptr.is-stack .dot,
.is-stack .ptr .dot,
.ptr.in-col .dot {
  background: var(--stack-arrow);
  box-shadow: 0 0 0 1px var(--panel);
}

.arr-path.arr-stack {
  stroke: var(--stack-arrow);
  stroke-dasharray: 6 3.5;
  stroke-linecap: round;
}
.arr-dot.arr-dot-stack {
  fill: var(--stack-arrow);
}

.arr-path.arr-tree {
  stroke: var(--arrow);
  stroke-width: 2px;
}
.ref-chip { font-family: var(--mono); font-size: 11px; line-height: 1.3; padding: 1px 5px; border-radius: 4px;
  background: var(--soft); color: var(--text); border: 1px solid var(--border); white-space: nowrap;
  max-width: 95px; text-overflow: ellipsis; overflow: hidden; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.ref-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }
.ref-chip.changed { background: var(--chg-bg); border-color: var(--hot); color: var(--hot); font-weight: 600; }

/* interactive focus and hover */
.arrows .arr-path.hover-active { stroke: var(--hot) !important; stroke-width: 2.8px !important; opacity: 1 !important; marker-end: url(#head-hover) !important; filter: drop-shadow(0 0 2px var(--hot)); }
.arrows .arr-dot.hover-active { fill: var(--hot) !important; r: 4.5px !important; }
.obj.target-active { outline: 2px solid var(--hot) !important; outline-offset: 2px; box-shadow: 0 0 10px var(--hot-soft); z-index: 10; }
.obj.source-active { outline: 2px dashed var(--accent) !important; outline-offset: 2px; }
.obj.target-pulse { animation: target-pulse 1.2s ease-out; }
@keyframes target-pulse {
  0% { box-shadow: 0 0 0 0 var(--hot-glow); }
  70% { box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

.foot { text-align: center; font-size: 13px; padding: 18px 20px 28px; }
kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }

/* what changed */
.changes-dock { margin: 0 0 10px; }
.changes-box { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); overflow: hidden; }
.changes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 0 14px; }
.changes-title { font-size: 12px; color: var(--muted); letter-spacing: .2px; }
button.mini { font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.changes { padding: 2px 14px 9px; font-size: 14px; line-height: 1.55; }
/* floating: a small window you can drag by its header and resize from the corner */
.changes-box.floating { position: fixed; z-index: 40; width: 380px; min-width: 240px; min-height: 80px; max-height: 70vh;
  resize: both; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.changes-box.floating .changes-head { cursor: move; user-select: none; touch-action: none; background: var(--soft);
  padding-bottom: 4px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.changes-box.floating .changes { min-height: 0 !important; padding-top: 6px; }
.changes-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.changes .ran { color: var(--muted); font-size: 13px; }
.changes ul { margin: 4px 0 0; padding-left: 18px; }
.changes li { margin: 1px 0; }
.changes .none { margin-top: 4px; color: var(--muted); }
.changes code { font-family: var(--mono); font-size: 13px; background: var(--soft); padding: 0 4px; border-radius: 4px; }
.changes .was { color: var(--muted); }
.changes .lost { color: var(--hot); }

.vrow.changed, .obj td.v.changed, .obj .cell.changed { background: var(--chg-bg); animation: flash .9s ease-out; }
@keyframes flash { from { box-shadow: inset 0 0 0 2px var(--hot); } to { box-shadow: inset 0 0 0 0 transparent; } }
.anchor { display: inline-block; width: 1px; height: 1px; }

/* labels mode */
.chip { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.changed { background: var(--chg-bg); color: var(--hot); font-weight: 600; }
.tags { position: absolute; left: -1px; bottom: calc(100% + 4px); display: flex; flex-wrap: wrap; gap: 3px; width: max-content; max-width: 230px; }
.ptag { font-family: var(--mono); font-size: 11.5px; line-height: 1.5; padding: 0 6px; border-radius: 4px; white-space: nowrap;
  background: var(--frame-bg); border: 1px solid var(--frame-border); color: var(--text); }
.ptag.local { border-color: var(--accent); color: var(--accent); }
.ptag.changed { background: var(--hot); border-color: var(--hot); color: #fff; }

.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
/* Neighbouring buttons overlap by 1px so there's a single divider; the selected
   one is lifted above its neighbour so all four of its accent borders show. */
.seg button:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.seg button { position: relative; }
.seg button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); z-index: 1; }

/* per-variable colours */
.vname { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border-radius: 4px; padding: 0 2px; margin: 0 -2px; }
.vname:hover { background: var(--accent-soft); }
.vname:focus-visible { outline: 2px solid var(--accent); }
.vrow { border-radius: 4px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; border: 2px solid transparent; flex: none; }
.ptag { cursor: pointer; }
.color-pop { position: absolute; z-index: 50; width: 300px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14); font-size: 13px; }
.pop-title { margin-bottom: 6px; }
.pop-title code { font-family: var(--mono); font-weight: 600; }
.pop-label { margin: 8px 0 4px; }
.pop-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; box-shadow: 0 0 0 1px var(--border); }
.sw.on { border-color: var(--panel); box-shadow: 0 0 0 2px var(--text); }
.sw.none { background: var(--panel); color: var(--muted); font-size: 13px; line-height: 18px; text-align: center; }
.sw.custom { position: relative; overflow: hidden; background: conic-gradient(#e03131, #f08c00, #fcc419, #2f9e44, #1c7ed6, #7048e8, #e03131); }
.sw.custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.pop-foot button { padding: 4px 10px; font-size: 13px; }

.version { display: inline-block; margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: none; }
.version:hover { color: var(--accent); text-decoration: underline; }

/* fading, to focus on some variables */
.vrow.faded, .ptag.faded, .obj.faded { opacity: .28; transition: opacity .15s; }
.vrow.faded:hover, .ptag.faded:hover, .obj.faded:hover { opacity: .75; }
.obj-head { cursor: pointer; }
.pop-fade.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.color-pop .pop-row button:not(.sw) { font-size: 13px; padding: 4px 10px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: min(560px, calc(100vw - 32px));
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px 10px 16px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); font-size: 14px; line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0,0,0,.15); }

/* ---------- Abstract Mode & Selection ---------- */
.obj.abstract-node {
  background: transparent;
  border: 0;
  box-shadow: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
}
.obj.abstract-node:hover {
  border: 0;
  box-shadow: none;
}
.obj.abstract-node .abstract-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--obj-bg);
  border: 2px solid var(--obj-border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.obj.abstract-node .abstract-circle:active {
  cursor: grabbing;
}
.obj.abstract-node:hover .abstract-circle {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 4px 10px rgba(0,0,0,0.12);
}
.obj.abstract-node.changed .abstract-circle {
  border-color: var(--hot);
  box-shadow: 0 0 0 2px var(--hot-soft);
}
.obj.abstract-node.changed .abstract-val {
  color: var(--hot);
}
.abstract-val {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  pointer-events: none;
  user-select: none;
  max-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.abstract-val.sm {
  font-size: 11px;
  font-weight: 600;
}

/* Ports on abstract circle */
.abstract-port {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.abstract-port.port-left { bottom: 2px; left: 6px; }
.abstract-port.port-right { bottom: 2px; right: 6px; }
.abstract-port.port-next { right: -3px; top: 50%; transform: translateY(-50%); }
.abstract-port .ptr {
  min-width: 10px;
  min-height: 10px;
}
.abstract-port .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--arrow);
  border: 1.5px solid var(--panel);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform .15s, background-color .15s;
}
.abstract-port:hover .dot {
  transform: scale(1.4);
  background: var(--accent);
}

/* Tooltip on abstract node hover */
.obj.abstract-node .abstract-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px 10px;
  z-index: 100;
  min-width: 140px;
  max-width: 260px;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.obj.abstract-node:hover .abstract-tooltip,
.obj.abstract-node:focus-within .abstract-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.obj.abstract-node.tooltip-top .abstract-tooltip {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}
.obj.abstract-node.tooltip-top:hover .abstract-tooltip,
.obj.abstract-node.tooltip-top:focus-within .abstract-tooltip {
  transform: translateX(-50%) translateY(0);
}
.obj.abstract-node .abstract-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent var(--border) transparent;
}
.obj.abstract-node.tooltip-top .abstract-tooltip::before {
  bottom: auto;
  top: 100%;
  border-color: var(--border) transparent transparent transparent;
}
.abstract-tooltip .tooltip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.abstract-tooltip table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
}
.abstract-tooltip td {
  padding: 2px 6px;
  white-space: nowrap;
}
.abstract-tooltip td.k {
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.abstract-tooltip td.v {
  padding-left: 8px;
}
.abstract-tooltip td.v.changed {
  background: var(--chg-bg);
  color: var(--hot);
  font-weight: 600;
}

/* Button to abstract / expand single node */
.abstract-btn, .expand-btn {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.abstract-btn:hover, .expand-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Selection highlight */
.obj.selected:not(.abstract-node) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.obj.abstract-node.selected .abstract-circle {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--accent-soft);
}

/* Selection marquee rectangle */
.selection-marquee {
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: rgba(83, 74, 183, 0.12);
  pointer-events: none;
  z-index: 90;
  border-radius: 4px;
}

/* Floating multi-select action bar */
.selection-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  z-index: 85;
  animation: slide-up .18s ease-out;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.selection-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}
.sel-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.sel-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sel-btn.mini {
  padding: 2px 7px;
  font-size: 13px;
  line-height: 1;
}

/* Desktop: fit the page to the window, so there's no page scrollbar by default.
   The editor and the drawing take whatever height is left; the drawing scrolls
   inside its own box. Short windows fall back to normal page scrolling. */
@media (min-width: 901px) and (min-height: 560px) {
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .top { flex: none; padding: 10px 20px; }
  .workspace { flex: 1; min-height: 0; width: 100%; box-sizing: border-box; align-items: stretch; padding: 12px 16px 6px; }
  .workspace > .left, .workspace > .right { display: flex; flex-direction: column; min-height: 0; }
  .workspace > .left > *, .workspace > .right > * { flex: none; }
  .workspace > .left > .editor-wrap { flex: 1; height: auto; min-height: 160px; resize: none; }
  .workspace > .right > .viz-col { flex: 1; min-height: 0; max-height: none; }
  .out-title { margin-top: 8px; }
  .stdout { max-height: 96px; }
  .foot { flex: none; padding: 4px 20px 8px; font-size: 12px; line-height: 1.5; }
}
