/* Axon Studio — studio-canvas (docs/studio.md §11). Owner: see docs/studio.md; prefix st- (studio), stc- (canvas), sts- (sources), sta- (agent).
   The node-graph editor (js/studio/editor/*). Type leads the hierarchy, surfaces separate layers, colour carries
   meaning only: a node's category tints its title bar, a port's type colours its socket and its wires, and status
   colours appear only where a run says something. Row heights mirror js/studio/editor/geometry.js (HEAD 36, ROW 24,
   PARAM 30, PREVIEW 76, FOOT 28): sockets are placed by computation, so keep both in step. */

/* set on the viewport every frame while zooming: registered as not inherited, so changing it restyles only the
   viewport, never the thousands of elements inside it */
@property --stc-dot-a { syntax: "<number>"; inherits: false; initial-value: 1; }

.stc-root {
  /* port types (types.PORT_COLORS), tuned per theme for contrast on the card */
  --stc-t-table: #6aa8ff;
  --stc-t-series: #3fd5ae;
  --stc-t-number: #c3a6ff;
  --stc-t-text: #b8bcc6;
  --stc-t-documents: #ffb86b;
  --stc-t-markets: #ff7eb6;
  --stc-t-event: #ffd166;
  --stc-t-probability: #5ce1e6;
  --stc-t-scenarios: #f78c6b;
  --stc-t-report: #e6e6e6;
  --stc-t-chart: #9be564;
  --stc-t-signal: #ff6b6b;
  --stc-t-any: #8a8f98;

  --stc-node: #17171b;
  --stc-node-2: #1f1f24;
  --stc-node-line: rgba(255, 255, 255, 0.07);
  --stc-node-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.32);
  --stc-head-tint: 26%;
  --stc-dot-rgb: 255 255 255;
  --stc-dot-alpha: 0.085;
  --stc-dot-major: rgba(255, 255, 255, 0.11);
  --stc-mm-view: rgba(255, 255, 255, 0.07);
  --stc-sheen: rgba(255, 255, 255, 0.16);
  --stc-z: 1;

  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: -0.003em;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  outline: none;
  isolation: isolate;
}
:root[data-theme="light"] .stc-root {
  --stc-t-table: #2f6fdb;
  --stc-t-series: #0f9d7a;
  --stc-t-number: #7b5cd6;
  --stc-t-text: #6b7280;
  --stc-t-documents: #d97706;
  --stc-t-markets: #d63384;
  --stc-t-event: #b88a00;
  --stc-t-probability: #0e9aa7;
  --stc-t-scenarios: #e0603c;
  --stc-t-report: #4b5563;
  --stc-t-chart: #4d9a1f;
  --stc-t-signal: #e03e3e;
  --stc-t-any: #8a8f98;
  --stc-node: #ffffff;
  --stc-node-2: #f4f4f6;
  --stc-node-line: rgba(0, 0, 0, 0.07);
  --stc-node-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.08);
  --stc-head-tint: 18%;
  --stc-dot-rgb: 0 0 0;
  --stc-dot-alpha: 0.13;
  --stc-dot-major: rgba(0, 0, 0, 0.16);
  --stc-mm-view: rgba(0, 0, 0, 0.05);
  --stc-sheen: rgba(255, 255, 255, 0.7);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .stc-root {
    --stc-t-table: #2f6fdb; --stc-t-series: #0f9d7a; --stc-t-number: #7b5cd6; --stc-t-text: #6b7280;
    --stc-t-documents: #d97706; --stc-t-markets: #d63384; --stc-t-event: #b88a00; --stc-t-probability: #0e9aa7;
    --stc-t-scenarios: #e0603c; --stc-t-report: #4b5563; --stc-t-chart: #4d9a1f; --stc-t-signal: #e03e3e; --stc-t-any: #8a8f98;
    --stc-node: #ffffff; --stc-node-2: #f4f4f6; --stc-node-line: rgba(0, 0, 0, 0.07);
    --stc-node-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.08);
    --stc-head-tint: 18%; --stc-dot-rgb: 0 0 0; --stc-dot-alpha: 0.13; --stc-dot-major: rgba(0, 0, 0, 0.16);
    --stc-mm-view: rgba(0, 0, 0, 0.05); --stc-sheen: rgba(255, 255, 255, 0.7);
  }
}
.stc-root:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }

