:root {
  /* Core Colors - Ableton-inspired dark theme */
  --bg-primary: #0c0c0c;
  --bg-secondary: #161616;
  --bg-tertiary: #1e1e1e;
  --bg-elevated: #252525;
  --bg-hover: #2d2d2d;
  
  /* Text Colors */
  --text-primary: #d1d1d1;
  --text-secondary: #808080;
  --text-tertiary: #666666;
  --text-disabled: #444444;
  
  /* Accent Colors - Muted monochromatic */
  --accent-primary: #808080;      /* Gray - active/selected */
  --accent-secondary: #a0a0a0;    /* Light gray - hover/highlight */
  --accent-success: #4ade80;      /* Green - success/positive */
  --accent-danger: #ff5555;       /* Red - danger/negative */
  --accent-repel: #cc6666;        /* Muted red for repel */
  --accent-attract: #66cc66;      /* Muted green for attract */
  
  /* UI Element Colors */
  --border-default: #2a2a2a;
  --border-subtle: #222222;
  --border-strong: #3a3a3a;
  --border-focus: var(--accent-primary);
  
  /* Shadows and Effects */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
  
  /* Spacing Scale - More compact */
  --space-xs: 2px;
  --space-sm: 4px;
  --space-md: 6px;
  --space-lg: 8px;
  --space-xl: 12px;
  --space-2xl: 16px;
  
  /* Border Radius */
  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 4px;
  --radius-full: 9999px;
  
  /* Typography - Smaller sizes */
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Courier New', monospace;
  --font-size-xs: 9px;
  --font-size-sm: 10px;
  --font-size-md: 11px;
  --font-size-lg: 12px;
  --font-size-xl: 13px;
  
  /* Animation */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Z-index Layers */
  --z-base: 0;
  --z-dropdown: 10;
  --z-sticky: 100;        /* MainUI and Left Panel */
  --z-overlay: 1000;      /* Performance/Shortcuts overlays */
  --z-modal: 2000;        /* CloudSync and PresetModal */
  --z-audio-prompt: 10000; /* Audio initialization prompt */
  --z-tooltip: 10001;
  
  /* Collapsible UI Variables */
  --collapsible-header-height: 32px;
  --collapsible-max-height: 2000px;
  --collapsible-transition: 0.3s ease-out;
}

/* Base Styles */
body {
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.5;
}

/* Panel Styles */
.panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-content {
  padding: var(--space-md);
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  line-height: 1;
  font-weight: normal;
}

.btn-primary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-primary:hover {
  background-color: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--bg-elevated);
  border-color: var(--border-default);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: transparent;
  color: var(--text-primary);
}

.btn-icon {
  padding: var(--space-sm);
  width: 32px;
  height: 32px;
}

/* Input Styles */
.input,
.select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: inherit;
  font-size: var(--font-size-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.3);
}

/* Range Slider Styles - Enhanced with quantize indicators */
.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  outline: none;
  transition: all var(--transition-fast);
  position: relative;
  box-sizing: border-box;
  display: block;
}


.range-slider:focus {
  background: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.2);
}

.range-slider:active {
  background: var(--accent-primary);
}

/* Slider container for quantize marks */
.range-slider-container {
  position: relative;
  width: 100%;
}


.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  z-index: 1;
  position: relative;
}

.range-slider::-webkit-slider-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.15);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.range-slider::-webkit-slider-thumb:active {
  background: var(--accent-primary);
  transform: scale(1.2);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px rgba(128, 128, 128, 0.2);
}

.range-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.range-slider::-moz-range-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.15);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.range-slider::-moz-range-thumb:active {
  background: var(--accent-primary);
  transform: scale(1.2);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px rgba(128, 128, 128, 0.2);
}

/* Control Group Styles - Compact */
.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  width: 100%;
  box-sizing: border-box;
}

/* Ensure all child elements in control groups take full width */
.control-group .range-slider {
  width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box;
}

.control-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  gap: var(--space-sm);
}

.control-group .value-display {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 500;
  min-width: 32px;
  text-align: right;
  font-size: var(--font-size-xs);
}

