@font-face { font-family: "Amiri Quran"; src: url(fonts/amiri-quran-ar.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; font-display: swap; }
@font-face { font-family: "Amiri Quran"; src: url(fonts/amiri-quran-lat.woff2) format("woff2"); unicode-range: U+0000-00FF; font-display: swap; }
@font-face { font-family: "Hind Siliguri"; font-weight: 400; src: url(fonts/hind-400-bn.woff2) format("woff2"); unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1; font-display: swap; }
@font-face { font-family: "Hind Siliguri"; font-weight: 400; src: url(fonts/hind-400-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212; font-display: swap; }
@font-face { font-family: "Hind Siliguri"; font-weight: 600; src: url(fonts/hind-600-bn.woff2) format("woff2"); unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1; font-display: swap; }
@font-face { font-family: "Hind Siliguri"; font-weight: 600; src: url(fonts/hind-600-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212; font-display: swap; }

:root {
  --bg: #f6f3ea;
  --surface: #fffdf7;
  --surface-2: #efe9da;
  --ink: #1d2622;
  --ink-2: #55615b;
  --ink-3: #87918b;
  --line: #e2dccb;
  --brand: #0f3d33;
  --brand-ink: #f3e7c6;
  --gold: #b08a3e;
  --accent: #0f6b55;
  --hl: #fff2c9;
  --ar-size: 30px;
  --bn-size: 18px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 61, 51, .06), 0 4px 16px rgba(15, 61, 51, .06);
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f1e6cf; --surface: #f8eedb; --surface-2: #e9dbbd; --line: #dccaa5;
  --ink: #3b2f1e; --ink-2: #6b5a40; --ink-3: #94825f; --hl: #f5dc9f;
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #16201d; --surface-2: #1d2a26; --line: #26332f;
  --ink: #e8e4d8; --ink-2: #a9b2ab; --ink-3: #75817a;
  --brand: #0b2a23; --brand-ink: #e9d9ac; --gold: #d0ab5c; --accent: #5cc6a6; --hl: #2b3a2a;
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e1513; --surface: #16201d; --surface-2: #1d2a26; --line: #26332f;
    --ink: #e8e4d8; --ink-2: #a9b2ab; --ink-3: #75817a;
    --brand: #0b2a23; --brand-ink: #e9d9ac; --gold: #d0ab5c; --accent: #5cc6a6; --hl: #2b3a2a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hind Siliguri", "Noto Sans Bengali", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ar { font-family: "Amiri Quran", "KFGQPC Uthmanic Script HAFS", serif; direction: rtl; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 16px;
  background: var(--brand); color: var(--brand-ink);
}
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 0; font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; flex: none; }
.icon-btn:active { background: rgba(127, 127, 127, .18); }
#backBtn { margin-left: -8px; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; outline: none; }

/* ---------- home ---------- */
.hero {
  margin: 16px 0 8px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), #1a5a4a); color: var(--brand-ink);
  display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow);
}
.hero .k { font-size: 12.5px; opacity: .8; }
.hero .t { font-size: 18px; font-weight: 600; }
.hero .s { font-size: 13.5px; opacity: .85; }
.hero .go { margin-left: auto; padding: 8px 14px; border-radius: 999px; background: var(--brand-ink); color: var(--brand); font-weight: 600; font-size: 14px; white-space: nowrap; }

