/* ================================================
   EGY QURAN — Premium Stylesheet (Ma'asrawi Edition)
   Design: Gold & Ink — Elegant Islamic Audio App
   ================================================ */

/* ── متغيرات الألوان والتوكنز ── */
:root {
    /* الوضع الفاتح */
    --bg-page:      #f5f3ef;
    --bg-card:      #ffffff;
    --bg-subtle:    #ede9e2;
    --bg-inset:     #faf8f5;

    --accent-gold:  #b8933e;
    --accent-light: #d4aa5a;
    --accent-glow:  rgba(184, 147, 62, 0.18);
    --accent-hover: #a07d33;

    --text-title:   #1a1510;
    --text-body:    #3d3426;
    --text-muted:   #8a7d6b;
    --text-faint:   #b5a898;

    --border-soft:  rgba(140, 110, 60, 0.12);
    --border-mid:   rgba(140, 110, 60, 0.22);

    --player-bg:    rgba(255, 252, 245, 0.97);
    --shadow-sm:    0 2px 8px rgba(100, 70, 20, 0.07);
    --shadow-md:    0 6px 24px rgba(100, 70, 20, 0.11);
    --shadow-lg:    0 12px 40px rgba(100, 70, 20, 0.15);

    --radius-sm:    10px;
    --radius-md:    16px;
    --radius-lg:    24px;
    --radius-full:  9999px;

    --transition:   0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --font-ui:      'Cairo', sans-serif;
}

/* الوضع الداكن */
body.dark-theme {
    --bg-page:      #0f0e0c;
    --bg-card:      #1a1812;
    --bg-subtle:    #231f18;
    --bg-inset:     #141210;

    --accent-gold:  #c5a459;
    --accent-light: #d9b96a;
    --accent-glow:  rgba(197, 164, 89, 0.15);
    --accent-hover: #b39048;

    --text-title:   #f5efdf;
    --text-body:    #cdc0a8;
    --text-muted:   #7a6e5e;
    --text-faint:   #4a4035;

    --border-soft:  rgba(197, 164, 89, 0.10);
    --border-mid:   rgba(197, 164, 89, 0.18);

    --player-bg:    rgba(18, 16, 12, 0.97);
    --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md:    0 6px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg:    0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ── إعادة الضبط الأساسية ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    padding-bottom: 150px;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* ── الحاوية الرئيسية ── */
.container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 16px 16px 0;
}

@media (min-width: 640px) {
    .container {
        padding: 24px 24px 0;
    }
}

/* ── التثبيت الانزلاقي ── */
.install-banner {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    width: 100%;
    max-width: 520px;
    background: var(--player-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 2px solid var(--accent-gold);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.install-banner.show {
    transform: translateX(-50%) translateY(0);
}

.install-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.install-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-title);
}

.install-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.install-action-btn {
    background: var(--accent-gold);
    color: #fff;
    border: none;
    padding: 7px 18px;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: transform var(--transition), background var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.install-action-btn:hover { background: var(--accent-hover); }
.install-action-btn:active { transform: scale(0.95); }

.install-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.install-close-btn:hover {
    background: var(--accent-glow);
    color: var(--text-title);
}

.install-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ── بانر الاستئناف ── */
#resume-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-200px);
    background: var(--player-bg);
    border: 1.5px solid var(--accent-gold);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.45s ease;
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

#resume-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.resume-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
}

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

.resume-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-title);
    text-align: center;
    line-height: 1.6;
}

