:root {
  --bg: #0e1a14;
  --card: #16241c;
  --card2: #1c2f24;
  --text: #e8f0ea;
  --muted: #93a89b;
  --accent: #2fb56b;
  --accent-dark: #22824e;
  --red: #e05252;
  --yellow: #d9a531;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column;
}

/* ---------- brand & hero ---------- */
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  animation: logo-float 3.5s ease-in-out infinite;
  box-shadow: 0 4px 18px rgba(47,181,107,.35);
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-3deg); }
}
.brand-title {
  font-size: 2rem; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(110deg, #6ee7a0 15%, #eafff2 38%, #2fb56b 55%, #6ee7a0 80%);
  background-size: 220% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: shimmer 4.5s linear infinite;
}
@keyframes shimmer { to { background-position: -220% center; } }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* halaman muka: pas satu layar, tanpa scroll */
body.home-mode footer { display: none; }
body.home-mode main { padding: 0 16px; height: 100%; display: flex; flex-direction: column; min-height: 0; }
#page-home {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#page-home[hidden] { display: none; }
#home-foot {
  margin-top: 26px; text-align: center;
  color: var(--muted); font-size: .72rem; font-weight: 600; opacity: .75;
}
/* Latar borderless: lapisan fixed selebar viewport penuh, tak dibatasi kontainer */
body.home-mode::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background-image:
    radial-gradient(48vw 36vh at 15% 10%, rgba(47,181,107,.14), transparent 70%),
    radial-gradient(52vw 40vh at 88% 85%, rgba(47,181,107,.10), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Cpath d='M36 10 L43 29 L62 36 L43 43 L36 62 L29 43 L10 36 L29 29 Z' fill='none' stroke='%232fb56b' stroke-opacity='.09'/%3E%3C/svg%3E");
}
.hero { text-align: center; padding: 12px 20px 0; max-width: 560px; }
@media (max-height: 700px) {
  .logo-hero { width: 60px; height: 60px; }
  .brand-hero { font-size: 2rem; }
  .hero-ayah { font-size: 1.9rem; }
  .cta { margin-top: 16px; padding: 13px 32px; }
  .features { margin-top: 16px; }
  .ornament { margin: 8px 0 4px; }
}
.logo-hero { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 14px; }
.brand-hero { font-size: 2.6rem; }
.ornament {
  color: var(--accent); letter-spacing: 10px; font-size: 1rem;
  margin: 14px 0 6px; opacity: .8; animation: fade-up 1s .15s ease both;
}
.hero-ayah {
  font-family: 'Amiri Quran', serif; font-size: 2.5rem; line-height: 1.9;
  color: #eafff2; margin-top: 6px; animation: fade-up 1.1s .25s ease both;
  text-shadow: 0 0 30px rgba(47,181,107,.35);
}
.hero-trans { color: var(--text); font-size: .95rem; margin-top: 10px; animation: fade-up 1.1s .4s ease both; }
.hero-ref { color: var(--muted); font-size: .8rem; margin-top: 4px; font-style: italic; animation: fade-up 1.1s .5s ease both; }
.cta {
  margin-top: 26px; font-size: 1.15rem; font-weight: 800; color: #fff;
  background: linear-gradient(120deg, var(--accent-dark), var(--accent));
  padding: 16px 40px; border-radius: 999px;
  box-shadow: 0 6px 30px rgba(47,181,107,.45);
  animation: fade-up 1.1s .6s ease both, cta-glow 2.6s ease-in-out 1.8s infinite;
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.08); }
@keyframes cta-glow {
  0%, 100% { box-shadow: 0 6px 30px rgba(47,181,107,.45); }
  50% { box-shadow: 0 6px 44px rgba(47,181,107,.75); }
}
.features {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 26px; animation: fade-up 1.1s .75s ease both;
}
.features span {
  background: var(--card); border: 1px solid #2a3f32; border-radius: 999px;
  padding: 6px 14px; font-size: .78rem; color: var(--muted);
}

/* header kecil halaman daftar surah */
.list-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.list-title { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--muted); }
.list-title b { color: var(--text); }
.mini-logo { width: 26px; height: 26px; border-radius: 7px; }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; }
footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 14px; line-height: 1.7; }
#foot-meta { opacity: .75; font-weight: 600; }

/* ---------- kunci viewport (home & baca): html+body 100% agar andal di mobile ---------- */
html.lock { height: 100%; overflow: hidden; }
html.lock body { height: 100%; min-height: 0; overflow: hidden; }

