/* ==========================================
   ZE(B)D 1 — Jungle & DnB Drum Machine
   Ultra-Minimal Noir & Blanc
   ========================================== */

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

/* === THEME VARIABLES === */
:root,
[data-theme="dark"] {
    --bg:          #070707;
    --bg2:         #0c0c0c;
    --panel:       #0f0f0f;
    --panel2:      #161616;
    --border:      #1e1e1e;
    --border2:     #2a2a2a;
    --chassis-bg:  linear-gradient(90deg, #1a1a1a 0%, #232323 3%, #1c1c1c 6%, #252525 10%, #1a1a1a 100%);
    --chassis-edge: linear-gradient(180deg, #333 0%, #1a1a1a 15%, #222 50%, #1a1a1a 85%, #333 100%);
    --chassis-screw: #2a2a2a;
    --chassis-groove: rgba(255,255,255,.03);
    --chassis-shadow: rgba(0,0,0,.5);
    --text:        #e0e0e0;
    --text2:       #555;
    --text3:       #333;
    --accent:      #fff;
    --accent2:     #aaa;
    --accent-inv:  #000;
    --red:         #e02040;
    --step-off:    #141414;
    --step-on:     #e0e0e0;
    --step-on-dim: #3c3c3c;
    --step-on-mid: #777;
    --step-play:   #fff;
    --pad-bg:      #111;
    --pad-active:  #fff;
    --knob-track:  #222;
    --knob-fill:   #fff;
    --shadow:      rgba(0,0,0,.7);
    --glow:        rgba(255,255,255,.06);
    --viz-line:    #fff;
    --viz-bg:      #070707;
    --bar-sep:     rgba(255,255,255,.04);
    --hover:       rgba(255,255,255,.05);
    --vel-bar:     rgba(255,255,255,.35);
}

[data-theme="light"] {
    --bg:          #f4f4f4;
    --bg2:         #ededed;
    --panel:       #fff;
    --panel2:      #f8f8f8;
    --border:      #ddd;
    --border2:     #ccc;
    --chassis-bg:  linear-gradient(90deg, #d0d0d0 0%, #dcdcdc 3%, #d5d5d5 6%, #e0e0e0 10%, #d0d0d0 100%);
    --chassis-edge: linear-gradient(180deg, #eee 0%, #d8d8d8 15%, #ddd 50%, #d8d8d8 85%, #eee 100%);
    --chassis-screw: #c0c0c0;
    --chassis-groove: rgba(0,0,0,.04);
    --chassis-shadow: rgba(0,0,0,.12);
    --text:        #111;
    --text2:       #888;
    --text3:       #bbb;
    --accent:      #111;
    --accent2:     #555;
    --accent-inv:  #fff;
    --red:         #c01030;
    --step-off:    #e6e6e6;
    --step-on:     #1a1a1a;
    --step-on-dim: #aaa;
    --step-on-mid: #666;
    --step-play:   #111;
    --pad-bg:      #eee;
    --pad-active:  #111;
    --knob-track:  #d5d5d5;
    --knob-fill:   #111;
    --shadow:      rgba(0,0,0,.08);
    --glow:        rgba(0,0,0,.03);
    --viz-line:    #111;
    --viz-bg:      #eaeaea;
    --bar-sep:     rgba(0,0,0,.04);
    --hover:       rgba(0,0,0,.04);
    --vel-bar:     rgba(0,0,0,.3);
}

/* === BASE === */
html { font-size: 13px; }
html[data-theme="light"] body { background: #c8c8c8; }
body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, 'Segoe UI', system-ui, sans-serif;
    background: #000;
    color: var(--text);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background .25s, color .25s;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 1520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
    box-shadow: 0 0 60px rgba(0,0,0,.5);
}

/* === HARDWARE CHASSIS — side panels === */
.app::before,
.app::after {
    content: '';
    position: fixed;
    top: 0;
    bottom: 0;
    width: 38px;
    z-index: 200;
    pointer-events: none;
    background: var(--chassis-edge);
    /* Brushed metal texture */
    background-size: 100% 100%;
}
.app::before {
    left: 0;
    border-right: 1px solid var(--chassis-groove);
    box-shadow:
        inset -8px 0 16px -6px var(--chassis-shadow),
        inset -1px 0 0 var(--chassis-groove);
    /* Brushed vertical grain */
    background-image:
        var(--chassis-edge),
        repeating-linear-gradient(0deg, transparent, transparent 1px, var(--chassis-groove) 1px, var(--chassis-groove) 2px);
}
.app::after {
    right: 0;
    border-left: 1px solid var(--chassis-groove);
    box-shadow:
        inset 8px 0 16px -6px var(--chassis-shadow),
        inset 1px 0 0 var(--chassis-groove);
    background-image:
        var(--chassis-edge),
        repeating-linear-gradient(0deg, transparent, transparent 1px, var(--chassis-groove) 1px, var(--chassis-groove) 2px);
}

/* Screw holes on side panels */
body::before,
body::after {
    content: '';
    position: fixed;
    z-index: 201;
    pointer-events: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--chassis-groove), var(--chassis-screw) 50%, var(--chassis-groove));
    box-shadow:
        0 0 1px rgba(0,0,0,.3),
        inset 0 1px 1px rgba(255,255,255,.1),
        /* Bottom screw */
        0 calc(100vh - 70px) 0 0 var(--chassis-screw),
        0 calc(100vh - 70px) 1px rgba(0,0,0,.3);
}
body::before {
    top: 30px;
    left: 14px;
}
body::after {
    top: 30px;
    right: 14px;
}

/* Push content inward to leave room for chassis */
.top-bar,
.pattern-bar,
.seq-section,
.viz-section,
.bottom-panel,
.footer-bar {
    margin-left: 38px;
    margin-right: 38px;
}

@media (max-width: 900px) {
    .app::before, .app::after { width: 16px; }
    body::before { left: 3px; }
    body::after { right: 3px; }
    .top-bar, .pattern-bar, .seq-section, .viz-section, .bottom-panel, .footer-bar {
        margin-left: 16px;
        margin-right: 16px;
    }
    .bottom-panel {
        left: 16px;
        right: 16px;
        max-width: calc(1520px - 32px);
    }
    .footer-bar {
        left: 16px;
        right: 16px;
        max-width: calc(1520px - 32px);
    }
}

/* === SVG ICONS === */
.icon {
    width: 16px; height: 16px;
    fill: currentColor;
    vertical-align: middle;
}

/* === TOP BAR === */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 6px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.top-center {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}
.logo-img {
    width: 26px; height: 26px;
    border-radius: 5px;
    filter: grayscale(100%) contrast(1.2);
}
[data-theme="dark"] .logo-img { filter: grayscale(100%) contrast(1.2) invert(1); }
.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--accent);
}
.logo-sub {
    font-size: .55rem;
    letter-spacing: 2px;
    color: var(--text2);
    font-weight: 500;
}

