:root {
  --bg: #f7f4ec;
  --bg-alt: #efe9db;
  --surface: #ffffff;
  --text: #1d2a25;
  --muted: #5d6b65;
  --line: #e2dccd;
  --primary: #0f5b45;
  --primary-soft: #dcebe4;
  --gold: #b8892f;
  --gold-soft: #f5ead2;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 8px 24px rgba(20, 40, 30, .06);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1714; --bg-alt: #131e1a; --surface: #18241f; --text: #e8eee9; --muted: #9aaba3;
    --line: #26352f; --primary: #4fbf95; --primary-soft: #1a3a2e; --gold: #e3b860; --gold-soft: #33291a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1714; --bg-alt: #131e1a; --surface: #18241f; --text: #e8eee9; --muted: #9aaba3;
  --line: #26352f; --primary: #4fbf95; --primary-soft: #1a3a2e; --gold: #e3b860; --gold-soft: #33291a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[lang="ar"], .arabic { font-family: Amiri, "Traditional Arabic", serif; direction: rtl; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary); color: var(--gold-soft); font-size: 1.2rem;
}
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--text); padding: 8px 12px; border-radius: 10px; font-size: .92rem; font-weight: 500; }
.nav a:hover { background: var(--primary-soft); color: var(--primary); }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.menu-btn { display: none; }

/* Hero */
.hero {
  padding: 56px 0 48px; text-align: center;
  background:
    radial-gradient(1000px 400px at 50% -10%, var(--primary-soft), transparent 70%),
    var(--bg);
}
.hero-arabic { font-size: clamp(1.6rem, 4vw, 2.4rem); color: var(--gold); margin: 0 0 12px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3.2rem); letter-spacing: -.02em; }
.hero h1 span { color: var(--primary); }
.hero-sub { max-width: 640px; margin: 0 auto 28px; color: var(--muted); font-size: 1.05rem; }
.search-box { position: relative; max-width: 640px; margin: 0 auto; }
.search-box input {
  width: 100%; padding: 16px 20px 16px 50px; font-size: 1rem; font-family: inherit;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); outline: none;
}
.search-box input:focus { border-color: var(--primary); }
.search-ico { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); }
.search-results {
  max-width: 640px; margin: 10px auto 0; text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 420px; overflow: auto;
}
.search-results a { display: block; padding: 12px 18px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: var(--primary-soft); }
.search-results .tag { font-size: .72rem; font-weight: 600; color: var(--gold); text-transform: uppercase; letter-spacing: .05em; }
.search-results .empty { padding: 16px 18px; color: var(--muted); }
.hero-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 36px; text-align: left; }
.mini-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.mini-card strong { font-size: 1.2rem; }
.mini-card.accent { background: var(--primary); border-color: var(--primary); color: #fff; }
.mini-card.accent .mini-label { color: rgba(255,255,255,.75); }
.mini-label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.countdown { font-variant-numeric: tabular-nums; color: var(--gold-soft); }
:root[data-theme="dark"] .mini-card.accent, :root:not([data-theme="light"]) .mini-card.accent { color: #0f1714; }

/* Sections */
.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head > div:first-child { max-width: 720px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0; }
.sub-title { margin: 40px 0 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font: 500 .88rem Inter, sans-serif;
}
.chip.active, .chip:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }

.card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card { display: flex; flex-direction: column; gap: 10px; }
.card .meta { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 600; font-size: .75rem; }
.card .ar { font-family: Amiri, serif; direction: rtl; font-size: 1.35rem; color: var(--primary); line-height: 1.8; margin: 0; }
.card .text { font-size: 1.02rem; margin: 0; }
.card .note { font-size: .9rem; color: var(--muted); border-left: 3px solid var(--gold); padding-left: 12px; margin: 0; }
.card .narrator { font-size: .85rem; color: var(--muted); margin: 0; }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font: 500 .85rem Inter, sans-serif; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }

