:root {
    --bg-dark: #0f111a;
    --bg-panel: rgba(25, 27, 40, 0.7);
    --bg-card: rgba(30, 32, 48, 0.6);
    --primary-neon: #a855f7;       /* Purple neon */
    --primary-glow: rgba(168, 85, 247, 0.4);
    --secondary-neon: #4ade80;     /* Emerald green */
    --secondary-glow: rgba(74, 222, 128, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-light: rgba(168, 85, 247, 0.2);
    --border-strong: rgba(168, 85, 247, 0.5);
    --glass-blur: blur(16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(168,85,247,0.1) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(74,222,128,0.05) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 40px;
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 40px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-neon) 0%, #6366f1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 0 15px var(--primary-glow);
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.logo-text span {
    color: var(--text-secondary);
}

/* Stage Containers */
.stage-container {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
    flex: 1;
}

.stage-container.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================================= */
/* STAGE 1: INITIALIZATION (DROP ZONE)                       */
/* ========================================================= */

#stage-1.active {
    display: block;
}

.stage-1-layout {
    display: flex;
    height: 75vh;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.05);
    margin-top: 10px;
}

@media (max-width: 900px) {
    .stage-1-layout {
        flex-direction: column;
        height: auto;
        min-height: 80vh;
    }
    
    .fx-rack-pane {
        border-right: none !important;
        border-bottom: 2px solid #000;
        min-height: 250px;
    }
    
    #uploadZone {
        min-height: 400px;
    }
    
    .vortex-container {
        transform: scale(0.8);
    }
}

/* Ensure uploadZone always renders as a centered flex column.
   mix-cloud.js calls  uploadZone.style.display = ''  on init which
   clears the inline display, so this CSS fallback keeps it centered.
   Setting display:none via inline style still overrides this (for
   the stage-1→stage-2 transition). */
#uploadZone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 1;
}

.vortex-container {
    position: relative;
    width: 400px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.vortex-ring-1, .vortex-ring-2, .vortex-ring-3 {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    animation: spin linear infinite;
    pointer-events: none;
}

.vortex-ring-1 { width: 100%; height: 100%; animation-duration: 20s; border-top-color: var(--primary-neon); }
.vortex-ring-2 { width: 80%; height: 80%; animation-duration: 15s; animation-direction: reverse; border-right-color: var(--primary-neon); }
.vortex-ring-3 { width: 60%; height: 60%; animation-duration: 10s; border-bottom-color: var(--primary-neon); box-shadow: inset 0 0 20px var(--primary-glow); }

@keyframes spin { 100% { transform: rotate(360deg); } }

.floating-icon {
    animation: suckIntoVortex 4s ease-in infinite;
}

@keyframes suckIntoVortex {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0; }
    10% { opacity: 0.6; }
    80% { transform: translate(60px, 30px) scale(0.6) rotate(180deg); opacity: 0.8; }
    100% { transform: translate(120px, 60px) scale(0) rotate(360deg); opacity: 0; }
}

.drop-content {
    text-align: center;
    z-index: 10;
}

.drop-icon {
    font-size: 3rem;
    color: var(--primary-neon);
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.drop-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

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

.vortex-container.drag-over .vortex-ring-3 {
    background: rgba(168, 85, 247, 0.1);
    box-shadow: inset 0 0 40px var(--primary-glow);
    border-color: var(--primary-neon);
}

/* ========================================================= */
/* STAGE 2: METADATA TAGGING                                 */
/* ========================================================= */
.tagging-layout {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 40px;
    min-height: 600px;
    align-items: start;
}

.track-list-column {
    background: var(--bg-panel);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: var(--glass-blur);
}

.track-list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.track-list-item:hover {
    background: rgba(255,255,255,0.03);
}

.track-checkbox {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-secondary);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}
.track-checkbox:checked {
    background: var(--primary-neon);
    border-color: var(--primary-neon);
}

.track-waveform {
    width: 60px;
    height: 24px;
    opacity: 0.5;
}

/* Glassmorphic Bulk Tag Toolbar */
.glass-toolbar {
    display: flex;
    gap: 15px;
    padding: 15px 25px;
    background: rgba(15, 17, 26, 0.85);
    border-radius: 20px;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), inset 0 0 20px rgba(168, 85, 247, 0.1);
    backdrop-filter: blur(24px);
    z-index: 100;
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-width: 80px;
}

.toolbar-btn i {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
}

.toolbar-btn span {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.toolbar-btn:hover {
    color: var(--primary-neon);
    background: rgba(168, 85, 247, 0.1);
}

.toolbar-btn:hover i {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.toolbar-btn:active {
    transform: scale(0.95);
}

@media (max-width: 900px) {
    .glass-toolbar {
        width: 95%;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 10px;
        bottom: 10px;
    }
    .toolbar-btn {
        min-width: 70px;
    }
}

.central-analysis {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    overflow-y: auto;
}

.analysis-ring {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-neon) 0%, var(--primary-neon) 71%, transparent 71%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px var(--primary-glow);
}
.analysis-ring::before {
    content: '';
    position: absolute;
    width: 270px;
    height: 270px;
    background: var(--bg-dark);
    border-radius: 50%;
}

.analysis-text {
    position: relative;
    z-index: 5;
    text-align: center;
}
.analysis-number {
    font-size: 3rem;
    font-weight: bold;
    color: #fff;
}
.analysis-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Modal for Bulk Tag */
.bulk-tag-modal {
    background: rgba(30, 32, 48, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    position: absolute;
    top: 100px;
    right: 40px;
    width: 300px;
    z-index: 100;
}

.pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
}

.tag-pill {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.tag-pill:hover, .tag-pill.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--primary-neon);
    color: #fff;
}

