/* Tilawahly — light / dark / system. Content first, UI quiet. */
:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --bg-2: #ecefe9;
  --surface: #ffffff;
  --surface-2: rgba(20, 45, 32, 0.05);
  --line: rgba(20, 45, 32, 0.09);
  --line-strong: rgba(20, 45, 32, 0.18);
  --text: #14201a;
  --muted: #68786f;
  --gold: #a8741a;
  --gold-soft: rgba(200, 150, 40, 0.14);
  --green: #16976a;
  --green-deep: #0f7a54;
  --green-text: #0b7a52;
  --green-soft: rgba(22, 151, 106, 0.12);
  --on-green: #fff;
  --danger: #d64545;
  --glass: rgba(255, 255, 255, 0.72);
  --radius: 24px;
  --radius-sm: 16px;
  --shadow: 0 1px 2px rgba(20, 45, 32, 0.04), 0 10px 30px rgba(20, 45, 32, 0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --arabic: "Amiri", "Scheherazade New", serif;
  /* Fullscreen (Bot API 8.0+) drops Telegram's header and bottom bar, so content
     runs under the status bar and the floating Telegram controls. The device
     inset covers the notch; the content inset covers Telegram's own overlays.
     env() is kept as the fallback for clients that expose no --tg-* variables. */
  --safe-top: calc(
    max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px)
  );
  --safe-bottom: calc(
    max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px)
  );
}

:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #0a100e;
  --bg-2: #0f1815;
  --surface: #131c19;
  --surface-2: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9f3ee;
  --muted: #8da298;
  --gold: #e8c37a;
  --gold-soft: rgba(232, 195, 122, 0.14);
  --green: #3ddc97;
  --green-deep: #19a06c;
  --green-text: #4ae3a4;
  --green-soft: rgba(61, 220, 151, 0.13);
  --on-green: #04150f;
  --danger: #ff7b7b;
  --glass: rgba(10, 16, 14, 0.72);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: radial-gradient(900px 380px at 50% -140px, var(--green-soft), transparent 72%), var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: none;
  padding-bottom: calc(96px + var(--safe-bottom));
  transition: background-color 0.3s ease, color 0.3s ease;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s;
}
button:active {
  transform: scale(0.96);
}