/* ---------- mode baca: layout viewport tetap, hanya ayat yang scroll ---------- */
body.read-mode footer { display: none; }
body.read-mode main { padding: 0 12px; height: 100%; display: flex; flex-direction: column; min-height: 0; }
#page-read { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#page-read[hidden] { display: none; }

#read-top { padding: 8px 2px 6px; border-bottom: 1px solid #22382b; }
.read-head { display: flex; align-items: center; gap: 10px; }
#read-title { font-weight: 800; font-size: 1rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* stats compact satu baris: skor besar + jumlah kata per status (warna = arti) */
#mini-stats {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 6px;
  white-space: nowrap; overflow-x: auto; scrollbar-width: none;
}
#mini-stats::-webkit-scrollbar { display: none; }
.ms-score {
  font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--text);
  min-width: 2.2ch; text-align: center;
}
.ms-score.s-good { color: #6ee7a0; } .ms-score.s-mid { color: var(--yellow); } .ms-score.s-bad { color: var(--red); }
.ms { color: var(--muted); font-size: .68rem; display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; }
.ms b { color: var(--text); font-size: .95rem; }
.ms-correct b { color: #6ee7a0; }
.ms-close b { color: var(--yellow); }
.ms-wrong b { color: var(--red); }
.ms-missed b { color: var(--muted); text-decoration: line-through; }

/* daftar ayat = SATU-SATUNYA area scroll */
#ayah-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 12px 2px;
  scroll-behavior: smooth;
}
.ayah-card {
  background: var(--card); border: 1px solid #22382b; border-radius: var(--radius);
  padding: 14px 16px; transition: border-color .2s, background .2s;
}
.ayah-card.ay-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ayah-card.ay-correct { background: #14301f; border-color: #2b6b45; }
.ayah-card.ay-wrong { background: #331a1a; border-color: #7a3535; }
.ay-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.ay-no { color: var(--accent); font-weight: 800; font-size: .78rem; }
.ay-score { font-weight: 800; font-size: .9rem; }
/* Fokus ke bacaan: ayat besar, arti kecil */
.ay-text {
  font-family: 'Amiri Quran', serif; font-size: 2.3rem; line-height: 2.15;
  text-align: right; margin-bottom: 6px;
}
.ay-trans { color: var(--muted); font-size: .64rem; opacity: .8; }
.w { padding: 0 3px; border-radius: 6px; transition: color .35s ease; }
.w-correct { color: #6ee7a0; }
.w-close  { color: var(--yellow); border-bottom: 2px dotted var(--yellow); }
.w-wrong  { color: var(--red); border-bottom: 2px solid var(--red); }
.w-missed { color: var(--muted); opacity: .55; text-decoration: line-through; }
.w-skip, .w-pending { color: var(--text); }

/* ---------- bar bawah compact: progress + tombol satu baris ---------- */
#live-bar {
  border-top: 1px solid #22382b; padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
}
#live-row { display: flex; align-items: center; gap: 10px; }
#level {
  font-family: inherit; font-size: .8rem; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1px solid #2a3f32; border-radius: 999px; padding: 7px 10px;
  outline: none; cursor: pointer;
}
#level:disabled { opacity: .5; }
#read-progress {
  position: relative; flex: 1; height: 30px; background: var(--card2);
  border-radius: 999px; overflow: hidden; text-align: center;
}
#rp-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  border-radius: 999px; overflow: hidden;
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
/* kilau lembut menyapu dari kiri ke kanan — halus, jalan di GPU */
#rp-fill::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 15%, rgba(255,255,255,.28) 50%, transparent 85%);
  animation: sheen 2.2s ease-in-out infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }
#rp-text {
  position: relative; z-index: 1; font-size: .72rem; font-weight: 700;
  line-height: 30px; color: var(--text); text-shadow: 0 1px 2px rgba(0,0,0,.5);
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 10px;
}

