/* ============================================
   STORYBOARD APP v1.0 — Part 1: Core Styles
   Drupal Asset Injector CSS (Part 1)
   Target: Content type "storyboard" pages
   
   PART 1 STYLES:
   1.  CSS Variables (colors, fonts, spacing, themes)
   2.  Reset & Font imports
   3.  App Shell & Toolbar
   4.  Mode Toggle (Edit/Play)
   5.  Edit Tools & View Tools
   6.  Canvas Container
   7.  Canvas Grid
   8.  Scene Nodes (story, decision, ending)
   9.  Node Handles & Connection Points
   10. SVG Connections
   11. Minimap
   12. View Mode Container
   13. View Mode Scene Display
   14. Decision Options
   15. Ending Screen
   16. Progress Indicator
   17. Empty States
   18. Toast Notifications
   19. Themes (cinematic, light, sepia, noir, fantasy)
   20. Animations & Transitions
   21. Scrollbar Styling
   22. Responsive: Tablet (768–1200px)
   23. Responsive: Mobile (<768px)
   24. Print Styles
   25. Accessibility
   ============================================ */

/* === 1. CSS VARIABLES === */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Crimson+Pro:ital,wght@0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* === CINEMATIC THEME (Default) === */
  --sb-bg: #0f172a;
  --sb-bg-secondary: #1e293b;
  --sb-surface: #1e293b;
  --sb-surface-hover: #334155;
  --sb-surface-elevated: #334155;
  --sb-text: #f1f5f9;
  --sb-text-secondary: #94a3b8;
  --sb-text-muted: #64748b;
  --sb-border: #334155;
  --sb-border-light: #475569;
  --sb-border-focus: #3b82f6;
  --sb-accent: #3b82f6;
  --sb-accent-light: rgba(59, 130, 246, 0.15);
  --sb-accent-dark: #2563eb;
  
  /* Radius */
  --sb-radius: 12px;
  --sb-radius-sm: 8px;
  --sb-radius-lg: 16px;
  --sb-radius-xl: 24px;
  
  /* Shadows */
  --sb-shadow-sm: 0 2px 4px rgba(0,0,0,.3);
  --sb-shadow: 0 4px 12px rgba(0,0,0,.4);
  --sb-shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  --sb-shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  
  /* Typography */
  --sb-font-body: 'DM Sans', system-ui, sans-serif;
  --sb-font-display: 'Plus Jakarta Sans', 'DM Sans', sans-serif;
  --sb-font-story: 'Crimson Pro', Georgia, serif;
  --sb-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Layout */
  --sb-toolbar-h: 56px;
  --sb-transition: .2s cubic-bezier(.4,0,.2,1);
  --sb-transition-slow: .4s cubic-bezier(.4,0,.2,1);
  
  /* Scene type colors */
  --sb-story: #3b82f6;
  --sb-decision: #f59e0b;
  --sb-ending: #10b981;
  
  /* Ending type colors */
  --sb-ending-good: #10b981;
  --sb-ending-bad: #ef4444;
  --sb-ending-neutral: #64748b;
  --sb-ending-twist: #8b5cf6;
  --sb-ending-true: #eab308;
  --sb-ending-secret: #ec4899;
  
  /* Option colors */
  --sb-option-1: #3b82f6;
  --sb-option-2: #10b981;
  --sb-option-3: #f59e0b;
  --sb-option-4: #8b5cf6;
  
  /* Canvas */
  --sb-canvas-bg: #0a0f1a;
  --sb-grid-color: rgba(255, 255, 255, 0.03);
  --sb-grid-color-strong: rgba(255, 255, 255, 0.06);
  
  /* Node dimensions */
  --sb-node-width: 200px;
  --sb-node-height: 120px;
}

/* === 2. RESET & BASE === */
.node--type-storyboard .file--mime-application-json { display: none !important; }
.node--type-storyboard h1.page-title,
.node--type-storyboard .page-title,
.node--type-storyboard article > h2 { display: none !important; }
.node--type-storyboard .node__content { padding: 0 !important; margin: 0 !important; max-width: none !important; }
.node--type-storyboard #block-system-main,
.node--type-storyboard .region-content,
.node--type-storyboard main { padding: 0 !important; margin: 0 !important; max-width: none !important; }

/* === 3. APP SHELL === */
.sb-app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sb-font-body);
  color: var(--sb-text);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow: hidden;
}

.sb-app *, .sb-app *::before, .sb-app *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Toolbar */
.sb-toolbar {
  position: relative;
  z-index: 100;
  height: var(--sb-toolbar-h);
  min-height: var(--sb-toolbar-h);
  background: var(--sb-surface);
  border-bottom: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

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

.sb-toolbar-left { flex: 1; min-width: 0; }
.sb-toolbar-center { flex: 0 0 auto; }
.sb-toolbar-right { flex: 1; justify-content: flex-end; min-width: 0; }

.sb-toolbar-title {
  font-family: var(--sb-font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--sb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-toolbar-title i {
  color: var(--sb-accent);
  font-size: 1.1rem;
}

.sb-toolbar-subtitle {
  font-size: .8rem;
  color: var(--sb-text-muted);
  white-space: nowrap;
  padding-left: 12px;
  margin-left: 12px;
  border-left: 1px solid var(--sb-border);
}

/* === 4. MODE TOGGLE === */
.sb-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  padding: 4px;
  gap: 4px;
}

.sb-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--sb-radius-sm);
  background: transparent;
  color: var(--sb-text-secondary);
  font-family: var(--sb-font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--sb-transition);
  white-space: nowrap;
}

.sb-mode-btn:hover {
  background: var(--sb-surface-hover);
  color: var(--sb-text);
}

.sb-mode-btn.sb-active {
  background: var(--sb-accent);
  color: #ffffff;
  box-shadow: var(--sb-shadow-sm);
}

.sb-mode-btn i {
  font-size: .9rem;
}

