/* Aydeen web reader. Site chrome (nav, footer) matches the rest of
   aydeen.com; everything inside <main> follows the reader's own reading
   theme, the same five palettes as the app's ReaderColorScheme. */

@font-face {
  font-family: 'UthmanicHafs';
  src: url('fonts/UthmanicHafs-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'ScheherazadeNew';
  src: url('fonts/ScheherazadeNew-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --emerald-950: #022C22;
  --emerald-900: #064E3B;
  --emerald-800: #065F46;
  --gold-500: #D4AF37;
  --gold-400: #E5C158;
  --gold-300: #FCD34D;
  --cream-50:  #FEF7E4;
  --cream-100: #FEF3C7;

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --quran: 'UthmanicHafs', 'ScheherazadeNew', serif;
  --naskh: 'ScheherazadeNew', 'Noto Naskh Arabic', serif;

  --maxw: 1180px;
  --readw: 860px;
  --pad-x: clamp(16px, 4vw, 48px);

  /* AydeenColors */
  --success: #2E7D32;
  --accent: #D4AF37;

  /* Reading theme: light (ReadingTheme.light) */
  --r-bg: #FFFFFF;
  --r-body: #1B1B1B;
  --r-arabic: #1B1B1B;
  --r-muted: #5C5C5C;
  --r-primary: #064E3B;
  --r-chip: #064E3B;
  --r-chip-ink: #FFFFFF;
  --r-band: #F3F7F5;

  /* Tajweed colours (TajweedRule.color in the app): darker shades for the
     light and sepia canvases, brighter ones for dark and high contrast. */
  --tj-gh: #178A4C; --tj-id: #C92A92; --tj-in: #7B8089; --tj-ik: #B07D05; --tj-iq: #0B8580; --tj-qq: #2563EB;

  /* Reading metrics; read.js overwrites these from the saved settings. */
  --ar-size: 30px;
  --ar-font: var(--quran);
  --tr-size: 15px;
  --tf-size: 14px;
  --hd-ar-size: 26px;
  --hd-tr-size: 16px;
  --lh: 1.8;
  --lh-tr: 1.5;
  --tr-weight: 400;
  --card-pad: 16px;
  --card-gap: 12px;
}

:root[data-rt="sepia"] {
  --r-bg: #F5ECD7; --r-body: #3B2E1E; --r-arabic: #1F1B12; --r-muted: #6B5B3B;
  --r-primary: #064E3B; --r-chip: #064E3B; --r-chip-ink: #FFFFFF; --r-band: #EFE3C8;
}
:root[data-rt="dark"] {
  --r-bg: #14171A; --r-body: #E4E4E4; --r-arabic: #EDE6D3; --r-muted: #9AA0A6;
  --r-primary: #6EE7B7; --r-chip: #047857; --r-chip-ink: #FFFFFF; --r-band: #1B2024;
  --tj-gh: #4ADE80; --tj-id: #F472B6; --tj-in: #A9AFB8; --tj-ik: #FACC15; --tj-iq: #2DD4BF; --tj-qq: #60A5FA;
}
:root[data-rt="highContrast"] {
  --r-bg: #000000; --r-body: #FFFFFF; --r-arabic: #FFFFFF; --r-muted: #E0E0E0;
  --r-primary: #FFE082; --r-chip: #FFFFFF; --r-chip-ink: #000000; --r-band: #111111;
  --tj-gh: #4ADE80; --tj-id: #F472B6; --tj-in: #A9AFB8; --tj-ik: #FACC15; --tj-iq: #2DD4BF; --tj-qq: #60A5FA;
}
@media (prefers-color-scheme: dark) {
  :root[data-rt="system"] {
    --r-bg: #14171A; --r-body: #E4E4E4; --r-arabic: #EDE6D3; --r-muted: #9AA0A6;
    --r-primary: #6EE7B7; --r-chip: #047857; --r-chip-ink: #FFFFFF; --r-band: #1B2024;
    --tj-gh: #4ADE80; --tj-id: #F472B6; --tj-in: #A9AFB8; --tj-ik: #FACC15; --tj-iq: #2DD4BF; --tj-qq: #60A5FA;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--r-body);
  background: var(--r-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--r-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; border-radius: 6px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: var(--pad-x); padding-right: var(--pad-x); }
.read-col { max-width: var(--readw); margin: 0 auto; }

/* ---------- site nav (same as the other aydeen.com pages, not sticky here) ---------- */
.nav { background: var(--emerald-950); border-bottom: 1px solid rgba(252, 211, 77, 0.12); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; color: var(--cream-100); }
.brand { display: inline-flex; align-items: center; gap: 14px; text-decoration: none !important; }
.brand-mark { width: 52px; height: 52px; border-radius: 13px; overflow: hidden; flex-shrink: 0; box-shadow: 0 8px 24px -8px rgba(0,0,0,0.45), 0 0 0 1px rgba(252,211,77,0.18) inset; }
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1; gap: 4px; }
.brand-name { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 40px; letter-spacing: -0.0278em; color: var(--cream-100); line-height: 0.95; }
.brand-divider { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; color: var(--gold-300); margin: 3px 0 2px; }
.brand-divider::before, .brand-divider::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--gold-300); opacity: 0.85; min-width: 24px; }
.brand-divider .diamond { font-size: 7px; line-height: 1; opacity: 0.9; }
.brand-tagline { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 11px; letter-spacing: 0.167em; color: var(--gold-300); opacity: 0.85; text-transform: lowercase; line-height: 1; text-align: center; }
.nav-links { display: none; gap: 24px; font-size: 14px; color: rgba(254, 243, 199, 0.85); }
.nav-links a { color: inherit; white-space: nowrap; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--gold-300); text-decoration: none; }
@media (min-width: 1000px) { .nav-links { display: flex; } }
.btn-cta { display: inline-flex; align-items: center; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--emerald-950); white-space: nowrap; }
.btn-cta:hover { text-decoration: none; }
@media (max-width: 600px) {
  .brand-mark { width: 44px; height: 44px; border-radius: 11px; }
  .brand-name { font-size: 26px; }
  .brand-tagline { font-size: 10px; }
}

