/* Global Styles */
* {
  box-sizing: border-box;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
  color: #fff;
  font-family: 'Arial', sans-serif;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top: 4px solid #00ff88;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.4em;
  font-weight: bold;
  margin-bottom: 15px;
  color: #00ff88;
}

.loading-progress-container {
  width: 300px;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  margin: 0 auto 10px;
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff88, #00ccff);
  border-radius: 4px;
  transition: width 0.2s ease-out;
}

.loading-status {
  font-size: 0.9em;
  color: #888;
  min-height: 1.2em;
}

/* Subdivision preset buttons */
.subdivision-preset {
  padding: 4px 8px;
  font-size: 0.75em;
  background: #444;
  color: #fff;
  border: 1px solid #666;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s;
}

.subdivision-preset:hover {
  background: #555;
}

.subdivision-preset:active {
  background: #666;
}

/* Auto-Fit button */
.auto-fit-btn {
  padding: 4px 8px !important;
  font-size: 0.75em !important;
  width: auto !important;
  background: #555;
  color: #fff;
  border: 1px solid #777;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.auto-fit-btn:hover {
  background: #666;
  border-color: #888;
}

.auto-fit-btn:active {
  background: #777;
  transform: scale(0.98);
}
body {
  margin: 0;
  font-family: 'Arial', sans-serif;
  background: #1e1e1e;
  color: #ddd;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #333;
  border-bottom: 2px solid #444;
}
header h1 {
  margin: 0;
  font-size: 1.5em;
  letter-spacing: 1px;
}
#night-mode-toggle button {
  padding: 5px 10px;
  border: none;
  background: #555;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.3s;
}
#night-mode-toggle button:hover {
  background: #777;
}
main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

/* Visualization Section */
#visualizer-section {
  width: 100%;
}
#visualizer-container {
  width: 100%;
  height: 80vh;
  position: relative;
  background: #000;
}
#visualizer, #glCanvas {
  width: 100%;
  height: 100%;
  display: none;
}
#visualizer {
  display: block;
}
#tracking-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Controls Section Layout */
#controls-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#top-panels {
  display: flex;
  gap: 10px;
}
#left-panels {
  flex: 0.7;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#right-panels {
  flex: 2.3;
}
/* Synth Panel Styles */
.synth-panel {
  background: #2b2b2b;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 10px;
  min-width: 260px;
}
.synth-panel h2,
.synth-panel h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1em;
  border-bottom: 1px solid #444;
  padding-bottom: 5px;
}
.synth-panel h4 {
  margin: 5px 0;
  font-size: 0.9em;
  color: #ccc;
  border-bottom: 1px solid #555;
  padding-bottom: 3px;
}

/* Audio Controls Collapsible */
.audio-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #444;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.audio-controls-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-controls-title h2 {
  margin: 0;
  border: none;
  padding: 0;
}

.audio-collapse-icon {
  font-size: 0.7em;
  color: #aaa;
  transition: transform 0.2s;
  width: 16px;
  text-align: center;
}

.audio-controls-header.collapsed .audio-collapse-icon {
  transform: rotate(-90deg);
}

.audio-mini-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #2a2a2a;
  border-radius: 4px;
  pointer-events: auto;
  cursor: default;
}

.audio-mini-player button {
  padding: 4px 8px;
  font-size: 0.85em;
  min-width: 40px;
}

.audio-mini-player #mini-time-display {
  font-size: 0.8em;
  color: #aaa;
  min-width: 80px;
  text-align: center;
  font-family: monospace;
}

.audio-mini-player #mini-volume-slider {
  width: 60px;
  height: 4px;
}

.audio-controls-content {
  display: block;
}

.audio-controls-content.collapsed {
  display: none;
}

/* Audio Source Management Collapsible */
.audio-source-management-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}

.audio-source-management-header h4 {
  margin: 0;
  border: none;
  padding: 0;
}

.audio-source-collapse-icon {
  font-size: 0.7em;
  color: #aaa;
  transition: transform 0.2s;
  width: 16px;
  text-align: center;
}

.audio-source-management-header.collapsed .audio-source-collapse-icon {
  transform: rotate(-90deg);
}

.audio-source-management-content {
  display: block;
}

.audio-source-management-content.collapsed {
  display: none;
}

.control-group {
  margin-bottom: 8px;
}
.control-group label {
  font-size: 0.9em;
  margin-bottom: 4px;
  display: block;
}
input[type="range"],
input[type="file"],
input[type="number"],
select,
button {
  width: 100%;
  padding: 4px;
  margin-top: 2px;
  margin-bottom: 4px;
  background: #3a3a3a;
  border: 1px solid #555;
  color: #ddd;
  border-radius: 2px;
  font-size: 0.9em;
}
.button-group {
  display: flex;
  gap: 5px;
}
.button-group button {
  flex: 1;
}
#audio-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.audio-buttons {
  display: flex;
  gap: 5px;
}
.visualizer-container {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.visualizer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.visualizer-item canvas {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 3px;
}

.visualizer-label {
  font-size: 0.75em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Modulation Matrix Panel */
#matrix-tables {
  width: 100%;
  overflow-x: auto;
}
#mode-parameters-table,
#global-parameters-table,
#color-inversion-parameters-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* Fixed layout prevents column width changes */
}

/* Table headers - taller for full label visibility */
#mode-parameters-table th,
#global-parameters-table th,
#color-inversion-parameters-table th {
  border: 1px solid #555;
  padding: 10px 6px; /* Increased vertical padding for better readability */
  text-align: center;
  font-size: 0.85em; /* Slightly larger font for better legibility */
  overflow: visible;
  text-overflow: clip;
  white-space: normal; /* Allow text wrapping in headers */
  vertical-align: middle;
  line-height: 1.3; /* Better line spacing for wrapped text */
  word-wrap: break-word;
  hyphens: auto;
  background: #2a2a2a; /* Slightly lighter background for better contrast */
  font-weight: 500; /* Slightly bolder for better readability */
}

/* Table cells - compact rows */
#mode-parameters-table td,
#global-parameters-table td,
#color-inversion-parameters-table td {
  border: 1px solid #555;
  padding: 4px 8px; /* Compact rows */
  text-align: center;
  font-size: 0.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fixed column widths to prevent layout shifts when values change */
#mode-parameters-table th:nth-child(1),
#mode-parameters-table td:nth-child(1),
#global-parameters-table th:nth-child(1),
#global-parameters-table td:nth-child(1),
#color-inversion-parameters-table th:nth-child(1),
#color-inversion-parameters-table td:nth-child(1) {
  width: 120px; /* Parameter/Setting name */
  text-align: left;
}