/* === 5. BUTTONS === */
.sb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
  background: var(--sb-surface);
  color: var(--sb-text);
  font-family: var(--sb-font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--sb-transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.sb-btn:hover {
  background: var(--sb-surface-hover);
  border-color: var(--sb-accent);
  color: var(--sb-accent);
}

.sb-btn.sb-active {
  background: var(--sb-accent-light);
  border-color: var(--sb-accent);
  color: var(--sb-accent);
}

.sb-btn-primary {
  background: var(--sb-accent);
  border-color: var(--sb-accent);
  color: #ffffff;
}

.sb-btn-primary:hover {
  background: var(--sb-accent-dark);
  border-color: var(--sb-accent-dark);
  color: #ffffff;
}

.sb-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: .9rem;
}

.sb-btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: .8rem;
}

.sb-btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  border-radius: var(--sb-radius);
}

.sb-btn-text { /* span wrapping button text */ }

.sb-divider {
  width: 1px;
  height: 24px;
  background: var(--sb-border);
  margin: 0 4px;
}

.sb-hidden { display: none !important; }

/* Zoom level display */
.sb-zoom-level {
  font-family: var(--sb-font-mono);
  font-size: .75rem;
  color: var(--sb-text-muted);
  min-width: 48px;
  text-align: center;
}

/* === 6. CANVAS CONTAINER === */
.sb-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.sb-canvas-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--sb-canvas-bg);
  cursor: grab;
}

.sb-canvas-container:active,
.sb-panning .sb-canvas-container {
  cursor: grabbing;
}

.sb-canvas {
  position: absolute;
  width: 10000px;
  height: 10000px;
  transform-origin: 0 0;
  will-change: transform;
}

/* === 7. CANVAS GRID === */
.sb-canvas-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(var(--sb-grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--sb-grid-color) 1px, transparent 1px),
    linear-gradient(var(--sb-grid-color-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--sb-grid-color-strong) 1px, transparent 1px);
  background-size: 
    20px 20px,
    20px 20px,
    100px 100px,
    100px 100px;
  pointer-events: none;
}

/* Nodes layer */
.sb-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
}

/* === 8. SCENE NODES === */
.sb-node {
  position: absolute;
  width: var(--sb-node-width);
  min-height: var(--sb-node-height);
  background: var(--sb-surface);
  border: 2px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow);
  cursor: move;
  transition: box-shadow var(--sb-transition), border-color var(--sb-transition), transform 0.1s ease;
  overflow: hidden;
  user-select: none;
}

.sb-node:hover {
  border-color: var(--sb-border-light);
  box-shadow: var(--sb-shadow-lg);
}

.sb-node-selected {
  border-color: var(--sb-accent) !important;
  box-shadow: var(--sb-shadow-glow), var(--sb-shadow-lg);
}

.sb-node-connecting {
  border-style: dashed;
  animation: sbPulse 1s ease infinite;
}

/* Node type styling */
.sb-node-story { border-color: var(--sb-story); }
.sb-node-decision { border-color: var(--sb-decision); }
.sb-node-ending { border-color: var(--sb-ending); }

/* Start badge */
.sb-node-start-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 10px;
  background: var(--sb-accent);
  color: #ffffff;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--sb-shadow-sm);
  z-index: 10;
}

.sb-node-start-badge i {
  font-size: .55rem;
}

/* Node type badge */
.sb-node-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  font-size: .65rem;
  font-weight: 600;
  color: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

.sb-node-type-badge i {
  font-size: .6rem;
}

/* Decision number badge */
.sb-node-decision-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  background: var(--sb-decision);
  color: #ffffff;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 4px;
  z-index: 5;
}

/* Node thumbnail */
.sb-node-thumbnail {
  width: 100%;
  height: 60px;
  background-size: cover;
  background-position: center;
  background-color: var(--sb-bg);
  border-bottom: 1px solid var(--sb-border);
}

.sb-node-thumbnail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-text-muted);
  font-size: 1.2rem;
}

/* Node content */
.sb-node-content {
  padding: 10px 12px 8px;
}

.sb-node-title {
  font-family: var(--sb-font-display);
  font-size: .82rem;
  font-weight: 600;
  color: var(--sb-text);
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-node-desc {
  font-size: .72rem;
  color: var(--sb-text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Node footer */
.sb-node-footer {
  padding: 6px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sb-node-options-count,
.sb-node-ending-type,
.sb-node-connection {
  font-size: .7rem;
  color: var(--sb-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sb-node-options-count i,
.sb-node-connection i {
  font-size: .65rem;
}

/* === 9. NODE HANDLES === */
.sb-node-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--sb-surface);
  border: 2px solid var(--sb-border-light);
  border-radius: 50%;
  cursor: crosshair;
  opacity: 0;
  transition: all var(--sb-transition);
  z-index: 20;
}

.sb-node:hover .sb-node-handle,
.sb-node-selected .sb-node-handle {
  opacity: 1;
}

.sb-node-handle:hover {
  background: var(--sb-accent);
  border-color: var(--sb-accent);
  transform: scale(1.2);
}

.sb-node-handle-in {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.sb-node-handle-out {
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.sb-node-handle-in:hover {
  transform: translateY(-50%) scale(1.2);
}

.sb-node-handle-out:hover {
  transform: translateY(-50%) scale(1.2);
}

/* === 10. SVG CONNECTIONS === */
.sb-connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.sb-connection {
  stroke-linecap: round;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke-width var(--sb-transition);
}

.sb-connection:hover {
  stroke-width: 4;
}

.sb-connection-label {
  font-family: var(--sb-font-body);
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
  pointer-events: none;
}

/* === 11. MINIMAP === */
.sb-minimap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 180px;
  height: 120px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
  box-shadow: var(--sb-shadow);
  overflow: hidden;
  z-index: 50;
}

.sb-minimap-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.sb-minimap-node {
  position: absolute;
  border-radius: 2px;
  opacity: 0.8;
}

.sb-minimap-viewport {
  position: absolute;
  border: 2px solid var(--sb-accent);
  background: rgba(59, 130, 246, 0.1);
  border-radius: 2px;
  pointer-events: none;
}

/* Empty canvas state */
.sb-empty-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background: radial-gradient(circle at center, var(--sb-surface) 0%, var(--sb-canvas-bg) 70%);
}

.sb-empty-icon {
  font-size: 4rem;
  color: var(--sb-text-muted);
  margin-bottom: 20px;
  opacity: 0.5;
}

.sb-empty-canvas h2 {
  font-family: var(--sb-font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sb-text);
  margin-bottom: 12px;
}

.sb-empty-canvas p {
  font-size: .95rem;
  color: var(--sb-text-secondary);
  max-width: 400px;
  margin-bottom: 24px;
}

/* === 12. VIEW MODE CONTAINER === */
.sb-view-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--sb-bg);
  overflow-y: auto;
}

.sb-view-scene {
  width: 100%;
  max-width: 800px;
  background: var(--sb-surface);
  border-radius: var(--sb-radius-lg);
  box-shadow: var(--sb-shadow-lg);
  overflow: hidden;
  animation: sbSlideIn var(--sb-transition-slow) ease;
}

/* === 13. VIEW MODE SCENE DISPLAY === */
.sb-view-image {
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background-size: cover;
  background-position: center;
  background-color: var(--sb-bg);
  position: relative;
}

.sb-view-image-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 40%;
}

.sb-view-image-empty i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
  color: var(--sb-text-muted);
  opacity: 0.3;
}

