/* Scene Graph editor (the Graph tab): toolbar, hierarchy tree, canvas, inspector, mini-map.
   Colours come from style.css tokens; the canvas reads the same tokens through getComputedStyle
   (see readTokens() in js/scenegraph.js - the token NAMES it reads are an API, do not rename them).

   THE IDEA HERE
   This is the engine's viewport. Three zones: an instrument rail across the top, two docked
   panels of readouts, and a lit well in the middle where the graph lives. The well is the only
   thing that glows; the panels around it are quiet, small-caps and technical.
   Dark: the well sinks to the darkest surface under an ambient blue wash. Light: the same well
   is a cool drafting table - a printed dot grid on cool silver - and the panels above it are
   brushed glass, so nothing in this view is ever plain white. */

.sg { position: relative; flex: 1; min-height: 0; display: grid; grid-template-rows: 46px minmax(0, 1fr); grid-template-columns: 216px minmax(0, 1fr) 268px;
      grid-template-areas: "bar bar bar" "hier canvas insp"; background: var(--surface); color: var(--text); font-size: 13px; }
.sg.no-hier { grid-template-columns: 0 minmax(0, 1fr) 268px; }
.sg.no-insp { grid-template-columns: 216px minmax(0, 1fr) 0; }
.sg.no-hier.no-insp { grid-template-columns: 0 minmax(0, 1fr) 0; }
.sg.no-hier .sg-hier, .sg.no-insp .sg-insp { display: none; }

/* ---- toolbar: the instrument rail ---- */
.sg-bar {
  grid-area: bar; position: relative; display: flex; align-items: center; gap: 6px; padding: 0 10px;
  border-bottom: 1px solid var(--border); min-width: 0; overflow: hidden;
  background: var(--sheen), color-mix(in srgb, var(--surface) 84%, var(--bg) 16%);
}
.sg-bar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--hud-line) 10%, var(--hud-line) 90%, transparent);
}
/* the mode switch: where you are in the model, said in the HUD's voice */
.sg-modes { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--input); border: 1px solid var(--border); flex: none; }
.sg-mode {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sg-mode:hover { color: var(--text-2); }
.sg-mode.is-active { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 var(--hud-line); }
.sg-mode.is-active::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: 2px; height: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 9px var(--accent);
}
/* Live is a runtime state, so it carries the cyan lamp the rest of the product uses for "running" */
.sg-mode[data-mode="live"]::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.sg-mode[data-mode="live"].is-active::before { background: var(--accent-3); box-shadow: 0 0 8px var(--accent-3); animation: pulse 1.4s infinite; }
.sg-mode[data-mode="live"].is-active::after { background: var(--accent-3); box-shadow: 0 0 9px var(--accent-3); }
.sg-search { position: relative; flex: 1 1 130px; min-width: 84px; max-width: 280px; display: flex; align-items: center; }
.sg-search svg { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; transition: color var(--dur) var(--ease); }
.sg-search input {
  width: 100%; height: 30px; padding: 0 26px 0 29px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--input); color: var(--text); font-size: 12.5px; outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sg-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sg-search input:focus ~ svg, .sg-search:focus-within svg { color: var(--accent); }
.sg-search input::placeholder { color: var(--muted); }
.sg-search .sg-clear { position: absolute; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; display: none; }
.sg-search .sg-clear:hover { background: var(--hover); color: var(--text); }
.sg-search.has-text .sg-clear { display: block; }