/* Transport */
.transport { display: flex; gap: 3px; }
.transport-btn {
    width: 34px; height: 34px;
    border: 1px solid var(--border2);
    background: var(--panel2);
    color: var(--text2);
    border-radius: 6px;
    cursor: pointer;
    transition: all .12s;
    display: flex; align-items: center; justify-content: center;
}
.transport-btn:hover { border-color: var(--accent2); color: var(--text); background: var(--hover); }
.transport-btn.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }
.rec-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.rec-btn.active .icon { fill: #fff; }

/* Controls */
.ctrl-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.ctrl-group label {
    font-size: .6rem;
    color: var(--text2);
    letter-spacing: 1.5px;
    font-weight: 600;
}

.num-input {
    width: 50px; height: 28px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 5px;
    text-align: center;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    outline: none;
    transition: border-color .12s;
}
.num-input:focus { border-color: var(--accent); }

.tiny-btn {
    width: 22px; height: 22px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text2);
    border-radius: 4px;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    transition: all .1s;
    padding: 0;
}
.tiny-btn:hover { border-color: var(--accent2); color: var(--text); }

.tap-btn {
    height: 28px;
    padding: 0 10px;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 5px;
    font-family: inherit;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all .1s;
}
.tap-btn:hover { border-color: var(--accent2); color: var(--text); }
.tap-btn:active { background: var(--accent); color: var(--accent-inv); }

