/* ==========================================================================
   PREMIUM DESIGN SYSTEM & CSS VARIABLES
   ========================================================================== */

:root {
  /* HSL Color Tokens - Dark Mode (Default) */
  --bg-primary: #0a0f0d;
  --bg-secondary: #111a17;
  --bg-card: #15221e;
  --border-color: rgba(212, 175, 55, 0.15);
  --border-color-hover: rgba(212, 175, 55, 0.3);

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary-emerald: #0b3a2f;
  --accent-emerald: #10b981;
  --accent-gold: #d4af37;
  --accent-gold-rgb: 212, 175, 55;
  --accent-gold-hover: #f5d061;
  --accent-gold-light: rgba(212, 175, 55, 0.1);

  --header-bg: rgba(10, 15, 13, 0.85);
  --sidebar-bg: #0b110f;

  /* Font Family Stacks */
  --font-arabic: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  /* Typography Variables (Controlled by JS) */
  --arabic-size: 36px;
  --english-size: 16px;

  /* Transitions & Shadows */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
  --shadow-premium: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 15px rgba(212, 175, 55, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: rgba(11, 58, 47, 0.08);
  --border-color-hover: rgba(11, 58, 47, 0.2);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --header-bg: rgba(248, 250, 252, 0.85);
  --sidebar-bg: #ffffff;

  --shadow-premium: 0 4px 20px rgba(11, 58, 47, 0.08);
  --shadow-glow: 0 0 15px rgba(11, 58, 47, 0.1);
}

/* Warm Sepia Theme Overrides */
[data-theme="sepia"] {
  --bg-primary: #f4ecd8;
  --bg-secondary: #eaddc3;
  --bg-card: #fdfaf2;
  --border-color: rgba(140, 106, 44, 0.15);
  --border-color-hover: rgba(140, 106, 44, 0.3);

  --text-primary: #3c2f2f;
  --text-secondary: #5c4a4a;
  --text-muted: #8c7a7a;

  --primary-emerald: #0b3a2f;
  --accent-emerald: #1b4d3e;
  --accent-gold: #b38600;
  --accent-gold-rgb: 179, 134, 0;
  --accent-gold-hover: #997300;
  --accent-gold-light: rgba(179, 134, 0, 0.08);

  --header-bg: rgba(244, 236, 216, 0.85);
  --sidebar-bg: #eaddc3;

  --shadow-premium: 0 4px 20px rgba(92, 74, 74, 0.06);
  --shadow-glow: 0 0 15px rgba(179, 134, 0, 0.1);
}

/* Royal Emerald Theme Overrides */
[data-theme="emerald"] {
  --bg-primary: #04241d;
  --bg-secondary: #082d25;
  --bg-card: #0b3a2f;
  --border-color: rgba(212, 175, 55, 0.2);
  --border-color-hover: rgba(212, 175, 55, 0.4);

  --text-primary: #f0f7f4;
  --text-secondary: #a3c4bc;
  --text-muted: #70978f;

  --primary-emerald: #0b3a2f;
  --accent-emerald: #10b981;
  --accent-gold: #d4af37;
  --accent-gold-rgb: 212, 175, 55;
  --accent-gold-hover: #f5d061;
  --accent-gold-light: rgba(212, 175, 55, 0.15);

  --header-bg: rgba(4, 36, 29, 0.85);
  --sidebar-bg: #031c17;

  --shadow-premium: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 15px rgba(212, 175, 55, 0.2);
}

/* ==========================================================================
   CSS RESET & GLOBAL STYLES
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  /* App Shell handles scrolling */
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  width: 100vw;
  touch-action: manipulation; /* Disable double-tap-to-zoom, preserve pinch-to-zoom */
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  font-weight: 600;
}

/* Premium Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ==========================================================================
   SIDEBAR & DRAWER NAVIGATION
   ========================================================================== */

.sidebar {
  width: 350px;
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 2px 8px rgba(var(--accent-gold-rgb), 0.2));
}

.logo-text h1 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.logo-text span {
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  color: var(--text-muted);
  display: block;
}

.close-sidebar-btn {
  display: none;
  /* Desktop only */
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: var(--text-secondary);
}

.close-sidebar-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  padding: 16px 24px 0 24px;
  gap: 8px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