/* Base, Raw, Eff columns - accommodate up to -10.00 */
#mode-parameters-table th:nth-child(2),
#mode-parameters-table td:nth-child(2),
#mode-parameters-table th:nth-child(8),
#mode-parameters-table td:nth-child(8),
#mode-parameters-table th:nth-child(10),
#mode-parameters-table td:nth-child(10),
#global-parameters-table th:nth-child(2),
#global-parameters-table td:nth-child(2),
#global-parameters-table th:nth-child(8),
#global-parameters-table td:nth-child(8),
#global-parameters-table th:nth-child(10),
#global-parameters-table td:nth-child(10),
#color-inversion-parameters-table th:nth-child(2),
#color-inversion-parameters-table td:nth-child(2),
#color-inversion-parameters-table th:nth-child(8),
#color-inversion-parameters-table td:nth-child(8),
#color-inversion-parameters-table th:nth-child(10),
#color-inversion-parameters-table td:nth-child(10) {
  width: 65px; /* Fixed width for numeric values */
  min-width: 65px;
}

/* Slot modulation columns (S1:Env, S2:Env, etc.) - increased width for readability */
#mode-parameters-table th:nth-child(n+3):nth-child(-n+7),
#mode-parameters-table td:nth-child(n+3):nth-child(-n+7),
#global-parameters-table th:nth-child(n+3):nth-child(-n+7),
#global-parameters-table td:nth-child(n+3):nth-child(-n+7),
#color-inversion-parameters-table th:nth-child(n+3):nth-child(-n+7),
#color-inversion-parameters-table td:nth-child(n+3):nth-child(-n+7) {
  width: 75px;
  min-width: 75px;
}

/* Scale column */
#mode-parameters-table th:nth-child(9),
#mode-parameters-table td:nth-child(9),
#global-parameters-table th:nth-child(9),
#global-parameters-table td:nth-child(9),
#color-inversion-parameters-table th:nth-child(9),
#color-inversion-parameters-table td:nth-child(9) {
  width: 70px;
  min-width: 70px;
}

/* Base Input column */
#mode-parameters-table th:nth-child(11),
#mode-parameters-table td:nth-child(11),
#global-parameters-table th:nth-child(11),
#global-parameters-table td:nth-child(11),
#color-inversion-parameters-table th:nth-child(11),
#color-inversion-parameters-table td:nth-child(11) {
  width: 70px;
  min-width: 70px;
}

/* Slot Amount columns (S1:Env Amt, etc.) - increased width for full header visibility */
#mode-parameters-table th:nth-child(n+12):nth-child(-n+16),
#mode-parameters-table td:nth-child(n+12):nth-child(-n+16),
#global-parameters-table th:nth-child(n+12):nth-child(-n+16),
#global-parameters-table td:nth-child(n+12):nth-child(-n+16),
#color-inversion-parameters-table th:nth-child(n+12):nth-child(-n+16),
#color-inversion-parameters-table td:nth-child(n+12):nth-child(-n+16) {
  width: 80px;
  min-width: 80px;
}

/* Input fields in tables */
#mode-parameters-table input[type="number"],
#global-parameters-table input[type="number"],
#color-inversion-parameters-table input[type="number"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 2px 4px;
  font-size: 0.8em;
}

/* Slot Amount Inputs - Basic styling only, no formatting changes */
.slot-amount-input {
  /* Keep original table input styling - no special formatting */
}

/* Rand checkbox column */
#mode-parameters-table th:nth-child(17),
#mode-parameters-table td:nth-child(17),
#global-parameters-table th:nth-child(17),
#global-parameters-table td:nth-child(17),
#color-inversion-parameters-table th:nth-child(17),
#color-inversion-parameters-table td:nth-child(17) {
  width: 50px;
  min-width: 50px;
}

/* Description column - wider to allow text wrapping, reducing row height */
#mode-parameters-table th:nth-last-child(2),
#mode-parameters-table td:nth-last-child(2),
#global-parameters-table th:nth-last-child(2),
#global-parameters-table td:nth-last-child(2),
#color-inversion-parameters-table th:nth-last-child(2),
#color-inversion-parameters-table td:nth-last-child(2) {
  width: 140px;
  min-width: 140px;
  text-align: left;
  white-space: normal;
  line-height: 1.2; /* Tighter line spacing for wrapping text */
}

/* Accepted column - compact, doesn't need much width */
#mode-parameters-table th:last-child,
#mode-parameters-table td:last-child,
#global-parameters-table th:last-child,
#global-parameters-table td:last-child,
#color-inversion-parameters-table th:last-child,
#color-inversion-parameters-table td:last-child {
  width: 60px;
  min-width: 60px;
  text-align: left;
  white-space: normal;
}

/* Compact Theme & Preset Panel */
#theme-preset-panel {
  padding: 8px 10px;
}

/* Video Export Styles */
#video-export-panel h4 {
  margin: 0 0 8px 0;
  font-size: 1em;
  color: #ddd;
}

.video-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  color: #4caf50;
}

#video-recording-indicator {
  color: #f44336;
  font-size: 1.2em;
  animation: pulse 1s ease-in-out infinite;
}

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

#video-export-panel button {
  padding: 6px 12px;
  font-size: 0.9em;
}

.video-recording-btn {
  flex: 1;
  min-width: 0;
  width: auto !important;
}

#video-export-panel .compact-row {
  justify-content: space-between;
  align-items: center;
}

.compact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

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

.compact-row label {
  min-width: 45px;
  font-size: 0.85em;
  margin: 0;
  flex-shrink: 0;
}

.compact-row select,
.compact-row input[type="text"] {
  flex: 1;
  padding: 4px 6px;
  min-width: 0;
  margin: 0;
}

.compact-row button {
  width: 32px;
  min-width: 32px;
  height: 26px;
  padding: 2px;
  font-size: 14px;
  flex-shrink: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-select {
  flex: 1;
}

/* Audio Sources Management Styles */
.audio-source-add-section {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 10px;
}

.audio-sources-list {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px;
  margin-top: 10px;
}

.audio-sources-list h5 {
  margin: 0 0 8px 0;
  font-size: 0.9em;
  color: #ccc;
  border-bottom: 1px solid #444;
  padding-bottom: 4px;
}

#audio-sources-list-content {
  max-height: 300px;
  overflow-y: auto;
}

.audio-source-item {
  background: #333;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 8px;
  margin-bottom: 8px;
  font-size: 0.85em;
  transition: border-color 0.2s;
}

.audio-source-item:last-child {
  margin-bottom: 0;
}

.audio-source-item:hover {
  border-color: #666;
}

.audio-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.audio-source-icon {
  font-size: 1.2em;
  margin-right: 4px;
}

