/* ── Base ─────────────────────────────────────────────────────────────────── */

body {
    background-color: #1a1a1a;
    color: #e0e0e0;
    font-family: 'Courier New', Courier, monospace;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

#desktop {
    width: 100vw;
    height: 100vh;
    background: #111;
    background-image: radial-gradient(#222 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    overflow: hidden;
}

/* ── Windows ──────────────────────────────────────────────────────────────── */

.window {
    position: absolute;
    background: #2a2a2a;
    border: 2px solid #4a3b2c;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    min-width: 140px;
    z-index: 10;
}

/* opacity+pointer-events preserves offsetLeft/offsetTop for future animation */
.window.minimized {
    opacity: 0;
    pointer-events: none;
}

.window-header {
    background: #4a3b2c;
    padding: 4px 8px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}

.window-title {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    color: #ffaa00;
    letter-spacing: 0.05em;
}

.window-controls { display: flex; gap: 4px; }

.win-btn {
    background: #222;
    border: 1px solid #111;
    color: #aaa;
    font-size: 8px;
    padding: 0 4px;
    cursor: pointer;
    line-height: 14px;
}
.win-btn:hover { background: #333; color: #fff; }

.window-content { padding: 8px; }

.module {
    background: #333;
    border: 1px solid #111;
    border-radius: 2px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

/* ── Controls ─────────────────────────────────────────────────────────────── */

.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 9px;
    gap: 2px;
}

.control-group label {
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.param-val {
    color: #ffaa00;
    font-size: 9px;
    min-width: 28px;
    text-align: center;
}

/* ── Range Inputs — webkit + moz ─────────────────────────────────────────── */

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 20px;
    background: transparent;
    margin: 4px 0;
    cursor: pointer;
}

input[type=range]:focus { outline: none; }

/* Webkit track */
input[type=range]::-webkit-slider-runnable-track {
    height: 5px;
    background: #111;
    border: 1px solid #555;
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
/* Webkit thumb */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 20px;
    margin-top: -8px;
    background: #ffaa00;
    border: 1px solid #000;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
    cursor: pointer;
}

/* Firefox track */
input[type=range]::-moz-range-track {
    height: 5px;
    background: #111;
    border: 1px solid #555;
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
/* Firefox thumb */
input[type=range]::-moz-range-thumb {
    width: 13px;
    height: 20px;
    background: #ffaa00;
    border: 1px solid #000;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
    cursor: pointer;
}

/* ── Vertical Fader ───────────────────────────────────────────────────────── */

.vertical-fader-wrapper {
    width: 28px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.vertical-fader {
    width: 100px !important;
    transform: rotate(-90deg);
    margin: 0 !important;
}

/* ── Master / Transport layout ────────────────────────────────────────────── */

.master-controls {
    flex-direction: row;
    align-items: flex-end;
    gap: 18px;
    flex-wrap: nowrap;
}

.transport-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transport-buttons {
    display: flex;
    gap: 5px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

button {
    background: #3a3a3a;
    color: #ccc;
    border: 1px solid #222;
    padding: 4px 9px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 10px;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
button:hover  { background: #484848; color: #fff; }
button:active { background: #222; }

button.active-play { background: #005500; color: #00dd00; border-color: #007700; }
button.active-rec  { background: #660000; color: #ff4444; border-color: #880000; }
button.rec-active  {
    background: #cc0000;
    color: #fff;
    border-color: #ff0000;
    animation: blink 0.8s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Select ───────────────────────────────────────────────────────────────── */

select {
    background: #1a1a1a;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 3px 4px;
    font-size: 10px;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
}

#bpmValue {
    color: #ffaa00;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ── Oscilloscope ─────────────────────────────────────────────────────────── */

.oscilloscope-canvas {
    display: block;
    width: 280px;
    height: 100px;
    border: 1px solid #1a3a1a;
    border-radius: 2px;
    box-shadow: 0 0 12px rgba(0,255,68,0.08), inset 0 0 20px rgba(0,0,0,0.6);
    background: #000;
}

/* ── Drum Machine ─────────────────────────────────────────────────────────── */

.dm-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 0;
}

.dm-track {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dm-label {
    width: 46px;
    font-size: 9px;
    color: #888;
    text-align: right;
    padding-right: 4px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.dm-steps {
    display: flex;
    gap: 2px;
}

/* Step buttons — override the global button styles */
.dm-step {
    width: 21px;
    height: 21px;
    min-width: unset;
    padding: 0;
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0;   /* hide any text */
    transition: background 0.05s;
}
.dm-step:hover  { background: #2e2e2e; border-color: #555; }
.dm-step.on     { background: #cc4400; border-color: #ff6622; box-shadow: 0 0 6px rgba(255,80,0,0.5); }
.dm-step.on:hover { background: #dd5511; }
.dm-step.dm-current { outline: 2px solid #ffaa00; outline-offset: 1px; }

/* Beat number labels above the grid */
.dm-step-labels {
    display: flex;
    padding-left: 51px;
    gap: 2px;
    margin-bottom: 2px;
}
.dm-step-label {
    width: 21px;
    font-size: 8px;
    text-align: center;
    color: #444;
}
.dm-step-label.dm-beat { color: #666; font-weight: bold; }

.dm-hint {
    font-size: 8px;
    color: #444;
    text-align: center;
    margin-top: 6px;
    letter-spacing: 0.03em;
}

/* ── Virtual Keyboard ─────────────────────────────────────────────────────── */

#keyboard {
    height: 90px;
    background: #111;
    padding: 5px 5px 0;
    border-radius: 3px 3px 0 0;
}

.key {
    width: 28px;
    height: 100%;
    background: linear-gradient(to bottom, #e8e8e8, #fff);
    border: 1px solid #999;
    border-top: none;
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: background 0.04s;
}
.key.black {
    width: 17px;
    height: 60%;
    background: linear-gradient(to bottom, #222, #000);
    position: absolute;
    z-index: 2;
    border-radius: 0 0 3px 3px;
    border-color: #000;
}
.key.active       { background: #ffaa00; }
.key.black.active { background: #cc8800; }

/* Key shortcut labels beneath white keys */
.kb-labels {
    position: relative;
    height: 14px;
    background: #0a0a0a;
    border-radius: 0 0 3px 3px;
}
.kb-key-label {
    position: absolute;
    font-size: 8px;
    color: #555;
    pointer-events: none;
    top: 2px;
}

/* ── Recorder ─────────────────────────────────────────────────────────────── */

.rec-ui {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 190px;
}

.rec-controls {
    display: flex;
    align-items: center;
    gap: 7px;
}

.rec-timer {
    color: #ffaa00;
    font-size: 14px;
    font-weight: bold;
    min-width: 40px;
    letter-spacing: 0.05em;
}

.rec-download {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a2a1a;
    border: 1px solid #2a5a2a;
    color: #00cc44;
    font-size: 10px;
    font-family: 'Courier New', Courier, monospace;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 2px;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.1s;
}
.rec-download:hover { background: #243424; color: #00ff55; }

.rec-hint {
    font-size: 8px;
    color: #444;
    letter-spacing: 0.03em;
}

/* ── Slice Sampler ────────────────────────────────────────────────────────── */

.slice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e1e1e;
    padding: 5px 6px;
    border-radius: 2px;
    margin-bottom: 3px;
}

.slice-id {
    font-size: 10px;
    color: #ffaa00;
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}

.slice-btn {
    font-size: 8px;
    padding: 2px 5px;
    min-width: 34px;
}

/* ── Taskbar ──────────────────────────────────────────────────────────────── */

#taskbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 28px;
    background: #1a1a1a;
    border-top: 2px solid #4a3b2c;
    display: flex;
    gap: 4px;
    padding: 0 6px;
    align-items: center;
    z-index: 1000;
}

.taskbar-item {
    background: #2e2e2e;
    border: 1px solid #4a3b2c;
    color: #888;
    font-size: 9px;
    padding: 2px 8px;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.04em;
    border-radius: 1px;
}
.taskbar-item:hover { background: #3a3a3a; color: #ddd; }
