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

body {
    overflow: hidden;
    background: #040410;
    font-family: 'Consolas', 'Courier New', monospace;
    color: #e8e8f0;
}

#fractal-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

#fps-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    font-size: 13px;
    font-family: 'Consolas', 'Courier New', monospace;
    color: #667788;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.2);
    pointer-events: none;
    z-index: 100;
    letter-spacing: 1px;
}

/* --- Control Panel --- */

#control-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: rgba(8, 8, 26, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(0, 180, 200, 0.2);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.panel-header {
    padding: 18px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(0, 180, 200, 0.2);
    flex-shrink: 0;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #00ffff;
    text-shadow:
        0 0 10px rgba(0, 255, 255, 0.8),
        0 0 30px rgba(0, 255, 255, 0.5),
        0 0 60px rgba(0, 255, 255, 0.3);
    animation: title-pulse 3s ease-in-out infinite;
    text-transform: uppercase;
}

@keyframes title-pulse {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(0, 255, 255, 0.8),
            0 0 30px rgba(0, 255, 255, 0.5),
            0 0 60px rgba(0, 255, 255, 0.3);
    }
    50% {
        text-shadow:
            0 0 15px rgba(0, 255, 255, 1),
            0 0 40px rgba(0, 255, 255, 0.7),
            0 0 80px rgba(0, 255, 255, 0.4),
            0 0 120px rgba(0, 255, 255, 0.2);
    }
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}

.panel-scroll::-webkit-scrollbar { width: 5px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.15);
    border-radius: 3px;
}
.panel-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.3);
}

/* Toggle button */
#panel-toggle {
    position: fixed;
    top: 50%;
    left: 320px;
    transform: translateY(-50%);
    z-index: 51;
    background: rgba(8, 8, 26, 0.88);
    border: 1px solid rgba(0, 180, 200, 0.2);
    border-left: none;
    color: #667788;
    font-size: 14px;
    font-family: 'Consolas', 'Courier New', monospace;
    padding: 8px 5px;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    transition: left 0.3s ease, background 0.2s, color 0.2s, box-shadow 0.2s;
}

#panel-toggle:hover {
    background: rgba(0, 255, 255, 0.06);
    color: #00ffff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

/* Sections */
.section {
    border-bottom: 1px solid #1a2233;
}

.section-header {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #667788;
    user-select: none;
    transition: color 0.2s, text-shadow 0.2s;
}

.section-header:hover {
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

.section-arrow { font-size: 10px; display: inline-block; width: 14px; }
.section-body { padding: 4px 16px 12px; }

/* Controls */
.control-row { margin-bottom: 10px; }
.control-row label {
    display: block;
    font-size: 11px;
    color: #88aacc;
    margin-bottom: 3px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.slider-value {
    float: right;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #1a2233;
    border-radius: 3px;
    outline: none;
    margin-top: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    background: #00ffff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px rgba(0, 255, 255, 0.5);
    transition: box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.8);
}

input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px;
    background: #00ffff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px rgba(0, 255, 255, 0.5);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: #1a2233;
    border-radius: 3px;
    border: none;
}

/* Select */
.control-select {
    width: 100%;
    padding: 6px 8px;
    background: #10102a;
    border: 1px solid #334455;
    border-radius: 3px;
    color: #aaccff;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 1px;
    outline: none;
    cursor: pointer;
    margin-top: 2px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.control-select:focus {
    border-color: #00ffff;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.2);
}

.control-select option {
    background: #0c0c22;
    color: #aaccff;
}

/* Buttons */
.control-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(0, 255, 255, 0.03);
    border: 1px solid #445566;
    border-radius: 3px;
    color: #88aacc;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(0, 255, 255, 0.08);
    border-color: #00ffff;
    color: #00ffff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
    transform: scale(1.03);
}

.control-btn:active {
    transform: scale(0.98);
}

.control-btn.active {
    background: rgba(0, 255, 255, 0.06);
    border-color: #00ffff;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.15),
                inset 0 0 8px rgba(0, 255, 255, 0.05);
}

/* Mic button special */
.mic-btn {
    font-size: 14px;
    font-weight: 700;
    padding: 14px 16px;
    text-align: center;
    letter-spacing: 2px;
    background: rgba(0, 255, 255, 0.06);
    border: 2px solid rgba(0, 255, 255, 0.35);
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.15),
                inset 0 0 8px rgba(0, 255, 255, 0.05);
    animation: ready-pulse 1.5s ease-in-out infinite alternate;
}

.mic-btn:hover {
    background: rgba(0, 255, 255, 0.15);
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3),
                inset 0 0 15px rgba(0, 255, 255, 0.1);
}

.mic-btn.active {
    background: rgba(0, 255, 136, 0.06);
    border-color: #00ff88;
    color: #00ff88;
    text-shadow: 0 0 6px rgba(0, 255, 136, 0.4);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.15),
                inset 0 0 8px rgba(0, 255, 136, 0.05);
    animation: none;
}

@keyframes ready-pulse {
    0%   { border-color: rgba(0, 255, 255, 0.35); }
    100% { border-color: rgba(0, 255, 255, 0.8);
           box-shadow: 0 0 12px rgba(0, 255, 255, 0.2); }
}

.mic-status {
    font-size: 11px;
    color: #667788;
    margin-top: 6px;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Fractal type button group */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.fractal-btn {
    flex: 1 1 auto;
    min-width: 80px;
    padding: 6px 8px;
    background: rgba(0, 255, 255, 0.03);
    border: 1px solid #334455;
    border-radius: 3px;
    color: #667788;
    font-size: 10px;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fractal-btn:hover {
    background: rgba(0, 255, 255, 0.08);
    color: #00ffff;
    border-color: rgba(0, 255, 255, 0.4);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.3);
}

.fractal-btn.active {
    background: rgba(0, 255, 255, 0.06);
    border-color: #00ffff;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.15);
}

/* Palette preview */
.palette-preview {
    width: 100%;
    height: 16px;
    border-radius: 3px;
    margin: 6px 0;
    border: 1px solid rgba(0, 180, 200, 0.2);
    image-rendering: pixelated;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.1);
}

/* Audio meters */
.audio-meters { margin-top: 4px; }

.meter-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.meter-label {
    font-size: 10px;
    color: #667788;
    width: 55px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.meter-bar-container {
    flex: 1;
    height: 6px;
    background: #1a2233;
    border-radius: 3px;
    overflow: hidden;
}

.meter-bar {
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #00ff88, #ffd700, #ff3333);
    border-radius: 3px;
    transition: width 0.05s linear;
    will-change: width;
}

/* Beat indicators */
.beat-indicators {
    display: flex;
    justify-content: space-around;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #1a2233;
}

.beat-dot-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.beat-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10102a;
    border: 1px solid #334455;
    transition: background 0.05s, box-shadow 0.05s;
}

.beat-dot.active {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88, 0 0 16px rgba(0, 255, 136, 0.4);
}

.beat-dot-label {
    font-size: 9px;
    color: #667788;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Consolas', 'Courier New', monospace;
}

/* Fractal params */
.fractal-params {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #1a2233;
}

/* Number inputs */
input[type="number"] {
    font-family: 'Consolas', 'Courier New', monospace;
    background: #10102a;
    border: 1px solid #334455;
    color: #aaccff;
    border-radius: 3px;
    padding: 4px;
    font-size: 12px;
}

input[type="number"]:focus {
    border-color: #00ffff;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.2);
    outline: none;
}

/* Checkboxes */
input[type="checkbox"] {
    accent-color: #00ffff;
}