.sb-view-content {
  padding: 32px 40px;
}

.sb-view-title {
  font-family: var(--sb-font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--sb-text);
  margin-bottom: 16px;
  line-height: 1.3;
}

.sb-view-description {
  font-family: var(--sb-font-story);
  font-size: 1.15rem;
  color: var(--sb-text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.sb-view-dialogue {
  font-family: var(--sb-font-story);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--sb-text);
  padding: 20px 24px;
  background: var(--sb-bg);
  border-left: 4px solid var(--sb-accent);
  border-radius: 0 var(--sb-radius-sm) var(--sb-radius-sm) 0;
  margin-top: 20px;
}

.sb-view-dialogue i {
  color: var(--sb-accent);
  margin-right: 8px;
  opacity: 0.7;
}

/* === 14. DECISION OPTIONS === */
.sb-view-actions {
  padding: 24px 40px 40px;
  border-top: 1px solid var(--sb-border);
}

.sb-view-actions-continue {
  display: flex;
  justify-content: center;
}

.sb-continue-btn {
  min-width: 200px;
}

.sb-continue-btn i {
  transition: transform var(--sb-transition);
}

.sb-continue-btn:hover i {
  transform: translateX(4px);
}

.sb-view-question {
  font-family: var(--sb-font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--sb-text);
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.sb-view-question i {
  color: var(--sb-decision);
  font-size: 1.2rem;
}

.sb-view-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-option-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: var(--sb-radius);
  font-family: var(--sb-font-body);
  cursor: pointer;
  transition: all var(--sb-transition);
  text-align: left;
  box-shadow: var(--sb-shadow-sm);
}

.sb-option-btn:hover {
  transform: translateX(6px);
  box-shadow: var(--sb-shadow);
}

.sb-option-btn:active {
  transform: translateX(3px) scale(0.99);
}

.sb-option-selected {
  transform: scale(0.98);
  opacity: 0.8;
}

.sb-option-letter {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-family: var(--sb-font-display);
  font-size: 1rem;
  font-weight: 700;
}

.sb-option-content {
  flex: 1;
  min-width: 0;
}

.sb-option-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.sb-option-hint {
  display: block;
  font-size: .85rem;
  opacity: 0.8;
  margin-top: 4px;
}

/* === 15. ENDING SCREEN === */
.sb-ending-container {
  background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-bg-secondary) 100%);
}

.sb-ending-screen {
  width: 100%;
  max-width: 700px;
  text-align: center;
  animation: sbFadeIn var(--sb-transition-slow) ease;
}

.sb-ending-badge {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .2em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.sb-ending-badge i {
  font-size: 1.2rem;
}

.sb-ending-title {
  font-family: var(--sb-font-display);
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  line-height: 1.2;
}

.sb-ending-title i {
  font-size: 2rem;
}

.sb-ending-image {
  width: 100%;
  max-width: 500px;
  height: 0;
  padding-bottom: 56.25%;
  margin: 0 auto 24px;
  background-size: cover;
  background-position: center;
  background-color: var(--sb-surface);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow-lg);
  position: relative;
}

.sb-ending-image-empty {
  padding-bottom: 35%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sb-ending-image-empty i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  opacity: 0.5;
}

.sb-ending-description {
  font-family: var(--sb-font-story);
  font-size: 1.2rem;
  color: var(--sb-text-secondary);
  line-height: 1.7;
  max-width: 550px;
  margin: 0 auto 32px;
}

/* Path visualization */
.sb-ending-path-section {
  margin-bottom: 32px;
}

.sb-ending-path-section h3 {
  font-family: var(--sb-font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--sb-text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 16px;
}

.sb-ending-path {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sb-ending-path-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--sb-surface);
  border-radius: var(--sb-radius-sm);
  box-shadow: var(--sb-shadow-sm);
}

.sb-ending-path-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sb-accent);
  color: #ffffff;
  font-size: .75rem;
  font-weight: 700;
  border-radius: 50%;
}

.sb-ending-path-choice {
  font-size: .8rem;
  color: var(--sb-text);
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-ending-path-arrow {
  color: var(--sb-text-muted);
  font-size: .8rem;
}

/* Stats */
.sb-ending-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  color: var(--sb-text-muted);
}

.sb-ending-stat {
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-ending-stat i {
  color: var(--sb-accent);
}

/* Ending actions */
.sb-ending-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* === 16. PROGRESS INDICATOR === */
.sb-progress-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.sb-progress-label {
  font-size: .75rem;
  color: var(--sb-text-muted);
  margin-right: 4px;
}

.sb-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sb-border);
  transition: all var(--sb-transition);
}

.sb-progress-dot-filled {
  background: var(--sb-accent);
}

.sb-progress-dot-current {
  background: var(--sb-decision);
  box-shadow: 0 0 8px var(--sb-decision);
  animation: sbPulse 1.5s ease infinite;
}

