        html {
            overflow-x: hidden;
            overflow-y: auto;
            height: 100%;
            /* Ensure html is the scrollable container */
            position: relative;
        }

        :root {
            /* Dark theme (default) */
            --bg-primary: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
            --bg-secondary: rgba(26, 26, 46, 0.98);
            --bg-module: rgba(255, 255, 255, 0.03);
            --bg-module-hover: rgba(255, 255, 255, 0.05);
            --bg-param: rgba(255, 255, 255, 0.03);
            --bg-info-panel: rgba(26, 26, 46, 0.98);
            --border-module: rgba(255, 255, 255, 0.1);
            --border-module-hover: rgba(255, 255, 255, 0.2);
            --border-param: rgba(255, 255, 255, 0.08);
            --text-primary: #fff;
            --text-secondary: #888;
            --text-tertiary: #666;
            --section-label: #666;
        }

        [data-theme="light"] {
            /* Light theme */
            --bg-primary: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
            --bg-secondary: rgba(255, 255, 255, 0.98);
            --bg-module: rgba(255, 255, 255, 0.95);
            --bg-module-hover: rgba(255, 255, 255, 1);
            --bg-param: rgba(255, 255, 255, 0.9);
            --bg-info-panel: rgba(255, 255, 255, 0.98);
            --border-module: rgba(0, 0, 0, 0.1);
            --border-module-hover: rgba(0, 0, 0, 0.2);
            --border-param: rgba(0, 0, 0, 0.08);
            --text-primary: #1a1a2e;
            --text-secondary: #555;
            --text-tertiary: #777;
            --section-label: #777;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
            background: var(--bg-primary);
            height: 100vh;
            display: flex;
            flex-direction: column;
            color: var(--text-primary);
            transition: background 0.3s ease, color 0.3s ease;
            overflow: hidden;
            position: relative;
            margin: 0;
            padding: 0;
        }

        .container {
            width: 100%;
            display: flex;
            flex-direction: column;
            flex: 1;
            overflow: hidden;
        }

        .header {
            display: none;
            /* Header removed */
        }

        /* Top Controls Bar */
        .top-controls {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 60px;
            background: var(--bg-primary);
            border-bottom: 1px solid var(--border-module);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 24px;
            gap: 24px;
            z-index: 1000;
            backdrop-filter: blur(10px);
        }

        .theme-toggle {
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 20px;
            padding: 7px 14px;
            cursor: pointer;
            font-size: 14px;
            color: var(--text-secondary);
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 7px;
        }

        .theme-toggle:hover {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
            color: var(--text-primary);
        }

        .synth-selector {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .synth-selector label {
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 500;
        }

        .synth-selector select {
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 6px;
            padding: 6px 12px;
            color: var(--text-primary);
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-family: inherit;
        }

        .synth-selector select:hover {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
        }

        .synth-selector select:focus {
            outline: none;
            border-color: var(--border-module-hover);
            background: var(--bg-module-hover);
        }

        .midi-controls {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .midi-button {
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 20px;
            padding: 7px 14px;
            cursor: pointer;
            font-size: 14px;
            color: var(--text-secondary);
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 7px;
            font-family: inherit;
        }

        .midi-button:hover {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
            color: var(--text-primary);
        }

        .midi-button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .midi-status {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .status-indicator {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--text-tertiary);
            transition: background 0.3s ease;
        }

        .status-indicator.connected {
            background: #43e97b;
            box-shadow: 0 0 6px rgba(67, 233, 123, 0.5);
        }

        .status-indicator.listening {
            background: #4facfe;
            box-shadow: 0 0 6px rgba(79, 172, 254, 0.5);
            animation: pulse-status 2s ease-in-out infinite;
        }

        @keyframes pulse-status {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.5;
            }
        }

        .container {
            display: flex;
            flex-direction: column;
            height: 100vh;
            padding-top: 60px;
            /* Space for top controls */
            overflow: hidden;
        }

        .signal-chain {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding: 24px;
            overflow: auto;
            position: relative;
            /* Ensure absolute children scroll with content */
        }

        /* Popup Tooltip Styles */
        .param-popup {
            position: absolute;
            background: rgba(26, 26, 46, 0.95);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            padding: 12px 14px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(10px);
            z-index: 10000;
            min-width: 180px;
            max-width: 280px;
            pointer-events: none;
            font-size: 13px;
        }

        /* Light mode popup */
        [data-theme="light"] .param-popup {
            background: rgba(255, 255, 255, 0.95);
            border: 1px solid rgba(0, 0, 0, 0.15);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        }

        .param-popup-header {
            margin-bottom: 10px;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        }

        [data-theme="light"] .param-popup-header {
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        }

        .param-popup-title {
            font-weight: 600;
            font-size: 14px;
            color: var(--text-primary);
            margin-bottom: 3px;
        }

        .param-popup-type {
            font-size: 11px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            opacity: 0.8;
        }

        .param-popup-content {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .param-popup-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 5px 0;
            gap: 16px;
        }

        .param-popup-label {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 500;
        }

        .param-popup-value {
            font-size: 12px;
            color: var(--text-primary);
            font-weight: 600;
            font-family: 'SF Mono', 'Roboto Mono', 'Consolas', monospace;
        }


        /* Old styles - hide */
        .info-panel:not(.info-panel-bottom) {
            display: none;
        }

        .info-panel-bottom {
            display: none;
        }

        .info-panel>* {
            background: transparent;
        }

        .info-panel.empty {
            color: var(--text-secondary);
            align-items: center;
            justify-content: center;
            font-size: 15px;
            padding: 40px;
            text-align: center;
            opacity: 0.7;
        }

        .info-panel.empty::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 80px;
            height: 80px;
            border: 2px dashed rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            pointer-events: none;
        }

        .info-panel-resizer {
            position: absolute;
            top: 0;
            right: 0;
            width: 4px;
            height: 100%;
            cursor: ew-resize;
            background: transparent;
            z-index: 101;
            transition: background 0.2s ease;
        }

        .info-panel-resizer:hover {
            background: var(--accent-color);
        }

        /* Resizing state */
        body.resizing-info-panel {
            cursor: ew-resize;
            user-select: none;
        }

        body.resizing-info-panel .info-panel-resizer {
            background: var(--accent-color);
        }

        .info-panel-header {
            padding: 20px 24px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            background: linear-gradient(135deg, rgba(79, 172, 254, 0.05) 0%, rgba(67, 233, 123, 0.05) 100%);
            position: relative;
        }

        .info-panel-icon {
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            color: var(--accent-color);
            font-size: 24px;
            margin-bottom: 12px;
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        .info-panel-title {
            flex: 1;
        }

        .info-panel-title h3 {
            margin: 0 0 4px 0;
            font-size: 18px;
            font-weight: 700;
            color: var(--text-primary);
            letter-spacing: -0.3px;
            line-height: 1.2;
        }

        .info-panel-title p {
            margin: 0;
            font-size: 12px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.8px;
            font-weight: 600;
            opacity: 0.7;
        }

        .info-panel-visual {
            margin: 16px 24px;
            padding: 16px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
        }


        .info-panel-params {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 8px;
            padding: 12px 24px 24px 24px;
        }

        .info-panel-param {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            padding: 6px 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.02);
            background: transparent;
            transition: background 0.15s ease;
        }

        .info-panel-param:hover {
            background: rgba(255, 255, 255, 0.02);
        }

        .info-panel-param-label {
            font-size: 20px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 500;
            opacity: 0.6;
            text-align: center;
            flex: 1;
        }

        .info-panel-param-value {
            font-size: 22px;
            font-weight: 500;
            color: var(--text-primary);
            font-family: 'SF Mono', 'Roboto Mono', 'Consolas', monospace;
            text-align: center;
            flex: 1;
        }

        /* Old styles - hide */
        .info-panel:not(.info-panel-bottom) {
            display: none;
        }

        .info-panel-bottom {
            display: none;
        }

        .info-panel>* {
            background: transparent;
        }

        .info-panel.empty {
            color: var(--text-secondary);
            align-items: center;
            justify-content: center;
            font-size: 15px;
            padding: 40px;
            text-align: center;
            letter-spacing: 0.3px;
        }

        .info-panel.empty::before {
            content: 'Select a Module';
            display: block;
            font-size: 18px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 8px;
            opacity: 0.7;
        }

        .info-panel-resizer {
            position: absolute;
            right: 0;
            top: 0;
            width: 1px;
            height: 100%;
            cursor: col-resize;
            background: var(--border-module);
            z-index: 10;
            transition: background 0.15s ease;
        }

        .info-panel-resizer:hover {
            background: rgba(79, 172, 254, 0.5);
            box-shadow: 0 0 8px rgba(79, 172, 254, 0.3);
        }

        body.resizing-info-panel {
            cursor: col-resize;
            user-select: none;
        }

        body.resizing-info-panel .info-panel-resizer {
            background: rgba(79, 172, 254, 0.8);
            box-shadow: 0 0 12px rgba(79, 172, 254, 0.5);
        }

        .info-panel-header {
            display: flex;
            align-items: center;
            gap: 20px;
            padding: 32px 32px 24px 32px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            flex-shrink: 0;
            background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
        }

        .info-panel-icon {
            width: 64px;
            height: 64px;
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 32px;
            flex-shrink: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
        }

        .info-panel-title {
            flex: 1;
            min-width: 0;
        }

        .info-panel-title h3 {
            font-size: 26px;
            font-weight: 800;
            margin-bottom: 6px;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            letter-spacing: -0.5px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .info-panel-title p {
            font-size: 14px;
            color: var(--text-secondary);
            text-transform: none;
            letter-spacing: 0.2px;
            font-weight: 500;
        }

        .info-panel-visual {
            margin: 20px 24px;
            padding: 20px;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.06));
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid rgba(255, 255, 255, 0.06);
            box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
        }


        .info-panel-params {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 8px;
            padding: 12px 24px 24px 24px;
        }

        .info-panel-param {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.02);
            background: transparent;
            transition: background 0.15s ease;
            gap: 4px;
        }

        .info-panel-param:hover {
            background: rgba(255, 255, 255, 0.02);
        }

        .info-panel-param-label {
            font-size: 14px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 500;
            opacity: 0.6;
            text-align: center;
        }

        .info-panel-param-value {
            font-size: 16px;
            font-weight: 500;
            color: var(--text-primary);
            font-family: 'SF Mono', 'Roboto Mono', 'Consolas', monospace;
            text-align: center;
        }

        /* Inline visualizations - minimal */
        .info-panel-visual {
            margin-top: 4px;
            padding: 4px;
            background: transparent;
            border-radius: 0;
            height: 35px;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0.7;
        }

        .info-panel-visual svg {
            max-width: 100%;
            max-height: 30px;
        }


        /* Style wavetable names nicely - show code and name (3rd Wave only) */
        body[data-synth="thirdwave"] .info-panel-param-value:contains(" - ") {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        /* For wavetable values with names, style them nicely */
        .param-value,
        .info-panel-param-value {
            white-space: pre-wrap;
            word-break: break-word;
        }

        /* When wavetable has a name (contains " - "), make it more readable */
        body[data-synth="thirdwave"] .param[data-param*="WAVETABLE"] .param-value,
        body[data-synth="thirdwave"] .info-panel-param[data-param*="WAVETABLE"] .info-panel-param-value {
            font-size: 12px;
            line-height: 1.4;
        }

        .info-panel-section {
            margin: 10px 24px 0 24px;
            padding: 16px 18px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.02);
        }

        .info-panel-section-label {
            font-size: 13px;
            color: var(--text-secondary);
            text-transform: none;
            letter-spacing: 0.2px;
            margin-bottom: 8px;
            font-weight: 700;
        }

        .info-panel-section-value {
            font-size: 14px;
            color: var(--text-primary);
            line-height: 1.7;
        }

        .section {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            justify-content: center;
            flex-wrap: wrap;
            overflow: visible;
            padding-top: 0;
        }

        /* For parallel flow sections (like oscillators), ensure horizontal alignment */
        .section[data-flow-type="parallel"] {
            flex-wrap: nowrap;
            align-items: flex-start;
        }

        .section-label {
            display: none;
            /* Hide section labels */
        }

        .flow-arrow {
            color: #ffffff;
            font-size: 22px;
            margin: 0 7px;
            opacity: 0.8;
        }

        /* Center flow arrows between sections */
        .signal-chain>.flow-arrow {
            display: block;
            text-align: center;
            width: 100%;
            margin: 2px 0;
        }

        .module {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0;
            min-width: 156px;
            cursor: pointer;
            padding-top: 0;
            /* No padding - modulators positioned absolutely above based on actual heights */
        }

        .modulation-stack {
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            z-index: 20;
            margin-bottom: 0;
            width: fit-content;
            max-width: 100%;
            pointer-events: none;
            /* Allow clicks to pass through to module card */
            /* display: grid and grid-template-columns set inline based on column count */
        }

        .module-card {
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 12px;
            padding: 4px;
            /* Reduced from 14px */
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            width: 100%;
            position: relative;
            z-index: 1;
        }

        /* Only apply hover to module card when NOT hovering over modulation indicators */
        .module:hover:not(:has(.modulation-indicator:hover)) .module-card {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
        }

        .module:hover {
            transform: translateY(-2px);
        }

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

        .module-icon {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 17px;
        }

        .module-icon svg {
            width: 100%;
            height: 100%;
        }

        .module-icon svg path {
            stroke: var(--text-primary);
        }

        .oscillator .module-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .noise .module-icon {
            background: linear-gradient(135deg, #a8a8a8 0%, #6a6a6a 100%);
        }

        .filter .module-icon {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        .vca .module-icon {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        .lfo .module-icon {
            background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
        }

        .envelope .module-icon {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        /* Unique colors for each LFO */
        #lfo1 .module-icon {
            background: #43e97b;
            /* Green */
        }

        #lfo2 .module-icon {
            background: #fa8bff;
            /* Pink */
        }

        #lfo3 .module-icon {
            background: #ffd89b;
            /* Orange */
        }

        /* Unique colors for each ENV */
        #env1 .module-icon {
            background: #4facfe;
            /* Blue */
        }

        #env2 .module-icon {
            background: #f5576c;
            /* Red */
        }

        body[data-synth="thirdwave"] #env3 .module-icon {
            background: #a8edea;
            /* Cyan */
        }

        .mult .module-icon {
            background: #ff6b6b;
        }

        .lag .module-icon {
            background: #6c5ce7;
        }

        .mixer .module-icon,
        .drive .module-icon,
        .distortion .module-icon {
            background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
        }

        .chorus .module-icon,
        .eq .module-icon,
        .delay .module-icon,
        .reverb .module-icon,
        .effect .module-icon {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        /* Unique colors for each effect */
        #chorus .module-icon {
            background: #9b59b6;
            /* Purple */
        }

        #eq .module-icon {
            background: #3498db;
            /* Blue */
        }

        #delay .module-icon {
            background: #e74c3c;
            /* Red */
        }

        #reverb .module-icon {
            background: #16a085;
            /* Teal */
        }

        .arpeggiator .module-icon,
        .sequencer .module-icon {
            background: linear-gradient(135deg, #fa8bff 0%, #2bd2ff 90%, #2bff88 100%);
        }

        .voice .module-icon {
            background: linear-gradient(135deg, #f5a623 0%, #f2994a 100%);
            border: 2px dashed rgba(245, 166, 35, 0.5);
        }

        .module-info {
            flex: 1;
            display: flex;
            align-items: center;
        }

        .module-name {
            font-size: 13px;
            font-weight: 600;
            margin: 0;
        }

        .module-type {
            display: none;
        }

        .module-params {
            display: none;
            /* Hide all parameters including labels */
        }

        .param {
            flex: 1;
        }

        .param-label {
            font-size: 10px;
            color: #666;
            margin-bottom: 2px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .param-value {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
            display: none;
            /* Hide parameter values */
        }

        .param {
            cursor: pointer;
            transition: opacity 0.2s;
        }

        .param:hover {
            opacity: 0.7;
        }

        /* Modulation stacking - CSS Grid layout */
        .modulation-row {
            display: contents;
            /* Allow cells to participate in parent grid */
        }

        .modulation-cell {
            display: flex;
            justify-content: center;
            align-items: center;
            pointer-events: none;
            /* Allow clicks to pass through cell */
            /* grid-column: span X set inline based on columnSpan */
        }

        .modulation-cell .modulation-indicator {
            pointer-events: auto;
            /* Re-enable clicks on the indicator itself */
        }

        .modulation-indicator {
            background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
            border: 2px solid rgba(67, 233, 123, 0.5);
            border-radius: 6px;
            padding: 0;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.5px;
            box-shadow: 0 2px 6px rgba(67, 233, 123, 0.2);
            animation: pulse 2s ease-in-out infinite;
            color: #0f0f1e;
            cursor: pointer;
            transition: all 0.2s;
            pointer-events: auto;
            /* Enable clicks/hovers on indicators */
            min-width: var(--min-modulator-width, 120px);
            text-align: center;
            display: inline-flex;
            flex-direction: column;
            position: relative;
            z-index: 21;
            /* Higher than modulation-stack */
            overflow: hidden;
        }

        .modulation-indicator-line {
            padding: 3px 10px;
            line-height: 1.13;
        }

        .modulation-indicator-top {
            /* First line keeps the original gradient background */
            border-radius: 4px 4px 0 0;
        }

        .modulation-indicator-bottom {
            background: var(--bg-primary);
            color: var(--text-primary);
            border-top: 1px solid rgba(67, 233, 123, 0.3);
            border-radius: 0 0 4px 4px;
        }

        [data-theme="light"] .modulation-indicator-bottom {
            background: white;
            color: black;
        }

        /* Remove drop shadows from modulation indicators in dark mode */
        :root .modulation-indicator,
        :root .modulation-indicator:hover {
            box-shadow: none !important;
        }

        .modulation-indicator:hover {
            transform: scale(1.1);
            box-shadow: 0 3px 8px rgba(67, 233, 123, 0.3);
        }

        /* Unique colors for each modulator indicator */
        .modulation-indicator.lfo1 {
            background: #FF6B6B;
            /* Coral Red */
            border: 2px solid rgba(255, 107, 107, 0.5);
            box-shadow: 0 2px 6px rgba(255, 107, 107, 0.2);
        }

        .modulation-indicator.lfo2 {
            background: #4ECDC4;
            /* Mint Teal */
            border: 2px solid rgba(78, 205, 196, 0.5);
            box-shadow: 0 2px 6px rgba(78, 205, 196, 0.2);
        }

        .modulation-indicator.lfo3 {
            background: #FFD166;
            /* Amber Yellow */
            border: 2px solid rgba(255, 209, 102, 0.6);
            box-shadow: 0 2px 6px rgba(255, 209, 102, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.lfo4 {
            background: #7C3AED;
            /* Purple */
            border: 2px solid rgba(124, 58, 237, 0.5);
            box-shadow: 0 2px 6px rgba(124, 58, 237, 0.2);
        }

        /* Oscillators as modulation sources */
        .modulation-indicator.osc1 {
            background: #06B6D4;
            /* Cyan */
            border: 2px solid rgba(6, 182, 212, 0.5);
            box-shadow: 0 2px 6px rgba(6, 182, 212, 0.2);
        }

        .modulation-indicator.osc2 {
            background: #34D399;
            /* Emerald Green */
            border: 2px solid rgba(52, 211, 153, 0.5);
            box-shadow: 0 2px 6px rgba(52, 211, 153, 0.2);
        }

        body[data-synth="thirdwave"] .modulation-indicator.osc3 {
            background: #FCD34D;
            /* Amber */
            border: 2px solid rgba(252, 211, 77, 0.5);
            box-shadow: 0 2px 6px rgba(252, 211, 77, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.filter_env {
            background: #2DD4BF;
            /* Aqua Mint */
            border: 2px solid rgba(45, 212, 191, 0.6);
            box-shadow: 0 2px 6px rgba(45, 212, 191, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.amp_env {
            background: #60A5FA;
            /* Sky Blue */
            border: 2px solid rgba(96, 165, 250, 0.5);
            box-shadow: 0 2px 6px rgba(96, 165, 250, 0.2);
        }

        .modulation-indicator.env1 {
            background: #F97316;
            /* Orange */
            border: 2px solid rgba(249, 115, 22, 0.6);
            box-shadow: 0 2px 6px rgba(249, 115, 22, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.env2 {
            background: #22C55E;
            /* Green */
            border: 2px solid rgba(34, 197, 94, 0.6);
            box-shadow: 0 2px 6px rgba(34, 197, 94, 0.2);
        }

        body[data-synth="thirdwave"] .modulation-indicator.env3 {
            background: #EC4899;
            /* Pink */
            border: 2px solid rgba(236, 72, 153, 0.6);
            box-shadow: 0 2px 6px rgba(236, 72, 153, 0.2);
        }

        body[data-synth="thirdwave"] .modulation-indicator.env4 {
            background: #A855F7;
            /* Violet */
            border: 2px solid rgba(168, 85, 247, 0.6);
            box-shadow: 0 2px 6px rgba(168, 85, 247, 0.2);
        }

        body[data-synth="thirdwave"] .modulation-indicator.wave_env1 {
            background: #F59E0B;
            /* Amber */
            border: 2px solid rgba(245, 158, 11, 0.6);
            box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
            color: #0f121a;
        }

        body[data-synth="thirdwave"] .modulation-indicator.wave_env2 {
            background: #0EA5E9;
            /* Cyan */
            border: 2px solid rgba(14, 165, 233, 0.6);
            box-shadow: 0 2px 6px rgba(14, 165, 233, 0.2);
        }

        body[data-synth="thirdwave"] .modulation-indicator.wave_env3 {
            background: #84CC16;
            /* Lime */
            border: 2px solid rgba(132, 204, 22, 0.6);
            box-shadow: 0 2px 6px rgba(132, 204, 22, 0.2);
        }

        /* Virtual modulators (control sources) */
        .modulation-indicator.note_number {
            background: #F43F5E;
            /* Rose */
            border: 2px solid rgba(244, 63, 94, 0.6);
            box-shadow: 0 2px 6px rgba(244, 63, 94, 0.2);
        }

        .modulation-indicator.pressure {
            background: #14B8A6;
            /* Teal */
            border: 2px solid rgba(20, 184, 166, 0.6);
            box-shadow: 0 2px 6px rgba(20, 184, 166, 0.2);
        }

        .modulation-indicator.velocity {
            background: #EAB308;
            /* Yellow */
            border: 2px solid rgba(234, 179, 8, 0.6);
            box-shadow: 0 2px 6px rgba(234, 179, 8, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.mod_wheel {
            background: #3B82F6;
            /* Blue */
            border: 2px solid rgba(59, 130, 246, 0.5);
            box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
        }

        .modulation-indicator.pitch_bend_wheel {
            background: #8B5CF6;
            /* Purple Accent */
            border: 2px solid rgba(139, 92, 246, 0.5);
            box-shadow: 0 2px 6px rgba(139, 92, 246, 0.2);
        }

        .modulation-indicator.expression {
            background: #10B981;
            /* Green Mint */
            border: 2px solid rgba(16, 185, 129, 0.5);
            box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
        }

        .modulation-indicator.foot_pedal {
            background: #F472B6;
            /* Pink Coral */
            border: 2px solid rgba(244, 114, 182, 0.6);
            box-shadow: 0 2px 6px rgba(244, 114, 182, 0.2);
        }

        .modulation-indicator.random {
            background: #FF8A00;
            /* Vibrant Orange */
            border: 2px solid rgba(255, 138, 0, 0.6);
            box-shadow: 0 2px 6px rgba(255, 138, 0, 0.2);
        }

        .modulation-indicator.dc {
            background: #020617;
            /* Ink */
            border: 2px solid rgba(2, 6, 23, 0.5);
            box-shadow: 0 2px 6px rgba(2, 6, 23, 0.2);
        }

        .modulation-indicator.mult1 {
            background: #FF5D8F;
            /* Bright Pink */
            border: 2px solid rgba(255, 93, 143, 0.5);
            box-shadow: 0 2px 6px rgba(255, 93, 143, 0.2);
        }

        .modulation-indicator.mult2 {
            background: #38BDF8;
            /* Bright Cyan */
            border: 2px solid rgba(56, 189, 248, 0.6);
            box-shadow: 0 2px 6px rgba(56, 189, 248, 0.2);
            color: #0f121a;
        }

        .modulation-indicator.lag {
            background: #C084FC;
            /* Soft Purple */
            border: 2px solid rgba(192, 132, 252, 0.6);
            box-shadow: 0 2px 6px rgba(192, 132, 252, 0.2);
        }

        /* Blue styling for envelope modulation indicators - keep for fallback */
        .modulation-indicator.envelope {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            border: 2px solid rgba(79, 172, 254, 0.5);
            box-shadow: 0 2px 6px rgba(79, 172, 254, 0.2);
        }

        @keyframes pulse {

            0%,
            100% {
                box-shadow: 0 2px 6px rgba(67, 233, 123, 0.2);
            }

            50% {
                box-shadow: 0 3px 10px rgba(67, 233, 123, 0.35);
            }
        }

        /* Light mode: change modulation indicator shadows to light grey */
        [data-theme="light"] .modulation-indicator {
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        }

        [data-theme="light"] .modulation-indicator:hover {
            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
        }

        [data-theme="light"] .modulation-indicator.lfo1,
        [data-theme="light"] .modulation-indicator.lfo2,
        [data-theme="light"] .modulation-indicator.lfo3,
        [data-theme="light"] .modulation-indicator.env1,
        [data-theme="light"] .modulation-indicator.env2,
        [data-theme="light"] .modulation-indicator.mult1,
        [data-theme="light"] .modulation-indicator.mult2,
        [data-theme="light"] .modulation-indicator.lag,
        [data-theme="light"] .modulation-indicator.envelope {
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        }

        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.env3,
        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.env4,
        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.osc3,
        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.wave_env1,
        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.wave_env2,
        body[data-synth="thirdwave"] [data-theme="light"] .modulation-indicator.wave_env3 {
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        }

        /* Override pulse animation for light mode */
        [data-theme="light"] .modulation-indicator {
            animation: pulse-light 2s ease-in-out infinite;
        }

        @keyframes pulse-light {

            0%,
            100% {
                box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
            }

            50% {
                box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
            }
        }

        .modulator-module {
            background: rgba(67, 233, 123, 0.05);
            border-color: rgba(67, 233, 123, 0.3);
            transition: margin-left 0.3s ease, transform 0.2s ease;
        }

        .modulator-module:hover {
            background: rgba(67, 233, 123, 0.1);
            border-color: rgba(67, 233, 123, 0.5);
        }

        .modulator-module.stacked-modulator {
            border-left: 3px solid rgba(67, 233, 123, 0.4);
            position: relative;
        }

        .modulator-module.stacked-modulator::before {
            content: '';
            position: absolute;
            left: -20px;
            top: 50%;
            width: 17px;
            height: 2px;
            background: rgba(67, 233, 123, 0.4);
        }

        .modulator-module.stacked-modulator:hover {
            transform: translateX(-5px);
            border-left-color: rgba(67, 233, 123, 0.8);
        }

        .modulator-module.envelope {
            background: rgba(79, 172, 254, 0.05);
            border-color: rgba(79, 172, 254, 0.3);
        }

        .modulator-module.envelope:hover {
            background: rgba(79, 172, 254, 0.1);
            border-color: rgba(79, 172, 254, 0.5);
        }

        /* Unique colors for each modulator in sidebar */
        #lfo1.modulator-module {
            background: rgba(67, 233, 123, 0.05);
            border-color: rgba(67, 233, 123, 0.3);
        }

        #lfo1.modulator-module:hover {
            background: rgba(67, 233, 123, 0.1);
            border-color: rgba(67, 233, 123, 0.5);
        }

        #lfo2.modulator-module {
            background: rgba(250, 139, 255, 0.05);
            border-color: rgba(250, 139, 255, 0.3);
        }

        #lfo2.modulator-module:hover {
            background: rgba(250, 139, 255, 0.1);
            border-color: rgba(250, 139, 255, 0.5);
        }

        #lfo3.modulator-module {
            background: rgba(255, 216, 155, 0.05);
            border-color: rgba(255, 216, 155, 0.3);
        }

        #lfo3.modulator-module:hover {
            background: rgba(255, 216, 155, 0.1);
            border-color: rgba(255, 216, 155, 0.5);
        }

        #env1.modulator-module {
            background: rgba(79, 172, 254, 0.05);
            border-color: rgba(79, 172, 254, 0.3);
        }

        #env1.modulator-module:hover {
            background: rgba(79, 172, 254, 0.1);
            border-color: rgba(79, 172, 254, 0.5);
        }

        #env2.modulator-module {
            background: rgba(245, 87, 108, 0.05);
            border-color: rgba(245, 87, 108, 0.3);
        }

        #env2.modulator-module:hover {
            background: rgba(245, 87, 108, 0.1);
            border-color: rgba(245, 87, 108, 0.5);
        }

        body[data-synth="thirdwave"] #env3.modulator-module {
            background: rgba(168, 237, 234, 0.05);
            border-color: rgba(168, 237, 234, 0.3);
        }

        body[data-synth="thirdwave"] #env3.modulator-module:hover {
            background: rgba(168, 237, 234, 0.1);
            border-color: rgba(168, 237, 234, 0.5);
        }

        /* Unique colors for Mult operators */
        #mult1 .module-icon {
            background: #ff6b6b;
            /* Coral Red */
        }

        #mult2 .module-icon {
            background: #ffa500;
            /* Orange */
        }

        #mult1.modulator-module {
            background: rgba(255, 107, 107, 0.05);
            border-color: rgba(255, 107, 107, 0.3);
        }

        #mult1.modulator-module:hover {
            background: rgba(255, 107, 107, 0.1);
            border-color: rgba(255, 107, 107, 0.5);
        }

        #mult2.modulator-module {
            background: rgba(255, 165, 0, 0.05);
            border-color: rgba(255, 165, 0, 0.3);
        }

        #mult2.modulator-module:hover {
            background: rgba(255, 165, 0, 0.1);
            border-color: rgba(255, 165, 0, 0.5);
        }

        /* Unique colors for Lag operator */
        #lag .module-icon {
            background: #6c5ce7;
            /* Purple */
        }

        #lag.modulator-module {
            background: rgba(108, 92, 231, 0.05);
            border-color: rgba(108, 92, 231, 0.3);
        }

        #lag.modulator-module:hover {
            background: rgba(108, 92, 231, 0.1);
            border-color: rgba(108, 92, 231, 0.5);
        }

        .modulation-targets {
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid rgba(67, 233, 123, 0.2);
        }

        /* Settings Modal */
        .settings-modal {
            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: 1000;
            backdrop-filter: blur(4px);
        }

        .settings-modal-content {
            background: var(--bg-secondary);
            border: 1px solid var(--border-module);
            border-radius: 12px;
            max-width: 600px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }

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

        .settings-modal-header h2 {
            margin: 0;
            font-size: 20px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .settings-close-btn {
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 28px;
            cursor: pointer;
            padding: 0;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            transition: all 0.2s ease;
        }

        .settings-close-btn:hover {
            background: var(--bg-module-hover);
            color: var(--text-primary);
        }

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

        .settings-backend-section {
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border-module);
        }

        .settings-backend-info {
            font-size: 12px;
            color: var(--text-tertiary);
            margin-top: 8px;
            font-style: italic;
        }

        .settings-backend-select {
            width: 100%;
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 6px;
            padding: 10px 12px;
            font-size: 14px;
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .settings-backend-select:hover {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
        }

        .settings-backend-select:focus {
            outline: none;
            border-color: var(--border-module-hover);
            background: var(--bg-module-hover);
        }

        .settings-backend-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        .settings-synth-section {
            margin-bottom: 30px;
        }

        .settings-synth-section:last-child {
            margin-bottom: 0;
        }

        .settings-synth-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 15px;
            padding-bottom: 8px;
            border-bottom: 1px solid var(--border-module);
        }

        .settings-device-group {
            margin-bottom: 20px;
        }

        .settings-device-group:last-child {
            margin-bottom: 0;
        }

        .settings-device-label {
            display: block;
            font-size: 14px;
            color: var(--text-secondary);
            margin-bottom: 8px;
            font-weight: 500;
        }

        .settings-device-select {
            width: 100%;
            background: var(--bg-module);
            border: 1px solid var(--border-module);
            border-radius: 6px;
            padding: 10px 12px;
            color: var(--text-primary);
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-family: inherit;
        }

        .settings-device-select:hover {
            background: var(--bg-module-hover);
            border-color: var(--border-module-hover);
        }

        .settings-device-select:focus {
            outline: none;
            border-color: var(--border-module-hover);
            background: var(--bg-module-hover);
        }

        .settings-device-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        .targets-label {
            font-size: 10px;
            color: #888;
            margin-bottom: 4px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .target-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
        }

        .target-chip {
            background: rgba(67, 233, 123, 0.1);
            border: 1px solid rgba(67, 233, 123, 0.3);
            border-radius: 4px;
            padding: 2px 6px;
            font-size: 11px;
            color: #43e97b;
        }

        /* Responsive */
        @media (max-width: 900px) {
            .patch-view {
                flex-direction: column;
            }

            .modulators-section {
                flex: 1;
                width: 100%;
            }

            .info-panel {
                width: 100%;
                position: relative;
                top: 0;
            }
        }

        /* Info Panel Layout Updates */
        .info-panel {
            display: flex;
            flex-direction: column;
            /* Ensure it takes full height */
            overflow: hidden;
            /* Hide overflow on the panel itself */
        }

        /* Ensure header stays at top */
        .info-panel-header {
            flex-shrink: 0;
            /* Existing styles are fine, but ensure it doesn't shrink */
            padding-top: 32px;
            /* Restore padding if needed, was in existing css */
        }

        /* Module info section takes remaining space and scrolls */
        .info-panel-module {
            flex: 1;
            overflow-y: auto;
            position: relative;
            display: flex;
            flex-direction: column;
        }

        .info-panel-module.empty {
            /* Center "Hover over..." message */
            justify-content: center;
            align-items: center;
            color: var(--text-secondary);
            font-size: 15px;
            padding: 20px;
            text-align: center;
        }

        /* Ensure visual and params go into the module section */
        .info-panel-visual,
        .info-panel-params {
            /* No special changes needed if they are children of info-panel-module */
        }

        /* Adjust resizer z-index if needed */
        .info-panel-resizer {
            z-index: 100;
        }

        /* AI Analysis Modal */
        .ai-modal {
            display: none;
            position: fixed;
            z-index: 2000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(5px);
            -webkit-backdrop-filter: blur(5px);
        }

        .ai-modal-content {
            background-color: var(--bg-secondary);
            margin: 5% auto;
            padding: 0;
            border: 1px solid var(--border-module);
            border-radius: 12px;
            width: 80%;
            max-width: 800px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            max-height: 85vh;
        }

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

        .ai-modal-header h2 {
            margin: 0;
            color: var(--text-primary);
            font-size: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .ai-modal-close {
            color: var(--text-secondary);
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            line-height: 1;
        }

        .ai-modal-close:hover {
            color: var(--text-primary);
        }

        .ai-modal-body {
            padding: 24px;
            overflow-y: auto;
            color: var(--text-primary);
            font-size: 15px;
            line-height: 1.6;
        }

        .ai-loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 60px 40px;
            gap: 20px;
            color: var(--text-secondary);
        }

        .ai-spinner {
            width: 40px;
            height: 40px;
            border: 3px solid var(--bg-module-hover);
            border-top: 3px solid #4facfe;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

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

            100% {
                transform: rotate(360deg);
            }
        }

        /* Markdown Styles inside Modal */
        .ai-modal-body h3 {
            margin-top: 1.5em;
            margin-bottom: 0.8em;
            color: #4facfe;
            font-size: 1.1em;
        }

        .ai-modal-body h3:first-child {
            margin-top: 0;
        }

        .ai-modal-body p {
            margin-bottom: 1em;
        }

        .ai-modal-body ul {
            margin-bottom: 1em;
            padding-left: 20px;
            list-style-type: disc;
        }

        .ai-modal-body li {
            margin-bottom: 0.5em;
            color: var(--text-tertiary);
        }

        .ai-modal-body strong {
            color: var(--text-primary);
            font-weight: 600;
        }

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

            100% {
                transform: rotate(360deg);
            }
        }