@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0D1826;
  --surface: #16233A;
  --surface-2: #1E2E48;
  --gold: #C9A227;
  --gold-soft: #E4C766;
  --teal: #4F9C82;
  --text: #F3EFE3;
  --text-muted: #8FA0B8;
  --divider: rgba(243, 239, 227, 0.09);
  --danger: #C9654A;
  --radius: 18px;
  --radius-sm: 12px;
  --scale: 1; /* display size setting: 0.9 / 1 / 1.1 */
}

* { box-sizing: border-box; }

html { font-size: calc(16px * var(--scale)); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 800px 400px at 50% -10%, rgba(201,162,39,0.08), transparent),
    var(--bg);
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 8px;
}

@media (max-width: 360px) {
  .container { padding-left: 10px; padding-right: 10px; }
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.app-header .brand { display: flex; align-items: center; gap: 10px; }

.crescent-mark { width: 2.1rem; height: 2.1rem; flex-shrink: 0; }

.brand-text .masjid {
  font-family: 'Amiri', serif;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.brand-text .date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}
.brand-text .date .hijri { color: var(--gold-soft); }
@media (max-width: 400px) {
  .brand-text .date .hijri { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--surface) 0%, #101d30 100%);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem 1.35rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.hero::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,39,0.16), transparent 70%);
}

.hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-soft);
  font-weight: 600;
}

.hero-name {
  font-family: 'Amiri', serif;
  font-size: clamp(2rem, 9vw, 2.9rem);
  font-weight: 700;
  margin: 4px 0 2px;
}

.hero-time {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.hero-countdown {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.7rem, 8vw, 2.15rem);
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 0.02em;
}

.hero-countdown-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

/* ---------- Misbaha bead tracker ---------- */
.misbaha-section {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.misbaha-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.misbaha-title .count {
  color: var(--gold-soft);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.misbaha-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  padding: 0 2px;
}
.misbaha-row::before {
  content: "";
  position: absolute;
  left: 20px; right: 20px; top: 1.15rem;
  height: 1px;
  background: var(--divider);
  z-index: 0;
}

.bead {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; padding: 0; flex: 1;
}
.bead-circle {
  width: 2.35rem; height: 2.35rem;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--divider);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
.bead.done .bead-circle {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(201,162,39,0.45);
}
.bead-circle svg { width: 1rem; height: 1rem; opacity: 0; transition: opacity 0.15s ease; }
.bead.done .bead-circle svg { opacity: 1; }
.bead-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; }
.bead.done .bead-label { color: var(--gold-soft); }

/* ---------- Week history strip ---------- */
.history-strip {
  display: flex;
  gap: 6px;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--divider);
}
.history-day { flex: 1; text-align: center; }
.history-day .dot-col {
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  margin-bottom: 4px;
}
.history-day .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--surface-2);
}
.history-day .dot.on { background: var(--gold); }
.history-day .d-label { font-size: 0.6rem; color: var(--text-muted); }
.history-day.today .d-label { color: var(--gold-soft); font-weight: 600; }

/* ---------- Salaah list ---------- */
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 1.35rem 0 0.6rem 4px;
}

.salaah-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 8px;
}
.salaah-card.active-now {
  border-color: rgba(201,162,39,0.5);
  background: linear-gradient(90deg, rgba(201,162,39,0.08), var(--surface) 40%);
}