.resume-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.resume-btn {
    flex: 1;
    background: var(--accent-gold);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.resume-btn:hover { background: var(--accent-hover); }
.resume-btn:active { transform: scale(0.97); }

.resume-close {
    flex: 1;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-soft);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.resume-close:hover {
    background: var(--border-soft);
    color: var(--text-body);
}

.resume-close:active { transform: scale(0.97); }

/* ── الشريط العلوي ── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
}

.top-bar-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.top-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.72rem;
    text-decoration: none;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.top-btn:hover {
    background: var(--accent-glow);
    color: var(--accent-gold);
    border-color: var(--border-mid);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.top-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.top-btn svg {
    width: 17px;
    height: 17px;
}

/* ── إشعار الإذاعة الفليشر ── */
.radio-flash-badge {
    position: absolute;
    top: 100%;
    margin-top: 6px;
    background: var(--accent-gold);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--accent-glow);
    animation: flash-pulse 1.5s infinite ease-in-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes flash-pulse {
    0% { opacity: 0.7; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.7; transform: scale(0.95); }
}

.lang-btn {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.email-btn:hover,
.email-btn:focus-visible {
    color: #3b82f6 !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    background: rgba(59, 130, 246, 0.08) !important;
}

/* ── الرأس ── */
header {
    text-align: center;
    padding-bottom: 22px;
}

.header-avatar-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.header-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 2.5px solid var(--accent-gold);
    box-shadow: var(--shadow-md), 0 0 0 6px var(--accent-glow);
    object-fit: cover;
    display: block;
    transition: box-shadow var(--transition);
}

.header-avatar-glow {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
}

.header-equalizer.playing ~ .header-img,
header:has(.header-equalizer.playing) .header-img {
    box-shadow: var(--shadow-md), 0 0 0 8px var(--accent-glow);
}

header h1 {
    font-family: var(--font-ui);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--text-body);
    margin-bottom: 4px;
    letter-spacing: 0.01em;
    transition: font-size var(--transition);
}

header h1 strong {
    font-weight: 800;
    color: var(--accent-gold);
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

/* المعادل الصوتي في الرأس */
.header-equalizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 20px;
    margin-top: 14px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.header-equalizer.playing {
    opacity: 1;
    visibility: visible;
}

.header-eq-bar {
    width: 3px;
    height: 100%;
    background: linear-gradient(to top, var(--accent-gold), var(--accent-light));
    border-radius: 3px;
    transform-origin: bottom;
    box-shadow: 0 0 10px var(--accent-glow);
}

.header-equalizer.playing .header-eq-bar:nth-child(1) { animation: equalize 0.70s infinite alternate ease-in-out; }
.header-equalizer.playing .header-eq-bar:nth-child(2) { animation: equalize 0.50s infinite alternate ease-in-out 0.20s; }
.header-equalizer.playing .header-eq-bar:nth-child(3) { animation: equalize 0.80s infinite alternate ease-in-out 0.10s; }
.header-equalizer.playing .header-eq-bar:nth-child(4) { animation: equalize 0.60s infinite alternate ease-in-out 0.30s; }
.header-equalizer.playing .header-eq-bar:nth-child(5) { animation: equalize 0.70s infinite alternate ease-in-out 0.15s; }

@keyframes equalize {
    0%   { transform: scaleY(0.2); }
    100% { transform: scaleY(1); }
}

/* ── القائمة المنسدلة للروايات ── */
.custom-dropdown {
    position: relative;
    margin: 0 0 20px;
    z-index: 100;
}

.dropdown-header {
    background: var(--bg-card);
    border: 1.5px solid var(--border-mid);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.dropdown-header:hover {
    border-color: var(--accent-gold);
    background: var(--bg-inset);
}

.dropdown-header-text {
    text-align: right;
}

html[dir="ltr"] .dropdown-header-text {
    text-align: left;
}

.dropdown-header-text strong {
    font-size: 0.9rem;
    color: var(--accent-gold);
}

.dropdown-header svg {
    width: 22px;
    height: 22px;
    color: var(--accent-gold);
    transition: transform 0.3s ease;
}

.dropdown-header.open {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.dropdown-header.open svg {
    transform: rotate(180deg);
}

.dropdown-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.dropdown-list.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: var(--border-soft);
    border-radius: 10px;
}

.dropdown-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-title);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-subtle);
    color: var(--accent-gold);
}

.dropdown-item.active {
    background: var(--accent-glow);
    color: var(--accent-gold);
    border-right: 3px solid var(--accent-gold); /* RTL Support */
}

html[dir="ltr"] .dropdown-item.active {
    border-right: none;
    border-left: 3px solid var(--accent-gold); /* LTR Support */
}

/* ── قائمة السور ── */
.surah-list-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.surah-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    cursor: default;
}

.surah-row:hover {
    border-color: var(--border-mid);
    box-shadow: var(--shadow-sm);
}

.surah-row.active-row {
    border-color: var(--accent-gold);
    background: var(--accent-glow);
    box-shadow: 0 0 0 1px var(--accent-gold);
}

