/* CSS Variables */
:root {
    --bg-dark: #0a0e1a;
    --bg-card: rgba(20, 28, 48, 0.95);
    --bg-card-inner: rgba(15, 22, 40, 0.8);
    --border-color: rgba(100, 120, 180, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --accent-yellow: #f5a623;
    --accent-purple: #7c3aed;
    --btn-primary: #10b981;
    --btn-secondary: #374151;
    --btn-super: #f59e0b;
    --slider-track: #374151;
    --slider-thumb: #f5a623;
}

/* Light Theme */
[data-theme="light"] {
    --bg-dark: #f0f4f8;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-inner: rgba(240, 244, 248, 0.9);
    --border-color: rgba(100, 120, 180, 0.2);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --slider-track: #cbd5e0;
}

[data-theme="light"] body {
    background: #e2e8f0;
}

[data-theme="light"] .background-layer::after {
    background: linear-gradient(135deg, rgba(240, 244, 248, 0.9) 0%, rgba(226, 232, 240, 0.9) 100%);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0a0e1a;
    min-height: 100vh;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

/* Background Layer */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    cursor: pointer;
    overflow: hidden;
}

.background-layer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(10, 14, 26, 0.85) 0%, rgba(13, 21, 37, 0.85) 50%, rgba(17, 24, 39, 0.85) 100%);
    pointer-events: none;
}

.bg-image,
.bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
}

.bg-video {
    z-index: 1;
}

.bg-image {
    z-index: 0;
}

.hidden {
    display: none !important;
}

.fullscreen-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

/* Container */
.container {
    width: 100%;
    max-width: 1100px;
    position: relative;
    z-index: 10;
}

/* Card */
.playground-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Header */
.playground-header {
    margin-bottom: 30px;
}

.playground-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.playground-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Content Grid */
.playground-content {
    display: grid;
    grid-template-columns: 200px 1fr 240px;
    gap: 30px;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.file-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-label {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-label:hover {
    background: rgba(30, 40, 65, 0.9);
}

.file-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Recording */
.recording-section {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-record {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 10px 16px;
}

.btn-record:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
}

.btn-record.recording {
    animation: pulse-record 1s infinite;
}

@keyframes pulse-record {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

.btn-record-stop {
    background: var(--btn-secondary);
    color: white;
}

.btn-record-stop:hover:not(:disabled) {
    background: #4b5563;
}

.btn-record-stop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.recording-status {
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 500;
}

.playback-controls {
    display: flex;
    gap: 16px;
}

/* Seek Bar */
.seek-section {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 8px;
}

.time-display {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

.time-display span:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.seek-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
}

.seek-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--btn-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.seek-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--btn-primary);
    cursor: pointer;
    border: none;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-primary {
    background: var(--btn-primary);
    color: white;
}

.btn-primary:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--btn-secondary);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-super {
    background: var(--btn-super);
    color: #1a1a2e;
    font-weight: 600;
}

.btn-super:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-preset {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-preset:hover {
    background: rgba(30, 40, 65, 0.9);
    border-color: var(--accent-yellow);
}

.btn-preset.active {
    border-color: var(--accent-yellow);
    background: rgba(245, 166, 35, 0.1);
}

.presets-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* Equalizer Panel */
.equalizer-panel {
    padding: 0 20px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.eq-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
}

.eq-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.eq-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.eq-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Preamp */
.preamp-section {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.preamp-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.preamp-label span:first-child {
    font-weight: 500;
}

.preamp-value {
    color: var(--accent-purple);
    font-weight: 600;
}

.preamp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--slider-track) 0%, var(--slider-track) 50%, var(--slider-track) 100%);
    outline: none;
    cursor: pointer;
}

.preamp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5);
    transition: transform 0.15s ease;
}

.preamp-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.preamp-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5);
}

.eq-sliders {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.eq-row {
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

.eq-band {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.freq-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Equalizer Sliders */
.eq-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
}

.eq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--slider-thumb);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(245, 166, 35, 0.4);
    transition: transform 0.15s ease;
}

.eq-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.eq-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--slider-thumb);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(245, 166, 35, 0.4);
}

