/* --- Modal & Popover Base --- */
.piano-overlay,
.add-track-popover-overlay,
.file-manager-overlay,
#drumSynthOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    z-index: 3000 !important;
    /* Ensure it is on top of add-track overlay (z-index 2000) */
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.piano-overlay,
.add-track-popover-overlay,
.file-manager-overlay,
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    font-family: 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.empty-msg {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 12px;
}

.file-manager-popover,
.add-track-modal,
.settings-popover,
.drumsynth-modal {
    background: linear-gradient(180deg, #1f1f1f 0%, #151515 100%);
    /* Textured dark plastic */
    border: 2px solid #3a3a3a;
    border-right-color: #111;
    border-bottom-color: #111;
    border-radius: 8px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Shared Modal Header --- */
.modal-header,
.file-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #333;
    border-bottom: 1px solid #444;
    width: 100%;
    box-sizing: border-box;
}

.modal-title,
.file-manager-header h3 {
    margin: 0;
    color: #ddd;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* --- Section Headers --- */
.section-header,
.add-track-section-header {
    background: #1a1a1a;
    padding: 12px 15px;
    font-size: 11px;
    font-weight: bold;
    color: #888;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    pointer-events: none;
    /* Ensure it's not clickable */
}

/* --- Buttons --- */
.close-btn,
.file-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:active,
.file-close-btn:active {
    color: #fff;
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background: #ffcc00;
    border: none;
    border-radius: 4px;
    color: #000;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.apply-btn:active {
    background: #ffdb4d;
    box-shadow: 0 4px 15px rgba(255, 204, 0, 0.3);
}

/* --- File Manager Specific --- */
.file-manager-popover {
    width: 90%;
    max-width: 600px;
}

.file-manager-header {
    background: #333;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #444;
    position: relative;
    gap: 10px;
}

.file-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-manager-header .modal-title {
    margin: 0;
    color: #ddd;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
}

.file-action-btn {
    background: linear-gradient(to bottom, #444, #333);
    border: 1px solid #222;
    color: #ddd;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
}

.file-action-btn:active {
    background: #222;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
    transform: translateY(1px);
}

.file-action-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.file-close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    box-shadow: none;
    position: absolute;
    top: 5px;
    right: 5px;
}

.file-close-btn:active {
    color: #fff;
    background: transparent;
}

.file-list-container {
    background: #2a2a2a;
    border-top: 1px solid #000;
    padding: 0;
}

.file-list {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
}

.file-item {
    padding: 8px 15px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s;
    height: 40px;
}

.file-item:active {
    background: #333;
}

.file-item.active {
    background: rgba(255, 204, 0, 0.05);
    border-left: 4px solid #ffcc00;
}

.file-info {
    display: flex;
    flex-direction: column;
}

.file-name {
    color: #eee;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.2;
}

.file-date {
    color: #888;
    font-size: 10px;
    margin-top: 2px;
}

.file-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.file-action-icon-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-action-icon-btn:active {
    background: #444;
    color: #fff;
}

.empty-file-list {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* --- Drum Track Management (Add Track Modal) --- */
.add-track-modal {
    width: 380px;
    max-width: 95vw;
}

.add-track-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #444;
}

.add-track-section-header {
    grid-column: 1 / span 2;
}

.add-track-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    width: 100%;
}

.add-track-item {
    background: #222;
    padding: 12px 10px 12px 10px;
    /* Reduced left padding */
    display: flex;
    align-items: center;
    gap: 0.2em;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    width: 100%;
}

.add-track-item:active:not(.locked) {
    background: #2a2a2a;
}

.add-track-item.active {
    background: rgba(255, 204, 0, 0.05);
    color: #ffcc00;
}

.add-track-item.locked {
    opacity: 0.5;
    cursor: default;
}

.track-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.add-track-item.active .track-icon {
    color: #ffcc00;
}

.track-label {
    flex: 1;
    font-size: 13px;
    font-weight: bold;
    color: #ddd;
}

.add-track-item.active .track-label {
    color: #ffcc00;
}

.track-check {
    font-size: 16px;
    color: #444;
}

.add-track-item.active .track-check {
    color: #ffcc00;
}

/* Edit button (cog) on the right side of each synth track row */
.track-edit-btn-side {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: #888;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    /* Gap from the label */
    transition: color 0.15s, border-color 0.15s;
}

.track-edit-btn-side:active {
    color: #ffcc00;
    border-color: #ffcc00;
}

.track-edit-btn-side svg {
    width: 14px;
    height: 14px;
}

.modal-footer {
    padding: 15px;
    background: #2a2a2a;
    border-top: 1px solid #444;
}

/* --- Settings Specific --- */
.settings-popover {
    width: 600px;
    max-width: 95vw;
    height: 500px;
}

.settings-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.settings-sidebar {
    width: 140px;
    background: #2a2a2a;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
}

.settings-tab-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 15px;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: all 0.2s;
    font-weight: bold;
    font-size: 12px;
}

