/* السَّفانة — هوية: أخضر زيتوني، ذهبي معتدل، عاجي دافئ */
@font-face {
  font-family: 'Hafs20';
  src: url('/fonts/Hafs_20.woff2') format('woff2');
  font-display: swap;
}
:root {
  --olive-900: #2f3a1f; --olive-800: #3d4a28; --olive-700: #4c5c32; --olive-600: #5d6f3e; --olive-100: #e9ecdc;
  --gold: #b08d4a; --gold-soft: #d8c28f; --gold-pale: #f3ead3;
  --ivory: #fbf7ee; --ivory-2: #f5efe1; --paper: #fffdf8;
  --ink: #2a2a22; --ink-2: #5a5a4c; --line: #e6dcc5;
  --ok: #4c7a3c;
  --radius: 18px; --shadow: 0 1px 2px rgba(60, 50, 20, .06), 0 6px 20px rgba(60, 50, 20, .06);
  --quran-size: 30px; --quran-lh: 2.25;
  --ui: system-ui, -apple-system, 'Segoe UI', 'Noto Sans Arabic', 'Geeza Pro', Tahoma, sans-serif;
  --tap: 48px;
  color-scheme: light;
}
[data-theme='dark'] {
  --ivory: #16190f; --ivory-2: #1d2115; --paper: #20251a; --ink: #ece6d3; --ink-2: #b8b29e; --line: #353a2a;
  --olive-100: #2a3220; --gold-pale: #2d2a1d; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--ui); background: var(--ivory); color: var(--ink);
  font-size: 17px; line-height: 1.7; min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--olive-700); }
[data-theme='dark'] a { color: var(--gold-soft); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* الرأس */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--ivory) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--olive-800); font-weight: 700; font-size: 20px; }
[data-theme='dark'] .brand { color: var(--gold-soft); }
.brand img { width: 34px; height: 34px; }
.top .sp { flex: 1; }
.iconbtn { min-width: var(--tap); height: var(--tap); border: 0; background: transparent; border-radius: 14px; cursor: pointer; display: grid; place-items: center; color: var(--olive-700); }
.iconbtn:hover { background: var(--olive-100); }
.iconbtn svg { width: 24px; height: 24px; }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }
h1 { font-size: 26px; line-height: 1.4; margin: 6px 0 12px; color: var(--olive-800); }
h2 { font-size: 20px; margin: 22px 0 10px; color: var(--olive-800); }
[data-theme='dark'] h1, [data-theme='dark'] h2 { color: var(--gold-soft); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

/* بطاقات */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 14px 0; }
.card.gold { background: linear-gradient(160deg, var(--gold-pale), var(--paper) 70%); border-color: var(--gold-soft); }

/* أزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 22px;
  border-radius: 16px; border: 1px solid transparent; font-weight: 700; font-size: 18px; cursor: pointer; text-decoration: none;
  background: var(--olive-700); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--olive-800); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--olive-800); }
[data-theme='dark'] .btn.ghost { color: var(--ink); }
.btn.ghost:hover { background: var(--olive-100); }
.btn.gold { background: var(--gold); }
.btn.gold:hover { background: #9a7a3e; }
.btn.danger { background: transparent; border-color: #d8b2a6; color: #9c3d2a; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }

/* البطل */
.hero { text-align: center; padding: 34px 6px 10px; }
.hero img { width: 92px; height: 92px; }
.hero h1 { font-size: 40px; margin: 10px 0 0; letter-spacing: 0; }
.hero .tag { font-size: 20px; color: var(--gold); margin: 6px 0 22px; font-weight: 600; }
.hero p { color: var(--ink-2); max-width: 30em; margin: 0 auto 24px; }
.pillars { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 22px; }
.pillars a, .pillars div { display: block; text-decoration: none; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; font-weight: 600; font-size: 15px; }
.pillars span { display: block; font-size: 24px; color: var(--gold); }

