/* ==========================================================================
   AI FLOWLAB - STYLESHEET (n8n-Inspired Ultra Modern Dark Theme)
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #0a0d14;
  --bg-canvas: #0e121e;
  --bg-panel: rgba(18, 24, 38, 0.85);
  --bg-card: #161d2f;
  --bg-card-hover: #1e273e;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  
  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-dim: #a8b5c8;
  
  /* Brand Accents */
  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Node Category Accent Colors */
  --color-trigger: #f59e0b;
  --color-model: #38bdf8;
  --color-tool: #a855f7;
  --color-logic: #ec4899;
  --color-output: #22c55e;
  
  /* Fonts & Shadows */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* BASE RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

/* Allow text selection in code blocks, logs, inputs, modals, and execution details */
input,
textarea,
pre,
code,
.console-output,
.console-output *,
.log-entry,
.log-entry *,
.exec-step-card,
.exec-code-block,
.exec-code-block *,
.modal-body,
.code-preview-area,
.code-preview-area * {
  user-select: text !important;
  -webkit-user-select: text !important;
}

::selection {
  background: rgba(56, 189, 248, 0.35);
  color: #ffffff;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* UTILITIES */
.text-cyan { color: var(--accent-cyan) !important; }
.text-purple { color: var(--accent-purple) !important; }
.text-pink { color: var(--accent-pink) !important; }
.text-green { color: var(--accent-green) !important; }
.text-amber { color: var(--accent-amber) !important; }

/* ==========================================================================
   TOP NAVBAR
   ========================================================================== */
.navbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 12px;
  background: rgba(14, 18, 30, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
  overflow: visible;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.68rem;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* GRADE LEVEL SELECTOR */
.grade-selector-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.selector-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 5px;
  white-space: nowrap;
}

.grade-toggle {
  display: flex;
  gap: 3px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-tag {
  font-size: 0.65rem;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 2px;
}

.mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
  font-weight: 600;
}

/* NAV ACTIONS */
.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-shrink: 0;
  min-width: 0;
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 2px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-highlight {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(56, 189, 248, 0.18));
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
  font-weight: 600;
}

.btn-highlight:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.28), rgba(56, 189, 248, 0.28));
  border-color: rgba(168, 85, 247, 0.65);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.35);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: white;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
  font-weight: 600;
  padding: 5px 13px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.45);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.45);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-run.running {
  background: linear-gradient(135deg, var(--accent-amber), #d97706);
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 25px rgba(245, 158, 11, 0.8); }
  100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
}

/* DROPDOWN MENU */
.dropdown-wrapper {
  position: relative;
}

/* Invisible hit bridge covering any vertical gap between button and menu */
.dropdown-wrapper:hover::after,
.dropdown-wrapper.clicked-open::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -20px;
  right: -20px;
  height: 16px;
  pointer-events: auto;
  z-index: 199;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0;
  width: 360px;
  max-height: min(480px, 80vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #121826;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: none;
  z-index: 200;
}

#templatesDropdown {
  width: 410px;
  max-height: min(540px, 82vh);
  padding-top: 4px;
  left: 0;
  right: auto;
}

#tutorialsDropdown {
  width: 385px;
  left: 0;
  right: auto;
}

#actionsDropdown {
  width: 240px;
  left: 0;
  right: auto;
}

.template-search-wrapper {
  position: sticky;
  top: -8px;
  background: #121826;
  padding: 4px 4px 8px 4px;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}

.template-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: border-color 0.15s;
}

.template-search-box:focus-within {
  border-color: var(--accent-cyan);
}

.template-search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.8rem;
  width: 100%;
  outline: none;
  font-family: inherit;
}

.template-search-box input::placeholder {
  color: var(--text-dim);
}

/* Category filter pills */
.template-cat-pills {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 6px 2px 2px 2px;
  scrollbar-width: none;
}

.template-cat-pills::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.cat-pill:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}

.cat-pill.active {
  background: rgba(56, 189, 248, 0.22);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* Custom sleek scrollbar for dropdown menus */
.dropdown-menu::-webkit-scrollbar {
  width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Generous transparent bridge to prevent hover loss in the gap */
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -30px;
  right: -30px;
  height: 24px;
  pointer-events: auto;
}

.dropdown-wrapper:hover .dropdown-menu,
.dropdown-wrapper.clicked-open .dropdown-menu,
.dropdown-menu.show {
  display: block;
  animation: fadeIn 0.15s ease-out;
}

.dropdown-header {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  padding: 8px 12px 4px 12px;
  letter-spacing: 0.05em;
  position: sticky;
  top: 76px;
  background: #121826;
  z-index: 2;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  margin-bottom: 4px;
}

.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

#templatesDropdown .dropdown-item {
  padding-left: 28px;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.dropdown-item strong {
  display: block;
  font-size: 0.83rem;
  color: var(--text-main);
}

.dropdown-item small {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: block;
  margin-top: 2px;
}

/* ==========================================================================
   WORKSPACE LAYOUT
   ========================================================================== */
.workspace {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* SIDEBAR PALETTE */
.sidebar-palette {
  width: var(--sidebar-left-width, 280px);
  min-width: 200px;
  max-width: 500px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
}

.sidebar-palette.collapsed {
  width: 68px !important;
  min-width: 68px;
  border-right: 1px solid var(--border-color);
}

.sidebar-palette.collapsed .palette-title > span,
.sidebar-palette.collapsed .palette-search,
.sidebar-palette.collapsed .category-title span,
.sidebar-palette.collapsed .node-item-text {
  display: none;
}

.sidebar-palette.collapsed .palette-header {
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: auto;
}

.sidebar-palette.collapsed .palette-title {
  justify-content: center;
  margin-bottom: 0;
}

.sidebar-palette.collapsed .palette-title i {
  margin: 0;
}

.sidebar-palette.collapsed .panel-toggle {
  display: none;
}

.sidebar-palette.collapsed .palette-categories {
  padding: 12px 8px;
  min-width: auto;
}

.sidebar-palette.collapsed .category-title {
  justify-content: center;
  margin-bottom: 12px;
}

.sidebar-palette.collapsed .category-title i {
  margin: 0;
}

.sidebar-palette.collapsed .palette-node-item {
  padding: 10px;
  justify-content: center;
}

.sidebar-palette.collapsed .node-icon {
  margin: 0;
}

/* SIDEBAR INSPECTOR (Right side) */
.sidebar-inspector {
  width: var(--sidebar-right-width, 380px);
  min-width: 320px;
  max-width: 650px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
}

.sidebar-inspector.collapsed {
  width: 0 !important;
  min-width: 0;
  border-left: none;
}

/* PANEL TOGGLES */
.panel-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.panel-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.palette-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.palette-title > div {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* PANEL EXPAND TABS */
.panel-expand-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, background 0.2s;
  box-shadow: var(--shadow-lg);
}

.panel-expand-tab:hover {
  background: var(--bg-card-hover);
  color: var(--accent-cyan);
}

.panel-expand-tab i {
  width: 16px;
  height: 16px;
}

.sidebar-palette.collapsed ~ .panel-expand-left {
  opacity: 1;
  pointer-events: auto;
  left: 68px;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.sidebar-inspector.collapsed ~ .panel-expand-right,
.workspace:has(.sidebar-inspector.collapsed) .panel-expand-right {
  opacity: 1;
  pointer-events: auto;
  right: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

/* PANEL DIVIDERS */
.panel-divider {
  width: 8px;
  background-color: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 15;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s;
}

.panel-divider:hover, .panel-divider.dragging {
  background-color: rgba(56, 189, 248, 0.1);
}

.divider-handle {
  width: 4px;
  height: 32px;
  border-radius: 4px;
  background-color: var(--text-dim);
  transition: background-color 0.2s, height 0.2s;
}

.panel-divider:hover .divider-handle, .panel-divider.dragging .divider-handle {
  background-color: var(--accent-cyan);
  height: 48px;
}

.sidebar-palette.collapsed + .panel-divider,
.panel-divider:has(+ .sidebar-inspector.collapsed) {
  display: none;
}

.palette-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  min-width: 250px;
}

.palette-search {
  position: relative;
  margin-top: 12px;
}

.palette-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
}

.palette-search input:focus {
  border-color: var(--border-focus);
}

.palette-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.palette-categories {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-width: 250px;
}

.palette-category {
  margin-bottom: 18px;
}

.category-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.palette-node-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.2s ease;
}

.palette-node-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.palette-node-item .node-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.node-item-text strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.node-item-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   CANVAS AREA
   ========================================================================== */
.canvas-container {
  flex: 1;
  position: relative;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: hidden;
  cursor: grab;
}

.canvas-container.panning {
  cursor: grabbing;
}

.svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.canvas-workspace {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  /* Above the wire overlay so node buttons (View Output) receive clicks.
     pointer-events is none so empty canvas and wires underneath stay clickable. */
  z-index: 4;
  pointer-events: none;
}

/* SVG CONNECTIONS */
.wire-path {
  fill: none;
  /* stroke is set inline per-wire for unique colors */
  stroke-width: 2.5px;
  stroke-linecap: round;
  pointer-events: none;
  cursor: pointer;
  transition: stroke-width 0.15s;
}

/* Dragging preview wire: animated glowing dashed line */
.wire-path.temp {
  fill: none;
  stroke: var(--accent-cyan, #38bdf8);
  stroke-width: 3px;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.85));
  animation: tempWireDash 0.5s linear infinite;
}