.sel-input {
    height: 28px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 5px;
    font-family: inherit;
    font-size: .7rem;
    font-weight: 500;
    padding: 0 8px;
    outline: none;
    cursor: pointer;
    transition: border-color .12s;
}
.sel-input.sm { width: 48px; }
.sel-input:focus { border-color: var(--accent); }

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 64px; height: 3px;
    background: var(--knob-track);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: transform .1s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.slider::-moz-range-thumb {
    width: 12px; height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.val-display {
    font-size: .65rem;
    color: var(--text2);
    min-width: 28px;
    font-weight: 600;
}

/* Top actions */
.top-actions { display: flex; gap: 4px; }
.icon-btn {
    height: 28px;
    min-width: 28px;
    padding: 0 8px;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 5px;
    font-family: inherit;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all .12s;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.icon-btn:hover { border-color: var(--accent2); color: var(--text); background: var(--hover); }
.icon-btn.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }
.icon-btn.active .icon { fill: var(--accent-inv); }
.icon-btn:disabled { opacity: .25; pointer-events: none; }

/* === VISUALIZER === */
.viz-section {
    background: var(--viz-bg);
    border-bottom: 1px solid var(--border);
    position: relative;
    height: 72px;
}
.viz-section canvas {
    width: 100%; height: 100%;
    display: block;
}
.viz-modes {
    position: absolute;
    top: 6px; right: 8px;
    display: flex; gap: 2px;
}
.viz-mode {
    padding: 2px 6px;
    font-size: .5rem;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 1px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text3);
    border-radius: 3px;
    cursor: pointer;
    transition: all .1s;
}
.viz-mode:hover { color: var(--text2); }
.viz-mode.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }

/* === PATTERN BAR === */
.pattern-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 5px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.pattern-section, .song-section, .preset-section {
    display: flex;
    align-items: center;
    gap: 5px;
}

.section-label {
    font-size: .5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text3);
    margin-right: 2px;
}

.pattern-btns { display: flex; gap: 2px; }
.pat-btn {
    width: 28px; height: 24px;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 4px;
    font-family: inherit;
    font-size: .7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .1s;
}
.pat-btn:hover { border-color: var(--accent2); color: var(--text); }
.pat-btn.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }
.pat-btn.has-data { box-shadow: inset 0 -2px 0 var(--accent2); }

.pattern-actions { display: flex; gap: 2px; }

.sm-btn {
    height: 24px;
    padding: 0 7px;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 4px;
    font-family: inherit;
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .5px;
    cursor: pointer;
    transition: all .1s;
}
.sm-btn:hover { border-color: var(--accent2); color: var(--text); background: var(--hover); }
.sm-btn.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }

/* Kit selector */
.kit-section {
    display: flex;
    align-items: center;
    gap: 5px;
}
.kit-sel {
    min-width: 100px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Song chain */
.song-chain {
    display: flex; gap: 2px;
    max-width: 300px;
    overflow-x: auto;
}
.song-chip {
    padding: 2px 6px;
    font-size: .6rem;
    font-weight: 700;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 3px;
    cursor: pointer;
    min-width: 22px;
    text-align: center;
    transition: all .1s;
}
.song-chip.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }

/* === STEP SEQUENCER === */
.seq-section {
    flex: 1;
    overflow: auto;
    padding: 6px 0;
    padding-bottom: 420px;
    background: var(--bg);
}

.seq-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 10px;
    min-width: fit-content;
}

.seq-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    height: var(--row-h, 38px);
}

.seq-header {
    display: flex;
    align-items: center;
    gap: 0;
    height: 18px;
    margin-bottom: 0;
}

.track-info {
    width: 140px;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 6px;
}

