/* ============================================================
   PORTAL SDM SERUT - AL-QUR'AN & HADIST STYLESHEET
   Desain Selaras, Ringan, Mobile-First, Bebas Egress
   ============================================================ */

:root {
    --primary: #059669;
    --primary-dark: #046c4e;
    --primary-light: #10b981;
    --primary-subtle: #ecfdf5;
    --primary-gradient: linear-gradient(135deg, #046c4e 0%, #059669 50%, #10b981 100%);
    --accent: #f59e0b;
    --accent-gold: #d97706;
    --accent-gold-subtle: #fef3c7;
    --danger: #ef4444;
    
    --bg-app: #f0fdf4;
    --bg-reader: #f6f0e4;
    --bg-card: #ffffff;
    --bg-ayah: #fffdf8;
    --bg-secondary: #f8fafc;
    --text-main: #0f172a;
    --text-arabic: #1c1917;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-card: rgba(5, 150, 105, 0.12);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 12px 28px rgba(5, 150, 105, 0.16);
    
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    /* Prioritas font Quran: Scheherazade New (Uthmani tercantik) -> Amiri Quran -> Amiri -> Noto Naskh */
    --font-arabic: 'Scheherazade New', 'Amiri Quran', 'Amiri', 'Noto Naskh Arabic', 'Traditional Arabic', serif;
    --font-arabic-ornament: 'Amiri', 'Scheherazade New', serif;
    
    /* Ukuran font default untuk desktop */
    --arabic-font-size: 36px;
    --arabic-line-height: 2.8;
    --arabic-word-spacing: 0.12em;
}

/* Dark Theme (selaras dengan portal & e-presensi) */
body.dark-theme {
    --bg-app: #0b1320;
    --bg-reader: #14110d;
    --bg-card: #152238;
    --bg-ayah: #1b1712;
    --bg-secondary: #1a2a44;
    --text-main: #f1f5f9;
    --text-arabic: #f5efe4;
    --text-muted: #94a3b8;
    --border: #233554;
    --border-card: rgba(16, 185, 129, 0.2);
    --primary-subtle: rgba(16, 185, 129, 0.15);
    --accent-gold-subtle: rgba(245, 158, 11, 0.15);
    --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* Dark mode untuk teks Arab */
body.dark-theme .ayah-arabic,
body.dark-theme .hadist-arabic,
body.dark-theme .bismillah-arabic {
    color: #f5efe4;
}

body.dark-theme .bismillah-arabic {
    color: #5eead4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body.reader-mode {
    background: var(--bg-reader);
}

body.reader-mode .quran-container {
    max-width: 760px;
}

body.reader-mode .tab-switcher-wrap {
    display: none;
}

/* ============================================================
   HEADER UTAMA (SELARAS SUB-MODUL PORTAL)
   ============================================================ */
.quran-header {
    background: var(--primary-gradient);
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(4, 108, 78, 0.25);
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 14px;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.btn-back-portal {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-back-portal:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateX(-2px);
}

.header-brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header-brand h1 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-brand p {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.btn-icon-head {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-head:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   CONTAINER UTAMA
   ============================================================ */
.quran-container {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
    flex: 1;
}

/* ============================================================
   TABS NAVIGASI (AL-QUR'AN & HADIST)
   ============================================================ */
.tab-switcher-wrap {
    background: var(--bg-card);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn i {
    font-size: 18px;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

/* ============================================================
   CARD LAST READ (TERAKHIR DIBACA)
   ============================================================ */
.card-last-read {
    background: linear-gradient(135deg, #046c4e 0%, #059669 60%, #10b981 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 24px rgba(4, 108, 78, 0.22);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-last-read:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(4, 108, 78, 0.3);
}

.card-last-read::after {
    content: '📖';
    position: absolute;
    right: -10px;
    bottom: -15px;
    font-size: 80px;
    opacity: 0.15;
    pointer-events: none;
}

.last-read-info {
    position: relative;
    z-index: 1;
}

.last-read-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 20px;
    margin-bottom: 6px;
}

.last-read-surah {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 2px;
}

.last-read-detail {
    font-size: 12px;
    opacity: 0.9;
}

.btn-continue-read {
    background: #ffffff;
    color: var(--primary-dark);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* ============================================================
   SEARCH BAR CLIENT-SIDE
   ============================================================ */
.search-container {
    margin-bottom: 18px;
}

.search-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-box i.search-icon {
    position: absolute;
    left: 14px;
    font-size: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 13px 42px 13px 44px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 12.5px;
}

.btn-clear-search {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
}

.btn-clear-search:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================================
   GRID & LIST SURAT
   ============================================================ */
.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.surah-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.surah-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.surah-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(5, 150, 105, 0.3);
}

.surah-card:hover::before {
    opacity: 1;
}

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

.surah-number-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--primary-subtle);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    flex-shrink: 0;
    border: 1px solid rgba(5, 150, 105, 0.15);
}

.surah-meta {
    min-width: 0;
}

.surah-name-latin {
    font-family: var(--font-heading);
    font-size: 14.5px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.surah-info-sub {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.surah-badge-revelation {
    font-size: 9.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.surah-card-right {
    text-align: right;
    flex-shrink: 0;
}

.surah-name-arabic {
    font-family: var(--font-arabic);
    font-size: 20px;
    color: var(--primary);
    font-weight: 700;
    direction: rtl;
    line-height: 1.2;
}

/* ============================================================
   SURAH READER VIEW (DETAIL AYAT)
   ============================================================ */
#surahReaderView {
    display: none;
}

.reader-nav-wrap {
    position: sticky;
    top: 68px;
    z-index: 90;
    margin-bottom: 16px;
}

.reader-nav-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

.btn-back-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back-list:hover {
    background: var(--primary-subtle);
    color: var(--primary);
}

.reader-title-box {
    text-align: center;
    flex: 1;
    min-width: 0;
}

.reader-title-main {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-title-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.reader-font-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.btn-font-size {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 11px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-font-size:hover {
    background: rgba(0, 0, 0, 0.05);
}

.reader-view-toggles {
    display: flex;
    gap: 8px;
    padding: 8px 12px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.btn-view-opt {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
}

.btn-view-opt.active {
    background: var(--primary-subtle);
    color: var(--primary-dark);
    border-color: rgba(5, 150, 105, 0.28);
}

body.dark-theme .btn-view-opt.active {
    color: var(--primary-light);
}

body.hide-latin .ayah-latin {
    display: none;
}

body.hide-translation .ayah-translation {
    display: none;
}

/* Bismillah Box */
.bismillah-box {
    background: var(--bg-ayah);
    border: 1px solid rgba(180, 140, 70, 0.22);
    border-radius: var(--radius-lg);
    padding: 28px 18px 22px;
    text-align: center;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.bismillah-arabic {
    font-family: var(--font-arabic-ornament);
    font-size: 36px;
    font-weight: 400;
    color: #0b5a3a;
    direction: rtl;
    line-height: 2.3;
    margin-bottom: 8px;
    word-spacing: 0.1em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: subpixel-antialiased;
    font-kerning: normal;
    font-variant-ligatures: common-ligatures contextual;
}

.bismillah-translation {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================================
   TAJWID LEGEND PANEL - WARNA WARNI SEPERTI APLIKASI HIJRAH
   ============================================================ */
.tajwid-legend-box {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.tajwid-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.tajwid-legend-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 800;
    color: var(--text-main);
}

.tajwid-close-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tajwid-close-btn:hover {
    background: var(--danger);
    color: #fff;
}

.tajwid-legend-box {
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.tajwid-legend-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-flow: row;
    gap: 10px 12px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.tajwid-item {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 11px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: transform 0.15s ease, border-color 0.15s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.tajwid-item:hover {
    transform: translateY(-1px);
    border-color: rgba(5, 150, 105, 0.35);
}

.tajwid-swatch {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    align-self: flex-start;
    border: 1.5px solid rgba(0,0,0,0.12);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35),
                0 1px 2px rgba(0,0,0,0.06);
}

.tajwid-info {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.tajwid-name {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 3px;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: block;
}

.tajwid-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: break-word;
    display: block;
}

/* WARNA-WARNA TAJWID (Standar aplikasi Quran Indonesia) */
.tajwid-nun-sukun {
    background: #0f766e;
}
.tajwid-izhar {
    background: #2563eb;
}
.tajwid-iqlab {
    background: #7c3aed;
}
.tajwid-idgham-bighunah {
    background: #db2777;
}
.tajwid-idgham-bilaghunah {
    background: #059669;
}
.tajwid-ikhfa {
    background: #b45309;
}
.tajwid-qalqalah {
    background: #991b1b;
}
.tajwid-madd {
    background: #ca8a04;
}
.tajwid-madd-fari {
    background: #0891b2;
}
.tajwid-ghunnah {
    background: #be185d;
}
.tajwid-waqaf {
    background: #4f46e5;
}
.tajwid-lam-syamsiah {
    background: #0ea5e9;
}

.tajwid-note {
    font-size: 10.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--primary-subtle);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}

/* Dark mode tajwid */
body.dark-theme .tajwid-legend-box {
    background: #1e293b;
    border-color: rgba(16, 185, 129, 0.15);
}
body.dark-theme .tajwid-item {
    background: #0f172a;
    border-color: var(--border);
}
body.dark-theme .tajwid-note {
    background: rgba(16, 185, 129, 0.12);
    color: var(--primary-light);
}

/* Mobile: 2 kolom agar muat — !important WAJIB untuk override desktop !important */
@media (max-width: 640px) {
    .tajwid-legend-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
    }
    .tajwid-item {
        padding: 7px 8px;
        gap: 7px;
        flex-direction: column !important;
        align-items: center;
        text-align: center;
    }
    .tajwid-swatch {
        width: 26px;
        height: 26px;
        align-self: center;
    }
    .tajwid-info {
        text-align: center;
    }
    .tajwid-name {
        font-size: 11px;
    }
    .tajwid-desc {
        font-size: 9.5px;
        line-height: 1.3;
    }
    .tajwid-legend-box {
        padding: 12px 10px;
    }
    .tajwid-legend-title {
        font-size: 13px;
    }
    .tajwid-note {
        font-size: 10px;
        padding: 7px 10px;
        line-height: 1.4;
    }
}

/* ============================================================
   INLINE TAJWID COLORS - WARNA PADA TEKS SAJA (NO BACKGROUND)
   🔴 SCOPE HANYA ke .ayah-arabic DAN .hadist-arabic AGAR TIDAK MERUSAK
      .tajwid-swatch / .tajwid-item di LEGENDA PANEL (swatch jadi putih bug)
   * NO FONT-WEIGHT CHANGE * agar harakat/tashkeel tidak tumpang tindih
   ============================================================ */
body.tajwid-colored .ayah-arabic [class*="tajwid-"],
body.tajwid-colored .hadist-arabic [class*="tajwid-"] {
    font-weight: inherit !important;
    display: inline;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    vertical-align: baseline !important;
    line-height: inherit !important;
    background: transparent !important;
    box-decoration-break: slice;
    -webkit-box-decoration-break: slice;
    text-shadow: none !important;
    letter-spacing: inherit !important;
    word-spacing: inherit !important;
}

/* HANYA WARNA TEKS, TIDAK ADA BACKGROUND SAMA SEKALI, JANGAN UBAH FONT-APAPUN LAIN */
/* 🔴 SCOPE HANYA di .ayah-arabic & .hadist-arabic AGAR TIDAK MEMPENGARUHI LEGENDA */
body.tajwid-colored .ayah-arabic .tajwid-nun-sukun,
body.tajwid-colored .ayah-arabic .tajwid-tanwin,
body.tajwid-colored .hadist-arabic .tajwid-nun-sukun,
body.tajwid-colored .hadist-arabic .tajwid-tanwin {
    color: #0f766e;
}
body.tajwid-colored .ayah-arabic .tajwid-izhar,
body.tajwid-colored .hadist-arabic .tajwid-izhar {
    color: #2563eb;
}
body.tajwid-colored .ayah-arabic .tajwid-iqlab,
body.tajwid-colored .hadist-arabic .tajwid-iqlab {
    color: #7c3aed;
}
body.tajwid-colored .ayah-arabic .tajwid-idgham-bighunah,
body.tajwid-colored .hadist-arabic .tajwid-idgham-bighunah {
    color: #db2777;
}
body.tajwid-colored .ayah-arabic .tajwid-idgham-bilaghunah,
body.tajwid-colored .hadist-arabic .tajwid-idgham-bilaghunah {
    color: #059669;
}
body.tajwid-colored .ayah-arabic .tajwid-ikhfa,
body.tajwid-colored .hadist-arabic .tajwid-ikhfa {
    color: #92400e;
}
body.tajwid-colored .ayah-arabic .tajwid-qalqalah,
body.tajwid-colored .hadist-arabic .tajwid-qalqalah {
    color: #991b1b;
}
body.tajwid-colored .ayah-arabic .tajwid-madd,
body.tajwid-colored .hadist-arabic .tajwid-madd {
    color: #a16207;
}
body.tajwid-colored .ayah-arabic .tajwid-madd-fari,
body.tajwid-colored .hadist-arabic .tajwid-madd-fari {
    color: #0e7490;
}
body.tajwid-colored .ayah-arabic .tajwid-ghunnah,
body.tajwid-colored .hadist-arabic .tajwid-ghunnah {
    color: #be185d;
}
body.tajwid-colored .ayah-arabic .tajwid-waqaf,
body.tajwid-colored .hadist-arabic .tajwid-waqaf {
    color: #4338ca;
}
body.tajwid-colored .ayah-arabic .tajwid-lam-syamsiah,
body.tajwid-colored .hadist-arabic .tajwid-lam-syamsiah {
    color: #0284c7;
}
body.tajwid-colored .ayah-arabic .tajwid-mim-sukun,
body.tajwid-colored .hadist-arabic .tajwid-mim-sukun {
    color: #7e22ce;
}
body.tajwid-colored .ayah-arabic .tajwid-idgham-mimi,
body.tajwid-colored .hadist-arabic .tajwid-idgham-mimi {
    color: #9f1239;
}
body.tajwid-colored .ayah-arabic .tajwid-ikhfa-syafawi,
body.tajwid-colored .ayah-arabic .tajwid-ikhfa-mimi,
body.tajwid-colored .hadist-arabic .tajwid-ikhfa-syafawi,
body.tajwid-colored .hadist-arabic .tajwid-ikhfa-mimi {
    color: #854d0e;
}

/* Dark mode: warna teks lebih cerah tapi tetap hanya warna teks */
/* 🔴 SCOPE HANYA di .ayah-arabic & .hadist-arabic AGAR TIDAK RUSAK LEGENDA */
body.dark-theme.tajwid-colored .ayah-arabic [class*="tajwid-"],
body.dark-theme.tajwid-colored .hadist-arabic [class*="tajwid-"] {
    background: transparent !important;
    font-weight: inherit !important;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-nun-sukun,
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-tanwin,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-nun-sukun,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-tanwin {
    color: #2dd4bf;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-izhar,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-izhar {
    color: #60a5fa;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-iqlab,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-iqlab {
    color: #c4b5fd;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-idgham-bighunah,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-idgham-bighunah {
    color: #f472b6;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-idgham-bilaghunah,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-idgham-bilaghunah {
    color: #34d399;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-ikhfa,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-ikhfa {
    color: #fbbf24;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-qalqalah,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-qalqalah {
    color: #f87171;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-madd,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-madd {
    color: #fde047;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-madd-fari,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-madd-fari {
    color: #22d3ee;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-ghunnah,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-ghunnah {
    color: #f9a8d4;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-waqaf,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-waqaf {
    color: #a5b4fc;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-lam-syamsiah,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-lam-syamsiah {
    color: #38bdf8;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-mim-sukun,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-mim-sukun {
    color: #c084fc;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-idgham-mimi,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-idgham-mimi {
    color: #fb7185;
}
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-ikhfa-syafawi,
body.dark-theme.tajwid-colored .ayah-arabic .tajwid-ikhfa-mimi,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-ikhfa-syafawi,
body.dark-theme.tajwid-colored .hadist-arabic .tajwid-ikhfa-mimi {
    color: #fde047;
}

.ayah-sheet {
    background: var(--bg-ayah);
    border: 1px solid rgba(180, 140, 70, 0.2);
    border-radius: var(--radius-lg);
    padding: 8px 6px;
    box-shadow: var(--shadow-sm);
}

/* Ayah Card */
.ayah-card {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(180, 140, 70, 0.16);
    border-radius: 0;
    padding: 22px 18px 20px;
    margin-bottom: 0;
    box-shadow: none;
    transition: background 0.2s ease;
}

.ayah-card:last-child {
    border-bottom: none;
}

.ayah-card.bookmarked {
    background: linear-gradient(90deg, var(--accent-gold-subtle) 0%, transparent 70%);
}

.ayah-card.ayah-active {
    background: rgba(5, 150, 105, 0.08);
}

.ayah-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ayah-badge {
    background: var(--primary-subtle);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.ayah-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-ayah-action {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.btn-ayah-action:hover {
    background: var(--bg-secondary);
    color: var(--text-main);
}

.btn-ayah-action.active-bookmark {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.ayah-arabic {
    font-family: var(--font-arabic);
    font-size: var(--arabic-font-size);
    font-weight: 400;
    color: #1a1a1a;
    direction: rtl;
    unicode-bidi: isolate;
    text-align: justify;
    text-align-last: right;
    line-height: var(--arabic-line-height);
    margin-bottom: 20px;
    word-spacing: var(--arabic-word-spacing);
    letter-spacing: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-kerning: normal;
    font-variant-ligatures: common-ligatures contextual;
    font-feature-settings: "kern", "liga", "clig", "calt";
}

/* ============================================================
   AYAH END MARK - SVG CUSTOM ORNAMEN ISLAM
   ✅ Bingkai ornamen 8 penjuru KHAS MUSHAF (render via SVG di JS)
   ✅ Semua detail ornamen (pucuk, bulatan, lekukan) di SVG native
   ✅ Overflow:visible agar ornamen luar TIDAK TERPUTUS
   ============================================================ */
.ayah-end-mark {
    display: inline-grid;
    place-items: center;
    position: relative;
    flex-shrink: 0;
    /* Ukuran PROPORSIONAL dengan stroke TEBAL — tetap kompak, tidak besar */
    width: 1.18em;
    height: 1.18em;
    margin-right: 0.08em;
    margin-left: 0.06em;
    vertical-align: -0.09em;
    /* OVERFLOW VISIBLE — ornamen luar SVG TIDAK BOLEH DIPOTONG */
    overflow: visible;
    border-radius: 0;
    background: transparent;
    border: none;
    box-sizing: border-box;
    z-index: 1;
}

.ayah-frame-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    z-index: 1;
}

/* NOMOR AYAT — LETAK TEPAT DI TENGAH LINGKARAN SVG */
.ayah-end-mark > .ayah-num-span {
    position: relative;
    z-index: 5;
    grid-area: 1 / 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    font-family: var(--font-arabic);
    /* Ukuran TEBAL & JELAS — muat 1, 2, 3 digit angka Arab */
    font-size: 0.37em;
    font-weight: 800;
    color: #065f46;
    line-height: 1;
    text-align: center;
    letter-spacing: 0;
    white-space: nowrap;
    /* Pastikan angka tepat di tengah (sesuai offset lingkaran r=52 dari cx=120) */
    transform: translateY(0.03em);
}

/* Hapus semua elemen ornamen CSS hack lama (tidak dipakai lagi) */
.ayah-end-mark::before,
.ayah-end-mark::after,
.ayah-end-mark > .ornament-ring,
.ayah-end-mark > .ornament-ring-2,
.ayah-end-mark > .ornament-dot,
.ayah-end-mark > .ornament {
    display: none !important;
    content: none !important;
    border: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* ============================================================
   DARK MODE - WARNA SVG DI OVERRIDE DARI CSS
   (stroke & fill SVG diatur ulang via CSS selectors — sesuaikan
    selector dengan r=54 / r=64 dan stroke="url(#..)" gradient)
   ============================================================ */
body.dark-theme .ayah-frame-svg g > * {
    stroke: #fbbf24 !important;
}
body.dark-theme .ayah-frame-svg g[fill="#fffdf7"] > * {
    fill: #1e293b !important;
    stroke: #fbbf24 !important;
}
body.dark-theme .ayah-frame-svg circle[r="54"] {
    fill: #0f172a !important;
    stroke: #fbbf24 !important;
}
body.dark-theme .ayah-frame-svg circle[r="64"] {
    stroke: #fbbf24 !important;
    fill: none !important;
}
body.dark-theme .ayah-frame-svg path,
body.dark-theme .ayah-frame-svg circle {
    stroke: #fbbf24 !important;
}
body.dark-theme .ayah-end-mark > .ayah-num-span {
    color: #fbbf24 !important;
}

.ayah-latin {
    font-size: 13.5px;
    color: var(--primary-dark);
    font-style: italic;
    margin-bottom: 10px;
    line-height: 1.7;
}

body.dark-theme .ayah-latin {
    color: var(--primary-light);
}

.ayah-translation {
    font-size: 15px;
    color: var(--text-main);
    line-height: 1.8;
    padding: 10px 12px;
    background: rgba(5, 150, 105, 0.06);
    border-radius: 12px;
    border-right: 3px solid var(--primary-light);
}

.reader-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0 8px;
}

.btn-pager {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-pager:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   HADIST SECTION
   ============================================================ */
#hadistView {
    display: none;
}

.hadist-header-banner {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.hadist-icon-box {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.hadist-banner-text h2 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 2px;
}

.hadist-banner-text p {
    font-size: 11.5px;
    opacity: 0.85;
}

.hadist-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.hadist-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}

.hadist-pill-no {
    background: var(--accent-gold-subtle);
    color: var(--accent-gold);
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(217, 119, 6, 0.25);
}

.hadist-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
}

.hadist-arabic {
    font-family: var(--font-arabic);
    font-size: calc(var(--arabic-font-size) - 2px);
    font-weight: 400;
    color: #1a1a1a;
    direction: rtl;
    unicode-bidi: isolate;
    text-align: justify;
    text-align-last: right;
    line-height: calc(var(--arabic-line-height) - 0.2);
    margin-bottom: 16px;
    word-spacing: calc(var(--arabic-word-spacing) - 0.02em);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-kerning: normal;
    font-variant-ligatures: common-ligatures contextual;
    font-feature-settings: "kern", "liga", "clig", "calt";
}

.hadist-translation {
    font-size: 15px;
    color: var(--text-main);
    line-height: 1.8;
}

/* ============================================================
   LOADING, EMPTY & ERROR STATES
   ============================================================ */
.state-box {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin: 20px 0;
}

.state-spinner {
    font-size: 36px;
    color: var(--primary);
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-bottom: 10px;
}

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

.state-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.state-desc {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 320px;
    margin: 0 auto 16px;
}

.btn-retry {
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 9px 18px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
#quranToast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

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

/* ============================================================
   RESPONSIVE MOBILE RULES — RAPI, TIDAK DUPLIKAT, NYAMAN BACA
   ============================================================ */
@media (max-width: 640px) {
    html {
        scroll-padding-top: 120px;
    }
    body {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .quran-header {
        padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 10px;
    }

    .quran-container {
        padding: 12px 10px 40px;
    }

    .header-brand h1 {
        font-size: 14px;
    }

    .header-brand p {
        font-size: 10px;
    }

    .btn-back-portal {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 36px;
    }

    .surah-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .reader-nav-wrap {
        top: 58px;
    }

    .reader-nav-bar {
        padding: 8px 12px;
    }

    .reader-title-main {
        font-size: 13.5px;
    }

    /* Tombol View Toggles — 4 tombol jadi 2x2 grid agar muat & teks tidak sempit */
    .reader-view-toggles {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px 10px;
    }
    .btn-view-opt {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        padding: 9px 8px;
        font-size: 11.5px;
        min-height: 40px;
        gap: 3px;
        border-radius: 12px;
    }
    .btn-view-opt .material-icons-round {
        font-size: 14px !important;
    }

    /* Bismillah box — lebih kompak */
    .bismillah-box {
        padding: 22px 14px 18px;
        margin-bottom: 12px;
        border-radius: 14px;
    }
    .bismillah-arabic {
        font-size: 24px;
        line-height: 2.1;
        margin-bottom: 6px;
    }
    .bismillah-translation {
        font-size: 12px;
        line-height: 1.6;
    }

    /* Ayah sheet & card — jarak nyaman untuk scroll jari */
    .ayah-sheet {
        padding: 4px 2px;
    }
    .ayah-card {
        padding: 16px 12px 14px;
        border-radius: 14px;
        margin-bottom: 10px;
    }
    .ayah-top-bar {
        margin-bottom: 12px;
    }
    .ayah-badge {
        min-width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .btn-ayah-action {
        width: 36px;
        height: 36px;
        min-height: 36px;
    }

    /* Ukuran font Arab DEFAULT mobile — nyaman baca, user bisa tambah dengan A+ */
    :root {
        --arabic-font-size: 24px;
        --arabic-line-height: 2.3;
        --arabic-word-spacing: 0.08em;
    }
    .ayah-arabic {
        margin-bottom: 12px;
        line-height: 2.3;
        word-spacing: 0.08em;
    }

    /* Pembatas ayat mobile — PROPORSIONAL dengan stroke TEBAL, aman tidak nabrak */
    .ayah-end-mark {
        width: 1.10em;
        height: 1.10em;
        margin-right: 0.08em;
        margin-left: 0.06em;
        vertical-align: -0.09em;
        background: transparent;
        border: none;
        overflow: visible;
    }
    .ayah-frame-svg {
        overflow: visible;
    }
    .ayah-end-mark > .ayah-num-span {
        font-size: 0.36em;
        font-weight: 800;
        transform: translateY(0.03em);
    }
    .ayah-end-mark::before,
    .ayah-end-mark::after,
    .ayah-end-mark > .ornament-ring,
    .ayah-end-mark > .ornament-ring-2,
    .ayah-end-mark > .ornament-dot,
    .ayah-end-mark > .ornament {
        display: none !important;
        content: none !important;
    }

    .ayah-latin {
        font-size: 12.5px;
        margin-bottom: 9px;
        line-height: 1.65;
    }
    .ayah-translation {
        font-size: 13.5px;
        padding: 9px 10px;
        line-height: 1.75;
        border-radius: 10px;
    }

    .hadist-arabic {
        font-size: 22px;
        line-height: 2.2;
    }

    /* Pager (sebelum/sesudah surah) — tinggi tap aman */
    .reader-pager {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .reader-pager .btn-pager {
        min-height: 44px;
    }

    /* State box (loading/error) — padding lebih kecil */
    .state-box {
        padding: 30px 16px;
    }
    .state-title {
        font-size: 15px;
    }
    .state-desc {
        font-size: 12px;
    }
}
