:root {
            --bg-body: #F9F7F2; --bg-surface: #FFFFFF; --bg-surface-hover: #F2EFE9;
            --text-primary: #1A3C34; --text-secondary: #5C706A; --primary: #1F4E43;
            --primary-light: #2A6658; --accent: #D4AF37; --border: #E0DCD5;
            --shadow: 0 4px 20px rgba(26, 60, 52, 0.06); --shadow-hover: 0 8px 30px rgba(26, 60, 52, 0.12);
            --radius-md: 16px; --radius-lg: 24px; --radius-full: 9999px;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            --font-heading: 'Amiri', serif; --font-ui: 'Tajawal', sans-serif;
            
            /* Player specific vars based on React design */
            --player-bg: rgba(255, 255, 255, 0.95);
            --player-border: #E0DCD5;
            --range-track: #E0DCD5;
        }

        [data-theme="dark"] {
            --bg-body: #0F1716; --bg-surface: #1A2624; --bg-surface-hover: #23302E;
            --text-primary: #ECECEC; --text-secondary: #A0B3B0; --primary: #468C79;
            --primary-light: #5AA390; --accent: #C5A028; --border: #2A3836;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.4); --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.6);
            
             /* Player specific vars dark */
            --player-bg: rgba(26, 38, 36, 0.95);
            --player-border: #2A3836;
            --range-track: #2A3836;
        }

        * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
        
        body {
            font-family: var(--font-ui); background-color: var(--bg-body);
            color: var(--text-primary); line-height: 1.6; transition: background-color 0.5s ease;
            overflow-x: hidden; background-image: radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.03) 0%, transparent 40%);
        }

        body::before {
            content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6z' fill='%23D4AF37' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E");
            pointer-events: none; z-index: -1;
        }

        h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; }
        button { cursor: pointer; border: none; background: none; font-family: inherit; transition: var(--transition); }
        .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

        header { display: flex; justify-content: space-between; align-items: center; padding: 24px 0; }
        .logo { font-family: var(--font-heading); font-size: 2rem; color: var(--primary); display: flex; align-items: center; gap: 12px; text-decoration: none; }
        [data-theme="dark"] .logo { color: var(--text-primary); }
        .logo i { color: var(--accent); }
        .theme-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-primary); }

        /* --- NEW PLAYER STYLES (Matching React Design) --- */
        .player-hero { text-align: center; padding: 20px 0 40px; position: relative; }
        
        .audio-player-wrapper {
            background: var(--player-bg);
            border: 1px solid var(--player-border);
            padding: 1.5rem; /* p-6 */
            border-radius: 1.5rem; /* rounded-3xl */
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); /* shadow-xl */
            backdrop-filter: blur(12px); /* backdrop-blur-md */
            max-width: 900px; /* Wider to accommodate flex layout */
            margin: 30px auto 0;
            position: sticky; top: 20px; z-index: 100;
            transition: all 0.3s ease;
        }

        .player-layout {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-between;
            gap: 1.5rem;
        }

        @media (min-width: 768px) {
            .player-layout {
                flex-direction: row;
            }
            .track-info-side {
                text-align: right;
                flex: 1;
            }
            .controls-side {
                flex: 1;
                width: 100%;
                max-width: 32rem; /* max-w-lg */
            }
        }

        .surah-name-display {
            font-family: var(--font-heading);
            font-size: 1.875rem; /* text-3xl */
            font-weight: 700;
            color: var(--primary); /* fallback */
            margin-bottom: 0.25rem;
        }
        [data-theme="dark"] .surah-name-display { color: #fff; }
        [data-theme="light"] .surah-name-display { color: #1F4E43; }

        @media (min-width: 768px) {
            .surah-name-display { font-size: 2.25rem; /* text-4xl */ }
        }

        .reciter-name-display {
            color: #D4AF37;
            font-size: 1.125rem; /* text-lg */
            font-weight: 700;
        }

        /* Range Input Styling (The Loader) */
        .range-wrapper {
            width: 100%;
            position: relative;
        }

        input[type=range] {
            -webkit-appearance: none;
            width: 100%;
            height: 8px; /* h-2 */
            border-radius: 8px; /* rounded-lg */
            background: var(--range-track);
            outline: none;
            cursor: pointer;
            direction: rtl; /* Important for Arabic slider */
        }

        /* --- EDIT: HIDING THE BALL (THUMB) --- */
        input[type=range]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 0;
            height: 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }
        
        input[type=range]::-moz-range-thumb {
            width: 0;
            height: 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }
        /* --- END EDIT --- */
        
        /* Time Stamps */
        .time-stamps {
            display: flex;
            justify-content: space-between;
            margin-top: 0.5rem;
            font-size: 0.875rem; /* text-sm */
            font-weight: 700;
            color: var(--text-secondary);
        }

        /* Buttons Row */
        .controls-row {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 1rem;
            margin-top: 1rem;
        }

        .btn-icon {
            padding: 0.75rem; /* p-3 */
            font-size: 1.25rem; /* text-xl */
            color: var(--text-secondary);
            transition: all 0.3s;
        }
        
        .btn-icon:hover { color: var(--primary); }
        [data-theme="dark"] .btn-icon:hover { color: var(--primary-light); }
        .btn-icon:hover.random-btn { color: #D4AF37; }

        .btn-play-main {
            width: 4rem; height: 4rem; /* w-16 h-16 */
            border-radius: 50%;
            background: var(--primary);
            color: white;
            display: flex; align-items: center; justify-content: center;
            font-size: 1.5rem; /* text-2xl */
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s;
        }
        [data-theme="dark"] .btn-play-main { background: #468C79; }
        
        .btn-play-main:hover { transform: scale(1.05); }

        .active-mode { color: #D4AF37 !important; }

        /* --- End Player Styles --- */

        .search-wrapper { max-width: 700px; margin: 40px auto 30px; }
        .search-box {
            width: 100%; padding: 12px 20px; border-radius: var(--radius-full);
            border: 1px solid var(--border); background: var(--bg-surface);
            font-family: var(--font-ui); font-size: 1rem; color: var(--text-primary);
            outline: none; transition: var(--transition);
        }
        .search-box:focus { border-color: var(--accent); box-shadow: var(--shadow); }

        .tabs { display: flex; gap: 20px; margin-bottom: 30px; justify-content: center; flex-wrap: wrap; }
        .tab-btn { padding: 10px 24px; border-radius: var(--radius-full); font-weight: 500; color: var(--text-secondary); border: 1px solid transparent; }
        .tab-btn.active { background: var(--bg-surface); color: var(--primary); border-color: var(--border); box-shadow: var(--shadow); }

        .grid-layout {
            display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 20px; margin-bottom: 30px;
        }
        
        .card {
            background: var(--bg-surface); padding: 20px; border-radius: var(--radius-md);
            border: 1px solid var(--border); transition: var(--transition);
            display: flex; align-items: center; gap: 16px; cursor: pointer; position: relative;
        }
        .card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
        .card.active { border-color: var(--primary); background: var(--bg-surface-hover); }

        .card-icon {
            width: 50px; height: 50px; background: var(--bg-body); border-radius: 50%;
            display: grid; place-items: center; color: var(--primary); font-size: 1.2rem; flex-shrink: 0;
        }
        
        .card-info { flex: 1; }
        .card-title { font-size: 1.1rem; margin-bottom: 4px; color: var(--text-primary); }
        .card-meta { font-size: 0.85rem; color: var(--text-secondary); }

        .fav-btn {
            position: relative; z-index: 2; padding: 10px;
            color: var(--text-secondary); transition: transform 0.2s; font-size: 1.2rem;
        }
        .fav-btn:hover { color: #e74c3c; transform: scale(1.1); }
        .fav-btn.is-fav { color: #e74c3c; }

        .pagination { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 60px; }
        .page-btn {
            padding: 8px 16px; border-radius: 8px; background: var(--bg-surface);
            border: 1px solid var(--border); color: var(--text-primary); font-weight: bold;
        }
        .page-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .page-info { font-weight: bold; color: var(--primary); }

        .surah-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
        .surah-item {
            background: var(--bg-surface); padding: 14px 18px; border-radius: 12px !important;
            display: flex; align-items: center; justify-content: space-between;
            border: 1px solid var(--border); cursor: pointer; transition: var(--transition);
        }
        .surah-item:hover { background: var(--bg-surface-hover); border-color: var(--accent); transform: translateY(-2px); }
        .surah-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
        .surah-info { display: flex; align-items: center; gap: 12px; }
        .surah-number {
            font-weight: 700; font-size: 0.85rem; color: var(--accent);
            width: 28px; height: 28px; display: grid; place-items: center;
            background: rgba(0,0,0,0.03); border-radius: 6px;
        }
        .error-toast {
            position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
            background: #468C79; color: white; padding: 12px 25px;
            border-radius: 30px; z-index: 10001; font-weight: bold;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2); animation: fadeInUp 0.5s;
        }
        @keyframes fadeInUp { from { opacity: 0; bottom: 0; } to { opacity: 1; bottom: 20px; } }

        .app-footer {
            text-align: center; padding: 40px 20px; margin-top: 40px; border-top: 1px solid var(--border);
            color: var(--text-secondary); font-size: 0.9rem;
        }
        .dev-name { color: var(--primary); font-weight: bold; }
        .footer-links { margin-top: 15px; display: flex; justify-content: center; gap: 20px; font-size: 1.3rem; }

        /* Track Actions (Save & Download) */
        .track-actions { 
            display: flex; 
            gap: 15px; 
            margin-top: 12px; 
            justify-content: center; 
        }
        @media (min-width: 768px) { 
            .track-actions { justify-content: flex-end; } 
        }
        .action-btn { 
            color: var(--text-secondary); 
            font-size: 1.25rem; /* was 1.2rem — now matches .btn-icon */
            transition: var(--transition); 
            padding: 0.75rem; /* was 5px — matched to .btn-icon so heart/download
                                  have the same tap area and visual weight as the
                                  other control icons instead of looking smaller
                                  and huddled together */
        }
        .action-btn:hover { 
            color: var(--primary); 
            transform: scale(1.1); 
        }
        .action-btn.is-saved { 
            color: #e74c3c; 
        }
        .action-btn.is-saved:hover { 
            color: #c0392b; 
        }
        /* زرار الحذف في الكارد الجديد */
        .delete-btn:hover { color: #e74c3c; }

        /* --- التحجيم للشاشات المختلفة (Scalability) --- */
        /* NOTE: this must stay max-width: 767px (not 768px) so it never overlaps
           the "@media (min-width: 768px)" desktop rules above. Using 768px on
           both sides made row-layout and mobile-card-padding apply at the same
           time at exactly 768px, causing the squeezed/overlapping player. */
        @media (max-width: 767px) {
            .audio-player-wrapper { padding: 16px; width: 100%; top: 0; border-radius: 0 0 20px 20px; margin-top: 0; }
            .grid-layout { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
            .surah-list { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
            .tabs { gap: 10px; }
            .tab-btn { padding: 8px 16px; font-size: 0.9rem; }
        }

        /* Small phones: 7 controls at full .btn-icon size can get tight, so
           trim the row gap and icon padding slightly rather than letting it wrap.
           Threshold pushed to 480px (was 400px) to hold the tight gap ~80px longer
           before it expands back to the default 1rem gap. */
        @media (max-width: 480px) {
            .controls-row { gap: 0.35rem; }
            .btn-icon, .action-btn { padding: 0.5rem; font-size: 1.1rem; }
            .btn-play-main { width: 3.25rem; height: 3.25rem; font-size: 1.3rem; }
        }

        /* Tablet range: row layout already applies (>=768px), but give the
           controls column a bit more breathing room than the max-w-lg used
           on large desktop, so buttons don't crowd on iPad-ish widths. */
        @media (min-width: 768px) and (max-width: 900px) {
            .controls-side { max-width: 100%; }
            .controls-row { gap: 0.65rem; }
            .btn-play-main { width: 3.5rem; height: 3.5rem; font-size: 1.3rem; }
        }
