:root {
  --bg-color: #0d0f12;
  --bg-grid: #1a1d24;
  --canvas-grid-dot: #262a33;
  --panel-bg: #14171f;
  --panel-border: #232836;
  --node-bg: #181c26;
  --node-border: #2b3244;
  --node-hover-border: #ff6d5a;
  --node-header-text: #f3f4f6;
  --node-subtext: #9ca3af;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-orange: #ff6d5a;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-emerald: #059669;

  --glow-orange: rgba(255, 109, 90, 0.6);
  --glow-cyan: rgba(6, 182, 212, 0.6);
  --glow-green: rgba(16, 185, 129, 0.8);
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  height: 60px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.n8n-badge {
  background: linear-gradient(135deg, #ea4b71, #ff6d5a);
  color: white;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 12px rgba(255, 109, 90, 0.4);
}

.title-area h1 {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-area span.sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Scenario Selector */
.scenario-selector {
  display: flex;
  background: #0d0f14;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  gap: 4px;
}

.scenario-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scenario-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.scenario-btn.active {
  background: var(--panel-border);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-run {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

.btn-run:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
}

.btn-run.running {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.btn-tutorial {
  background: #232836;
  color: #e5e7eb;
  border: 1px solid #374151;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tutorial:hover {
  background: #2d3345;
  color: white;
}

/* Main Layout */
.main-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Canvas Area */
.canvas-wrapper {
  flex: 1;
  position: relative;
  background-color: var(--bg-color);
  background-image: radial-gradient(var(--canvas-grid-dot) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  overflow: auto;
  user-select: none;
}

.canvas-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 2200px;
  height: 1100px;
  transform-origin: 0 0;
}

/* SVG Connection Lines Layer */
.connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.connection-path {
  fill: none;
  stroke: #2e3648;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease;
}

.connection-path.active {
  stroke: #4b5563;
}

.connection-path.subnode-path {
  stroke-dasharray: 4 4;
  stroke-width: 2;
  stroke: #283042;
}

/* Animated Neon Energy Pulses */
.neon-pulse {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Nodes Styling */
.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.node {
  position: absolute;
  background-color: var(--node-bg);
  border: 1.5px solid var(--node-border);
  border-radius: 12px;
  width: 220px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.15s;
  user-select: none;
}

.node:hover {
  border-color: #4b5568;
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.7);
}

.node.selected {
  border-color: #ff6d5a !important;
  box-shadow: 0 0 0 2px rgba(255, 109, 90, 0.4), 0 12px 32px rgba(0,0,0,0.8);
}

/* Node Glowing Execution States (As seen in the Instagram reel) */
.node.pulse-orange {
  border-color: #ff8c00 !important;
  box-shadow: 0 0 30px rgba(255, 140, 0, 0.7), 0 0 60px rgba(255, 100, 0, 0.4) !important;
  animation: nodeGlowOrange 1.2s infinite alternate;
}

.node.pulse-cyan {
  border-color: #00f0ff !important;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.7), 0 0 60px rgba(0, 150, 255, 0.4) !important;
  animation: nodeGlowCyan 1.2s infinite alternate;
}

.node.pulse-green {
  border-color: #10b981 !important;
  box-shadow: 0 0 45px rgba(16, 185, 129, 0.95), 0 0 90px rgba(5, 150, 105, 0.7) !important;
  animation: nodeGlowGreen 0.9s ease-in-out;
}

@keyframes nodeGlowOrange {
  from { box-shadow: 0 0 20px rgba(255, 140, 0, 0.5); }
  to { box-shadow: 0 0 40px rgba(255, 140, 0, 0.9); }
}

@keyframes nodeGlowCyan {
  from { box-shadow: 0 0 20px rgba(0, 240, 255, 0.5); }
  to { box-shadow: 0 0 40px rgba(0, 240, 255, 0.9); }
}

@keyframes nodeGlowGreen {
  0% { transform: scale(1); box-shadow: 0 0 15px rgba(16, 185, 129, 0.4); }
  50% { transform: scale(1.06); box-shadow: 0 0 75px rgba(16, 185, 129, 1); }
  100% { transform: scale(1); box-shadow: 0 0 40px rgba(16, 185, 129, 0.85); }
}

.node-body {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.node-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #11141c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
}

.node-text {
  flex: 1;
  overflow: hidden;
}

.node-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--node-header-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-subtitle {
  font-size: 11px;
  color: var(--node-subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Ports (Connectors) */
.port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #2b3244;
  border: 2px solid #141720;
  z-index: 15;
  transition: all 0.2s;
}

.port-input {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.port-output {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.port-sub-input {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

.port-sub-output {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
}

/* Subnode styling (Models, Parsers, Memory connected below) */
.node.subnode {
  border-radius: 50px;
  padding: 4px 12px;
  width: 180px;
  background: #12151e;
  border-style: dashed;
}

.node.subnode .node-body {
  padding: 6px 4px;
}

.node.subnode .node-icon-wrapper {
  width: 26px;
  height: 26px;
  font-size: 13px;
}

.node.subnode .node-title {
  font-size: 11px;
}

.node.subnode .node-subtitle {
  font-size: 9px;
}

/* Inspector Drawer */
.inspector-panel {
  width: 440px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.3s ease;
  overflow-y: auto;
  box-shadow: -6px 0 24px rgba(0,0,0,0.5);
}

.inspector-panel.closed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
}

.inspector-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #10121a;
  position: sticky;
  top: 0;
  z-index: 10;
}

.inspector-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-inspector {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-close-inspector:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.inspector-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.inspector-card {
  background: #181c26;
  border: 1px solid var(--node-border);
  border-radius: 10px;
  padding: 14px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ff6d5a;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title.blue { color: #38bdf8; }
.card-title.green { color: #34d399; }
.card-title.amber { color: #fbbf24; }

.inspector-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #d1d5db;
}

.json-box {
  background: #0d0f14;
  border: 1px solid #1f2430;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  color: #a5f3fc;
  overflow-x: auto;
  max-height: 200px;
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.param-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #242b3b;
}

.param-table td.key {
  color: #9ca3af;
  font-weight: 500;
  width: 35%;
}

.param-table td.val {
  color: #f3f4f6;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Modal Tutorial */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #141720;
  border: 1px solid #2b3244;
  border-radius: 14px;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  background: #10121a;
  border-bottom: 1px solid #232836;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: #d1d5db;
}

.modal-body h3 {
  color: #fff;
  font-size: 16px;
  margin: 18px 0 8px 0;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.cmd-box {
  background: #090b0e;
  border: 1px solid #232836;
  border-left: 3px solid #ff6d5a;
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #38bdf8;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cmd-box code {
  color: #38bdf8;
}

.copy-btn {
  background: #1f2433;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 4px;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

.copy-btn:hover {
  color: #fff;
  background: #2b3247;
}

/* Bottom Execution Bar */
.execution-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 23, 32, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 8px 20px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4b5563;
  transition: all 0.3s;
}

.status-dot.active {
  background: #10b981;
  box-shadow: 0 0 12px #10b981;
}

.status-text {
  font-size: 13px;
  font-weight: 500;
  color: #e5e7eb;
}
