/* ============ Design Tokens ============ */
:root {
  --sky: #1B2A4A; --sky-dark: #14213A; --sky-deep: #0F1B3C;
  --grass: #059669; --grass-dark: #047857; --grass-deep: #065F46;
  --sun: #D97706; --sun-dark: #B45309; --sun-deep: #92400E;
  --berry: #E11D48; --berry-dark: #BE123C; --berry-deep: #9F1239;
  --grape: #C9A227; --grape-dark: #A6821C; --grape-deep: #8A6B17;
  --orange: #F59E0B; --orange-dark: #D97706; --orange-deep: #B45309;
  --slate: #94A3B8; --slate-dark: #64748B; --slate-deep: #475569;
  --gold: #C9A227; --gold-dark: #A6821C; --gold-light: #F3E3A8;

  --bg-color: #F6F4EC;
  --card-bg: #FFFFFF;
  --text-main: #151C2E;
  --text-muted: #6B6759;
  --panel-bg: rgba(255, 255, 255, 0.86);
  --surface: #FFFFFF;
  --surface-border: #E8E3D3;
  --surface-hover: #F7F3E7;
  --track-bg: #EDE9DA;
  --goal-track-bg: #E4F5EE;
  --arabic-bg: #FAF8F1;
  --arabic-border: #E4DFCB;
  --handle-bg: #D9D3BC;
  --bg-glow-1: rgba(15, 27, 60, 0.10);
  --bg-glow-2: rgba(5, 150, 105, 0.08);
  --bg-glow-3: rgba(184, 134, 11, 0.12);
  --shadow-color: 15, 27, 60;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-full: 999px;
  --nav-h: 92px;
  --brand-amber: #0F1B3C;

  /* Header panel */
  --header-bg: #E6C878;
  --header-bg-light: #FBF1D6;
  --header-bg-mid: #F0DA9C;
  --header-bg-dark: #DDC070;
  --header-text: #14213A;
  --header-text-muted: rgba(20, 33, 58, 0.66);
  --header-surface: rgba(255, 255, 255, 0.35);
  --header-surface-border: rgba(15, 27, 60, 0.18);
  --header-surface-hover: rgba(255, 255, 255, 0.5);
  --header-track-bg: rgba(255, 255, 255, 0.4);
  --header-accent: #14213A;
  --header-accent-dark: #0F1B3C;
  --header-shadow: 0, 0, 0;
  --header-glow-shadow: 166, 130, 28;

  /* Tajweed rule colors (per the standard King Fahd Complex color key) */
  --tajweed-ham-wasl: #8A8A8A;
  --tajweed-madda-normal: #4C74E8;
  --tajweed-madda-permissible: #3A57D6;
  --tajweed-madda-necessary: #1E2FA8;
  --tajweed-qalaqah: #D6000A;
  --tajweed-madda-obligatory: #2144C1;
  --tajweed-ikhafa-shafawi: #C300B0;
  --tajweed-ikhafa: #86009A;
  --tajweed-idgham-shafawi: #4E9E00;
  --tajweed-iqlab: #1FA8D6;
  --tajweed-idgham-ghunnah: #0F8F72;
  --tajweed-idgham-wo-ghunnah: #128A00;
  --tajweed-idgham-mutajanisayn: #8E8E8E;
  --tajweed-ghunnah: #E86A10;
}

