/* ═══════════════════════════════════════════════════
   main.css — المصحف PWA
   Mobile-first, RTL, dark & light themes
═══════════════════════════════════════════════════ */

/* ─── TOKENS ─────────────────────────────────────── */
:root {
  --green:   #14a27d;
  --green-d: #0a6e54;
  --green-l: #4ecfa0;
  --gold:    #c9972e;
  --gold-l:  #f0c060;

  --bg:      #0d1f16;
  --bg2:     #122419;
  --surface: #1a2e22;
  --sur2:    #223828;
  --border:  rgba(255,255,255,.08);
  --ink:     #e8f0eb;
  --ink2:    #9db8a5;
  --ink3:    #5e7a67;
  --red:     #e05454;

  --r: 14px;
  --r-sm: 8px;
  --r-lg: 20px;
  --t: .18s ease;

  --topbar-h: clamp(52px, 7vh, 60px);
  --btmnav-h: clamp(54px, 8vh, 68px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
body[data-theme="light"] {
  --bg:      #f6faf7;
  --bg2:     #ffffff;
  --surface: #ffffff;
  --sur2:    #e8f3ed;
  --border:  rgba(24,58,43,.12);
  --ink:     #143427;
  --ink2:    #2f6b4f;
  --ink3:    #6f9783;
  --gold:    #b9851e;
  --gold-l:  #d29f36;
}

body[data-theme="light"] .top-bar,
body[data-theme="light"] .bottom-nav,
body[data-theme="light"] .sb-bar,
body[data-theme="light"] .vs-topbar {
  background: rgba(255,255,255,.92);
  border-color: rgba(24,58,43,.12);
}

body[data-theme="light"] .sg-card,
body[data-theme="light"] .h-stat-card,
body[data-theme="light"] .hab,
body[data-theme="light"] .khatma-card,
body[data-theme="light"] .khatma-active-card,
body[data-theme="light"] .ac-profile-card,
body[data-theme="light"] .bm-item,
body[data-theme="light"] .h-live-item,
body[data-theme="light"] .h-progress-card {
  box-shadow: 0 6px 22px rgba(22, 65, 46, .06);
}

body[data-theme="light"] .vs-inline-tafsir {
  background: rgba(20,162,125,.08);
  color: #245642;
}

body[data-theme="light"] .bn-btn.active {
  color: #0c8a67;
}

body[data-theme="light"] .bn-badge {
  color: #2f2207;
}

/* ─── RESET ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow: hidden;   /* app shell handles scroll */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation;
}
input, select, textarea {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
.hidden { display: none !important; }

/* ─── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sur2); border-radius: 4px; }

/* ═══════════════════════════════════════════════════
   AUTH
═══════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-brand { text-align: center; }
.auth-brand img { margin: 0 auto 8px; }
.auth-brand h1 { font-size: 1.4rem; font-weight: 800; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg2); border-radius: var(--r-sm); padding: 4px; }
.at {
  flex: 1; padding: 8px; border-radius: 6px; font-size: .9rem; font-weight: 600;
  transition: background var(--t), color var(--t);
}
.at.active { background: var(--surface); color: var(--green); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: .95rem;
  width: 100%;
  transition: border-color var(--t);
}
.auth-form input:focus { border-color: var(--green); }
.auth-err { color: var(--red); font-size: .82rem; min-height: .82rem; }
.auth-err:empty { display: none; }
.auth-btn {
  background: var(--green);
  color: #fff;
  padding: 13px;
  border-radius: var(--r-sm);
  font-size: .98rem; font-weight: 700;
  transition: opacity var(--t);
}
.auth-btn:active { opacity: .85; }

/* ═══════════════════════════════════════════════════
   SPLASH
═══════════════════════════════════════════════════ */
.splash-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.splash-geo {
  position: absolute; inset: 0; overflow: hidden;
  opacity: .7;
}
.sp-ring1 { animation: spin 40s linear infinite; transform-origin: 400px 400px; }
.sp-ring2 { animation: spin 28s linear infinite reverse; transform-origin: 400px 400px; }
@keyframes spin { to { transform: rotate(360deg); } }

.splash-body {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; text-align: center;
  padding: 32px 24px;
  max-width: 400px; width: 100%;
}
.sp-icon {
  width: 80px; height: 80px;
  filter: drop-shadow(0 0 20px rgba(201,151,46,.4));
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.sp-title {
  font-size: 2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--gold-l), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sp-sub { color: var(--ink2); font-size: .95rem; }
.sp-prog-wrap { width: 100%; max-width: 280px; }
.sp-bar {
  height: 4px; background: var(--sur2);
  border-radius: 4px; overflow: hidden;
  margin-bottom: 8px;
}
.sp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: 4px;
  transition: width .5s ease;
}
.sp-label { color: var(--ink2); font-size: .85rem; }

.sp-welcome {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; width: 100%;
  animation: fadeUp .7s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sp-verse-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 3px solid var(--gold);
  border-radius: var(--r);
  padding: 16px 18px;
  text-align: right;
}
.sp-ayah {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(1rem, 4vw, 1.2rem);
  line-height: 2.2;
  color: var(--ink);
}
.sp-ref {
  display: block; margin-top: 6px;
  font-size: .8rem; color: var(--gold); font-weight: 600;
}
.sp-hadith {
  font-size: .85rem; color: var(--ink2);
  font-style: italic; text-align: center;
}
.sp-enter-btn {
  background: linear-gradient(135deg, var(--green-d), var(--green));
  color: #fff;
  padding: 14px 32px;
  border-radius: var(--r);
  font-size: 1rem; font-weight: 700;
  box-shadow: 0 8px 24px rgba(20,162,125,.3);
  transition: transform var(--t), box-shadow var(--t);
}
.sp-enter-btn:active { transform: scale(.97); box-shadow: none; }

/* ═══════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════ */
.app-shell {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* ─── TOP BAR ───────────────────────────────────── */
.top-bar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 10;
}
.tb-icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--ink2);
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.tb-icon-btn:active { background: var(--sur2); color: var(--ink); }
.tb-center {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
}
.tb-title {
  font-size: clamp(.95rem, 2.4vw, 1.1rem); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.tb-sub {
  font-size: clamp(.7rem, 2vw, .82rem); color: var(--ink2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-end {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.tb-wake-btn { color: var(--ink3); }
.tb-wake-btn.active { color: var(--green); }
/* network indicator */
.tb-net-btn { padding: 6px !important; }
.net-dot {
  width: 9px; height: 9px; border-radius: 50%; display: block;
  background: var(--ink3); transition: background .4s, box-shadow .4s;
}
.net-dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(20,162,125,.7); }
.net-dot.offline { background: #e05252; box-shadow: 0 0 6px rgba(224,82,82,.6); }
.live-pill {
  display: flex; align-items: center; gap: 5px;
  background: rgba(20,162,125,.15);
  border: 1px solid rgba(20,162,125,.35);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: .82rem; font-weight: 700; color: var(--green);
  box-shadow: 0 0 10px rgba(20,162,125,.12);
}
.live-pill-lbl { font-size: .7rem; font-weight: 500; opacity: .8; }
.today-group {
  display: flex; align-items: baseline; gap: 3px;
  border-right: 1px solid rgba(20,162,125,.25);
  padding-right: 7px; margin-right: 2px;
}
.today-group:has(.today-count:empty) { display: none; }
.today-count { font-weight: 700; font-size: .78rem; }
.today-lbl   { font-size: .65rem; opacity: .7; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.8); }
}

/* ─── HIJRI DATE BAR ─────────────────────────────── */
.hijri-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 7px;
  padding: 5px 16px;
  background: linear-gradient(90deg, rgba(201,151,46,.08) 0%, rgba(201,151,46,.13) 50%, rgba(201,151,46,.08) 100%);
  border-bottom: 1px solid rgba(201,151,46,.15);
  font-size: .75rem;
  direction: rtl;
  overflow: hidden;
  white-space: nowrap;
}
.hijri-crescent { font-size: .9rem; color: #c9972e; line-height: 1; }
.hijri-date { color: #e8c96a; font-weight: 700; letter-spacing: .02em; }
.hijri-sep  { color: rgba(201,151,46,.4); }
.hijri-virtue {
  color: var(--ink2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes hijriSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hijri-bar:not([hidden]) { animation: hijriSlide .4s ease; }

/* ─── ANIMATED LIVE PILL ─────────────────────────── */
.live-pill { position: relative; overflow: visible; }
.live-pill::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 99px;
  border: 1px solid rgba(20,162,125,.4);
  animation: liveRing 2.5s ease-out infinite;
  pointer-events: none;
}
@keyframes liveRing {
  0%   { opacity: .7; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.25); }
  100% { opacity: 0;  transform: scale(1.25); }
}
/* Number flip animation when value updates */
@keyframes countFlip {
  0%   { opacity: 0; transform: translateY(-8px) scale(.85); }
  60%  { opacity: 1; transform: translateY(2px)  scale(1.08); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}
.live-num-flip { animation: countFlip .45s cubic-bezier(.34,1.56,.64,1); }

/* ─── SETTINGS DRAWER ───────────────────────────── */
.sd-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sd-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(320px, 88vw);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex !important; /* override hidden attr via JS */
  flex-direction: column;
  transform: translateX(110%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sd-drawer.open { transform: translateX(0); }

/* ─── SETTINGS HEADER (redesigned) ─────────────────── */
.sd-header {
  flex-shrink: 0;
  background: linear-gradient(160deg, #0a6e54 0%, var(--bg2) 100%);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sd-brand-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 8px;
}
.sd-brand-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.9);
  flex-shrink: 0;
}
.sd-brand-text { flex: 1; }
.sd-brand-name { font-size: 1.1rem; font-weight: 800; color: #fff; }
.sd-brand-version { font-size: .72rem; color: rgba(255,255,255,.6); margin-top: 1px; }
.sd-close-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.7);
  transition: background var(--t);
  flex-shrink: 0;
}
.sd-close-btn:active { background: rgba(255,255,255,.15); }
.sd-user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px 16px;
}
.sd-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.sd-user-details { flex: 1; min-width: 0; }
.sd-username { font-weight: 700; font-size: .95rem; color: #fff; }
.sd-user-stats {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; flex-wrap: wrap;
}
.sd-stat-chip {
  display: flex; align-items: baseline; gap: 3px;
}
.sd-stat-chip span { font-size: .88rem; font-weight: 700; color: rgba(255,255,255,.9); }
.sd-stat-chip small { font-size: .7rem; color: rgba(255,255,255,.6); }
.sd-stat-sep { color: rgba(255,255,255,.3); font-size: .8rem; }
.sd-body {
  flex: 1; overflow-y: auto;
  padding: 14px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.sd-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
}
.sd-sep { height: 1px; background: var(--border); margin: 4px 0; }
.sd-section-label {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink3); padding: 4px 0 0;
}
.sd-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 0;
  font-size: .92rem;
}
/* toggle switch */
.toggle-sw { display: flex; cursor: pointer; flex-shrink: 0; }
.toggle-sw input { display: none; }
.sw-knob {
  width: 44px; height: 24px;
  background: var(--sur2);
  border-radius: 99px;
  position: relative;
  transition: background var(--t);
}
.sw-knob::after {
  content: ''; position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink2);
  transition: transform var(--t), background var(--t);
}
.toggle-sw input:checked ~ .sw-knob { background: var(--green); }
.toggle-sw input:checked ~ .sw-knob::after {
  transform: translateX(-20px);
  background: #fff;
}
.sd-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: .88rem; color: var(--ink);
  cursor: pointer;
}
.sd-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: .88rem; color: var(--ink);
  width: 130px;
}
/* ═ old btn stubs removed, new ones above ═ */
.sd-version { font-size: .75rem; color: var(--ink3); text-align: center; padding: 4px 0; }
/* Settings cards & buttons */
.sd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.sd-card-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 700; color: var(--ink2);
  text-transform: uppercase; letter-spacing: .06em;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.sd-btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.sd-btn {
  flex: 1; min-width: 80px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: opacity var(--t), transform var(--t);
  cursor: pointer;
}
.sd-btn:active { transform: scale(.96); opacity: .85; }
.sd-btn-primary { background: var(--green); color: #fff; }
.sd-btn-warn    { background: rgba(255,150,50,.15); color: #e07820; border: 1px solid rgba(255,150,50,.3); }
.sd-btn-danger  { background: rgba(220,60,60,.12); color: #d94040; border: 1px solid rgba(220,60,60,.25); }
.sd-btn-logout  {
  width: 100%; background: transparent;
  border: 1px solid var(--border); color: var(--ink2);
  padding: 9px; border-radius: var(--r-sm);
  font-size: .85rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 2px;
}
.sd-hint { font-size: .72rem; color: var(--ink3); line-height: 1.55; padding: 2px 0; }
/* Offline section UI */
.sd-offline-status {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--ink2); padding: 2px 0;
}
.os-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink3); transition: background .4s;
}
.os-dot.ready { background: var(--green); box-shadow: 0 0 6px rgba(20,162,125,.5); }
.sd-offline-prog { display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.offline-bar {
  height: 7px; border-radius: 99px;
  background: var(--sur2); overflow: hidden;
}
.offline-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: 99px;
  transition: width .3s ease;
}
.offline-prog-txt { font-size: .75rem; color: var(--ink3); }

