:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-elevated: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #047857;
    --primary-hover: #065f46;
    --primary-light: #d1fae5;
    --accent: #d97706;
    --accent-light: #fef3c7;
    
    --quran-text: #064e3b;
    --quran-size: 28px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --bg-main: #0b1319;
    --bg-card: #15222e;
    --bg-elevated: #1e2f3e;
    --border-color: #273b4d;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --primary: #10b981;
    --primary-hover: #34d399;
    --primary-light: #064e3b;
    --accent: #f59e0b;
    --accent-light: #78350f;
    
    --quran-text: #6ee7b7;
}

[data-theme="sepia"] {
    --bg-main: #fbf7ee;
    --bg-card: #f4ecdc;
    --bg-elevated: #ede2cd;
    --border-color: #dfcfb3;
    --text-primary: #3d2f1f;
    --text-secondary: #6e583f;
    --text-muted: #9c8466;
    
    --primary: #2d5a27;
    --primary-hover: #1f3d1b;
    --primary-light: #d8e8d5;
    --accent: #b45309;
    --accent-light: #fef3c7;
    
    --quran-text: #1e3a1a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-bottom: 85px; /* for bottom nav */
}

/* Container */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header & Navigation */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary);
}

.brand-text p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Action Buttons & Icons */
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.btn-icon:hover {
    background: var(--bg-elevated);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

/* Hero / Daily Ayah Card */
.hero-card {
    background: linear-gradient(135deg, rgba(4, 120, 87, 0.08) 0%, rgba(217, 119, 6, 0.08) 100%), var(--bg-card);
    border: 1px solid var(--primary-light);
    border-radius: 20px;
    padding: 24px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.hero-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 12px;
    margin-bottom: 12px;
}

.hero-arabic {
    font-size: 26px;
    color: var(--quran-text);
    text-align: center;
    margin: 16px 0;
    direction: rtl;
    line-height: 2.2;
}

.hero-urdu {
    font-size: 18px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
    direction: rtl;
}

.hero-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Quick Tools Bar */
.quick-tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 640px) {
    .quick-tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.quick-tool-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.quick-tool-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.quick-tool-icon {
    font-size: 28px;
}

.quick-tool-label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Surah Grid */
.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.surah-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.surah-card:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.surah-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.surah-number {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.surah-names h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.surah-names span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.surah-arabic {
    font-size: 1.4rem;
    color: var(--primary);
    direction: rtl;
    font-family: 'Hafs', serif;
}

/* Search Bar */
.search-wrapper {
    position: relative;
    margin: 16px 0;
}

.search-input {
    width: 100%;
    padding: 14px 20px 14px 44px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

/* Topic Pills */
.topics-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin: 12px 0 20px;
    scrollbar-width: none;
}

.topics-scroll::-webkit-scrollbar {
    display: none;
}

.topic-chip {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.topic-chip:hover, .topic-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Ayah View in surah.php */
.ayah-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
}

.ayah-card.active-ayah {
    border-color: var(--primary);
    background: var(--primary-light);
}

.ayah-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.ayah-badge {
    background: var(--bg-elevated);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.ayah-actions {
    display: flex;
    gap: 8px;
}

.ayah-arabic {
    font-size: var(--quran-size);
    color: var(--quran-text);
    text-align: right;
    direction: rtl;
    line-height: 2.2;
    margin-bottom: 16px;
    font-family: 'Hafs', serif;
}

.ayah-transliteration {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 12px;
}

.ayah-urdu {
    font-size: 1.15rem;
    color: var(--text-secondary);
    direction: rtl;
    line-height: 2;
    font-family: 'Jameel', 'Noto Nastaliq Urdu', serif;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

/* Audio Player Bottom Floating Bar */
.audio-player-bar {
    position: fixed;
    bottom: 64px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    padding: 10px 16px;
    display: none;
    z-index: 45;
}

.audio-player-inner {
    max-width: 1140px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mobile Bottom Navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    gap: 3px;
    flex: 1;
    height: 100%;
    transition: color 0.2s;
}

.mobile-nav-item.active, .mobile-nav-item:hover {
    color: var(--primary);
}

.mobile-nav-icon {
    font-size: 20px;
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}