body.theme-dark {
  --bg-color: #0B0E16;
  --card-bg: #141A28;
  --text-main: #F0EDE2;
  --text-muted: #9A9686;
  --panel-bg: rgba(20, 26, 40, 0.82);
  --surface: #17202F;
  --surface-border: #2A3448;
  --surface-hover: #1C2536;
  --track-bg: #1A2334;
  --goal-track-bg: #10251E;
  --arabic-bg: #121927;
  --arabic-border: #2A3448;
  --handle-bg: #3A4560;
  --bg-glow-1: rgba(91, 122, 176, 0.14);
  --bg-glow-2: rgba(34, 211, 238, 0.07);
  --bg-glow-3: rgba(229, 193, 88, 0.10);
  --sky: #5B7AB0; --sky-dark: #4568A0; --sky-deep: #2E4570;
  --grass: #34D399; --grass-dark: #10B981; --grass-deep: #059669;
  --sun: #FBBF24; --sun-dark: #F59E0B; --sun-deep: #D97706;
  --berry: #FB7185; --berry-dark: #F43F5E; --berry-deep: #E11D48;
  --grape: #E5C158; --grape-dark: #C9A227; --grape-deep: #B8860B;
  --orange: #FBBF24; --orange-dark: #F59E0B; --orange-deep: #D97706;
  --gold: #E7C34B; --gold-dark: #C9A227; --gold-light: #4A3F1C;
  --brand-amber: #F3E3A8;

  /* Tajweed rule colors, brightened for dark backgrounds */
  --tajweed-ham-wasl: #9AA3B5;
  --tajweed-madda-normal: #7FA0FF;
  --tajweed-madda-permissible: #6C8CFF;
  --tajweed-madda-necessary: #7A8CFF;
  --tajweed-qalaqah: #FF6B6F;
  --tajweed-madda-obligatory: #7C93FF;
  --tajweed-ikhafa-shafawi: #E86EDB;
  --tajweed-ikhafa: #C778E0;
  --tajweed-idgham-shafawi: #8CDB4E;
  --tajweed-iqlab: #5FD4F5;
  --tajweed-idgham-ghunnah: #3FCBA8;
  --tajweed-idgham-wo-ghunnah: #5FD44A;
  --tajweed-idgham-mutajanisayn: #B7BCC7;
  --tajweed-ghunnah: #FFA85C;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-color);
  background-image:
    radial-gradient(ellipse at 12% 0%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(ellipse at 88% 18%, var(--bg-glow-3) 0%, transparent 42%),
    radial-gradient(ellipse at 88% 92%, var(--bg-glow-2) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 0.9rem 1.4rem;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Base Layout & App Containers */
.app-container {
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  position: relative;
}

.dashboard {
  position: sticky;
  top: 10px;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

/* ============ Animations ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.app-container > * { animation: fadeUp 0.55s cubic-bezier(.16,.8,.3,1) both; }
.app-container > *:nth-child(1) { animation-delay: .02s; }
.app-container > *:nth-child(2) { animation-delay: .07s; }
.app-container > *:nth-child(3) { animation-delay: .12s; }
.app-container > *:nth-child(4) { animation-delay: .17s; }
.app-container > *:nth-child(5) { animation-delay: .22s; }
.app-container > *:nth-child(6) { animation-delay: .27s; }
.app-container > *:nth-child(7) { animation-delay: .32s; }
.app-container > *:nth-child(8) { animation-delay: .37s; }
.app-container > *:nth-child(9) { animation-delay: .42s; }

@keyframes prayer-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
/* Updates the pulse animation to match the new shadow color */
@keyframes playBadgePulse {
  0%, 100% { box-shadow: 0 6px 16px -5px rgba(15, 27, 60, 0.3); }
  50% { box-shadow: 0 6px 20px -3px rgba(15, 27, 60, 0.5); }
}
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

/* ============ Responsive Web/Desktop Layout ============ */
/* Same single-column flow as mobile everywhere — just a width-controlling wrapper so
   desktop can be wider without introducing a different (sidebar) layout. */
.page-stack { display: flex; flex-direction: column; gap: 1.3rem; width: 100%; }
.page-stack > * { animation: fadeUp 0.55s cubic-bezier(.16,.8,.3,1) both; }
.page-stack > *:nth-child(1) { animation-delay: .02s; }
.page-stack > *:nth-child(2) { animation-delay: .07s; }
.page-stack > *:nth-child(3) { animation-delay: .12s; }
.page-stack > *:nth-child(4) { animation-delay: .17s; }
.page-stack > *:nth-child(5) { animation-delay: .22s; }
.page-stack > *:nth-child(6) { animation-delay: .27s; }
.page-stack > *:nth-child(7) { animation-delay: .32s; }
.page-stack > *:nth-child(8) { animation-delay: .37s; }
.page-stack > *:nth-child(9) { animation-delay: .42s; }
.app-header {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  box-shadow: 0 10px 30px -12px rgba(var(--shadow-color), 0.18), 0 0 0 1px rgba(var(--shadow-color), 0.04);
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

/* Header panel logic (shared across top-panels) */
.app-header.top-panel, #combinedGoalPanel.app-header {
  padding: 0.85rem 1rem;
  gap: 0.65rem;
  background: linear-gradient(155deg, var(--header-bg-light) 0%, var(--header-bg-mid) 42%, var(--header-bg-dark) 100%);
  color: var(--header-text);
  border-color: rgba(15, 27, 60, 0.14);
  box-shadow: 0 10px 30px -12px rgba(var(--header-shadow), 0.22), 0 0 0 1px rgba(15, 27, 60, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-md);
}

.app-header.top-panel::before, #combinedGoalPanel.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 22%, rgba(255, 255, 255, 0.65) 40%, rgba(255, 255, 255, 0.15) 52%, transparent 68%);
  pointer-events: none;
  z-index: 0;
}

#combinedGoalPanel .icon-btn-slate, .top-panel .icon-btn-slate { background: var(--header-surface); border-color: var(--header-surface-border); color: var(--header-text); box-shadow: none; }
#combinedGoalPanel .cs-profile-strip:hover, .top-panel .cs-profile-strip:hover { background: var(--header-surface-hover); }
#combinedGoalPanel .cs-profile-avatar, .top-panel .cs-profile-avatar { background: var(--header-track-bg); border-color: var(--header-surface-border); }
#combinedGoalPanel .cs-profile-name, .top-panel .cs-profile-name { color: var(--header-text); }
#combinedGoalPanel .header-divider, .top-panel .header-divider { background: var(--header-surface-border); opacity: 1; }
#combinedGoalPanel .progress-title, .top-panel .progress-title { color: var(--header-text); }
#combinedGoalPanel .progress-value-display, .top-panel .progress-value-display { color: var(--header-accent); }
#combinedGoalPanel .goal-bar, .top-panel .goal-bar { background: var(--header-track-bg); }
#combinedGoalPanel .quran-progress-container-inline:hover, .top-panel .quran-progress-container-inline:hover { background: var(--header-surface-hover); }

.brand {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--sky), var(--grape));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.home-logo-link {
  display: flex; align-items: center; justify-content: flex-start;
  width: 190px; height: 52px; flex-shrink: 0;
  cursor: pointer; text-decoration: none; border: none; background: transparent;
  transition: transform 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}
.home-logo-link svg { width: 100%; height: 100%; }
.home-logo-link:active { transform: scale(0.96); opacity: 0.85; }

.header-icons { display: flex; gap: 0.4rem; flex-shrink: 0; }
.header-divider { height: 1px; background: var(--surface-border); width: 100%; opacity: 0.8; position: relative; z-index: 1; }

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; cursor: pointer; text-decoration: none; border: none;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}
.icon-btn:active { transform: translateY(1px) scale(0.94); filter: brightness(0.95); }
.icon-btn-slate { background: var(--surface); border: 1px solid var(--surface-border); color: var(--text-main); box-shadow: 0 2px 8px -3px rgba(var(--shadow-color), 0.15); }
.icon-btn-sm { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }

/* ============ Profile Switcher ============ */
.cs-profile-wrap { position: relative; flex: 1; min-width: 0; }
.cs-profile-strip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 4px; box-sizing: border-box; cursor: pointer;
  background: transparent; border: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.cs-profile-strip:hover { background: var(--surface-hover); }
.cs-profile-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--track-bg); border: 1px solid var(--surface-border);
  font-size: 0.9rem;
}
.cs-profile-stats {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  overflow-x: auto; scrollbar-width: none;
}
.cs-profile-stats::-webkit-scrollbar { display: none; }
.cs-profile-name {
  flex: 1; font-weight: 800; font-size: 1rem; min-width: 0;
  color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.cs-profile-chevron { font-size: 0.75rem; opacity: 0.7; transition: transform 0.25s ease; flex-shrink: 0; }
.cs-profile-wrap.expanded .cs-profile-chevron { transform: rotate(180deg); }
.cs-profile-list {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: 100%; max-width: calc(100vw - 2rem);
  max-height: 0; opacity: 0; overflow: hidden; pointer-events: none;
  box-sizing: border-box; transition: max-height 0.25s ease, opacity 0.2s ease;
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-sm);
  box-shadow: 0 14px 32px -14px rgba(var(--shadow-color), 0.35);
}
.cs-profile-wrap.expanded .cs-profile-list { max-height: 240px; opacity: 1; overflow-y: auto; pointer-events: auto; }
.cs-profile-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  cursor: pointer; border-bottom: 1px solid var(--surface-border);
  transition: background 0.15s ease;
}
.cs-profile-item:last-child { border-bottom: none; }
.cs-profile-item:hover { background: var(--surface-hover); }
.cs-profile-item.active { background: var(--bg-glow-1); }
.cs-profile-item-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--track-bg); border: 1px solid var(--surface-border);
  font-size: 0.85rem;
}
.cs-profile-item-name { flex: 1; font-size: 0.9rem; font-weight: 600; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-profile-item-check { color: var(--sky-dark); font-weight: bold; font-size: 0.9rem; display: block; }

/* ============ Progress Container ============ */
.quran-progress-container-inline {
  background: transparent; border-radius: var(--radius-sm);
  padding: 0.3rem 0.1rem 0.05rem; margin-bottom: 0; cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  position: relative; z-index: 1;
}
.quran-progress-container-inline:hover { background: var(--surface-hover); }
.quran-progress-container-inline:active { transform: scale(0.98); }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.progress-title { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.progress-value-display { font-weight: 800; font-size: 0.95rem; color: var(--sky-dark); }
.goal-bar { height: 5px; background: var(--goal-track-bg); border-radius: 10px; width: 100%; overflow: hidden; }

/* ============ Index UI Elements ============ */
.star8 { position: relative; display: block; }
.star8::before, .star8::after {
  content: ''; position: absolute; inset: 0;
  border: 1.5px solid currentColor;
}
.star8::after { transform: rotate(45deg); }

.bg-motif {
  position: absolute; pointer-events: none; color: var(--sky);
  opacity: 0.07; z-index: 0;
}

.section-title {
  font-size: 0.92rem; font-weight: 800; color: var(--text-main);
  letter-spacing: -0.01em; margin-bottom: -0.55rem;
  display: flex; justify-content: space-between; align-items: center; padding-left: 0.05rem;
}
.section-title-text { display: flex; align-items: center; gap: 0.5rem; }
.section-title-text .star8 { width: 9px; height: 9px; color: var(--gold-dark); flex-shrink: 0; }
body.theme-dark .section-title-text .star8 { color: var(--gold); }
.section-link { font-size: 0.75rem; color: var(--sky); font-weight: 700; text-decoration: none; }

.prayer-count-inline { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }

.prayer-panel { padding-top: 1.1rem; padding-bottom: 1rem; gap: 0.9rem; }
.prayer-track-wrap { position: relative; z-index: 1; padding: 0 4px; }
.prayer-track { position: absolute; left: 28px; right: 28px; top: 24px; height: 3px; background: var(--track-bg); border-radius: 3px; }
.prayer-track-fill {
  position: absolute; left: 28px; top: 24px; height: 3px; width: 0%; max-width: calc(100% - 56px);
  background: linear-gradient(90deg, var(--header-bg-mid), var(--header-bg-dark)); border-radius: 3px; transition: width 0.5s cubic-bezier(.4,1.4,.6,1);
}
.prayer-row-items { display: flex; justify-content: space-between; gap: 0.4rem; position: relative; }
.prayer-dot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; cursor: pointer; user-select: none; }
.prayer-dot-circle {
  position: relative; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--surface); border: 2px solid var(--surface-border);
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.prayer-dot:hover .prayer-dot-circle { transform: translateY(-2px); box-shadow: 0 8px 16px -8px rgba(var(--shadow-color), 0.4); }
.prayer-dot-time { font-size: 0.64rem; font-weight: 800; color: var(--text-main); z-index: 2; }
.prayer-dot-check {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%); color: var(--header-accent-dark);
  font-weight: 800; font-size: 1.1rem; border-radius: 50%; z-index: 1;
}
.prayer-dot.completed .prayer-dot-circle { border-color: var(--header-bg-dark); background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%); box-shadow: 0 6px 14px -6px rgba(var(--header-glow-shadow), 0.55); }
.prayer-dot.completed .prayer-dot-time { display: none; }
.prayer-dot.completed .prayer-dot-check { display: flex; }
.prayer-dot-label { font-size: 0.74rem; font-weight: 700; color: var(--text-muted); }
.prayer-dot.completed .prayer-dot-label { color: var(--header-accent); }
body.theme-dark .prayer-dot.completed .prayer-dot-label { color: var(--header-bg-dark); }
.prayer-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; position: relative; z-index: 1; }
.prayer-location-inline { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 0.3rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prayer-sync-btn {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: 50%; width: 28px; height: 28px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; cursor: pointer; color: var(--text-main);
  transition: transform 0.15s ease, background 0.2s ease;
}
.prayer-sync-btn:hover { background: var(--surface-hover); }
.prayer-sync-btn:active { transform: scale(0.9); }
.prayer-sync-btn.spinning { animation: prayer-spin 0.8s linear infinite; }

.continue-reading-card {
  background: var(--card-bg); border: 1px solid var(--surface-border); border-radius: var(--radius-md); padding: 0.8rem 1.2rem;
  display: flex; align-items: center; gap: 0.8rem; text-decoration: none; color: var(--text-main);
  box-shadow: 0 4px 12px -4px rgba(var(--shadow-color), 0.08); transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease; position: relative; width: 100%;
}
.continue-reading-card:hover { border-color: var(--sky); box-shadow: 0 8px 18px -8px rgba(var(--shadow-color), 0.25); }
.continue-reading-card:active { transform: scale(0.98); }
.cr-left-block { display: flex; align-items: center; justify-content: center; background: var(--bg-glow-1); padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); flex-shrink: 0; font-size: 1.15rem; }
.cr-content { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.cr-title { font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 0.4rem; }
.cr-surah { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-top: 0.05rem; }
.cr-chevron { color: var(--text-muted); font-size: 0.9rem; opacity: 0.6; margin-left: auto; flex-shrink: 0; transition: transform 0.2s ease; }
.continue-reading-card:hover .cr-chevron { transform: translateX(3px); opacity: 0.9; }

.surah-scroll { display: flex; gap: 0.8rem; overflow-x: auto; padding: 0.15rem 0.15rem 0.6rem; scrollbar-width: none; }
.surah-scroll::-webkit-scrollbar { display: none; }
.surah-chip {
  background: var(--surface); border: 1px solid var(--surface-border); padding: 0.8rem 1.2rem; border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 0.8rem; flex-shrink: 0; font-weight: 700; color: var(--text-main); text-decoration: none; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease; box-shadow: 0 4px 10px -4px rgba(var(--shadow-color), 0.06);
}
.surah-chip:hover { border-color: var(--sky); box-shadow: 0 8px 18px -8px rgba(var(--shadow-color), 0.3); }
.surah-chip:active { transform: scale(0.96); }
.surah-chip-num { background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%); color: var(--header-accent-dark); width: 34px; height: 34px; display: flex; justify-content: center; align-items: center; border-radius: 9px; font-size: 0.8rem; font-weight: 800; }

