/* ---------- Themes ---------- */
:root, [data-theme="light"] {
  --bm: #c2410c;
  --bg: #f7f7f5; --surface: #ffffff; --surface-2: #f1f1ee; --fg: #1c1c1e; --muted: #6b6b70;
  --line: #e7e7e3; --accent: #0f766e; --accent-soft: #e3f1ef; --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .04);
  color-scheme: light;
}
[data-theme="sepia"] {
  --bm: #b3362a;
  --bg: #f4ecd8; --surface: #fbf5e6; --surface-2: #efe4ca; --fg: #3b2f20; --muted: #7d6a50;
  --line: #e3d5b5; --accent: #8a5a19; --accent-soft: #f0e0bf; --accent-fg: #fffaf0;
  --shadow: 0 1px 2px rgb(60 40 10 / .06), 0 4px 16px rgb(60 40 10 / .05);
  color-scheme: light;
}
[data-theme="dark"] {
  --bm: #f2735f;
  --bg: #0e0f11; --surface: #17191c; --surface-2: #202328; --fg: #ececec; --muted: #9a9ca3;
  --line: #2a2d33; --accent: #2dd4bf; --accent-soft: #123a36; --accent-fg: #062622;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  color-scheme: dark;
}

:root {
  --ar-size: 34px; --tr-size: 17px; --radius: 14px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "Amiri Quran", "Amiri", "Scheherazade New", "Traditional Arabic", serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: 90px; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; padding-bottom: 110px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
/* No blue/grey tap flash on mobile; no double-tap-zoom delay on controls */
* { -webkit-tap-highlight-color: transparent; }
button, a, select, input, .mw, .word { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 20px; height: 20px; flex: none; }

select {
  appearance: none; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 34px 9px 12px; width: 100%;
}

.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(12px, 3vw, 28px); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.logo { width: 26px; height: 26px; color: var(--accent); }
.surah-picker { flex: 1; min-width: 0; max-width: 380px; margin: 0 auto; }
.topbar-actions { display: flex; gap: 4px; }
.i-moon { display: block; } .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }
[data-theme="dark"] .i-sun { display: block; }

/* ---------- Content ---------- */
.content { max-width: 860px; margin: 0 auto; padding: 24px clamp(12px, 3vw, 24px); overflow-x: clip; }
.verse-body { min-width: 0; }
.status { text-align: center; color: var(--muted); margin: 8px 0; min-height: 1em; }

.surah-header { text-align: center; padding: 28px 16px 20px; }
.surah-header .ar-name { font-family: var(--font-ar); font-size: 2.6rem; color: var(--accent); line-height: 2; margin: 0; }
.surah-header h1 { margin: 4px 0 2px; font-size: 1.6rem; letter-spacing: -.01em; }
.surah-header .meaning { color: var(--muted); margin: 0; }
.meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.bismillah { font-family: var(--font-ar); font-size: 2rem; margin: 24px 0 0; color: var(--fg); }
.play-surah { margin-top: 18px; display: inline-flex; align-items: center; gap: 8px; border: 0;
  background: var(--accent); color: var(--accent-fg); padding: 10px 18px; border-radius: 999px; font-weight: 600; }
.play-surah svg { width: 16px; height: 16px; }
.play-surah:hover { filter: brightness(1.08); }

/* ---------- Verses ---------- */
.verses { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
/* Verse card: medallion + key on top, Arabic, translation as a quoted block, actions in a footer bar */
.verse { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 14px 22px 10px; box-shadow: var(--shadow); transition: border-color .2s, background .2s; }
.verse.playing { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.verse-top { display: flex; align-items: center; gap: 10px; min-height: 38px; padding-right: 40px; }
/* Ayah number inside an eight-pointed star (two overlapping squares) */
.ayah-no { position: relative; isolation: isolate; flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.ayah-no::before, .ayah-no::after { content: ""; position: absolute; inset: 7px; z-index: -1; border-radius: 4px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.ayah-no::after { transform: rotate(45deg); }
.verse-ref { font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.verse-body { padding: 4px 0 2px; }
.verse .arabic { margin: 6px 0 14px; }
.verse .trans { padding-inline-start: 14px; border-inline-start: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.verse-actions { display: flex; align-items: center; gap: 2px; margin-top: 14px; padding-top: 8px;
  border-top: 1px dashed var(--line); }
.verse-actions .icon-btn { width: 36px; height: 36px; }
.act-play { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; border: 0; border-radius: 999px;
  padding: 7px 15px 7px 11px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .85rem;
  transition: background .15s, color .15s; }
.act-play svg { width: 15px; height: 15px; }
.act-play:hover { background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft)); }
.act-play .l-pause, .verse.is-playing .act-play .l-play { display: none; }
.verse.is-playing .act-play .l-pause { display: inline; }
.verse .i-pause, .play-main .i-pause { display: none; }
.verse.is-playing .i-pause, .player.is-playing .i-pause { display: block; }
.verse.is-playing .act-play .i-play, .player.is-playing .i-play { display: none; }
.verse.is-playing .act-play { background: var(--accent); color: var(--accent-fg); }

/* ---------- Bookmark ribbon: hangs from the top edge of a verse card or Mushaf page ---------- */
.bm { position: absolute; top: -1px; right: 18px; z-index: 2; width: 24px; height: 36px; padding: 0; border: 0;
  background: none; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bm::after { content: ""; position: absolute; inset: -6px -10px -10px; } /* bigger tap target */
.bm svg { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 50% 0; transform: scaleY(.72);
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1), color .2s; }
.bm path { fill: transparent; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  transition: fill .2s; }
.bm:hover, .bm:focus-visible { color: var(--bm); }
.bm:hover svg { transform: scaleY(.86); }
.is-bm > .bm { color: var(--bm); }
.is-bm > .bm svg { transform: none; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .22)); animation: bm-drop .55s cubic-bezier(.3, 1.5, .5, 1); }
.is-bm > .bm path { fill: currentColor; }
@keyframes bm-drop { from { transform: scaleY(.3); } }
.bm-tag { display: none; margin-left: auto; align-items: center; font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--bm); white-space: nowrap; }
.verse.is-bm .bm-tag { display: inline-flex; animation: fade .3s; }
.verse.is-bm { border-color: color-mix(in srgb, var(--bm) 45%, var(--line)); }
.kick-bm { width: 9px; height: 13px; margin-right: 6px; vertical-align: -1px; fill: var(--bm); }

.arabic { font-family: var(--font-ar); font-size: var(--ar-size); line-height: 2.1; text-align: right;
  margin: 0 0 10px; word-spacing: .05em; }
.word { position: relative; font: inherit; line-height: inherit; background: none; border: 0; padding: 0 .08em;
  margin: 0; border-radius: 8px; transition: color .12s, background .12s; }
.word:hover { color: var(--accent); }
.word.active { background: var(--accent-soft); color: var(--accent); }
/* Word tooltip (transliteration + meaning) is a single floating element: see .word-tip */
.word-tip { position: fixed; z-index: 70; left: 0; top: 0; max-width: min(320px, calc(100vw - 16px)); pointer-events: none;
  display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px; background: var(--fg); color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / .25); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
  text-align: center; }
