/* Quran Navigation — styles. Light/dark via CSS variables; mobile-first. */

/* ---------- Theme tokens ---------- */
:root {
  --bg: #faf7f0; --panel: #ffffff; --panel2: #f2ede1; --line: #e2dccd;
  --text: #1f1a10; --muted: #6b6356; --gold: #9a6f06; --gold-dim: #c9a24a;
  --gold-rgb: 154,111,6; --on-gold: #ffffff; --shadow: 0 10px 30px rgba(0,0,0,.12);
  --overlay: rgba(20,16,8,.45); --page-bg: #fbf6e9;
  --radius: 14px; --head-h: 112px; --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg:#0c0f14; --panel:#151a22; --panel2:#1c232e; --line:#2a3340;
    --text:#ece7d8; --muted:#9aa3b0; --gold:#e1b23c; --gold-dim:#8a6d24; --gold-rgb:225,178,60;
    --on-gold:#1a1405; --shadow: 0 10px 30px rgba(0,0,0,.5); --overlay: rgba(4,6,9,.78); --page-bg:#fbf6e9;
    color-scheme: dark; }
}
:root[data-theme="dark"] { --bg:#0c0f14; --panel:#151a22; --panel2:#1c232e; --line:#2a3340;
  --text:#ece7d8; --muted:#9aa3b0; --gold:#e1b23c; --gold-dim:#8a6d24; --gold-rgb:225,178,60;
  --on-gold:#1a1405; --shadow: 0 10px 30px rgba(0,0,0,.5); --overlay: rgba(4,6,9,.78); color-scheme: dark; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", "Noto Sans Bengali", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; line-height: 1.55;
  -webkit-tap-highlight-color: transparent; }
body { overflow-x: clip; } /* clip (not hidden) keeps position: sticky working */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
body.lang-ar { font-family: "Amiri", "Traditional Arabic", serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
img { max-width: 100%; }

/* ---------- Header (sticky) ---------- */
.app-head { position: sticky; top: 0; z-index: 20; background: var(--panel);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; object-fit: contain; }
.brand h1 { margin: 0; font-size: 1.05rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .tagline { display: none; }
.icon-btn { font-size: 1.15rem; min-width: var(--tap); min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); cursor: pointer; display: inline-grid; place-items: center; padding: 0 12px; }
.icon-btn:hover { border-color: var(--gold-dim); }
.lang-btn { font-weight: 600; font-size: .95rem; color: var(--gold); white-space: nowrap; }
.install-btn { background: var(--gold); color: var(--on-gold); border: none; font-weight: 700; font-size: .85rem; }
.catnav { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); }
.catbar { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; scroll-snap-type: x proximity; }
.catbar::-webkit-scrollbar { display: none; }
.catbar a { flex: 0 0 auto; scroll-snap-align: start; min-height: 40px; display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 10px; color: var(--muted); white-space: nowrap; font-size: .92rem; }
.catbar a[aria-current="page"] { background: var(--panel2); color: var(--gold); font-weight: 600; }
.menubtn { flex: 0 0 auto; min-height: 40px; background: var(--gold); color: var(--on-gold); border: none;
  border-radius: 10px; padding: 6px 14px; cursor: pointer; font-weight: 700; }
.offline-bar { background: var(--panel2); color: var(--muted); font-size: .8rem; text-align: center; padding: 4px; border-top: 1px solid var(--line); }