.audio-source-label {
  font-weight: bold;
  color: #fff;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-source-status {
  font-size: 0.85em;
  margin-right: 8px;
  white-space: nowrap;
}

.audio-source-active {
  color: #4caf50;
}

.audio-source-inactive {
  color: #888;
}

.audio-source-remove-btn {
  background: #d32f2f;
  color: white;
  border: none;
  border-radius: 3px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.audio-source-remove-btn:hover {
  background: #f44336;
}

.audio-source-file-info {
  font-size: 0.75em;
  color: #aaa;
  margin-bottom: 4px;
  font-style: italic;
}

.audio-source-slots {
  font-size: 0.8em;
  color: #aaa;
  margin-top: 4px;
}

.audio-source-slots strong {
  color: #ccc;
}

.audio-source-unused {
  color: #666;
  font-style: italic;
}

.audio-source-item-empty {
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 12px;
}

/* GIF Controls Styles */
#gif-layers-group {
  background: #303030;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
}

#gif-layers-group h4 {
  margin: 0 0 8px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #555;
  color: #ffd18f;
  font-size: 0.95em;
}

.gif-layers-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid #444;
}

.gif-layer-header-cell {
  font-size: 0.75em;
  color: #888;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.gif-layer-header-cell:nth-child(1) {
  width: 50px; /* Layer number */
}

.gif-layer-header-cell:nth-child(2),
.gif-layer-header-cell:nth-child(3) {
  width: 50px; /* Load/Clear buttons */
}

.gif-layer-header-cell:nth-child(4) {
  flex: 1; /* Status - takes remaining space */
}

.gif-layer-header-cell:nth-child(5) {
  width: 100px; /* Motion Source */
  text-align: center;
}

.gif-layer-header-cell:nth-child(6) {
  width: 40px; /* Tab */
  text-align: center;
}

.gif-layer-header-cell:nth-child(7) {
  width: 90px; /* Settings button */
  text-align: center;
}

.gif-layers-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gif-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 8px;
}

.gif-layer-row button {
  width: auto !important;
  padding: 4px 10px;
  font-size: 0.85em;
  margin: 0;
}

.gif-layer-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ddd;
  font-family: monospace;
  cursor: pointer;
  user-select: none;
}

.gif-layer-radio input[type="radio"] {
  width: auto;
  margin: 0;
}

.gif-layer-status {
  flex: 1;
  font-size: 0.8em;
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gif-layer-status.ready {
  color: #aaffaa;
}

.gif-layer-status.loading {
  color: #8fd4ff;
}

.gif-layer-status.error {
  color: #ff9aa2;
}

.gif-layer-vectors {
  font-size: 0.7em;
  padding: 2px 5px;
  background: #2a3a4a;
  border-radius: 3px;
  color: #8ab;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.gif-layer-toggle {
  padding: 4px 8px !important;
  font-size: 0.78em !important;
  line-height: 1.1;
  min-width: 72px;
  background: #2a3a4a;
  border: 1px solid #3a4a5a;
  color: #ffd18f;
}

.gif-layer-toggle:hover {
  filter: brightness(1.08);
}

.gif-layer-toggle.is-open {
  background: #3a4a5a;
}

.gif-layer-drawer {
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 10px 10px 8px 10px;
  margin-top: -4px; /* visually attaches to row above within the gap */
}

.gif-layer-drawer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.gif-layer-drawer-section {
  background: #1a1a1a;
  border: 1px solid #2f2f2f;
  border-radius: 4px;
  padding: 8px 10px;
}

.gif-layer-drawer-title {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #bbb;
  font-weight: 700;
  margin-bottom: 6px;
}

.gif-layer-drawer-row {
  margin: 6px 0;
}

.gif-layer-vector-host {
  width: 100%;
}

.gif-layer-vector-host .control-group {
  margin-top: 8px;
}

.gif-layer-vectors.gif_derived {
  background: #2a4a3a;
  color: #8fc;
}

.gif-layer-vectors.external_gif {
  background: #3a3a4a;
  color: #aaf;
}

.gif-layer-vectors.csv_data {
  background: #4a3a2a;
  color: #fc8;
}

.gif-layer-vectors.procedural {
  background: #3a2a4a;
  color: #c8f;
}

.gif-layer-vectors.physics {
  background: #4a2a3a;
  color: #f8c;
}

.gif-layer-tab {
  font-size: 0.75em;
  padding: 2px 6px;
  background: #3a3a3a;
  border-radius: 3px;
  color: #aaa;
  white-space: nowrap;
  margin-left: 4px;
  font-weight: 500;
  min-width: 28px;
  text-align: center;
}

.gif-layer-tab.active-tab {
  background: #4a5a6a;
  color: #8fd4ff;
  font-weight: 600;
}

/* Warp Status Indicator */
#warp-status-group {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px;
}

#warp-status-group h4 {
  margin: 0 0 8px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #555;
  color: #ffd18f;
  font-size: 0.95em;
}

.warp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: #1a1a1a;
  border-radius: 3px;
}

.warp-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75em;
  font-weight: bold;
  font-family: monospace;
  text-transform: uppercase;
  min-width: 40px;
  text-align: center;
}

.warp-status-badge.gpu {
  background: #4a9eff;
  color: #fff;
}

.warp-status-badge.cpu {
  background: #ffaa44;
  color: #000;
}

.warp-status-badge.error {
  background: #ff4444;
  color: #fff;
}

.warp-status-badge.unavailable {
  background: #666;
  color: #aaa;
}

.warp-status-text {
  flex: 1;
  font-size: 0.85em;
  color: #ddd;
}

.warp-status-text.active {
  color: #aaffaa;
}

.warp-status-text.warning {
  color: #ffaa44;
}

.warp-status-text.error {
  color: #ff9aa2;
}

/* ========================================
   Resource Monitor (DAW-style meters)
   ======================================== */
#resource-monitor-header {
  transition: background 0.2s ease, border-radius 0.2s ease;
  user-select: none;
}

#resource-monitor-header:hover {
  background: #3a6a9a !important;
}

#resource-monitor-header.resource-monitor-expanded {
  background: #1a3a5a;
  border: 1px solid #3a5a7a;
  border-bottom: none;
}

#resource-monitor-panel {
  background: #1a2a3a;
  border: 1px solid #3a5a7a;
  border-radius: 0 0 4px 4px;
  padding: 10px;
}

.resource-meters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter-name {
  width: 55px;
  font-size: 0.75em;
  color: #8ab;
  text-align: right;
}

.meter {
  flex: 1;
  height: 16px;
  background: #222;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  border: 1px solid #3a5a7a;
}

.meter-fill {
  height: 100%;
  transition: width 0.15s ease-out;
  border-radius: 2px;
}

