.constructor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: hidden;
  overflow-y: auto;
}

.constructor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  flex-shrink: 0;
}

.constructor-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #f8fafc;
}

.constructor-back {
  color: #7dd3fc;
  text-decoration: none;
  font-size: 0.95rem;
}

.constructor-back:hover {
  text-decoration: underline;
}

.constructor-logout {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e2e8f0;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.constructor-lead {
  max-width: 56rem;
  margin: 0.75rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #94a3b8;
  flex-shrink: 0;
}

.constructor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 0.75rem;
  flex-shrink: 0;
}

.constructor-toolbar-sep {
  display: inline-block;
  width: 1px;
  height: 1.25rem;
  background: rgba(148, 163, 184, 0.35);
  margin: 0 0.15rem;
}

.constructor-btn-secondary {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.constructor-btn-secondary:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.55);
}

.constructor-toolbar .msg {
  margin: 0;
  color: #86efac;
}

.constructor-toolbar .msg.err {
  color: #fca5a5;
}

.constructor-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 1rem 1rem;
}

.constructor-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background-color: #0c1222;
  background-image: linear-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: auto;
}

.constructor-layer {
  position: relative;
  width: 2000px;
  height: 1400px;
}

.constructor-edges-svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 2000px;
  height: 1400px;
  pointer-events: none;
  z-index: 1;
}

.constructor-edges-svg path.constructor-edge-path {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2;
  opacity: 0.9;
  marker-end: url(#constructor-edge-arrow);
}

.constructor-edges-svg path.constructor-link-preview {
  fill: none;
  stroke: #a5f3fc;
  stroke-width: 2;
  stroke-dasharray: 8 6;
  opacity: 0.95;
  pointer-events: none;
}

body.constructor-link-dragging {
  cursor: crosshair;
  user-select: none;
}

body.constructor-link-dragging .constructor-canvas-wrap {
  cursor: crosshair;
}

.constructor-node.constructor-drop-target {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
}

.constructor-edges-svg text.constructor-edge-label {
  fill: #e2e8f0;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  paint-order: stroke fill;
  stroke: #0c1222;
  stroke-width: 3px;
  pointer-events: none;
}

.constructor-node {
  position: absolute;
  z-index: 2;
  width: 260px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: grab;
}

.constructor-node.is-selected {
  border-color: #e879f9;
  box-shadow: 0 0 0 2px rgba(232, 121, 249, 0.35);
}

.constructor-node.constructor-node--start {
  border-color: rgba(34, 197, 94, 0.45);
  background: linear-gradient(180deg, #162e21 0%, #0f172a 100%);
}

.constructor-node:active {
  cursor: grabbing;
}

.constructor-node-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px 10px 0 0;
}

.constructor-node-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #f1f5f9;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.constructor-node-edit {
  margin-left: auto;
  border: none;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.constructor-node-edit:hover {
  background: rgba(56, 189, 248, 0.28);
}

.constructor-node-preview {
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #94a3b8;
  max-height: 4.5em;
  overflow: hidden;
}

.constructor-node-ports {
  padding: 6px 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.constructor-port-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.constructor-port-row:last-child {
  margin-bottom: 0;
}

.constructor-port-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.constructor-port-out {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  background: #0f172a;
  cursor: grab;
  padding: 0;
}

.constructor-port-out.is-pending {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.5);
}

.constructor-port-out:hover {
  background: #38bdf8;
}

.constructor-port-in {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #64748b;
  background: #0f172a;
  cursor: default;
  box-sizing: border-box;
  opacity: 0.55;
}

.constructor-port-in:hover {
  border-color: #38bdf8;
  background: #164e63;
}

.menu-modes-wrap {
  margin-top: 0.75rem;
}

.menu-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2vh 1rem;
  box-sizing: border-box;
}

.menu-modal.hidden {
  display: none;
}

.menu-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.menu-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  max-height: 96vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #111;
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.menu-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #e5e5e5);
}

.menu-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.menu-modal-close {
  border: none;
  background: #f3f4f6;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.menu-modal-body {
  overflow: auto;
  padding: 0.75rem 1rem 1.25rem;
  max-height: calc(96vh - 56px);
}

.constructor-modal-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.constructor-modal-section:last-of-type {
  border-bottom: none;
}

.constructor-modal-section.is-highlight {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 4px;
  border-radius: 8px;
}

.constructor-modal-section.constructor-modal-section--hidden {
  display: none !important;
}
