@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("fonts/IBMPlexSansArabic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Uthmanic Hafs";
  src: url("fonts/UthmanicHafs.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("fonts/IBMPlexSansArabic-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("fonts/IBMPlexSansArabic-Bold.woff2") format("woff2");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #18312a;
  --muted: #6f7d77;
  --paper: #f7f4ed;
  --card: #fffefa;
  --green: #173f35;
  --green-2: #2d6a57;
  --mint: #e4efe9;
  --gold: #b58a43;
  --line: #e4e0d7;
  --shadow: 0 14px 36px rgba(37, 55, 48, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% -10%, rgba(181, 138, 67, .12), transparent 35%),
    linear-gradient(180deg, #f8f6f0 0%, #f4f1ea 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "SF Arabic", "Geeza Pro", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { cursor: pointer; }

#app { min-height: 100vh; padding-bottom: 98px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  background: rgba(248, 246, 240, .88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(228, 224, 215, .7);
}

.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 13px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 7vw, 38px); letter-spacing: -.6px; }
h2 { font-size: 25px; }
h3 { font-size: 19px; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--card);
  font-size: 22px;
}

.page-shell { width: min(720px, 100%); margin: 0 auto; padding: 20px 16px 30px; }

.date-row { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin: 2px 4px 18px; }
.date-row h2 { margin: 0; font-size: 20px; }
.date-row p { margin: 0; color: var(--muted); font-size: 13px; }

.progress-card {
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 22px;
  background: var(--green);
  color: white;
  box-shadow: var(--shadow);
}
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.progress-head strong { font-size: 18px; }
.progress-head span { color: #cfe2d8; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.16); }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: #e6c985; transition: width .35s ease; }

.section-card {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 8px 28px rgba(37, 55, 48, .045);
  overflow: hidden;
}

.section-title { display: flex; align-items: center; gap: 11px; padding: 18px 18px 10px; }
.section-title .symbol { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--mint); color: var(--green); font-size: 17px; }
.section-title h3 { margin: 0; }