@keyframes tempWireDash {
  to {
    stroke-dashoffset: -10;
  }
}

/* Wide invisible hit area — pointer-events: stroke makes only the stroke zone clickable */
.wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18px;
  cursor: pointer;
  pointer-events: stroke !important;
}

.wire-delete-badge {
  pointer-events: all !important;
  cursor: pointer;
}

.wire-halo {
  fill: none;
  pointer-events: none;
}

.wire-path.wire-selected {
  stroke-width: 4px;
  animation: wireSelectPulse 1.6s ease-in-out infinite alternate;
}

@keyframes wireSelectPulse {
  0%   { stroke-width: 3.5px; }
  100% { stroke-width: 5px; }
}

.wire-path.executing {
  stroke-width: 4px;
  animation: wireGlowPulse 1.2s ease-in-out infinite alternate;
}

@keyframes wireGlowPulse {
  0% {
    stroke-width: 3.5px;
    filter: drop-shadow(0 0 6px currentColor);
  }
  100% {
    stroke-width: 5px;
    filter: drop-shadow(0 0 14px currentColor);
  }
}


/* CANVAS FLOATING CONTROLS */
.canvas-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.ctrl-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.15);
}

.ctrl-btn-highlight {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
}

.ctrl-btn-highlight:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #fff;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.ctrl-btn:disabled,
.ctrl-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.ctrl-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 4px;
}

/* NAVBAR HISTORY (UNDO / REDO) BUTTON GROUP */
.history-btn-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.history-btn-group .btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  position: static;
}

.history-btn-group .btn-icon:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent-cyan);
}

.history-btn-group .btn-icon:disabled,
.history-btn-group .btn-icon.disabled {
  opacity: 0.3;
  color: var(--text-dim);
  cursor: not-allowed;
  pointer-events: none;
}

.history-btn-group .btn-icon svg,
.history-btn-group .btn-icon i {
  width: 15px;
  height: 15px;
}

/* FLOATING NOTIFICATION / TOAST (UNDO / REDO) */
.flowlab-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.25);
  color: var(--text-main);
  font-size: 0.82rem;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.flowlab-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-undo-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid #38bdf8;
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toast-undo-btn:hover {
  background: #38bdf8;
  color: #0f172a;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* EXPLORER BANNER */
.explorer-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.9), rgba(168, 85, 247, 0.9));
  backdrop-filter: blur(12px);
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: 0 10px 25px rgba(236, 72, 153, 0.3);
  z-index: 10;
  animation: slideDown 0.3s ease-out;
}

.banner-icon {
  width: 24px;
  height: 24px;
}

.banner-content strong {
  display: block;
  font-size: 0.9rem;
}

.banner-content span {
  font-size: 0.8rem;
  opacity: 0.9;
}

.banner-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.7;
}

.banner-close:hover { opacity: 1; }

/* TEMPLATE EDUCATIONAL BANNER */
.template-lesson-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 820px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  color: var(--text-main);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(6, 182, 212, 0.15);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.lesson-banner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lesson-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.lesson-banner-title strong {
  color: var(--text-main);
  font-weight: 700;
}

.lesson-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-banner-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.lesson-banner-prompts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.prompts-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.prompt-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 0.73rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.prompt-chip:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.6);
  color: #38bdf8;
  transform: translateY(-1px);
}

.lesson-banner-drawer {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lesson-drawer-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.lesson-box-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.lesson-box-card strong {
  display: block;
  font-size: 0.78rem;
  color: var(--accent-cyan);
  margin-bottom: 2px;
}

.lesson-box-card small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
}

/* ==========================================================================
   VISUAL NODE CARDS ON CANVAS (n8n Style)
   ========================================================================== */
.flow-node {
  position: absolute;
  width: 240px;
  background: rgba(20, 26, 41, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  cursor: move;
  transition: border-color 0.2s, box-shadow 0.2s;
  z-index: 5;
  pointer-events: auto;
}

.flow-node.layout-animating {
  transition: left 0.45s cubic-bezier(0.2, 0.9, 0.3, 1),
              top 0.45s cubic-bezier(0.2, 0.9, 0.3, 1),
              width 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
}

.flow-node:hover {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
}

.flow-node.selected {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2.5px #38bdf8, 0 0 28px rgba(56, 189, 248, 0.45), 0 16px 40px rgba(0, 0, 0, 0.75) !important;
  z-index: 25;
}

.flow-node.selected .node-header {
  background: rgba(56, 189, 248, 0.12);
  border-bottom-color: rgba(56, 189, 248, 0.35);
}

.flow-node.selected .node-title {
  color: #f0f9ff;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.flow-node.running {
  border-color: var(--accent-amber);
  animation: nodeRunningPulse 1.2s infinite;
}

@keyframes nodeRunningPulse {
  0% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 25px rgba(245, 158, 11, 0.8); }
  100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
}