.track-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text);
    white-space: nowrap;
    min-width: 44px;
    text-align: right;
}

.track-vol {
    -webkit-appearance: none;
    appearance: none;
    width: 32px; height: 2px;
    background: var(--knob-track);
    border-radius: 1px;
    outline: none;
    cursor: pointer;
}
.track-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 8px; height: 8px;
    background: var(--text2);
    border-radius: 50%;
    cursor: pointer; border: none;
}
.track-vol::-moz-range-thumb {
    width: 8px; height: 8px;
    background: var(--text2);
    border-radius: 50%; cursor: pointer; border: none;
}

.mute-btn, .solo-btn {
    width: 16px; height: 16px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text3);
    border-radius: 3px;
    font-family: inherit;
    font-size: .5rem;
    font-weight: 800;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: all .08s;
}
.mute-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.solo-btn.active { background: var(--accent); color: var(--accent-inv); border-color: var(--accent); }

.steps-container {
    display: flex;
    gap: 2px;
    align-items: stretch;
    flex: 1;
    min-width: 0;
}

.header-steps {
    width: 140px; min-width: 140px;
}

.step-num {
    flex: 1 1 0;
    min-width: 18px;
    height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: .5rem;
    font-weight: 600;
    color: var(--text3);
}
.step-num.bar-start { color: var(--text2); }

/* STEP CELL — with velocity bar */
.step {
    flex: 1 1 0;
    min-width: 18px;
    background: var(--step-off);
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: background .06s, border-color .06s;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}
.step:hover { border-color: var(--text3); }

/* Velocity bar inside step */
.step .vel-bar {
    width: 100%;
    background: var(--vel-bar);
    transition: height .08s;
    border-radius: 0 0 2px 2px;
    pointer-events: none;
}

.step.on { background: var(--step-on); }
.step.on .vel-bar { background: var(--accent-inv); opacity: .5; }
.step.on.vel-low { background: var(--step-on-dim); }
.step.on.vel-low .vel-bar { background: var(--accent); opacity: .2; }
.step.on.vel-mid { background: var(--step-on-mid); }
.step.on.vel-mid .vel-bar { background: var(--accent-inv); opacity: .3; }

.step.playing {
    box-shadow: 0 0 6px var(--step-play);
    border-color: var(--step-play);
}

/* Probability indicator dot */
.step .prob-dot {
    position: absolute;
    top: 2px; right: 2px;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--text2);
    pointer-events: none;
    display: none;
}
.step.has-prob .prob-dot { display: block; }

/* Bar separator */
.step.bar-start { margin-left: 3px; }
.step-num.bar-start-m { margin-left: 3px; }

/* === BOTTOM PANEL === */
.bottom-panel {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border);
    background: var(--panel);
    flex-wrap: wrap;
    position: fixed;
    bottom: 40px;
    left: 38px;
    right: 38px;
    z-index: 90;
    max-width: calc(1520px - 76px);
    margin: 0 auto;
    box-shadow: 0 -4px 16px var(--shadow);
}

/* MPC PADS */
.pads-area {
    flex: 0 0 320px;
    padding: 10px 14px;
    border-right: 1px solid var(--border);
}

.panel-title {
    font-size: .6rem;
    letter-spacing: 2px;
    color: var(--text2);
    margin-bottom: 8px;
    font-weight: 700;
}
.panel-title .hint { font-weight: 500; font-size: .5rem; color: var(--text3); }

.pads-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.pad {
    aspect-ratio: 1;
    background: var(--pad-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all .06s;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.pad:hover { border-color: var(--accent2); background: var(--hover); }
.pad:active, .pad.hit {
    background: var(--pad-active);
    transform: scale(.94);
    border-color: var(--accent);
}
.pad:active .pad-name, .pad.hit .pad-name,
.pad:active .pad-key, .pad.hit .pad-key {
    color: var(--accent-inv);
}

.pad .pad-name {
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text);
    pointer-events: none;
}
.pad .pad-key {
    font-size: .45rem;
    font-weight: 600;
    color: var(--text3);
    pointer-events: none;
}
.pad .pad-indicator {
    position: absolute;
    top: 4px; right: 4px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: transparent;
    pointer-events: none;
}
.pad.has-sample .pad-indicator { background: var(--accent); }

/* === FX MODULE === */
.fx-area {
    flex: 1;
    padding: 10px 14px;
    min-width: 300px;
}

.fx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}
.fx-header .panel-title { margin-bottom: 0; }

