/* ==========================================================================
   Islamic Pocket Book — design system v2
   Layout: desktop (≥1024px) sidebar + content + optional aside; mobile: top bar + bottom tabs.
   ========================================================================== */
@font-face { font-family: 'Inter'; src: url('../fonts/inter-latin-wght.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../fonts/amiri-arabic-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Naskh Arabic'; src: url('../fonts/noto-naskh-arabic-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Naskh Arabic'; src: url('../fonts/noto-naskh-arabic-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Noto Nastaliq Urdu'; src: url('../fonts/noto-nastaliq-urdu-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Nastaliq Urdu'; src: url('../fonts/noto-nastaliq-urdu-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --teal: #0d7377; --teal-600: #0a5c5f; --teal-400: #14a3a8; --teal-300: #3fc4c8; --teal-soft: #e3f3f3; --teal-glow: rgba(20,163,168,.35);
  --gold: #c9a227; --gold-300: #e8c96a; --gold-soft: #fbf3d6;
  --ink: #0f1a1b;
  --bg: #f3f6f6; --bg-2: #e9efef; --surface: rgba(255,255,255,.86); --surface-solid: #ffffff; --surface-2: #eef3f3;
  --text: #172223; --muted: #5d6f71; --border: rgba(13,115,119,.12); --border-strong: #cfdcdc;
  --shadow-sm: 0 1px 2px rgba(15,26,27,.06), 0 2px 8px rgba(15,26,27,.05);
  --shadow: 0 4px 16px rgba(15,26,27,.08), 0 12px 32px rgba(13,115,119,.08);
  --shadow-lg: 0 20px 60px rgba(13,115,119,.22);
  --radius: 18px; --radius-sm: 12px;
  --font-latin: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-ar: 'Amiri', 'Noto Naskh Arabic', 'Scheherazade New', serif;
  --font-ur: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Noto Naskh Arabic', serif;
  --ar-size: 1.45rem; --ur-size: 1.1rem; --en-size: 1rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --side-w: 264px; --header-h: 64px;
  --ease: cubic-bezier(.2,.7,.2,1);
}
html[data-theme="dark"] { --bg: #0b1213; --bg-2: #0f1a1b; --surface: rgba(24,33,34,.82); --surface-solid: #182122; --surface-2: #1f2b2c; --text: #e7eeee; --muted: #9db0b1; --border: rgba(63,196,200,.14); --border-strong: #2b3b3c; --teal-soft: #113a3c; --gold-soft: #3b3113; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 6px 24px rgba(0,0,0,.45); --shadow-lg: 0 24px 70px rgba(0,0,0,.6); }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] { --bg: #0b1213; --bg-2: #0f1a1b; --surface: rgba(24,33,34,.82); --surface-solid: #182122; --surface-2: #1f2b2c; --text: #e7eeee; --muted: #9db0b1; --border: rgba(63,196,200,.14); --border-strong: #2b3b3c; --teal-soft: #113a3c; --gold-soft: #3b3113; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 6px 24px rgba(0,0,0,.45); --shadow-lg: 0 24px 70px rgba(0,0,0,.6); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-latin); font-size: 16px; line-height: 1.55; min-height: 100vh; overflow-x: hidden; }
html[lang="ur"] body { font-family: var(--font-ur), var(--font-latin); }
html[lang="ur"] { direction: rtl; } html[lang="en"] { direction: ltr; }
a { color: var(--teal); text-decoration: none; } a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
::selection { background: var(--teal-300); color: #06282a; }
/* inline icons (IPB.icon) have no intrinsic size: give every unsized svg a sane 1em default; specific containers override below */
:where(svg:not([width])) { width: 1em; height: 1em; fill: currentColor; flex: none; vertical-align: -.15em; }
:focus-visible { outline: 2px solid var(--teal-400); outline-offset: 2px; border-radius: 6px; }
.search-box input:focus-visible { outline: 0; }

.ar { font-family: var(--font-ar); font-size: var(--ar-size); line-height: 2.05; direction: rtl; text-align: right; unicode-bidi: plaintext; }
.ur { font-family: var(--font-ur); font-size: var(--ur-size); line-height: 2.15; direction: rtl; text-align: right; unicode-bidi: plaintext; }
.en { font-family: var(--font-latin); font-size: var(--en-size); direction: ltr; text-align: left; }
html[lang="ur"] .ui-text { font-family: var(--font-ur); }
mark { background: linear-gradient(transparent 40%, rgba(232,201,106,.65) 40%); color: inherit; border-radius: 3px; padding: 0 2px; }
html[data-theme="dark"] mark { background: linear-gradient(transparent 40%, rgba(201,162,39,.45) 40%); }

/* ---------- fixed animated background ---------- */
#bgLayer { position: fixed; inset: -10% 0 -10% 0; z-index: -1; pointer-events: none; overflow: hidden; will-change: transform; }
#bgLayer .pattern { position: absolute; inset: 0; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%230d7377' stroke-opacity='.10' stroke-width='1'%3E%3Cpath d='M60 0l17.3 30H42.7zM60 120l17.3-30H42.7zM0 60l30-17.3v34.6zM120 60L90 42.7v34.6z'/%3E%3Cpath d='M60 18l36.4 21v42L60 102 23.6 81V39z'/%3E%3Ccircle cx='60' cy='60' r='14'/%3E%3Ccircle cx='60' cy='60' r='42'/%3E%3C/g%3E%3C/svg%3E"); }
#bgLayer .glow { position: absolute; width: 60vw; height: 60vw; border-radius: 50%; filter: blur(90px); opacity: .35; }
#bgLayer .glow.a { top: -20vw; inset-inline-end: -15vw; background: radial-gradient(circle, var(--teal-300), transparent 70%); }
#bgLayer .glow.b { bottom: -25vw; inset-inline-start: -20vw; background: radial-gradient(circle, var(--gold-300), transparent 70%); opacity: .25; }
#bgLayer canvas { position: absolute; top: 0; left: 0; width: 100%; height: 42vh; opacity: .07; filter: grayscale(1) contrast(1.2); mask-image: linear-gradient(#000 40%, transparent); -webkit-mask-image: linear-gradient(#000 40%, transparent); }
html[data-theme="dark"] #bgLayer canvas { opacity: .12; }
html[data-theme="dark"] #bgLayer .pattern { opacity: .35; }

/* ---------- app frame ---------- */
.app { min-height: 100vh; }
.app-header { position: sticky; top: 0; z-index: 30; height: var(--header-h); display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
@supports not (background: color-mix(in srgb, red, blue)) { .app-header, .mobile-search, .topic-nav { background: var(--surface); } }
.header-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; width: 100%; max-width: 1400px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.02rem; min-width: 0; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 4px 12px var(--teal-glow); }
.brand .sub { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); line-height: 1.2; }
.brand .txt { display: flex; flex-direction: column; }
.header-search { flex: 1; display: flex; justify-content: center; min-width: 0; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { background: var(--surface-2); color: var(--text); border: 1px solid transparent; border-radius: 12px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; flex: none; transition: background .2s, transform .2s var(--ease), border-color .2s; position: relative; overflow: hidden; }
.icon-btn:hover { background: var(--teal-soft); border-color: var(--border); transform: translateY(-1px); }
.icon-btn.text { width: auto; padding: 0 12px; font-size: .85rem; font-weight: 700; }
.icon-btn svg { width: 21px; height: 21px; fill: currentColor; }

.search-box { display: flex; align-items: center; width: 100%; max-width: 640px; background: var(--surface-solid); border-radius: 999px; border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); transition: box-shadow .25s, border-color .25s, transform .25s var(--ease); overflow: hidden; }
.search-box:focus-within { border-color: var(--teal-400); box-shadow: 0 0 0 4px var(--teal-glow), var(--shadow); transform: translateY(-1px); }
.search-box input { flex: 1; border: 0; outline: 0; padding: 11px 16px; font-size: 1rem; background: transparent; color: var(--text); font-family: var(--font-latin), var(--font-ur); min-width: 0; }
html[lang="ur"] .search-box input { font-family: var(--font-ur), var(--font-latin); }
.search-box input::placeholder { color: var(--muted); opacity: .8; }
.search-box button { border: 0; background: var(--teal); color: #fff; width: 42px; height: 42px; margin: 2px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; transition: background .2s, transform .2s; flex: none; }
.search-box button:hover { background: var(--teal-600); transform: scale(1.05); }
.search-box button svg { width: 20px; height: 20px; fill: currentColor; }
.search-box .kbd-hint { font-size: .7rem; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; margin-inline-end: 6px; font-family: ui-monospace, monospace; }
@media (max-width: 767px) { .search-box .kbd-hint { display: none; } }

/* mobile: search bar below header */
.mobile-search { display: none; padding: 8px 12px 10px; }
.search-hint { font-size: .75rem; color: var(--muted); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.search-hint .chip { background: var(--surface-2); border: 0; border-radius: 999px; padding: 4px 12px; font-size: .78rem; cursor: pointer; transition: background .2s, transform .2s; position: relative; overflow: hidden; }
.search-hint .chip:hover { background: var(--teal-soft); transform: translateY(-1px); }
/* base chip (reference pills, filters inherit + override) */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .82rem; font-weight: 600; line-height: 1.5; text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s, transform .2s var(--ease); }
.chip:hover { background: var(--teal-soft); border-color: var(--teal-400); color: var(--teal); text-decoration: none; transform: translateY(-1px); }
.chip svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
.chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }

.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1400px; margin: 0 auto; gap: 0; }
.side-nav { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); padding: 18px 14px; border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: .95rem; position: relative; overflow: hidden; transition: background .2s, color .2s, transform .25s var(--ease); }
.side-nav a svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; transform: translateX(3px); }
html[dir="rtl"] .side-nav a:hover { transform: translateX(-3px); }
.side-nav a.active { background: linear-gradient(135deg, var(--teal), var(--teal-400)); color: #fff; box-shadow: 0 8px 20px var(--teal-glow); }
.side-nav .sep { height: 1px; background: var(--border); margin: 10px 6px; }
.side-nav .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 6px 14px 2px; font-family: var(--font-latin); }
.side-nav .foot { margin-top: auto; font-size: .72rem; color: var(--muted); padding: 10px 14px; line-height: 1.5; }
.side-nav .status-line { margin: 6px 6px 0; }
main { padding: 22px clamp(14px, 3vw, 40px) calc(40px + var(--safe-bottom)); min-width: 0; }
.content { max-width: 960px; margin: 0 auto; }
.tabbar { display: none; }

@media (max-width: 1023px) {
  .layout { grid-template-columns: 1fr; }
  .side-nav { display: none; }
  .header-search { display: none; }
  .mobile-search { display: block; position: sticky; top: var(--header-h); z-index: 29; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
  main { padding: 16px 14px calc(96px + var(--safe-bottom)); }
  .tabbar { position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 30; display: flex; justify-content: space-around; padding: 6px; margin-bottom: var(--safe-bottom);
    background: var(--surface); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: .66rem; font-weight: 600; padding: 7px 2px; border-radius: 16px; position: relative; overflow: hidden; transition: color .2s, background .25s, transform .25s var(--ease); }
  .tabbar a svg { width: 23px; height: 23px; fill: currentColor; transition: transform .3s var(--ease); }
  .tabbar a.active { color: var(--teal); background: var(--teal-soft); }
  .tabbar a.active svg { transform: translateY(-2px) scale(1.1); }
  .tabbar a:hover { text-decoration: none; }
  .brand .sub { display: none; }
}
@media (max-width: 480px) { .brand .txt > span:first-child { font-size: .95rem; } .header-actions .icon-btn.text { padding: 0 9px; } }

/* ---------- page transition & reveals ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
main.page-in > .content { animation: pageIn .45s var(--ease) both; }
.reveal { opacity: 0; transform: translateY(22px) scale(.985); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } main.page-in > .content { animation: none; } * { scroll-behavior: auto !important; } }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .18; transform: scale(0); animation: ripple .6s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- cards ---------- */
.card { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; margin-bottom: 14px; border: 1px solid var(--border); transition: box-shadow .3s, transform .3s var(--ease), border-color .3s; position: relative; }
.card:hover { box-shadow: var(--shadow); border-color: rgba(13,115,119,.22); }
.card h2, .card h3 { margin: 0 0 8px; }
.card-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-title .icon { font-size: 1.5rem; }
h1.page-title { font-size: clamp(1.4rem, 2.4vw, 1.9rem); margin: 4px 0 16px; color: var(--text); letter-spacing: -.02em; font-weight: 800; }
h1.page-title::after { content: ''; display: block; width: 56px; height: 4px; border-radius: 2px; margin-top: 8px; background: linear-gradient(90deg, var(--teal), var(--gold)); }
h2.section-title { font-size: 1.05rem; color: var(--text); margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
h2.section-title::before { content: ''; width: 6px; height: 22px; border-radius: 3px; background: linear-gradient(var(--teal), var(--teal-400)); flex: none; }
h2.section-title .count { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }
.muted { color: var(--muted); font-size: .9rem; } .small { font-size: .82rem; }
.badge { display: inline-flex; align-items: center; font-size: .72rem; padding: 3px 10px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-weight: 700; font-family: var(--font-latin); direction: ltr; letter-spacing: .01em; }
.badge.gold { background: var(--gold-soft); color: #8a6d0b; } .badge.gray { background: var(--surface-2); color: var(--muted); } .badge.red { background: #fde3e3; color: #a12626; }
html[data-theme="dark"] .badge.gold { color: #f0d77a; } html[data-theme="dark"] .badge.red { background: #4a1c1c; color: #f3a4a4; }

.ref-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.ref-line a { font-weight: 700; }
.verse-text, .hadith-text { margin: 10px 0; }
.verse-text .ar, .hadith-text .ar { padding: 6px 0; }
.hadith-text .ar { font-size: calc(var(--ar-size) * .88); line-height: 1.9; }
.verse-text > div + div, .hadith-text > div + div { border-top: 1px dashed var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.btn { border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); padding: 7px 13px; border-radius: 11px; font-size: .84rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; transition: background .2s, transform .2s var(--ease), box-shadow .2s, border-color .2s; position: relative; overflow: hidden; }
.btn:hover { background: var(--teal-soft); border-color: var(--teal-400); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--teal), var(--teal-400)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px var(--teal-glow); }
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 10px 24px var(--teal-glow); }
.btn.gold { background: linear-gradient(135deg, #b8901c, var(--gold-300)); color: #2b230a; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn.bookmarked { color: #a97f0c; border-color: var(--gold); background: var(--gold-soft); }
.btn.small { padding: 5px 9px; font-size: .78rem; }
.note { background: var(--teal-soft); border-inline-start: 4px solid var(--teal); padding: 10px 14px; border-radius: 10px; margin: 8px 0; font-size: .95rem; }

/* ---------- HERO (home) ---------- */
.hero { position: relative; border-radius: 26px; overflow: hidden; min-height: 420px; margin-bottom: 22px; color: #fff; isolation: isolate; box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.08); }
.hero-media { position: absolute; inset: 0; z-index: -2; background: #061f21; transform-origin: center; }
.hero-media canvas.flag { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .8; display: block; }
.hero-media canvas.flag.failed { display: none; }
/* CSS-animated fallback (no canvas / image draw failed): the flag image itself waves with a skew + drift animation */
.hero-media .flag-img { display: none; position: absolute; inset: -6% -4%; width: 108%; height: 112%; object-fit: cover; opacity: .8; transform-origin: left center; }
.hero-media.flag-fallback .flag-img { display: block; animation: flag-wave 6s ease-in-out infinite; }
@keyframes flag-wave { 0%, 100% { transform: skewY(-1.5deg) translateX(0) scale(1.02); } 25% { transform: skewY(1.2deg) translateX(-1.5%) scale(1.04); } 50% { transform: skewY(-0.8deg) translateX(0.5%) scale(1.02); } 75% { transform: skewY(1.6deg) translateX(-1%) scale(1.05); } }
.hero-media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(4,40,42,.94) 0%, rgba(6,60,63,.78) 42%, rgba(6,60,63,.18) 100%); }
html[dir="rtl"] .hero-media::after { background: linear-gradient(-100deg, rgba(4,40,42,.94) 0%, rgba(6,60,63,.78) 42%, rgba(6,60,63,.18) 100%); }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 420px; }
.hero-inner { padding: clamp(24px, 4vw, 52px); display: flex; flex-direction: column; justify-content: center; gap: 14px; position: relative; z-index: 1; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-300); font-family: var(--font-latin); font-weight: 700; }
.hero-kicker::before { content: ''; width: 28px; height: 2px; background: var(--gold-300); }
.hero-title { margin: 0; font-size: clamp(1.7rem, 3.6vw, 2.9rem); line-height: 1.15; font-weight: 800; letter-spacing: -.02em; text-shadow: 0 4px 30px rgba(0,0,0,.35); }
html[lang="ur"] .hero-title { line-height: 1.7; }
.hero-title .ar-line { display: block; font-family: var(--font-ar); font-size: 1.15em; color: var(--gold-300); margin-bottom: 4px; }
.hero-sub { margin: 0; font-size: 1.02rem; opacity: .92; max-width: 48ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.hero-actions .btn { padding: 11px 18px; font-size: .92rem; border-radius: 14px; }
.hero-actions .btn.glass { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); backdrop-filter: blur(8px); }
.hero-actions .btn.glass:hover { background: rgba(255,255,255,.22); }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hero-badge { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 4px 12px; font-size: .78rem; backdrop-filter: blur(6px); }
.hero-badge b { color: var(--gold-300); font-family: var(--font-latin); }
.hero-visual { position: relative; perspective: 1200px; min-height: 300px; }
.portrait-wrap { position: absolute; will-change: transform; }
.portrait { position: relative; width: 100%; height: 100%; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.15); background: #0b1213; transform-style: preserve-3d; transition: transform .35s var(--ease); will-change: transform; }
.portrait::before { content: ''; position: absolute; inset: 0; padding: 3px; border-radius: inherit; background: linear-gradient(140deg, var(--gold-300), transparent 40%, transparent 60%, var(--gold)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; z-index: 2; pointer-events: none; }
.portrait::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at var(--gx, 30%) var(--gy, 20%), rgba(255,255,255,.22), transparent 55%); z-index: 1; pointer-events: none; }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.portrait .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; font-size: .74rem; line-height: 1.35; background: linear-gradient(transparent, rgba(0,0,0,.85)); z-index: 3; text-align: center; }
.portrait .cap b { display: block; font-size: .82rem; color: var(--gold-300); }
.portrait-wrap.p1 { width: 40%; aspect-ratio: 3/4; inset-inline-end: 44%; top: 12%; z-index: 2; }
.portrait-wrap.p2 { width: 46%; aspect-ratio: 3/4; inset-inline-end: 6%; top: 22%; z-index: 3; }
.hero-visual .orb { position: absolute; border-radius: 50%; filter: blur(30px); opacity: .5; }
.hero-visual .orb.a { width: 200px; height: 200px; background: var(--teal-300); top: -30px; inset-inline-end: 20%; }
.hero-visual .orb.b { width: 160px; height: 160px; background: var(--gold); bottom: 0; inset-inline-end: 55%; opacity: .35; }
@media (max-width: 860px) {
  .hero { min-height: 0; }
  .hero-grid { grid-template-columns: 1fr; min-height: 0; }
  .hero-media { background: #050909; }
  .hero-visual { min-height: calc(180px + 60vw); order: -1; }
  .hero-inner { padding-top: 0; }
  .portrait-wrap.p1 { width: 38%; inset-inline-start: 8%; inset-inline-end: auto; top: 150px; }
  .portrait-wrap.p2 { width: 44%; inset-inline-end: 6%; top: 168px; }
  .hero-media::after { background: linear-gradient(180deg, rgba(4,40,42,0) 0%, rgba(4,40,42,.12) 24%, rgba(4,40,42,.82) 40%, rgba(4,40,42,.97) 100%); }
  html[dir="rtl"] .hero-media::after { background: linear-gradient(180deg, rgba(4,40,42,0) 0%, rgba(4,40,42,.12) 24%, rgba(4,40,42,.82) 40%, rgba(4,40,42,.97) 100%); }
  .hero-media canvas.flag, .hero-media .flag-img { opacity: 1; }
  .hero-media .flag-img { inset: 0 auto auto 0; width: 100%; height: auto; object-fit: contain; }
  .hero-visual .orb { opacity: .22; }
}

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0 0 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; inset-inline-end: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; background: var(--teal-soft); opacity: .7; }
.stat .n { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; color: var(--teal); font-family: var(--font-latin); position: relative; }
.stat .l { font-size: .8rem; color: var(--muted); position: relative; }

/* ---------- tiles / grids ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform .35s var(--ease), box-shadow .35s, border-color .3s; transform-style: preserve-3d; }
.tile::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(63,196,200,.18), transparent 55%); opacity: 0; transition: opacity .3s; pointer-events: none; }
.tile:hover { transform: translateY(-4px); border-color: var(--teal-400); box-shadow: var(--shadow); text-decoration: none; }
.tile:hover::after { opacity: 1; }
.tile .icon { font-size: 1.7rem; width: 48px; height: 48px; border-radius: 14px; background: var(--teal-soft); display: flex; align-items: center; justify-content: center; transition: transform .35s var(--ease); }
.tile:hover .icon { transform: scale(1.08) rotate(-4deg); }
.tile .t { font-weight: 700; } .tile .d { font-size: .8rem; color: var(--muted); }
.tile > span:not(.icon) { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.tile .t, .tile .d { display: block; overflow-wrap: anywhere; word-break: break-word; }
html[lang="ur"] .tile .t { line-height: 1.9; } html[lang="ur"] .tile .d { line-height: 1.8; }
.tile.accent { background: linear-gradient(135deg, var(--teal), var(--teal-400)); color: #fff; border-color: transparent; }
.tile.accent .d { color: rgba(255,255,255,.8); } .tile.accent .icon { background: rgba(255,255,255,.18); }
.topic-list .tile { flex-direction: row; align-items: center; gap: 14px; }
.topic-list .tile .icon { flex: none; }
.topic-list .tile > span:not(.icon) { flex: 1 1 auto; }
@media (max-width: 600px) { .topic-list { grid-template-columns: 1fr; } .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; } .tile { padding: 14px 12px; } }
.status-line { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin: 6px 0 12px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #d9a400; display: inline-block; box-shadow: 0 0 0 3px rgba(217,164,0,.2); animation: pulse 1.6s infinite; }
.dot.ok { background: #29a36a; box-shadow: 0 0 0 3px rgba(41,163,106,.2); animation: none; } .dot.err { background: #d33; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(217,164,0,.05); } }
.progress { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; flex: 1; min-width: 80px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-300)); transition: width .4s var(--ease); }
.status-box { margin: 6px 0 14px; } .status-box .status-line { margin: 0 0 6px; }
.status-books { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.status-books .bk { font-size: .7rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.status-books .bk.loading { color: var(--teal); border-color: var(--teal-400); background: var(--teal-soft); animation: pulse-bg 1.2s infinite; }
.status-books .bk.ready { color: #1f7a4f; background: rgba(41,163,106,.14); border-color: transparent; }
.status-books .bk.error { color: #a12626; background: #fde3e3; border-color: transparent; }
html[data-theme="dark"] .status-books .bk.ready { color: #7fe0b0; } html[data-theme="dark"] .status-books .bk.error { background: #4a1c1c; color: #f3a4a4; }
@keyframes pulse-bg { 50% { opacity: .55; } }
.side-nav .status-box { padding: 0 6px; } .side-nav .status-note { display: none; }

/* ---------- topics ---------- */
.topic-header { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.topic-header .icon { font-size: 2.2rem; line-height: 1; width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--teal-soft), var(--gold-soft)); display: flex; align-items: center; justify-content: center; flex: none; }
.topic-header h1 { margin: 0; font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 800; letter-spacing: -.01em; }
.topic-header p { margin: 4px 0 0; color: var(--muted); }
.topic-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; position: sticky; top: calc(var(--header-h) + 6px); z-index: 5; padding: 8px; border-radius: 14px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); }
@media (max-width: 1023px) { .topic-nav { top: calc(var(--header-h) + 70px); } }
.topic-nav a { font-size: .8rem; padding: 5px 12px; border-radius: 999px; background: var(--surface-solid); border: 1px solid var(--border-strong); color: var(--text); font-weight: 600; transition: background .2s, color .2s; }
.topic-nav a:hover { background: var(--teal); color: #fff; border-color: var(--teal); text-decoration: none; }
.summary { font-size: 1.04rem; } .summary p:first-child { margin-top: 0; } .summary p:last-child { margin-bottom: 0; }
.point-list { padding-inline-start: 1.3em; margin: 6px 0; } .point-list li { margin: 10px 0; padding-inline-start: 4px; } .point-list li::marker { color: var(--teal); font-weight: 800; }
.qa { border: 1px solid var(--border); border-radius: 14px; margin: 10px 0; overflow: hidden; background: var(--surface); transition: box-shadow .3s; }
.qa[open] { box-shadow: var(--shadow); }
.qa summary { padding: 12px 16px; cursor: pointer; font-weight: 700; background: var(--surface-2); list-style: none; display: flex; gap: 10px; align-items: center; transition: background .2s; }
.qa summary::before { content: '?'; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-latin); font-size: .9rem; }
.qa summary::-webkit-details-marker { display: none; }
.qa summary:hover { background: var(--teal-soft); }
.qa .a { padding: 12px 16px; animation: pageIn .35s var(--ease); } .qa .a p:first-child { margin-top: 0; } .qa .a p:last-child { margin-bottom: 0; }
.other-ref { border-inline-start: 3px solid var(--gold); padding: 8px 14px; margin: 10px 0; background: var(--surface-2); border-radius: 10px; }
.other-ref .src { font-size: .8rem; color: #8a6d0b; font-weight: 700; } html[data-theme="dark"] .other-ref .src { color: var(--gold-300); }
.other-ref p:first-child { margin-top: 4px; } .other-ref p:last-child { margin-bottom: 0; }
.pocket-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.pocket-item:last-child { border-bottom: 0; }
.pocket-item .pg { flex: none; background: linear-gradient(135deg, #b8901c, var(--gold-300)); color: #2b230a; font-weight: 800; border-radius: 10px; padding: 5px 11px; font-family: var(--font-latin); direction: ltr; font-size: .82rem; min-width: 64px; text-align: center; }
.link-list a { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); transition: padding .2s; }
.link-list a:hover { padding-inline-start: 6px; text-decoration: none; }
.link-list a:last-child { border-bottom: 0; }
.link-list svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
/* scholars' positions */
.scholar .who { font-weight: 800; color: var(--teal); margin-bottom: 8px; font-size: 1rem; }
.scholar .view, .scholar .reply { padding: 10px 14px; border-radius: 12px; margin: 8px 0; position: relative; }
.scholar .view { background: var(--surface-2); border-inline-start: 4px solid var(--muted); }
.scholar .reply { background: var(--teal-soft); border-inline-start: 4px solid var(--teal); }
.scholar .lbl { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; font-family: var(--font-latin); }
html[lang="ur"] .scholar .lbl { font-family: var(--font-ur); text-transform: none; letter-spacing: 0; font-size: .82rem; }
.scholar .reply .lbl { color: var(--teal); }
.scholar p:first-of-type { margin-top: 0; } .scholar p:last-child { margin-bottom: 0; }
/* askahmadiyyat.org article lists */
/* answer card (question intents) */
.answer-card { border: 1px solid var(--border-strong); background: linear-gradient(180deg, var(--teal-soft), var(--surface-solid) 46%); box-shadow: var(--shadow); padding: 20px 22px; overflow: hidden; }
.answer-card::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(var(--teal), var(--gold)); }
.answer-q { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.answer-q .qi { flex: none; width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, var(--teal), var(--teal-400)); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px var(--teal-glow); }
.answer-q .qi svg { width: 22px; height: 22px; fill: currentColor; }
.answer-q .qt { flex: 1; min-width: 0; font-weight: 800; font-size: 1.12rem; line-height: 1.4; color: var(--teal); overflow-wrap: anywhere; }
.answer-q .kicker { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-family: var(--font-latin); margin-bottom: 2px; }
html[lang="ur"] .answer-q .qt { line-height: 1.9; font-size: 1.15rem; }
html[lang="ur"] .answer-q .kicker { font-family: var(--font-ur); letter-spacing: 0; text-transform: none; font-size: .8rem; }
.answer-a { font-size: 1.04rem; line-height: 1.85; } .answer-a p:first-child { margin-top: 0; } .answer-a p:last-child { margin-bottom: 0; }
html[lang="ur"] .answer-a { line-height: 2.15; font-size: 1.06rem; }
.answer-refs { margin: 14px 0 6px; padding-top: 12px; border-top: 1px dashed var(--border); }
.answer-refs .lbl { font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-family: var(--font-latin); margin-bottom: 8px; }
html[lang="ur"] .answer-refs .lbl { font-family: var(--font-ur); letter-spacing: 0; text-transform: none; font-size: .84rem; }
.answer-refs .chip { background: var(--surface-solid); font-family: var(--font-latin); direction: ltr; }
html[lang="ur"] .answer-refs .chip { font-family: var(--font-ur), var(--font-latin); direction: rtl; }
.answer-refs .chip.ghost { background: transparent; border-style: dashed; cursor: default; }
.answer-refs .chip.ghost:hover { transform: none; color: var(--text); border-color: var(--border); }
.answer-verses:not(:empty) { margin-top: 12px; }
.answer-verses .verse-card { margin: 8px 0 0; }
.verse-card.compact { padding: 12px 14px; box-shadow: none; background: var(--surface-solid); }
.verse-card.compact .ar { font-size: calc(var(--ar-size) * .88); line-height: 1.9; }
.verse-card.compact .ur { font-size: calc(var(--ur-size) * .95); }
.verse-card.compact .en { font-size: calc(var(--en-size) * .95); }
.verse-card.compact .actions .btn { padding: 4px 9px; font-size: .76rem; }
.answer-card > .actions { margin-top: 14px; }
.related-q { padding: 12px 16px; }
.related-q .lbl { font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-family: var(--font-latin); margin-bottom: 4px; }
html[lang="ur"] .related-q .lbl { font-family: var(--font-ur); letter-spacing: 0; text-transform: none; font-size: .84rem; }
.related-q .q-link { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-weight: 600; color: var(--text); border-top: 1px dashed var(--border); transition: color .2s, padding .2s; }
.related-q .q-link:first-of-type { border-top: 0; }
.related-q .q-link svg { width: 16px; height: 16px; fill: var(--muted); flex: none; }
.related-q .q-link:hover { color: var(--teal); text-decoration: none; padding-inline-start: 4px; }
.related-q .q-link:hover svg { fill: var(--teal); }
html[lang="ur"] .related-q .q-link { line-height: 1.9; }
@media (max-width: 600px) { .answer-card { padding: 16px 16px 16px 18px; } .answer-q .qi { width: 36px; height: 36px; border-radius: 11px; } .answer-q .qt { font-size: 1.04rem; } }
.qa .a .chip { font-size: .8rem; background: var(--surface-solid); font-family: var(--font-latin); direction: ltr; }
html[lang="ur"] .qa .a .chip { font-family: var(--font-ur), var(--font-latin); direction: rtl; }
.ask-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin: 10px 0 16px; }
.ask-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(135deg, var(--teal-soft), var(--gold-soft)); border-bottom: 1px solid var(--border); }
.ask-logo { font-family: var(--font-ur); font-size: 1.05rem; font-weight: 700; color: var(--teal); background: var(--surface-solid); border-radius: 10px; padding: 4px 12px; line-height: 1.8; white-space: nowrap; }
.ask-title { font-size: .85rem; color: var(--muted); font-weight: 600; }
.ask-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px dashed var(--border); color: var(--text); text-decoration: none; direction: rtl; text-align: right; transition: background .2s; }
.ask-item:last-child { border-bottom: 0; }
.ask-item:hover { background: var(--teal-soft); text-decoration: none; }
.ask-item .ur-title { font-family: var(--font-ur); font-size: 1rem; line-height: 2; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ask-item .meta { display: flex; align-items: center; gap: 6px; flex: none; }
.ask-item .meta svg { width: 14px; height: 14px; fill: var(--muted); }
@media (max-width: 600px) { .ask-item { flex-direction: column; align-items: flex-end; gap: 6px; } .ask-item .meta { flex-wrap: wrap; justify-content: flex-end; } }
.chip .count { font-size: .7rem; opacity: .7; }
.loading-ref { color: var(--muted); font-style: italic; font-size: .9rem; padding: 6px 0; }
.topic-ref { margin-bottom: 6px; }

/* ---------- quran / hadith browsing ---------- */
.surah-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.surah-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; color: var(--text); transition: transform .3s var(--ease), border-color .2s, box-shadow .3s; }
.surah-item:hover { border-color: var(--teal-400); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.surah-item .num { flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); font-weight: 800; display: flex; align-items: center; justify-content: center; font-family: var(--font-latin); direction: ltr; clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.surah-item .names { flex: 1; min-width: 0; } .surah-item .names .n1 { font-weight: 700; } .surah-item .names .n2 { font-size: .76rem; color: var(--muted); }
.surah-item .arname { font-family: var(--font-ar); font-size: 1.35rem; color: var(--teal); }
.verse-row { padding: 14px 0; border-bottom: 1px solid var(--border); transition: background .3s; }
.verse-row:last-child { border-bottom: 0; }
.verse-row.target { background: linear-gradient(90deg, var(--gold-soft), transparent); margin: 0 -20px; padding: 14px 20px; border-inline-start: 4px solid var(--gold); }
.verse-num { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-weight: 800; font-family: var(--font-latin); direction: ltr; font-size: .84rem; padding: 0 7px; border: 1px solid rgba(13,115,119,.2); }
.verse-num .std { font-weight: 500; font-size: .68rem; opacity: .75; margin-inline-start: 3px; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin: 16px 0; }
.jump { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.jump input, .jump select, .field select, .field input { border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; transition: border-color .2s, box-shadow .2s; }
.jump input:focus, .jump select:focus { outline: 0; border-color: var(--teal-400); box-shadow: 0 0 0 3px var(--teal-glow); }
.jump input { width: 90px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.filter-row .chip { border: 1px solid var(--border-strong); background: var(--surface-solid); border-radius: 999px; padding: 6px 14px; font-size: .82rem; color: var(--text); font-weight: 600; position: relative; overflow: hidden; transition: all .2s; }
.filter-row .chip:hover { border-color: var(--teal-400); text-decoration: none; }
.filter-row .chip.on { background: var(--teal); color: #fff; border-color: var(--teal); box-shadow: 0 6px 14px var(--teal-glow); }

/* ---------- settings ---------- */
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.field:last-child { border-bottom: 0; } .field label { font-weight: 700; } .field .desc { font-size: .8rem; color: var(--muted); font-weight: 400; display: block; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: var(--surface-solid); }
.seg button { border: 0; background: transparent; color: var(--text); padding: 7px 13px; font-size: .85rem; font-weight: 600; transition: background .2s, color .2s; }
.seg button.on { background: var(--teal); color: #fff; }
.switch { position: relative; width: 46px; height: 27px; border-radius: 14px; background: var(--border-strong); border: 0; flex: none; transition: background .25s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--teal); } .switch.on::after { transform: translateX(19px); }
html[dir="rtl"] .switch::after { left: auto; right: 3px; } html[dir="rtl"] .switch.on::after { transform: translateX(-19px); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 10px; } .empty .big { font-size: 3rem; filter: grayscale(.2); }
.toast { position: fixed; bottom: calc(96px + var(--safe-bottom)); left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: .9rem; z-index: 50; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .25s, transform .25s var(--ease); pointer-events: none; max-width: 90vw; text-align: center; }
@media (min-width: 1024px) { .toast { bottom: 28px; } }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); gap: 8px; }
.history-item:last-child { border-bottom: 0; } .history-item a { flex: 1; font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border-strong); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.install-banner { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--teal-400); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.install-banner .t { flex: 1; font-size: .9rem; } .install-banner svg { width: 22px; height: 22px; fill: var(--teal); flex: none; }
.footer-note { text-align: center; color: var(--muted); font-size: .78rem; margin: 28px 0 8px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-2) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; height: 16px; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* quote block on home */
.quote { position: relative; border-radius: var(--radius); overflow: hidden; padding: 26px 24px; color: #fff; background: linear-gradient(135deg, #0a4d50, #0d7377 60%, #14a3a8); box-shadow: var(--shadow); margin-bottom: 14px; }
.quote::before { content: '❝'; position: absolute; top: -20px; inset-inline-start: 14px; font-size: 7rem; opacity: .12; font-family: serif; }
.quote .ar { font-size: 1.6rem; color: var(--gold-300); }
.quote .src { font-size: .8rem; opacity: .85; margin-top: 8px; }

@media print { .app-header, .tabbar, .side-nav, .actions, .topic-nav, .mobile-search, #bgLayer { display: none !important; } main { padding: 0; } .card { box-shadow: none; break-inside: avoid; } .reveal { opacity: 1; transform: none; } }

/* ---------- Books of the Jama'at / key passages (v2.4) ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 8px 0 14px; }
.book-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.book-head { display: flex; gap: 12px; align-items: flex-start; }
.book-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-family: var(--font-latin); background: linear-gradient(135deg, var(--teal), var(--teal-400)); color: #fff; font-size: 1rem; box-shadow: var(--shadow-sm); }
.book-titles { min-width: 0; flex: 1; }
.book-title { font-weight: 800; font-size: 1.02rem; line-height: 1.5; color: var(--text); display: block; }
.book-title:hover { color: var(--teal); }
.book-alt { color: var(--muted); font-size: .84rem; line-height: 1.6; }
.book-meta { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.book-about { margin: 0; font-size: .92rem; line-height: 1.75; }
.book-card .actions { margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.vol-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 2px 6px; font-weight: 800; color: var(--teal); font-size: .98rem; }
.topic-select { flex: 1; min-width: 180px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid); color: var(--text); font: inherit; font-size: .9rem; }
.quote-card { border-inline-start: 4px solid var(--gold); padding: 16px 18px; background: linear-gradient(180deg, var(--gold-soft), var(--surface-solid) 60%); }
.quote-card.scholar-quote { border-inline-start-color: var(--teal); background: linear-gradient(180deg, var(--teal-soft), var(--surface-solid) 60%); }
.quote-kicker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: .82rem; margin-bottom: 8px; }
.quote-kicker a { font-weight: 700; color: #8a6d0b; } html[data-theme="dark"] .quote-kicker a { color: var(--gold-300); }
.quote-kicker .who { font-weight: 800; color: var(--teal); }
.quote-text { font-size: .98rem; line-height: 1.9; }
.quote-text p:first-child { margin-top: 0; } .quote-text p:last-child { margin-bottom: 0; }
.quote-ar { font-size: 1.25rem; line-height: 2; margin: 4px 0 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.quote-cite { font-size: .8rem; color: var(--muted); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.quote-cite svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
.quote-card .actions { margin-top: 10px; flex-wrap: wrap; }
.books-box { margin: 8px 0 16px; }
.books-box > .actions { margin-top: 4px; }
@media (max-width: 480px) { .book-grid { grid-template-columns: 1fr; } }

/* ---------- v2.5: scroll effects (AOS + vanilla-tilt, both bundled in vendor/) ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--teal), var(--teal-400), var(--gold)); pointer-events: none; box-shadow: 0 0 12px var(--teal-glow); }
html[dir="rtl"] .scroll-progress { transform-origin: 100% 50%; }
html.scrolled .app-header { box-shadow: 0 8px 30px rgba(0,0,0,.08); border-bottom-color: transparent; }
html[data-theme="dark"].scrolled .app-header { box-shadow: 0 8px 30px rgba(0,0,0,.45); }
/* AOS timing overrides: slightly springier, and elements deep in long lists stay cheap */
[data-aos] { transition-timing-function: cubic-bezier(.2,.8,.2,1) !important; }
.grid, .topic-list, .stats, .hero-visual { perspective: 1200px; }
.js-tilt-glare { border-radius: inherit; z-index: 3; }
.portrait .js-tilt-glare { mix-blend-mode: soft-light; }
.tile[data-tilt-ready], .stat[data-tilt-ready] { will-change: transform; }
.tile[data-tilt-ready]:hover { transform: none; }  /* vanilla-tilt owns the transform; keep the lift via shadow only */
.tile[data-tilt-ready]:hover .icon { transform: translateZ(28px) scale(1.1); }
.tile[data-tilt-ready] .t, .tile[data-tilt-ready] .d { transform: translateZ(14px); }
/* never leave content invisible: printing, reduced motion, or a browser without the library */
@media print { [data-aos] { opacity: 1 !important; transform: none !important; } .scroll-progress { display: none; } }
@media (prefers-reduced-motion: reduce) { [data-aos] { opacity: 1 !important; transform: none !important; transition: none !important; } .scroll-progress { display: none; } }

/* ---------- v2.6: speak to search ---------- */
.search-box .mic-btn { background: transparent; color: var(--teal); box-shadow: none; }
.search-box .mic-btn:hover { background: var(--teal-soft); transform: none; }
.voice-btn svg { width: 20px; height: 20px; fill: currentColor; }
.voice-cta { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: linear-gradient(135deg, var(--teal-soft), var(--surface)); border-color: var(--teal-400); }
.voice-cta-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.voice-cta .voice-btn { flex: none; }
@media (max-width: 520px) { .voice-cta { flex-direction: column; align-items: stretch; text-align: center; } }
.voice-fab { position: fixed; z-index: 35; inset-inline-end: 16px; bottom: calc(84px + var(--safe-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--teal), var(--teal-600)); color: #fff; box-shadow: 0 10px 28px var(--teal-glow), 0 2px 6px rgba(0,0,0,.2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s; overflow: hidden; }
.voice-fab svg { width: 26px; height: 26px; fill: currentColor; }
.voice-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 14px 34px var(--teal-glow); }
.voice-fab::before { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(13,115,119,.5); animation: fabPulse 2.6s ease-out infinite; }
@keyframes fabPulse { 0% { box-shadow: 0 0 0 0 rgba(13,115,119,.45); } 70% { box-shadow: 0 0 0 16px rgba(13,115,119,0); } 100% { box-shadow: 0 0 0 0 rgba(13,115,119,0); } }
@media (min-width: 900px) { .voice-fab { bottom: 28px; } }
html.voice-open .voice-fab { display: none; }
html.voice-open { overflow: hidden; }

.voice-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(6,20,21,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; }
.voice-overlay[hidden] { display: none; }
.voice-panel { width: 100%; max-width: 760px; height: min(92vh, 100%); height: min(92dvh, 100%); overflow: hidden; background: var(--bg); color: var(--text); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: voiceIn .35s var(--ease) both; }
@media (min-width: 900px) { .voice-overlay { align-items: center; } .voice-panel { height: min(86vh, 820px); border-radius: 24px; } }
@keyframes voiceIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.voice-head { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 10px; border-bottom: 1px solid var(--border); flex: none; }
.voice-head-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.voice-head-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.voice-head-row .voice-langs { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 0; }
.voice-head-row .voice-langs::-webkit-scrollbar { display: none; }
.voice-head-row .voice-langs .chip, .voice-engine { flex: none; white-space: nowrap; }
.voice-title { font-weight: 800; display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.05rem; }
.voice-title svg { width: 22px; height: 22px; fill: var(--teal); }
.voice-langs { display: flex; gap: 6px; flex-wrap: wrap; }
.voice-langs .chip { padding: 4px 11px; font-size: .78rem; cursor: pointer; }
.voice-log { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 14px 20px; scroll-behavior: smooth; overscroll-behavior: contain; }
.voice-intro { color: var(--muted); text-align: center; padding: 40px 18px; line-height: 2; }
.voice-msg { margin-bottom: 14px; }
.voice-msg.you { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.voice-msg.you .bubble { background: linear-gradient(135deg, var(--teal), var(--teal-600)); color: #fff; border-radius: 18px 18px 4px 18px; padding: 10px 16px; max-width: 85%; font-size: 1.05rem; line-height: 1.8; box-shadow: 0 6px 16px var(--teal-glow); display: inline-flex; gap: 8px; align-items: flex-start; }
html[dir="rtl"] .voice-msg.you .bubble { border-radius: 18px 18px 18px 4px; }
.voice-msg.you .bubble svg { width: 18px; height: 18px; fill: currentColor; flex: none; margin-top: 6px; }
.voice-msg-actions { display: flex; gap: 6px; }
.voice-msg-actions .chip { cursor: pointer; font-size: .76rem; }
.voice-msg.app .voice-results .card { margin-bottom: 10px; }
.voice-msg.app .voice-results .filter-row { display: none; }
.voice-summary { margin: 0 0 8px; padding: 0 4px; }
.voice-foot { flex: none; border-top: 1px solid var(--border); padding: 10px 14px calc(14px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--surface-solid); border-radius: 0 0 24px 24px; }
.voice-live { min-height: 1.6em; text-align: center; font-size: 1.05rem; line-height: 1.7; color: var(--text); max-width: 100%; overflow-wrap: anywhere; }
.voice-live.live { color: var(--teal); }
.voice-live.err { color: #c0392b; font-size: .9rem; }
.voice-live.muted { color: var(--muted); font-size: .9rem; }
.voice-mic { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--teal), var(--teal-600)); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 12px 30px var(--teal-glow); transition: transform .2s var(--ease), background .2s; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.voice-mic svg { width: 38px; height: 38px; fill: currentColor; pointer-events: none; }
.voice-mic .ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; pointer-events: none; }
.voice-mic.on { transform: scale(1.1); background: linear-gradient(135deg, #d6453d, #a12626); box-shadow: 0 12px 34px rgba(214,69,61,.45); }
.voice-mic.on .ring { border-color: rgba(214,69,61,.6); animation: micRing 1.1s ease-out infinite; }
@keyframes micRing { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.voice-hint { font-size: .78rem; color: var(--muted); }
.voice-session .vs-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 6px; }
.voice-session .vs-head svg { width: 18px; height: 18px; fill: var(--teal); vertical-align: -3px; }
.voice-session .vs-item { flex-wrap: wrap; }
.voice-session .vs-ai { width: 100%; color: var(--muted); padding: 2px 0 6px; }
.voice-session .vs-ai svg, .history-item svg { width: 14px; height: 14px; fill: var(--teal); vertical-align: -2px; }

/* ---------- AI answer ---------- */
.ai-card { border-color: rgba(201,162,39,.45); background: linear-gradient(180deg, var(--gold-soft), var(--surface) 30%); }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: #8a6d0b; }
html[data-theme="dark"] .ai-badge { color: var(--gold-300); }
.ai-badge svg { width: 18px; height: 18px; fill: currentColor; }
.ai-text { line-height: 1.9; } .ai-text p { margin: 0 0 8px; } .ai-text ul, .ai-text ol { margin: 4px 0 8px; padding-inline-start: 22px; } .ai-text h4 { margin: 10px 0 4px; font-size: 1rem; } .ai-text code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
html[lang="ur"] .ai-text { line-height: 2.2; }
.ai-sources { margin-top: 8px; } .ai-sources .lbl { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.ai-offer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ai-offer .btn svg, .ai-card .actions svg { width: 16px; height: 16px; fill: currentColor; }
.ai-disclaimer { margin-top: 8px; }
.field.col { flex-direction: column; align-items: stretch; }
.key-row { display: flex; gap: 6px; } .key-row input { flex: 1; min-width: 0; font-family: var(--font-latin); }
.field select, .field input[type="text"], .field input[type="password"] { border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; max-width: 100%; }
.field .key-link { color: var(--teal); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .voice-fab::before, .voice-mic.on .ring { animation: none; } .voice-panel { animation: none; } }
@media print { .voice-fab, .voice-overlay { display: none !important; } }

.voice-engine { cursor: pointer; font-size: .74rem; padding: 4px 10px; }
.key-guide { margin: 6px 0 10px; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }
.key-guide summary { cursor: pointer; font-weight: 700; color: var(--teal); }
.key-guide ol { margin: 8px 0; padding-inline-start: 22px; line-height: 1.9; }
.key-guide .chip svg { width: 13px; height: 13px; }
.own-key[hidden] { display: none; }

/* ---------- v2.7 polish: nothing overlaps / leaves the frame on phones ---------- */
.content, .card, .voice-results { min-width: 0; max-width: 100%; }
.card, .ai-text, .answer-a, .summary, .qa .a, .book-about, .quote-text { overflow-wrap: anywhere; }
.ai-text a { overflow-wrap: anywhere; word-break: break-all; }
.card img, .card video, .card iframe, .card table { max-width: 100%; }
/* example chips under the phone search bar: one scrollable row, never a second line that pushes the page down */
.mobile-search .search-hint { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
html[dir="rtl"] .mobile-search .search-hint { -webkit-mask-image: linear-gradient(-90deg, #000 92%, transparent); mask-image: linear-gradient(-90deg, #000 92%, transparent); }
.mobile-search .search-hint::-webkit-scrollbar { display: none; }
.mobile-search .search-hint .chip { flex: none; white-space: nowrap; }
/* settings rows: wrap on narrow screens instead of squeezing the control out of the card */
.field { flex-wrap: wrap; }
.field > label { flex: 1 1 200px; min-width: 0; }
.field .seg { max-width: 100%; flex-wrap: wrap; }
.field select, .field input[type="text"], .field input[type="password"] { min-width: 0; }
@media (max-width: 600px) {
  .field .seg { width: 100%; }
  .field .seg button { flex: 1 1 auto; padding: 8px 8px; font-size: .8rem; }
  .field .seg button + button { border-inline-start: 1px solid var(--border); }
}
/* pagers with long surah / book names */
.pager .btn { min-width: 0; max-width: 49%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 1.6; }
/* highlighted verse row must stay inside the card on phones */
@media (max-width: 600px) { .verse-row.target { margin: 0 -14px; padding: 14px 14px; } .card { padding: 16px 14px; } }
/* toast never sits under the mic button / tab bar */
.toast { max-width: min(78vw, 520px); text-align: center; }
@media (max-width: 899px) { .toast { bottom: calc(150px + var(--safe-bottom)); } }
/* floating mic: keep clear of the last card's action buttons */
@media (max-width: 899px) { main { padding-bottom: calc(150px + var(--safe-bottom)); } }
/* topic quick-nav under a two-line phone search bar */
@media (max-width: 1023px) { .topic-nav { position: static; } }
/* AI offer card */
.ai-offer-txt { display: flex; flex-direction: column; gap: 2px; flex: 1 1 240px; min-width: 0; }
.ai-offer-txt strong { color: var(--text); }
.ai-offer .btn { flex: none; }
.ai-card.ai-nothing { border-color: var(--teal-400); background: linear-gradient(180deg, var(--teal-soft), var(--surface) 40%); }
.ai-offtopic svg { width: 16px; height: 16px; fill: var(--teal); vertical-align: -3px; }
.ai-scope { line-height: 1.5; }
/* header brand text must not push the buttons off screen */
.brand .txt { min-width: 0; } .brand .txt > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { flex: none; }
/* long words in bubbles / summaries */
.voice-msg.you .bubble, .voice-summary, .voice-live { overflow-wrap: anywhere; }