.flow-node.success {
  border-color: var(--accent-green);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
}

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

.node-header-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.node-title-group strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
}

.node-title-group small {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.node-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.node-status-dot.active { background: var(--accent-green); }
.node-status-dot.running { background: var(--accent-amber); }

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

.node-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: #fb7185;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.flow-node:hover .node-delete-btn,
.flow-node.selected .node-delete-btn {
  opacity: 0.85;
}

.node-delete-btn:hover {
  opacity: 1;
  background: rgba(244, 63, 94, 0.25);
  border-color: #f43f5e;
  color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.45);
}

.node-delete-btn svg,
.node-delete-btn i {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.node-body {
  padding: 12px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.node-preview-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* NODE PORTS (INPUT / OUTPUT HANDLES) */
.node-ports {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 0 10px 0;
  position: relative;
  gap: 8px;
}

.inputs-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-start;
  margin-left: -7px;
}

.outputs-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
  margin-right: -7px;
}

/* Each port row = dot + label inline */
.port {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  border: none;
  cursor: crosshair;
  position: relative;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
}

/* The actual circle dot — a pseudo-element on a child span */
.port-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent-cyan);
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
  display: block;
}

.port:hover .port-dot {
  transform: scale(1.3);
  background: var(--accent-cyan);
}

.port-input .port-dot {
  border-color: var(--accent-cyan);
}

.port-output .port-dot {
  border-color: var(--accent-purple);
}

.port-output:hover .port-dot {
  background: var(--accent-purple);
}

/* Input ports: dot on left, label on right */
.port-input {
  flex-direction: row;
}

/* Output ports: label on left, dot on right */
.port-output {
  flex-direction: row-reverse;
}

.port-label {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}

/* ==========================================================================
   WIRE DRAG & DYNAMIC CONNECTION TARGET GUIDANCE
   ========================================================================== */

/* While dragging a wire, set cursor crosshair on canvas */
.canvas-container.is-dragging-wire {
  cursor: crosshair !important;
}

/* Source port actively emitting a wire */
.port.port-dragging-source .port-dot {
  transform: scale(1.4) !important;
  background: #f43f5e !important;
  border-color: #f43f5e !important;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.35), 0 0 16px rgba(244, 63, 94, 0.8) !important;
  animation: none !important;
}
.port.port-dragging-source .port-label {
  color: #fb7185 !important;
  font-weight: 700;
}
.flow-node.node-dragging-source {
  border-color: rgba(244, 63, 94, 0.45) !important;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.15), var(--shadow-card) !important;
}

/* Valid Target Ports (Pulsing beacon rings showing where user can connect) */
.port.port-valid-target {
  cursor: pointer !important;
  z-index: 30;
}
.port.port-valid-target .port-dot {
  transform: scale(1.25);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dragging-from-output .port.port-valid-target .port-dot {
  border-color: var(--accent-cyan) !important;
  background: rgba(56, 189, 248, 0.3) !important;
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
  animation: cyanPortBeacon 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}
.dragging-from-input .port.port-valid-target .port-dot {
  border-color: var(--accent-purple) !important;
  background: rgba(168, 85, 247, 0.3) !important;
  box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7);
  animation: purplePortBeacon 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}
.port.port-valid-target .port-label {
  color: #f8fafc !important;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

@keyframes cyanPortBeacon {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.8), 0 0 8px rgba(56, 189, 248, 0.6);
  }
  65% {
    box-shadow: 0 0 0 9px rgba(56, 189, 248, 0), 0 0 16px rgba(56, 189, 248, 0.9);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0), 0 0 8px rgba(56, 189, 248, 0.6);
  }
}

@keyframes purplePortBeacon {
  0% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.8), 0 0 8px rgba(168, 85, 247, 0.6);
  }
  65% {
    box-shadow: 0 0 0 9px rgba(168, 85, 247, 0), 0 0 16px rgba(168, 85, 247, 0.9);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0), 0 0 8px rgba(168, 85, 247, 0.6);
  }
}

/* Candidate Target Nodes */
.flow-node.node-drop-candidate {
  border-color: rgba(56, 189, 248, 0.4) !important;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.12), var(--shadow-card) !important;
}
.dragging-from-input .flow-node.node-drop-candidate {
  border-color: rgba(168, 85, 247, 0.4) !important;
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.12), var(--shadow-card) !important;
}

/* Hover / Snapped Target Port */
.port.port-hover-snap {
  transform: scale(1.15) !important;
  z-index: 40 !important;
}
.port.port-hover-snap .port-dot {
  transform: scale(1.6) !important;
  background: #22c55e !important;
  border-color: #4ade80 !important;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.35), 0 0 20px rgba(34, 197, 94, 0.95) !important;
  animation: none !important;
}
.port.port-hover-snap .port-label {
  color: #4ade80 !important;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.9) !important;
}

/* Incompatible Ports (Dimmed to keep UI focused on valid drop locations) */
.port.port-incompatible {
  opacity: 0.25 !important;
  filter: grayscale(0.85);
  cursor: not-allowed !important;
  pointer-events: none !important;
  transition: opacity 0.2s ease;
}

/* Floating Wire Drag Guidance HUD */
.wire-drag-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 9999px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #f8fafc;
  pointer-events: none;
  z-index: 1000;
  animation: hudSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  transition: all 0.2s ease;
}
.wire-drag-hud.snap-ready {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(6, 78, 59, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 24px rgba(34, 197, 94, 0.4);
}
.wire-drag-hud.snap-error {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(88, 28, 28, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(239, 68, 68, 0.35);
}
.wire-drag-hud .hud-beacon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
  flex-shrink: 0;
  animation: hudBlink 1s infinite alternate ease-in-out;
}
.wire-drag-hud.snap-ready .hud-beacon {
  background: #4ade80;
  box-shadow: 0 0 12px #4ade80;
}
.wire-drag-hud.snap-error .hud-beacon {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}
.wire-drag-hud .hud-text {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wire-drag-hud .badge-port {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
}

@keyframes hudSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}
@keyframes hudBlink {
  0% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.15); }
}

/* ==========================================================================
   RIGHT INSPECTOR & CONSOLE
   ========================================================================== */
.inspector-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(14, 18, 30, 0.7);
  padding: 0 4px;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 11px 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tab-btn:hover { color: var(--text-main); }

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.06);
  font-weight: 600;
}

.badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 0.68rem;
}
.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  display: none;
  padding: 16px;
}

.tab-content.active { display: block; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* FORM CONTROLS IN INSPECTOR */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
}