.sb-progress-dot-empty {
  background: var(--sb-border);
}

.sb-progress-count {
  font-family: var(--sb-font-mono);
  font-size: .75rem;
  color: var(--sb-text-muted);
  margin-left: 4px;
}

/* === 17. EMPTY STATES === */
.sb-view-empty {
  text-align: center;
  padding: 60px 40px;
}

.sb-view-empty-icon {
  font-size: 4rem;
  color: var(--sb-text-muted);
  opacity: 0.4;
  margin-bottom: 24px;
}

.sb-view-empty h2 {
  font-family: var(--sb-font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sb-text);
  margin-bottom: 12px;
}

.sb-view-empty p {
  font-size: 1rem;
  color: var(--sb-text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Loading state */
.sb-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--sb-bg);
  color: var(--sb-text-muted);
  font-size: .95rem;
}

.sb-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--sb-border);
  border-top-color: var(--sb-accent);
  border-radius: 50%;
  animation: sbSpin 1s linear infinite;
}

/* Error state */
.sb-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background: var(--sb-bg);
}

.sb-error i {
  font-size: 3rem;
  color: #ef4444;
  margin-bottom: 16px;
}

.sb-error p {
  font-size: 1rem;
  color: var(--sb-text-secondary);
  max-width: 400px;
}

.sb-error small {
  color: var(--sb-text-muted);
  font-family: var(--sb-font-mono);
}

/* === 18. TOAST NOTIFICATIONS === */
.sb-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--sb-surface-elevated);
  color: var(--sb-text);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow-lg);
  font-size: .9rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all var(--sb-transition);
}

.sb-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.sb-toast i {
  font-size: .95rem;
}

.sb-toast-success { border-color: var(--sb-ending-good); }
.sb-toast-success i { color: var(--sb-ending-good); }

.sb-toast-error { border-color: var(--sb-ending-bad); }
.sb-toast-error i { color: var(--sb-ending-bad); }

/* === 19. THEMES === */

/* Light Theme */
.sb-app.sb-theme-light {
  --sb-bg: #f8fafc;
  --sb-bg-secondary: #f1f5f9;
  --sb-surface: #ffffff;
  --sb-surface-hover: #f1f5f9;
  --sb-surface-elevated: #ffffff;
  --sb-text: #0f172a;
  --sb-text-secondary: #475569;
  --sb-text-muted: #94a3b8;
  --sb-border: #e2e8f0;
  --sb-border-light: #cbd5e1;
  --sb-canvas-bg: #e2e8f0;
  --sb-grid-color: rgba(0, 0, 0, 0.05);
  --sb-grid-color-strong: rgba(0, 0, 0, 0.1);
  --sb-shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --sb-shadow: 0 2px 8px rgba(0,0,0,.1);
  --sb-shadow-lg: 0 8px 24px rgba(0,0,0,.12);
}

/* Sepia Theme */
.sb-app.sb-theme-sepia {
  --sb-bg: #fef3c7;
  --sb-bg-secondary: #fde68a;
  --sb-surface: #fffbeb;
  --sb-surface-hover: #fef3c7;
  --sb-surface-elevated: #ffffff;
  --sb-text: #78350f;
  --sb-text-secondary: #92400e;
  --sb-text-muted: #b45309;
  --sb-border: #fcd34d;
  --sb-border-light: #fbbf24;
  --sb-accent: #92400e;
  --sb-accent-light: rgba(146, 64, 14, 0.1);
  --sb-canvas-bg: #fde68a;
  --sb-grid-color: rgba(120, 53, 15, 0.05);
  --sb-grid-color-strong: rgba(120, 53, 15, 0.1);
}

/* Noir Theme */
.sb-app.sb-theme-noir {
  --sb-bg: #171717;
  --sb-bg-secondary: #262626;
  --sb-surface: #262626;
  --sb-surface-hover: #404040;
  --sb-surface-elevated: #404040;
  --sb-text: #fafafa;
  --sb-text-secondary: #a3a3a3;
  --sb-text-muted: #737373;
  --sb-border: #404040;
  --sb-border-light: #525252;
  --sb-accent: #a3a3a3;
  --sb-accent-light: rgba(163, 163, 163, 0.1);
  --sb-canvas-bg: #0a0a0a;
  --sb-grid-color: rgba(255, 255, 255, 0.03);
  --sb-grid-color-strong: rgba(255, 255, 255, 0.06);
}

/* Fantasy Theme */
.sb-app.sb-theme-fantasy {
  --sb-bg: #1e1b4b;
  --sb-bg-secondary: #312e81;
  --sb-surface: #312e81;
  --sb-surface-hover: #3730a3;
  --sb-surface-elevated: #4338ca;
  --sb-text: #e0e7ff;
  --sb-text-secondary: #a5b4fc;
  --sb-text-muted: #818cf8;
  --sb-border: #4338ca;
  --sb-border-light: #6366f1;
  --sb-accent: #a78bfa;
  --sb-accent-light: rgba(167, 139, 250, 0.15);
  --sb-canvas-bg: #0f0d2e;
  --sb-grid-color: rgba(167, 139, 250, 0.05);
  --sb-grid-color-strong: rgba(167, 139, 250, 0.1);
  --sb-shadow-glow: 0 0 30px rgba(167, 139, 250, 0.3);
}

