.nfe {
  --nfe-bg: #e7e7e2;
  --nfe-grid: rgba(45, 48, 43, 0.09);
  --nfe-panel: #fafaf7;
  --nfe-panel-border: #b2b7ac;
  --nfe-header: #e1e4dc;
  --nfe-text: #252b26;
  --nfe-muted: #656e61;
  --nfe-label: #353d32;
  --nfe-edge: #707969;
  --nfe-accent: #434ad8;
  --nfe-focus: #434ad8;
  --nfe-success: #d4e5d8;
  --nfe-warning: #f1dfc5;
  --nfe-error: #f0d5cf;
  --nfe-tag-bg: #e9ece4;
  position: relative;
  color: var(--nfe-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.nfe *,
.nfe *::before,
.nfe *::after {
  box-sizing: border-box;
}

.nfe-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 18px;
  margin: 0 2px 13px;
  color: #707a6a;
  font-size: 10px;
  line-height: 1.4;
}

.nfe-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.nfe-legend-mark {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 10px;
  flex: 0 0 18px;
}

.nfe-legend-mark.line::before {
  position: absolute;
  top: 4px;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: var(--border-radius, 7px);
  background: #788172;
  content: "";
}

.nfe-legend-mark.line.highlight::before {
  height: 3px;
  background: var(--nfe-accent);
}

.nfe-legend-mark.port::before,
.nfe-legend-mark.port.free::before {
  position: absolute;
  top: 1px;
  left: 4px;
  width: 8px;
  height: 8px;
  border: 1.5px solid #909a87;
  border-radius: var(--border-radius, 7px);
  background: var(--nfe-bg);
  content: "";
}

.nfe-legend-mark.port.free::before {
  border-color: #465040;
  background: #465040;
}

.nfe-legend-mark.node::before {
  position: absolute;
  inset: 1px 2px;
  border-radius: var(--border-radius, 7px);
  background: #697463;
  content: "";
}

.nfe-legend-mark.node.inactive::before {
  opacity: 0.4;
}

.nfe-legend-mark.tag::before {
  position: absolute;
  top: 2px;
  left: 1px;
  width: 16px;
  height: 6px;
  border-radius: var(--border-radius, 7px);
  background: #737e6b;
  content: "";
}

.nfe-legend-mark.state::before {
  position: absolute;
  inset: 1px 3px;
  border-radius: var(--border-radius, 7px);
  background: linear-gradient(90deg, var(--nfe-success) 0 33%, var(--nfe-warning) 33% 66%, var(--nfe-error) 66%);
  content: "";
}

.nfe-stage {
  position: relative;
  width: 100%;
  min-height: 400px;
  height: max(460px, calc(100dvh - var(--nfe-top-offset, 350px)));
  overflow: hidden;
  border: 1px solid #c9cec1;
  border-radius: var(--border-radius, 7px);
  background: var(--nfe-bg);
  box-shadow: 0 18px 48px rgba(27, 34, 24, 0.07);
}

.nfe-stage:focus-visible {
  outline: 3px solid var(--nfe-focus);
  outline-offset: 3px;
}

.nfe-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: var(--border-radius, 7px);
  background: var(--nfe-bg);
}

.nfe-stage.nfe-fullscreen {
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: var(--border-radius, 7px);
  background: var(--nfe-bg);
}

body.nfe-fullscreen-open {
  overflow: hidden;
}

.nfe-svg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.nfe-is-interacting .nfe-svg {
  cursor: grabbing;
}

.nfe-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  padding: 3px;
  border: 1px solid #c9cec1;
  border-radius: var(--border-radius, 7px);
  background: rgba(250, 250, 247, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
  backdrop-filter: blur(9px);
}

.nfe-toolbar button {
  display: inline-grid;
  width: 35px;
  min-width: 35px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--border-radius, 7px);
  color: #252b26;
  background: transparent;
  font: 600 15px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.nfe-toolbar button:hover {
  background: #e4e7df;
}

.nfe-toolbar button:focus-visible {
  outline: 2px solid var(--nfe-focus);
  outline-offset: -2px;
}

.nfe-bg {
  fill: var(--nfe-bg);
}

.nfe-grid {
  pointer-events: none;
}