.form-help {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* PROCESS & OUTPUT SECTION IN INSPECTOR */
.process-section {
  margin-top: 24px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.process-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.process-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.process-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.process-status-badge.idle {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.process-status-badge.running {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.process-status-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.process-status-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.process-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: all 0.2s ease;
}

.process-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.process-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.process-card-header > span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.process-card-content {
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.5;
}

.process-code-box {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #38bdf8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

.process-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.process-meta-item {
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.process-meta-label {
  color: var(--text-dim);
  display: block;
  margin-bottom: 2px;
}

.process-meta-val {
  color: var(--text-main);
  font-weight: 600;
  font-family: var(--font-mono);
}

.btn-test-block {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: var(--radius-md);
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}

.btn-test-block:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(59, 130, 246, 0.3));
  border-color: rgba(6, 182, 212, 0.6);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
  transform: translateY(-1px);
}

.btn-copy-output {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-copy-output:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

/* CONSOLE LOGS */
.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.console-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.console-output {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.console-output ::selection,
.log-entry ::selection,
.log-msg ::selection,
.exec-step-card ::selection,
pre ::selection,
code ::selection {
  background: rgba(56, 189, 248, 0.4);
  color: #ffffff;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  position: relative;
  transition: background 0.15s ease;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.04);
}

.log-time {
  color: var(--text-dim);
  font-size: 0.7rem;
  flex-shrink: 0;
  user-select: text;
  -webkit-user-select: text;
}

.log-content-wrap {
  flex: 1;
  min-width: 0;
  user-select: text;
  -webkit-user-select: text;
}

.log-msg {
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.log-copy-btn {
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-family: inherit;
  transition: all 0.15s ease;
  flex-shrink: 0;
  user-select: none;
}

.log-entry:hover .log-copy-btn {
  opacity: 1;
  pointer-events: auto;
}

.log-copy-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent-cyan);
}

.log-copy-btn.copied {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  color: #10b981;
}

.log-entry.info { color: var(--text-muted); }
.log-entry.success { color: var(--accent-green); }
.log-entry.running { color: var(--accent-amber); }
.log-entry.error { color: var(--accent-rose); }

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal-backdrop.show { display: flex; }

.modal-card {
  width: 680px;
  max-width: 90vw;
  background: #121826;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: zoomIn 0.2s ease-out;
}

.modal-card.modal-sm { width: 440px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.code-block {
  background: #080a10;
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #a7f3d0;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-card.modal-lg { width: 840px; }

/* VIDEO TUTORIAL STYLES */
.video-container {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.video-preview-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.video-chapters {
  margin-top: 14px;
}

.video-chapters h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.chapter-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.chapter-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.chapter-card strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-main);
}

.chapter-card p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* INTERACTIVE TOUR STYLES */
.tour-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  z-index: 400;
  display: none;
  pointer-events: auto;
}

.tour-backdrop.show { display: block; }

.tour-highlight {
  position: absolute;
  border: 2px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 0 30px var(--accent-cyan), inset 0 0 20px rgba(56, 189, 248, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tour-card {
  position: absolute;
  width: 340px;
  background: #141a29;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
  z-index: 410;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: zoomIn 0.25s ease-out;
}

.tour-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tour-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: 12px;
}

.tour-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.tour-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.tour-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 16px;
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tour-dots {
  display: flex;
  gap: 6px;
}

.tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.tour-dot.active {
  background: var(--accent-cyan);
  transform: scale(1.25);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes zoomIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ==========================================================================
   AI ARCHITECTURE & LESSONS HUB STYLING
   ========================================================================== */
.modal-card.modal-xl {
  width: 960px;
  max-width: 94vw;
}

.lessons-tabs-bar {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.lessons-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.lessons-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.lessons-tab-btn.active {
  color: var(--accent-purple);
  border-bottom-color: var(--accent-purple);
  font-weight: 600;
}

.lessons-body {
  padding: 24px;
  max-height: 72vh;
  overflow-y: auto;
}

.lessons-tab-content {
  display: none;
}

.lessons-tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

/* ARCHITECTURE PIPELINE DIAGRAM */
.arch-overview-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.arch-overview-card h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.arch-overview-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.arch-pipeline-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 10px;
  background: #0d121f;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.arch-step-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  transition: all 0.3s;
}

.arch-step-node.active {
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
  transform: translateY(-2px);
}

.step-num {
  position: absolute;
  top: -10px;
  background: var(--accent-purple);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arch-step-node i {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  color: var(--accent-cyan);
}

.arch-step-node strong {
  font-size: 0.85rem;
  color: var(--text-main);
}

.arch-step-node small {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.arch-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: bold;
}

/* SIMULATOR INSPECTOR BOX */
.sim-inspector-box {
  background: #101625;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.sim-inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sim-phase-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-step-badge {
  font-size: 0.75rem;
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.sim-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.sim-card h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sim-card p {
  font-size: 0.84rem;
  color: var(--text-main);
  line-height: 1.4;
}

.sim-payload-box {
  background: #080a10;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.payload-header {
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.sim-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* CONCEPT CARDS GRID */
.lesson-article h2 {
  font-size: 1.25rem;
  margin-bottom: 10px;
}

.lesson-article h3 {
  font-size: 1rem;
  margin: 18px 0 10px 0;
}

.lesson-article p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.concept-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.concept-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.concept-card.border-pink { border-top: 3px solid var(--accent-pink); }
.concept-card.border-cyan { border-top: 3px solid var(--accent-cyan); }
.concept-card.border-purple { border-top: 3px solid var(--accent-purple); }

.concept-icon {
  margin-bottom: 8px;
}

.concept-card h3 {
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.concept-card p {
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.code-snippet {
  background: #070a12;
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #818cf8;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.bullet-list {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* WORKFLOW STEPS LIST */
.workflow-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wf-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.wf-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 4px 8px;
  border-radius: 4px;
}

.wf-step strong {
  font-size: 0.88rem;
  color: var(--text-main);
  display: block;
}

.wf-step p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  margin-bottom: 0;
}

/* REACT LOOP DIAGRAM */
.react-loop-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  margin: 20px auto;
}

.react-circle-box {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.react-circle-box.border-pink { border-left: 4px solid var(--accent-pink); }
.react-circle-box.border-cyan { border-left: 4px solid var(--accent-cyan); }
.react-circle-box.border-green { border-left: 4px solid var(--accent-green); }

.react-circle-box h4 {
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.react-circle-box p {
  font-size: 0.8rem;
  margin-bottom: 0;
}

.react-arrow-down {
  color: var(--text-dim);
  font-size: 1.2rem;
}

/* ==========================================================================
   RESPONSIVE NAVBAR MEDIA QUERIES (ZERO-OVERFLOW GUARANTEE)
   ========================================================================== */

/* Screen <= 1500px: hide redundant selector labels and extra tags */
@media (max-width: 1500px) {
  .selector-label {
    display: none !important;
  }
  .brand-subtitle {
    display: none !important;
  }
  .mode-tag {
    display: none !important;
  }
}

/* Screen <= 1360px: compact button paddings and hide badge pill */
@media (max-width: 1360px) {
  .navbar {
    padding: 0 10px !important;
    gap: 6px !important;
  }
  .nav-actions {
    gap: 4px !important;
  }
  .nav-actions .btn {
    padding: 5px 7px !important;
    gap: 3px !important;
    font-size: 0.76rem !important;
  }
  .mode-btn {
    padding: 4px 7px !important;
    font-size: 0.74rem !important;
  }
}

/* Screen <= 1220px: collapse text for secondary dropdowns (Tutorials, Actions) */
@media (max-width: 1220px) {
  #tutorialsBtn .btn-text,
  #actionsBtn .btn-text {
    display: none !important;
  }
  #tutorialsBtn .btn-arrow,
  #actionsBtn .btn-arrow {
    display: none !important;
  }
  #tutorialsBtn,
  #actionsBtn {
    padding: 5px 8px !important;
  }
}

/* Screen <= 1100px: collapse Templates and simplify grade mode labels */
@media (max-width: 1100px) {
  #templatesBtn .btn-text,
  #templatesBtn .btn-arrow {
    display: none !important;
  }
  #templatesBtn {
    padding: 5px 8px !important;
  }
  .mode-btn span {
    font-size: 0.7rem !important;
  }
}

/* Screen <= 1380px: collapse text labels to icons */
@media (max-width: 1380px) {
  #navExportCodeBtn .btn-text,
  #navLaunchPortalBtn .btn-text,
  #navApiKeysBtn .btn-text {
    display: none !important;
  }
  #navExportCodeBtn,
  #navLaunchPortalBtn,
  #navApiKeysBtn {
    padding: 5px 8px !important;
  }
  .mode-btn span {
    display: none !important;
  }
  .mode-btn {
    padding: 4px 6px !important;
  }
  .brand-title {
    font-size: 0.95rem !important;
  }
  .history-btn-group {
    display: none !important;
  }
  #runFlowBtn .btn-text {
    display: none !important;
  }
  #runFlowBtn {
    padding: 5px 9px !important;
  }
  .grade-selector-container {
    padding: 1px !important;
  }
}


/* INPUT WITH ICON TOGGLE */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input {
  padding-right: 40px;
}

.input-with-icon .btn-icon {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.input-with-icon .btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.input-with-icon .btn-icon i {
  width: 16px;
  height: 16px;
}

/* --- TOKENS & INFERENCE LESSONS --- */

/* Tokens Demo Box */
.token-demo-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 20px 0;
  text-align: center;
}

.token-input-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.token-input-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
}