.meter-fill.normal {
  background: linear-gradient(to right, #4a9eff, #6ab0ff);
}

.meter-fill.warning {
  background: linear-gradient(to right, #ffaa44, #ffcc66);
}

.meter-fill.critical {
  background: linear-gradient(to right, #ff4444, #ff6666);
  animation: pulse-critical 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-critical {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

.meter-label {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
}

.resource-warning {
  padding: 4px 8px;
  margin-top: 4px;
  background: rgba(255, 170, 68, 0.15);
  border-left: 3px solid #ffaa44;
  font-size: 0.75em;
  color: #ffcc88;
  border-radius: 0 3px 3px 0;
}

/* ========================================
   Inline Progress Bars (for file uploads/exports)
   ======================================== */
.inline-progress {
  margin-top: 10px;
  padding: 10px;
  background: #1a2a3a;
  border: 1px solid #3a5a7a;
  border-radius: 4px;
}

.inline-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.inline-progress-label {
  font-size: 0.85em;
  color: #8fd4ff;
  font-weight: 500;
}

.inline-progress-percent {
  font-size: 0.85em;
  color: #8fd4ff;
  font-weight: bold;
  font-family: monospace;
}

.inline-progress-bar {
  height: 8px;
  background: #0a1a2a;
  border-radius: 4px;
  overflow: hidden;
}

.inline-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2a6a9a, #4a9acc);
  border-radius: 4px;
  transition: width 0.2s ease-out;
}

.inline-progress-fill.complete {
  background: linear-gradient(90deg, #2a8a4a, #4acc6a);
}

.inline-progress-fill.error {
  background: linear-gradient(90deg, #8a2a2a, #cc4a4a);
}

.inline-progress-status {
  margin-top: 6px;
  font-size: 0.75em;
  color: #888;
}

#gif-controls-group {
  background: #353535;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
}

#gif-controls-group h4 {
  margin: 0 0 8px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #555;
  color: #8fd4ff;
  font-size: 0.95em;
}

.gif-info {
  background: #2a2a2a;
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 0.85em;
  color: #aaffaa;
  margin-bottom: 8px;
  font-family: monospace;
}

.gif-playback-hint {
  margin-top: 8px;
  padding: 6px;
  background: #2a2a2a;
  border-left: 3px solid #8fd4ff;
  border-radius: 2px;
}

.gif-playback-hint small {
  color: #999;
  font-size: 0.8em;
  line-height: 1.4;
}

.gif-bpm-readout {
  background: #2a2a2a;
  padding: 4px 8px;
  border-radius: 3px;
  margin: 6px 0;
}

.gif-bpm-readout small {
  color: #8fd4ff;
  font-family: monospace;
  font-size: 0.85em;
}

/* Manual BPM input */
#manual-bpm {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #2a2a2a;
  color: #fff;
  font-size: 0.9em;
  margin-left: 8px;
}

#manual-bpm:focus {
  outline: none;
  border-color: #8fd4ff;
}

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

#tap-tempo-btn {
  padding: 4px 10px;
  background: linear-gradient(to bottom, #4a4a4a, #3a3a3a);
  border: 1px solid #555;
  border-radius: 3px;
  color: #fff;
  font-size: 0.8em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s ease;
}

#tap-tempo-btn:hover {
  background: linear-gradient(to bottom, #5a5a5a, #4a4a4a);
  border-color: #8fd4ff;
}

#tap-tempo-btn:active,
#tap-tempo-btn.tapped {
  background: linear-gradient(to bottom, #8fd4ff, #6ab4df);
  color: #000;
  transform: scale(0.95);
}

#clear-bpm-btn {
  padding: 4px 8px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 3px;
  color: #888;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.15s ease;
}

#clear-bpm-btn:hover {
  background: #4a3a3a;
  border-color: #f66;
  color: #f66;
}

.bpm-display {
  font-size: 0.85em;
  color: #8fd4ff;
  margin-left: 10px;
}