.sg-bar .btn {
  height: 30px; padding: 0 9px; font-size: 12.5px; border-radius: 8px; flex: none;
  background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none;
}
.sg-bar .btn:hover { background: var(--hover); border-color: var(--border); color: var(--text); }
.sg-bar .btn.is-on {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent); box-shadow: var(--glow-2);
}
.sg-bar .btn:disabled { opacity: .4; }
.sg-bar .btn svg { width: 14px; height: 14px; }
.sg-lbl { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.sg-zoom { display: flex; align-items: center; gap: 0; flex: none; margin-left: auto; }
.sg-zoom .btn { width: 30px; padding: 0; }
.sg-zoom-pct {
  min-width: 50px; text-align: center; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-2); font-variant-numeric: tabular-nums; cursor: pointer;
}
.sg-zoom-pct:hover { color: var(--accent); }
.sg-sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; flex: none; }
.sg-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px 0 11px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  color: var(--accent); font-size: 11.5px; font-weight: 600; white-space: nowrap; flex: none;
}
.sg-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; border-radius: 4px; }
.sg-chip button:hover { background: var(--tint); }
.sg-chip input[type="range"] { width: 56px; accent-color: var(--accent); }
.sg-bench { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; color: var(--warn); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sg-panel-toggles { display: none; }

/* ---- popover menus (filter, context) ---- */
.sg-pop {
  position: absolute; z-index: 20; min-width: 190px; padding: 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--sheen), var(--surface); box-shadow: var(--shadow); font-size: 12.5px;
  animation: sg-pop-in 140ms var(--ease);
}
.sg-pop h4 { margin: 5px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); }
.sg-pop label { display: flex; align-items: center; gap: 8px; height: 27px; padding: 0 8px; border-radius: 6px; cursor: pointer; color: var(--text-2); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.sg-pop label:hover { background: var(--hover); color: var(--text); }
.sg-pop input { accent-color: var(--accent); margin: 0; }
.sg-pop .sg-swatch { width: 18px; height: 0; border-top: 2px solid var(--border-strong); }
.sg-pop .sg-swatch.event { border-color: var(--warn); }
.sg-pop .sg-swatch.reference { border-style: dashed; }
.sg-pop .sg-swatch.dependency { border-style: dotted; }
.sg-pop .sg-swatch.transition { border-width: 3px; border-color: var(--accent); }
.sg-menu button { display: flex; align-items: center; gap: 8px; width: 100%; height: 29px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 12.5px; text-align: left; cursor: pointer; transition: background var(--dur) var(--ease); }
.sg-menu button:hover { background: var(--hover); }
.sg-menu button svg, .sg-list svg, .sg-chip svg { width: 14px; height: 14px; flex: none; }
.sg-menu button:disabled { color: var(--muted); cursor: default; background: transparent; }
.sg-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- hierarchy (left) ---- */
.sg-hier {
  grid-area: hier; min-width: 0; min-height: 0; overflow: auto; padding: 8px 6px 14px;
  border-right: 1px solid var(--border);
  background: var(--sheen), color-mix(in srgb, var(--surface) 95%, var(--bg) 5%);
  box-shadow: inset -1px 0 0 color-mix(in srgb, var(--hud-line) 45%, transparent);
}
.sg-side-title {
  position: relative; display: flex; align-items: center; gap: 8px; height: 30px; margin-bottom: 4px;
  padding: 0 6px 0 12px; color: var(--text-2);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.sg-side-title::before {
  content: ""; position: absolute; left: 2px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 9px -1px var(--accent);
}
.sg-side-title .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.sg-tree { list-style: none; margin: 0; padding: 0; }
.sg-tree ul { list-style: none; margin: 0 0 0 11px; padding-left: 14px; border-left: 1px solid var(--border); }
.sg-tree li { margin: 0; }
.sg-row {
  position: relative; display: flex; align-items: center; gap: 6px; height: 27px; padding: 0 6px 0 4px;
  border-radius: 7px; cursor: pointer; color: var(--text-2); white-space: nowrap; overflow: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sg-row:hover { background: var(--hover); color: var(--text); }
/* the selected node is lit, not merely tinted */
.sg-row.is-selected {
  background: linear-gradient(90deg, var(--tint), color-mix(in srgb, var(--accent) 4%, transparent));
  color: var(--accent); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent), 0 0 16px -8px var(--accent);
}
.sg-row.is-dim { opacity: .35; }
.sg-row .sg-tw { width: 14px; height: 14px; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 9px; }
.sg-row .sg-tw::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-bottom: 2px; transition: transform .15s var(--ease); }
.sg-row.is-closed .sg-tw::before { transform: rotate(-45deg); margin: 0 0 0 2px; }
.sg-row .sg-tw.is-leaf::before { display: none; }
.sg-row svg { width: 14px; height: 14px; flex: none; }
.sg-row .sg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.sg-row.is-selected .sg-name { font-weight: 600; }
.sg-row .sg-sub { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.sg-row.is-selected .sg-sub { color: inherit; opacity: .75; }
li.is-closed > ul { display: none; }
.sg-empty { padding: 18px 10px; color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; }

/* ---- canvas (centre): the lit well ---- */
.sg-stage {
  grid-area: canvas; position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background:
    radial-gradient(128% 92% at 50% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 64%),
    radial-gradient(var(--border) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 120px 120px,
    var(--bg);
}
/* the well is deeper at its edges - depth, and it keeps the eye on the graph */
.sg-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 130px -46px color-mix(in srgb, var(--stage) 74%, transparent),
              inset 0 1px 0 color-mix(in srgb, var(--hud-line) 60%, transparent);
}
.sg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
.sg-canvas.is-panning { cursor: grabbing; }
.sg-canvas.is-over { cursor: pointer; }
.sg-canvas.is-dragging { cursor: move; }
.sg-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* the status pill: what the well is currently showing */
.sg-note {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 14px;
  max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  font-size: 11.5px; box-shadow: var(--shadow); pointer-events: none;
}
.sg-note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.sg-note.is-live { color: var(--text); border-color: color-mix(in srgb, var(--good) 45%, transparent);
                   box-shadow: var(--shadow), 0 0 24px -8px var(--good); }
.sg-note.is-live::before { background: var(--good); box-shadow: 0 0 9px var(--good); animation: pulse 1s infinite; }
.sg-note strong { color: var(--text); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }

/* the mini-map: a framed instrument, bracketed like the stage */
.sg-minimap {
  position: absolute; right: 12px; bottom: 12px; z-index: 3; width: 144px; height: 92px;
  border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; cursor: crosshair;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  box-shadow: var(--shadow), inset 0 1px 0 var(--hud-line);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sg-minimap:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--shadow), var(--glow-2); }
.sg-minimap::after {
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  --bracket: color-mix(in srgb, var(--accent) 34%, transparent);
  background:
    linear-gradient(var(--bracket), var(--bracket)) left top / 9px 1px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) left top / 1px 9px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) right bottom / 9px 1px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) right bottom / 1px 9px no-repeat;
}
.sg-minimap canvas { width: 100%; height: 100%; display: block; }
.sg-empty-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); pointer-events: none; }
.sg-empty-stage p { max-width: 330px; line-height: 1.55; font-size: 12.5px; }
.sg-rename { position: absolute; z-index: 5; height: 27px; padding: 0 9px; border: 1px solid var(--accent); border-radius: 7px; background: var(--surface); color: var(--text); font: 600 12.5px "Inter", sans-serif; outline: none; box-shadow: 0 0 0 3px var(--accent-soft), var(--glow-2); }