.token-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.token-output-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-bottom: 12px;
}

.token-pill {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: hsl(var(--pill-hue), 70%, 20%);
  border: 1px solid hsl(var(--pill-hue), 70%, 40%);
  color: hsl(var(--pill-hue), 100%, 85%);
  font-family: monospace;
  font-size: 0.95rem;
}

.token-ids-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.token-id {
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-family: monospace;
  min-width: 60px;
}

/* Inference Pipeline */
.inference-pipeline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  margin: 20px 0;
  overflow-x: auto;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  text-align: center;
}

.pipeline-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--step-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--step-color);
  margin-bottom: 8px;
}

.pipeline-step strong {
  font-size: 0.85rem;
  color: var(--text-main);
}

.pipeline-step small {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.pipeline-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* Context Window Visualizer */
.context-window-viz {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 20px 0;
}

.context-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  text-align: center;
}

.context-bar {
  display: flex;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.context-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  cursor: help;
  transition: opacity 0.2s;
  overflow: hidden;
  white-space: nowrap;
}

.context-segment:hover {
  opacity: 0.8;
}

.context-segment.system { background: var(--accent-pink); }
.context-segment.user { background: var(--accent-cyan); }
.context-segment.response { background: var(--accent-purple); }
.context-segment.available { background: rgba(255, 255, 255, 0.1); color: var(--text-dim); }

.context-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.context-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.system { background: var(--accent-pink); }
.legend-dot.user { background: var(--accent-cyan); }
.legend-dot.response { background: var(--accent-purple); }
.legend-dot.available { background: rgba(255, 255, 255, 0.1); }

/* Custom colored template items */
.template-item-colored {
  background: var(--cat-bg) !important;
  border-left: 3px solid var(--cat-main) !important;
  margin-bottom: 5px;
  border-radius: var(--radius-sm);
  transition: all 0.18s ease-in-out;
}
.template-item-colored strong {
  color: var(--cat-title) !important;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.template-item-colored small {
  color: var(--text-muted) !important;
  line-height: 1.35;
  transition: color 0.15s ease;
}
.template-item-colored:hover {
  background: color-mix(in srgb, var(--cat-main) 18%, rgba(22, 29, 47, 0.95)) !important;
  border-left: 4px solid var(--cat-title) !important;
  transform: translateX(3px);
}
.template-item-colored:hover strong {
  filter: brightness(1.15);
}
.template-item-colored:hover small {
  color: #e2e8f0 !important;
}

/* ==========================================================================
   EXECUTION BOX (LIVE PIPELINE TRACE & TASK BLOCKS)
   ========================================================================== */
.exec-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.exec-box-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exec-status-pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 12px;
}
.exec-status-pill.idle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}
.exec-status-pill.running {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  animation: pulsePill 1.2s infinite alternate;
}
.exec-status-pill.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}
.exec-status-pill.error {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

@keyframes pulsePill {
  from { opacity: 0.7; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.03); }
}

.exec-box-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.exec-stat-card {
  background: rgba(22, 29, 47, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  text-align: center;
}

.exec-stat-card .stat-num {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.2;
}

.exec-stat-card .stat-name {
  display: block;
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}

.exec-task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* EXECUTION TASK CARD */
.exec-task-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--task-accent, var(--accent-cyan));
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.exec-task-card:hover {
  transform: translateX(3px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.exec-task-card.running {
  border-color: var(--task-accent, var(--accent-amber));
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
  background: linear-gradient(135deg, var(--bg-card), rgba(22, 29, 47, 0.9));
}

.exec-task-card.running::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--task-accent, var(--accent-cyan)), transparent);
  animation: scanProgress 1.5s infinite linear;
}

@keyframes scanProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.exec-task-card.completed {
  border-left-color: var(--accent-green);
}

.exec-task-card.error {
  border-left-color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}

.exec-task-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.exec-task-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.exec-task-icon i {
  width: 14px;
  height: 14px;
}

.exec-task-info {
  flex: 1;
  min-width: 0;
}

.exec-task-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.exec-task-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exec-task-type {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
}

.exec-task-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.exec-task-status-badge.running {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}
.exec-task-status-badge.completed {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}
.exec-task-status-badge.error {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.exec-task-body {
  font-size: 0.74rem;
  background: rgba(10, 13, 20, 0.6);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.exec-section {
  margin-bottom: 6px;
}
.exec-section:last-child {
  margin-bottom: 0;
}

.exec-section-label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.exec-section-label i {
  width: 11px;
  height: 11px;
}

.exec-param-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.exec-param-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
}
.exec-param-chip .chip-key {
  color: var(--text-dim);
}
.exec-param-chip .chip-val {
  color: var(--accent-cyan);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-output-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-main);
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.exec-output-box.placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.exec-copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}
.exec-copy-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

/* ==========================================================================
   INTERACTIVE PRACTICALS LAB & STEPPED ACADEMY STYLES
   ========================================================================== */

/* Navbar Badge */
.badge-pill.bg-pink {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(244, 63, 94, 0.35));
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.4);
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 5px;
}

/* Catalog Modal */
.practicals-modal-backdrop {
  z-index: 9999;
}

