@font-face {
  font-family: "El Messiri";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/ElMessiri-Variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}

@font-face {
  font-family: "Aref Ruqaa";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Aref-Ruqaa-Regular.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}

@font-face {
  font-family: "Aref Ruqaa";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Aref-Ruqaa-Bold.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}

:root {
  --bg: #0f1720;
  --bg-soft: #17222e;
  --bg-soft-2: #1e2b38;
  --accent: #2fbf8f;
  --accent-strong: #45e0ac;
  --accent-soft: #1d3b32;
  --text: #eef3f7;
  --text-dim: #8ea0b0;
  --danger: #e0605a;
  --danger-soft: #3a2222;
  --radius-lg: 26px;
  --radius-md: 18px;
  --hold-duration: 650ms;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f6f8;
    --bg-soft: #ffffff;
    --bg-soft-2: #eef2f5;
    --accent: #1f9d78;
    --accent-strong: #17825f;
    --accent-soft: #dcf1e8;
    --text: #16212b;
    --text-dim: #62727e;
    --danger: #c94a44;
    --danger-soft: #fbe7e6;
  }
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: "El Messiri", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: pan-y;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.app {
  width: 100%;
  max-width: 440px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Header */

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app__logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
}

.app__header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.icon-btn {
  background: var(--bg-soft);
  border: none;
  color: var(--text-dim);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.9) rotate(20deg);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dhikr card */

.dhikr {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 16px 6px;
  max-height: 24vh;
  max-height: 24dvh;
}

.dhikr__arrow {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 4px 12px;
  line-height: 1;
  flex-shrink: 0;
}

.dhikr__arrow:active {
  color: var(--accent);
}

.dhikr__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  min-width: 0;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  max-height: calc(24vh - 32px);
  max-height: calc(24dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  transition: background 0.15s ease;
}

.dhikr__text:active {
  background: var(--bg-soft-2);
}

.dhikr__label {
  font-family: "Aref Ruqaa", "Amiri", "Traditional Arabic", serif;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.4;
  direction: rtl;
  transition: opacity 0.15s ease;
}

.dhikr__label--long {
  font-size: 1.15rem;
  line-height: 1.6;
}

.dhikr__sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: opacity 0.15s ease;
}

/* Counter */

.counter {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.ring-wrap {
  position: relative;
  width: clamp(190px, 42dvh, 250px);
  height: clamp(190px, 42dvh, 250px);
}

.ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.ring__track {
  fill: none;
  stroke: var(--bg-soft-2);
  stroke-width: 10;
}

.ring__progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 678.6;
  stroke-dashoffset: 678.6;
  transition: stroke-dashoffset 0.25s ease, stroke 0.25s ease;
}

.ring__progress.complete {
  stroke: var(--accent-strong);
  filter: drop-shadow(0 0 6px rgba(69, 224, 172, 0.65));
}

.counter__display {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: none;
  background: var(--bg-soft);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition: transform 0.1s ease, background 0.25s ease, box-shadow 0.25s ease;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.counter__display:active {
  transform: scale(0.96);
}

.counter__display.pulse {
  animation: pulse 0.35s ease;
}

.counter__display.complete {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 0 0 4px var(--accent-soft);
}

@keyframes pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

#count {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 4.2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.counter__target {
  color: var(--text-dim);
  font-size: 1rem;
  margin-top: 6px;
}

/* Beads / rounds */

.beads {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 260px;
}

.beads__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.beads__more {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}

.beads__empty {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Actions */

.counter__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.secondary-btn {
  background: var(--bg-soft);
  border: none;
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
}

.secondary-btn:active {
  background: var(--bg-soft-2);
}

.hold-btn {
  position: relative;
  overflow: hidden;
  background: var(--bg-soft);
  border: none;
  color: var(--text-dim);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.hold-btn__fill {
  position: absolute;
  inset: 0;
  background: var(--danger-soft);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 0;
}

.hold-btn__fill.filling {
  transition: transform var(--hold-duration) linear;
  transform: scaleX(1);
}

.hold-btn__label {
  position: relative;
  z-index: 1;
}

.hold-btn.danger .hold-btn__label {
  color: var(--danger);
}

/* Overlay + bottom sheet */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 440px;
  background: var(--bg-soft);
  border-radius: 24px 24px 0 0;
  padding: 10px 24px max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet.open {
  transform: translateY(0);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-soft-2);
  margin: 6px auto 0;
}

.sheet h2 {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.sheet__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.98rem;
}

.sheet__section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-top: 4px;
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  background: var(--bg-soft-2);
  border-radius: 999px;
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch__track::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.switch input:checked + .switch__track {
  background: var(--accent);
}

.switch input:checked + .switch__track::before {
  transform: translateX(18px);
}

.target-select {
  display: flex;
  gap: 8px;
}

.target-chip {
  flex: 1;
  background: var(--bg-soft-2);
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 10px 0;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
}

.target-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.stats {
  display: flex;
  gap: 12px;
}

.stats__item {
  flex: 1;
  background: var(--bg-soft-2);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stats__item strong {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

.stats__item span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.danger-btn {
  background: none;
  border: none;
  color: var(--danger);
  padding: 10px 0 4px;
  font-size: 0.92rem;
  cursor: pointer;
}

.dhikr-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
}

.dhikr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-soft-2);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  color: var(--text);
}

.dhikr-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dhikr-item.active .dhikr-item__ar {
  color: var(--accent-strong);
}

.dhikr-item__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dhikr-item__ar {
  font-family: "Aref Ruqaa", "Amiri", "Traditional Arabic", serif;
  font-size: 1.3rem;
  font-weight: 700;
  direction: rtl;
  color: var(--text);
  display: block;
}

.dhikr-item__ar--long {
  font-size: 0.95rem;
  line-height: 1.6;
}

.dhikr-item__en {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.dhikr-item__check {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
  visibility: hidden;
}

.dhikr-item.active .dhikr-item__check {
  visibility: visible;
}
