@font-face {
  font-family: 'Digital Khatt IndoPak';
  src: url('fonts/digitalkhatt-indopak-v2.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'Amiri Quran';
  src: url('fonts/amiri-quran.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  src: url('fonts/NotoNastaliqUrdu-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  src: url('fonts/noto-naskh.ttf') format('truetype');
  font-display: swap;
}

/* Light: Munajaat's own background kept (green-tinted white + original pattern) */
:root {
  --bg: #FBFDF7;
  --card: rgb(255, 255, 255);
  --primary: #1B5E20;                /* Munajaat green brand accent */
  --gold: #B28704;
  --text: #1A1C19;
  --text-dim: #5a5c58;
  --pattern-img: url('assets/bg_pattern.png');
  --pattern-opacity: 0.35;
  --shadow: 0 2px 8px rgba(27, 94, 32, 0.08), 0 1px 3px rgba(0,0,0,0.06);
}
html[data-theme="dark"] {
  --bg: rgb(16, 22, 19);             /* identical to JustQuran dark */
  --card: rgb(43, 44, 47);
  --primary: #8ECB87;
  --gold: rgb(201, 166, 88);
  --text: rgb(240, 235, 220);        /* cream */
  --text-dim: rgba(240, 235, 220, 0.55);
  --pattern-img: url('assets/bg_pattern.png');
  --pattern-opacity: 0.12;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  transition: background-color .25s, color .25s;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--pattern-img) repeat;
  opacity: var(--pattern-opacity);
  pointer-events: none;
  z-index: 0;
}
#app { position: relative; z-index: 1; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Headers ---------- */
.home-header { padding: calc(32px + env(safe-area-inset-top, 0px)) 8px 8px; }
.home-header h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.9rem;
  color: var(--primary);
  letter-spacing: .3px;
}
.home-header .subtitle {
  color: var(--gold);
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  margin-top: 2px;
}
.divider { height: 3px; background: var(--primary); border-radius: 2px; margin: 14px 0 18px; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 0 10px;
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.topbar .title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
  color: var(--primary);
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .divider { margin: 0; position: absolute; left: 0; right: 0; bottom: 0; }
.icon-row { display: flex; gap: 4px; margin-left: auto; }

.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--primary); padding: 8px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: rgba(128,128,128,.15); }
.icon-btn svg { width: 24px; height: 24px; display: block; }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn.gold { color: var(--gold); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  transition: background-color .25s;
}

.day-card {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; text-decoration: none; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.day-card:hover { filter: brightness(.97); }
html[data-theme="dark"] .day-card:hover { filter: brightness(1.15); }
.day-card .day-title { font-family: Georgia, 'Times New Roman', serif; font-size: 1.2rem; color: var(--primary); }
.day-card .day-count { color: var(--text-dim); font-size: .9rem; }
.day-card .chevron { margin-left: auto; color: var(--gold); font-size: 1.5rem; line-height: 1; }

/* ---------- Dua cards ---------- */
.dua-card { position: relative; }
.dua-head { display: flex; align-items: flex-start; }
.num-badge {
  min-width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #FBFDF7;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .95rem; flex-shrink: 0;
}
html[data-theme="dark"] .num-badge { color: #101613; }
.dua-actions { margin-left: auto; display: flex; gap: 2px; }
.dua-actions .icon-btn { padding: 6px; }

.arabic {
  font-family: 'Digital Khatt IndoPak', 'Amiri Quran', 'Amiri', 'Noto Naskh Arabic', serif;
  direction: rtl; text-align: right;
  font-size: calc(1.9rem * var(--arabic-scale, 1)); line-height: calc(2.1 * var(--arabic-lh, 1));
  margin: 14px 0 10px;
}
.urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl; text-align: right;
  font-size: calc(1.25rem * var(--urdu-scale, 1)); line-height: 2.4;
  margin: 10px 0;
}
.english { text-align: left; margin: 10px 0; font-size: calc(1rem * var(--text-scale, 1)); line-height: 1.7; }
.transliteration {
  text-align: left; font-style: italic; opacity: .85;
  font-size: calc(1rem * var(--translit-scale, 1)); line-height: 1.6;
  margin: 4px 0 10px;
}

.ref-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--gold); font-weight: 600; font-size: .95rem;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 0; margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}
.ref-toggle .tri { display: inline-block; transition: transform .2s; font-size: .7rem; }
.ref-toggle[aria-expanded="true"] .tri { transform: rotate(90deg); }
.ref-body {
  display: none;
  white-space: pre-line;
  color: var(--text-dim);
  font-size: .9rem;
  border-left: 3px solid var(--gold);
  padding: 8px 12px; margin-top: 6px;
}
.ref-body.open { display: block; }

/* ---------- Search ---------- */
.search-input {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--primary); border-radius: 12px;
  background: var(--card); color: var(--text);
  font-size: 1rem; margin-bottom: 16px; outline: none;
}
.result-card { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.result-card .r-meta { color: var(--primary); font-weight: 600; font-size: .9rem; }
.result-card .r-snippet { color: var(--text); margin-top: 4px; }
.result-card:hover { filter: brightness(.97); }
html[data-theme="dark"] .result-card:hover { filter: brightness(1.15); }

/* ---------- Settings ---------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid rgba(128,128,128,.2);
}
.setting-row label { font-size: 1rem; }
.switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; margin: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 13px;
  background: rgba(128,128,128,.4); transition: background .2s;
  pointer-events: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(22px); }

/* ---------- Credits ---------- */
.credits p { margin: 12px 0; }
.credits .gold { color: var(--gold); }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--text-dim); padding: 48px 16px; }
.error-box {
  background: var(--card); border-left: 4px solid #b00020;
  padding: 16px; border-radius: 12px; margin: 24px 0;
}

