:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f1ead9;
  --ink: #1f2a26;
  --muted: #66706b;
  --line: #e2d8c3;
  --brand: #0f5c4d;
  --brand-2: #157a66;
  --gold: #b8892d;
  --gold-soft: #f4e6c4;
  --good: #2f8a4c;
  --bad: #b24a3b;
  --c-quraysh: #b8892d;
  --c-jews: #3d6fa8;
  --c-arabs: #8a5a9e;
  --c-romans: #b24a3b;
  --era-pre: #8c7a5b;
  --era-makki: #b8892d;
  --era-madani: #0f5c4d;
  --pe1: #7a6a9c; --pe2: #b0693a; --pe3: #b8892d; --pe4: #3d7f8a; --pe5: #3d6fa8; --pe6: #0f5c4d;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 20px rgba(40, 30, 10, .06);
  --radius: 14px;
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-head: 'Amiri', 'Traditional Arabic', serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #161e1b; --surface-2: #1d2824; --ink: #e9e4d8;
    --muted: #9aa49f; --line: #2a3632; --brand: #3fb69a; --brand-2: #5cc9ae;
    --gold: #d8b05c; --gold-soft: #3a3120;
    --era-pre: #a8987a; --era-makki: #d8b05c; --era-madani: #3fb69a;
    --pe1: #a596c9; --pe2: #d48d5c; --pe3: #d8b05c; --pe4: #62aab5; --pe5: #6f9bd4; --pe6: #3fb69a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --surface-2: #1d2824; --ink: #e9e4d8;
  --muted: #9aa49f; --line: #2a3632; --brand: #3fb69a; --brand-2: #5cc9ae;
  --gold: #d8b05c; --gold-soft: #3a3120;
    --era-pre: #a8987a; --era-makki: #d8b05c; --era-madani: #3fb69a;
    --pe1: #a596c9; --pe2: #d48d5c; --pe3: #d8b05c; --pe4: #62aab5; --pe5: #6f9bd4; --pe6: #3fb69a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

