* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: sans-serif;
  overflow: hidden;
}

/* ── Main split ── */

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Output panel (left 50%) ── */

#output-panel {
  width: 50%;
  position: relative;
  border-right: 1px solid #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#output-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* ── Graph panel (right 50%) ── */

#graph-panel {
  width: 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


#graph-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid #000;
  flex-shrink: 0;
  position: relative;
}


/* graph-surface clips graph-container's 6000x6000 expanse */

#graph-surface {
  flex: 1;
  overflow: hidden;
  position: relative;
}

body.tidy-mode #graph-surface {
  cursor: alias;
}

#graph-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 6000px;
  transform-origin: top left;
  background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='4' height='4' fill='%23cccccc'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ── Nodes Menu ── */

#nodes-menu {
  position: absolute;
  background: rgba(237, 210, 221, 1);
  border: 1px solid #000;
  border-radius: 4px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  margin: 1rem;
}

#buttons-help {
  position: absolute;
  background: rgba(210, 221, 237, 1);
  border: 1px solid #000;
  border-radius: 4px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  max-width: 300px;
  margin: 1rem;
  padding: 0.5rem;
}

.nodes-menu-heading {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.5rem 0.2rem;
  color: #666;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

button {
  padding: 0.1rem 0.2rem;
}

#nodes-menu button {
  margin: 0.5rem;
}

/* ── Nodes ── */

.node {
  position: absolute;
  border: 1px solid #000;
  background: rgba(173, 216, 230, 0.95);
  user-select: none;
}

.node-header {
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: bold;
  border-bottom: 1px solid #000;
  cursor: grab;
}

body.delete-mode .node-header {
  cursor: not-allowed;
}

body.string-mode .node-header {
  cursor: cell !important;
}

body.string-mode .port-circle {
  cursor: cell !important;
}

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

.node-body {
  position: relative;
  pointer-events: none;
}

/* ports span the full node width, positioned absolutely within node-body */

.port {
  position: absolute;
  left: 0;
  width: 160px;
  height: 16px;
  display: flex;
  align-items: center;
}

/* port circles sit on the node edges */

.port-circle {
  position: absolute;
  top: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #000;
  background: #fff;
  cursor: crosshair;
  pointer-events: all;
}

.port-input .port-circle  { left:  -8px; }
.port-output .port-circle { right: -8px; }

.port-label {
  font-size: 9px;
  white-space: nowrap;
  pointer-events: none;
}

.port-label-input  { margin-left:  20px; }
.port-label-output { margin-left: auto; margin-right: 20px; }

/* ── Strings ── */

.string-delete {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 1px solid #000;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

/* ── Bottom bar ── */

#bottom-bar {
  display: flex;
  border-top: 1px solid #000;
}

#bottom-left {
  width: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

#bottom-right {
  width: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

body.view-mode .node         { cursor: help !important; }
body.view-mode .node-header { cursor: help !important; }

.node.view-hover::after {
  content: attr(data-view-label);
  position: absolute;
  top: -28px;
  left: 0;
  background: #111;
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  pointer-events: none;
  white-space: nowrap;
}

.node.view-pinned {
  outline: 2px solid #DFA0B8;
}