/* Modulation Slot Panel Styles */
.slot-panel {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.slot-header {
  background: linear-gradient(to bottom, #3a3a3a, #333);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #444;
}

.slot-collapse-toggle {
  cursor: pointer;
  color: #aaa;
  font-size: 0.8em;
  width: 16px;
  text-align: center;
  user-select: none;
  /* Minimal UI overhead: no transitions */
  transition: none !important;
  display: inline-block;
  margin-right: 0;
}

.slot-collapse-toggle:hover {
  color: #fff;
}

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

.slot-number {
  font-weight: bold;
  color: #8fd4ff;
  font-size: 0.95em;
  min-width: 50px;
}

.slot-type-select {
  padding: 6px 28px 6px 10px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #2a2a2a;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
  min-width: 140px;
  appearance: none;
  -webkit-appearance: none;
  -moz-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='%23888' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  /* Minimal UI overhead: no transitions */
  transition: none !important;
  position: relative;
}

.slot-type-select:hover {
  border-color: #666;
  background-color: #333;
  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='%23aaa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.slot-type-select:focus {
  outline: none;
  border-color: #8fd4ff;
  box-shadow: 0 0 0 2px rgba(143, 212, 255, 0.2);
  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='%238fd4ff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.slot-type-select:active {
  background-color: #2a2a2a;
}

.slot-enable-label {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #aaa;
  font-size: 0.85em;
}

.slot-enable-label input {
  cursor: pointer;
}

.slot-controls {
  padding: 10px 12px;
}

.slot-empty {
  color: #666;
  font-style: italic;
  font-size: 0.9em;
  text-align: center;
  padding: 10px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.control-row label {
  font-size: 0.85em;
  color: #bbb;
  min-width: 100px;
}

.control-row input[type="range"] {
  flex: 1;
  max-width: 150px;
}

.control-row select {
  padding: 3px 6px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #333;
  color: #fff;
  font-size: 0.85em;
}

.control-row.checkbox-row {
  gap: 16px;
}

.control-row.checkbox-row label {
  min-width: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.slot-disabled {
  opacity: 0.4;
}

.slot-disabled input {
  pointer-events: none;
}

/* Slot Visualizers (5 canvases in a row) */
.slot-visualizers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.slot-visualizers .visualizer-item {
  flex: 0 0 auto;
}

.slot-visualizers canvas {
  border: 1px solid #444;
  border-radius: 3px;
  background: #1a1a1a;
}

.slot-visualizers .visualizer-label {
  font-size: 0.75em;
  text-align: center;
  display: block;
  margin-top: 2px;
  font-family: monospace;
}

/* Collapsible Source Group Styles */
.source-group-header {
  background: #3a3a3a;
  padding: 8px 10px;
  margin: -10px -10px 10px -10px;
  border-bottom: 1px solid #555;
  font-weight: bold;
  font-size: 1em;
  color: #ddd;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.source-group-header:hover {
  background: #454545;
}

.collapse-indicator {
  font-size: 0.8em;
  color: #888;
  width: 12px;
  display: inline-block;
  text-align: center;
}

.source-group-content {
  padding-top: 5px;
}

/* Checkbox row for inline checkboxes */
.checkbox-row {
  display: flex;
  gap: 15px;
  margin-top: 5px;
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Parameter Group Styles */
.parameter-group-header {
  background: #333;
  cursor: pointer;
  user-select: none;
}

.parameter-group-header:hover {
  background: #3a3a3a;
}

.parameter-group-header td {
  border: 1px solid #555;
  padding: 6px 8px;
  text-align: left;
  overflow: visible;
  white-space: normal;
}

.group-collapse-toggle {
  cursor: pointer;
  color: #888;
  font-size: 0.8em;
  margin-right: 8px;
  display: inline-block;
  /* Minimal UI overhead: no transitions */
  transition: none !important;
  width: 16px;
  text-align: center;
}

.group-collapse-toggle:hover {
  color: #aaa;
}

.parameter-group-header.collapsed .group-collapse-toggle {
  transform: rotate(-90deg);
}

.group-name {
  font-size: 0.85em;
  color: #8fd4ff;
  font-weight: bold;
  margin-right: 12px;
  display: inline;
}

.group-description {
  font-size: 0.75em;
  color: #aaa;
  font-style: italic;
  margin-right: 12px;
  display: inline;
}

.group-count {
  font-size: 0.75em;
  color: #666;
  float: right;
  display: inline-block;
}

/* Parameter rows within groups - slight indent for visual hierarchy */
.parameter-row.group-global-param td:first-child,
.parameter-row.group-mode-param td:first-child,
.parameter-row.group-color-param td:first-child {
  padding-left: 30px;
}

/* Collapsible Sections for Movement Vectors & Compression Panel */
.collapsible-section {
  margin-bottom: 10px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #252525;
}

.section-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #2a2a2a;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.section-header:hover {
  background: #333;
}

.section-header h3 {
  margin: 0;
  font-size: 1em;
  border: none;
  padding: 0;
  flex: 1;
}

.section-header .collapse-icon {
  margin-right: 8px;
  transition: transform 0.2s;
  font-size: 0.8em;
  color: #aaa;
  width: 16px;
  text-align: center;
}

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

.section-content {
  padding: 12px;
  display: block;
}

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

/* Sub-sections (nested collapsible) */
.sub-section {
  margin-top: 8px;
  margin-left: 16px;
  border-left: 2px solid #444;
  padding-left: 12px;
}

.sub-section-header {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9em;
  color: #aaa;
  user-select: none;
  transition: color 0.2s;
}

.sub-section-header:hover {
  color: #fff;
}

.sub-section-header h4 {
  margin: 0;
  font-size: 0.9em;
  font-weight: normal;
  flex: 1;
}

.sub-section-header .collapse-icon {
  margin-right: 6px;
  transition: transform 0.2s;
  font-size: 0.7em;
  width: 12px;
  text-align: center;
}

.sub-section-header.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.sub-section-content {
  padding: 8px;
  padding-left: 20px;
  display: block;
}

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

/* ===== Modulation Tab Bar ===== */
.mod-tabs-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  border: 1px solid #333;
}

.mod-tab-btn {
  position: relative;
  padding: 8px 16px;
  background: #333;
  color: #999;
  border: 1px solid #444;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: bold;
  transition: all 0.15s ease;
  min-width: 70px;
}

.mod-tab-btn:hover {
  background: #444;
  color: #ccc;
}

.mod-tab-btn.active {
  background: #2b2b2b;
  color: #00ff88;
  border-bottom-color: #2b2b2b;
  box-shadow: 0 2px 0 #00ff88 inset;
}

.mod-tab-btn .tab-layer-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #00aaff;
  color: #fff;
  font-size: 0.65em;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
  line-height: 1;
}

.mod-tab-copy-paste {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid #444;
}

.mod-tab-action-btn {
  padding: 4px 10px;
  background: #444;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.15s ease;
}

.mod-tab-action-btn:hover:not(:disabled) {
  background: #555;
  color: #fff;
}

.mod-tab-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mod-tab-hints {
  margin-left: auto;
  color: #666;
  font-size: 0.75em;
}

.mod-tab-hints small {
  white-space: nowrap;
}

/* Row copy button */
.param-name-cell {
  position: relative;
}

.row-copy-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.9em;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.parameter-row:hover .row-copy-btn {
  opacity: 1;
}

.row-copy-btn:hover {
  color: #8fd4ff;
}

.row-input-sources-btn {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.9em;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.parameter-row:hover .row-input-sources-btn {
  opacity: 1;
}

.row-input-sources-btn:hover {
  color: #8fd4ff;
}

.row-input-sources-btn.has-sources {
  color: #8fd4ff;
  opacity: 0.7;
}

.row-input-sources-btn.has-sources:hover {
  opacity: 1;
}

/* Parameter Input Sources Dialog */
.parameter-input-sources-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.parameter-input-sources-dialog {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.parameter-input-sources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
}

.parameter-input-sources-header h3 {
  margin: 0;
  color: #8fd4ff;
  font-size: 1.2em;
}

.parameter-input-sources-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 30px;
}

.parameter-input-sources-close:hover {
  color: #fff;
}

.parameter-input-sources-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.parameter-input-sources-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.parameter-input-source-item {
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 15px;
}

.source-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.source-type {
  color: #8fd4ff;
  font-weight: bold;
  font-size: 0.9em;
}

.source-remove {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.2em;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  line-height: 24px;
}

.source-remove:hover {
  color: #ff4444;
}

.source-item-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-field label {
  color: #aaa;
  font-size: 0.9em;
  min-width: 100px;
}

.source-field select,
.source-field input[type="number"] {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9em;
}

.source-field select:focus,
.source-field input[type="number"]:focus {
  outline: none;
  border-color: #8fd4ff;
}

.source-key-learn {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  min-width: 150px;
  text-align: left;
}

.source-key-learn:hover {
  background: #444;
  border-color: #8fd4ff;
}

.source-key-learn.bound {
  color: #8fd4ff;
  border-color: #8fd4ff;
}

.parameter-input-sources-add {
  display: flex;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid #444;
}

.parameter-input-sources-add-btn {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.parameter-input-sources-add-btn:hover {
  background: #444;
  border-color: #8fd4ff;
}

/* Macro Hotkey Dialog */
.macro-hotkey-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.macro-hotkey-dialog {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.macro-hotkey-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
}

.macro-hotkey-dialog-header h3 {
  margin: 0;
  color: #8fd4ff;
  font-size: 1.2em;
}

.macro-hotkey-dialog-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 30px;
}

.macro-hotkey-dialog-close:hover {
  color: #fff;
}

.macro-hotkey-dialog-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.macro-hotkey-type-select {
  display: flex;
  gap: 10px;
}

.macro-hotkey-type-btn {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-type-btn:hover {
  background: #444;
  border-color: #8fd4ff;
}

.macro-hotkey-type-btn.active {
  background: #2a4a5a;
  border-color: #8fd4ff;
  color: #8fd4ff;
}

.macro-hotkey-config {
  min-height: 200px;
}

.macro-hotkey-keyboard-config,
.macro-hotkey-midi-config {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.macro-hotkey-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.macro-hotkey-field label {
  color: #aaa;
  font-size: 0.9em;
  min-width: 100px;
}

.macro-hotkey-field select,
.macro-hotkey-field input[type="number"] {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9em;
}

.macro-hotkey-field select:focus,
.macro-hotkey-field input[type="number"]:focus {
  outline: none;
  border-color: #8fd4ff;
}

.macro-hotkey-learn-btn,
.macro-hotkey-apply-btn {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-learn-btn:hover,
.macro-hotkey-apply-btn:hover {
  background: #444;
  border-color: #8fd4ff;
}

.macro-hotkey-remove {
  background: #442222;
  border: 1px solid #664444;
  color: #ff8888;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-remove:hover {
  background: #553333;
  border-color: #ff4444;
}

.macro-hotkey-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #222;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* Macro Hotkey Dialog */
.macro-hotkey-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.macro-hotkey-dialog {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.macro-hotkey-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
}

.macro-hotkey-dialog-header h3 {
  margin: 0;
  color: #8fd4ff;
  font-size: 1.2em;
}

.macro-hotkey-dialog-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 30px;
}

.macro-hotkey-dialog-close:hover {
  color: #fff;
}

.macro-hotkey-dialog-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.macro-hotkey-type-select {
  display: flex;
  gap: 10px;
}

.macro-hotkey-type-btn {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-type-btn:hover {
  background: #444;
  border-color: #8fd4ff;
}

.macro-hotkey-type-btn.active {
  background: #2a4a5a;
  border-color: #8fd4ff;
  color: #8fd4ff;
}

.macro-hotkey-config {
  min-height: 200px;
}

.macro-hotkey-keyboard-config,
.macro-hotkey-midi-config {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.macro-hotkey-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.macro-hotkey-field label {
  color: #aaa;
  font-size: 0.9em;
  min-width: 100px;
}

.macro-hotkey-field select,
.macro-hotkey-field input[type="number"] {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9em;
}

.macro-hotkey-field select:focus,
.macro-hotkey-field input[type="number"]:focus {
  outline: none;
  border-color: #8fd4ff;
}

.macro-hotkey-learn-btn,
.macro-hotkey-apply-btn {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-learn-btn:hover,
.macro-hotkey-apply-btn:hover {
  background: #444;
  border-color: #8fd4ff;
}

.macro-hotkey-remove {
  background: #442222;
  border: 1px solid #664444;
  color: #ff8888;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s, border-color 0.2s;
}

.macro-hotkey-remove:hover {
  background: #553333;
  border-color: #ff4444;
}

.macro-hotkey-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #222;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* Row copy menu popup */
.row-copy-menu {
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  min-width: 120px;
}

.row-copy-menu-title {
  font-size: 0.8em;
  color: #aaa;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.row-copy-menu-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  color: #ccc;
  cursor: pointer;
  text-align: left;
  font-size: 0.85em;
  border-radius: 3px;
  transition: background 0.1s;
}

.row-copy-menu-btn:hover {
  background: #444;
  color: #fff;
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */

/* Fullscreen container styles */
#visualizer-container:fullscreen,
#visualizer-container:-webkit-full-screen,
#visualizer-container:-moz-full-screen,
#visualizer-container:-ms-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  background: #000;
  padding: 0;
  margin: 0;
}

#visualizer-container:fullscreen canvas,
#visualizer-container:-webkit-full-screen canvas,
#visualizer-container:-moz-full-screen canvas,
#visualizer-container:-ms-fullscreen canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Hide tracking canvas border in fullscreen */
#visualizer-container:fullscreen #tracking-canvas,
#visualizer-container:-webkit-full-screen #tracking-canvas {
  border: none;
}

/* Body state class for fullscreen mode */
.is-fullscreen {
  overflow: hidden;
}

/* Fullscreen hint overlay (optional - shows briefly on enter) */
.fullscreen-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.9em;
  pointer-events: none;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fullscreen-hint.visible {
  opacity: 1;
}

/* ========================================
   SLOT HOVER HIGHLIGHTING (Bidirectional)
   ======================================== */

/* Highlight style for matrix columns when hovering slot panels/visualizers */
.slot-column-highlight {
  background: rgba(143, 212, 255, 0.15) !important;
  /* Minimal highlight: avoid expensive shadows/transitions on large tables */
  box-shadow: none !important;
  transition: none !important;
}

/* Stronger highlight for header cells */
th.slot-column-highlight {
  background: rgba(143, 212, 255, 0.25) !important;
  color: #8fd4ff;
}

/* Ultra-fast column highlighting: toggle ONE class on <body> and use nth-child selectors */
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(3),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(4),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(5),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(6),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(7),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(12),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(13),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(14),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(15),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(th, td):nth-child(16) {
  /* no-op baseline; prevents accidental specificity surprises */
}

/* S0:Offset column highlighting (column index 1 left = nth-child(2), column index 10 right = nth-child(11)) */
body.slot-highlight-offset :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(2),
body.slot-highlight-offset :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(11),
/* S1-S5 column highlighting */
body.slot-highlight-0 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(3),
body.slot-highlight-0 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(12),
body.slot-highlight-1 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(4),
body.slot-highlight-1 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(13),
body.slot-highlight-2 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(5),
body.slot-highlight-2 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(14),
body.slot-highlight-3 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(6),
body.slot-highlight-3 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(15),
body.slot-highlight-4 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(7),
body.slot-highlight-4 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) :is(td, th):nth-child(16) {
  background: rgba(143, 212, 255, 0.15) !important;
  /* Minimal highlight: no shadows/transitions */
  box-shadow: none !important;
  transition: none !important;
}

/* S0:Offset header highlighting */
body.slot-highlight-offset :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(2),
body.slot-highlight-offset :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(11),
/* S1-S5 header highlighting */
body.slot-highlight-0 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(3),
body.slot-highlight-0 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(12),
body.slot-highlight-1 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(4),
body.slot-highlight-1 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(13),
body.slot-highlight-2 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(5),
body.slot-highlight-2 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(14),
body.slot-highlight-3 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(6),
body.slot-highlight-3 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(15),
body.slot-highlight-4 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(7),
body.slot-highlight-4 :is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table) th:nth-child(16) {
  background: rgba(143, 212, 255, 0.25) !important;
  color: #8fd4ff;
}

/* Paired column highlight (S0:Offset ↔ S0:Offset) - uses same color as slot highlighting */
.paired-column-highlight {
  background: rgba(143, 212, 255, 0.15) !important;
  /* Minimal: no shadows/transitions */
  box-shadow: none !important;
  transition: none !important;
}

/* Stronger highlight for paired header cells */
th.paired-column-highlight {
  background: rgba(143, 212, 255, 0.25) !important;
  color: #8fd4ff;
}

/* Ultra-fast paired offset highlight: toggle ONE class on table, CSS uses nth-child */
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table).paired-offset-highlight :is(td, th):nth-child(2),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table).paired-offset-highlight :is(td, th):nth-child(11) {
  background: rgba(143, 212, 255, 0.15) !important;
  box-shadow: none !important;
  transition: none !important;
}

:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table).paired-offset-highlight th:nth-child(2),
:is(#global-parameters-table, #mode-parameters-table, #color-inversion-parameters-table).paired-offset-highlight th:nth-child(11) {
  background: rgba(143, 212, 255, 0.25) !important;
  color: #8fd4ff;
}

/* Make slot panels show they're interactive */
.slot-panel {
  /* Minimal UI overhead: keep interactions crisp, avoid expensive paints */
  transition: none !important;
}

.slot-panel:hover {
  border-color: #8fd4ff;
}

/* Slot panel highlight (bidirectional - triggered from any related element) */
.slot-panel.slot-panel-highlight {
  border-color: #8fd4ff !important;
  /* Minimal highlight: subtle tint + crisp outline (better in low light, cheaper to render) */
  box-shadow: none !important;
  background: rgba(143, 212, 255, 0.06) !important;
  outline: 1px solid rgba(143, 212, 255, 0.55);
  outline-offset: 1px;
}

.slot-panel.slot-panel-highlight .slot-header {
  background: linear-gradient(to bottom, #4a5a6a, #3a4a5a) !important;
}

.slot-panel.slot-panel-highlight .slot-number {
  color: #aaf4ff;
  text-shadow: none !important;
}

/* Slot visualizer canvas hover effect */
.slot-visualizers .visualizer-item {
  transition: none !important;
}

.slot-visualizers .visualizer-item canvas {
  transition: none !important;
}

.slot-visualizers .visualizer-item canvas:hover {
  border-color: #8fd4ff;
  box-shadow: none !important;
  cursor: pointer;
}

/* Slot visualizer highlight (bidirectional - triggered from any related element) */
.slot-visualizers .visualizer-item.slot-visualizer-highlight {
  transform: none !important;
}

.slot-visualizers .visualizer-item.slot-visualizer-highlight canvas {
  border-color: #8fd4ff !important;
  box-shadow: none !important;
  outline: 1px solid rgba(143, 212, 255, 0.75);
  outline-offset: 1px;
}

.slot-visualizers .visualizer-item.slot-visualizer-highlight .visualizer-label {
  color: #8fd4ff;
  text-shadow: none !important;
  font-weight: bold;
}

/* Visual feedback: pulse animation when slot is actively modulating */
@keyframes slot-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(143, 212, 255, 0.2); }
  50% { box-shadow: 0 0 12px rgba(143, 212, 255, 0.5); }
}

