:root {
  /* Premium Dark Mode / Glassmorphism Palette */
  --bg-color: #0d0f14;
  --bg-gradient: radial-gradient(circle at top right, #1a1e29 0%, #0d0f14 100%);
  --surface1: rgba(30, 36, 48, 0.4); /* Glass base */
  --surface2: rgba(40, 48, 62, 0.6);
  --surface3: rgba(55, 65, 81, 0.8);
  
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.15);
  
  --text: #f3f4f6;
  --text2: #d1d5db;
  --text3: #9ca3af;
  
  /* Vibrant Accents */
  --accent: #6c8ef5;       /* Primary blue */
  --accent-light: #94adfc;
  --accent-glow: rgba(108, 142, 245, 0.3);
  
  --accent2: #f59e0b;      /* Amber / Orange */
  --accent3: #10b981;      /* Emerald */
  
  --r: 16px; /* Primary radius */
  --r-sm: 8px; /* Small radius */
  
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
  --glass-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  background: var(--bg-gradient);
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Defaults */
.glass {
  background: var(--surface1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), var(--glass-shadow);
}

/* App Header & Topbar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(13, 15, 20, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.logo-area { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 18px; letter-spacing: -0.5px; }
.logo-icon { 
  width: 32px; height: 32px; 
  background: linear-gradient(135deg, var(--accent), #b16cf5); 
  border-radius: var(--r-sm); 
  display: flex; align-items: center; justify-content: center; 
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 0 16px var(--accent-glow);
}

.topbar-actions { display: flex; gap: 12px; align-items: center; }

/* Profile Dropdown Component */
.profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 40px;
  background: var(--surface1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.profile-pill:hover { background: var(--surface2); border-color: var(--border2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(to bottom, #4b5563, #374151);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.dropdown-menu {
  position: absolute; top: 70px; right: 24px;
  width: 280px;
  padding: 8px;
  border-radius: var(--r);
  z-index: 200;
  transform-origin: top right;
  animation: slideFade 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideFade {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-header {
  padding: 12px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text2); font-size: 14px;
  cursor: pointer; transition: 0.15s;
}
.dropdown-item:hover { background: var(--surface2); color: var(--text); }
.dropdown-item.accent { color: var(--accent-light); }
.dropdown-item.accent:hover { background: rgba(108,142,245,0.1); }
.dropdown-item.danger { color: #f87171; }
.dropdown-item.danger:hover { background: rgba(248,113,113,0.1); }

/* Canvas Area */
.canvas {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden; cursor: grab; background-size: 40px 40px;
  /* Premium dotted grid */
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
}
.canvas:active { cursor: grabbing; }

/* Nodes */
.node {
  position: absolute;
  background: rgba(20, 24, 32, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm), var(--glass-shadow);
  display: flex; flex-direction: column;
  transition: box-shadow 0.2s, border-color 0.2s;
  will-change: transform, left, top;
}
.node:hover { border-color: var(--border2); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); z-index: 50; }
.node.dragging { opacity: 0.8; z-index: 100; transition: none; }

.node-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.node-header:active { cursor: grabbing; }

.node-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.node-title-wrap { flex: 1; overflow: hidden; }
.node-title { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.node-subtitle { font-size: 11px; color: var(--text3); }

.node-body { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.node-actions {
  display: flex; padding: 8px; gap: 4px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1); border-bottom-left-radius: var(--r); border-bottom-right-radius: var(--r);
}
.node-action-btn {
  flex: 1; background: transparent; border: none; color: var(--text3); font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 0;
  border-radius: var(--r-sm); cursor: pointer; transition: 0.15s; font-family: inherit; font-weight: 500;
}
.node-action-btn:hover { background: var(--surface2); color: var(--text); }
.node-action-btn svg { width: 14px; height: 14px; }

/* SVG Lines */
svg.connections { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.line { fill: none; stroke: var(--border2); stroke-width: 2; transition: stroke-dashoffset 0.1s linear; }
.line.active { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 6px var(--accent-glow)); }

/* Ports */
.port {
  position: absolute; width: 12px; height: 12px;
  background: var(--surface3); border: 2px solid var(--text3); border-radius: 50%;
  cursor: crosshair; z-index: 10; opacity: 0; transition: 0.2s;
}
.node:hover .port, .node.selected .port, .port:hover { opacity: 1; }
.port:hover { transform: scale(1.3); background: var(--accent); border-color: var(--bg-color); }
.port-top { top: -6px; left: 50%; margin-left: -6px; }
.port-bottom { bottom: -6px; left: 50%; margin-left: -6px; }
.port-left { left: -6px; top: 50%; margin-top: -6px; }
.port-right { right: -6px; top: 50%; margin-top: -6px; }

/* Form Controls */
.btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 16px; border-radius: var(--r-sm); font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: 0.2s; white-space: nowrap; outline: none; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn:hover:not(:disabled) { background: var(--surface3); border-color: var(--border2); }
.btn.accent {
  background: linear-gradient(135deg, #6c8ef5, #5a7be6);
  color: #fff; border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn.accent:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(108,142,245,0.4); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  background: transparent; border: none; color: var(--text2);
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.15s; outline: none;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.input {
  background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); padding: 10px 12px; font-family: inherit; font-size: 14px;
  width: 100%; outline: none; transition: 0.2s; box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), inset 0 1px 2px rgba(0,0,0,0.2); }
.input::placeholder { color: var(--text3); }
select.input { background: rgba(20,24,32,0.98); color: var(--text); }
select.input option { background: #1a1e29; color: var(--text); }

/* Modals */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.modal {
  background: rgba(26, 30, 41, 0.95);
  border: 1px solid var(--border2);
  border-radius: 24px; padding: 32px; width: 420px;
  box-shadow: var(--shadow-lg), inset 0 1px 1px rgba(255,255,255,0.1);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-title { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; margin-bottom: 6px; }
.modal-sub { font-size: 14px; color: var(--text3); margin-bottom: 24px; line-height: 1.5; }
.modal-section { margin-bottom: 20px; }
.modal-label { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Plan Cards */
.plan-card {
  background: var(--surface1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px; cursor: pointer; transition: 0.2s; position: relative; overflow: hidden;
}
.plan-card:hover { border-color: var(--border2); background: var(--surface2); }
.plan-card.active { border-color: var(--accent); background: rgba(108,142,245,0.08); box-shadow: 0 0 0 1px var(--accent); }
.plan-name { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.plan-price { font-size: 28px; font-weight: 700; margin-bottom: 12px; }
.plan-price span { font-size: 14px; font-weight: 500; color: var(--text3); }
.plan-features { display: flex; flex-direction: column; gap: 8px; }
.plan-feature { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.plan-feature::before { content: '✓'; color: var(--accent); font-weight: bold; }

/* Full Chat Slide Panel */
.full-chat {
  position: fixed; top: 0; right: 0; bottom: 0; width: 50%; min-width: 480px;
  background: rgba(13, 15, 20, 0.95); backdrop-filter: blur(24px); border-left: 1px solid var(--border);
  z-index: 500; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,0.5);
  animation: slideLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }

.full-chat-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.full-chat-title { font-weight: 600; font-size: 18px; flex: 1; letter-spacing: -0.3px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px;
}

.message { display: flex; gap: 16px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.user-avatar { background: var(--surface3); color: var(--text); }
.ai-avatar { background: linear-gradient(135deg, var(--accent), #b16cf5); color: #fff; box-shadow: 0 4px 12px var(--accent-glow); }
.message-bubble {
  background: var(--surface2); padding: 14px 18px; border-radius: 18px;
  font-size: 15px; line-height: 1.6; color: var(--text); white-space: pre-wrap;
}
.message.user .message-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.message.ai .message-bubble { border-top-left-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.chat-input-row {
  display: flex; gap: 12px; background: rgba(30, 36, 48, 0.8); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 24px; padding: 8px; padding-left: 20px;
  box-shadow: var(--shadow-sm); align-items: flex-end; margin-top: auto;
}
.chat-textarea {
  flex: 1; background: transparent; border: none; color: var(--text); outline: none;
  font-family: inherit; font-size: 15px; resize: none; max-height: 150px;
  padding: 12px 0; line-height: 1.5;
}
.chat-textarea::placeholder { color: var(--text3); }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s;
}
.send-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px var(--accent-glow); }
.send-btn:disabled { background: var(--surface3); color: var(--text3); cursor: not-allowed; }
.send-btn svg { width: 20px; height: 20px; }

/* Typing animation */
.typing-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3); margin: 0 2px; animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Context Menu */
.ctx-menu {
  position: absolute; background: rgba(30, 36, 48, 0.95); backdrop-filter: blur(16px);
  border: 1px solid var(--border2); border-radius: var(--r-sm); padding: 6px;
  min-width: 180px; box-shadow: var(--shadow-lg); z-index: 1000;
  animation: slideFade 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.ctx-item {
  padding: 8px 12px; border-radius: 4px;
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text2);
  cursor: pointer; transition: 0.1s;
}
.ctx-item:hover { background: var(--accent); color: #fff; }
.ctx-item.danger:hover { background: #ef4444; }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }
.ctx-item svg { width: 14px; height: 14px; }

.node.fit-screen {
  position: fixed !important;
  top: 70px !important;
  left: 20px !important;
  right: 20px !important;
  bottom: 20px !important;
  width: auto !important;
  height: auto !important;
  z-index: 2000 !important;
  margin: 0 !important;
  transform: none !important;
}

/* Debate Styles */
.debate-round {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.debate-round:last-child { border-bottom: none; }
.debate-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.debate-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 4px;
  border-bottom: 2px solid currentColor;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.debate-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* Status Bar */
.status-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 30px;
  background: rgba(13, 15, 20, 0.8); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace;
}
.sync-status { display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; }
.sync-dot.success { background: var(--accent3); box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
.sync-dot.error { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.6); }
.sync-dot.loading { background: var(--accent2); box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
