/* ==========================================================================
   Quran Rihla — stylesheet (no build step)
   Text first, calm, mobile first. Tokens drive every theme (PRD 12).
   ========================================================================== */

@font-face {
  font-family: "me_quran";
  /* WOFF2: the same font, packed smaller (449 KB as TTF); the TTF is only for browsers without WOFF2. */
  src: url("/fonts/me_quran.woff2") format("woff2"), url("/fonts/me_quran.ttf") format("truetype");
  font-display: swap;
}
/* IndoPak (Naskh-Nastaleeq) Quran font by QuranWBW, for Quran.com's IndoPak text; loaded only when IndoPak is chosen. */
@font-face {
  font-family: "AlQuran IndoPak";
  src: url("/fonts/indopak-nastaleeq-waqf-lazim-v4.2.1.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Nafees Nastaleeq";
  src: url("/fonts/NafeesNastaleeq.woff2") format("woff2"), url("/fonts/NafeesNastaleeq.ttf") format("truetype");
  font-display: swap;
}
/* Lato (SIL Open Font License, see fonts/Lato-LICENSE.txt), the brand typeface. Only the "Share as
   image" card uses it, so browsers fetch it when that dialog opens and never otherwise. */
@font-face { font-family: "Lato"; font-weight: 400; src: url("/fonts/Lato-Regular.woff2") format("woff2"), url("/fonts/Lato-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Lato"; font-weight: 700; src: url("/fonts/Lato-Bold.woff2") format("woff2"), url("/fonts/Lato-Bold.ttf") format("truetype"); font-display: swap; }

/* ---------- tokens ---------- */
:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "me_quran", "Amiri Quran", "Scheherazade New", "Traditional Arabic", serif;
  --font-ip: "AlQuran IndoPak", "me_quran", serif;
  --font-ur: "Nafees Nastaleeq", "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  --font-tr: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ar-size: 2.25rem;
  --tr-size: 1.08rem;
  --ar-lh: 2.3;
  --measure: 46rem;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --player-h: 0px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bg: #faf8f3;
  --bg-elev: #ffffff;
  --bg-sunk: #f2efe6;
  --text: #1c2421;
  --text-soft: #56615c;
  --text-faint: #6c7671;
  --line: #e3ded2;
  --line-strong: #cfc8b8;
  --primary: #0f5c4d;
  --primary-ink: #ffffff;
  --primary-soft: #e3efe9;
  --accent: #8a6a24;
  --accent-soft: #f6ecd5;
  --play: #fbeab3;
  --mark: #ffe58a;
  --danger: #a52a2a;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 6px 24px rgba(20, 30, 25, .08);
  color-scheme: light;
}

[data-theme="sepia"] {
  --bg: #f4ecd8; --bg-elev: #fbf5e6; --bg-sunk: #ebe0c6; --text: #3b2f20; --text-soft: #6a5a43; --text-faint: #7b6a51;
  --line: #e0d2b3; --line-strong: #cdbb95; --primary: #6b4f1d; --primary-soft: #efe2c4; --accent: #8a5a12; --accent-soft: #f1e1bd;
  --play: #f2d78a; --mark: #f5d36b;
}

[data-theme="dark"] {
  --bg: #0d1513; --bg-elev: #15201d; --bg-sunk: #0a110f; --text: #e6ece9; --text-soft: #a9b6b1; --text-faint: #8a9893;
  --line: #24312d; --line-strong: #33433e; --primary: #5cc0a6; --primary-ink: #06231c; --primary-soft: #16302a; --accent: #d9b46a;
  --accent-soft: #2c261a; --play: #383416; --mark: #6b5a12; --danger: #ff8a80; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0d1513; --bg-elev: #15201d; --bg-sunk: #0a110f; --text: #e6ece9; --text-soft: #a9b6b1; --text-faint: #8a9893;
    --line: #24312d; --line-strong: #33433e; --primary: #5cc0a6; --primary-ink: #06231c; --primary-soft: #16302a; --accent: #d9b46a;
    --accent-soft: #2c261a; --play: #383416; --mark: #6b5a12; --danger: #ff8a80; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
[data-theme="contrast"] {
  --bg: #000; --bg-elev: #000; --bg-sunk: #111; --text: #fff; --text-soft: #fff; --text-faint: #e6e6e6;
  --line: #fff; --line-strong: #fff; --primary: #ffd400; --primary-ink: #000; --primary-soft: #222; --accent: #ffd400; --accent-soft: #222;
  --play: #333300; --mark: #ffd400; --danger: #ff6b6b; --shadow: none;
  color-scheme: dark;
}
[data-theme="contrast"] mark { color: #000; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 48px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font-ui);
  min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; outline: none; }
a { color: var(--primary); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
small { color: var(--text-soft); }
code, kbd { font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; }
kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; background: var(--bg-elev); color: var(--text-soft); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 .08em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--primary); color: var(--primary-ink); padding: .6rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: .5rem; }
/* Nastaleeq sets words close together; a little extra space between words reads more easily. */
[lang="ur"], .tr-ur { font-family: var(--font-ur); word-spacing: .2em; }
.tr-ur .tr-name { word-spacing: normal; }   /* the translator's name is in English */
[dir="rtl"] { text-align: right; }
.home-hero-ar[dir], .surah-hero-ar[dir], .surah-head-ar[dir], .empty-state .arabic[dir], .popover .pop-ar[dir], .popover .pop-tu[dir] { text-align: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 44px; padding: .5rem 1rem;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--text);
  font: 600 .95rem/1.2 var(--font-ui); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { min-height: 34px; padding: .3rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem; min-width: 44px; min-height: 44px; padding: 0 .5rem;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-soft); cursor: pointer; position: relative; font: inherit;
}
.icon-btn:hover { background: var(--bg-sunk); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--primary); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.badge { position: absolute; top: 4px; right: 2px; font-size: .65rem; background: var(--primary); color: var(--primary-ink); border-radius: 999px; padding: 0 .35em; line-height: 1.4; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .55rem .7rem; min-height: 44px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; line-height: 1.5; }
/* Dropdowns draw their own arrow: the browser's sits against the border once a select is styled.
   The arrow is a chevron in --text-soft, so each theme gets its own colour. */