.task-row {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.task-row.informational { grid-template-columns: 1fr; padding-right: 22px; }
.task-row.completed .task-copy { color: #8c9691; text-decoration: line-through; text-decoration-thickness: 1px; }
.task-row label { cursor: pointer; }
.check {
  appearance: none;
  width: 25px;
  height: 25px;
  margin: 1px 0 0;
  border: 2px solid #9baa9f;
  border-radius: 8px;
  background: white;
  display: grid;
  place-content: center;
}
.check::after { content: "✓"; color: white; font-size: 17px; transform: scale(0); transition: transform .12s ease; }
.check:checked { border-color: var(--green-2); background: var(--green-2); }
.check:checked::after { transform: scale(1); }
.task-label { display: block; margin-bottom: 4px; color: var(--green-2); font-weight: 800; font-size: 14px; }
.task-copy { line-height: 1.75; font-size: 16px; }
.task-note { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.hint { padding: 14px 18px 18px; border-top: 1px solid var(--line); color: var(--muted); line-height: 1.7; font-size: 13px; }

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  grid-template-columns: repeat(var(--nav-count, 4), 1fr);
  width: min(520px, calc(100% - 24px));
  margin: auto;
  padding: 7px;
  border: 1px solid rgba(228, 224, 215, .9);
  border-radius: 22px;
  background: rgba(255, 254, 250, .94);
  box-shadow: 0 16px 42px rgba(24, 49, 42, .16);
  backdrop-filter: blur(18px);
}
.nav-item { border: 0; border-radius: 16px; background: transparent; color: var(--muted); padding: 7px 3px; font-size: 12px; font-weight: 700; }
.nav-item span { display: block; margin-bottom: 1px; font-size: 20px; }
.nav-item.active { background: var(--mint); color: var(--green); }
.nav-item[hidden] { display: none; }

.task-reader {
  display: inline-flex;
  margin-top: 9px;
  padding: 7px 11px;
  border: 1px solid #cddbd4;
  border-radius: 10px;
  background: var(--mint);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.reader-loading { padding: 90px 20px; text-align: center; color: var(--muted); }
.reader-head { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.reader-head p { margin-bottom: 3px; color: var(--gold); font-size: 13px; font-weight: 700; }
.reader-head h2 { margin-bottom: 0; }
.reader-page-actions { display: flex; gap: 6px; }
.compact { min-height: 36px; padding: 6px 10px; border-radius: 10px; font-size: 12px; }
.compact:disabled { opacity: .45; cursor: default; }
.mushaf-card { margin-bottom: 14px; }
.mushaf-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--green-2); font: inherit; font-size: 12px; font-weight: 800; }
.mushaf-page {
  min-height: 445px;
  padding: 25px 21px;
  border: 1px solid #cdbf9f;
  border-radius: 8px;
  background: #fffdf5;
  color: #17201b;
  font-family: "Uthmanic Hafs", "Traditional Arabic", serif;
  font-size: clamp(23px, 6vw, 31px);
  line-height: 2.12;
  text-align: justify;
  box-shadow: inset 0 0 0 4px #f2ead8;
}
.surah-heading { margin: 3px 0 12px; padding: 1px 12px; border: 1px solid #bca671; border-radius: 999px; background: #faf1db; color: #6f5423; text-align: center; font-family: "IBM Plex Sans Arabic", sans-serif; font-size: 15px; font-weight: 700; }
.reader-ayah { display: inline; }
.reader-word { border-radius: 4px; transition: color .18s ease, background .18s ease; }
.reader-word.concealed { color: transparent; background: #e5dfd2; text-shadow: none; user-select: none; }
.reader-word.revealed { background: #f8eccb; }
.reader-word.heard { background: #dbeee5; color: #173f35; }
.reader-word.missed { background: #f5d8d0; color: #8e3d31; text-decoration: underline; text-decoration-style: wavy; }
.ayah-number { color: #8a6a2d; white-space: nowrap; }
.reader-controls, .rating-card { margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.reader-button-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.microphone-button { margin-top: 10px; }
.experimental { display: inline-block; margin-right: 5px; padding: 2px 6px; border-radius: 99px; background: rgba(255,255,255,.14); font-size: 10px; }
.speech-status { margin: 9px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.speech-status.error { color: #9c3d2f; }
.rating-card h3 { margin-bottom: 10px; }
.rating-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.rating-grid button { min-height: 42px; padding: 5px 3px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); font: inherit; font-size: 12px; }
.rating-grid button.selected { border-color: var(--green); background: var(--green); color: white; }
.weak-row, .mistake-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.weak-row:first-of-type, .mistake-row:first-of-type { border-top: 0; }
.weak-row strong, .mistake-row strong { display: block; font-size: 14px; line-height: 1.6; }
.weak-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.compact-empty { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.similar-card { padding: 18px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.similar-card h3 { margin-bottom: 10px; color: var(--green-2); }
.similar-verse { margin-bottom: 9px; font-family: "Uthmanic Hafs", "Traditional Arabic", serif; font-size: clamp(23px, 6vw, 30px); line-height: 2; }
.similar-verse mark { padding: 0 3px; border-radius: 5px; background: #f0d793; color: #423317; }

.settings-card {
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
}
.settings-card label, .sheet label { display: block; margin: 16px 0; font-weight: 800; }
input[type="number"], input[type="text"], input[type="password"] { width: 100%; margin-top: 7px; padding: 12px 14px; border: 1px solid #cfcac0; border-radius: 13px; background: white; color: var(--ink); direction: rtl; }
small, .muted { display: block; color: var(--muted); line-height: 1.6; font-weight: 400; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.settings-summary { padding: 10px 13px; border-radius: 12px; background: var(--mint); color: var(--green); font-weight: 700; }
.days-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 20px; }
.day-chip { position: relative; margin: 0 !important; }
.day-chip input { position: absolute; opacity: 0; pointer-events: none; }
.day-chip span { display: grid; min-height: 42px; place-items: center; padding: 7px 5px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--muted); font-size: 13px; }
.day-chip input:checked + span { border-color: var(--green-2); background: var(--mint); color: var(--green); }
.toggle-line { display: flex !important; align-items: center; gap: 10px; }
.toggle-line input { width: 22px; height: 22px; accent-color: var(--green-2); }
.spaced-button { margin-top: 10px; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.primary, .secondary, .danger { min-height: 46px; border-radius: 14px; padding: 10px 14px; font-weight: 800; }
.primary { border: 0; background: var(--green); color: white; }
.secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
.danger { border: 1px solid #e2c7c1; background: #fff5f2; color: #9c3d2f; }
.wide { width: 100%; }

dialog { border: 0; }
dialog::backdrop { background: rgba(17, 37, 31, .48); backdrop-filter: blur(3px); }
.sheet {
  width: min(560px, calc(100% - 24px));
  max-height: 88vh;
  margin: auto;
  padding: 24px;
  border-radius: 25px;
  background: var(--paper);
  color: var(--ink);
}
.confirm-dialog { width: min(420px, calc(100% - 32px)); padding: 22px; border-radius: 22px; background: var(--card); color: var(--ink); }
.confirm-dialog p { color: var(--muted); line-height: 1.7; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.login-sheet { width: min(430px, calc(100% - 24px)); text-align: right; }
.login-mark { display: grid; width: 58px; height: 58px; margin-bottom: 18px; place-items: center; border-radius: 19px; background: var(--green); color: white; font-size: 31px; font-weight: 800; }
.form-error { min-height: 25px; margin: 4px 0 10px; color: #9c3d2f; font-size: 14px; font-weight: 700; }
.forgot-password { display: block; margin: -3px 0 14px; padding: 0; border: 0; background: transparent; color: var(--green-2); font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }
.forgot-password[hidden] { display: none; }
.local-note { margin-top: 13px; text-align: center; }
.locked #app { visibility: hidden; }

.empty { padding: 38px 20px; text-align: center; color: var(--muted); }
.toast { position: fixed; z-index: 30; right: 20px; bottom: 102px; left: 20px; width: fit-content; max-width: calc(100% - 40px); margin: auto; padding: 12px 16px; border-radius: 13px; background: var(--ink); color: white; box-shadow: var(--shadow); animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 700px) {
  .topbar { padding-right: max(28px, calc((100vw - 720px) / 2)); padding-left: max(28px, calc((100vw - 720px) / 2)); }
  .page-shell { padding-top: 28px; }
}

@media (max-width: 430px) {
  .days-grid { grid-template-columns: repeat(3, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .reader-head { align-items: start; }
  .reader-page-actions { flex-direction: column; }
  .mushaf-page { min-height: 400px; padding: 20px 16px; }
  .reader-button-grid { grid-template-columns: 1fr; }
  .rating-grid { grid-template-columns: 1fr 1fr; }
  .weak-row, .mistake-row { align-items: start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