.salaah-info { min-width: 0; }
.salaah-info .name {
  font-family: 'Amiri', serif;
  font-size: 1.12rem;
  font-weight: 700;
}
.salaah-info .times {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.salaah-info .times .lbl { color: #5a6b85; }
.salaah-info .prayed-at {
  font-size: 0.72rem;
  color: var(--teal);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.check-btn {
  width: 2.15rem; height: 2.15rem;
  border-radius: 50%;
  border: 2px solid var(--divider);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.check-btn.done { background: var(--teal); border-color: var(--teal); }
.check-btn svg { width: 1rem; height: 1rem; opacity: 0; }
.check-btn.done svg { opacity: 1; }

/* ---------- Stats ---------- */
.stats-row { display: flex; gap: 8px; margin-bottom: 6px; }
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.7rem;
  text-align: center;
}
.stat-card .value {
  font-family: 'Amiri', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-soft);
}
.stat-card .label {
  font-size: 0.63rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ---------- Month table ---------- */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0.4rem 4px 0.7rem;
}
.month-nav .month-label { font-family: 'Amiri', serif; font-size: 1.12rem; font-weight: 700; }
.month-nav button {
  background: var(--surface);
  border: 1px solid var(--divider);
  color: var(--text);
  width: 2rem; height: 2rem;
  border-radius: 8px; cursor: pointer;
  font-size: 1rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

table.timetable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.timetable th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.timetable td {
  padding: 7px 10px;
  border-top: 1px solid var(--divider);
}
table.timetable tr.today td {
  background: rgba(201,162,39,0.1);
  color: var(--gold-soft);
  font-weight: 600;
}

/* ---------- Learn tab ---------- */
.learn-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.learn-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.learn-card > summary::-webkit-details-marker { display: none; }
.learn-card > summary .l-icon {
  width: 2.2rem; height: 2.2rem;
  border-radius: 10px;
  background: rgba(201,162,39,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}
.learn-card > summary .l-title {
  font-family: 'Amiri', serif;
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}
.learn-card > summary .chev {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.learn-card[open] > summary .chev { transform: rotate(90deg); }

.learn-body {
  padding: 0 1.1rem 1.1rem;
  font-size: 0.88rem;
  line-height: 1.65;
}
.learn-body h4 {
  font-family: 'Amiri', serif;
  color: var(--gold-soft);
  font-size: 1rem;
  margin: 1rem 0 0.35rem;
}
.learn-body h4:first-child { margin-top: 0; }
.learn-body p { margin: 0 0 0.6rem; }
.learn-body ol, .learn-body ul { margin: 0 0 0.7rem; padding-left: 1.25rem; }
.learn-body li { margin-bottom: 0.35rem; }
.learn-body .ar {
  font-family: 'Amiri', serif;
  font-size: 1.15rem;
  color: var(--gold-soft);
  direction: rtl;
  display: block;
  margin: 0.25rem 0;
}
.learn-body .note {
  background: rgba(79,156,130,0.1);
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

table.rakaat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 0.4rem 0 0.7rem;
}
table.rakaat-table th, table.rakaat-table td {
  border: 1px solid var(--divider);
  padding: 6px 8px;
  text-align: center;
}
table.rakaat-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
}
table.rakaat-table td:first-child {
  font-family: 'Amiri', serif;
  font-weight: 700;
  text-align: left;
}

/* ---------- Qadha ---------- */
.qadha-summary { text-align: center; padding: 1.4rem 1rem; }
.qadha-total-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
}
.qadha-total {
  font-family: 'Amiri', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold-soft);
  line-height: 1.15;
}
.qadha-total-sub { font-size: 0.78rem; color: var(--text-muted); }

.qadha-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin-bottom: 8px;
}
.qadha-row .q-name {
  font-family: 'Amiri', serif;
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 4.2rem;
}
.qadha-row .q-count {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-soft);
  min-width: 2.6rem;
  text-align: center;
}
.qadha-row .q-count.zero { color: var(--teal); }
.qadha-row .q-actions { display: flex; gap: 6px; align-items: center; }
.q-btn {
  border: 1px solid var(--divider);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  min-width: 2rem;
  height: 2rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.q-btn.pray {
  background: rgba(79,156,130,0.2);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
  padding: 0 10px;
  font-size: 0.78rem;
}
.qadha-breakdown {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 4px 4px 0;
  line-height: 1.5;
}

.calc-field { margin-bottom: 0.8rem; }
.calc-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.calc-field input[type="date"], .calc-field select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color-scheme: dark;
}
.calc-inline { display: flex; gap: 8px; }
.calc-inline input { flex: 1; }
.btn-mini {
  background: var(--surface-2);
  color: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.calc-result {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-top: 0.4rem;
}
.calc-result .big {
  font-family: 'Amiri', serif;
  font-size: 1.35rem;
  color: var(--gold-soft);
  font-weight: 700;
}


.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(13,24,38,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}

.nav-btn {
  background: none; border: none;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.62rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  padding: 4px 2px;
  min-width: 0;
  flex: 1;
}
.nav-btn svg { width: 1.25rem; height: 1.25rem; }
.nav-btn.active { color: var(--gold-soft); }

/* ---------- Panels, cards, controls ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .panel.active { animation: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 14px;
}
.card h3 { font-family: 'Amiri', serif; margin: 0 0 4px; font-size: 1.08rem; }
.card p.desc {
  font-size: 0.79rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
  line-height: 1.5;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 0.65rem 0;
  border-top: 1px solid var(--divider);
}
.toggle-row:first-of-type { border-top: none; }
.toggle-row .label { font-size: 0.88rem; }
.toggle-row .sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.switch { position: relative; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 20px;
  transition: background 0.15s ease;
}
.switch .thumb {
  position: absolute; top: 2px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .track { background: rgba(201,162,39,0.3); border-color: var(--gold); }
.switch input:checked + .track + .thumb { transform: translateX(19px); background: var(--gold); }

.btn {
  display: block; width: 100%;
  text-align: center;
  padding: 0.8rem;
  border-radius: 12px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-primary { background: var(--gold); color: #16233A; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--divider); }

.select-row select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
}

.seg-group { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-group .seg {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
}
.seg-group .seg.on {
  background: rgba(201,162,39,0.25);
  border-color: var(--gold);
  color: var(--gold-soft);
  font-weight: 600;
}

.per-salaah-grid .toggle-row .label { font-family: 'Amiri', serif; font-size: 0.95rem; }

.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.82rem;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.install-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(90deg, rgba(201,162,39,0.15), var(--surface));
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--gold); color: #16233A;
  border: none; padding: 8px 14px;
  border-radius: 8px; font-weight: 600;
  font-size: 0.78rem; cursor: pointer;
  white-space: nowrap;
}

.install-steps { font-size: 0.84rem; line-height: 1.6; }
.install-steps ol { padding-left: 1.25rem; margin: 0.4rem 0 0.6rem; }
.install-steps li { margin-bottom: 0.4rem; }
.badge {
  display: inline-block;
  background: rgba(201,162,39,0.15);
  color: var(--gold-soft);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 600;
}

:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; border-radius: 6px; }
