* { box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #0a0a0f;
    color: #f4f4f5;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    font-family: 'Tajawal', sans-serif;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

@media (display-mode: standalone), (display-mode: window-controls-overlay) {
    #topShortcutBar { display: none !important; }
    main {
        padding-top: calc(env(safe-area-inset-top, 0px) + 0.5rem) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6rem) !important;
    }
    #floatingPlayer {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px) !important;
    }
    aside {
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important;
    }
}

input, textarea, select {
    user-select: text !important;
    -webkit-user-select: text !important;
}

button, a, input, select {
    -webkit-tap-highlight-color: transparent;
    outline: none !important;
}
button:focus, a:focus {
    outline: none !important;
    box-shadow: none !important;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5e; }

.modern-input {
    background: rgba(18, 18, 26, 0.8);
    border: 1.5px solid #2a2a3e;
    color: white;
    border-radius: 14px;
    padding: 0.85rem 1.3rem;
    outline: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    font-size: 14px;
    backdrop-filter: blur(10px);
}
.modern-input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15), 0 0 20px rgba(139, 92, 246, 0.1);
    background: rgba(18, 18, 26, 1);
}
.modern-input::placeholder { color: #6b7280; }

.btn {
    padding: 0.85rem 1.6rem;
    border-radius: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    overflow: hidden;
    font-size: 14px;
    letter-spacing: 0.01em;
    border: none;
    background: transparent;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:hover:not(:disabled) { transform: translateY(-1px); }

@keyframes shimmer { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }
.shimmer-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent); animation: shimmer 1.5s infinite linear; }

.view-section { display: none !important; opacity: 0; }
.view-section.active { display: block !important; opacity: 1; animation: fadeInView 0.4s ease forwards; }
.view-section.active.flex-layout { display: flex !important; }

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

#progBar {
    transition: width 0.5s cubic-bezier(0.1, 0.8, 0.25, 1);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

#floatingPlayer {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    left: 16px;
    width: min(380px, calc(100vw - 84px));
    max-height: calc(100dvh - 24px);
    background: rgba(12, 12, 20, 0.96);
    backdrop-filter: blur(30px) saturate(1.5);
    -webkit-backdrop-filter: blur(30px) saturate(1.5);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.85), 0 0 30px rgba(139, 92, 246, 0.15);
    z-index: 100;
    overflow-y: auto;
    display: none;
    opacity: 0;
    transform: scale(0.92) translateY(20px);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#floatingPlayer.active-player { display: block !important; opacity: 1; transform: scale(1) translateY(0); }

#floatingPlayer.dragging-player {
    transform: scale(0.96) !important;
    opacity: 0.65 !important;
    border-color: rgba(139, 92, 246, 0.6) !important;
    box-shadow: 0 40px 80px rgba(0,0,0,0.9), 0 0 40px rgba(139, 92, 246, 0.35) !important;
}

.drag-handle { cursor: grab; user-select: none; touch-action: none; }
.drag-handle:active { cursor: grabbing; }

@keyframes spinDisk { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.album-spin { animation: spinDisk 20s linear infinite; }

@keyframes bounceGpu { 0% { transform: scaleY(0.15); } 100% { transform: scaleY(1.0); } }
.wave-bar {
    width: 3.5px;
    height: 28px;
    background: linear-gradient(to top, #8b5cf6, #a78bfa);
    border-radius: 4px;
    transform-origin: bottom;
    transform: scaleY(0.15);
    transition: transform 0.15s ease;
}
.playing-visualizer .wave-bar { animation: bounceGpu 0.7s ease-in-out infinite alternate; }
.playing-visualizer .wave-bar:nth-child(1) { animation-delay: 0.1s; animation-duration: 0.5s; }
.playing-visualizer .wave-bar:nth-child(2) { animation-delay: 0.25s; animation-duration: 0.65s; }
.playing-visualizer .wave-bar:nth-child(3) { animation-delay: 0.05s; animation-duration: 0.55s; }
.playing-visualizer .wave-bar:nth-child(4) { animation-delay: 0.35s; animation-duration: 0.75s; }
.playing-visualizer .wave-bar:nth-child(5) { animation-delay: 0.15s; animation-duration: 0.45s; }
.playing-visualizer .wave-bar:nth-child(6) { animation-delay: 0.45s; animation-duration: 0.7s; }
.playing-visualizer .wave-bar:nth-child(7) { animation-delay: 0.2s; animation-duration: 0.6s; }

#floatingPlayer.compact-mode { width: min(340px, calc(100vw - 92px)) !important; height: auto !important; }
#floatingPlayer.compact-mode #playerBody { display: none; }

.marquee-wrapper {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

@keyframes smoothMarquee {
    0% { transform: translate3d(100%, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}

.animate-marquee {
    display: inline-block;
    white-space: nowrap;
    padding-right: 15px;
    will-change: transform;
    animation: smoothMarquee 15s linear infinite;
}

.animate-marquee:hover {
    animation-play-state: paused;
}

#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    opacity: 0;
    z-index: 1000;
    padding: 12px 24px;
    border-radius: 16px;
    font-weight: 700;
    color: white;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    pointer-events: none;
    backdrop-filter: blur(20px);
    font-size: 13px;
    max-width: calc(100vw - 32px);
    text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.glass-card {
    background: rgba(18, 18, 26, 0.6);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid rgba(42, 42, 62, 0.6);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.03);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.glass-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 25px 60px rgba(0,0,0,0.4), 0 0 20px rgba(139, 92, 246, 0.05);
}

.nav-btn-active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a78bfa;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.1);
}

.glow-accent {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3), 0 8px 30px rgba(139, 92, 246, 0.2);
}

.search-result-item, .lib-card, .recent-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.search-result-item:hover, .recent-item:hover {
    transform: translateX(-4px);
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.05);
}
.lib-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), 0 0 15px rgba(139, 92, 246, 0.08);
}

.active-playing-item {
    border-color: rgba(139, 92, 246, 0.8) !important;
    background: rgba(139, 92, 246, 0.12) !important;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2) !important;
}

.pulse-dot { animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.sidebar-glow { position: relative; }
.sidebar-glow::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.03) 0%, transparent 50%, rgba(139, 92, 246, 0.02) 100%);
    pointer-events: none;
}

.typing-cursor::after {
    content: '|';
    animation: blink 0.7s infinite;
    color: #8b5cf6;
    margin-right: 3px;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

@media (max-width: 640px) {
    .sidebar-glow {
        width: 60px !important;
    }
    #floatingPlayer {
        left: 8px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        width: calc(100vw - 76px);
        border-radius: 20px;
    }
    .btn {
        padding: 0.75rem 1.2rem;
        font-size: 13px;
    }
}
