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

:root {
    --c-bg: #2b2b2b;
    --c-bg-header: #252525;
    --c-bg-panel: #303030;
    --c-bg-module: #383838;
    --c-bg-inset: #1a1a1a;
    --c-border: #444444;
    --c-border-dark: #1e1e1e;
    --c-text: #e0e0e0;
    --c-text-dim: #999999;
    --c-text-muted: #666666;
    --c-title: #f0f0f0;
    --c-label: #aaaaaa;
    --c-signal: #3dff3d;
    --c-master: #d4a017;
    --c-btn: #404040;
    --c-btn-hover: #505050;
    --c-strip-w: 110px;
    --c-thumb-h: 26px;
    --eq-accent: #00c8ff;
    --eq-accent-glow: rgba(0, 200, 255, 0.55);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: system-ui, -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: var(--c-bg-header);
    border-bottom: 1px solid var(--c-border-dark);
    flex-shrink: 0;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-title);
    letter-spacing: 0.5px;
}

#controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

#bank_count {
    font-size: 11px;
    color: var(--c-text-dim);
}

/* ---- Performance Monitor ---- */
#perf_monitor {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 12px;
    background: var(--c-bg-inset);
    border: 1px solid var(--c-border);
    border-radius: 6px;
}

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

.perf-label {
    font-size: 8px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perf-value {
    font-size: 11px;
    color: var(--c-label);
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.perf-bar {
    width: 60px;
    height: 5px;
    background: var(--c-bg-inset);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--c-border);
}

.perf-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.3s;
    background-position: 0% 0%;
}

#midi_status {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

#midi_status.midi-on {
    color: var(--c-signal);
    background: rgba(61, 255, 61, 0.1);
}

#midi_status.midi-off {
    color: var(--c-text-dim);
    background: rgba(136, 136, 136, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--c-btn);
    color: var(--c-text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--c-border);
    transition: background .15s;
}

.btn:hover {
    background: var(--c-btn-hover);
}

.btn input {
    display: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#middle_section {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
}

#card_panel {
    width: 30%;
    display: flex;
    flex-direction: column;
    background: var(--c-bg-panel);
    border-right: 1px solid var(--c-border-dark);
    overflow: hidden;
    flex-shrink: 0;
}

.card-tabs {
    display: flex;
    border-bottom: 1px solid var(--c-border-dark);
    flex-shrink: 0;
}

.card-tab {
    flex: 1;
    padding: 6px 4px;
    background: var(--c-bg);
    border: none;
    color: var(--c-text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.card-tab:hover {
    color: var(--c-text);
    background: var(--c-bg-panel);
}

.card-tab.active {
    color: var(--c-accent);
    border-bottom-color: var(--c-accent);
    background: var(--c-bg-panel);
}

.card-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.card-content.active {
    display: flex;
    flex-direction: column;
}

#fader_strip {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 70%;
    padding: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border-dark);
    border-right: 1px solid var(--c-border-dark);
    overflow-x: auto;
    min-width: 0;
}

#synth_section {
    flex-direction: column;
    padding: 12px 12px 8px;
    overflow-y: auto;
}

/* ---- SYNTH TABS ---- */
.synth-tabs-nav {
    display: flex;
    gap: 3px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--c-border);
    padding-bottom: 0;
}

.synth-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--c-text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 5px 12px;
    cursor: pointer;
    transition: color 0.18s, border-color 0.18s, background 0.18s;
    border-radius: 4px 4px 0 0;
}

.synth-tab-btn:hover {
    color: var(--c-text-dim);
    background: rgba(255,255,255,0.04);
}

.synth-tab-btn.active {
    color: var(--c-title);
    border-bottom-color: var(--c-title);
    background: rgba(255, 255, 255, 0.05);
}

.synth-tab-panel {
    display: none;
    animation: tabFadeIn 0.18s ease;
}

.synth-tab-panel.active {
    display: block;
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.synth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--c-border);
}

.synth-header h2 {
    font-size: 13px;
    color: var(--c-title);
    font-weight: 800;
    letter-spacing: 2px;
}

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

.synth-vu-container {
    width: 8px;
    height: 40px;
    background: var(--c-bg-inset);
    border-radius: 4px;
    border: 1px solid var(--c-border);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.synth-vu-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #2ecc71, #f1c40f 70%, #e74c3c);
    border-radius: 3px;
    transition: height 0.05s;
}

.synth-vol-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.synth-track-label {
    font-size: 8px;
    color: var(--c-text-muted);
    text-transform: uppercase;
}

.synth-mute-btn {
    background: var(--c-bg-inset);
    border: 1px solid var(--c-border);
    color: var(--c-text-dim);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
}

.synth-mute-btn.active {
    background: #555;
    color: var(--c-title);
    border-color: #666;
}

.synth-power-btn {
    background: var(--c-btn);
    border: 1px solid var(--c-border);
    color: var(--c-text-dim);
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

/* ---- Help Tooltip ---- */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--c-btn);
    color: var(--c-text-muted);
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    position: relative;
    margin-left: 4px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    border: 1px solid #333;
}
.help-icon:hover {
    background: var(--c-btn-hover);
    color: var(--c-text-dim);
}
.help-icon:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: #ddd;
    font-size: 10px;
    padding: 5px 9px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    border: 1px solid #333;
    pointer-events: none;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
}

/* ---- Preset Selector ---- */
.synth-preset-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    width: 100%;
}
.synth-preset-select {
    flex: 1;
    background: var(--c-bg-inset);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: 3px;
    font-size: 10px;
    padding: 3px 4px;
    outline: none;
    cursor: pointer;
}
.synth-preset-btn {
    background: var(--c-btn);
    border: 1px solid var(--c-border);
    color: var(--c-text-dim);
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    letter-spacing: 0.5px;
}
.synth-preset-btn:hover {
    background: var(--c-btn-hover);
    color: var(--c-title);
}
.synth-preset-btn.save {
    color: #2ecc71;
    border-color: #2ecc71;
}
.synth-preset-btn.save:hover {
    background: rgba(46, 204, 113, 0.15);
}
.synth-preset-btn.del {
    color: #e74c3c;
    border-color: #e74c3c;
}
.synth-preset-btn.del:hover {
    background: rgba(231, 76, 60, 0.15);
}