:root { --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2356615c' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
[data-theme="sepia"] { --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236a5a43' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
[data-theme="dark"] { --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b6b1' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] { --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b6b1' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
}
[data-theme="contrast"] { --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23ffffff' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: var(--select-arrow); background-repeat: no-repeat; background-size: 12px 8px;
  background-position: right .8rem center; padding-inline-end: 2.4rem;
}
[dir="rtl"] select:not([multiple]):not([size]), select[dir="rtl"]:not([multiple]):not([size]) { background-position: left .8rem center; }
/* The small pill and inline dropdowns (player speed, admin forms). */
select.player-select:not([multiple]):not([size]), .inline-form select:not([multiple]):not([size]) { background-position: right .6rem center; background-size: 10px 7px; padding-inline-end: 1.8rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[type="range"] { width: 100%; padding: 0; border: 0; background: none; accent-color: var(--primary); min-height: 32px; }
input[type="checkbox"], input[type="radio"] { min-height: auto; accent-color: var(--primary); width: 1.1rem; height: 1.1rem; }
.form { display: grid; gap: .9rem; }
.form label:not(.check) { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form label:not(.check) > input, .form label:not(.check) > select, .form label:not(.check) > textarea { font-weight: 400; }
.check { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; cursor: pointer; }
.check.indent, .segmented.indent { margin-inline-start: 1.7rem; }
.field-error { color: var(--danger); font-size: .9rem; margin: 0; }
.hint { color: var(--text-soft); font-size: .9rem; }
.notice { background: var(--accent-soft); border-radius: var(--radius-sm); padding: .7rem 1rem; }
.reset-link-box { margin-bottom: 1rem; }
.reset-link-box p { margin: .3rem 0; }
.reset-link-box input { width: 100%; font: .85rem ui-monospace, monospace; }
.empty { color: var(--text-soft); }

.segmented { display: flex; flex-wrap: wrap; gap: .35rem; }
.segmented label, .seg-link { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span, .seg-link {
  display: inline-flex; align-items: center; min-height: 38px; padding: .3rem .8rem; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: .88rem; cursor: pointer; color: var(--text); text-decoration: none; background: var(--bg-elev);
}
.segmented input:checked + span, .seg-link[aria-current="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.segmented input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

.tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > button, .tabs > a {
  flex: none; border: 0; background: none; font: 600 .92rem var(--font-ui); color: var(--text-soft); padding: .7rem .9rem; cursor: pointer;
  border-bottom: 3px solid transparent; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center;
}
.tabs > [aria-selected="true"], .tabs > [aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card h2 { font-size: 1.05rem; }
.danger-card { border-color: var(--danger); }
.ok-card { border-color: var(--primary); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
  transition: transform .25s var(--ease);
}
.topbar.is-hidden { transform: translateY(calc(-1 * var(--topbar-h))); }
.topbar-inner { display: flex; align-items: center; gap: .75rem; height: var(--topbar-h); padding: 0 max(1rem, env(safe-area-inset-left)); max-width: 80rem; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 700; flex: none; }
.brand-mark { width: 30px; height: 30px; color: var(--primary); }
.search-trigger {
  flex: 1; min-width: 0; max-width: 26rem; display: flex; align-items: center; gap: .6rem; min-height: 40px; padding: 0 .8rem; margin-inline-start: auto;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg-elev); color: var(--text-faint); font: inherit; cursor: pointer; text-align: start;
}
.search-trigger:hover { border-color: var(--primary); }
.search-trigger-label { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .92rem; }
.topnav { display: flex; gap: .2rem; }
.topnav-link { color: var(--text-soft); text-decoration: none; font-weight: 600; padding: .5rem .7rem; border-radius: 999px; font-size: .93rem; }
.topnav-link:hover { background: var(--bg-sunk); color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: .1rem; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 12rem; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .35rem; display: grid; z-index: 40;
}
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: start; padding: .6rem .8rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--bg-sunk); }
.menu-panel [aria-current="true"] { font-weight: 700; color: var(--primary); }
.menu-label { padding: .5rem .8rem; font-size: .82rem; color: var(--text-soft); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; margin-inline-start: .3rem; }
.context-bar {
  display: flex; gap: .9rem; justify-content: center; align-items: center; font-size: .8rem; color: var(--text-soft); padding: .25rem 1rem;
  border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden;
}
.context-bar strong { color: var(--text); font-weight: 650; }
.context-bar span + span::before { content: "·"; margin-inline-end: .9rem; color: var(--text-faint); }
.flash { max-width: var(--measure); margin: 1rem auto 0; padding: .8rem 1rem; background: var(--primary-soft); border-radius: var(--radius-sm); }
.flash-error { background: color-mix(in srgb, var(--danger) 15%, var(--bg)); }

/* ---------- page containers ---------- */
#pjax-body { padding: 1.25rem max(1rem, env(safe-area-inset-left)) 3rem; }
.page-narrow { max-width: var(--measure); margin: 0 auto; }
.page-wide { max-width: 72rem; margin: 0 auto; }
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.prose { font-size: 1.02rem; line-height: 1.75; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: .35em; }
.prose details { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.prose summary { cursor: pointer; font-weight: 600; }
.crumbs { font-size: .88rem; color: var(--text-soft); margin-bottom: .75rem; }
.crumbs a { color: var(--text-soft); }
.source-line { color: var(--text-faint); font-size: .85rem; margin-top: 1rem; }
.table-wrap { overflow-x: auto; margin-bottom: 1.5rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { text-align: start; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.plain-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.plain-list li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.empty-state { text-align: center; padding-top: 3rem; }
.empty-state .arabic { font-size: 2rem; }

/* ---------- footer & bottom nav ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-sunk); padding: 2rem 1rem calc(5rem + var(--player-h)); }
.footer-inner { max-width: 72rem; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; }
.footer-brand p { color: var(--text-soft); font-size: .9rem; margin: .25rem 0 0; }
.footer-brand .footer-tagline { color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .9rem; }
.footer-links a { color: var(--text-soft); }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: none; background: var(--bg-elev); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem 0 .4rem; min-height: 54px;
  color: var(--text-soft); text-decoration: none; font: 600 .68rem var(--font-ui); background: none; border: 0; cursor: pointer;
}
.bottom-nav a, .bottom-nav button { min-width: 0; white-space: nowrap; }
.bottom-nav svg { width: 22px; height: 22px; }
@media (max-width: 359px) { .bottom-nav a, .bottom-nav button { font-size: .62rem; } }

/* ---------- home ---------- */
.home { max-width: 72rem; margin: 0 auto; }
.home-hero { text-align: center; padding: 1.5rem 0 1.25rem; }
.home-hero-ar { font: 2.6rem/1.6 var(--font-ar); color: var(--primary); margin: 0 0 .55em; }   /* room for the marks below the letters */
.home-hero h1 { font-size: clamp(1.4rem, 1rem + 1.5vw, 2rem); color: var(--text-soft); font-weight: 600; }
.home-hero h1 { margin-bottom: .15rem; }
.home-tagline { margin: 0; color: var(--text-soft); font-size: .98rem; }
.home-tagline strong { color: var(--primary); }
.home-search { display: flex; align-items: center; gap: .5rem; max-width: 38rem; margin: 1rem auto; background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 999px; padding: .3rem .3rem .3rem 1rem; box-shadow: var(--shadow); }
.home-search svg { color: var(--text-faint); }
.home-search input { flex: 1; border: 0; background: none; min-width: 0; padding: .4rem 0; }
.home-search input:focus { outline: none; }
.quick-links { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.quick-links a { padding: .35rem .85rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); text-decoration: none; font-size: .88rem; font-weight: 600; }
.home-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); margin: 1.5rem 0; }
.continue-card .continue-link { display: flex; flex-direction: column; text-decoration: none; }
.continue-name { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.continue-key { color: var(--primary); font-weight: 600; }
/* A card, so smaller than the reader: 65% of the chosen Arabic size, but not below 1.2rem at the smallest sizes. */
.daily-card .arabic { font: max(1.2rem, calc(var(--ar-size) * .65))/2.1 var(--font-ar); margin: .25rem 0 .5rem; }
.daily-tr { font-family: var(--font-tr); font-size: .94rem; color: var(--text-soft); }
.daily-ref { font-weight: 600; text-decoration: none; }
/* Reading plan (home card, end of a day's pages in the reader, setup dialog) */
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.plan-head h2 { margin: 0; }
.plan-lead { color: var(--text-soft); margin: .4rem 0 .9rem; }
.plan-day { margin: .35rem 0 .2rem; font-size: .88rem; color: var(--text-soft); }
.plan-state { font-weight: 600; color: var(--primary); }
.plan-state.is-behind { color: var(--accent); }
.plan-today { margin: .2rem 0 .6rem; }
.plan-today strong { font-size: 1.08rem; }
.plan-today small { display: block; color: var(--text-soft); font-size: .88rem; margin-top: .1rem; }
.plan-meta { margin: .3rem 0 .8rem; font-size: .85rem; color: var(--text-soft); }
.plan-bar { display: block; width: 100%; height: .5rem; border: 0; border-radius: 999px; background: var(--bg-sunk); color: var(--primary); overflow: hidden; appearance: none; -webkit-appearance: none; }
.plan-bar::-webkit-progress-bar { background: var(--bg-sunk); border-radius: 999px; }
.plan-bar::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.plan-bar::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.plan-bar + .plan-actions { margin-top: .9rem; }
.plan-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.plan-actions:empty { display: none; }
.plan-end { margin: 1.5rem 0 1rem; border-color: var(--primary); }
.plan-end .plan-bar { margin-bottom: .9rem; }
.plan-end .hint { margin: 0 0 .7rem; }
.plan-preview { margin: .25rem 0 .5rem; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); font-weight: 600; font-size: .92rem; }
.plan-preview.is-error { background: color-mix(in srgb, var(--danger) 12%, var(--bg-elev)); color: var(--danger); }
.plan-dialog { width: min(30rem, calc(100% - 1.5rem)); }
.plan-dialog #plan-page { max-width: 8rem; }
.plan-dialog .dialog-actions { flex-wrap: wrap; }
.plan-end-btn { color: var(--danger); margin-inline-end: auto; }
/* Sleep timer countdown on the player's Options button */
.sleep-badge { display: inline-flex; align-items: center; gap: .15rem; font-variant-numeric: tabular-nums; }
.sleep-badge[hidden] { display: none; }
.sleep-badge svg { width: .85em; height: .85em; stroke-width: 2.4; }
.sleep-field { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .75rem; }
#pl-sleep-left { font-variant-numeric: tabular-nums; }
/* Hifz (memorisation tracker): page, home card, add dialog */
.hifz-page { max-width: var(--measure); margin: 0 auto; }
.hifz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.hifz-head .lead { margin-top: .25rem; }
.hifz-page > .notice { margin: 0 0 1rem; }
.hifz-stat { margin-bottom: .6rem; }
.hifz-stat strong { font-size: 1.35rem; }
.juz-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .3rem 1rem; margin-top: 1.1rem; }
.juz-head h3 { margin: 0; font-size: .95rem; }
.juz-key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .8rem; font-size: .8rem; color: var(--text-soft); }
.juz-key li { display: inline-flex; align-items: center; gap: .3rem; }
.juz-key i { width: .8rem; height: .8rem; border-radius: 3px; background: var(--bg-sunk); box-shadow: inset 0 0 0 1px var(--line); }
.juz-key .k-full { background: var(--primary); box-shadow: none; }
.juz-key .k-part { background: linear-gradient(to top, color-mix(in srgb, var(--primary) 35%, var(--bg-sunk)) 45%, var(--bg-sunk) 45%); }
.juz-grid { list-style: none; padding: 0; margin: .55rem 0 0; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.juz-hint { margin: .45rem 0 0; font-size: .8rem; }
.juz-cell { position: relative; width: 100%; height: 2.1rem; padding: 0; border: 0; border-radius: 6px; background: var(--bg-sunk); overflow: hidden; display: flex; align-items: center; justify-content: center; font: .72rem var(--font-ui); color: var(--text-faint); cursor: pointer; }
.juz-cell:focus-visible { outline: 3px solid var(--primary); outline-offset: 1px; }
.juz-cell span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.juz-cell i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--primary); opacity: .35; }
.juz-cell.is-full i { opacity: 1; }
.juz-cell.is-full span { color: var(--primary-ink); font-weight: 700; }
.juz-cell.is-part span { color: var(--text); font-weight: 600; }
.hifz-page h2 .count { display: inline-block; min-width: 1.5em; padding: 0 .45em; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .8rem; text-align: center; vertical-align: middle; }
.hifz-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.hifz-row { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .75rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.hifz-row:first-child { border-top: 0; }
.hifz-what { flex: 1 1 10rem; min-width: 0; display: flex; flex-direction: column; }   /* the buttons wrap below when the row is narrow */
.hifz-what a { font-weight: 650; text-decoration: none; color: var(--text); }
.hifz-what small { color: var(--text-soft); font-size: .84rem; }
.hifz-acts { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; margin-inline-start: auto; }
.hz-weak { color: var(--accent); font-weight: 600; }
.hifz-done { margin: .4rem 0 0; }
.hifz-empty p { color: var(--text-soft); }
.hifz-link { display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: var(--text); border-color: var(--primary); }
.hifz-link span { color: var(--text-soft); font-size: .9rem; }
.hifz-dialog { width: min(32rem, calc(100% - 1.5rem)); }
.hifz-dialog form > .segmented, #hifz-surah-fields > .segmented { margin-bottom: .75rem; }
#hifz-surah-fields > label { display: grid; gap: .3rem; margin-bottom: .6rem; font-weight: 600; font-size: .92rem; }
#hifz-range { margin-bottom: .75rem; }
.hifz-status { border: 0; padding: 0; margin: .25rem 0 .5rem; }
.hifz-status legend { font-weight: 600; font-size: .92rem; margin-bottom: .2rem; }
.hifz-status .check { align-items: flex-start; }
.hifz-status .check input { margin-top: .3rem; }
.hifz-status small { display: block; color: var(--text-soft); font-size: .84rem; }
/* Hifz test mode (a reader page opened with ?hifz=…): each Arabic word is a blank until tapped */
.test-on:not(.test-all) .w:not(.shown) { color: transparent !important; text-shadow: none; background: var(--bg-sunk); border-radius: .3em; box-shadow: inset 0 0 0 1px var(--line); }
.test-on:not(.test-all) .w:not(.shown)::before, .test-on:not(.test-all) .w:not(.shown)::after { visibility: hidden; }
.test-on:not(.test-all) .verse .arabic:not(.shown) .tj { filter: blur(8px); }
.test-on .verse .w, .test-on .verse .arabic { cursor: pointer; }
.test-on .translit { display: none !important; }
.hifz-bar { border-color: var(--primary); margin-bottom: 1rem; }
.hifz-bar p { margin: 0 0 .4rem; }
.hifz-scores { flex-wrap: nowrap; }
.hifz-scores .btn { flex: 1 1 0; min-width: 0; flex-direction: column; line-height: 1.15; padding: .45rem .4rem; border-radius: var(--radius-sm); }
.hifz-scores .btn small { color: inherit; font-weight: 400; font-size: .75rem; opacity: .85; white-space: nowrap; }
.index-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.index-head h2 { margin: 0 0 .6rem; }
.index-head .tabs { border: 0; margin: 0; }
.index-tools { display: flex; gap: .5rem; margin-bottom: 1rem; }
.index-tools input { flex: 1; min-width: 0; }   /* else its default width pushes the sort menu off a phone screen */
.surah-grid, .unit-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); }
/* Every card the same height: rows as tall as the tallest card, each card filling its cell. */
.surah-grid { grid-auto-rows: 1fr; }
.surah-grid > li, .unit-grid > li { display: flex; }
.surah-card, .unit-card {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--text); text-decoration: none; min-height: 64px; transition: border-color .15s, transform .15s;
}
.surah-card:hover, .unit-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.surah-num {
  flex: none; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--primary-soft); color: var(--primary); border-radius: 10px; transform: rotate(45deg);
}
.surah-num::after { content: none; }
.surah-card .surah-num, .unit-card .surah-num { transform: none; border-radius: 50%; }
.surah-names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.surah-names > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah-name { font-weight: 650; }
.surah-meaning, .surah-count, .unit-card small { font-size: .8rem; color: var(--text-soft); }
.unit-card span:last-child { display: flex; flex-direction: column; }
.surah-side { display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.surah-ar { font: 1.35rem/1.4 var(--font-ar); color: var(--text); }
.page-jump { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-jump input { width: 7rem; }

/* ---------- reader ---------- */
.reader { max-width: var(--measure); margin: 0 auto; }
.w-narrow .reader { --measure: 38rem; }
.w-wide .reader { --measure: 60rem; }
.surah-hero { text-align: center; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.surah-hero-ar { font: 2.4rem/1.7 var(--font-ar); color: var(--primary); margin: 0; }
.surah-hero h1 { margin-bottom: .3rem; }
.surah-hero-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem .9rem; color: var(--text-soft); font-size: .9rem; }
.surah-hero-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.surah-head { text-align: center; margin: 2.5rem 0 1rem; }
.surah-head-frame {
  display: flex; flex-direction: column; align-items: center; padding: .6rem 1rem; border: 1px solid var(--accent); border-radius: var(--radius);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box; position: relative;
}
.surah-head-ar { font: 1.8rem/1.6 var(--font-ar); color: var(--accent); }
.surah-head-name { font-weight: 650; color: var(--text); text-decoration: none; font-size: .95rem; }
.surah-head-name small { font-weight: 400; }
.bismillah { font: calc(var(--ar-size) * .85)/2 var(--font-ar); text-align: center !important; margin: 1rem 0; color: var(--text); }

.verse { padding: 1.25rem 0 1rem; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 3rem); transition: background .3s; position: relative; }
.verse-bar { display: flex; align-items: center; gap: .25rem; margin-bottom: .35rem; flex-wrap: wrap; }
.verse-key {
  font: 600 .8rem var(--font-ui); color: var(--primary); text-decoration: none; background: var(--primary-soft); padding: .2rem .55rem;
  border-radius: 999px; margin-inline-end: .25rem; min-height: 28px; display: inline-flex; align-items: center;
}
.verse-actions { display: flex; align-items: center; opacity: .75; }
.verse:hover .verse-actions, .verse:focus-within .verse-actions { opacity: 1; }
.verse-actions .icon-btn { min-width: 40px; min-height: 40px; }
.note-flag { color: var(--accent); font-size: .9rem; padding: 0 .3rem; }
.sajdah-badge { font-size: .75rem; color: var(--accent); background: var(--accent-soft); padding: .1rem .5rem; border-radius: 999px; margin-inline-start: auto; }
.verse.is-bookmarked .bm-btn { color: var(--primary); }
.verse.is-bookmarked .bm-btn svg { fill: currentColor; }
.result, .bismillah { position: relative; }
/* Playing ayah: tinted band reaching a little past the text, with an accent stripe at the start. */
.verse.is-playing, .result.is-playing, .bismillah.is-playing { background: var(--play); box-shadow: -.75rem 0 0 var(--play), .75rem 0 0 var(--play); }
.verse.is-playing::before, .result.is-playing::before, .bismillah.is-playing::before {
  content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: -.75rem; width: 4px; background: var(--accent);
}
.verse.is-playing .verse-key { background: var(--primary); color: var(--primary-ink); }

.arabic {
  font-family: var(--font-ar); font-size: var(--ar-size); line-height: var(--ar-lh); direction: rtl; text-align: right;
  margin: .25rem 0 .75rem; word-spacing: .08em; color: var(--text); font-feature-settings: "calt", "liga";
}
.w { border-radius: 6px; cursor: pointer; transition: background .15s, color .15s; padding: 0 .02em; }
.w:hover, .w:focus-visible { background: var(--primary-soft); outline: none; }
.w.is-word-playing { color: var(--primary); }
/* The ayah mark: the font draws ﴿١﴾ as a medallion as tall as the letters, so it is set a little smaller than the text (in em, so it follows the chosen size). */
.end { font-family: var(--font-ar); color: var(--accent); cursor: pointer; white-space: nowrap; font-size: .75em; padding: 0 .1em; border-radius: 6px; }
.end:hover { background: var(--accent-soft); }
/* The same mark where it is not a button (ayah of the day, tafsir): same size as in the reader. */
.ayah-mark { font-size: .75em; white-space: nowrap; }

/* Word-by-word under each word: instant, CSS-only toggle (PRD 3.4) */
.s-wbw .verse .arabic { line-height: 1.6; }
.s-wbw .verse .w { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; margin: 0 .2em .6em; padding: .1em .15em; }
.s-wbw .verse .w::after {
  content: attr(data-t); font: 400 max(.72rem, calc(var(--tr-size) * .72))/1.3 var(--font-ui); color: var(--text-soft); direction: ltr;
  text-align: center; max-width: 9em; white-space: normal; margin-top: .25em;
}
.s-wbw.s-wbw-ur .verse .w::after { content: attr(data-tu); font: 400 max(.85rem, calc(var(--tr-size) * .85))/1.9 var(--font-ur); direction: rtl; word-spacing: .2em; }
.s-wbw.s-wbw-tl .verse .w::before { content: attr(data-tl); order: 2; font: italic 400 max(.7rem, calc(var(--tr-size) * .7))/1.3 var(--font-ui); color: var(--accent); direction: ltr; margin-top: .25em; }
.s-wbw .verse .w::after { order: 3; }
.s-wbw .verse .end { display: inline-flex; vertical-align: top; }

.translit { display: none; font: italic var(--tr-size)/1.6 var(--font-tr); color: var(--accent); margin: 0 0 .6rem; }
.s-translit .translit { display: block; }
.translit u { text-decoration: none; }
.translit b { font-weight: 600; }
.tr { margin: 0 0 .75rem; }
.tr-text { font: var(--tr-size)/1.7 var(--font-tr); margin: 0; color: var(--text); }
.tr-ur .tr-text { font: calc(var(--tr-size) * 1.12)/2.25 var(--font-ur); }
.tr-name { font: .75rem var(--font-ui); color: var(--text-faint); margin: .15rem 0 0; }
.tr-ur .tr-name { font-family: var(--font-ui); }
.fn button { border: 0; background: var(--primary-soft); color: var(--primary); font: 700 .7rem var(--font-ui); border-radius: 4px; padding: 0 .3em; cursor: pointer; vertical-align: super; line-height: 1.2; min-width: 1.4em; }
.fn { display: none; }
.s-fn .fn { display: inline; }
.page-marker { text-align: center; margin: .5rem 0; font-size: .75rem; color: var(--text-faint); display: flex; align-items: center; gap: .75rem; }
.page-marker::before, .page-marker::after { content: ""; flex: 1; border-top: 1px dashed var(--line-strong); }

/* Memorisation (hifz) mode: hide Arabic while playing, tap to reveal (PRD 4.3) */
.hifz-on .verse .arabic, .hifz-on .mline { filter: blur(7px); transition: filter .2s; }
.hifz-on .verse .arabic:hover, .hifz-on .verse .arabic.reveal, .hifz-on .mline:hover, .hifz-on .mline.reveal { filter: none; }

/* IndoPak script: the Quran text, ayah marks and Bismillah use the IndoPak font (page numbers and surah names keep the default). */
.script-indopak .verse .arabic, .script-indopak .mtext, .script-indopak .bismillah, .script-indopak .end { font-family: var(--font-ip); }
/* Its ayah mark is bracketed digits, not a medallion, so it is already smaller than the letters. */
.script-indopak .end { font-size: .9em; }

/* Reading (Mushaf) view */
.view-reading .verses { margin: 0 auto; }
/*
 * The page grows with the Arabic text size, so every size step shows. --mline-em is the widest printed
 * line of the Madani layout in each font, in em (measured over all 604 pages). While the screen can hold
 * the printed lines (shrinking at most 15%), each line keeps its words; on a narrower screen the lines
 * flow as one paragraph at the chosen size.
 */
/*
 * It is drawn to look like a printed Mushaf with CSS alone (no images or extra fonts, so nothing more to download):
 * warm paper, a double-ruled frame around the text, the surah and juz above the frame and the page number below it,
 * a framed band for each surah title and a faint shadow on the binding side.
 * --mushaf-pad is the space inside the frame, --page-pad the paper around it, --band the frame's inner band.
 */
.view-reading {
  --mline-em: 27.6; --mushaf-pad: clamp(.85rem, 2.5vw + .3rem, 2rem); --page-pad: clamp(.45rem, 1.6vw, 1.1rem); --band: clamp(3px, .5vw, 5px);
  --mushaf-w: calc(var(--ar-size) * var(--mline-em) + 2 * var(--mushaf-pad) + 2 * var(--page-pad) + 4px);
  --paper: color-mix(in srgb, var(--bg-elev) 80%, var(--accent-soft));
  --frame: color-mix(in srgb, var(--accent) 70%, var(--paper));
  --frame-soft: color-mix(in srgb, var(--accent-soft) 70%, var(--paper));
}
.view-reading.script-indopak { --mline-em: 25.6; }
.reader.view-reading { max-width: max(var(--measure), var(--mushaf-w)); }
/*
 * Settings that change nothing on a Mushaf page are hidden while one is shown: "Text width" (the page's width
 * follows the Arabic text size), "Tajweed colours" (the Mushaf draws plain Uthmani words), "Translation text
 * size" (a Mushaf page has no translation text) and "Show" (transliteration, footnotes and word by word belong
 * to the translation view; the word popover shows both meanings regardless). "Translations" stays: copying,
 * sharing and share images use the first one. A reader who chose Tajweed sees Uthmani selected there, since
 * that is what the page shows; their choices are kept for the translation view.
 */
html:has(.reader.view-reading) .setting-width,
html:has(.reader.view-reading) .setting-tr-size,
html:has(.reader.view-reading) .setting-show,
html:has(.reader.view-reading) [data-setting="script"] label:has(input[value="tajweed"]) { display: none; }
html:has(.reader.view-reading) [data-setting="script"]:has(input[value="tajweed"]:checked) input[value="uthmani"] + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.mushaf-page {
  background-color: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: .2rem var(--page-pad) .25rem;
  margin: 0 auto 1.5rem; box-shadow: var(--shadow); max-width: var(--mushaf-w); font-size: var(--ar-size);
}
/* The binding: on the left of a right-hand (odd) page, on the right of a left-hand (even) one. */
.mushaf-page.is-odd { background-image: linear-gradient(to right, rgb(60 40 10 / .07), transparent 2rem); }
.mushaf-page.is-even { background-image: linear-gradient(to left, rgb(60 40 10 / .07), transparent 2rem); }
.mushaf-frame {
  container: mushaf / inline-size; border: 1px solid var(--frame);
  padding: calc(var(--band) + .35rem) var(--mushaf-pad);
  box-shadow: inset 0 0 0 var(--band) var(--frame-soft), inset 0 0 0 calc(var(--band) + 1px) var(--frame);
}
/* The Quran font draws a narrow space, so the running head and surah band get a little more between words. */
.mushaf-head, .mushaf-page-num { font: max(1rem, .48em)/2 var(--font-ar); color: var(--text-soft); word-spacing: .25em; }
.mushaf-head { display: flex; justify-content: space-between; gap: 1rem; padding: 0 .4rem; }
.mtext { font: 1em/var(--ar-lh) var(--font-ar); }
.mline {
  text-align: justify; text-align-last: justify; white-space: nowrap; margin: 0;
  font-size: min(1em, calc(100cqi / var(--mline-em)));
}
.mline-short { text-align: center; text-align-last: center; }
@container mushaf (max-width: 23.4em) {
  .view-reading:not(.script-indopak) .mtext { text-align: justify; }
  .view-reading:not(.script-indopak) .mline { display: inline; font-size: 1em; white-space: normal; }
}
@container mushaf (max-width: 21.7em) {
  .script-indopak .mtext { text-align: justify; }
  .script-indopak .mline { display: inline; font-size: 1em; white-space: normal; }
}
.mline .w.is-verse-playing { background: var(--play); box-shadow: 0 0 0 2px var(--play); border-radius: 3px; }
/* A surah title as a printed Mushaf frames it: a double-ruled band with a diamond at each end. */
.mushaf-page .surah-head { margin: .5rem 0 .25rem; }
.mushaf-page .surah-head-frame {
  border: 1px solid var(--frame); border-radius: 3px; padding: .25rem 2.4rem .35rem; background: var(--frame-soft);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--frame);
}
.mushaf-page .surah-head-frame::before, .mushaf-page .surah-head-frame::after {
  content: ""; position: absolute; top: 50%; width: .6rem; height: .6rem; border: 1px solid var(--frame); background: var(--paper);
  transform: translateY(-50%) rotate(45deg);
}
.mushaf-page .surah-head-frame::before { left: 1rem; }
.mushaf-page .surah-head-frame::after { right: 1rem; }
.mushaf-page .surah-head-ar { color: var(--text); word-spacing: .2em; }
.mushaf-page .bismillah { margin: .25rem 0; }
/* The Quran font draws its digits as parts of the ayah medallion, so the page number uses the interface font. */
.mushaf-page-num { text-align: center; font-family: var(--font-ui); font-size: max(.85rem, .4em); }
.mushaf-page-num a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .6em; }
.mushaf-page-num a::before, .mushaf-page-num a::after { content: ""; width: .4em; height: .4em; border: 1px solid var(--frame); transform: rotate(45deg); }

