/* تَجْوِيدٌ — phone-first, RTL, light and dark. Quran text in Amiri Quran; UI in the system Arabic font. */
@font-face { font-family: "Amiri Quran"; src: url("fonts/AmiriQuran.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
:root {
  --bg: #f6f1e7; --card: #fffdf8; --ink: #1d2a22; --muted: #6b7a70; --line: #e4dccb; --accent: #1f6f4f; --accent-ink: #fff; --gold: #b58a3c;
  --danger: #b4443c; --ok: #2f8f5b; --warn: #c7872b; --chip: #ece5d6;
  --tj-ghunnah: #ff7e1e; --tj-qalqalah: #dd0008; --tj-ikhfa: #9400a8; --tj-ikhfa-sh: #d500b7; --tj-idgham-g: #169777; --tj-idgham-wg: #169200;
  --tj-idgham-sh: #58b800; --tj-iqlab: #26bffd; --tj-madd-n: #537fff; --tj-madd-p: #4050ff; --tj-madd-o: #2144c1; --tj-madd-nec: #000ebc;
  --tj-silent: #9a9a9a; --tj-hamwasl: #9a9a9a; --tj-shams: #9a9a9a;
  --fs: 1;
}
@media (prefers-color-scheme: dark) { :root { --bg: #0f1a14; --card: #16241c; --ink: #efe8d8; --muted: #9fb0a5; --line: #26382e; --accent: #4fb28a; --accent-ink: #0b1510; --gold: #c9a961; --chip: #203229;
  --tj-madd-nec: #6d7bff; --tj-madd-o: #6f8cff; --tj-idgham-wg: #4fd45a; --tj-silent: #8a8a8a; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "SF Arabic", "Segoe UI", "Noto Naskh Arabic", "Amiri", serif; font-size: calc(17px * var(--fs)); line-height: 1.7; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
#topTitle { font-weight: 700; font-size: 1.15em; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 0; background: var(--muted); padding: 0; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--danger); } .dot.busy { background: var(--warn); }
main { padding: 14px 16px 24px; max-width: 760px; margin: 0 auto; }
h1, h2, h3 { line-height: 1.4; margin: 0.6em 0 0.4em; } h1 { font-size: 1.35em; } h2 { font-size: 1.2em; } h3 { font-size: 1.05em; }
p { margin: 0.5em 0; } .muted { color: var(--muted); } .small { font-size: 0.88em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 10px 16px; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.ghost { background: transparent; } .btn:disabled { opacity: 0.5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { text-align: center; padding: 10px; } .stat b { display: block; font-size: 1.6em; color: var(--accent); }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: 0.85em; margin: 2px; }
.list button, .list a { display: block; width: 100%; text-align: start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 8px 0; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
.list .sub { color: var(--muted); font-size: 0.88em; }
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.hidden { display: none !important; }
.login { width: 100%; max-width: 380px; } .login .logo { font-family: "Amiri Quran", serif; font-size: 2.4em; text-align: center; color: var(--gold); }
label { display: block; margin: 10px 0 4px; color: var(--muted); }
input[type=password], input[type=text], select, textarea { width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
.msg { color: var(--danger); min-height: 1.4em; }
#tabs { position: fixed; bottom: 0; inset-inline: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#tabs button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.78em; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
#tabs button svg { width: 24px; height: 24px; fill: currentColor; } #tabs button.active { color: var(--accent); }
/* Quran */
.q { font-family: "Amiri Quran", "Amiri", serif; font-size: 1.55em; line-height: 2.2; direction: rtl; text-align: justify; }
.q.big { font-size: 1.9em; line-height: 2.1; text-align: center; }
.q .w { display: inline; padding: 0 1px; border-radius: 6px; }
.q .w.cur { background: color-mix(in srgb, var(--gold) 28%, transparent); }
.q .w.pick { outline: 2px solid var(--accent); }
.q .n { font-size: 0.6em; color: var(--gold); margin: 0 4px; }
.plain tajweed, .plain rule { color: inherit !important; text-decoration: none !important; }
/* tajweed colours + non-colour cues (WCAG 1.4.1): wavy = ghunnah family, dotted = qalqalah, thickness = madd grade */
tajweed, rule { text-decoration-skip-ink: none; }
tajweed.ghunnah, rule.ghunnah { color: var(--tj-ghunnah); text-decoration: underline wavy; }
tajweed.qalaqah, rule.qalaqah { color: var(--tj-qalqalah); text-decoration: underline dotted; }
tajweed.ikhafa, rule.ikhafa { color: var(--tj-ikhfa); background: color-mix(in srgb, var(--tj-ikhfa) 12%, transparent); }
tajweed.ikhafa_shafawi, rule.ikhafa_shafawi { color: var(--tj-ikhfa-sh); background: color-mix(in srgb, var(--tj-ikhfa-sh) 12%, transparent); }
tajweed.idgham_ghunnah, rule.idgham_ghunnah { color: var(--tj-idgham-g); text-decoration: underline wavy; }
tajweed.idgham_wo_ghunnah, rule.idgham_wo_ghunnah { color: var(--tj-idgham-wg); text-decoration: underline double; }
tajweed.idgham_shafawi, rule.idgham_shafawi { color: var(--tj-idgham-sh); text-decoration: underline wavy; }
tajweed.idgham_mutajanisayn, rule.idgham_mutajanisayn, tajweed.idgham_mutaqaribayn, rule.idgham_mutaqaribayn { color: var(--tj-idgham-wg); text-decoration: underline double; }
tajweed.iqlab, rule.iqlab { color: var(--tj-iqlab); background: color-mix(in srgb, var(--tj-iqlab) 14%, transparent); }
tajweed.madda_normal, rule.madda_normal { color: var(--tj-madd-n); text-decoration: underline; text-decoration-thickness: 1px; }
tajweed.madda_permissible, rule.madda_permissible { color: var(--tj-madd-p); text-decoration: underline; text-decoration-thickness: 2px; }
tajweed.madda_obligatory, rule.madda_obligatory { color: var(--tj-madd-o); text-decoration: underline; text-decoration-thickness: 3px; }
tajweed.madda_necessary, rule.madda_necessary { color: var(--tj-madd-nec); text-decoration: underline; text-decoration-thickness: 4px; }
tajweed.slnt, rule.slnt, tajweed.ham_wasl, rule.ham_wasl, tajweed.laam_shamsiyah, rule.laam_shamsiyah { color: var(--tj-silent); opacity: 0.75; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 0.85em; }
.legend span::before { content: "●"; margin-inline-end: 4px; }
/* lesson reader */
.lesson { font-family: "Amiri", serif; font-size: 1.08em; line-height: 1.95; }
.lesson details { background: var(--chip); border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.lesson summary { cursor: pointer; font-weight: 700; }
.lesson table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.95em; } .lesson td, .lesson th { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.lesson h2 { border-inline-start: 4px solid var(--gold); padding-inline-start: 10px; margin-top: 1.4em; }
.lesson code { font-size: 0.9em; }
/* flash card */
.flash { min-height: 220px; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.flash .front { font-size: 1.1em; } .flash .back { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; text-align: start; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.ratings button { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ratings button small { color: var(--muted); font-size: 0.75em; }
.ratings .again { border-color: var(--danger); } .ratings .good { border-color: var(--accent); }
.progress { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin: 8px 0; } .progress i { display: block; height: 100%; background: var(--accent); }
.opts button { display: block; width: 100%; margin: 6px 0; text-align: start; }
.opts button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.opts button.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--card)); }
.fab { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); inset-inline-end: 16px; z-index: 6; border-radius: 999px; padding: 12px 18px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.verse { padding: 10px 12px; border-radius: 12px; margin: 6px 0; cursor: pointer; }
.verse.playing { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.tools { position: sticky; top: 56px; background: var(--bg); padding: 6px 0; z-index: 4; }
.rec { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
kbd.sign { font-family: "Amiri Quran", serif; font-size: 1.3em; }
.toast { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); inset-inline: 16px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; text-align: center; z-index: 20; }
.fieldlist dt { font-weight: 700; margin-top: 8px; color: var(--accent); } .fieldlist dd { margin: 0 0 4px; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--accent); text-decoration: none; font-weight: 600; }
.rid { display: inline-block; font-size: .72em; padding: 0 6px; border-radius: 10px; background: var(--accent-soft, rgba(80,160,120,.18)); color: var(--accent); text-decoration: none; cursor: pointer; vertical-align: middle; }
.lesson .q { font-size: 1.15em; }
.tree li { margin: 6px 0; } .tree ul { padding-inline-start: 18px; }