.settings-tab-btn:active {
    background: #333;
    color: #ddd;
}

.settings-tab-btn.active {
    background: #333;
    color: #ffcc00;
    border-left: 3px solid #ffcc00;
}

.file-manager-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    /* Explicitly allow vertical panning in touch emulators (Chrome DevTools fix) */
    overscroll-behavior-y: contain;
    color: #ddd;
}

.settings-content {
    flex: 1;
    background: #1a1a1a;
    padding: 20px;
    overflow-y: auto;
    color: #ddd;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.tab-header h4 {
    margin: 0;
    color: #ddd;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-actions {
    display: flex;
    gap: 5px;
}

/* Settings Options */
.settings-option {
    margin-bottom: 20px;
}

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #ddd;
    font-size: 14px;
}

.settings-checkbox input[type="checkbox"] {
    display: none;
}

.settings-checkbox .checkmark {
    width: 20px;
    height: 20px;
    background: #333;
    border: 2px solid #555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.settings-checkbox input[type="checkbox"]:checked+.checkmark {
    background: #d85c2e;
    border-color: #ff7744;
}

.settings-checkbox input[type="checkbox"]:checked+.checkmark::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

.settings-checkbox:active .checkmark {
    border-color: #888;
}

.settings-checkbox .label-text {
    flex: 1;
}

.settings-help {
    margin: 8px 0 0 32px;
    color: #888;
    font-size: 12px;
    line-height: 1.4;
}

/* MIDI Mapping List */
.midi-mapping-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    color: #ddd;
    font-size: 12px;
}

.midi-mapping-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.midi-mapping-target {
    font-weight: bold;
    color: #fff;
}

.midi-mapping-source {
    color: #aaa;
    font-family: monospace;
}

.midi-delete-btn {
    background: transparent;
    border: none;
    color: #ff4444;
    cursor: pointer;
    padding: 5px;
}

.midi-delete-btn:active {
    color: #ff0000;
}

/* MIDI Device List */
.midi-device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    color: #ddd;
}

.midi-device-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.midi-device-name {
    font-weight: bold;
    color: #fff;
    font-size: 13px;
}

.midi-device-meta {
    color: #888;
    font-size: 11px;
}

.midi-device-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #444;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.midi-device-status.connected {
    background: #00ff00;
    box-shadow: 0 0 8px #00ff00;
}

.midi-device-status.disconnected {
    background: #ff3333;
}

.midi-empty-state {
    text-align: center;
    color: #666;
    font-style: italic;
}

.midi-empty-devices {
    padding: 15px;
}

.midi-empty-mappings {
    padding: 20px;
}

.midi-learn-toggle {
    width: 100%;
    margin-bottom: 15px;
    justify-content: center;
}

.midi-learn-toggle.learning {
    background: #ff3333;
}

/* --- Piano Editor Specific --- */
.step-nav button {
    background: linear-gradient(to bottom, #444, #333);
    border: 1px solid #222;
    color: #ddd;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    font-family: 'Arial Narrow', sans-serif;
}

.step-indicator {
    font-family: 'DSEG7Classic', monospace;
    color: #ff3333;
    font-size: 20px;
    background: #000;
    padding: 6px 10px;
    border-radius: 2px;
    border: 1px solid #555;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8);
    min-width: 44px;
    text-align: center;
}

.toggle-btn {
    flex: 1;
    padding: 12px;
    background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
    border: 1px solid #111;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.1s;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    font-size: 12px;
}

.toggle-btn.active {
    color: #fff;
    border-color: #ffcc00;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

/* --- Audio Resume Overlay --- */
.audio-resume-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.audio-resume-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #ffcc00 0%, #d85c2e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 40px rgba(255, 204, 0, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.audio-resume-text {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 30px;
}

/* --- Toast --- */
#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #222;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 2500;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    border: 1px solid #444;
}

#toast.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein {
    from {
        bottom: 0;
        opacity: 0;
    }

    to {
        bottom: 30px;
        opacity: 1;
    }
}

@keyframes fadeout {
    from {
        bottom: 30px;
        opacity: 1;
    }

    to {
        bottom: 0;
        opacity: 0;
    }
}

