:root {
  --bg: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-tertiary: #3a3a3c;
  --panel: #1c1c1e;
  --panel-elevated: #28292a;
  --panel-secondary: #2c2c2e;
  --ink: #f2f2f7;
  --ink-secondary: #ebebf5;
  --muted: #a9a9af;
  --muted-secondary: #636366;
  --accent: #007aff;
  --accent-secondary: #5ac8fa;
  --bad: #ff453a;
  --good: #30d158;
  --warning: #ff9f0a;

  --spacing-xs: 2px;
  --spacing-sm: 4px;
  --spacing-md: 6px;
  --spacing-lg: 8px;
  --spacing-xl: 12px;
  --spacing-xxl: 16px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 13px;
  --font-size-lg: 14px;
  --font-size-xl: 16px;
  --font-size-xxl: 18px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.4);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'SF Pro Text', 'SF Pro Display', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: var(--font-size-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga', 'kern';
}

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg);
}

/* Top Toolbar */
#topbar {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  align-items: center;
  padding: 8px 16px;
  background: var(--panel-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 16px;
}

#topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#appTitle {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

#topbar-center {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

#topbar-right {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

/* Main Content Grid */
#mainContent {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

/* Editor Panel */
#editorPanel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 0;
  overflow: hidden;
}

/* Output Panel (Canvas + Inspector) */
#outputPanel {
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--panel-elevated);
  min-height: 0;
  overflow: hidden;
}
/* Canvas Container */
#canvasContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#canvasContainer canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Inspector Panel */
#inspectorPanel {
  display: flex;
  flex-direction: column;
  background: var(--panel-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  max-height: 400px;
  min-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease, min-height 0.3s ease;
}

#inspectorPanel.collapsed {
  max-height: 36px;
  min-height: 36px;
}

#inspectorPanel.collapsed #inspectorContent {
  display: none;
}

#inspectorTabs {
  display: flex;
  gap: 0;
  padding: 0 var(--spacing-md);
  background: var(--panel-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.inspector-tab {
  font-size: var(--font-size-sm);
  padding: var(--spacing-lg) var(--spacing-xl);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  position: relative;
  border-bottom: 2px solid transparent;
}

.inspector-tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.inspector-tab:hover:not(.active) {
  color: var(--ink-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.inspector-collapse-btn {
  margin-left: auto;
  font-size: 10px;
  padding: 4px 12px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}

.inspector-collapse-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.inspector-collapse-btn.collapsed {
  transform: rotate(180deg);
}

#inspectorContent {
  flex: 1;
  overflow: hidden;
  background: var(--panel);
}

.inspector-pane {
  display: none;
  height: 100%;
  overflow: auto;
}

.inspector-pane.active {
  display: block;
}

/* Collapsible Inspector Sections */
.inspector-section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.section-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel-secondary);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.section-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink);
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
}

.section-toggle {
  font-size: 10px;
  color: var(--muted);
  transition: transform var(--transition-fast);
}

.section-header.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-content {
  padding: 12px 16px;
  background: var(--panel);
  max-height: 400px;
  overflow: auto;
  transition: max-height var(--transition-normal);
}

.section-content.collapsed {
  display: none;
}

/* Settings Menu */
#settingsMenu {
  position: absolute;
  top: 48px;
  right: 16px;
  background: var(--panel-elevated);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

#settingsMenu.hidden {
  display: none;
}

.menu-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 0;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: var(--font-size-xs);
  color: var(--muted);
}

#settingsMenu button {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  margin: 2px 0;
  color: var(--ink);
}

#settingsMenu a {
  text-decoration: none;
  display: block;
}

#settingsMenu a button {
  width: 100%;
}

/* Clean button styling - no borders or backgrounds */
button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  cursor: pointer;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}

button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
}

button:active {
  transform: scale(0.98);
}

/* Primary Button */
.primary-btn {
  background: var(--accent);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.primary-btn:hover {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px rgba(0, 122, 255, 0.4);
}

/* Toggle button active states */
#interpToggle.active,
#autorunBtn.active,
button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 6px rgba(0, 122, 255, 0.4);
}