.tabs { position: sticky; top: 64px; z-index: 10; display: flex; gap: 6px; padding: 10px 0; background: var(--bg); }
.tab { flex: 1; padding: 8px 0; border-radius: 999px; font-size: 15px; color: var(--ink-2); background: var(--surface-2); }
.tab[aria-selected="true"] { background: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .tab[aria-selected="true"] { color: #0e1513; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .tab[aria-selected="true"] { color: #0e1513; } }

.filter { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin: 2px 0 10px; outline: none; }
.filter:focus { border-color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list li:last-child .row { border-bottom: 0; }
.row:active { background: var(--surface-2); }
.num {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  font-size: 14px; font-weight: 600; color: var(--gold);
  background: var(--surface-2); border-radius: 12px; transform: rotate(45deg);
}
.num > span { transform: rotate(-45deg); }
.row .mid { flex: 1; min-width: 0; }
.row .name { font-weight: 600; font-size: 16.5px; }
.row .meta { font-size: 13px; color: var(--ink-3); }
.row .arname { font-size: 24px; color: var(--accent); line-height: 1.2; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 16px; }

/* ---------- reader ---------- */
.surah-head { text-align: center; padding: 22px 8px 8px; }
.surah-head .arname { font-size: 40px; color: var(--accent); line-height: 2; margin-bottom: 4px; }
.surah-head .bn { font-size: 20px; font-weight: 600; }
.surah-head .meta { color: var(--ink-3); font-size: 14px; }
.surah-head .info-btn { margin-top: 10px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; color: var(--accent); }
.bismillah { text-align: center; font-size: 30px; color: var(--ink); padding: 8px 0 12px; }

.ayah { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin: 12px 0; padding: 14px 16px 10px; scroll-margin-top: 80px; transition: background .3s; }
.ayah.playing, .ayah.flash { background: var(--hl); }
.ayah.speaking { box-shadow: 0 0 0 2px var(--accent); }
.reading { background: var(--hl); border-radius: 8px; box-shadow: 0 0 0 4px var(--hl); transition: background .2s; }
.listen-btn { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; padding: 7px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14.5px; }
.listen-btn svg { width: 18px; height: 18px; }
select.filter { appearance: auto; }
.ayah .bar { display: flex; align-items: center; gap: 2px; margin: -4px -8px 4px 0; }
.ayah .ref { font-size: 13px; font-weight: 600; color: var(--gold); padding: 2px 10px; border-radius: 999px; background: var(--surface-2); margin-right: auto; }
.ayah .bar .icon-btn { width: 38px; height: 38px; color: var(--ink-3); }
.ayah .bar .icon-btn.on { color: var(--gold); }
.ayah .bar .icon-btn.on svg { fill: currentColor; }
.ayah .arabic { font-size: var(--ar-size); line-height: 2.05; text-align: right; margin: 4px 0 10px; word-spacing: 2px; }
.ayah .bangla { font-size: var(--bn-size); line-height: 1.75; margin: 0 0 6px; }
.ayah .uc { font-size: calc(var(--bn-size) - 1px); line-height: 1.7; margin: 0 0 6px; color: var(--accent); }
.ayah .uc .lbl { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--gold); background: var(--surface-2); border-radius: 6px; padding: 0 6px; margin-right: 6px; vertical-align: 2px; }
.ayah .tr { font-family: system-ui, sans-serif; font-style: italic; font-size: calc(var(--bn-size) - 3px); line-height: 1.6; color: var(--ink-3); margin: 0 0 8px; }
.ayah .bangla { border-top: 1px solid var(--line); padding-top: 8px; }
body.no-ar .ayah .arabic, body.no-ar .bismillah, body.no-uc .ayah .uc, body.no-tr .ayah .tr { display: none; }
.fn { display: inline-block; min-width: 1.5em; padding: 0 4px; margin: 0 1px; border-radius: 6px; font-size: .72em; line-height: 1.5; vertical-align: super; color: var(--accent); background: var(--surface-2); font-weight: 600; }
.tafsir-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--accent); padding: 6px 0; }
.tafsir-toggle svg { width: 16px; height: 16px; transition: transform .2s; }
.tafsir-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.tafsir { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; font-size: calc(var(--bn-size) - 2px); color: var(--ink-2); }
.note { margin: 0 0 14px; }
.note .nn { display: inline-block; font-weight: 600; color: var(--accent); margin-right: 6px; }
.note b, .intro b { color: var(--ink); }
.ar-in { font-family: "Amiri Quran", serif; font-size: 1.25em; direction: rtl; unicode-bidi: isolate; }

.pager { display: flex; gap: 10px; margin: 20px 0; }
.pager a { flex: 1; text-align: center; padding: 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--accent); font-weight: 600; font-size: 15px; }

/* ---------- search ---------- */
.result { display: block; text-decoration: none; color: inherit; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.result .ref { font-size: 13px; font-weight: 600; color: var(--gold); }
.result p { margin: 2px 0 0; font-size: 15.5px; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.count { font-size: 13.5px; color: var(--ink-3); margin: 0 2px 8px; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 760px; margin: 0 auto; max-height: 82dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; padding: 4px 8px 4px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 14px 18px 24px; font-size: 16.5px; line-height: 1.75; }
.intro p { margin: 0 0 12px; }

.setting { padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting label, .setting .lbl { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.setting .lbl span, .setting label span { color: var(--ink-3); font-weight: 400; }
.setting input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 15px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.btn { width: 100%; padding: 12px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; }
.btn:disabled { opacity: .6; }
.small { font-size: 13px; color: var(--ink-3); margin: 6px 0 0; }
.credit { font-size: 13px; color: var(--ink-3); text-align: center; margin: 24px 8px; line-height: 1.6; }
.credit a { color: var(--accent); }

/* ---------- player / toast ---------- */
.player {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 8px;
  border-radius: 18px; background: var(--brand); color: var(--brand-ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.player .play { background: var(--brand-ink); color: var(--brand); }
.player .play svg { fill: currentColor; }
.pl-label { flex: 1; min-width: 0; font-size: 14px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 50; background: #222; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); }

.spinner { margin: 60px auto; width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ayah-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.listen-chip { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 6px 14px 6px 10px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; }
.listen-chip svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.ayah.speaking .listen-chip { background: var(--gold); }
:root[data-theme="dark"] .listen-chip { color: #0e1513; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .listen-chip { color: #0e1513; } }