.fx-preset-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}
.fx-preset-bar .sel-input {
    min-width: 110px;
    font-size: .55rem;
    padding: 3px 6px;
}
.fx-preset-bar .sm-btn {
    font-size: .5rem;
    padding: 3px 8px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    letter-spacing: 1px;
    font-weight: 700;
    transition: background .15s;
}
.fx-preset-bar .sm-btn:hover {
    background: var(--accent);
    color: var(--accent-inv);
}

.fx-rack {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.fx-unit {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 90px;
}
.fx-unit h4 {
    font-size: .5rem;
    letter-spacing: 2px;
    color: var(--text2);
    margin-bottom: 8px;
    text-align: center;
    font-weight: 700;
}

.knob-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.knob-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.knob-wrap label {
    font-size: .45rem;
    color: var(--text3);
    letter-spacing: .5px;
    font-weight: 600;
}
.knob-val {
    font-size: .5rem;
    color: var(--text2);
    font-weight: 700;
    min-height: 12px;
}

.knob {
    -webkit-appearance: none;
    appearance: none;
    width: 44px; height: 3px;
    background: var(--knob-track);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.knob::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px; height: 10px;
    background: var(--knob-fill);
    border-radius: 50%;
    cursor: pointer; border: none;
    transition: transform .1s;
}
.knob::-webkit-slider-thumb:hover { transform: scale(1.3); }
.knob::-moz-range-thumb {
    width: 10px; height: 10px;
    background: var(--knob-fill);
    border-radius: 50%; cursor: pointer; border: none;
}

/* === FOOTER === */
.footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 38px;
    right: 38px;
    z-index: 91;
    max-width: calc(1520px - 76px);
    margin: 0 auto;
}

.file-actions { display: flex; gap: 4px; }

.act-btn {
    height: 28px;
    padding: 0 12px;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 5px;
    font-family: inherit;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all .1s;
}
.act-btn:hover { border-color: var(--accent2); color: var(--text); background: var(--hover); }

.status {
    font-size: .55rem;
    color: var(--text2);
    font-weight: 600;
    letter-spacing: .5px;
    min-height: 16px;
    transition: color .2s;
}
.status.flash { color: var(--accent); }