.practicals-catalog-card {
  width: 92vw;
  max-width: 1240px;
  height: 88vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 10% 10%, rgba(30, 27, 75, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(168, 85, 247, 0.15);
  border-radius: 16px;
  overflow: hidden;
}

.practicals-catalog-header {
  padding: 18px 24px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.practicals-catalog-header .modal-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.practicals-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

.practicals-catalog-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.practicals-catalog-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.practicals-user-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.stat-badge.xp-badge {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.stat-badge.completed-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

/* Filter & Search Bar */
.practicals-filter-bar {
  padding: 14px 24px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.practicals-tier-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tier-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tier-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.tier-pill.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: #a855f7;
  color: #e9d5ff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.practicals-search-wrapper {
  position: relative;
  min-width: 280px;
}

.practicals-search-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-dim);
}

.practicals-search-wrapper input {
  width: 100%;
  padding: 7px 14px 7px 34px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: #fff;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.practicals-search-wrapper input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Practicals Grid */
.practicals-catalog-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.practicals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.practical-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.practical-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.practical-card.is-completed {
  border-color: rgba(34, 197, 94, 0.3);
}

.card-tier-strip {
  width: 5px;
  flex-shrink: 0;
}

.card-content {
  padding: 16px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-tier-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid;
  background: rgba(255, 255, 255, 0.03);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-xp {
  color: #fbbf24;
  font-weight: 700;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 2px;
}

.card-subtitle {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin: 0 0 10px;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 12px;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag-pill {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-badge.status-done {
  color: #4ade80;
}

.status-badge.status-steps {
  color: var(--text-dim);
}

.practicals-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.practicals-empty-state i {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ==========================================================================
   FLOATING INTERACTIVE HUD (TUTOR CARD OVERLAY ON CANVAS)
   ========================================================================== */

.practical-hud {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 680px;
  z-index: 120;
  pointer-events: auto;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(168, 85, 247, 0.2);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-inner {
  display: flex;
  flex-direction: column;
}

.hud-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
}

.hud-scenario-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.hud-tier-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid;
  background: rgba(255, 255, 255, 0.05);
}

.hud-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-step-counter {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

.hud-progress-container {
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}

.hud-progress-bar {
  height: 100%;
  transition: width 0.35s ease;
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
}

.hud-body {
  padding: 16px 20px;
}

.hud-step-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.hud-step-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.hud-step-text-wrap {
  flex: 1;
}

.hud-step-text-wrap h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
}

.hud-step-instruction {
  font-size: 0.84rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Micro Chips in instructions */
.hud-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.hud-chip.chip-trigger {
  background: rgba(245, 158, 11, 0.2);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.hud-chip.chip-model {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.hud-chip.chip-tool {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.hud-chip.chip-logic {
  background: rgba(236, 72, 153, 0.2);
  color: #f9a8d4;
  border: 1px solid rgba(236, 72, 153, 0.4);
}
.hud-chip.chip-output {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}
.hud-chip.chip-port {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.hud-chip.chip-action {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.45);
}

.hud-step-why {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #fbbf24;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
}
.hud-step-why .why-icon {
  width: 14px;
  height: 14px;
  color: #fbbf24;
  flex-shrink: 0;
  margin-top: 2px;
}

.hud-validation-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  margin-bottom: 14px;
  transition: all 0.25s;
}

.hud-validation-status.is-pending {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fde047;
}

.hud-validation-status.is-satisfied {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.hud-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-left-actions, .hud-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.hud-btn-hint {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border-color: rgba(255, 255, 255, 0.08);
}
.hud-btn-hint:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.hud-btn-autofix {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.25);
}
.hud-btn-autofix:hover {
  background: rgba(56, 189, 248, 0.25);
  color: #fff;
}

.hud-btn-prev {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}
.hud-btn-prev:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hud-btn-next {
  background: linear-gradient(135deg, #a855f7, #6366f1);
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.hud-btn-next:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.4);
}

.hud-btn-pulsing {
  animation: nextPulse 1.8s infinite;
}

@keyframes nextPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Palette Glowing Highlight Pulse */
.practical-highlight-pulse {
  position: relative;
  outline: 2px solid #ec4899 !important;
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.7) !important;
  animation: paletteItemGlow 1.2s infinite alternate !important;
}

@keyframes paletteItemGlow {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(236, 72, 153, 0.4); }
  100% { transform: scale(1.02); box-shadow: 0 0 24px rgba(236, 72, 153, 0.9); }
}

/* Celebration Modal */
.practicals-celeb-backdrop {
  z-index: 10000;
}

.practicals-celeb-card {
  width: 90%;
  max-width: 500px;
  background: radial-gradient(circle at 50% 20%, rgba(30, 27, 75, 0.98), rgba(15, 23, 42, 0.99));
  border: 1px solid rgba(236, 72, 153, 0.4);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 40px rgba(236, 72, 153, 0.25);
  border-radius: 18px;
  overflow: hidden;
  text-align: center;
  padding: 30px 24px;
  position: relative;
}

.celeb-confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.celeb-trophy {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 16px;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}

.celeb-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
}

.celeb-header p {
  font-size: 0.9rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin: 0 0 20px;
}

.celeb-rewards-box {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.reward-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 20px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reward-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.reward-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fbbf24;
}

.celeb-skills-box {
  margin-bottom: 24px;
}

.celeb-skills-box h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.celeb-skills-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.celeb-skill-tag {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.celeb-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   UNIFIED DIALOG MODAL (REPLACES JS ALERTS & CONFIRMS)
   ========================================================================== */

.dialog-backdrop {
  z-index: 10005;
}

.dialog-modal-card {
  width: 90%;
  max-width: 500px;
  background: radial-gradient(circle at 10% 10%, rgba(30, 27, 75, 0.98), rgba(15, 23, 42, 0.99));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.8), 0 0 40px rgba(168, 85, 247, 0.2);
  overflow: hidden;
  animation: dialogPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialogPop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(30, 41, 59, 0.4);
}

.dialog-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dialog-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.dialog-icon-wrapper i {
  width: 22px;
  height: 22px;
}

.dialog-header-text h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 2px;
}

.dialog-subtitle {
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 500;
  display: block;
}

.dialog-body {
  padding: 20px 22px;
}

.dialog-message {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.6;
}

.dialog-message strong {
  color: #fff;
  font-weight: 700;
}

.dialog-hint-content {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #fbbf24;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  color: #fde047;
  font-size: 0.85rem;
  line-height: 1.55;
}

.dialog-details-box {
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.5);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 7px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   CODE EXPORTER MODAL & RUNTIME BANNER STYLES
   ========================================================================== */

.code-export-modal-card {
  width: 92vw;
  max-width: 1040px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 10% 10%, rgba(20, 30, 55, 0.98), rgba(10, 15, 30, 0.99));
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15);
  border-radius: 16px;
  overflow: hidden;
}

.code-run-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  color: #7dd3fc;
}

.code-run-banner i {
  width: 18px;
  height: 18px;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.code-run-banner code {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-weight: 700;
}

.code-block-lg {
  max-height: 480px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  background: #05070e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  color: #a7f3d0;
  padding: 16px;
  white-space: pre;
}

.code-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
}

.code-modal-footer-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 600;
}