/* ============ Mood Tracker (emoji-forward) ============ */
.mood-scroll { display: flex; gap: 0.65rem; overflow-x: auto; padding: 0.35rem 0.15rem 0.7rem; scrollbar-width: none; }
.mood-scroll::-webkit-scrollbar { display: none; }

.mood-chip {
  --mood-color: var(--sky);
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  flex-shrink: 0; width: 74px; padding: 0.7rem 0.4rem 0.55rem;
  background: var(--surface); border: 1.5px solid var(--surface-border); border-radius: var(--radius-lg);
  cursor: pointer; text-align: center; user-select: none;
  box-shadow: 0 4px 10px -4px rgba(var(--shadow-color), 0.06);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.mood-chip:hover { transform: translateY(-3px); border-color: var(--mood-color); box-shadow: 0 10px 20px -10px rgba(var(--shadow-color), 0.35); }
.mood-chip:active { transform: scale(0.94) translateY(0); }
.mood-chip.active {
  border-color: var(--mood-color);
  background: color-mix(in srgb, var(--mood-color) 16%, var(--surface));
  box-shadow: 0 8px 18px -8px rgba(var(--shadow-color), 0.32);
}
.mood-chip-emoji {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; line-height: 1;
  background: linear-gradient(150deg, color-mix(in srgb, var(--mood-color) 24%, var(--surface)), color-mix(in srgb, var(--mood-color) 8%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--mood-color) 32%, var(--surface-border));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mood-chip:hover .mood-chip-emoji { transform: scale(1.14) rotate(-4deg); }
.mood-chip:active .mood-chip-emoji { transform: scale(0.88); }
.mood-chip.active .mood-chip-emoji { transform: scale(1.08); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mood-color) 30%, transparent); }
.mood-chip-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.01em; }
.mood-chip.active .mood-chip-label { color: var(--text-main); }