/* === 20. ANIMATIONS === */
@keyframes sbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sbSlideIn {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes sbSpin {
  to { transform: rotate(360deg); }
}

@keyframes sbPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* View mode transitions */
.sb-view-exit {
  animation: sbViewExit 0.2s ease forwards;
}

@keyframes sbViewExit {
  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

.sb-view-enter {
  animation: sbViewEnter 0.3s ease forwards;
}

@keyframes sbViewEnter {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Node animations */
.sb-node {
  animation: sbNodeAppear 0.3s ease;
}

@keyframes sbNodeAppear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* === 21. SCROLLBAR STYLING === */
.sb-view-container::-webkit-scrollbar { width: 8px; }
.sb-view-container::-webkit-scrollbar-track { background: transparent; }
.sb-view-container::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 4px; }
.sb-view-container::-webkit-scrollbar-thumb:hover { background: var(--sb-text-muted); }

/* === 22. RESPONSIVE: TABLET (768–1200px) === */
@media (max-width: 1200px) {
  .sb-toolbar { padding: 0 16px; }
  .sb-toolbar-subtitle { display: none; }
  .sb-toolbar .sb-btn-text { display: none; }
  
  .sb-mode-btn {
    padding: 0 12px;
    font-size: .8rem;
  }
  
  .sb-mode-btn .sb-btn-text { display: none; }
  
  .sb-view-container { padding: 30px; }
  .sb-view-scene { max-width: 700px; }
  .sb-view-content { padding: 24px 30px; }
  .sb-view-title { font-size: 1.5rem; }
  .sb-view-description { font-size: 1.05rem; }
  .sb-view-actions { padding: 20px 30px 30px; }
  
  .sb-ending-title { font-size: 2rem; }
  .sb-ending-path-step { padding: 10px 12px; }
  
  .sb-minimap { width: 150px; height: 100px; }
}

/* === 23. RESPONSIVE: MOBILE (<768px) === */
@media (max-width: 767px) {
  :root {
    --sb-toolbar-h: 50px;
  }
  
  .sb-toolbar {
    padding: 0 12px;
    gap: 6px;
  }
  
  .sb-toolbar-title {
    font-size: .9rem;
    max-width: 150px;
  }
  
  .sb-toolbar-subtitle { display: none; }
  
  .sb-toolbar .sb-btn-text,
  .sb-toolbar .sb-divider { display: none; }
  
  .sb-mode-toggle {
    padding: 2px;
    gap: 2px;
  }
  
  .sb-mode-btn {
    height: 32px;
    padding: 0 10px;
    font-size: .75rem;
  }
  
  .sb-mode-btn .sb-btn-text { display: none; }
  
  .sb-btn {
    height: 32px;
    padding: 0 10px;
    font-size: .8rem;
  }
  
  .sb-btn-icon {
    width: 32px;
    height: 32px;
    font-size: .85rem;
  }
  
  .sb-zoom-level { display: none; }
  
  /* Canvas */
  .sb-minimap { display: none; }
  
  .sb-node {
    --sb-node-width: 160px;
    --sb-node-height: 100px;
  }
  
  .sb-node-title { font-size: .75rem; }
  .sb-node-desc { font-size: .68rem; }
  .sb-node-type-badge { font-size: .6rem; padding: 2px 6px; }
  
  /* View mode */
  .sb-view-container {
    padding: 16px;
    align-items: flex-start;
  }
  
  .sb-view-scene {
    border-radius: var(--sb-radius);
  }
  
  .sb-view-image {
    padding-bottom: 50%;
  }
  
  .sb-view-content {
    padding: 20px;
  }
  
  .sb-view-title {
    font-size: 1.25rem;
    margin-bottom: 12px;
  }
  
  .sb-view-description {
    font-size: 1rem;
    line-height: 1.6;
  }
  
  .sb-view-dialogue {
    font-size: 1rem;
    padding: 14px 16px;
  }
  
  .sb-view-actions {
    padding: 16px 20px 24px;
  }
  
  .sb-view-question {
    font-size: 1rem;
    margin-bottom: 16px;
  }
  
  .sb-option-btn {
    padding: 14px 16px;
    gap: 12px;
  }
  
  .sb-option-letter {
    width: 32px;
    height: 32px;
    font-size: .9rem;
  }
  
  .sb-option-label { font-size: .95rem; }
  .sb-option-hint { font-size: .8rem; }
  
  .sb-continue-btn { min-width: 160px; }
  
  /* Ending */
  .sb-ending-title {
    font-size: 1.6rem;
    flex-direction: column;
    gap: 8px;
  }
  
  .sb-ending-title i { font-size: 1.5rem; }
  
  .sb-ending-image {
    max-width: 100%;
  }
  
  .sb-ending-description {
    font-size: 1rem;
    padding: 0 16px;
  }
  
  .sb-ending-path {
    flex-direction: column;
    gap: 4px;
  }
  
  .sb-ending-path-step {
    flex-direction: row;
    width: 100%;
    max-width: 280px;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 16px;
  }
  
  .sb-ending-path-arrow {
    transform: rotate(90deg);
  }
  
  .sb-ending-path-choice {
    max-width: none;
    flex: 1;
  }
  
  .sb-ending-actions {
    flex-direction: column;
    width: 100%;
    padding: 0 20px;
  }
  
  .sb-ending-actions .sb-btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Progress indicator */
  .sb-progress-indicator {
    padding: 0 8px;
    gap: 6px;
  }
  
  .sb-progress-label { display: none; }
  .sb-progress-dot { width: 8px; height: 8px; }
  
  /* Toast */
  .sb-toast {
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(80px);
    text-align: center;
    justify-content: center;
  }
  
  .sb-toast.show {
    transform: translateX(0) translateY(0);
  }
  
  /* Empty states */
  .sb-empty-canvas h2 { font-size: 1.25rem; }
  .sb-empty-canvas p { font-size: .9rem; }
  .sb-empty-icon { font-size: 3rem; }
}

/* === 24. PRINT STYLES === */
@media print {
  .sb-toolbar,
  .sb-toast,
  .sb-minimap,
  .sb-edit-tools,
  .sb-view-tools,
  .sb-mode-toggle,
  .sb-ending-actions { display: none !important; }
  
  .sb-app {
    min-height: auto;
    background: #fff;
    color: #000;
  }
  
  .sb-main { overflow: visible; }
  
  .sb-view-container {
    position: static;
    padding: 20px;
    background: #fff;
  }
  
  .sb-view-scene {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .sb-node {
    box-shadow: none;
    border: 1px solid #ccc;
    animation: none;
  }
}

/* === 25. ACCESSIBILITY === */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sb-node,
  .sb-view-scene,
  .sb-ending-screen,
  .sb-toast,
  .sb-spinner {
    animation: none;
    transition: none;
  }
  
  .sb-option-btn:hover {
    transform: none;
  }
  
  .sb-continue-btn:hover i {
    transform: none;
  }
  
  .sb-progress-dot-current {
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .sb-node { border-width: 3px; }
  .sb-option-btn { border: 2px solid currentColor; }
  .sb-progress-dot { border: 2px solid var(--sb-text); }
}

/* Focus styles for keyboard navigation */
.sb-btn:focus-visible,
.sb-mode-btn:focus-visible,
.sb-option-btn:focus-visible {
  outline: 2px solid var(--sb-accent);
  outline-offset: 2px;
}

.sb-node:focus-visible {
  border-color: var(--sb-accent);
  box-shadow: var(--sb-shadow-glow);
  outline: none;
}

/* Dragging state */
.sb-dragging {
  cursor: grabbing !important;
}

.sb-dragging .sb-node {
  cursor: grabbing;
}

.sb-dragging .sb-canvas-container {
  cursor: grabbing;
}









/* ============================================
   STORYBOARD APP v1.0 — Part 2: Editing UI CSS
   Drupal Asset Injector CSS (Part 2)
   REQUIRES: Part 1 CSS loaded first
   
   PART 2 STYLES:
   1.  Context Menus
   2.  Inline Text Editing
   3.  Side Panel (desktop)
   4.  Side Panel (mobile bottom sheet)
   5.  Panel Tabs
   6.  Panel Form Fields
   7.  Panel Options Editor
   8.  Panel Connections List
   9.  Modal Overlays & Dialogs
   10. Add Scene Modal
   11. Change Type Modal
   12. Scene Type Cards
   13. Undo/Redo Button States
   14. Connection Drawing Mode
   15. Node Selection States
   16. Inline Dropdowns
   17. Quick Actions
   18. Form Utilities
   19. Edit Mode Enhancements
   20. Responsive Adjustments
   21. Accessibility & Polish
   22. Animations
   ============================================ */

/* === 1. CONTEXT MENUS === */
.sb-ctx-menu {
  position: fixed;
  z-index: 8000;
  background: var(--sb-surface-elevated);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow-lg);
  padding: 6px;
  min-width: 200px;
  max-width: 280px;
  animation: sbCtxIn .15s ease;
}

@keyframes sbCtxIn {
  from { opacity: 0; transform: scale(.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.sb-ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--sb-radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  transition: all var(--sb-transition);
  user-select: none;
}

.sb-ctx-item:hover {
  background: var(--sb-accent-light);
  color: var(--sb-accent);
}

.sb-ctx-item i {
  width: 18px;
  text-align: center;
  font-size: .85rem;
  flex-shrink: 0;
  opacity: 0.8;
}

.sb-ctx-item:hover i {
  opacity: 1;
}

.sb-ctx-danger {
  color: var(--sb-ending-bad);
}

.sb-ctx-danger:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  color: var(--sb-ending-bad) !important;
}

.sb-ctx-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 8px;
}

.sb-ctx-header {
  padding: 8px 14px 6px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--sb-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* === 2. INLINE TEXT EDITING === */
.sb-inline-edit {
  width: 100%;
  border: 2px solid var(--sb-accent);
  border-radius: var(--sb-radius-sm);
  padding: 4px 8px;
  font-family: var(--sb-font-body);
  font-size: inherit;
  font-weight: inherit;
  color: var(--sb-text);
  background: var(--sb-surface);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  transition: box-shadow var(--sb-transition);
}

.sb-inline-edit:focus {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

.sb-node-title .sb-inline-edit {
  display: block;
  font-family: var(--sb-font-display);
}

/* === 3. SIDE PANEL (DESKTOP) === */
.sb-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 7000;
  opacity: 0;
  transition: opacity .25s ease;
}

.sb-panel-overlay:not(.sb-hidden) {
  opacity: 1;
}

.sb-side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--sb-surface);
  z-index: 7500;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

.sb-side-panel:not(.sb-hidden) {
  transform: translateX(0);
}

.sb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  background: var(--sb-bg);
}

.sb-panel-header h3,
#sbPanelTitle {
  font-family: var(--sb-font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--sb-text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 50px);
}

