@font-face {
  font-family: 'Amiri';
  src: url('fonts/amiri-arabic-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #1d2420;
  --muted: #5f6b64;
  --paper: #f6f2ea;
  --card: #fffdf8;
  --line: #e4ddcf;
  --brand: #1f4d3a;
  --brand-ink: #ffffff;
  --bad: #b3261e;
  --bad-bg: #fbe3e0;
  --warn: #8a5a00;
  --warn-bg: #fdeec4;
  --info: #1d5a8c;
  --info-bg: #ddeaf6;
  --radius: 14px;
  --ar: 'Amiri', 'Geeza Pro', 'Noto Naskh Arabic', serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none; }

.top {
  padding: calc(18px + env(safe-area-inset-top)) 20px 6px;
  max-width: 720px;
  margin: 0 auto;
}
.top__title { margin: 0; font-size: 26px; color: var(--brand); letter-spacing: -0.01em; }
.top__sub { margin: 2px 0 0; color: var(--muted); }

.main { max-width: 720px; margin: 0 auto; padding: 8px 14px 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 12px 0;
}
.card--model { border-color: var(--brand); }
.card__title { margin: 0 0 6px; font-size: 18px; }

.field { display: block; margin: 0 0 12px; }
.field__label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field__input {
  width: 100%;
  font: inherit;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Amiri', sans-serif;
  font-size: 17px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
}
.field__input:focus { outline: 3px solid rgb(31 77 58 / 25%); border-color: var(--brand); }

.range { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.range .field { margin: 0; }
.range__whole { min-height: 46px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 11px 16px;
  min-height: 46px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: default; }

progress { width: 100%; height: 10px; accent-color: var(--brand); margin: 10px 0 6px; }

.recbox { display: flex; flex-direction: column; align-items: center; margin-top: 18px; gap: 10px; }
.rec {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(31 77 58 / 25%);
  transition: transform 0.12s ease, background-color 0.2s ease;
}
.rec:active { transform: scale(0.97); }
.rec:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.rec__dot { width: 22px; height: 22px; border-radius: 50%; background: #ff5a4e; }
.rec--on { background: var(--bad); }
.rec--on .rec__dot { border-radius: 4px; background: #fff; }

.meter { display: flex; align-items: center; gap: 10px; width: min(320px, 100%); }
.meter__time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; }
.meter__track { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter__level { display: block; height: 100%; background: var(--brand); transform-origin: left; transform: scaleX(0); transition: transform 0.08s linear; }

.status { min-height: 1.5em; margin: 0; text-align: center; color: var(--muted); }

.filepick { color: var(--brand); font-size: 15px; text-decoration: underline; cursor: pointer; }
.filepick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filepick:has(input:disabled) { color: var(--muted); cursor: default; text-decoration: none; }

.progress { margin-top: 14px; }

.sum__title { margin: 0; font-weight: 700; font-size: 18px; }
.sum__chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.sum__note { margin: 4px 0; color: var(--muted); }
.sum__note--bad { color: var(--bad); font-weight: 600; }

.chip { border-radius: 999px; padding: 5px 12px; font-size: 15px; }
.chip b { font-size: 17px; }
.chip--mistakes { background: var(--bad-bg); color: var(--bad); }
.chip--check { background: var(--warn-bg); color: var(--warn); }
.chip--repeat { background: var(--info-bg); color: var(--info); }

.player { width: 100%; margin: 12px 0 4px; }
.savelink { color: var(--brand); font-size: 15px; }

.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.legend .w, .legend .x { font-family: inherit; font-size: 14px; cursor: default; }

.quran { margin: 14px 0 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.ayah {
  font-family: var(--ar);
  font-size: 27px;
  line-height: 2.25;
  text-align: right;
  margin: 0 0 6px;
  word-spacing: 2px;
}
.ayah__num { color: var(--brand); font-size: 0.85em; white-space: nowrap; }
.skipline { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0; padding: 6px; border: 1px dashed var(--line); border-radius: 8px; }

.w {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0 1px;
  border-radius: 6px;
}
button.w { cursor: pointer; }
.w--missed { color: var(--bad); background: var(--bad-bg); outline: 2px dashed var(--bad); outline-offset: -2px; text-decoration: line-through; text-decoration-thickness: 2px; }
.w--changed { color: var(--bad); text-decoration: underline wavy var(--bad); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.w--check { background: var(--warn-bg); color: var(--warn); }
.w--not-recited { color: var(--muted); opacity: 0.55; }

.x {
  font-family: var(--ar);
  font-size: 0.7em;
  border-radius: 999px;
  padding: 0 9px;
  border: 1px solid transparent;
  cursor: pointer;
  vertical-align: middle;
}
.x--extra { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); }
.x--check { color: var(--warn); background: var(--warn-bg); }
.x--repeat { color: var(--info); background: var(--info-bg); }
.x--outside { color: var(--muted); background: var(--paper); border-color: var(--line); }

.sheet { position: fixed; inset: 0; background: rgb(0 0 0 / 35%); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet__panel {
  background: var(--card);
  width: min(720px, 100%);
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet__title { margin: 0 0 10px; font-size: 17px; }
.sheet__row { display: flex; align-items: baseline; gap: 12px; margin: 6px 0; }
.sheet__key { color: var(--muted); font-size: 14px; min-width: 60px; }
.sheet__ar { font-family: var(--ar); font-size: 28px; }
.sheet__actions { display: flex; gap: 10px; margin-top: 14px; }

.foot { color: var(--muted); font-size: 12px; margin: 18px 4px; }

@media (prefers-reduced-motion: reduce) {
  .rec, .meter__level { transition: none; }
}