.reciter-card { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-md); padding: 1rem; box-shadow: 0 4px 12px -4px rgba(var(--shadow-color), 0.08); }
.reciter-info { display: flex; align-items: center; gap: 0.8rem; }
.reciter-icon { width: 44px; height: 44px; background: linear-gradient(135deg, var(--grape), var(--sky)); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; box-shadow: 0 6px 14px -6px rgba(var(--shadow-color), 0.5); }
.reciter-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.reciter-style { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.change-btn { background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%); color: var(--header-accent-dark); border: none; padding: 0.55rem 1.1rem; border-radius: 50px; font-weight: 700; font-size: 0.8rem; cursor: pointer; transition: filter 0.2s ease; }
.change-btn:hover { filter: brightness(0.96); }
.change-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

/* ============ Quran UI Elements ============ */
.verse-card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 2.4rem 1.4rem 1.7rem; border: 1px solid var(--surface-border);
  box-shadow: 0 20px 45px -18px rgba(var(--shadow-color), 0.28), 0 0 0 1px rgba(var(--shadow-color), 0.03);
  position: relative; text-align: center; margin-top: 0.6rem; touch-action: pan-y; transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.verse-card.load-error { cursor: pointer; border: 1px dashed var(--grape-dark); }
.verse-card.load-error .arabic-text { color: var(--grape-deep); }

.surah-badge {
  display: inline-block; background: linear-gradient(135deg, var(--grape), var(--grape-dark)); color: white;
  padding: 0.45rem 1.3rem; border-radius: 50px; font-weight: 700; font-size: 1.02rem;
  box-shadow: 0 8px 18px -6px rgba(184, 134, 11, 0.5); position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  max-width: 88%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; z-index: 5;
}
.surah-badge:hover { transform: translateX(-50%) scale(1.04); box-shadow: 0 8px 24px -6px rgba(184, 134, 11, 0.7); }
.surah-badge:active { transform: translateX(-50%) scale(0.95); }
.surah-badge .badge-hint { font-size: 0.6rem; opacity: 0.7; margin-left: 6px; font-weight: 400; }

.verse-play-btn {
  position: absolute; top: -15px; right: 12px; display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  background: linear-gradient(135deg, var(--grape), var(--grape-dark)); color: #fff; padding: 0.38rem 0.85rem; border-radius: 50px;
  font-weight: 700; font-size: 0.82rem; line-height: 1; border: 1.5px solid var(--card-bg); box-shadow: 0 6px 16px -5px rgba(184, 134, 11, 0.6);
  z-index: 6; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease; animation: playBadgePulse 2.4s ease-in-out infinite;
}
.verse-play-btn .play-icon { font-size: 0.85rem; }
.verse-play-btn .play-label { letter-spacing: 0.01em; }
.verse-play-btn:active { transform: scale(0.92); }
.verse-play-btn.playing { background: linear-gradient(135deg, var(--sun), var(--sun-dark)); box-shadow: 0 6px 16px -5px rgba(217, 119, 6, 0.6); animation: none; }
.verse-play-btn.loading { opacity: 0.6; cursor: wait; }
.verse-play-btn:disabled { opacity: 0.35; cursor: not-allowed; animation: none; }

.verse-star-badge {
  position: absolute; top: -13px; left: 12px; display: flex; align-items: center; gap: 0.22rem;
  background: linear-gradient(135deg, var(--grape), var(--grape-dark)); color: white; padding: 0.38rem 0.85rem; border-radius: 50px;
  font-weight: 700; font-size: 0.82rem; line-height: 1; border: 1.5px solid var(--card-bg); box-shadow: 0 5px 12px -6px rgba(184, 134, 11, 0.5);
  z-index: 6; transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.verse-star-badge .star-icon { font-size: 0.82rem; }
.verse-star-badge.pop { animation: pop 0.35s ease; }

.ayah-meta {
  margin-top: 12px;
  margin-bottom: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 4;
  padding-top: 8px;
}
.ayah-counter {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  opacity: 0.68;
  margin: 0;
  background: var(--card-bg);
  padding: 0 12px;
  border-radius: 12px;
}

.arabic-text { font-family: 'Noto Naskh Arabic', serif; color: var(--text-main); direction: rtl; margin-bottom: 1.3rem; padding: 1.2rem 1.1rem; background: var(--arabic-bg); border-radius: var(--radius-md); border: 1px solid var(--arabic-border); transition: font-size 0.2s ease, line-height 0.2s ease; }

/* IndoPak script style: rendered in a Nastaliq-style face, which is how the
   South Asian mushaf tradition is typically distinguished on screen. */
.arabic-text.script-indopak,
.review-card-arabic.script-indopak {
  font-family: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif;
}
.verse-text-small .arabic-text.script-indopak { line-height: 2.15 !important; }
.verse-text-medium .arabic-text.script-indopak { line-height: 2.5 !important; }
.verse-text-large .arabic-text.script-indopak { line-height: 2.75 !important; }
.verse-text-xl .arabic-text.script-indopak { line-height: 3.1 !important; }

/* Tajweed color-coded rules (King Fahd Complex color key) */
.tajweed-ham_wasl, .tajweed-slnt, .tajweed-laam_shamsiyah,
.tajweed-idgham_mutajanisayn, .tajweed-idgham_mutaqaribayn { color: var(--tajweed-idgham-mutajanisayn); }
.tajweed-madda_normal { color: var(--tajweed-madda-normal); }
.tajweed-madda_permissible { color: var(--tajweed-madda-permissible); }
.tajweed-madda_necessary { color: var(--tajweed-madda-necessary); }
.tajweed-qalaqah { color: var(--tajweed-qalaqah); font-weight: 700; }
.tajweed-madda_obligatory { color: var(--tajweed-madda-obligatory); }
.tajweed-ikhafa_shafawi { color: var(--tajweed-ikhafa-shafawi); }
.tajweed-ikhafa { color: var(--tajweed-ikhafa); }
.tajweed-idgham_shafawi { color: var(--tajweed-idgham-shafawi); }
.tajweed-iqlab { color: var(--tajweed-iqlab); }
.tajweed-idgham_ghunnah { color: var(--tajweed-idgham-ghunnah); }
.tajweed-idgham_wo_ghunnah { color: var(--tajweed-idgham-wo-ghunnah); }
.tajweed-ghunnah { color: var(--tajweed-ghunnah); }

/* Small legend shown under the reader when Tajweed script is active */
.tajweed-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin: -0.6rem 0 1rem; padding: 0 0.2rem; }
.tajweed-legend span { display: inline-flex; align-items: center; gap: 4px; }
.tajweed-legend span::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.translation-text { color: var(--text-main); font-weight: 500; transition: font-size 0.2s ease, line-height 0.2s ease; }
.translation-text .translation-block + .translation-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--surface-border); }
.translation-source-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 2px; }