.word-tip.show { opacity: 1; transform: none; }
.word-tip::after { content: ""; position: absolute; left: calc(var(--ax, 50%) - 6px); width: 12px; height: 12px;
  background: inherit; transform: rotate(45deg); bottom: -5px; }
.word-tip.below::after { bottom: auto; top: -5px; }
.word-tip .wt-tr { font: italic 500 13px/1.35 var(--font-ui); opacity: .8; overflow-wrap: anywhere; }
.word-tip .wt-mn { font: 600 15px/1.45 var(--font-ui), "Noto Naskh Arabic", sans-serif; overflow-wrap: anywhere; }
.word-tip .wt-mn.rtl { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; line-height: 2; font-size: 16px; }
.end { display: inline-grid; place-items: center; color: var(--accent); font-size: .8em; padding: 0 .15em; }

.trans { margin: 0; font-size: var(--tr-size); line-height: 1.7; color: color-mix(in srgb, var(--fg) 88%, var(--muted)); }
body.hide-trans .trans { display: none; }

/* Skeleton */
.skeleton { display: grid; gap: 12px; }
.skeleton[hidden] { display: none; }
.sk-card { height: 150px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

.surah-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.nav-btn { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px;
  font-weight: 600; color: var(--fg); transition: border-color .15s; }
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn[hidden] { visibility: hidden; display: block; }
.nav-btn:last-child { text-align: right; }
.nav-btn:first-child { text-align: left; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 40; animation: fade .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 50; background: var(--surface);
  border-left: 1px solid var(--line); padding: 16px 20px; overflow-y: auto; transform: translateX(100%);
  transition: transform .25s ease; box-shadow: var(--shadow); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 1.15rem; }
.field { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface-2); padding: 4px; border-radius: 10px; gap: 4px; }
.segmented button { border: 0; background: transparent; padding: 8px; border-radius: 8px; font-size: .9rem; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.switch-row { grid-template-columns: 1fr auto; align-items: center; }
.switch { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative;
  cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.drawer-foot { color: var(--muted); font-size: .8rem; margin-top: 20px; }

/* ---------- Player ---------- */
.player { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; width: min(560px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 40px rgb(0 0 0 / .18);
  overflow: hidden; animation: rise .25s ease; }
.player[hidden] { display: none; }
.player-progress { height: 3px; background: var(--surface-2); overflow: hidden; }
/* scaleX instead of width: no layout work per animation frame */
#progressBar { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); will-change: transform; }
.player-body { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; }
.player-info { display: grid; min-width: 0; }
.player-info strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-info span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-controls { display: flex; align-items: center; gap: 4px; }
.play-main { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; transition: transform .1s, filter .15s; }
.play-main:hover { filter: brightness(1.08); }
.play-main:active { transform: scale(.94); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ---------- Views ---------- */
.view[hidden] { display: none !important; }
body:not([data-view="read"]) [data-show-on="read"] { visibility: hidden; }

/* Home */
.home { max-width: 640px; margin: 0 auto; padding: clamp(32px, 8vh, 80px) 20px 40px; }
.hero { text-align: center; margin-bottom: 36px; }
.hero-logo { width: 72px; height: 72px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 22px;
  background: var(--accent-soft); color: var(--accent); }
.hero-logo svg { width: 40px; height: 40px; }
.hero-ar { font-family: var(--font-ar); font-size: 2.4rem; color: var(--accent); margin: 0 0 6px; line-height: 2.2; }
.hero h1 { margin: 0; font-size: 2rem; letter-spacing: -.02em; }
.hero-sub { margin: 6px 0 0; color: var(--muted); }
.home-cards { display: grid; gap: 14px; }
.home-card { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--fg); text-decoration: none;
  transition: border-color .15s, transform .15s; }
.home-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.home-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent); }
.home-icon svg { width: 26px; height: 26px; }
.home-icon.big { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 12px; }
.home-icon.big svg { width: 38px; height: 38px; }
.home-text { flex: 1; display: grid; gap: 3px; min-width: 0; }
.home-text strong { font-size: 1.1rem; }
.home-text span { color: var(--muted); font-size: .9rem; }
.home-arrow { color: var(--muted); }
.home-card:hover .home-arrow { color: var(--accent); }
.badge { font-size: .72rem; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); white-space: nowrap; }

/* Listen view: see listen.css */