#toast {
  position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(80px);
  background: var(--primary); color: #fff;
  padding: 10px 22px; border-radius: 24px;
  font-size: .9rem; opacity: 0; pointer-events: none;
  transition: transform .25s, opacity .25s; z-index: 100;
}
html[data-theme="dark"] #toast { color: #101613; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#ios-banner, #android-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 90;
  background: var(--primary); color: #fff;
  border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
html[data-theme="dark"] #ios-banner, #android-banner { color: #101613; }
#ios-banner[hidden], #android-banner[hidden] { display: none; }
#ios-banner button, #android-banner button {
  background: none; border: none; color: inherit;
  font-size: 1.3rem; cursor: pointer; padding: 2px 8px; flex-shrink: 0;
}

@media (max-width: 480px) {
  .arabic { font-size: calc(1.7rem * var(--arabic-scale, 1)); }
  .home-header h1 { font-size: 1.6rem; }
}

/* ---------- Font size sliders ---------- */
.setting-slider { flex-direction: column; align-items: stretch; gap: 8px; }
.slider-head { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.slider-head label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setting-slider input[type="range"] {
  width: 100%; margin: 0; accent-color: var(--primary); cursor: pointer;
}
.slider-val {
  min-width: 44px; text-align: right; color: var(--text-dim);
  font-size: .9rem; font-variant-numeric: tabular-nums;
}

#android-banner .install-btn {
  font-weight: 700; background: rgba(255,255,255,.25); border-radius: 8px;
  padding: 4px 14px !important; margin-left: 6px;
}

/* Support box (Credits page) */
.support-box { background: var(--card, #fff); border-radius: 16px; padding: 20px; margin-top: 16px; text-align: center; }
.support-box h3 { margin: 0 0 8px; color: var(--primary); font-family: Georgia, 'Times New Roman', serif; }
.support-box p { margin: 0 0 14px; font-size: 0.95rem; opacity: 0.85; }
.support-btn { display: inline-block; background: var(--primary); color: #fff; padding: 10px 22px; border-radius: 999px; text-decoration: none; font-weight: 600; }
.support-btn:hover { opacity: 0.9; }
html[data-theme="dark"] .support-btn { color: #101613; }

/* About/Credits page sections */
.about-head { text-align: center; }
.about-head h2 { margin: 4px 0 8px; }
.about-tagline { color: var(--text-dim); margin: 0 0 6px; }
.about-site { color: var(--gold); text-decoration: none; font-size: 0.95rem; }
.about-heading { color: var(--gold); font-size: 0.8rem; letter-spacing: 0.12em; font-weight: 600; margin: 2px 0 14px; }
.about-row { display: flex; gap: 16px; margin: 0 0 14px; }
.about-row:last-child { margin-bottom: 0; }
.about-label { flex: 0 0 38%; color: var(--text-dim); }
.about-value { flex: 1; }
.support-box h3 { color: var(--gold); }
.about-foot { text-align: center; color: var(--text-dim); margin: 14px 0 0; }
.about-gold { color: var(--gold); }

/* Netlify OSS footer */
#site-footer { text-align: center; padding: 20px 8px calc(28px + env(safe-area-inset-bottom, 0px)); font-size: 0.75rem; }
#site-footer a { color: var(--text-dim); text-decoration: none; opacity: .85; }
#site-footer a:hover { color: var(--gold); text-decoration: underline; opacity: 1; }

/* ---------- Responsive Desktop Sidebar & Dual-Pane Layout ---------- */
.desktop-sidebar { display: none; }
.layout-container { width: 100%; min-height: 100vh; }
.main-content { width: 100%; }

@media (min-width: 960px) {
  .layout-container {
    display: flex;
    min-height: 100vh;
  }
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--card);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding: 24px 16px 16px;
    box-sizing: border-box;
    z-index: 20;
  }
  html[data-theme="dark"] .desktop-sidebar {
    border-right-color: rgba(255, 255, 255, 0.08);
  }
  .main-content {
    flex: 1;
    min-width: 0;
    padding: 12px 32px 64px;
    display: flex;
    justify-content: center;
  }
  .main-content .wrap {
    max-width: 780px;
    width: 100%;
    margin: 0;
    padding: 16px 0 96px;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    padding: 4px 8px 16px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 16px;
  }
  .sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }
  .sidebar-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
  }
  .sidebar-sub {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--gold);
    margin-top: 2px;
  }
  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .nav-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin: 14px 8px 6px;
    text-transform: uppercase;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
  }
  .nav-item:hover {
    background: rgba(128, 128, 128, 0.12);
  }
  .nav-item.active {
    background: var(--primary);
    color: #FBFDF7;
    font-weight: 600;
  }
  html[data-theme="dark"] .nav-item.active {
    color: #101613;
  }
  .nav-item.active .nav-badge {
    background: rgba(255, 255, 255, 0.25);
    color: inherit;
  }
  .nav-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #FBFDF7;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  html[data-theme="dark"] .nav-badge {
    color: #101613;
  }
  .nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
  }
  .nav-item.active .nav-icon {
    color: inherit;
  }
  .nav-icon svg {
    width: 18px;
    height: 18px;
  }
  .sidebar-foot {
    display: flex;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: auto;
  }
  html[data-theme="dark"] .sidebar-foot {
    border-top-color: rgba(255, 255, 255, 0.08);
  }
  .sidebar-btn {
    flex: 1;
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
  }
  .sidebar-btn:hover {
    background: rgba(128, 128, 128, 0.2);
  }
}