.i {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[dir="rtl"] .i--dir {
  transform: scaleX(-1);
}

/* Edge blur ---------------------------------------------------------------- */
.edge {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 15;
  pointer-events: none;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.edge--top {
  top: 0;
  height: calc(var(--safe-top) + 22px);
  background: linear-gradient(to bottom, var(--bg), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.edge--bottom {
  bottom: 0;
  height: calc(104px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 30%, transparent);
  -webkit-mask-image: linear-gradient(to top, #000 45%, transparent);
  mask-image: linear-gradient(to top, #000 45%, transparent);
}

/* Layout ------------------------------------------------------------------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 6px 0 18px;
}
.topbar__title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.6px;
}

.is-deep .topbar {
  display: none;
}
#viewBack {
  display: none;
}
.is-sub #viewBack {
  display: grid;
}
.has-tg-back #viewBack {
  display: none !important;
}
.has-tg-back #readerBack,
.has-tg-back #learnBack,
.has-tg-back #hadithBack {
  display: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.icon-btn--accent {
  background: var(--green);
  border-color: transparent;
  color: var(--on-green);
}

.view {
  display: none;
}
.view.is-active {
  display: block;
  animation: rise 0.45s var(--ease) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.is-hidden {
  display: none !important;
}
.reader,
.learn-panel {
  animation: rise 0.4s var(--ease) both;
}

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.head__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.head__meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.section-title {
  margin: 28px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Buttons ------------------------------------------------------------------ */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.btn {
  flex: 1 1 auto;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.btn--primary {
  background: var(--green);
  color: var(--on-green);
}
.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.btn:disabled {
  opacity: 0.5;
}
.pill {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Compass ------------------------------------------------------------------ */
.compass-card {
  padding: 18px 16px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.compass-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compass-card__title {
  margin: 0;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compass {
  display: grid;
  place-items: center;
  padding: 22px 0 18px;
  direction: ltr;
}
.compass__dial {
  position: relative;
  width: min(74vw, 300px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--green-soft), transparent 70%), var(--surface-2);
  touch-action: none;
  transition: box-shadow 0.4s;
}
.compass__dial.is-aligned {
  box-shadow: 0 0 0 2px var(--green), 0 0 36px var(--green-soft);
}
.compass__ticks {
  position: absolute;
  inset: 8px;
}
.compass__tick {
  position: absolute;
  inset: 0;
}
.compass__tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 7px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--line-strong);
}
.compass__tick--major::before {
  height: 12px;
  background: var(--green);
}
.compass__ring {
  position: absolute;
  inset: 0;
}
.compass__dir {
  position: absolute;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.compass__dir--n {
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
}
.compass__dir--e {
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
}
.compass__dir--s {
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
}
.compass__dir--w {
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
}
.compass__needle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: start center;
  padding-top: 50px;
  transition: transform 0.4s var(--ease);
}
.compass__kaaba {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #151a18;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.compass__kaaba::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 9px;
  height: 4px;
  background: #d9b261;
}
.compass__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
  pointer-events: none;
}
.compass__deg {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
}
.compass__cap {
  font-size: 11px;
  color: var(--muted);
}
.compass-card__foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.stat {
  display: grid;
  gap: 2px;
  text-align: center;
}
.stat + .stat {
  border-inline-start: 1px solid var(--line);
}
.stat__value {
  font-size: 15px;
  font-weight: 700;
}
.stat__label {
  font-size: 11px;
  color: var(--muted);
}
.hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

/* Prayer ------------------------------------------------------------------- */
.next-banner {
  display: grid;
  gap: 2px;
  margin-bottom: 14px;
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(140deg, var(--green), var(--green-deep));
  color: var(--on-green);
}
.next-banner:empty {
  display: none;
}
.next__label {
  font-size: 13px;
  opacity: 0.8;
}
.next__name {
  font-size: 15px;
  font-weight: 600;
}
.next__time {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.next__left {
  font-size: 13px;
  opacity: 0.85;
}
.prayer-list {
  list-style: none;
  margin: 0;
  padding: 4px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.prayer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  font-size: 16px;
  font-weight: 500;
}
.prayer-row + .prayer-row {
  border-top: 1px solid var(--line);
}
.prayer-row__name {
  display: flex;
  align-items: center;
  gap: 10px;
}
.prayer-row__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
}
.prayer-row__time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.prayer-row.is-next {
  color: var(--green-text);
}
.prayer-row.is-next .prayer-row__dot {
  background: var(--green);
}
.prayer-row.is-past {
  opacity: 0.4;
}

/* Quran list --------------------------------------------------------------- */
.reader__resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(140deg, var(--green), var(--green-deep));
  color: var(--on-green);
}
.reader__resume .btn {
  flex: none;
  min-height: 42px;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.resume__label {
  font-size: 12px;
  opacity: 0.8;
}
.reader__resume .card__title {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 700;
}
.reader__resume .card__meta {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.85;
}

.tools {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
}
.field .i {
  width: 18px;
  height: 18px;
}
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}
.select {
  flex: 0 1 38%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
}

.surah-grid {
  display: grid;
}
.surah-btn {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  column-gap: 14px;
  padding: 13px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: start;
}
.surah-btn__num {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--green-text);
}
.surah-btn__name {
  font-size: 16px;
  font-weight: 600;
}
.surah-btn__sub {
  grid-column: 2;
  font-size: 12.5px;
  color: var(--muted);
}
.surah-btn__ar {
  grid-row: span 2;
  font-family: var(--arabic);
  font-size: 22px;
  color: var(--green-text);
}

/* Reader ------------------------------------------------------------------- */
.reader__bar {
  position: sticky;
  top: 0;
  z-index: 12;
  margin: 0 -16px 12px;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
}
.reader__top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reader__titles {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.reader__titles .head__title,
.reader__titles .head__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader__titles .head__title {
  font-size: 17px;
}
.reader__titles .head__meta {
  margin-top: 2px;
  font-size: 12px;
}
.reader__progress {
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.reader__progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--green);
  transition: width 0.4s var(--ease);
}

.ayahs {
  display: grid;
}
.ayah {
  padding: 22px 4px 16px;
  border-bottom: 1px solid var(--line);
  transition: background 0.3s;
}
.ayah.is-playing {
  margin: 0 -12px;
  padding-inline: 16px;
  border-radius: var(--radius-sm);
  border-bottom-color: transparent;
  background: var(--green-soft);
}
.ayah.is-read .ayah__num {
  background: var(--green);
  color: var(--on-green);
}
.ayah__arabic {
  margin: 0 0 14px;
  font-family: var(--arabic);
  font-size: 30px;
  line-height: 2.05;
  direction: rtl;
  text-align: start;
}
.ayah__translation {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}
.ayah__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.ayah__num {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.ayah__tools {
  display: flex;
  gap: 2px;
}
.mini-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}
.mini-btn .i {
  width: 19px;
  height: 19px;
}
.mini-btn.is-on,
.ayah.is-playing .mini-btn[data-tool="audio"] {
  color: var(--green-text);
}
.mini-btn.is-on .i {
  fill: currentColor;
}

.reader__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}
.reader__actions .btn--primary {
  grid-column: 1 / -1;
}

/* Learn -------------------------------------------------------------------- */
.learn-hub {
  display: grid;
  gap: 10px;
}
.hub {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 17px;
  font-weight: 600;
  text-align: start;
}
.hub span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--green-soft);
  font-family: var(--arabic);
  font-size: 30px;
  font-weight: 400;
  color: var(--green-text);
}
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 8px;
}
.letter-btn {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-family: var(--arabic);
  font-size: 30px;
}
.letter-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 24px 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.letter-card .card__title {
  margin: 0;
  font-size: 20px;
}
.letter-card .card__meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.letter-card .eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.letter-card__glyph {
  font-family: var(--arabic);
  font-size: 88px;
  line-height: 1.3;
  color: var(--green-text);
}
.letter-card .btn {
  min-width: 160px;
  flex: none;
}
.letter-forms {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 16px;
}
.letter-forms div {
  padding: 12px 4px 8px;
  border-radius: 14px;
  background: var(--surface-2);
}
.letter-forms span {
  display: block;
  font-family: var(--arabic);
  font-size: 26px;
}
.letter-forms small {
  font-size: 10.5px;
  color: var(--muted);
}
.lesson-list {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
}
.lesson-item__num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--green-text);
}
.lesson-item.is-done .lesson-item__num {
  background: var(--green);
  color: var(--on-green);
}
.lesson-item__title {
  font-size: 15px;
  font-weight: 500;
}
.lesson-detail > p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}
.lesson-detail .ayah__arabic {
  margin: 0;
  padding: 8px 0;
}
.practice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 8px 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.practice__arabic {
  min-width: 64px;
  font-family: var(--arabic);
  font-size: 26px;
  direction: rtl;
}
.practice__meta {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}
.practice__meta b {
  color: var(--text);
  font-weight: 600;
}