.synth-power-btn.active {
    background: #27ae60;
    color: #fff;
    border-color: #1e8449;
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.4);
}

.synth-modules {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.synth-module {
    background: var(--c-bg-module);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 120px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.25);
}

.envelope-module {
    min-width: 220px;
}

.synth-module-title {
    font-size: 10px;
    color: var(--c-label);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 4px;
}

.osc-toggle {
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--c-border);
    background: var(--c-bg-inset);
    color: var(--c-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: bold;
}

.osc-toggle.active {
    background: #27ae60;
    color: #fff;
    border-color: #1e8449;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.4);
}

.osc-toggle.inactive {
    background: transparent;
    color: #555;
    border-color: #333;
}

.synth-knob-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.synth-knob-group label {
    font-size: 9px;
    color: #aaa;
}

.synth-select {
    background: var(--c-bg-inset);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: 3px;
    font-size: 10px;
    padding: 2px 4px;
    outline: none;
}

.env-knobs {
    display: flex;
    gap: 16px;
    width: 100%;
    justify-content: center;
}

.synth-knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.synth-knob {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #555, #333);
    border: 2px solid var(--c-border);
    position: relative;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.05);
    touch-action: none;
    user-select: none;
}

.synth-knob::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 10px;
    background: var(--c-signal);
    border-radius: 1px;
}

.synth-knob-orange { border-color: #e67e22; }
.synth-knob-orange::after { background: #e67e22; }

.synth-knob-cyan { border-color: #1abc9c; }
.synth-knob-cyan::after { background: #1abc9c; }

.synth-knob-purple { border-color: #9b59b6; }
.synth-knob-purple::after { background: #9b59b6; }

.synth-knob.midi-mapped { box-shadow: 0 0 0 2px #f39c12, 0 4px 8px rgba(0,0,0,0.4); }

.synth-val {
    font-size: 9px;
    color: #888;
    background: #111;
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#pads_section {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.pads-section-title {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--c-label);
    text-transform: uppercase;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--c-border);
}

.pads-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
    flex: 1;
}

.pad {
    background: var(--c-bg-module);
    border-radius: 8px;
    border: 2px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0,0,0,0.4);
}

.pad:active, .pad.active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.08);
    border-color: #888;
    color: var(--c-title);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.15), inset 0 0 8px rgba(255, 255, 255, 0.08);
}

/* Estado: áudio tocando — LED branco aceso */
.pad.playing {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.7);
    color: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 0 10px rgba(255, 255, 255, 0.4),
        0 0 20px rgba(255, 255, 255, 0.15),
        inset 0 0 8px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

/* ---- Mixer channel strips (DAW style) ---- */
.fader-slot,
.master-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: var(--c-strip-w);
    max-width: var(--c-strip-w);
    padding: 10px 6px 8px;
    border-right: 1px solid var(--c-border-dark);
    gap: 6px;
    background: var(--c-bg);
    flex-shrink: 0;
}

.master-slot {
    background: linear-gradient(135deg, rgba(212,160,23,0.06) 0%, rgba(212,160,23,0.02) 100%);
    position: relative;
}

.master-slot::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--c-master);
}

.fader-label {
    font-size: 9px;
    color: var(--c-text-dim);
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.1;
    letter-spacing: 0.3px;
}

.master-slot .fader-label {
    color: var(--c-master);
    font-weight: 600;
}

/* Pan knob */
.fader-knob-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 55%, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

.fader-knob-container.hidden {
    visibility: hidden;
    pointer-events: none;
}

.fader-pan-label {
    font-size: 7px;
    color: #9999aa;
    text-align: center;
    width: 100%;
    line-height: 1;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.fader-knob {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(160deg, #e8e8e8 0%, #b0b0b0 35%, #888 70%, #666 100%);
    border: 1px solid #555;
    position: relative;
    cursor: pointer;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.6);
    touch-action: none;
    user-select: none;
}

.fader-knob::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 7px;
    background: #3dff3d;
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(61, 255, 61, 0.7);
}

/* Numeric display boxes */
.ch-displays {
    display: flex;
    gap: 3px;
    width: 100%;
}

.ch-display {
    flex: 1;
    background: var(--c-bg-inset);
    border: 1px solid var(--c-border);
    border-radius: 2px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10px;
    text-align: center;
    padding: 3px 2px;
    line-height: 1.3;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.ch-display-val {
    color: #ccc;
}

.ch-display-val.editing {
    border-color: #4a90d9;
    box-shadow: 0 0 0 1px #4a90d9;
}

.ch-display-peak {
    color: #3dff3d;
}

/* Fader + scale + meter row */
.mixer-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 3px;
    flex: 1;
    min-width: 90px;
    min-height: 130px;
    width: 100%;
}

.ch-fader-col {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
}

.ch-fader-ticks {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 2px 2px 0;
    width: 6px;
}

.ch-fader-tick {
    width: 4px;
    height: 1px;
    background: #888;
    flex-shrink: 0;
}

.fader-track {
    width: 18px;
    position: relative;
    background: #0a0a0a;
    border-radius: 2px;
    border: 1px solid #1a1a1a;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    touch-action: none;
    flex-shrink: 0;
}

.fader-thumb {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--c-thumb-h);
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.15) 2px,
            rgba(0, 0, 0, 0.15) 3px
        ),
        linear-gradient(to bottom, #f0f0f0 0%, #c8c8c8 40%, #a0a0a0 100%);
    border: 1px solid #666;
    border-radius: 1px;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.fader-thumb:active {
    cursor: grabbing;
}

.ch-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
    font-size: 7px;
    color: #9999aa;
    user-select: none;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.ch-scale span {
    display: block;
}

/* Stereo level meter */
.ch-meter {
    display: flex;
    flex-direction: row;
    gap: 2px;
    flex-shrink: 0;
    align-self: stretch;
}

.fader-vu {
    width: 6px;
    height: 100%;
    background: #000;
    border: 1px solid #1a1a1a;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column-reverse;
}

.fader-vu-fill {
    width: 100%;
    height: 0%;
    background: #3dff3d;
    transition: height 0.04s linear;
    flex-shrink: 0;
}

.fader-vu-fill.mid {
    background: #ffcc00;
}

.fader-vu-fill.high {
    background: #ff6600;
}

.fader-vu-fill.peak {
    background: #ff2200;
}

/* Legacy compat */
.vu-wrapper {
    display: contents;
}

.fader-value {
    display: none;
}

/* M / S buttons */
.fader-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    margin-top: 2px;
}