.slot-panel.active-modulation {
  /* Minimal UI overhead: disable pulse animation */
  animation: none !important;
}

/* Connecting line indicator (optional visual enhancement) */
.slot-connection-indicator {
  position: absolute;
  pointer-events: none;
  border: 2px dashed rgba(143, 212, 255, 0.3);
  border-radius: 4px;
  z-index: 1000;
  /* Minimal UI overhead: disable connection pulse animation */
  animation: none !important;
}

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

/* ========================================
   MACRO PANEL
   ======================================== */
.macro-panel {
  margin-bottom: 10px;
}

.macro-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #2a2a2a;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #444;
  gap: 10px;
}

.macro-panel-header .macro-collapse-toggle {
  margin-right: 8px;
}

.macro-panel-header h2 {
  margin: 0;
  border: none;
  padding: 0;
}

.macro-panel-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
  flex-wrap: nowrap;
}

.macro-control-group {
  display: flex;
  gap: 5px;
  align-items: center;
  white-space: nowrap;
}

.macro-control-group label {
  font-size: 0.75em;
  color: #aaa;
  white-space: nowrap;
  margin-right: 2px;
}

.macro-control-select {
  padding: 4px 8px;
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75em;
  cursor: pointer;
  min-width: 100px;
}

.macro-control-select:focus {
  outline: none;
  border-color: #8fd4ff;
}