/* ========================================================= */
/* STAGE 3: GENRE SONIC PROFILER                             */
/* ========================================================= */
.profiler-header {
    text-align: center;
    margin-bottom: 40px;
}

.profiler-header h1 {
    font-size: 2.5rem;
    font-weight: 500;
}

.genre-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 50px;
    position: relative;
}

/* Background Waveform for Profiler */
.genre-grid::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -10vw;
    right: -10vw;
    height: 200px;
    transform: translateY(-50%);
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 100 100"><path d="M0,50 Q25,20 50,50 T100,50" fill="none" stroke="rgba(168,85,247,0.3)" stroke-width="2"/></svg>') no-repeat center;
    background-size: 100% 100%;
    z-index: 0;
    pointer-events: none;
}

.genre-card {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    z-index: 1;
}

.genre-card:hover {
    border-color: var(--primary-neon);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 0 20px rgba(168,85,247,0.1);
    transform: translateY(-5px);
}

/* Selected state — clearly distinct from hover */
.genre-card.active {
    border-color: var(--primary-neon);
    background: rgba(168,85,247,0.18);
    box-shadow: 0 0 0 2px var(--primary-neon), 0 10px 30px rgba(0,0,0,0.4), inset 0 0 30px rgba(168,85,247,0.2);
    transform: translateY(-4px);
}

.genre-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
    transition: color 0.3s;
    pointer-events: none;
}

.genre-card:hover .genre-icon, .genre-card.active .genre-icon {
    color: var(--primary-neon);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.genre-name {
    font-size: 1.1rem;
    letter-spacing: 1px;
    font-weight: 600;
}

.action-bar {
    text-align: center;
}

.btn-neon {
    background: linear-gradient(135deg, var(--primary-neon) 0%, #6366f1 100%);
    color: #fff;
    border: none;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 0 20px var(--primary-glow);
    transition: all 0.3s;
    letter-spacing: 1px;
}

.btn-neon:hover {
    box-shadow: 0 0 30px var(--primary-neon);
    transform: scale(1.05);
}

/* ========================================================= */
/* STAGE 4: COMMAND TERMINAL (MIX PIPELINE)                  */
/* ========================================================= */
.pipeline-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: calc(100vh - 120px);
}

.pipeline-tracker {
    display: flex;
    gap: 4px;
    background: transparent;
    border: none;
    overflow: visible;
    padding: 4px 0;
}

.pipeline-step {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.1px;
    color: rgba(var(--sc, 168,85,247), 0.5);
    background: rgba(var(--sc, 168,85,247), 0.07);
    border-radius: 6px;
    transition: all 0.5s ease;
    /* NO BORDER — clean glass rectangles */
}

.pipeline-step.active {
    background: rgba(var(--sc, 168,85,247), 0.30);
    color: #fff;
    animation: stageGlow 1.4s ease-in-out infinite;
}

.pipeline-step.complete {
    background: rgba(74, 222, 128, 0.14);
    color: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.25);
}

@keyframes stageGlow {
    0%, 100% {
        box-shadow: 0 0 22px rgba(var(--sc, 168,85,247), 0.65),
                    inset 0 0 14px rgba(var(--sc, 168,85,247), 0.20);
        background: rgba(var(--sc, 168,85,247), 0.30);
    }
    50% {
        box-shadow: 0 0 50px rgba(var(--sc, 168,85,247), 1.0),
                    inset 0 0 28px rgba(var(--sc, 168,85,247), 0.45);
        background: rgba(var(--sc, 168,85,247), 0.52);
    }
}

/* Active stage description bar */
.stage-desc {
    text-align: center;
    font-size: 0.78rem;
    color: rgba(168,85,247,0.85);
    letter-spacing: 0.5px;
    font-style: italic;
    min-height: 18px;
    padding: 4px 0 6px;
    transition: all 0.4s ease;
}

/* Always hide legacy progress section */
#progressSection { display: none !important; }

.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