.surah-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.surah-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 30px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.surah-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.surah-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.surah-action-btn {
    width: 29px;
    height: 29px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.surah-action-btn:hover {
    background: var(--accent-glow);
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    transform: scale(1.08);
}

.surah-action-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.surah-action-btn svg {
    width: 14px !important;
    height: 14px !important;
}

.active-row .play-cell {
    background: var(--accent-gold);
    color: #fff;
    border-color: var(--accent-gold);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.active-row .play-cell:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* ── أزرار أيقونات المشغل ── */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), transform var(--transition);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.icon-btn:hover { color: var(--accent-gold); }
.icon-btn:active { transform: scale(0.92); }

.icon-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.icon-btn.active-feature {
    color: var(--accent-gold) !important;
}

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

/* ── نافذة التحميل ── */
.download-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.download-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 88%;
    max-width: 320px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slide-up-fade 0.3s ease;
}

@keyframes slide-up-fade {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.dl-modal-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: var(--accent-gold);
}

.dl-modal-icon svg {
    width: 22px;
    height: 22px;
}

.dl-modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-title);
}

.dl-progress-track {
    width: 100%;
    height: 6px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.dl-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-light));
    transition: width 0.15s linear;
    border-radius: var(--radius-full);
}

.dl-modal-pct {
    margin-top: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent-gold);
}

/* ── المشغل السفلي ── */
.floating-player {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 480px;
    background: var(--player-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    padding: 8px 16px 10px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    transition: box-shadow var(--transition);
}

/* تحسينات للمشغل عند تشغيل الإذاعة */
.floating-player.radio-mode .player-seekbar-container,
.floating-player.radio-mode .player-time,
.floating-player.radio-mode .player-main-controls .nav-btn,
.floating-player.radio-mode .player-side-btn {
    display: none !important;
}

.floating-player.radio-mode .player-main-controls {
    justify-content: center;
    width: 100%;
}

/* شريط التقدم */
.player-seekbar-container {
    width: 100%;
    height: 14px;
    display: flex;
    align-items: center;
    cursor: pointer;
    direction: ltr;
    margin-bottom: 4px;
    touch-action: none;
    border-radius: var(--radius-full);
}

.player-seekbar-track {
    width: 100%;
    height: 3px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    position: relative;
    transition: height 0.2s ease;
}

.player-seekbar-container:hover .player-seekbar-track {
    height: 5px;
}

.player-seekbar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-light));
    width: 0%;
    border-radius: var(--radius-full);
    position: relative;
    pointer-events: none;
}

.player-seekbar-thumb {
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.player-seekbar-container:hover .player-seekbar-thumb {
    transform: translateY(-50%) scale(1);
}

/* صف معلومات التشغيل */
.player-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.player-track-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.player-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.time-sep {
    margin: 0 2px;
}

/* صف أزرار التحكم */
.player-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: ltr;
}

.player-side-btn {
    width: 85px;
    display: flex;
    justify-content: flex-start;
}

.player-side-btn--end {
    justify-content: flex-end;
    position: relative;
}

.player-main-controls {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav-btn svg {
    width: 22px !important;
    height: 22px !important;
}

.play-toggle-btn {
    background: var(--accent-gold);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.play-toggle-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.play-toggle-btn:active { transform: scale(0.92); }

.play-toggle-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 3px;
}

.play-toggle-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* زر وضع التشغيل */
.playback-mode-btn {
    display: flex;
    gap: 5px;
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-weight: 700;
    align-items: center;
    border-radius: var(--radius-full);
    padding: 4px 8px;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}

.playback-mode-btn:hover {
    background: var(--accent-glow);
    border-color: var(--border-mid);
}

/* قائمة التشغيل */
.playback-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: 130px;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    transform: translateY(8px);
    z-index: 1010;
    direction: rtl;
}

