/* Węzeł (NODE) */
.node {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 180px;
  max-width: 250px;
  padding: 0;
  border-radius: 12px;
  background: var(--node);
  border: 2px solid var(--accent);
  color: var(--text);
  text-align: center;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.6),
    0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  cursor: grab;
  user-select: none;
  z-index: 10;
  transition: left 0.1s linear, top 0.1s linear, box-shadow 0.3s, transform 0.1s;
  backdrop-filter: blur(10px);
}

.node:hover {
  background: var(--node-hover);
  border-color: var(--accent-glow);
  box-shadow:
    0 8px 30px color-mix(in srgb, var(--accent) 30%, transparent),
    0 0 0 2px var(--accent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%) scale(1.02);
}

.node:active, .node.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow:
    0 12px 40px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 0 3px var(--accent),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: none !important;
}

.node.selected {
  border: 3px solid #3498db;
  box-shadow: 0 0 20px rgba(52, 152, 219, 0.6);
  animation: pulse 2s infinite;
}

.node.connecting {
  border: 3px solid #ff2a6d;
  box-shadow: 0 0 25px rgba(255, 42, 109, 0.6);
  animation: glow 1.5s infinite alternate;
}

.node:not(.dragging) {
    transition: left 0.3s linear, top 0.3s linear, box-shadow 0.3s, transform 0.1s !important;
}

.node.new { animation: nodePulse 0.6s ease-out; }

.node a {
  color: inherit;
  text-decoration: none;
  display: block;
  width: 100%;
  height: 100%;
  padding: 15px 20px;
  box-sizing: border-box;
  line-height: 1.3;
  font-weight: bold;
}

.node a:hover { text-decoration: underline; }

.node-connections {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 0 10px var(--accent-glow);
  z-index: 11;
}

.node-tags {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.node-tag {
  background: rgba(0, 0, 0, 0.5);
  color: var(--accent);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--accent);
}

.node.connected {
  box-shadow:
    0 4px 20px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 0 2px var(--accent),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 30px color-mix(in srgb, var(--accent) 30%, transparent);
}

.connection {
  stroke: var(--connection-color);
  stroke-width: 3;
  fill: none;
  transition: all 0.3s ease;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px var(--accent-glow));
}

.connection:hover {
  stroke: var(--accent);
  stroke-width: 4;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

body.editing .node { cursor: grab; }
body.editing .node a { pointer-events: none; cursor: grab !important; }

@keyframes pulse {
  0% { box-shadow: 0 0 20px rgba(52, 152, 219, 0.6); }
  50% { box-shadow: 0 0 30px rgba(52, 152, 219, 0.9); }
  100% { box-shadow: 0 0 20px rgba(52, 152, 219, 0.6); }
}

@keyframes glow {
  from { box-shadow: 0 0 20px rgba(255, 42, 109, 0.6); }
  to { box-shadow: 0 0 35px rgba(255, 42, 109, 0.9); }
}

@keyframes nodePulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  70% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}