/* ─── MAIN STAGE ────────────────────────────────── */
.main-stage {
  flex: 1; min-height: 0;
  position: relative;
  overflow: hidden;
}
.view {
  position: absolute; inset: 0;
  overflow: hidden;
}
.view-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 8px);
}
.view-head {
  padding: 20px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.view-head h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.view-head p  { font-size: .85rem; color: var(--ink2); }

/* ═══════════════════════════════════════════════════
   SURAH BROWSER
═══════════════════════════════════════════════════ */
.surah-browser {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sb-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.sb-search {
  flex: 1 1 220px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: .92rem;
  transition: border-color var(--t);
}
.sb-search:focus { border-color: var(--green); }
.sb-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: .88rem; color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 110px;
}
.surah-grid {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(8px, 2vw, 14px);
  padding: clamp(10px, 2.6vw, 16px);
  align-content: start;
  padding-bottom: calc(var(--btmnav-h) + var(--safe-bottom) + 12px);
}
.sg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: clamp(12px, 2.4vw, 16px) clamp(10px, 2vw, 14px);
  cursor: pointer;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
  text-align: right;
  min-height: 104px;
}
.sg-card::before {
  content: ''; position: absolute;
  top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--border);
  transition: background var(--t);
}
.sg-card:active { transform: scale(.97); }
.sg-card:hover  { border-color: var(--green); box-shadow: 0 4px 16px rgba(20,162,125,.12); }
.sg-card:hover::before { background: var(--green); }
.sg-num {
  font-size: .75rem; color: var(--ink3);
  background: var(--bg2); border-radius: 4px;
  padding: 2px 6px; width: fit-content;
  font-weight: 700;
}
.sg-name {
  font-size: clamp(.95rem, 2.6vw, 1.12rem); font-weight: 700;
  color: var(--ink); line-height: 1.4;
}
.sg-meta { font-size: clamp(.72rem, 2vw, .82rem); color: var(--ink2); }
.sg-type {
  font-size: clamp(.7rem, 1.9vw, .8rem); color: var(--ink3);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   VERSE STAGE
═══════════════════════════════════════════════════ */
.verse-stage {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* animated background */
.vs-bg {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.vs-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(201,151,46,.07);
}
.vs-ring.r1 {
  width: 600px; height: 600px;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  animation: ringPulse 8s ease-in-out infinite;
}
.vs-ring.r2 {
  width: 380px; height: 380px;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  border-color: rgba(20,162,125,.06);
  animation: ringPulse 6s ease-in-out infinite .5s reverse;
}
@keyframes ringPulse {
  0%,100% { opacity: .6; transform: translate(-50%,-50%) scale(1); }
  50%      { opacity: 1;  transform: translate(-50%,-50%) scale(1.04); }
}
.vs-particles { position: absolute; inset: 0; pointer-events: none; }
.vp {
  position: absolute; border-radius: 50%;
  background: rgba(201,151,46,.3);
  animation: vpRise 8s ease-in infinite;
}
@keyframes vpRise {
  0%   { opacity: 0; transform: translateY(0) scale(1); }
  20%  { opacity: .6; }
  100% { opacity: 0; transform: translateY(-60vh) scale(.4); }
}

/* top bar */
.vs-topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(13,31,22,.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.vs-icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--ink2);
  flex-shrink: 0;
  transition: background var(--t), color var(--t);
}
.vs-icon-btn:active { background: var(--sur2); color: var(--ink); }
.vs-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  justify-content: center;
}
.vs-ch-name {
  font-size: 1rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vs-meta-row {
  display: flex; align-items: center; gap: 6px;
}
.vs-progress-pill {
  background: var(--sur2);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: .75rem; color: var(--ink2);
  white-space: nowrap; flex-shrink: 0;
}
.vs-juz-pill {
  background: rgba(20,162,125,.12);
  border: 1px solid rgba(20,162,125,.25);
  border-radius: 99px;
  padding: 3px 9px;
  font-size: .72rem; font-weight: 600; color: var(--green);
  white-space: nowrap; flex-shrink: 0;
}
.vs-juz-pill:empty { display: none; }
.vs-hassanat-mini {
  position: relative;
  z-index: 2;
  margin: 8px auto 0;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 32, 24, .88);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}