.pill {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-family: 'SF Pro Text', 'SF Mono', ui-monospace, monospace;
  font-weight: 600;
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  letter-spacing: 0.02em;
  height: 20px;
}

/* Clock component styling */
#clockContainer {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

#playPauseBtn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--ink);
  transition: all var(--transition-fast);
}

#playPauseBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent);
  transform: scale(1.05);
}

#playPauseBtn.playing {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

#frameIndicator {
  min-width: 20px;
  text-align: center;
  font-weight: 600;
  transition: all var(--transition-fast);
  color: var(--muted);
}

#frameIndicator.active {
  color: var(--accent);
  transform: scale(1.15);
  text-shadow: 0 0 8px rgba(0, 122, 255, 0.5);
}
#editorContainer {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--panel);
}

/* CodeMirror styling */
#editorContainer .CodeMirror {
  height: 100%;
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.6;
}

#editorContainer .CodeMirror-gutters {
  background: var(--panel-secondary);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

#editorContainer .CodeMirror-linenumber {
  color: var(--muted);
  padding: 0 8px;
}

#editorContainer .CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

#editorContainer .CodeMirror-selected {
  background: rgba(0, 122, 255, 0.25);
}

#editorContainer .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03);
}


#editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: var(--spacing-xxl);
  resize: none;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  font-family: 'SF Mono', ui-monospace, 'Monaco', 'Menlo', monospace;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  caret-color: var(--accent);
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-weight: 400;
  font-feature-settings: 'liga', 'calt';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#editor::selection {
  background: rgba(0, 122, 255, 0.25);
  border-radius: 2px;
}

#editor::-moz-selection {
  background: rgba(0, 122, 255, 0.25);
  border-radius: 2px;
}

#errors {
  padding: 12px 16px;
  min-height: 40px;
  color: var(--bad);
  white-space: pre-wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--panel-secondary);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.5;
  flex-shrink: 0;
}

#rgbDisplay {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 17, 21, 0.9);
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  border: 1px solid #23283a;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
#stats { display: flex; gap: 10px; color: var(--muted); font-size: 12px; }
code { color: #cbd5e1; }
.good { color: var(--good); }
.muted { color: var(--muted); }


/* Widget Panel Styles - No floating panel needed, popovers only */
.widget-panel {
  display: none; /* Not needed - parameters show as popovers on hover */
  position: fixed;
  top: 60px;
  right: 16px;
  width: 280px;
  max-height: calc(100vh - 80px);
  background: rgba(21, 24, 33, 0.95);
  border-radius: 12px;
  border: 1px solid rgba(122, 162, 255, 0.1);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  padding: 16px;
  overflow-y: auto;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'SF Pro Display', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.widget-panel.hidden {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

/* Refined button styling - matches other buttons exactly */
.refined-button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  cursor: pointer;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}

.refined-button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
}

.refined-button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 4px rgba(0, 122, 255, 0.3);
}

.refined-button:active {
  transform: scale(0.98);
}

/* Parameter widget containers */
.parameter-widget-container {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.parameter-widget-container:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(122, 162, 255, 0.2);
}

/* Slider styling */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.parameter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  font-family: 'SF Pro Display', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refined-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: all 0.2s ease;
}

.refined-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #6b94ff 100%);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.refined-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 16px rgba(122, 162, 255, 0.4);
}

.refined-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7aa2ff 0%, #6b94ff 100%);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.value-display {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'SF Mono', 'SF Pro Text', ui-monospace, 'Monaco', 'Menlo', monospace;
}

.value-input {
  width: 60px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--ink);
  padding: 4px 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'SF Pro Text', ui-monospace, 'Monaco', 'Menlo', monospace;
  outline: none;
  transition: all 0.2s ease;
}

.value-input:focus {
  border-color: rgba(122, 162, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.1);
}

