/* Node Studio — the node graph window (src/mapgraph/node-panel.js).
   Tactical Glass: dark blue glass, cool hairlines, corner ticks, glow only on
   what is active. The three families are told apart by a thin hue on the
   node's head and its wires: sources azure, operations violet, outputs teal. */

.mg {
  --mg-src: #6eb0ff;
  --mg-op: #a78bfa;
  --mg-ctl: #f0c75e;
  --mg-out: #5eead4;
  --mg-rail-w: 286px;
  --mg-bad: #ff6b5e;
  --mg-node-bg: linear-gradient(180deg, rgba(23, 34, 53, 0.97), rgba(14, 21, 34, 0.97));
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.mg-win {
  position: absolute;
  inset: 60px 14px 74px 14px;
  display: none;
  flex-direction: column;
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(13, 20, 32, 0.9), rgba(8, 13, 22, 0.92));
  border: 1px solid var(--edge, rgba(120, 184, 255, 0.34));
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(160, 205, 255, 0.08);
  backdrop-filter: blur(14px) saturate(1.15);
  overflow: hidden;
  will-change: transform, opacity;
}
.mg.is-open .mg-win { display: flex; }
.mg.is-folded .mg-win { visibility: hidden; pointer-events: none; }

/* corner ticks */
.mg-win::before,
.mg-win::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 3;
}
.mg-win::before { top: 5px; left: 5px; border-top: 1px solid var(--blue-400, #6eb0ff); border-left: 1px solid var(--blue-400, #6eb0ff); }
.mg-win::after { bottom: 5px; right: 5px; border-bottom: 1px solid var(--blue-400, #6eb0ff); border-right: 1px solid var(--blue-400, #6eb0ff); }

/* ---- head ----------------------------------------------------------------- */

.mg-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px 9px 16px;
  border-bottom: 1px solid var(--edge-soft, rgba(120, 184, 255, 0.18));
  background: linear-gradient(180deg, rgba(25, 39, 62, 0.75), rgba(14, 22, 36, 0.4));
}
.mg-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mg-brand-mark { width: 26px; height: 26px; color: var(--blue-400, #6eb0ff); filter: drop-shadow(0 0 8px rgba(61, 139, 255, 0.55)); }
.mg-brand-mark svg { width: 100%; height: 100%; }
.mg-brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.mg-brand-copy b { color: #eaf4ff; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.mg-brand-copy small { color: var(--muted, #8fa0b4); font-size: 10.5px; letter-spacing: 0.04em; }
.mg-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.mg-sep { width: 1px; height: 20px; background: var(--edge-soft, rgba(120, 184, 255, 0.18)); margin: 0 4px; }

/* ---- buttons ---------------------------------------------------------------- */

.mg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  color: #d6e6f8;
  background: rgba(70, 120, 180, 0.12);
  border: 1px solid rgba(120, 184, 255, 0.26);
  border-radius: 6px;
  font: 600 11.5px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.1s;
}
.mg-btn svg { width: 15px; height: 15px; flex: none; }
.mg-btn:hover { background: rgba(70, 130, 200, 0.24); border-color: rgba(140, 196, 255, 0.55); color: #fff; }
.mg-btn:active { transform: translateY(1px); }
.mg-btn:disabled { opacity: 0.45; cursor: default; }
.mg-btn--primary {
  color: #eaf4ff;
  background: linear-gradient(180deg, rgba(61, 139, 255, 0.55), rgba(42, 104, 210, 0.42));
  border-color: rgba(140, 196, 255, 0.7);
  box-shadow: 0 0 14px rgba(61, 139, 255, 0.32);
}
.mg-btn--primary:hover { background: linear-gradient(180deg, rgba(80, 155, 255, 0.7), rgba(52, 118, 225, 0.55)); box-shadow: 0 0 18px rgba(61, 139, 255, 0.5); }
.mg-btn--ghost { background: transparent; border-color: rgba(120, 184, 255, 0.18); color: #b9cde4; }
.mg-btn--icon { width: 28px; padding: 0; justify-content: center; font-size: 15px; }
.mg-btn--close:hover { border-color: rgba(255, 120, 110, 0.6); background: rgba(255, 90, 80, 0.16); }
.mg-btn--sm { height: 24px; padding: 0 9px; font-size: 11px; }
.mg-btn--tiny { width: 22px; height: 22px; font-size: 13px; }
.mg-btn--lib[aria-pressed="true"] { border-color: rgba(140, 196, 255, 0.6); background: rgba(61, 139, 255, 0.22); box-shadow: inset 0 0 10px rgba(61, 139, 255, 0.25); }

/* ---- body: canvas + library ---------------------------------------------------- */

.mg-body { position: relative; flex: 1; display: flex; min-height: 0; }

.mg-canvas {
  position: relative;
  flex: 1;
  overflow: hidden;
  outline: none;
  cursor: default;
  background-color: rgba(6, 10, 18, 0.55);
  background-image:
    radial-gradient(circle, rgba(120, 184, 255, 0.16) 1px, transparent 1.4px),
    linear-gradient(rgba(120, 184, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 184, 255, 0.045) 1px, transparent 1px);
  background-size: 26px 26px, 104px 104px, 104px 104px;
}
.mg-canvas.is-panning { cursor: grabbing; }
.mg-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mg-wires {
  position: absolute;
  left: -20000px;
  top: -20000px;
  width: 40000px;
  height: 40000px;
  overflow: visible;
  pointer-events: none;
}
.mg-nodes { position: absolute; left: 0; top: 0; }

/* ---- wires ---------------------------------------------------------------------- */

.mg-link { --wc: var(--mg-src); }
.mg-link--op { --wc: var(--mg-op); }
.mg-link--out { --wc: var(--mg-out); }
.mg-link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.mg-link-line { fill: none; stroke: var(--wc); stroke-width: 2; stroke-opacity: 0.38; transition: stroke-opacity 0.2s; }
.mg-link-flow { fill: none; stroke: var(--wc); stroke-width: 2.2; stroke-dasharray: 3 13; stroke-linecap: round; opacity: 0; }
.mg-link.is-live .mg-link-line { stroke-opacity: 0.62; }
.mg-link.is-live .mg-link-flow { opacity: 0.95; animation: mg-flow 1.1s linear infinite; filter: drop-shadow(0 0 3px var(--wc)); }
.mg-link.is-busy .mg-link-flow { opacity: 0.8; animation: mg-flow 0.45s linear infinite; }
.mg-link.is-bad .mg-link-line { stroke: var(--mg-bad); stroke-dasharray: 5 5; stroke-opacity: 0.6; }
.mg-link:hover .mg-link-line,
.mg-link.is-selected .mg-link-line { stroke-opacity: 1; stroke-width: 3; }
.mg-link.is-selected .mg-link-line { filter: drop-shadow(0 0 5px var(--wc)); }
@keyframes mg-flow { to { stroke-dashoffset: -16; } }
.mg-drag-wire { fill: none; stroke: #eaf4ff; stroke-width: 2; stroke-dasharray: 6 5; opacity: 0.85; filter: drop-shadow(0 0 4px rgba(110, 176, 255, 0.9)); }

/* ---- nodes ------------------------------------------------------------------------ */

.mg-node {
  --nc: var(--mg-src);
  position: absolute;
  width: 232px;
  color: #dbe8f6;
  background: var(--mg-node-bg);
  border: 1px solid rgba(120, 184, 255, 0.22);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  font-size: 11.5px;
  user-select: none;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.mg-node--op { --nc: var(--mg-op); }
.mg-node--out { --nc: var(--mg-out); }
.mg-node::before {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: -1px;
  height: 2px;
  border-radius: 8px 8px 0 0;
  background: var(--nc);
  opacity: 0.85;
  box-shadow: 0 0 10px var(--nc);
}
.mg-node:hover { border-color: rgba(140, 196, 255, 0.4); }
.mg-node.is-selected {
  border-color: color-mix(in srgb, var(--nc) 70%, white 10%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--nc) 45%, transparent), 0 0 22px color-mix(in srgb, var(--nc) 35%, transparent), 0 14px 30px rgba(0, 0, 0, 0.5);
}
.mg-node.is-dragging { box-shadow: 0 24px 46px rgba(0, 0, 0, 0.6), 0 0 18px color-mix(in srgb, var(--nc) 30%, transparent); z-index: 2; }
.mg-node.is-error { border-color: rgba(255, 107, 94, 0.55); }
.mg-node.is-waiting { opacity: 0.86; }
.mg-node.is-pulse { animation: mg-pulse 0.9s ease-out; }
@keyframes mg-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--nc) 70%, transparent), 0 10px 26px rgba(0, 0, 0, 0.42); }
  100% { box-shadow: 0 0 0 16px transparent, 0 10px 26px rgba(0, 0, 0, 0.42); }
}

.mg-node-head {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 6px 0 9px;
  border-bottom: 1px solid rgba(120, 184, 255, 0.12);
  cursor: grab;
}
.mg-node.is-dragging .mg-node-head { cursor: grabbing; }
.mg-node-icon { width: 17px; height: 17px; color: var(--nc); flex: none; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--nc) 60%, transparent)); }
.mg-node-icon svg { width: 100%; height: 100%; }
.mg-node-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f0f6ff;
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.01em;
}
.mg-node-sym {
  flex: none;
  padding: 1px 5px;
  color: var(--nc);
  border: 1px solid color-mix(in srgb, var(--nc) 40%, transparent);
  border-radius: 4px;
  font: 700 10px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.mg-title-input {
  flex: 1;
  min-width: 0;
  height: 22px;
  padding: 0 6px;
  color: #fff;
  background: rgba(5, 10, 18, 0.8);
  border: 1px solid rgba(140, 196, 255, 0.6);
  border-radius: 4px;
  font: 600 12px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-node-state {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(143, 160, 180, 0.4);
}
.mg-node-state[data-state="ok"] { background: var(--nc); box-shadow: 0 0 7px var(--nc); }
.mg-node-state[data-state="busy"] { background: transparent; border: 1.5px solid var(--nc); border-top-color: transparent; animation: mg-spin 0.7s linear infinite; }
.mg-node-state[data-state="waiting"] { background: transparent; border: 1.5px solid rgba(143, 160, 180, 0.6); }
.mg-node-state[data-state="error"],
.mg-node-state[data-state="blocked"] { background: var(--mg-bad); box-shadow: 0 0 7px var(--mg-bad); }
@keyframes mg-spin { to { transform: rotate(360deg); } }
.mg-node-x {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.mg-node:hover .mg-node-x,
.mg-node.is-selected .mg-node-x,
.mg-node-x.is-armed { opacity: 1; }
.mg-node-x:hover { color: #fff; background: rgba(255, 90, 80, 0.25); }
.mg-node-x.is-armed { color: #fff; background: rgba(255, 90, 80, 0.55); border-color: rgba(255, 140, 130, 0.8); }

/* ports */
.mg-node-io { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0 4px; }
.mg-ins, .mg-outs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mg-outs { align-items: flex-end; }
.mg-port {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 18px;
  color: #a9bdd4;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  cursor: crosshair;
}
.mg-port span { white-space: nowrap; }
.mg-port em { font-style: normal; color: var(--muted, #8fa0b4); margin-left: 3px; }
.mg-port i {
  position: relative;
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: #0b1220;
  border: 2px solid rgba(143, 170, 200, 0.55);
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.mg-port--in i { margin-left: -7px; }
.mg-port--out i { margin-right: -7px; }
.mg-port:hover i,
.mg-port.is-target i { transform: scale(1.35); border-color: #fff; box-shadow: 0 0 10px rgba(140, 196, 255, 0.95); }
.mg-port.is-wired i { border-color: var(--nc); background: color-mix(in srgb, var(--nc) 30%, #0b1220); }
.mg-port--out.has-data i { background: var(--nc); border-color: color-mix(in srgb, var(--nc) 70%, white 30%); box-shadow: 0 0 8px var(--nc); }
.mg-port--in.is-wired i { border-color: #cfe3ff; }

/* body */
.mg-node-body { display: flex; flex-direction: column; gap: 7px; padding: 4px 10px 8px; }
.mg-node-body[hidden] { display: none; }
.mg-meta { color: #a9bdd4; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.mg-meta b { color: #eaf4ff; }
.mg-note { color: var(--muted, #8fa0b4); font-size: 10.5px; font-style: italic; }
.mg-f { display: flex; align-items: center; gap: 7px; min-width: 0; }
.mg-f-label { flex: none; width: 52px; color: #8fa0b4; font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; }
.mg-f-label[data-scrub] { cursor: ew-resize; border-bottom: 1px dashed rgba(143, 160, 180, 0.35); }
.mg-f-label[data-scrub]:hover { color: #cfe3ff; }
.mg-f input[type="number"],
.mg-f input[type="text"],
.mg-f select {
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 0 7px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.7);
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 5px;
  font: 12px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-f input:focus,
.mg-f select:focus { border-color: rgba(140, 196, 255, 0.7); box-shadow: 0 0 0 2px rgba(61, 139, 255, 0.18); }
.mg-f input[type="number"] { width: 70px; flex: 0 1 auto; font-variant-numeric: tabular-nums; }
.mg-f em { color: #8fa0b4; font-style: normal; font-size: 11px; }
.mg-f select option { background: #0d1420; }
.mg-swatches { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.mg-sw {
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 4px;
  background: var(--sw);
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.mg-sw:hover { transform: scale(1.15); }
.mg-sw.is-on { box-shadow: 0 0 0 2px #0b1220, 0 0 0 3.5px #eaf4ff; }
.mg-sw--none { width: auto; padding: 0 5px; color: #a9bdd4; background: rgba(255, 255, 255, 0.06); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.mg-eye {
  margin-left: auto;
  width: 22px;
  height: 18px;
  padding: 0;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.mg-eye.is-on { color: var(--nc); border-color: color-mix(in srgb, var(--nc) 45%, transparent); }
.mg-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.mg-chip {
  height: 22px;
  padding: 0 8px;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 11px;
  font: 600 10.5px "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mg-chip.is-on { color: #eaf4ff; background: color-mix(in srgb, var(--nc) 22%, transparent); border-color: color-mix(in srgb, var(--nc) 55%, transparent); }
.mg-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.mg-taglist { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 7px;
  color: #cfe0f3;
  background: rgba(120, 184, 255, 0.08);
  border-radius: 10px;
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, transparent); flex: none; }
.mg-sinkbar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.mg-btn--glyph { width: 24px; padding: 0; justify-content: center; font-size: 13px; }
.mg-grow { flex: 1; }
.mg-switch { display: inline-flex; align-items: center; gap: 6px; color: #a9bdd4; font-size: 11px; cursor: pointer; }
.mg-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mg-switch i {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 7px;
  background: rgba(143, 160, 180, 0.25);
  border: 1px solid rgba(143, 160, 180, 0.35);
  transition: background 0.15s, border-color 0.15s;
}
.mg-switch i::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfd9e5;
  transition: transform 0.18s cubic-bezier(.2, .9, .3, 1.2);
}
.mg-switch input:checked + i { background: color-mix(in srgb, var(--nc) 45%, transparent); border-color: var(--nc); box-shadow: 0 0 8px color-mix(in srgb, var(--nc) 50%, transparent); }
.mg-switch input:checked + i::after { transform: translateX(12px); background: #fff; }
.mg-switch input:checked ~ span { color: #eaf4ff; }
.mg-share { display: flex; align-items: center; gap: 6px; color: #a9bdd4; font-size: 11px; }
.mg-codechip {
  padding: 2px 7px;
  color: #eaf4ff;
  background: rgba(94, 234, 212, 0.12);
  border: 1px solid rgba(94, 234, 212, 0.45);
  border-radius: 4px;
  font: 700 12px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.12em;
  user-select: all;
}

.mg-node-out {
  margin: 0 10px 6px;
  padding: 5px 8px;
  color: #a9bdd4;
  background: rgba(120, 184, 255, 0.06);
  border-left: 2px solid rgba(143, 160, 180, 0.4);
  border-radius: 0 4px 4px 0;
  font-size: 10.5px;
  line-height: 1.35;
}
.mg-node-out[data-tone="ok"] { color: #d8f7f1; border-left-color: var(--mg-out); background: rgba(94, 234, 212, 0.08); }
.mg-node-out[data-tone="busy"] { color: #cfe3ff; border-left-color: var(--blue-400, #6eb0ff); }
.mg-node-out[data-tone="bad"] { color: #ffd2cd; border-left-color: var(--mg-bad); background: rgba(255, 107, 94, 0.08); }

.mg-node-thumb { position: relative; padding: 0 10px; }
/* The picture's place is kept while there is nothing to draw yet, so a node
   does not grow into its neighbour the moment its data arrives. */
.mg-node-thumb:empty::before {
  content: "";
  display: block;
  height: 118px;
  border: 1px dashed rgba(120, 184, 255, 0.12);
  border-radius: 5px;
  background: rgba(3, 7, 13, 0.3);
}
.mg-node-thumb svg {
  display: block;
  width: 100%;
  height: 118px;
  cursor: zoom-in;
  background: radial-gradient(ellipse at center, rgba(61, 139, 255, 0.08), transparent 70%), rgba(3, 7, 13, 0.55);
  border: 1px solid rgba(120, 184, 255, 0.1);
  border-radius: 5px;
}
.mg-node-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 6px 10px 8px;
  color: #cfe0f3;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.mg-node-foot { min-height: 28px; }
.mg-dim { color: #75879c; }
.mg-foot-msg { color: #a9bdd4; font-style: italic; }
.mg-foot-msg--error,
.mg-foot-msg--blocked { color: #ffb4ab; font-style: normal; }
.mg-foot-msg--waiting { color: #8fa0b4; }

/* far zoom: hide the small print */
.mg-canvas.is-far .mg-node-body,
.mg-canvas.is-far .mg-node-foot,
.mg-canvas.is-far .mg-port span { visibility: hidden; }

/* ---- empty state + drop veil -------------------------------------------------------- */

.mg-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.mg-empty[hidden] { display: none; }
.mg-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  padding: 30px 34px;
  text-align: center;
  color: #a9bdd4;
  font-size: 12.5px;
  line-height: 1.5;
  border: 1px dashed rgba(120, 184, 255, 0.35);
  border-radius: 14px;
  background: radial-gradient(ellipse at center, rgba(61, 139, 255, 0.1), rgba(8, 13, 22, 0.4));
  pointer-events: auto;
}
.mg-empty-card b { color: #eaf4ff; font-size: 15px; letter-spacing: 0.02em; }
.mg-empty-mark { width: 46px; height: 46px; color: var(--blue-400, #6eb0ff); filter: drop-shadow(0 0 14px rgba(61, 139, 255, 0.6)); animation: mg-breathe 3.2s ease-in-out infinite; }
.mg-empty-mark svg { width: 100%; height: 100%; }
.mg-empty-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
@keyframes mg-breathe { 50% { transform: scale(1.06); filter: drop-shadow(0 0 22px rgba(61, 139, 255, 0.85)); } }

.mg-dropveil {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(140, 196, 255, 0.7);
  border-radius: 12px;
  background: rgba(61, 139, 255, 0.1);
  color: #eaf4ff;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.mg-canvas.is-dropping .mg-dropveil { opacity: 1; }

/* ---- palette: three columns, centred over the canvas ------------------------------- */

.mg-palette {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(ellipse at center, rgba(6, 10, 18, 0.55), rgba(6, 10, 18, 0.78));
  backdrop-filter: blur(2px);
  animation: mg-fade 0.16s ease-out;
}
.mg-palette[hidden] { display: none; }
@keyframes mg-fade { from { opacity: 0; } }
.mg-pal-card {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  max-height: 100%;
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.98), rgba(10, 16, 27, 0.98));
  border: 1px solid rgba(140, 196, 255, 0.45);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 30px rgba(61, 139, 255, 0.18);
  overflow: hidden;
  animation: mg-pop 0.2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes mg-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.mg-pal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(120, 184, 255, 0.14);
}
.mg-pal-head b { color: #eaf4ff; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.mg-pal-search {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.85);
  border: 1px solid rgba(120, 184, 255, 0.3);
  border-radius: 7px;
  font: 13px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-pal-search:focus { border-color: rgba(140, 196, 255, 0.75); box-shadow: 0 0 0 3px rgba(61, 139, 255, 0.15); }
.mg-pal-keys { color: #64768b; font: 600 10.5px ui-monospace, Consolas, monospace; white-space: nowrap; }
.mg-pal-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 0;
  overflow: hidden;
}
.mg-pal-col {
  --nc: var(--mg-src);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(120, 184, 255, 0.1);
  transition: opacity 0.15s;
}
.mg-pal-col:last-child { border-right: 0; }
.mg-pal-col--op { --nc: var(--mg-op); }
.mg-pal-col--out { --nc: var(--mg-out); }
.mg-pal-col.is-off { opacity: 0.38; }
.mg-pal-col header {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 12px 14px 8px;
  border-top: 2px solid var(--nc);
  background: linear-gradient(180deg, color-mix(in srgb, var(--nc) 10%, transparent), transparent);
}
.mg-pal-col header b { color: var(--nc); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.mg-pal-col header span { color: #75879c; font-size: 10.5px; }
.mg-pal-list { overflow-y: auto; padding: 2px 8px 12px; }
.mg-pal-group { padding: 10px 6px 4px; color: #64768b; font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.mg-pal-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 5px 8px;
  color: #dbe8f6;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}
.mg-pal-item:hover,
.mg-pal-item.is-active { background: color-mix(in srgb, var(--nc) 14%, transparent); border-color: color-mix(in srgb, var(--nc) 38%, transparent); }
.mg-pal-item.is-active { box-shadow: inset 2px 0 0 var(--nc); }
.mg-pal-item.is-off { opacity: 0.35; cursor: not-allowed; }
.mg-pal-item.is-off:hover { background: transparent; border-color: transparent; }
.mg-pal-icon { width: 20px; height: 20px; flex: none; color: var(--nc); margin-top: 1px; }
.mg-pal-icon svg { width: 100%; height: 100%; }
.mg-pal-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mg-pal-text b { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; }
.mg-pal-text b em { color: var(--nc); font: 700 10.5px ui-monospace, Consolas, monospace; font-style: normal; }
.mg-pal-text small {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #8fa0b4;
  font-size: 10.5px;
  line-height: 1.35;
}
.mg-pal-none { padding: 14px; color: #64768b; font-size: 11px; text-align: center; }
/* Everything fits without scrolling: one line of description, two when tall. */
@media (min-height: 1000px) {
  .mg-pal-item { padding: 7px 8px; }
  .mg-pal-text small { -webkit-line-clamp: 2; }
}
.mg-pal-group { padding-top: 8px; }

/* "LIVE" — this node follows what the app has loaded */
.mg-tagchip {
  flex: none;
  padding: 1px 5px;
  color: #04201b;
  background: var(--mg-out);
  border-radius: 3px;
  font: 800 8.5px/1.5 "Segoe UI", system-ui, sans-serif;
  font-style: normal;
  letter-spacing: 0.1em;
  box-shadow: 0 0 6px rgba(94, 234, 212, 0.5);
}

/* ---- toast + zoom ---------------------------------------------------------------------------- */

.mg-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 7;
  max-width: min(560px, 80%);
  padding: 8px 14px;
  color: #eaf4ff;
  background: rgba(12, 19, 31, 0.96);
  border: 1px solid rgba(140, 196, 255, 0.4);
  border-radius: 7px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.mg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.mg-toast { display: flex; align-items: center; gap: 12px; }
.mg-toast.has-action.is-on { pointer-events: auto; }
.mg-toast[data-tone="ok"] { border-color: rgba(94, 234, 212, 0.55); }
.mg-toast[data-tone="warn"] { border-color: rgba(224, 145, 63, 0.7); color: #ffe3c7; }
.mg-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 7px;
  color: #75879c;
  font: 600 10.5px ui-monospace, Consolas, monospace;
  pointer-events: none;
}

/* ---- library --------------------------------------------------------------------------------- */

.mg-lib {
  display: none;
  flex-direction: column;
  width: 288px;
  min-height: 0;
  border-left: 1px solid var(--edge-soft, rgba(120, 184, 255, 0.18));
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.92), rgba(10, 16, 27, 0.92));
}
.mg-lib.is-open { display: flex; animation: mg-slide 0.22s cubic-bezier(.2, .9, .3, 1); }
@keyframes mg-slide { from { opacity: 0; transform: translateX(14px); } }
.mg-lib-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.mg-lib-head b { color: #eaf4ff; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.mg-srv {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  color: #8fa0b4;
  font-size: 10.5px;
  white-space: nowrap;
}
.mg-srv::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: rgba(143, 160, 180, 0.5); }
.mg-srv[data-state="online"] { color: #cdeee7; }
.mg-srv[data-state="online"]::before { background: var(--ok, #6fcf86); box-shadow: 0 0 6px var(--ok, #6fcf86); }
.mg-srv[data-state="syncing"]::before,
.mg-srv[data-state="idle"]::before { background: var(--blue-400, #6eb0ff); animation: mg-blink 0.9s ease-in-out infinite; }
.mg-srv[data-state="offline"]::before { background: var(--warn, #e0913f); }
.mg-srv[data-state="local"]::before { background: transparent; border: 1px solid #8fa0b4; }
@keyframes mg-blink { 50% { opacity: 0.25; } }
.mg-lib-tabs { display: flex; gap: 4px; padding: 0 12px 8px; }
.mg-lib-tabs button {
  flex: 1;
  height: 26px;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid rgba(120, 184, 255, 0.16);
  border-radius: 5px;
  font: 650 11px "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mg-lib-tabs button.is-on { color: #eaf4ff; background: rgba(61, 139, 255, 0.2); border-color: rgba(140, 196, 255, 0.5); }
.mg-lib-pane { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; padding: 0 12px; }
.mg-lib-pane[hidden] { display: none; }
.mg-me { display: flex; align-items: center; gap: 6px; color: #8fa0b4; font-size: 11px; }
.mg-me-name { color: #eaf4ff; cursor: text; border-bottom: 1px dashed rgba(143, 160, 180, 0.4); }
.mg-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--dot, #6eb0ff); box-shadow: 0 0 6px var(--dot, #6eb0ff); }
.mg-lib-search {
  height: 28px;
  padding: 0 9px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.7);
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 6px;
  font: 12px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-lib-search:focus { border-color: rgba(140, 196, 255, 0.7); }
.mg-lib-list { flex: 1; min-height: 60px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.mg-lib-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: grab;
}
.mg-lib-row:hover { background: rgba(61, 139, 255, 0.1); border-color: rgba(120, 184, 255, 0.2); }
.mg-lib-row--all { margin-bottom: 4px; background: rgba(61, 139, 255, 0.07); border-color: rgba(120, 184, 255, 0.16); }
.mg-lib-icon { width: 16px; height: 16px; color: var(--mg-src); flex: none; }
.mg-lib-icon svg { width: 100%; height: 100%; }
.mg-lib-name { flex: 1; min-width: 0; display: flex; flex-direction: column; color: #dbe8f6; font-size: 11.5px; overflow: hidden; }
.mg-lib-name,
.mg-lib-name small { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.mg-lib-name small { color: #75879c; font-size: 10px; }
.mg-lib-act {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid rgba(120, 184, 255, 0.16);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.mg-lib-row:hover .mg-lib-act,
.mg-lib-row:focus-within .mg-lib-act,
.mg-lib-row--all .mg-lib-add,
.mg-lib-act.is-armed { opacity: 1; }
.mg-lib-act:hover { color: #fff; border-color: rgba(140, 196, 255, 0.6); background: rgba(61, 139, 255, 0.2); }
.mg-lib-del:hover { border-color: rgba(255, 120, 110, 0.6); background: rgba(255, 90, 80, 0.2); }
.mg-lib-del.is-armed { color: #fff; background: rgba(255, 90, 80, 0.55); border-color: rgba(255, 140, 130, 0.85); }
.mg-lib-name[data-lib-fly] { cursor: pointer; }
.mg-lib-row.is-pulse { animation: mg-rowpulse 0.9s ease-out; }
@keyframes mg-rowpulse { 0% { background: rgba(61, 139, 255, 0.35); } 100% { background: transparent; } }
.mg-lib-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.mg-lib-tools .mg-btn { height: 24px; padding: 0 8px; font-size: 10.5px; }
.mg-eyebtn { color: #8fa0b4; }
.mg-eyebtn.is-on { color: #eaf4ff; border-color: rgba(140, 196, 255, 0.55); background: rgba(61, 139, 255, 0.18); }
.mg-lib-more { padding: 10px 8px; color: #75879c; font-size: 11px; line-height: 1.45; }
.mg-code { padding: 10px 0 4px; border-top: 1px solid rgba(120, 184, 255, 0.12); }
.mg-code-label { display: block; margin-bottom: 6px; color: #8fa0b4; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.mg-code-row { display: flex; gap: 6px; }
.mg-code-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 9px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.7);
  border: 1px solid rgba(94, 234, 212, 0.3);
  border-radius: 6px;
  font: 700 12.5px ui-monospace, Consolas, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  outline: none;
}
.mg-code-input:focus { border-color: rgba(94, 234, 212, 0.75); }
.mg-lib-foot { padding: 8px 12px 10px; color: #64768b; font-size: 10.5px; }

/* ---- foot ---------------------------------------------------------------------------------- */

.mg-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 26px;
  padding: 0 14px;
  color: #75879c;
  font-size: 10.5px;
  border-top: 1px solid rgba(120, 184, 255, 0.12);
  background: rgba(8, 13, 22, 0.6);
}
.mg-foot-stats { color: #a9bdd4; font-variant-numeric: tabular-nums; }
.mg-foot-hint { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- the drawing pod: the zone node, out on the map --------------------------------------- */

.mg-pod {
  --nc: var(--mg-src);
  position: absolute;
  top: 72px;
  right: 22px;
  width: 268px;
  padding: 10px 12px 10px;
  color: #dbe8f6;
  background: linear-gradient(180deg, rgba(23, 34, 53, 0.97), rgba(13, 20, 32, 0.97));
  border: 1px solid rgba(140, 196, 255, 0.5);
  border-radius: 9px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(61, 139, 255, 0.12);
  pointer-events: auto;
  font-size: 11.5px;
  will-change: transform;
}
.mg-pod[hidden] { display: none; }
.mg-pod::before {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: -1px;
  height: 2px;
  border-radius: 9px 9px 0 0;
  background: var(--nc);
  box-shadow: 0 0 12px var(--nc);
}
.mg-pod-head { display: flex; align-items: center; gap: 8px; }
.mg-pod-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f0f6ff; font-size: 12.5px; }
.mg-pod-mode {
  padding: 2px 7px;
  color: #eaf4ff;
  background: rgba(61, 139, 255, 0.28);
  border: 1px solid rgba(140, 196, 255, 0.55);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: mg-blink 1.6s ease-in-out infinite;
}
.mg-pod-stats { display: flex; gap: 14px; margin: 9px 0 4px; color: #a9bdd4; font-variant-numeric: tabular-nums; }
.mg-pod-stats b { color: #eaf4ff; font-size: 14px; }
.mg-pod-hint { color: #8fa0b4; font-size: 11px; line-height: 1.4; min-height: 30px; }
.mg-pod-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.mg-pod-foot { margin-top: 7px; color: #64768b; font-size: 10px; }
.mg-pod-sub { margin-top: 2px; color: #64768b; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.mg-pod-note { margin-top: 7px; padding: 5px 7px; color: #d8f7f1; background: rgba(94, 234, 212, 0.08); border-left: 2px solid var(--mg-out); border-radius: 0 4px 4px 0; font-size: 10.5px; }
.mg-pod[data-kind="merge"] .mg-pod-hint { min-height: 0; margin-top: 6px; }

.mg-trail {
  position: absolute;
  height: 2px;
  transform-origin: 0 50%;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(110, 176, 255, 0), rgba(110, 176, 255, 0.95) 70%, #fff);
  box-shadow: 0 0 12px rgba(110, 176, 255, 0.85);
  border-radius: 2px;
}

/* ---- the launcher in the status strip --------------------------------------------------------- */

.mapgraph-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.mapgraph-launcher svg { width: 14px; height: 14px; }
.mapgraph-launcher.is-on {
  color: #eaf4ff;
  background: rgba(61, 139, 255, 0.35);
  border-color: rgba(140, 196, 255, 0.75);
  box-shadow: 0 0 10px rgba(61, 139, 255, 0.4);
}
.mapgraph-launcher.has-live::after {
  content: attr(data-live);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  color: #04201b;
  background: var(--mg-out, #5eead4);
  border-radius: 7px;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 0 6px rgba(94, 234, 212, 0.8);
}

@media (max-width: 900px) {
  .mg-win { inset: 56px 6px 70px 6px; }
  .mg-lib.is-open { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5); }
  .mg-tools .mg-btn span { display: none; }
  .mg-foot-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-link.is-live .mg-link-flow,
  .mg-empty-mark,
  .mg-pod-mode { animation: none; }
}

/* ---- the left rail's one remaining line about zones ------------------------------------- */

.tsrc-studio-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  color: #cfe0f3;
  text-align: left;
  background: rgba(61, 139, 255, 0.07);
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tsrc-studio-link:hover { background: rgba(61, 139, 255, 0.16); border-color: rgba(140, 196, 255, 0.5); }
.tsrc-studio-link svg { width: 18px; height: 18px; flex: none; color: var(--blue-400, #6eb0ff); }
.tsrc-studio-link span { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.tsrc-studio-link b { font-size: 11px; letter-spacing: 0.04em; }
.tsrc-studio-link small { color: #75879c; font-size: 10px; }
.tsrc-studio-link kbd {
  padding: 1px 6px;
  color: #a9bdd4;
  border: 1px solid rgba(120, 184, 255, 0.3);
  border-radius: 4px;
  font: 700 10px ui-monospace, Consolas, monospace;
}

/* ---- outputs: checkbox, wire counter, problems ------------------------------------------ */

.mg-check { display: flex; align-items: center; gap: 7px; color: #a9bdd4; font-size: 11px; cursor: pointer; }
.mg-check input { position: absolute; opacity: 0; pointer-events: none; }
.mg-check i {
  position: relative;
  width: 14px;
  height: 14px;
  flex: none;
  border: 1.5px solid rgba(143, 170, 200, 0.6);
  border-radius: 3px;
  background: rgba(4, 8, 15, 0.7);
  transition: background 0.12s, border-color 0.12s;
}
.mg-check input:checked + i { background: var(--nc); border-color: var(--nc); box-shadow: 0 0 6px color-mix(in srgb, var(--nc) 60%, transparent); }
.mg-check input:checked + i::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid #04201b;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mg-check input:focus-visible + i { outline: 2px solid rgba(140, 196, 255, 0.7); outline-offset: 2px; }
.mg-check input:checked ~ span { color: #eaf4ff; }
.mg-wirecount { color: #8fa0b4; font-size: 10.5px; }
.mg-note--bad { color: #ffb4ab; font-style: normal; }
.mg-origin {
  margin-left: 4px;
  padding: 0 5px;
  color: #8fa0b4;
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 3px;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---- this map + the Wiki of maps ------------------------------------------------------------ */

.mg-mapname { color: #9fccff !important; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-this {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(61, 139, 255, 0.1), rgba(61, 139, 255, 0.03));
}
.mg-this-kicker { color: #75879c; font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.mg-this-head { display: flex; align-items: center; gap: 8px; }
.mg-map-name {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  color: #f0f6ff;
  background: rgba(4, 8, 15, 0.6);
  border: 1px solid rgba(120, 184, 255, 0.22);
  border-radius: 5px;
  font: 650 13px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-map-name:focus { border-color: rgba(140, 196, 255, 0.75); }
.mg-map-name::placeholder { color: #64768b; font-weight: 400; }
.mg-this-sub { color: #8fa0b4; font-size: 10.5px; line-height: 1.35; }
.mg-this-share { margin-top: 2px; }
.mg-this-share[hidden] { display: none; }
.mg-map-row .mg-lib-name small b { color: #9fccff; font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.06em; }
.mg-lib-act.mg-lib-open { width: auto; padding: 0 7px; opacity: 1; color: #d6e6f8; font-size: 10.5px; font-weight: 650; }

/* ---- opening a map: replace or add? ---------------------------------------------------------- */

.mg-dialog {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 18, 0.62);
  backdrop-filter: blur(2px);
  animation: mg-fade 0.16s ease-out;
}
.mg-dialog[hidden] { display: none; }
.mg-dialog-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 460px;
  padding: 24px 28px;
  text-align: center;
  color: #a9bdd4;
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.98), rgba(10, 16, 27, 0.98));
  border: 1px solid rgba(140, 196, 255, 0.45);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 30px rgba(61, 139, 255, 0.18);
  animation: mg-pop 0.2s cubic-bezier(.2, .9, .3, 1.1);
}
.mg-dialog-icon { width: 34px; height: 34px; color: var(--blue-400, #6eb0ff); }
.mg-dialog-icon svg { width: 100%; height: 100%; }
.mg-dialog-card b { color: #eaf4ff; font-size: 15px; }
.mg-dialog-sub { font-size: 11.5px; }
.mg-dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.mg-dialog-note { color: #64768b; font-size: 10.5px; }

/* ---- the picture's ⤢ ---------------------------------------------------------------------- */

.mg-thumb-open {
  position: absolute;
  top: 5px;
  right: 15px;
  width: 24px;
  height: 22px;
  padding: 0;
  color: #eaf4ff;
  background: rgba(8, 14, 24, 0.82);
  border: 1px solid rgba(140, 196, 255, 0.45);
  border-radius: 5px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.mg-node:hover .mg-thumb-open,
.mg-node.is-selected .mg-thumb-open { opacity: 1; }
.mg-thumb-open:hover { background: rgba(61, 139, 255, 0.45); }
.mg-node-thumb svg:hover { border-color: rgba(140, 196, 255, 0.35); }

/* ---- full-screen preview -------------------------------------------------------------------- */

.mg-viewer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(24, 40, 66, 0.55), transparent 70%),
    linear-gradient(180deg, #070c15, #04070d);
}
.mg-viewer[hidden] { display: none; }
.mg-viewer:fullscreen { width: 100vw; height: 100vh; }
.mg-v-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(120, 184, 255, 0.18);
  background: linear-gradient(180deg, rgba(20, 31, 49, 0.96), rgba(12, 19, 31, 0.92));
}
.mg-v-title { display: flex; flex-direction: column; min-width: 0; max-width: 34%; line-height: 1.2; }
.mg-v-title b { overflow: hidden; color: #f0f6ff; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.mg-v-title small { color: #8fa0b4; font-size: 11px; }
.mg-v-tabs, .mg-v-kinds { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-v-tabs .mg-chip, .mg-v-kinds .mg-chip { --nc: #6eb0ff; }
.mg-v-head .mg-btn.is-on { color: #eaf4ff; border-color: rgba(140, 196, 255, 0.6); background: rgba(61, 139, 255, 0.22); }
.mg-v-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; }
.mg-v-stage.is-dragging { cursor: grabbing; }
.mg-v-canvas { position: absolute; inset: 0; display: block; }
.mg-v-tip {
  position: absolute;
  z-index: 2;
  max-width: 320px;
  padding: 8px 10px;
  color: #cfe0f3;
  background: rgba(10, 16, 27, 0.96);
  border: 1px solid rgba(140, 196, 255, 0.45);
  border-radius: 7px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 11.5px;
  pointer-events: none;
}
.mg-v-tip[hidden] { display: none; }
.mg-v-tip-head { display: flex; align-items: center; gap: 7px; }
.mg-v-tip-head b { color: #f0f6ff; font-size: 12.5px; }
.mg-v-tip-kind { display: block; margin-top: 3px; color: #8fa0b4; font-size: 10.5px; }
.mg-v-tip p { margin: 6px 0 0; color: #a9bdd4; line-height: 1.4; }
.mg-v-sw { flex: none; width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--c) 45%, transparent); border: 1.5px solid var(--c); }
.mg-v-sw--line { height: 3px; border: 0; border-radius: 2px; background: var(--c); }
.mg-v-sw--point { width: 9px; height: 9px; border-radius: 50%; background: var(--c); border: 1px solid rgba(4, 8, 15, 0.8); }
.mg-v-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60%;
  padding: 6px;
  overflow-y: auto;
  background: rgba(10, 16, 27, 0.86);
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 8px;
}
.mg-v-legend:empty { display: none; }
.mg-v-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  color: #cfe0f3;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font: 11px "Segoe UI", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.mg-v-leg:hover { background: rgba(61, 139, 255, 0.14); }
.mg-v-leg span { flex: 1; }
.mg-v-leg b { color: #eaf4ff; font-variant-numeric: tabular-nums; }
.mg-v-leg.is-off { opacity: 0.35; }
.mg-v-more { padding: 3px 7px; color: #64768b; font-size: 10.5px; }
.mg-v-scale {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  color: #cfe0f3;
  font: 600 10.5px ui-monospace, Consolas, monospace;
  pointer-events: none;
}
.mg-v-scale i { display: block; height: 6px; border: 1.5px solid #cfe0f3; border-top: 0; }
.mg-v-coords {
  position: absolute;
  right: 14px;
  top: 10px;
  z-index: 2;
  color: #75879c;
  font: 10.5px ui-monospace, Consolas, monospace;
  pointer-events: none;
}
.mg-v-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #64768b; font-size: 13px; pointer-events: none; }
.mg-v-empty[hidden] { display: none; }

/* =============================================================================================
   THE RAIL — outputs fixed to the right edge of the canvas. Brushed gunmetal with
   recessed bays, ring jacks and green status lights.
   ============================================================================================= */

.mg-rail {
  position: relative;
  z-index: 1;
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: var(--mg-rail-w);
  color: #c9d3dd;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 5px),
    linear-gradient(90deg, #1d2229 0%, #2c333c 7%, #3a424c 22%, #2f363f 48%, #363e48 74%, #262c34 100%);
  border-left: 1px solid rgba(214, 226, 240, 0.22);
  box-shadow:
    -14px 0 34px rgba(0, 0, 0, 0.5),
    inset 1px 0 0 rgba(255, 255, 255, 0.08),
    inset 3px 0 6px rgba(0, 0, 0, 0.35);
  user-select: none;
}
.mg-rail::before {
  /* a bevelled lip where the rail meets the canvas */
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(255, 255, 255, 0.06));
  pointer-events: none;
}
.mg-screw {
  position: absolute;
  z-index: 1;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d7dee6, #7d8792 45%, #3a414a 75%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.7), inset 0 0 0 0.5px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.mg-screw::after {
  content: "";
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  top: 4px;
  height: 1px;
  background: rgba(30, 34, 40, 0.85);
  transform: rotate(-35deg);
}
.mg-screw--tl { top: 7px; left: 9px; }
.mg-screw--tr { top: 7px; right: 7px; }
.mg-screw--bl { bottom: 7px; left: 9px; }
.mg-screw--br { bottom: 7px; right: 7px; }
.mg-screw--tr::after, .mg-screw--bl::after { transform: rotate(50deg); }

.mg-rail-head {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 14px 10px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.mg-rail-kicker {
  color: #aeb9c5;
  font: 800 10.5px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  /* stamped into the plate */
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75), 0 1px 0 rgba(255, 255, 255, 0.1);
}
.mg-rail-maps { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-rail-map {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  height: 22px;
  padding: 0 8px;
  overflow: hidden;
  color: #b7c2cd;
  background: linear-gradient(180deg, #2b3139, #22272e);
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(255, 255, 255, 0.05);
  font: 650 10.5px "Segoe UI", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.mg-rail-map i { color: var(--mg-out); font-size: 7px; font-style: normal; }
.mg-rail-map em {
  min-width: 14px;
  padding: 0 4px;
  color: #04201b;
  background: var(--mg-out);
  border-radius: 7px;
  font: 800 9px/14px "Segoe UI", system-ui, sans-serif;
  font-style: normal;
  text-align: center;
}
.mg-rail-map:hover { color: #eaf4ff; }
.mg-rail-map.is-on {
  color: #e9fff9;
  background: linear-gradient(180deg, #1b2a29, #142020);
  border-color: rgba(94, 234, 212, 0.55);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 8px rgba(94, 234, 212, 0.18);
}
.mg-rail-map.is-target { border-color: #fff; box-shadow: 0 0 10px rgba(94, 234, 212, 0.8); }

.mg-rail-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 10px 10px 22px 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 175, 190, 0.35) transparent;
}
.mg-rail-div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 2px 8px;
  color: #8995a2;
  font: 800 9.5px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
.mg-rail-div::before, .mg-rail-div::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 50%, rgba(255, 255, 255, 0.07) 50%);
}

/* a bay: recessed into the plate */
.mg-bay {
  --bay: var(--mg-out);
  position: relative;
  margin-bottom: 10px;
  padding: 8px 8px 8px 10px;
  background: linear-gradient(180deg, #161a20, #1c2128 40%, #1a1f26);
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 7px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 1px 0 rgba(255, 255, 255, 0.07);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.mg-bay--out-zones, .mg-bay--out-file { --bay: #8fb8d8; }
.mg-bay.is-target {
  border-color: color-mix(in srgb, var(--bay) 80%, white 10%);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65), 0 0 0 1px color-mix(in srgb, var(--bay) 60%, transparent), 0 0 18px color-mix(in srgb, var(--bay) 40%, transparent);
}
.mg-bay.is-flash { animation: mg-bayflash 1s ease-out; }
@keyframes mg-bayflash {
  0% { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65), 0 0 0 2px var(--bay), 0 0 24px var(--bay); }
  100% { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65), 0 0 0 0 transparent, 0 1px 0 rgba(255, 255, 255, 0.07); }
}
.mg-bay.is-dormant { opacity: 0.8; }
.mg-bay-head { display: flex; align-items: center; gap: 7px; min-height: 22px; }
.mg-bay-icon { width: 16px; height: 16px; color: var(--bay); flex: none; opacity: 0.9; }
.mg-bay-icon svg { width: 100%; height: 100%; }
.mg-bay-name {
  color: #e4ebf2;
  font: 750 11.5px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.mg-bay-count {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #7f8b98;
  font: 10px ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-bay-btn {
  flex: none;
  height: 18px;
  padding: 0 6px;
  color: #a8b3bf;
  background: linear-gradient(180deg, #313841, #252b33);
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font: 700 9px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.mg-bay-btn:hover { color: #fff; }
.mg-bay-btn.is-on { color: #04201b; background: var(--bay); box-shadow: 0 0 8px color-mix(in srgb, var(--bay) 60%, transparent); }

/* status light */
.mg-led {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3c4a47, #1a2321 70%);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.mg-led[data-state="on"] {
  background: radial-gradient(circle at 35% 30%, #eafff8, #5ef0b0 40%, #1fa36d 80%);
  box-shadow: 0 0 8px rgba(80, 240, 170, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.mg-led[data-state="busy"] {
  background: radial-gradient(circle at 35% 30%, #fff7dd, #ffcf5a 45%, #b07d12 85%);
  box-shadow: 0 0 8px rgba(255, 196, 70, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.6);
  animation: mg-blink 0.8s ease-in-out infinite;
}
.mg-led[data-state="bad"] {
  background: radial-gradient(circle at 35% 30%, #ffe1dc, #ff6b5e 45%, #a3271c 85%);
  box-shadow: 0 0 8px rgba(255, 107, 94, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* Live lever */
.mg-lever { position: relative; flex: none; cursor: pointer; }
.mg-lever input { position: absolute; opacity: 0; pointer-events: none; }
.mg-lever i {
  position: relative;
  display: block;
  width: 26px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #0d1013, #1b2026);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.07);
}
.mg-lever i::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e6ecf2, #8b96a2 55%, #4a535d);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  transition: transform 0.18s cubic-bezier(.2, .9, .3, 1.2);
}
.mg-lever input:checked + i { background: linear-gradient(180deg, #0f3a2c, #155a43); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(80, 240, 170, 0.35); }
.mg-lever input:checked + i::after { transform: translateX(12px); }
.mg-lever input:focus-visible + i { outline: 2px solid rgba(140, 196, 255, 0.7); outline-offset: 2px; }

/* channels */
.mg-chans { margin: 7px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.mg-chan {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 4px 4px 18px;
  background: linear-gradient(180deg, #232930, #1d2229);
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.15s, background 0.15s;
}
.mg-chan:hover { border-color: rgba(160, 200, 230, 0.28); }
.mg-chan.is-selected { border-color: color-mix(in srgb, var(--bay) 70%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 10px color-mix(in srgb, var(--bay) 30%, transparent); }
.mg-chan.is-flash { animation: mg-chanflash 1.1s ease-out; }
@keyframes mg-chanflash { 0% { background: color-mix(in srgb, var(--bay) 35%, #1d2229); } 100% { background: #1f242b; } }
.mg-chan.is-off .mg-chan-main b { color: #8d97a2; text-decoration: line-through; text-decoration-color: rgba(141, 151, 162, 0.5); }

/* the jack: a metal ring the wire plugs into, on the channel's left edge */
.mg-jack {
  position: absolute;
  left: -15px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(circle, #06080a 0 32%, #9aa5b1 36%, #d9e1e9 46%, #6d7883 62%, #2d343c 78%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  cursor: grab;
  transition: transform 0.12s;
}
.mg-jack.is-plugged {
  background: radial-gradient(circle, color-mix(in srgb, var(--bay) 85%, white 15%) 0 30%, #0c1a17 34%, #9aa5b1 40%, #d9e1e9 50%, #6d7883 64%, #2d343c 80%);
  box-shadow: 0 0 9px color-mix(in srgb, var(--bay) 70%, transparent), 0 1px 2px rgba(0, 0, 0, 0.7);
}
.mg-jack:hover { transform: scale(1.18); }
.mg-chan .mg-jack { left: -8px; }
/* The jack's lead: the wire reaches the canvas's edge, the lead brings it in to the jack. */
.mg-chan { --lead: var(--mg-src); }
.mg-chan[data-cat="op"] { --lead: var(--mg-op); }
.mg-chan[data-cat="ctl"] { --lead: var(--mg-ctl); }
.mg-chan .mg-jack.is-plugged::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 30px;
  height: 2px;
  margin-top: -1px;
  background: var(--lead);
  opacity: 0.85;
  box-shadow: 0 0 5px var(--lead);
  pointer-events: none;
}
.mg-chan.is-off .mg-jack.is-plugged::before { opacity: 0.35; background: repeating-linear-gradient(90deg, var(--lead) 0 6px, transparent 6px 11px); box-shadow: none; }

.mg-chan-led {
  flex: none;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #45524f, #1a2321 70%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 0 2px #14181d, 0 0 0 3px rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s;
}
.mg-chan-led.is-on {
  background: radial-gradient(circle at 35% 30%, #f2fffa, #6ff5b9 38%, #1ea36c 80%);
  box-shadow: 0 0 9px rgba(80, 240, 170, 0.9), 0 0 0 2px #14181d, 0 0 0 3px rgba(80, 240, 170, 0.25);
}
.mg-chan-led.is-keep { cursor: default; background: radial-gradient(circle at 35% 30%, #cfe3ff, #6e9ccc 50%, #2c4766); box-shadow: 0 0 0 2px #14181d; width: 8px; height: 8px; margin: 0 3px; }
.mg-chan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; cursor: pointer; }
.mg-chan-main b {
  overflow: hidden;
  color: #e7eef5;
  font: 650 11.5px/1.2 "Segoe UI", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-chan-main small {
  align-self: flex-start;
  color: #8995a2;
  font: 10px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  cursor: zoom-in;
}
.mg-chan-main small:hover { color: #cfe3ff; }
.mg-chan-tools { display: flex; align-items: center; gap: 3px; flex: none; }
.mg-chan-tools button {
  height: 20px;
  min-width: 20px;
  padding: 0 4px;
  color: #9aa6b2;
  background: linear-gradient(180deg, #2f363e, #242a31);
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font: 700 10px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mg-chan-tools button:hover { color: #fff; }
.mg-chan-tools button:disabled { opacity: 0.5; cursor: default; }
.mg-chan-pin { letter-spacing: 0.04em; }
.mg-chan-pin.is-on { color: #1a1406 !important; background: linear-gradient(180deg, #f6d77a, #d9ae3d) !important; border-color: rgba(60, 40, 0, 0.6) !important; }
.mg-chan-act { color: #dcebfa !important; }
.mg-chan-x { opacity: 0; transition: opacity 0.12s; }
.mg-chan:hover .mg-chan-x { opacity: 1; }
.mg-chan-x:hover { background: rgba(255, 90, 80, 0.45) !important; }

/* an empty plug */
.mg-plug {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 6px 6px 18px;
  color: #7f8b98;
  border: 1px dashed rgba(180, 195, 210, 0.2);
  border-radius: 5px;
  font-size: 10.5px;
  cursor: crosshair;
}
.mg-plug .mg-jack { left: -8px; }
.mg-plug:hover { color: #cfe3ff; border-color: color-mix(in srgb, var(--bay) 50%, transparent); }
.mg-bay-foot { margin-top: 6px; color: #75818e; font-size: 10px; font-style: italic; }
.mg-bay-note {
  margin-top: 6px;
  padding: 4px 7px;
  color: #a9bdd4;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid rgba(143, 160, 180, 0.4);
  border-radius: 0 3px 3px 0;
  font-size: 10.5px;
  line-height: 1.35;
}
.mg-bay-note[data-tone="bad"] { color: #ffd2cd; border-left-color: var(--mg-bad); }
.mg-bay-note[data-tone="busy"] { color: #ffe9b8; border-left-color: #ffcf5a; }
.mg-bay-note[data-tone="ok"] { color: #d8f7f1; border-left-color: var(--mg-out); }
.mg-bay-acts { display: flex; gap: 4px; margin-top: 7px; }
.mg-bay-acts button {
  height: 20px;
  padding: 0 7px;
  color: #a8b3bf;
  background: transparent;
  border: 1px solid rgba(180, 195, 210, 0.18);
  border-radius: 3px;
  font: 650 10px "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mg-bay-acts button:hover { color: #fff; border-color: rgba(180, 195, 210, 0.45); }

/* what a bay takes in */
.mg-intake {
  margin-top: 8px;
  padding: 8px 9px;
  color: #a9b6c3;
  background: rgba(4, 7, 10, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 5px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7);
  font-size: 10.5px;
  line-height: 1.4;
}
.mg-intake p { margin: 0 0 7px; }
.mg-intake ul { margin: 0 0 7px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.mg-intake-row { display: flex; align-items: flex-start; gap: 7px; }
.mg-intake-glyph { width: 12px; flex: none; color: var(--bay); text-align: center; }
.mg-intake-what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mg-intake-what b { color: #e2e9f0; font-weight: 650; }
.mg-intake-what small { color: #7f8b98; font-size: 10px; }
.mg-intake-n { flex: none; color: #e2e9f0; font: 650 10.5px ui-monospace, Consolas, monospace; }
.mg-intake-row.is-drop .mg-intake-what b,
.mg-intake-row.is-drop .mg-intake-n { color: #8d97a2; }
.mg-intake-row.is-zero { opacity: 0.55; }
.mg-intake-sum { color: #d8f7f1 !important; }

/* wires into the rail */
.mg-link--ctl { --wc: var(--mg-ctl); }
.mg-link.is-away .mg-link-line { stroke-dasharray: 2 6; stroke-opacity: 0.35; }
.mg-link.is-away .mg-link-flow { opacity: 0 !important; }
.mg-link.is-off .mg-link-line { stroke-dasharray: 6 5; stroke-opacity: 0.3; }
.mg-link.is-off .mg-link-flow { opacity: 0 !important; }

/* =============================================================================================
   Look & control nodes, wide nodes, pins
   ============================================================================================= */

.mg-node--ctl { --nc: var(--mg-ctl); }
.mg-node--wide { width: 300px; }
.mg-pal-col--ctl { --nc: var(--mg-ctl); }
.mg-lookchip {
  flex: none;
  padding: 0 5px;
  color: #241a02;
  background: var(--mg-ctl);
  border-radius: 3px;
  font: 800 8.5px/1.6 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mg-prow { display: flex; align-items: center; gap: 4px; min-width: 0; }
.mg-prow > :first-child { flex: 1; min-width: 0; }
.mg-prow.is-pinned {
  margin: 0 -6px;
  padding: 2px 4px 2px 5px;
  background: linear-gradient(90deg, rgba(240, 199, 94, 0.12), transparent 75%);
  border-left: 2px solid var(--mg-ctl);
  border-radius: 0 4px 4px 0;
}
.mg-pin {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 2px;
  color: #64768b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}
.mg-pin svg { display: block; width: 100%; height: 100%; }
.mg-node:hover .mg-pin, .mg-node.is-selected .mg-pin { opacity: 1; }
.mg-pin:hover { color: #f6e3a8; border-color: rgba(240, 199, 94, 0.5); background: rgba(240, 199, 94, 0.1); }
.mg-pin.is-on { color: #241a02; background: var(--mg-ctl); border-color: var(--mg-ctl); opacity: 1; box-shadow: 0 0 8px rgba(240, 199, 94, 0.45); }

.mg-f--range input[type="range"] { flex: 1; min-width: 0; accent-color: var(--nc); }
.mg-range-val { flex: none; min-width: 38px; color: #eaf4ff; font: 650 11px ui-monospace, Consolas, monospace; text-align: right; }

.mg-node[data-kind="switch"] .mg-check { padding: 4px 0; font-size: 12px; }
.mg-node[data-kind="switch"] .mg-check i { width: 18px; height: 18px; }
.mg-node[data-kind="switch"] .mg-check input:checked + i::after { left: 5px; top: 1.5px; width: 5px; height: 10px; }

/* the Rules editor */
.mg-rules { display: flex; flex-direction: column; gap: 6px; }
.mg-rules select, .mg-rules input[type="text"], .mg-rules input[type="number"] {
  min-width: 0;
  height: 23px;
  padding: 0 5px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.75);
  border: 1px solid rgba(120, 184, 255, 0.2);
  border-radius: 4px;
  font: 11.5px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-rules select:focus, .mg-rules input:focus { border-color: rgba(140, 196, 255, 0.7); }
.mg-rules select option { background: #0d1420; }
.mg-rules-preset { display: flex; align-items: center; gap: 7px; }
.mg-rules-preset span { flex: none; color: #8fa0b4; font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; }
.mg-rules-preset select { flex: 1; }
.mg-rules-mode { display: flex; align-items: center; gap: 5px; color: #8fa0b4; font-size: 11px; }
.mg-rules-mode .mg-chip { height: 20px; padding: 0 8px; }
.mg-rule {
  display: grid;
  grid-template-columns: 30% 32% 1fr 20px;
  gap: 4px;
  align-items: center;
  padding: 4px;
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.16);
  border-radius: 5px;
}
.mg-rule > * { min-width: 0; width: 100%; }
.mg-rule input[type="color"] { height: 23px; padding: 1px; background: transparent; border: 1px solid rgba(120, 184, 255, 0.2); border-radius: 4px; }
.mg-rule-num { display: flex; align-items: center; gap: 3px; }
.mg-rule-num input { flex: 1; width: 100%; }
.mg-rule-num em { color: #8fa0b4; font-size: 10px; font-style: normal; }
.mg-rule-x {
  width: 20px;
  height: 20px;
  padding: 0;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.mg-rule-x:hover { color: #fff; background: rgba(255, 90, 80, 0.3); }
.mg-rules-none { color: #75879c; font-size: 11px; font-style: italic; }
.mg-rules-add { align-self: flex-start; }
.mg-rules-sum { color: #a9bdd4; font-size: 11px; font-variant-numeric: tabular-nums; }
.mg-rules-sum b { color: #eaf4ff; }

/* palette: the pin tip, and "plug it straight into" */
.mg-pal-tip {
  display: flex;
  gap: 9px;
  margin: 12px 6px 4px;
  padding: 9px 10px;
  color: #c9b98a;
  background: rgba(240, 199, 94, 0.07);
  border: 1px dashed rgba(240, 199, 94, 0.35);
  border-radius: 7px;
  font-size: 10.5px;
  line-height: 1.45;
}
.mg-pal-tip svg { width: 16px; height: 16px; flex: none; color: var(--mg-ctl); margin-top: 1px; }
.mg-pal-tip b { color: #f6e3a8; }
.mg-pal-plug {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(120, 184, 255, 0.14);
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.06), transparent);
}
.mg-pal-plug > span { color: #75879c; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; margin-right: 4px; }
.mg-pal-plug .mg-btn svg { width: 13px; height: 13px; color: var(--mg-out); }
.mg-foot-pin { width: 12px; height: 12px; vertical-align: -2px; color: var(--mg-ctl); }

/* =============================================================================================
   The tour
   ============================================================================================= */

.mg-tour { position: absolute; inset: 0; z-index: 40; pointer-events: auto; }
.mg-tour[hidden] { display: none; }
.mg-tour-spot {
  position: fixed;
  border-radius: 9px;
  box-shadow: 0 0 0 9999px rgba(3, 6, 12, 0.66), 0 0 0 2px rgba(240, 199, 94, 0.85), 0 0 26px rgba(240, 199, 94, 0.45);
  pointer-events: none;
  transition: left 0.32s cubic-bezier(.2, .9, .3, 1), top 0.32s cubic-bezier(.2, .9, .3, 1), width 0.32s cubic-bezier(.2, .9, .3, 1), height 0.32s cubic-bezier(.2, .9, .3, 1);
}
.mg-tour.is-free .mg-tour-spot { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgba(3, 6, 12, 0.66); }
.mg-tour-card {
  position: fixed;
  width: 360px;
  max-width: calc(100vw - 16px);
  padding: 12px 14px 12px;
  color: #b9cbe0;
  background: linear-gradient(180deg, rgba(20, 31, 49, 0.99), rgba(11, 17, 28, 0.99));
  border: 1px solid rgba(240, 199, 94, 0.55);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 24px rgba(240, 199, 94, 0.12);
  font-size: 12px;
  line-height: 1.5;
  transition: left 0.32s cubic-bezier(.2, .9, .3, 1), top 0.32s cubic-bezier(.2, .9, .3, 1);
}
.mg-tour-card.is-in { animation: mg-pop 0.22s cubic-bezier(.2, .9, .3, 1.1); }
.mg-tour-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mg-tour-count { color: #c9a94f; font: 700 10.5px ui-monospace, Consolas, monospace; }
.mg-tour-dots { display: flex; gap: 3px; flex: 1; }
.mg-tour-dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(143, 160, 180, 0.35); }
.mg-tour-dots i.is-past { background: rgba(240, 199, 94, 0.5); }
.mg-tour-dots i.is-on { background: var(--mg-ctl); box-shadow: 0 0 6px var(--mg-ctl); }
.mg-tour-x { width: 22px; height: 22px; padding: 0; color: #8fa0b4; background: transparent; border: 0; border-radius: 4px; font-size: 15px; cursor: pointer; }
.mg-tour-x:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.mg-tour-title { display: block; margin-bottom: 4px; color: #f6efd8; font-size: 14.5px; letter-spacing: 0.01em; }
.mg-tour-body p { margin: 0 0 7px; }
.mg-tour-body b { color: #eaf4ff; }
.mg-tour-body i { color: #f0d999; font-style: normal; }
.mg-tour-body svg { width: 14px; height: 14px; vertical-align: -2px; color: var(--mg-ctl); }
.mg-tour-card kbd {
  padding: 0 5px;
  color: #eaf4ff;
  border: 1px solid rgba(120, 184, 255, 0.35);
  border-radius: 3px;
  font: 700 10.5px ui-monospace, Consolas, monospace;
}
.mg-tour-acts { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.mg-tour-mock {
  margin: 4px 0 6px;
  padding: 8px 10px;
  background: rgba(4, 8, 15, 0.7);
  border: 1px solid rgba(120, 184, 255, 0.22);
  border-radius: 7px;
  font-size: 11px;
}
.mg-tour-mock-head { margin-bottom: 6px; color: #8fa0b4; font-size: 9.5px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.mg-tour-mock-head span { margin-left: 6px; color: #64768b; font-weight: 600; letter-spacing: 0.04em; text-transform: none; }
.mg-tour-mock-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
.mg-tour-mock-row i { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid #6eb0ff; }
.mg-tour-mock-row i.is-on { background: #6eb0ff; }
.mg-tour-mock-row b { color: #eaf4ff; font-weight: 600; }
.mg-tour-mock-row small { margin-left: auto; color: #c9a94f; font-size: 10px; }
.mg-tour-mock-ctl { display: flex; align-items: center; gap: 7px; margin-left: 5px; padding: 2px 0 4px 12px; border-left: 2px solid var(--mg-ctl); }
.mg-tour-mock-ctl > span:first-child { width: 26px; color: #8fa0b4; }
.mg-tour-mock-bar { flex: 1; height: 4px; overflow: hidden; border-radius: 2px; background: rgba(143, 160, 180, 0.25); }
.mg-tour-mock-bar span { display: block; height: 100%; background: var(--mg-ctl); }
.mg-tour-mock-ctl em { color: #eaf4ff; font: 650 10.5px ui-monospace, Consolas, monospace; font-style: normal; }

@media (max-width: 900px) {
  .mg { --mg-rail-w: 220px; }
  .mg-chan-tools .mg-chan-pin { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-led[data-state="busy"] { animation: none; }
  .mg-tour-spot, .mg-tour-card { transition: none; }
}

/* =============================================================================================
   Map data (left menu): rows that are World channels, and the controls pinned from nodes
   ============================================================================================= */

/* A channel row: its name gets the whole first line, the four buttons share the second. */
.kml-row.is-channel .kml-row-head { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kml-row.is-channel .kml-toggle { grid-column: 1 / -1; }
.kml-row.is-channel { border-left: 2px solid rgba(94, 234, 212, 0.45); }
.kml-row .kml-graph { color: #bff3e9; border-color: rgba(94, 234, 212, 0.3); }
.kml-row .kml-graph:hover { border-color: rgba(94, 234, 212, 0.7); background: rgba(94, 234, 212, 0.12); }

.kml-controls {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding: 6px;
  background: rgba(240, 199, 94, 0.05);
  border: 1px solid rgba(240, 199, 94, 0.22);
}
.kml-controls-head {
  color: #e8d49a;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.kml-controls-head span { margin-left: 6px; color: #8a7d58; font-weight: 600; letter-spacing: 0.04em; text-transform: none; }
.kml-controls-tip {
  margin-top: 6px;
  padding: 6px 8px;
  color: #8a96a3;
  border: 1px dashed rgba(240, 199, 94, 0.25);
  font-size: 10px;
  line-height: 1.4;
}

.mdc {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 24px;
  padding: 2px 2px 2px 7px;
  border-left: 2px solid #f0c75e;
  background: linear-gradient(90deg, rgba(240, 199, 94, 0.1), transparent 80%);
  font-size: 10.5px;
}
.mdc.is-nested { margin-left: 18px; }
.mdc-main { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: #dfe7ef; }
.mdc-main > span:first-child { flex: none; max-width: 46%; overflow: hidden; color: #c8d3de; text-overflow: ellipsis; white-space: nowrap; }
.mdc-check > span { max-width: none !important; flex: 1 !important; }
.mdc-check input { position: absolute; opacity: 0; pointer-events: none; }
.mdc-check i {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(240, 199, 94, 0.7);
  border-radius: 3px;
  background: rgba(4, 8, 15, 0.7);
}
.mdc-check input:checked + i { background: #f0c75e; border-color: #f0c75e; }
.mdc-check input:checked + i::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid #241a02;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mdc-check input:focus-visible + i { outline: 2px solid rgba(240, 199, 94, 0.7); outline-offset: 2px; }
.mdc-check { cursor: pointer; }
.mdc-range input { flex: 1; min-width: 40px; accent-color: #f0c75e; }
.mdc-range b { flex: none; min-width: 34px; color: #f6e3a8; font: 650 10.5px ui-monospace, Consolas, monospace; text-align: right; }
.mdc-num input, .mdc-text input {
  flex: 1;
  min-width: 0;
  height: 20px;
  padding: 0 5px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.7);
  border: 1px solid rgba(240, 199, 94, 0.3);
  font: 11px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mdc-num input { max-width: 70px; }
.mdc-num em { color: #8a96a3; font-size: 10px; font-style: normal; }
.mdc-sws { display: flex; flex-wrap: wrap; gap: 3px; }
.kml-row .mdc .mdc-sw, .kml-controls .mdc .mdc-sw {
  width: 13px;
  min-width: 13px;
  height: 13px;
  padding: 0;
  background: var(--sw);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}
.kml-row .mdc .mdc-sw.is-on, .kml-controls .mdc .mdc-sw.is-on { box-shadow: 0 0 0 1.5px #0b1220, 0 0 0 3px #eaf4ff; }
.kml-row .mdc .mdc-sw--none, .kml-controls .mdc .mdc-sw--none { width: auto; padding: 0 4px; color: #a9bdd4; background: rgba(255, 255, 255, 0.06); font-size: 8.5px; }
.kml-row .mdc .mdc-chip, .kml-controls .mdc .mdc-chip {
  height: 18px;
  padding: 0 6px;
  color: #8fa0b4;
  background: transparent;
  border: 1px solid rgba(240, 199, 94, 0.25);
  border-radius: 9px;
  font-size: 9px;
}
.kml-row .mdc .mdc-chip.is-on, .kml-controls .mdc .mdc-chip.is-on { color: #241a02; background: #f0c75e; border-color: #f0c75e; }
.mdc-where { flex: none; max-width: 30%; overflow: hidden; color: #8a7d58; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.kml-row .mdc .mdc-go, .kml-row .mdc .mdc-unpin,
.kml-controls .mdc .mdc-go, .kml-controls .mdc .mdc-unpin {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 3px;
  color: #8a96a3;
  background: transparent;
  border: 1px solid transparent;
  opacity: 0;
  transition: opacity 0.12s;
}
.mdc:hover .mdc-go, .mdc:hover .mdc-unpin, .mdc:focus-within .mdc-go, .mdc:focus-within .mdc-unpin { opacity: 1; }
.kml-row .mdc .mdc-unpin:hover, .kml-controls .mdc .mdc-unpin:hover { color: #241a02; background: #f0c75e; }
.mdc-go svg, .mdc-unpin svg { display: block; width: 100%; height: 100%; }

/* =============================================================================================
   The Outputs board ON THE CANVAS (default) — a big metal node in the world: it pans and zooms
   with the graph, its jacks sit on its left edge like a node's ports. Docked, the same element
   is the column beside the canvas (the rules above).
   ============================================================================================= */

.mg-rail-top { display: flex; align-items: center; gap: 8px; }
.mg-rail-ctl { display: flex; gap: 4px; margin-left: auto; }
.mg-rail-btn {
  width: 22px;
  height: 20px;
  padding: 2px 3px;
  color: #a8b3bf;
  background: linear-gradient(180deg, #313841, #232930);
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
}
.mg-rail-btn svg { display: block; width: 100%; height: 100%; }
.mg-rail-btn:hover { color: #fff; }
.mg-rail-btn.is-on { color: #1a1406; background: linear-gradient(180deg, #f6d77a, #d9ae3d); }

.mg-rail.is-board {
  position: absolute;
  z-index: 1;
  width: 300px;
  border: 1px solid rgba(214, 226, 240, 0.3);
  border-radius: 12px;
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 8px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.15s;
}
.mg-rail.is-board::before { display: none; }
.mg-rail.is-board .mg-rail-head { border-radius: 11px 11px 0 0; }
.mg-rail.is-board .mg-rail-body { overflow: visible; padding-bottom: 16px; }
.mg-rail.is-board.is-free .mg-rail-head { cursor: grab; background: repeating-linear-gradient(135deg, rgba(240, 199, 94, 0.07) 0 6px, transparent 6px 12px); }
.mg-rail.is-board.is-dragging { box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(240, 199, 94, 0.6), 0 0 28px rgba(240, 199, 94, 0.25); }
.mg-rail.is-board.is-dragging .mg-rail-head { cursor: grabbing; }
/* Jacks on the plate's edge, the way a node's ports sit on its border. */
.mg-rail.is-board .mg-chan .mg-jack,
.mg-rail.is-board .mg-plug .mg-jack { left: -34px; }
.mg-rail.is-board .mg-jack.is-plugged::before { display: none; }

/* Only the board so far: the invitation keeps to the left of it. */
.mg-canvas.has-board .mg-empty { inset: 0 38% 0 0; }

/* =============================================================================================
   Measure — the node's summary and its table
   ============================================================================================= */

.mg-measure { display: flex; flex-direction: column; gap: 6px; }
.mg-measure-sum { color: #a9bdd4; font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.mg-measure-sum b { color: #eaf4ff; }
.mg-measure-top { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 0; list-style: none; }
.mg-measure-top li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px;
  border-radius: 4px;
  color: #cfe0f3;
  font-size: 11px;
  cursor: pointer;
}
.mg-measure-top li:hover { background: rgba(167, 139, 250, 0.12); }
.mg-measure-top li i { width: 8px; height: 8px; flex: none; border-radius: 2px; background: var(--c); }
.mg-measure-top li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-measure-top li b { flex: none; color: #eaf4ff; font: 650 10.5px ui-monospace, Consolas, monospace; }
.mg-measure-open { align-self: flex-start; }

.mg-mtable-host { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.mg-mtable {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 10, 18, 0.66);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  animation: mg-fade 0.16s ease-out;
}
.mg-mtable[hidden] { display: none; }
.mg-mt-card {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: min(760px, 100%);
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.99), rgba(10, 16, 27, 0.99));
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 30px rgba(167, 139, 250, 0.15);
  overflow: hidden;
  animation: mg-pop 0.2s cubic-bezier(.2, .9, .3, 1.1);
}
.mg-mt-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(120, 184, 255, 0.14);
}
.mg-mt-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.mg-mt-title b { color: #eaf4ff; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }
.mg-mt-title small { max-width: 260px; overflow: hidden; color: #8fa0b4; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mg-mt-search {
  flex: 1;
  min-width: 160px;
  height: 30px;
  padding: 0 10px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.85);
  border: 1px solid rgba(120, 184, 255, 0.3);
  border-radius: 7px;
  font: 12.5px "Segoe UI", system-ui, sans-serif;
  outline: none;
}
.mg-mt-search:focus { border-color: rgba(140, 196, 255, 0.75); }
.mg-mt-kinds { display: flex; gap: 4px; }
.mg-mt-kinds .mg-chip { --nc: var(--mg-op); }
.mg-mt-unit { display: flex; align-items: center; gap: 6px; color: #8fa0b4; font-size: 11px; }
.mg-mt-unit select {
  height: 26px;
  padding: 0 6px;
  color: #eaf4ff;
  background: rgba(4, 8, 15, 0.85);
  border: 1px solid rgba(120, 184, 255, 0.3);
  border-radius: 5px;
  font: 12px "Segoe UI", system-ui, sans-serif;
}
.mg-mt-unit select option { background: #0d1420; }
.mg-mt-scroll { flex: 1; min-height: 0; overflow: auto; }
.mg-mt-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.mg-mt-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 10px;
  color: #8fa0b4;
  background: #121b2b;
  border-bottom: 1px solid rgba(120, 184, 255, 0.2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.mg-mt-table th:hover { color: #eaf4ff; }
.mg-mt-table th.is-sorted { color: #d9cdff; }
.mg-mt-table td { padding: 5px 10px; color: #cfe0f3; border-bottom: 1px solid rgba(120, 184, 255, 0.07); white-space: nowrap; }
.mg-mt-table .is-num { text-align: right; }
.mg-mt-table tbody tr:hover td { background: rgba(167, 139, 250, 0.08); }
.mg-mt-table tr.is-picked td { background: rgba(167, 139, 250, 0.16); }
.mg-mt-pick { width: 28px; cursor: default; }
.mg-mt-pick input { accent-color: var(--mg-op); }
.mg-mt-name { max-width: 380px; }
.mg-mt-name > * { vertical-align: middle; }
.mg-mt-name i { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 2px; background: var(--c); }
.mg-mt-name span { display: inline-block; max-width: 300px; overflow: hidden; color: #eaf4ff; text-overflow: ellipsis; }
.mg-mt-name small, .mg-mt-table td small { margin-left: 6px; color: #75879c; font-size: 10.5px; }
.mg-mt-fly {
  width: 24px;
  height: 22px;
  padding: 0;
  color: #a9bdd4;
  background: transparent;
  border: 1px solid rgba(120, 184, 255, 0.18);
  border-radius: 4px;
  cursor: pointer;
}
.mg-mt-fly:hover { color: #fff; border-color: rgba(140, 196, 255, 0.6); background: rgba(61, 139, 255, 0.2); }
.mg-mt-none, .mg-mt-more { padding: 14px; color: #75879c; font-size: 11.5px; text-align: center; }
.mg-mt-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid rgba(120, 184, 255, 0.14);
  color: #a9bdd4;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.mg-mt-foot b { color: #eaf4ff; }
.mg-mt-picked { color: #d9cdff; font-weight: 650; }
.mg-mt-hint { color: #64768b; font-size: 11px; }

.mg-v-tip-size { display: block; margin-top: 3px; color: #cfe0f3; font-size: 11px; }
.mg-v-tip-size b { color: #f0f6ff; }

/* =============================================================================================
   Zones library: on the globe or only in the library, picking several, bulk actions
   ============================================================================================= */

.mg-lib-row .mg-lib-eye { opacity: 1; padding: 3px; }
.mg-lib-eye svg { display: block; width: 100%; height: 100%; }
.mg-lib-eye.is-on { color: #cfe3ff; }
.mg-lib-eye:not(.is-on) { color: #64768b; border-color: transparent; }
.mg-lib-row.is-shelved .mg-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--dot, #6eb0ff); }
.mg-lib-row.is-shelved .mg-lib-name { color: #a9bdd4; }
.mg-lib-row.is-selecting { cursor: pointer; }
.mg-lib-row.is-picked { background: rgba(61, 139, 255, 0.16); border-color: rgba(140, 196, 255, 0.4); }
.mg-lib-pick { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.mg-lib-pick input { position: absolute; opacity: 0; pointer-events: none; }
.mg-lib-pick i {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(143, 170, 200, 0.6);
  border-radius: 3px;
  background: rgba(4, 8, 15, 0.7);
}
.mg-lib-pick input:checked + i { background: var(--blue-400, #6eb0ff); border-color: var(--blue-400, #6eb0ff); }
.mg-lib-pick input:checked + i::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid #04121f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mg-zsel-btn.is-on { color: #eaf4ff; background: rgba(61, 139, 255, 0.28); border-color: rgba(140, 196, 255, 0.65); }
.mg-zbulk {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 7px;
  background: rgba(61, 139, 255, 0.08);
  border: 1px solid rgba(120, 184, 255, 0.22);
  border-radius: 7px;
}
.mg-zbulk[hidden] { display: none; }
.mg-zbulk-n { color: #a9bdd4; font-size: 11px; margin-right: 2px; }
.mg-zbulk-n b { color: #eaf4ff; }
.mg-zb {
  height: 22px;
  min-width: 22px;
  padding: 0 7px;
  color: #cfe0f3;
  background: rgba(70, 120, 180, 0.12);
  border: 1px solid rgba(120, 184, 255, 0.24);
  border-radius: 5px;
  font: 650 10.5px "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mg-zb svg { display: block; width: 14px; height: 14px; }
.mg-zb:hover:not(:disabled) { color: #fff; border-color: rgba(140, 196, 255, 0.55); background: rgba(61, 139, 255, 0.22); }
.mg-zb:disabled { opacity: 0.4; cursor: default; }
.mg-zb--del:hover:not(:disabled) { border-color: rgba(255, 120, 110, 0.6); background: rgba(255, 90, 80, 0.2); }
.mg-zb--del.is-armed { color: #fff; background: rgba(255, 90, 80, 0.6); border-color: rgba(255, 140, 130, 0.85); }