.vh-item { display: flex; align-items: baseline; gap: 6px; }
.vh-label { font-size: .72rem; color: var(--ink3); }
.vh-item strong { font-size: .86rem; color: var(--gold-l); }
.vh-sep { width: 1px; height: 16px; background: var(--border); }
/* live readers in verse stage */
.vh-live-item { align-items: center !important; }
.vh-live-item strong { color: var(--green) !important; }
.vh-live-item .vh-label { color: var(--green); opacity: .85; }
.vhl-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease infinite;
  margin-bottom: 1px;
}

/* slides */
.vs-slide-wrap {
  flex: 1; min-height: 0;
  position: relative; overflow: hidden;
}
.vs-slides {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  direction: rtl;
}
.vs-slide {
  min-width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 24px;
  overflow-y: auto;
}
/* Bismillah slide */
.vs-slide-bismillah {
  background: linear-gradient(160deg, rgba(20,162,125,.06) 0%, transparent 100%);
}
.vs-bismillah-text {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 2;
  text-align: center;
  color: var(--ink);
  direction: rtl;
  letter-spacing: .02em;
  text-shadow: 0 2px 18px rgba(20,162,125,.18);
}
.vs-slide-ayah {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(1.5rem, 6vw, 2.4rem);
  line-height: 2.4;
  text-align: center;
  color: var(--ink);
  direction: rtl;
}
.vs-slide-key {
  margin-top: 12px;
  font-size: .78rem; color: var(--ink3);
  letter-spacing: .04em;
}
.vs-inline-tafsir {
  width: min(100%, 780px);
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(20,162,125,.06);
  color: var(--ink2);
  font-size: .86rem;
  line-height: 1.9;
  text-align: right;
  direction: rtl;
}
.vs-slide-end {
  font-size: .7em; color: var(--gold);
  margin-right: 4px;
}