/* Search Bar */
.search-container {
  padding: 16px 24px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

[data-theme="light"] .search-wrapper input {
  background-color: rgba(0, 0, 0, 0.03);
}

.search-wrapper input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.clear-btn {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px;
}

.clear-btn:hover {
  color: var(--text-primary);
}

/* Sidebar List Containers */
.sidebar-list-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.list-section {
  display: none;
  padding: 8px 16px;
}

.list-section.active {
  display: block;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Sidebar items styling */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background-color: rgba(212, 175, 55, 0.05);
  border-color: rgba(212, 175, 55, 0.1);
}

.nav-item.active {
  background-color: rgba(212, 175, 55, 0.1);
  border-color: var(--accent-gold);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-item-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.nav-item.active .nav-item-num {
  background-color: var(--accent-gold);
  color: var(--primary-emerald);
}

.nav-item-meta {
  display: flex;
  flex-direction: column;
}

.nav-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.nav-item-translation {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-item-right {
  text-align: right;
}

.nav-item-arabic {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.nav-item-ayah-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

/* Sidebar Settings Section */
.sidebar-settings {
  padding: 20px 24px;
  background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sidebar-settings {
  background-color: rgba(0, 0, 0, 0.01);
}

.settings-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
  margin-bottom: 16px;
}

.setting-item {
  margin-bottom: 14px;
}

.setting-item.flex-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.setting-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.setting-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
}

/* Sliders */
input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Toggle Switches */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

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

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid transparent;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

.switch-toggle input:checked+.slider-round {
  background-color: var(--accent-emerald);
}

.switch-toggle input:checked+.slider-round:before {
  transform: translateX(18px);
  background-color: white;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background-color: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--accent-gold);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-toggle-btn:hover {
  background-color: rgba(212, 175, 55, 0.15);
  border-color: var(--accent-gold);
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="light"] .theme-icon-dark {
  display: none;
}

/* Caching Indicator */
.cache-badge-container {
  margin-top: 18px;
  display: flex;
}

.cache-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .cache-badge {
  background-color: rgba(0, 0, 0, 0.03);
}

.cache-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.cache-badge .dot.blinking {
  background-color: var(--accent-gold);
  animation: pulse 1.5s infinite ease-in-out;
}

.cache-badge .dot.success {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.cache-badge .dot.error {
  background-color: #ef4444;
}

.badge-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   MAIN CONTENT AREA & HEADER
   ========================================================================== */

.main-content {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.main-header {
  height: 70px;
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 90;
  transition: background-color 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle-btn {
  display: none;
  /* Desktop hidden */
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.menu-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.menu-toggle-btn svg,
.close-sidebar-btn svg,
#btn-copy-link svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
}

.bc-section {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.bc-divider {
  color: var(--accent-gold);
  font-size: 0.8rem;
}

.bc-sub {
  color: var(--accent-gold);
  font-size: 0.95rem;
  font-weight: 500;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.btn-gold {
  background-color: var(--accent-gold);
  color: #0b110f;
}

.btn-gold:hover {
  background-color: var(--accent-gold-hover);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--accent-gold);
  background-color: rgba(212, 175, 55, 0.05);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.btn-icon:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background-color: rgba(212, 175, 55, 0.05);
}

.icon-left {
  margin-right: 8px;
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Reading Progress Bar */
.reading-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: rgba(255, 255, 255, 0.05);
}

.reading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-gold));
  transition: width 0.1s ease;
}

/* ==========================================================================
   VIEWPORT & READERS
   ========================================================================== */

.reading-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 30px 16px;
  position: relative;
  scroll-behavior: smooth;
}

/* Welcome Screen Styling */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 150px);
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 0;
}

.welcome-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-gold));
}

.welcome-logo {
  width: 90px;
  height: 90px;
  margin: 0 auto 24px auto;
}

.ornament-svg {
  width: 100%;
  height: 100%;
  animation: rotate-slow 20s infinite linear;
}

.welcome-card h2 {
  font-family: var(--font-arabic);
  font-size: 2.2rem;
  color: var(--accent-gold);
  margin-bottom: 12px;
  direction: rtl;
}

.welcome-card h3 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.welcome-card>p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 580px;
  margin: 0 auto 36px auto;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
  text-align: left;
}

.feature-item {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(212, 175, 55, 0.05);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition-smooth);
}

[data-theme="light"] .feature-item {
  background-color: rgba(0, 0, 0, 0.02);
}