/* شريط التمرير بألوان الموقع */
html, .detail, .ruler-wrap, .compare-table-wrap, .flash .back {
  scrollbar-color: var(--brand) var(--surface-2);
}
html { scrollbar-width: auto; }
.detail, .ruler-wrap, .compare-table-wrap, .flash .back { scrollbar-width: thin; }
::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb {
  background: var(--brand); border-radius: 999px; border: 3px solid var(--surface-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
::-webkit-scrollbar-corner { background: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.75;
}
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.55rem; color: var(--brand); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ===== الشريط العلوي ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: color-mix(in srgb, var(--surface) 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(--ink); }
.brand strong { display: block; font-family: var(--font-head); font-size: 1.2rem; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .8rem; }
.brand-mark { display: block; width: 40px; height: 40px; flex: none; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.nav a {
  padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { background: var(--brand); color: #fff; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.1rem;
}

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.view-head { margin-bottom: 20px; }

/* ===== عام ===== */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 .panel { margin-bottom: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: transform .1s, background .2s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.good { border-color: var(--good); color: var(--good); }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
.chip {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.quraysh { background: color-mix(in srgb, var(--c-quraysh) 18%, transparent); color: var(--c-quraysh); }
.chip.jews { background: color-mix(in srgb, var(--c-jews) 18%, transparent); color: var(--c-jews); }
.chip.arabs { background: color-mix(in srgb, var(--c-arabs) 18%, transparent); color: var(--c-arabs); }
.chip.romans { background: color-mix(in srgb, var(--c-romans) 18%, transparent); color: var(--c-romans); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }

/* ===== الرئيسية ===== */
.hero {
  text-align: center; padding: 36px 20px 30px; margin-bottom: 24px; border-radius: 20px;
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 50%),
    radial-gradient(circle at 80% 100%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 50%),
    var(--surface);
  border: 1px solid var(--line);
}
.hero h1 { font-size: 2.8rem; }
.hero h1 span { color: var(--gold); }
.lead { font-family: var(--font-head); font-size: 1.25rem; color: var(--muted); margin: 0 auto 20px; max-width: 640px; }
.hero-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.stat {
  min-width: 120px; padding: 10px 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
}
.stat b { display: block; font-size: 1.8rem; color: var(--brand); line-height: 1.2; }
.stat span { font-size: .85rem; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.diff { display: grid; gap: 10px; margin-top: 10px; }
.diff div { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }
.diff b { color: var(--brand); }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.counts div { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--surface-2); }
.counts b { display: block; font-size: 1.6rem; color: var(--gold); }
.counts span { font-size: .8rem; color: var(--muted); }
.checks { margin: 0; padding: 0; list-style: none; }
.checks li { padding-inline-start: 26px; position: relative; }
.checks li::before { content: '✓'; position: absolute; inset-inline-start: 0; color: var(--good); font-weight: 700; }

.year-bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; align-items: end; height: 220px; }
.ybar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: pointer; text-decoration: none; color: inherit; }
.ybar .bar {
  width: 100%; max-width: 70px; border-radius: 8px 8px 3px 3px; background: var(--brand);
  display: flex; align-items: flex-start; justify-content: center; color: #fff; font-weight: 700; padding-top: 4px;
  transition: background .2s;
}
.ybar:hover .bar { background: var(--gold); }
.ybar .lbl { margin-top: 6px; font-weight: 700; }
.ybar .sub { font-size: .75rem; color: var(--muted); }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.key { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border-inline-start: 4px solid var(--gold); }
.key b { display: block; color: var(--brand); }

/* ===== المسطرة الزمنية ===== */
.ruler-wrap { overflow-x: auto; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 8px; }
.ruler { position: relative; min-width: 900px; height: 120px; }
.ruler .axis { position: absolute; inset-inline: 0; top: 58px; height: 4px; border-radius: 2px; background: var(--line); }
.ruler .tick { position: absolute; top: 66px; transform: translateX(50%); font-size: .8rem; color: var(--muted); text-align: center; white-space: nowrap; }
.ruler .tick b { display: block; color: var(--ink); font-size: .95rem; }
.ruler .tick::before { content: ''; position: absolute; top: -12px; right: 50%; width: 1px; height: 8px; background: var(--muted); }
.ruler .dot {
  position: absolute; width: 14px; height: 14px; border-radius: 50%; transform: translate(50%, -50%);
  border: 2px solid var(--surface); cursor: pointer; transition: transform .15s;
}
.ruler .dot:hover, .ruler .dot.hl { transform: translate(50%, -50%) scale(1.6); z-index: 2; }
.ruler .dot.major { width: 18px; height: 18px; }
.ruler .dot-label { position: absolute; transform: translateX(50%); font-size: .72rem; white-space: nowrap; color: var(--muted); pointer-events: none; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filters button {
  padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer;
}
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filters .sep { width: 1px; background: var(--line); margin: 0 4px; }

/* ===== الخط الزمني الرأسي ===== */
.timeline { position: relative; padding-inline-start: 34px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 11px; top: 0; bottom: 0; width: 3px; background: var(--line); border-radius: 2px; }
.year-head {
  position: relative; margin: 26px 0 12px; font-family: var(--font-head); font-size: 1.5rem; color: var(--gold);
  display: flex; align-items: baseline; gap: 10px; scroll-margin-top: 80px;
}
.year-head::before {
  content: ''; position: absolute; inset-inline-start: -30px; top: 50%; width: 16px; height: 16px; border-radius: 4px;
  background: var(--gold); transform: translateY(-50%) rotate(45deg);
}
.year-head small { font-family: var(--font); font-size: .85rem; color: var(--muted); }
.event {
  position: relative; display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.event:hover { transform: translateX(-4px); border-color: var(--brand); }
.event > * { min-width: 0; }
.event h3 { overflow-wrap: anywhere; }
.event::before {
  content: ''; position: absolute; inset-inline-start: -28px; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  background: var(--dot, var(--brand)); border: 3px solid var(--bg); transform: translateY(-50%);
}
.event .num {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--surface-2); font-weight: 800; color: var(--brand); font-size: 1.15rem;
}
.event.major .num { background: var(--brand); color: #fff; }
.event h3 { font-size: 1.25rem; margin: 0; }
.event .meta { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.event .date { text-align: end; font-weight: 700; white-space: nowrap; }
.event .date small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }

/* ===== نافذة التفاصيل ===== */
.detail {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0;
  border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.detail::backdrop { background: rgba(10, 20, 15, .55); backdrop-filter: blur(3px); }
.detail header { padding: 22px 24px 16px; padding-inline-end: 70px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: relative; }
.detail header .meta { flex-wrap: wrap; }
.detail header h2 { font-size: 1.9rem; margin: 0 0 6px; }
.detail .close { position: absolute; top: 14px; inset-inline-end: 14px; }
.detail .body { padding: 18px 24px 24px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kv div { padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.kv span { display: block; font-size: .78rem; color: var(--muted); }
.kv b { font-size: 1rem; }
.detail h4 { margin: 14px 0 4px; color: var(--brand); font-size: 1.05rem; }
.detail p { margin: 0 0 8px; }
.tip { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--gold-soft); color: var(--ink); }
.tip b { color: var(--gold); }
.note { margin-top: 10px; padding: 10px 14px; border-radius: 10px; border: 1px dashed var(--line); color: var(--muted); font-size: .92rem; }
.nav-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

/* ===== المقارنات ===== */
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.picker button {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer;
}
.picker button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.picker button:disabled { opacity: .4; cursor: not-allowed; }
.compare-table-wrap { overflow-x: auto; margin-bottom: 20px; }
.ctable { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ctable th, .ctable td { padding: 10px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
.ctable thead th { background: var(--brand); color: #fff; font-family: var(--font-head); font-size: 1.15rem; }
.ctable tbody th { width: 130px; background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: .9rem; }
.ctable tr:last-child td, .ctable tr:last-child th { border-bottom: 0; }
.ctable td.diffcell { background: color-mix(in srgb, var(--gold) 8%, transparent); }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

.forces { display: grid; gap: 8px; }
.force-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; font-size: .9rem; }
.force-row .bars { display: grid; gap: 3px; }
.force-row .b { height: 14px; border-radius: 3px; display: flex; align-items: center; padding-inline-start: 6px; font-size: .72rem; color: #fff; min-width: 34px; }
.force-row .b.m { background: var(--brand); }
.force-row .b.e { background: var(--bad); }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-inline-end: 4px; }

.by-enemy { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.enemy-col { padding: 14px; border-radius: 12px; background: var(--bg); border-top: 4px solid var(--c); }
.enemy-col h3 { font-size: 1.2rem; color: var(--c); display: flex; justify-content: space-between; }
.enemy-col ol { margin: 0; padding-inline-start: 20px; font-size: .92rem; }
.enemy-col li { cursor: pointer; }
.enemy-col li:hover { color: var(--brand); }

/* ===== البطاقات ===== */
.card-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.pbar { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--good); transition: width .3s; }
.flash-wrap { perspective: 1400px; max-width: 620px; margin: 0 auto 16px; }
.flash {
  position: relative; min-height: 340px; cursor: pointer; transform-style: preserve-3d; transition: transform .55s;
  outline: none;
}
.flash.flipped { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; padding: 26px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.flash .back { transform: rotateY(180deg); justify-content: flex-start; text-align: start; align-items: stretch; overflow-y: auto; }
.flash .front .idx { color: var(--muted); font-size: .9rem; }
.flash .front h2 { font-size: 2.4rem; color: var(--ink); margin: 10px 0; }
.flash .front .hint { color: var(--muted); font-size: .9rem; margin-top: 18px; }
.flash .back h3 { color: var(--brand); font-size: 1.5rem; }
.flash .back .big { font-size: 1.3rem; font-weight: 800; color: var(--gold); margin-bottom: 8px; }
.flash .back ul { margin: 8px 0 0; padding-inline-start: 20px; }
.flash.known .face { border-color: var(--good); }
.flash-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.flash-opts { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: .92rem; }

/* ===== الاختبار ===== */
.quiz-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.mode {
  text-align: start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; box-shadow: var(--shadow);
}
.mode:hover { border-color: var(--brand); }
.mode.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.mode b { display: block; font-size: 1.05rem; }
.mode small { color: var(--muted); }
.mode .best { display: block; margin-top: 4px; font-size: .8rem; color: var(--gold); }
.quiz-box { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); min-height: 300px; }
.q-top { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.q-text { font-family: var(--font-head); font-size: 1.7rem; margin-bottom: 18px; }
.q-text em { font-style: normal; color: var(--brand); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  color: var(--ink); font: inherit; font-size: 1.05rem; cursor: pointer; text-align: start;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--bg)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--bg)); }
.opt .ord { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .85rem; margin-inline-end: 8px; }
.feedback { margin-top: 16px; padding: 12px 16px; border-radius: 12px; background: var(--surface-2); }
.feedback.ok { background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.feedback.no { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.q-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.score { text-align: center; padding: 20px 0; }
.score .big { font-size: 4rem; font-weight: 800; color: var(--brand); line-height: 1; }
.review { margin-top: 16px; text-align: start; }
.review li { margin-bottom: 4px; }

.footer { text-align: center; padding: 20px; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); }

/* ===== السيرة ===== */
.era-strip { display: flex; gap: 4px; border-radius: 12px; overflow: hidden; }
.era-strip a {
  display: block; padding: 10px 12px; color: #fff; text-decoration: none; min-width: 0;
  background: var(--c); transition: filter .2s;
}
.era-strip a:hover { filter: brightness(1.12); }
.era-strip b { display: block; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.era-strip span { font-size: .8rem; opacity: .9; white-space: nowrap; }
.era-strip.big { margin-bottom: 16px; }
.era-strip.big a { padding: 14px 16px; }
.era-strip.big b { font-family: var(--font-head); font-size: 1.35rem; }

.seerah-ruler { min-width: 1000px; height: 150px; }
.ruler-note { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.seerah-ruler .band { position: absolute; top: 50px; height: 20px; border-radius: 4px; opacity: .22; }
.seerah-ruler .band-label { position: absolute; top: 2px; transform: translateX(50%); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.seerah-ruler .axis { top: 58px; }
.seerah-ruler .tick { top: 80px; }
.seerah-ruler .gdot { position: absolute; top: 74px; width: 3px; height: 9px; border-radius: 2px; transform: translateX(50%); cursor: pointer; opacity: .8; }
.seerah-ruler .dot-label { top: 28px; line-height: 1.3; }
.seerah-ruler .dot-label.low { top: 108px; }

.stage-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.stage-nav a {
  padding: 4px 12px; border-radius: 999px; font-size: .88rem; text-decoration: none;
  border: 1px solid var(--line); color: var(--ink); background: var(--surface);
}
.stage-nav a i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-inline-end: 6px; }

.stage { margin-top: 26px; scroll-margin-top: 80px; }
.stage-head {
  padding: 16px 20px; border-radius: var(--radius); margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #000));
}
.stage-head .era-name { font-size: .82rem; opacity: .85; }
.stage-head h2 { color: #fff; margin: 0; font-size: 1.7rem; }
.stage-head p { margin: 6px 0 0; opacity: .95; }
.stage-head .stage-tip { margin-top: 8px; display: inline-block; padding: 2px 10px; border-radius: 8px; background: rgba(255,255,255,.18); font-size: .9rem; }
.stage .timeline { margin-top: 4px; }
.event.seerah-ev { --dot: var(--c); }
.event.seerah-ev .num { font-size: .85rem; line-height: 1.1; text-align: center; }
.event.seerah-ev.major .num { background: var(--c); }
.event.mini {
  grid-template-columns: 54px 1fr auto; padding: 6px 14px; box-shadow: none;
  background: transparent; border-style: dashed;
}
.event.mini::before { width: 8px; height: 8px; inset-inline-start: -26px; }
.event.mini .num { width: 34px; height: 34px; font-size: .85rem; justify-self: center; background: var(--surface-2); color: var(--muted); }
.event.mini h3 { font-size: 1.02rem; font-family: var(--font); font-weight: 500; }
.event.mini .date { font-size: .85rem; }
.ghz-group-toggle { font-size: .85rem; color: var(--muted); margin: 4px 0 8px; }

.deck-tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; }
.deck-tabs button {
  padding: 6px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; cursor: pointer;
}
.deck-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== بوابة الموسوعة ===== */
.section-title { margin: 6px 0 14px; }
.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 22px; }
.sec-card {
  position: relative; display: block; padding: 18px 18px 16px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-top: 4px solid var(--c, var(--brand));
  transition: transform .15s, border-color .15s;
}
a.sec-card:hover { transform: translateY(-3px); border-color: var(--c, var(--brand)); }
.sec-card .ico { font-size: 1.6rem; line-height: 1; }
.sec-card h3 { font-size: 1.35rem; margin: 8px 0 4px; color: var(--c, var(--brand)); }
.sec-card p { margin: 0 0 10px; font-size: .92rem; color: var(--muted); }
.sec-card .pbar { height: 6px; }
.sec-card .prog { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.sec-card.soon { opacity: .6; box-shadow: none; border-style: dashed; border-top-style: solid; }
.sec-card.soon .badge { position: absolute; top: 14px; inset-inline-end: 14px; font-size: .75rem; padding: 1px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.intro-details { margin-bottom: 18px; }
.intro-details > summary {
  cursor: pointer; list-style: none; padding: 10px 16px; border-radius: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 700; color: var(--brand);
}
.intro-details > summary::-webkit-details-marker { display: none; }
.intro-details > summary::before { content: '▾ '; }
.intro-details:not([open]) > summary::before { content: '◂ '; }

/* ===== الأنبياء ===== */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fact { padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); font-size: .95rem; }
.fact b { display: block; color: var(--brand); margin-bottom: 2px; }
.fact a { font-size: .85rem; }

.prophet-ruler { min-width: 1000px; height: 130px; }
.prophet-ruler .band { position: absolute; top: 50px; height: 20px; border-radius: 4px; opacity: .22; }
.prophet-ruler .band-label { position: absolute; top: 4px; transform: translateX(50%); font-size: .78rem; font-weight: 700; white-space: nowrap; text-decoration: none; }
.prophet-ruler .dot-label { top: 76px; font-size: .74rem; color: var(--ink); line-height: 1.3; }
.prophet-ruler .dot-label.low { top: 96px; }

.subtabs { display: flex; gap: 6px; margin: 4px 0 16px; flex-wrap: wrap; }
.subtabs button {
  padding: 7px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-weight: 500; cursor: pointer;
}
.subtabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.p-era { margin-top: 22px; scroll-margin-top: 80px; }
.p-era-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 10px; border-bottom: 2px solid var(--c); padding-bottom: 6px; }
.p-era-head h2 { color: var(--c); margin: 0; font-size: 1.5rem; }
.p-era-head span { color: var(--muted); font-size: .9rem; }
.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.p-card {
  display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: start; text-align: start;
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); cursor: pointer; font: inherit; color: var(--ink); transition: transform .15s, border-color .15s;
}
.p-card > * { min-width: 0; }
.p-card:hover { transform: translateY(-2px); border-color: var(--c); }
.p-card .num { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; font-size: 1.1rem; }
.p-card h3 { margin: 0; font-size: 1.45rem; }
.p-card h3 small { font-family: var(--font); font-size: .78rem; color: var(--muted); font-weight: 400; margin-inline-start: 4px; }
.p-card .sent { font-size: .88rem; color: var(--muted); margin: 2px 0 6px; }
.p-card .chips { display: flex; gap: 4px; flex-wrap: wrap; }

.quote {
  margin: 14px 0; padding: 14px 18px; border-radius: 12px; background: var(--surface-2);
  font-family: var(--font-head); font-size: 1.35rem; line-height: 2; border-inline-start: 4px solid var(--gold);
}
.quote a { display: block; font-family: var(--font); font-size: .82rem; margin-top: 4px; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; }
.refs a {
  display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 999px; font-size: .88rem;
  background: var(--bg); border: 1px solid var(--line); text-decoration: none; color: var(--brand);
}
.refs a:hover { border-color: var(--brand); }
.refs a:not(.no-ext)::after { content: '↗'; font-size: .75rem; opacity: .7; }
.source-note { margin-top: 12px; font-size: .85rem; color: var(--muted); }

/* شجرة النسب */
.tree-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.tree-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.tree-legend i { display: inline-block; width: 26px; border-top: 2px solid var(--muted); vertical-align: middle; margin-inline-end: 6px; }
.tree-legend i.gap { border-top-style: dotted; border-top-width: 3px; }
.tree-legend i.weak { border-top-style: dashed; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-inline-start: 28px; position: relative; }
.tree li { position: relative; padding: 4px 0; padding-inline-start: 18px; }
.tree li::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; border-inline-start: 2px solid var(--line); }
.tree li:last-child::before { bottom: auto; height: 22px; }
.tree li::after { content: ''; position: absolute; inset-inline-start: 0; top: 21px; width: 16px; border-top: 2px solid var(--line); }
.tree li.gap::after { border-top: 3px dotted var(--muted); }
.tree li.weak::after { border-top: 2px dashed var(--muted); }
.tree > li { padding-inline-start: 0; }
.tree > li::before, .tree > li::after { display: none; }
.t-node {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font: inherit;
  background: var(--c); color: #fff; border: 0; cursor: pointer; font-weight: 700; white-space: nowrap;
}
.t-node small { font-weight: 400; opacity: .85; font-size: .75rem; }
.t-ghost { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); font-size: .85rem; white-space: nowrap; }
.t-label { font-size: .75rem; color: var(--muted); margin-inline-start: 6px; }

/* ===== قصص القرآن ===== */
.kahf-panel { border-top: 4px solid var(--gold); }
.kahf-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kahf-card {
  text-align: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  font: inherit; color: var(--ink); cursor: pointer; transition: border-color .15s, transform .15s;
}
.kahf-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.kahf-card .trial { display: inline-block; font-size: .8rem; font-weight: 700; color: var(--gold); background: var(--gold-soft); padding: 1px 10px; border-radius: 999px; }
.kahf-card h3 { margin: 6px 0 4px; font-size: 1.3rem; }
.kahf-card p { margin: 0; font-size: .88rem; color: var(--muted); }
.surah-group { margin-bottom: 14px; }
.surah-group h3 { display: flex; align-items: baseline; gap: 8px; color: var(--brand); margin: 0 0 8px; }
.surah-group h3 small { font-family: var(--font); font-size: .8rem; color: var(--muted); font-weight: 400; }

/* ===== أركان الإيمان ===== */
.iman-intro .hadith {
  font-family: var(--font-head); font-size: 1.45rem; line-height: 2; text-align: center;
  padding: 10px 16px; border-radius: 12px; background: var(--gold-soft); margin-bottom: 6px;
}
.iman-intro .hadith-src { text-align: center; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.levels div { padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); text-align: center; }
.levels div.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.levels b { display: block; font-size: 1.15rem; color: var(--brand); }
.levels span { font-size: .88rem; color: var(--muted); }

.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pillar-card {
  position: relative; text-align: start; padding: 18px 18px 16px; border-radius: var(--radius); font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--c); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s, border-color .15s;
}
.pillar-card:hover { transform: translateY(-3px); border-color: var(--c); }
.pillar-card .big-num {
  position: absolute; top: 12px; inset-inline-end: 14px; font-family: var(--font-head); font-size: 2.6rem; line-height: 1;
  color: var(--c); opacity: .25; font-weight: 700;
}
.pillar-card h3 { font-size: 1.45rem; color: var(--c); margin: 0 0 6px; }
.pillar-card p { margin: 0 0 10px; font-size: .9rem; color: var(--muted); }
.pillar-card ul { margin: 0; padding-inline-start: 18px; font-size: .88rem; }

.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; counter-reset: st; }
.stage-step {
  position: relative; padding: 14px 12px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stage-step .n {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--pe2); color: #fff;
  font-weight: 800; font-size: .9rem; margin-bottom: 6px;
}
.stage-step b { display: block; font-size: 1.08rem; }
.stage-step p { margin: 4px 0 8px; font-size: .85rem; color: var(--muted); }
.stage-step:not(:nth-child(5n)):not(:last-child)::after {
  content: '←'; position: absolute; inset-inline-end: -12px; top: 18px; color: var(--muted); font-weight: 700; z-index: 1;
}
.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.matrix td.yes { text-align: center; color: var(--good); font-weight: 800; font-size: 1.1rem; }
.matrix td.no { text-align: center; color: var(--line); }
.inc { padding: 10px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 8px; }
.inc b { color: var(--brand); }
.inc .refs { margin-top: 6px; }

/* ===== الجوال ===== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: 5px 12px; }
  .icon-btn { margin-inline-start: auto; }
  main { padding: 18px 16px 50px; }
  .hero h1 { font-size: 2rem; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .counts { grid-template-columns: repeat(2, 1fr); }
  .year-bars { height: 170px; gap: 5px; }
  .event { grid-template-columns: 40px 1fr; }
  .event .num { width: 38px; height: 38px; font-size: 1rem; }
  .event .date { grid-column: 2; text-align: start; white-space: normal; }
  .options { grid-template-columns: 1fr; }
  .q-text { font-size: 1.35rem; }
  .force-row { grid-template-columns: 80px 1fr; }
  .era-strip { flex-direction: column; }
  .era-strip a { flex: none !important; }
  .event.mini { grid-template-columns: 40px 1fr; }
  .p-grid { grid-template-columns: 1fr; }
  .kahf-grid { grid-template-columns: 1fr 1fr; }
  .pillars { grid-template-columns: 1fr; }
  .levels { grid-template-columns: 1fr; }
  .stages { grid-template-columns: 1fr 1fr; }
  .stage-step::after { display: none; }
  .iman-intro .hadith { font-size: 1.2rem; }
  .quote { font-size: 1.15rem; }
}

/* الشاشات المتوسطة: مراحل اليوم الآخر في ثلاثة أعمدة بلا أسهم */
@media (max-width: 1000px) and (min-width: 761px) {
  .stages { grid-template-columns: repeat(3, 1fr); }
  .stage-step::after { display: none; }
  .pillars { grid-template-columns: 1fr 1fr; }
}

/* شريط التنقل: تسعة روابط في سطر واحد على الشاشات العريضة */
.brand small { white-space: nowrap; }
.nav { flex-wrap: nowrap; }
.nav a { white-space: nowrap; }
@media (max-width: 1240px) and (min-width: 761px) {
  .topbar { gap: 10px; padding-inline: 16px; }
  .nav { gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav a { padding: 6px 10px; font-size: .92rem; }
  .brand small { display: none; }
}

/* ===== أركان الإسلام ===== */
.pillars.five { grid-template-columns: repeat(5, 1fr); }
.pillars.five .pillar-card h3 { font-size: 1.25rem; }
.pillars.five .pillar-card p { font-size: .85rem; }
.freq { display: inline-block; margin-top: 6px; font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.recip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.recip { padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); border-inline-start: 4px solid var(--pe3); }
.recip .n { font-weight: 800; color: var(--pe3); margin-inline-end: 4px; }
.recip b { font-size: 1.05rem; }
.recip p { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.total-row td { font-weight: 800; background: var(--gold-soft); }
.cond-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
@media (max-width: 1000px) and (min-width: 761px) {
  .pillars.five { grid-template-columns: repeat(3, 1fr); }
  .recip-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .pillars.five { grid-template-columns: 1fr; }
  .recip-grid { grid-template-columns: 1fr; }
}