/* word chips */
.wc {
  display: inline;
  cursor: pointer;
  border-radius: 3px;
  transition: color .3s ease, text-shadow .3s ease;
  padding: 0 1px;
}
.wc:hover { color: var(--gold-l); }
/* currently playing word — smooth colour glow, no box */
.wc.playing {
  color: var(--gold-l);
  text-shadow: 0 0 16px rgba(201,151,46,.65), 0 0 4px rgba(201,151,46,.35);
}
/* words already read — dim gently */
.wc.active { color: var(--ink3); transition: color .5s ease; }

/* word inspector */
.word-inspector {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 20px;
}
.wi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 20px 20px;
  width: 100%; max-width: 400px;
  text-align: center;
  position: relative;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.wi-close {
  position: absolute; top: 14px; left: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--sur2);
  font-size: .9rem; color: var(--ink2);
  display: flex; align-items: center; justify-content: center;
}
.wi-word {
  font-family: 'Amiri Quran', serif;
  font-size: 2rem; color: var(--ink);
  margin: 8px 0;
}
.wi-translit { font-size: .9rem; color: var(--ink2); margin-bottom: 4px; }
.wi-meaning  { font-size: .88rem; color: var(--green-l); font-weight: 600; }
.wi-play-btn {
  margin-top: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 20px;
  font-size: .88rem; font-weight: 600;
  transition: background var(--t);
}
.wi-play-btn:active { background: var(--sur2); }

/* ═══════════════════════════════════════════════════
   UNIFIED BOTTOM BAR — PLAYER SECTION
═══════════════════════════════════════════════════ */

/* player section — hidden by default, shown when reading */
.bn-player {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bar-bg, rgba(10,26,18,.95));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
body.in-verse .bn-player {
  display: flex;
}

/* slim progress strip */
.va-track {
  height: 3px;
  background: rgba(255,255,255,.08);
}
.va-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  width: 0%;
  transition: width .25s ease;
  border-radius: 2px;
}

