/* Node outline refinements and SVG wires. */
/* Rounded outer node and inner header; keep overflow visible for menus and ports. */
.graph-node {
  border-radius: 9px;
  overflow: visible;
}
.graph-node > .node-head {
  border-radius: 8px 8px 0 0;
}
.graph-node > .node-inline-properties:last-child {
  border-radius: 0 0 8px 8px;
}
.graph-node > .node-inline-properties:not([open]) {
  padding-bottom: 8px;
}
/* 0.40: infinite SVG wire coordinates and focus stacking. */
#wires {
  overflow: visible !important;
  width: 1px !important;
  height: 1px !important;
  contain: none;
}
#graph-content {
  overflow: visible;
}
#nodes-layer {
  overflow: visible;
}
.graph-node {
  z-index: 3;
}
.graph-node.selected {
  z-index: 3;
}
.graph-node.dragging {
  z-index: 3;
}
.material-studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #05090cdb;
  display: grid;
  place-items: center;
  padding: 20px;
}
.material-studio-dialog {
  width: min(900px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #19232e;
  border: 1px solid #5c7586;
  border-radius: 12px;
  box-shadow: 0 24px 70px #000b;
}
.material-studio-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #3c4c5c;
}
.material-studio-header strong {
  font-size: 19px;
}
.material-studio-header span {
  flex: 1;
  color: #9aabb8;
}
.material-studio-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}
.material-studio-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.material-studio-list button {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
}
.material-studio-list button.active {
  border-color: #8dc7a3;
  background: #2d4b43;
}
.material-studio-chip {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid #fff5;
  flex-shrink: 0;
}
.material-studio-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.material-studio-fields > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.material-studio-preview {
  width: 256px;
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid #536477;
  border-radius: 8px;
  image-rendering: auto;
}
.material-studio-number {
  display: grid;
  grid-template-columns: 1fr 1.2fr 90px 38px;
  gap: 8px;
  align-items: center;
}
.material-studio-number input {
  min-width: 0;
  width: 100%;
}
.material-studio-launch {
  border-color: #8dc7a3;
  color: #c9f5da;
}
@media (max-width: 650px) {
  .material-studio-layout {
    grid-template-columns: 1fr;
  }
  .material-studio-list {
    max-height: 140px;
    overflow: auto;
  }
  .material-studio-number {
    grid-template-columns: 1fr 90px 38px;
  }
  .material-studio-number label {
    grid-column: 1/-1;
  }
}

/* Base and temporary wire overlays; established edges use ranked SVG layers. */
#wires-overlay, #wires-focus-overlay {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  contain: none;
  z-index: 1;
  pointer-events: none;
}
#wires-overlay *, #wires-focus-overlay * { pointer-events: none; }