/* ------------------------------------------------------------------ viewport, grid, world */
.stc-viewport {
  position: absolute;
  inset: 0 0 var(--stc-bar, 40px) 0;
  overflow: hidden;
  cursor: default;
  background-color: var(--canvas);
  /* minor dots (fade out as you zoom out) and major dots every fifth step */
  background-image:
    radial-gradient(circle at 1px 1px, rgb(var(--stc-dot-rgb) / calc(var(--stc-dot-alpha) * var(--stc-dot-a, 1))) 1px, transparent 1.5px),
    radial-gradient(circle at 1.5px 1.5px, var(--stc-dot-major) 1.25px, transparent 1.9px);
  background-size: 24px 24px, 120px 120px;
}
/* gesture cursors sit on the viewport only: a gesture captures the pointer there, and a `.stc-viewport *` rule would
   restyle every element of a 200-node graph each time a gesture starts (measured 62 ms) */
.stc-root.is-panning .stc-viewport { cursor: grabbing; }
.stc-root.is-space .stc-viewport { cursor: grab; }
.stc-root.is-dragging .stc-viewport { cursor: grabbing; }
.stc-root.is-wiring .stc-viewport { cursor: crosshair; }
.stc-root.is-dropping .stc-viewport { box-shadow: inset 0 0 0 2px var(--accent); }
/* its own cursor stops the viewport's gesture cursors (inherited) from restyling every card when a gesture starts */
.stc-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; cursor: default; }
.stc-root.is-moving .stc-world { will-change: transform; }
.stc-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.stc-wires, .stc-overlay { position: absolute; left: 0; top: 0; width: 1px; height: 1px; max-width: none; overflow: visible; pointer-events: none; }
/* the wires get a compositing layer of their own: an SVG that overflows a 1px box is otherwise repainted on every
   pan frame (measured: 200 nodes / 398 wires, 28 ms → 9.7 ms a frame at 50% zoom) */
.stc-wires { will-change: transform; }
.stc-overlay { z-index: 4; }

/* ------------------------------------------------------------------ wires */
.stc-wire {
  fill: none;
  stroke: var(--c, var(--ink-3));
  stroke-width: 2.25px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.85;
  transition: opacity var(--t-1) var(--ease), stroke-width var(--t-1) var(--ease);
}
.stc-wire-hit { fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }
.stc-wire-hit:hover + .stc-wire { opacity: 1; stroke-width: 3px; }
.stc-wire.is-selected { opacity: 1; stroke-width: 3.25px; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--c) 70%, transparent)); }
.stc-wire.is-muted { opacity: 0.32; }
.stc-wire.is-problem { stroke: var(--crit); stroke-dasharray: 5 5; opacity: 1; }
.stc-wire.is-active { stroke-dasharray: 7 7; animation: stc-flow 0.9s linear infinite; opacity: 1; }
.stc-wire.is-hidden, .stc-wire-hit.is-hidden { display: none; }
.stc-wire-temp { opacity: 1; stroke-width: 2.5px; stroke-dasharray: none; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--c) 55%, transparent)); }
@keyframes stc-flow { to { stroke-dashoffset: -14; } }

/* ------------------------------------------------------------------ node cards */
.stc-node {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 12px;
  background: var(--stc-node);
  box-shadow: var(--stc-node-shadow);
  color: var(--ink);
  outline: none;
  transition: opacity var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
}
.stc-node:hover, .stc-node:focus-within, .stc-node.is-selected { z-index: 2; }
.stc-node.is-tip:has(.stc-tip:not([hidden])), .stc-node:focus-visible:has(.stc-tip:not([hidden])) { z-index: 3; }
.stc-node.is-selected { outline: 2px solid var(--accent); outline-offset: 3px; }
.stc-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.stc-head {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 4px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cat) var(--stc-head-tint), transparent), color-mix(in srgb, var(--cat) 6%, transparent) 85%);
  box-shadow: inset 0 -1px 0 var(--stc-node-line);
  overflow: hidden;
}
.stc-node.is-collapsed .stc-head { border-radius: 12px; box-shadow: none; }
.stc-title { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stc-collapse {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-3);
}
.stc-collapse:hover { background: var(--wash-2); color: var(--ink); }
.stc-collapse svg { width: 14px; height: 14px; transition: transform var(--t-1) var(--ease); }
.stc-node.is-collapsed .stc-collapse svg { transform: rotate(-90deg); }
.stc-status { flex: none; display: grid; place-items: center; width: 18px; height: 18px; color: var(--ink-3); }
.stc-status svg { width: 15px; height: 15px; }
.stc-node[data-status="done"] .stc-status { color: var(--ok); }
.stc-node[data-status="cached"] .stc-status { color: var(--accent-ink); }
.stc-node[data-status="failed"] .stc-status, .stc-node[data-status="blocked"] .stc-status { color: var(--crit); }
.stc-node[data-status="awaiting_approval"] .stc-status { color: var(--warn-ink); }
.stc-node[data-status="running"] .stc-status { color: var(--accent-ink); }
.stc-node[data-status="running"] .stc-status svg { animation: stc-spin 1s linear infinite; }
.stc-badge, .stc-pbadge {
  flex: none; display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.01em;
}
.stc-pbadge svg { width: 11px; height: 11px; }
.stc-badge-bypass { background: var(--biz-wash); color: var(--biz); }
.stc-pbadge.is-error { background: var(--crit-wash); color: var(--crit); }
.stc-pbadge.is-warning { background: var(--warn-wash); color: var(--warn-ink); }