.sb-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

.sb-panel-body::-webkit-scrollbar { width: 6px; }
.sb-panel-body::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 3px; }

.sb-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
  gap: 12px;
  background: var(--sb-bg);
}

.sb-panel-close {
  flex-shrink: 0;
}

/* === 4. SIDE PANEL — MOBILE BOTTOM SHEET === */
@media (max-width: 767px) {
  .sb-side-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--sb-radius-xl) var(--sb-radius-xl) 0 0;
    transform: translateY(100%);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
  }

  .sb-side-panel:not(.sb-hidden) {
    transform: translateY(0);
  }

  .sb-panel-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--sb-border-light);
  }

  .sb-panel-header {
    position: relative;
    padding-top: 28px;
  }
}

/* === 5. PANEL TABS === */
.sb-panel-tabs,
#sbPanelTabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--sb-border);
  background: var(--sb-bg);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.sb-panel-tabs::-webkit-scrollbar,
#sbPanelTabs::-webkit-scrollbar {
  display: none;
}

.sb-panel-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  background: none;
  font-family: var(--sb-font-body);
  font-size: .85rem;
  font-weight: 600;
  color: var(--sb-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--sb-transition);
  white-space: nowrap;
}

.sb-panel-tab:hover {
  color: var(--sb-text);
  background: var(--sb-surface-hover);
}

.sb-panel-tab.sb-active {
  color: var(--sb-accent);
  border-bottom-color: var(--sb-accent);
}

.sb-panel-tab i {
  font-size: .9rem;
  opacity: 0.8;
}

.sb-panel-tab.sb-active i {
  opacity: 1;
}

/* Hide options tab when not decision scene */
.sb-panel-tab.sb-hidden {
  display: none;
}

/* === 6. PANEL FORM FIELDS === */
.sb-pf {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sb-pf-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-pf-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--sb-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-pf-hint {
  font-weight: 400;
  color: var(--sb-text-muted);
  font-size: .75rem;
}

.sb-pf-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
  background: var(--sb-bg);
  color: var(--sb-text);
  font-family: var(--sb-font-body);
  font-size: .9rem;
  outline: none;
  transition: all var(--sb-transition);
}