.daily-hadith {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000));
  color: #fff; border-radius: 20px; padding: 28px; margin-bottom: 24px;
}
.daily-hadith .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: #f5dfae; font-weight: 700; }
.daily-hadith p { font-size: clamp(1.1rem, 2.4vw, 1.4rem); margin: 10px 0; }
.daily-hadith .src { opacity: .8; font-size: .9rem; }
:root[data-theme="dark"] .daily-hadith, :root:not([data-theme="light"]) .daily-hadith { color: #0f1714; }

/* Speakers */
.grid.speakers { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.speaker { display: flex; flex-direction: column; gap: 8px; }
.avatar {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 700; font-size: 1.2rem; background: var(--gold-soft); color: var(--gold);
}
.speaker.featured { border-color: var(--gold); }

/* Fatwa accordion */
.accordion { display: grid; gap: 10px; }
.acc-item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.acc-item summary {
  list-style: none; cursor: pointer; padding: 18px 22px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.acc-item summary::-webkit-details-marker { display: none; }
.acc-item summary::after { content: "+"; font-size: 1.4rem; color: var(--primary); }
.acc-item[open] summary::after { content: "−"; }
.acc-item .acc-body { padding: 0 22px 20px; color: var(--text); }
.acc-item .acc-body p { margin: 0 0 8px; }

/* Calendar */
.ramadan-banner {
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--gold); border-radius: 20px; padding: 26px; margin-bottom: 20px;
}
.ramadan-banner h3 { font-size: 1.4rem; }
.timer { display: flex; gap: 10px; }
.timer div { background: var(--gold-soft); border-radius: 12px; padding: 10px 14px; text-align: center; min-width: 70px; }
.timer b { display: block; font-size: 1.6rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.timer span { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.grid.events { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.event { display: flex; gap: 14px; align-items: flex-start; }
.event .date-box {
  flex: none; width: 58px; text-align: center; border-radius: 12px; padding: 6px 0;
  background: var(--primary-soft); color: var(--primary);
}
.event .date-box b { display: block; font-size: 1.4rem; line-height: 1.1; }
.event .date-box span { font-size: .72rem; text-transform: uppercase; font-weight: 600; }
.event h4 { margin: 0 0 2px; font-size: 1rem; }
.event p { margin: 0; font-size: .85rem; color: var(--muted); }
.event.big { border-color: var(--gold); }
.event.big .date-box { background: var(--gold-soft); color: var(--gold); }

.month-cal { margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.month-cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.month-cal-head h3 { margin: 0; font-size: 1.15rem; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid .dow { text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); padding: 4px 0; }
.cal-day {
  min-height: 64px; border-radius: 10px; padding: 6px 8px; background: var(--bg);
  display: flex; flex-direction: column; font-size: .8rem; position: relative;
}
.cal-day b { font-size: 1rem; }
.cal-day .h { color: var(--muted); font-size: .72rem; }
.cal-day.today { outline: 2px solid var(--primary); }
.cal-day.holiday { background: var(--gold-soft); }
.cal-day.holiday .hname { color: var(--gold); font-size: .68rem; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.cal-day.empty { background: transparent; }

/* Prayers */
.select {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: 500 .95rem Inter, sans-serif; min-width: 200px;
}
.grid.prayers { grid-template-columns: repeat(6, 1fr); }
.prayer { text-align: center; padding: 20px 10px; }
.prayer .pname { font-weight: 600; color: var(--muted); font-size: .9rem; }
.prayer .ptime { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.prayer .par { font-family: Amiri, serif; color: var(--gold); }
.prayer.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.prayer.current .pname { color: rgba(255,255,255,.8); }
:root[data-theme="dark"] .prayer.current, :root:not([data-theme="light"]) .prayer.current { color: #0f1714; }

/* Basics */
.pillars { margin: 0; padding-left: 0; list-style: none; counter-reset: p; display: grid; gap: 12px; }
.pillars li { counter-increment: p; display: grid; grid-template-columns: 36px 1fr; gap: 12px; }
.pillars li::before {
  content: counter(p); width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.pillars strong { display: block; }
.pillars span { color: var(--muted); font-size: .9rem; }
.links-panel { margin-top: 16px; }
.grid.links { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.link-card { display: block; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.link-card:hover { border-color: var(--primary); }
.link-card span { display: block; color: var(--muted); font-size: .82rem; }

.footer { border-top: 1px solid var(--line); padding: 32px 0; }
.footer-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.footer p { margin: 6px 0 0; }

.hl { background: var(--gold-soft); color: inherit; border-radius: 3px; }
.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: var(--shadow); } }

@media (max-width: 960px) {
  .grid.prayers { grid-template-columns: repeat(3, 1fr); }
  .menu-btn { display: block; }
  .nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
  }
  .nav.open { display: flex; }
  .top-actions { margin-left: auto; }
}
@media (max-width: 700px) {
  .hero { padding-top: 36px; }
  .hero-cards, .grid.two, .footer-inner { grid-template-columns: 1fr; }
  .grid.cards { grid-template-columns: 1fr; }
  .ramadan-banner { grid-template-columns: 1fr; }
  .timer div { min-width: 0; flex: 1; padding: 8px 4px; }
  .cal-day { min-height: 52px; padding: 4px; }
  .cal-day .hname { display: none; }
  .section { padding: 48px 0; }
}