/* run states */
.stc-node[data-status="running"] .stc-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--stc-sheen) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: stc-sheen 1.6s linear infinite;
  pointer-events: none;
  mix-blend-mode: soft-light;
}
.stc-node[data-status="running"] { box-shadow: var(--stc-node-shadow), 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent); }
.stc-node[data-status="pending"], .stc-node[data-status="queued"] { box-shadow: var(--stc-node-shadow), 0 0 0 1.5px color-mix(in srgb, var(--ink-3) 45%, transparent); }
.stc-node[data-status="failed"], .stc-node.has-error { box-shadow: var(--stc-node-shadow), 0 0 0 1.5px var(--crit); }
.stc-node[data-status="awaiting_approval"] { box-shadow: var(--stc-node-shadow), 0 0 0 1.5px var(--warn); }
.stc-node[data-status="awaiting_approval"] .stc-head { background: linear-gradient(90deg, var(--warn-wash), transparent 85%); }
.stc-node[data-status="blocked"] { box-shadow: var(--stc-node-shadow), 0 0 0 1.5px color-mix(in srgb, var(--crit) 60%, transparent); }
.stc-node[data-status="blocked"] .stc-head { background: repeating-linear-gradient(135deg, var(--crit-wash) 0 7px, transparent 7px 14px); }
/* skipped, cancelled and bypassed cards stay opaque (no wire shows through them); only their contents dim, and a dashed
   ring says they did not run */
.stc-node[data-status="skipped"], .stc-node[data-status="cancelled"] { box-shadow: var(--stc-node-shadow), 0 0 0 1px var(--stc-node-line); }
.stc-node[data-status="skipped"] > :not(.stc-tip):not(.stc-sock), .stc-node[data-status="cancelled"] > :not(.stc-tip):not(.stc-sock) { opacity: 0.66; }
.stc-node[data-status="skipped"]::after, .stc-node[data-status="cancelled"]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  outline: 1px dashed color-mix(in srgb, var(--ink-3) 70%, transparent); outline-offset: -1px;
}
.stc-node.is-bypassed > :not(.stc-tip):not(.stc-sock) { opacity: 0.7; }
.stc-node.is-bypassed .stc-head { background: repeating-linear-gradient(135deg, var(--biz-wash) 0 7px, transparent 7px 14px); }
.stc-node.is-unknown .stc-head { background: var(--crit-wash); }
.stc-unknown { position: absolute; left: 12px; right: 12px; top: 44px; display: flex; gap: 6px; align-items: center; color: var(--crit); font-size: 12px; }
@keyframes stc-sheen { from { background-position: 125% 0; } to { background-position: -125% 0; } }
@keyframes stc-spin { to { transform: rotate(360deg); } }