.footer-chip i {
  width: 12px;
  height: 12px;
  color: #4ade80;
}

.code-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* KEY PRIVACY & SCOPE BADGES */
.key-fallback-badge {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 4px;
}
.key-fallback-badge.active {
  display: inline-flex;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #34d399;
}
.key-fallback-badge.none {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* ==========================================================================
   MULTI-TOOL PICKER
   ========================================================================== */

.tool-picker-wrapper {
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  margin-top: 4px;
}
.tool-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: rgba(124, 58, 237, 0.1);
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  gap: 8px;
}
.tool-picker-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  padding: 4px 8px;
}
.tool-picker-count {
  font-size: 0.7rem;
  color: #a78bfa;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(124,58,237,0.15);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(124,58,237,0.35);
}
.tool-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 10px;
  min-height: 38px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.15);
}
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid;
  cursor: default;
  user-select: none;
  animation: chipIn 0.18s ease;
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.tool-chip-remove {
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.7;
  margin-left: 2px;
  transition: opacity 0.15s;
}
.tool-chip-remove:hover { opacity: 1; }
.tool-picker-categories {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(124,58,237,0.4) transparent;
}
.tool-picker-categories::-webkit-scrollbar { width: 4px; }
.tool-picker-categories::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 4px; }
.tool-picker-cat { padding: 4px 8px 6px; }
.tool-picker-cat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 2px 4px 5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 5px;
}
.tool-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.tool-picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.02);
  transition: all 0.15s ease;
}
.tool-picker-item:hover {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.45);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.tool-picker-item.selected {
  background: rgba(124,58,237,0.18);
  border-color: var(--tool-color, #7c3aed);
  box-shadow: 0 0 0 1px var(--tool-color, #7c3aed) inset;
}
.tool-item-icon { font-size: 0.9rem; line-height: 1; flex-shrink: 0; }
.tool-item-name {
  font-size: 0.69rem;
  color: var(--text-secondary);
  flex: 1;
  line-height: 1.3;
  font-weight: 500;
}
.tool-picker-item.selected .tool-item-name { color: var(--text-main); }
.tool-item-key-badge { font-size: 0.65rem; opacity: 0.5; flex-shrink: 0; }
.tool-item-check {
  font-size: 0.75rem;
  color: #a78bfa;
  opacity: 0;
  flex-shrink: 0;
  font-weight: 700;
  transition: opacity 0.15s;
}
.tool-picker-item.selected .tool-item-check { opacity: 1; }

/* ==========================================================================
   AGENT MARKDOWN OUTPUT RENDERER
   ========================================================================== */

.agent-md-output {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(52,211,153,0.25);
  border-radius: 6px;
  padding: 12px 14px;
  max-height: 420px;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.6;
  color: #e2e8f0;
  scrollbar-width: thin;
  scrollbar-color: rgba(52,211,153,0.3) transparent;
}
.agent-md-output::-webkit-scrollbar { width: 4px; }
.agent-md-output::-webkit-scrollbar-thumb { background: rgba(52,211,153,0.3); border-radius: 4px; }

.md-h1 { font-size: 1rem; font-weight: 700; color: #f1f5f9; margin: 8px 0 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.md-h2 { font-size: 0.88rem; font-weight: 700; color: #e2e8f0; margin: 10px 0 5px; padding-bottom: 3px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.md-h3 { font-size: 0.82rem; font-weight: 700; color: #cbd5e1; margin: 8px 0 4px; }
.md-h4 { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin: 6px 0 3px; }

.md-p { margin: 5px 0; color: #cbd5e1; }

.md-hr { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 0; }

.md-code-block {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 5px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.72rem;
  line-height: 1.5;
  color: #86efac;
  white-space: pre;
}

.md-inline-code {
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: #c4b5fd;
}

.md-table-wrap { overflow-x: auto; margin: 6px 0; }
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.md-table thead { background: rgba(124,58,237,0.1); }
.md-td {
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.07);
  color: #cbd5e1;
  vertical-align: top;
}
.md-table thead .md-td {
  color: #e2e8f0;
  font-weight: 600;
  border-color: rgba(124,58,237,0.3);
}
.md-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }

.md-ul, .md-ol {
  margin: 4px 0 4px 14px;
  padding-left: 8px;
  color: #cbd5e1;
}
.md-li { margin: 3px 0; line-height: 1.5; }
.md-ul .md-li { list-style-type: disc; }
.md-ol .md-li { list-style-type: decimal; }

.md-blockquote {
  border-left: 3px solid #7c3aed;
  padding: 4px 10px;
  background: rgba(124,58,237,0.07);
  border-radius: 0 4px 4px 0;
  color: #a78bfa;
  font-style: italic;
  margin: 5px 0;
  font-size: 0.76rem;
}

.agent-md-output strong { color: #f1f5f9; font-weight: 700; }
.agent-md-output em { color: #c4b5fd; font-style: italic; }

/* ==========================================================================
   FORMATTED BLOCK OUTPUT VIEWER MODAL & CANVAS AFFORDANCES
   ========================================================================== */

/* Clickable Port Output Hover & Sparkle Indicator */
.port.port-output {
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.port.port-output:hover .port-label {
  color: var(--accent-purple);
}
.port.port-output.has-output .port-dot {
  background: var(--accent-purple);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Dedicated View Output Link on Port */
.btn-port-view-link {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.6rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  user-select: none;
  z-index: 15;
  margin-right: 4px;
}
.btn-port-view-link:hover {
  background: rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
  color: #fff;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
  transform: scale(1.05);
}
.btn-port-view-link i, .btn-port-view-link svg {
  width: 9px;
  height: 9px;
}

/* Node card footer view output action button */
.node-view-output-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  margin-top: 6px;
  width: 100%;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}
.node-view-output-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}
.node-view-output-btn i, .node-view-output-btn svg {
  width: 11px;
  height: 11px;
  pointer-events: none;
}

/* Floating Wire Action Badges */
.wire-view-data-btn:hover {
  filter: brightness(1.2);
  transform: scale(1.04);
}
.wire-del-btn:hover {
  filter: brightness(1.2);
  transform: scale(1.1);
}

/* Clickable Preview Box on Node Cards */
.node-preview-box {
  cursor: text;
  position: relative;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.node-preview-box:hover {
  border-color: var(--accent-cyan) !important;
  background: rgba(56, 189, 248, 0.08) !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}
.node-preview-box::after {
  content: 'Click to expand output';
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 0.58rem;
  color: var(--accent-cyan);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.node-preview-box:hover::after {
  opacity: 0.85;
}

/* Output Modal Card */
.output-viewer-modal-card {
  max-width: 900px;
  width: 90%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(124, 58, 237, 0.18);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.25s ease;
}
.output-viewer-modal-card.fullscreen {
  max-width: 98vw;
  width: 98vw;
  max-height: 96vh;
  height: 96vh;
}

/* Header */
.output-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 18, 30, 0.6);
}
.output-modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.output-modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.35);
}
.output-modal-icon i, .output-modal-icon svg {
  width: 20px;
  height: 20px;
}
.output-modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.output-modal-title-row h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}
.output-modal-header-left small {
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-top: 2px;
  display: block;
}
.output-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges */
.badge-port {
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.badge-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-status.ready {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}
.badge-status.running {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}
.badge-status.idle {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-muted);
}
.badge-status.error {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

#outputViewerModal {
  z-index: 1050;
}

/* Output Toolbar */
.output-viewer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  flex-wrap: wrap;
}
.output-view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}
.output-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.output-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.04);
}
.output-tab-btn.active {
  color: #f8fafc;
  background: rgba(124, 58, 237, 0.25);
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.2);
}
.output-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.output-search-wrapper i, .output-search-wrapper svg {
  position: absolute;
  left: 8px;
  width: 13px;
  height: 13px;
  color: var(--text-dim);
  pointer-events: none;
}
.output-search-wrapper input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 8px 5px 28px;
  font-size: 0.75rem;
  color: #f8fafc;
  width: 190px;
  transition: width 0.2s, border-color 0.2s;
}
.output-search-wrapper input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  width: 240px;
}