.playback-menu.show {
    max-height: 200px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.playback-menu-item {
    padding: 9px 14px;
    font-family: var(--font-ui);
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    text-align: right;
    transition: background var(--transition), color var(--transition);
    border-bottom: 1px solid var(--border-soft);
}

html[dir="ltr"] .playback-menu-item {
    text-align: left;
}

.playback-menu-item:last-child { border-bottom: none; }

.playback-menu-item:hover {
    background: var(--bg-subtle);
    color: var(--text-body);
}

.playback-menu-item.active {
    background: var(--accent-glow);
    color: var(--accent-gold);
}

/* ── رسالة التوست ── */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--text-title);
    color: var(--bg-page);
    padding: 7px 18px;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: 0.76rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10000;
    text-align: center;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── حركات مشتركة ── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.loading-spin {
    animation: spin 0.9s linear infinite;
    will-change: transform;
    display: block;
}

/* ── وضع الاستماع الهادئ (Focus Mode) ── */
body.focus-mode-active .custom-dropdown,
body.focus-mode-active .surah-list-container,
body.focus-mode-active .top-bar-group,
body.focus-mode-active .install-banner,
body.focus-mode-active .lang-btn {
    display: none !important;
}

body.focus-mode-active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-page);
}

body.focus-mode-active .container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    margin-top: -70px;
}

body.focus-mode-active header {
    transform: scale(1.4);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 32px;
}

/* تصغير حجم خط اسم الشيخ في وضع الاستماع الهادئ */
body.focus-mode-active header h1 {
    font-size: 0.95rem;
    transition: font-size var(--transition);
}

body.focus-mode-active .top-bar {
    position: absolute;
    top: 16px;
    right: 16px;
    padding-bottom: 0;
}

/* ── تحسينات الشاشات الكبيرة ── */
@media (min-width: 640px) {
    .floating-player {
        max-width: 500px;
        border-radius: var(--radius-lg);
        bottom: 20px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .header-img {
        width: 104px;
        height: 104px;
    }

    /* حجم الخط المصغر لاسم الشيخ على الشاشات الكبيرة في وضع الاستماع الهادئ */
    body.focus-mode-active header h1 {
        font-size: 1.05rem;
    }
}
/* ================================================
   شاشة القراءة والمزامنة (Reading / Sync View)
   ================================================ */

.reading-view {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: var(--bg-page);
    display: none;
    flex-direction: column;
    transform: translateY(12px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.reading-view.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.reading-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-card);
    flex: 0 0 auto;
}

.reading-back-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-subtle);
    color: var(--accent-gold);
    cursor: pointer;
    transition: background var(--transition);
}

.reading-back-btn svg {
    width: 20px;
    height: 20px;
    /* في الاتجاه RTL نعكس السهم ليشير لليمين */
    transform: scaleX(-1);
}

.reading-back-btn:hover {
    background: var(--bg-inset);
}

.reading-titles {
    flex: 1 1 auto;
    text-align: center;
    overflow: hidden;
}

.reading-juz-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reading-surah-title {
    font-size: 0.78rem;
    color: var(--accent-gold);
    font-weight: 600;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ayat-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 20px 16px 180px;
}

.reading-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    font-weight: 600;
}

.reading-loading.show {
    display: flex;
}

.ayat-container {
    max-width: 640px;
    margin: 0 auto;
}

.surah-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 28px 0 20px;
    color: var(--accent-gold);
    font-family: 'Amiri', serif;
    font-weight: 700;
    font-size: 1.15rem;
}

.surah-divider:first-child {
    margin-top: 4px;
}

.surah-divider::before,
.surah-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: var(--border-mid);
}

.ayah-block {
    font-family: 'Amiri', serif;
    font-size: 1.45rem;
    line-height: 2.4;
    color: var(--text-body);
    text-align: justify;
    background: transparent;
}

.ayah-span {
    cursor: pointer;
    border-radius: 8px;
    padding: 2px 3px;
    transition: background 0.35s ease, color 0.35s ease;
}

.ayah-span:hover {
    background: var(--bg-subtle);
}

.ayah-span.active-ayah {
    background: var(--accent-glow);
    color: var(--accent-hover);
    box-shadow: 0 0 0 1px var(--border-mid) inset;
}

.ayah-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-gold);
    width: 24px;
    height: 24px;
    border: 1.5px solid var(--accent-gold);
    border-radius: 50%;
    margin: 0 4px;
    vertical-align: middle;
}

body.dark-theme .ayah-span.active-ayah {
    color: var(--accent-light);
}

@media (min-width: 640px) {
    .ayah-block {
        font-size: 1.6rem;
    }
}

