/* Itqan AlQuran — feuille de style principale. Propriétés logiques : fonctionne en LTR et RTL. */
:root {
  --green-900: #0a3528; --green: #0d4636; --green-600: #1a6a4f; --green-100: #dfeee6; --green-50: #eef6f1;
  --gold: #9b722d; --gold-600: #b8893b; --gold-100: #f3e8d2;
  --cream: #faf6ec; --paper: #ffffff; --ink: #1c2a24; --muted: #5c6b63; --line: #e3ddcd; --line-2: #cfd9d3;
  --red: #a63d2f; --red-100: #f6e2de; --amber: #b7791f; --amber-100: #fbeed6; --blue: #2b5c8a; --blue-100: #dde9f5;
  --radius: 12px; --radius-s: 8px; --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 6px 20px -12px rgba(20, 40, 30, .25);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", "Noto Naskh Arabic", "Amiri", serif;
  --s-not_started: #ece7da; --s-in_progress: #e5c97a; --s-memorized: #4f9d78; --s-to_review: #d9843b; --s-consolidated: #0d4636;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--cream); line-height: 1.5; font-size: 16px; }
[dir="rtl"] body { font-size: 17px; }
a { color: var(--green-600); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); color: var(--green); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; margin-top: 1.5rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; } .muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Barre du haut */
.topbar { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar .inner { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; min-height: 56px; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-family: var(--serif); font-size: 1.15rem; letter-spacing: .04em; white-space: nowrap; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand:hover { text-decoration: none; }
.topbar .grow { flex: 1; }
.topbar nav.main { display: none; gap: .25rem; }
.topbar nav.main a { color: #e9f3ee; padding: .4rem .7rem; border-radius: 999px; font-size: .95rem; }
.topbar nav.main a.active, .topbar nav.main a:hover { background: rgba(255,255,255,.14); text-decoration: none; }
@media (min-width: 900px) { .topbar nav.main { display: flex; } }
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: .35rem .8rem; font-size: .9rem; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary .pname { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { details.menu summary .ptype { display: none; } details.menu summary .pname { max-width: 6.5rem; } .brand { font-size: 1rem; } }
details.menu .panel { position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); background: var(--paper); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 240px; padding: .5rem; z-index: 30; border: 1px solid var(--line); }
details.menu .panel a, details.menu .panel button { display: block; width: 100%; text-align: start; padding: .55rem .7rem; border-radius: var(--radius-s); color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
details.menu .panel a:hover, details.menu .panel button:hover { background: var(--green-50); text-decoration: none; }
details.menu .panel .sep { border-top: 1px solid var(--line); margin: .4rem 0; }
details.menu .panel .label { padding: .3rem .7rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; }
.langs { display: flex; gap: .15rem; }
.langs a { color: #e9f3ee; font-size: .8rem; padding: .25rem .45rem; border-radius: 6px; opacity: .8; }
.langs a.active { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }

/* Contenu */
main.container { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 6rem; }
@media (min-width: 900px) { main.container { padding-bottom: 3rem; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--muted); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid-2 { display: grid; gap: 1rem; } @media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: 1rem; } @media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

/* Boutons et formulaires */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid var(--green); background: var(--green); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--green-600); text-decoration: none; }
.btn.secondary { background: var(--paper); color: var(--green); border-color: var(--green-600); }
.btn.secondary:hover { background: var(--green-50); }
.btn.gold { background: var(--gold); border-color: var(--gold); } .btn.gold:hover { background: var(--gold-600); }
.btn.danger { background: var(--paper); color: var(--red); border-color: var(--red); } .btn.danger:hover { background: var(--red-100); }
.btn.small { padding: .35rem .8rem; min-height: 34px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--green-600); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
form.inline { display: inline; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--line-2); border-radius: var(--radius-s); font: inherit; background: var(--paper); color: var(--ink); min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-600); outline-offset: 1px; border-color: var(--gold-600); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 1rem; }
.fields { display: grid; gap: .75rem 1rem; } @media (min-width: 640px) { .fields.cols-2 { grid-template-columns: 1fr 1fr; } .fields.cols-3 { grid-template-columns: repeat(3, 1fr); } .fields.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 1.2rem; height: 1.2rem; }
.radio-cards { display: grid; gap: .5rem; }
.radio-cards label { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: .7rem .8rem; font-weight: 500; cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--green-600); background: var(--green-50); }