/* --- MIDI Learn Mode Banner --- */
.learn-mode-exit-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b35 0%, #d85c2e 100%);
    color: white;
    padding: 12px 20px;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.learn-mode-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.learn-mode-banner-text {
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 1px;
}

.exit-learn-mode-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.2s;
}

.exit-learn-mode-btn:active {
    background: rgba(0, 0, 0, 0.5);
}

/* MIDI Learn Mode Highlights */
body.midi-learn-active [data-midi-mappable] {
    outline: 2px dashed #00ff00;
    cursor: crosshair !important;
    position: relative;
    z-index: 50;
}

body.midi-learn-active .midi-mapped {
    outline: 2px solid #00aaff !important;
    cursor: crosshair !important;
    position: relative;
    z-index: 50;
}

body.midi-learn-active .midi-mapped::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #00aaff;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 51;
    box-shadow: 0 0 4px rgba(0, 170, 255, 0.8);
}

.midi-learning {
    outline: 2px solid #ff0000 !important;
    box-shadow: 0 0 15px #ff0000 !important;
    animation: midi-blink 0.5s infinite alternate;
}

@keyframes midi-blink {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.5;
    }
}

/* --- Audio Resume Overlay --- */
.audio-resume-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.audio-resume-subtext {
    font-size: 14px;
    color: #888;
    text-align: center;
}

/* --- Responsive Overlays --- */
@media (max-width: 600px) {

    .file-manager-popover,
    .add-track-modal,
    .settings-popover {
        width: 95%;
    }

    .settings-sidebar {
        width: 100px;
    }
}

/* --- DrumSynth Editor Overlay --- */
#drumSynthOverlay {
    z-index: 10000 !important;
}

@media (max-width: 600px) {
    #drumSynthOverlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .drumsynth-modal {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border: none;
        border-radius: 0;
    }

    .drumsynth-body {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}



.drumsynth-body {
    flex: 1;
    overflow-y: auto;
    background: #222;
    display: flex;
    flex-direction: column;
}



/* --- DrumSynth Refined Design (Channel Strip Style) --- */

.drumsynth-modal {
    width: 600px;
    max-width: 95vw;
    height: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Module Container - Horizontal Strip */
.ds-module {
    background: #2a2a2a;
    border: 1px solid #1a1a1a;
    border-radius: 4px;
    padding: 0;
    margin: 4px;
    /* Tighter margin */
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.ds-module .module-header {
    padding: 4px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #222, #1a1a1a);
    border-bottom: 1px solid #111;
    border-radius: 4px 4px 0 0;
}

.ds-module .module-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #888;
}

/* Color Coding for Modules (References) */
#ds-osc1 .module-title {
    color: #ff77a8;
}

#ds-osc2 .module-title {
    color: #29adff;
}

#ds-osc3 .module-title {
    color: #ffcc00;
}

#ds-osc4 .module-title {
    color: #00e756;
}

#ds-click .module-title {
    color: #bd93f9;
}

#ds-snap .module-title {
    color: #8be9fd;
}

#ds-noise .module-title {
    color: #ff5555;
}

#ds-noise2 .module-title {
    color: #ff9966;
}


.ds-module .module-controls {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping for tighter dense packing */
    padding: 10px;
    gap: 8px;
    /* Tighter gap */
    align-items: center;
}

.ds-module .ds-select {
    background: #1a1a1a;
    color: #eee;
    border: 1px solid #000;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 10px;
    height: 22px;
}

.ds-module .knob-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    /* Tighter knob spacing */
}

/* Knob Styling Overrides for Dark Theme */
.drumsynth-modal .knob-wrapper .knob-label {
    color: #999 !important;
    font-size: 9px;
    margin-bottom: 4px;
}

.drumsynth-modal .knob-wrapper {
    width: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Unify with 303 base knob style */
.drumsynth-modal .rotary-knob {
    width: 28px;
    height: 28px;
    background: var(--knob-body);
    /* Inherit from base.css */
    border: 1px solid #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    /* Subtle, centered drop shadow */
    border-radius: 50%;
    position: relative;
    margin: 0;
}

/* User's requested realistic highlight reflection */
.drumsynth-modal .rotary-knob::after {
    content: '';
    position: absolute;
    top: 0;
    left: 55%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 50%);
    pointer-events: none;
    z-index: 10;
}

/* The actual indicator line now uses a ::before pseudo element or is handled by RotaryKnob JS */
.drumsynth-modal .rotary-knob::before {
    content: '';
    position: absolute;
    background: var(--knob-indicator);
    width: 2px;
    height: 8px;
    top: 3px;
    left: calc(50% - 1px);
    border-radius: 1px;
}