/* ================================================
   الإذاعة المباشرة الوهمية (Pseudo Live Radio)
   ================================================ */

/* زر الإذاعة في الشريط العلوي */
.radio-btn {
    position: relative;
}

.radio-live-dot {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e0483f;
    box-shadow: 0 0 0 2px var(--bg-card);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.radio-btn.on-air .radio-live-dot {
    opacity: 1;
    transform: scale(1);
    animation: radio-dot-pulse 1.4s infinite;
}

.radio-btn.on-air {
    color: var(--accent-gold);
    border-color: var(--border-mid);
}

@keyframes radio-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 2px rgba(224, 72, 63, 0.0); }
    50%      { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 5px rgba(224, 72, 63, 0.35); }
}

/* لوحة الإذاعة (Overlay) */
.radio-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.radio-modal.show {
    display: flex;
}

.radio-modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1.5px solid var(--accent-gold);
    border-radius: var(--radius-lg);
    padding: 32px 24px 26px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slide-up-fade 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.radio-close-btn {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-subtle);
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.radio-close-btn:hover {
    background: var(--accent-glow);
    color: var(--accent-gold);
}

.radio-close-btn svg {
    width: 15px;
    height: 15px;
}

/* شارة "مباشر" */
.radio-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(224, 72, 63, 0.12);
    color: #e0483f;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    margin-bottom: 18px;
}

.radio-live-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e0483f;
    animation: radio-dot-pulse 1.4s infinite;
}

/* صورة الشيخ داخل اللوحة */
.radio-avatar-wrapper {
    position: relative;
    width: 92px;
    height: 92px;
    margin: 0 auto 16px;
}

.radio-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid var(--accent-gold);
    box-shadow: var(--shadow-md), 0 0 0 6px var(--accent-glow);
    display: block;
}

.radio-eq {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 16px;
    padding: 3px 7px;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-full);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.radio-eq.playing {
    opacity: 1;
    visibility: visible;
}

.radio-eq-bar {
    width: 2.5px;
    height: 100%;
    background: linear-gradient(to top, var(--accent-gold), var(--accent-light));
    border-radius: 2px;
    transform-origin: bottom;
}

.radio-eq.playing .radio-eq-bar:nth-child(1) { animation: equalize 0.70s infinite alternate ease-in-out; }
.radio-eq.playing .radio-eq-bar:nth-child(2) { animation: equalize 0.50s infinite alternate ease-in-out 0.20s; }
.radio-eq.playing .radio-eq-bar:nth-child(3) { animation: equalize 0.80s infinite alternate ease-in-out 0.10s; }
.radio-eq.playing .radio-eq-bar:nth-child(4) { animation: equalize 0.60s infinite alternate ease-in-out 0.30s; }
.radio-eq.playing .radio-eq-bar:nth-child(5) { animation: equalize 0.70s infinite alternate ease-in-out 0.15s; }

.radio-modal-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-title);
    margin-bottom: 4px;
}

.radio-track-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    min-height: 1.2em;
}

/* زر التشغيل الكبير */
.radio-play-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gold);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 auto 22px;
    box-shadow: 0 6px 22px var(--accent-glow);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.radio-play-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 26px var(--accent-glow);
}

.radio-play-btn:active { transform: scale(0.93); }

.radio-play-btn svg {
    width: 26px;
    height: 26px;
}

.radio-play-btn.loading svg {
    animation: spin 0.9s linear infinite;
}

/* إشعار الفلاش أسفل اللوحة */
.radio-flash-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: start;
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-body);
    font-size: 0.76rem;
    line-height: 1.55;
    position: relative;
    overflow: hidden;
    animation: radio-flash-glow 2.2s infinite;
}

.radio-flash-notice svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--accent-gold);
    animation: radio-bolt-flash 1.6s infinite;
}

@keyframes radio-flash-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); border-color: var(--border-mid); }
    50%      { box-shadow: 0 0 14px 1px var(--accent-glow); border-color: var(--accent-gold); }
}

@keyframes radio-bolt-flash {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
    .radio-flash-notice,
    .radio-flash-notice svg,
    .radio-btn.on-air .radio-live-dot,
    .radio-live-pulse {
        animation: none !important;
    }
}