.sb-pf-input:focus {
  border-color: var(--sb-accent);
  background: var(--sb-surface);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sb-pf-input::placeholder {
  color: var(--sb-text-muted);
}

.sb-pf-textarea {
  height: auto;
  min-height: 80px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

.sb-pf-input[type="number"] {
  width: 100px;
}

select.sb-pf-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Row layout for multiple fields */
.sb-pf-row {
  display: flex;
  gap: 12px;
}

.sb-pf-half {
  flex: 1;
}

.sb-pf-third {
  flex: 1;
}

/* Checkbox styling */
.sb-pf-checkbox {
  flex-direction: row;
  align-items: center;
}

.sb-pf-checkbox label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}

.sb-pf-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--sb-accent);
  cursor: pointer;
}

/* Type display */
.sb-pf-type-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
  font-size: .9rem;
  color: var(--sb-text);
}

.sb-pf-type-badge {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #ffffff;
  font-size: .85rem;
}

.sb-pf-type-display .sb-btn {
  margin-left: auto;
}

/* Empty state in panel */
.sb-pf-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--sb-text-muted);
  font-size: .9rem;
}

/* Note text */
.sb-pf-note {
  font-size: .8rem;
  color: var(--sb-text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.sb-pf-note i {
  color: var(--sb-accent);
}

/* === 7. PANEL OPTIONS EDITOR === */
.sb-pf-options-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sb-pf-option {
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  padding: 16px;
  position: relative;
}

.sb-pf-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sb-pf-option-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #ffffff;
  font-family: var(--sb-font-display);
  font-size: .95rem;
  font-weight: 700;
}

.sb-pf-option-delete {
  opacity: 0.6;
  transition: opacity var(--sb-transition);
}

.sb-pf-option:hover .sb-pf-option-delete {
  opacity: 1;
}

.sb-pf-option .sb-pf-group {
  gap: 6px;
}

.sb-pf-option .sb-pf-group label {
  font-size: .75rem;
}

.sb-pf-option .sb-pf-input {
  height: 38px;
  font-size: .85rem;
}

/* === 8. PANEL CONNECTIONS LIST === */
.sb-pf-connections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sb-pf-conn-section h4 {
  font-size: .85rem;
  font-weight: 600;
  color: var(--sb-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-pf-conn-section h4 i {
  color: var(--sb-accent);
  font-size: .9rem;
}

.sb-pf-conn-empty {
  font-size: .85rem;
  color: var(--sb-text-muted);
  font-style: italic;
  padding: 8px 0;
}

.sb-pf-conn-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-pf-conn-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
  font-size: .85rem;
}

.sb-pf-conn-name {
  color: var(--sb-text);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-pf-conn-option {
  font-size: .75rem;
  color: var(--sb-text-muted);
  background: var(--sb-surface-hover);
  padding: 2px 8px;
  border-radius: 4px;
}

.sb-pf-conn-arrow {
  color: var(--sb-text-muted);
  font-size: .75rem;
}

.sb-pf-conn-delete {
  opacity: 0.5;
  transition: opacity var(--sb-transition);
}

.sb-pf-conn-item:hover .sb-pf-conn-delete {
  opacity: 1;
}

/* === 9. MODAL OVERLAYS & DIALOGS === */
.sb-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 8500;
  opacity: 0;
  transition: opacity .25s ease;
}

.sb-modal-overlay:not(.sb-hidden) {
  opacity: 1;
}

.sb-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 500px;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-lg);
  box-shadow: var(--sb-shadow-lg);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
}

.sb-modal:not(.sb-hidden) {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.sb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sb-modal-header h3 {
  font-family: var(--sb-font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sb-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-modal-header h3 i {
  color: var(--sb-accent);
}

.sb-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

.sb-modal-body::-webkit-scrollbar { width: 6px; }
.sb-modal-body::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 3px; }

.sb-modal-desc {
  font-size: .95rem;
  color: var(--sb-text-secondary);
  margin-bottom: 20px;
}

.sb-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sb-modal-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--sb-radius-sm);
  font-size: .85rem;
  color: #f59e0b;
  margin-top: 16px;
}

.sb-modal-warning i {
  flex-shrink: 0;
}

/* === 10. ADD SCENE MODAL === */
#sbAddSceneModal {
  width: 560px;
}

/* === 11. CHANGE TYPE MODAL === */
#sbChangeTypeModal {
  width: 560px;
}

/* === 12. SCENE TYPE CARDS === */
.sb-scene-type-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-scene-type-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--sb-bg);
  border: 2px solid var(--sb-border);
  border-radius: var(--sb-radius);
  cursor: pointer;
  transition: all var(--sb-transition);
  text-align: left;
  position: relative;
}

.sb-scene-type-card:hover {
  background: var(--sb-surface-hover);
  transform: translateX(4px);
}

.sb-scene-type-card.sb-active {
  border-color: var(--sb-accent);
  background: var(--sb-accent-light);
}

.sb-stc-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--sb-radius-sm);
  color: #ffffff;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.sb-stc-info {
  flex: 1;
  min-width: 0;
}

.sb-stc-info h4 {
  font-family: var(--sb-font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--sb-text);
  margin: 0 0 4px 0;
}

.sb-stc-info p {
  font-size: .85rem;
  color: var(--sb-text-secondary);
  margin: 0;
  line-height: 1.4;
}

.sb-stc-current {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sb-accent);
  background: var(--sb-accent-light);
  padding: 3px 8px;
  border-radius: 4px;
}

/* === 13. UNDO/REDO BUTTON STATES === */
.sb-btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#sbUndoBtn,
#sbRedoBtn {
  transition: opacity var(--sb-transition);
}

/* === 14. CONNECTION DRAWING MODE === */
.sb-node-connecting {
  border-style: dashed !important;
  border-color: var(--sb-accent) !important;
  animation: sbConnectPulse 1.2s ease infinite;
}

@keyframes sbConnectPulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4), var(--sb-shadow); 
  }
  50% { 
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0), var(--sb-shadow); 
  }
}

