@import url('https://fonts.googleapis.com/css2?family=Amiri+Quran&family=Amiri:wght@400;700&family=Cairo:wght@400;600;700&display=swap');

/* خط مصحف المدينة الرسمي — KFGQPC Uthmanic Hafs */
@font-face {
  font-family: 'UthmanicHafs';
  src: url('/tarteela/read/static/fonts/UthmanicHafs.otf') format('opentype');
  font-display: swap;
  font-weight: normal;
}

:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --accent: #1a7f5a;
  --accent-soft: #e6f3ec;
  --border: #e3ddd0;
  --highlight: #fff3c4;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  direction: rtl;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  background: linear-gradient(180deg, #1a7f5a 0%, #0f5e42 100%);
  color: white;
  padding: 1.2rem 2rem;
  box-shadow: var(--shadow);
}
header .wrap { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 2rem; }
header h1 { margin: 0; font-size: 1.6rem; font-weight: 700; }
header h1 a { color: white; }
header .tag { color: rgba(255,255,255,0.85); font-size: 0.95rem; }
header nav { margin-inline-start: auto; display: flex; gap: 1.2rem; }
header nav a { color: white; opacity: 0.9; }
header nav a:hover { opacity: 1; text-decoration: none; }

main { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }

.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}
.search-box form { display: flex; flex-direction: column; gap: 0.9rem; }
.search-box input[type=text] {
  font-family: inherit;
  font-size: 1.15rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfcf7;
  direction: rtl;
}
.search-box input[type=text]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.search-modes { display: flex; gap: 1.5rem; align-items: center; }
.search-modes label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.search-box button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  align-self: flex-start;
}
.search-box button:hover { background: #0f5e42; }

.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.surah-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: transform 0.1s, box-shadow 0.1s;
}
.surah-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.surah-card .num {
  background: var(--accent-soft);
  color: var(--accent);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}
.surah-card .name { font-weight: 600; font-size: 1.1rem; color: var(--ink); }
.surah-card .meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.1rem; }

.ayah {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 0.7rem;
  box-shadow: var(--shadow);
}
.ayah-text {
  font-family: 'Amiri Quran', 'Amiri', serif;
  font-size: 1.85rem;
  line-height: 2.4;
  color: var(--ink);
}
.ayah-text .word {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  transition: background 0.1s;
}
.ayah-text .word:hover { background: var(--highlight); }
.ayah-text .word.no-root { cursor: default; }
.ayah-text .word.no-root:hover { background: transparent; }
.ayah-meta {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: start;
}
.ayah-meta a { color: var(--muted); }

.ayah-num {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  width: 32px; height: 32px;
  line-height: 32px;
  text-align: center;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  margin-inline-start: 0.5rem;
  vertical-align: middle;
}

.section-title {
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-soft);
  font-size: 1.3rem;
  color: var(--accent);
}

.root-header {
  background: linear-gradient(135deg, var(--accent-soft), #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.8rem;
  margin-bottom: 1.5rem;
  text-align: center;
}
.root-header .root-text {
  font-family: 'Amiri Quran', serif;
  font-size: 3.5rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.3rem;
}
.root-header .stats { color: var(--muted); margin-top: 0.5rem; }

.derivatives {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.derivative {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-family: 'Amiri Quran', serif;
  font-size: 1.2rem;
}
.derivative .count {
  color: var(--muted);
  font-family: 'Cairo', sans-serif;
  font-size: 0.75rem;
  margin-inline-start: 0.4rem;
}

.crumbs {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.crumbs a { color: var(--muted); }

footer {
  margin-top: 4rem;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  font-size: 1.1rem;
}

.hint {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  color: var(--accent);
  font-size: 0.95rem;
}

/* ===== Root meaning card (from classical Arabic dictionaries) ===== */
.meaning-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-block: 0.8rem 0.5rem;
  box-shadow: var(--shadow);
}
.meaning-card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  user-select: none;
}
.meaning-card > summary::-webkit-details-marker { display: none; }
.meaning-card > summary::before {
  content: "▾";
  display: inline-block;
  color: var(--accent);
  transition: transform 0.15s;
  margin-inline-end: 0.3rem;
}
.meaning-card:not([open]) > summary::before { transform: rotate(-90deg); }
.meaning-title {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
}
.meaning-source {
  color: var(--muted);
  font-size: 0.9rem;
}
.meaning-short {
  margin-top: 0.7rem;
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--ink);
  font-family: 'Amiri', 'Cairo', serif;
}
.meaning-full {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-block-start: 1px dashed var(--border);
}
.meaning-full > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  user-select: none;
}
.meaning-full-text {
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.95;
  color: var(--ink);
  font-family: 'Amiri', 'Cairo', serif;
  white-space: pre-wrap;
  max-height: 24rem;
  overflow-y: auto;
  padding-inline-end: 0.5rem;
}
.meaning-empty .meaning-short { color: var(--muted); }