/* ---------- reader toolbar ---------- */
.toolbar { position: sticky; top: 0; z-index: 40; background: var(--emerald-900); color: var(--cream-100); box-shadow: 0 6px 18px -12px rgba(0,0,0,0.5); }
.toolbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.tabs { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(2, 44, 34, 0.55); border: 1px solid rgba(252,211,77,0.18); }
.tab { padding: 6px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: rgba(254,243,199,0.8); }
.tab:hover { text-decoration: none; color: var(--cream-50); }
.tab[aria-selected="true"] { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--emerald-950); }
.toolbar-actions { display: inline-flex; align-items: center; gap: 6px; }
.toolbar .icon-btn { color: var(--cream-100); }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(252,211,77,0.35); background: transparent; color: var(--cream-100); font-size: 14px; font-weight: 600; cursor: pointer; }
.pill-btn svg { width: 18px; height: 18px; fill: currentColor; }
.pill-btn:hover { background: rgba(252,211,77,0.12); }
@media (max-width: 520px) { .pill-btn span { display: none; } .pill-btn { padding: 8px; } }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 0; background: transparent; color: var(--r-muted); cursor: pointer; flex-shrink: 0; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.icon-btn.on { color: var(--r-primary); }
.icon-btn.gold { color: var(--accent); }
.icon-btn.done { color: var(--success); }
:root[data-rt="dark"] .icon-btn.done, :root[data-rt="highContrast"] .icon-btn.done { color: #66BB6A; }
@media (prefers-color-scheme: dark) { :root[data-rt="system"] .icon-btn.done { color: #66BB6A; } }

/* ---------- main ---------- */
.ayah-ar, .ayah-tl, .ayah-tr, .tafsir-body, .hadith-ar, .hadith-en, .hadith-by, .mushaf, .page-title { overflow-wrap: anywhere; }
main { flex: 1 0 auto; padding: 24px 0 64px; outline: none; }
body.playing main { padding-bottom: 120px; }
.state { padding: 64px 0; text-align: center; color: var(--r-muted); }
.state .err { color: #C62828; margin-bottom: 12px; }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--r-muted) 25%, transparent); border-top-color: var(--r-primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-title { font-family: var(--serif); font-weight: 500; font-size: clamp(34px, 5vw, 48px); letter-spacing: -0.015em; line-height: 1.1; margin: 8px 0 6px; color: var(--r-body); }
.page-sub { margin: 0 0 24px; color: var(--r-muted); font-size: 15px; max-width: 62ch; }
.section-label { font-size: 12px; letter-spacing: 0.12em; font-weight: 700; text-transform: uppercase; color: var(--r-muted); margin: 28px 4px 10px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; color: var(--r-muted); margin-bottom: 8px; }
.crumb svg { width: 18px; height: 18px; fill: currentColor; }

.card { background: var(--r-bg); border: 1px solid color-mix(in srgb, var(--r-muted) 18%, transparent); border-radius: 16px; }
.hero-card { display: block; background: var(--emerald-900); color: #fff; border-radius: 16px; padding: 20px; }
.hero-card:hover { text-decoration: none; background: var(--emerald-800); }
.hero-card .k { font-size: 12px; letter-spacing: 1px; color: rgba(255,255,255,0.7); text-transform: uppercase; }
.hero-card .t { font-size: 22px; font-weight: 700; margin: 2px 0; }
.hero-card .s { font-size: 14px; color: rgba(255,255,255,0.75); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1.3fr 1fr; } }
.progress { padding: 18px 20px; }
.progress .bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--r-muted) 18%, transparent); overflow: hidden; margin: 10px 0 6px; }
.progress .bar i { display: block; height: 100%; background: var(--success); border-radius: 99px; }
.progress .n { font-size: 22px; font-weight: 700; }
.progress small { color: var(--r-muted); }

.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; margin: 24px 0 4px; }
.search svg { width: 20px; height: 20px; fill: var(--r-muted); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--r-body); font: inherit; font-size: 16px; }
.search input::placeholder { color: var(--r-muted); }
.jump { display: inline-flex; margin: 8px 0 0; }