/* highlight (an agent's change, focusNode) */
.stc-node.is-highlight::before, .stc-note.is-highlight::before, .stc-group.is-highlight::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 18px;
  border: 2px solid var(--accent);
  pointer-events: none;
  animation: stc-hl 1.6s var(--ease) both;
}
@keyframes stc-hl {
  0% { opacity: 0; transform: scale(1.06); }
  18% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* sockets and port labels */
.stc-sock {
  position: absolute;
  z-index: 2;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--stc-node);
  box-shadow: inset 0 0 0 2px var(--c);
  cursor: crosshair;
  transition: transform var(--t-1) var(--ease), opacity var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
}
.stc-sock::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; }
.stc-sock.is-multi { border-radius: 3.5px; }
.stc-sock.is-multi::after { border-radius: 6px; }
.stc-sock.is-wired { background: var(--c); }
.stc-sock:hover { transform: scale(1.3); }
.stc-sock.is-problem { box-shadow: inset 0 0 0 2px var(--c), 0 0 0 3px var(--crit); }
.stc-root.is-readonly .stc-sock { cursor: default; }
.stc-root.is-readonly .stc-sock:hover { transform: none; }
.stc-root.is-wiring .stc-sock { opacity: 0.22; }
.stc-root.is-wiring .stc-sock.is-compat { opacity: 1; box-shadow: inset 0 0 0 2px var(--c), 0 0 0 4px color-mix(in srgb, var(--c) 32%, transparent); }
.stc-root.is-wiring .stc-sock.is-target { transform: scale(1.5); background: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent); }
.stc-root.is-wiring .stc-node:not(.has-compat) { opacity: 0.4; }
.stc-ports { position: absolute; left: 0; right: 0; top: 36px; pointer-events: none; }
.stc-plabel {
  position: absolute;
  height: 18px;
  line-height: 18px;
  max-width: calc(50% - 18px);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stc-plabel-in { left: 14px; }
.stc-plabel-out { right: 14px; text-align: right; }
.stc-plabel.is-optional { color: var(--ink-3); }

/* inline parameters */
.stc-params { position: absolute; left: 10px; right: 10px; }
.stc-prm { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); align-items: center; gap: 8px; height: 30px; }
.stc-prm-l { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stc-ctl {
  width: 100%;
  min-width: 0;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: var(--wash);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: background var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
}
.stc-ctl:hover:not([disabled]) { background: var(--wash-2); }
.stc-ctl:focus, .stc-ctl:focus-visible { outline: none; background: var(--wash-2); box-shadow: inset 0 0 0 1px var(--accent); }
.stc-ctl[disabled] { opacity: 0.75; cursor: default; }
.stc-ctl::placeholder { color: var(--ink-3); }
.stc-ctl.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.stc-ctl.is-mono { font-family: var(--mono); font-size: 11.5px; }
.stc-ctl-select { appearance: none; -webkit-appearance: none; padding-right: 22px; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 6px center; background-size: 12px; cursor: pointer; }
.stc-ctl-check { width: 16px; height: 16px; padding: 0; justify-self: end; accent-color: var(--accent); cursor: pointer; }
.stc-ctl-more { text-align: left; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.stc-ctl-more.is-empty { color: var(--ink-3); }
.stc-ctl::-webkit-inner-spin-button { opacity: 0.4; }
.stc-ctl[type="date"] { font-variant-numeric: tabular-nums; }
.stc-ctl[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; filter: invert(var(--stc-invert, 1)); }
:root[data-theme="light"] .stc-root { --stc-invert: 0; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .stc-root { --stc-invert: 0; } }

/* inline preview (filled by viz.preview) */
.stc-preview { position: absolute; left: 10px; right: 10px; border-radius: 9px; background: var(--stc-node-2); overflow: hidden; }
.stc-preview-in { position: absolute; inset: 0; padding: 6px 8px; font-size: 12px; color: var(--ink-2); overflow: hidden; }
.stc-preview-locked { position: absolute; inset: 0; display: flex; gap: 6px; align-items: center; justify-content: center; color: var(--ink-3); font-size: 12px; }
.stc-preview-locked svg { width: 14px; height: 14px; }

/* footer meta */
.stc-foot {
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border-top: 1px solid var(--stc-node-line);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.stc-summary { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.stc-chip { flex: none; display: inline-flex; align-items: center; gap: 3px; }
.stc-chip > span { overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.stc-chip.stc-src { flex: 0 1 auto; min-width: 24px; }
.stc-chip svg { width: 12px; height: 12px; flex: none; opacity: 0.85; }
.stc-chip.stc-src > span { max-width: 96px; }
.stc-lock { flex: none; }
.stc-lock.is-open { color: var(--ink-3); }
.stc-lock.is-restricted { color: var(--warn-ink); }
.stc-lock.is-blocked { color: var(--crit); }
.stc-conf::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: none; }
.stc-conf.is-high::before { background: var(--ok); }
.stc-conf.is-medium::before { background: var(--warn); }
.stc-conf.is-low::before { background: var(--crit); }
.stc-live.is-stale { color: var(--warn-ink); }
.stc-took { margin-left: auto; color: var(--ink-3); flex: none; }
.stc-kind { color: var(--ink-3); }
/* a value past its freshness window: still shown, its age in the warning ink */
.stc-chip.stc-stale { color: var(--warn-ink); }
.stc-chip.stc-stale > span { max-width: 132px; }
/* past its own freshness window but within the workflow's schedule: only a faint tint (QA-6) */
.stc-chip.stc-asof.is-aging { color: color-mix(in srgb, var(--warn-ink) 40%, var(--ink-3)); }
/* computed before newer upstream data: a small button that runs the node again */
.stc-chip.stc-rerun {
  height: 20px; padding: 0 7px; border: 0; border-radius: 999px; background: var(--warn-wash); color: var(--warn-ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
button.stc-chip.stc-rerun:hover { background: color-mix(in srgb, var(--warn) 26%, transparent); }
button.stc-chip.stc-rerun:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.stc-node.is-outdated .stc-preview-in { opacity: 0.85; }
/* rests on an input past its freshness window: a quiet hint, the number stays as it is */
.stc-chip.stc-stale-in { color: var(--warn-ink); opacity: 0.9; }
.stc-chip.stc-stale-in > span { max-width: 132px; }
/* a hidden badge, status or headline takes no room (their display rules would otherwise show an empty pill) */
.stc-pbadge[hidden], .stc-status[hidden], .stc-headline[hidden], .stc-badge[hidden] { display: none !important; }
/* the headline a far-away title strip shows (hidden at reading zoom, where the preview says it) */
.stc-headline { display: none; }

/* error and problem tooltip, kept at screen size whatever the zoom */
.stc-tip {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 6;
  width: max-content;
  min-width: 220px;
  max-width: 320px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--s3);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--hair-2);
  transform: scale(calc(1 / var(--stc-z)));
  transform-origin: 0 0;
  white-space: normal;
  pointer-events: none;
  display: none;
}
/* while the pointer is on the card (interact.js sets .is-tip) or it has keyboard focus; never just because it is
   selected, so it goes when the pointer leaves */
.stc-node.is-tip > .stc-tip:not([hidden]), .stc-node:focus-visible > .stc-tip:not([hidden]) { display: block; }
.stc-root.is-moving .stc-tip, .stc-root.is-dragging .stc-tip, .stc-root.is-wiring .stc-tip { display: none !important; }
.stc-tip p + p { margin-top: 5px; }
.stc-tip-err { color: var(--crit); font-weight: 550; }
.stc-tip-fix { color: var(--ink-2); }
.stc-tip-prob::before { content: "•"; color: var(--crit); margin-right: 6px; }
.stc-tip-prob.is-warning::before { color: var(--warn-ink); }

/* inline rename */
.stc-rename {
  flex: 1 1 auto; min-width: 0; height: 24px; padding: 0 6px; border: 0; border-radius: 6px; background: var(--stc-node);
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); outline: none;
  -webkit-user-select: text; user-select: text;
}

/* level of detail: far away, cards keep their colour and a large title */
.stc-root[data-lod="far"] .stc-plabel, .stc-root[data-lod="far"] .stc-params, .stc-root[data-lod="far"] .stc-foot > *,
.stc-root[data-lod="far"] .stc-preview-in, .stc-root[data-lod="far"] .stc-badge, .stc-root[data-lod="far"] .stc-pbadge,
.stc-root[data-lod="far"] .stc-collapse { visibility: hidden; }
/* far: the head fills the card and its title keeps about 12px on screen (it grows as the zoom shrinks), up to three lines */
.stc-root[data-lod="far"] .stc-node:not(.is-collapsed) .stc-head { bottom: 0; height: auto; align-items: flex-start; padding: 10px 12px; border-radius: 12px; box-shadow: none;
  background: color-mix(in srgb, var(--cat) 22%, var(--stc-node)); }
.stc-root[data-lod="far"] .stc-title { font-size: clamp(22px, calc(12px / var(--stc-z, 0.4)), 64px); line-height: 1.12; letter-spacing: -0.02em;
  white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.stc-root[data-lod="far"] .stc-node.is-collapsed .stc-title { -webkit-line-clamp: 1; font-size: clamp(18px, calc(11px / var(--stc-z, 0.4)), 28px); }
.stc-root[data-lod="far"] .stc-collapse { display: none; }
.stc-root[data-lod="far"] .stc-preview { visibility: hidden; }
/* far away a card's state is its ring: failed, waiting, running stay visible */
.stc-root[data-lod="far"] .stc-node[data-status="failed"], .stc-root[data-lod="far"] .stc-node.has-error { box-shadow: 0 0 0 3px var(--crit); }
.stc-root[data-lod="far"] .stc-node[data-status="awaiting_approval"] { box-shadow: 0 0 0 3px var(--warn); }
.stc-root[data-lod="far"] .stc-node[data-status="running"] { box-shadow: 0 0 0 3px var(--accent); }
.stc-root[data-lod="far"] .stc-node[data-status="blocked"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 60%, transparent); }
.stc-root[data-lod="far"] .stc-node { box-shadow: 0 0 0 1px var(--stc-node-line); background: color-mix(in srgb, var(--cat) 16%, var(--stc-node)); }
.stc-root[data-lod="far"] .stc-group-head { font-size: 30px; height: 56px; }
.stc-root[data-lod="far"] .stc-headline:not([hidden]) {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0 0.3em; position: absolute; left: 12px; right: 12px; bottom: 10px;
  font-size: clamp(26px, calc(17px / var(--stc-z, 0.4)), 84px); font-weight: 650;
  line-height: 1; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
}
.stc-root[data-lod="far"] .stc-hl-v { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stc-root[data-lod="far"] .stc-node.is-collapsed .stc-headline { display: none; }
.stc-root[data-lod="far"] .stc-node:has(.stc-headline:not([hidden])) .stc-title { -webkit-line-clamp: 2; }
.stc-root[data-lod="far"] .stc-node:has(.stc-hl-mark) .stc-title { -webkit-line-clamp: 1; }
.stc-root[data-lod="far"] .stc-node.is-stale .stc-headline .stc-hl-v { color: var(--warn-ink); }
/* a blend left with one venue: its name beside the far-away number ("30.5% Polymarket only") */
.stc-hl-l { display: none; }
.stc-root[data-lod="far"] .stc-hl-l {
  display: inline; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2);
  font-size: clamp(12px, calc(10.5px / var(--stc-z, 0.4)), 44px); font-weight: 600; letter-spacing: 0;
}
/* the mark beside a far-away headline: "needs re-run" or "built on stale data", never in place of the number */
.stc-hl-mark { display: none; }
.stc-root[data-lod="far"] .stc-hl-mark {
  flex: 0 1 auto; max-width: 100%; min-width: 0; overflow: hidden; display: inline-flex; align-items: center; gap: 0.25em; padding: 0.15em 0.5em;
  border-radius: 999px; margin-top: 0.2em; white-space: nowrap;
  font-size: clamp(12px, calc(10.5px / var(--stc-z, 0.4)), 44px); font-weight: 650; letter-spacing: 0; background: var(--warn-wash); color: var(--warn-ink);
}
.stc-root[data-lod="far"] .stc-hl-mark svg { width: 1em; height: 1em; flex: none; }
.stc-root[data-lod="far"] .stc-hl-mark > span { overflow: hidden; text-overflow: ellipsis; }
.stc-root[data-lod="far"] .stc-hl-mark.is-stale-in { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 40%, transparent); }

/* ------------------------------------------------------------------ groups */
.stc-group {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 18px;
  background: color-mix(in srgb, var(--g) 8%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--g) 26%, transparent);
  pointer-events: none;
}
.stc-group.is-selected, .stc-group:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.stc-group-head {
  height: 42px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 18px 18px 0 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: color-mix(in srgb, var(--g) 55%, var(--ink));
  pointer-events: auto;
  cursor: grab;
}
.stc-group-head:hover { background: color-mix(in srgb, var(--g) 7%, transparent); }
.stc-group-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stc-resize { position: absolute; right: 2px; bottom: 2px; width: 18px; height: 18px; cursor: nwse-resize; pointer-events: auto; opacity: 0.55; }
.stc-resize::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  border-radius: 0 0 3px 0;
}
.stc-resize:hover { opacity: 1; }