.nfe-edge {
  fill: none;
  stroke: var(--nfe-edge);
  stroke-width: 2.2;
  opacity: 0.82;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.nfe-edge-highlight {
  stroke: var(--nfe-accent);
  stroke-width: 3;
  opacity: 1;
}

.nfe-edge-dimmed {
  opacity: 0.24;
}

.nfe-node {
  cursor: default;
  outline: none;
}

.nfe[data-mode="layout"] .nfe-node {
  cursor: grab;
}

.nfe[data-mode="layout"] .nfe-node.nfe-node-dragging {
  cursor: grabbing;
}

.nfe-node-shell {
  fill: var(--nfe-panel);
  stroke: var(--nfe-panel-border);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.nfe-node-header {
  fill: var(--nfe-header);
}

.nfe-node-tag-bg {
  fill: var(--nfe-tag-bg);
}

.nfe-node-title {
  fill: var(--nfe-text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nfe-node-label {
  fill: var(--nfe-label);
  font-size: 12px;
}

.nfe-node-tag {
  fill: #1f261d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 650;
}

.nfe-port {
  fill: var(--nfe-bg);
  stroke: #777780;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.nfe-port-connected {
  stroke: var(--nfe-edge);
}

.nfe-port-highlight {
  stroke: var(--nfe-accent);
  stroke-width: 2.6;
}

.nfe-node[data-state="success"] .nfe-node-header {
  fill: var(--nfe-success);
}

.nfe-node[data-state="warning"] .nfe-node-header {
  fill: var(--nfe-warning);
}

.nfe-node[data-state="error"] .nfe-node-header {
  fill: var(--nfe-error);
}

.nfe-node[data-state="inactive"] {
  opacity: 0.38;
}

.nfe-node:hover .nfe-node-shell,
.nfe-node-selected .nfe-node-shell {
  stroke: var(--nfe-accent);
  stroke-width: 2.5;
}

.nfe-node:focus-visible .nfe-node-shell {
  stroke: var(--nfe-focus);
  stroke-width: 3;
}

.nfe-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.nfe-theme-light {
  --nfe-bg: #f5f5f2;
  --nfe-grid: rgba(0, 0, 0, 0.07);
  --nfe-panel: #e4e4df;
  --nfe-panel-border: #9a9a92;
  --nfe-header: #666661;
  --nfe-text: #ffffff;
  --nfe-muted: #383834;
  --nfe-label: #20201d;
  --nfe-edge: #565650;
  --nfe-focus: #563ad8;
}

@media (max-width: 700px) {
  .nfe-stage {
    min-height: 430px;
    height: max(460px, 70dvh);
  }

  .nfe-legend {
    gap: 8px 13px;
    font-size: 9px;
  }

  .nfe-toolbar {
    top: 8px;
    right: 8px;
  }

  .nfe-toolbar button {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }
}

@media (prefers-contrast: more) {
  .nfe {
    --nfe-panel-border: #343c30;
    --nfe-edge: #343c30;
  }

  .nfe-edge {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nfe *,
  .nfe *::before,
  .nfe *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  .nfe-toolbar {
    display: none !important;
  }

  .nfe-legend {
    color: #333;
  }

  .nfe-stage {
    height: 620px;
    border-color: #777;
    box-shadow: none;
  }
}


/* Logical canvas uses readable pixel sizes; overflow stays inside the frame. */
.nfe-scroll{position:absolute;inset:0;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain}
.nfe-scroll>.nfe-svg{max-width:none;max-height:none;flex:none}
.nfe-layout-label{margin:0 0 10px;color:var(--muted,#777c76);font-size:11px}
.campaign-detail .nfe-stage{height:max(440px,62dvh)}
.nfe-port:not(.nfe-port-connected){fill:var(--nfe-edge);stroke:none}

.nfe-scroll{scrollbar-color:#9ca494 #e7e7e2}.nfe-scroll::-webkit-scrollbar{width:12px;height:12px}.nfe-scroll::-webkit-scrollbar-track{background:#e7e7e2}.nfe-scroll::-webkit-scrollbar-thumb{background:#9ca494;border:3px solid #e7e7e2;border-radius:var(--border-radius,7px)}.nfe-scroll::-webkit-scrollbar-corner{background:#e7e7e2}