.list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.list > *, .grid-2 > * { min-width: 0; }
@media (min-width: 700px) { .list.cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 1040px) { .list.cols3 { grid-template-columns: 1fr 1fr 1fr; } }
.row-link { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: var(--r-body); }
.row-link:hover { text-decoration: none; border-color: color-mix(in srgb, var(--r-primary) 45%, transparent); }
.row-link .num { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--r-primary); border: 1.5px solid color-mix(in srgb, var(--r-primary) 45%, transparent); border-radius: 10px; transform: rotate(45deg); }
.row-link .num span { transform: rotate(-45deg); }
.row-link .main { flex: 1; min-width: 0; }
.row-link .ttl, .row-link .meta { display: block; }
.row-link .ttl { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link .meta { font-size: 13px; color: var(--r-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link .ar { font-family: var(--ar-font); font-size: 22px; color: var(--r-primary); direction: rtl; white-space: nowrap; line-height: 1.4; flex-shrink: 0; }
@media (max-width: 420px) { .row-link { gap: 10px; padding: 12px; } .row-link .ar { font-size: 18px; } .row-link .num { width: 32px; height: 32px; } }
.row-link .read-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.empty { padding: 18px 16px; color: var(--r-muted); font-size: 14px; }

/* ---------- surah reader ---------- */
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px 8px 16px; border-radius: 14px; background: var(--r-band); margin-bottom: 16px; }
.reader-bar .who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; flex: 1; min-width: 160px; border: 0; background: none; padding: 0; color: inherit; text-align: left; cursor: pointer; }
.reader-bar .who svg { width: 16px; height: 16px; fill: var(--r-primary); flex-shrink: 0; }
.reader-bar .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--r-primary) 40%, transparent); background: transparent; color: var(--r-primary); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn:hover { background: color-mix(in srgb, var(--r-primary) 10%, transparent); text-decoration: none; }
.btn.solid { background: var(--r-chip); color: var(--r-chip-ink); border-color: var(--r-chip); }
.btn.solid:hover { filter: brightness(1.1); }