/* playback controls row */
.bn-pl-ctrls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2.5vw, 18px);
  padding: 8px 12px 5px;
}
.bn-plbtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink2);
  transition: background var(--t), color var(--t), transform var(--t);
  flex-shrink: 0;
}
.bn-plbtn svg { width: 20px; height: 20px; }
.bn-plbtn:hover  { background: rgba(255,255,255,.07); color: var(--ink); }
.bn-plbtn:active { transform: scale(.88); background: rgba(255,255,255,.07); }
.bn-plbtn:disabled { opacity: .25; pointer-events: none; }
/* autoplay variant */
.bn-autoplay {
  border: 1.5px solid var(--border);
  background: var(--sur2);
  color: var(--ink3);
}
.bn-autoplay.active {
  background: rgba(20,162,125,.15);
  border-color: var(--green);
  color: var(--green);
  animation: autoPlayPulse 2s ease-in-out infinite;
}
@keyframes autoPlayPulse {
  0%,100% { box-shadow: 0 0 8px rgba(20,162,125,.3); }
  50%      { box-shadow: 0 0 18px rgba(20,162,125,.65); }
}
/* big play button */
.bn-play-btn {
  width: 52px; height: 52px;
  background: var(--green);
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(20,162,125,.45);
  transition: transform var(--t), box-shadow var(--t), background var(--t);
  flex-shrink: 0;
}
.bn-play-btn svg { width: 20px; height: 20px; margin-right: -2px; }
.bn-play-btn:active { transform: scale(.9); }
.bn-play-btn.playing {
  background: var(--gold);
  box-shadow: 0 4px 16px rgba(201,151,46,.5);
  animation: playGlow 1.6s ease-in-out infinite;
}
@keyframes playGlow {
  0%,100% { box-shadow: 0 6px 20px rgba(201,151,46,.45); }
  50%      { box-shadow: 0 6px 32px rgba(201,151,46,.85); }
}
.bn-ayah-num {
  font-size: .78rem; font-weight: 800; color: var(--ink2);
  min-width: 40px; text-align: center;
  background: var(--sur2);
  padding: 3px 8px; border-radius: 20px;
  flex-shrink: 0;
}

/* action buttons row */
.bn-pl-acts {
  display: flex;
  align-items: stretch;
  padding: 4px 8px 7px;
  gap: 2px;
}
.bn-act-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px;
  border-radius: var(--r-sm);
  color: var(--ink2);
  font-size: .6rem; font-weight: 600;
  transition: background var(--t), color var(--t), transform var(--t);
  min-width: 0;
}
.bn-act-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.bn-act-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.bn-act-btn:active { transform: scale(.9); background: rgba(255,255,255,.06); }
.bn-act-btn.done  { color: var(--green); }
.bn-act-btn.active { color: var(--green); background: rgba(20,162,125,.12); }
#vsMarkBtn.active  { color: var(--gold); background: rgba(201,151,46,.1); }

/* light theme overrides */
body[data-theme="light"] .bn-player {
  --bar-bg: rgba(248,252,250,.97);
  border-bottom-color: rgba(0,0,0,.08);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
body[data-theme="light"] .va-track { background: rgba(0,0,0,.07); }
body[data-theme="light"] .bn-act-btn:hover { background: rgba(0,0,0,.05); }
body[data-theme="light"] .bn-plbtn:hover  { background: rgba(0,0,0,.05); }

/* desktop — wider spacing */
@media (min-width: 600px) {
  .bn-pl-ctrls { gap: 22px; padding: 10px 24px 7px; }
  .bn-plbtn { width: 46px; height: 46px; }
  .bn-play-btn { width: 56px; height: 56px; }
  .bn-pl-acts { padding: 6px 24px 10px; gap: 8px; }
  .bn-act-btn { font-size: .7rem; padding: 7px 4px; }
  .bn-act-btn svg { width: 18px; height: 18px; }
}

/* focus mode — fade out player/topbar until touch */

/* bottom panels (tafsir / ayah list) */
.btm-panel {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 70%;
  display: flex; flex-direction: column;
  animation: panelUp .25s ease;
}
@keyframes panelUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.btm-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.btm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btm-title { font-size: .95rem; font-weight: 700; }
.btm-close {
  width: 28px; height: 28px;
  background: var(--sur2); border-radius: 50%;
  font-size: .85rem; color: var(--ink2);
  display: flex; align-items: center; justify-content: center;
}
.btm-body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
}

/* tafsir text */
.tafsir-text, #tafsirContent {
  font-size: .92rem; line-height: 2; color: var(--ink);
  direction: rtl; text-align: right;
}
.tafsir-text * { font-family: 'Tajawal', sans-serif !important; }
.tp-loading { color: var(--ink2); text-align: center; padding: 24px 0; }
.tafsir-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.tafsir-head {
  font-size: .84rem;
  color: var(--gold);
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 6px;
}