/* ------------------------------------------------------------------ notes */
.stc-note {
  position: absolute;
  left: 0;
  top: 0;
  padding: 12px 14px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 10%, var(--stc-node));
  box-shadow: var(--stc-node-shadow);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  cursor: grab;
  outline: none;
}
.stc-note.is-selected, .stc-note:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.stc-note-body { height: 100%; overflow: hidden; }
.stc-note-body p + p, .stc-note-body ul + p, .stc-note-body p + ul { margin-top: 6px; }
.stc-note-body h3, .stc-note-body h4 { font-size: 14px; font-weight: 650; margin: 0 0 4px; }
.stc-note-body ul { list-style: disc; padding-left: 18px; }
.stc-note-body code { font-family: var(--mono); font-size: 12px; padding: 0 4px; border-radius: 4px; background: var(--wash-2); }
.stc-note-body a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.stc-note-empty { color: var(--ink-3); }
/* far away a note is a strip with its gist, large enough to read at a fit (cards show their titles the same way) */
.stc-note-sum { display: none; }
.stc-root[data-lod="far"] .stc-note-body { visibility: hidden; }
.stc-root[data-lod="far"] .stc-note-sum:not(:empty) {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; position: absolute; inset: 12px 14px;
  font-size: clamp(20px, calc(12px / var(--stc-z, 0.4)), 56px); line-height: 1.15; font-weight: 600; letter-spacing: -0.015em; color: var(--ink);
}
.stc-note.is-editing { cursor: text; outline: 2px solid var(--accent); outline-offset: 3px; }
.stc-note-edit {
  width: 100%; height: 100%; resize: none; border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit;
  outline: none; -webkit-user-select: text; user-select: text;
}