.fader-btn-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.fader-buttons.hidden {
    display: none;
}

.fader-btn {
    width: 30px;
    height: 24px;
    border: 1px solid #444;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    color: #aaa;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.4);
}

.fader-btn:hover {
    background: linear-gradient(180deg, #444 0%, #333 100%);
    color: #ddd;
}

.fader-btn-m.active {
    background: linear-gradient(180deg, #555 0%, #3a3a3a 100%);
    color: #fff;
    border-color: #666;
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.15);
}

.fader-btn-s.active {
    background: linear-gradient(180deg, #555 0%, #3a3a3a 100%);
    color: #3dff3d;
    border-color: #666;
    box-shadow: inset 0 0 6px rgba(61, 255, 61, 0.2);
}

.fader-btn-l {
    background: linear-gradient(180deg, #2a3a2a 0%, #1a2a1a 100%);
    color: #8c8;
    border-color: #353;
}

.fader-btn-l:hover {
    background: linear-gradient(180deg, #3a4a3a 0%, #2a3a2a 100%);
    color: #aea;
}

/* ---- MIDI mapping ---- */
.fader-midi {
    font-size: 7px;
    color: #666;
    text-align: center;
    width: 100%;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--c-bg-panel);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 4px;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.context-menu-info {
    padding: 4px 8px;
    font-size: 10px;
    color: var(--c-label);
    text-align: center;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 2px;
}

.context-menu-btn {
    display: block;
    width: 100%;
    padding: 5px 8px;
    background: none;
    border: none;
    color: var(--c-text);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    border-radius: 3px;
}

.context-menu-btn:hover {
    background: var(--c-btn-hover);
    color: var(--c-title);
}

.fader-remove {
    background: none;
    border: 1px solid #333;
    color: #555;
    width: 100%;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    line-height: 1.4;
    transition: background .1s, color .1s;
}

.fader-remove:hover {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border-color: #e74c3c;
}

.fader-pan {
    -webkit-appearance: none;
    appearance: none;
    width: 52px;
    height: 4px;
    background: var(--c-bg-inset);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.fader-pan::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    cursor: pointer;
}

.fader-pan::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    cursor: pointer;
    border: none;
}

.fader-pan-label {
    font-size: 8px;
    color: #666;
    text-align: center;
    line-height: 1;
}

.empty-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--c-strip-w);
    font-size: 9px;
    color: var(--c-text-muted);
    background: var(--c-bg);
    border-right: 1px solid var(--c-border-dark);
}

/* ---- Keyboard ---- */
#keyboard_wrapper {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    background: var(--c-bg-header);
    border-top: 1px solid var(--c-border-dark);
}

/* ---- 8 Drum Pads Row ---- */
#drum_pads_row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    background: var(--c-bg-panel);
    border-bottom: 1px solid var(--c-border-dark);
    flex-shrink: 0;
}

.drum-pads-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--c-label);
    text-transform: uppercase;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    padding-right: 6px;
    border-right: 1px solid var(--c-border);
}

.drum-pads-grid {
    display: flex;
    gap: 8px;
    flex: 1;
}

.drum-pad {
    flex: 1;
    height: 70px;
    border-radius: 7px;
    border: 2px solid var(--c-border);
    background: var(--c-bg-module);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    transition: all 0.08s ease;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.4), 0 3px 6px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    color: rgba(255,255,255,0.5);
}

.drum-pad::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    opacity: 0;
    transition: opacity 0.08s;
}

.drum-pad:active, .drum-pad.active {
    transform: scale(0.93);
    background: rgba(255, 255, 255, 0.08);
    border-color: #888;
    color: var(--c-title);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.15), inset 0 0 10px rgba(255, 255, 255, 0.08);
}

.drum-pad:active::before, .drum-pad.active::before {
    opacity: 0.35;
}

.drum-pad-name {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.08s;
}

.drum-pad-note {
    font-size: 8px;
    opacity: 0.45;
    font-family: monospace;
}

#velocity_canvas {
    display: none;
}

#keyboard {
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    --current-min-height: 7;
    min-height: calc(var(--current-min-height) * 1vw);
    background: black;
    width: 100%;
    touch-action: none;
    transform-origin: bottom center;
    --key-border-radius: 0.4vmin;
    border: solid 1px black;
    flex-shrink: 0;
}

#keyboard .key {
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    flex: 1;
    transition: transform 0.1s ease, border-radius 0.5s ease;
    border-radius: 0 0 var(--key-border-radius) var(--key-border-radius);
    position: relative;
    transform-origin: center top;
    --pressed-transform-skew: 0.0007;
    --pressed-transform: matrix3d(1,0,0,0,0,1,0,var(--pressed-transform-skew),0,0,1,0,0,0,0,1);
    cursor: default;
    --flat-half-width: 1.4;
    --flat-half-translate: 18%;
    --sharp-transform: scale(1, 0.7);
    --flat-between-transform: scale(1.9, 1);
    --flat-left-transform: scale(var(--flat-half-width), 1) translateX(calc(var(--flat-half-translate) * -1));
    --flat-right-transform: scale(var(--flat-half-width), 1) translateX(var(--flat-half-translate));
}

#keyboard .flat_key {
    background: linear-gradient(90deg, #bbb, white);
    z-index: 1;
    border-right: 1px solid #ccc;
}

#keyboard .sharp_key {
    transform: var(--sharp-transform);
    z-index: 10;
    background: linear-gradient(140deg, #222, black);
    border: 1px solid #000;
}

#keyboard .flat_key.between_sharps {
    transform: var(--flat-between-transform);
}

#keyboard .flat_key.left_sharp {
    transform: var(--flat-left-transform);
}

#keyboard .flat_key.right_sharp {
    transform: var(--flat-right-transform);
}

.sharp_key.pressed {
    transform: var(--sharp-transform) var(--pressed-transform) !important;
}

.flat_key.between_sharps.pressed {
    transform: var(--flat-between-transform) var(--pressed-transform) !important;
}