.macro-control-btn {
  padding: 4px 8px;
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
  font-size: 0.75em;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.macro-control-btn:hover:not(:disabled) {
  background: #444;
  color: #fff;
  border-color: #8fd4ff;
}

.macro-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.macro-collapse-toggle {
  font-size: 0.7em;
  color: #aaa;
  transition: transform 0.2s;
  width: 16px;
  text-align: center;
}

.macro-panel-header.collapsed .macro-collapse-toggle {
  transform: rotate(-90deg);
}

.macro-panel-content {
  padding: 10px;
}

.macros-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.macro-knob {
  flex: 1;
  min-width: 200px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 8px;
}

/* Macro header row - controls */
.macro-header-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 0.8em;
}

.macro-name-input {
  width: 65px;
  padding: 2px 4px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 2px;
  color: #ddd;
  font-size: inherit;
}

.macro-btn {
  padding: 2px 6px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 2px;
  color: #aaa;
  cursor: pointer;
  font-size: inherit;
  white-space: nowrap;
}

.macro-btn:hover {
  background: #4a4a4a;
  border-color: #8fd4ff;
  color: #fff;
}

.macro-btn.bound {
  background: #2a4a5a;
  border-color: #8fd4ff;
  color: #8fd4ff;
}

.macro-dest-btn {
  color: #7c7;
}

