@font-face { font-family: "IndoPak"; src: url("../fonts/indopak.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "AmiriQuran"; src: url("../fonts/AmiriQuran.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Nastaliq"; src: url("../fonts/NotoNastaliqUrdu.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Outfit"; src: url("../fonts/Outfit.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

/* Dark green + gold theme (default) */
:root, [data-theme="dark"] {
  --ar-scale: 1; --tx-scale: 1;
  --bg: #07130f; --bg2: #0a1a15; --surface: #0d201a; --surface2: #12291f; --surface3: #173327;
  --text: #f5f1eb; --muted: #9fb3aa; --line: #1d3a30;
  --gold: #e9c46a; --gold-soft: rgba(233, 196, 106, .12);
  --teal: #5fc4a3; --primary: #144d3c; --primary-hi: #1a6049; --primary-ink: #f5f1eb;
  --link: #e9c46a; --link-soft: rgba(233, 196, 106, .12);
  --play: rgba(233, 196, 106, .08); --mark: rgba(233, 196, 106, .35);
  --good: #2f9e63; --mid: #b7791f; --bad: #c0443d;
  --radius: 20px; --shadow: 0 1px 0 rgba(255,255,255,.02) inset;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ar-font: "IndoPak", "AmiriQuran", "Noto Naskh Arabic", serif;
  --ur-font: "Nastaliq", "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  --nav-h: 64px; --bar-h: 64px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f7f5ef; --bg2: #efece3; --surface: #ffffff; --surface2: #f3f0e7; --surface3: #e9e4d6;
  --text: #10261e; --muted: #5d6f67; --line: #e1dccd;
  --gold: #a87a12; --gold-soft: rgba(168, 122, 18, .1);
  --teal: #187a5f; --primary: #144d3c; --primary-hi: #1a6049; --primary-ink: #ffffff;
  --link: #9a6a00; --link-soft: #fbf0d4; --play: #fff6d6; --mark: #ffe58a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.04);
  color-scheme: light;
}
[data-theme="sepia"] {
  --bg: #f4ecd8; --bg2: #ede2c8; --surface: #fbf5e6; --surface2: #f1e7cd; --surface3: #e8dbbb;
  --text: #3b2f1e; --muted: #7a6a50; --line: #e0d2b0;
  --gold: #8a5a10; --gold-soft: rgba(138, 90, 16, .1); --teal: #6a5a20;
  --primary: #6b4513; --primary-hi: #7d5219; --primary-ink: #fff;
  --link: #8a3b00; --link-soft: #f6e0c0; --play: #f3e3a6; --mark: #f3d77a;
  color-scheme: light;
}
[data-script="uthmani"] { --ar-font: "AmiriQuran", "IndoPak", "Noto Naskh Arabic", serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: calc(16px * var(--tx-scale)); line-height: 1.55;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.has-bar { padding-bottom: calc(var(--nav-h) + var(--bar-h) + env(safe-area-inset-bottom)); }
body.no-scroll { overflow: hidden; }
a { color: var(--gold); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
[lang="ar"] { font-family: var(--ar-font); }
[lang="ur"] { font-family: var(--ur-font); line-height: 2.1; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; justify-content: center; }
.accent { color: var(--gold); }
h1 { font-size: 1.6rem; margin: .2em 0 .5em; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 1.4em 0 .5em; font-weight: 700; }
h3 { font-size: 1.1rem; margin: .5em 0 .3em; font-weight: 700; }
h4 { font-size: .95rem; margin: 1em 0 .4em; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-ink); padding: 8px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; color: var(--gold); margin: 0 0 4px; }
.kicker-plain { color: var(--muted); font-size: .9rem; margin: 0 0 6px; }
.label { text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.topbar-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 8px 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.05rem; }
.logo { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); display: grid; place-items: center; font-size: 18px; }
.spacer { flex: 1; }
.topnav { display: none; gap: 4px; margin-inline-end: 8px; }
.topnav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 12px; font-weight: 600; font-size: .95rem; position: relative; }
.topnav a:hover { color: var(--text); background: var(--surface2); }
.topnav a.active { color: var(--text); }
.icon-btn {
  min-width: 42px; height: 42px; border: 0; background: transparent; border-radius: 12px; cursor: pointer;
  display: inline-grid; place-items: center; text-decoration: none; color: var(--text); font-size: 1.05rem; padding: 0 6px;
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.round { border: 1px solid var(--line); border-radius: 99px; min-width: 38px; height: 38px; font-size: .9rem; }
.icon-btn.round.play { color: var(--gold); }
.topbar .icon-btn.active { background: var(--surface2); }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; background: var(--bg2);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .76rem; position: relative; font-weight: 500;
}
.nav a span:first-child { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.nav a.active { color: var(--text); font-weight: 700; }
.nav a.active span:first-child { color: var(--gold); }
.badge { position: absolute; top: 6px; left: calc(50% + 10px); background: var(--bad); color: #fff; border-radius: 99px; font-size: .68rem; padding: 0 6px; line-height: 1.6; font-weight: 700; }
.topnav .badge { position: static; margin-inline-start: 4px; }

main { outline: none; }
.view, .page { max-width: 1240px; margin: 0 auto; padding: 16px 14px 30px; }
.view > .page { padding: 0; }
.view:has(.reader), .view:has(.hifz), .view:has(.settings), .view:has(.flash) { max-width: 980px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  body.has-bar { padding-bottom: var(--bar-h); }
  .nav { display: none; }
  .topnav { display: flex; }
  .view, .page { padding: 26px 28px 44px; }
  h1 { font-size: 2rem; }
}

/* ---------- common ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px;
  border-radius: 14px; border: 1px solid var(--line); background: transparent; cursor: pointer; text-decoration: none; color: var(--text);
  font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--teal); background: var(--surface2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hi); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn.small-btn { min-height: 36px; padding: 6px 14px; font-size: .88rem; border-radius: 10px; background: var(--surface3); border-color: transparent; }
.btn.ghost.small-btn { background: transparent; border-color: var(--line); }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.good2 { background: #127a6a; color: #fff; border-color: #127a6a; }
.btn.mid { background: var(--mid); color: #fff; border-color: var(--mid); }
.btn.bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn:disabled { opacity: .6; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.row.between { justify-content: space-between; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); font-size: .8rem; text-decoration: none; color: var(--text); }
.chip:hover { border-color: var(--teal); }
.chip.ok { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.refs { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.pill:hover { border-color: var(--teal); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg button { border: 1px solid var(--line); background: transparent; padding: 7px 14px; cursor: pointer; min-height: 38px; border-radius: 99px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg button:hover { border-color: var(--teal); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.seg-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-inline-end: 4px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.bar { display: block; height: 6px; background: var(--surface3); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--gold); }
progress { width: 100%; height: 10px; accent-color: var(--gold); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--bar-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--surface3); color: var(--text); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { #toast { bottom: calc(var(--bar-h) + 20px); } }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; background: linear-gradient(135deg, var(--surface2), var(--surface));
  border: 1px solid var(--line); border-radius: 28px; padding: 26px 22px; margin-bottom: 10px;
}
.hero h1 { font-size: 2rem; max-width: 20ch; }
.hero .lead { color: var(--muted); max-width: 62ch; font-size: 1.02rem; }
.hero-deco { position: absolute; right: 24px; top: 6px; font-size: 7rem; color: var(--text); opacity: .06; pointer-events: none; line-height: 1.4; }
@media (min-width: 900px) { .hero { padding: 44px 40px; } .hero h1 { font-size: 3rem; } .hero-deco { font-size: 9rem; right: 40px; } }
.sec-title { margin: 1.6em 0 .1em; font-size: 1.5rem; }
.sec-sub { margin: 0 0 14px; }
.steps { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { display: flex; flex-direction: column; gap: 4px; }
.step h3 { margin: 0; }
.step .row { margin-top: auto; padding-top: 8px; }
.list-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; justify-content: space-between; margin-bottom: 4px; }
.filter, .search-box input, select, input[type="number"] {
  border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 9px 12px; min-height: 42px; color: var(--text);
}
.filter { flex: 1; min-width: 200px; max-width: 380px; }
.surah-list { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .surah-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .surah-list { grid-template-columns: 1fr 1fr 1fr; } }
.surah-list a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-decoration: none; color: var(--text); transition: border-color .15s; }
.surah-list a:hover { border-color: var(--teal); }
.sl-n { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; background: var(--surface3); color: var(--gold); border-radius: 12px; font-weight: 700; font-size: .9rem; }
.sl-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sl-ar { font-size: 1.45rem; color: var(--gold); }

/* ---------- reader ---------- */
.surah-head { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 1px solid var(--line); border-radius: 28px; padding: 22px 16px; margin-bottom: 18px; text-align: center; }
.sh-deco { position: absolute; right: 24px; top: 10px; font-size: 5rem; opacity: .07; pointer-events: none; }
.sh-top { display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.sh-title { flex: 1; }
.sh-title h1 { margin: 2px 0 0; }
.sh-ar { font-size: calc(2.6rem * var(--ar-scale)); color: var(--gold); font-weight: 400; line-height: 1.5; }
.sh-ur { margin: 0; font-size: 1.2rem; color: var(--muted); }
.sh-en { margin: 2px 0 0; font-weight: 600; }
.lang-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; margin-top: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.jump { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.jump input { width: 76px; }
.bismillah { text-align: center; font-size: calc(2rem * var(--ar-scale)); margin: 10px 0 0; color: var(--gold); }
.bismillah-tr { text-align: center; margin: 0 0 14px; font-size: .9rem; }
.load-prev-wrap { text-align: center; margin-bottom: 8px; }

.verse { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 18px; margin-bottom: 16px; scroll-margin-top: 80px; transition: background .3s, border-color .3s; }
@media (min-width: 900px) { .verse { padding: 22px 26px 24px; } }
.verse.playing { background: linear-gradient(var(--play), var(--play)), var(--surface); border-color: var(--gold); }
.v-head { display: flex; align-items: center; gap: 6px; }
.v-num { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--surface3); color: var(--gold); font-weight: 700; font-size: .85rem; }
.v-ar { font-size: calc(2rem * var(--ar-scale)); line-height: 2.2; margin: 10px 0 4px; text-align: right; word-spacing: .1em; }
@media (min-width: 900px) { .v-ar { font-size: calc(2.3rem * var(--ar-scale)); } }
[data-script="uthmani"] .v-ar { line-height: 2.3; }
.aw { cursor: pointer; border-radius: 8px; transition: background .15s; }
.aw:hover { background: var(--gold-soft); }
/* Amiri draws the ornate brackets with the number inside; the IndoPak font drops the number */
.v-end { color: var(--gold); font-family: "AmiriQuran", "Noto Naskh Arabic", serif; white-space: nowrap; font-size: .8em; }
.v-tl { color: var(--teal); font-style: italic; margin: 0 0 4px; font-size: .95rem; }
.v-tr { margin-top: 6px; }
.tr-block { margin-top: 12px; }
.tr-block .label { margin: 0 0 6px; }
.tr-block p { margin: 0; }
.tr-hl { background: var(--surface2); border-inline-start: 3px solid var(--teal); border-radius: 14px; padding: 12px 16px; }
.tr-hl .t-ro { color: var(--gold); font-weight: 600; font-size: 1.08rem; }
.t-ro { font-size: 1.05rem; }
.t-ur { font-size: 1.25rem; text-align: right; line-height: 2.2; }
.t-en { font-size: 1rem; color: var(--text); }

.wgrid { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.wcard {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 10px 9px; min-width: 76px; max-width: 180px;
  background: transparent; border: 1px solid transparent; border-radius: 14px; cursor: pointer; text-align: center; direction: ltr; transition: background .15s, border-color .15s;
}
.wcard:hover, .wcard:focus-visible { background: var(--surface2); border-color: var(--line); }
.wcard.has-link { background: var(--surface2); }
.w-ar { font-size: calc(1.6rem * var(--ar-scale)); line-height: 1.9; }
.w-tl { font-size: .76rem; color: var(--teal); }
.w-m { display: flex; flex-direction: column; font-size: .86rem; line-height: 1.3; gap: 1px; }
.m-ro { font-weight: 600; }
.m-ur { font-size: .98rem; line-height: 1.9; }
.m-en { color: var(--muted); font-size: .82rem; }
.link-badge { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; margin-top: 4px; padding: 1px 8px; background: var(--link-soft); color: var(--link); border-radius: 99px; font-size: .72rem; font-weight: 600; }
.link-badge [lang="ur"] { line-height: 1.6; font-size: 1.05em; }
.link-badge .ico { font-size: .8em; }
.link-badge.big { font-size: .95rem; padding: 4px 12px; }
.surah-end { text-align: center; margin: 24px 0; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); opacity: 0; transition: .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s ease; box-shadow: 0 -10px 30px rgba(0,0,0,.35);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-grip { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 6px; }
.sheet-x { position: absolute; top: 8px; right: 8px; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(640px, 92vw); max-height: 86vh; border-radius: 24px; transform: translate(-50%, -46%); opacity: 0; transition: .2s; }
  .sheet-wrap.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grip { display: none; }
}
.menu-list { display: flex; flex-direction: column; }
.menu-list button { text-align: start; padding: 14px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 1rem; }

.wd-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-right: 40px; }
.wd-ar { font-size: calc(2.8rem * var(--ar-scale)); margin: 0; line-height: 1.8; color: var(--gold); }
.wd-tl { font-size: 1.1rem; font-style: italic; color: var(--teal); margin: 0 0 8px; }
.wd-m { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 10px; }
.wd-m dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; padding-top: 5px; }
.wd-m dd { margin: 0; font-weight: 600; font-size: 1.05rem; }
.wd-m dd.ur { font-weight: 400; font-size: 1.2rem; text-align: right; }
.wd-link { background: var(--link-soft); color: var(--text); border-radius: 14px; padding: 10px 14px; margin: 8px 0; }
.wd-link strong { color: var(--link); }
.wd-link p { margin: 4px 0 0; }
.root-ar { font-size: 1.4em; letter-spacing: .1em; color: var(--gold); }
.uw-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.uw { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; display: flex; flex-direction: column; }
.uw-ur { font-size: 1.15rem; line-height: 1.9; text-align: right; }
.uw-ro { font-weight: 700; }
.uw-m { font-size: .8rem; }
.wd-root .btn { margin: 10px 6px 0 0; }

/* ---------- hifz ---------- */
.hz-head { display: flex; align-items: center; gap: 8px; }
.hz-head h1 { margin: 0; font-size: 1.3rem; }
.hz-progress { height: 6px; background: var(--surface3); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.hz-progress span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.levels { display: flex; width: 100%; }
.levels button { flex: 1; padding: 8px 6px; font-size: .85rem; }
.hz-verse { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.hz-verse.playing { border-color: var(--gold); }
.hz-words { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: flex-start; }
.hw { display: flex; flex-direction: column; align-items: center; border: 0; background: transparent; padding: 2px 6px; border-radius: 12px; cursor: default; direction: ltr; }
.hw.covered { cursor: pointer; background: var(--surface2); }
.hw.peek { background: var(--gold-soft); }
.hw-ar { font-size: calc(2rem * var(--ar-scale)); line-height: 2; }
.hw-blank { color: var(--muted); letter-spacing: 2px; }
.hw-dots { color: var(--muted); }
.hw-tl { font-size: .8rem; color: var(--teal); }
.hw-m { font-size: .8rem; display: flex; flex-direction: column; text-align: center; }
.hz-audio { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hz-audio label { display: flex; align-items: center; gap: 6px; }
.hz-grade { text-align: center; }
.hz-grade .row, .grade { justify-content: center; }
.check { display: flex; gap: 6px; align-items: center; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
@media (min-width: 640px) { .form-grid { grid-template-columns: 2fr 1fr 1fr auto; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--teal); }
.tile-ar { font-size: 1.5rem; color: var(--gold); }
.tile.big b { font-size: 2.2rem; color: var(--gold); }

/* ---------- words / flashcards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.stat b { font-size: 1.5rem; color: var(--gold); }
.stat span { font-size: .85rem; color: var(--muted); }
.vocab { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.vrow { width: 100%; display: flex; align-items: center; gap: 12px; text-align: start; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
.vrow:hover { border-color: var(--teal); }
.v-rank { width: 32px; color: var(--muted); font-size: .8rem; }
.vrow .v-ar { font-size: calc(1.6rem * var(--ar-scale)); min-width: 74px; text-align: center; margin: 0; line-height: 1.9; color: var(--gold); }
.v-txt { flex: 1; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.v-txt .v-tl { color: var(--teal); font-size: .85rem; }
.v-means { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
.v-c { font-size: .8rem; }
.flash .fcard {
  width: 100%; min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 1px solid var(--line); border-radius: 26px; cursor: pointer; padding: 24px;
}
.fcard.flipped { border-color: var(--gold); }
.fc-ar { font-size: calc(3.4rem * var(--ar-scale)); line-height: 1.8; color: var(--gold); }
.fc-tl { font-size: 1.15rem; color: var(--teal); font-style: italic; }
.fc-back { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fc-means { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.3rem; }
.fc-means .m-en { font-size: 1.05rem; }
.fc-rel { font-size: .9rem; }

/* ---------- search / settings / root ---------- */
.search-box input { width: 100%; font-size: 1.05rem; }
.results { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.result { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.result:hover { border-color: var(--teal); }
.settings fieldset { margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.settings legend { font-weight: 700; padding: 0 6px; color: var(--gold); }
.opt { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.opt input { width: 20px; height: 20px; accent-color: var(--teal); }
.range { display: flex; flex-direction: column; gap: 4px; }
.range input { accent-color: var(--teal); }
.settings select { width: 100%; margin-top: 4px; }
.root-verses { display: flex; flex-direction: column; gap: 10px; }
.rv { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.rv-ar { font-size: calc(1.6rem * var(--ar-scale)); line-height: 2; text-align: right; }

/* ---------- audio bar ---------- */
.audio-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--bg2); border-top: 1px solid var(--line); height: var(--bar-h);
}
.ab-in { max-width: 1240px; height: 100%; margin: 0 auto; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.ab-toggle { color: var(--gold); border-color: var(--gold) !important; }
.ab-status { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--muted); text-align: start; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ab-reciter { min-width: 0; max-width: 240px; min-height: 38px; border-radius: 99px; padding: 6px 12px; font-size: .85rem; font-weight: 600; background: var(--surface); }
@media (min-width: 900px) { .audio-bar { bottom: 0; } .ab-in { padding: 0 28px; gap: 10px; } }
@media (max-width: 600px) {
  .ab-prev, .ab-next, .ab-stop { display: none; }
  .ab-status { display: none; }
  .ab-in { gap: 6px; }
  .ab-reciter { flex: 1 1 0; max-width: none; }
  .lang-bar { flex-direction: column; align-items: center; gap: 10px; }
  .seg.multi { justify-content: center; }
  .seg.multi .seg-label { width: 100%; text-align: center; margin: 0; }
  .seg.multi button { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
  .sh-deco { font-size: 3.5rem; right: 14px; }
}

@media (max-width: 420px) {
  .toolbar .btn { padding: 8px 12px; }
  .wcard { min-width: 70px; padding: 6px; }
  .v-ar { font-size: calc(1.75rem * var(--ar-scale)); }
  .hero h1 { font-size: 1.7rem; }
  .brand-txt { font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