/* When in connection mode, highlight valid targets */
.sb-app.sb-connection-mode .sb-node:not(.sb-node-connecting):hover {
  border-color: var(--sb-ending-good) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3), var(--sb-shadow-lg);
}

.sb-app.sb-connection-mode .sb-canvas-container {
  cursor: crosshair;
}

/* === 15. NODE SELECTION STATES === */
.sb-node-selected {
  border-color: var(--sb-accent) !important;
  box-shadow: var(--sb-shadow-glow), var(--sb-shadow-lg) !important;
  z-index: 10;
}

.sb-node-selected .sb-node-handle {
  opacity: 1;
}

/* === 16. INLINE DROPDOWNS === */
.sb-inline-dd {
  position: fixed;
  z-index: 8000;
  background: var(--sb-surface-elevated);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow-lg);
  padding: 6px;
  min-width: 180px;
  max-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  animation: sbCtxIn .15s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

.sb-inline-dd::-webkit-scrollbar { width: 5px; }
.sb-inline-dd::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 4px; }

.sb-idd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--sb-radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  transition: background var(--sb-transition);
  user-select: none;
  white-space: nowrap;
}

.sb-idd-item:hover {
  background: var(--sb-surface-hover);
}

.sb-idd-item.sb-active {
  background: var(--sb-accent-light);
  color: var(--sb-accent);
  font-weight: 600;
}

.sb-idd-item i {
  width: 18px;
  text-align: center;
  font-size: .85rem;
  flex-shrink: 0;
}

.sb-idd-item .sb-check-icon {
  margin-left: auto;
  font-size: .75rem;
  color: var(--sb-accent);
}

/* === 17. QUICK ACTIONS === */
.sb-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--sb-surface-elevated);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow);
}

/* === 18. FORM UTILITIES === */
.sb-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--sb-ending-bad);
}

.sb-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--sb-ending-bad);
}

.sb-btn-success {
  background: var(--sb-ending-good);
  border-color: var(--sb-ending-good);
  color: #ffffff;
}

.sb-btn-success:hover {
  background: #059669;
  border-color: #059669;
}

/* === 19. EDIT MODE ENHANCEMENTS === */
.sb-mode-edit .sb-toolbar {
  border-bottom-color: var(--sb-accent);
}

.sb-mode-edit .sb-node {
  cursor: move;
}

.sb-mode-edit .sb-node:hover .sb-node-handle {
  opacity: 1;
}

/* Subtle edit mode indicator */
.sb-mode-edit::after {
  content: 'EDIT MODE';
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 6px 12px;
  background: var(--sb-accent);
  color: #ffffff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  border-radius: 4px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 100;
}

/* === 20. RESPONSIVE ADJUSTMENTS === */
@media (max-width: 767px) {
  /* Context menu full width at bottom */
  .sb-ctx-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: 100%;
    border-radius: var(--sb-radius-lg) var(--sb-radius-lg) 0 0;
    padding: 12px 16px 24px;
    animation: sbSlideUp .2s ease;
  }

  @keyframes sbSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .sb-ctx-item {
    padding: 14px 16px;
    font-size: .95rem;
  }

  /* Modal full screen on mobile */
  .sb-modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: translateY(20px);
  }

  .sb-modal:not(.sb-hidden) {
    transform: translateY(0);
  }

  .sb-modal-header {
    padding: 16px 20px;
  }

  .sb-modal-body {
    padding: 20px;
  }

  .sb-modal-footer {
    padding: 14px 20px;
  }

  /* Scene type cards stack */
  .sb-scene-type-card {
    padding: 14px 16px;
  }

  .sb-stc-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .sb-stc-info h4 {
    font-size: .95rem;
  }

  .sb-stc-info p {
    font-size: .8rem;
  }

  /* Panel tabs scroll */
  .sb-panel-tabs {
    padding: 0 12px;
  }

  .sb-panel-tab {
    padding: 12px 14px;
    font-size: .8rem;
  }

  /* Form fields */
  .sb-pf-row {
    flex-direction: column;
  }

  .sb-pf-input {
    height: 44px;
  }

  /* Options editor */
  .sb-pf-option {
    padding: 14px;
  }

  /* Hide edit mode indicator on mobile */
  .sb-mode-edit::after {
    display: none;
  }
}

/* === 21. ACCESSIBILITY & POLISH === */

/* Focus states */
.sb-btn:focus-visible,
.sb-modal-close:focus-visible,
.sb-panel-close:focus-visible,
.sb-panel-tab:focus-visible,
.sb-scene-type-card:focus-visible,
.sb-ctx-item:focus-visible {
  outline: 2px solid var(--sb-accent);
  outline-offset: 2px;
}

.sb-pf-input:focus-visible {
  outline: none;
  border-color: var(--sb-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .sb-ctx-menu,
  .sb-modal,
  .sb-side-panel {
    border-width: 2px;
  }

  .sb-pf-input {
    border-width: 2px;
  }

  .sb-scene-type-card {
    border-width: 3px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sb-ctx-menu,
  .sb-modal,
  .sb-side-panel,
  .sb-panel-overlay,
  .sb-modal-overlay,
  .sb-scene-type-card,
  .sb-node-connecting {
    animation: none;
    transition-duration: 0.01ms !important;
  }
}

/* === 22. ANIMATIONS === */
@keyframes sbShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.sb-shake {
  animation: sbShake 0.4s ease;
}

@keyframes sbPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.sb-pop {
  animation: sbPop 0.3s ease;
}

/* Smooth transitions for all interactive elements */
.sb-btn,
.sb-ctx-item,
.sb-idd-item,
.sb-panel-tab,
.sb-scene-type-card,
.sb-pf-input,
.sb-pf-option,
.sb-pf-conn-item {
  transition-property: background, border-color, color, box-shadow, transform, opacity;
  transition-duration: 0.2s;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Print styles for Part 2 elements */
@media print {
  .sb-ctx-menu,
  .sb-modal,
  .sb-modal-overlay,
  .sb-side-panel,
  .sb-panel-overlay,
  .sb-inline-dd {
    display: none !important;
  }
}