/* =========================================================================
   Nûr al-Qur'ân — feuille de style
   Compagnon de lecture, d'écoute et de mémorisation du Saint Coran
   Thèmes : clair · sombre · sépia  —  RTL pour l'arabe, LTR pour le français
   ========================================================================= */

/* ---- Polices locales (SIL OFL) ---- */
@font-face {
  font-family: 'Amiri Quran';
  src: url('../fonts/amiri-quran-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('../fonts/amiri-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('../fonts/amiri-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Scheherazade New';
  src: url('../fonts/scheherazade-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  src: url('../fonts/noto-naskh-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  src: url('../fonts/noto-naskh-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lateef';
  src: url('../fonts/lateef-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Arabic';
  src: url('../fonts/noto-sans-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Arabic';
  src: url('../fonts/noto-sans-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  src: url('../fonts/nastaliq-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ---- Jetons de thème ---- */
:root {
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-ar: 'Amiri Quran', 'Amiri', 'Scheherazade New', serif;

  --ayah-size: 2rem;
  --ayah-leading: 2.2;
  --trans-size: 1rem;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.08);
  --tap: 44px;
  --maxw: 820px;
  --transition: .2s ease;
}

/* Clair (défaut) */
:root, :root[data-theme="light"] {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #f1efe7;
  --text: #1f2421;
  --text-soft: #5b625c;
  --muted: #8b918a;
  --border: #e4e0d5;
  --accent: #0f7b6c;        /* vert sobre */
  --accent-soft: #d7ebe6;
  --accent-ink: #0a564b;
  --gold: #a9801f;
  --highlight: #fff3c4;     /* surlignage récitation */
  --highlight-ink: #5a4a12;
  --danger: #b4452f;
  --overlay: rgba(31,36,33,.45);
}

:root[data-theme="dark"] {
  --bg: #12140f;
  --surface: #1b1e18;
  --surface-2: #23271f;
  --text: #ecefe6;
  --text-soft: #b4bbad;
  --muted: #828a7a;
  --border: #2e332a;
  --accent: #4fc9b4;
  --accent-soft: #1d3a35;
  --accent-ink: #9fe6d9;
  --gold: #d7b45a;
  --highlight: #4a4320;
  --highlight-ink: #ffe9a3;
  --danger: #e2735c;
  --overlay: rgba(0,0,0,.6);
  --shadow: 0 8px 30px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.3);
}

:root[data-theme="sepia"] {
  --bg: #efe6d2;
  --surface: #f7f0df;
  --surface-2: #ece0c7;
  --text: #4a3c28;
  --text-soft: #6e5c43;
  --muted: #9a876a;
  --border: #ddcdab;
  --accent: #96702a;
  --accent-soft: #e6d7b4;
  --accent-ink: #6d4f17;
  --gold: #8a6a1e;
  --highlight: #e8d08a;
  --highlight-ink: #5a4412;
  --danger: #a4452a;
  --overlay: rgba(74,60,40,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Écran de démarrage ---- */
#splash {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; background: var(--bg); color: var(--text);
  transition: opacity .4s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash .logo { font-family: var(--font-ar); font-size: 3.2rem; color: var(--accent); }
#splash .tagline { color: var(--text-soft); font-size: .95rem; }
#splash .bar { width: 180px; height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
#splash .bar > i { display:block; height:100%; width:30%; background: var(--accent); border-radius:4px; animation: slide 1.1s infinite; }
@keyframes slide { 0%{transform:translateX(-120%)} 100%{transform:translateX(420%)} }
#splash .status { font-size: .8rem; color: var(--muted); min-height: 1.1em; }

/* ---- Écran d'accueil (menu) ---- */
#home {
  min-height: 100dvh; max-width: var(--maxw); margin: 0 auto;
  padding: .4rem .9rem calc(.5rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center; gap: .35rem;
}
.home-head { text-align: center; }
.home-basmala { font-family: var(--font-ar); font-size: 1.1rem; color: var(--gold); direction: rtl; line-height: 1.5; }
.home-logo { font-family: var(--font-ar); font-size: 1.8rem; color: var(--accent); line-height: 1.1; }
.home-head h1 { font-size: 1.1rem; margin: 0; }
.home-head p { color: var(--text-soft); font-size: .76rem; margin: .1rem auto 0; max-width: 24rem; line-height: 1.25; }
.home-menu { display: flex; flex-direction: column; gap: .35rem; margin-top: .4rem; }
.home-item {
  display: flex; align-items: center; gap: .7rem; text-align: start;
  padding: .5rem .75rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .12s ease, border-color .15s ease;
}
.home-item:hover, .home-item:focus-visible { border-color: var(--accent); transform: translateY(-1px); }
.home-item .hi-ic { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); font-size: 1.1rem; }
.home-item .hi-ic svg { width: 19px; height: 19px; }
@media (max-height: 720px) { .home-head p { display: none; } .home-logo { font-size: 1.5rem; } }
.home-item .hi-txt { flex: 1; min-width: 0; }
.home-item .hi-txt b { display: block; font-size: .95rem; }
.home-item .hi-txt small { color: var(--text-soft); font-size: .72rem; }
.home-item .hi-ar { font-family: var(--font-ar); font-size: 1.3rem; color: var(--accent-ink); opacity: .8; }

/* ---- Cours de tajwīd ---- */
#tajwid-view { min-height: 100vh; }
.course { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1rem 4rem; line-height: 1.7; }
.course h2 { font-size: 1.2rem; color: var(--accent-ink); margin: 1.6rem 0 .5rem; border-bottom: 2px solid var(--accent-soft); padding-bottom: .3rem; }
.course h3 { font-size: 1rem; margin: 1.1rem 0 .3rem; }
.course p { margin: .5rem 0; color: var(--text); font-size: .92rem; }
.course .intro { background: var(--surface-2); border-radius: var(--radius); padding: .9rem 1rem; font-size: .9rem; }
.course .ex { background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--gold); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: .5rem 0; }
.course .ex .ar { font-family: var(--font-ar); direction: rtl; font-size: 1.9rem; line-height: 1.9; }
.course .ex .exp { font-size: .82rem; color: var(--text-soft); margin-top: .2rem; }
.course .rule-color { display: inline-block; padding: 0 .4em; border-radius: 5px; font-weight: 700; }
.course ul { padding-inline-start: 1.2rem; font-size: .9rem; }
.course li { margin: .25rem 0; }
.course .note-adab { background: color-mix(in srgb, var(--gold) 14%, transparent); border-radius: var(--radius-sm); padding: .7rem .8rem; font-size: .85rem; margin: 1rem 0; }

/* ---- Barre supérieure ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .25rem;
  padding: .4rem .5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .title {
  flex: 1; min-width: 0; text-align: center; line-height: 1.1;
}
.topbar .title b { display:block; font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { display:block; font-size: .72rem; color: var(--text-soft); }
.iconbtn {
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  display: grid; place-items: center;
  background: transparent; border: none; color: var(--text);
  border-radius: 50%; transition: background var(--transition);
}
.iconbtn:hover, .iconbtn:focus-visible { background: var(--surface-2); }
.iconbtn svg { width: 24px; height: 24px; }
.iconbtn.active { color: var(--accent); }

/* ---- Contenu / lecteur ---- */
.reader-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem 10rem; }
.surah-head {
  text-align: center; margin: 1.6rem auto 1rem; padding: 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface-2));
  box-shadow: var(--shadow-sm);
}
.surah-head .ar { font-family: var(--font-ar); font-size: 2.1rem; color: var(--accent-ink); }
.surah-head .en { color: var(--text-soft); font-size: .95rem; margin-top: .2rem; }
.surah-head .meta { color: var(--muted); font-size: .78rem; margin-top: .35rem; }
.basmala {
  text-align: center; font-family: var(--font-ar);
  font-size: 1.6rem; color: var(--gold);
  margin: 1.2rem 0 1.6rem; direction: rtl; line-height: 1.6;
}

/* Un verset */
.ayah {
  padding: .9rem .6rem; border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  scroll-margin-top: 80px;
}
.ayah:last-child { border-bottom: none; }
.ayah.has-hl { background: var(--row-hl); }
.ayah.has-hl .ayah-ar { color: #2a2a2a; }
.ayah.playing { background: var(--highlight) !important; }
.ayah.playing .ayah-ar { color: var(--highlight-ink) !important; }
.ayah.bookmarked { box-shadow: inset 3px 0 0 var(--gold); }
.ayah-ar {
  font-family: var(--font-ar); direction: rtl; text-align: right;
  font-size: var(--ayah-size); line-height: var(--ayah-leading);
  color: var(--text); word-spacing: .05em;
}
.ayah-num {
  display: inline-grid; place-items: center;
  min-width: 1.9em; height: 1.9em; margin: 0 .25em;
  font-family: var(--font-ui); font-size: .42em; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 50%; vertical-align: middle;
  padding: 0 .2em;
}
.ayah-sajda { color: var(--gold); font-size: .5em; margin-inline-start: .3em; }
.ayah-trans {
  font-family: var(--font-ui); direction: ltr; text-align: left;
  font-size: var(--trans-size); color: var(--text-soft);
  margin-top: .5rem; line-height: 1.55;
}
.ayah-translit {
  font-style: italic; color: var(--muted); font-size: calc(var(--trans-size) * .95);
  margin-top: .3rem; direction: ltr;
}
.ayah-tools { display: flex; gap: .15rem; margin-top: .5rem; opacity: .75; }
.ayah-tools button {
  display: inline-flex; align-items: center; gap: .3rem;
  background: transparent; border: none; color: var(--text-soft);
  font-size: .78rem; padding: .35rem .5rem; border-radius: 8px;
}
.ayah-tools button:hover { background: var(--surface-2); color: var(--text); }
.ayah-tools button svg { width: 17px; height: 17px; }
.ayah-note {
  margin-top: .5rem; padding: .55rem .7rem; font-size: .85rem;
  background: var(--surface-2); border-inline-start: 3px solid var(--gold);
  border-radius: 8px; color: var(--text-soft); white-space: pre-wrap;
}

/* ---- Vue Mushaf page par page ---- */
.mushaf-page { max-width: var(--maxw); margin: 0 auto; padding: 1rem 0 2rem; }
.mushaf-surah {
  text-align: center; margin: 1.2rem auto .4rem; padding: .5rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface-2));
}
.mushaf-surah .ar { font-family: var(--font-ar); font-size: 1.7rem; color: var(--accent-ink); }
.mushaf-text {
  font-family: var(--font-ar); direction: rtl; text-align: justify; text-align-last: center;
  font-size: calc(var(--ayah-size) * .92); line-height: calc(var(--ayah-leading) * 1.05);
  color: var(--text); word-spacing: .04em; padding: .3rem .2rem;
}
.ayah-inline { cursor: pointer; border-radius: 6px; transition: background .15s; }
.ayah-inline:hover { background: var(--surface-2); }
.ayah-inline.playing { background: var(--highlight) !important; color: var(--highlight-ink); }
.ayah-end {
  display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em;
  margin: 0 .15em; font-family: var(--font-ui); font-size: .4em; font-weight: 700;
  color: var(--gold); border: 1.5px solid var(--gold); border-radius: 50%;
  vertical-align: middle; padding: 0 .2em; background: var(--surface);
}
.mushaf-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1.6rem; padding: 0 .4rem; }
.mushaf-foot .btn { flex: 0 0 auto; font-size: .82rem; }
.mushaf-pagenum { flex: 1; text-align: center; font-size: .74rem; color: var(--text-soft); }

/* ---- Mode lecture recueillie (épuré) ---- */
body.focus-mode .topbar,
body.focus-mode .audiobar { transform: translateY(-120%); opacity: 0; pointer-events: none; }
body.focus-mode .audiobar { transform: translateY(120%); }
.topbar, .audiobar { transition: transform .3s ease, opacity .3s ease; }
body.focus-mode .ayah-tools { display: none; }
.focus-exit {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 60; display: none; gap: .4rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 999px; padding: .4rem .9rem;
  font-size: .85rem; color: var(--text);
}
body.focus-mode .focus-exit { display: inline-flex; }

/* ---- Barre audio ---- */
.audiobar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: .5rem max(.6rem, env(safe-area-inset-left)) calc(.5rem + env(safe-area-inset-bottom));
}
.audiobar .row { display: flex; align-items: center; gap: .4rem; max-width: var(--maxw); margin: 0 auto; }
.audiobar .now { flex: 1; min-width: 0; font-size: .8rem; color: var(--text-soft); }
.audiobar .now b { color: var(--text); font-weight: 700; }
.audiobar .controls { display: flex; align-items: center; gap: .1rem; }
.play-main {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.play-main svg { width: 26px; height: 26px; }
.audiobar .seek { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; max-width: var(--maxw); margin-inline: auto; }
.audiobar .seek input[type=range] { flex: 1; }
.audiobar .seek .t { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 5px; background: var(--surface-2); border-radius: 5px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* ---- Drawer / panneaux ---- */
.scrim {
  position: fixed; inset: 0; background: var(--overlay); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed; top: 0; bottom: 0; z-index: 100; width: min(90vw, 360px);
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .28s ease;
}
.panel.left  { left: 0;  transform: translateX(-102%); }
.panel.right { right: 0; transform: translateX(102%); }
.panel.open { transform: translateX(0); }
.panel-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .5rem .6rem 1rem;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.panel-head h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.panel-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: .5rem; }

/* Onglets de navigation */
.tabs { display: flex; gap: .25rem; padding: .5rem; border-bottom: 1px solid var(--border); }
.tabs button {
  flex: 1; padding: .5rem; border: none; background: var(--surface-2);
  color: var(--text-soft); border-radius: 8px; font-size: .82rem; font-weight: 600;
}
.tabs button.active { background: var(--accent); color: #fff; }

.filter-input, .text-input, select {
  width: 100%; padding: .6rem .7rem; font-size: .95rem; font-family: inherit;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
}
select { appearance: none; }

.surah-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.surah-list li { }
.surah-list button {
  width: 100%; display: flex; align-items: center; gap: .6rem;
  padding: .6rem .5rem; background: transparent; border: none;
  border-radius: var(--radius-sm); color: var(--text); text-align: start;
}
.surah-list button:hover, .surah-list button.current { background: var(--surface-2); }
.surah-list button.current { box-shadow: inset 3px 0 0 var(--accent); }
.surah-list .idx {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; color: var(--accent);
  border: 1px solid var(--accent-soft); background: var(--accent-soft);
  transform: rotate(45deg); border-radius: 6px;
}
.surah-list .idx span { transform: rotate(-45deg); }
.surah-list .nm { flex: 1; min-width: 0; }
.surah-list .nm b { display: block; font-size: .92rem; }
.surah-list .nm small { color: var(--muted); font-size: .72rem; }
.surah-list .ar { font-family: var(--font-ar); font-size: 1.3rem; color: var(--accent-ink); }

.jump-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .5rem; }
.jump-grid label { font-size: .78rem; color: var(--text-soft); display: block; margin-bottom: .25rem; }
.jump-grid .full { grid-column: 1 / -1; }

/* ---- Réglages ---- */
.setting { padding: .75rem .25rem; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: none; }
.setting .lbl { font-size: .9rem; font-weight: 600; margin-bottom: .5rem; display: flex; justify-content: space-between; align-items: center; }
.setting .lbl span.val { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: .3rem; }
.seg button {
  flex: 1; padding: .5rem; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); border-radius: 8px; font-size: .82rem; font-weight: 600;
}
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.switch { display: flex; align-items: center; justify-content: space-between; }
.toggle { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: var(--transition); }
.toggle .track::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 2px; background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: var(--shadow-sm); }
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::before { transform: translateX(20px); }

