:root {
    --bg-color: #53305e;
    --text-color: #ffffff;
    --accent-color: #a3e635;
    --card-width: 320px;
    --card-height: 320px;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(180deg, #4c2858 0%, #a25068 50%, #e28268 100%);
    background-size: cover;
}

#visualizer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 2rem 1rem;
    box-sizing: border-box;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: auto;
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

header p {
    color: var(--accent-color);
    margin-top: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.top-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.genre-filters {
    display: flex;
    gap: 0.5rem;
    background: rgba(255,255,255,0.05);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch;
}
.genre-filters::after {
    content: '';
    padding-right: 1rem;
}
.genre-filters::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.genre-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.genre-btn:hover {
    color: white;
}

.genre-btn.active {
    background: var(--accent-color);
    color: #1e293b;
    box-shadow: 0 2px 10px rgba(163, 230, 53, 0.4);
}

.icon-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.05);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn.liked svg {
    fill: #ec4899;
    stroke: #ec4899;
}

.carousel-container {
    position: relative;
    height: 450px;
    perspective: 1200px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.loading-spinner {
    position: absolute;
    font-size: 1.5rem;
    color: #94a3b8;
    z-index: 10;
    display: none;
}

.card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.6s ease;
    transform-style: preserve-3d;
    user-select: none;
    will-change: transform;
}

.sleeve-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    z-index: 2;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: left center;
}

.sleeve-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped .sleeve-inner {
    transform: rotateY(180deg);
}

.sleeve-front, .sleeve-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    backface-visibility: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    cursor: pointer;
}

.sleeve-front::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.6) 100%);
    border-radius: 4px;
    pointer-events: none;
}

.sleeve-back {
    transform: rotateY(180deg);
    background: linear-gradient(to bottom right, #1e293b, #0f172a);
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sleeve-back h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
}

.tracklist {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    color: #cbd5e1;
    overflow-y: auto;
    flex-grow: 1;
}

.tracklist li {
    padding: 0.4rem 0;
    border-bottom: 1px dashed rgba(255,255,255,0.05);
}

.vinyl-container {
    position: absolute;
    width: 96%;
    height: 96%;
    top: 2%;
    left: 2%;
    z-index: 1;
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

.vinyl {
    width: 100%;
    height: 100%;
    background-image: url('assets/vinyl_record.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), inset 0 0 0 2px rgba(255,255,255,0.05);
    cursor: grab;
}

.vinyl:active {
    cursor: grabbing;
}

.vinyl::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: repeating-radial-gradient(
        transparent 0, 
        transparent 4px, 
        rgba(0,0,0,0.1) 5px, 
        rgba(0,0,0,0.2) 6px
    );
    pointer-events: none;
}

/* Playing State */
.card.playing .sleeve-wrapper {
    transform: translateX(-50px) rotateY(-12deg);
}

.card.playing .vinyl-container {
    transform: translateX(140px);
}

.controls-panel {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    z-index: 10;
}

.deck-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: rgba(0,0,0,0.4);
    padding: 1rem 2rem;
    border-radius: 40px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
}

.pitch-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.pitch-control label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pitch-control input[type=range] {
    width: 120px;
    accent-color: #3b82f6;
}

#pitch-display {
    font-size: 0.8rem;
    color: #3b82f6;
    font-weight: 700;
}

.control-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.1);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.record-info {
    display: flex;
    justify-content: center;
    margin-top: auto;
    margin-bottom: 1rem;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: rgba(255,255,255,0.03);
    padding: 1rem 2rem;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(5px);
}

.text-info {
    text-align: left;
}

.text-info h2 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.text-info p {
    color: #94a3b8;
    margin-top: 0.3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    transition: opacity 0.3s ease;
}

.action-btns {
    display: flex;
    gap: 0.8rem;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 300px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255,255,255,0.1);
    z-index: 100;
    transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.crate-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.crate-item {
    display: flex;
    gap: 1rem;
    background: rgba(255,255,255,0.05);
    padding: 0.8rem;
    border-radius: 12px;
    align-items: center;
}

.crate-item img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
}

.crate-item-info {
    flex-grow: 1;
    overflow: hidden;
}

.crate-item-info h4 {
    margin: 0 0 0.2rem 0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crate-item-info p {
    margin: 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Card states */
.card[data-status="active"] { transform: translateX(0) translateZ(0) scale(1); opacity: 1; z-index: 5; }
.card[data-status="prev"] { transform: translateX(-220px) translateZ(-150px) rotateY(35deg); opacity: 0.6; z-index: 4; }
.card[data-status="next"] { transform: translateX(220px) translateZ(-150px) rotateY(-35deg); opacity: 0.6; z-index: 4; }
.card[data-status="prev-hidden"] { transform: translateX(-350px) translateZ(-300px) rotateY(45deg); opacity: 0; z-index: 3; pointer-events: none; }
.card[data-status="next-hidden"] { transform: translateX(350px) translateZ(-300px) rotateY(-45deg); opacity: 0; z-index: 3; pointer-events: none; }

@media (max-width: 768px) {
    :root {
        --card-width: 220px;
        --card-height: 220px;
    }
    
    .top-controls { flex-direction: column; gap: 0.8rem; }
    .genre-filters { width: 90vw; }
    
    .card[data-status="prev"] { transform: translateX(-140px) translateZ(-150px) rotateY(35deg); }
    .card[data-status="next"] { transform: translateX(140px) translateZ(-150px) rotateY(-35deg); }
    .card.playing .sleeve-wrapper { transform: translateX(-30px) rotateY(-10deg); }
    .card.playing .vinyl-container { transform: translateX(90px); }
    
    .deck-controls { padding: 0.5rem 1rem; gap: 1rem; }
    .info-header { flex-direction: column; text-align: center; gap: 1rem; }
    .text-info { text-align: center; }
}

#ar-camera {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: -2;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.ar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, rgba(76, 40, 88, 0.85) 0%, rgba(162, 80, 104, 0.85) 50%, rgba(226, 130, 104, 0.85) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.5s ease;
}

body.ar-active {
    background: transparent !important;
}

body.ar-active #ar-camera {
    opacity: 1;
}

body.ar-active .ar-overlay {
    opacity: 1;
}

.tool-btns {
    display: flex;
    gap: 0.5rem;
}

.sidebar-tabs {
    display: flex;
    width: 100%;
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 0.5rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    font-weight: 500;
}
.tab-btn.active {
    color: white;
    border-bottom-color: var(--accent-color);
}
.tab-content {
    display: none;
    flex-direction: column;
}
.tab-content.active {
    display: flex;
}

.discogs-info {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255,255,255,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.discogs-price {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 700;
}
.discogs-link {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    transition: background 0.3s;
}
.discogs-link:hover {
    background: var(--accent-color);
    color: #1e293b;
}

@keyframes wandPulse {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.5); box-shadow: 0 0 15px var(--accent-color); }
    100% { transform: scale(1); filter: brightness(1); }
}
#ai-vibe-btn.searching {
    animation: wandPulse 1s infinite;
    background: var(--accent-color);
    color: #1e293b;
}