.load-more { text-align: center; margin: 1.25rem 0; }
.verses-skeleton { padding: 1rem 0; }
.sk { height: 1.1rem; border-radius: 6px; background: linear-gradient(90deg, var(--bg-sunk), var(--line), var(--bg-sunk)); background-size: 200% 100%; animation: sk 1.2s infinite linear; margin: .6rem 0; }
.sk-ar { height: 2.4rem; width: 80%; margin-inline-start: auto; }
.sk.short { width: 55%; }
@keyframes sk { to { background-position: -200% 0; } }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 2rem 0 0; }
.pager a { display: flex; flex-direction: column; padding: .8rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 650; background: var(--bg-elev); }
.pager a span { font-size: .75rem; color: var(--text-soft); font-weight: 500; }
.pager-next { text-align: end; margin-inline-start: auto; }

/* ayah page */
.ayah-title small { display: block; font-size: 1rem; color: var(--text-soft); font-weight: 500; }
.ayah-nav { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin: 1.25rem 0; }
.tafsir-inline { margin-top: 2rem; }
.tafsir-inline-head h2 { margin-bottom: .25rem; }
.tafsir-text { line-height: 1.8; }
.tafsir-text[lang="ar"] { font: 1.25rem/2.1 var(--font-ar); }
.tafsir-text[lang="ur"] { font: 1.2rem/2.3 var(--font-ur); }
.tafsir-text h2 { font-size: 1.05rem; }
.tafsir-verse { font-size: min(calc(var(--ar-size) * .8), 2rem); }