/* Temporary wire overlay baseline. */
#wires { z-index: 0; }
#wires-focus-overlay { z-index: 2; }
#wires-overlay { display: block; }
.parameter-link-wire {fill:none;stroke:#d47777;stroke-width:2;stroke-dasharray:5 4;pointer-events:stroke;cursor:pointer;}
.parameter-link-wire.highlighted {stroke:#ffaaaa;stroke-width:3;}
.parameter-link-drag {pointer-events:none;}
.parameter-link-ports {padding:4px 8px;color:#e0a0a0;font-size:11px;}
.parameter-link-port-row {display:flex;align-items:center;gap:5px;}
.parameter-link-port {color:#e58b8b;cursor:crosshair;padding:1px 5px;touch-action:none;}
.parameter-link-controls {display:flex;flex-wrap:wrap;gap:4px;align-items:center;min-width:0;}
.parameter-link-controls select,.parameter-link-controls input {min-width:0;max-width:100%;}
.parameter-link-controls input {width:75px;}
#wires-overlay .parameter-link-wire, #wires-focus-overlay .parameter-link-wire {pointer-events:stroke;}
#wires-overlay .parameter-link-drag, #wires-focus-overlay .parameter-link-drag {pointer-events:none;}
#group-boundaries:not([hidden]) {margin:3px 0;padding:5px 9px;}
#node-properties .parameter-link-controls {width:100%;}
#node-properties .parameter-link-controls select {flex:1 1 100px;}
.parameter-link-port-row:has([data-parameter-target]) {cursor:crosshair;}
.parameter-link-port.parameter-drop-hover {background:#843e42;color:white;outline:2px solid #ffaaaa;}
 .parameter-hub {padding-bottom:8px;}
.parameter-hub > button {margin:6px 8px;display:block;}
.parameter-hub-row {display:grid;grid-template-columns:64px minmax(0,1fr) 24px 20px;gap:5px;padding:5px 8px;align-items:center;}
.parameter-hub-row input {min-width:0;width:100%;box-sizing:border-box;}
.parameter-hub-row input[type=text] {text-align:right;background:#151e27;border:1px solid #687889;}
.parameter-hub-row input[type=text]:focus {border-color:#e58b8b;}
.parameter-hub-pending {text-align:center;color:#8795a3;}
.parameter-link-port-row {min-height:24px;}

.parameter-link-port {width:14px;height:14px;min-width:14px;padding:0;border:1px solid #e58b8b;border-radius:2px;background:#202832;flex-shrink:0;}
.parameter-link-port[data-hub-source], .parameter-link-port[data-linked="true"] {background:#d47777;}
.parameter-hub {border-color:#a65c60;}
.parameter-hub.selected {border-color:#e58b8b;box-shadow:0 0 0 1px #e58b8b,0 9px 20px #0007;}

/* Neighbor emphasis does not change stack order. */
.graph-node:is(.data-neighbor, .parameter-neighbor):not(.selected):not(.dragging) {
  outline: 1px solid #8dc7a3;
  outline-offset: 1px;
}
.graph-node.parameter-neighbor:not(.selected):not(.dragging) { outline-color: #d47777; }

/* Nodes and ranked SVGs share the graph stacking context. */
#nodes-layer { z-index: auto; }

.parameter-hub.selected, .parameter-hub.dragging { z-index: 2000; }

/* Interleave connection SVGs and node bodies in the same stacking context. */
.stacked-wire { position:absolute; inset:0; width:1px; height:1px; overflow:visible; pointer-events:none; }
.stacked-wire .wire-hit, .stacked-wire .parameter-link-wire { pointer-events:stroke; }

.graph-selection-frame { z-index: 2147483647; }

/* Evaluation diagnostics are independent of selection and mascot visibility. */
.evaluation-error-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 19px;
  height: 19px;
  margin-left: 6px;
  border-radius: 50%;
  background: #b82d3b;
  color: white;
  font-weight: bold;
  cursor: help;
}
.required-port-warning { color: #ff626b; font-weight: bold; flex: none; cursor: help; }

.parameter-hub-settings {padding:0; min-width:0; height:24px;}
.parameter-hub-controls {display:flex; flex-wrap:wrap; align-items:center; gap:5px; padding:4px 8px 8px; }
.parameter-hub-controls label {display:flex; align-items:center; gap:4px; font-size:11px;}
.parameter-hub-controls input[type=number] {width:85px; min-width:0;}
/* Optional per-instance presentation; default category styling remains intact. */
.graph-node.custom-node-appearance:not(.boundary-node) > .node-head {
  background: linear-gradient(90deg, color-mix(in srgb, var(--custom-node-color) 65%, #18212b), #31404e);
  border-top: 3px solid var(--custom-node-color);
  color: #f1f5f9;
}
.custom-node-icon { margin-right: .45em; }
.node-appearance-dialog { color: #e8edf2; background: #202a34; border: 1px solid #526273; border-radius: 9px; padding: 20px; min-width: 290px; }
.node-appearance-dialog::backdrop { background: #0008; }
.node-appearance-dialog form { display: grid; gap: 12px; }
.node-appearance-dialog h3 { margin: 0; }
.node-appearance-dialog label { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.appearance-swatches, .appearance-actions { display: flex; gap: 6px; }
.appearance-swatches button { width: 28px; height: 28px; border: 1px solid #a0aab5; padding: 0; }
.appearance-actions { justify-content: flex-end; }

/* Library update action: native keyboard activation, independent of node drag. */
.node-head > .library-update-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 6px;
  padding: 0 5px;
  min-width: 24px;
  min-height: 24px;
  border: 1px solid #b89960;
  border-radius: 4px;
  background: #252b30;
  color: #f1ce82;
  font: inherit;
  cursor: pointer;
}
.node-head > .library-update-button:hover { background: #4b4333; }
.node-head > .library-update-button:focus-visible { outline: 2px solid #f1ce82; outline-offset: 2px; }
.parameter-range-controls {display:grid; grid-template-columns:1fr; gap:5px; width:100%;}
.parameter-range-controls label {justify-content:space-between;}