/* Section Styles - Compact */
.section {
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Graph Styles */
.graph-container {
  position: relative;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.graph-canvas {
  display: block;
  cursor: crosshair;
}

.graph-tooltip {
  position: absolute;
  padding: var(--space-xs) var(--space-sm);
  background-color: rgba(12, 12, 12, 0.95);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  pointer-events: none;
  white-space: nowrap;
  z-index: var(--z-tooltip);
}

/* Checkbox Styles */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

input[type="checkbox"]:checked {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 3px;
  height: 6px;
  border: solid var(--bg-primary);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}

input[type="checkbox"]:hover {
  border-color: var(--border-strong);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.fade-in {
  animation: fadeIn var(--transition-normal);
}

.fade-out {
  animation: fadeOut var(--transition-normal);
}

/* Test/Debug Interface Extensions */
.test-header,
.debug-header {
  background: var(--bg-secondary);
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-default);
}

.test-header h1,
.debug-header h1 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-normal);
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.test-container,
.debug-container {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
}

.test-panel,
.debug-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.test-section,
.debug-section {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.test-section:last-child,
.debug-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.test-section h3,
.debug-section h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Status Indicators */
.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  display: inline-block;
}

.status-indicator.running {
  background: var(--accent-secondary);
  animation: pulse 1s infinite;
}

.status-indicator.success {
  background: var(--accent-success);
}

.status-indicator.error {
  background: var(--accent-danger);
}

.status-indicator.warning {
  background: var(--accent-secondary);
}

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

/* Console/Log Styling */
.console,
.log-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-size: var(--font-size-xs);
  line-height: 1.4;
  overflow-y: auto;
  max-height: 300px;
}

.console-entry,
.log-entry {
  margin: var(--space-xs) 0;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.console-entry.info,
.log-entry.info {
  color: var(--text-secondary);
}

.console-entry.success,
.log-entry.success {
  color: var(--accent-success);
  background: rgba(74, 222, 128, 0.1);
}

.console-entry.error,
.log-entry.error {
  color: var(--accent-danger);
  background: rgba(255, 85, 85, 0.1);
}

.console-entry.warning,
.log-entry.warning {
  color: var(--text-secondary);
  background: rgba(160, 160, 160, 0.1);
}

/* Test/Debug Specific Buttons */
.btn-test {
  min-width: 120px;
  font-size: var(--font-size-xs);
}

/* Status Grid */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.status-item {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.status-value {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-mono);
}

/* Test Results */
.test-item {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.test-item:hover {
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

.test-name {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.test-time {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Color Picker Styles */
.color-picker-container {
  position: relative;
  display: inline-block;
}

.color-picker-display {
  width: 32px;
  height: 20px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  padding: 0;
  position: relative;
}

.color-picker-display:hover {
  border-color: var(--border-strong);
}

.color-picker-display:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.3);
}

.color-picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
}

.color-picker-canvas {
  border: 1px solid var(--border-default);
  cursor: crosshair;
  margin-bottom: var(--space-md);
  display: block;
  position: relative;
}

.color-picker-content {
  position: relative;
}

.color-picker-indicator {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: none;
}

.color-picker-sliders {
  margin-top: var(--space-md);
}

.color-slider-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.color-slider-group label {
  width: 14px;
  color: var(--text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.color-slider-group .value-display {
  min-width: 28px;
  text-align: right;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

.color-slider {
  flex: 1;
}

.color-picker-hex {
  margin-top: var(--space-md);
}

.hex-input {
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  background: var(--bg-primary);
  border-color: var(--border-subtle);
}

/* Species Size Display */
.species-size-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

#selected-species-name {
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}

/* Species Colors Row Styling */
.species-color-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  min-height: 32px;
}

.species-color-row:last-child {
  border-bottom: none;
}

.species-label {
  min-width: 60px;
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  font-weight: 500;
}

.species-color-wrapper {
  position: relative;
}

.species-color {
  width: 40px;
  height: 28px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  background: none;
}

.species-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.species-color::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.species-amount {
  width: 50px;
  text-align: center;
  font-size: var(--font-size-xs);
}

.species-sliders {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 120px;
}

.mini-slider-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: 16px;
}

.mini-label {
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 35px;
  text-align: left;
}

.mini-slider {
  flex: 1;
  height: 12px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mini-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.mini-slider::-moz-range-thumb {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.mini-slider:focus {
  outline: none;
  border-color: var(--border-focus);
}

.mini-value {
  font-size: 9px;
  color: var(--text-tertiary);
  min-width: 20px;
  text-align: right;
  font-family: var(--font-mono);
}

/* Dual Range Slider Styles */
.dual-range-slider {
  position: relative;
  height: 18px;
  margin: var(--space-xs) 0;
}

.dual-range-slider input[type="range"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 18px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  margin: 0;
}

.dual-range-slider input[type="range"]::-webkit-slider-track {
  height: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
}

.dual-range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  position: relative;
  z-index: 2;
  transition: all var(--transition-fast);
}

.dual-range-slider input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.15);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.dual-range-slider input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  border: none;
}

.dual-range-slider input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  box-shadow: none;
}

.dual-range-slider input[type="range"]::-moz-range-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.15);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.dual-range-slider .range-track {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
}

.dual-range-slider .range-fill {
  position: absolute;
  top: 8px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.dual-range-values {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: var(--space-xs);
}

.dual-range-values span {
  min-width: 32px;
  text-align: center;
}

/* Control Subgroup Styles */
.control-subgroup {
  margin-left: var(--space-md);
}

.control-subgroup label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  gap: var(--space-sm);
}

.control-subgroup .dual-range-values {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* Modulation Dual Range Slider */
.modulation-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  border: 2px solid var(--bg-secondary);
  transition: all 0.2s ease;
}

