/* ===== Makhraj 3D — tema turquoise ebook + krem pola ===== */
@font-face { font-family: 'Amiri'; src: url('../vendor/amiri-arabic-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../vendor/amiri-arabic-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Amiri Quran'; src: url('../vendor/amiri-quran-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --tosca: #1597cf;
  --tosca-gelap: #0b6c98;
  --tosca-muda: #e4f3fb;
  --krem: #f6efdf;
  --kertas: #fffdf7;
  --emas: #f2b705;
  --emas-gelap: #b98700;
  --marun: #7a2b2b;
  --teks: #2b2522;
  --teks-lembut: #4f4337;
  --arab: #5b1f1a;        /* warna teks Arab: marun tua, kontras tinggi di atas krem */
  --arab-lembut: #7a3a22;
  --garis: #e2d5b9;
  --bayang: 0 6px 22px rgba(80, 58, 20, .13), 0 1px 3px rgba(80, 58, 20, .1);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, 'Noto Sans', sans-serif;
  color: var(--teks);
  background: var(--krem) url('../assets/bg-pola.jpg') repeat;
  background-size: 360px;
  display: flex; flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.arab { font-family: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif; direction: rtl; unicode-bidi: isolate; }
/* Arab di dalam teks Latin: kotak inline setinggi tinta (harakat atas ≈1,24em, bawah ≈0,64em) */
.arab.ar { display: inline-block; line-height: 1.8; padding-top: .14em; vertical-align: baseline; white-space: nowrap; }
/* Glyph tunggal dalam kotak tetap — dipusatkan oleh JS (pasGlyph) */
.glyph-box { display: flex; justify-content: center; align-items: flex-start; width: 100%; overflow: visible; }
.glyph { display: inline-block; white-space: nowrap; line-height: 1; transform-origin: 50% 50%; }
button { font: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--emas); outline-offset: 2px; }

/* ---------- header ---------- */
#header {
  flex: 0 0 auto; position: relative;
  background: linear-gradient(180deg, #1aa3dc 0%, #1290c7 100%);
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 22px; gap: 12px;
}
#header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 18px;
  background: url('../assets/ornamen-pita.jpg') repeat-x center / auto 100%;
}
#header h1 { font-size: 24px; font-weight: 800; letter-spacing: .5px; line-height: 1.1; text-shadow: 0 2px 6px rgba(0, 50, 80, .35); }
#header h1 span { color: #ffe27a; }
#subjudul { font-size: 12.5px; opacity: .95; }
.header-aksi { display: flex; gap: 8px; }
.btn-header {
  background: rgba(255, 255, 255, .16); color: #fff; border: 1px solid rgba(255, 255, 255, .45);
  padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  transition: background .15s, transform .15s;
}
.btn-header:hover { background: rgba(255, 255, 255, .28); }
.btn-header.aktif { background: var(--emas); color: #3d2c00; border-color: var(--emas); }
.btn-header.ikon { width: 36px; padding: 7px 0; }

/* ---------- layout ---------- */
#main {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 330px; gap: 12px; padding: 12px;
}
#panel-huruf, #kartu-info {
  background: rgba(255, 253, 247, .94); border: 1px solid var(--garis); border-radius: var(--radius);
  box-shadow: var(--bayang); overflow-y: auto; min-height: 0;
}
#panel-huruf { padding: 12px 10px; }
.panel-judul, .info-judul {
  font-weight: 800; color: var(--tosca-gelap); font-size: 12.5px; text-transform: uppercase; letter-spacing: 1px;
}
.panel-judul { margin: 0 4px 8px; }
.grup { margin-bottom: 12px; }
.grup-judul { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 700; color: var(--marun); margin: 0 4px 6px; }
.grup-judul { align-items: center; }
.grup-judul .arab { font-size: 21px; font-weight: 700; color: var(--arab); line-height: 1.6; padding-top: 0; }
.grup-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
/* warna penanda tiap wilayah makhraj */
.grup { --w: var(--tosca-gelap); --w-bg: #e4f3fb; }
.grup[data-wilayah="tenggorokan"] { --w: #b77900; --w-bg: #fff3d1; }
.grup[data-wilayah="lidah"]       { --w: #c0392b; --w-bg: #fde9e5; }
.grup[data-wilayah="bibir"]       { --w: #6f52c8; --w-bg: #efeafd; }
.grup[data-wilayah="rongga"]      { --w: #147f78; --w-bg: #ddf3f1; }
.grup-judul { border-left: 5px solid var(--w); padding-left: 7px; border-radius: 2px; gap: 10px; }
.grup-judul .arab { flex: 0 0 auto; }
.gj-kiri { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
#daftar-huruf.alfabetis .gj-jml { display: none; }
.gj-nama { color: var(--w); }
.gj-jml { font-size: 11.5px; font-weight: 600; color: var(--teks-lembut); }
/* desktop: jarak & garis pemisah antar wilayah makhraj */
@media (min-width: 861px) {
  .grup { margin-bottom: 0; }
  .grup + .grup { margin-top: 16px; padding-top: 14px; border-top: 2px dashed var(--garis); }
}
/* panel huruf sempit (3 kolom): jumlah huruf disembunyikan agar judul tidak terpotong */
@media (min-width: 861px) and (max-width: 1180px) { .gj-jml { display: none; } }
/* Alfabetis: huruf disusun dari kanan ke kiri sesuai kaidah tulisan Arab */
#daftar-huruf.alfabetis .grup-row { direction: rtl; }
#daftar-huruf.alfabetis .tombol-huruf { direction: ltr; }
.tombol-huruf {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 2px 6px; min-height: 62px; gap: 2px;
  background: linear-gradient(180deg, #22a8e0, #1391c8); color: #fff;
  border: none; border-radius: 11px;
  box-shadow: 0 2px 0 #0c6f9c, 0 3px 8px rgba(12, 111, 156, .25);
  transition: transform .12s, box-shadow .12s, background .2s;
}
.tombol-huruf:hover { transform: translateY(-2px); box-shadow: 0 4px 0 #0c6f9c, 0 6px 12px rgba(12, 111, 156, .3); }
.tombol-huruf:active { transform: translateY(1px); box-shadow: 0 1px 0 #0c6f9c; }
.tombol-huruf.aktif { background: linear-gradient(180deg, #ffd23f, #f2b705); color: #3d2c00; box-shadow: 0 2px 0 #b98700, 0 0 0 3px rgba(242, 183, 5, .35); }
.tombol-huruf .glyph-box { height: 34px; }
.tombol-huruf .glyph { font-size: 28px; }
.tombol-huruf .nm { font-size: 11.5px; font-weight: 700; opacity: .95; line-height: 1.15; white-space: nowrap; }

/* ---------- panggung ---------- */
#panggung { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 10px; }
#viewport {
  position: relative; flex: 1 1 auto; min-height: 260px; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 45% 40%, #fffaf0 0%, #f6ecd6 55%, #e9dcc0 100%);
  border: 1px solid var(--garis); box-shadow: var(--bayang);
}
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
/* Layar sentuh: gulir halaman tetap bisa dari area 3D (geser vertikal), putar dengan geser horizontal */
@media (pointer: coarse) { #gl { touch-action: pan-y; } }
#gl.seret { cursor: grabbing; }
#garis-label, #labels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.label3d {
  position: absolute; left: 0; top: 0; max-width: 250px;
  background: rgba(255, 253, 247, .96); color: var(--teks);
  border: 2px solid var(--emas); border-radius: 10px;
  font-size: 14px; font-weight: 700; padding: 5px 10px; line-height: 1.3;
  box-shadow: 0 3px 10px rgba(60, 40, 10, .18);
  transition: opacity .3s; white-space: normal; text-align: center;
}
.label3d.kecil { font-size: 13px; font-weight: 700; padding: 4px 9px; }
#garis-label line { stroke-width: 2; }
#garis-label circle { stroke: #fff; stroke-width: 2; }
#hint-orbit {
  position: absolute; bottom: 10px; right: 12px; font-size: 12px; color: var(--teks-lembut);
  background: rgba(255, 255, 255, .7); padding: 3px 9px; border-radius: 99px; pointer-events: none;
  transition: opacity .6s;
}
#alat-view { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; }
.alat {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--garis);
  background: rgba(255, 253, 247, .92); color: var(--tosca-gelap); font-size: 17px;
  box-shadow: 0 2px 6px rgba(60, 40, 10, .12);
}
.alat:hover { background: #fff; }
.alat.aktif { color: var(--emas-gelap); }
#legenda {
  position: absolute; left: 12px; bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--teks); font-weight: 600; pointer-events: none; transition: opacity .4s;
}
#legenda span { background: rgba(255, 253, 247, .9); padding: 3px 9px 3px 7px; border-radius: 99px; display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
#legenda i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }

/* inset SVG */
.inset {
  position: absolute; top: 10px; right: 10px; width: 300px; max-width: 44%;
  background: rgba(255, 253, 247, .97); border: 1px solid var(--garis); border-radius: 12px;
  box-shadow: var(--bayang); padding: 8px 10px 9px;
  opacity: 0; transform: translateY(-8px) scale(.98); transition: opacity .35s, transform .35s; pointer-events: none;
}
.inset.tampil { opacity: 1; transform: none; }
.inset[data-jenis="glotis"] { width: 190px; }
.inset[data-jenis="langit"] { width: 350px; }
.inset-judul { font-size: 12.5px; font-weight: 800; color: var(--tosca-gelap); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.inset-ket { font-size: 13.5px; color: var(--teks); margin-top: 8px; line-height: 1.35; }
.inset svg { display: block; }

/* ---------- keterangan langkah ---------- */
#keterangan {
  flex: 0 0 auto; background: rgba(255, 253, 247, .96); border: 1px solid var(--garis);
  border-radius: var(--radius); box-shadow: var(--bayang); padding: 10px 14px 12px;
}
#baris-langkah { display: flex; align-items: center; gap: 8px; }
.bulat {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--tosca-muda); color: var(--tosca-gelap); font-size: 14px;
  transition: background .15s;
}
.bulat:hover { background: #cfeaf8; }
.bulat.utama { width: 44px; height: 44px; background: var(--tosca); color: #fff; font-size: 16px; box-shadow: 0 3px 10px rgba(21, 151, 207, .35); }
.bulat.utama:hover { background: var(--tosca-gelap); }
.bulat:disabled { opacity: .35; cursor: default; }
#chip-langkah { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; scrollbar-width: thin; flex: 1 1 auto; }
.chip {
  position: relative; flex: 0 0 auto; border: 1px solid #cfe3ee; background: #fff; color: var(--tosca-gelap);
  border-radius: 999px; padding: 6px 13px; font-size: 13.5px; font-weight: 700; overflow: hidden;
  transition: border-color .15s;
}
.chip b { font-weight: 800; opacity: .6; margin-right: 4px; }
.chip:hover { border-color: var(--tosca); }
.chip.aktif { background: var(--tosca); color: #fff; border-color: var(--tosca); }
.chip.aktif b { opacity: .85; }
.chip.selesai { background: #eef8fd; }
.chip .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--emas); width: 0; }
#teks-langkah { margin-top: 8px; min-height: 84px; overflow-y: auto; }
.tl-kepala { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#tl-no { font-size: 11.5px; font-weight: 800; color: #fff; background: var(--marun); border-radius: 6px; padding: 2px 7px; }
#tl-judul { font-size: 20px; font-weight: 800; color: var(--marun); }
#tl-arab { font-size: 30px; font-weight: 700; color: var(--arab); line-height: 1.8; padding-top: .14em; }
.tl-kepala { align-items: center !important; row-gap: 0; }
#tl-isi { font-size: 15.5px; line-height: 1.55; color: var(--teks); margin-top: 3px; }
#tl-lihat { font-size: 14px; color: var(--teks-lembut); margin-top: 3px; }
#tl-lihat:not(:empty)::before { content: '👁 '; }
#tl-kelompok { font-size: 14px; color: var(--teks-lembut); margin-top: 3px; }
#tl-kelompok .arab { font-size: 26px; font-weight: 700; color: var(--tosca-gelap); }
#tl-isi .arab, #tl-lihat .arab, .label3d .arab, .kuis .umpan .arab { font-size: 1.45em; font-weight: 700; color: var(--arab); }
.label3d .arab { color: inherit; }
#tl-judul .arab { font-size: 1.1em; font-weight: 400; }

/* ---------- kartu info ---------- */
#kartu-info { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.huruf-besar-wrap { display: flex; align-items: center; gap: 14px; }
#info-arab {
  font-size: 64px; line-height: 1; color: #fff; width: 92px; height: 92px; flex: 0 0 auto;
  display: flex; align-items: flex-start; justify-content: center; overflow: hidden;
  background: linear-gradient(180deg, #22a8e0, #1289be); border-radius: 18px;
  box-shadow: 0 4px 0 #0c6f9c, 0 8px 18px rgba(12, 111, 156, .3);
}
#info-nama { font-size: 22px; font-weight: 800; color: var(--teks); }
#info-wilayah { font-size: 14px; color: var(--teks-lembut); line-height: 1.35; }
#info-wilayah .arab { font-size: 22px; font-weight: 700; color: var(--arab); }
#info-latihan { font-size: 14px; color: var(--teks-lembut); margin-top: 2px; line-height: 1.2; }
#info-latihan .arab { font-size: 32px; font-weight: 700; color: var(--arab); vertical-align: middle; }
.huruf-besar-wrap > div:last-child { min-width: 0; }
.info-judul { margin-top: 10px; }
#info-makhraj { font-size: 15px; line-height: 1.55; background: #fff8e6; border-left: 4px solid var(--emas); padding: 7px 10px; border-radius: 0 8px 8px 0; }
#info-sifat { list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 5px; }
#info-sifat li button {
  counter-increment: s; width: 100%; text-align: left; display: flex; align-items: center; gap: 8px;
  border: 1px solid #d7e9f3; background: #f6fbfe; border-radius: 9px; padding: 4px 10px; font-size: 15px; color: var(--teks);
  transition: background .15s, border-color .15s;
}
#info-sifat li button::before { content: counter(s) '.'; font-weight: 800; color: var(--tosca-gelap); width: 16px; }
#info-sifat li button .arab { margin-left: auto; font-size: 24px; font-weight: 700; color: var(--arab); line-height: 1.7; padding-top: .1em; }
#info-sifat li button { min-height: 46px; }
#info-sifat li button:hover { border-color: var(--tosca); }
#info-sifat li button.aktif { background: #fff4cc; border-color: var(--emas); font-weight: 700; }
.kontrol-khusus { margin-top: 4px; }
.segmen { display: flex; background: var(--tosca-muda); border-radius: 10px; padding: 3px; gap: 3px; margin-top: 6px; }
.segmen button { flex: 1; border: none; background: transparent; padding: 7px; border-radius: 8px; font-size: 13.5px; color: var(--tosca-gelap); font-weight: 600; }
.segmen button.aktif { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); color: var(--teks); }
#slider-tebal { width: 100%; accent-color: #e5533b; margin-top: 8px; }
.tebal-skala { display: flex; justify-content: space-between; font-size: 13px; color: var(--teks-lembut); }
#info-sumber { margin-top: auto; padding-top: 10px; font-size: 12.5px; color: var(--teks-lembut); }
.btn-dengar { border: 1px solid var(--tosca); background: #fff; color: var(--tosca-gelap); border-radius: 10px; padding: 7px; font-weight: 600; }

/* ---------- footer ---------- */
#kontrol {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 7px 16px; background: rgba(255, 253, 247, .95); border-top: 1px solid var(--garis);
  font-size: 14px; color: var(--teks-lembut);
}
#kontrol .ctl { display: flex; align-items: center; gap: 6px; }
#kontrol .t-pendek { display: none; }
/* Mode Jelajah melewati langkah Latihan → chip-nya disembunyikan agar jelas */
body.mode-jelajah #chip-langkah .chip-latihan { display: none; }
#kontrol select { border-radius: 8px; border: 1px solid #d8c9a8; padding: 4px 6px; background: #fff; font-size: 13px; }
#vol { width: 90px; accent-color: var(--tosca); }
.spasi { flex: 1; }
.ikon-btn { border: none; background: var(--tosca-muda); border-radius: 8px; padding: 4px 9px; font-size: 16px; }
#status-jelajah { font-weight: 700; color: var(--tosca-gelap); }

/* ---------- kuis ---------- */
/* kartu kuis berada DI BAWAH tampilan 3D (bukan menumpuk di atasnya),
   sehingga makhraj di area mana pun — termasuk tenggorokan — selalu terlihat */
.kuis {
  flex: 0 0 auto; width: 100%; background: rgba(255, 253, 247, .98); border: 2px solid var(--emas);
  border-radius: var(--radius); box-shadow: var(--bayang); padding: 12px 14px; text-align: center;
}
.kuis[hidden] { display: none; }
.kuis { scroll-margin-bottom: 64px; }
.kuis .opsi { max-width: 620px; margin: 0 auto; }
body.mode-kuis #keterangan { display: none; }
body.kuis-tebak #inset { display: none; }
body.kuis-tebak #legenda { visibility: hidden; }
.kuis h3 { font-size: 16px; color: var(--marun); margin-bottom: 8px; }
.kuis .opsi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kuis .opsi button {
  border: 2px solid #cfe3ee; background: #fff; border-radius: 12px; padding: 4px 0 6px; font-size: 13px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; transition: transform .1s, background .2s, border-color .2s;
}
.kuis .opsi button .glyph-box { height: 48px; }
.kuis .opsi button .glyph { font-size: 38px; color: var(--tosca-gelap); }
.kuis .opsi button .nm { line-height: 1.2; }
.kuis .opsi button:hover { transform: translateY(-2px); border-color: var(--tosca); }
.kuis .opsi button.benar { background: #e5f7ea; border-color: #2ea44f; }
.kuis .opsi button.salah { background: #fdecec; border-color: #d73a49; }
.kuis .umpan { min-height: 20px; margin-top: 8px; font-size: 14.5px; }
.kuis .baris { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14px; color: var(--teks-lembut); }
.kuis .baris button { border: none; background: var(--tosca); color: #fff; padding: 6px 14px; border-radius: 99px; font-weight: 700; }
.kuis .baris button.lain { background: #eee; color: var(--teks); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(30, 20, 5, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-isi { position: relative; background: var(--kertas); border-radius: 16px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.3); font-size: 14px; line-height: 1.55; }
.modal-isi h2 { color: var(--tosca-gelap); margin-bottom: 10px; font-size: 20px; }
.modal-isi h3 { color: var(--marun); margin: 12px 0 6px; font-size: 15px; }
.modal-isi ol { padding-left: 20px; }
.modal-isi a { color: var(--tosca-gelap); font-weight: 600; }
.modal-isi .referensi li { margin-bottom: 8px; }
.modal-isi .referensi .arab { font-size: 19px; line-height: 1.7; color: var(--arab); margin-inline-start: 4px; white-space: nowrap; }
.modal-isi .ref-ket { display: block; color: var(--teks-lembut); font-size: 13px; }
.modal-isi .kredit { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(12, 111, 156, .08); border-left: 4px solid var(--tosca-gelap); font-size: 13.5px; }
.modal-isi .tutup { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 20px; color: var(--teks-lembut); }
.legenda-bantu { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.legenda-bantu i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
kbd { background: #fff; border: 1px solid #ccc; border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; }
.kecil { font-size: 13px; color: var(--teks-lembut); margin-top: 10px; }
#webgl-gagal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; font-size: 15px; background: var(--krem); }
#webgl-gagal[hidden] { display: none; }

/* ---------- layar penuh (proyektor) ---------- */
body.layar-penuh #header, body.layar-penuh #panel-huruf, body.layar-penuh #kontrol { display: none; }
body.layar-penuh #main { grid-template-columns: minmax(0, 1fr) 320px; }
body.layar-penuh #tl-isi { font-size: 17px; }
body.layar-penuh #tl-judul { font-size: 22px; }

/* ---------- layar sedang ---------- */
@media (max-width: 1180px) {
  #main { grid-template-columns: 214px minmax(0, 1fr) 290px; gap: 10px; padding: 10px; }
  .grup-row { grid-template-columns: repeat(3, 1fr); }
  #info-arab { width: 76px; height: 76px; font-size: 52px; }
}
/* ---------- ponsel & tablet potret ---------- */
@media (max-width: 860px) {
  body { overflow: auto; display: block; height: auto; }
  #header h1 { white-space: nowrap; }
  .btn-header { white-space: nowrap; }
  .btn-header .t-panjang { display: none; }
  #main { min-height: auto; }
  #panggung { min-height: auto; }
  #keterangan { padding: 8px 10px 10px; }
  #teks-langkah { min-height: 0; overflow: visible; }
  #tl-isi { font-size: 15px; }
  #kontrol { position: sticky; bottom: 0; z-index: 5; flex-wrap: nowrap; padding: 6px 12px; }
  #kontrol .ctl:has(#vol) { display: none; }
  #header { padding: 6px 12px 18px; }
  #header h1 { font-size: 19px; }
  #subjudul { display: none; }
  .btn-header { padding: 6px 10px; font-size: 12.5px; }
  #main { display: flex; flex-direction: column; padding: 8px; gap: 8px; }
  #panel-huruf { order: 1; padding: 8px; overflow-x: auto; overflow-y: hidden; }
  #panel-huruf .panel-judul { display: none; }
  #daftar-huruf { display: flex; gap: 10px; }
  .grup { margin: 0; flex: 0 0 auto; }
  .grup-row { display: flex; gap: 5px; }
  .tombol-huruf { width: 56px; }
  .grup { min-width: max-content; }
  .grup-judul { gap: 10px; white-space: nowrap; }
  /* HP: tiap wilayah jadi kotak berwarna sendiri; judulnya tetap terlihat saat digeser */
  #daftar-huruf { gap: 8px; }
  .grup { background: var(--w-bg); border: 2px solid var(--w); border-radius: 14px; padding: 5px 6px 7px; }
  .grup-judul {
    position: sticky; left: 4px; z-index: 1; display: inline-flex; width: max-content; justify-content: flex-start;
    gap: 8px; margin: 0 0 6px; padding: 1px 12px 1px 10px; border: none; border-radius: 999px;
    background: var(--w); color: #fff; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  }
  .grup-judul .gj-nama { color: #fff; }
  .grup-judul .gj-jml { color: rgba(255,255,255,.88); font-size: 11px; }
  /* harakat Arab (syaddah+fathah dll.) butuh ruang di atas agar tidak menempel tepi label */
  .grup-judul { align-items: center; padding: 2px 12px 2px 10px; }
  .grup-judul .arab { color: #fff; font-size: 16px; line-height: 1; padding: 11px 0 5px; }
  #daftar-huruf.alfabetis .grup-judul { left: auto; right: 4px; }
  #daftar-huruf.alfabetis .gj-kiri { direction: ltr; }
  #panggung { order: 2; }
  #viewport { height: 50vh; min-height: 300px; max-height: 560px; flex: 0 0 auto; }
  #kartu-info { order: 3; overflow: visible; }
  /* gambar sisipan menjadi kartu tersendiri di bawah tampilan 3D */
  .inset.dok, .inset.dok[data-jenis] {
    position: static; width: 100%; max-width: none; transform: none; opacity: 1;
    display: none; padding: 10px 12px; box-shadow: var(--bayang);
  }
  .inset.dok.tampil { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "j j" "s k"; gap: 4px 12px; align-items: center; }
  .inset.dok .inset-judul { grid-area: j; font-size: 12px; }
  .inset.dok .inset-svg { grid-area: s; }
  .inset.dok .inset-ket { grid-area: k; font-size: 14px; margin: 0; }
  .inset.dok .inset-svg svg { width: auto; height: 170px; max-width: 58vw; margin: 0 auto; }
  .inset.dok[data-jenis="langit"] .inset-svg svg { width: 100%; max-width: 440px; height: auto; }
  .inset.dok[data-jenis="langit"].tampil { grid-template-columns: 1fr; grid-template-areas: "j" "s" "k"; }
  #hint-orbit { display: none; }
  #legenda { font-size: 12px; }
  #kontrol { gap: 10px; }
  #kontrol { gap: 8px; }
  #kontrol .lbl, #kontrol .t-panjang { display: none; }
  #kontrol .t-pendek { display: inline; }
  #kontrol .ctl { gap: 4px; white-space: nowrap; }
  #kontrol select { font-size: 12.5px; padding: 4px 3px; }
  #panel-huruf.alfabetis { direction: rtl; } /* strip HP mulai dari kanan (Hamzah) */
  #daftar-huruf.alfabetis .grup-judul { justify-content: flex-start; direction: rtl; }
  body.mode-kuis #viewport { height: 46vh; min-height: 280px; }
  .kuis { padding: 10px; }
  .kuis h3 { font-size: 15px; }
  .kuis .opsi { gap: 6px; }
  .kuis .opsi button .glyph { font-size: 30px; }
  .kuis .opsi button .glyph-box { height: 42px; }
}

/* peta sifat berpasangan */
.kecil-inline { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--teks-lembut); font-size: 12px; }
#peta-sifat { display: flex; flex-direction: column; gap: 5px; }
.peta-baris { display: flex; gap: 4px; }
.peta-baris span {
  flex: 1; text-align: center; font-size: 13px; padding: 6px 2px; border-radius: 8px;
  background: #f1ece2; color: #7d6f58; border: 1px dashed #e0d5c0; white-space: nowrap;
}
.peta-baris span.punya { color: #fff; font-weight: 700; border-style: solid; border-color: transparent; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.peta-baris span.punya.aktif { outline: 3px solid var(--emas); outline-offset: 1px; }
.peta-tambahan { display: flex; flex-wrap: wrap; gap: 4px; }
.peta-tambahan span { font-size: 13px; padding: 4px 9px; border-radius: 99px; color: #fff; font-weight: 700; cursor: pointer; }
.peta-tambahan span.aktif { outline: 3px solid var(--emas); outline-offset: 1px; }

/* ================= LATIHAN MEMBACA ================= */
.quran { font-family: 'Amiri Quran', 'Amiri', 'Traditional Arabic', serif; direction: rtl; unicode-bidi: isolate; color: #1d1512; font-weight: 400;}
.quran .tt { color: #d0161b; }
.tanpa-tanda .quran .tt { color: inherit; }
.btn-latihan {
  display: flex; flex-direction: column; align-items: center; gap: 1px; margin-top: 8px;
  border: none; border-radius: 12px; padding: 9px 10px; font-size: 15.5px; font-weight: 800; color: #3d2c00;
  background: linear-gradient(180deg, #ffd84d, #f2b705); box-shadow: 0 2px 0 #b98700, 0 4px 10px rgba(185, 135, 0, .25);
}
.btn-latihan .jml { font-size: 12.5px; font-weight: 600; opacity: .85; }
.btn-latihan:hover { filter: brightness(1.04); }
.btn-latihan[hidden] { display: none; }

#keterangan.mode-latihan #tl-lihat, #keterangan.mode-latihan #tl-kelompok, #keterangan.mode-latihan #tl-isi { display: none; }
#keterangan.mode-latihan #tl-isi { font-size: 13.5px; color: var(--teks-lembut); margin-top: 0; }
#keterangan.mode-latihan #teks-langkah { min-height: 0; }
#tl-latihan { margin-top: 6px; }
/* versi ringkas di panel langkah: satu kartu (suku kata / ayat) agar tinggi panel sama dengan langkah lain */
#tl-latihan .lat-drill { background: none; padding: 2px 0 6px; font-size: 20px; gap: 4px; flex-wrap: nowrap; justify-content: safe center;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
#tl-latihan .lat-drill .suku { flex: 0 0 auto; }
#tl-latihan .lat-kartu .lat-ayat { font-size: 25px; line-height: 2.05; padding-bottom: .3em; }
#tl-latihan .lat-bagian { line-height: 1.8; }
#tl-latihan .lat-carousel { margin-top: 5px; }
.lat-drill { font-size: 27px; background: #fff8e6; border-radius: 12px; padding: 6px 8px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 6px; }
.lat-drill .suku { display: inline-block; line-height: 1; padding: .32em .4em .97em; background: #fff; border: 1px solid #f0dfb0; border-radius: 9px; white-space: nowrap; }
/* catatan: Amiri Quran — ascent font 1,82em, descent 0,63em; tinta suku kata terjauh naik 1,35em & turun 0,83em.
   Dengan line-height 1, garis dasar di 1,095em → tinta −0,26…1,93em; padding di atas membungkus seluruh tinta. */
.lat-carousel { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.lat-carousel .bulat.kecil { width: 40px; height: 40px; font-size: 24px; line-height: 1; padding-bottom: 3px; flex: 0 0 auto; }
.lat-kartu { flex: 1; min-width: 0; text-align: center; background: #fff; border: 1px solid var(--garis); border-radius: 12px; padding: 0 12px 5px; }
.lat-bagian { font-size: 13px; font-weight: 800; color: var(--tosca-gelap); line-height: 2; }
.lat-bagian .jd-ar { font-size: 19px; line-height: 1.5; }
.lat-kartu .lat-ayat { font-size: 31px; line-height: 1.95; }
.lat-ref { font-size: 13px; color: var(--teks-lembut); font-weight: 600; position: relative; padding-top: 2px; }
.lat-kartu .lat-ayat, .lat-daftar .lat-ayat { padding-bottom: .45em; line-height: 2.3; }
.btn-lat-semua { flex: 0 0 auto; max-width: 96px; white-space: normal; border: 1px solid var(--tosca); background: #fff; color: var(--tosca-gelap); font-weight: 700; font-size: 12.5px; line-height: 1.25; border-radius: 12px; padding: 6px 10px; }
.btn-lat-semua b { font-size: 16px; }
.btn-lat-semua:hover { background: var(--tosca-muda); }
.lat-kosong { font-size: 14px; color: var(--teks-lembut); font-style: italic; }

/* jendela latihan */
.modal-isi.lat-modal { max-width: 920px; padding: 0; display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }
#modal-latihan { --lat-skala: 1; }
.lat-kepala { display: flex; align-items: center; gap: 14px; padding: 16px 56px 12px 20px; border-bottom: 1px solid var(--garis); position: relative; }
.lat-kepala .tutup { top: 14px; }
.lat-glyph { width: 64px; height: 64px; flex: 0 0 auto; border-radius: 14px; color: #fff; font-size: 44px; overflow: hidden;
  display: flex; justify-content: center; align-items: flex-start;
  background: linear-gradient(180deg, #22a8e0, #1289be); box-shadow: 0 3px 0 #0c6f9c; }
.lat-kepala h2 { font-size: 21px; color: var(--marun); margin: 0; }
.lat-sub { font-size: 14px; color: var(--teks-lembut); margin-top: 2px; }
.lat-alat { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 20px; background: #fbf6ea; border-bottom: 1px solid var(--garis); }
.lat-alat button { border: 1px solid #cfe3ee; background: #fff; color: var(--tosca-gelap); font-weight: 700; font-size: 14px; border-radius: 99px; padding: 6px 13px; }
.lat-alat button:hover { border-color: var(--tosca); }
.lat-alat button:disabled { opacity: .4; cursor: default; }
.lat-nav { display: flex; gap: 8px; margin-right: auto; }
.lat-ukuran { display: flex; align-items: center; gap: 4px; }
.lat-ukuran button { min-width: 44px; }
.lat-persen { min-width: 46px; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--teks); }
.lat-cek { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--teks); }
.lat-badan { overflow-y: auto; padding: 6px 20px 16px; }
.lat-badan section { margin-top: 12px; }
.lat-badan h3 { display: flex; align-items: center; gap: 4px; min-height: 36px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--tosca-gelap); margin-bottom: 6px; }
.lat-drill.besar { font-size: calc(36px * var(--lat-skala)); }
.lat-daftar { list-style: none; counter-reset: none; display: grid; gap: 8px; }
.lat-daftar li { background: #fff; border: 1px solid var(--garis); border-radius: 12px; padding: 4px 16px 8px; }
.lat-no { display: inline-block; min-width: 24px; height: 24px; margin-right: 8px; border-radius: 50%; background: var(--tosca-muda);
  color: var(--tosca-gelap); font-weight: 800; font-size: 13px; text-align: center; line-height: 24px; }
.lat-daftar .lat-ayat { font-size: calc(34px * var(--lat-skala)); line-height: 2.3; text-align: right; }
.lat-daftar .lat-ref { text-align: left; display: flex; align-items: center; border-top: 1px dashed #eadfc6; padding-top: 5px; }
.lat-sumber { font-size: 12.5px; color: var(--teks-lembut); margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: #fbf6ea; }
.jd-ar { display: inline-block; font-size: 22px; line-height: 1.6; padding: 0 .4em; margin-left: 4px; text-transform: none; letter-spacing: 0;
  color: var(--arab); background: #fff; border: 1px solid #f0dfb0; border-radius: 8px; }
body.modal-terbuka { overflow: hidden; }

@media (max-width: 860px) {
  .lat-drill { font-size: 25px; padding: 2px 8px; }
  .lat-kartu .lat-ayat { font-size: 28px; }
  #tl-latihan .lat-kartu .lat-ayat { font-size: 21px; }
  #tl-latihan .lat-drill { font-size: 18px; justify-content: flex-start; }
  .lat-carousel { gap: 6px; }
  .lat-carousel { flex-wrap: wrap; }
  .lat-carousel .bulat.kecil { width: 32px; height: 32px; }
  .lat-kartu { order: 0; }
  .btn-lat-semua { order: 3; flex: 1 1 100%; max-width: none; padding: 7px; font-size: 13.5px; }
  .btn-lat-semua b { font-size: 14px; }
  #modal-latihan { padding: 0; }
  .modal-isi.lat-modal { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .lat-kepala { padding: 12px 50px 10px 14px; }
  .lat-glyph { width: 50px; height: 50px; font-size: 34px; }
  .lat-kepala h2 { font-size: 17px; }
  .lat-sub { font-size: 12.5px; }
  .lat-alat { padding: 8px 10px; gap: 6px; flex-wrap: nowrap; }
  .lat-alat button { padding: 5px 10px; font-size: 14px; }
  .lat-nav { gap: 5px; }
  .lat-nav button { min-width: 38px; font-size: 18px; line-height: 1; padding: 4px 0 6px; }
  .lat-nav .t-panjang { display: none; }
  .lat-cek { font-size: 13px; gap: 4px; white-space: nowrap; }
  .lat-ukuran button { min-width: 38px; padding: 5px 6px; }
  .lat-persen { min-width: 38px; font-size: 12.5px; }
  .lat-badan { padding: 4px 12px 14px; }
  .lat-drill.besar { font-size: calc(28px * var(--lat-skala)); }
  .lat-daftar .lat-ayat { font-size: calc(27px * var(--lat-skala)); }
  .lat-daftar li { padding: 2px 12px 6px; }
  .lat-drill { gap: 4px; padding: 5px 6px; }
}
@media (max-width: 380px) {
  #kontrol { gap: 5px; padding: 6px 8px; }
  #kontrol select { font-size: 12px; padding: 3px 1px; }
  #btn-mute { width: 34px; }
}