/* ---------- Mega menu (sheet on phones, panel on larger screens) ---------- */
.mega { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.mega-panel { width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--gold-dim);
  border-radius: 20px 20px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  animation: sheetUp .22s ease-out; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.mega-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mega-head h2 { margin: 0; color: var(--gold); font-size: 1.2rem; }
.mega-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.mcard { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 12px; border-radius: 14px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.mcard:active { border-color: var(--gold); }
.mico { font-size: 1.4rem; min-width: 40px; text-align: center; color: var(--gold); font-family: "Amiri", serif; }
.mtext { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mtext .muted { font-size: .8rem; }
.mcount { font-size: .82rem; color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.kbd { text-align: center; margin: 12px 0 0; font-size: .78rem; }

/* ---------- Layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); }
h2 { margin: .2rem 0 .8rem; font-size: 1.2rem; }
.muted { color: var(--muted); font-size: .9rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.item { display: flex; gap: 12px; align-items: center; min-height: var(--tap); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; color: var(--text); }
.item:active, .item:focus-visible { border-color: var(--gold); outline: none; }
.num { flex: 0 0 auto; min-width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--panel2); color: var(--gold); font-weight: 700; font-size: .9rem; }
.item .names { flex: 1; min-width: 0; }
.item .ar { font-family: "Amiri", serif; font-size: 1.3rem; color: var(--gold); line-height: 1.3; }
.item .sub { font-size: .85rem; color: var(--muted); }
.item.pending { opacity: .55; border-style: dashed; }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.searchbox, .select, .field { width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 16px; /* 16px avoids iOS zoom */ margin-bottom: 14px; }
.searchbox:focus, .select:focus, .field:focus { outline: none; border-color: var(--gold); }
.continue { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; border-color: var(--gold-dim); }
.btn { min-height: var(--tap); background: var(--gold); color: var(--on-gold); border: none; border-radius: 12px;
  padding: 10px 16px; cursor: pointer; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--line); font-weight: 600; }
.btn.disabled, .btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- Reader ---------- */
.reader-head { text-align: center; padding: 16px 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.reader-head .ar { font-family: "Amiri", serif; font-size: 2.2rem; color: var(--gold); line-height: 1.4; }
.reader-head .meta { color: var(--muted); font-size: .88rem; }
.bar { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.bar .btn { font-size: .9rem; }

#player { position: sticky; top: var(--head-h); z-index: 10; }
.player { margin: 0 0 12px; display: grid; gap: 8px;
  background: var(--panel); box-shadow: var(--shadow); padding: 10px 12px; }
.player-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.player-row.btns { justify-content: center; }
.player-row.btns .btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: .9rem; }
.player .select { flex: 1; margin: 0; min-height: 44px; font-size: 16px; }
#playerStatus { text-align: center; min-height: 1.3em; font-size: .85rem; }
.player .note { display: none; }

.ayah { display: flex; gap: 10px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px dashed var(--line);
  scroll-margin-top: calc(var(--head-h) + 130px); border-radius: 10px; }
.ayah.hl, .ayah.playing { background: rgba(var(--gold-rgb), .14); }
.ayah.playing { border-inline-start: 3px solid var(--gold); }
.ayah .badge { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gold-dim);
  background: transparent; color: var(--gold); display: grid; place-items: center; font-size: .8rem; cursor: pointer; margin-top: 4px; }
.ayah .badge:active, .ayah .badge:focus-visible { background: var(--gold); color: var(--on-gold); outline: none; }
.ayah .txt { font-family: "Amiri", "Traditional Arabic", serif; font-size: 1.7rem; line-height: 2.1;
  direction: rtl; text-align: right; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bm { flex: 0 0 auto; min-width: 40px; min-height: 40px; background: transparent; border: none; color: var(--muted);
  font-size: 1.4rem; cursor: pointer; margin-top: 2px; }
.bm.on { color: var(--gold); }
.sajdah-mark { color: var(--gold); font-size: 1.1rem; }
.note { font-size: .82rem; color: var(--muted); text-align: center; margin: 20px 0 0; }

/* ---------- Other views ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pager .btn { flex: 1 1 110px; }
.pager form { display: flex; gap: 8px; }
.pager input { width: 96px; min-height: var(--tap); padding: 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); text-align: center; font-size: 16px; }
.page-info { text-align: center; margin-bottom: 10px; font-size: .92rem; }
.page-img { display: block; width: 100%; max-width: 620px; height: auto; margin: 0 auto; border-radius: 10px;
  border: 1px solid var(--line); background: var(--page-bg); }
.hit { display: block; padding: 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.hit:active { background: var(--panel2); }
.hit .txt { font-family: "Amiri", serif; font-size: 1.25rem; direction: rtl; text-align: right; }
.hit .ref { color: var(--gold); font-size: .85rem; }
.bmrow { display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); }
.bmrow .hit { flex: 1; border-bottom: none; }
.rm { min-width: var(--tap); min-height: var(--tap); padding: 6px; }
.goform { display: grid; gap: 8px; max-width: 460px; }
.goform .btn { justify-self: stretch; }
.goform label { margin-top: 4px; }
/* Footer: see "Site footer" block at the end of this file. */

/* ---------- Toast (install / update / offline) ---------- */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--panel2); border: 1px solid var(--gold-dim); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.toast span { font-size: .92rem; }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 700px) {
  .brand .tagline { display: block; font-size: .8rem; color: var(--muted); }
  .brand h1 { font-size: 1.2rem; }
  .mega { align-items: start; padding: 40px 14px; }
  .mega-panel { max-width: 960px; border-radius: 18px; border-top: 1px solid var(--gold-dim); }
  .mega-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .player { border-radius: var(--radius); }
  .ayah .txt { font-size: 1.95rem; }
}

/* ---------- Phones ---------- */
@media (max-width: 380px) {
  .brand img { width: 34px; height: 34px; }
  .brand h1 { font-size: .95rem; }
  .lang-btn { padding: 0 10px; font-size: .88rem; }
  .ayah .txt { font-size: 1.5rem; }
  .ayah .badge { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ===== Hifz tracker ===== */
.hifz h2 { margin-bottom: 10px; }
.hifz h3 { margin: 0 0 10px; font-size: 1.02rem; color: var(--gold); }
.hifz .card { margin-bottom: 12px; }
.hifz-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 1.05rem; }
.hifz-stat span { color: var(--gold); font-weight: 700; }
.bar-track { height: 12px; border-radius: 999px; background: var(--panel2); overflow: hidden; margin: 10px 0 6px; border: 1px solid var(--line); }
.bar-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width .3s; }
.row-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row-form label, .mistake-step, .card label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.row-form .btn { grid-column: 1 / -1; }
.field.small { width: 90px; margin: 0; min-height: 44px; }
.srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: none; }
.sinfo { display: grid; gap: 2px; min-width: 0; }
.sactions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.sactions.wrap { flex-wrap: wrap; }
.btn.danger { color: #c0392b; border-color: #c0392b; }
.file-label { cursor: pointer; }
.warn { background: rgba(192,57,43,.12); color: var(--text); border: 1px solid #c0392b; border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.ok { color: var(--gold); font-weight: 600; }
@media (max-width: 380px) { .row-form { grid-template-columns: 1fr; } }

/* ===== Tajweed ===== */
:root { --tj-noon: #b5651d; --tj-mim: #1f6fa8; --tj-qal: #b3264e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tj-noon: #f0a35e; --tj-mim: #7fb8e6; --tj-qal: #f08ba6; } }
:root[data-theme="dark"] { --tj-noon: #f0a35e; --tj-mim: #7fb8e6; --tj-qal: #f08ba6; }
.tj-noon, .tj-mim, .tj-qal { font-weight: 700; border-bottom: 2px solid currentColor; padding: 0 1px; border-radius: 3px; }
.tj-noon { color: var(--tj-noon); } .tj-mim { color: var(--tj-mim); } .tj-qal { color: var(--tj-qal); }
.ayah-scan { font-family: "Amiri", "Traditional Arabic", serif; font-size: 1.8rem; line-height: 2.1; direction: rtl; text-align: right; }
.sec { margin: 18px 0 8px; font-size: 1rem; color: var(--gold); }
.legend { padding-inline-start: 18px; margin: 0; display: grid; gap: 6px; }
.legend-key { margin-top: 12px; font-size: .85rem; display: flex; gap: 14px; flex-wrap: wrap; }
.quiz-grid { grid-template-columns: 1fr 1fr; margin-top: 10px; }
.quiz-opt { min-height: var(--tap); }
.quiz-opt:disabled { opacity: .6; }
.mz-line { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mz-n { min-width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); color: var(--gold); display: grid; place-items: center; font-weight: 700; }
.mz-body { flex: 1; min-width: 0; }
.mz-ar { font-family: "Amiri", serif; font-size: 1.5rem; line-height: 2; direction: rtl; text-align: right; transition: filter .2s; }
.mz-ar.blur { filter: blur(7px); user-select: none; }
.mz-bn { font-size: .9rem; color: var(--muted); }
.mz-done { font-size: .85rem; display: flex; gap: 6px; align-items: center; white-space: nowrap; min-height: 40px; }
.mz-done input { width: 22px; height: 22px; }

/* =====================================================================
   Splash screen
   ===================================================================== */
.splash { display: none; position: fixed; inset: 0; z-index: 100; background: #000000; color: #ffffff;
  align-items: center; justify-content: center; padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  transition: opacity .6s ease, visibility .6s ease; }
.js .splash { display: flex; }
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 320px; }
.splash-mark { width: 112px; height: 112px; object-fit: contain; animation: qn-rise .9s cubic-bezier(.2,.7,.2,1) both; }
.splash-name { margin: 0; color: #DDB441; font-weight: 700; letter-spacing: .02em; font-size: 1.25rem; }
.splash-bn { font-size: 1.05rem; font-weight: 600; font-family: "Noto Sans Bengali", "Inter", "Segoe UI", system-ui, sans-serif; }
.splash-ar { font-family: "Amiri", serif; font-size: 1.2rem; font-weight: 700; color: #ffffff; opacity: .92; }
.splash-bar { width: 140px; height: 3px; margin: 22px 0 14px; border-radius: 3px; background: rgba(221,180,65,.18); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: #DDB441; border-radius: 3px;
  animation: qn-sweep 1.4s ease-in-out infinite; }
.splash-credit { margin: 0; font-size: .8rem; color: rgba(255,255,255,.7); }
.splash-credit strong { color: #ffffff; font-weight: 600; }
@keyframes qn-rise { from { opacity: 0; transform: translateY(14px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes qn-sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

/* =====================================================================
   Share button and sheet
   ===================================================================== */
.share-btn { color: var(--gold); }
.share-btn svg { display: block; }
.sheet { position: fixed; inset: 0; background: var(--overlay); z-index: 55; display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel { width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--gold-dim);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; color: var(--gold); font-size: 1.1rem; }
.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.share-opt { min-height: var(--tap); display: flex; align-items: center; justify-content: center; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: center; }
.share-opt:hover, .share-opt:focus-visible { border-color: var(--gold); }
.share-url { margin: 12px 0 0; font-size: .8rem; color: var(--muted); word-break: break-all; user-select: all; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-panel { max-width: 460px; border-radius: 18px; border-top: 1px solid var(--gold-dim); } }

/* =====================================================================
   Site footer
   ===================================================================== */
.site-foot { border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .85rem;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom)); text-align: center; }
.foot-main { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 16px; }
.foot-dev { margin: 0; color: var(--text); font-size: .95rem; }
.foot-author { color: var(--gold); font-weight: 700; }
.foot-org { margin: 0; font-size: .78rem; color: var(--muted); }
.foot-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0 auto 16px; max-width: 520px; }
.foot-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); }
.foot-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.foot-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.foot-clock { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .95rem; direction: ltr; unicode-bidi: isolate; }
.foot-sub { font-size: .72rem; color: var(--muted); }
.foot-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 14px; }
.foot-share, .foot-link { min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px;
  font-weight: 600; font-size: .9rem; text-decoration: none; cursor: pointer; }
.foot-share { background: var(--gold); color: var(--on-gold); border: none; }
.foot-link { border: 1px solid var(--gold-dim); color: var(--gold); background: transparent; }
.foot-legal { margin: 0; font-size: .75rem; color: var(--muted); }
@media (min-width: 560px) { .foot-grid { grid-template-columns: repeat(2, 1fr); } .foot-grid .foot-cell:first-child { grid-column: 1 / -1; } }
@media (min-width: 900px) { .foot-grid { grid-template-columns: repeat(3, 1fr); } .foot-grid .foot-cell:first-child { grid-column: auto; } }
