:root {
  --bg: #F2F5FA;
  --surface: #FFFFFF;
  --ink: #1D2547;
  --muted: #5B6485;
  --line: #DCE2EE;
  --lapis: #23308F;
  --saffron: #F2A007;
  --arab-size: 2rem;
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;

  --turquoise: #0E9494;
  --rose: #D63A72;
  --emerald: #1B8F52;
  --plum: #7E37BA;
  --coral: #E0553A;
  --blue: #3553D6;
  --amber: #C27C00;

  /* Tajwid Colors (Standard Mushaf) */
  --tj-mad: #DC2626;      /* Merah - Mad Panjang */
  --tj-ghunnah: #16A34A;  /* Hijau - Ghunnah Musyaddadah */
  --tj-ikhfa: #0D9488;    /* Toska - Ikhfa & Iqlab */
  --tj-idgham: #EA580C;   /* Oranye - Idgham Bighunnah/Bilaghunnah */
  --tj-qalqalah: #2563EB; /* Biru - Qalqalah Sughra/Kubra */

  --hue: var(--lapis);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121735;
    --surface: #1B2146;
    --ink: #EEF1FB;
    --muted: #A9B0CF;
    --line: #2E3766;
    --tj-mad: #F87171;
    --tj-ghunnah: #4ADE80;
    --tj-ikhfa: #2DD4BF;
    --tj-idgham: #FB923C;
    --tj-qalqalah: #60A5FA;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121735;
  --surface: #1B2146;
  --ink: #EEF1FB;
  --muted: #A9B0CF;
  --line: #2E3766;
  --tj-mad: #F87171;
  --tj-ghunnah: #4ADE80;
  --tj-ikhfa: #2DD4BF;
  --tj-idgham: #FB923C;
  --tj-qalqalah: #60A5FA;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
[lang="ar"] { font-family: "Scheherazade New", serif; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(60rem 30rem at 85% 40%, rgba(91,123,255,.45), transparent 60%),
    radial-gradient(40rem 25rem at 0% 100%, rgba(224,69,123,.35), transparent 60%),
    var(--lapis);
}
.hero::before { /* 8-point star tiling */
  content: "";
  position: absolute; inset: 0;
  opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.5'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
}
.hero-inner {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  align-items: center;
}
.hero-arab {
  font-family: "Aref Ruqaa", serif;
  font-size: clamp(4rem, 11vw, 7.5rem);
  line-height: 1.1;
  margin: 0;
  color: var(--saffron);
  text-align: left;
  animation: rise .9s .9s both cubic-bezier(.2,.8,.2,1);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  font-weight: 800;
  margin: .25rem 0 1rem;
  max-width: 14ch;
  animation: rise .9s 1.05s both cubic-bezier(.2,.8,.2,1);
}
.hero-lede {
  max-width: 46ch;
  color: #D9DEFF;
  font-size: 1.075rem;
  margin: 0 0 2rem;
  animation: rise .9s 1.2s both cubic-bezier(.2,.8,.2,1);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; animation: rise .9s 1.35s both cubic-bezier(.2,.8,.2,1); }

.rosette { width: min(420px, 100%); justify-self: center; overflow: visible; }
.rosette-spin { transform-origin: 100px 100px; animation: spin 90s linear 1.6s infinite; }
.rosette use[href="#petal"] {
  transform-origin: 100px 100px;
  transform: rotate(calc(var(--i) * 45deg)) scale(0);
  animation: bloom .7s calc(var(--i) * 90ms) forwards cubic-bezier(.3,1.5,.5,1);
}
.rosette .dots { fill: rgba(255,255,255,.8); animation: fade .6s .9s both; }

@keyframes bloom { to { transform: rotate(calc(var(--i) * 45deg)) scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes fade { from { opacity: 0; } }

.theme-toggle {
  position: absolute; top: 1rem; right: 1rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font: 700 1rem/1 var(--sans);
  padding: .95rem 1.4rem;
  border-radius: 999px;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s;
}
.btn:active { transform: scale(.97); }
.btn-solid { background: var(--saffron); color: #231800; }
.btn-ghost { border-color: rgba(255,255,255,.5); color: #fff; }
.round {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 700 1.25rem/1 var(--sans);
  cursor: pointer;
  display: grid; place-items: center;
}
.round.sm { font-size: .9rem; width: 40px; height: 40px; }

/* ---------- Sections ---------- */
.section { max-width: 1120px; margin: 0 auto; padding: 4rem 1.5rem; }
.section h2 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); letter-spacing: -.01em; margin: 0; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 2rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font: 500 .95rem/1 var(--sans);
  padding: .7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Bacaan waktu ini ---------- */
.section.today { padding-bottom: 0; }
.today-panel {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.75rem;
}
.today-panel h2 { margin-bottom: 1rem; }
.today-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.today-item {
  width: 100%;
  display: flex; align-items: center; gap: .9rem;
  text-align: left;
  font: inherit; color: inherit;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 16px;
  padding: .85rem 1rem;
  cursor: pointer;
}
.today-item:hover { border-color: var(--hue); }
.today-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--hue); }
.today-text { flex: 1; }
.today-text strong { display: block; line-height: 1.35; }
.today-text small { color: var(--muted); font-size: .88rem; }
.today-check {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--line);
  color: transparent;
  font-weight: 800; font-size: .8rem;
}
.today-item.is-read .today-check { background: var(--hue); border-color: var(--hue); color: #fff; }
.today-stats { display: flex; flex-direction: column; justify-content: center; gap: .75rem; }
.stat { margin: 0; padding: 1.1rem 1.25rem; border-radius: 20px; background: var(--lapis); color: #D9DEFF; font-size: .92rem; }
.stat b { display: block; font-size: 2.4rem; line-height: 1.05; font-weight: 800; color: var(--saffron); }
.stat-alt { background: var(--emerald); color: #E3F7EC; }
.stat-alt b { color: #fff; }

/* ---------- Tiles ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.grid li[hidden] { display: none; }
.tile {
  width: 100%; height: 100%;
  text-align: left;
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .2s, border-color .2s;
}
.tile:hover { transform: translateY(-4px); border-color: var(--hue); }
.tile-top {
  position: relative;
  background: var(--hue);
  color: #fff;
  padding: 1.25rem 1.25rem 1rem;
  min-height: 118px;
  display: flex; align-items: flex-end; justify-content: flex-end;
}
.tile-top::before {
  content: "";
  position: absolute; inset: 0;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath fill='%23fff' d='M20 6l4 10 10 4-10 4-4 10-4-10-10-4 10-4z'/%3E%3C/svg%3E");
}
.tile.is-read .tile-top::after {
  content: "✓ Dibaca hari ini";
  position: absolute; top: .75rem; left: .75rem;
  padding: .3rem .65rem;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #1D2547;
  font-size: .75rem; font-weight: 700;
}
.tile-arab { position: relative; font-size: 2.2rem; line-height: 1.3; margin: 0; }
.tile-body { padding: 1.1rem 1.25rem 1.3rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.tile-title { font-weight: 800; font-size: 1.15rem; line-height: 1.3; margin: 0; }
.tile-desc { color: var(--muted); font-size: .94rem; margin: 0; flex: 1; }
.tile-meta { font-size: .82rem; font-weight: 700; color: var(--hue); margin: .35rem 0 0; }
:root[data-theme="dark"] .tile-meta { filter: brightness(1.6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile-meta { filter: brightness(1.6); } }

/* ---------- Quotes ---------- */
.quotes { text-align: center; }
.quote {
  position: relative;
  margin: 2rem auto 1.5rem;
  max-width: 760px;
  min-height: 220px;
  padding: 2.5rem 2rem 2rem;
  border-radius: 28px;
  background: var(--hue);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  transition: background-color .6s;
}
.quote::before {
  content: "❝";
  position: absolute; top: -.2rem; left: 1.2rem;
  font-size: 4.5rem; line-height: 1;
  opacity: .35;
}
.quote blockquote { margin: 0; font-size: clamp(1.1rem, 2.4vw, 1.4rem); line-height: 1.55; font-weight: 500; }
.quote figcaption { margin-top: 1rem; font-weight: 700; opacity: .85; font-size: .95rem; }
.quote.swap blockquote, .quote.swap figcaption { animation: rise .5s both; }
.quote-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.quote-dots { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.quote-dots button {
  width: 10px; height: 10px; padding: 0;
  border-radius: 50%; border: 0;
  background: var(--line);
  cursor: pointer;
}
.quote-dots button[aria-current="true"] { background: var(--ink); width: 26px; border-radius: 5px; }

.footer { text-align: center; color: var(--muted); font-size: .9rem; padding: 2rem 1.5rem 3rem; border-top: 1px solid var(--line); }
.footer p { max-width: 62ch; margin: 0 auto; }

/* ---------- Reader dialog ---------- */
.reader {
  width: min(840px, 100vw);
  max-width: 100vw;
  height: min(92vh, 100%);
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--bg);
  color: var(--ink);
  flex-direction: column;
}
.reader[open] { display: flex; animation: sheet .45s cubic-bezier(.2,.8,.2,1); }
.reader::backdrop { background: rgba(10,14,40,.6); backdrop-filter: blur(4px); }
@keyframes sheet { from { transform: translateY(60px); opacity: 0; } }
@media (min-width: 880px) {
  .reader { margin: auto; border-radius: 28px; height: 88vh; }
}
.reader-head {
  position: relative;
  background: var(--hue);
  color: #fff;
  padding: 1.25rem 1.5rem 1.25rem;
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
}
.reader-arab { font-size: 1.8rem; line-height: 1.3; margin: 0; text-align: left; }
.reader-head h2 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.reader-src { margin: .2rem 0 0; opacity: .85; font-size: .9rem; }
.head-actions { display: flex; gap: .5rem; }
.head-btn { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); color: #fff; font-size: 1rem; }
.reader-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  padding: .8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.btn-play { background: var(--hue); color: #fff; padding: .75rem 1.1rem; font-size: .95rem; }
.qari, .toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 500; }
.qari select {
  font: inherit; color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .5rem .6rem;
  max-width: 200px;
}
.qari[hidden] { display: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--hue); }
.size { display: flex; gap: .4rem; margin-left: auto; }
.tajwid-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .9rem;
  padding: .5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}
.tajwid-legend[hidden] { display: none; }
.tajwid-legend-label {
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .8;
}
.tj-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-weight: 600;
  font-size: .8rem;
}
.tj-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.tj-tag.tj-mad { color: var(--tj-mad); }
.tj-tag.tj-mad .tj-dot { background: var(--tj-mad); }
.tj-tag.tj-ghunnah { color: var(--tj-ghunnah); }
.tj-tag.tj-ghunnah .tj-dot { background: var(--tj-ghunnah); }
.tj-tag.tj-ikhfa { color: var(--tj-ikhfa); }
.tj-tag.tj-ikhfa .tj-dot { background: var(--tj-ikhfa); }
.tj-tag.tj-idgham { color: var(--tj-idgham); }
.tj-tag.tj-idgham .tj-dot { background: var(--tj-idgham); }
.tj-tag.tj-qalqalah { color: var(--tj-qalqalah); }
.tj-tag.tj-qalqalah .tj-dot { background: var(--tj-qalqalah); }

/* Tajwid text marks inside Arabic verses */
.tj-mad { color: var(--tj-mad); font-weight: 700; }
.tj-ghunnah { color: var(--tj-ghunnah); font-weight: 700; }
.tj-ikhfa { color: var(--tj-ikhfa); font-weight: 700; }
.tj-idgham { color: var(--tj-idgham); font-weight: 700; }
.tj-qalqalah { color: var(--tj-qalqalah); font-weight: 700; }

.hide-tajwid .tj-mad,
.hide-tajwid .tj-ghunnah,
.hide-tajwid .tj-ikhfa,
.hide-tajwid .tj-idgham,
.hide-tajwid .tj-qalqalah {
  color: inherit !important;
  font-weight: inherit !important;
}

.reader-body { overflow-y: auto; padding: 1.25rem 1.5rem 3rem; flex: 1; overscroll-behavior: contain; }

.fadhilah {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--hue);
  border-radius: 14px;
  padding: .9rem 1.1rem;
  margin-bottom: 1.25rem;
}
.fadhilah summary { font-weight: 700; cursor: pointer; }
.fadhilah p { margin: .6rem 0 0; color: var(--muted); font-size: .95rem; }
.basmalah { text-align: center; font-size: calc(var(--arab-size) * 1.05); margin: .5rem 0 1rem; color: var(--hue); }
:root[data-theme="dark"] .basmalah { filter: brightness(1.6); }

.ayat { list-style: none; margin: 0; padding: 0; }
.ayah {
  border-bottom: 1px solid var(--line);
  padding: 1.25rem .75rem;
  border-radius: 16px;
  transition: background-color .3s;
}
.ayah.playing { background: color-mix(in srgb, var(--hue) 14%, transparent); }
.ayah-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.ayah-no {
  display: grid; place-items: center;
  min-width: 36px; height: 36px; padding: 0 .4rem;
  border-radius: 12px;
  background: var(--hue); color: #fff;
  font-weight: 800; font-size: .85rem;
}
.ayah-label { font-size: .82rem; color: var(--muted); flex: 1; }
.ayah-play { width: 38px; height: 38px; font-size: .85rem; }
.ayah.playing .ayah-play { background: var(--hue); color: #fff; border-color: var(--hue); }
.ayah-arab { font-size: var(--arab-size); line-height: 2.1; margin: 0 0 .6rem; text-align: right; }
.ayah-latin { font-style: italic; color: var(--hue); margin: 0 0 .35rem; font-size: .98rem; }
:root[data-theme="dark"] .ayah-latin { filter: brightness(1.7); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ayah-latin, :root:not([data-theme="light"]) .basmalah { filter: brightness(1.7); } }
.ayah-arti { margin: 0; color: var(--muted); font-size: .98rem; max-width: 70ch; }
.hide-latin .ayah-latin, .hide-arti .ayah-arti { display: none; }
.counter {
  margin-top: 1rem;
  max-width: 360px;
  padding: .9rem;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.counter-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.count-step {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%;
  border: 2px solid var(--hue);
  background: transparent;
  color: var(--ink);
  font: 700 1.8rem/1 var(--sans);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform .08s;
}
.count-step.plus { width: 72px; height: 72px; background: var(--hue); color: #fff; font-size: 2.2rem; }
.count-step:active { transform: scale(.92); }
.count-value { margin: 0; text-align: center; font-variant-numeric: tabular-nums; }
.count-value b { display: block; font-size: 2.4rem; line-height: 1; font-weight: 800; }
.count-value span { font-size: .9rem; color: var(--muted); }
.count-bar { height: 6px; margin: .8rem 0 .4rem; border-radius: 3px; background: var(--line); overflow: hidden; }
.count-bar span { display: block; height: 100%; width: 0; background: var(--hue); transition: width .2s; }
.count-reset {
  display: block; margin: 0 auto;
  font: 500 .85rem/1 var(--sans); color: var(--muted);
  background: none; border: 0; padding: .5rem; cursor: pointer;
}
.counter.done { border-color: var(--hue); }
.counter.done .count-value span::after { content: " · selesai"; font-weight: 700; }
.mark-read {
  display: flex; justify-content: center;
  width: 100%; max-width: 420px;
  margin: 2rem auto 0;
  background: var(--surface); color: var(--ink);
  border-color: var(--hue);
}
.mark-read.is-read { background: var(--hue); color: #fff; }
.note { font-size: .9rem; color: var(--muted); margin: 1rem 0 0; }

.state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 1rem;
  border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--hue);
  animation: spin 0.9s linear infinite;
}

.toast {
  position: fixed; left: 50%; bottom: 1.5rem;
  transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg);
  padding: .8rem 1.2rem; border-radius: 14px;
  font-size: .92rem; max-width: calc(100vw - 2rem);
  visibility: hidden;
  transition: transform .3s, visibility .3s;
  z-index: 99999;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; padding: 4rem 1rem 3.5rem; text-align: center; }
  .hero-arab { text-align: center; }
  .hero h1, .hero-lede { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .rosette { width: 220px; order: -1; }
  .today-panel { grid-template-columns: 1fr; padding: 1.25rem; }
  .today-stats { flex-direction: row; }
  .stat { flex: 1; }
  .section { padding: 3rem 1rem; }
  .reader-head, .reader-bar { padding-left: 1rem; padding-right: 1rem; }
  .tajwid-legend { padding: .4rem 1rem; gap: .35rem .65rem; font-size: .76rem; }
  .reader-body { padding: 1rem 1rem 3rem; }
  .ayah { padding: 1.1rem .4rem; }
  .size { margin-left: 0; }
  .quote { padding: 2.5rem 1.25rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rosette use[href="#petal"] { transform: rotate(calc(var(--i) * 45deg)); }
  html { scroll-behavior: auto; }
}