/* المعالج */
.steps { display: flex; gap: 6px; margin: 8px 0 18px; }
.steps i { flex: 1; height: 6px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--gold); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choice {
  min-height: 74px; border: 2px solid var(--line); background: var(--paper); border-radius: 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; font-weight: 700; font-size: 18px; text-align: center;
}
.choice small { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.choice[aria-pressed='true'] { border-color: var(--olive-600); background: var(--olive-100); }
.field { display: block; margin: 14px 0; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.input, select.input {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); font-size: 18px;
}
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { min-width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 14px; }
.days button[aria-pressed='true'] { background: var(--olive-700); color: #fff; border-color: var(--olive-700); }

/* القراءة */
.wird-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.toolbar { position: sticky; top: 64px; z-index: 10; display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; background: var(--ivory); scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed='true'] { background: var(--olive-700); color: #fff; border-color: var(--olive-700); }
.surah-head { margin: 22px 0 6px; text-align: center; border: 1px solid var(--gold-soft); border-radius: 14px; padding: 10px; background: var(--gold-pale); color: var(--olive-800); font-weight: 700; }
[data-theme='dark'] .surah-head { color: var(--gold-soft); }
.surah-head small { display: block; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.basmala { font-family: 'Hafs20', serif; text-align: center; font-size: calc(var(--quran-size) * .95); margin: 8px 0 2px; }
.mushaf { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; margin: 10px 0; box-shadow: var(--shadow); }
.ayah { padding: 12px 0; border-bottom: 1px dashed var(--line); scroll-margin-top: 130px; }
.ayah:last-child { border-bottom: 0; }
.ayah.playing { background: linear-gradient(90deg, transparent, var(--gold-pale), transparent); border-radius: 10px; }
.q { font-family: 'Hafs20', 'KFGQPC HAFS Uthmanic Script', serif; font-size: var(--quran-size); line-height: var(--quran-lh); text-align: justify; text-align-last: center; direction: rtl; word-spacing: 2px; margin: 0; }
.q .n { font-family: 'Hafs20', serif; color: var(--gold); }
.ayah-meta { display: flex; gap: 6px; justify-content: flex-start; margin-top: 4px; }
.ayah-meta button { min-height: 40px; min-width: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; }
.ayah-meta button:hover { border-color: var(--line); }
.tafsir, .trans { margin-top: 8px; padding: 12px 14px; border-radius: 12px; font-size: 17px; line-height: 1.9; }
.tafsir { background: var(--olive-100); }
.trans { background: var(--ivory-2); }
.src { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.done-box { text-align: center; }
.done-box .big { font-size: 46px; color: var(--gold); line-height: 1; }

/* التقدم */
.progress { height: 12px; border-radius: 8px; background: var(--ivory-2); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--olive-600), var(--gold)); border-radius: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--ivory-2); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; color: var(--olive-800); }
[data-theme='dark'] .stat b { color: var(--gold-soft); }
.stat span { font-size: 14px; color: var(--ink-2); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.cal i { aspect-ratio: 1; border-radius: 8px; background: var(--ivory-2); border: 1px solid var(--line); }
.cal i.on { background: var(--olive-600); border-color: var(--olive-600); }

/* القوائم */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list a, .list button.li { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 4px; text-decoration: none; color: inherit; width: 100%; background: none; border: 0; cursor: pointer; text-align: start; }
.list .num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-pale); color: var(--olive-800); font-size: 14px; flex: none; }
.list .grow { flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--gold-pale); color: #7a5f28; }

/* المشغل */
.player {
  position: fixed; inset-inline: 0; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 760px;
  background: var(--olive-800); color: #fff; border-radius: 18px 18px 0 0; padding: 10px 14px; display: none;
}
.player.on { display: block; }
.player .ptitle { font-size: 14px; opacity: .9; text-align: center; }
.player .pbar { height: 4px; background: rgba(255, 255, 255, .2); border-radius: 3px; margin: 6px 0; overflow: hidden; }
.player .pbar i { display: block; height: 100%; background: var(--gold-soft); width: 0; }
.player .pctl { display: flex; justify-content: center; gap: 6px; }
.player .pctl button { min-width: 52px; height: 48px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; display: grid; place-items: center; }
.player .pctl button svg { width: 24px; height: 24px; }
.player .pctl button.main { background: var(--gold); min-width: 64px; }

/* الشريط السفلي */
.tabs {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 40; display: flex; justify-content: space-around; background: var(--paper);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12.5px; text-decoration: none; color: var(--ink-2); padding: 4px 0; min-height: 52px; border-radius: 12px; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current='page'] { color: var(--olive-700); font-weight: 700; }
[data-theme='dark'] .tabs a[aria-current='page'] { color: var(--gold-soft); }

.notice { padding: 12px 14px; border-radius: 14px; background: var(--gold-pale); border: 1px solid var(--gold-soft); font-size: 15px; margin: 12px 0; }
.toast { position: fixed; bottom: calc(150px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: 0 auto; max-width: 420px; background: var(--olive-900); color: #fff; padding: 12px 16px; border-radius: 14px; text-align: center; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }
dialog { border: 0; border-radius: 20px; padding: 22px; max-width: 420px; width: calc(100% - 32px); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(20, 20, 10, .45); }
.range { width: 100%; accent-color: var(--olive-700); height: 36px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; border-bottom: 1px solid var(--line); }
.switch input { width: 52px; height: 30px; accent-color: var(--olive-700); }
.key { font-family: ui-monospace, monospace; direction: ltr; font-size: 18px; letter-spacing: 1px; background: var(--ivory-2); padding: 10px; border-radius: 10px; text-align: center; user-select: all; word-break: break-all; }
footer.foot { text-align: center; font-size: 13px; color: var(--ink-2); padding: 20px 0 10px; }
footer.foot a { color: inherit; }
@media (min-width: 700px) {
  .choices { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .pillars { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
#view:focus { outline: none; }
.donebar { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 15; padding: 10px 0; background: linear-gradient(transparent, var(--ivory) 30%); }
.player.on ~ main .donebar, body:has(.player.on) .donebar { bottom: calc(190px + env(safe-area-inset-bottom)); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); }
.days button { min-width: 0; padding: 0; font-size: 13px; }
@media (min-width: 800px) { .tabs { max-width: 760px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; } }
.hasanat { color: var(--gold); font-weight: 600; margin: 4px 0 0; }
.hasanat:empty { display: none; }
.big-h { font-size: 18px; margin: 6px 0 2px; }