.macro-hotkey-btn {
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.macro-spacer {
  flex: 1;
}

.macro-range-label {
  color: #666;
  font-size: inherit;
}

.macro-range-input {
  width: 32px;
  padding: 1px 2px;
  background: #333;
  border: 1px solid #444;
  border-radius: 2px;
  color: #888;
  font-size: inherit;
  text-align: center;
}

.macro-range-input:focus {
  border-color: #8fd4ff;
  color: #ddd;
  outline: none;
}

/* Macro slider row - dedicated row for oversized slider */
.macro-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.macro-slider {
  flex: 1;
  cursor: pointer;
}

.macro-value-display {
  min-width: 35px;
  text-align: right;
  font-family: monospace;
  font-size: 0.85em;
  color: #8fd4ff;
  font-weight: bold;
}

.macro-destinations-summary {
  font-size: 0.7em;
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(79, 212, 255, 0.05);
  border: 1px solid rgba(79, 212, 255, 0.15);
  border-radius: 3px;
  max-height: 150px;
  overflow-y: auto;
  transition: background-color 0.2s ease;
}

.macro-destinations-summary:hover {
  background: rgba(79, 212, 255, 0.12);
}

.macro-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}

.macro-summary-table thead {
  position: sticky;
  top: 0;
  background: rgba(42, 42, 42, 0.95);
  z-index: 1;
}

.macro-summary-table th {
  text-align: left;
  padding: 4px 6px;
  font-size: 0.75em;
  color: #8fd4ff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(79, 212, 255, 0.3);
}

.macro-summary-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(79, 212, 255, 0.1);
  vertical-align: middle;
}

.macro-summary-table tbody tr:hover {
  background: rgba(79, 212, 255, 0.05);
}

.macro-summary-table tbody tr.inactive {
  opacity: 0.6;
}

.macro-summary-table tbody tr.inactive:hover {
  opacity: 0.8;
}

.macro-summary-table input {
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 2px;
  color: #ddd;
  text-align: center;
}

.macro-summary-table input:focus {
  outline: none;
  border-color: #8fd4ff;
  background: #4a4a4a;
}

.macro-summary-param {
  font-weight: 500;
  min-width: 120px;
}

.macro-summary-source {
  font-size: 0.85em;
  min-width: 80px;
}

.macro-summary-value {
  font-family: monospace;
  text-align: right;
  min-width: 50px;
}

.macro-summary-range {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 120px;
}

.macro-summary-amount,
.macro-summary-onset {
  min-width: 70px;
}

/* ========================================
   HOTKEY BUTTONS
   ======================================== */
.param-hotkeys-cell {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.hotkey-learn-btn {
  padding: 2px 6px;
  background: #444;
  border: 1px solid #555;
  border-radius: 3px;
  color: #aaa;
  cursor: pointer;
  font-size: 0.75em;
  min-width: 24px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hotkey-learn-btn:hover {
  background: #555;
  color: #fff;
}

.hotkey-learn-btn.bound {
  background: #4a6a9a;
  color: #fff;
}

.hotkey-learn-btn.bound[data-key]::after {
  content: attr(data-key);
  font-size: 0.7em;
  margin-left: 4px;
}

/* ========================================
   MACRO AMOUNT INPUTS
   ======================================== */
.param-macro-amounts-cell {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 4px;
}

.macro-amount-input {
  width: 50px;
  padding: 2px 4px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 2px;
  color: #ddd;
  font-size: 0.75em;
  text-align: center;
}

.macro-amount-input:focus {
  outline: none;
  border-color: #8fd4ff;
}

/* Key learn mode visual feedback */
body.key-learn-active {
  cursor: crosshair;
}

body.key-learn-active .hotkey-learn-btn:not(.bound),
body.key-learn-active .macro-learn-btn:not(.bound) {
  animation: pulse-learn 1s ease-in-out infinite;
}

@keyframes pulse-learn {
  0%, 100% { background: #4a6a9a; }
  50% { background: #6a8aaa; }
}

/* ========================================
   MACRO DESTINATIONS DIALOG
   ======================================== */
.macro-destinations-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.macro-destinations-dialog {
  background: #2b2b2b;
  border: 2px solid #555;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.macro-destinations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #555;
  background: #333;
}

.macro-destinations-header h3 {
  margin: 0;
  font-size: 1.1em;
  color: #8fd4ff;
}

.macro-destinations-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.macro-destinations-close:hover {
  background: #444;
  color: #fff;
}

.macro-destinations-add {
  padding: 12px 16px;
  border-bottom: 1px solid #444;
  background: #252525;
}

.macro-destinations-add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-destinations-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-destinations-form-group label {
  font-size: 0.85em;
  color: #ccc;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.macro-destinations-param-select,
.macro-destinations-column-select,
.macro-destinations-amount-input {
  padding: 8px 10px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ddd;
  font-size: 0.9em;
  width: 100%;
}

.macro-destinations-amount-input {
  width: 100px;
}

.macro-destinations-add-btn {
  padding: 10px 20px;
  background: #4a6a9a;
  border: 1px solid #5a7aaa;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 500;
  align-self: flex-start;
  margin-top: 4px;
}

.macro-destinations-add-btn:hover {
  background: #5a7aaa;
}

.macro-destinations-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-destinations-empty {
  text-align: center;
  color: #888;
  padding: 40px;
  font-style: italic;
}

.macro-destination-item {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.macro-destination-param-name {
  font-weight: bold;
  color: #8fd4ff;
  font-size: 1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.macro-destination-remove {
  background: #6a2a2a;
  border: 1px solid #7a3a3a;
  border-radius: 4px;
  color: #ffaaaa;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1.2em;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.macro-destination-remove:hover {
  background: #7a3a3a;
  color: #ffcccc;
}

.macro-destination-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.macro-destination-control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.macro-destination-control-group label {
  font-size: 0.8em;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.macro-destination-control-group input {
  padding: 6px 8px;
  background: #3a3a3a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ddd;
  font-size: 0.9em;
}

.macro-destination-control-group input:focus {
  outline: none;
  border-color: #8fd4ff;
}

.macro-destination-control-group.amount input {
  background: #3a4a5a;
}

.macro-destination-control-group.onset input {
  background: #4a3a5a;
}

.macro-destination-control-group.mode select {
  padding: 6px 8px;
  background: #3a4a5a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ddd;
  font-size: 0.9em;
}

.macro-destination-control-group.mode select:focus {
  outline: none;
  border-color: #8fd4ff;
}

/* Slot destinations button */
.slot-destinations-btn {
  padding: 4px 10px;
  background: #4a5a6a;
  border: 1px solid #5a6a7a;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8em;
  white-space: nowrap;
  margin-right: 4px;
}

.slot-destinations-btn:hover {
  background: #5a6a7a;
}

/* Link button in slot destinations */
.macro-destination-link-btn {
  padding: 6px 12px;
  background: #4a6a9a;
  border: 1px solid #5a7aaa;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 0.85em;
  margin-top: 8px;
  width: 100%;
}

.macro-destination-link-btn:hover {
  background: #5a7aaa;
}
