:root { --primary: #ef4444; --bg-dark: #09090b; --surface: #18181b; }

/* SAFE AREA UTILITIES */
.safe-area-padding {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

body { 
    background-color: var(--bg-dark); 
    color: #e4e4e7; 
    font-family: 'Outfit', sans-serif; 
    -webkit-tap-highlight-color: transparent; 
    overflow-x: hidden; 
    background-image: radial-gradient(circle at 50% 0%, #27272a 0%, #09090b 70%);
    overscroll-behavior-y: none;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }

/* Animation: Simplified for performance */
@keyframes fade-in-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-enter { animation: fade-in-up 0.4s ease-out forwards; }

.player-shell { 
    position: relative; width: 100%; padding-bottom: 56.25%; 
    background: #000; overflow: hidden; border-radius: 16px; 
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1); 
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
}
.player-shell iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

/* Standard Fullscreen */
.player-shell:fullscreen, .player-shell:-webkit-full-screen { 
    padding-bottom: 0 !important; width: 100vw !important; height: 100vh !important; 
    border-radius: 0 !important; display: flex; align-items: center; justify-content: center; background: black; 
}
.player-shell:fullscreen iframe { position: relative; width: 100%; height: 100%; max-height: 100vh; max-width: 100vw; object-fit: contain; }

/* iOS Fake Fullscreen */
.ios-fullscreen-active .player-shell {
    position: fixed !important; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important; height: 100dvh !important;
    max-width: none !important; max-height: none !important;
    z-index: 9999; padding-bottom: 0 !important; border-radius: 0 !important;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    background: black;
}
.ios-fullscreen-active body { overflow: hidden; }

/* Helpers */
.ios-only { display: none; }
.is-ios .ios-only { display: block; }

#audio-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(9, 9, 11, 0.95); z-index: 20; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
#audio-overlay.active { opacity: 1; pointer-events: auto; }

.pulse-ring { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(239, 68, 68, 0.3); animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite; }
@keyframes pulse-ring { 0% { transform: scale(0.8); opacity: 0.8; } 100% { transform: scale(2.2); opacity: 0; } }

.player-shell.user-inactive { cursor: none; }
.player-shell.user-inactive .controls-bar, .player-shell.user-inactive .top-actions { opacity: 0 !important; transition: opacity 0.5s ease; pointer-events: none; }
.player-shell.is-paused iframe { filter: blur(12px) grayscale(0.8) brightness(0.7); transform: scale(1.05); }

.touch-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 25; cursor: pointer; }
.top-actions { position: absolute; top: 16px; right: 16px; z-index: 60; display: flex; gap: 12px; opacity: 0; transition: opacity 0.3s ease; }
.player-shell:hover .top-actions, .player-shell.active .top-actions, .player-shell.is-paused .top-actions { opacity: 1; }

/* FIX: Increased Tap Target Size (48px) */
.glass-btn { 
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); 
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 50%; 
    width: 48px; height: 48px; /* PageSpeed Recommendation */
    display: flex; align-items: center; justify-content: center; 
    color: white; transition: all 0.2s ease; cursor: pointer; 
    touch-action: manipulation; /* Removes 300ms delay */
}
.glass-btn:active { transform: scale(0.95); }
.glass-btn.active-state { color: #ef4444; background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }

.controls-bar { position: absolute; bottom: 0; left: 0; width: 100%; padding: 40px 20px 16px 20px; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.8) 40%, transparent 100%); z-index: 50; display: flex; flex-direction: row; align-items: center; gap: 16px; opacity: 0; transition: opacity 0.3s ease; pointer-events: none; }
.controls-bar > * { pointer-events: auto; }
.player-shell:hover .controls-bar, .player-shell.active .controls-bar, .player-shell.is-paused .controls-bar { opacity: 1; }

.seek-container { position: relative; width: 100%; flex: 1; height: 32px; /* Taller container */ display: flex; align-items: center; cursor: pointer; group; }        
.seek-track { width: 100%; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; position: relative; overflow: hidden; }
.seek-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #f87171); width: 0%; position: absolute; top: 0; left: 0; box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
/* FIX: Taller input for touch dragging */
.seek-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; margin: 0; touch-action: none; }

.vol-group { display: flex; align-items: center; background: rgba(0,0,0,0.3); border-radius: 20px; padding-right: 0; transition: all 0.3s ease; border: 1px solid transparent; }
@media (min-width: 768px) { .vol-group:hover { padding-right: 12px; background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.1); } .vol-group:hover .vol-container { width: 60px; margin-left: 8px; opacity: 1; } }
.vol-container { width: 0; overflow: hidden; transition: all 0.3s ease; display: flex; align-items: center; opacity: 0; }
.vol-input { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.3); outline: none; touch-action: none; }
.vol-input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: white; cursor: pointer; border: 1px solid rgba(0,0,0,0.1); }

#library-drawer { transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); background: rgba(24, 24, 27, 0.98); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); z-index: 70; }
.tab-btn { position: relative; padding: 12px 24px; /* Larger tap area */ font-size: 14px; font-weight: 600; color: #a1a1aa; transition: all 0.2s; letter-spacing: 0.02em; }
.tab-btn::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 0; height: 2px; background: #ef4444; transition: all 0.3s ease; transform: translateX(-50%); border-radius: 2px; }
.tab-btn.active { color: #fff; }
.tab-btn.active::after { width: 80%; }

.custom-input { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); transition: all 0.2s ease; }
.custom-input:focus { background: rgba(255, 255, 255, 0.08); border-color: rgba(239, 68, 68, 0.5); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1); }

#toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(255,255,255,0.9); color: black; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.chevron { transition: transform 0.3s ease; }
.expanded .chevron { transform: rotate(180deg); }

.seek-feedback { position: absolute; top: 50%; transform: translateY(-50%); width: 80px; height: 80px; background: rgba(0,0,0,0.6); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; opacity: 0; pointer-events: none; z-index: 60; backdrop-filter: blur(4px); }
.seek-feedback.left { left: 15%; }
.seek-feedback.right { right: 15%; }
@keyframes feedback-pulse { 0% { opacity: 0; transform: translateY(-50%) scale(0.5); } 20% { opacity: 1; transform: translateY(-50%) scale(1.1); } 100% { opacity: 0; transform: translateY(-50%) scale(1.5); } }

#autoplay-toggle:checked ~ .toggle-bg { background-color: #ef4444; }
#autoplay-toggle:checked ~ .dot { transform: translateX(1.25rem); }
#autoplay-toggle:disabled ~ .toggle-bg { background-color: #333; }
#autoplay-toggle:disabled ~ .dot { background-color: #555; }

@media (max-width: 640px) {
    .player-shell:hover .controls-bar, .player-shell:hover .top-actions { opacity: 1; }
    .top-actions { opacity: 1 !important; }
    .controls-bar { padding-bottom: 10px; opacity: 0; }
    .player-shell.active .controls-bar { opacity: 1; }
    .controls-bar { flex-wrap: wrap; justify-content: space-between; gap: 8px; }
    .seek-container { order: 1; width: 100%; flex-basis: 100%; margin-bottom: 4px; }
    .time-display { order: 2; }
    .action-buttons { order: 3; }
}