/* ===== Word-specific meaning card (after click in mushaf/surah) ===== */
.word-card {
  background: linear-gradient(180deg, #fffaee 0%, #fdf8ea 100%);
  border: 1px solid #c4a96a;
  border-inline-start: 5px solid var(--accent);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin-block: 0.8rem 1rem;
  box-shadow: var(--shadow);
}
.word-card-header {
  text-align: center;
  padding-block-end: 0.8rem;
  margin-block-end: 0.8rem;
  border-block-end: 1px dashed rgba(184,148,86,0.4);
}
.word-uthmani {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: 2.4rem;
  color: #1a1a1a;
  margin-block-end: 0.4rem;
  line-height: 1.6;
}
.word-meta {
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.word-lemma { color: var(--ink); }
.word-lemma bdi {
  font-family: 'Amiri', 'Cairo', serif;
  color: var(--accent);
  font-weight: 700;
}

.word-excerpt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-block-end: 0.5rem;
}
.word-excerpt-card > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.word-excerpt-card > summary::-webkit-details-marker { display: none; }
.word-excerpt-card > summary::before {
  content: "▾";
  display: inline-block;
  color: var(--accent);
  margin-inline-end: 0.3rem;
  transition: transform 0.15s;
}
.word-excerpt-card:not([open]) > summary::before { transform: rotate(-90deg); }
.word-excerpt-list {
  margin: 0.6rem 0 0;
  padding-inline-start: 1.4rem;
  font-family: 'Amiri', 'Cairo', serif;
  font-size: 1.05rem;
  line-height: 1.95;
}
.word-excerpt-list li {
  margin-block-end: 0.5rem;
  color: var(--ink);
}
.word-no-excerpt {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 0.5rem;
}

/* ===== Lexicon-only hits (non-Quranic word found in lexicon text) ===== */
.lexicon-hits {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.lexicon-hit {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
}
.lexicon-hit-header {
  font-size: 0.95rem;
  margin-block-end: 0.3rem;
  color: var(--ink);
}
.lexicon-hit-header a {
  font-family: 'Amiri', 'Cairo', serif;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
  margin-inline: 0.3rem;
}
.lexicon-hit-header .muted { color: var(--muted); font-size: 0.85rem; }
.lexicon-hit .word-excerpt-list {
  font-size: 1rem;
  margin-top: 0.3rem;
  margin-block-end: 0;
}

/* ===== Poetry citations (شواهد شعرية) ===== */
.poetry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: bayt;
}
.poetry-bayt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid #b89456;
  border-radius: 10px;
  padding: 1rem 1.4rem;
  margin-block-end: 0.7rem;
  position: relative;
}
.poetry-bayt::before {
  counter-increment: bayt;
  content: counter(bayt);
  position: absolute;
  inset-inline-start: -14px;
  top: 1rem;
  background: #b89456;
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
}
.bayt-text {
  font-family: 'Amiri', 'Amiri Quran', serif;
  font-size: 1.3rem;
  line-height: 2;
  text-align: center;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.bayt-text .hemistich {
  flex: 1 1 40%;
  min-width: 200px;
}
.bayt-text .hemistich.h1 { text-align: end; }
.bayt-text .hemistich.h2 { text-align: start; }
.hemistich-sep {
  color: #b89456;
  font-size: 0.9rem;
  flex: 0 0 auto;
}
.bayt-attrib {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}
.bayt-attrib bdi {
  font-family: 'Amiri', 'Cairo', serif;
}
.bayt-attrib .bayt-source {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .bayt-text { flex-direction: column; gap: 0.2rem; font-size: 1.1rem; }
  .bayt-text .hemistich.h1, .bayt-text .hemistich.h2 { text-align: center; }
  .hemistich-sep { font-size: 0.7rem; }
}

/* ===== مصحف المدينة ===== */
.mushaf-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.mushaf-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.mushaf-meta {
  font-size: 0.95rem;
  color: var(--ink);
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.mushaf-meta strong { color: var(--accent); }
.mushaf-meta .dot { color: var(--muted); }

.nav-btn {
  background: var(--accent);
  color: white;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav-btn:hover { background: #0f5e42; text-decoration: none; }
.nav-btn.disabled { background: #c8c8c8; pointer-events: none; }

.goto-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.goto-form label { font-weight: 600; }
.goto-form input[type=number],
.goto-form select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fdfcf7;
}
.goto-form input[type=number] { width: 90px; }
.goto-form select { max-width: 280px; }
.goto-form button {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.goto-form button:hover { background: var(--accent); color: white; }

/* ===== صفحة المصحف ===== */
.mushaf-page,
.mushaf-v1-page {
  /* لون ورقة المصحف: عاجي/كريمي مائل قليلاً للأصفر، أقرب لمصحف المدينة المطبوع */
  background: #f7efd8;
  background-image:
    radial-gradient(ellipse at 0 0, rgba(120,90,40,0.06) 0, transparent 65%),
    radial-gradient(ellipse at 100% 100%, rgba(120,90,40,0.06) 0, transparent 65%);
  border: 2px solid #b89456;
  border-radius: 6px;
  padding-block: 2.5rem 1.8rem;
  padding-inline: 2.2rem;
  box-shadow: 0 6px 30px rgba(0,0,0,0.08);
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}

/* ===== QPC v1 — تخطيط ١٥ سطراً ===== */
.mushaf-v1-page {
  direction: rtl;
  unicode-bidi: isolate;
}
.mushaf-v1-page .mline {
  font-size: 30px;
  line-height: 2.1;
  text-align: justify;
  text-align-last: justify;
  text-justify: inter-word;
  margin-block-end: 0.05rem;
  white-space: nowrap;
  /* QPC fonts: تفعيل ميزات OpenType للكشيدة والربط الصحيح */
  font-feature-settings: "kern" on, "liga" on, "calt" on, "ss01" on;
  font-variant-ligatures: common-ligatures contextual;
}
/* Non-centered ayah lines: spread the (whitespace-less) word spans edge to
   edge so every full line fills the column exactly and all lines look equal
   — the QPC v1 way to justify, since CSS `justify` has no spaces to stretch. */
.mushaf-v1-page .mline--ayah:not(.mline--center) {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.mushaf-v1-page .mline--center,
.mushaf-v1-page .mline--surah-name,
.mushaf-v1-page .mline--basmallah {
  text-align: center;
  text-align-last: center;
  margin-block: 0.4rem;
}
.mushaf-v1-page .word {
  color: #111;
  text-decoration: none;
  cursor: default;
  margin-inline: 0.04em;
}
.mushaf-v1-page .word.has-root {
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-radius: 3px;
}
.mushaf-v1-page .word.has-root:hover {
  background: rgba(178, 34, 52, 0.12);
  color: #8a1027;
}
.mushaf-v1-page .word.no-root { color: #1a1a1a; }
/* علامة نهاية الآية: حمراء قانية كما في مصحف المدينة المطبوع */
.mushaf-v1-page .end-mark {
  color: #b22234;
  margin-inline: 0.05em;
}

/* ===== Top metadata strip (juz | surah) ===== */
.mushaf-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  /* Plain UI font (not the Quran font) so the juz digit renders as a normal
     numeral, not inside the font's decorative ring — matches the iOS header. */
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  /* override the global `header { background:green }` rule — the strip is a
     <header>, so it must explicitly reset to the cream page colour.
     Plain, undecorated header (no divider line) to match the iOS app. */
  background: none;
  box-shadow: none;
  color: #6b4a1a;
  font-size: 1rem;
  padding-inline: 0;
  padding-block: 0.1rem 0.6rem;
  margin-block-end: 0.4rem;
}
.mushaf-strip-juz strong { margin-inline-start: 0.25rem; }
.mushaf-strip-surah { font-size: 1.05rem; }
.mushaf-strip-surah a { color: inherit; }
.mushaf-strip-surah a:hover { color: var(--accent); text-decoration: none; }
.mushaf-strip-divider { flex: 1; }

/* ===== Surah-name banner (mainframe.png from Al-Furkan) ===== */
.mushaf-v1-page .mline--surah-name { padding: 0; }
.surah-banner-asset {
  background-image: url('/tarteela/read/static/chrome/surah-banner.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  /* native asset is 2000×208 ≈ aspect 9.6 */
  aspect-ratio: 2000 / 208;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block: 0.2rem 0.4rem;
}
.surah-banner-asset .surah-banner-name {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: clamp(1rem, 3.2vw, 1.7rem);
  color: #6b4a1a;
  font-weight: 700;
  /* center the name inside the empty cartouche of the PNG (which is the middle ~50%) */
  padding-inline: 22%;
  white-space: nowrap;
}

.bismillah-v1 {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: 2.4rem;
  color: #6b4a1a;
  margin-block: 0.2rem 0.4rem;
}

/* ===== Bottom row — plain page number on the OUTER edge + hizb label on the
   inner edge (matches the iOS per-page footer). Forced LTR so `space-between`
   places the first DOM child (page number) on the left; row-reverse on odd
   (right-hand) pages flips the number to the right outer edge. ===== */
.mushaf-pagenum {
  display: flex;
  direction: ltr;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-block-start: 1rem;
  padding-block-start: 0.6rem;
}
.mushaf-pagenum[data-side="odd"] { flex-direction: row-reverse; }
.mushaf-pagenum-text {
  /* plain numeral, no decorative ring (matches iOS) */
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  font-size: 1rem;
  color: #6b4a1a;
  font-weight: 700;
}
.mushaf-hizb {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  font-size: 0.9rem;
  color: #6b4a1a;
  /* hizb text is Arabic — keep it RTL inside the LTR footer row */
  direction: rtl;
}

/* preserve legacy class names from earlier passes (defensive) */
.surah-banner-v1 { display: flex; justify-content: center; }

@media (max-width: 760px) {
  .mushaf-v1-page { padding-inline: 1rem; padding-block: 1.4rem; }
  .mushaf-v1-page .mline { font-size: 22px; line-height: 1.95; }
  .surah-banner-name { font-size: 1.4rem; }
  .bismillah-v1 { font-size: 1.6rem; }
}

.surah-banner {
  margin: 0.3rem 0 1rem;
  display: flex;
  justify-content: center;
}
.surah-banner-frame {
  background: linear-gradient(180deg, #f5e6c4 0%, #e8d49a 100%);
  border: 2px solid #c4a96a;
  border-radius: 4px;
  padding: 0.7rem 2rem;
  text-align: center;
  min-width: 60%;
  position: relative;
}
.surah-banner-frame::before,
.surah-banner-frame::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  background: #c4a96a;
  border-radius: 50%;
  transform: translateY(-50%);
}
.surah-banner-frame::before { right: -7px; }
.surah-banner-frame::after { left: -7px; }
.surah-banner-name {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: 1.8rem;
  color: #6b4a1a;
  font-weight: 700;
}
.surah-banner-sub {
  font-size: 0.85rem;
  color: #8a6a3a;
  margin-top: 0.1rem;
}

.bismillah {
  text-align: center;
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: 2rem;
  color: #6b4a1a;
  margin: 0.6rem 0 1.2rem;
}

.mushaf-text {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  font-size: 2.1rem;
  line-height: 2.5;
  text-align: justify;
  text-justify: inter-word;
  color: #1a1a1a;
  margin-bottom: 1rem;
  text-indent: 0;
  word-spacing: 0.04em;
}
.mushaf-text .ayah-span { display: inline; }
/* علامة نهاية الآية: U+06DD متبوعة بأرقام هندية — الخط يرسمها كوردة بالرقم داخلها. */
.mushaf-text .ayah-mark {
  font-family: 'UthmanicHafs', 'Amiri Quran', serif;
  color: #b8860b;
  font-size: 2.1rem;
  margin: 0 0.05rem;
}

.mushaf-page-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed #c4a96a;
  color: #8a6a3a;
  font-size: 0.95rem;
  font-weight: 600;
}

@media (max-width: 720px) {
  .mushaf-page { padding: 1.5rem 1.2rem; }
  .mushaf-text { font-size: 1.55rem; line-height: 2.2; }
  .surah-banner-name { font-size: 1.4rem; }
  .bismillah { font-size: 1.5rem; }
}

/* ============================================================================
   Responsive reader shell — 1-page (phone) / 2-page facing spread (tablet+).
   ============================================================================ */
.mushaf-spread {
  display: flex;
  flex-direction: row;     /* dir="rtl" on the element → first child = right */
  gap: 1.2rem;
  align-items: stretch;
  justify-content: center;
}
.mushaf-spread .mushaf-v1-page {
  margin: 0;               /* override single-page auto-centering */
}
/* Facing-page spread: two pages share the width, odd on the right. */
.mushaf-spread.is-spread .mushaf-v1-page {
  flex: 1 1 0;
  max-width: 620px;
  min-width: 0;
}
.mushaf-spread.is-spread .mushaf-v1-page .mline { font-size: 26px; }

/* Reader toolbar (mirrors .mushaf-toolbar styling). */
.reader-toolbar { max-width: 1300px; margin: 0 auto 1rem; }
.reader-toolbar-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; flex-wrap: wrap; margin-block: 0.4rem;
}
.reader-meta { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); }
.reader-meta strong { color: var(--accent); }
.reader-meta .dot { color: var(--muted); }
.reader-toolbar .nav-btn[disabled] { opacity: 0.4; pointer-events: none; }
.reader-error { text-align: center; color: var(--accent); padding: 2rem; }

/* Listen-only audio bar. */
.reader-audio {
  max-width: 1300px; margin: 1rem auto 0;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 1rem; border: 1px solid rgba(184,148,86,0.4);
  border-radius: 10px; background: #fbf6e9;
}
.audio-btn {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 1px solid var(--accent); background: white; color: var(--accent);
  font-size: 1rem; cursor: pointer; line-height: 1;
}
.audio-btn:hover { background: var(--accent); color: white; }
.audio-btn--ghost { border-color: var(--muted); color: var(--muted); }
.audio-status { font-variant-numeric: tabular-nums; color: var(--ink); }

/* Currently-playing ayah: continuous rounded bands drawn BEHIND the words
   (theme gold, so it stays distinct from the green has-root dotted underline,
   which paints on top). Positions/rounding are set inline by the reader JS. */
.mushaf-v1-page .mushaf-body { position: relative; z-index: 1; }
.ayah-hl {
  position: absolute;
  z-index: 0;
  background: rgba(184, 134, 11, 0.20);
  pointer-events: none;
}

@media (max-width: 1023px) {
  /* Single-page mode: keep the page centred and readable. */
  .mushaf-spread .mushaf-v1-page { margin: 0 auto; }
}

/* ============================================================================
   Standalone web reader — minimal top header (logo + home) and a single
   bottom control strip (page nav + jump menus + audio). Phone & desktop alike.
   ============================================================================ */
body.standalone { display: flex; flex-direction: column; min-height: 100vh; }
body.standalone main {
  max-width: 1320px; width: 100%; margin: 0 auto;
  padding: 1rem 1rem 84px;         /* bottom pad clears the one-line control strip */
  flex: 1 0 auto;
}

.reader-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1.1rem;
  background: linear-gradient(180deg, #1a7f5a 0%, #0f5e42 100%);
  color: #fff; box-shadow: var(--shadow);
}
.reader-header a { color: #fff; }
.reader-header a:hover { text-decoration: none; opacity: 1; }
.reader-logo { font-weight: 800; font-size: 1.35rem; letter-spacing: .5px; }
.reader-home {
  font-size: .95rem; opacity: .92;
  display: inline-flex; align-items: center; gap: .35rem;
}
.reader-home span { font-size: 1.1rem; }

.reader-controls {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
  background: #fbf6e9; border-top: 1px solid rgba(184,148,86,.5);
  box-shadow: 0 -2px 14px rgba(0,0,0,.08);
}
.rc-inner { max-width: 1320px; margin: 0 auto; padding: .5rem .7rem; }
/* One single-line strip: prev / page / surah / juz / rub / audio / next.
   Selects flex-share the middle; everything else is fixed-size. nowrap keeps
   it to one line on phone & desktop alike. */
.rc-bar {
  display: flex; align-items: center; gap: .4rem;
  flex-wrap: nowrap; justify-content: center;
}
.rc-bar > * { flex: 0 0 auto; }            /* prev / next stay pinned */
/* The middle cluster (page + surah/juz/rub + reciter + audio) shrinks and
   scrolls horizontally on narrow phones, so nothing gets crushed and the
   prev/next buttons remain fixed at the edges. */
.rc-mid {
  flex: 0 1 auto; min-width: 0;
  display: flex; align-items: center; gap: .4rem;
  overflow-x: auto; justify-content: flex-start;   /* RTL → starts at the right */
  scrollbar-width: thin;
}
.rc-mid > * { flex: 0 0 auto; }
.rc-mid::-webkit-scrollbar { height: 4px; }
.nav-btn--icon { padding: .4rem .72rem; font-size: 1.15rem; line-height: 1; }
/* Every menu is shrunk to fit just its short label / value — the native
   picker still shows full names/pages on open. Keeps the whole strip on one
   line without overflow. */
.rc-sel {
  flex: 0 0 auto; width: 3.4rem; min-width: 0;
  padding: .4rem .2rem; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font: inherit; font-size: .9rem; color: var(--ink);
  text-align: center; text-align-last: center;
}
.rc-pagesel { width: 3rem; }      /* current page number (≤ 604) */
.rc-reciter { width: 4.2rem; }    /* reciter's first name; full list on open */
.rc-audio { display: inline-flex; align-items: center; gap: .3rem; }
.rc-audio .audio-status { display: none; }   /* keep the strip compact */

@media (max-width: 1023px) {
  body.standalone main { padding-bottom: 80px; }
  .rc-bar { gap: .3rem; }
  .rc-inner { padding: .45rem .4rem; }
  .rc-sel { font-size: .8rem; padding: .4rem .12rem; width: 3.1rem; }
  .rc-pagesel { display: none; }      /* mobile: navigate by prev/next + surah/juz/rub */
  .rc-reciter { width: 3.9rem; }
  .nav-btn--icon { padding: .4rem .52rem; }
}

/* ============================================================================
   Word-meaning popover (standalone reader). Words that have a dictionary root
   get a faint dotted underline; long-press (touch) / click (mouse) opens a
   sheet with the six short glosses.
   ============================================================================ */
.mushaf-v1-page .word.has-root {
  text-decoration: underline dotted rgba(26, 127, 90, 0.40);
  text-underline-offset: 4px;
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;   /* no red/grey flash on tap */
}
.word-pop {
  position: fixed; z-index: 200; box-sizing: border-box;
  background: #fffdf7; border: 1px solid rgba(184, 148, 86, 0.55);
  border-radius: 12px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.20);
  padding: 12px 14px; max-height: 52vh; overflow-y: auto;
  font-family: 'Cairo', 'Segoe UI', sans-serif; direction: rtl; text-align: right;
}
.word-pop-close {
  position: absolute; top: 4px; left: 8px; border: none; background: none;
  font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px;
}
.word-pop-root { font-weight: 700; color: var(--accent); font-size: 1.05rem; margin: 0 0 6px; padding-inline-end: 22px; }
.word-pop-src { font-weight: 600; color: var(--muted); font-size: .78rem; margin-top: 9px; }
.word-pop-gloss { color: var(--ink); font-size: .92rem; line-height: 1.75; }
.word-pop-msg { color: var(--muted); font-size: .9rem; }

/* ============================================================================
   Reader header actions (search / mushaf) + Arabic dictionary search page.
   ============================================================================ */
.reader-nav { display: inline-flex; align-items: center; gap: .9rem; }
.reader-act { font-size: 1.15rem; text-decoration: none; line-height: 1; }
.reader-act:hover { text-decoration: none; }

.dict-search { margin: 0 auto 1rem; max-width: 720px; }
.dict-search input {
  width: 100%; box-sizing: border-box; padding: .8rem 1rem;
  border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 1.15rem; background: #fff; color: var(--ink);
}
.dict-hint { max-width: 720px; margin: 0 auto; color: var(--muted); line-height: 1.9; }
#dict-results { max-width: 760px; margin: 1.2rem auto 0; }
.dict-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem;
  padding-bottom: .7rem; border-bottom: 2px solid var(--accent-soft); margin-bottom: 1rem;
}
.dict-word { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.dict-root { font-size: 1.05rem; color: var(--ink); }
.dict-root bdi { font-weight: 700; }
.dict-count { font-size: .85rem; color: var(--muted); }
.dict-sec { margin: 1.4rem 0; }
.dict-sec > h3 {
  font-size: 1rem; color: var(--accent); margin: 0 0 .6rem;
  border-inline-start: 4px solid var(--accent); padding-inline-start: .5rem;
}
.dict-mean { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .5rem; background: #fff; }
.dict-mean > summary { cursor: pointer; padding: .6rem .9rem; font-weight: 600; color: var(--ink); }
.dict-mean-body { padding: 0 .9rem .8rem; white-space: pre-wrap; line-height: 1.9; color: var(--ink); }
.dict-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.dict-chip { background: var(--accent-soft); border-radius: 999px; padding: .25rem .7rem; font-size: .95rem; }
.dict-chip em { color: var(--muted); font-style: normal; font-size: .8rem; }
.dict-ayahs { display: flex; flex-direction: column; gap: .5rem; }
.dict-ayah {
  display: block; padding: .6rem .9rem; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--ink); text-decoration: none;
}
.dict-ayah:hover { border-color: var(--accent); text-decoration: none; }
.dict-ayah-ref { color: var(--accent); font-weight: 700; font-size: .9rem; }
.dict-ayah-text { font-family: 'Amiri Quran', serif; font-size: 1.25rem; line-height: 2; }
.dict-poems { display: flex; flex-direction: column; gap: .7rem; }
.dict-poem { border-inline-start: 3px solid var(--accent-soft); padding-inline-start: .8rem; }
.dict-bayt { font-size: 1.1rem; line-height: 2; color: var(--ink); }
.dict-sadr { text-align: right; }   /* first hemistich → right */
.dict-ajz  { text-align: left; }    /* second hemistich → left (shifted) */
.dict-poet { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.dict-empty, .dict-loading { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ٩٩ badge in the reader header + Names-of-Allah page. */
.reader-badge {
  font-size: .8rem; font-weight: 700; line-height: 1;
  border: 1.5px solid rgba(255,255,255,.85); border-radius: 999px; padding: 2px 7px;
}
.asma-title { text-align: center; color: var(--accent); font-size: 1.5rem; margin: .5rem 0 1rem; }
.asma-tabs { display: flex; gap: .5rem; justify-content: center; margin-bottom: 1.2rem; }
.asma-tab {
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  border-radius: 999px; padding: .45rem 1.1rem; font: inherit; cursor: pointer;
}
.asma-tab.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.asma-list { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: .5rem; }
.asma-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.asma-card > summary {
  cursor: pointer; list-style: none; padding: .7rem 1rem;
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
}
.asma-card > summary::-webkit-details-marker { display: none; }
.asma-name { font-family: 'Amiri Quran','Amiri',serif; font-size: 1.5rem; color: var(--accent); font-weight: 700; }
.asma-tr { color: var(--ink); font-size: .95rem; }
.asma-en { color: var(--muted); font-size: .85rem; }
.asma-count { margin-inline-start: auto; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; font-weight: 700; }
.asma-card[open] > summary { border-bottom: 1px solid var(--border); }
.asma-card .dict-ayahs { padding: .7rem 1rem; }

/* Names co-occurrence map (constellation) — monochrome green nodes / gold links. */
.map-hint { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }
.map-wrap { max-width: 760px; margin: 0 auto; }
.map-svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.map-edge { stroke: rgba(184,134,11,.45); }
.map-node { cursor: pointer; }
.map-node circle { fill: var(--accent); transition: fill .12s; }
.map-label {
  font-family: 'Amiri Quran','Amiri',serif; fill: var(--ink); text-anchor: middle;
  pointer-events: none; paint-order: stroke; stroke: #fbf6e9; stroke-width: 3px;
}
.map-node.minor .map-label { display: none; }
.map-svg.has-focus .map-node:not(.is-on) { opacity: .12; }
.map-svg.has-focus .map-edge:not(.is-on) { opacity: .06; }
.map-svg.has-focus .map-node.minor.is-on .map-label { display: block; }
.map-node.is-on circle { fill: #b8860b; }
.map-edge.is-on { stroke: #b8860b; opacity: 1; }
.map-info { max-width: 760px; margin: 1rem auto 0; }
.map-info-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.map-occ-link { color: var(--accent); font-size: .9rem; margin-inline-start: auto; white-space: nowrap; }
.map-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.map-chip { background: var(--accent-soft); border-radius: 999px; padding: .3rem .8rem; font-size: 1rem; cursor: pointer; }
.map-chip em { color: var(--muted); font-style: normal; font-size: .8rem; }

/* Map name-picker: alphabetical chips above the constellation. */
.map-picker { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; max-width: 760px; margin: 0 auto .8rem; }
.map-pick {
  font-family: 'Amiri Quran','Amiri',serif; font-size: 1.05rem; line-height: 1.2;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  border-radius: 999px; padding: .2rem .7rem; cursor: pointer;
}
.map-pick:hover { border-color: var(--accent); }
.map-pick.is-active { background: #b8860b; color: #fff; border-color: #b8860b; }
