/* ============ CSS VARIABLES ============ */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --accent: #2d6a4f;
    --accent-light: rgba(45, 106, 79, 0.1);
    --accent-dark: #1b4332;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --gold: #d4a574;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --sajda-color: #9333ea;
    --quran-font: 'Amiri Quran', serif;
    --arabic-font-size: 32px;
    --translation-font-size: 17px;
    --transliteration-font-size: 15px;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border: #2d3748;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* ============ SELF-HOSTED QURAN FONTS ============ */
@font-face {
    font-family: 'KFGQPC Uthmanic Hafs';
    src: url('fonts/KFGQPCHafs18.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'QPC Uthmanic Hafs';
    src: url('fonts/UthmanicHafs1-Ver09.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Uthman Taha Naskh';
    src: url('fonts/UthmanTN1-Ver10.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Uthman Taha Naskh';
    src: url('fonts/UthmanTN1B-Ver10.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'KFGQPC Hafs Smart';
    src: url('fonts/hafssmart8.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============ FONT FAMILIES ============ */
.font-amiri-quran { font-family: 'Amiri Quran', serif !important; }
.font-scheherazade { font-family: 'Scheherazade New', serif !important; }
.font-noto-naskh { font-family: 'Noto Naskh Arabic', serif !important; }
.font-noto-sans { font-family: 'Noto Sans Arabic', sans-serif !important; }
.font-lateef { font-family: 'Lateef', serif !important; }
.font-amiri { font-family: 'Amiri', serif !important; }
.font-reem-kufi { font-family: 'Reem Kufi', sans-serif !important; }
.font-aref-ruqaa { font-family: 'Aref Ruqaa', serif !important; }
.font-harmattan { font-family: 'Harmattan', sans-serif !important; }
.font-uthmanic { font-family: 'KFGQPC Uthmanic Hafs', 'Amiri Quran', serif !important; }
.font-medine-mushaf { font-family: 'QPC Uthmanic Hafs', 'KFGQPC Uthmanic Hafs', 'Amiri Quran', serif !important; }
.font-uthman-taha { font-family: 'Uthman Taha Naskh', 'Noto Naskh Arabic', serif !important; }
.font-hafs-smart { font-family: 'KFGQPC Hafs Smart', 'KFGQPC Uthmanic Hafs', 'Amiri Quran', serif !important; }

/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============ LAYOUT ============ */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    font-family: var(--quran-font);
    font-size: 24px;
    color: var(--accent);
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.sidebar-tab {
    flex: 1;
    min-width: 60px;
    padding: 10px 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    transition: all 0.2s;
    text-align: center;
}

.sidebar-tab.active {
    color: var(--accent);
    background: var(--bg-secondary);
    font-weight: 600;
}

.sidebar-tab:hover {
    color: var(--accent);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Surah List */
.surah-list {
    list-style: none;
}

.surah-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    gap: 10px;
}

.surah-item:hover {
    background: var(--accent-light);
}

.surah-item.active {
    background: var(--accent);
    color: white;
}

.surah-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.surah-item.active .surah-number {
    background: rgba(255,255,255,0.2);
}

.surah-info {
    flex: 1;
    min-width: 0;
}

.surah-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.surah-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.surah-item.active .surah-meta {
    color: rgba(255,255,255,0.8);
}

.surah-arabic {
    font-family: var(--quran-font);
    font-size: 16px;
}

/* Search */
.search-container {
    padding: 15px;
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    padding-left: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-results {
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.search-result-ref {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 5px;
}

.search-result-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Page Grid */
.page-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    padding: 10px;
}

.page-grid-item {
    padding: 8px;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.page-grid-item:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.page-grid-item.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Juz Grid */
.juz-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
}

.juz-item {
    padding: 15px 10px;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.juz-item:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.juz-number {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

.juz-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* Flow mode verse action sheet */
.flow-action-sheet {
    position: fixed;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    z-index: 1100;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
    transition: bottom 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 300px;
    max-width: 90vw;
}

.flow-action-sheet.show {
    bottom: 24px;
}

.flow-sheet-ref {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.flow-sheet-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.flow-sheet-btn {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.flow-sheet-btn:hover, .flow-sheet-btn:active {
    background: var(--accent-light);
}

.flow-sheet-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.flow-sheet-close {
    background: var(--bg-tertiary);
    min-width: 36px;
}

/* Hatim Dua */
.hatim-dua-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 10px;
    max-width: 700px;
    margin: 0 auto;
}

.hatim-dua-img {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px var(--shadow);
}

/* Bookmarks */
.bookmarks-list {
    padding: 10px;
}

.bookmark-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.bookmark-item:hover {
    background: var(--accent-light);
}

.bookmark-icon {
    font-size: 20px;
    margin-right: 12px;
    color: var(--gold);
}

.bookmark-info {
    flex: 1;
}

.bookmark-title {
    font-size: 14px;
    font-weight: 500;
}

.bookmark-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.bookmark-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.bookmark-item:hover .bookmark-delete {
    opacity: 1;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Bookmark Action Popup */
.bookmark-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s;
}

.bookmark-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.bookmark-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 1101;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.bookmark-popup.show {
    transform: translateY(0);
}

.bookmark-popup-info {
    text-align: center;
    padding: 8px 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.bookmark-popup-info strong {
    color: var(--text-primary);
}

.bookmark-popup-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    color: var(--text-primary);
    gap: 12px;
}

.bookmark-popup-btn:last-child {
    margin-bottom: 0;
}

.bookmark-popup-btn:hover,
.bookmark-popup-btn:active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.bookmark-popup-btn.move {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.bookmark-popup-btn.move:hover,
.bookmark-popup-btn.move:active {
    opacity: 0.9;
}

.bookmark-popup-btn-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.bookmark-popup-btn-text {
    flex: 1;
    text-align: left;
}

/* ============ MAIN CONTENT ============ */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 10px;
}

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

.menu-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    line-height: 1;
}

.menu-btn:hover {
    background: var(--accent-light);
}

.header-center {
    text-align: center;
    flex: 1;
    min-width: 0;
}

.current-surah {
    font-size: 16px;
    font-weight: 600;
}

.current-surah-arabic {
    font-family: var(--quran-font);
    font-size: 18px;
    color: var(--accent);
    margin-left: 8px;
}

.current-page-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    line-height: 1;
}

.icon-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.icon-btn.active {
    color: var(--accent);
    background: var(--accent-light);
}

/* View Controls */
.view-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 10px 20px;
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.view-btn-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.view-btn {
    padding: 8px 15px;
    background: var(--bg-primary);
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.view-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.view-btn.active {
    background: var(--accent);
    color: white;
}

.control-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.control-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.control-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.control-select,
.font-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    max-width: 200px;
}

.control-select:focus,
.font-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Language Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.language-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.language-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.language-section h4 {
    color: var(--accent);
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.2s;
}

.language-option:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
}

.language-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.secondary {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.modal-btn.secondary:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.05));
}

.modal-btn.primary {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--accent-dark, #155a3c);
}

.font-size-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.font-size-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.font-size-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* Main Content Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* Tefeül / Verse of Day Banner */
.verse-of-day {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.verse-of-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.verse-of-day-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tefeul-toggle {
    font-size: 16px;
    opacity: 0.8;
    transition: transform 0.2s;
}

.tefeul-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 0;
    margin-top: 0;
}

.tefeul-body.show {
    max-height: 500px;
    opacity: 1;
    margin-top: 15px;
}

.tefeul-loading {
    text-align: center;
    opacity: 0.7;
    padding: 10px 0;
    font-size: 13px;
}

.verse-of-day-ref {
    font-size: 13px;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 12px;
}

.verse-of-day-arabic {
    font-family: var(--quran-font);
    font-size: 24px;
    text-align: center;
    direction: rtl;
    margin-bottom: 15px;
    line-height: 1.8;
}

.verse-of-day-translation {
    font-size: 14px;
    text-align: center;
    opacity: 0.9;
    line-height: 1.6;
}

.tefeul-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.verse-of-day-btn {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.verse-of-day-btn:hover {
    background: rgba(255,255,255,0.3);
}

.tefeul-refresh {
    background: rgba(255,255,255,0.1);
}

.tefeul-refresh:hover {
    background: rgba(255,255,255,0.25);
}

/* Last Read Banner */
.last-read-banner {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

.last-read-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.last-read-icon {
    font-size: 24px;
    color: var(--accent);
}

.last-read-text h4 {
    font-size: 14px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.last-read-ago {
    font-size: 11px;
    font-weight: normal;
    color: var(--text-secondary);
}

.last-read-text p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.last-read-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    width: 180px;
    overflow: hidden;
    margin-bottom: 3px;
}

.last-read-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.last-read-progress-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.last-read-btn {
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Quran Container */
.quran-container {
    max-width: 900px;
    margin: 0 auto;
}

.quran-container.two-page-view {
    max-width: 1400px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Page */
.quran-page {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.page-number {
    font-size: 13px;
    color: var(--text-secondary);
}

.page-juz {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

/* Surah Header */
.surah-header {
    text-align: center;
    padding: 20px;
    margin: 15px 0;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: 12px;
    color: white;
}

.surah-header-arabic {
    font-family: var(--quran-font);
    font-size: 28px;
    margin-bottom: 5px;
}

.surah-header-english {
    font-size: 14px;
    opacity: 0.9;
}

.surah-header-meta {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 5px;
}

/* Bismillah */
.bismillah {
    text-align: center;
    font-family: var(--quran-font);
    font-size: 26px;
    color: var(--accent);
    padding: 15px;
    margin: 10px 0;
}

/* Verse */
.verse {
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.verse:last-child {
    border-bottom: none;
}

.verse.highlighted,
.verse.verse-highlight {
    background: var(--accent-light);
    margin: 0 -15px;
    padding: 15px;
    border-radius: 8px;
}

.verse.verse-highlight {
    animation: highlightPulse 3s ease-out;
}

@keyframes highlightPulse {
    0% {
        background: var(--accent);
        box-shadow: 0 0 20px var(--accent);
    }
    100% {
        background: var(--accent-light);
        box-shadow: none;
    }
}

.verse.now-playing {
    background: linear-gradient(135deg, var(--accent-light) 0%, rgba(30, 107, 78, 0.15) 100%);
    border-left: 3px solid var(--accent);
    margin-left: -3px;
}

/* Sajda Verse Styling */
.verse.sajda-verse {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.1) 0%, rgba(147, 51, 234, 0.05) 100%);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    border-left: 3px solid var(--sajda-color);
}

.sajda-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--sajda-color);
    color: white;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    margin-left: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

/* Sajda Sidebar Panel */
.sajda-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.1) 0%, rgba(147, 51, 234, 0.05) 100%);
    border-bottom: 1px solid var(--border);
}

.sajda-header-icon {
    font-size: 32px;
}

.sajda-header h4 {
    margin: 0;
    color: var(--sajda-color);
    font-size: 16px;
}

.sajda-header p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.sajda-list {
    padding: 10px;
}

.sajda-list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sajda-list-item:hover {
    background: rgba(147, 51, 234, 0.1);
    border-color: var(--sajda-color);
    transform: translateX(3px);
}

.sajda-list-icon {
    font-size: 24px;
    margin-right: 12px;
}

.sajda-list-info {
    flex: 1;
}

.sajda-list-surah {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.sajda-list-ayah {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Sajda Popup */
.sajda-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sajda-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sajda-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-secondary);
    border: 2px solid var(--sajda-color);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    z-index: 1101;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.sajda-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.sajda-popup-icon {
    font-size: 56px;
    margin-bottom: 15px;
}

.sajda-popup h3 {
    color: var(--sajda-color);
    margin: 0 0 15px;
    font-size: 22px;
}

.sajda-popup p {
    color: var(--text-secondary);
    margin: 0 0 25px;
    line-height: 1.6;
    font-size: 15px;
}

.sajda-popup-btn {
    background: var(--sajda-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
}

.sajda-popup-btn:hover {
    background: #7c22ce;
}

.verse-arabic {
    direction: rtl;
    text-align: right;
    margin-bottom: 12px;
    line-height: 2.2;
}

.verse-text {
    font-family: var(--quran-font);
    font-size: var(--arabic-font-size);
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.verse-text:hover {
    background: var(--accent-light);
}

/* Durak / Waqf (Stop Sign) Marks */
.waqf-mark {
    color: var(--waqf-color, #c41e3a);
    font-weight: bold;
    position: relative;
    cursor: help;
}
[data-theme="dark"] .waqf-mark { --waqf-color: #ff6b6b; }
.waqf-mark[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    right: 50%;
    transform: translateX(50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: system-ui, sans-serif;
    white-space: nowrap;
    z-index: 100;
    direction: ltr;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Durak Legend */
.waqf-legend-wrapper { position: relative; display: inline-block; }
.waqf-legend-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s;
}
.waqf-legend-btn:hover, .waqf-legend-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
}
.waqf-legend-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
}
.waqf-legend-panel.show { display: block; }

/* Mobile: show as bottom sheet instead of dropdown */
@media (max-width: 1024px) {
    .waqf-legend-panel.mobile-sheet {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
        min-width: unset;
        width: 100%;
        z-index: 1050;
        padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
    }
    /* Dim background behind sheet */
    body.waqf-sheet-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1049;
    }
}
.waqf-legend-title { font-weight: 600; font-size: 14px; margin-bottom: 12px; color: var(--text-primary); }
.waqf-legend-item { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.waqf-legend-item:last-child { border-bottom: none; }
.waqf-legend-symbol { font-size: 22px; color: var(--waqf-color, #c41e3a); min-width: 32px; text-align: center; font-family: 'Scheherazade New', 'Amiri Quran', serif; }
.waqf-legend-info { flex: 1; }
.waqf-legend-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.waqf-legend-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.waqf-legend-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin: 10px 0 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.waqf-legend-cat:first-of-type { margin-top: 4px; border-top: none; padding-top: 0; }

/* Tajweed marks — subtler color */
.tajweed-mark {
    color: var(--tajweed-color, #1a73e8);
    font-weight: normal;
}
[data-theme="dark"] .tajweed-mark { --tajweed-color: #8ab4f8; }

/* Surah alternative names */
.surah-alt-name { font-size: 0.85em; opacity: 0.6; font-weight: normal; }
.surah-alt-arabic { font-size: 0.8em; opacity: 0.6; }

/* Arabic-only flow mode — verses run continuously like a traditional mushaf page */
.quran-page.arabic-flow .surah-verses {
    direction: rtl;
    text-align: justify;
    line-height: 2.4;
    padding: 0 4px;
}

.quran-page.arabic-flow .verse {
    display: inline;
    padding: 0;
    border-bottom: none;
    position: static;
    background: none !important;
    border-left: none !important;
    margin: 0 !important;
}

.quran-page.arabic-flow .verse-arabic {
    display: inline;
    margin-bottom: 0;
    direction: rtl;
}

.quran-page.arabic-flow .verse-actions,
.quran-page.arabic-flow .bookmark-ribbon {
    display: none;
}

/* Bookmarked verse number ring in flow mode */
.quran-page.arabic-flow .verse-number.bookmarked {
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--accent);
}

/* Selected verse highlight in flow mode — box-decoration-break makes it wrap correctly */
.quran-page.arabic-flow .verse.flow-selected .verse-text {
    background: var(--accent-light);
    border-radius: 3px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.quran-page.arabic-flow .sajda-badge {
    font-size: 11px;
    vertical-align: super;
    margin: 0 2px;
}

/* Word-by-Word Mode */
.verse-arabic.wbw-mode {
    direction: rtl;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.8;
}

.wbw-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    flex: 1;
}

.wbw-word {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 60px;
}

.wbw-word:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.wbw-arabic {
    font-family: var(--quran-font);
    font-size: calc(var(--arabic-font-size) * 0.85);
    color: var(--text-primary);
    margin-bottom: 4px;
    direction: rtl;
}

.wbw-translation {
    font-size: 11px;
    color: var(--accent);
    font-weight: 500;
    max-width: 100px;
    line-height: 1.3;
}

.wbw-transliteration {
    font-size: 10px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 2px;
}

.wbw-loading {
    display: block;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 20px;
    font-style: italic;
}

.verse-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    margin: 0 8px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.verse-transliteration {
    font-size: var(--transliteration-font-size);
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 10px;
    line-height: 1.6;
}

.verse-translation {
    font-size: var(--translation-font-size);
    color: var(--text-secondary);
    line-height: 1.7;
}

.translation-item {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}

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

.translation-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 3px;
}

/* Verse Actions */
.verse-actions {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    gap: 5px;
    z-index: 10;
}

.verse:hover .verse-actions {
    display: flex;
}

.verse-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 5px var(--shadow);
    transition: all 0.2s;
}

.verse-action-btn:hover {
    background: var(--accent);
    color: white;
}

.verse-action-btn.bookmarked {
    color: var(--gold);
}

/* Bookmark Ribbon - visible on the right edge of bookmarked verses */
.bookmark-ribbon {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 40px;
    cursor: pointer;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s;
}

.bookmark-ribbon::after {
    content: '';
    position: absolute;
    top: 0;
    right: 8px;
    width: 18px;
    height: 36px;
    background: var(--gold, #c9a227);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
    opacity: 0.25;
    transition: opacity 0.2s;
}

.bookmark-ribbon:hover::after {
    opacity: 0.5;
}

.verse:hover .bookmark-ribbon {
    opacity: 1;
}

.bookmark-ribbon.active {
    opacity: 1;
}

.bookmark-ribbon.active::after {
    opacity: 1;
    box-shadow: 0 2px 6px rgba(201, 162, 39, 0.4);
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 15px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ AUDIO PLAYER ============ */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    display: none;
    align-items: center;
    gap: 15px;
    z-index: 200;
    box-shadow: 0 -4px 12px var(--shadow);
}

.audio-player.visible {
    display: flex;
}

.audio-info {
    flex: 0 0 auto;
    max-width: 200px;
}

.audio-surah {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-verse {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.audio-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn.play-btn {
    background: var(--accent);
    color: white;
    width: 50px;
    height: 50px;
    font-size: 20px;
}

.audio-btn.play-btn:hover {
    transform: scale(1.05);
}

.audio-btn:not(.play-btn) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.audio-btn:not(.play-btn):hover {
    background: var(--accent-light);
    color: var(--accent);
}

.audio-progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-progress {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.audio-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s;
}

.audio-time {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 40px;
}

.audio-reciter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    max-width: 150px;
}

.audio-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px;
}

/* Repeat Controls */
.audio-repeat-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.repeat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.repeat-count-input {
    width: 40px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ============ SETTINGS PANEL ============ */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: -4px 0 20px var(--shadow);
    z-index: 201;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.settings-panel.open {
    right: 0;
}

.settings-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-title {
    font-size: 18px;
    font-weight: 600;
}

.settings-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-label {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
    display: block;
    color: var(--text-secondary);
}

.setting-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Multi-select for translations */
.translation-checkboxes {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
}

.translation-group-header {
    font-weight: 600;
    font-size: 12px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 8px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    margin-top: 8px;
}

.translation-group-header:first-child {
    margin-top: 0;
    padding-top: 4px;
}

.translation-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 14px;
}

.translation-checkbox-item:hover {
    background: var(--bg-tertiary);
}

.translation-checkbox-item input {
    margin-right: 10px;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Daily Goal */
.daily-goal {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    margin-top: 15px;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.goal-title {
    font-size: 14px;
    font-weight: 500;
}

.goal-progress-text {
    font-size: 13px;
    color: var(--accent);
}

.goal-progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.goal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    border-radius: 5px;
    transition: width 0.3s;
}

/* Install Banner */
.install-banner {
    display: none;
    background: linear-gradient(135deg, var(--accent) 0%, #155a3c 100%);
    color: white;
    padding: 12px 20px;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
}

.install-banner.show {
    display: flex;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-banner-icon {
    font-size: 28px;
}

.install-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-banner-text strong {
    font-size: 14px;
}

.install-banner-text span {
    font-size: 12px;
    opacity: 0.9;
}

.install-banner-actions {
    display: flex;
    gap: 10px;
}

.install-banner-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.install-banner-btn.primary {
    background: white;
    color: var(--accent);
    border: none;
}

.install-banner-btn.primary:hover {
    background: #f0f0f0;
}

.install-banner-btn.secondary {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
}

.install-banner-btn.secondary:hover {
    background: rgba(255,255,255,0.1);
}

.install-btn {
    color: var(--accent) !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Scroll to Top */
.scroll-top-btn {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    right: calc(30px + env(safe-area-inset-right, 0px));
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 100;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top-btn:hover {
    transform: translateY(-3px);
}

/* Auto-Scroll Controls */
.auto-scroll-controls {
    position: fixed;
    bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    right: calc(30px + env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 100;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.auto-scroll-controls:hover,
.auto-scroll-controls.active {
    opacity: 1;
}

.auto-scroll-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-scroll-controls.active .auto-scroll-toggle {
    background: #e74c3c;
}

.auto-scroll-toggle:hover {
    transform: translateY(-2px);
}

.auto-scroll-speed {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 6px;
    box-shadow: 0 2px 8px var(--shadow);
}

.auto-scroll-speed input[type="range"] {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 6px;
    height: 140px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.auto-scroll-speed input[type="range"]::-webkit-slider-runnable-track {
    width: 6px;
    height: 100%;
    background: var(--border);
    border-radius: 3px;
}

.auto-scroll-speed input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: -6px;
    cursor: pointer;
}

.auto-scroll-speed input[type="range"]::-moz-range-track {
    width: 6px;
    background: var(--border);
    border-radius: 3px;
}

.auto-scroll-speed input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
}

.auto-scroll-speed-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .quran-container.two-page-view {
        grid-template-columns: 1fr;
        max-width: 900px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 150;
        width: 85vw;
        max-width: 320px;
        transform: translateX(-100%);
        pointer-events: none;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left, 0px);
    }

    .sidebar.open {
        transform: translateX(0);
        pointer-events: auto;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 140;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        pointer-events: none;
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .header {
        padding: 8px 10px;
        z-index: 130;
        flex-wrap: nowrap;
        overflow: visible;
    }

    .header-center {
        flex: 1;
        margin: 0 5px;
    }

    .current-surah {
        font-size: 13px;
    }

    .current-surah-arabic {
        font-size: 15px;
        margin-left: 5px;
    }

    .current-page-info {
        font-size: 10px;
    }

    .header-right {
        gap: 2px;
        flex-shrink: 0;
    }

    .icon-btn {
        padding: 6px;
        font-size: 16px;
        flex-shrink: 0;
    }

    /* Hide install button on very small screens when installed as PWA */
    .install-btn {
        display: none !important;
    }

    /* Ensure auth button is always visible */
    .auth-btn {
        display: flex !important;
    }

    /* Make user avatar smaller on mobile */
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .view-controls {
        padding: 8px 10px;
        gap: 8px;
    }

    .control-divider {
        display: none;
    }

    .control-select,
    .font-select {
        font-size: 12px;
        padding: 6px 8px;
        max-width: 150px;
    }

    .control-btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    .view-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .font-size-control {
        gap: 5px;
    }

    .font-size-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        -webkit-appearance: none;
        appearance: none;
        user-select: none;
        -webkit-user-select: none;
        position: relative;
        z-index: 10;
    }

    .font-size-btn:active {
        background: var(--accent-light);
        transform: scale(0.95);
    }

    #fontSizeDisplay {
        font-size: 12px;
        min-width: 40px;
        text-align: center;
    }

    .language-modal {
        width: 95%;
        max-height: 85vh;
    }

    .language-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 10px;
    }

    .quran-page {
        padding: 15px;
    }

    .verse-text {
        font-size: var(--arabic-font-size);
    }

    .audio-player {
        flex-wrap: wrap;
        padding: 10px;
        gap: 10px;
    }

    .audio-progress-container {
        order: 10;
        width: 100%;
        flex: none;
    }

    .audio-reciter-select {
        display: none;
    }

    .scroll-top-btn {
        bottom: 100px;
        right: 15px;
        width: 45px;
        height: 45px;
    }

    .auto-scroll-controls {
        bottom: 80px;
        right: auto;
        left: 10px;
        opacity: 0.6;
        flex-direction: row;
        gap: 6px;
    }

    .auto-scroll-controls:active,
    .auto-scroll-controls:focus-within {
        opacity: 1;
    }

    .auto-scroll-toggle {
        width: 44px;
        height: 44px;
        font-size: 18px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* Hide speed slider when autoscroll is active — just show play/pause */
    .auto-scroll-controls.active .auto-scroll-speed {
        display: none;
    }

    .auto-scroll-speed {
        flex-direction: row;
        padding: 6px 10px;
        gap: 6px;
    }

    .auto-scroll-speed input[type="range"] {
        writing-mode: horizontal-tb;
        direction: ltr;
        width: 140px;
        height: 6px;
    }

    .auto-scroll-speed input[type="range"]::-webkit-slider-thumb {
        margin-top: -6px;
        margin-left: 0;
    }

    /* ---- Reader mode (auto-scroll active on mobile) ---- */
    .header {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    .view-controls {
        transition: transform 0.3s ease, opacity 0.3s ease, max-height 0.3s ease;
        overflow: hidden;
    }

    body.reader-mode .header {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }
    body.reader-mode .view-controls {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-bottom: none;
        pointer-events: none;
    }
    body.reader-mode .verse-of-day,
    body.reader-mode .last-read-banner,
    body.reader-mode .install-banner {
        display: none !important;
    }
    body.reader-mode .scroll-top-btn {
        display: none !important;
    }

    /* When header peeks back on tap */
    body.reader-mode.header-peek .header {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .verse-of-day {
        margin: 10px;
        padding: 15px;
    }

    .verse-of-day-arabic {
        font-size: 20px;
    }

    .last-read-banner {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        margin: 10px;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* ============ FIREBASE AUTH ============ */

/* Sync Indicator */
.sync-indicator {
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    cursor: help;
}

.sync-indicator.synced {
    color: var(--success);
}

.sync-indicator.syncing {
    animation: spin 1s linear infinite;
}

.sync-indicator.error {
    color: var(--danger);
}

.sync-indicator.offline {
    color: var(--text-secondary);
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--shadow);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

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

.user-dropdown-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.user-email {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 15px;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.user-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.user-dropdown-item:last-child {
    border-radius: 0 0 12px 12px;
}

/* Auth Modal */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1099;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.auth-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.auth-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 420px;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
}

.auth-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
}

.auth-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.auth-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.auth-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.auth-modal-body {
    padding: 25px;
}

.auth-error {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 15px;
}

.auth-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.auth-form-group {
    margin-bottom: 18px;
}

.auth-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.auth-form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    margin-top: 10px;
}

.auth-btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 25px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

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

.auth-divider span {
    padding: 0 15px;
}

.auth-btn-google {
    width: 100%;
    padding: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, border-color 0.2s;
}

.auth-btn-google:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.auth-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 25px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    transition: color 0.2s;
}

.auth-link:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

.auth-info {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.auth-modal-footer {
    padding: 15px 25px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-modal-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Responsive Auth */
@media (max-width: 1024px) {
    .auth-modal {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .auth-modal-header {
        padding: 15px 20px;
    }

    .auth-modal-body {
        padding: 20px;
    }

    .user-dropdown {
        right: -10px;
    }
}

/* ============ RTL SUPPORT ============ */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-left: 1px solid var(--border);
    border-right: none;
}

[dir="rtl"] .app-content {
    margin-left: 0;
    margin-right: 300px;
}

[dir="rtl"] .header-left,
[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}

[dir="rtl"] .sidebar-toggle {
    left: auto;
    right: 10px;
}

[dir="rtl"] .verse-number {
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .verse-actions {
    left: 10px;
    right: auto;
}

[dir="rtl"] .bookmark-ribbon {
    right: auto;
    left: 0;
}

[dir="rtl"] .bookmark-ribbon::after {
    right: auto;
    left: 8px;
}

[dir="rtl"] .settings-panel {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

[dir="rtl"] .settings-panel.open {
    transform: translateX(0);
}

[dir="rtl"] .setting-toggle {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-arrows {
    flex-direction: row-reverse;
}

@media (max-width: 1024px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] .sidebar.open {
        transform: translateX(0);
    }

    [dir="rtl"] .app-content {
        margin-right: 0;
    }
}