.feature-item:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  background-color: rgba(212, 175, 55, 0.03);
}

.feature-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
  display: block;
}

.feature-item strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.feature-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.welcome-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* ==========================================================================
   QURAN CONTENT CONTAINER
   ========================================================================== */

.quran-container {
  max-width: 840px;
  margin: 0 auto;
  padding-bottom: 100px;
}

/* Surah Header Card */
.surah-banner {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 40px;
  position: relative;
  text-align: center;
  box-shadow: var(--shadow-premium);
  overflow: hidden;
}

.surah-banner::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius-lg) - 4px);
  margin: 4px;
  pointer-events: none;
}

.surah-banner-arabic {
  font-family: var(--font-arabic);
  font-size: 2.8rem;
  color: var(--accent-gold);
  margin-bottom: 8px;
  direction: rtl;
}

.surah-banner-english {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--text-primary);
  font-weight: 700;
}

.surah-banner-meaning {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 12px;
}

.surah-banner-meta {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.meta-pill {
  background-color: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 12px;
}

/* Bismillah Centered Calligraphy Styling */
.bismillah-wrapper {
  text-align: center;
  margin: 30px 0 45px 0;
  position: relative;
}

.bismillah-arabic {
  font-family: var(--font-arabic);
  font-size: 2.2rem;
  color: var(--text-primary);
  display: inline-block;
  padding: 10px 30px;
  position: relative;
}

.bismillah-arabic::before,
.bismillah-arabic::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

.bismillah-arabic::before {
  right: 100%;
}

.bismillah-arabic::after {
  left: 100%;
}

/* Ayah Card Styling */
.ayah-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  position: relative;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

.ayah-card:hover {
  border-color: rgba(212, 175, 55, 0.35);
  transform: translateY(-1px);
}

/* Active Highlight state with observer glow */
.ayah-card.active {
  border-color: var(--accent-gold);
  border-left: 6px solid var(--accent-gold);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), var(--shadow-glow);
  background-color: rgba(212, 175, 55, 0.03);
}

[data-theme="light"] .ayah-card.active {
  background-color: rgba(11, 58, 47, 0.02);
  border-left-color: var(--primary-emerald);
  border-color: var(--primary-emerald);
}

.ayah-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 12px;
}

[data-theme="light"] .ayah-header {
  border-bottom-color: rgba(0, 0, 0, 0.03);
}

.ayah-key {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  background-color: rgba(212, 175, 55, 0.06);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
}

.ayah-card.active .ayah-key {
  background-color: var(--accent-gold);
  color: var(--primary-emerald);
}

.ayah-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ayah-actions .action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.ayah-actions .action-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--accent-gold);
}

[data-theme="light"] .ayah-actions .action-btn:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.ayah-actions .action-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Beautiful Arabic Verses */
.ayah-text-arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  color: var(--text-primary);
  line-height: 2.1;
  text-align: right;
  direction: rtl;
  margin-bottom: 24px;
  word-wrap: break-word;
  word-break: break-word;
}

/* Traditonal ornamental flower circle wrapper around Ayah index numbers */
.ayah-number-badge {
  font-family: var(--font-sans);
  font-size: 13px !important; /* Lock the size so it never overflows or wraps! */
  font-weight: 700;
  color: var(--accent-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 12px;
  margin-right: 12px;
  position: relative;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50,2.5 L59.3,13.6 L73.2,7.3 L77.5,22.1 L91.9,19.3 L90.4,34 L100,40 L93,52.8 L97.5,67 L86.6,76.5 L86,91 L71.5,91.6 L64,101.5 L50,96 L36,101.5 L28.5,91.6 L14,91 L13.4,76.5 L2.5,67 L7,52.8 L0,40 L9.6,34 L8.1,19.3 L22.5,22.1 L26.8,7.3 L40.7,13.6 Z' fill='none' stroke='%23d4af37' stroke-width='3.5'/%3E%3Ccircle cx='50' cy='50' r='38' fill='none' stroke='%23d4af37' stroke-width='1.5' stroke-dasharray='4 2'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transform: translateY(-2px);
  white-space: nowrap;
  flex-shrink: 0;
  direction: ltr; /* Keeps Arabic numerals rendering left-to-right */
  unicode-bidi: isolate;
  padding-bottom: 1px; /* Align numerals visually in center of the ornament */
}

/* English Verses */
.ayah-text-english {
  font-size: var(--english-size);
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: left;
  direction: ltr;
}

.ayah-text-english.hidden {
  display: none;
}

/* ==========================================================================
   SCROLL SPINNER & STATUS INDICATORS
   ========================================================================== */

.infinite-scroll-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(212, 175, 55, 0.1);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: rotate-slow 1s infinite linear;
}