.verse-text-small .arabic-text { font-size: clamp(1.1rem, 3.5vw, 1.6rem) !important; line-height: 1.7 !important; }
.verse-text-small .translation-text { font-size: 0.85rem !important; line-height: 1.5 !important; }
.verse-text-small .translation-source-label { font-size: 0.6rem !important; }
.verse-text-medium .arabic-text { font-size: clamp(1.7rem, 6vw, 2.6rem) !important; line-height: 2 !important; }
.verse-text-medium .translation-text { font-size: 1.05rem !important; line-height: 1.65 !important; }
.verse-text-medium .translation-source-label { font-size: 0.72rem !important; }
.verse-text-large .arabic-text { font-size: clamp(2.2rem, 8vw, 3.4rem) !important; line-height: 2.3 !important; }
.verse-text-large .translation-text { font-size: 1.3rem !important; line-height: 1.8 !important; }
.verse-text-large .translation-source-label { font-size: 0.8rem !important; }
.verse-text-xl .arabic-text { font-size: clamp(2.8rem, 10vw, 4.4rem) !important; line-height: 2.8 !important; }
.verse-text-xl .translation-text { font-size: 1.6rem !important; line-height: 1.9 !important; }
.verse-text-xl .translation-source-label { font-size: 0.85rem !important; }

.swipe-hint { margin-top: 1rem; font-size: 0.76rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.01em; opacity: 0.7; }
.swipe-hint .hint-desktop { display: none; }

.verse-auto-progress-row { display: none; align-items: center; gap: 8px; width: 100%; max-width: 260px; }
.verse-auto-progress-row.active { display: flex; }
.verse-auto-progress {
  position: relative; flex: 1; height: 6px; border-radius: 10px; background: var(--goal-track-bg); overflow: hidden;
}
.verse-auto-progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--sky), var(--grape)); border-radius: 10px;
}
.verse-auto-pause-btn {
  position: static; width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--card-bg); border: 1.5px solid var(--surface-border); color: var(--text-main);
  align-items: center; justify-content: center; font-size: 0.68rem; cursor: pointer; z-index: 6;
  box-shadow: 0 3px 8px -3px rgba(var(--shadow-color), 0.35); transition: transform 0.15s ease, opacity 0.15s ease;
}
.verse-auto-pause-btn:active { transform: scale(0.9); }

.nav-controls {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; max-width: 640px; margin: 0 auto;
  background: var(--panel-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--surface-border); border-bottom: none; border-radius: 16px 16px 0 0;
  padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom)); box-shadow: 0 -12px 30px -14px rgba(var(--shadow-color), 0.25);
}

.btn {
  padding: 0.7rem 0.5rem; border-radius: var(--radius-sm); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.98rem; cursor: pointer; display: flex; flex-direction: row;
  align-items: center; justify-content: center; gap: 0.5rem; color: white; border: none; min-height: 58px; transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease; letter-spacing: -0.01em;
}
.btn-icon { font-size: 1.25rem; line-height: 1; }
.btn:active:not(:disabled) { transform: translateY(2px) scale(0.98); filter: brightness(0.95); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }
.btn-prev { background: var(--surface); color: var(--text-main); border: 1px solid var(--surface-border); box-shadow: 0 4px 12px -6px rgba(var(--shadow-color), 0.15); }
.btn-next { background: linear-gradient(150deg, var(--sky), var(--grape)); box-shadow: 0 8px 20px -8px rgba(15, 27, 60, 0.55); }

