/* ============================================================================
   VoltMaster AI — Premium Dark Theme CSS
   ============================================================================ */

:root {
    --bg-primary: #08090D;
    --bg-secondary: #0E1017;
    --bg-card: #12141D;
    --bg-card-hover: #181B26;
    --bg-elevated: #1A1D29;
    --accent: #00FF88;
    --accent-secondary: #00E5FF;
    --accent-gradient: linear-gradient(135deg, #00FF88 0%, #00E5FF 100%);
    --text-primary: #E8EAED;
    --text-secondary: #9AA0A6;
    --text-muted: #5F6368;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(0, 255, 136, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 100px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 350ms cubic-bezier(0.16, 1, 0.3, 1);

    /* MudBlazor overrides */
    --mud-palette-primary: #00FF88;
    --mud-palette-background: #08090D;
    --mud-palette-surface: #12141D;
    --mud-palette-drawer-background: #12141D;
    --mud-palette-text-primary: #E8EAED;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ============================================================================
   MASTERING APP LAYOUT
   ============================================================================ */

.mastering-app {
    display: flex;
    height: 100%;
    width: 100%;
    background: var(--bg-primary);
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar-panel {
    width: 300px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    padding: 20px 16px;
    gap: 16px;
}

.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-footer {
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.export-options {
    margin-bottom: 8px;
    width: 100%;
}

.export-select {
    width: 100%;
    background: rgba(10, 11, 16, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #ddd;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
    appearance: none;
}

.export-select:hover, .export-select:focus {
    border-color: rgba(0, 255, 136, 0.3);
    background: rgba(10, 11, 16, 0.8);
}

.export-select option {
    background: #0A0B10;
    color: #fff;
    padding: 8px;
}

/* Song items */
.song-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
}

.song-item:hover { background: rgba(255, 255, 255, 0.04); }

.song-item.active {
    border-color: rgba(0, 255, 136, 0.2);
    background: rgba(0, 255, 136, 0.03);
}

.song-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
}

.song-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.song-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

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

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.icon-btn:hover { background: rgba(255,255,255,0.06); }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    flex: 1;
}

.empty-icon-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px dashed rgba(0,255,136,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-ring 3s ease-in-out infinite;
}

@keyframes pulse-ring {
    0%, 100% { transform: scale(1); border-color: rgba(0,255,136,0.1); }
    50% { transform: scale(1.05); border-color: rgba(0,255,136,0.25); }
}

/* Export button */
.export-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--accent-gradient);
    color: #0A0B10;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-glow);
}

.export-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 0 32px rgba(0, 255, 136, 0.25);
}

.export-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.export-btn.exporting {
    background: rgba(255,255,255,0.1);
    color: var(--text-secondary);
    box-shadow: none;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 32px;
    gap: 20px;
}

/* ── HEADER ── */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #0A0B10;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
}

.play-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(255,255,255,0.2);
}

.play-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.play-btn.playing {
    background: var(--accent);
    box-shadow: var(--shadow-glow);
    animation: play-pulse 2s infinite;
}

@keyframes play-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.5); }
    70% { box-shadow: 0 0 0 16px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

.track-info { display: flex; flex-direction: column; gap: 4px; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Custom Aesthetic Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 136, 0.2); border-radius: 10px; border: 2px solid var(--bg-primary); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 255, 136, 0.5); }

.track-title {
    font-size: 1.25rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
}

.meta-tag.genre {
    color: var(--accent);
    border-color: rgba(0,255,136,0.2);
    text-transform: capitalize;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.analyzing-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(0,255,136,0.06);
    border: 1px solid rgba(0,255,136,0.15);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--accent);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.preset-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border: 1px solid;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── WAVEFORM ── */
.waveform-section {
    position: relative;
    min-height: 180px;
}

.upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(0,255,136,0.02) 0%, transparent 100%);
    border: 1px solid var(--border-subtle);
}

.waveform-container {
    height: 180px;
    position: relative;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(0,255,136,0.02) 0%, transparent 100%);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    z-index: 1;
}

.spectrum-canvas {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.55;
    mix-blend-mode: screen;
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    cursor: pointer;
    gap: 12px;
    transition: all var(--transition-normal);
    border: 2px dashed transparent;
    border-radius: var(--radius-lg);
    padding: 20px;
}

.upload-prompt:hover {
    background: rgba(0,255,136,0.03);
    border-color: rgba(0,255,136,0.15);
}

.upload-icon-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(0,255,136,0.06);
    border: 2px dashed rgba(0,255,136,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
}

.upload-prompt:hover .upload-icon-ring {
    background: rgba(0,255,136,0.1);
    border-color: rgba(0,255,136,0.4);
    transform: scale(1.08);
}

.upload-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── CONTROLS BAR ── */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.ab-toggle-group {
    display: flex;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-pill);
    padding: 3px;
    gap: 2px;
}

.ab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.ab-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }

.ab-btn.active {
    background: white;
    color: #0A0B10;
    box-shadow: var(--shadow-sm);
}

.intensity-control, .de-noise-control {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 65px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.slider-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
}

/* Custom range slider */
.intensity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(255,255,255,0.08) 100%);
    outline: none;
    cursor: pointer;
}

.intensity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px rgba(0,255,136,0.3);
    cursor: grab;
    transition: all var(--transition-fast);
}