/* Messages */
.flash { padding: .7rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem; border: 1px solid; }
.flash.success { background: var(--green-100); border-color: #bddccb; color: var(--green-900); }
.flash.error { background: var(--red-100); border-color: #ecc6bf; color: var(--red); }
.flash.info { background: var(--gold-100); border-color: #e4d2ab; color: #6a4b16; }
.errors { background: var(--red-100); border: 1px solid #ecc6bf; color: var(--red); border-radius: var(--radius-s); padding: .7rem 1rem; margin-bottom: 1rem; }
.errors ul { margin: 0; padding-inline-start: 1.2rem; }

/* Badges et statuts */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--green-50); color: var(--green); border: 1px solid var(--green-100); }
.badge.gold { background: var(--gold-100); color: #6a4b16; border-color: #e4d2ab; }
.badge.grey { background: #f0ede4; color: var(--muted); border-color: var(--line); }
.badge.red { background: var(--red-100); color: var(--red); border-color: #ecc6bf; }
.dot { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.08); }
.st-not_started { background: var(--s-not_started); } .st-in_progress { background: var(--s-in_progress); } .st-memorized { background: var(--s-memorized); } .st-to_review { background: var(--s-to_review); } .st-consolidated { background: var(--s-consolidated); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }

/* Progression */
.progress { height: 14px; background: #ece7da; border-radius: 999px; overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .6rem .75rem; }
.stat .n { font-size: 1.5rem; font-weight: 700; color: var(--green); font-family: var(--serif); }
.stat .l { font-size: .78rem; color: var(--muted); }
.big-number { font-family: var(--serif); font-size: 2.6rem; color: var(--green); line-height: 1; }

/* Grille des pages */
.juz { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-bottom: .6rem; overflow: hidden; }
.juz summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; }
.juz summary::-webkit-details-marker { display: none; }
.juz summary .name { font-weight: 600; min-width: 5.5rem; }
.juz summary .mini { flex: 1; display: flex; gap: 2px; height: 10px; }
.juz summary .mini i { flex: 1; border-radius: 2px; }
.juz summary .count { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; padding: .6rem .9rem .9rem; border-top: 1px solid var(--line); }
.cell { aspect-ratio: 1; border-radius: 7px; display: grid; place-items: center; font-size: .78rem; font-weight: 600; color: var(--ink); border: 1px solid rgba(0,0,0,.06); text-decoration: none; }
.cell:hover { outline: 2px solid var(--gold-600); text-decoration: none; }
.cell.st-memorized, .cell.st-consolidated, .cell.st-to_review { color: #fff; }
.cell.st-to_review { color: #fff; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: start; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .7rem 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; }
.list li:last-child { border-bottom: 0; }

/* Formulaire de séance : lignes dynamiques */
.rows { display: grid; gap: .5rem; }
.rowline { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; align-items: end; padding: .6rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fdfbf5; }
@media (min-width: 720px) { .rowline.rec { grid-template-columns: 1.2fr 1fr 1fr 1.2fr 1.3fr auto; } .rowline.err { grid-template-columns: 1fr 1.5fr 1fr 1fr 2fr auto; } }
.rowline label { font-size: .75rem; margin-bottom: .15rem; }
.rowline .remove { align-self: end; }

/* Barre de navigation mobile */
.bottomnav { position: fixed; bottom: 0; inset-inline: 0; background: var(--paper); border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; text-align: center; padding: .55rem .25rem .5rem; font-size: .7rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--green); font-weight: 600; }
.bottomnav a:hover { text-decoration: none; }
@media (min-width: 900px) { .bottomnav { display: none; } }

/* Accueil */
.hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.hero img { width: 140px; height: 140px; border-radius: 28px; box-shadow: var(--shadow); }
.hero h1 { font-size: 2.1rem; margin-top: 1rem; }
.hero p { max-width: 620px; margin: .5rem auto 1.25rem; color: var(--muted); font-size: 1.05rem; }
.features { display: grid; gap: 1rem; margin-top: 1.5rem; } @media (min-width: 720px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.feature .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--green-50); color: var(--green); display: grid; place-items: center; margin-bottom: .6rem; }
.auth-card { max-width: 480px; margin: 1rem auto; }
footer.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.kbd { background: #f0ede4; border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; font-size: .85em; }
.linkbox { display: flex; gap: .5rem; align-items: center; }
.linkbox input { font-size: .85rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.wp { border-inline-start: 4px solid var(--amber); }
.wp.done { border-inline-start-color: var(--s-memorized); opacity: .8; }
.timeline li { display: block; }
.ar { font-family: var(--serif); font-size: 1.15em; }