/* Hadith ------------------------------------------------------------------- */
.hadith-books {
  display: grid;
  gap: 10px;
}
.hadith-book {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
}
.hadith-book__main {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.hadith-book__title {
  font-size: 16px;
  font-weight: 600;
}
.hadith-book__note {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}
.hadith-book__count {
  flex: none;
  display: grid;
  justify-items: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--green-text);
}
.hadith-book__count small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.section-list {
  display: flex;
  gap: 8px;
  margin: 0 -16px 8px;
  padding: 4px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.section-list::-webkit-scrollbar {
  display: none;
}
.section-btn {
  flex: none;
  max-width: 70vw;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hadith-item {
  padding: 22px 4px 18px;
  border-bottom: 1px solid var(--line);
}
.hadith-item__num {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-text);
}
.hadith-item__arabic {
  margin: 0 0 14px;
  font-family: var(--arabic);
  font-size: 26px;
  line-height: 2;
  direction: rtl;
  text-align: start;
}
.hadith-item__text {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}
.hadith-item__meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.hadith-notice {
  margin: 4px 0 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  font-size: 13px;
  line-height: 1.5;
}

/* Progress ----------------------------------------------------------------- */
.progress-hero {
  display: grid;
  place-items: center;
  padding: 8px 0 24px;
}
.ring {
  --pct: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 176px;
  height: 176px;
}
.ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--line) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 12px), #000 calc(100% - 11px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 12px), #000 calc(100% - 11px));
}
.ring__inner {
  display: grid;
  text-align: center;
}
.ring__value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
}
.ring__label {
  font-size: 12px;
  color: var(--muted);
}
.progress-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.progress-stats div {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--muted);
}
.progress-stats div:last-child {
  grid-column: 1 / -1;
}
.progress-stats strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
}
.chip--empty {
  background: transparent;
  box-shadow: none;
  padding: 0;
  color: var(--muted);
}