.intensity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(0,255,136,0.5);
}

.intensity-slider.denoise {
    background: linear-gradient(90deg, #06B6D4 0%, rgba(255,255,255,0.08) 100%);
}

.intensity-slider.denoise::-webkit-slider-thumb {
    border-color: #06B6D4;
    box-shadow: 0 0 8px rgba(6,182,212,0.3);
}

/* ── CONTENT GRID ── */
.content-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 24px;
    min-height: 0;
}

/* ── PRESETS ── */
.presets-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.preset-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-normal);
    overflow: hidden;
    min-height: 130px;
}

.preset-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preset-card.selected {
    border-color: var(--preset-color, var(--accent));
    background: color-mix(in srgb, var(--preset-color, var(--accent)) 6%, var(--bg-card));
    box-shadow: 0 0 24px color-mix(in srgb, var(--preset-color, var(--accent)) 15%, transparent);
}

.preset-glow {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    filter: blur(30px);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.preset-card.selected .preset-glow,
.preset-card:hover .preset-glow {
    opacity: 0.15;
}

.preset-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.preset-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
}

.preset-lufs {
    font-size: 0.6rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
}

/* ── MANUAL CONTROLS ── */
.manual-section {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    overflow: hidden;
}

.manual-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.manual-toggle:hover { background: rgba(255,255,255,0.02); }

.manual-toggle-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
}

.manual-controls {
    padding: 4px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 250ms ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.control-group {
    display: grid;
    grid-template-columns: 130px 1fr 55px;
    align-items: center;
    gap: 12px;
}

.cg-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.cg-value {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 700;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.control-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* EQ slider */
.eq-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.08);
    outline: none;
    cursor: pointer;
}

.eq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid rgba(0,0,0,0.3);
    cursor: grab;
    transition: all var(--transition-fast);
}

.eq-slider.comp::-webkit-slider-thumb {
    background: #F59E0B;
}

/* ── REPORT ── */
.report-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 280px;
    overflow-y: auto;
    max-height: 400px;
}

.report-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

.pulse-rings {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring {
    position: absolute;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: ring-pulse 2s ease-out infinite;
}

.ring-1 { width: 40px; height: 40px; animation-delay: 0s; }
.ring-2 { width: 60px; height: 60px; animation-delay: 0.3s; }
.ring-3 { width: 80px; height: 80px; animation-delay: 0.6s; }

@keyframes ring-pulse {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}

.report-content {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.report-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.report-heading:first-child { margin-top: 0; }

.report-text {
    margin: 4px 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.6;
}

.report-bullet {
    margin: 3px 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding-left: 8px;
}

.report-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

/* ── METRICS GRID ── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.metric-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.metric-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Inter', monospace;
}

/* ============================================================================
   MUDBLAZOR OVERRIDES
   ============================================================================ */

.mud-paper { background-color: var(--bg-card) !important; }

.mud-button-filled.mud-button-filled-primary {
    background: var(--accent-gradient) !important;
    color: #0A0B10 !important;
    text-transform: none;
    font-weight: 700;
}

.mud-button-filled.mud-button-filled-primary:hover {
    filter: brightness(1.1);
}

/* Override MudLayout */
.mud-appbar {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-subtle);
}

.mud-drawer {
    background: var(--bg-secondary) !important;
}

.mud-main-content {
    padding: 0 !important;
    padding-top: 52px !important;
    margin-top: 0 !important;
    background: var(--bg-primary) !important;
    overflow: hidden !important;
    height: 100vh;
    box-sizing: border-box;
}

/* ============================================================================
   WAVEFORM OVERRIDES
   ============================================================================ */

#waveform wave { overflow: hidden !important; }

/* ============================================================================
   LOADING PROGRESS
   ============================================================================ */

.loading-progress {
    position: relative;
    display: block;
    width: 120px;
    height: 120px;
    margin: 30vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 4px;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 1.2), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

#blazor-error-ui {
    background: #b32121;
    color: white;
    bottom: 0;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    display: none;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 1200px) {
    .content-grid { grid-template-columns: 1fr; }
    .preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .sidebar-panel { width: 300px; min-width: 300px; }
    .preset-grid { grid-template-columns: repeat(2, 1fr); }
    .controls-bar { flex-wrap: wrap; justify-content: center; gap: 16px; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .mastering-app { 
        display: flex;
        flex-direction: column; 
    }
    
    .main-content {
        order: 1; /* MOVE TO TOP */
        padding: 12px;
        overflow-x: visible; /* Prevents preset clipping bugs */
    }

    .sidebar-panel {
        order: 2; /* MOVE TO BOTTOM */
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: none; /* Let it stretch */
        border-right: none;
        border-top: 1px solid var(--border-subtle);
        border-bottom: none;
        padding-top: 12px;
    }
    
    /* Hide unnecessary panels to save mobile screen real estate */
    .sidebar-section {
        display: none !important;
    }
    
    /* Safer 2-Column Grid for Presets to avoid disappearing bounds */
    .preset-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .preset-card {
        min-width: 100%;
        padding: 12px 8px;
    }
    
    .waveform-container { height: 110px; }
    
    .controls-bar {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .player-left, .player-right { width: 100%; justify-content: center; }
    
    .metrics-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
}