:root {
  --encre: #0f3d33; --encre-2: #16564a; --or: #b8913a; --or-clair: #e8d7a8;
  --papier: #f7f3ea; --carte: #fffdf8; --texte: #1f2a26; --doux: #5f6b66; --ligne: #e3dccb;
  --danger: #a33b2b; --ok: #2f7a4f; --ombre: 0 1px 2px rgba(15,61,51,.06), 0 6px 20px rgba(15,61,51,.07);
  --rayon: 14px; --ar: 'Amiri', 'Noto Naskh Arabic', serif; --quran: 'Amiri Quran', 'Amiri', serif;
  --titre: 'Lora', Georgia, serif; --corps: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --encre: #7fc7b2; --encre-2: #9ad8c5; --or: #d8b866; --or-clair: #4a3f22; --papier: #0d1714; --carte: #14211d;
    --texte: #e6ece9; --doux: #9aa9a3; --ligne: #24352f; --ombre: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--papier); color: var(--texte); font: 16px/1.6 var(--corps); padding-bottom: 72px; }
[dir=rtl] body { font-family: var(--ar), var(--corps); font-size: 18px; }
a { color: var(--encre-2); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* entête */
.entete { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: #0f3d33; color: #f5efe0; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.marque { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.marque span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marque b { font-family: var(--titre); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marque small { font-family: var(--ar); color: #e8d7a8; font-size: 15px; }
.nav-haut { display: none; gap: 4px; margin-inline-start: auto; }
.nav-haut a { color: #e9e2cf; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 15px; }
.nav-haut a.actif, .nav-haut a:hover { background: rgba(255,255,255,.12); color: #fff; }
.outils { margin-inline-start: auto; }
.langues { display: flex; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; }
.langues button { background: none; border: 0; color: #e9e2cf; padding: 4px 10px; cursor: pointer; font-size: 14px; }
.langues button.actif { background: #b8913a; color: #1b1406; font-weight: 600; }
@media (min-width: 900px) { .nav-haut { display: flex; } .outils { margin-inline-start: 8px; } body { padding-bottom: 0; } .nav-bas { display: none !important; } }

.nav-bas { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--carte); border-top: 1px solid var(--ligne); padding-bottom: env(safe-area-inset-bottom); }
.nav-bas a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; text-decoration: none; color: var(--doux); font-size: 12px; }
.nav-bas a svg { width: 22px; height: 22px; }
.nav-bas a.actif { color: var(--encre); font-weight: 600; }

.annonce { background: var(--or-clair); color: var(--texte); padding: 8px 16px; text-align: center; font-size: 15px; }
main { max-width: 1060px; margin: 0 auto; padding: 16px; outline: none; min-height: 60vh; }

/* éléments */
h1, h2, h3 { font-family: var(--titre); color: var(--encre); line-height: 1.25; margin: 0 0 .5em; }
[dir=rtl] h1, [dir=rtl] h2, [dir=rtl] h3 { font-family: var(--ar); }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 18px; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); }
.pile > * + * { margin-top: 14px; }
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doux { color: var(--doux); font-size: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; font-size: 15px; min-height: 40px; }
.btn:hover { border-color: var(--or); }
.btn.principal { background: var(--encre); border-color: var(--encre); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.principal { color: #0d1714; } }
.btn.or { background: var(--or); border-color: var(--or); color: #1b1406; }
.btn.danger { color: var(--danger); }
.btn.petit { padding: 4px 10px; min-height: 32px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }
.puces { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.puce { flex: none; border: 1px solid var(--ligne); background: var(--carte); border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.puce.actif { background: var(--encre); color: #fff; border-color: var(--encre); }
@media (prefers-color-scheme: dark) { .puce.actif { color: #0d1714; } }
label.champ { display: block; font-size: 14px; color: var(--doux); }
label.champ input, label.champ select, label.champ textarea, .saisie { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--ligne);
  border-radius: 10px; background: var(--carte); color: var(--texte); font-size: 16px; }
textarea { min-height: 90px; resize: vertical; }
.grille2 { display: grid; gap: 12px; } @media (min-width: 640px) { .grille2 { grid-template-columns: 1fr 1fr; } }
.erreur { color: var(--danger); font-size: 14px; }
.vide { text-align: center; color: var(--doux); padding: 32px 8px; }
mark { background: var(--or-clair); color: inherit; border-radius: 3px; padding: 0 2px; }

/* accueil */
.hero { text-align: center; padding: 28px 12px 18px; }
.hero .calli { font-family: var(--quran); font-size: 46px; color: var(--encre); line-height: 1.3; }
.hero p { color: var(--doux); margin: 4px 0 18px; }
.barre-recherche { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.barre-recherche input { flex: 1; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--ligne); background: var(--carte); font-size: 16px; min-width: 0; }
.barre-recherche button { border-radius: 999px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat { text-align: center; padding: 12px 6px; }
.stat b { display: block; font-family: var(--titre); font-size: 24px; color: var(--encre); }
.stat span { font-size: 13px; color: var(--doux); }
.tuiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tuile { display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden; }
.tuile .ar { font-family: var(--quran); font-size: 30px; color: var(--or); line-height: 1.2; }
.tuile h3 { margin: 6px 0 2px; }

/* Coran */
.liste-sourates { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sourate-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; color: inherit; }
.num { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border: 1.5px solid var(--or); border-radius: 50%; font-size: 13px; color: var(--encre); transform: rotate(45deg); }
.num span { transform: rotate(-45deg); }
.sourate-item .ar { margin-inline-start: auto; font-family: var(--quran); font-size: 22px; color: var(--encre); }
.tete-sourate { text-align: center; padding: 18px 8px; }
.tete-sourate .ar { font-family: var(--quran); font-size: 40px; color: var(--encre); }
.basmala { font-family: var(--quran); font-size: 28px; text-align: center; color: var(--encre); margin: 8px 0 16px; }
.ayah { padding: 14px 4px; border-bottom: 1px solid var(--ligne); scroll-margin-top: 80px; }
.ayah.cible { background: color-mix(in srgb, var(--or-clair) 45%, transparent); border-radius: 10px; }
.ayah .arabe { font-family: var(--quran); font-size: 28px; line-height: 2.1; direction: rtl; text-align: right; }
.fin-ayah { display: inline-grid; place-items: center; min-width: 30px; height: 30px; margin: 0 6px; font-family: var(--ar); font-size: 15px;
  border: 1.5px solid var(--or); border-radius: 50%; color: var(--encre); vertical-align: middle; }
.ayah .trad { color: var(--texte); margin-top: 6px; font-size: 16px; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.actions button, .actions a { border: 0; background: none; color: var(--doux); font-size: 13px; padding: 4px 8px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.actions button:hover, .actions a:hover { background: var(--ligne); color: var(--texte); }
.actions .on { color: var(--or); }
.texte-tafsir { font-family: var(--ar); font-size: 20px; line-height: 1.9; white-space: pre-wrap; }
.texte-tafsir.latin { font-family: var(--corps); font-size: 16px; line-height: 1.7; }

/* Hadith */
.hadith { padding: 16px 4px; border-bottom: 1px solid var(--ligne); scroll-margin-top: 80px; }
.hadith .arabe { font-family: var(--ar); font-size: 21px; line-height: 1.95; direction: rtl; text-align: right; }
.hadith .trad { margin-top: 8px; }
.etiquette { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--or-clair); color: var(--texte); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 18px 0; flex-wrap: wrap; }

/* Livres */
.grille-livres { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.livre-carte { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.couv { aspect-ratio: 3/4; border-radius: 8px; overflow: hidden; background: var(--encre); box-shadow: var(--ombre); display: grid; place-items: center; position: relative; }
.couv img { width: 100%; height: 100%; object-fit: cover; }
.couv .gen { padding: 12px; text-align: center; color: #f5efe0; font-family: var(--titre); font-size: 15px; line-height: 1.3;
  border: 1.5px solid rgba(232,215,168,.6); inset: 8px; position: absolute; border-radius: 4px; display: grid; place-items: center; }
.livre-carte b { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.livre-carte small { color: var(--doux); font-size: 13px; }
.fiche { display: grid; gap: 18px; } @media (min-width: 700px) { .fiche { grid-template-columns: 220px 1fr; } }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 15px; }
.meta dt { color: var(--doux); } .meta dd { margin: 0; }

/* lecteur */
.lecteur-barre { position: sticky; top: 58px; z-index: 5; background: var(--papier); padding: 8px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lecteur-barre input { width: 64px; text-align: center; padding: 6px; border: 1px solid var(--ligne); border-radius: 8px; background: var(--carte); }
.page-pdf { display: flex; justify-content: center; overflow: auto; }
.page-pdf canvas { background: #fff; box-shadow: var(--ombre); max-width: none; }
.progression { height: 8px; background: var(--ligne); border-radius: 99px; overflow: hidden; }
.progression div { height: 100%; background: var(--or); width: 0; transition: width .2s; }

/* résultats */
.resultat { display: block; text-decoration: none; color: inherit; }
.resultat .type { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--or); font-weight: 600; }
.resultat .arabe { font-family: var(--ar); font-size: 20px; direction: rtl; text-align: right; line-height: 1.8; }
.extrait { font-size: 15px; color: var(--texte); }
.tronque { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* tableaux admin */
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.defile { overflow-x: auto; }

/* pied */
.pied { max-width: 1060px; margin: 24px auto 0; padding: 18px 16px 28px; border-top: 1px solid var(--ligne); display: flex; align-items: center; gap: 12px; color: var(--doux); font-size: 14px; flex-wrap: wrap; }
.pied img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--or); }
.pied b { color: var(--texte); }

/* feuille (fenêtre) */
.feuille { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.feuille-fond { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.feuille-corps { position: relative; background: var(--carte); width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 22px 18px 28px; }
@media (min-width: 720px) { .feuille { align-items: center; } .feuille-corps { border-radius: 18px; } }
.fermer { position: absolute; top: 8px; inset-inline-end: 10px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--doux); }
.toast { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); background: #0f3d33; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; font-size: 15px; max-width: 90vw; }
.chargeur { text-align: center; color: var(--doux); padding: 30px; }