/* Tabbar ------------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: min(calc(100% - 48px), 380px);
  padding: 5px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: var(--shadow);
  transition: transform 0.45s var(--ease), opacity 0.3s;
}
.is-sub .tabbar {
  transform: translate(-50%, 170%);
  opacity: 0;
  pointer-events: none;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.tab {
  position: relative;
  z-index: 1;
}
.tab.is-active {
  color: var(--green-text);
}
.tabbar__pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(6px) brightness(1.05);
  backdrop-filter: blur(6px) brightness(1.05);
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.3, 1.25, 0.4, 1), width 0.55s cubic-bezier(0.3, 1.25, 0.4, 1), scale 0.35s var(--ease);
}
.tabbar__pill.is-moving {
  scale: 1.1 1.1;
}
.tabbar__pill.no-anim {
  transition: none;
}
.tab__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast & sheet ------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  z-index: 40;
  max-width: 88vw;
  padding: 11px 18px;
  transform: translate(-50%, 12px);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.3s var(--ease);
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
}
.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade 0.25s both;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet__panel {
  position: relative;
  width: min(100%, 560px);
  padding: 10px 18px calc(22px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  animation: sheet-up 0.4s var(--ease) both;
}
@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}
.sheet__grip {
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 4px;
  background: var(--line-strong);
}
.sheet__title {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.sheet__title:first-of-type {
  margin-top: 0;
}
.opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sheet__option,
.seg__btn {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
}
.sheet__option.is-active,
.seg__btn.is-active {
  background: var(--green-soft);
  color: var(--green-text);
  font-weight: 700;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.skeleton {
  height: 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@media (max-width: 380px) {
  .app {
    padding-inline: 12px;
  }
  .reader__bar,
  .section-list {
    margin-inline: -12px;
    padding-inline: 12px;
  }
  .topbar__title {
    font-size: 26px;
  }
  .ayah__arabic {
    font-size: 27px;
  }
  .next__time {
    font-size: 38px;
  }
  .select {
    flex-basis: 34%;
  }
  .tabbar {
    width: calc(100% - 16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- v3: Today / Services / Settings, calendar, letter pager ---------------- */
[hidden] {
  display: none !important;
}
.icon-btn--flat {
  width: 40px;
  height: 40px;
  margin: 4px auto 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--green-text);
}
.loc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.loc-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loc-link .i {
  width: 16px;
  height: 16px;
}
.compass-card__head .loc-link {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}
.hijri-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -8px 0 16px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 500;
}
.hijri-line .i {
  width: 18px;
  height: 18px;
  color: var(--green);
}
.prayer-card {
  padding: 18px 18px 8px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.prayer-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.prayer-card .next-banner {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--text);
}
.prayer-card .next__label {
  color: var(--muted);
  font-weight: 600;
}
.prayer-card .next__time {
  font-size: 36px;
}
.prayer-card .prayer-list {
  padding: 0;
  background: none;
  box-shadow: none;
}
.prayer-card .prayer-row {
  min-height: 46px;
}
.event-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-top: 12px;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
}
.event-card--row {
  margin-top: 0;
}
.days {
  display: grid;
  gap: 10px;
}
.event__date {
  display: grid;
  justify-items: center;
  min-width: 52px;
}
.event__date b {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.05;
}
.event__date small {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.event__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.event__main b {
  font-size: 17px;
  font-weight: 700;
}
.event__main small {
  font-size: 13px;
  color: var(--muted);
}
.fast {
  display: grid;
  gap: 2px;
  margin-top: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.fast__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.fast b {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: 132px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
  font-size: 16px;
  font-weight: 600;
}
.tile__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green-text);
}
.tile--accent {
  background: linear-gradient(140deg, var(--green), var(--green-deep));
  color: var(--on-green);
}
.tile--accent .tile__icon {
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}
.tile--wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 0;
}

.group {
  margin-bottom: 14px;
  padding: 4px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.group--pad {
  padding: 16px 18px 18px;
}
.group__label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.srow {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: start;
  font-size: 16px;
}
.srow + .srow {
  border-top: 1px solid var(--line);
}
.srow > .i:first-child {
  color: var(--muted);
}
.srow__t {
  flex: 1;
  min-width: 0;
}
.srow__v {
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--muted);
}
.srow__c {
  width: 18px;
  height: 18px;
  color: var(--line-strong);
}