#scroll-sentinel {
  height: 50px;
  width: 100%;
}

/* ==========================================================================
   LOADING SKELETON SCREENS
   ========================================================================== */

.skeleton-list-item {
  height: 58px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.02) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}

[data-theme="light"] .skeleton-list-item {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.02) 25%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0.02) 75%);
  background-size: 200% 100%;
}

.skeleton-card {
  height: 200px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.02) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

[data-theme="light"] .skeleton-card {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.02) 25%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0.02) 75%);
  background-size: 200% 100%;
}

/* ==========================================================================
   TOAST NOTIFICATION COMPONENT
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-premium), var(--shadow-glow);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(100px);
  opacity: 0;
  animation: slide-up-fade-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  min-width: 250px;
}

.toast.success {
  border-color: var(--accent-emerald);
}

.toast.info {
  border-color: var(--accent-gold);
}

.toast.error {
  border-color: #ef4444;
}

.toast-icon {
  font-size: 1.1rem;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes rotate-slow {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.4;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(0.9);
    opacity: 0.4;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes slide-up-fade-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==========================================================================
   RESPONSIVE STYLING (RESPONSIVE GRID & DRAWERS)
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .close-sidebar-btn {
    display: flex;
  }

  .menu-toggle-btn {
    display: block;
  }

  .main-header {
    padding: 0 16px;
  }
}

@media (max-width: 768px) {
  .welcome-features {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .welcome-card {
    padding: 24px 16px;
  }

  .welcome-actions {
    flex-direction: column;
    gap: 8px;
  }

  .surah-banner {
    padding: 20px;
    margin-bottom: 24px;
  }

  .surah-banner-arabic {
    font-size: 2.2rem;
  }

  .surah-banner-english {
    font-size: 1.4rem;
  }

  .ayah-card {
    padding: 20px 16px;
  }

  .ayah-text-arabic {
    font-size: 28px;
    line-height: 1.8;
  }
}

/* Overlay behind drawer on mobile */
.sidebar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 95;
  transition: opacity 0.3s ease;
  display: none;
}

.sidebar-overlay.visible {
  display: block;
}

/* ==========================================================================
   THEME SELECTOR & VIEW MODE CONTROLS (NEW MODES)
   ========================================================================== */

/* Theme Palette Selector Grid */
.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.theme-option {
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--theme-preview-bg);
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
}

.theme-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.theme-option.active {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold);
}

.theme-option::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--theme-preview-color);
  font-size: 11px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.theme-option.active::after {
  opacity: 1;
}



/* ==========================================================================
   LANGUAGE TOGGLE SEGMENTED CAPSULE
   ========================================================================== */

.lang-visibility-selector {
  display: inline-flex;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  margin-right: 8px;
}

[data-theme="light"] .lang-visibility-selector {
  background-color: rgba(0, 0, 0, 0.04);
}

.lang-toggle-btn {
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  min-width: 32px;
  text-align: center;
}

.lang-toggle-btn:hover {
  color: var(--text-primary);
}

.lang-toggle-btn.active {
  background-color: var(--accent-gold);
  color: var(--bg-primary); /* Adapts to theme */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="sepia"] .lang-toggle-btn.active {
  color: #fdfaf2;
  background-color: var(--accent-emerald);
}

[data-theme="light"] .lang-toggle-btn.active {
  color: #ffffff;
  background-color: var(--primary-emerald);
}

/* Visibility Control overrides */
.hide-arabic .ayah-text-arabic {
  display: none !important;
}

.hide-arabic .bismillah-wrapper {
  display: none !important;
}

.hide-translation .ayah-text-english {
  display: none !important;
}