/* ---- inspector (right): the readouts ---- */
.sg-insp {
  grid-area: insp; min-width: 0; min-height: 0; overflow: auto; padding: 8px 12px 18px;
  border-left: 1px solid var(--border);
  background: var(--sheen), color-mix(in srgb, var(--surface) 95%, var(--bg) 5%);
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--hud-line) 45%, transparent);
}
.sg-insp-head {
  display: flex; align-items: center; gap: 11px; margin: 2px 0 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sg-insp-icon {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 9px;
  background: color-mix(in srgb, var(--raised) 86%, var(--bg) 14%); color: var(--accent);
  border: 1px solid var(--border); box-shadow: inset 0 0 14px -6px currentColor;
}
.sg-insp-icon svg { width: 18px; height: 18px; }
.sg-insp-icon.enemy { color: var(--bad); } .sg-insp-icon.pickup { color: var(--warn); } .sg-insp-icon.scene { color: var(--good); }
.sg-insp-icon.asset { color: var(--warn); } .sg-insp-icon.scenery, .sg-insp-icon.other, .sg-insp-icon.camera { color: var(--text-2); }
.sg-insp-title { min-width: 0; line-height: 1.3; }
.sg-insp-title strong { display: block; font: 600 15.5px "Space Grotesk", "Inter", sans-serif; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-insp-title span { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sg-insp p.sg-summary { color: var(--text-2); font-size: 12.5px; line-height: 1.5; margin-bottom: 10px; }
.sg-sec { border-top: 1px solid var(--border); padding: 10px 0; }
.sg-sec:first-of-type { border-top: 0; }
.sg-sec > h4 {
  display: flex; align-items: center; gap: 7px; margin: 0 0 7px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.sg-sec > h4::before { content: ""; width: 7px; height: 1px; flex: none; background: var(--accent); }
.sg-sec > h4 .count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* a key/value block reads like telemetry: quiet labels, values that line up */
.sg-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 12.5px; }
.sg-kv dt { color: var(--muted); white-space: nowrap; font-size: 11.5px; }
.sg-kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sg-kv code, .sg-list code { font: 11.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text-2); }
.sg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.sg-list li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sg-list li > span:first-child { flex: none; display: inline-flex; color: var(--muted); }
.sg-list .sg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-list .sg-dim { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-list button.sg-link { border: 0; background: transparent; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; border-radius: 4px; }
.sg-list button.sg-link:hover { text-decoration: underline; }
.sg-list button.sg-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* a component is a module bolted to the object: a slab with a lit edge */
.sg-comp {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 0 9px; align-items: start;
  padding: 6px 8px 6px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--raised) 84%, var(--bg) 16%);
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sg-comp:hover { border-color: var(--border-strong); background: var(--hover); }
.sg-comp svg { width: 14px; height: 14px; margin-top: 2px; color: var(--accent); }
.sg-comp b { font-weight: 600; font-size: 12.5px; }
.sg-comp small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }
.sg-comps { display: flex; flex-direction: column; gap: 5px; }
.sg-swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sg-swatch-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); }
.sg-swatch-item i { width: 15px; height: 15px; border-radius: 4px; border: 1px solid var(--border-strong); display: inline-block; box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent-ink) 25%, transparent); }
.sg-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.sg-tag {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--raised) 86%, var(--bg) 14%); border: 1px solid var(--border);
  color: var(--text-2); font-size: 11.5px;
}
.sg-tag code { color: inherit; }
.sg-tag.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: color-mix(in srgb, var(--warn) 34%, transparent); color: var(--warn); }
.sg-tag.good { background: color-mix(in srgb, var(--good) 14%, transparent); border-color: color-mix(in srgb, var(--good) 34%, transparent); color: var(--good); }
.sg-tag.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 34%, transparent); color: var(--accent); }
.sg-ask { display: flex; flex-direction: column; gap: 6px; }
.sg-ask .btn { justify-content: flex-start; height: 32px; font-size: 12.5px; gap: 8px; text-align: left; }
.sg-ask .btn svg { width: 14px; height: 14px; color: var(--accent); }