/* ============ Modals & Settings ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 10, 30, 0.55); display: flex; justify-content: center; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; z-index: 200; backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--bg-color); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 1.5rem 1.3rem calc(1.5rem + env(safe-area-inset-bottom)); border: 1px solid var(--surface-border);
  border-bottom: none; box-shadow: 0 -20px 45px -18px rgba(0,0,0,0.25); max-height: 82dvh; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-content::before { content: ""; display: block; width: 40px; height: 5px; background: var(--handle-bg); border-radius: 10px; margin: -0.5rem auto 0.9rem; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; }
.modal-header h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text-main); }
.close-btn {
  background: var(--surface); color: var(--text-main); border: 1px solid var(--surface-border); width: 34px; height: 34px; border-radius: 50%; font-size: 1.05rem; font-weight: bold; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: transform 0.12s ease, background 0.12s ease;
}
.close-btn:active { transform: scale(0.92); background: var(--surface-hover); }

.surah-search { width: 100%; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.98rem; padding: 0.7rem 1rem; border-radius: var(--radius-md); border: 1px solid var(--surface-border); margin-bottom: 0.8rem; background: var(--surface); color: var(--text-main); flex-shrink: 0; }
.surah-search:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(15, 27, 60, 0.15); }
.surah-list { overflow-y: auto; display: flex; flex-direction: column; gap: 0.55rem; -webkit-overflow-scrolling: touch; }
.surah-item { display: flex; align-items: center; padding: 0.8rem 0.9rem; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--surface-border); cursor: pointer; font-weight: 600; font-size: 1rem; min-height: 56px; transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease; }
.surah-item:active { transform: scale(0.98); }
.surah-item:hover { border-color: var(--sky); background: var(--surface-hover); }
.surah-num { background: linear-gradient(150deg, var(--gold), var(--gold-dark)); color: white; width: 36px; height: 36px; display: flex; justify-content: center; align-items: center; border-radius: 10px; font-weight: 800; margin-right: 0.9rem; flex-shrink: 0; font-size: 0.85rem; }
body.theme-dark .surah-num { color: var(--sky-deep); }
.surah-check { margin-left: auto; color: var(--sky-dark); font-size: 1.2rem; display: none; flex-shrink: 0; }
.surah-item.completed .surah-check { display: block; }
.surah-item.hidden { display: none; }

.surah-progress-badge {
  margin-left: auto; flex-shrink: 0; display: none; align-items: center; gap: 0.25rem;
  font-size: 0.68rem; font-weight: 800; color: var(--gold-dark); white-space: nowrap;
  background: rgba(201,162,39,0.14); border: 1px solid rgba(201,162,39,0.4);
  border-radius: var(--radius-full); padding: 0.2rem 0.55rem;
}
body.theme-dark .surah-progress-badge { color: var(--gold); background: rgba(231,195,75,0.14); border-color: rgba(231,195,75,0.4); }
.surah-item.in-progress { border-color: rgba(201,162,39,0.45); background: var(--arabic-bg); }
.surah-item.in-progress .surah-progress-badge { display: inline-flex; }

.option-row { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
.option-btn { padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--surface-border); background: var(--surface); color: var(--text-main); font-family: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; text-align: center; }
.option-btn:active { transform: scale(0.98); background: var(--surface-hover); }
.option-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.text-input { width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--surface-border); background: var(--bg-color); color: var(--text-main); font-family: inherit; font-weight: 600; font-size: 0.95rem; box-sizing: border-box; }
.translation-checkbox-list { width: 100%; max-height: 260px; overflow-y: auto; border: 1px solid var(--surface-border); border-radius: var(--radius-sm); padding: 8px; background: var(--bg-color); box-sizing: border-box; }
.translation-group-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 10px 6px 4px; }
.translation-group-label:first-child { margin-top: 2px; }
.translation-check-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.translation-check-row:hover { background: var(--surface-hover); }
.translation-check-row input[type="checkbox"] { width: 19px; height: 19px; flex-shrink: 0; accent-color: var(--sky); }
.translation-check-row span { font-size: 0.92rem; font-weight: 600; color: var(--text-main); }
.translation-check-row.disabled { opacity: 0.4; cursor: not-allowed; }

.settings-section { margin-bottom: 1.3rem; }
.settings-label { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.95rem; color: var(--text-main); margin-bottom: 0.55rem; }
.seg-group { display: flex; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 999px; padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1; padding: 0.6rem 0.5rem; border-radius: 999px; font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.9rem; cursor: pointer; background: transparent; border: none; color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.seg-btn:active { transform: scale(0.96); }
.seg-btn.active { background: linear-gradient(150deg, var(--sky), var(--sky-dark)); color: white; box-shadow: 0 4px 12px -4px rgba(15, 27, 60, 0.5); }

.modal-section-label { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0.2rem 0 0.5rem; }
.achievements-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; overflow-y: auto; }
.achievement-card { background: var(--surface); padding: 0.9rem; border-radius: var(--radius-sm); text-align: center; border: 1px solid var(--surface-border); filter: grayscale(100%); opacity: 0.5; transition: 0.3s; }
.achievement-card.unlocked { filter: grayscale(0%); opacity: 1; border-color: var(--sun); box-shadow: 0 6px 18px -8px rgba(217, 119, 6, 0.35); }
.ach-icon { font-size: 2.2rem; margin-bottom: 0.4rem; }
.ach-title { font-weight: 700; color: var(--text-main); font-size: 0.9rem; }
.ach-desc { font-size: 0.74rem; color: var(--text-muted); font-weight: 500; }

.reminder-streak-box { background: var(--reminder-box-bg, #FFF7ED); padding: 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--reminder-box-border, #FDE1B8); display: inline-block; color: var(--text-main); }
body.theme-dark { --reminder-box-bg: #1D1710; --reminder-box-border: #4A3416; }
.reminder-content { text-align: center; padding: 0.4rem 0; }
.reminder-emoji { font-size: 3.6rem; animation: bounce 2.4s ease-in-out infinite; margin-bottom: 0.6rem; }
.reminder-btn { background: linear-gradient(150deg, var(--sky), var(--grape)); color: white; border: none; padding: 0.9rem 2rem; border-radius: 50px; font-size: 1.1rem; font-weight: 700; box-shadow: 0 10px 25px -8px rgba(15, 27, 60, 0.55); cursor: pointer; margin-top: 1.2rem; width: 100%; transition: transform 0.12s ease; }
.reminder-btn:active { transform: translateY(2px) scale(0.98); }

.celebration { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 1000; opacity: 0; transition: opacity 0.5s; padding: 1.5rem; text-align: center; }
.celebration.active { opacity: 1; background: rgba(244, 242, 252, 0.97); }
body.theme-dark .celebration.active { background: rgba(10, 9, 18, 0.97); }
.celebration h1 { font-size: clamp(2.1rem, 8vw, 3.2rem); font-weight: 800; background: linear-gradient(135deg, var(--sky), var(--grape)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: bounce 1s ease-in-out infinite; }
.celebration p { font-size: clamp(1.1rem, 4.5vw, 1.5rem); color: var(--text-main); font-weight: 600; margin-top: 0.3rem; }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 0.5rem 0 1rem; }
.feature-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-sm); padding: 0.9rem 0.6rem; text-align: center; }
.feature-card .icon { font-size: 2rem; }
.feature-card .label { font-weight: 700; font-size: 0.9rem; margin-top: 0.2rem; }
.feature-card .value { font-size: 1.2rem; font-weight: 800; color: var(--sky-dark); }


/* ============ AI Tafsir Design ============ */
.ai-tafsir-container {
  margin-top: 1.5rem;
  border-top: 1px dashed var(--surface-border);
  padding-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  text-align: left;
}

.verse-actions-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.ai-tafsir-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--bg-glow-3), transparent);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1 1 auto;
}

.ai-tafsir-toggle:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -4px rgba(var(--shadow-color), 0.1);
}

.ai-tafsir-toggle .ai-icon {
  font-size: 1.2rem;
}

.memo-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1 1 auto;
}

.memo-toggle-btn:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -4px rgba(var(--shadow-color), 0.1);
}

.memo-toggle-btn.in-deck {
  background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%);
  border-color: transparent;
  color: var(--header-accent-dark);
  box-shadow: 0 4px 12px -5px rgba(var(--header-glow-shadow), 0.45);
}

.ai-tafsir-content {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: 0 4px 12px -4px rgba(var(--shadow-color), 0.1);
  animation: fadeUp 0.3s ease forwards;
}

.ai-tafsir-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--surface-border);
}