/* Effects Row */
.effects-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn-effect {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-effect:hover {
    background: rgba(30, 40, 65, 0.9);
    border-color: var(--accent-purple);
}

.btn-effect.active {
    border-color: var(--accent-purple);
    background: rgba(124, 58, 237, 0.15);
}

/* Frequency Panel */
.frequency-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.frequency-panel h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.frequency-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.freq-slider-container {
    position: relative;
}

.freq-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
}

.freq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4);
}

.freq-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    border: none;
}

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

.freq-input-row input {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100px;
}

.freq-input-row input:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.freq-input-row span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.freq-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.btn-action {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
}

.btn-action:hover {
    background: rgba(30, 40, 65, 0.9);
    border-color: var(--accent-yellow);
}

/* Responsive */
@media (max-width: 900px) {
    .playground-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .equalizer-panel {
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        padding: 24px 0;
    }

    .playback-controls {
        flex-direction: column;
    }
}

@media (max-width: 500px) {
    .playground-card {
        padding: 20px;
    }

    .eq-row {
        flex-wrap: wrap;
    }

    .eq-band {
        min-width: 60px;
    }

    .effects-row {
        justify-content: center;
    }
}

/* Soundboard */
.soundboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-top: 20px;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.soundboard-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.soundboard-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 16px;
}

.soundboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.sound-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    padding: 16px 12px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.sound-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.sound-btn:active {
    transform: translateY(-1px);
}

.sound-btn:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.sound-btn:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.sound-btn:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
}

.sound-btn:nth-child(5) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.3);
}

.sound-btn:nth-child(6) {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
    box-shadow: 0 4px 15px rgba(168, 237, 234, 0.3);
}

.sound-btn:nth-child(7) {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 154, 158, 0.3);
}

.sound-btn.playing {
    animation: pulse-sound 0.5s ease;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.8);
}

@keyframes pulse-sound {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

/* ==================== NEW FEATURES STYLES ==================== */

/* Header Enhancements */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.header-actions {
    display: flex;
    gap: 16px;
}

.btn-theme,
.btn-share {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-theme:hover,
.btn-share:hover {
    background: rgba(30, 40, 65, 0.9);
    border-color: var(--accent-purple);
}

.keyboard-hints {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.keyboard-hints span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

kbd {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-family: inherit;
    color: var(--accent-yellow);
}

/* Control Row (Speed, Pitch) */
.control-row {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.control-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.control-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    /* Reduced touch target height slightly to match visual */
    border-radius: 3px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
    min-width: 100px;
    /* Ensure it never collapses to 0 */
}

.control-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
}

.control-value {
    font-size: 0.8rem;
    color: var(--accent-purple);
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* Fade Controls */
.fade-controls {
    display: flex;
    gap: 24px;
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-purple);
    width: 16px;
    height: 16px;
}

/* Visualizer */
.visualizer-section {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.visualizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.visualizer-header span {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.visualizer-toggle {
    display: flex;
    gap: 4px;
}

.btn-vis-mode {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-vis-mode.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: white;
}

#visualizerCanvas {
    width: 100%;
    height: 80px;
    border-radius: 4px;
    background: rgba(10, 14, 26, 0.8);
}

/* Soundboard Enhancements */
.soundboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.soundboard-actions {
    display: flex;
    gap: 16px;
}

.btn-stop-all {
    background: #ef4444;
    color: white;
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-stop-all:hover {
    background: #dc2626;
}

.btn-add-sound {
    background: var(--btn-primary);
    color: white;
    padding: 8px 14px;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-add-sound:hover {
    background: #059669;
}

.sound-btn.custom-sound {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.soundboard-subtitle kbd {
    margin-left: 4px;
}

/* Export Card */
.export-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    backdrop-filter: blur(20px);
    text-align: center;
}

.export-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.export-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-export {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Drag & Drop Overlay */
.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 26, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.drop-overlay.hidden {
    display: none;
}

.drop-message {
    font-size: 2rem;
    color: var(--accent-yellow);
    text-align: center;
    padding: 60px;
    border: 3px dashed var(--accent-yellow);
    border-radius: 20px;
    animation: pulse-drop 1.5s ease-in-out infinite;
}

@keyframes pulse-drop {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}