.modulation-slider::-webkit-slider-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.modulation-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  border: 2px solid var(--bg-secondary);
  transition: all 0.2s ease;
}

.modulation-slider::-moz-range-thumb:hover {
  background: var(--text-primary);
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.modulation-slider::-webkit-slider-runnable-track {
  height: 0;
  background: transparent;
}

.modulation-slider::-moz-range-track {
  height: 0;
  background: transparent;
}

.section-subtitle {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-sm);
  display: block;
  width: 100%;
}

/* UI Container Initial State - Hide until ready */
.ui-container {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}

.ui-container.ui-ready {
  opacity: 1;
  transform: translateY(0);
}

/* Clean Loading: Hide original sections until transformation complete */
.ui-section {
  display: none !important;
}

.collapsible-section {
  display: block;
}

/* Collapsible Section Styles */
.collapsible-section {
  margin-bottom: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;  /* Keep hidden for rounded corners */
  transition: all var(--transition-normal);
  will-change: transform;
  /* Ensure sections are visible */
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.collapsible-section.open {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  user-select: none;
  background: var(--bg-elevated);
  border-bottom: 1px solid transparent;
  transition: all var(--transition-fast);
  min-height: var(--collapsible-header-height);
}

.collapsible-header:hover {
  background: var(--bg-hover);
  border-bottom-color: var(--border-subtle);
}

.collapsible-header.active {
  border-bottom-color: var(--border-subtle);
  background: var(--bg-elevated);
}

.collapsible-header:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.collapsible-title-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.collapsible-icon {
  font-size: var(--font-size-lg);
  opacity: 0.8;
  filter: grayscale(50%);
}

.collapsible-title {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  transition: transform var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-toggle svg {
  width: 12px;
  height: 12px;
}

.collapsible-toggle.open {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--collapsible-transition) cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-secondary);
  transform: translateZ(0); /* Hardware acceleration */
}

/* When section is open, ensure content can be seen */
.collapsible-section.open .collapsible-content {
  overflow: hidden;  /* Keep hidden for clean animation, scrolling handled by container */
}

/* Special handling for particles and forces sections to ensure they can expand fully */
.collapsible-section[data-section-id="particles"] .collapsible-content,
.collapsible-section[data-section-id="forces"] .collapsible-content {
  /* When open, these sections get their full height from JS (3000px/2500px) */
}

.collapsible-content-inner {
  padding: var(--space-lg);
  /* Ensure inner content can expand naturally */
  min-height: 0;
  height: auto !important;
  max-height: none !important;
}

/* Removed height management - sections now expand to natural height */

/* Performance optimizations for animations */
.collapsible-section.animating {
  will-change: max-height, transform;
  contain: layout style;
}

.collapsible-section:not(.animating) {
  will-change: auto;
  contain: none;
}

/* Collapsible Section Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Responsive Collapsible Styles */
@media (max-width: 768px) {
  .collapsible-header {
    padding: var(--space-sm) var(--space-md);
  }
  
  .collapsible-title {
    font-size: var(--font-size-sm);
  }
  
  .collapsible-content-inner {
    padding: var(--space-md);
  }
}

/* Touch-friendly styles for mobile */
@media (hover: none) {
  .collapsible-header {
    min-height: 44px;
  }
  
  .collapsible-toggle {
    width: 44px;
    height: 44px;
  }
}

/* Performance Monitor Styles */
.performance-monitor {
  position: fixed;
  top: 10px;
  left: 10px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: var(--z-overlay);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  min-width: 140px;
  user-select: none;
  transition: all var(--transition-fast);
}

.performance-monitor:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.performance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  min-height: var(--collapsible-header-height);
}

.performance-header:hover {
  background-color: var(--bg-hover);
}

.performance-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.performance-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.performance-toggle:hover {
  color: var(--text-primary);
}

.performance-toggle svg {
  transition: transform var(--transition-fast);
}

.performance-content {
  max-height: var(--collapsible-max-height);
  opacity: 1;
  overflow: hidden;
  transition: max-height var(--collapsible-transition), opacity var(--collapsible-transition);
}

.performance-monitor.collapsed .performance-content {
  max-height: 0;
  opacity: 0;
}

.performance-metrics {
  padding: var(--space-md);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  line-height: 1.2;
}

.metric-row:last-child {
  margin-bottom: 0;
}

.metric-label {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

.metric-value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-align: right;
  min-width: 40px;
}

/* Responsive adjustments for Performance Monitor */
@media (max-width: 768px) {
  .performance-monitor {
    font-size: var(--font-size-xs);
    min-width: 120px;
  }
  
  .performance-header {
    padding: var(--space-xs) var(--space-sm);
  }
  
  .performance-metrics {
    padding: var(--space-sm);
  }
  
  .metric-row {
    margin-bottom: var(--space-xs);
  }
}