.ai-badge {
  background: linear-gradient(135deg, var(--grape), var(--sun));
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.ai-tafsir-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

.ai-tafsir-text.loading {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-tafsir-text.loading::after {
  content: "⏳";
  animation: pop 1.5s infinite;
}

/* ============ Media Queries ============ */
@media (min-width: 640px) {
  body { padding: 1.6rem 1.6rem 4rem; }
  .app-container { padding-top: 20px; max-width: 700px; }
  .nav-controls { display: grid; position: static; max-width: 420px; margin: 1rem auto 0; border-radius: 100px; border: 1px solid var(--surface-border); box-shadow: 0 12px 30px -14px rgba(var(--shadow-color), 0.25); padding: 0.7rem; }
  .swipe-hint .hint-mobile { display: none; }
  .swipe-hint .hint-desktop { display: inline; }
  .btn { min-height: 64px; font-size: 1rem; }
  .modal-overlay { align-items: center; padding: 1rem; }
  .modal-content { border-radius: 18px; border-bottom: 1px solid var(--surface-border); transform: translateY(12px) scale(0.98); max-height: 82vh; }
  .modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
  .modal-content::before { display: none; }
}

@media (max-width: 400px) {
  .brand { font-size: 1.02rem; }
  .app-header.top-panel, #combinedGoalPanel.app-header { padding: 0.65rem 0.75rem; gap: 0.5rem; }
  .icon-btn { width: 34px; height: 34px; font-size: 0.95rem; }
  .home-logo-link { width: 160px; height: 44px; }
  .icon-btn-sm { width: 32px; height: 32px; font-size: 0.92rem; }
  .cs-profile-avatar { width: 24px; height: 24px; font-size: 0.8rem; }
  .cs-profile-name { font-size: 0.88rem; }
  .surah-badge { font-size: 0.85rem; padding: 0.35rem 1rem; top: -16px; }
  .surah-badge .badge-hint { font-size: 0.5rem; }
  .verse-star-badge { font-size: 0.66rem; padding: 0.28rem 0.6rem; top: -10px; left: 6px; border-width: 1px; }
  .verse-star-badge .star-icon { font-size: 0.7rem; }
  .verse-play-btn { font-size: 0.66rem; padding: 0.28rem 0.6rem; top: -12px; right: 6px; border-width: 1px; }
  .verse-play-btn .play-icon { font-size: 0.72rem; }
}

/* Tablet: give both pages more breathing room */
@media (min-width: 768px) {
  body { padding: 1.8rem 2rem 4rem; }
  .app-container { max-width: 760px; }
}

/* Desktop / web: same single-column layout as mobile, just given more width to breathe.
   Both index.html and quran.html share the same container size here. */
@media (min-width: 1024px) {
  body { padding: 2rem 2.4rem 4rem; }
  .app-container { max-width: 900px; padding-top: 24px; }

  body.page-reader .verse-card { padding: 2.2rem 2.6rem; }
  body.page-reader .arabic-text { padding: 1.7rem 2rem; }

  .modal-content { max-width: 560px; }
  #settingsModal .modal-content,
  #achievementsModal .modal-content,
  #memorizationModal .modal-content,
  #reviewSessionModal .modal-content { max-width: 640px; }
  .achievements-grid { grid-template-columns: repeat(3, 1fr); }
  .feature-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Large desktop: a touch more room, still single column, still shared by both pages */
@media (min-width: 1280px) {
  .app-container { max-width: 980px; }
}


@media (prefers-reduced-motion: reduce) {
  .app-container > *, .page-stack > * { animation: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}


/* ============================================================
   NEW: Clean Verse Top Bar (overrides old badge styles)
   ============================================================ */

.verse-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.2rem 0.8rem 0.2rem;
  margin-bottom: 0.2rem;
  position: relative;
  width: 100%;
}

.verse-top-left,
.verse-top-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 44px;
}

.verse-top-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

/* Star Badge - Clean & Minimal */
.verse-star-badge {
  position: absolute; 
  top: -13px; 
  left: 12px; 
  display: flex; 
  align-items: center; 
  gap: 0.22rem;
  background: linear-gradient(155deg, var(--header-bg-light) 0%, var(--header-bg-mid) 42%, var(--header-bg-dark) 100%); 
  color: var(--header-text); 
  padding: 0.38rem 0.85rem; 
  border-radius: 50px;
  font-weight: 800; 
  font-size: 0.82rem; 
  line-height: 1; 
  border: 1.5px solid var(--card-bg); 
  box-shadow: 0 5px 12px -6px rgba(15, 27, 60, 0.25);
  z-index: 6; 
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.verse-star-badge .star-icon { font-size: 0.82rem; }
.verse-star-badge.pop { animation: pop 0.35s ease; }

/* ============ Updated Verse Top Bar Badges ============ */
.surah-badge {
  display: inline-block; 
  background: linear-gradient(155deg, var(--header-bg-light) 0%, var(--header-bg-mid) 42%, var(--header-bg-dark) 100%); 
  color: var(--header-text);
  padding: 0.45rem 1.3rem; 
  border-radius: 50px; 
  font-weight: 800; 
  font-size: 1.02rem;
  box-shadow: 0 8px 18px -6px rgba(15, 27, 60, 0.25); 
  position: absolute; 
  top: -20px; 
  left: 50%; 
  transform: translateX(-50%);
  max-width: 88%; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  letter-spacing: -0.01em; 
  cursor: pointer; 
  transition: transform 0.15s ease, box-shadow 0.15s ease; 
  z-index: 5;
  border: 1px solid rgba(15, 27, 60, 0.1);
}

.surah-badge:hover { 
  transform: translateX(-50%) scale(1.04); 
  box-shadow: 0 8px 24px -6px rgba(15, 27, 60, 0.35); 
}
.surah-badge:active { 
  transform: translateX(-50%) scale(0.95); 
}
.surah-badge .badge-hint { 
  font-size: 0.6rem; 
  opacity: 0.7; 
  margin-left: 6px; 
  font-weight: 600; 
}

.surah-badge:hover .badge-hint {
  opacity: 0.8;
}

/* Play Button - Clean & Purposeful */
.verse-play-btn {
  position: absolute; 
  top: -15px; 
  right: 12px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 0.3rem;
  background: linear-gradient(155deg, var(--header-bg-light) 0%, var(--header-bg-mid) 42%, var(--header-bg-dark) 100%); 
  color: var(--header-text); 
  padding: 0.38rem 0.85rem; 
  border-radius: 50px;
  font-weight: 800; 
  font-size: 0.82rem; 
  line-height: 1; 
  border: 1.5px solid var(--card-bg); 
  box-shadow: 0 6px 16px -5px rgba(15, 27, 60, 0.25);
  z-index: 6; 
  cursor: pointer; 
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease; 
  animation: playBadgePulse 2.4s ease-in-out infinite;
}

.verse-play-btn .play-icon { font-size: 0.85rem; }
.verse-play-btn .play-label { letter-spacing: 0.01em; }
.verse-play-btn:active { transform: scale(0.92); }
.verse-play-btn.playing { 
  background: linear-gradient(135deg, var(--sun), var(--sun-dark)); 
  color: white; 
  box-shadow: 0 6px 16px -5px rgba(217, 119, 6, 0.6); 
  animation: none; 
}
.verse-play-btn.loading { opacity: 0.6; cursor: wait; }
.verse-play-btn:disabled { opacity: 0.35; cursor: not-allowed; animation: none; }

/* Mobile adjustments */
@media (max-width: 400px) {
  .verse-top-bar {
    padding-bottom: 0.5rem;
    gap: 0.3rem;
  }
  
  .verse-star-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
  }
  
  .verse-star-badge .star-icon {
    font-size: 0.7rem;
  }
  
  .surah-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
  }
  
  .verse-play-btn {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem 0.15rem 0.4rem;
  }
  
  .verse-play-btn .play-icon {
    font-size: 0.7rem;
  }
  
  .verse-play-btn .play-label {
    font-size: 0.65rem;
  }
}

/* ============ AI Memorization Coach ============ */
.memo-stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.7rem; margin: 0.5rem 0 1rem; }
.memo-stat-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-sm); padding: 0.8rem 0.4rem; text-align: center; }
.memo-stat-card .memo-stat-value { font-size: 1.25rem; font-weight: 800; color: var(--sky-dark); }
.memo-stat-card .memo-stat-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); margin-top: 0.15rem; }