/* Color widget styling */
.color-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.refined-color-input {
  width: 60px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

.hex-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--ink);
  padding: 6px 12px;
  font-size: 12px;
  font-family: 'SF Mono', 'SF Pro Text', ui-monospace, 'Monaco', 'Menlo', monospace;
  outline: none;
  transition: all 0.2s ease;
}

.hex-input:focus {
  border-color: rgba(122, 162, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.1);
}

/* Popover styling */
.parameter-popover {
  position: fixed;
  background: var(--panel-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm);
  min-width: 120px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  z-index: 10000;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  transition: all var(--transition-fast);
  font-family: 'SF Pro Display', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.parameter-popover.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.popover-header {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--spacing-md);
  text-align: center;
  letter-spacing: -0.01em;
}

.popover-slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.popover-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.popover-value {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--muted);
  font-family: 'SF Mono', ui-monospace, 'Monaco', 'Menlo', monospace;
  margin-bottom: var(--spacing-xs);
}

.popover-color {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

/* Color component sliders */
.popover-slider.color-component::-webkit-slider-thumb {
  border: 2px solid var(--panel-elevated);
}

/* XY component sliders */
.popover-slider.xy-component::-webkit-slider-thumb {
  border: 2px solid var(--panel-elevated);
}

/* Toggle styling */
.toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-sm) 0;
}

.popover-toggle {
  appearance: none;
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-normal);
}

.popover-toggle:checked {
  background: var(--accent);
}

.popover-toggle::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: all var(--transition-normal);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.popover-toggle:checked::before {
  transform: translateX(16px);
}

.toggle-label {
  font-size: var(--font-size-xs);
  color: var(--ink);
  font-weight: 600;
  min-width: 28px;
  text-align: center;
}

/* Modern Debug Panel Styles */
#debugPanel {
  border-top: 2px solid #2a3441;
  background: linear-gradient(135deg, #151821 0%, #1a1f2b 100%);
  height: 280px;
  min-height: 44px;
  max-height: 80vh;
  overflow: hidden;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  position: relative;
  resize: vertical;
}

#debugPanel.collapsed {
  height: 44px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

#debugResizeHandle {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  background: transparent;
  z-index: 10;
}

#debugResizeHandle:hover {
  background: rgba(122, 162, 255, 0.3);
}

#debugResizeHandle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 4px;
  background: rgba(122, 162, 255, 0.5);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#debugResizeHandle:hover::before {
  opacity: 1;
}

#debugHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(90deg, #1e2530 0%, #252b38 100%);
  border-bottom: 1px solid #2a3441;
  font-size: 13px;
  font-weight: 600;
  color: #e8ecf1;
  position: relative;
}

#debugHeader::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #7aa2ff, transparent);
}

#debugHeader button {
  font-size: var(--font-size-xs);
  padding: var(--spacing-sm) var(--spacing-lg);
  margin-left: var(--spacing-sm);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  transition: all var(--transition-fast);
  font-weight: 500;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#debugHeader button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-secondary);
  border-color: rgba(255, 255, 255, 0.12);
}

#debugPane #debugContent {
  padding: var(--spacing-xl);
  height: 100%;
  overflow: hidden;
  background: var(--panel);
}


#logFilters {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  background: var(--panel-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.log-level-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}

.log-level-filter:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-secondary);
}

.log-level-filter input[type="checkbox"] {
  width: 10px;
  height: 10px;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-separator {
  color: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

#logFilters button {
  font-size: 10px;
  padding: 2px 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: auto;
  height: 20px;
}

#logFilters button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-secondary);
  border-color: rgba(255, 255, 255, 0.12);
}

#componentFilterList {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

#componentFilterList label {
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#componentFilterList label:hover {
  background: rgba(255, 255, 255, 0.05);
}

#componentFilterList input[type="checkbox"] {
  width: 10px;
  height: 10px;
}

#logOutput {
  font-size: 11px;
  line-height: 1.4;
  font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  flex: 1;
  overflow-y: auto;
  background: var(--panel);
  padding: 8px;
}

#debugPane {
  display: flex;
  flex-direction: column;
}

