:root {
  --bg: #f6f1e6;
  --bg-soft: #fffdf7;
  --ink: #2b2620;
  --ink-soft: #6d6355;
  --gold: #a9822f;
  --gold-soft: #e6d3a3;
  --line: #e2d7c0;
  --accent: #1f6f5c;
  --accent-soft: #d8ece5;
  --mark: #fff2b8;
  --mark2: #ffd9d2;
  --hl-a: #fff2b8; --hl-a-line: #d9b43c;
  --hl-b: #dbe9ff; --hl-b-line: #5a86c9;
  --hl-c: #dcf3e4; --hl-c-line: #48a473;
  --shadow: 0 10px 30px rgba(90, 70, 30, 0.12);
  --acc-hover: rgba(169, 130, 47, 0.09);
  --quran-size: 30px;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #14171a;
  --bg-soft: #1b1f23;
  --ink: #e8e3d8;
  --ink-soft: #a59d8f;
  --gold: #d0a94f;
  --gold-soft: #4a3d1f;
  --line: #2c3238;
  --accent: #59c1a3;
  --accent-soft: #1f3b34;
  --mark: #4d4318;
  --mark2: #4d2a24;
  --hl-a: #4d4318; --hl-a-line: #b08f2e;
  --hl-b: #24344d; --hl-b-line: #5a86c9;
  --hl-c: #1f3b2e; --hl-c-line: #48a473;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --acc-hover: rgba(208, 169, 79, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tajawal", "Segoe UI", system-ui, sans-serif;
  line-height: 1.85;
}