/* Tajweed colours (PRD 3.5) */
tajweed { cursor: help; }
tajweed.ham_wasl, tajweed.slnt, tajweed.laam_shamsiyah { color: #8f8f8f; }
tajweed.madda_normal { color: #537fff; }
tajweed.madda_permissible { color: #4050ff; }
tajweed.madda_necessary { color: #000ebc; }
tajweed.madda_obligatory { color: #2144c1; }
tajweed.qalaqah { color: #dd0008; }
tajweed.ikhafa_shafawi { color: #d500b7; }
tajweed.ikhafa { color: #9400a8; }
tajweed.idgham_shafawi { color: #58b800; }
tajweed.iqlab { color: #26bffd; }
tajweed.idgham_ghunnah { color: #169777; }
tajweed.idgham_wo_ghunnah { color: #169200; }
tajweed.idgham_mutajanisayn, tajweed.idgham_mutaqaribayn { color: #a1a1a1; }
tajweed.ghunnah { color: #ff7e1e; }
[data-theme="dark"] tajweed.madda_necessary, [data-theme="dark"] tajweed.madda_permissible { color: #8fa3ff; }
.tajweed-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; margin: 0 0 1rem; }
.tajweed-legend span::before { content: "●"; margin-inline-end: .3em; color: var(--c); }

/* ---------- player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--bg-elev); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(0,0,0,.08); padding-bottom: env(safe-area-inset-bottom);
}
.player-progress input { display: block; width: 100%; margin: -9px 0 -6px; height: 18px; }
.player-inner { display: flex; align-items: center; gap: .5rem; max-width: 72rem; margin: 0 auto; padding: .3rem .75rem; }
.player-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Shown in full: a long name wraps (the player grows a little) instead of being cut off with "…". */
.player-title { font-weight: 650; color: var(--text); text-decoration: none; overflow-wrap: anywhere; line-height: 1.3; }
.player-sub { font-size: .78rem; color: var(--text-soft); overflow-wrap: anywhere; line-height: 1.35; }
.player-controls { display: flex; align-items: center; }
.player-play { background: var(--primary); color: var(--primary-ink); width: 48px; height: 48px; }
.player-play:hover { background: var(--primary); color: var(--primary-ink); filter: brightness(1.1); }
.player-play svg { fill: currentColor; stroke: none; width: 22px; height: 22px; }
.player-play .i-load { fill: none; stroke: currentColor; stroke-width: 2.4; animation: spin 1s linear infinite; }
.player .i-pause, .player .i-load, .player.is-playing .i-play, .player.is-loading .i-play, .player.is-loading .i-pause { display: none; }
.player.is-playing:not(.is-loading) .i-pause, .player.is-loading .i-load { display: block; }
.player .i-muted, .player.is-muted .i-vol { display: none; }
.player.is-muted .i-muted { display: inline; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-time { font: .8rem ui-monospace, monospace; color: var(--text-soft); white-space: nowrap; }
.player-extra { display: flex; align-items: center; }
.player-select { min-height: 36px; padding: .2rem .4rem; font-size: .85rem; border-radius: 999px; }
.pl-text-btn {
  display: inline-flex; align-items: center; gap: .3rem; min-height: 36px; padding: 0 .75rem; margin-inline-start: .35rem;
  border: 1px solid var(--line-strong); border-radius: 999px; background: none; color: var(--text); font: 600 .85rem var(--font-ui);
  cursor: pointer; white-space: nowrap;
}
.pl-text-btn:hover { border-color: var(--primary); color: var(--primary); }
.pl-text-btn .badge { position: static; }
.pl-chevron { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; transition: transform .2s; }
.pl-text-btn[aria-expanded="true"] .pl-chevron { transform: rotate(180deg); }
/* Options open: the button turns into a filled "Done" (its badges wait), and Stop steps aside. */
.pl-when-open { display: none; }
.player.is-options-open .pl-when-open { display: inline; }
.player.is-options-open .pl-when-closed, .player.is-options-open .pl-options-btn .badge, .player.is-options-open .pl-stop-btn { display: none; }
.player.is-options-open .pl-options-btn, .player.is-options-open .pl-options-btn:hover { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.player.is-options-open .pl-options-btn:hover { filter: brightness(1.1); }
.pl-stop-btn svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
#pl-reciter { width: 100%; }
.player-options { max-width: 72rem; margin: 0 auto; padding: .5rem 1rem 1rem; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
/* On short screens the options scroll inside the player, so its controls and the top bar stay on screen. */
.player-options { max-height: calc(100vh - 14rem); max-height: calc(100dvh - 14rem); overflow-y: auto; overscroll-behavior: contain; }
.field-row { display: grid; grid-template-columns: 12rem 1fr; align-items: center; gap: .75rem; }
.inline-fields { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inline-fields input { width: 5.5rem; }
.player-error { color: var(--danger); text-align: center; margin: 0; padding: .3rem; font-size: .9rem; }

/* ---------- drawers, dialogs, popovers ---------- */
.drawer {
  position: fixed; top: 0; bottom: 0; z-index: 50; width: min(26rem, 100%); background: var(--bg-elev); box-shadow: var(--shadow);
  display: flex; flex-direction: column; inset-inline-end: 0; border-inline-start: 1px solid var(--line); animation: slide-in .22s var(--ease);
}
.drawer-wide { width: min(38rem, 100%); }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .75rem .6rem 1.2rem; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.1rem; }
.drawer-body { overflow-y: auto; padding: 1rem 1.2rem 2rem; flex: 1; overscroll-behavior: contain; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45; }
.setting { border: 0; padding: 0; margin: 0 0 1.25rem; }
.setting legend, .setting > label { font-weight: 650; font-size: .92rem; margin-bottom: .45rem; display: flex; justify-content: space-between; width: 100%; }
.setting output { color: var(--text-soft); font-weight: 500; }
/* On/off settings: label and explanation on the left, a switch on the right. */
.toggle-group { border: 1px solid var(--line); border-radius: var(--radius); padding: .15rem .9rem .35rem; margin-bottom: .75rem; background: var(--bg-elev); }
.toggle-group-title { margin: .6rem 0 .1rem; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; cursor: pointer; }
.toggle-row-static { cursor: default; }
.toggle-group > .toggle-row + .toggle-row, .toggle-sub > .toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.toggle-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.toggle-label { font-weight: 600; font-size: .93rem; color: var(--text); }
.toggle-hint { font-size: .8rem; line-height: 1.35; color: var(--text-soft); }
.toggle-sub { margin: 0 0 .4rem .2rem; padding-inline-start: .9rem; border-inline-start: 3px solid var(--primary-soft); }
.toggle-note { margin: .2rem 0 .45rem; font-size: .78rem; color: var(--text-faint); }
.toggle-note-box { margin: 0 0 .75rem; padding: .6rem .9rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: .85rem; color: var(--text-soft); }
.segmented-small span { padding: .25rem .75rem; font-size: .85rem; }
input.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; min-height: 0; margin: 0;
  padding: 0; border: 0; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: background .2s;
}
input.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
input.switch:checked { background: var(--primary); }
input.switch:checked::before { transform: translateX(18px); }
input.switch:focus { outline: none; }
input.switch:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
[data-theme="contrast"] input.switch { border: 1px solid #fff; background: #000; }
[data-theme="contrast"] input.switch::before { background: #fff; top: 2px; left: 2px; }
[data-theme="contrast"] input.switch:checked { background: var(--primary); }
[data-theme="contrast"] input.switch:checked::before { background: #000; }
.settings-preview { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem; margin-bottom: 1.25rem; }
.settings-preview .arabic { margin: 0; }
.settings-preview .pv-ip, .s-ip .settings-preview .pv-uthmani { display: none; }
.s-ip .settings-preview .pv-ip { display: block; font-family: var(--font-ip); }
.settings-preview .translit-line { display: none; font: italic var(--tr-size)/1.5 var(--font-tr); color: var(--accent); margin: 0 0 .3rem; }
.s-translit .settings-preview .translit-line { display: block; }
.settings-preview .tr-text { margin-bottom: .3rem; }
.tr-filter { width: 100%; margin: .25rem 0 .35rem; }
.check-group { border-bottom: 1px solid var(--line); }
.check-group > .check { padding-inline-start: .35rem; }
.check-group:last-of-type { margin-bottom: .4rem; }
.check-group-label {
  display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .55rem .1rem; font-size: .9rem; font-weight: 600; color: var(--text);
  list-style: none;
}
.check-group-label::-webkit-details-marker { display: none; }
.check-group-label::after { content: "+"; margin-inline-start: auto; color: var(--text-faint); font-weight: 400; }
.check-group[open] > .check-group-label::after { content: "–"; }
.check-group-count { font-size: .75rem; font-weight: 500; color: var(--text-faint); background: var(--bg-sunk); border-radius: 999px; padding: 0 .45rem; }
.chosen-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; }
.chosen-list li { display: flex; align-items: center; gap: .4rem; background: var(--primary-soft); border-radius: var(--radius-sm); padding: .2rem .3rem .2rem .7rem; font-size: .88rem; }
.chosen-list li span { flex: 1; }
.chosen-list .icon-btn { min-width: 34px; min-height: 34px; }

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); padding: 1.25rem;
  width: min(32rem, calc(100% - 2rem)); box-shadow: var(--shadow); max-height: calc(100vh - 2rem);
}
.dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog h2 { font-size: 1.15rem; }
.dialog form > label, .report-form label { display: grid; gap: .3rem; margin-bottom: .75rem; font-weight: 600; font-size: .92rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.dialog-top { margin-top: 8vh; width: min(40rem, calc(100% - 1.5rem)); padding: 0; overflow: hidden; }
.search-form { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
.search-form > svg { color: var(--text-faint); }
.search-form input { flex: 1; border: 0; background: none; font-size: 1.1rem; min-width: 0; }
.search-form input:focus { outline: none; }
.suggest { max-height: 60vh; overflow-y: auto; padding: .4rem; }
.suggest-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: .6rem .7rem .2rem; }
.suggest a, .suggest button.sg {
  display: flex; gap: .6rem; align-items: baseline; padding: .55rem .7rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
  width: 100%; background: none; border: 0; font: inherit; text-align: start; cursor: pointer;
}
.suggest a[aria-selected="true"], .suggest a:hover { background: var(--primary-soft); }
.suggest .sg-key { flex: none; font-weight: 650; color: var(--primary); font-size: .85rem; }
.suggest .sg-text { color: var(--text-soft); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.suggest .sg-text[dir="rtl"] { font-family: var(--font-ar); font-size: 1.15rem; }
.suggest-empty { padding: 1rem; color: var(--text-soft); text-align: center; }
.jump-grid { display: grid; grid-template-columns: 1fr 6rem; gap: .75rem; }
.jump-grid label, .jump-row label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.jump-grid select { width: 100%; }
.jump-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: .75rem; }
.note-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .5rem; }
.note-list li { background: var(--bg-sunk); border-radius: var(--radius-sm); padding: .6rem .8rem; white-space: pre-wrap; font-size: .92rem; }
.note-list .note-meta { display: flex; justify-content: space-between; align-items: center; color: var(--text-faint); font-size: .78rem; margin-top: .3rem; white-space: normal; }
/* Tall images (long ayahs) shrink to fit the screen; the canvas keeps its shape. */
.share-wrap canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: min(58vh, 640px); margin: 0 auto .75rem; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.share-options { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; }
.share-note { color: var(--text-soft); font-size: .85rem; margin: .5rem 0 0; min-height: 1.3em; }
.share-wrap .dialog-actions { flex-wrap: wrap; }

/* Cookie consent for analytics: a card above the player (and the bottom bar on phones). */
.consent {
  position: fixed; z-index: 65; left: 1rem; bottom: calc(var(--player-h) + 1rem + env(safe-area-inset-bottom));
  width: min(26rem, calc(100% - 2rem)); background: var(--bg-elev); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.consent h2 { font-size: 1rem; margin: 0 0 .35rem; }
.consent p { font-size: .9rem; color: var(--text-soft); margin: 0 0 .8rem; }
.consent-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.consent-actions .btn { flex: 1; }
.segmented input:disabled + span { opacity: .45; cursor: not-allowed; }

.popover {
  position: absolute; z-index: 60; background: var(--bg-elev); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .5rem; min-width: 12rem; max-width: min(22rem, calc(100vw - 1rem));
}
.popover .pop-word { padding: .4rem .6rem; }
.popover .pop-ar { font: 2rem/1.6 var(--font-ar); text-align: center; display: block; }
.popover .pop-ip { font-family: var(--font-ip); line-height: 2; }
.popover .pop-tl { font-style: italic; color: var(--accent); display: block; text-align: center; }
.popover .pop-tr { display: block; text-align: center; font-weight: 600; }
.popover .pop-tu { display: block; text-align: center; font: 1.1rem/2 var(--font-ur); }
.popover .pop-actions { display: flex; justify-content: center; gap: .25rem; border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .3rem; }
.popover menu { list-style: none; margin: 0; padding: 0; display: grid; }
.popover menu button, .popover menu a {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: start; background: none; border: 0; padding: .55rem .7rem; min-height: 40px;
  border-radius: var(--radius-sm); font: inherit; color: var(--text); cursor: pointer; text-decoration: none;
}
.popover menu button:hover, .popover menu a:hover { background: var(--bg-sunk); }
.popover .fn-text { font-size: .92rem; line-height: 1.6; padding: .4rem .6rem; max-height: 50vh; overflow: auto; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 1rem + env(safe-area-inset-bottom)); z-index: 70;
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 999px; font-size: .92rem; box-shadow: var(--shadow);
  display: flex; gap: .75rem; align-items: center; max-width: calc(100% - 2rem);
}
.toast button { background: none; border: 0; color: var(--primary-soft); font-weight: 700; cursor: pointer; }

/* tafsir drawer */
.tafsir-panel-top { position: sticky; top: -1rem; background: var(--bg-elev); padding-top: .25rem; z-index: 1; }
.tafsir-nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.tabs-scroll { margin-bottom: .75rem; }

/* ---------- search page ---------- */
.search-page { max-width: var(--measure); margin: 0 auto; }
.search-page-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.search-page-form input[type="search"], .search-page-form input[name="q"] { flex: 1; min-width: 12rem; }
.advanced { width: 100%; }
.advanced summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .92rem; padding: .3rem 0; }
.advanced-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; margin: .75rem 0; }
.advanced-grid label { display: grid; gap: .25rem; font-size: .85rem; font-weight: 600; min-width: 0; }
.advanced-grid select { width: 100%; min-width: 0; text-overflow: ellipsis; }   /* long translation names stay inside their column */
.jump-cards { display: grid; gap: .5rem; margin-bottom: 1rem; }
.jump-card { padding: .8rem 1rem; border-radius: var(--radius); background: var(--primary-soft); text-decoration: none; color: var(--text); }
.did-you-mean { font-size: 1.05rem; }
.result-count { color: var(--text-soft); font-size: .9rem; }
.results { list-style: none; padding: 0; margin: 0; }
.result { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.result-head { display: flex; justify-content: space-between; align-items: center; }
.result-key { font-weight: 650; text-decoration: none; }
.result-ar { font-size: calc(var(--ar-size) * .8); margin: .3rem 0; }
.result-tr { font: var(--tr-size)/1.7 var(--font-tr); margin: 0; }
.result-tr[lang="ur"] { font: calc(var(--tr-size) * 1.1)/2.2 var(--font-ur); }
.result-tr .tr-name { font: .78rem var(--font-ui); color: var(--text-faint); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1.5rem 0; }

/* ---------- auth / account / my ---------- */
.auth-card { max-width: 26rem; margin: 1rem auto; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: .92rem; }
/* Sign in with Google / Apple: colours follow each company's button guidelines. */
.social-auth { display: grid; gap: .6rem; margin: 1rem 0 .25rem; }
.btn-social { border-radius: 999px; gap: .6rem; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #747775; }
.btn-google:hover { background: #f6f8fa; border-color: #1f1f1f; }
.btn-apple { background: #000; color: #fff; border-color: #000; }
.btn-apple:hover { background: #222; border-color: #222; }
[data-theme="dark"] .btn-apple, [data-theme="contrast"] .btn-apple { background: #fff; color: #000; border-color: #fff; }
@media (prefers-color-scheme: dark) { [data-theme="auto"] .btn-apple { background: #fff; color: #000; border-color: #fff; } }
.social-terms { margin: 0; text-align: center; font-size: .8rem; }
.or-divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; color: var(--text-faint); font-size: .85rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.sign-in-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.sign-in-list form { display: flex; align-items: center; gap: .6rem; margin: 0; }
.my-page { max-width: var(--measure); margin: 0 auto; }
.my-item { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.my-item-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.my-item .arabic { font-size: calc(var(--ar-size) * .75); margin: .2rem 0; }
.my-item .tr-text { font-size: calc(var(--tr-size) * .95); color: var(--text-soft); }
.my-item .note-body { white-space: pre-wrap; background: var(--accent-soft); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: .4rem 0; }
.export-card { margin-top: 2rem; }

/* ---------- admin ---------- */
.admin-nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-bottom: 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.admin-nav a { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--text-soft); font-weight: 600; font-size: .9rem; }
.admin-nav a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.admin-role { margin-inline-start: auto; font-size: .78rem; text-transform: capitalize; background: var(--accent-soft); padding: .2rem .6rem; border-radius: 999px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: .82rem; color: var(--text-soft); }
.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.inline-form { display: inline-flex; gap: .3rem; align-items: center; }
.inline-form input, .inline-form select { min-height: 34px; padding: .2rem .4rem; font-size: .85rem; }
.row-actions { display: flex; gap: .3rem; }
.status { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg-sunk); }
.status-open { background: var(--accent-soft); }
.status-accepted { background: var(--primary-soft); color: var(--primary); }
.dl { display: grid; grid-template-columns: 8rem 1fr; gap: .3rem 1rem; }
.dl dt { color: var(--text-soft); }
.dl dd { margin: 0; }
.pre { white-space: pre-wrap; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-bottom: 1rem; }
.bars span { flex: 1; height: var(--h); min-height: 2px; background: var(--primary); border-radius: 2px 2px 0 0; }
.api-docs code { background: var(--bg-sunk); padding: .1em .35em; border-radius: 4px; }
.api-docs pre { background: var(--bg-sunk); padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; }
.api-docs pre code { background: none; padding: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .topnav { display: none; }
}
@media (max-width: 639px) {
  :root { --topbar-h: 52px; }
  .brand-name, .search-trigger kbd, .signin-link, .topbar-actions [data-open="jump"], .topbar-actions [data-open="settings"] { display: none; }
  .search-trigger { max-width: none; }
  .bottom-nav { display: flex; }
  body { padding-bottom: calc(56px + var(--player-h) + env(safe-area-inset-bottom)); }
  .player { bottom: calc(56px + env(safe-area-inset-bottom)); padding-bottom: 0; }
  .toast { bottom: calc(66px + var(--player-h)); }
  .consent { left: .75rem; width: calc(100% - 1.5rem); bottom: calc(66px + var(--player-h) + env(safe-area-inset-bottom)); }
  .player-time, .player-extra .player-select, .player-extra [data-pl="mute"] { display: none; }
  /* The surah, ayah and reciter get a line of their own, shown in full (wrapping if long), with the
     buttons below; squeezed beside the buttons they were cut to a few letters. */
  .player-inner { flex-wrap: wrap; row-gap: 0; padding: .4rem .5rem .2rem; }
  .player-info { flex: 1 0 100%; flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: .65rem; padding: 0 .25rem; }
  .player-title { font-size: .95rem; }
  .player-sub { font-size: .8rem; }
  .player-extra { margin-inline-start: auto; }
  .pl-text-btn { padding: 0 .6rem; margin-inline-start: .2rem; }
  .pl-chevron { display: none; }
  .sleep-badge span { display: none; }   /* the moon alone; the time left shows in the options */
  .drawer, .drawer-wide { width: 100%; top: auto; height: 88vh; border-radius: 16px 16px 0 0; border: 0; animation-name: sheet-up; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .surah-grid, .unit-grid { grid-template-columns: minmax(0, 1fr); }   /* plain 1fr grows to the card's content on small phones */
  .jump-row { grid-template-columns: repeat(3, 1fr); }
  .verse-actions { opacity: 1; }
  .home-hero-ar { font-size: 2rem; }
  .context-bar { font-size: .74rem; gap: .6rem; }
  .context-bar span + span::before { margin-inline-end: .6rem; }
  .site-footer { padding-bottom: calc(7rem + var(--player-h)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- print (PRD 3.7) ---------- */
@media print {
  .topbar, .bottom-nav, .player, .site-footer, .verse-actions, .load-more, .pager, .surah-hero-actions, .drawer, .dialog, .toast, .flash, .ayah-nav, .tabs, .crumbs, .export-card, .skip-link, .plan-end, .hifz-bar { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  #pjax-body { padding: 0; }
  .verse { break-inside: avoid; border-color: #ccc; }
  .mushaf-page { box-shadow: none; border: 0; break-after: page; }
  a { color: #000; text-decoration: none; }
  .verse.is-playing, .bismillah.is-playing { background: none; box-shadow: none; }
  .is-playing::before { display: none; }
}

/* ---------- topics ---------- */
.lead { color: var(--text-soft); font-size: 1.02rem; max-width: 46rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
.chip {
  display: inline-flex; align-items: baseline; gap: .3rem; padding: .3rem .8rem; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); text-decoration: none; font-size: .88rem; font-weight: 600;
}
.chip small { color: var(--text-soft); font-weight: 500; }
.chip:hover { text-decoration: underline; }

/* A–Z index */
.az { display: flex; flex-wrap: wrap; gap: .15rem; margin: 0 0 1.25rem; position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg); padding: .4rem 0; }
.az a, .az span { min-width: 2rem; text-align: center; padding: .25rem .2rem; border-radius: var(--radius-sm); font-weight: 650; font-size: .92rem; text-decoration: none; }
.az a:hover { background: var(--primary-soft); }
.az span { color: var(--text-faint); }
.topic-letter { scroll-margin-top: calc(var(--topbar-h) + 3.5rem); margin-bottom: 1rem; }
.topic-letter h2 { font-size: 1.1rem; color: var(--primary); border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.topic-list { list-style: none; margin: 0; padding: 0; columns: 3 15rem; column-gap: 2rem; }
.topic-list li { break-inside: avoid; padding: .3rem 0; display: flex; justify-content: space-between; gap: .75rem; border-bottom: 1px dashed var(--line); }
.topic-list a { font-weight: 550; text-decoration: none; }
.topic-list a:hover { text-decoration: underline; }
.topic-count { color: var(--text-faint); font-size: .82rem; white-space: nowrap; }

/* A topic page: as wide as the reader */
.topic-page { max-width: var(--measure); margin: 0 auto; }
.w-narrow .topic-page { --measure: 38rem; }
.w-wide .topic-page { --measure: 60rem; }
.topic-head { margin-bottom: 1rem; }
.topic-head h1 { margin-bottom: .2rem; }
.topic-meta { color: var(--text-soft); margin: 0 0 .75rem; }
.topic-actions { display: flex; gap: .5rem; margin-bottom: .75rem; }
.topic-actions svg { width: 1em; height: 1em; fill: currentColor; stroke: none; vertical-align: -.12em; }
.topic-related { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; }
.topic-related > span { color: var(--text-soft); font-size: .88rem; margin-inline-end: .2rem; }
.topic-toc { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem; margin: 0 0 1rem; background: var(--bg-elev); }
.topic-toc summary { cursor: pointer; font-weight: 650; }
.topic-toc ol { list-style: none; margin: .5rem 0 0; padding: 0; columns: 2 16rem; column-gap: 1.5rem; }
.topic-toc li { break-inside: avoid; display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0; font-size: .92rem; }
.topic-toc .toc-d2 { padding-inline-start: 1rem; }
.topic-toc .toc-d3 { padding-inline-start: 2rem; }
.topic-section { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.topic-sub { margin: 1.75rem 0 .25rem; padding-bottom: .35rem; border-bottom: 2px solid var(--primary-soft); }
.topic-sub::first-letter { text-transform: uppercase; }
h2.topic-sub { font-size: 1.15rem; }
h3.topic-sub { font-size: 1.02rem; }
h4.topic-sub { font-size: .95rem; }
.topic-sub small { color: var(--text-soft); font-weight: 500; }
.topic-continued { color: var(--text-soft); font-weight: 600; margin: 1rem 0 0; }
.topic-see, .topic-also { color: var(--text-soft); font-size: .92rem; margin: .5rem 0; }
.topic-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: 1.5rem 0; }
.topic-pager-n { color: var(--text-soft); font-size: .9rem; }

/* Topics on an ayah page, in the verse menu, in search and on the home page */
.ayah-topics { margin: 1rem 0; padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
.ayah-topics h2 { font-size: 1rem; margin-bottom: .4rem; }
.ayah-topics ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.ayah-topic { font-weight: 650; }
.ayah-topic-subs { color: var(--text-soft); font-size: .92rem; margin-inline-start: .4rem; }
.ayah-topic-subs::before { content: "— "; }
.pop-topics { padding: .75rem .9rem; max-width: min(22rem, 90vw); }
.pop-topics .pop-title { font-weight: 650; margin: 0 0 .4rem; }
.pop-topics ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.pop-topics li a:first-child { font-weight: 650; }
.pop-topics li span { display: block; font-size: .85rem; color: var(--text-soft); }
.pop-topics .pop-more { margin: .6rem 0 0; font-size: .88rem; }
.topic-hits { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; margin: 0 0 1rem; }
.topic-hits-label { color: var(--text-soft); font-size: .88rem; font-weight: 600; margin-inline-end: .2rem; }
.suggest .sg-count { color: var(--text-faint); font-size: .82rem; white-space: nowrap; margin-inline-start: auto; }

@media (max-width: 639px) {
  .topic-list { columns: 1; }
  .topic-toc ol { columns: 1; }
  .az a, .az span { min-width: 1.6rem; }
}