/* ------------------------------------------------------------------ marquee, HUD, minimap */
.stc-marquee {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 4px;
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1px var(--accent);
  pointer-events: none;
}
/* the view controls: a slim bar under the canvas (outside its content area), never over a card */
.stc-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--stc-bar, 40px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 10px;
  background: var(--s1);
  box-shadow: inset 0 0.5px 0 var(--hair-2);
}
.stc-zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 2px;
}
.stc-zoom-btn, .stc-zoom-pct {
  height: 30px;
  min-width: 30px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stc-zoom-pct { min-width: 50px; }
.stc-zoom-btn:hover, .stc-zoom-pct:hover { background: var(--wash-2); color: var(--ink); }
.stc-zoom-btn:active, .stc-zoom-pct:active { transform: scale(0.94); }
.stc-zoom-btn svg { width: 16px; height: 16px; }
.stc-zoom-sep { width: 1px; height: 18px; background: var(--hair-2); margin: 0 2px; }
.stc-q { font-size: 13px; font-weight: 700; }
/* the minimap: a popover opened from the bar, above its right end */
.stc-minimap {
  position: absolute;
  right: 10px;
  bottom: calc(100% + 8px);
  width: 200px;
  height: 128px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 1px var(--hair-2), 0 8px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  touch-action: none;
}
.stc-minimap-cv { display: block; width: 200px; height: 128px; max-width: none; }
.stc-hud.is-mm-off .stc-minimap { display: none; }
.stc-mm-toggle[aria-pressed="true"] { color: var(--ink); background: var(--wash-2); }

/* a version preview's diff: added green, changed amber, removed a red ghost */
.stc-node.is-diff-added { box-shadow: 0 0 0 2px var(--ok), var(--stc-node-shadow, 0 0 0 transparent); }
.stc-node.is-diff-changed { box-shadow: 0 0 0 2px var(--warn), var(--stc-node-shadow, 0 0 0 transparent); }
.stc-node.is-diff-removed { opacity: 0.5; background: transparent; box-shadow: none; outline: 2px dashed var(--crit); outline-offset: 0; }
.stc-node.is-diff-removed .stc-head { background: var(--crit-wash); }
/* far away the ring keeps about 3px on screen and the card takes the colour too */
.stc-root[data-lod="far"] .stc-node.is-diff-added { box-shadow: 0 0 0 calc(3px / var(--stc-z, 0.4)) var(--ok); background: color-mix(in srgb, var(--ok) 32%, var(--stc-node)); }
.stc-root[data-lod="far"] .stc-node.is-diff-changed { box-shadow: 0 0 0 calc(3px / var(--stc-z, 0.4)) var(--warn); background: color-mix(in srgb, var(--warn) 30%, var(--stc-node)); }
.stc-root[data-lod="far"] .stc-node.is-diff-added .stc-head, .stc-root[data-lod="far"] .stc-node.is-diff-changed .stc-head { background: transparent; }
.stc-root[data-lod="far"] .stc-node.is-diff-removed { outline-width: calc(2px / var(--stc-z, 0.4)); }
.stc-ro-badge {
  margin-right: auto; display: inline-flex; align-items: center; gap: 6px; height: 28px;
  padding: 0 11px; border-radius: 999px; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 1px var(--hair-2); color: var(--ink-2); font-size: 12px; font-weight: 600;
}
.stc-ro-badge svg { width: 14px; height: 14px; }
@media (max-width: 640px) {
  .stc-minimap, .stc-mm-toggle, .stc-all-btn { display: none; }
}

/* ------------------------------------------------------------------ palette */
.stc-pal {
  position: absolute;
  z-index: 30;
  width: 380px;
  max-width: calc(100% - 16px);
  max-height: min(420px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--s2);
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--hair-2);
  overflow: hidden;
  animation: stc-pop var(--t-1) var(--ease);
  -webkit-user-select: none;
  user-select: none;
}
.stc-pal-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; box-shadow: inset 0 -1px 0 var(--hair); color: var(--ink-3); flex-wrap: wrap; }
.stc-pal-head > svg { width: 16px; height: 16px; flex: none; }
.stc-pal-input { flex: 1 1 140px; min-width: 0; height: 28px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; outline: none; -webkit-user-select: text; user-select: text; }
.stc-pal-input::placeholder { color: var(--ink-3); }
.stc-pal-input::-webkit-search-cancel-button { display: none; }
.stc-pal-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 24px; padding: 0 4px 0 9px; border-radius: 999px;
  background: var(--accent-wash); color: var(--accent-ink); font-size: 12px; font-weight: 550;
}
.stc-pal-chip > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stc-pal-chip-x { width: 18px; height: 18px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.stc-pal-chip-x:hover { background: var(--accent-wash); }
.stc-pal-chip-x svg { width: 11px; height: 11px; }
.stc-pal-list { flex: 1 1 auto; overflow: auto; padding: 6px; overscroll-behavior: contain; }
.stc-pal-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.stc-pal-item.is-active { background: var(--wash-2); }
.stc-pal-cat { width: 8px; height: 8px; border-radius: 50%; }
.stc-pal-text { min-width: 0; display: flex; flex-direction: column; }
.stc-pal-title { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stc-pal-sub { font-size: 11px; color: var(--ink-3); }
.stc-pal-ports { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-4); }
.stc-pal-ports svg { width: 11px; height: 11px; margin: 0 2px; }
.stc-pal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.stc-pal-none { font-size: 10.5px; color: var(--ink-3); }
.stc-pal-empty { padding: 18px 12px; color: var(--ink-3); font-size: 13px; }
.stc-pal-foot { padding: 7px 12px; font-size: 11px; color: var(--ink-3); box-shadow: inset 0 1px 0 var(--hair); }
@keyframes stc-pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ context menu */
.stc-menu {
  position: absolute;
  z-index: 30;
  min-width: 232px;
  padding: 6px;
  border-radius: 13px;
  background: var(--s2);
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--hair-2);
  animation: stc-pop var(--t-1) var(--ease);
}
.stc-menu-item {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
}
.stc-menu-item:hover, .stc-menu-item:focus-visible { background: var(--wash-2); outline: none; }
.stc-menu-item[disabled] { color: var(--ink-4); cursor: default; background: transparent; }
.stc-menu-item svg, .stc-menu-ic { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.stc-menu-item.is-danger, .stc-menu-item.is-danger svg { color: var(--crit); }
.stc-menu-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stc-menu kbd { margin-left: 12px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.stc-menu-sep { height: 1px; margin: 5px 8px; background: var(--hair-2); }
.stc-menu-swatches { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px 0 35px; font-size: 13px; }
.stc-menu-sw { display: flex; gap: 5px; }
.stc-swatch {
  width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--hair-2);
}
.stc-swatch.is-none { background: linear-gradient(135deg, transparent 45%, var(--ink-3) 45% 55%, transparent 55%), var(--wash); }
.stc-swatch.is-on, .stc-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ shortcut sheet */
.stc-keys-scrim {
  position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.stc-keys {
  width: min(920px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 22px 24px 26px;
  border-radius: 22px;
  background: var(--s1);
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--hair-2);
  -webkit-user-select: text;
  user-select: text;
  outline: none;
}
.stc-keys header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stc-keys h2 { font-size: var(--fs-h2); letter-spacing: -0.02em; }
.stc-keys h3 { font-size: var(--fs-cap); font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin: 6px 0 6px; }
:lang(zh) .stc-keys h3 { text-transform: none; letter-spacing: 0.02em; }
.stc-keys-x { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--wash); color: var(--ink-2); }
.stc-keys-x:hover { background: var(--wash-2); color: var(--ink); }
.stc-keys-x svg { width: 16px; height: 16px; }
.stc-keys-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 26px; }
.stc-keys-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; box-shadow: inset 0 -1px 0 var(--hair); font-size: 13px; }
.stc-keys-what { flex: 1 0 auto; min-width: 5.5em; max-width: 55%; color: var(--ink); }
.stc-keys-k { flex: 0 1 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; text-align: right; }
.stc-keys-how { color: var(--ink-3); font-size: 12px; }
.stc-keys kbd {
  font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--wash-2);
  box-shadow: inset 0 -1px 0 var(--hair-2); color: var(--ink); white-space: nowrap;
}
@media (max-width: 860px) { .stc-keys-cols { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ motion */
@media (prefers-reduced-motion: reduce) {
  .stc-node[data-status="running"] .stc-head::after { animation: none; background: linear-gradient(90deg, transparent, var(--stc-sheen), transparent); opacity: 0.5; }
  .stc-node[data-status="running"] .stc-status svg { animation: none; }
  .stc-wire.is-active { animation: none; stroke-dasharray: 7 4; }
  .stc-node.is-highlight::before, .stc-note.is-highlight::before, .stc-group.is-highlight::before { animation: none; opacity: 1; }
  .stc-pal, .stc-menu { animation: none; }
}
