*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #1a1a2e;
  --bg-panel: #16213e;
  --bg-node: #0f3460;
  --bg-node-header: #533483;
  --color-text: #e0e0e0;
  --color-muted: #888;
  --color-accent: #e94560;
  --color-border: #2a2a4a;
  --color-port-in: #4fc3f7;
  --color-port-out: #81c784;
  --color-edge: #6a6a9a;
  --color-edge-hover: #aaaaff;
  --node-width: 200px;
  --port-size: 12px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: var(--color-text);
}

/* ── Toolbar ── */
#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 100;
}

#toolbar h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-right: 16px;
  letter-spacing: 0.5px;
}

.toolbar-btn {
  background: var(--bg-node);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 5px 14px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.toolbar-btn:hover {
  background: var(--bg-node-header);
  border-color: var(--color-accent);
}

.toolbar-btn--accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  font-weight: 600;
}

.toolbar-btn--accent:hover {
  background: #c73652;
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 4px;
}

#zoom-label {
  font-size: 11px;
  color: var(--color-muted);
  min-width: 44px;
  text-align: right;
}

.toolbar-select {
  background: var(--bg-node);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.toolbar-select:hover,
.toolbar-select:focus {
  border-color: var(--color-accent);
  background: var(--bg-node-header);
}

/* ── Canvas ── */
#canvas-container {
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
}

#canvas-svg {
  width: 100%;
  height: 100%;
  cursor: default;
  display: block;
}

#canvas-svg.panning {
  cursor: grabbing;
}

/* Grid background via SVG pattern — defined inline in canvas.js */

/* ── Nodes (rendered as foreignObject > div) ── */
.node {
  width: var(--node-width);
  background: var(--bg-node);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: visible;
  user-select: none;
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.node:hover {
  border-color: #4a4a6a;
}

.node.selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(233,69,96,0.3), 0 4px 16px rgba(0,0,0,0.4);
}

.node__header {
  padding: 7px 10px;
  border-radius: 7px 7px 0 0;
  font-weight: 600;
  font-size: 12px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 6px;
}

.node__header:active {
  cursor: grabbing;
}

.node__header-icon {
  font-size: 14px;
}

.node__body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Ports ── */
.node__ports {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node__port-row {
  display: flex;
  align-items: center;
  height: 20px;
  position: relative;
}

.node__port-row--input {
  justify-content: flex-start;
}

.node__port-row--output {
  justify-content: flex-end;
}

.node__port-label {
  font-size: 11px;
  color: var(--color-muted);
  padding: 0 6px;
}

/* Ports are rendered as SVG circles in canvas.js — these styles are for the foreignObject layout helpers */

/* ── Properties (input fields inside node) ── */
.node__prop {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.node__prop label {
  font-size: 10px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.node__prop input,
.node__prop select,
.node__prop textarea {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-size: 12px;
  padding: 4px 6px;
  width: 100%;
  outline: none;
}

.node__prop input:focus,
.node__prop select:focus {
  border-color: var(--color-accent);
}

/* ── Status indicators ── */
.node { position: relative; }

.node__status-icon {
  font-size: 11px;
  margin-left: auto;
}

/* Overlay beim laufenden Node */
.node.node--running::before {
  content: '⏳';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: rgba(10, 10, 30, 0.55);
  border-radius: 8px;
  z-index: 10;
  animation: spin-slow 1.5s linear infinite;
  pointer-events: none;
}

@keyframes spin-slow {
  0%   { opacity: 1;   transform: scale(1.0); }
  50%  { opacity: 0.6; transform: scale(0.85); }
  100% { opacity: 1;   transform: scale(1.0); }
}

/* ── Context Menu ── */
#context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 7px;
  padding: 4px 0;
  z-index: 200;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
}

#context-menu.visible {
  display: block;
}

.context-menu__title {
  font-size: 10px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px 4px;
}

.context-menu__item {
  padding: 7px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: background 0.1s;
}

.context-menu__item:hover {
  background: rgba(255,255,255,0.07);
}

.context-menu__item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Footer ── */
#site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: var(--bg-panel);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 60;
  font-size: 11px;
}

#site-footer a {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.15s;
}

#site-footer a:hover {
  color: var(--color-text);
}

.footer-sep {
  color: var(--color-border);
}

/* ── Info-Dialoge (Impressum etc.) ── */
.info-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  padding: 24px;
  min-width: 340px;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.info-dialog h3 {
  font-size: 15px;
  margin-bottom: 16px;
}

.info-dialog h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text);
  margin-bottom: 6px;
}

.info-dialog p {
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.info-dialog::backdrop {
  background: rgba(0,0,0,0.6);
}

/* ── Output Panel ── */
#output-panel {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  height: 140px;
  background: var(--bg-panel);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: height 0.2s;
}

#output-panel.collapsed {
  height: 28px;
}

#output-panel-header {
  display: flex;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  cursor: pointer;
  font-size: 11px;
  color: var(--color-muted);
  gap: 8px;
}

#output-panel-header:hover {
  color: var(--color-text);
}

#output-log {
  overflow-y: auto;
  padding: 6px 12px;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 12px;
  flex: 1;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: pre-wrap;
  word-break: break-all;
}

.log-entry--info  { color: #90caf9; }
.log-entry--success { color: #a5d6a7; }
.log-entry--error { color: #ef9a9a; }
.log-entry--data  { color: #fff59d; }

/* ── Tooltip ── */
.node-tooltip {
  position: fixed;
  background: #2a0a0a;
  border: 1px solid var(--color-accent);
  color: #ef9a9a;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  z-index: 300;
  pointer-events: none;
  max-width: 260px;
}