/* ---------- Home (redesign) ---------- */
.home2 { max-width: 980px; margin: 0 auto; padding: 18px clamp(14px, 3vw, 28px) 30px; display: grid; gap: 22px; }
.h-hero { position: relative; overflow: hidden; border-radius: 24px; padding: clamp(22px, 4vw, 38px);
  background: linear-gradient(135deg, #0f766e 0%, #115e59 45%, #1e3a8a 100%); color: #fff; box-shadow: 0 18px 50px rgb(15 118 110 / .25); }
[data-theme="sepia"] .h-hero { background: linear-gradient(135deg, #8a5a19, #6b4413 55%, #3f2a10); box-shadow: 0 18px 50px rgb(138 90 25 / .25); }
/* Subtle eight-point star pattern */
.h-hero-pattern { position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.2'%3E%3Cpath d='M32 6l7.4 17.9L57 31.3l-17.6 7.4L32 56.6l-7.4-17.9L7 31.3l17.6-7.4z'/%3E%3Crect x='17' y='16.3' width='30' height='30' transform='rotate(45 32 31.3)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px; -webkit-mask-image: linear-gradient(115deg, transparent 20%, #000 75%); mask-image: linear-gradient(115deg, transparent 20%, #000 75%); }
.h-hero-meta { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: .88rem; opacity: .9; }
.h-date { font-weight: 600; background: rgb(255 255 255 / .14); padding: 3px 10px; border-radius: 999px; }
.h-date:empty { display: none; }
.h-brand { position: relative; display: flex; align-items: center; gap: 16px; margin-top: clamp(22px, 5vw, 42px); }
.h-logo { width: 62px; height: 62px; flex: none; display: grid; place-items: center; border-radius: 18px; background: rgb(255 255 255 / .16);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25); }
.h-logo svg { width: 36px; height: 36px; color: #fff; }
.h-brand h1 { margin: 0; font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: -.03em; line-height: 1.1; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.h-brand h1 span { font-family: var(--font-ar); font-weight: 400; font-size: .8em; opacity: .85; line-height: 1.6; }
.h-brand p { margin: 8px 0 0; opacity: .85; }

.h-section { display: grid; gap: 12px; }
.h-section[hidden] { display: none; }
.h-title { margin: 0; font-size: 1.1rem; letter-spacing: -.01em; }

/* Jump back in */
.h-jump { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.h-jump-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); text-align: left; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.h-jump-card[hidden] { display: none; }
.h-jump-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.h-jump-art { width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center; background: var(--accent); color: var(--accent-fg); }
.h-jump-card.is-listen .h-jump-art { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.h-jump-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.h-jump-text strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-jump-text span:not(.continue-kicker) { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-jump-card.is-listen .continue-kicker { color: #7c3aed !important; }
[data-theme="dark"] .h-jump-card.is-listen .continue-kicker { color: #a78bfa !important; }
.h-arrow { color: var(--muted); }
.h-play { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--fg); color: var(--bg); flex: none; }
.h-play svg { width: 18px; height: 18px; }

/* Main tiles */
.h-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.h-tile { position: relative; overflow: hidden; display: grid; gap: 6px; align-content: start; min-height: 210px; padding: 22px;
  border-radius: 22px; color: #fff; text-decoration: none; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.h-tile:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgb(0 0 0 / .18); }
.h-tile.is-read { background: linear-gradient(145deg, #14b8a6, #0f766e 55%, #115e59); }
.h-tile.is-listen { background: linear-gradient(145deg, #6366f1, #4f46e5 50%, #6d28d9); }
.h-tile-ar { position: absolute; right: -6px; bottom: -34px; font-family: var(--font-ar); font-size: 150px; line-height: 1; opacity: .13; pointer-events: none; }
.h-tile-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: rgb(255 255 255 / .18); margin-bottom: 8px; }
.h-tile-icon svg { width: 26px; height: 26px; }
.h-tile strong { font-size: 1.35rem; letter-spacing: -.01em; }
.h-tile > span:not(.h-tile-ar):not(.h-tile-icon):not(.h-tile-go) { opacity: .88; font-size: .9rem; line-height: 1.5; max-width: 34ch; }
.h-tile-go { margin-top: auto; padding-top: 14px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; }
.h-tile-go svg { width: 18px; height: 18px; transition: transform .15s; }
.h-tile:hover .h-tile-go svg { transform: translateX(4px); }

/* Ayah of the day */
.h-ayah { position: relative; padding: clamp(18px, 3.5vw, 30px); border-radius: 22px; border: 1px solid var(--line); background:
  radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 60%), var(--surface);
  box-shadow: var(--shadow); display: grid; gap: 12px; }
.h-ayah-ar { margin: 0; font-family: var(--font-ar); font-size: clamp(24px, 4vw, 34px); line-height: 2.1; text-align: center; }
.h-ayah-ar:empty::before { content: "…"; color: var(--muted); }
.h-ayah-tr { margin: 0 auto; max-width: 62ch; text-align: center; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.h-ayah-tr.rtl-script { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; line-height: 2.3; }
.h-ayah-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px;
  padding-top: 12px; border-top: 1px solid var(--line); }
.h-ayah-ref { font-weight: 700; color: var(--accent); font-size: .9rem; }
.h-ayah-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Quick picks */
.h-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.h-pick { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-align: left; transition: border-color .15s, transform .15s; }
.h-pick:hover { border-color: var(--accent); transform: translateY(-1px); }
.h-pick.tagged { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.h-pick-art { --h: 170; width: 46px; height: 46px; flex: none; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 45) 60% 26%)); container-type: inline-size; }
.h-pick-text { display: grid; min-width: 0; }
.h-pick-text strong { font-size: .95rem; }
.h-pick-text span { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-tag { position: absolute; top: -8px; right: 10px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); }

/* ---------- Your tree (hero) ---------- */
:root { --tr-leaf: #5fb04a; --tr-leaf2: #86c95f; --tr-leaf3: #3d8a3a; --tr-stem: #5fa048; --tr-trunk: #7a4f2a; --tr-soil: #8a5b33; --tr-fruit: #f2b53c; }
[data-theme="dark"] { --tr-leaf: #4fa845; --tr-leaf2: #7cc25a; --tr-leaf3: #2f7a33; --tr-soil: #5e3d22; }
.h-tree { margin-left: auto; flex: none; display: grid; justify-items: center; gap: 1px; width: 118px; padding: 8px 8px 9px;
  border: 1px solid rgb(255 255 255 / .22); border-radius: 18px; background: rgb(255 255 255 / .12); color: #fff;
  backdrop-filter: blur(3px); transition: background .15s, transform .15s; }
.h-tree:hover { background: rgb(255 255 255 / .2); transform: translateY(-2px); }
.h-tree-art { width: 78px; height: 84px; display: block; position: relative; --fall: 70px; }
.tree-holder { display: block; width: 100%; height: 100%; }
/* Watering: three drops fall onto the soil, then a small splash ring */
.tree-drops { position: absolute; inset: 0; pointer-events: none; }
.tree-drops i { position: absolute; top: -4px; width: 7px; height: 7px; border-radius: 0 50% 50% 50%; opacity: 0;
  background: linear-gradient(135deg, #d6f1ff, #3fa9f5); box-shadow: 0 0 0 1px rgb(255 255 255 / .35);
  transform: translateY(0) rotate(45deg); animation: tree-drop .72s cubic-bezier(.5, 0, .9, .5) forwards; will-change: transform, opacity; }
.tree-drops i:nth-child(1) { left: calc(50% - 12px); animation-delay: 0s; }
.tree-drops i:nth-child(2) { left: calc(50% + 6px); animation-delay: .16s; }
.tree-drops i:nth-child(3) { left: calc(50% - 3px); animation-delay: .32s; }
.tree-drops b { position: absolute; left: 50%; bottom: 4%; width: 44%; height: 9%; translate: -50% 0; border-radius: 50%;
  border: 2px solid rgb(150 215 255 / .9); opacity: 0; animation: tree-splash .6s .95s ease-out forwards; }
@keyframes tree-drop {
  0% { opacity: 0; transform: translateY(0) rotate(45deg); }
  15% { opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translateY(var(--fall)) rotate(45deg) scale(.8); }
}
@keyframes tree-splash { 0% { opacity: .95; transform: scale(.35); } 100% { opacity: 0; transform: scale(1.35); } }
/* The day label pops when it changes */
.h-tree-day.bump { animation: tree-bump .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tree-bump { 0% { transform: scale(.85); opacity: .4; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.h-tree-art svg, .tree-big svg { width: 100%; height: 100%; display: block; overflow: visible; }
.h-tree-day { font-size: .78rem; font-weight: 700; line-height: 1.2; }
.h-tree-count { font-size: .68rem; opacity: .8; line-height: 1.2; }
.h-tree.complete { border-color: rgb(242 181 60 / .7); box-shadow: 0 0 0 3px rgb(242 181 60 / .18); }
.h-tree.testing::after { content: "TEST"; position: absolute; margin-top: -6px; font-size: .55rem; font-weight: 800; letter-spacing: .08em;
  background: #f2b53c; color: #3b2a08; padding: 1px 5px; border-radius: 4px; }
/* Grow animation: the plant springs up from the ground */
.tree-plant { transform-origin: 50px 100px; }
.grow .tree-plant { animation: tree-grow .9s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes tree-grow { 0% { transform: scale(.55); opacity: .4; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
.stage-7 .tree-plant circle[fill="var(--tr-fruit)"] { animation: fruit 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fruit { 50% { transform: scale(1.25); } }
/* Reduced motion: no falling or springing; drops fade in at the soil and the tree fades up to its new stage */
@media (prefers-reduced-motion: reduce) {
  .stage-7 .tree-plant circle, .h-tree-day.bump { animation: none; }
  .h-tree-art .tree-drops i, .tree-big .tree-drops i { animation: tree-drop-calm 1s ease forwards !important; }
  .h-tree-art .tree-drops b, .tree-big .tree-drops b { animation: tree-fade-ring .6s .9s ease forwards !important; }
  .h-tree-art.grow .tree-plant, .tree-big.grow .tree-plant { animation: tree-fade .6s ease !important; }
}
@keyframes tree-drop-calm {
  0% { opacity: 0; transform: translateY(calc(var(--fall) * .78)) rotate(45deg); }
  35%, 70% { opacity: 1; transform: translateY(calc(var(--fall) * .78)) rotate(45deg); }
  100% { opacity: 0; transform: translateY(calc(var(--fall) * .78)) rotate(45deg); }
}
@keyframes tree-fade-ring { 0% { opacity: .8; } 100% { opacity: 0; } }
@keyframes tree-fade { from { opacity: .15; } to { opacity: 1; } }

/* Tree details sheet */
.l-sheet.tree-sheet { width: min(460px, calc(100vw - 16px)); }
.tree-body { display: flex; gap: 16px; align-items: center; padding: 4px 18px 10px; }
.tree-big { position: relative; --fall: 118px; width: 140px; height: 150px; flex: none; border-radius: 18px; padding: 8px;
  background: radial-gradient(90% 70% at 50% 35%, color-mix(in srgb, var(--accent-soft) 80%, transparent), transparent 70%), var(--surface-2); }
.tree-info { display: grid; gap: 8px; min-width: 0; }
.tree-stage { font-size: 1.15rem; font-weight: 800; }
.tree-line { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.tree-week { display: flex; gap: 6px; }
.tw-day { display: grid; justify-items: center; gap: 3px; font-size: .68rem; color: var(--muted); }
.tw-day i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: block; }
.tw-day.on i { background: var(--tr-leaf); border-color: var(--tr-leaf3); box-shadow: inset 0 0 0 3px rgb(255 255 255 / .35); }
.tw-day.today i { outline: 2px solid var(--accent); outline-offset: 2px; }
.tw-day.future i { border-style: dashed; }
.tree-stats { display: flex; align-items: baseline; gap: 6px; }
.tree-stats strong { font-size: 1.5rem; color: var(--accent); }
.tree-stats span { color: var(--muted); font-size: .85rem; }
.tree-note { margin: 0; font-size: .75rem; color: var(--muted); line-height: 1.5; }
.tree-test { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 16px 6px; padding: 10px; border-radius: 12px;
  border: 1px dashed #f2b53c; background: color-mix(in srgb, #f2b53c 12%, transparent); }
.tree-test[hidden] { display: none; }
.tree-test > span { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #b7791f; margin-right: 4px; }
@media (max-width: 560px) {
  .h-logo { display: none; } /* room for the tree beside the title on phones */
  .h-brand h1 { font-size: 1.9rem; }
  .h-tree { width: 92px; padding: 6px 6px 7px; border-radius: 16px; }
  .h-tree-art { width: 60px; height: 64px; --fall: 54px; }
  .h-tree-count { display: none; }
  .tree-body { flex-direction: column; text-align: center; }
  .tree-week { justify-content: center; }
  .tree-stats { justify-content: center; }
}

/* ---------- Study panel (tafsir + word study) ---------- */
.l-sheet.study-dlg { width: min(680px, calc(100vw - 16px)); max-height: min(90vh, 920px); overflow: hidden; display: none; }
.l-sheet.study-dlg[open] { display: flex; flex-direction: column; }
.study-head { padding: 16px 18px 6px; outline: none; }
.study-head strong { color: var(--accent); font-size: .9rem; }
.study-ar { margin: 6px 0 4px; font-family: var(--font-ar); font-size: clamp(20px, 3.4vw, 26px); line-height: 2; text-align: right;
  max-height: 6.2em; overflow-y: auto; overscroll-behavior: contain; }
.study-tr { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.6; max-height: 4.8em; overflow: auto; }
.study-tr.rtl-script { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; line-height: 2.2; text-align: right; }
.study-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 10px 16px 0; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.study-tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.study-tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.tafsir-bar { margin: 10px 16px 0; }
.tafsir-bar[hidden] { display: none; }
.study-body { flex: 1; min-height: 160px; overflow-y: auto; overscroll-behavior: contain; padding: 12px 18px 8px; margin-top: 4px; }
.study-status, .study-note { color: var(--muted); font-size: .88rem; margin: 6px 0 12px; }
.tafsir-text { font-size: 1rem; line-height: 1.75; }
.tafsir-text h1, .tafsir-text h2, .tafsir-text h3 { font-size: 1.05rem; margin: 16px 0 6px; color: var(--accent); }
.tafsir-text p { margin: 0 0 12px; }
.tafsir-text.rtl { font-family: "Noto Naskh Arabic", var(--font-ar), serif; text-align: right; direction: rtl; line-height: 2.1; font-size: 1.1rem; }
.tafsir-text.urdu { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; line-height: 2.5; }
.ws-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ws-item { display: grid; grid-template-columns: 22px 38px 1fr auto; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.ws-n { font-size: .75rem; color: var(--muted); text-align: center; }
.ws-play { width: 36px; height: 36px; border-radius: 50%; background: var(--surface); }
.ws-text { display: grid; min-width: 0; }
.ws-ar { font-family: var(--font-ar); font-weight: 400; font-size: 1.6rem; line-height: 1.6; }
.ws-tr { font-size: .8rem; font-style: italic; color: var(--muted); }
.ws-mean { font-size: .9rem; }
.ws-find { font-size: .78rem; padding: 6px 10px; }
.ws-occ { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 8px; }
.ws-count { margin: 0 0 6px; font-size: .82rem; font-weight: 700; color: var(--accent); }
.ws-occ-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 280px; overflow-y: auto; }
.ws-occ-item { width: 100%; display: grid; gap: 2px; padding: 8px 10px; border: 0; border-radius: 10px; background: var(--surface); text-align: left; }
.ws-occ-item:hover { outline: 1px solid var(--accent); }
.ws-occ-item.here { outline: 1px dashed var(--accent); }
.ws-occ-ref { font-size: .75rem; font-weight: 700; color: var(--accent); }
.ws-occ-ar { font-family: var(--font-ar); font-size: 1.15rem; line-height: 1.9; text-align: right; }
.ws-more { margin-top: 6px; }
@media (max-width: 560px) { .ws-item { grid-template-columns: 34px 1fr; } .ws-n { display: none; } .ws-find { grid-column: 1 / -1; justify-self: start; } }

/* ---------- Ayah image dialog ---------- */
.l-sheet.snap-dlg { width: min(460px, calc(100vw - 16px)); }
.snap-preview { margin: 0 16px; border-radius: 14px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1080 / 1350;
  max-height: 58vh; display: grid; place-items: center; box-shadow: 0 10px 30px rgb(0 0 0 / .18); }
.snap-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.snap-preview img:not([src]) { opacity: 0; }
.snap-styles { grid-template-columns: repeat(3, 1fr); margin: 12px 16px 0; }
.snap-actions { display: flex; gap: 8px; margin: 12px 16px 4px; }
.snap-actions .btn-primary { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; padding: 12px; font-size: .95rem; }
.snap-actions .btn-primary svg { width: 18px; height: 18px; }
.snap-actions .pill-btn[hidden] { display: none; }

/* Existing cards reused on home */
.home2 .install-card { margin: 0; }
.home2 .app-foot { margin-top: 10px; }

@media (max-width: 640px) {
  .h-tiles { grid-template-columns: 1fr; }
  .h-tile { min-height: 170px; }
  .h-tile-ar { font-size: 120px; }
  .h-ayah-foot { justify-content: center; }
  .h-quick { grid-template-columns: 1fr 1fr; }
  .h-pick-text span { display: none; }
}
@media (max-width: 380px) { .h-quick { grid-template-columns: 1fr; } }

/* ---------- Tajweed colours ---------- */
:root, [data-theme="light"] {
  --tj-madd6: #9c1c1c; --tj-madd45: #db2b39; --tj-madd246: #ea6a1f; --tj-madd2: #b98200;
  --tj-ghunnah: #179443; --tj-idgham: #0b8577; --tj-iqlab: #1597c9; --tj-qalqalah: #2f5bd8; --tj-silent: #9ca3af;
}
[data-theme="sepia"] {
  --tj-madd6: #8f1717; --tj-madd45: #c72431; --tj-madd246: #d25f16; --tj-madd2: #9c6d00;
  --tj-ghunnah: #147a38; --tj-idgham: #0a7065; --tj-iqlab: #127fa8; --tj-qalqalah: #284fbd; --tj-silent: #a3927a;
}
[data-theme="dark"] {
  --tj-madd6: #ff5a5a; --tj-madd45: #ff8c9a; --tj-madd246: #ffa45c; --tj-madd2: #f4cf48;
  --tj-ghunnah: #4ade80; --tj-idgham: #2dd4bf; --tj-iqlab: #56c8f5; --tj-qalqalah: #8fa8ff; --tj-silent: #6b7280;
}
.tj-madd6 { color: var(--tj-madd6); } .tj-madd45 { color: var(--tj-madd45); } .tj-madd246 { color: var(--tj-madd246); }
.tj-madd2 { color: var(--tj-madd2); } .tj-ghunnah { color: var(--tj-ghunnah); } .tj-idgham { color: var(--tj-idgham); }
.tj-iqlab { color: var(--tj-iqlab); } .tj-qalqalah { color: var(--tj-qalqalah); } .tj-silent { color: var(--tj-silent); }
.tj-bg-madd6 { background: var(--tj-madd6); } .tj-bg-madd45 { background: var(--tj-madd45); } .tj-bg-madd246 { background: var(--tj-madd246); }
.tj-bg-madd2 { background: var(--tj-madd2); } .tj-bg-ghunnah { background: var(--tj-ghunnah); } .tj-bg-idgham { background: var(--tj-idgham); }
.tj-bg-iqlab { background: var(--tj-iqlab); } .tj-bg-qalqalah { background: var(--tj-qalqalah); } .tj-bg-silent { background: var(--tj-silent); }
/* Word states keep their highlight background without hiding the rule colours */
.word:hover .tj, .word.active .tj, .word.reading .tj { filter: saturate(1.2); }

/* Toggle pill with a tiny three-colour swatch */
.tj-swatch { display: inline-flex; gap: 2px; margin-right: 2px; }
.tj-swatch i { width: 6px; height: 14px; border-radius: 3px; display: block; }
.tj-toggle.on { color: var(--fg); border-color: var(--accent); background: var(--accent-soft); }
.tools-pill { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; margin-right: auto; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600;
  font-size: .85rem; box-shadow: var(--shadow); }
.tools-pill:hover { color: var(--fg); }

/* Colour key under the surah header */
.tj-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 16px auto 0; max-width: 720px; }
.tj-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); font-size: .78rem; font-weight: 500; }
.tj-chip:hover { border-color: var(--accent); }
.tj-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.tj-dot.lg { width: 14px; height: 14px; }
.tj-guide-btn { font-weight: 700; color: var(--accent); }
.tj-guide-list { list-style: none; margin: 0; padding: 0 12px 6px; display: grid; gap: 6px; max-height: 60vh; overflow-y: auto; }
.tj-rule { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.tj-rule.focus { outline: 2px solid var(--accent); }
.tj-rule-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tj-rule-head strong { font-size: .95rem; }
.tj-ar { font-family: var(--font-ar); font-size: 1.15rem; color: var(--muted); }
.tj-count { margin-left: auto; font-size: .75rem; font-weight: 700; color: var(--muted); background: var(--surface); padding: 3px 8px; border-radius: 999px; }
.tj-rule p { margin: 6px 0 0 24px; font-size: .86rem; color: var(--muted); line-height: 1.5; }

/* ---------- PWA: offline bar, install card, download badges ---------- */
.offline-bar { position: sticky; top: 61px; z-index: 19; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 12px; background: #7c2d12; color: #fff; font-size: .85rem; font-weight: 600; }
.offline-bar[hidden] { display: none; }
.offline-bar svg { width: 18px; height: 18px; }
.install-card { border-style: dashed; }
.install-card[hidden] { display: none; }
.install-btn { border: 0; padding: 9px 18px; font-size: .9rem; }
.install-btn[hidden] { display: none; }
@media (max-width: 560px) {
  .install-card { flex-wrap: wrap; position: relative; padding-right: 44px; }
  .install-card .home-text { flex: 1 1 60%; }
  .install-card .install-btn { order: 3; flex: 1 1 100%; }
  .install-card #installClose { position: absolute; top: 8px; right: 8px; }
}
.save-offline.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.save-offline:disabled { opacity: .7; cursor: progress; }
.dl-badge { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 6px; vertical-align: -2px; color: var(--accent); }
.dl-badge svg { width: 16px; height: 16px; }
.dl-badge.busy { animation: pulse 1.2s ease-in-out infinite; }
.dl-badge[hidden] { display: none; }
@keyframes pulse { 50% { opacity: .35; } }
.l-dl-btn.on { color: var(--accent); border-color: var(--accent); }
.l-dl-btn[hidden] { display: none; }

/* Home footer */
.app-foot { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 40px; padding: 16px 0 8px; }
.app-foot p { margin: 0; }
.app-foot-note { margin-top: 6px !important; font-size: .8rem; line-height: 1.5; max-width: 420px; margin-inline: auto !important; opacity: .85; }
.app-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.app-foot a:hover { text-decoration: underline; }
.share-miftah { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); color: var(--accent);
  font: 600 .88rem var(--font-ui); cursor: pointer; transition: filter .15s; }
.share-miftah svg { width: 16px; height: 16px; }
.share-miftah:hover { filter: brightness(1.05); }

/* ---------- One-time tips ---------- */
.tour { position: fixed; inset: 0; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity .2s; }
.tour.show { opacity: 1; pointer-events: auto; }
.tour-block { position: fixed; inset: 0; }
.tour-spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px rgb(0 0 0 / .62), 0 0 0 2px var(--accent);
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease, box-shadow .25s; pointer-events: none; }
.tour-spot.none { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgb(0 0 0 / .62); }
.tour-card { position: fixed; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 16px 12px; box-shadow: 0 18px 50px rgb(0 0 0 / .35); transition: left .35s ease, top .35s ease; }
.tour-card.in { animation: tour-in .28s ease; }
@keyframes tour-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.tour-card[data-arrow]::before { content: ""; position: absolute; left: calc(var(--ax, 50%) - 7px); width: 14px; height: 14px;
  background: var(--surface); border: 1px solid var(--line); transform: rotate(45deg); }
.tour-card[data-arrow="up"]::before { top: -8px; border-right: 0; border-bottom: 0; }
.tour-card[data-arrow="down"]::before { bottom: -8px; border-left: 0; border-top: 0; }
.tour-card[data-arrow=""]::before { display: none; }
.tour-count { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tour-title { display: block; font-size: 1.05rem; margin: 4px 0 4px; }
.tour-text { margin: 0 0 14px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-spacer { flex: 1; }
.tour-dots { display: flex; gap: 4px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: width .2s, background .2s; }
.tour-dots i.on { width: 16px; border-radius: 3px; background: var(--accent); }
.tour-skip { border: 0; background: none; color: var(--muted); font-weight: 600; padding: 8px 10px; border-radius: 8px; }
.tour-skip:hover { color: var(--fg); background: var(--surface-2); }
.tour-next { border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 700; padding: 8px 18px; border-radius: 999px; }
.tour-next:hover { filter: brightness(1.08); }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card { transition: none; } }

/* Continue reading */
.continue-card { width: 100%; font: inherit; text-align: left; cursor: pointer;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent-soft) 70%, var(--surface)), var(--surface)); }
.continue-card[hidden] { display: none; }
.continue-art { container-type: inline-size; background: var(--accent); color: var(--accent-fg); }
.continue-glyph { font-family: "surahnames"; line-height: 1; font-size: min(calc(62cqw), calc(84cqw / var(--gw, 1.6)));
  translate: calc(var(--gx, 0) * 1em) calc(var(--gy, 0) * 1em); }
.continue-kicker { font-size: .72rem !important; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent) !important; }
.btn-primary { display: inline-block; background: var(--accent); color: var(--accent-fg); text-decoration: none;
  padding: 10px 20px; border-radius: 999px; font-weight: 600; }

/* Translation quick-switch in surah header */
.trans-pill { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: .85rem; }
.trans-pill:hover { border-color: var(--accent); color: var(--accent); }
.trans-pill svg { width: 16px; height: 16px; }
.header-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; }
.header-actions .play-surah, .header-actions .trans-pill { margin-top: 0; }

/* RTL-script translations (Urdu, Persian, …) */
.trans.rtl-script { font-family: "Noto Naskh Arabic", var(--font-ui); line-height: 2; text-align: right; }
.trans.urdu { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; line-height: 2.5; }

/* Word being recited */
.word.reading { color: var(--accent); background: var(--accent-soft); }

/* Player reciter switcher */
.player-reciter { display: flex; align-items: center; gap: 4px; color: var(--muted); min-width: 0; }
.player-reciter svg { width: 14px; height: 14px; }
.player-reciter select { background-color: transparent; border: 0; padding: 2px 22px 2px 0; font-size: .8rem;
  color: var(--muted); background-position: right 4px center; width: auto; max-width: 100%; text-overflow: ellipsis; }
.player-reciter select:hover { color: var(--accent); }
.player-reciter select option { color: var(--fg); background: var(--surface); }
.spinner { display: none; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor;
  border-right-color: transparent; animation: spin .7s linear infinite; }
.player.is-loading .spinner { display: block; }
.player.is-loading .i-play, .player.is-loading .i-pause { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mode switch (Translation / Reading) ---------- */
.mode-switch { grid-template-columns: repeat(2, auto); flex: none; }
.mode-switch button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; }
.mode-switch svg { width: 16px; height: 16px; }
body[data-mode="reading"] .trans-pill { display: none; }
@media (max-width: 720px) { .mode-switch span { display: none; } .mode-switch button { padding: 7px 9px; } }

/* ---------- Mushaf (reading view) ---------- */
@font-face {
  font-family: "surahnames";
  src: url("https://verses.quran.foundation/fonts/quran/surah-names/v1/sura_names.woff2") format("woff2");
  font-display: block;
}
@font-face {
  font-family: "UthmanicHafs";
  src: url("https://verses.quran.foundation/fonts/quran/hafs/uthmanic_hafs/UthmanicHafs1Ver18.woff2") format("woff2");
  font-display: swap;
}
.mushaf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; justify-items: center; }
.mushaf[hidden] { display: none; }
.m-page { position: relative; width: min(100%, 620px); container-type: inline-size; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 5cqw 4.5cqw 3cqw; }
.m-page.pending { aspect-ratio: 0.62; }
.m-page.centered { padding-top: 10cqw; padding-bottom: 6cqw; }
.m-lines { direction: rtl; font-size: 5.25cqw; color: var(--fg); }
.m-line { display: flex; justify-content: space-between; align-items: center; height: 1.95em; white-space: nowrap; }
.m-page.centered .m-line { justify-content: center; gap: .18em; }
.m-line.blank { height: 1.95em; }
.mw { font: inherit; font-family: var(--qf); line-height: 1; background: none; border: 0; padding: .06em .02em; margin: 0;
  color: inherit; border-radius: 6px; cursor: pointer; transition: background .12s, color .12s; }
.mw:hover { color: var(--accent); }
.mw.end { color: var(--accent); }
.mw.ayah-active { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.mw.reading, .mw.active { color: var(--accent); background: var(--accent-soft); }
.m-surah { display: flex; justify-content: center; align-items: center; height: 1.95em; }
/* Ornamental banner: double rule frame with medallion ends */
.m-surah-frame { position: relative; width: 100%; height: 1.55em; display: grid; place-items: center;
  border: 1px solid var(--accent); border-radius: 4px; outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 3px; background:
    linear-gradient(90deg, transparent 0 11%, var(--accent-soft) 11% 89%, transparent 89%); }
.m-surah-frame::before, .m-surah-frame::after { content: ""; position: absolute; top: 50%; width: .5em; height: .5em;
  transform: translateY(-50%) rotate(45deg); border: 1px solid var(--accent); background: var(--accent-soft); }
.m-surah-frame::before { right: 4.5%; } .m-surah-frame::after { left: 4.5%; }
.m-surah-title { display: inline-flex; flex-direction: row; gap: .12em; direction: ltr; font-family: "surahnames";
  font-size: 1.5em; line-height: 1; color: var(--accent); transform: translateY(.04em); }
.m-bismillah { display: flex; justify-content: center; align-items: center; height: 1.95em; line-height: 1; }
.m-foot { display: flex; justify-content: space-between; margin-top: 2.2cqw; padding-top: 2cqw; border-top: 1px solid var(--line);
  font-size: max(11px, 2.1cqw); color: var(--muted); direction: ltr; }
.m-foot .pno { font-weight: 600; color: var(--fg); }

/* Page toolbar with play button */
.m-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; direction: ltr;
  margin: -1.5cqw 0 2.5cqw; padding-bottom: 2cqw; border-bottom: 1px solid var(--line); }
.m-range { font-size: max(12px, 2.2cqw); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-play { display: inline-flex; align-items: center; gap: 6px; flex: none; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--fg); border-radius: 999px; padding: 6px 14px 6px 10px;
  font-size: max(12px, 2.2cqw); font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
.m-play svg { width: 14px; height: 14px; }
.m-play:hover { border-color: var(--accent); color: var(--accent); }
.m-play .i-pause { display: none; }
.m-play.is-playing .i-pause { display: block; }
.m-play.is-playing .i-play { display: none; }
.m-play.is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.m-play.is-current:hover { filter: brightness(1.08); color: var(--accent-fg); }
.m-page.is-current { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.m-page > .bm { right: max(10px, 3.2%); }
.m-page .m-head { padding-right: 32px; }
.m-page.is-bm { border-color: color-mix(in srgb, var(--bm) 50%, var(--line)); }
.m-page.is-bm .m-range::before { content: "Where you stopped · "; color: var(--bm); font-weight: 700; }
.m-error { text-align: center; color: var(--muted); padding: 40px 0; }

/* Skip rendering off-screen cards/pages (big win on long surahs, esp. mobile) */
.verse { content-visibility: auto; contain-intrinsic-size: auto 220px; }
.m-page:not(.pending) { content-visibility: auto; contain-intrinsic-size: auto 1000px; }

/* ---------- Surah search button + dialog ---------- */
.surah-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; color: var(--fg); text-align: left; }
.surah-btn:hover { border-color: var(--accent); }
.surah-btn span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah-btn svg { width: 16px; height: 16px; color: var(--muted); }

.surah-dialog { width: min(560px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgb(0 0 0 / .3); overflow: hidden; }
.surah-dialog[open] { display: flex; flex-direction: column; animation: pop .16s ease; }
.surah-dialog::backdrop { background: rgb(0 0 0 / .4); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.sd-head { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.sd-search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px; }
.sd-search:focus-within { border-color: var(--accent); }
.sd-search svg { width: 18px; height: 18px; color: var(--muted); }
.sd-search input { flex: 1; border: 0; background: transparent; padding: 11px 0; outline: none; font-size: 16px; min-width: 0; }
.sd-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.sd-item { width: 100%; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 10px;
  border: 0; border-radius: 10px; background: none; text-align: left; }
.sd-item:hover, .sd-item:focus-visible, .sd-item.kb { background: var(--surface-2); outline: none; }
.sd-item[aria-selected="true"] { background: var(--accent-soft); }
.sd-num { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2);
  font-size: .8rem; font-weight: 600; color: var(--accent); }
.sd-item[aria-selected="true"] .sd-num { background: var(--accent); color: var(--accent-fg); }
.sd-name { display: grid; min-width: 0; }
.sd-name strong { font-size: .95rem; }
.sd-name span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-ar { font-family: "surahnames"; font-size: 1.7rem; color: var(--fg); line-height: 1; }
.sd-empty { text-align: center; color: var(--muted); padding: 30px; margin: 0; }

/* ---------- Mushaf text size control ---------- */
.mushaf-tools { position: sticky; top: 72px; z-index: 5; display: flex; justify-content: flex-end; margin: -6px auto 10px;
  width: min(100%, var(--m-width, 620px)); pointer-events: none; }
.mushaf-tools[hidden] { display: none; }
.size-ctl { pointer-events: auto; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.size-ctl button { display: inline-flex; align-items: baseline; gap: 1px; border: 0; background: transparent; color: var(--fg);
  padding: 6px 11px; border-radius: 999px; font-weight: 600; }
.size-ctl button:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); }
.size-ctl button:disabled { opacity: .35; cursor: default; }
.size-ctl .a-small { font-size: .8rem; } .size-ctl .a-big { font-size: 1.1rem; }
.size-ctl output { min-width: 44px; text-align: center; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Page width & text size are driven by JS (--m-width / --m-pad / --m-font) */
.m-page { width: min(100%, var(--m-width, 620px));
  padding: calc(var(--m-pad, 620px) * .05) calc(var(--m-pad, 620px) * .045) calc(var(--m-pad, 620px) * .03); }
.m-page.centered { padding-top: calc(var(--m-pad, 620px) * .1); padding-bottom: calc(var(--m-pad, 620px) * .06); }
.m-lines { font-size: var(--m-font, 5.25cqw); }
/* Big-text flow: when the page can't widen any further, let words wrap naturally */
.mushaf.flow .m-lines { text-align: justify; text-align-last: start; line-height: 2.1; }
.mushaf.flow .m-line { display: contents; }
.mushaf.flow .m-line.blank { display: none; }
.mushaf.flow .mw { display: inline-block; padding: .1em .06em; margin: 0 .04em; }
.m-glue { display: contents; }
.mushaf.flow .m-glue { display: inline-block; white-space: nowrap; }
.mushaf.flow .m-surah, .mushaf.flow .m-bismillah { height: auto; padding: .35em 0; }

@media (max-width: 560px) {
  /* backdrop blur on a sticky bar is expensive while scrolling on phones */
  .topbar { backdrop-filter: none; background: var(--bg); }
  .brand span { display: none; }
  .verse { padding: 12px 16px 8px; border-radius: 20px; }
  .bm { right: 14px; }
  .surah-header .ar-name { font-size: 2.1rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