.credits {
    font-size: .55rem;
    color: var(--text3);
    letter-spacing: 1px;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* === RESPONSIVE === */

/* Large screens: taller rows, more gap */
@media (min-width: 1600px) {
    :root { --row-h: 48px; }
    .steps-container { gap: 3px; }
    .step { border-radius: 4px; }
    .seq-grid { gap: 2px; }
}
@media (min-width: 2000px) {
    :root { --row-h: 56px; }
    .steps-container { gap: 4px; }
    .step { border-radius: 5px; }
    .seq-grid { gap: 3px; }
    .step-num { font-size: .6rem; }
    .track-label { font-size: .75rem; }
}
@media (min-width: 2560px) {
    :root { --row-h: 64px; }
    .steps-container { gap: 5px; }
    .seq-grid { gap: 4px; }
    .track-info { width: 180px; min-width: 180px; }
    .header-steps { width: 180px; min-width: 180px; }
}

/* === TABLET (max-width: 900px) === */
@media (max-width: 900px) {
    .pads-area { flex: 0 0 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .fx-area   { flex: 0 0 100%; }
    .top-bar   { gap: 6px; }
    .slider    { width: 48px; }
    .logo-sub  { display: none; }
}

/* =============================================
   MOBILE — full ergonomic redesign (max 768px)
   ============================================= */
@media (max-width: 768px) {

    /* --- Kill chassis side panels --- */
    .app::before, .app::after { display: none; }
    body::before, body::after { display: none; }
    .top-bar, .pattern-bar, .seq-section, .viz-section, .bottom-panel, .footer-bar {
        margin-left: 0;
        margin-right: 0;
    }

    /* --- TOP BAR: 2 compact rows --- */
    .top-bar {
        gap: 6px;
        padding: 6px 10px;
    }
    .logo { gap: 6px; margin-right: 0; flex-shrink: 0; }
    .logo-img { width: 22px; height: 22px; }
    .logo-text { font-size: .8rem; letter-spacing: 3px; }

    /* Transport always visible in row 1 */
    .transport { flex-shrink: 0; }
    .transport-btn { width: 38px; height: 38px; }

    /* Controls row: full-width scrollable second row */
    .top-center {
        order: 4;
        flex: 0 0 100%;
        justify-content: flex-start;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 0;
    }
    .top-center::-webkit-scrollbar { display: none; }

    /* Action buttons: compact, stay row 1 */
    .top-actions { margin-left: auto; gap: 2px; flex-shrink: 0; }
    .icon-btn { min-width: 26px; height: 28px; padding: 0 5px; font-size: .5rem; }

    /* Controls sizes */
    .ctrl-group { flex-shrink: 0; }
    .ctrl-group label { font-size: .5rem; letter-spacing: 1px; }
    .num-input { width: 44px; height: 26px; font-size: .8rem; }
    .tiny-btn { width: 22px; height: 22px; }
    .tap-btn { height: 26px; padding: 0 8px; font-size: .5rem; }
    .slider { width: 48px; }
    .sel-input { height: 26px; font-size: .6rem; padding: 0 5px; }
    .val-display { font-size: .55rem; min-width: 20px; }

    /* --- VISUALIZER: shorter --- */
    .viz-section { height: 48px; }

    /* --- PATTERN BAR: horizontal scroll --- */
    .pattern-bar {
        gap: 10px;
        padding: 5px 10px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .pattern-bar::-webkit-scrollbar { display: none; }
    .pattern-section, .song-section, .preset-section, .kit-section { flex-shrink: 0; }
    .pat-btn { width: 26px; height: 22px; font-size: .65rem; }

    /* --- SEQUENCER: touch-friendly, no fixed offset --- */
    .seq-section {
        padding-bottom: 10px;
    }
    .seq-grid { padding: 0 6px; }
    .track-info { width: 72px; min-width: 72px; gap: 2px; padding-right: 3px; }
    .track-label { font-size: .55rem; letter-spacing: .5px; min-width: 28px; }
    .track-vol { display: none; }
    .header-steps { width: 72px; min-width: 72px; }
    .step { min-width: 24px; border-radius: 4px; }
    .step-num { min-width: 24px; }

    /* --- BOTTOM PANEL: static flow (not fixed) --- */
    .bottom-panel {
        position: static;
        left: auto;
        right: auto;
        max-width: none;
        box-shadow: none;
        flex-direction: column;
    }
    .pads-area {
        flex: 0 0 auto;
        padding: 10px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .panel-title .hint { display: none; }
    .pads-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        max-width: 380px;
        margin: 0 auto;
    }
    .pad { border-radius: 10px; min-height: 54px; }

    /* FX area */
    .fx-area {
        flex: 0 0 auto;
        padding: 10px;
        min-width: 0;
    }
    .fx-header { gap: 4px; margin-bottom: 6px; }
    .fx-preset-bar { flex-wrap: wrap; gap: 3px; }
    .fx-rack {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .fx-unit { min-width: 0; padding: 6px 8px; }
    .knob { width: 36px; }

    /* --- FOOTER: static --- */
    .footer-bar {
        position: static;
        left: auto;
        right: auto;
        max-width: none;
        padding: 8px 10px;
        gap: 6px;
    }
    .file-actions { flex-wrap: wrap; gap: 4px; }
    .act-btn { height: 34px; padding: 0 14px; font-size: .55rem; }
    .credits { font-size: .5rem; }
}

/* =============================================
   SMALL MOBILE (max 480px)
   ============================================= */
@media (max-width: 480px) {
    html { font-size: 11px; }

    .top-bar { padding: 4px 6px; }
    .logo-text { font-size: .75rem; letter-spacing: 2px; }
    .logo-img { width: 20px; height: 20px; }

    /* Bigger transport for thumb */
    .transport-btn { width: 42px; height: 42px; }
    .transport-btn .icon { width: 18px; height: 18px; }

    .top-center { gap: 8px; }

    .viz-section { height: 40px; }
    .pattern-bar { padding: 4px 6px; gap: 8px; }

    /* Sequencer: compact track info */
    .seq-grid { padding: 0 3px; }
    .track-info { width: 56px; min-width: 56px; }
    .track-label { font-size: .5rem; letter-spacing: 0; min-width: 20px; }
    .mute-btn, .solo-btn { width: 14px; height: 14px; font-size: .4rem; }
    .header-steps { width: 56px; min-width: 56px; }
    .step { min-width: 22px; }
    .step-num { min-width: 22px; }

    /* Pads: centered, generous tap targets */
    .pads-area { padding: 8px 6px; }
    .pads-grid {
        gap: 5px;
        max-width: 320px;
    }
    .pad { min-height: 50px; border-radius: 8px; }
    .pad .pad-name { font-size: .5rem; }
    .pad .pad-key { font-size: .4rem; }

    /* FX: tighter */
    .fx-area { padding: 8px 6px; }
    .fx-rack { gap: 4px; }
    .fx-unit { padding: 5px 6px; }
    .knob-row { gap: 4px; }
    .knob { width: 30px; }

    /* Footer: full-width buttons */
    .footer-bar { padding: 6px; }
    .file-actions { width: 100%; justify-content: space-between; }
    .act-btn { flex: 1; text-align: center; min-width: 0; height: 36px; }
    .status { flex: 0 0 100%; text-align: center; order: 3; }
}

/* =============================================
   MIDI PANEL
   ============================================= */
.midi-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
}
.midi-overlay.open { display: flex; }

.midi-panel {
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: 12px;
    width: 420px;
    max-width: 94vw;
    max-height: 88vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

.midi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.midi-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--accent);
}
.midi-close {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .1s;
}
.midi-close:hover { background: var(--accent); color: var(--accent-inv); }

.midi-status {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text2);
    padding: 6px 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 14px;
    text-align: center;
}
.midi-status.ok { color: #4c4; border-color: #4c4; }
.midi-status.err { color: var(--red); border-color: var(--red); }

.midi-section {
    margin-bottom: 14px;
    padding: 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.midi-section h4 {
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text2);
    margin-bottom: 8px;
}
.midi-hint {
    font-weight: 500;
    color: var(--text3);
    letter-spacing: 0;
}

.midi-sel {
    width: 100%;
    margin-bottom: 8px;
}
.midi-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .6rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: .5px;
    cursor: pointer;
}
.midi-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px; height: 14px;
    cursor: pointer;
}

.midi-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.midi-row label {
    font-size: .55rem;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: 1px;
}
.midi-ch-sel { width: 60px; }

.midi-map {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.midi-map-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 3px 6px;
    background: var(--panel);
    border-radius: 4px;
}
.midi-map-row .map-label {
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
}
.midi-map-row input {
    width: 42px;
    height: 22px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
    text-align: center;
    font-family: inherit;
    font-size: .65rem;
    font-weight: 700;
    outline: none;
}
.midi-map-row input:focus { border-color: var(--accent); }

.midi-monitor {
    font-family: 'Courier New', monospace;
    font-size: .55rem;
    color: var(--text2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    min-height: 48px;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.6;
    white-space: pre-wrap;
}

.midi-refresh-btn {
    width: 100%;
    margin-top: 4px;
    text-align: center;
}

#btn-midi.midi-active {
    background: var(--accent);
    color: var(--accent-inv);
    border-color: var(--accent);
}