/* ---- Recherche ---- */
.search-panel { position: fixed; inset: 0; z-index: 110; background: var(--bg); display: none; flex-direction: column; }
.search-panel.open { display: flex; }
.search-head { display: flex; align-items: center; gap: .3rem; padding: .5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.search-results { overflow-y: auto; flex: 1; padding: .5rem; max-width: var(--maxw); margin: 0 auto; width: 100%; }
.result {
  padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .5rem; background: var(--surface); cursor: pointer; transition: border-color var(--transition);
}
.result:hover { border-color: var(--accent); }
.result .ref { font-size: .72rem; color: var(--accent); font-weight: 700; margin-bottom: .3rem; }
.result .ar { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 1.4rem; line-height: 1.9; }
.result .fr { font-size: .85rem; color: var(--text-soft); margin-top: .3rem; }
.result mark { background: var(--highlight); color: var(--highlight-ink); padding: 0 .1em; border-radius: 3px; }
.search-empty { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: .9rem; }

/* ---- Feuille d'action d'un verset ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  background: var(--surface); border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow); padding: .5rem .5rem calc(1rem + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .28s ease; max-width: var(--maxw); margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: .4rem auto .6rem; }
.sheet .sheet-ref { text-align: center; font-weight: 700; color: var(--accent); font-size: .9rem; margin-bottom: .5rem; }
.sheet-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.sheet-actions button {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .7rem .2rem; background: var(--surface-2); border: none; border-radius: var(--radius-sm);
  color: var(--text); font-size: .72rem;
}
.sheet-actions button svg { width: 22px; height: 22px; color: var(--accent); }
.hl-colors { display: flex; gap: .5rem; justify-content: center; padding: .6rem; }
.hl-colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); }
.hl-colors button.none { background: var(--surface); position: relative; }
.hl-colors button.none::after { content: "∅"; color: var(--muted); }

/* ---- Modale générique (note, intégrité, à propos) ---- */
.modal { position: fixed; inset: 0; z-index: 130; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal.open { display: flex; }
.modal .card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(100%, 460px); max-height: 85vh; overflow-y: auto; padding: 1.1rem;
}
.modal h2 { margin-top: 0; font-size: 1.15rem; }
.modal textarea { width: 100%; min-height: 120px; resize: vertical; padding: .6rem; font-family: inherit; font-size: .95rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.btn { padding: .6rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .9rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.integrity { display: flex; align-items: center; gap: .5rem; font-size: .82rem; padding: .5rem .7rem; border-radius: var(--radius-sm); margin: .5rem 0; }
.integrity.ok { background: var(--accent-soft); color: var(--accent-ink); }
.integrity.bad { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.integrity svg { width: 18px; height: 18px; flex: 0 0 auto; }

.tafsir-body { max-height: 56vh; overflow-y: auto; font-size: .92rem; line-height: 1.75; white-space: pre-wrap; }
.tafsir-body.rtl { direction: rtl; text-align: right; font-family: var(--font-ar); font-size: 1.25rem; line-height: 2; }
.tafsir-body .loading { color: var(--muted); text-align: center; padding: 1.5rem; }
.tafsir-ref { font-size: .8rem; color: var(--accent); font-weight: 700; }

.meta-table { width: 100%; font-size: .82rem; border-collapse: collapse; }
.meta-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.meta-table td:first-child { color: var(--text-soft); white-space: nowrap; }

/* ---- Bannière traduction ---- */
.notice {
  font-size: .78rem; color: var(--text-soft); background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: .6rem .7rem; margin: 1rem 0;
}
.notice b { color: var(--text); }

/* ---- Toast ---- */
#toasts { position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .55rem .9rem; border-radius: 999px; font-size: .82rem; box-shadow: var(--shadow); animation: pop .25s ease; max-width: 90vw; }
@keyframes pop { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

.empty-hint { text-align: center; color: var(--muted); font-size: .88rem; padding: 2rem 1rem; }

/* ---- Tableau de bord (Lot 4) ---- */
.dash-goal { display: flex; align-items: center; gap: 1rem; padding: .6rem .2rem 1rem; }
.ring {
  width: 84px; height: 84px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--surface-2) 0);
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-weight: 800; font-size: 1.3rem; color: var(--accent); }
.dash-goal-txt b { display: block; font-size: 1rem; }
.dash-goal-txt span { font-size: .82rem; color: var(--text-soft); }

.minichart { display: flex; align-items: flex-end; gap: 3px; height: 54px; margin: .4rem 0 1rem; }
.minichart .bar { flex: 1; background: var(--surface-2); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.minichart .bar.has { background: var(--accent); }
.minichart .bar.today { outline: 2px solid var(--gold); outline-offset: 1px; }

.dash-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; margin: .7rem 0; background: var(--surface); }
.dash-card h3 { margin: 0 0 .5rem; font-size: .95rem; }
.dash-plan-portion { font-family: var(--font-ar); direction: rtl; font-size: 1.1rem; }
.dash-row { display: flex; gap: .5rem; margin-top: .5rem; }
.dash-row .btn { flex: 1; }
.plan-bar { height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; margin: .4rem 0; }
.plan-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.plan-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .3rem; border-bottom: 1px solid var(--border); }
.plan-item .nm { flex: 1; font-size: .86rem; }
.plan-item .nm small { display: block; color: var(--muted); font-size: .72rem; }
.plan-item.active .nm b { color: var(--accent); }
.behind-badge { font-size: .7rem; color: var(--danger); }
.goal-row { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.goal-row:last-child { border-bottom: none; }
.goal-row .gl { flex: 1; font-weight: 600; }
.goal-row .gp { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.goal-row .gb { font-size: .74rem; color: var(--muted); min-width: 68px; text-align: end; }
.goal-row.met .gb { color: var(--accent); }

/* ---- Mémorisation (ḥifẓ) ---- */
.ayah-ar.masked { cursor: pointer; border-radius: 8px; transition: opacity .2s, text-shadow .2s, color .2s; }
.ayah-ar.mask-fade:not(.revealed) { opacity: .1; }
.ayah-ar.mask-hide:not(.revealed) { color: transparent; text-shadow: 0 0 15px var(--text); }
.ayah-ar.masked:not(.revealed):hover { outline: 1px dashed var(--border); }

.ayah.hifz-known .ayah-num { background: var(--accent); color: #fff; }
.ayah.hifz-learning .ayah-num { box-shadow: 0 0 0 2px var(--gold); }
.ayah.hifz-new .ayah-num { box-shadow: 0 0 0 2px var(--muted); }

.memobar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 56;
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(10px); border-top: 2px solid var(--gold);
  padding: .6rem max(.7rem, env(safe-area-inset-left)) calc(.6rem + env(safe-area-inset-bottom));
  display: none;
}
.memobar.open { display: block; }
.memobar .row { display: flex; align-items: center; gap: .5rem; max-width: var(--maxw); margin: 0 auto; }
.memobar .row .grow { flex: 1; min-width: 0; font-size: .82rem; color: var(--text-soft); }
.memobar .seg { flex: 0 0 auto; }
.memobar .seg button { padding: .4rem .55rem; font-size: .78rem; }

.hifz-stats { display: flex; gap: .4rem; text-align: center; margin: .3rem 0 .8rem; }
.hifz-stats .cell { flex: 1; background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem .2rem; }
.hifz-stats .cell b { display: block; font-size: 1.3rem; }
.hifz-stats .cell.new b { color: var(--muted); }
.hifz-stats .cell.learn b { color: var(--gold); }
.hifz-stats .cell.known b { color: var(--accent); }
.hifz-stats .cell.due b { color: var(--danger); }
.hifz-stats .cell span { font-size: .68rem; color: var(--text-soft); }

.review-ayah { text-align: center; padding: 1rem .5rem; }
.review-ayah .ref { font-size: .8rem; color: var(--accent); font-weight: 700; margin-bottom: .6rem; }
.review-ayah .ar { font-family: var(--font-ar); direction: rtl; font-size: 2rem; line-height: 2; min-height: 2.5em; }
.review-ayah .ar.hidden-text { color: transparent; text-shadow: 0 0 16px var(--text); }
.review-ayah .fr { font-size: .9rem; color: var(--text-soft); margin-top: .6rem; }
.review-grade { display: grid; grid-template-columns: repeat(3,1fr); gap: .4rem; margin-top: .6rem; }
.review-grade button { padding: .7rem .3rem; border-radius: var(--radius-sm); border: none; font-weight: 600; font-size: .82rem; color: #fff; }
.review-grade .again { background: var(--danger); }
.review-grade .good { background: var(--accent); }
.review-grade .easy { background: var(--gold); }

.journal-row { display: flex; align-items: center; gap: .5rem; padding: .45rem .3rem; border-bottom: 1px solid var(--border); }
.journal-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.journal-row .dot.new { background: var(--muted); }
.journal-row .dot.learning { background: var(--gold); }
.journal-row .dot.known { background: var(--accent); }
.journal-row .nm { flex: 1; font-size: .85rem; }
.journal-row .cnt { font-size: .74rem; color: var(--text-soft); }

/* ---- Récitations hors-ligne ---- */
.dl-progress { margin-top: .6rem; }
.dl-progress[hidden] { display: none; }
.dl-progress i { display: block; height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; position: relative; }
.dl-progress i::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); background: var(--accent); border-radius: 6px; transition: width .2s; }
.dl-progress span { font-size: .76rem; color: var(--text-soft); }
.dl-row { display: flex; align-items: center; gap: .5rem; padding: .5rem .3rem; border-bottom: 1px solid var(--border); }
.dl-row .nm { flex: 1; font-size: .86rem; }
.dl-row .nm small { display: block; color: var(--muted); font-size: .72rem; }
.dl-row button { background: transparent; border: none; color: var(--danger); padding: .3rem; border-radius: 8px; }
.dl-row button svg { width: 18px; height: 18px; }

/* ---- Couleurs tajwīd (affichage des règles) ---- */
:root {
  --tj-madd: #c0392b;     /* prolongation */
  --tj-ghunna: #1e8449;   /* nasalisation */
  --tj-qalqala: #2471a3;  /* rebond */
  --tj-ikhfa: #7d3c98;    /* dissimulation */
  --tj-idgham: #935116;   /* assimilation */
  --tj-iqlab: #117a8b;    /* substitution */
  --tj-silent: #9aa0a6;   /* non prononcé */
}
:root[data-theme="dark"] {
  --tj-madd: #ff6b5e; --tj-ghunna: #52d39a; --tj-qalqala: #5aa9e6;
  --tj-ikhfa: #c08ae0; --tj-idgham: #d79a4e; --tj-iqlab: #4fc9b4; --tj-silent: #8a9096;
}
.tj-madd { color: var(--tj-madd); }
.tj-ghunna { color: var(--tj-ghunna); }
.tj-qalqala { color: var(--tj-qalqala); }
.tj-ikhfa { color: var(--tj-ikhfa); }
.tj-idgham { color: var(--tj-idgham); }
.tj-iqlab { color: var(--tj-iqlab); }
.tj-silent { color: var(--tj-silent); }

.legend-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .2rem; border-bottom: 1px solid var(--border); }
.legend-row .sw { width: 22px; height: 22px; border-radius: 6px; flex: 0 0 auto; }
.legend-row .lab { font-size: .88rem; }

/* ---- Mode récitation guidée (Lot 2) ---- */
.w { transition: color .15s ease, background .15s ease; border-radius: 4px; padding: 0 .02em; }
.w.w-matched { color: var(--accent); }
.w.w-current { background: var(--highlight); color: var(--highlight-ink); box-shadow: 0 0 0 2px var(--highlight); }
.w.w-omitted { color: var(--danger); text-decoration: underline wavy var(--danger); text-underline-offset: 4px; }

.recitebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 56;
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(10px); border-top: 2px solid var(--accent);
  padding: .6rem max(.7rem, env(safe-area-inset-left)) calc(.6rem + env(safe-area-inset-bottom));
  display: none;
}
.recitebar.open { display: block; }
.recitebar .row { display: flex; align-items: center; gap: .6rem; max-width: var(--maxw); margin: 0 auto; }
.recitebar .mic {
  width: 52px; height: 52px; border-radius: 50%; border: none; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center; position: relative;
}
.recitebar .mic svg { width: 26px; height: 26px; }
.recitebar .mic.listening::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--accent); animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.9); opacity: .9 } 100% { transform: scale(1.5); opacity: 0 } }
.recitebar .info { flex: 1; min-width: 0; }
.recitebar .info b { font-size: .9rem; }
.recitebar .info .sub { font-size: .76rem; color: var(--text-soft); }
.recitebar .progress { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: .5rem; max-width: var(--maxw); margin-inline: auto; }
.recitebar .progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .25s ease; }
.recitebar .interim { font-family: var(--font-ar); direction: rtl; font-size: 1rem; color: var(--muted); min-height: 1.4em; margin-top: .35rem; text-align: right; max-width: var(--maxw); margin-inline: auto; }

.rec-stat { display: flex; gap: .5rem; text-align: center; margin: .6rem 0; }
.rec-stat .cell { flex: 1; background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .3rem; }
.rec-stat .cell b { display: block; font-size: 1.4rem; color: var(--accent); }
.rec-stat .cell span { font-size: .72rem; color: var(--text-soft); }
.rec-review-list { max-height: 40vh; overflow-y: auto; }
.rec-review-list .ra { padding: .5rem; border-bottom: 1px solid var(--border); }
.rec-review-list .ra .ref { font-size: .74rem; color: var(--accent); font-weight: 700; }
.rec-review-list .ra .ww { font-family: var(--font-ar); direction: rtl; font-size: 1.3rem; color: var(--danger); margin-top: .2rem; }

.consent-list { font-size: .86rem; line-height: 1.6; padding-inline-start: 1.1rem; color: var(--text-soft); }
.consent-list li { margin-bottom: .3rem; }
.consent-warn { font-size: .82rem; background: color-mix(in srgb, var(--gold) 16%, transparent); border-inline-start: 3px solid var(--gold); padding: .6rem .7rem; border-radius: 8px; margin: .6rem 0; }

/* ---- Divers ---- */
.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 680px) {
  :root { --ayah-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