/* ayah list */
.alp-body { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.alp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t);
}
.alp-item:active { background: var(--sur2); }
.alp-item.active { background: rgba(20,162,125,.1); }
.alp-item.read   { opacity: .6; }
.alp-num {
  min-width: 28px; height: 28px;
  background: var(--sur2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--ink2);
  flex-shrink: 0;
}
.alp-item.active .alp-num { background: var(--green); color: #fff; }
.alp-text {
  flex: 1; font-family: 'Amiri Quran', serif;
  font-size: .95rem; line-height: 1.8;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.alp-mark { font-size: .9rem; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════
   KHATMA VIEW
═══════════════════════════════════════════════════ */
.khatma-area {
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.khatma-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.kc-label { font-size: .82rem; color: var(--ink3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kc-actions { display: flex; gap: 10px; }
.kc-btn {
  flex: 1; padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 700;
  text-align: center;
  transition: background var(--t), border-color var(--t);
}
.kc-btn.primary { background: var(--green); color: #fff; border-color: transparent; }
.kc-btn:not(.primary):active { background: var(--sur2); }
.kc-form { display: flex; flex-direction: column; gap: 10px; }
.kc-input, .kc-code-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: .92rem;
  transition: border-color var(--t);
}
.kc-input:focus, .kc-code-input:focus { border-color: var(--green); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .9rem;
}
.kc-submit {
  background: var(--green); color: #fff;
  padding: 12px;
  border-radius: var(--r-sm);
  font-size: .95rem; font-weight: 700;
}
.kc-join-row { display: flex; gap: 8px; }
.khatma-active-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.kha-badge {
  background: rgba(20,162,125,.1);
  color: var(--green);
  font-size: .78rem; font-weight: 700;
  padding: 4px 10px; border-radius: 99px;
  width: fit-content;
}
.kha-name { font-size: 1.15rem; font-weight: 800; }
.kha-code-strip {
  background: var(--bg2); border-radius: var(--r-sm);
  padding: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.kha-code-label { font-size: .75rem; color: var(--ink3); display: block; margin-bottom: 2px; }
.kha-code-big { font-size: 1.6rem; font-weight: 800; letter-spacing: .15em; color: var(--gold); }
.kha-qr {
  width: 72px; height: 72px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: cover;
}
.kha-share-btn {
  background: var(--green); color: #fff;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: .85rem; font-weight: 700;
}
.kha-progress { display: flex; flex-direction: column; gap: 6px; }
.kha-prog-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink2); }
.prog-bar { height: 8px; background: var(--sur2); border-radius: 4px; overflow: hidden; }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); border-radius: 4px; transition: width .4s ease; }
.kha-members-head { display: flex; align-items: center; justify-content: space-between; }
.kha-members-title { font-size: .88rem; font-weight: 700; }
.kha-refresh-btn {
  font-size: .8rem; color: var(--green); font-weight: 600;
  padding: 4px 10px; border: 1px solid rgba(20,162,125,.3);
  border-radius: var(--r-sm);
}
.km-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.km-item:last-child { border-bottom: none; }
.km-item.km-me .km-name::after { content: ' (أنت)'; font-weight: 400; color: var(--ink3); font-size: .8rem; }
.km-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sur2);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; flex-shrink: 0;
}
.km-info { flex: 1; min-width: 0; }
.km-name  { font-size: .88rem; font-weight: 600; }
.km-count { font-size: .78rem; color: var(--ink2); }
.km-bar-wrap { width: 70px; flex-shrink: 0; }
.km-bar { height: 6px; background: var(--sur2); border-radius: 3px; overflow: hidden; }
.km-fill { height: 100%; background: var(--green); border-radius: 3px; }
.kha-leave-btn {
  padding: 11px;
  border: 1px solid rgba(224,84,84,.25);
  border-radius: var(--r-sm);
  color: var(--red); font-size: .9rem; font-weight: 600;
  text-align: center;
}
.klist-wrap { display: flex; flex-direction: column; gap: 10px; }
.klist-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}
.klist-main { min-width: 0; }
.klist-name {
  font-weight: 700;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.klist-code {
  font-size: .82rem;
  letter-spacing: .12em;
  color: var(--gold);
  margin-top: 2px;
}
.klist-qr {
  width: 56px; height: 56px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.qr-scan-overlay {
  position: fixed; inset: 0; z-index: 180;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.qr-scan-box {
  width: min(420px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.qr-video {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: #000;
  object-fit: cover;
}
.qr-close {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════
   HASSANAT VIEW
═══════════════════════════════════════════════════ */
.hassanat-area { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.h-live-box {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
}
.h-live-item {
  background: linear-gradient(135deg, rgba(20,162,125,.12), rgba(201,151,46,.12));
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
}
.h-live-label { display: block; font-size: .74rem; color: var(--ink2); }
.h-live-num { display: block; font-size: 1.25rem; color: var(--gold); margin-top: 4px; }
.h-stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.h-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 10px;
  text-align: center;
}
.h-stat-num  { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.h-stat-label{ font-size: .72rem; color: var(--ink2); margin-top: 4px; }
.h-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}
.h-progress-top {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--ink2);
  margin-bottom: 6px;
}
.badges-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.hab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 8px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color var(--t), transform var(--t);
}
.hab.earned {
  border-color: rgba(201,151,46,.4);
  background: linear-gradient(135deg, rgba(201,151,46,.06), rgba(20,162,125,.04));
}
.hab.locked { opacity: .45; filter: grayscale(.5); }
.hab-icon { font-size: 1.6rem; }
.hab-name  { font-size: .72rem; color: var(--ink2); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   ACCOUNT VIEW
═══════════════════════════════════════════════════ */
.ac-hero {
  padding: 32px 18px 20px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; text-align: center;
  background: linear-gradient(180deg, var(--bg2) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}
.ac-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-d), var(--green));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; color: #fff;
  box-shadow: 0 6px 24px rgba(20,162,125,.3); margin-bottom: 4px;
}
.ac-hero-name { font-size: 1.1rem; font-weight: 800; }
.ac-hero-sub  { font-size: .8rem; color: var(--ink2); }
.ac-join-date { font-size: .72rem; color: var(--ink3); }
.ac-stats-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 0; border-bottom: 1px solid var(--border);
}
.ac-stats-6 { grid-template-columns: repeat(3,1fr); }
.ac-stat { padding: 14px 8px; text-align: center; border-left: 1px solid var(--border); }
.ac-stat:nth-child(3), .ac-stat:nth-child(6) { border-left: none; }
.ac-stats-6 .ac-stat:nth-child(n+4) { border-top: 1px solid var(--border); }
.ac-stat-val { font-size: 1.2rem; font-weight: 800; color: var(--green); }
.ac-stat-lbl { font-size: .68rem; color: var(--ink2); }
.ac-section { padding: 16px 16px 0; }
.ac-section-title { font-size: .75rem; font-weight: 700; color: var(--ink3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 10px; }
.ac-sync-status { font-size: .78rem; color: var(--ink3); text-align: center; padding: 8px; }
.ac-progress-wrap { display: flex; align-items: center; gap: 10px; }
.ac-progress-bar { flex: 1; height: 8px; background: var(--sur2); border-radius: 8px; overflow: hidden; }
.ac-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), var(--gold)); border-radius: 8px; transition: width .6s ease; }
.ac-progress-txt { font-size: .72rem; color: var(--ink2); white-space: nowrap; }
.ac-last-read {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.ac-lr-empty { font-size: .85rem; color: var(--ink3); }
.ac-lr-info { flex: 1; }
.ac-lr-surah { font-size: .9rem; font-weight: 700; }
.ac-lr-ayah  { font-size: .75rem; color: var(--ink2); }
.ac-lr-goto  {
  font-size: .78rem; color: var(--green); font-weight: 700;
  padding: 5px 12px; border: 1px solid rgba(20,162,125,.3); border-radius: var(--r-sm);
  white-space: nowrap;
}
.ac-lr-goto:active { background: rgba(20,162,125,.1); }
.ac-achievements { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.ac-badge {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 6px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: border-color var(--t), opacity var(--t);
}
.ac-badge.locked { opacity: .35; filter: grayscale(.8); }
.ac-badge-icon { font-size: 1.4rem; line-height: 1; }
.ac-badge-name { font-size: .62rem; color: var(--ink2); font-weight: 600; line-height: 1.2; }
.ac-badge.unlocked { border-color: var(--gold); }
.ac-badge.unlocked .ac-badge-name { color: var(--gold); }
.ac-share-btn {
  width: 100%; padding: 13px; margin-bottom: 4px;
  background: linear-gradient(135deg, var(--green-d), var(--green));
  color: #fff; border-radius: var(--r-sm);
  font-size: .92rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(20,162,125,.3);
}
.ac-share-btn:active { opacity: .85; }
.ac-logout-btn {
  margin: 12px 16px 20px; padding: 12px;
  border: 1px solid rgba(224,84,84,.25);
  border-radius: var(--r-sm);
  color: var(--red); font-size: .9rem; font-weight: 600;
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ac-logout-btn:active { background: rgba(224,84,84,.06); }

/* bookmarks */
.bookmarks-list { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.bm-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--t);
}
.bm-item:hover { border-color: var(--green); }
.bm-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.bm-ref { font-size: .78rem; color: var(--green); font-weight: 700; }
.bm-actions { display: flex; align-items: center; gap: 6px; }
.bm-play {
  font-size: .72rem; color: var(--green);
  padding: 2px 8px; border: 1px solid rgba(20,162,125,.3);
  border-radius: var(--r-sm);
}
.bm-del {
  font-size: .75rem; color: var(--red);
  padding: 2px 8px; border: 1px solid rgba(224,84,84,.25);
  border-radius: var(--r-sm);
}
.bm-text {
  font-family: 'Amiri Quran', serif;
  font-size: .88rem; color: var(--ink2); line-height: 1.8;
}

/* reminder redesign */
.rem-perm-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(201,151,46,.08); border: 1px solid rgba(201,151,46,.2);
  border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 6px;
  font-size: .8rem; color: var(--gold);
}
.rem-perm-row span { flex: 1; }
.rem-perm-btn {
  font-size: .75rem; font-weight: 700; color: var(--bg);
  background: var(--gold); padding: 4px 10px;
  border-radius: var(--r-sm); white-space: nowrap;
}
.rem-settings { display: flex; flex-direction: column; gap: 0; }
.rem-days { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px 0; }
.rem-day {
  flex: 1; min-width: 32px; padding: 6px 4px;
  background: var(--sur2); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: .72rem; font-weight: 700;
  color: var(--ink3); text-align: center;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.rem-day.active { background: rgba(20,162,125,.15); border-color: var(--green); color: var(--green); }

/* ═══════════════════════════════════════════════════
   BOTTOM NAV
═══════════════════════════════════════════════════ */
.bottom-nav {
  flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  position: relative; z-index: 10;
}
/* tabs row — always visible */
.bn-tabs {
  display: flex; align-items: stretch;
  height: calc(var(--btmnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
}
.bn-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: .68rem; font-weight: 600; color: var(--ink3);
  transition: color var(--t), background var(--t);
  border-radius: 0;
  padding: 0;
  position: relative;
}
.bn-badge {
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: linear-gradient(135deg, var(--gold), var(--gold-l));
  color: #1f1a0b;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 99px;
  padding: 2px 7px;
  font-size: .68rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.bn-badge.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.bn-btn::before {
  content: ''; position: absolute;
  top: 0; left: 25%; right: 25%; height: 2px;
  background: var(--green);
  border-radius: 0 0 2px 2px;
  transform: scaleX(0);
  transition: transform var(--t);
}
.bn-btn.active { color: var(--green); }
.bn-btn.active::before { transform: scaleX(1); }
.bn-btn:active { background: rgba(20,162,125,.06); }
.bn-icon {
  width: 22px; height: 22px;
  stroke: currentColor;
  transition: transform var(--t);
}
.bn-btn.active .bn-icon { transform: scale(1.1); }

/* ═══════════════════════════════════════════════════
   UPDATE BANNER
═══════════════════════════════════════════════════ */
.update-banner {
  position: fixed; bottom: calc(var(--btmnav-h) + var(--safe-bottom) + 8px);
  left: 12px; right: 12px; z-index: 40;
  background: var(--sur2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .88rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.update-banner button {
  background: var(--green); color: #fff;
  padding: 7px 16px; border-radius: var(--r-sm);
  font-size: .85rem; font-weight: 700;
}

/* ═══════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════ */
.toast {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  z-index: 100;
  background: var(--sur2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 20px;
  font-size: .9rem; font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: top .3s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.toast.show { top: calc(var(--topbar-h) + 8px); }

/* ═══════════════════════════════════════════════════
   LOADING HUD
═══════════════════════════════════════════════════ */
.loading-hud {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(13,31,22,.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t);
}
.loading-hud.show { opacity: 1; pointer-events: all; }
.lh-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 28px;
  text-align: center; min-width: 200px;
  display: flex; flex-direction: column; gap: 12px;
}
.lh-text { font-size: .92rem; color: var(--ink2); }
.lh-bar {
  height: 4px; background: var(--sur2);
  border-radius: 4px; overflow: hidden;
}
.lh-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: 4px; transition: width .4s ease;
}

/* ═══════════════════════════════════════════════════
   FOCUS MODE
═══════════════════════════════════════════════════ */
body.focus-mode .bn-player,
body.focus-mode .vs-topbar {
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
body.focus-mode .verse-stage:active .bn-player,
body.focus-mode .verse-stage:active .vs-topbar {
  opacity: 1; pointer-events: all;
}

/* ═══════════════════════════════════════════════════
   IN-VERSE: player section shown via body.in-verse
   (handled in .bn-player display block above)
═══════════════════════════════════════════════════ */

/* Inline tafsir hidden by default, revealed when tafsir-mode is active */
.vs-inline-tafsir {
  display: none;
}
body.show-tafsir .vs-inline-tafsir {
  display: block;
}

/* ═══════════════════════════════════════════════════
   VERSE CENTERING — max-width on desktop
═══════════════════════════════════════════════════ */
/* Centered content well for verse slides */
.vs-slide-inner {
  display: flex; flex-direction: column; align-items: center;
  width: min(100%, 700px);
  margin: 0 auto;
  text-align: center;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */
@media (min-width: 600px) {
  .surah-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .h-stats-row { grid-template-columns: repeat(3,1fr); }
  .badges-grid { grid-template-columns: repeat(4,1fr); }
  .vs-slide-ayah { font-size: clamp(1.6rem, 4vw, 2.6rem); }
  /* Center the slide content on wider screens */
  .vs-slide { padding: 40px 48px; }
  .vs-inline-tafsir { font-size: .9rem; }

}
@media (min-width: 900px) {
  .surah-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .badges-grid { grid-template-columns: repeat(6,1fr); }
  .vs-slide { padding: 48px 80px; }
  .sd-drawer { width: 360px; }
  /* Desktop: constrain verse width to readable column */
  .vs-slide-ayah    { max-width: 760px; }
  .vs-inline-tafsir { max-width: 760px; }
}
@media (max-width: 360px) {
  .va-read  { display: none; }
  .h-stat-num { font-size: 1.2rem; }
  .h-stat-label { font-size: .65rem; }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .vs-slide-ayah { font-size: 1.3rem; line-height: 2; }
  .vs-topbar { padding-top: 6px; padding-bottom: 6px; }
}

/* ═══════════════════════════════════════════════════
   FULL-PAGE TAFSIR VIEW
═══════════════════════════════════════════════════ */
.tafsir-page {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: tpSlideIn .22s ease;
}
@keyframes tpSlideIn {
  from { transform: translateX(-30px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.tp-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  min-height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tp-topbar-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--green);
  flex-shrink: 0;
  transition: background var(--t);
}
.tp-topbar-back:active { background: var(--sur2); }
.tp-topbar-spacer { width: 36px; flex-shrink: 0; }
.tp-topbar-info { flex: 1; text-align: center; }
.tp-surah-name { font-size: .95rem; font-weight: 800; color: var(--ink); line-height: 1.2; }
.tp-verse-ref  { font-size: .75rem; color: var(--green); font-weight: 700; margin-top: 2px; }
.tp-scroll {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.tp-verse-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  border-right: 3px solid var(--green);
  padding: 18px 16px;
  font-family: 'Amiri Quran', serif;
  font-size: 1.35rem;
  line-height: 2.3;
  text-align: center;
  color: var(--ink);
  direction: rtl;
}
.tp-tafsir-section { display: flex; flex-direction: column; gap: 12px; }
.tp-tafsir-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.tp-tafsir-block-title {
  font-size: .82rem; font-weight: 800;
  color: var(--green);
  padding: 8px 14px;
  background: rgba(20,162,125,.07);
  border-bottom: 1px solid var(--border);
}
.tp-tafsir-text {
  font-size: .9rem; line-height: 2;
  color: var(--ink2);
  direction: rtl;
  text-align: justify;
  padding: 12px 14px;
}
.tp-tafsir-section > .tp-tafsir-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.tp-loading {
  text-align: center; color: var(--ink3);
  font-size: .9rem; padding: 40px 16px;
}
.tp-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.tp-nav-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink2);
  font-size: .82rem; font-weight: 600;
  border: 1px solid var(--border);
  transition: background var(--t), color var(--t), opacity var(--t);
  min-width: 90px; justify-content: center;
}
.tp-nav-btn:active { background: var(--sur2); }
.tp-nav-btn:disabled { opacity: .35; pointer-events: none; }
.tp-nav-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.tp-nav-ref {
  font-size: .8rem; font-weight: 700;
  color: var(--ink3); text-align: center;
  white-space: nowrap;
}
/* light theme */
body[data-theme="light"] .sd-header {
  background: linear-gradient(160deg, #0a6e54 0%, #f6faf7 100%);
}
body[data-theme="light"] .tp-topbar { background: rgba(255,255,255,.95); }
body[data-theme="light"] .tp-nav    { background: rgba(255,255,255,.95); }