/* ---------- tombol ---------- */
button {
  font-family: inherit; font-size: 1rem; font-weight: 600; border: none;
  border-radius: var(--radius); padding: 12px 26px; cursor: pointer; transition: .15s;
}
.record { background: var(--accent); color: #fff; font-size: 1.05rem; }
#live-row .record {
  padding: 8px 22px; font-size: .95rem; white-space: nowrap; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center; min-width: 108px;
}
.bi { width: 17px; height: 17px; flex-shrink: 0; }
.spin { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* mic dengan gelombang ambient saat merekam */
.mic-wrap { position: relative; display: inline-flex; width: 17px; height: 17px; flex-shrink: 0; }
.mic-wrap .bi { position: relative; z-index: 1; animation: mic-breathe 1.6s ease-in-out infinite; }
.recording .mic-wrap::before,
.recording .mic-wrap::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.65);
  animation: ring 1.7s ease-out infinite;
}
.recording .mic-wrap::after { animation-delay: .85s; }
@keyframes ring {
  from { transform: scale(.55); opacity: .9; }
  to { transform: scale(2); opacity: 0; }
}
@keyframes mic-breathe { 50% { transform: scale(1.12); } }

/* bubble toast */
#toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 60;
  transform: translateX(-50%) translateY(10px) scale(.95);
  background: var(--card); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 20px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(47,181,107,.15);
  opacity: 0; pointer-events: none; white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
  transition: opacity .35s ease, transform .35s cubic-bezier(.34,1.56,.64,1);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.record.recording { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(224,82,82,.15); } }
.primary { background: var(--accent); color: #fff; }
.ghost { background: transparent; color: var(--muted); border: 1px solid #2a3f32; }
.ghost.small { padding: 8px 14px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 11px; border-radius: 12px; color: var(--text);
}
.icon-btn .bi { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost:hover, .primary:hover, .record:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }

/* ---------- daftar surah ---------- */
#search {
  width: 100%; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid #2a3f32; background: var(--card); color: var(--text);
  font-size: 1rem; margin-bottom: 14px; outline: none;
}
#search:focus { border-color: var(--accent); }
#surah-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.surah-item {
  background: var(--card); border: 1px solid #22382b; border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  transition: .15s;
}
.surah-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.surah-no {
  background: var(--card2); color: var(--accent); font-weight: 800;
  width: 38px; height: 38px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; font-size: .85rem;
}
.surah-meta { flex: 1; min-width: 0; }
.surah-latin { font-weight: 600; font-size: .95rem; }
.surah-sub { color: var(--muted); font-size: .75rem; }
.surah-ar { font-family: 'Amiri Quran', serif; font-size: 1.3rem; color: var(--accent); }

/* ---------- overlay summary ---------- */
#summary-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(6,12,9,.75);
  backdrop-filter: blur(4px);
}
#summary-overlay[hidden] { display: none; }
.card {
  background: var(--card); border: 1px solid #22382b; border-radius: var(--radius);
  padding: 20px; width: 100%; max-width: 440px; animation: fade-up .35s ease both;
}
#summary h2 {
  font-size: 1.15rem; margin-bottom: 10px; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.sum-ic { width: 24px; height: 24px; color: var(--accent); flex-shrink: 0; }
.btn-ic { display: inline-flex; align-items: center; gap: 7px; }
#sum-top { display: flex; justify-content: center; align-items: baseline; gap: 30px; margin-bottom: 14px; }
#sum-pct { font-size: 2.6rem; font-weight: 800; text-align: center; }
#sum-pct small, #sum-accum small { display: block; font-size: .74rem; font-weight: 600; color: var(--muted); }
#sum-accum { font-size: 2.6rem; font-weight: 800; text-align: center; color: var(--text); }
#sum-accum .of { font-size: 1.2rem; color: var(--muted); font-weight: 700; }
#sum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.sum-item { background: var(--card2); border-radius: 10px; padding: 10px 4px; text-align: center; }
.sum-item span { font-size: 1.3rem; font-weight: 800; display: block; }
.sum-item label { color: var(--muted); font-size: .68rem; }
.st-good span { color: #6ee7a0; }
.st-bad span { color: var(--red); }
#sum-cheer {
  color: #6ee7a0; font-size: .9rem; font-weight: 700; text-align: center;
  margin-bottom: 8px; animation: fade-up .5s .15s ease both;
}
#sum-tempo { color: var(--text); font-size: .85rem; font-weight: 600; text-align: center; margin-bottom: 6px; }
#sum-note { color: var(--muted); font-size: .85rem; text-align: center; margin-bottom: 4px; }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

.s-good { color: #6ee7a0; } .s-mid { color: var(--yellow); } .s-bad { color: var(--red); }

@media (max-width: 520px) {
  .ay-text { font-size: 1.95rem; line-height: 2.1; }
  #sum-grid { grid-template-columns: repeat(2, 1fr); }
}