/* the live readout: the one place a number changes while you watch it */
.sg-live-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px;
  padding: 6px 9px; border-radius: 7px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--raised) 84%, var(--bg) 16%);
}
.sg-live-row + .sg-live-row { margin-top: 4px; }
.sg-live-row span { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sg-live-row b { font: 600 13px "Space Grotesk", "Inter", sans-serif; font-variant-numeric: tabular-nums; color: var(--text); }
.sg-insp-empty { color: var(--muted); font-size: 12.5px; line-height: 1.6; padding: 8px 0; }
.sg-insp-empty kbd { display: inline-block; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--raised); color: var(--text-2); font: 10.5px ui-monospace, monospace; }
/* ---- motion of this file ---- */
@keyframes sg-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---- small screens: canvas + toolbar; the side panels become overlays ---- */
@media (max-width: 1640px) { .sg-lbl { display: none; } .sg-bar .btn { padding: 0 8px; } }
@media (max-width: 1240px) {
  .sg { grid-template-columns: 204px minmax(0, 1fr) 246px; }
  .sg.no-hier { grid-template-columns: 0 minmax(0, 1fr) 246px; }
  .sg.no-insp { grid-template-columns: 204px minmax(0, 1fr) 0; }
}
@media (max-width: 960px) {
  .sg { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "bar" "canvas"; }
  .sg-bar { flex-wrap: wrap; height: auto; padding: 6px 8px; row-gap: 4px; }
  .sg-search { max-width: none; flex-basis: 100%; order: 5; }
  .sg-hide-hier, .sg-hide-insp, .sg-bar .sg-sep:last-of-type { display: none; }
  .sg-zoom { margin-left: 0; }
  .sg-note { font-size: 11px; }
  .sg-hier, .sg-insp { display: none; position: absolute; top: 46px; bottom: 0; width: min(300px, 84%); z-index: 6; box-shadow: var(--shadow); }
  .sg-hier { left: 0; } .sg-insp { right: 0; }
  .sg.show-hier .sg-hier, .sg.show-insp .sg-insp { display: block; }
  .sg-panel-toggles { display: flex; gap: 2px; }
  .sg-minimap { width: 112px; height: 74px; }
  .sg-zoom-pct { display: none; }
}

/* where the game runs */
.sg-targets { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; align-items: center; pointer-events: none; z-index: 2; }
.sg-targets[hidden] { display: none; }
.sg-target { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); }
.sg-target.android { border-color: color-mix(in srgb, var(--good) 50%, transparent); color: var(--good); }
.sg-target-fact { font-size: 11px; color: var(--muted); }
