/* Layout: one centered column — setup strip, the player card (the star), then the step ladder. */
:root {
  --bg: #eef5f1;
  --surface: #ffffff;
  --ink: #15332d;
  --muted: #5b7670;
  --line: #d3e3dc;
  --teal: #1f6f62;
  --teal-soft: #dcefe8;
  --sun: #f0a531;
  --sun-soft: #fff1d6;
  --font-ui: "Baloo Bhaijaan 2", "Segoe UI", system-ui, sans-serif;
  --font-quran: "Amiri Quran", "Amiri", "Traditional Arabic", "Scheherazade New", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1a17;
    --surface: #142521;
    --ink: #e4efea;
    --muted: #93ada6;
    --line: #26403a;
    --teal: #5cc3ae;
    --teal-soft: #1b3a33;
    --sun: #f4b551;
    --sun-soft: #3a2e17;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }

.top, .wrap {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top { padding-block: 20px 8px; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--teal); color: var(--surface); }
.logo svg { width: 30px; height: 30px; }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.15; font-weight: 800; text-wrap: balance; }
h1 .ar { font-weight: 600; color: var(--teal); margin-inline-start: 6px; }
.tag { margin: 0; color: var(--muted); font-size: 0.95rem; }

.wrap { display: flex; flex-direction: column; gap: 16px; padding-block: 8px 32px; }

/* setup */
.setup { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.9rem; font-weight: 700; color: var(--muted); }
select {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
}
.counts { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); }
.count-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.count-row label { font-weight: 700; min-width: 0; }
.reciter-field { grid-column: 1 / -1; }
.more { grid-column: 1 / -1; }
.more summary { cursor: pointer; font-weight: 700; color: var(--teal); padding: 4px 0; width: fit-content; }
.more .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 10px; }
.more .wide { grid-column: 1 / -1; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); font-size: 1.4rem; font-weight: 700; cursor: pointer;
}
.stepper .count {
  width: 3.2ch; min-height: 46px; padding: 0; text-align: center; font-size: 1.4rem; font-weight: 800;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
}

/* player */
.player {
  background: var(--surface);
  border-radius: 24px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 1px 0 var(--line), 0 12px 30px -18px rgba(21, 51, 45, 0.35);
}
.now { display: flex; flex-direction: column; gap: 0; }
.step-label { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.step-title { margin: 0; font-size: 1.35rem; font-weight: 800; }
.step-title .kind { display: inline-block; margin-inline-start: 8px; padding: 0 10px; border-radius: 99px; font-size: 0.85rem; vertical-align: middle; }
.kind.new { background: var(--teal-soft); color: var(--teal); }
.kind.link { background: var(--sun-soft); color: var(--ink); }
.kind.review { background: var(--teal); color: var(--surface); }

.mushaf {
  font-family: var(--font-quran);
  font-size: clamp(1.6rem, 6vw, 2.3rem);
  line-height: 2.25;
  text-align: center;
  max-height: 46vh;
  overflow-y: auto;
  padding: 6px 4px;
  border-radius: 16px;
}
.mushaf .ay { border-radius: 10px; padding: 0 4px; transition: background-color .25s, color .25s, filter .25s; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.mushaf .ay.playing { background: var(--sun-soft); color: var(--ink); }
.mushaf .ay.dim { color: var(--muted); opacity: 0.55; }
.mushaf .num {
  display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em;
  margin: 0 4px; border-radius: 50%; border: 1.5px solid var(--teal);
  color: var(--teal); font-family: var(--font-ui); font-size: 0.5em; font-weight: 700; line-height: 1;
  vertical-align: middle;
}
.mushaf.hidden .ay .w { filter: blur(9px); }
.mushaf.hidden .ay:active .w { filter: none; }

.reps { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); transition: background-color .2s, border-color .2s, transform .2s; }
.dot.done { background: var(--sun); border-color: var(--sun); }
.dot.cur { border-color: var(--sun); transform: scale(1.15); }
.rep-text { margin: 0; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; justify-content: center; align-items: center; gap: 22px; }
.ctl {
  width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--surface); color: var(--teal); display: grid; place-items: center; cursor: pointer;
}
.ctl svg { width: 22px; height: 22px; }
[dir="rtl"] .ctl:not(.play) svg { transform: scaleX(-1); }
.ctl.play { width: 78px; height: 78px; border: 0; background: var(--teal); color: var(--surface); }
.ctl.play svg { width: 34px; height: 34px; }
.ctl.play .i-pause, .playing-now .ctl.play .i-play { display: none; }
.playing-now .ctl.play .i-pause { display: block; }
.ctl:active { transform: scale(0.95); }

.toggles { display: flex; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 99px; background: var(--bg); font-weight: 600; cursor: pointer; }
.chip input { width: 18px; height: 18px; accent-color: var(--teal); }
.status { margin: 0; min-height: 1.5em; text-align: center; color: var(--muted); font-size: 0.95rem; }
.status.err { color: #c2412d; }

/* ladder */
.ladder-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ladder h2 { margin: 0; font-size: 1.15rem; }
.ladder-head p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.ladder ol { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ladder li button {
  width: 100%; display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: 10px;
  padding: 8px 12px; border: 2px solid transparent; border-radius: 14px; background: var(--surface);
  text-align: start; cursor: pointer;
}
.ladder .n { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ladder .what { font-weight: 700; min-width: 0; }
.ladder .x { font-weight: 800; font-variant-numeric: tabular-nums; padding: 0 10px; border-radius: 99px; }
.ladder li.new .x { background: var(--teal-soft); color: var(--teal); }
.ladder li.link .x { background: var(--sun-soft); color: var(--ink); }
.ladder li.review .x { background: var(--teal); color: var(--surface); }
.ladder li.link button { margin-inline-start: 18px; width: calc(100% - 18px); }
.ladder li.done button { opacity: 0.55; }
.ladder li.done .n::after { content: " ✓"; color: var(--teal); }
.ladder li.cur button { border-color: var(--teal); }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; }

/* celebration */
.celebrate { position: fixed; inset: 0; background: rgba(13, 26, 23, 0.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.celebrate .card { background: var(--surface); border-radius: 24px; padding: 28px 24px; max-width: 360px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.celebrate .stars { color: var(--sun); font-size: 2.4rem; animation: pop .6s ease-out both; }
.celebrate h2 { margin: 0; font-family: var(--font-quran); font-size: 2rem; color: var(--teal); }
.celebrate p { margin: 0 0 6px; }
.primary, .ghost { min-height: 48px; border-radius: 14px; font-weight: 800; cursor: pointer; }
.primary { background: var(--teal); color: var(--surface); border: 0; }
.ghost { background: transparent; border: 2px solid var(--line); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 520px) {
  .setup { grid-template-columns: 1fr 1fr; }
  .setup > .wide { grid-column: 1 / -1; }
  .player { padding: 16px; border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
