/* الهوية: غابة وعاج وتيراكوتا */
@font-face { font-family: "Dad Naskh"; src: url("../assets/fonts/Amiri-Regular.ttf") format("truetype"), local("Amiri"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Dad Naskh"; src: url("../assets/fonts/Amiri-Bold.ttf") format("truetype"), local("Amiri Bold"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Dad UI"; src: url("../assets/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype"), local("IBM Plex Sans Arabic"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Dad UI"; src: url("../assets/fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype"), local("IBM Plex Sans Arabic SemiBold"); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #FBF7EF; --surface: #FFFFFF; --sunk: #F3ECDF; --line: #E4DAC8; --ink: #2B2F2E; --muted: #5F6765;
  --brand: #0F3D3A; --brand-2: #1F6F5C; --brand-soft: #E3EFE9; --on-brand: #FBF7EF;
  --accent: #A9522A; --accent-2: #C8683A; --on-accent: #FFFFFF;
  --ok-bg: #CFE8D8; --ok-ink: #12452F; --sg-bg: #F8DFCB; --sg-ink: #7A3412; --bad: #A12D22;
  --r: 16px; --shadow: 0 1px 2px rgba(15,61,58,.06), 0 10px 30px rgba(15,61,58,.08);
  --ui: "Dad UI", "Segoe UI", Tahoma, system-ui, sans-serif; --naskh: "Dad Naskh", "Traditional Arabic", "Noto Naskh Arabic", serif;
}
:root[data-theme="dark"] {
  --bg: #0C1614; --surface: #132220; --sunk: #0F1C1A; --line: #24403A; --ink: #E7E2D6; --muted: #9DB0AA;
  --brand: #8FCDB6; --brand-2: #2F8A72; --brand-soft: #17352E; --on-brand: #F6F1E6;
  --accent: #E08A5C; --accent-2: #B45A30; --on-accent: #FFFFFF;
  --ok-bg: #1D4A35; --ok-ink: #D5F2E0; --sg-bg: #5A3220; --sg-ink: #FCE3D2; --bad: #FF9A8A;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); line-height: 1.7; min-width: 320px; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .4rem; color: var(--brand); text-wrap: balance; }
a { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--surface); padding: 8px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 8px; }

/* الشريط العلوي والقائمة */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem; height: 64px; padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); background: #0F3D3A; color: #FBF7EF; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.menu-btn { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(251,247,239,.28); background: rgba(251,247,239,.08); color: inherit; font: 600 .95rem var(--ui); cursor: pointer; }
.menu-btn[aria-expanded="true"] { background: #C8683A; border-color: #C8683A; }
.logo { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font: 700 1.35rem var(--naskh); white-space: nowrap; overflow: hidden; }
.logo-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #FBF7EF; color: #0F3D3A; font-size: 1.5rem; line-height: 1; }
.top-actions { margin-inline-start: auto; display: flex; gap: .4rem; }
.top .btn.ghost { color: #FBF7EF; border-color: rgba(251,247,239,.28); background: transparent; }
.drawer { position: fixed; top: 64px; bottom: 0; inset-inline-start: 0; width: min(300px, 85vw); background: var(--surface); border-inline-end: 1px solid var(--line); overflow-y: auto; z-index: 25; transform: translateX(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; padding: 12px; box-shadow: var(--shadow); }
[dir="ltr"] .drawer { transform: translateX(-105%); }
.menu-open .drawer, [dir="ltr"] .menu-open .drawer { transform: none; visibility: visible; }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.drawer a { display: flex; align-items: center; gap: .7rem; min-height: 46px; padding: 6px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.drawer a:hover { background: var(--sunk); }
.drawer a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.drawer a small { margin-inline-start: auto; font-size: .72rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; color: var(--muted); }
.ic { width: 22px; height: 22px; flex: none; }
.backdrop { position: fixed; inset: 64px 0 0; background: rgba(10,25,23,.5); z-index: 20; }
main { padding: 20px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right)); max-width: 1320px; margin-inline: auto; outline: none; }
@media (min-width: 1000px) {
  body.menu-desktop .drawer { width: 270px; box-shadow: none; }
  main { transition: margin .25s ease; }
  body.menu-desktop.menu-open main { margin-inline-start: 270px; margin-inline-end: 0; max-width: none; }
}

/* الأزرار والحقول */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: 6px 18px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .95rem var(--ui); cursor: pointer; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--accent-2); transform: translateY(-1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; }
.btn:disabled { cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 8px 20px rgba(169,82,42,.28); }
:root[data-theme="dark"] .btn.primary { background: var(--accent-2); border-color: var(--accent-2); }
.btn.small { min-height: 38px; padding: 2px 12px; font-size: .85rem; }
.btn.big { min-height: 54px; padding-inline: 34px; font-size: 1.1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.tools { margin-bottom: .6rem; }
textarea { width: 100%; min-height: 280px; resize: vertical; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 1.35rem/2.2 var(--naskh); padding: 12px 16px; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--sunk); padding: 4px; border-radius: 14px; }
.seg label, .chip { position: relative; }
.seg input, .chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 14px; border-radius: 10px; font-size: .9rem; }
.seg input:checked + span { background: #0F3D3A; color: #FBF7EF; }
:root[data-theme="dark"] .seg input:checked + span { background: var(--brand-2); }
.seg input:focus-visible + span, .chip input:focus-visible + span { outline: 3px solid var(--accent-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip span { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 4px 14px; border: 1.5px solid var(--line); border-radius: 99px; font-size: .9rem; }
.chip span::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.chip input:checked + span { background: var(--brand-soft); border-color: var(--brand-2); }
.chip input:checked + span::before { background: var(--brand-2); border-color: var(--brand-2); }
.chip.off { opacity: .5; }
input[type="range"] { width: 100%; accent-color: var(--accent-2); }

/* المدقق */
.page-head { margin-bottom: 14px; }
.page-head p { margin: 0; color: var(--muted); }
.panels { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .panels { grid-template-columns: minmax(0,1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel.narrow { max-width: 760px; }
.panel-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-h h2 { margin: 0; font-size: 1.15rem; }
.panel-b { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-b > div > p.empty { margin: 0; }
.drop { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border: 2px dashed var(--brand-2); background: var(--brand-soft); border-radius: var(--r); padding: 14px; }
.drop > span:first-child { flex: 1; min-width: 200px; }
.drop.over { border-color: var(--accent-2); background: var(--sg-bg); color: var(--sg-ink); }
.fmts { font-size: .75rem; color: var(--muted); }
.hint { margin: 0; font-size: .82rem; color: var(--muted); }
.status { margin: 0; min-height: 1.4em; font-size: .9rem; color: var(--brand-2); }
.status.bad { color: var(--bad); }
.warn { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--sg-bg); color: var(--sg-ink); font-size: .85rem; }
.tabs { display: flex; gap: 4px; background: var(--sunk); padding: 4px; border-radius: 14px; }
.tabs button { min-height: 38px; border: 0; background: transparent; color: var(--muted); font: 600 .88rem var(--ui); padding: 4px 12px; border-radius: 10px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.count { display: inline-block; min-width: 1.7em; border-radius: 99px; background: var(--accent-2); color: #fff; font-size: .72rem; }
.out { font: 1.5rem/2.5 var(--naskh); overflow-wrap: anywhere; }
.out h3 { font: 700 1.8rem/2.2 var(--naskh); margin: .2rem 0; }
.out p { margin: 0 0 .5rem; }
.out ul { margin: 0 0 .5rem; padding-inline-start: 1.5em; }
.sec { font: 600 .8rem var(--ui); color: var(--accent); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.out .w { cursor: pointer; border-radius: 5px; }
.out .w:hover { background: var(--sunk); }
mark.ok { background: var(--ok-bg); color: var(--ok-ink); padding: 0 3px; }
mark.sg { background: var(--sg-bg); color: var(--sg-ink); padding: 0 3px; text-decoration: underline wavy var(--accent-2) 1px; text-underline-offset: 10px; }
.empty { color: var(--muted); font: .95rem var(--ui); }
.pop { background: var(--brand-soft); border-radius: 12px; padding: 8px 14px; margin-bottom: 8px; }
.fixes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fixes li { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: grid; gap: 6px; justify-items: start; }
.pair { display: flex; flex-wrap: wrap; gap: 10px; font: 1.3rem/2 var(--naskh); }
.pair del { color: var(--bad); }
.pair ins { text-decoration: none; background: var(--ok-bg); color: var(--ok-ink); padding: 0 6px; border-radius: 6px; }
.why { font-size: .88rem; color: var(--muted); }
.tag { display: inline-block; font-size: .76rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 10px; margin-inline-end: 4px; color: var(--ink); }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.tag.sg { background: var(--sg-bg); color: var(--sg-ink); border-color: transparent; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stats div { background: var(--sunk); border-radius: 14px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 1.5rem; color: var(--brand); font-variant-numeric: tabular-nums; }
.stats span { font-size: .78rem; color: var(--muted); }
.an h3 { font-size: 1rem; margin-top: 4px; }

/* الحساب ولوحة المدير */
.field { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.field input { width: 100%; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 6px 14px; font: 1rem var(--ui); }
.check { display: flex; align-items: center; gap: .6rem; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent-2); }
.quota { display: flex; align-items: baseline; gap: .6rem; }
.quota b { font-size: 3rem; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 12px; accent-color: var(--brand-2); }
.gap { margin-top: 16px; }
.tbl { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td .row { flex-wrap: nowrap; }
.announce { margin: 0; padding: 10px 20px; background: var(--sg-bg); color: var(--sg-ink); font-weight: 600; text-align: center; }
@media (min-width: 1000px) { body.menu-desktop.menu-open .announce { margin-inline-start: 270px; } }

.w.low { text-decoration: underline dotted var(--muted); text-underline-offset: .35em; }
.w[data-src="trusted"] { text-decoration: underline solid var(--brand-2); text-underline-offset: .35em; }
.grow { flex: 1; min-width: 180px; }
textarea.short { min-height: 130px; }
.pop input#edit { min-height: 40px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 4px 10px; font-size: 1.1rem; }

/* القرآن */
select, input.search { min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 6px 12px; font: 1rem var(--ui); }
.mushaf { margin-top: 16px; font-family: "Dad Naskh", "Amiri", "Traditional Arabic", serif; line-height: 2.4; }
.mushaf h2 { text-align: center; color: var(--brand); }
.aya { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px 16px 12px; margin-bottom: 10px; }
.aya p { margin: 0; }
.basmala { display: block; text-align: center; color: var(--brand); }
.aya .num { font-size: .6em; color: var(--muted); }
.aya .row, .irab { font-family: var(--ui); font-size: 1rem; line-height: 1.8; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* الشعر والصرف */
.verses { margin-top: 16px; }
.verse { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 16px; margin-bottom: 10px; }
.bayt { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 32px; text-align: center; font-family: var(--naskh); font-size: 1.35rem; line-height: 2.2; }
.conj td { font-family: var(--naskh); font-size: 1.25rem; line-height: 2; }
summary.panel-h { cursor: pointer; }

/* الأدوات والتدريبات وأدوات المعلم */
.page-tabs { flex-wrap: wrap; margin: 14px 0; }
.tab-body > div > .btn, .tab-body .choices + .btn { margin-top: 10px; }
.keys { display: grid; gap: 4px; }
.keys div { display: flex; flex-wrap: wrap; gap: 4px; }
.keys button { min-width: 38px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 1.2rem var(--naskh); cursor: pointer; }
.keys button.wide { min-width: 120px; font: .9rem var(--ui); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.choices .btn, .match .btn { font: 1.3rem var(--naskh); min-height: 52px; }
.btn.good { border-color: var(--brand-2); outline: 3px solid var(--brand-2); }
.btn.wrong { outline: 3px solid #b3402a; }
.btn.chosen { outline: 3px solid var(--accent, #c8683a); }
.slot { min-height: 2.6em; border-bottom: 2px dashed var(--line); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.match .col { display: grid; gap: 8px; }
.flash { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-align: center; font: 1.6rem var(--naskh); margin-bottom: 10px; }
.wheel-name { font: 700 2.4rem var(--naskh); text-align: center; min-height: 1.8em; color: var(--brand); }
.clock { font-size: clamp(3rem, 14vw, 8rem); text-align: center; margin: 0; font-variant-numeric: tabular-nums; color: var(--brand); }
.clock.done { color: #b3402a; }
.picked li { margin-bottom: 6px; }
select { max-width: 100%; }
select[multiple] { min-height: 130px; }
.paper { background: #fff; color: #111; border-radius: 12px; padding: 24px; margin-top: 14px; border: 1px solid var(--line); overflow-x: auto; }
.sheet { font-family: var(--naskh); font-size: 1.15rem; line-height: 2.1; }
.sheet-head { border-bottom: 2px solid #333; margin-bottom: 12px; }
.sheet h1 { font-size: 1.6rem; margin: 0; }
.sheet h2 { font-size: 1.25rem; margin: 10px 0 0; }
.write { border-bottom: 1.5px dotted #888; height: 2.4em; }
.trace { width: 100%; height: auto; display: block; }
.key { border-top: 2px dashed #888; margin-top: 24px; break-before: page; }
.cert { box-sizing: border-box; text-align: center; border: 6px double #0F3D3A; border-radius: 16px; padding: 48px 32px; font-family: var(--naskh); min-height: 170mm; display: flex; flex-direction: column; justify-content: center; page: cert; break-after: page; }
.cert:last-child { break-after: auto; }
.cert h1 { font-size: 2.8rem; margin: 0; color: #0F3D3A; }
.cert h2 { font-size: 2.2rem; color: #A9522A; margin: 8px 0; }
.cert p { font-size: 1.4rem; }
.cert .sign { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
@page cert { size: A4 landscape; margin: 10mm; }

.update { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 60; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 2px solid var(--accent-2); box-shadow: var(--shadow); }

/* الرئيسية */
.hero { position: relative; overflow: hidden; border-radius: 28px; padding: clamp(24px, 6vw, 64px); background: linear-gradient(135deg, #0F3D3A, #1F6F5C); color: #FBF7EF; animation: rise .5s ease both; }
.hero h1 { color: #FBF7EF; font: 700 clamp(2rem, 6vw, 3.6rem)/1.5 var(--naskh); max-width: 16ch; }
.hero p { max-width: 46ch; color: #E3EFE9; font-size: 1.05rem; }
.hero .hero-name { margin: 0; font-weight: 600; color: #F4B894; }
.hero .btn.primary { background: #A9522A; border-color: #C8683A; }
.hero-letter { position: absolute; inset-inline-end: -2%; bottom: -22%; font: 700 clamp(14rem, 34vw, 26rem)/1 var(--naskh); color: rgba(251,247,239,.09); pointer-events: none; }
.section-title { margin: 28px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card { display: grid; gap: 10px; align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .18s, border-color .18s; }
.card:hover { transform: translateY(-4px); border-color: var(--accent-2); }
.card .ic { width: 44px; height: 44px; padding: 9px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); }
.card span { font-weight: 600; }
.card small { color: var(--muted); font-size: .76rem; }
.card small.live { color: var(--accent); font-weight: 600; }
.soon { text-align: center; padding: 60px 16px; }
.soon .ic { width: 80px; height: 80px; color: var(--accent-2); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) { .logo span:last-child { font-size: 1.1rem; } .menu-btn span { font-size: .85rem; } #lang { padding-inline: 8px; } }
@media (max-width: 380px) { .logo span:last-child { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* الطباعة إلى PDF */
#print-area { display: none; }
@media print {
  body > :not(#print-area) { display: none !important; }
  body { background: #fff; color: #000; }
  #print-area { display: block; font: 14pt/2.1 var(--naskh); }
  #print-area .sec { color: #000; }
  #print-area h3 { color: #000; break-after: avoid; }
  @page { margin: 18mm; }
}