.flat_key.left_sharp.pressed {
    transform: var(--flat-left-transform) var(--pressed-transform) !important;
}

.flat_key.right_sharp.pressed {
    transform: var(--flat-right-transform) var(--pressed-transform) !important;
}

/* ---- FX Modal ---- */
.fx-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fx-modal {
    background: var(--c-bg-panel);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    width: 760px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.fx-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
    font-weight: 600;
    color: var(--c-title);
}

.fx-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.fx-modal-close:hover {
    color: var(--c-title);
}

.fx-modal-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.fx-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--c-master);
    text-transform: uppercase;
    border-bottom: 1px solid var(--c-border-dark);
    padding-bottom: 3px;
    margin-top: 4px;
}

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

.fx-row-label {
    font-size: 11px;
    color: #aaa;
    min-width: 50px;
}

.fx-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 5px;
    background: #0a0a1a;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.fx-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #888;
    cursor: pointer;
}

.fx-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #888;
    cursor: pointer;
    border: none;
}

.fx-row-val {
    font-size: 11px;
    color: var(--c-label);
    min-width: 28px;
    text-align: right;
}

.fx-reset {
    background: #333;
    border: none;
    color: #888;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1.2;
}

.fx-reset:hover {
    background: #555;
    color: #fff;
}

/* ── FX modal tabs ── */
.fx-tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 10px;
}

.fx-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 4px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.15s, border-color 0.15s;
}

.fx-tab:hover {
    color: #ccc;
}

.fx-tab.active {
    color: var(--c-title);
    border-bottom-color: var(--c-master);
}

.fx-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    flex: 1;
    overflow: auto;
}

.fx-tab-panel.fx-reverb-tab,
.fx-tab-panel.fx-chorus-tab,
.fx-tab-panel.fx-delay-tab,
.fx-tab-panel.fx-comp-tab {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 18px;
    align-items: start;
    padding: 10px 0;
}

.fx-tab-panel.fx-reverb-tab .fx-row,
.fx-tab-panel.fx-chorus-tab .fx-row,
.fx-tab-panel.fx-delay-tab .fx-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-width: 120px;
}

.fx-tab-panel.fx-reverb-tab .fx-row-label,
.fx-tab-panel.fx-chorus-tab .fx-row-label,
.fx-tab-panel.fx-delay-tab .fx-row-label {
    display: block;
    width: 100%;
    text-align: center;
}

.fx-tab-panel.fx-reverb-tab .fx-slider,
.fx-tab-panel.fx-chorus-tab .fx-slider,
.fx-tab-panel.fx-delay-tab .fx-slider {
    width: 10px;
    height: 180px;
    margin: 0;
    transform: rotate(-90deg);
    transform-origin: center center;
}

.fx-delay-mode-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 4px 0 6px;
}

.fx-delay-mode-button {
    background: #20232d;
    border: 1px solid #3a3f51;
    color: #aaa;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.fx-delay-mode-button.active,
.fx-delay-mode-button:hover {
    background: #262b3d;
    border-color: var(--c-master);
    color: var(--c-title);
}

.fx-delay-knob-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 16px;
    padding: 4px 0;
}

.fx-delay-knob-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.fx-row-val {
    min-width: auto;
}

.fx-row-val,
.fx-row-label {
    color: #b8c6db;
}

.fx-tab-panel.fx-reverb-tab .fx-reset,
.fx-tab-panel.fx-chorus-tab .fx-reset,
.fx-tab-panel.fx-delay-tab .fx-reset {
    align-self: center;
}

.fx-bypass {
    align-self: flex-end;
    background: #1a6b3c;
    border: none;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: background 0.15s;
}

.fx-bypass.off {
    background: #5a2a2a;
    color: #aaa;
}

.fx-bypass:hover {
    filter: brightness(1.2);
}

/* ── Graphic EQ (track FX) ── */
.fx-modal-eq {
    min-width: 760px;
    max-width: 920px;
}

.fx-eq-band-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    padding: 8px 4px 4px;
    background: #252525;
    border: 1px solid var(--c-border-dark);
    border-radius: 4px;
}

.fx-eq-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 72px;
    flex: 1;
    max-width: 88px;
    padding: 6px 4px 8px;
    background: #2e2e2e;
    border: 1px solid #1a1a1a;
    border-radius: 3px;
}

.fx-eq-led {
    width: 10px;
    height: 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 1px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

.fx-eq-led.active {
    background: var(--eq-accent);
    border-color: #0088bb;
    box-shadow:
        0 0 6px var(--eq-accent-glow),
        0 0 12px var(--eq-accent-glow),
        inset 0 0 2px rgba(255, 255, 255, 0.4);
}

.fx-eq-freq {
    font-size: 9px;
    font-weight: 600;
    color: #aaa;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 0.2px;
    cursor: pointer;
    line-height: 1;
    user-select: none;
}

.fx-eq-freq:hover {
    color: var(--c-title);
}

.fx-eq-fader-wrap {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 2px;
    height: 130px;
}

.fx-eq-fader-ticks {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 0;
    width: 4px;
}

.fx-eq-fader-tick {
    width: 3px;
    height: 1px;
    background: #666;
    flex-shrink: 0;
}

.fx-eq-fader-track {
    width: 16px;
    height: 100%;
    background: #0a0a0a;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    border: 1px solid #1a1a1a;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.9);
    touch-action: none;
}

.fx-eq-fader-center {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #444;
    pointer-events: none;
    z-index: 0;
}

.fx-eq-fader-fill {
    position: absolute;
    left: 2px;
    right: 2px;
    background: linear-gradient(to top, rgba(0, 200, 255, 0.35), rgba(0, 200, 255, 0.08));
    border-radius: 1px;
    pointer-events: none;
    z-index: 0;
}

.fx-eq-fader-thumb {
    position: absolute;
    left: 0;
    right: 0;
    height: 14px;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.12) 2px,
            rgba(0, 0, 0, 0.12) 3px
        ),
        linear-gradient(to bottom, #f2f2f2 0%, #c0c0c0 45%, #909090 100%);
    border: 1px solid #555;
    border-radius: 1px;
    pointer-events: none;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.fx-eq-gain-val {
    font-size: 10px;
    font-weight: 600;
    font-family: 'Consolas', 'Courier New', monospace;
    color: #bbb;
    background: #111;
    border: 1px solid #333;
    border-radius: 2px;
    padding: 2px 4px;
    min-width: 44px;
    text-align: center;
    line-height: 1.2;
}

.fx-eq-knobs-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 2px;
}