/* Compiled Code Viewer */
#compiledCodeViewer {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 16px;
  margin: 0;
  color: #d4d4d4;
  background: var(--panel);
  overflow: auto;
  height: 100%;
  white-space: pre;
  tab-size: 2;
}

#logOutput::-webkit-scrollbar {
  width: 6px;
}

#logOutput::-webkit-scrollbar-track {
  background: rgba(33, 37, 52, 0.3);
  border-radius: 3px;
}

#logOutput::-webkit-scrollbar-thumb {
  background: rgba(122, 162, 255, 0.4);
  border-radius: 3px;
}

#logOutput::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 162, 255, 0.6);
}

.log-entry {
  margin: 4px 0;
  padding: 8px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: all 0.1s ease;
  font-family: inherit;
}

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

.log-entry.debug {
  border-left-color: #9aa4b2;
  background: rgba(154, 164, 178, 0.05);
}

.log-entry.info {
  border-left-color: #7aa2ff;
  background: rgba(122, 162, 255, 0.08);
}

.log-entry.warn {
  background: rgba(255, 179, 71, 0.12);
  border-left-color: #ffb347;
}

.log-entry.error {
  background: rgba(255, 107, 107, 0.15);
  border-left-color: #ff6b6b;
}

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

.log-timestamp {
  color: #5a6374;
  font-size: 9px;
  font-weight: 400;
  opacity: 0.8;
}