/* Output Body Container */
.output-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  max-height: 58vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.4) transparent;
}
.output-viewer-modal-card.fullscreen .output-viewer-body {
  max-height: calc(96vh - 160px);
}

/* Formatted Views */
.out-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.out-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Markdown View inside Output Modal */
.out-markdown-view {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #e2e8f0;
}
.out-markdown-view h1, .out-markdown-view .md-h1 {
  font-size: 1.15rem;
  color: #f8fafc;
  margin-top: 14px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.out-markdown-view h2, .out-markdown-view .md-h2 {
  font-size: 1.02rem;
  color: #cbd5e1;
  margin-top: 12px;
  margin-bottom: 6px;
}
.out-markdown-view pre {
  background: #090d16;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  position: relative;
  margin: 10px 0;
}
.out-markdown-view code {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.8rem;
  color: #38bdf8;
}

/* Copy button inside code block */
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 6px 6px 0 0;
  margin: 10px 0 -10px;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.btn-copy-code {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-copy-code:hover {
  color: #fff;
}

/* Image View */
.out-image-wrapper {
  text-align: center;
  padding: 10px;
}
.out-image-wrapper img {
  max-width: 100%;
  max-height: 480px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.out-image-prompt-card {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #cbd5e1;
  text-align: left;
}

/* RAG Document Match Cards */
.out-rag-doc-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: all 0.15s;
}
.out-rag-doc-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.05);
}
.out-rag-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 4px;
}
.out-rag-score-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--accent-green);
}

/* Agent Step Timeline */
.out-agent-step {
  border-left: 2px solid var(--accent-purple);
  padding-left: 12px;
  margin-bottom: 12px;
  position: relative;
}
.out-agent-step::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-purple);
}
.out-agent-step-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 4px;
}
.out-agent-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #e2e8f0;
  margin-top: 4px;
}

/* Chunks Cards */
.out-chunk-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.out-chunk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 4px;
}

/* JSON Tree Styles */
.json-collapsible {
  margin: 2px 0;
}
.json-summary {
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.json-summary::-webkit-details-marker { display: none; }
.json-summary::before {
  content: '▶';
  font-size: 0.6rem;
  color: var(--text-muted);
  display: inline-block;
  transition: transform 0.15s;
}
.json-collapsible[open] > .json-summary::before {
  transform: rotate(90deg);
}
.json-tree-block {
  padding-left: 16px;
  border-left: 1px dashed rgba(255, 255, 255, 0.1);
  margin-left: 4px;
}
.json-tree-row {
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
.json-key { color: #38bdf8; font-weight: 600; }
.json-str { color: #34d399; }
.json-num { color: #fbbf24; }
.json-bool { color: #c084fc; font-weight: 600; }
.json-null { color: #f43f5e; font-weight: 600; }
.json-type-label { color: var(--text-muted); font-size: 0.7rem; font-style: italic; }

/* Raw Monospace Box */
.out-raw-box {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  line-height: 1.6;
  color: #f1f5f9;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 52vh;
  overflow-y: auto;
}

/* Stats / Metrics Grid */
.out-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.out-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 10px 14px;
}
.out-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.out-stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 4px;
}

/* Empty / Awaiting Execution State */
.out-empty-state {
  text-align: center;
  padding: 36px 20px;
}
.out-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-purple);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.out-empty-state h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 6px;
}
.out-empty-state p {
  color: var(--text-dim);
  font-size: 0.8rem;
  max-width: 460px;
  margin: 0 auto 16px;
}

/* Footer */
.output-viewer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 18, 30, 0.6);
  flex-wrap: wrap;
  gap: 10px;
}
.output-footer-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.output-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── DEDICATED CHAT RESULT DISPLAY CARD ── */
.out-chat-result-card {
  border-radius: 10px;
  padding: 16px;
  background: rgba(6, 78, 59, 0.08) !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 15px rgba(16, 185, 129, 0.08);
}
.out-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.out-chat-bubble {
  border-radius: 8px;
  transition: all 0.15s ease;
}
.out-chat-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.out-chat-user {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.out-chat-assistant {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.out-chat-assistant:hover {
  border-color: rgba(16, 185, 129, 0.5);
}





/* ==========================================================================
   BUSINESS PORTAL
   ========================================================================== */

.portal-open .left-panel,
.portal-open .right-panel,
.portal-open .canvas-workspace,
.portal-open .canvas-controls,
.portal-open .explorer-banner,
.portal-open .template-lesson-banner,
.portal-open .panel-expand-tab,
.portal-open .panel-divider {
  display: none !important;
}

.business-portal {
  display: none;
  width: 100%;
  height: 100%;
  background: var(--bg-main);
  overflow-y: auto;
  padding: 40px 20px;
  box-sizing: border-box;
}

.portal-open .business-portal {
  display: block;
}

.bp-container {
  max-width: 1000px;
  margin: 0 auto;
}

.bp-header-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bp-header-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.bp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.bp-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bp-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(56, 189, 248, 0.1);
  background: rgba(30, 41, 59, 0.8);
}

.bp-card-icon {
  width: 48px;
  height: 48px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-card-icon svg, .bp-card-icon i {
  width: 24px;
  height: 24px;
}

.bp-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.bp-card-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
  flex-grow: 1;
}

/* WORKSPACE */
.bp-workspace {
  animation: fadeIn 0.3s ease-out;
}

.bp-back-btn {
  margin-bottom: 20px;
  padding-left: 0;
}

.bp-active-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.bp-active-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 30px;
}

.bp-form-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 30px;
}

.bp-inputs-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 30px;
}

.bp-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bp-field label {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.bp-field textarea {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s;
}

.bp-field textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.bp-execute-btn {
  width: 100%;
  padding: 16px !important;
  font-size: 1.1rem !important;
  justify-content: center;
  border-radius: var(--radius-md);
}

.bp-result-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-lg);
  padding: 30px;
  animation: slideUp 0.4s ease-out;
}

.bp-result-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
  margin-bottom: 20px;
  color: #fff;
}

.bp-result-content {
  color: var(--text-main);
  line-height: 1.6;
  font-size: 1.05rem;
}