/* ==========================================================================
   PREMIUM MOBILE & PHONE STYLING OVERRIDES (Max Width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
  /* Sticky Header optimization for narrow screens */
  .main-header {
    padding: 0 10px !important;
    height: 60px !important;
  }
  
  .header-left {
    gap: 8px !important;
  }
  
  .menu-toggle-btn {
    padding: 4px !important;
  }
  
  .breadcrumb {
    max-width: 120px !important;
    gap: 4px !important;
  }
  
  .bc-section {
    font-size: 0.92rem !important;
  }
  
  .bc-divider {
    font-size: 0.7rem !important;
  }
  
  .bc-sub {
    font-size: 0.82rem !important;
  }

  /* Segmented language capsule layout */
  .lang-visibility-selector {
    margin-right: 4px !important;
    padding: 1px !important;
    border-radius: var(--radius-sm) !important;
  }
  
  .lang-toggle-btn {
    padding: 4px 8px !important;
    font-size: 0.65rem !important;
    min-width: 26px !important;
    border-radius: calc(var(--radius-sm) - 1px) !important;
  }

  /* Bookmark and Share icons */
  #btn-copy-link {
    padding: 6px !important;
  }
  
  #btn-copy-link svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* Resume Reading button: show only icon to save header space */
  .btn-resume {
    padding: 6px 8px !important;
    font-size: 0 !important;
    min-width: unset !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md) !important;
  }
  
  .btn-resume svg {
    margin-right: 0 !important;
    width: 16px !important;
    height: 16px !important;
  }

  /* Quran card view flow margins and padding */
  .quran-container {
    padding: 0 8px 80px 8px !important;
  }
  
  .ayah-card {
    padding: 16px 12px !important;
    margin-bottom: 16px !important;
  }
  
  .ayah-header {
    margin-bottom: 12px !important;
  }

  .ayah-key {
    font-size: 0.72rem !important;
  }

  .ayah-actions .action-btn {
    padding: 6px !important;
  }

  .ayah-actions .action-btn svg {
    width: 16px !important;
    height: 16px !important;
  }
  
  /* Traditional ornamental verse badge scaling */
  .ayah-number-badge {
    width: 38px !important;
    height: 38px !important;
    font-size: 11px !important;
    margin-left: 8px !important;
    margin-right: 8px !important;
  }

  /* Scale welcome and error screens dynamically */
  .welcome-card h2 {
    font-size: 1.6rem !important;
  }
  
  .welcome-card p {
    font-size: 0.9rem !important;
  }
}

/* ==========================================================================
   GLOBAL AUDIO RECITER & PLAY STATE HIGHLIGHTS
   ========================================================================== */
.select-wrapper {
  position: relative;
  width: 100%;
}

.settings-select {
  width: 100%;
  padding: 10px 16px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%23d4af37'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: var(--transition-smooth);
}

[data-theme="light"] .settings-select {
  background-color: rgba(0, 0, 0, 0.03);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%230b3a2f'/%3E%3C/svg%3E");
}

[data-theme="sepia"] .settings-select {
  background-color: rgba(0, 0, 0, 0.05);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%231b4d3e'/%3E%3C/svg%3E");
}

.settings-select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.15);
}

[data-theme="sepia"] .settings-select:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(27, 77, 62, 0.15);
}

[data-theme="light"] .settings-select:focus {
  border-color: var(--primary-emerald);
  box-shadow: 0 0 0 2px rgba(11, 58, 47, 0.15);
}

/* Beautiful audio playing state glow and borders */
.ayah-card.playing {
  border-left: 3px solid var(--accent-gold) !important;
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.15) !important;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.02) 0%, var(--bg-card) 100%) !important;
}

[data-theme="sepia"] .ayah-card.playing {
  border-left: 3px solid var(--accent-emerald) !important;
  box-shadow: 0 0 15px rgba(27, 77, 62, 0.15) !important;
  background: linear-gradient(90deg, rgba(27, 77, 62, 0.02) 0%, var(--bg-card) 100%) !important;
}

[data-theme="light"] .ayah-card.playing {
  border-left: 3px solid var(--primary-emerald) !important;
  box-shadow: 0 0 15px rgba(11, 58, 47, 0.1) !important;
  background: linear-gradient(90deg, rgba(11, 58, 47, 0.01) 0%, var(--bg-card) 100%) !important;
}

.ayah-actions .btn-play {
  color: var(--accent-gold) !important;
}

[data-theme="sepia"] .ayah-actions .btn-play {
  color: var(--accent-emerald) !important;
}

[data-theme="light"] .ayah-actions .btn-play {
  color: var(--primary-emerald) !important;
}