.segmented { display: inline-flex; border: 1px solid color-mix(in srgb, var(--r-muted) 35%, transparent); border-radius: 999px; overflow: hidden; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; background: transparent; color: var(--r-muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented button + button { border-left: 1px solid color-mix(in srgb, var(--r-muted) 35%, transparent); }
.segmented button svg { width: 16px; height: 16px; fill: currentColor; }
.segmented button[aria-pressed="true"] { background: color-mix(in srgb, var(--r-primary) 14%, transparent); color: var(--r-primary); }

.surah-head { text-align: center; padding: 8px 0 16px; }
.surah-head .ar-name { font-family: var(--ar-font); font-size: 36px; color: var(--r-primary); line-height: 1.6; direction: rtl; }
.surah-head .names { color: var(--r-muted); font-size: 14px; }
.surah-head .info { color: var(--r-muted); font-size: 12px; }
.surah-head .bismillah { font-family: var(--ar-font); font-size: 28px; color: var(--r-arabic); direction: rtl; margin-top: 24px; line-height: 1.8; }
.surah-head hr, .rule { border: 0; height: 1px; background: color-mix(in srgb, var(--r-muted) 30%, transparent); margin: 8px 0 0; }

.ayahs { display: flex; flex-direction: column; gap: var(--card-gap); margin-top: 16px; }
.ayah { padding: var(--card-pad); scroll-margin-top: 72px; transition: box-shadow .2s ease; }
.ayah.read { background: color-mix(in srgb, var(--success) 10%, var(--r-bg)); }
.ayah.active { box-shadow: 0 0 0 2px var(--r-primary); }
.ayah-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ayah-num { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--r-chip); color: var(--r-chip-ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.ayah-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ayah-actions .icon-btn { width: 38px; height: 38px; }
.ayah-ar { font-family: var(--ar-font); font-size: var(--ar-size); line-height: var(--lh); color: var(--r-arabic); direction: rtl; text-align: right; margin-top: 8px; word-wrap: break-word; }
.ayah-tl { font-size: var(--tr-size); line-height: var(--lh-tr); font-style: italic; color: var(--r-muted); margin-top: 10px; }
.ayah-tr { font-size: var(--tr-size); line-height: var(--lh-tr); font-weight: var(--tr-weight); color: var(--r-body); margin-top: 12px; }
.ayah-tr[dir="rtl"] { text-align: right; font-family: var(--naskh); font-size: calc(var(--tr-size) * 1.2); }
:root.no-tl .ayah-tl, :root.no-tr .ayah-tr, :root.no-tr .prev-tr, :root.no-tl .prev-tl { display: none; }
:root.no-num .ayah-num { visibility: hidden; }

.tafsir { margin-top: 8px; border-top: 1px solid color-mix(in srgb, var(--r-muted) 20%, transparent); }
.tafsir-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 0; border: 0; background: transparent; color: var(--r-muted); font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; }
.tafsir-toggle svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.tafsir-toggle span { flex: 1; }
.tafsir-body { margin: 4px 0 12px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--r-muted) 8%, transparent); font-size: var(--tf-size); line-height: var(--lh-tr); color: var(--r-body); }
.tafsir-body p { margin: 0 0 0.8em; }
.tafsir-body p:last-child { margin-bottom: 0; }
.tafsir-body[dir="rtl"] { font-family: var(--naskh); font-size: calc(var(--tf-size) * 1.2); text-align: right; }
.tafsir-body .src { font-size: 12px; color: var(--r-muted); margin-top: 8px; }

/* Tajweed */
.tj-gh { color: var(--tj-gh); }
.tj-id { color: var(--tj-id); }
.tj-in { color: var(--tj-in); }
.tj-ik { color: var(--tj-ik); }
.tj-iq { color: var(--tj-iq); }
.tj-qq { color: var(--tj-qq); }
:root.no-tj .tj { color: inherit; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--r-muted); margin: -6px 4px 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }

