/* ============================================================================
 * Motion Graph editor (js/live/motion-graph-panel.js), the Scene look sliders
 * and tint layer (js/fx/scene-look.js).
 * Port / wire colours by data type: value = cyan, hits = accent, colour = gold.
 * ========================================================================== */
:root { --mg-value: #3ce8ff; --mg-trigger: #ff3c78; --mg-color: #ffd166; }

/* ---------- scene look ------------------------------------------------------- */
#lookTint { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color; opacity: 0; }
#canvas, #glCanvas { transform-origin: 50% 50%; }
.look-row label { width: 112px; }
.look-sub { margin: var(--space-3) 0 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
#lookPanel .action-btn { margin-top: var(--space-2); }
.lk-color { width: 44px; height: 30px; padding: 0; border: 1px solid var(--hairline-2); border-radius: 6px; background: none; cursor: pointer; }

/* ---------- list ----------------------------------------------------------------- */
.mg-list .lk-top { gap: 6px; }
.mg-list .live-mini { min-height: 34px; min-width: 34px; padding: 0 8px; }
.mg-new .tts-select { flex: 1; margin: 0; }

/* ---------- editor shell ----------------------------------------------------------- */
body.mg-open { overflow: hidden; }
.mg-editor {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  background: #08080a; color: var(--ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.mg-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--hairline-2);
  background: rgba(14, 14, 16, .96); flex-wrap: wrap;
}
.mg-x {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--hairline-2); background: var(--surface-3);
  color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer;
}
.mg-name {
  flex: 0 1 240px; min-width: 120px; height: 36px; padding: 0 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
}
.mg-name:hover, .mg-name:focus { border-color: var(--hairline-2); background: var(--surface-3); outline: none; }
.mg-sp { flex: 1; }
.mg-btn {
  height: 36px; min-width: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--hairline-2);
  background: var(--surface-4); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mg-btn:hover:not(:disabled) { background: var(--surface-5); color: var(--ink); }
.mg-btn:disabled { opacity: .35; cursor: default; }
.mg-add { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.mg-del:not(:disabled) { color: var(--err); }
.mg-legend {
  display: flex; gap: 14px; align-items: center; padding: 6px 14px; font-size: 11px; color: var(--ink-3);
  border-bottom: 1px solid var(--hairline); overflow: hidden; white-space: nowrap;
}
.mg-legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.mg-legend .t-value::before { background: var(--mg-value); }
.mg-legend .t-trigger::before { background: var(--mg-trigger); }
.mg-legend .t-color::before { background: var(--mg-color); }
.mg-legend em { font-style: normal; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; }
.mg-legend em.bad { color: var(--err); font-weight: 600; }

/* ---------- canvas ------------------------------------------------------------------ */
.mg-stage {
  position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab;
  background-color: #08080a;
  background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: calc(24px * var(--zoom, 1)) calc(24px * var(--zoom, 1));
}
.mg-stage:active { cursor: grabbing; }
.mg-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mg-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.mg-wire { fill: none; stroke-width: 2.5; opacity: .85; stroke: var(--mg-value); }
.mg-wire.t-trigger { stroke: var(--mg-trigger); }
.mg-wire.t-color { stroke: var(--mg-color); }
.mg-wire.sel { stroke-width: 4.5; opacity: 1; filter: drop-shadow(0 0 6px currentColor); }
.mg-wire.temp { stroke-dasharray: 6 5; }
.mg-wire.temp.bad { stroke: var(--err); }
.mg-wire-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.mg-empty {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); max-width: 340px; margin: 0;
  text-align: center; color: var(--ink-3); font-size: 14px; line-height: 1.5; pointer-events: none;
}

/* ---------- nodes ---------------------------------------------------------------------- */
.mg-node {
  --g: var(--ink-4);
  position: absolute; border-radius: 12px; background: rgba(22, 22, 26, .97); border: 1px solid var(--hairline-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: 12px; cursor: default; user-select: none;
}
.mg-node.g-sources { --g: #7affb6; }
.mg-node.g-shape { --g: #5ac8fa; }
.mg-node.g-logic { --g: #b388ff; }
.mg-node.g-colour { --g: #ffd166; }
.mg-node.g-outputs { --g: #ff3c78; }
.mg-node.sel { border-color: var(--g); box-shadow: 0 0 0 1px var(--g), 0 10px 30px rgba(0, 0, 0, .5); }
.mg-node-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: move; touch-action: none;
  border-bottom: 1px solid var(--hairline); border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--g) 22%, transparent), transparent);
}
.mg-node-head b { flex: 1; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.mg-scope { flex: 0 0 46px; height: 6px; border-radius: 3px; background: var(--surface-5); overflow: hidden; }
.mg-scope i { display: block; height: 100%; width: 0; background: var(--g); border-radius: 3px; }
.mg-ports { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; }
.mg-ins, .mg-outs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mg-outs { align-items: flex-end; }
.mg-port {
  --t: var(--mg-value);
  display: flex; align-items: center; gap: 6px; height: 22px; color: var(--ink-3); font-size: 11px; cursor: crosshair; touch-action: none;
}
.mg-port.t-trigger { --t: var(--mg-trigger); }
.mg-port.t-color { --t: var(--mg-color); }
.mg-port i {
  flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--t); background: #16161a;
  box-sizing: border-box;
}
.mg-port.in { margin-left: -7px; }
.mg-port.out { margin-right: -7px; }
.mg-port.in.wired i, .mg-port.out i { background: var(--t); }
.mg-port:hover i { box-shadow: 0 0 0 4px color-mix(in srgb, var(--t) 30%, transparent); }
.mg-port span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-fields { display: grid; gap: 6px; padding: 4px 10px 10px; }
.mg-f { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; color: var(--ink-3); font-size: 11px; }
.mg-f > span { grid-column: 1 / -1; }
.mg-f input[type="range"] { width: 100%; margin: 0; accent-color: var(--g); }
.mg-f output { font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); min-width: 32px; text-align: right; }
.mg-f select, .mg-f .mg-in {
  grid-column: 1 / -1; height: 28px; border-radius: 7px; border: 1px solid var(--hairline-2); background: var(--surface-3);
  color: var(--ink); font: inherit; font-size: 12px; padding: 0 6px; min-width: 0;
}
.mg-f select option { background: #111; }
.mg-f input[type="color"] { grid-column: 1 / -1; width: 100%; height: 28px; padding: 0; border: 1px solid var(--hairline-2); border-radius: 7px; background: none; cursor: pointer; }
.mg-pickbtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 6px 8px; text-align: left;
  border-radius: 8px; border: 1px solid var(--hairline-2); background: var(--surface-3); color: inherit; font: inherit; cursor: pointer;
}
.mg-pickbtn:hover { border-color: var(--g); }
.mg-pickbtn small { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-4); }
.mg-pickbtn b { font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- picker ---------------------------------------------------------------------- */
.mg-pick {
  position: absolute; z-index: 5; right: 12px; top: 64px; bottom: 12px; width: min(380px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-radius: 14px;
  background: #101013; border: 1px solid var(--hairline-2); box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.mg-pick[hidden] { display: none; }
.mg-pick-head { display: flex; align-items: center; justify-content: space-between; }
.mg-pick-head b { font-size: 15px; }
.mg-pick-search { margin: 0; }
.mg-pick-list { overflow-y: auto; flex: 1; }
.mg-pick-group h4 { margin: 10px 0 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-4); }
.mg-pick-opt {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 10px; margin-bottom: 4px; text-align: left; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--hairline); background: var(--surface-3); color: inherit; font: inherit;
}
.mg-pick-opt:hover { border-color: var(--accent); }
.mg-pick-opt b { font-size: 13px; font-weight: 600; }
.mg-pick-opt small { font-size: 11px; color: var(--ink-3); }

@media (max-width: 767px) {
  .mg-legend em:not(.bad) { display: none; }
  .mg-name { flex-basis: 140px; }
  .mg-pick { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 72vh; border-radius: 16px 16px 0 0; }
}