.fx-eq-knob-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.fx-eq-knob-label {
    font-size: 7px;
    font-weight: 700;
    color: #666;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.fx-eq-knob-wrap {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 55%, #1a1a1a 0%, #0a0a0a 100%);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fx-eq-knob {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(160deg, #e4e4e4 0%, #b8b8b8 40%, #888 100%);
    border: 1px solid #555;
    position: relative;
    cursor: pointer;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    touch-action: none;
    user-select: none;
}

.fx-eq-knob::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 6px;
    background: var(--eq-accent);
    border-radius: 1px;
    box-shadow: 0 0 3px var(--eq-accent-glow);
}

.fx-eq-knob-val {
    font-size: 8px;
    color: #888;
    font-family: monospace;
    line-height: 1;
}

.fx-eq-type-indicators {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-width: 52px;
    margin-bottom: 1px;
}

.fx-eq-type-dot {
    font-size: 6px;
    font-weight: 700;
    color: #555;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 2px;
    padding: 1px 2px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.fx-eq-type-dot.active {
    color: var(--eq-accent);
    border-color: #0088bb;
    background: rgba(0, 200, 255, 0.12);
    box-shadow: 0 0 4px var(--eq-accent-glow);
}

.fx-eq-type-dot:hover {
    color: #aaa;
}

/* ── Reverb modal ── */
.fx-modal.reverb-modal {
    min-width: 440px;
    max-width: 540px;
}

.fx-preset-select {
    flex: 1;
    background: #1a1a2a;
    border: 1px solid var(--c-border);
    color: var(--c-title);
    font-size: 11px;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
}

.fx-preset-btn {
    background: #2a3a2a;
    border: 1px solid #353;
    color: #8c8;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.fx-preset-btn:hover {
    background: #3a4a3a;
    color: #aea;
}

.fx-preset-del {
    background: #3a2a2a;
    border-color: #533;
    color: #c88;
}

.fx-preset-del:hover {
    background: #4a3a3a;
    color: #eaa;
}

.fx-eq-type-dot.active {
    background: var(--eq-accent);
    border-color: #0088bb;
    box-shadow: 0 0 4px var(--eq-accent-glow);
}

/* ── Compressor (track FX) ── */
.fx-modal-comp .fx-comp-tab {
    min-height: 320px;
}

.fx-comp-panel {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    margin-top: 8px;
    background: #3c4354;
    border: 1px solid #2a2f3a;
    border-radius: 4px;
    overflow: hidden;
}

.fx-comp-meter-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    min-width: 56px;
    background: #353b4a;
}

.fx-comp-meter-col.gr {
    background: #323848;
}

.fx-comp-meter-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.fx-comp-meter-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #b8bcc8;
    text-transform: uppercase;
}

.fx-comp-meter-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 4px;
    flex: 1;
}

.fx-comp-gr-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 7px;
    color: #888;
    font-family: monospace;
    padding: 2px 0;
    min-width: 14px;
    text-align: right;
}

.fx-comp-led-col {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2px;
    padding: 4px 3px;
    background: #252830;
    border: 1px solid #1a1d24;
    border-radius: 2px;
    min-height: 200px;
}

.fx-comp-led {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1a1212;
    border: 1px solid #333;
    flex-shrink: 0;
}

.fx-comp-led.lit {
    background: #e22;
    border-color: #a11;
    box-shadow: 0 0 4px rgba(255, 40, 40, 0.7), inset 0 0 2px rgba(255, 120, 120, 0.5);
}

.fx-comp-meters-right {
    display: flex;
    flex-direction: row;
    border-left: 1px solid #2a2f3a;
}

.fx-comp-knobs {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-left: 1px solid #2a2f3a;
    border-right: 1px solid #2a2f3a;
}

.fx-comp-knob-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 32px;
}

.fx-comp-knob-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.fx-comp-knob-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #b0b4c0;
    text-transform: uppercase;
}

.fx-comp-knob-val {
    font-size: 9px;
    color: #a8acb8;
    font-family: monospace;
    line-height: 1;
}

.fx-comp-knob-ring {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: repeating-conic-gradient(
        from -4deg,
        #b8bcc4 0deg 4deg,
        #787f8c 4deg 8deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

.fx-comp-knob-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 3px;
    margin: -1.5px 0 0 -1.5px;
    background: rgba(160, 165, 175, 0.75);
    border-radius: 50%;
    pointer-events: none;
    transform-origin: center center;
}

.fx-comp-knob {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.6),
        inset 0 1px 3px rgba(255, 255, 255, 0.08);
    z-index: 1;
}

.fx-comp-knob::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    width: 5px;
    height: 5px;
    background: #fff;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.9);
}