.panel {
    background: #111520; /* Darker UI background like photo */
    border: 1px solid #23283E;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}

.panel-header {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.spectrogram-container {
    flex: 1;
    min-height: 250px;
    background: #000;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    /* Create an animated flowing spectrogram-like background */
    background: linear-gradient(90deg, #101525, #1E1235, #0B2533, #152B1E, #101525);
    background-size: 400% 400%;
    animation: flowSpectrogram 8s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}
@keyframes flowSpectrogram {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
/* Adding fake waveform bars */
.spectrogram-container::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 80%;
    background: repeating-linear-gradient(90deg, 
        rgba(168, 85, 247, 0.4) 0px, rgba(168, 85, 247, 0.4) 4px, 
        transparent 5px, transparent 10px,
        rgba(74, 222, 128, 0.5) 10px, rgba(74, 222, 128, 0.5) 14px,
        transparent 15px, transparent 20px
    );
    opacity: 0.5;
    mask-image: linear-gradient(to top, rgba(0,0,0,1), transparent);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1), transparent);
}

.vectorscope-container {
    flex: 1;
    min-height: 250px;
    background: #000;
    border-radius: 4px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vectorscope grid */
.vectorscope-container::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}
.vectorscope-container::after {
    content: '';
    position: absolute;
    width: 2px; height: 100%; background: rgba(255,255,255,0.1);
}

.vectorscope-line {
    width: 60%;
    height: 60%;
    border: 2px solid var(--secondary-neon);
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    animation: morphScope 4s linear infinite alternate;
    box-shadow: 0 0 15px var(--secondary-neon), inset 0 0 10px var(--primary-neon);
    position: relative;
    z-index: 2;
}
@keyframes morphScope {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; border-color: var(--secondary-neon); transform: rotate(0deg); }
    100% { border-radius: 60% 40% 30% 70% / 60% 50% 40% 50%; border-color: var(--primary-neon); transform: rotate(360deg); }
}

.terminal-bottom {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

/* ── Untagged track indicators ─────────────────────────────────────── */
.track-list-item.untagged {
    border-left: 3px solid #eab308;
    background: rgba(234,179,8,0.05);
    border-radius: 6px;
    animation: rowPulse 1s ease-in-out infinite;
}

.tag-badge-untagged {
    background: rgba(234,179,8,0.15) !important;
    border: 1px solid rgba(234,179,8,0.8) !important;
    color: #eab308 !important;
    animation: untaggedBlink 0.9s ease-in-out infinite;
}

@keyframes untaggedBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.15; }
}

@keyframes rowPulse {
    0%, 100% { background: rgba(234,179,8,0.06); border-left-color: #eab308; }
    50%       { background: rgba(234,179,8,0.14); border-left-color: rgba(234,179,8,0.45); }
}

@keyframes shakeRow {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-6px); }
    40%     { transform: translateX(6px); }
    60%     { transform: translateX(-4px); }
    80%     { transform: translateX(4px); }
}

/* ─────────────────────────────────────────────────────────────────── */

.live-log {
    background: #0A0A0E;
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #A3A3A3;
    height: 140px;
    overflow-y: auto;
}

.log-entry { margin-bottom: 3px; }
.log-entry.purple { color: #A855F7; }
.log-entry.dim    { color: #22d3ee; }  /* cyan — matches terminal reference */
.log-entry.green  { color: #4ADE80; }
.log-entry.amber  { color: #F59E0B; }

.action-buttons-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: #111520;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #23283E;
}

.orb-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    width: 100%;
}

.orb-btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.orb-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 2.5rem;
    position: relative;
    color: #fff;
}
.orb-btn i {
    z-index: 2;
}

.orb-btn.play {
    background: radial-gradient(circle at center, rgba(74, 222, 128, 0.4) 0%, #111520 70%);
    border: 3px solid rgba(74, 222, 128, 0.8);
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.5), inset 0 0 20px rgba(74, 222, 128, 0.5);
}
.orb-btn.play:hover { transform: scale(1.05); box-shadow: 0 0 50px rgba(74, 222, 128, 0.8), inset 0 0 30px rgba(74, 222, 128, 0.8); }

.orb-btn.download {
    background: radial-gradient(circle at center, rgba(168, 85, 247, 0.4) 0%, #111520 70%);
    border: 3px solid rgba(168, 85, 247, 0.8);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.5), inset 0 0 20px rgba(168, 85, 247, 0.5);
    text-decoration: none;
}
.orb-btn.download:hover { transform: scale(1.05); box-shadow: 0 0 50px rgba(168, 85, 247, 0.8), inset 0 0 30px rgba(168, 85, 247, 0.8); }

.orb-label {
    text-align: center;
    font-size: 0.75rem;
    color: #9CA3AF;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.orb-label.green { color: #4ADE80; }
.orb-label.purple { color: #A855F7; }

.remix-btn {
    align-self: flex-end;
    background: transparent;
    border: 1px solid #4B5563;
    color: #9CA3AF;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    margin-top: auto;
}
.remix-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }

/* Utilities to hide actual AWS SDK elements but keep them in DOM */
.aws-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Selected track row (click to select before tagging) ─────────────────── */
.track-list-item.is-selected {
    background: rgba(168,85,247,0.14) !important;
    border-left: 3px solid var(--primary-neon) !important;
    border-radius: 6px;
    animation: none !important;
    box-shadow: inset 0 0 12px rgba(168,85,247,0.1);
}
.track-list-item.is-selected .track-checkbox {
    background: var(--primary-neon);
    border-color: var(--primary-neon);
}