.memo-level-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.3rem; }
.memo-level-label { font-weight: 700; font-size: 0.88rem; color: var(--text-main); }
.memo-xp-label { font-size: 0.78rem; font-weight: 700; color: var(--header-accent); }

.memo-start-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 1rem; padding: 0.9rem 1rem;
  background: linear-gradient(150deg, var(--header-bg-light) 0%, var(--header-bg-mid) 45%, var(--header-bg-dark) 100%);
  color: var(--header-accent-dark); border: none; border-radius: var(--radius-full);
  font-family: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(var(--header-glow-shadow), 0.55);
}
.memo-start-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.memo-empty-hint { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin-top: 0.6rem; line-height: 1.5; }

.memo-deck-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 220px; overflow-y: auto; margin-top: 0.4rem; }
.memo-deck-item { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; }
.memo-deck-item-name { font-weight: 700; font-size: 0.85rem; color: var(--text-main); }
.memo-deck-item-sub { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.memo-deck-badge { font-size: 0.68rem; font-weight: 800; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.memo-deck-badge.due { background: linear-gradient(135deg, var(--header-bg-mid), var(--header-bg-dark)); color: var(--header-accent-dark); }
.memo-deck-badge.scheduled { background: var(--track-bg); color: var(--text-muted); }
.memo-deck-badge.mastered { background: linear-gradient(135deg, var(--header-bg-light), var(--header-bg-dark)); color: var(--header-accent-dark); }

/* ---- Review session ---- */
.review-progress-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.review-progress-track { flex: 1; height: 6px; background: var(--track-bg); border-radius: 6px; overflow: hidden; }
.review-progress-fill { height: 100%; background: linear-gradient(90deg, var(--header-bg-mid), var(--header-bg-dark)); border-radius: 6px; transition: width 0.3s ease; }
.review-progress-count { font-size: 0.78rem; font-weight: 800; color: var(--text-muted); white-space: nowrap; }

.review-card {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-md);
  padding: 1.4rem 1.1rem; text-align: center; min-height: 160px;
  display: flex; flex-direction: column; justify-content: center; gap: 0.7rem;
}
.review-card-surah { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); }
.review-card-arabic { font-family: 'Noto Naskh Arabic', serif; font-size: 1.6rem; line-height: 2; color: var(--text-main); direction: rtl; }
.review-card-translation { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; display: none; }
.review-card-translation.revealed { display: block; animation: fadeUp 0.3s ease forwards; }

.review-reveal-btn {
  display: block; margin: 0.8rem auto 0; padding: 0.65rem 1.3rem;
  background: linear-gradient(150deg, var(--header-bg-light), var(--header-bg-mid));
  color: var(--header-accent-dark); border: none; border-radius: 50px;
  font-family: inherit; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}

.review-grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 1.1rem; }
.review-grade-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 0.7rem 0.3rem; border-radius: var(--radius-sm); border: 1px solid var(--surface-border);
  background: var(--surface); font-family: inherit; cursor: pointer; transition: transform 0.15s ease;
}
.review-grade-btn:active { transform: scale(0.95); }
.review-grade-btn .grade-icon { font-size: 1.35rem; }
.review-grade-btn .grade-label { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); }
.review-grade-btn.grade-forgot:hover { border-color: var(--orange); }
.review-grade-btn.grade-hard:hover { border-color: var(--sun); }
.review-grade-btn.grade-good:hover { border-color: var(--header-accent); }
.review-grade-btn.grade-easy:hover { border-color: var(--header-bg-dark); background: var(--header-surface); }
.review-grade-row.disabled { opacity: 0.35; pointer-events: none; }

.review-summary { text-align: center; padding: 1rem 0; }
.review-summary .summary-emoji { font-size: 2.6rem; }
.review-summary h3 { font-size: 1.2rem; font-weight: 800; color: var(--text-main); margin-top: 0.4rem; }
.review-summary p { font-size: 0.88rem; color: var(--text-muted); margin-top: 0.3rem; line-height: 1.5; }
.review-summary .summary-xp { font-weight: 800; color: var(--header-accent); }




/* Base styling for Arabic Text (Defaults to Uthmani) */
.arabic-text, .review-card-arabic {
  font-family: 'Amiri Quran', 'Noto Naskh Arabic', serif;
  line-height: 2.2;
  direction: rtl;
}

/* IndoPak Script Styling */
.script-indopak {
  font-family: 'Lateef', 'Noto Nastaliq Urdu', 'Amiri', 'Noto Naskh Arabic', serif !important;
  line-height: 2.4 !important;
  font-size: 1.15em; /* IndoPak fonts usually need a slight size bump */
  word-spacing: 0.1em;
}

/* Uthmani Script Styling */
.script-uthmani {
  font-family: 'Amiri Quran', 'Noto Naskh Arabic', serif !important;
  line-height: 2.2 !important;
}

/* Tajweed Script Styling (Handles colored spans if returned by API) */
.script-tajweed {
  font-family: 'Amiri', 'Noto Naskh Arabic', serif !important;
  line-height: 2.3 !important;
}