/* Mushaf (sequence) mode */
.mushaf { font-family: var(--ar-font); font-size: var(--ar-size); line-height: var(--lh); color: var(--r-arabic); direction: rtl; text-align: justify; margin-top: 16px; word-wrap: break-word; }
.mushaf .a { border-radius: 6px; scroll-margin-top: 80px; }
.mushaf .a.active { background: color-mix(in srgb, var(--r-primary) 16%, transparent); }
.marker { display: inline-flex; align-items: center; justify-content: center; width: 0.95em; height: 0.95em; border-radius: 50%; border: 1.2px solid color-mix(in srgb, var(--r-arabic) 55%, transparent); font-family: var(--naskh); font-weight: 600; font-size: 1em; vertical-align: middle; margin: 0 0.1em; }
.marker b { font-size: 0.5em; line-height: 1; font-weight: 600; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; }
.pager a { flex: 1; max-width: 48%; padding: 14px 16px; color: var(--r-body); }
.pager a:hover { text-decoration: none; border-color: color-mix(in srgb, var(--r-primary) 45%, transparent); }
.pager a small { display: block; color: var(--r-muted); font-size: 12px; }
.pager a strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- hadith ---------- */
.book-card { display: block; padding: 18px 20px; color: var(--r-body); }
.book-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--r-primary) 45%, transparent); }
.book-card .ar { font-family: var(--naskh); font-size: 24px; line-height: 1.5; direction: rtl; text-align: right; color: var(--r-primary); }
.book-card h3 { margin: 4px 0 2px; font-size: 18px; }
.book-card .by { font-size: 13px; color: var(--r-muted); }
.book-card .count { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--r-muted); }
.book-head { padding: 18px 20px; margin-bottom: 8px; }
.book-head .ar { font-family: var(--naskh); font-size: 28px; line-height: 1.6; direction: rtl; text-align: right; color: var(--r-primary); }
.book-head .who { font-weight: 700; font-size: 14px; margin-top: 4px; }
.book-head .dates { font-size: 12px; color: var(--r-muted); }
.book-head p { font-size: 14px; color: var(--r-muted); margin: 10px 0 0; }
.chip-n { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--r-primary); background: color-mix(in srgb, var(--r-primary) 12%, transparent); }

