:root {
  --deep: #0c2340;
  --green: #0b5d3b;
  --gold: #c9a227;
  --bg: #f4f7f5;
  --card: #ffffff;
  --ink: #1a2e28;
  --muted: #5f7369;
  --line: #e2ebe5;
  --urgent: #c0392b;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(12, 35, 64, 0.08);
  --nav-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Cairo', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; cursor: pointer; }

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: linear-gradient(180deg, #fafcfb 0%, var(--bg) 100%);
}

/* Splash */
.splash {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--deep), var(--green));
  color: #fff; transition: opacity 0.5s, visibility 0.5s;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 50%;
  background: #fff; padding: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
  animation: splashPulse 2s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.splash h1 { margin-top: 16px; font-size: 2rem; font-weight: 800; }
.splash p { opacity: 0.85; margin-top: 6px; font-size: 0.95rem; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--deep);
  color: #eef5f1;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-brand img { width: 36px; height: 36px; border-radius: 10px; }
.header-brand span { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.header-meta { font-size: 0.75rem; opacity: 0.85; text-align: left; }
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  background: rgba(255,255,255,.12); border: none; color: inherit;
  width: 36px; height: 36px; border-radius: 10px; font-size: 1rem;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(0.94); }

/* Views */
.view { display: none; padding: 0 14px 16px; animation: fadeIn 0.35s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Section */
.section { margin-top: 14px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 { font-size: 1.05rem; color: var(--deep); font-weight: 800; }
.tag {
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: #eef5f0; color: var(--green);
}

/* Weather */
.weather-card {
  margin-top: 14px; border-radius: 22px; overflow: hidden;
  position: relative; min-height: 140px; cursor: pointer;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.weather-card:active { transform: scale(0.985); }
.weather-card.day { background: linear-gradient(135deg, #4a9fd4 0%, #87ceeb 50%, #b8dff5 100%); }
.weather-card.night { background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 50%, #2d3f6b 100%); }
.weather-stars { position: absolute; inset: 0; pointer-events: none; opacity: 0.6; }
.weather-body { position: relative; z-index: 1; padding: 16px; color: #fff; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.weather-card.night .weather-body { color: #f0f4ff; }
.weather-icon { font-size: 3rem; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)); }
.weather-main strong { font-size: 2rem; font-weight: 900; display: block; line-height: 1.1; }
.weather-main small { opacity: 0.9; font-size: 0.85rem; }
.weather-grid {
  grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 4px;
}
.weather-grid span {
  background: rgba(255,255,255,.18); backdrop-filter: blur(6px);
  padding: 6px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 600;
}

/* Breaking */
.breaking {
  margin-top: 12px; background: linear-gradient(90deg, #8b0000, var(--urgent));
  color: #fff; border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  animation: urgentGlow 2.5s ease-in-out infinite;
}
@keyframes urgentGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(192,57,43,0); }
  50% { box-shadow: 0 0 20px rgba(192,57,43,.35); }
}
.breaking b { white-space: nowrap; font-size: 0.85rem; }
.breaking .ticker { overflow: hidden; flex: 1; }
.breaking .ticker span { display: inline-block; white-space: nowrap; animation: breakMarquee 18s linear infinite; }
@keyframes breakMarquee {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); margin-bottom: 10px;
  cursor: pointer; transition: transform 0.15s;
}
.card:active { transform: scale(0.985); }
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #e8eee9; display: block; }
.card-img.contain { object-fit: contain; background: #f0f4f1; }
.card-body { padding: 12px 14px; }
.card-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 0.98rem; font-weight: 800; color: var(--deep); line-height: 1.4; }
.card-excerpt { font-size: 0.82rem; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-hero { border: 2px solid var(--gold); }
.badge-urgent { color: var(--urgent); font-weight: 800; }
.badge-death { color: #444; font-weight: 800; }

/* Categories */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 12px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s;
}
.cat-item:active { transform: scale(0.96); border-color: var(--green); }
.cat-item .icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.cat-item b { font-size: 0.88rem; color: var(--deep); }

/* Prayer */
.prayer-card {
  background: linear-gradient(180deg, #fff, #f5faf7);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 14px; box-shadow: var(--shadow);
}
.prayer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.prayer-head h2 { font-size: 1rem; color: var(--deep); }
.next-pill {
  font-size: 0.72rem; font-weight: 800; padding: 5px 10px;
  border-radius: 999px; background: #e8f5ec; color: var(--green);
}
.prayer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.prayer-slot {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  text-align: center; padding: 10px 4px;
}
.prayer-slot b { display: block; font-size: 0.78rem; color: var(--deep); }
.prayer-slot span { display: block; font-size: 1rem; font-weight: 900; color: var(--green); margin-top: 2px; }
.prayer-slot.next { background: var(--green); border-color: var(--green); }
.prayer-slot.next b, .prayer-slot.next span { color: #fff; }

/* Reactions */
.reactions {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.react-btn {
  border: 1px solid var(--line); background: #fafcfb; border-radius: 999px;
  padding: 6px 12px; font-size: 0.82rem; display: flex; align-items: center; gap: 4px;
  transition: background 0.15s, border-color 0.15s;
}
.react-btn.active { background: #e8f5ec; border-color: var(--green); }
.react-btn:active { transform: scale(0.95); }

/* Article reader */
.article-reader { padding-bottom: 24px; }
.article-reader img { width: 100%; max-height: 320px; object-fit: contain; background: #f0f4f1; border-radius: 16px; margin-bottom: 14px; }
.article-reader h1 { font-size: 1.35rem; color: var(--deep); line-height: 1.45; margin-bottom: 10px; }
.article-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 14px; }
.article-body { font-size: 1rem; line-height: 1.75; white-space: pre-wrap; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  max-width: 520px; margin: 0 auto;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b));
  box-shadow: 0 -4px 24px rgba(0,0,0,.06);
}
.nav-btn {
  border: none; background: none; color: var(--muted);
  font-size: 0.62rem; font-weight: 700; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav-btn .ico { font-size: 1.25rem; line-height: 1; }
.nav-btn.active { color: var(--green); }

/* Toast & prompts */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--deep); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; z-index: 300; opacity: 0;
  transition: transform 0.3s, opacity 0.3s; pointer-events: none; white-space: nowrap;
  max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.prompt-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(12,35,64,.45); backdrop-filter: blur(4px);
  display: none; place-items: center; padding: 20px;
}
.prompt-overlay.show { display: grid; }
.prompt-card {
  background: #fff; border-radius: 22px; padding: 24px 20px;
  max-width: 360px; width: 100%; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.2);
  animation: fadeIn 0.3s ease;
}
.prompt-card img { width: 64px; height: 64px; margin-bottom: 12px; border-radius: 14px; }
.prompt-card h3 { font-size: 1.15rem; color: var(--deep); margin-bottom: 8px; }
.prompt-card p { font-size: 0.88rem; color: var(--muted); margin-bottom: 18px; line-height: 1.6; }
.prompt-actions { display: flex; gap: 8px; }
.btn {
  flex: 1; border: none; border-radius: 14px; padding: 12px 16px;
  font-size: 0.9rem; font-weight: 800;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-ghost { background: #eef2ef; color: var(--deep); }
.btn:active { transform: scale(0.97); }

.empty {
  text-align: center; padding: 32px 16px; color: var(--muted);
  font-size: 0.9rem; background: var(--card); border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.back-bar { margin: 12px 0; }
.back-btn {
  border: none; background: #eef2ef; color: var(--deep);
  padding: 8px 14px; border-radius: 12px; font-weight: 700; font-size: 0.85rem;
}

/* Weather panel sheet */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 180;
  background: rgba(0,0,0,.4); display: none; place-items: end;
}
.sheet-overlay.show { display: grid; }
.sheet {
  background: #fff; border-radius: 22px 22px 0 0; width: 100%; max-width: 520px;
  max-height: 80vh; overflow-y: auto; padding: 20px 16px calc(20px + var(--safe-b));
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet h2 { font-size: 1.1rem; color: var(--deep); margin-bottom: 14px; }
.weather-hours { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.weather-hour { flex: 0 0 auto; text-align: center; background: #f5faf7; border-radius: 14px; padding: 10px 12px; min-width: 64px; }
.weather-hour b { display: block; font-size: 0.72rem; color: var(--muted); }
.weather-hour span { font-size: 1.4rem; display: block; margin: 4px 0; }
.weather-hour small { font-weight: 800; color: var(--green); }

@media (min-width: 400px) {
  .section-head h2 { font-size: 1.12rem; }
}

/* Rates ticker */
.rates-bar {
  margin-top: 12px; background: linear-gradient(90deg, #0b5d3b, #1a7a52);
  color: #fff; border-radius: 14px; overflow: hidden;
  display: flex; align-items: stretch; cursor: pointer;
  box-shadow: var(--shadow); min-height: 42px;
  opacity: 0.92; transition: opacity 0.25s;
}
.rates-bar.ready { opacity: 1; }
.rates-bar > b {
  padding: 10px 12px; white-space: nowrap; font-size: 0.85rem;
  background: rgba(0,0,0,.15); flex-shrink: 0; display: flex; align-items: center;
}
.rates-ticker { overflow: hidden; flex: 1; min-width: 0; display: flex; align-items: center; }
.rates-track { width: 100%; overflow: hidden; }
.rates-marquee { overflow: hidden; width: 100%; }
.rates-marquee-inner {
  display: inline-flex; align-items: center; white-space: nowrap;
  animation: ratesMarquee 50s linear infinite; padding: 10px 0; will-change: transform;
}
.rates-bar:hover .rates-marquee-inner { animation-play-state: paused; }
.rates-item { font-size: 0.78rem; font-weight: 700; padding: 0 10px; flex-shrink: 0; }
.rates-item b { font-weight: 900; margin-left: 4px; }
.rates-sep { opacity: 0.45; padding: 0 4px; flex-shrink: 0; }
.chg-up { color: #8dffb0; }
.chg-down { color: #ffb4b4; }
.chg-flat { color: #dbe8df; }
@keyframes ratesMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(50%); }
}

.rates-panel-section { font-weight: 800; color: var(--deep); margin: 14px 0 8px; font-size: 0.9rem; }
.rates-cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rates-card { background: #f8fbf9; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.rates-card.gold { border-color: #e8dcc0; background: linear-gradient(180deg, #fffdf7, #fff8ea); }
.rates-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rates-card-code { font-weight: 900; color: var(--deep); font-size: 0.85rem; }
.rates-card-change { font-size: 0.68rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; }
.rates-card-change.up { background: #e8f5ec; color: var(--green); }
.rates-card-change.down { background: #fff0ef; color: var(--urgent); }
.rates-card-change.flat { background: #eef1f0; color: var(--muted); }
.rates-card-name { font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.rates-card-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.rates-card-prices div { text-align: center; background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--line); }
.rates-card-prices small { display: block; font-size: 0.65rem; color: var(--muted); }
.rates-card-prices b { font-size: 0.85rem; color: var(--deep); }
.rates-ounce-card { grid-column: 1 / -1; background: linear-gradient(135deg, #8b6914, #c9a227); color: #fff; border: none; }
.rates-ounce-card .rates-card-code, .rates-ounce-card b { color: #fff; }
.sheet-meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }

/* Azkar */
.azkar-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.azkar-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 12px; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.15s;
}
.azkar-card:active { transform: scale(0.97); }
.azkar-card b { display: block; color: var(--deep); font-size: 0.92rem; }
.azkar-card small { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.dhikr-box {
  background: #f8fbf9; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-bottom: 8px; line-height: 1.8; font-size: 0.92rem;
}

/* Reminders */
.reminder-controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.reminder-on {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  background: #e8f5ec; border: 1px solid #c5e6d0; border-radius: 14px; padding: 10px 12px;
  font-size: 0.85rem; font-weight: 700; color: var(--green);
}
.reminder-toggles { display: grid; gap: 8px; }
.reminder-toggle {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-size: 0.88rem; font-weight: 700;
}

/* Footer */
.app-footer {
  margin: 20px 0 8px; text-align: center; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.app-footer .brand { font-weight: 900; color: var(--deep); font-size: 1.1rem; }
.app-footer small { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.app-footer a {
  display: inline-block; margin-top: 10px; padding: 8px 14px; border-radius: 12px;
  background: #eef5f0; color: var(--green); font-weight: 800; text-decoration: none; font-size: 0.82rem;
}

@media (max-width: 380px) {
  .rates-cards-grid { grid-template-columns: 1fr; }
}