/* Header Layout */
.drumsynth-modal .header-left,
.drumsynth-modal .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Header Action Buttons (Load/Save/Reset) */
.header-action-btn {
    background: linear-gradient(to bottom, #eee, #ccc);
    color: #111;
    border: 1px solid #999;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}

.header-action-btn:active {
    background: #bbb;
    transform: translateY(1px);
}

.header-action-btn.icon-only {
    padding: 0;
    width: 30px;
}

.header-action-btn .icon {
    width: 14px;
    height: 14px;
    background-color: #111;
    /* Mask color for SVG icons */
}

/* Footer redesign */
.ds-footer {
    background: #333;
    border-top: 1px solid #444;
    padding: 10px 15px;
    display: flex;
    flex-wrap: wrap;
    /* Allows stacking if viewport is too narrow */
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    /* Explicitly allow tooltips to overflow upwards */
    overflow: visible !important;
    flex-shrink: 0;
    /* Ensures the footer height is preserved and not squished by central content */
}

.ds-footer-left {
    display: flex;
    flex-direction: column;
    /* Fallback */
    gap: 10px;
    width: 100%;
    overflow: visible;
}

.ds-footer-flex-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.ds-live-knobs-clean {
    margin-top: 0;
    border: none;
    background: none;
    padding: 0;
    flex: 1;
    /* Allow it to take up available space instead of overflowing */
    min-width: 0;
    /* Important for flex items to shrink below their content size if needed */
    overflow: visible;
}

.ds-preview-controls-clean {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    /* Prevent the button from squishing */
}

.ds-play-label {
    font-size: 8px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

/* Radio Group (Waveform) - List Style */
.ds-radio-group {
    display: grid;
    grid-template-columns: min-content auto;
    width: 2.2em;
    /* Lock radio group width to match spacer */
    gap: 2px 4px;
    margin-right: 12px;
    background: transparent;
    border: none;
    height: auto;
}

.ds-radio-group input {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0;
    appearance: none;
    background: #222;
    border: 1px solid #555;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
}

.ds-radio-group input:checked {
    border-color: #ffcc00;
}

.ds-radio-group input:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    background: #ffcc00;
    border-radius: 50%;
}

.ds-radio-group label {
    font-size: 9px;
    color: #888;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: normal;
    padding: 0;
    min-width: 0;
    /* Alignment */
    display: flex;
    align-items: center;
}

.ds-radio-group label:last-child {
    border: none;
}

.ds-radio-group input:checked+label {
    background: transparent;
    color: #ffcc00;
    font-weight: bold;
}

#ds-live-knobs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 15px;
    background: #222;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #333;
    width: 100%;
    box-sizing: border-box;
    scrollbar-width: none;
}

#ds-live-knobs::-webkit-scrollbar {
    display: none;
}

.current-voice-label {
    display: none;
    /* Redundant with header or selected track highlight */
}

.apply-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Arcade/Joystick Push Button Style for Preview */
.preview-btn.arcade-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ff5555, #cc0000);
    border: none;
    box-shadow:
        0 6px 0 #8b0000,
        0 8px 6px rgba(0, 0, 0, 0.6),
        inset 0 2px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    outline: none;
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

/* Base ring/bezel beneath the button */
.preview-btn.arcade-button::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -8px;
    /* Extend for 3D depth */
    border-radius: 50%;
    background: linear-gradient(to bottom, #444, #111);
    z-index: -1;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.8);
    border: 1px solid #000;
}

.preview-btn.arcade-button:active {
    margin-top: 6px;
    box-shadow:
        0 3px 0 #8b0000,
        0 8px 6px rgba(0, 0, 0, 0.6),
        inset 0 2px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* DS Switch (Waveform Style) */
.ds-switch {
    width: 60px;
    height: 18px;
    background: #111;
    border: 1px solid #444;
    border-radius: 2px;
    display: flex;
    position: relative;
    margin-right: 5px;
}

.ds-switch input {
    display: none;
}

.ds-switch label {
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 900;
    color: #555;
    z-index: 2;
    cursor: pointer;
    transition: color 0.1s;
}

.ds-switch .switch-handle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(50% - 2px);
    height: calc(100% - 4px);
    background: #888;
    border-radius: 1px;
    transition: transform 0.15s ease, background-color 0.15s;
    z-index: 1;
}

/* ON State (value="true") moves handle to right */
.ds-switch input[value="true"]:checked~.switch-handle {
    transform: translateX(100%);
    background: #ffcc00;
}

/* Active Label Color */
.ds-switch input:checked+label {
    color: #111;
}

/* Hide rows wrapper styling to let modules stack */
.ds-section-row {
    display: contents;
}