.hadiths { display: flex; flex-direction: column; gap: var(--card-gap); margin-top: 16px; }
.hadith { padding: var(--card-pad); scroll-margin-top: 72px; }
.hadith-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.tag.no { color: #A07D10; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tag.grade { color: var(--success); background: color-mix(in srgb, var(--success) 16%, transparent); }
:root[data-rt="dark"] .tag.no, :root[data-rt="highContrast"] .tag.no { color: var(--gold-300); }
:root[data-rt="dark"] .tag.grade, :root[data-rt="highContrast"] .tag.grade { color: #81C784; }
@media (prefers-color-scheme: dark) {
  :root[data-rt="system"] .tag.no { color: var(--gold-300); }
  :root[data-rt="system"] .tag.grade { color: #81C784; }
}
.hadith-top .spacer { flex: 1; }
.hadith-ar { font-family: var(--naskh); font-size: var(--hd-ar-size); line-height: var(--lh); color: var(--r-arabic); direction: rtl; text-align: right; margin-top: 10px; }
.hadith-en { font-size: var(--hd-tr-size); line-height: var(--lh-tr); font-weight: var(--tr-weight); color: var(--r-body); margin-top: 12px; white-space: pre-line; }
.hadith-by { font-size: 13px; font-weight: 600; color: var(--r-muted); margin-top: 8px; }
.hadith-ref { font-size: 12px; color: var(--r-muted); margin-top: 2px; }
:root.no-tr .hadith-en { display: none; }
.hadith-en[dir="rtl"] { font-family: var(--naskh); font-size: calc(var(--hd-tr-size) * 1.25); text-align: right; line-height: var(--lh); }
.lang-note { margin: -12px 0 16px; padding: 10px 14px; border-radius: 10px; background: var(--r-band); color: var(--r-muted); font-size: 13px; }

/* ---------- about ---------- */
.about h2 { font-size: 18px; margin: 28px 0 6px; }
.about p, .about li { font-size: 15px; color: var(--r-body); }
.about pre { white-space: pre-wrap; font-size: 12px; padding: 14px; border-radius: 10px; background: var(--r-band); color: var(--r-muted); overflow-x: auto; }

/* ---------- settings drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 60; }
.settings { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 61; display: flex; flex-direction: column; background: #F7F4EE; color: #1B1B1B; box-shadow: -20px 0 40px -20px rgba(0,0,0,0.4); }
/* The drawer is always light, so its legend keeps the light shades. */
.settings .s-legend { --tj-gh: #178A4C; --tj-id: #C92A92; --tj-in: #7B8089; --tj-ik: #B07D05; --tj-iq: #0B8580; --tj-qq: #2563EB; color: #5C5C5C; margin: 0; padding: 0 16px 12px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid rgba(0,0,0,0.08); background: #fff; }
.settings-head h2 { margin: 0; font-size: 18px; }
.settings-head .icon-btn { color: #1B1B1B; }
.settings-body { overflow-y: auto; padding: 8px 16px 32px; overscroll-behavior: contain; }
.settings .section-label { color: #5C5C5C; margin: 20px 4px 8px; }
.s-card { background: #fff; border-radius: 14px; border: 1px solid rgba(0,0,0,0.06); overflow: hidden; }
.s-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.s-row + .s-row { border-top: 1px solid rgba(0,0,0,0.06); }
.s-row input[type="radio"], .s-row input[type="checkbox"] { accent-color: var(--emerald-900); width: 18px; height: 18px; flex-shrink: 0; margin: 0; }
.s-row .t { flex: 1; min-width: 0; }
.s-row .t b { display: block; font-weight: 600; font-size: 15px; }
.s-row .t small { display: block; color: #5C5C5C; font-size: 12px; line-height: 1.4; }
.s-row .sample { font-size: 24px; color: var(--emerald-900); direction: rtl; line-height: 1.6; }
.s-row.switch input { order: 2; appearance: none; width: 42px; height: 24px; border-radius: 99px; background: #C9C9C9; position: relative; cursor: pointer; transition: background .2s; }
.s-row.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.s-row.switch input:checked { background: var(--emerald-900); }
.s-row.switch input:checked::after { transform: translateX(18px); }
.s-slider { padding: 12px 16px 6px; }
.s-slider label { display: block; font-size: 13px; font-weight: 600; }
.s-slider input { width: 100%; accent-color: var(--emerald-900); margin: 8px 0 6px; }
.s-select { display: block; padding: 12px 16px; }
.s-select + .s-select { border-top: 1px solid rgba(0,0,0,0.06); }
.s-select span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.s-select select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.15); background: #fff; font: inherit; font-size: 15px; color: #1B1B1B; }
.preview { padding: 16px; border-radius: 14px; background: var(--r-bg); border: 1px solid rgba(0,0,0,0.06); }
.preview .prev-ar { font-family: var(--ar-font); font-size: var(--ar-size); line-height: var(--lh); color: var(--r-arabic); direction: rtl; text-align: right; }
.preview .prev-tl { font-size: var(--tr-size); line-height: var(--lh-tr); font-style: italic; color: var(--r-muted); margin-top: 10px; }
.preview .prev-tr { font-size: var(--tr-size); line-height: var(--lh-tr); font-weight: var(--tr-weight); color: var(--r-body); margin-top: 12px; }
.reset { display: flex; justify-content: center; margin-top: 20px; }
.reset button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--emerald-900); font-weight: 600; font-size: 15px; cursor: pointer; padding: 10px 14px; border-radius: 999px; }
.reset button:hover { background: rgba(6,78,59,0.08); }
.s-help { font-size: 12px; color: #5C5C5C; margin: -2px 4px 8px; line-height: 1.45; }
.s-note { text-align: center; font-size: 12px; color: #5C5C5C; margin-top: 4px; }

/* ---------- player ---------- */
.player { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; width: min(640px, calc(100% - 24px)); display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-radius: 18px; background: var(--emerald-950); color: var(--cream-100); box-shadow: 0 18px 40px -16px rgba(0,0,0,0.55), 0 0 0 1px rgba(252,211,77,0.18) inset; }
.player .info { flex: 1; min-width: 0; cursor: pointer; }
.player .info b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .info small { display: block; font-size: 12px; color: rgba(254,243,199,0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .icon-btn { color: var(--cream-100); }
.player .icon-btn.big { width: 46px; height: 46px; background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--emerald-950); }
.player .icon-btn.big svg { width: 26px; height: 26px; }
.player .loading svg { animation: spin 1s linear infinite; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 70; padding: 10px 16px; border-radius: 10px; background: #1B1B1B; color: #fff; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5); }

/* ---------- footer ---------- */
footer { background: #04201A; color: rgba(254,243,199,0.65); padding: 28px 0; border-top: 1px solid rgba(252,211,77,0.12); font-size: 14px; }
footer .row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
footer a { color: var(--cream-100); }
footer a:hover { color: var(--gold-300); }
footer .links { display: flex; flex-wrap: wrap; gap: 18px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