/* ــــــ الشريط العلوي ــــــ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; }
.brand p { margin: 0; font-size: 12px; color: var(--ink-soft); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--gold), #c9a961);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.tab {
  border: 1px solid transparent;
  background: none;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tab:hover { background: var(--accent-soft); color: var(--ink); }
.tab.is-active { background: var(--accent); color: #fff; }

.tools { display: flex; gap: 6px; align-items: center; }
#search {
  width: 210px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: inherit;
  font: inherit;
  font-size: 14px;
}
/* زرّ الاستماع: مكتوبٌ عليه وظيفته لا رمزًا مجرّدًا */
.listen {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.listen:hover { background: var(--accent); color: #fff; }
.listen.is-playing { background: var(--accent); color: #fff; }
.listen .listen-ico { font-size: 11px; }

.icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
}
.icon:hover { color: var(--ink); border-color: var(--gold); }

/* ــــــ العروض ــــــ */
main { max-width: 1040px; margin: 0 auto; padding: 22px 20px 80px; }
.view { display: none; }
.view.is-active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.mushaf-bar {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.legend b { font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-soft);
  cursor: pointer; font: inherit; font-size: 12.5px; color: inherit;
}
.chip.is-on { border-color: var(--gold); background: var(--gold-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; }

.progress { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.progress-track { width: 120px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

/* ــــــ المصحف ــــــ */
.mushaf { display: grid; gap: 20px; }
.page {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 30px 20px;
  position: relative;
}
.page::before {
  content: "";
  position: absolute; inset: 8px;
  border: 1px solid var(--gold-soft);
  border-radius: 10px;
  pointer-events: none;
}
.page-num {
  position: absolute; bottom: 6px; left: 0; right: 0;
  text-align: center; font-size: 12px; color: var(--ink-soft);
}
.basmala {
  text-align: center;
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: calc(var(--quran-size) * 0.92);
  color: var(--gold);
  margin: 4px 0 14px;
}
.page-text {
  font-family: "Amiri Quran", "Amiri", "Traditional Arabic", serif;
  font-size: var(--quran-size);
  line-height: 2.4;
  text-align: justify;
  text-align-last: center;
  word-spacing: 1px;
}

.ayah { cursor: pointer; border-radius: 6px; padding: 0 1px; transition: background 0.18s; }
.ayah:hover { background: var(--accent-soft); }
.ayah.is-active { background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
/* التظليل: لونٌ لكل علاقة، مع شريط بيانٍ يوضّح معناه */
.ayah.hl-mathani { background: var(--hl-a); box-shadow: inset 0 -2px 0 var(--hl-a-line); }
.ayah.hl-nazair { background: var(--hl-b); box-shadow: inset 0 -2px 0 var(--hl-b-line); }
.ayah.hl-muq { background: var(--hl-c); box-shadow: inset 0 -2px 0 var(--hl-c-line); }
.ayah.hl-theme { background: var(--mark2); }

.hl-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft);
  font-size: 0.84rem;
}
.hl-legend[hidden] { display: none; }
.hl-legend .hl-cap { font-weight: 700; color: var(--ink); }
.hl-legend .hl-key { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.hl-legend .hl-key i { width: 15px; height: 15px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }
.hl-legend .hl-key i.hl-mathani { background: var(--hl-a); border-color: var(--hl-a-line); }
.hl-legend .hl-key i.hl-nazair { background: var(--hl-b); border-color: var(--hl-b-line); }
.hl-legend .hl-key i.hl-muq { background: var(--hl-c); border-color: var(--hl-c-line); }
.hl-legend .hl-key i.hl-theme { background: var(--mark2); }
.hl-legend .hl-key b { color: var(--ink); }
.hl-legend .chip { margin-inline-start: auto; }
.ayah.is-done { box-shadow: inset 0 -2px 0 var(--gold-soft); }
.ayah.has-fawaid .num { color: var(--accent); }

.num {
  font-family: "Amiri", serif;
  font-size: 0.72em;
  color: var(--gold);
  padding: 0 2px;
  white-space: nowrap;
}
.sajda { color: var(--gold); font-size: 0.6em; }

/* ــــــ البطاقات العامة ــــــ */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card h4 { margin: 14px 0 4px; font-size: 15px; color: var(--accent); }
.card p { margin: 6px 0; }
.card ul { margin: 6px 0; padding-inline-start: 20px; }
.card li { margin: 4px 0; }
.muted { color: var(--ink-soft); font-size: 13.5px; }
.view h2.section-title { font-size: 20px; margin: 4px 0 4px; }
.view p.section-lead { color: var(--ink-soft); margin: 0 0 18px; font-size: 14.5px; }

.q {
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: 1.12em;
  line-height: 2.1;
}

/* ــــــ بواعث الطلب وزيادات المفاتيح ــــــ */
.view h3.sub-title { font-size: 17px; margin: 26px 0 10px; }
.card.bawaith { border-inline-start: 3px solid var(--gold); }

.athar {
  margin: 12px 0; padding: 10px 14px;
  border-inline-start: 3px solid var(--gold-soft);
  background: var(--bg-soft, rgba(0, 0, 0, 0.02));
  border-radius: 0 8px 8px 0;
  font-size: 15px; line-height: 1.95;
}
.athar cite { display: block; margin-top: 6px; font-size: 12.5px; color: var(--ink-soft); font-style: normal; }

.acc-tag {
  margin-inline-start: auto; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--gold-soft); color: var(--gold);
  font-size: 11.5px; font-weight: 700; direction: ltr;
}

.extras { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.extras h4 { margin: 0 0 10px; color: var(--gold); font-size: 14px; }
.extra + .extra { margin-top: 14px; }
.extra strong { display: block; margin-bottom: 4px; }
.extra p { margin: 0 0 6px; }

.ref {
  display: inline-block;
  border: 1px solid var(--gold-soft);
  background: var(--gold-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 1px 9px;
  margin: 2px;
  margin-inline-start: 0;
  font-size: 12.5px;
  cursor: pointer;
}
.ref:hover { border-color: var(--gold); }
.ref.ext { background: none; cursor: default; }

.acc { border-top: 1px solid var(--line); }
.acc:first-of-type { border-top: none; }
.acc-head {
  width: 100%; text-align: start;
  background: none; border: none; font: inherit;
  color: inherit; cursor: pointer;
  padding: 12px; margin-inline: -12px; border-radius: 8px;
  display: flex; gap: 10px; align-items: baseline;
  transition: background 0.15s ease, color 0.15s ease;
}
/* علامةُ الفتح: سهمٌ مرسومٌ بالحدود، ينقلب إلى أعلى عند الفتح.
   ومرسومٌ بالحدود لا بمحرفٍ نصّيّ حتى لا يختلف باختلاف الخطوط. */
.acc-head::after {
  content: ""; flex: none; align-self: center;
  margin-inline-start: auto;
  width: 8px; height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.5;
}
/* إذا كان في العنوان وسمٌ جانبيّ فهو الذي يأخذ الفراغ، ويليه السهم */
.acc-head:has(.acc-tag)::after { margin-inline-start: 10px; }
.acc-head:hover,
.acc-head:focus-visible { color: var(--accent); background: var(--acc-hover); }
.acc-head:hover::after { opacity: 1; }
.acc-head:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 8px; }
.acc-head .idx { color: var(--gold); font-weight: 700; min-width: 26px; }
.acc-body { display: none; padding: 0 12px 14px 12px; }
.acc.is-open .acc-body { display: block; }
.acc.is-open .acc-head { color: var(--accent); }
.acc.is-open .acc-head::after { transform: translateY(2px) rotate(-135deg); opacity: 1; }

table.cmp { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14.5px; }
table.cmp th, table.cmp td { border: 1px solid var(--line); padding: 9px 11px; vertical-align: top; text-align: start; }
table.cmp th { background: var(--accent-soft); }

/* ــــــ اللوحة الجانبية ــــــ */
.panel {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: min(460px, 100%);
  background: var(--bg-soft);
  border-inline-end: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 0.28s ease;
  z-index: 60;
  display: flex; flex-direction: column;
}
.panel.is-open { transform: none; }
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 16px 18px 10px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 2px 0 0; font-size: 16px; }
.panel-badge {
  background: var(--accent); color: #fff;
  border-radius: 999px; padding: 2px 10px; font-size: 12px;
}
.panel-actions { display: flex; gap: 6px; }
.panel-ayah {
  font-family: "Amiri Quran", "Amiri", serif;
  font-size: 23px; line-height: 2.1;
  margin: 0; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  max-height: 30vh; overflow: auto;
}
.panel-tabs { display: flex; gap: 4px; padding: 10px 14px 0; flex-wrap: wrap; }
.ptab {
  border: none; background: none; font: inherit; font-size: 13.5px;
  color: var(--ink-soft); padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.ptab.is-active { background: var(--accent-soft); color: var(--ink); }
.ptab .count { font-size: 11px; color: var(--gold); }
.panel-body { flex: 1; overflow: auto; padding: 12px 18px; }
.panel-body h4 { margin: 14px 0 4px; font-size: 14px; color: var(--accent); }
.panel-body ul { margin: 4px 0; padding-inline-start: 18px; }
.panel-body li { margin: 7px 0; }
.empty { color: var(--ink-soft); font-size: 14px; padding: 18px 0; text-align: center; }
.panel-note { padding: 10px 18px; border-top: 1px solid var(--line); }
.panel-note label { font-size: 12.5px; color: var(--ink-soft); }
#noteBox {
  width: 100%; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit; font-size: 14px; padding: 8px 10px; resize: vertical;
}
.panel-nav { display: flex; gap: 8px; padding: 10px 18px 16px; }
.panel-nav button {
  flex: 1; border: 1px solid var(--line); background: var(--bg);
  color: inherit; font: inherit; font-size: 14px;
  padding: 8px; border-radius: 10px; cursor: pointer;
}
.panel-nav button:hover { border-color: var(--gold); }

.scrim {
  position: fixed; inset: 0; background: rgba(20, 15, 5, 0.32);
  opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 50;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.stats { display: flex; gap: 18px; justify-content: center; color: var(--ink-soft); font-size: 13.5px; margin-bottom: 12px; }

/* ــــــ أبواب الاختبار والمراجعة ــــــ */
.topic-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; }
.chip.topic.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chip.go { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chip.danger { border-color: #c0483c; color: #c0483c; }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }

.qtopic {
  display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; margin-bottom: 10px;
}
.qcard .qbig { font-size: 20px; line-height: 2.1; margin: 6px 0 14px; }

/* اختيار نمط الاختبار */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.mode-card {
  display: grid; gap: 6px; text-align: start; font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: var(--radius); padding: 16px 18px;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card.is-on { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow); }
.mode-card .mode-icon { font-size: 22px; color: var(--gold); }
.mode-card .muted { font-size: 13px; line-height: 1.7; }
.mode-card .mode-n { font-size: 12.5px; color: var(--ink-soft); }

/* شريط الاختبار الثابت: التقدّم والخروج */
.quiz-bar {
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; display: grid; gap: 10px;
}
.quiz-bar-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.quiz-mode { font-weight: 700; }
.quiz-count { color: var(--ink-soft); }
.quiz-bar-track { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.quiz-bar-track i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.quiz-bar-acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* وصل الأشباه والنظائر */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.match-col { display: grid; gap: 8px; align-content: start; }
.match-item {
  position: relative; text-align: start; font: inherit; font-size: 14.5px; line-height: 1.9; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: 10px; padding: 10px 14px;
}
.match-item:hover:not(:disabled) { border-color: var(--accent); }
.match-item.alt { background: var(--bg); }
.match-item.is-sel { border-color: var(--gold); background: var(--gold-soft); box-shadow: var(--shadow); }
.match-item.is-linked { border-color: var(--accent); }
.match-item.is-right { border-color: var(--accent); background: var(--accent-soft); }
.match-item.is-wrong { border-color: #c0483c; background: var(--mark2); }
.match-item.is-static { opacity: 0.75; }
.match-tag {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-inline-end: 8px;
  border-radius: 6px; background: var(--gold-soft); color: var(--gold); font-size: 12.5px; font-weight: 700;
}
.match-item[data-left] .match-tag { position: absolute; inset-inline-start: 8px; top: 8px; margin: 0; }

/* الكروت القلّابة */
.flip-card {
  min-height: 210px; display: grid; place-items: center; text-align: center; cursor: pointer;
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 26px 22px; margin: 6px 0 14px;
  background: var(--bg);
}
.flip-card.is-back { cursor: default; border-style: solid; background: var(--bg-soft); text-align: start; }
.flip-card .flip-face { width: 100%; }
.flip-card .flip-hint { color: var(--ink-soft); font-size: 13px; margin-top: 14px; }
.flip-card ul { text-align: start; }

/* الحكم على النفس */
.grade { margin-top: 8px; }
.grade-lead { font-size: 14px; margin: 0 0 10px; }
.grade-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.grade button, .grade-row button {
  display: grid; gap: 3px; text-align: center; font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: 10px; padding: 10px 14px;
}
.grade button b { font-size: 14.5px; }
.grade button span { font-size: 12px; color: var(--ink-soft); }
.grade button:hover { border-color: var(--accent); }
.grade .g-no:hover, .grade .grade-no:hover { border-color: #c0483c; }
.grade .g-easy:hover { border-color: var(--gold); }
.grade .grade-yes, .grade .grade-no { display: inline-block; padding: 9px 20px; }
.grade .grade-yes { border-color: var(--accent); color: var(--accent); }

.review-card .review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-back { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); text-align: start; }

/* بيان القراءات داخل لوحة الآية */
.qiraat {
  margin-top: 18px; padding: 14px 16px;
  border: 1px solid var(--gold-soft); border-inline-start: 3px solid var(--gold);
  border-radius: 10px; background: var(--bg);
}
.qiraat h4 { margin: 0 0 8px; color: var(--gold); }
.qiraat ul { margin: 8px 0 0; }
.qiraat li { margin-bottom: 8px; }

.result-list { display: grid; gap: 10px; }
.result-list li { display: flex; gap: 8px; align-items: flex-start; line-height: 1.9; }
.result-list li.ok > b { color: var(--accent); }
.result-list li.bad > b { color: #c0483c; }

@media (max-width: 680px) {
  .match-grid { grid-template-columns: 1fr; }
}

/* ــــــ الخريطة الذهنية (شجرة SVG على هيئة XMind) ــــــ */
.mind-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.mind-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.mind-tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.mind-tools .icon { min-width: 32px; }

.mind-canvas {
  position: relative; overflow: hidden; cursor: grab;
  height: min(72vh, 760px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 12%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg-soft);
}
.mind-canvas.is-dragging { cursor: grabbing; }
.mind-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#mindPan { transform-origin: 0 0; }

.mind-link { fill: none; stroke-width: 2.2; opacity: 0.85; stroke-linecap: round; }

.mind-n { cursor: pointer; }
/* مع direction:rtl يكون «بدء» النص هو طرفه الأيمن، فنُثبّته عند يمين الصندوق */
.mind-n text {
  font-family: inherit; font-size: 13.5px; fill: var(--ink);
  text-anchor: start; direction: rtl; unicode-bidi: plaintext;
  dominant-baseline: middle; pointer-events: none;
}
.mind-n .hit { fill: transparent; stroke: none; }
.mind-n .box { fill: var(--bg); stroke: var(--c); stroke-width: 1.6; }
.mind-n .underline { stroke: var(--c); stroke-width: 2; opacity: 0.9; }
.mind-n:hover .hit { fill: color-mix(in srgb, var(--c) 12%, transparent); }
.mind-n:hover text { fill: var(--c); }

.mind-n.is-root .box { fill: var(--c); stroke: var(--c); }
.mind-n.is-root text { fill: #fff; font-size: 16px; font-weight: 700; }
.mind-n.is-branch .box { fill: color-mix(in srgb, var(--c) 14%, var(--bg)); }
.mind-n.is-branch text { font-weight: 700; font-size: 14.5px; }
.mind-n.is-focus .hit { fill: var(--mark); }
.mind-n.is-focus .box { stroke-width: 3; }

.mind-n .tw circle { fill: var(--bg); stroke: var(--c); stroke-width: 1.5; }
.mind-n .tw .twt { font-size: 13px; font-weight: 700; fill: var(--c); text-anchor: middle; }
.mind-n:hover .tw circle { fill: var(--c); }
.mind-n:hover .tw .twt { fill: #fff; }
/* بسطُ ثيمات المقدمة: فقراتٌ موسَّعة داخل البند */
.basat {
  margin: 12px 0; padding: 12px 14px;
  border-inline-start: 3px solid var(--gold-soft);
  background: var(--bg); border-radius: 0 10px 10px 0;
}
.basat h4 { margin: 0 0 6px; color: var(--gold); font-size: 14.5px; }
.basat p { margin: 0 0 6px; }

/* مبدّل الخريطتين */
.mind-switch { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mind-switch .chip { cursor: pointer; }
.mind-switch .chip.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.lead-pill {
  display: inline-block; padding: 1px 8px; border-radius: 5px;
  border: 1px solid var(--gold-soft); color: var(--gold); font-weight: 700; font-size: 0.92em;
}

/* تلميح الطيّ: يحمل السهم نفسه الذي على العناوين ليُعرَف معناه */
.lead-hint {
  display: inline-flex; align-items: center; gap: 7px;
  margin-inline-start: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--gold-soft); background: var(--acc-hover);
  color: var(--gold); font-size: 0.88em; font-weight: 700;
  white-space: nowrap;
}
.lead-caret {
  width: 7px; height: 7px; flex: none;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

/* مربّعات أرقام الآيات داخل عقد الخريطة: مفاتيحُ انتقالٍ إلى المصحف */
.mind-ref { cursor: pointer; }
.mind-ref rect { fill: var(--bg); stroke: var(--gold-soft); stroke-width: 1; }
.mind-ref text { font-size: 11.5px; font-weight: 700; fill: var(--gold); text-anchor: middle; direction: ltr; }
.mind-ref:hover rect { fill: var(--gold); stroke: var(--gold); }
.mind-ref:hover text { fill: #fff; }
.mind-ref.is-more { cursor: pointer; }
.mind-ref.is-more rect { fill: transparent; stroke-dasharray: 3 2; }

.mind-note-box { display: none; margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.mind-note-box.is-on { display: block; }
.mind-note-box h4 { margin: 0 0 8px; }

/* ــــــ العرض التطبيقي ــــــ */
ol.flow { padding-inline-start: 22px; }
ol.flow > li { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
ol.flow > li:last-child { border-bottom: 0; }
ol.flow > li p { margin: 0 0 6px; }
ol.flow > li::marker { color: var(--gold); font-weight: 700; }

/* ــــــ الخصال والمقابلات ــــــ */
.pair {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0;
}
.pair-vs { color: var(--gold); font-size: 12.5px; white-space: nowrap; }
.pair-side p { margin: 0 0 6px; }
.src { font-size: 12.5px; }
.by { font-size: 12.5px; margin-top: -4px; }

/* ــــــ الاختبار ــــــ */
.choices { display: grid; gap: 8px; margin: 12px 0; }
.choice {
  font: inherit; text-align: start; cursor: pointer; padding: 11px 14px;
  border: 1px solid var(--line); background: var(--bg-soft); color: inherit; border-radius: 12px;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.is-right { border-color: var(--accent); background: var(--mark); }
.choice.is-wrong { border-color: #c0483c; background: var(--mark2); }
.explain { border-top: 1px dashed var(--line); padding-top: 12px; }
li.ok { color: var(--ink); }
li.bad { color: #c0483c; }

.hit { cursor: pointer; }
.hit mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

@media (max-width: 880px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; }
  .tools { justify-content: space-between; }
  #search { flex: 1; width: auto; }
  .page { padding: 20px 16px 18px; }
  .pair { grid-template-columns: 1fr; }
  .pair-vs { text-align: center; }
  :root { --quran-size: 25px; }
}

/* بسط المحاضرة: فقرات كاملة وتوقيت لكل خطوة، بلا قص للنص. */
.lecture-step { padding: 14px 0; border-bottom: 1px solid var(--line); }
.lecture-step:last-child { border-bottom: 0; }
.lecture-step h4 { margin: 0 0 10px; line-height: 1.8; color: var(--accent); }
.lecture-step p { line-height: 2; overflow-wrap: anywhere; }
.lecture-step-number { font-size: .85em; margin-inline-end: 6px; }
.lecture-summary, .lecture-review { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.lecture-summary summary, .lecture-review summary, .review-back summary { cursor: pointer; line-height: 1.8; }
.lecture-benefit > .acc-head { flex-wrap: wrap; }

/* إضافات المحاضرات: النص الكامل يفتح دون قص، مع مصدر وروابط واضحة. */
.maryam-collection { margin: 24px 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.maryam-collection h3, .maryam-collection h4 { color: var(--accent); }
.maryam-index { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.maryam-index .chip, .maryam-homes .chip { white-space: normal; text-align: start; }
.maryam-group { margin: 28px 0; }
.maryam-benefit { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; scroll-margin-top: 180px; background: var(--bg-soft); }
.maryam-benefit > summary { cursor: pointer; padding: 16px; font-weight: 700; color: var(--ink); line-height: 1.8; }
.maryam-benefit > summary::marker { color: var(--accent); }
.maryam-benefit > summary:hover { background: var(--acc-hover); }
.maryam-benefit > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.maryam-open-label { display: inline-block; margin-inline-start: 12px; font-size: .8em; color: var(--accent); font-weight: 400; }
.maryam-benefit[open] > summary { border-bottom: 1px solid var(--line); background: var(--accent-soft); }
.maryam-body { padding: 8px 20px 20px; overflow-wrap: anywhere; line-height: 2; }
.maryam-source { margin: 20px 0; padding: 14px; background: var(--bg); border-inline-start: 3px solid var(--gold); font-size: .9em; }
.maryam-source a { color: var(--accent); text-decoration: underline; }
.maryam-connections { font-size: .9em; color: var(--ink-soft); }
.maryam-homes { padding-top: 12px; border-top: 1px solid var(--line); }
.maryam-panel .maryam-body { padding: 8px 12px 16px; }
@media (max-width: 600px) {
  .maryam-collection { padding: 12px; }
  .maryam-body { padding: 8px 12px 16px; }
  .maryam-open-label { display: block; margin-inline-start: 0; }
}

/* الهاتف: تبويبات قابلة للسحب وأدوات موزعة دون توسيع الصفحة. */
.topbar > *, .tools > *, main, .view { min-width: 0; }
#jump { width: 76px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); color: inherit; font: inherit; }
#btnBack { width: auto; min-width: 62px; white-space: nowrap; }
.panel-body { min-height: 0; overflow-wrap: anywhere; }
.mind-canvas { touch-action: none; }
@media (max-width: 880px) {
  .tools { flex-wrap: wrap; }
  #search { min-width: 140px; }
  .tabs { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; max-width: 100%; padding-bottom: 5px; }
  .tab { flex: 0 0 auto; white-space: nowrap; min-height: 44px; }
}
@media (max-width: 600px) {
  .topbar { position: relative; padding: 10px 12px; gap: 8px; }
  .brand-mark { flex-shrink: 0; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 11px; }
  .tools { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
  #search { grid-column: 1 / -1; grid-row: 1; width: 100%; min-width: 0; }
  #jump { grid-column: span 2; width: 100%; }
  #btnBack { grid-column: span 2; }
  .tools .icon { width: 100%; }
  .icon, .listen, .ptab { min-height: 44px; }
  input, textarea, #search, #jump, #noteBox { font-size: 16px; }
  main { padding: 14px 10px 40px; }
  .card { padding: 14px 12px; }
  .page { padding: 18px 14px 24px; }
  .page-text { text-align: start; text-align-last: auto; line-height: 2.25; }
  .mushaf-bar, .progress, .stats { flex-wrap: wrap; gap: 8px; }
  .acc-head { margin-inline: 0; padding-inline: 0; gap: 6px; }
  .acc-body { padding-inline: 2px; }
  .acc-tag { white-space: normal; flex-shrink: 0; max-width: 28%; }
  .chip, .ref, .choice { max-width: 100%; white-space: normal; overflow-wrap: anywhere; min-height: 40px; }
  .card p, .card li, .src, .by { overflow-wrap: anywhere; }
  table.cmp { display: block; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  table.cmp th, table.cmp td { min-width: 130px; }
  .maryam-collection { padding: 10px; }
  .maryam-body, .maryam-source { padding: 10px; }
  .maryam-benefit > summary { padding: 12px; }
  .maryam-benefit { scroll-margin-top: 12px; }
  .panel { width: 100%; height: 100dvh; inset-block-end: auto; }
  .panel-head { padding: 8px 10px; align-items: center; flex-shrink: 0; }
  .panel-head > div { min-width: 0; }
  .panel-actions { flex-wrap: wrap; justify-content: flex-end; }
  .panel-ayah { padding: 8px 12px; font-size: 21px; max-height: 22dvh; flex-shrink: 0; }
  .panel-tabs { flex-wrap: nowrap; overflow-x: auto; padding: 6px 10px; flex-shrink: 0; }
  .ptab { flex: 0 0 auto; white-space: nowrap; }
  .panel-body { padding: 10px 12px; overscroll-behavior-y: contain; }
  .panel-note { padding: 4px 10px; }
  #noteBox { max-height: 65px; }
  .panel-nav { padding: 6px 10px max(8px,env(safe-area-inset-bottom)); flex-shrink: 0; }
  .mind-canvas { height: 62dvh; min-height: 300px; }
  .mind-tools { gap: 8px; }
  .flip-card { padding: 18px 12px; }
  .grade-row { grid-template-columns: 1fr; }
}
