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

body {
    background: #000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: #fff;
    height: 100vh;
    width: 100vw;
}

/* ── Canvas ── */
#canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hidden { display: none !important; }

/* ── Upload Overlay ── */
#upload-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: radial-gradient(ellipse at center,
        rgba(28, 0, 58, 0.97) 0%,
        rgba(0, 0, 0, 0.99) 100%);
    transition: opacity 0.4s;
}

#upload-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 52px 68px;
    border: 1.5px dashed rgba(124, 58, 237, 0.35);
    border-radius: 20px;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
    max-width: 420px;
    width: 90%;
}

#drop-zone.dragover {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.08);
}

.upload-icon {
    font-size: 52px;
    line-height: 1;
    opacity: 0.55;
    margin-bottom: 2px;
}

#drop-zone h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: rgba(255, 255, 255, 0.9);
}

#drop-zone p {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.45);
}

.or-text {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.2) !important;
    letter-spacing: 0.06em;
    margin: -2px 0;
}

.upload-btn {
    display: inline-block;
    background: #7c3aed;
    color: #fff;
    padding: 10px 34px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background 0.2s, transform 0.1s;
    margin: 2px 0;
}

.upload-btn:hover  { background: #6d28d9; }
.upload-btn:active { transform: scale(0.97); }

.formats {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.18) !important;
    letter-spacing: 0.09em;
    margin-top: -4px;
}

/* ── Fractal Sensitivity Sliders ── */
#fractal-controls {
    position: fixed;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px 16px;
}

.fractal-slider label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.5);
    margin-bottom: 4px;
}

.slider-val {
    color: #a78bfa;
    min-width: 24px;
    text-align: right;
}

.fractal-slider input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 130px;
    height: 3px;
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.fractal-slider input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #7c3aed;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.fractal-slider input[type=range]::-webkit-slider-thumb:hover {
    background: #a855f7;
    transform: scale(1.2);
}

.fractal-slider input[type=range]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #7c3aed;
    border: none;
    cursor: pointer;
}

#mandelbrot-controls {
    position: fixed;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px 16px;
}

.mb-point-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

#mb-point-name {
    font-size: 11px;
    font-weight: 600;
    color: #a78bfa;
    text-align: center;
    flex: 1;
    letter-spacing: 0.03em;
}

.mb-nav-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(255,255,255,0.55);
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
}

.mb-nav-btn:hover {
    color: #a78bfa;
    border-color: rgba(167,139,250,0.5);
}

/* ── Viz Mode Buttons ── */
#viz-modes {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 6px;
    z-index: 50;
}

.viz-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.45);
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.2s;
    backdrop-filter: blur(12px);
}

.viz-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.85);
}

.viz-btn.active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

/* ── Bottom Controls ── */
#controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 66px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 18px;
    z-index: 50;
}

#song-info {
    flex: 0 0 180px;
    min-width: 0;
    overflow: hidden;
}

#song-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#transport {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

#play-pause-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
    transition: border-color 0.2s, background 0.2s;
}

#play-pause-btn.playing { padding-left: 0; }

#play-pause-btn:hover {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.2);
}

#time-current,
#time-total {
    flex-shrink: 0;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.38);
    letter-spacing: 0.04em;
}

#progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

#progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(to right, #6d28d9, #7c3aed);
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
    transition: background 0.2s;
}

#progress-bar:hover #progress-fill {
    background: linear-gradient(to right, #7c3aed, #a855f7);
}

#progress-input {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 24px;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

#right-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

#bpm-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 48px;
}

#bpm-value {
    font-size: 14px;
    font-weight: 600;
    color: #a78bfa;
    letter-spacing: -0.01em;
    transition: color 0.1s;
}

#bpm-display.beat #bpm-value {
    color: #fff;
}

#key-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 96px;
}

.key-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: rgba(167, 139, 250, 0.55);
}

#key-value {
    font-size: 14px;
    font-weight: 600;
    color: #a78bfa;
    letter-spacing: -0.01em;
    transition: color 0.3s;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.38);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.08);
}
