/* Tema Islami: hijau zamrud + emas, motif bintang segi delapan (rub el hizb). */
:root {
  --bg: #F2F6F1;
  --surface: #FFFFFF;
  --surface-2: #E7EEE8;
  --fg: #11261F;
  --muted: #4F645B;
  --line: #D2DDD4;
  --primary: #0B5D4B;
  --primary-2: #0E7A62;
  --on-primary: #FFFFFF;
  --gold: #946509;          /* emas untuk teks di latar terang */
  --gold-bright: #E4C15E;   /* emas untuk latar gelap */
  --hdr-1: #0B5D4B;
  --hdr-2: #073A2F;
  --hdr-fg: #F6F1DC;
  --good: #1B7F4B;
  --bad: #B3342B;
  --font-arab: "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1511; --surface: #12211B; --surface-2: #1A2D25; --fg: #E6F0EA; --muted: #9CB3A8; --line: #28402F;
    --primary: #46C79B; --primary-2: #66D8B0; --on-primary: #06231A; --gold: #E4C15E;
    --hdr-1: #0A3F33; --hdr-2: #06241D; --good: #5ED08F; --bad: #FF8A7E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1511; --surface: #12211B; --surface-2: #1A2D25; --fg: #E6F0EA; --muted: #9CB3A8; --line: #28402F;
  --primary: #46C79B; --primary-2: #66D8B0; --on-primary: #06231A; --gold: #E4C15E;
  --hdr-1: #0A3F33; --hdr-2: #06241D; --good: #5ED08F; --bad: #FF8A7E;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 var(--font-body); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ar { font-family: var(--font-arab); direction: rtl; line-height: 1.9; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold-bright); color: #1a1a1a; padding: 8px 14px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }

.wrap {
  width: 100%; max-width: 900px; margin: 0 auto; flex: 1;
  padding: 22px max(16px, env(safe-area-inset-left, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 20px; align-content: start;
}
.wrap > * { min-width: 0; }

/* ---------- header ---------- */
header.site {
  background: linear-gradient(135deg, var(--hdr-1), var(--hdr-2));
  background-image: url("../img/pattern.svg"), linear-gradient(135deg, var(--hdr-1), var(--hdr-2));
  color: var(--hdr-fg);
  border-bottom: 3px solid var(--gold-bright);
  padding-top: env(safe-area-inset-top, 0px);
}
.site-in, nav.main {
  max-width: 900px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.site-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 14px 6px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--hdr-fg); text-decoration: none; min-width: 0; }
.brand b { display: block; font-size: 1.2rem; letter-spacing: -0.01em; line-height: 1.2; }
.brand small { display: block; font-size: .74rem; opacity: .75; letter-spacing: .02em; }
.mark { width: 42px; height: 42px; flex: none; }
.mark rect { fill: none; stroke: var(--gold-bright); stroke-width: 2; }
.mark circle { fill: var(--gold-bright); }
.acct { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct form { margin: 0; }
.who { font-size: .88rem; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.tbtn { background: rgba(255,255,255,.1); color: var(--hdr-fg); border: 1px solid rgba(255,255,255,.28); border-radius: 9px; padding: 6px 12px; font-size: .86rem; font-weight: 600; text-decoration: none; line-height: 1.4; }
.tbtn:hover { background: rgba(255,255,255,.2); }
.tbtn.solid { background: var(--gold-bright); color: #1B2A10; border-color: var(--gold-bright); }
nav.main { display: flex; gap: 2px; overflow-x: auto; padding-block: 6px 0; scrollbar-width: none; }
nav.main::-webkit-scrollbar { display: none; }
nav.main a { color: var(--hdr-fg); text-decoration: none; padding: 10px 16px 11px; font-weight: 600; font-size: .95rem; opacity: .82; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -3px; }
nav.main a:hover { opacity: 1; }
nav.main a[aria-current="page"] { opacity: 1; border-bottom-color: var(--gold-bright); color: var(--gold-bright); }

/* ---------- umum ---------- */
h1, h2 { letter-spacing: -0.01em; line-height: 1.25; margin: 0; }
h1.pt { font-size: 1.7rem; }
h2.sec { font-size: 1.1rem; margin-bottom: 10px; }
.lead { color: var(--muted); max-width: 62ch; margin: 6px 0 0; }
.note { color: var(--muted); font-size: .88rem; margin: 0; }
.note.tight { margin-top: 8px; }
.crumb { margin: 0 0 4px; font-size: .88rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.pill { display: inline-block; padding: 2px 11px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 9px 16px; font-weight: 600; font-size: .92rem; text-decoration: none; line-height: 1.35; }
.btn:hover { border-color: var(--primary); }
.btn.small { padding: 5px 11px; font-size: .82rem; }
.btn.primary, .btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.gold { background: var(--gold-bright); color: #1B2A10; border-color: var(--gold-bright); }
.btn.ghost { background: transparent; color: var(--hdr-fg); border-color: rgba(255,255,255,.45); }
.bar { display: block; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--gold-bright)); transition: width .3s; }
.hear { display: none; }
.has-voice .hear { display: inline-flex; }
.has-voice .note.hear { display: block; }

/* ---------- beranda ---------- */
.hero { background: linear-gradient(135deg, var(--hdr-1), var(--hdr-2)); background-image: url("../img/pattern.svg"), linear-gradient(135deg, var(--hdr-1), var(--hdr-2)); color: var(--hdr-fg); border-radius: 18px; padding: 34px 24px; border: 1px solid rgba(228,193,94,.35); }
.hero-in { max-width: 640px; }
.bismillah { font-size: clamp(1.8rem, 6vw, 2.6rem); color: var(--gold-bright); margin: 0 0 6px; text-align: right; direction: rtl; }
.hero h1 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); }
.hero .lead { color: rgba(246,241,220,.85); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-decoration: none; color: var(--fg); }
.stat:hover { border-color: var(--primary); }
.stat-k { color: var(--muted); font-size: .84rem; font-weight: 600; }
.stat-v { font-size: 1.5rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.guestnote { margin-top: 12px; }
.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.path li { counter-increment: step; }
.path a { display: grid; grid-template-columns: 38px 1fr; column-gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--fg); }
.path a:hover { border-color: var(--primary); }
.path a::before { content: counter(step); grid-row: span 2; width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--gold); color: var(--gold); border-radius: 10px; transform: rotate(45deg); font-weight: 700; }
.path a::before { transform: none; border-radius: 50%; }
.path b { font-size: 1.02rem; }
.path span { color: var(--muted); font-size: .9rem; }

/* ---------- huruf ---------- */
.detail { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 22px; align-items: center; }
.big { font-size: 7rem; line-height: 1.3; text-align: center; color: var(--primary); background: var(--surface-2); border-radius: 14px; padding: 6px 0; direction: ltr; }
.dname { font-size: 1.65rem; }
.forms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.forms div { text-align: center; background: var(--surface-2); border-radius: 10px; padding: 6px 4px; min-width: 0; }
.forms b { display: block; font-size: 1.9rem; font-weight: 400; line-height: 1.7; direction: ltr; }
.forms span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.cell { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px 8px; text-align: center; min-width: 0; }
.cell:hover { border-color: var(--primary); }
.cell .ar { font-size: 2.2rem; line-height: 1.5; display: block; }
.cell small { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; }
.cell[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.cell.known::after { content: ""; position: absolute; top: 7px; left: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--good); }

/* ---------- harakat ---------- */
select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; max-width: 100%; }
.hk { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hk button { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; min-width: 0; cursor: default; }
.has-voice .hk button { cursor: pointer; }
.has-voice .hk button:hover { border-color: var(--primary); }
.hk .ar { font-size: 2.6rem; line-height: 1.6; display: block; color: var(--primary); }
.hk b { display: block; font-size: 1.05rem; }
.hk small { color: var(--muted); font-size: .78rem; line-height: 1.3; display: block; }
.hk .mini { font-family: var(--font-arab); font-size: 1.25rem; color: var(--gold); }

/* ---------- surah ---------- */
.slist { display: grid; gap: 10px; }
.scard { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--fg); }
.scard:hover { border-color: var(--primary); }
.snum { width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--gold); color: var(--gold); border-radius: 50%; font-weight: 700; font-size: .88rem; font-variant-numeric: tabular-nums; }
.sbody { display: grid; gap: 3px; min-width: 0; }
.sbody small { color: var(--muted); }
.sar { font-size: 1.7rem; color: var(--primary); line-height: 1.4; }
.sheadar { font-size: 2.4rem; color: var(--gold); margin: 0; line-height: 1.4; }
.opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.opts label { display: inline-flex; gap: 6px; align-items: center; font-size: .92rem; }
input[type=range] { accent-color: var(--primary); width: 120px; }
input[type=checkbox] { accent-color: var(--primary); width: 18px; height: 18px; }
.ayat { margin-top: 8px; --ar-size: 2.1rem; }
.ayah { display: grid; gap: 4px; padding: 18px 0; border-top: 1px solid var(--line); }
.ayah:first-child { border-top: 0; }
.ayah p { margin: 0; }
.ayah .ar { font-size: var(--ar-size); }
.ayah .no { display: inline-flex; width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1.5px solid var(--gold); color: var(--gold); font: 600 .78rem/1 var(--font-body); align-items: center; justify-content: center; margin-inline-end: 8px; vertical-align: middle; }
.ayah .lat { color: var(--primary); font-weight: 600; font-style: italic; }
.ayah .idn { color: var(--muted); }
.ayah.done .ar { opacity: .55; }
.chk { display: inline-flex; gap: 6px; align-items: center; }
.hide-lat .lat, .hide-idn .idn { display: none; }
.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- kuis ---------- */
.quizmenu { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.quizmenu .panel { display: grid; gap: 8px; align-content: start; }
.qbox { text-align: center; display: grid; gap: 14px; justify-items: center; }
.qbox .ar { font-size: 5.5rem; line-height: 1.5; color: var(--primary); margin: 0; direction: ltr; }
.qbox p { margin: 0; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 480px; }
.answers button { padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.answers button:hover:not(:disabled) { border-color: var(--primary); }
.answers button.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 16%, var(--surface)); }
.answers button.no { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.score { font-size: 2.6rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.qbox .bar { width: 100%; }
.qtop { width: 100%; display: flex; justify-content: space-between; gap: 8px; }

/* ---------- akun ---------- */
.authbox { max-width: 460px; display: grid; gap: 12px; }
.form { display: grid; gap: 8px; }
.form label { font-weight: 600; font-size: .9rem; }
.form input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
.form .btn { margin-top: 8px; }
.alert { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad); border-radius: 10px; padding: 10px 14px; margin: 0; }
.bignum { font-size: 4rem; color: var(--gold); margin: 0; text-align: left; direction: ltr; }

/* ---------- footer ---------- */
.site-foot { background: var(--surface-2); border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .86rem; padding-bottom: env(safe-area-inset-bottom, 0px); }
.site-foot .wrap { flex: none; padding-block: 22px; gap: 4px; }
.site-foot p { margin: 0 auto; max-width: 60ch; }
.site-foot .ar { font-size: 1.7rem; color: var(--gold); }

@media (max-width: 520px) {
  .detail { grid-template-columns: 1fr; }
  .big { font-size: 5.5rem; }
  .forms b { font-size: 1.6rem; }
  .qbox .ar { font-size: 4.5rem; }
  .hero { padding: 26px 18px; }
  .scard { grid-template-columns: 40px 1fr; }
  .scard .sar { grid-column: 1 / -1; text-align: right; }
  h1.pt { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* ---------- audio ---------- */
.player { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 12px; }
.player label { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.player select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.playbtn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.ayah.playing { background: color-mix(in srgb, var(--gold-bright) 16%, transparent); border-radius: 12px; box-shadow: -4px 0 0 var(--gold-bright); padding-inline: 12px; }
@media (prefers-reduced-motion: no-preference) { .ayah { transition: background .2s; } }

/* ---------- tab bar bawah ---------- */
.tabbar { display: none; }
.tbtn#themeBtn { font-size: 1.1rem; padding: 4px 11px; }
@media (max-width: 720px) {
  nav.main { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 58px; padding: 6px 2px;
    color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; }
  .tabbar a[aria-current="page"] { color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar .ti { font-size: 1.45rem; line-height: 24px; height: 24px; direction: ltr; }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- kartu lanjutkan belajar ---------- */
.resume { display: none; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; text-decoration: none;
  background: linear-gradient(135deg, var(--hdr-1), var(--hdr-2)); color: var(--hdr-fg); border-radius: 16px; padding: 18px 20px; }
html.returning .resume { display: grid; }
html.returning .hero { display: none; }
.resume .kick { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-bright); }
.resume h2 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.resume .note { color: var(--hdr-fg); opacity: .85; }
.resume .bar { grid-column: 1 / -1; background: rgba(255,255,255,.22); margin-top: 8px; }
.resume .bar i { background: var(--gold-bright); }
.resume .go { grid-column: 2; grid-row: 1 / 4; width: 46px; height: 46px; border-radius: 50%; background: var(--gold-bright); color: #1B2A10;
  display: grid; place-items: center; font-size: 1.8rem; line-height: 1; }
.resume:hover .go, .resume:focus-visible .go { transform: translateX(3px); }
@media (prefers-reduced-motion: no-preference) { .resume .go { transition: transform .15s; } }

/* ---------- bottom sheet huruf ---------- */
.sheet-bar { display: none; }
.sheet-bg { display: none; }
@media (max-width: 720px) {
  .sheet-bar { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 12px; }
  .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin-inline: 8px; }
  .sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; margin: 0; max-height: 86vh; overflow: auto; overscroll-behavior: contain;
    border-radius: 20px 20px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -12px 32px rgba(0,0,0,.28);
    transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  .sheet.open { transform: none; visibility: visible; transition: transform .25s ease; }
  .sheet-bg { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.45); }
  .sheet-bg[hidden] { display: none; }
  .sheet .big { font-size: 4.6rem; }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheet.open { transition: none; } }