.cal {
  padding: 16px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.cal__head .icon-btn {
  box-shadow: none;
  background: var(--surface-2);
  border: 0;
}
.cal__title {
  min-width: 0;
  text-align: center;
}
.cal__title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.cal__title p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.cal__week,
.cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}
.cal__week {
  padding: 6px 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}
.cal__grid {
  gap: 4px;
}
.cal__day {
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  border-radius: 14px;
  line-height: 1.15;
}
.cal__day b {
  font-size: 16px;
  font-weight: 600;
}
.cal__day small {
  font-size: 10px;
  color: var(--muted);
}
.cal__day.has-event {
  box-shadow: inset 0 0 0 1.5px var(--green);
}
.cal__day.is-today {
  background: var(--green);
  color: var(--on-green);
}
.cal__day.is-today small {
  color: inherit;
  opacity: 0.8;
}

.pager {
  display: flex;
  gap: 12px;
  margin: 0 -16px;
  padding: 4px 7% 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.pager::-webkit-scrollbar {
  display: none;
}
.pager .letter-card {
  flex: 0 0 86%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.pager .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pager__count {
  margin: 4px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 380px) {
  .pager,
  .reader__bar {
    margin-inline: -12px;
  }
  .tile {
    min-height: 116px;
  }
}

/* ---- Tasbih: full screen ----------------------------------------------- */
.is-immersive .topbar,
.is-immersive .edge {
  display: none;
}
#view-tasbih.is-active {
  animation: none;
}
.tasbih {
  position: fixed;
  inset: 0;
  z-index: 30;
  direction: ltr;
  overflow: hidden;
  color: var(--ink);
  background: radial-gradient(520px 420px at 72% 50%, var(--glow), transparent 70%), #080706;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  outline: 0;
}
/* skins: bead colours, grain, rope, tassel, swatch */
.tasbih,
.swatch {
  --ink: #efe2c3;
  --glow: rgba(214, 150, 60, 0.2);
  --b1: #f1d089;
  --b2: #c68a3e;
  --b3: #5a3412;
  --shine: rgba(255, 244, 214, 0.35);
  --grain: repeating-linear-gradient(112deg, transparent 0 8px, rgba(95, 52, 12, 0.26) 9px 10px, transparent 11px 19px);
  --r1: #6a2a1f;
  --r2: #a8503a;
  --r3: #3e140d;
}
:is(.tasbih, .swatch)[data-skin="amber"] {
  --glow: rgba(255, 150, 40, 0.24);
  --b1: #ffd98a;
  --b2: #e8902a;
  --b3: #6a2a06;
  --shine: rgba(255, 236, 170, 0.5);
  --grain: radial-gradient(circle at 62% 72%, rgba(255, 190, 60, 0.55), transparent 52%);
}
:is(.tasbih, .swatch)[data-skin="pearl"] {
  --ink: #f4efe6;
  --glow: rgba(255, 245, 225, 0.16);
  --b1: #ffffff;
  --b2: #e2dacb;
  --b3: #7d7466;
  --shine: rgba(255, 255, 255, 0.6);
  --grain: radial-gradient(circle at 70% 75%, rgba(190, 170, 220, 0.3), transparent 50%);
  --r1: #a8832f;
  --r2: #e8cf86;
  --r3: #6e5316;
}
:is(.tasbih, .swatch)[data-skin="onyx"] {
  --glow: rgba(160, 175, 200, 0.14);
  --b1: #626872;
  --b2: #1c1e23;
  --b3: #000000;
  --shine: rgba(255, 255, 255, 0.3);
  --grain: none;
  --r1: #7b8189;
  --r2: #c9ced4;
  --r3: #4a4f56;
}
:is(.tasbih, .swatch)[data-skin="jade"] {
  --glow: rgba(60, 220, 150, 0.2);
  --b1: #a6f2cb;
  --b2: #1fa070;
  --b3: #08392a;
  --shine: rgba(230, 255, 240, 0.45);
  --grain: repeating-radial-gradient(circle at 30% 70%, transparent 0 9px, rgba(255, 255, 255, 0.1) 10px 11px);
  --r1: #a8832f;
  --r2: #e8cf86;
  --r3: #6e5316;
}
.tasbih__beads {
  position: absolute;
  inset: 0 0 0 auto;
  width: 48%;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
}
.tasbih__rope {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 7px;
  margin-left: -3.5px;
  background: repeating-linear-gradient(160deg, var(--r1) 0 3px, var(--r2) 3px 5px, var(--r3) 5px 7px);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.tasbih__strand {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
}
.bead {
  position: absolute;
  left: 50%;
  top: 0;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.9) 0 3.5%, rgba(255, 255, 255, 0) 13%),
    radial-gradient(circle at 34% 28%, var(--shine), transparent 46%),
    var(--grain),
    radial-gradient(circle at 42% 36%, var(--b1), var(--b2) 58%, var(--b3) 100%);
  box-shadow: inset -8px -10px 15px rgba(0, 0, 0, 0.5), inset 3px 3px 9px rgba(255, 245, 220, 0.2), 0 9px 16px rgba(0, 0, 0, 0.6);
  transition: transform 0.45s cubic-bezier(0.25, 0.9, 0.3, 1);
  will-change: transform;
}
.tasbih__strand.no-anim .bead {
  transition: none;
}
.bead.is-cross {
  z-index: 2;
  transition-duration: 0.5s;
  transition-timing-function: cubic-bezier(0.5, 0, 0.2, 1.1);
  animation: lift 0.5s ease;
}
@keyframes lift {
  40% {
    scale: 1.16;
    filter: brightness(1.2);
  }
}
.bead--gap {
  width: 84px;
  height: 28px;
  margin: -14px 0 0 -42px;
  background:
    radial-gradient(ellipse at 34% 28%, rgba(255, 255, 255, 0.45), transparent 32%),
    radial-gradient(ellipse at 50% 50%, var(--b2), var(--b3) 95%);
}
.bead--tassel {
  width: 40px;
  height: 130px;
  margin: -65px 0 0 -20px;
  border-radius: 40% 40% 50% 50% / 20% 20% 70% 70%;
  background: linear-gradient(90deg, var(--b3), var(--b1) 45%, var(--b2));
}
.tasbih__text {
  position: absolute;
  left: 0;
  top: 50%;
  width: 52%;
  padding: 0 14px 0 20px;
  transform: translateY(-50%);
  text-align: end;
  pointer-events: none;
}
.tasbih__ar {
  margin: 0;
  font-family: var(--arabic);
  font-size: 38px;
  line-height: 1.7;
  direction: rtl;
}
.tasbih__pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  opacity: 0.7;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: auto;
}
.tasbih__pick .i {
  width: 14px;
  height: 14px;
}
.tasbih__count {
  margin: 12px 0 0;
  font-family: var(--arabic);
  font-size: 84px;
  line-height: 1;
}
.tasbih__of {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.6;
}
.tasbih__rounds {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.tasbih__rounds i {
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  border: 1.2px solid var(--ink);
  opacity: 0.6;
  transition: background 0.3s, opacity 0.3s;
}
.tasbih__rounds i.is-on {
  background: var(--b1);
  border-color: var(--b1);
  opacity: 1;
}
.tasbih__bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 4;
  display: flex;
  gap: 8px;
  padding: calc(var(--safe-top) + 12px) 12px 0;
  pointer-events: none;
}
.tasbih__btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
.tasbih__btn--end {
  margin-inline-start: auto;
}
.has-tg-back #tasbihBack {
  visibility: hidden;
}
.tasbih__list,
.tasbih__skins {
  position: absolute;
  z-index: 5;
  background: rgba(34, 29, 24, 0.8);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  animation: fade 0.2s both;
}
.tasbih__list {
  left: 12px;
  top: calc(var(--safe-top) + 68px);
  display: grid;
  gap: 2px;
  width: min(300px, calc(100% - 24px));
  padding: 8px;
  border-radius: 22px;
}
.tasbih__list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: start;
}
.tasbih__list button:active {
  background: rgba(255, 255, 255, 0.08);
}
.tasbih__list span {
  font-family: var(--arabic);
  font-size: 22px;
  direction: rtl;
}
.tasbih__list small {
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.6;
}
.tasbih__skins {
  right: 12px;
  top: calc(var(--safe-top) + 68px);
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 999px;
}
.swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--b1), var(--b2) 60%, var(--b3));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.swatch.is-on {
  border-color: #efe2c3;
}
@media (max-width: 380px) {
  .tasbih__ar {
    font-size: 32px;
  }
  .tasbih__count {
    font-size: 68px;
  }
}