.fx-comp-knob-threshold {
    background: radial-gradient(circle at 38% 32%, #555 0%, #1a1a1a 70%);
}

.fx-comp-knob-attack,
.fx-comp-knob-release {
    background: radial-gradient(circle at 38% 32%, #5a4868 0%, #2a2038 70%);
}

.fx-comp-knob-ratio,
.fx-comp-knob-makeup,
.fx-comp-knob-knee {
    background: radial-gradient(circle at 38% 32%, #4a5568 0%, #222830 70%);
}

/* ── Master track reverb button ── */
.fader-btn-r {
    background: linear-gradient(180deg, #3a3020 0%, #2a2010 100%);
    color: #da3;
    border-color: #553;
}

.fader-btn-r:hover {
    background: linear-gradient(180deg, #4a4030 0%, #3a3020 100%);
    color: #ec5;
}

/* ── Offline indicator ── */
.offline-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    transition: background 0.3s;
}
.offline-indicator.on {
    background: #3dff3d;
    box-shadow: 0 0 6px #3dff3d66;
}
.offline-indicator.off {
    background: #888;
}

/* ── App update banner ── */
.app-update-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #3a3f4d 0%, #2a2f3a 100%);
    border: 1px solid #5a6270;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    transform: translate(-50%, 120%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}

.app-update-banner.visible {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.app-update-banner.app-update-busy {
    opacity: 0.7;
    pointer-events: none;
}

.app-update-text {
    font-size: 12px;
    font-weight: 600;
    color: #e8eaed;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.app-update-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #4a7c59 0%, #3a6b48 100%);
    border: 1px solid #5a9a6a;
    border-radius: 4px;
    cursor: pointer;
}

.app-update-btn:hover {
    filter: brightness(1.1);
}

/* ── App toast notifications ── */
.app-toast {
    position: fixed;
    top: 56px;
    left: 50%;
    z-index: 10001;
    max-width: calc(100vw - 24px);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: #e8eaed;
    background: linear-gradient(180deg, #3a3f4d 0%, #2a2f3a 100%);
    border: 1px solid #5a6270;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    transform: translate(-50%, -120%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}
.app-toast.visible {
    transform: translate(-50%, 0);
    opacity: 1;
}
.app-toast-ok { border-color: #4a9a5a; }
.app-toast-error { border-color: #c44; color: #fcc; }

/* ── MIDI connect dialog ── */
.midi-connect-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 16px;
}
.midi-connect-overlay.visible { opacity: 1; }
.midi-connect-modal {
    width: min(320px, 100%);
    padding: 20px 18px;
    border-radius: 10px;
    background: linear-gradient(180deg, #3a3f4d 0%, #2a2f3a 100%);
    border: 1px solid #5a6270;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    text-align: center;
}
.midi-connect-modal h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #e8eaed;
    letter-spacing: 0.3px;
}
.midi-connect-name {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-signal);
    word-break: break-word;
}
.midi-connect-question {
    margin: 0 0 16px;
    font-size: 12px;
    color: #aaa;
}
.midi-connect-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.midi-connect-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid #555;
    cursor: pointer;
}
.midi-connect-yes {
    color: #fff;
    background: linear-gradient(180deg, #4a7c59 0%, #3a6b48 100%);
    border-color: #5a9a6a;
}
.midi-connect-no {
    color: #ccc;
    background: #333;
}

/* ── Keyboard Toggle ── */
#kbd_toggle {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(30,30,40,0.85);
    border: 1px solid #555;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    touch-action: manipulation;
}
#kbd_toggle:hover { background: rgba(50,50,65,0.9); color: #ddd; }
#kbd_toggle.active { background: rgba(45,70,55,0.85); border-color: #4a6; color: #8f8; }

.kbd-hidden #keyboard_wrapper { display: none; }

/* ── Mobile (touch) ── */
@media (hover: none) and (pointer: coarse) {

    :root {
        --app-h: 100dvh;
        --app-w: 100dvw;
        --vv-top: 0px;
        --vv-left: 0px;
        --header-h: 28px;
        --page-h: calc(var(--app-h) - var(--header-h));
        --c-strip-w: 52px;
        --c-thumb-h: 16px;
    }

    @supports not (height: 100dvh) {
        :root {
            --app-h: 100svh;
        }
    }

    html, body {
        height: var(--app-h);
        max-height: var(--app-h);
        overflow: hidden;
        background: var(--c-bg);
        padding: 0;
        margin: 0;
    }

    #app {
        position: fixed;
        top: var(--vv-top, 0);
        left: var(--vv-left, 0);
        width: var(--app-w, 100%);
        height: var(--app-h, 100dvh);
        max-height: var(--app-h, 100dvh);
        min-height: 0;
        overflow: hidden;
        padding:
            env(safe-area-inset-top, 0)
            env(safe-area-inset-right, 0)
            env(safe-area-inset-bottom, 0)
            env(safe-area-inset-left, 0);
        box-sizing: border-box;
    }

    /* Hide keyboard until carousel mounts */
    #app:not(.mobile-ready) #keyboard_wrapper {
        display: none !important;
    }

    /* ── Layout: carrossel ── */
    main {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    #kbd_toggle { display: none; }
    .mobile-ready #keyboard_wrapper { display: none !important; }

    /* ── Header: single compact line ── */
    header {
        display: flex;
        align-items: center;
        padding: 2px 6px;
        gap: 4px;
        flex-shrink: 0;
        min-height: var(--header-h);
        max-height: var(--header-h);
    }
    header h1 { font-size: 11px; margin: 0; flex-shrink: 0; }

    /* Controls: perf monitor centered + midi_status pushed right */
    #controls {
        display: flex;
        align-items: center;
        flex: 1;
        gap: 2px;
        min-width: 0;
    }
    #bank_count { display: none; }
    #offline_indicator { display: none; }
    #project_controls { display: none !important; }
    #perf_monitor {
        display: flex !important;
        align-items: center;
        gap: 2px;
        margin: 0;
    }
    #perf_monitor .perf-item {
        display: flex;
        align-items: center;
        gap: 1px;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    #perf_monitor .perf-label { display: none; }
    #bpm_input {
        width: 20px;
        font-size: 8px;
        padding: 0;
        text-align: center;
        border: none;
        background: transparent;
        color: #3dff3d;
        font-family: monospace;
    }
    #tap_tempo_btn { padding: 1px 2px; font-size: 6px; line-height: 1; }
    .perf-item + .perf-item::before { content: "|"; color: #333; font-size: 7px; }
    #perf_voices { font-size: 7px; color: #aaa; }
    .perf-bar { width: 16px; height: 3px; background: #222; border-radius: 1px; }
    .perf-bar-fill { height: 100%; background: #3dff3d; border-radius: 1px; }
    #perf_latency { font-size: 7px; color: #aaa; }

    #midi_status {
        font-size: 7px;
        padding: 1px 3px;
        white-space: nowrap;
        flex-shrink: 0;
        margin-left: auto;
    }

    /* Nav arrows */
    .carousel-nav {
        display: flex;
        align-items: center;
        gap: 2px;
        flex-shrink: 0;
    }
    .carousel-page-label {
        font-size: 8px;
        color: var(--c-text-dim);
        min-width: 28px;
        text-align: center;
        line-height: 1;
    }
    .carousel-arrow {
        background: none;
        border: none;
        color: #999;
        font-size: 8px;
        padding: 2px 3px;
        cursor: pointer;
        line-height: 1;
        touch-action: manipulation;
    }
    .carousel-arrow:active { color: #ddd; }

    /* ── Menu (☰) Salvar / Carregar ── */
    .mobile-menu-wrap {
        position: relative;
        flex-shrink: 0;
    }
    .mobile-menu-btn {
        background: none;
        border: 1px solid #444;
        color: #999;
        font-size: 10px;
        padding: 2px 5px;
        cursor: pointer;
        border-radius: 3px;
        line-height: 1;
        touch-action: manipulation;
    }
    .mobile-menu-btn:active { background: #333; color: #ddd; }
    .mobile-menu {
        display: none;
        position: absolute;
        right: 0;
        top: 100%;
        z-index: 200;
        background: #1a1a1a;
        border: 1px solid #444;
        border-radius: 4px;
        overflow: hidden;
        min-width: 80px;
    }
    .mobile-menu.open { display: block; }
    .mobile-menu button {
        display: block;
        width: 100%;
        background: none;
        border: none;
        color: #ccc;
        font-size: 11px;
        padding: 6px 12px;
        text-align: left;
        cursor: pointer;
    }
    .mobile-menu button:active { background: #333; }

    /* ── Carrossel ── */
    .mobile-carousel {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
        height: var(--page-h);
        width: 100%;
        scrollbar-width: none;
    }
    .mobile-carousel::-webkit-scrollbar { display: none; }
    .mobile-page {
        flex: 0 0 100%;
        width: 100%;
        scroll-snap-align: start;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
    }

    /* Page 1 – Tracks (full-height mixer) */
    .page-tracks {
        padding: 0;
        overflow: hidden;
        height: 100%;
    }
    .page-tracks #fader_strip,
    .mobile-mixer-strip {
        width: 100%;
        height: 100%;
        flex: 1;
        min-height: 0;
        overflow-x: auto;
        overflow-y: hidden;
        border: none;
        align-items: stretch;
        display: flex;
        background: var(--c-bg);
    }
    .page-tracks .fader-slot,
    .page-tracks .master-slot {
        min-width: var(--c-strip-w);
        max-width: var(--c-strip-w);
        width: var(--c-strip-w);
        height: 100%;
        padding: 1px 1px 0;
        gap: 1px;
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
    }
    .page-tracks .master-slot::before { height: 1px; }
    .page-tracks .fader-label {
        font-size: 7px;
        line-height: 1.1;
        flex-shrink: 0;
        padding: 0 1px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
        color: var(--c-signal);
    }
    .page-tracks .fader-knob-container,
    .page-tracks .fader-pan-label,
    .page-tracks .mobile-pan-slider,
    .page-tracks .fader-value,
    .page-tracks .fader-midi,
    .page-tracks .ch-display-peak {
        display: none !important;
    }
    .page-tracks .ch-displays {
        gap: 0;
        flex-shrink: 0;
        width: 100%;
    }
    .page-tracks .ch-display {
        font-size: 6px;
        padding: 0;
        line-height: 1.2;
    }
    .page-tracks .ch-display-val { flex: 1; }
    .page-tracks .mixer-row {
        flex: 1 1 0;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        min-width: 0;
        gap: 1px;
        align-items: stretch;
    }
    .page-tracks .ch-scale {
        font-size: 4px;
        padding: 0 1px;
        flex-shrink: 0;
    }
    .page-tracks .ch-fader-col {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        min-width: 0;
    }
    .page-tracks .ch-fader-ticks { display: none; }
    .page-tracks .fader-track {
        flex: 1 1 auto;
        width: 11px;
        min-height: 0;
        height: auto !important;
    }
    .page-tracks .fader-thumb {
        height: var(--c-thumb-h);
    }
    .page-tracks .ch-meter {
        min-height: 0;
        flex: 1;
        align-self: stretch;
    }
    .page-tracks .fader-vu {
        min-height: 0;
        flex: 1;
    }
    .page-tracks .fader-buttons,
    .page-tracks .fader-btn-row {
        flex-shrink: 0;
        gap: 1px;
        margin-top: auto;
    }
    .page-tracks .fader-btn {
        font-size: 5px;
        padding: 1px 0;
        min-width: 0;
        line-height: 1.1;
        min-height: 12px;
    }
    .page-tracks #card_panel,
    .page-tracks #keyboard_wrapper,
    .page-tracks #drum_pads_row {
        display: none !important;
    }

    /* Page 1 – Pan slider on mobile */
    .mobile-pan-slider {
        width: 60px;
        height: 3px;
        -webkit-appearance: none;
        appearance: none;
        background: #333;
        border-radius: 2px;
        outline: none;
        margin: 2px auto;
        display: block;
    }
    .mobile-pan-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #999;
        cursor: pointer;
        border: 1px solid #555;
    }
    .mobile-pan-slider::-moz-range-thumb {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #999;
        cursor: pointer;
        border: 1px solid #555;
    }

    /* Page 2 – Synth (horizontal modules, fill height) */
    .page-synth {
        padding: 0;
        overflow: hidden;
        height: 100%;
    }
    .page-synth #synth_section {
        width: 100%;
        height: 100%;
        flex: 1;
        min-height: 0;
        overflow: hidden;
        padding: 2px 4px 4px;
        display: flex;
        flex-direction: column;
    }
    .page-synth .synth-header {
        margin-bottom: 2px;
        padding-bottom: 2px;
        flex-shrink: 0;
    }
    .page-synth .synth-header h2 { font-size: 9px; letter-spacing: 0.5px; }
    .page-synth .synth-vu-container { height: 18px; width: 4px; }
    .page-synth .synth-power-btn { font-size: 7px; padding: 1px 5px; }
    .page-synth .synth-tabs-nav {
        margin-bottom: 2px;
        gap: 1px;
        flex-shrink: 0;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .page-synth .synth-tab-btn { padding: 2px 5px; font-size: 7px; letter-spacing: 0.3px; flex-shrink: 0; }
    .page-synth .synth-preset-row {
        padding: 0;
        margin-bottom: 2px;
        flex-shrink: 0;
    }
    .page-synth .synth-preset-select { font-size: 7px; max-width: 72px; }
    .page-synth .synth-preset-btn { padding: 1px 4px; font-size: 8px; }
    .page-synth .synth-tab-panel.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    .page-synth .synth-modules {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        flex: 1;
        min-height: 0;
        align-items: stretch;
        gap: 4px;
        padding-bottom: 2px;
    }
    .page-synth .synth-module {
        padding: 3px 4px;
        gap: 2px;
        min-width: 88px;
        max-width: 120px;
        flex: 0 0 auto;
        height: 100%;
        overflow-y: auto;
    }
    .page-synth .envelope-module { min-width: 100px; }
    .page-synth .synth-module-title { font-size: 7px; padding-bottom: 1px; }
    .page-synth .synth-knob { width: 22px; height: 22px; border-width: 1.5px; }
    .page-synth .synth-knob::after { width: 1.5px; height: 6px; top: 2px; }
    .page-synth .synth-knob-group { gap: 1px; }
    .page-synth .synth-knob-group label { font-size: 6px; }
    .page-synth .synth-knob-container { gap: 0; }
    .page-synth .synth-select { font-size: 7px; padding: 0 1px; }
    .page-synth .env-knobs { gap: 4px; }
    .page-synth .osc-toggle { font-size: 5px; padding: 1px 3px; }
    .page-synth .synth-knob-val,
    .page-synth .synth-val { font-size: 6px; }

    /* Page 3 – Pads contínuos (full grid) */
    .page-pads {
        padding: 4px 6px;
        overflow: hidden;
        height: 100%;
        box-sizing: border-box;
    }
    .page-pads #pads_section {
        width: 100%;
        height: 100%;
        flex: 1;
        min-height: 0;
        display: flex !important;
        flex-direction: column;
        padding: 0 !important;
    }
    .page-pads .pads-section-title {
        font-size: 8px;
        margin-bottom: 4px;
        padding-bottom: 2px;
        flex-shrink: 0;
    }
    .page-pads .pads-grid {
        flex: 1;
        min-height: 0;
        width: 100%;
        height: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 5px;
    }
    .page-pads .pad {
        min-height: 0;
        height: 100%;
        width: 100%;
        font-size: clamp(7px, 2.2vh, 11px);
        border-radius: 6px;
        border-width: 1px;
    }

    /* Page 4 – Drum pads (full grid) */
    .page-drums {
        padding: 4px 6px;
        overflow: hidden;
        height: 100%;
        box-sizing: border-box;
    }
    .page-drums #drum_pads_row {
        width: 100%;
        height: 100%;
        flex: 1;
        min-height: 0;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px;
        padding: 0 !important;
        background: transparent;
        border: none;
    }
    .page-drums .drum-pads-label {
        font-size: 8px;
        writing-mode: horizontal-tb;
        transform: none;
        border-right: none;
        border-bottom: 1px solid var(--c-border);
        padding: 0 0 3px 0;
        flex-shrink: 0;
    }
    .page-drums .drum-pads-grid {
        flex: 1;
        min-height: 0;
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 5px;
    }
    .page-drums .drum-pad {
        height: 100%;
        min-height: 0;
        width: 100%;
        border-width: 1px;
        border-radius: 6px;
        flex: unset;
    }
    .page-drums .drum-pad-name { font-size: clamp(6px, 1.8vh, 9px); }
    .page-drums .drum-pad-note { font-size: clamp(5px, 1.5vh, 8px); }

    .page-synth #pads_section,
    .page-pads #synth_section,
    .page-drums #synth_section,
    .page-drums #pads_section,
    .page-synth #fader_strip,
    .page-pads #fader_strip,
    .page-drums #fader_strip,
    .page-synth #keyboard_wrapper,
    .page-pads #keyboard_wrapper,
    .page-drums #keyboard_wrapper {
        display: none !important;
    }

    /* Legacy page-keys (removed) */
    .page-keys { display: none !important; }

    #mobile_install_btn {
        color: #8f8;
        font-weight: 600;
    }

    /* ── FX Modal compact ── */
    .fx-modal {
        width: calc(var(--app-w, 100vw) - 10px);
        height: calc(var(--app-h, 100dvh) - 10px);
        max-width: 100%;
        max-height: var(--app-h, 100dvh);
        border-radius: 4px;
    }
    .fx-modal-body { padding: 6px 8px; gap: 4px; }
    .fx-tab-bar { gap: 2px; }
    .fx-tab { padding: 3px 8px; font-size: 9px; letter-spacing: 0.5px; }
    .fx-tab-panel { gap: 4px; }
    .fx-row { gap: 4px; }
    .fx-row-label { font-size: 9px; min-width: 30px; }
    .fx-row-val { font-size: 9px; min-width: 30px; }
    .fx-slider { height: 4px; }
    .fx-bypass { padding: 2px 8px; font-size: 9px; }
    .fx-preset-select { font-size: 9px; padding: 2px 4px; }
    .fx-preset-btn { padding: 2px 6px; font-size: 9px; }
    .fx-comp-led { width: 4px; height: 20px; }
    .fx-comp-led-col { gap: 1px; }
    .fx-comp-led-label { font-size: 7px; }
    .fx-comp-knob-cell { gap: 2px; }
    .fx-comp-knob-ring { width: 28px; height: 28px; }
    .fx-comp-knob-ring::after { width: 2px; height: 6px; top: 2px; }
    .fx-comp-knob-val { font-size: 8px; }
    .fx-chorus-knob-grid { gap: 4px; }
    .fx-delay-knob-grid { gap: 4px; }
    .fx-chorus-knob-cell { gap: 2px; }
    .fx-delay-knob-cell { gap: 2px; }
    .fx-eq-col { min-width: 38px; padding: 3px 1px; }
    .fx-eq-col-label { font-size: 8px; }
    .fx-eq-fader-track { width: 12px; height: 50px; }
    .fx-eq-gain-val { font-size: 8px; }
    .fx-eq-freq { font-size: 7px; }
    .fx-eq-q-slider { height: 2px; }
    .fx-eq-q-val { font-size: 7px; min-width: 14px; }
    .fx-eq-type-icon { font-size: 7px; padding: 0 3px; }
    .fx-modal.reverb-modal {
        width: calc(100vw - 20px);
        height: auto;
        max-height: calc(100vh - 20px);
        max-width: 100vw;
    }
}