.log-component {
  color: #70e000;
  font-weight: 600;
  background: rgba(112, 224, 0, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.log-message {
  color: inherit;
  font-size: 11px;
  line-height: 1.3;
}

.log-data {
  margin-top: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  font-size: 10px;
  color: #cbd5e1;
  white-space: pre-wrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.log-data-inline {
  font-weight: 500;
  color: #cbd5e1;
}

/* Scope Viewer Styles */
.empty-state {
  color: #5a6374;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.scope-level {
  margin-bottom: 12px;
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.scope-header {
  background: rgba(122, 162, 255, 0.1);
  color: #7aa2ff;
  font-weight: 600;
  padding: 6px 12px;
  font-size: 11px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.2);
}

.scope-vars {
  padding: 8px 12px;
}

.scope-var {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.scope-var:last-child {
  border-bottom: none;
}

.scope-key {
  color: #e8ecf1;
  font-weight: 500;
}

.scope-value {
  font-family: 'SF Mono', 'SF Pro Text', ui-monospace, 'Monaco', 'Menlo', monospace;
  font-size: 10px;
}

.scope-function { color: #ffb347; }
.scope-strand { color: #70e000; }
.scope-object { color: #7aa2ff; }
.scope-number { color: #ff9ff3; }
.scope-string { color: #7aa2ff; }

.scope-empty {
  color: #5a6374;
  font-style: italic;
  font-size: 10px;
}

/* Instance Viewer Styles */
.instance-item {
  margin-bottom: 8px;
  border: 1px solid rgba(112, 224, 0, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.instance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(112, 224, 0, 0.1);
  padding: 6px 12px;
  border-bottom: 1px solid rgba(112, 224, 0, 0.2);
}

.instance-name {
  color: #70e000;
  font-weight: 600;
  font-size: 11px;
}

.instance-count {
  color: #9aa4b2;
  font-size: 10px;
  font-weight: 400;
}

.instance-outputs {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.instance-output {
  background: rgba(122, 162, 255, 0.15);
  color: #7aa2ff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  border: 1px solid rgba(122, 162, 255, 0.3);
}

/* Instance badges in toolbar */
#instanceBadges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.instance-badge {
  padding: 4px 8px;
  background: rgba(78, 201, 176, 0.15);
  color: #4ec9b0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: 'SF Mono', ui-monospace, monospace;
  border: 1px solid rgba(78, 201, 176, 0.3);
  cursor: help;
}

/* Instance cards removed - using consistent AST style */

/* Enhanced animations */
@keyframes debugPanelOpen {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Mobile responsiveness */
@media (max-width: 768px) {
  #mainContent {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  #editorPanel {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
}


#astViewer,
#graphViewer,
#instanceViewer {
  color: var(--ink);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

/* Coordinate Probe Overlay */
.probe-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 10;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
}

.probe-overlay.visible {
  opacity: 0.5;
  visibility: visible;
}


.probe-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  cursor: crosshair;
}

.crosshair-vertical,
.crosshair-horizontal {
  position: absolute;
  background: var(--accent);
  opacity: 0.8;
  pointer-events: none;
  box-shadow: 0 0 2px rgba(0, 122, 255, 0.5);
}

.crosshair-vertical {
  width: 1px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.crosshair-horizontal {
  width: 100%;
  height: 1px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.probe-info {
  position: absolute;
  top: var(--spacing-lg);
  left: var(--spacing-lg);
  pointer-events: none;
  z-index: 20;
}

.coordinate-display {
  background: rgba(28, 28, 30, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: var(--font-size-sm);
  color: var(--ink);
  font-weight: 500;
  opacity: 0;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.coordinate-display.visible {
  opacity: 1;
  transform: translateY(0);
}

.coord-x,
.coord-y {
  color: var(--accent);
}

/* Probe Information Panel */
.probe-info-panel {
  position: fixed;
  top: 20%;
  right: var(--spacing-xxl);
  width: 280px;
  min-height: 240px;
  background: var(--panel-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-normal);
  z-index: 1000;
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.probe-info-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.probe-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--panel-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.probe-panel-header:active {
  cursor: grabbing;
}

.probe-panel-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--ink);
}

.probe-panel-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.probe-panel-close:hover {
  background: var(--bg-tertiary);
  color: var(--ink);
}

.probe-panel-content {
  flex: 1;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  overflow-y: auto;
}

.coordinate-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-tertiary);
}

.coord-label {
  font-size: var(--font-size-xs);
  color: var(--muted);
  font-weight: 500;
}

.coord-value {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: var(--font-size-xs);
  color: var(--ink);
  font-weight: 500;
}

.transformation-pipeline {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.pipeline-title {
  font-size: var(--font-size-xs);
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 1px;
}

.pipeline-stages {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--spacing-xs);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-tertiary);
}

.stage-label {
  font-size: var(--font-size-xs);
  color: var(--muted);
  font-weight: 500;
}

.stage-value {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: var(--font-size-xs);
  color: var(--ink);
  font-weight: 500;
}

.stage-description {
  font-size: var(--font-size-xs);
  color: var(--muted-secondary);
  font-style: italic;
}

.pipeline-arrow {
  text-align: center;
  color: var(--muted);
  font-size: var(--font-size-xs);
  margin: 1px 0;
}

.pipeline-empty,
.pipeline-error {
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--muted);
  font-size: var(--font-size-xs);
  font-style: italic;
}

.pipeline-error {
  color: var(--bad);
}

/* Probe toggle button styling */
#probeToggle {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-family: 'SF Pro Text', -apple-system, system-ui, sans-serif;
  font-size: var(--font-size-xs);
  font-weight: 500;
  min-height: 24px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#probeToggle:hover {
  background: var(--bg-tertiary);
  color: var(--ink);
}

#probeToggle.active {
  background: var(--accent);
  color: white;
}

#probeToggle.active:hover {
  background: var(--accent-secondary);
}

/* Hover Detection System for Parameters */
.hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  padding: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
}

.hover-parameter {
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  transition: all 0.15s ease;
}

.hover-parameter.direct-param {
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.15);
  border-radius: 3px;
  padding: 0px 1px;
}

.hover-parameter.strand-access {
  background: rgba(0, 122, 255, 0.25) !important;
  border: 2px solid rgba(0, 122, 255, 0.5) !important;
  border-radius: 4px;
  padding: 1px 2px;
  color: rgba(0, 122, 255, 0.8) !important;
}

.hover-parameter:hover {
  background: rgba(0, 122, 255, 0.2) !important;
  border-color: rgba(0, 122, 255, 0.4) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}