/* ============================================
   QURAN MEMORIZER — Islamic Themed Styles
   Inspired by Islamic geometric patterns,
   arabesque motifs, and traditional color palette
   ============================================ */

@font-face {
  font-family: 'UthmanicHafs';
  src: url('UthmanicHafs1 Ver16.ttf') format('truetype');
  font-display: swap;
}

/* ---------- CSS Variables ---------- */
:root {
  /* Primary palette - inspired by Islamic art */
  --navy: #0a1628;
  --navy-light: #101e36;
  --navy-mid: #1a2d4a;
  --teal: #1a6b5a;
  --teal-light: #2a8b76;
  --teal-glow: rgba(26, 107, 90, 0.3);
  --gold: #c9a84c;
  --gold-light: #e8c65a;
  --gold-dark: #a8882e;
  --gold-glow: rgba(201, 168, 76, 0.25);
  --cream: #f5efe0;
  --cream-light: #faf5ea;
  --parchment: #e8dcc8;
  --burgundy: #6b1d2f;
  --burgundy-light: #8a2a3f;
  --white-soft: rgba(255, 255, 255, 0.92);
  --white-muted: rgba(255, 255, 255, 0.7);
  --white-dim: rgba(255, 255, 255, 0.4);

  /* Shadows */
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 40px rgba(201, 168, 76, 0.1);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.2);

  /* Typography */
  --font-arabic: 'UthmanicHafs', 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif;
  --font-ui: 'Poppins', 'Segoe UI', sans-serif;

  /* Borders */
  --border-gold: 1px solid rgba(201, 168, 76, 0.3);
  --border-gold-strong: 1px solid rgba(201, 168, 76, 0.6);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--navy);
  color: var(--white-soft);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ---------- Background Pattern ---------- */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* Geometric star pattern using radial gradients */
    radial-gradient(2px 2px at 20% 30%, rgba(201, 168, 76, 0.08) 0%, transparent 100%),
    radial-gradient(2px 2px at 40% 70%, rgba(201, 168, 76, 0.06) 0%, transparent 100%),
    radial-gradient(2px 2px at 60% 20%, rgba(201, 168, 76, 0.08) 0%, transparent 100%),
    radial-gradient(2px 2px at 80% 50%, rgba(201, 168, 76, 0.06) 0%, transparent 100%),
    radial-gradient(2px 2px at 30% 85%, rgba(201, 168, 76, 0.07) 0%, transparent 100%),
    radial-gradient(2px 2px at 70% 90%, rgba(201, 168, 76, 0.05) 0%, transparent 100%),
    /* Subtle geometric lines */
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 80px,
      rgba(201, 168, 76, 0.02) 80px,
      rgba(201, 168, 76, 0.02) 81px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 80px,
      rgba(201, 168, 76, 0.02) 80px,
      rgba(201, 168, 76, 0.02) 81px
    );
  background-color: var(--navy);
}

/* ---------- App Container ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================
   HEADER — Islamic Ornamental Design
   ============================================ */
.header {
  padding: 24px 0 16px;
  position: relative;
}

.header-ornament {
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold) 20%,
    var(--gold-light) 50%,
    var(--gold) 80%,
    transparent 100%
  );
  border-radius: 2px;
  opacity: 0.6;
}

.top-ornament {
  margin-bottom: 20px;
}

.bottom-ornament {
  margin-top: 20px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  font-family: var(--font-arabic);
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 20px var(--gold-glow);
}

.app-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--white-soft);
  letter-spacing: 0.02em;
}

.app-subtitle {
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  color: var(--gold);
  opacity: 0.8;
  margin-top: 2px;
}

/* Progress Summary */
.progress-summary {
  display: flex;
  gap: 20px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: var(--border-gold);
  border-radius: 12px;
  padding: 10px 20px;
  backdrop-filter: blur(10px);
}

.progress-stat {
  text-align: center;
  padding: 0 8px;
  position: relative;
}

.progress-stat + .progress-stat::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 24px;
  background: linear-gradient(to bottom, transparent, rgba(201, 168, 76, 0.3), transparent);
}

.stat-number {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--white-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   MAIN CONTENT — Page & Ayah Sidebar
   ============================================ */
.main-content {
  display: flex;
  gap: 24px;
  flex: 1;
  padding: 12px 0 20px;
  align-items: flex-start;
}

/* ---------- Page Viewer ---------- */
.page-viewer {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.page-frame {
  max-width: 720px;
  width: 100%;
  position: relative;
  transition: padding-bottom 0.3s ease;
}

.page-frame.teacher-active {
  padding-bottom: 65vh; /* Allows scrolling bottom ayahs all the way to the top */
}

.page-border {
  position: relative;
  background: linear-gradient(135deg, var(--navy-light), var(--navy-mid));
  border: var(--border-gold);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  overflow: hidden;
}

/* Corner ornaments */
.page-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 5;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.7;
}
.page-corner.tl { top: 6px; left: 6px; border-width: 2px 0 0 2px; border-radius: 3px 0 0 0; }
.page-corner.tr { top: 6px; right: 6px; border-width: 2px 2px 0 0; border-radius: 0 3px 0 0; }
.page-corner.bl { bottom: 6px; left: 6px; border-width: 0 0 2px 2px; border-radius: 0 0 0 3px; }
.page-corner.br { bottom: 6px; right: 6px; border-width: 0 2px 2px 0; border-radius: 0 0 3px 0; }

.page-image-container {
  position: relative;
  border-radius: 5px;
  overflow: hidden;
  background: var(--parchment);
  aspect-ratio: 0.7; /* Standard Quran page ratio */
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size; /* Enables container query units: cqw & cqh */
}

.page-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.3s ease;
}

.page-image.loading {
  opacity: 0;
}

/* ---------- Text Overlay Mode (Medina Alignment) ---------- */
.page-text-overlay {
  position: absolute;
  inset: 0;
  padding: 8.7% 10% 10.3% 10%; /* Shifted up by 0.8% for perfect Medina alignment */
  display: block;
  direction: rtl;
  z-index: 5;
  opacity: 1; /* Always active to show transparent highlight blocks over calligraphy */
  pointer-events: none; /* Pointer events pass through in Image Mode */
  transition: all 0.3s ease;
  box-sizing: border-box;
  font-family: var(--font-arabic);
  font-size: 3.4cqw; /* Viewport-container relative scaling */
  line-height: 1;
}

.page-text-overlay.active {
  opacity: 1;
  pointer-events: auto;
  background: var(--navy);
  background-image: radial-gradient(circle at center, var(--navy-light) 0%, var(--navy) 100%);
  overflow-y: hidden;
}

.text-overlay-content {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Special scaling and margins for pages 1 and 2 */
.text-overlay-content.page-1-2 {
  padding: 16% 15%;
  font-size: 4.8cqw;
}

.text-overlay-content.page-1 {
  transform: translateY(-4.5%) !important;
}

.mushaf-line {
  display: block;
  text-align: justify;
  text-align-last: justify;
  direction: rtl;
  width: 100%;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.mushaf-line.header-line {
  text-align: center;
  text-align-last: center;
  font-weight: 700;
  font-size: 3.8cqw;
  color: var(--gold-light);
}

.mushaf-line.basmalah-line {
  text-align: center;
  text-align-last: center;
  font-size: 3.5cqw;
}

.ayah-number-digit {
  font-family: var(--font-arabic);
  color: var(--gold-light);
  font-size: 0.8em;
  margin-right: 4px;
  display: inline-block;
  vertical-align: middle;
  transition: color 0.15s ease;
}

.page-image-container.hide-image .page-image {
  opacity: 0.15 !important;
}

/* If Memory Mode runs simultaneously with Text Mode, hide the parchment bg to keep the dark theme */
.page-image-container.hide-image .memory-overlay-bg {
  opacity: 0 !important;
}

/* Hide the text in memory mode so the user can test their memory */
.page-image-container.memory-mode .text-overlay-content {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Reveal the text when peeking in memory mode */
.page-image-container.memory-mode.peek-faded .text-overlay-content,
.page-image-container.memory-mode.peek-faded-hover .text-overlay-content {
  opacity: 0.15 !important;
}

.page-image-container.memory-mode.peek-clear .text-overlay-content,
.page-image-container.memory-mode.peek-clear-hover .text-overlay-content {
  opacity: 1 !important;
}

.text-overlay-content {
  font-family: var(--font-arabic);
  font-size: inherit;
  line-height: inherit;
  color: var(--cream-light);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.ayah-marker-inline {
  color: var(--gold);
  margin: 0 4px;
  font-size: 1.1em;
  white-space: nowrap;
}

.toggle-text-btn.active,
.theme-toggle-btn.active,
.toggle-hints-btn.active {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 0 10px rgba(201, 168, 76, 0.1);
}

.toggle-text-btn:hover,
.theme-toggle-btn:hover,
.toggle-hints-btn:hover {
  background: rgba(201, 168, 76, 0.12) !important;
  border-color: var(--gold) !important;
  color: var(--gold-light) !important;
}

/* Loading overlay */
.page-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10, 22, 40, 0.85);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2;
  transition: opacity 0.3s ease;
}

.page-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(201, 168, 76, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Page number badge */
.page-number-badge {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-dark));
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 12px rgba(201, 168, 76, 0.3);
  z-index: 5;
}

.page-label {
  opacity: 0.8;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

/* ---------- Sidebar Wrapper & Ayah Sidebar ---------- */
.sidebar-wrapper {
  width: 440px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 24px;
  margin-top: 12px;
}

.ayah-sidebar {
  width: 100%;
  background: linear-gradient(180deg, rgba(16, 30, 54, 0.95), rgba(10, 22, 40, 0.98));
  border: var(--border-gold);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
  min-height: 0;
  backdrop-filter: blur(10px);
}

.sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.01em;
}

.sidebar-subtitle {
  font-size: 0.72rem;
  color: var(--white-dim);
  margin-top: 4px;
}

.sidebar-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--white-muted);
  font-weight: 500;
  min-width: 40px;
  text-align: right;
}

/* Voice Engine Initialization Progress */
.global-index-progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.3s ease;
}

.page-top-progress {
  margin-bottom: 16px;
  background: rgba(10, 22, 40, 0.85);
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.global-index-progress-container.hidden {
  display: none;
}

.global-index-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.global-index-title {
  font-size: 0.7rem;
  color: var(--teal-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.global-index-text {
  font-size: 0.7rem;
  color: var(--white-muted);
  font-weight: 500;
}

.global-index-fill {
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
}

/* Ayah List */
.ayah-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, 0.2) transparent;
}

.ayah-list::-webkit-scrollbar {
  width: 4px;
}
.ayah-list::-webkit-scrollbar-track {
  background: transparent;
}
.ayah-list::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.2);
  border-radius: 4px;
}

.ayah-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--white-dim);
  gap: 8px;
}

.ayah-list-empty .empty-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* ---------- Ayah Card ---------- */
.ayah-card {
  background: linear-gradient(135deg, rgba(26, 45, 74, 0.6), rgba(16, 30, 54, 0.8));
  border: 1px solid rgba(201, 168, 76, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.ayah-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(201, 168, 76, 0.03));
  border-radius: 10px;
  pointer-events: none;
}

.ayah-card:hover {
  border-color: rgba(201, 168, 76, 0.3);
  background: linear-gradient(135deg, rgba(26, 45, 74, 0.8), rgba(16, 30, 54, 0.9));
  transform: translateX(2px);
}

.ayah-card:active {
  transform: translateX(0) scale(0.99);
}

/* Ayah card header - number + surah info */
.ayah-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ayah-number-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--navy);
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.2);
  transition: all 0.3s ease;
}

.ayah-card.revealed .ayah-number-badge {
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  box-shadow: 0 2px 8px rgba(26, 107, 90, 0.2);
}

.ayah-surah-info {
  font-size: 0.7rem;
  color: var(--white-dim);
}

.ayah-number-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
}

/* Ayah text container */
.ayah-text-container {
  position: relative;
  min-height: 24px;
}

.ayah-text {
  font-family: var(--font-arabic);
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  line-height: 2;
  color: var(--cream-light);
  text-align: right;
  direction: rtl;
  transition: all 0.4s ease;
}

body.memory-mode-active .ayah-text.hidden {
  filter: blur(8px);
  color: transparent;
  text-shadow: 0 0 12px rgba(245, 239, 224, 0.15);
  user-select: none;
  min-height: 1.8em;
  /* Hide the text content behind the blur */
  position: relative;
}

/* Decorative brackets behind the blur - visible enough to indicate hidden text */
body.memory-mode-active .ayah-text.hidden::before {
  content: '﴿';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: rgba(201, 168, 76, 0.12);
  filter: none;
}

body.memory-mode-active .ayah-text.hidden::after {
  content: '﴾';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: rgba(201, 168, 76, 0.12);
  filter: none;
}

.ayah-text.revealed {
  filter: blur(0);
  color: var(--cream-light);
  text-shadow: none;
  user-select: text;
}

/* Reveal animation */
.ayah-card.revealed {
  border-color: rgba(26, 107, 90, 0.3);
  background: linear-gradient(135deg, rgba(26, 107, 90, 0.08), rgba(16, 30, 54, 0.8));
}

body.memory-mode-active .ayah-card.revealed .ayah-text {
  animation: revealText 0.4s ease forwards;
}

@keyframes revealText {
  0% {
    filter: blur(8px);
    opacity: 0.3;
  }
  60% {
    filter: blur(0);
    opacity: 0.8;
  }
  100% {
    filter: blur(0);
    opacity: 1;
  }
}

/* Click hint */
.ayah-click-hint {
  display: none;
  font-size: 0.65rem;
  color: var(--white-dim);
  text-align: center;
  margin-top: 4px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

body.memory-mode-active .ayah-click-hint {
  display: block;
}

.ayah-card:hover .ayah-click-hint {
  opacity: 1;
}

.ayah-card.revealed .ayah-click-hint {
  display: none;
}

/* ============================================
   BOTTOM CONTROLS — Navigation
   ============================================ */
.bottom-controls {
  padding: 14px 0 20px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--navy) 60%, transparent);
  z-index: 10;
  width: 100%;
  max-width: 720px;
}

.controls-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(16, 30, 54, 0.95);
  border: var(--border-gold);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  flex-wrap: wrap;
}

/* Control buttons */
.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 10px;
  background: transparent;
  color: var(--white-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold);
  border-color: rgba(201, 168, 76, 0.4);
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(0) scale(0.95);
}

.control-btn.primary {
  width: 48px;
  height: 44px;
  border-color: rgba(201, 168, 76, 0.3);
  color: var(--gold);
}

.control-btn.primary:hover {
  background: rgba(201, 168, 76, 0.15);
  box-shadow: 0 0 20px var(--gold-glow);
}

/* Page jumper */
.page-jumper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 10px;
  padding: 2px;
}

.jumper-btn {
  color: var(--white-dim);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

.page-input {
  width: 60px;
  padding: 6px 8px;
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 6px;
  color: var(--white-soft);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease;
}

.page-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

/* Hide number input spinners */
.page-input::-webkit-inner-spin-button,
.page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.page-input[type=number] {
  -moz-appearance: textfield;
}

.go-btn {
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border: none;
  border-radius: 7px;
  color: #ffffff !important;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.go-btn:hover {
  box-shadow: 0 0 16px var(--gold-glow);
  transform: translateY(-1px);
}

.go-btn:active {
  transform: translateY(0);
}

/* Divider */
.controls-divider {
  width: 1px;
  height: 28px;
  background: linear-gradient(to bottom, transparent, rgba(201, 168, 76, 0.3), transparent);
  margin: 0 4px;
}

/* Action buttons */
.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 10px;
  background: transparent;
  color: var(--white-muted);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.reveal-all-btn:hover {
  background: rgba(26, 107, 90, 0.15);
  border-color: var(--teal);
  color: var(--teal-light);
}

.reset-btn:hover {
  background: rgba(107, 29, 47, 0.15);
  border-color: var(--burgundy);
  color: #d45a6f;
}

.surah-btn:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold);
  color: var(--gold-light);
}

/* Listen Mode Button */
/* Pause Listen Button */
.pause-listen-btn.hidden {
  display: none !important;
}

/* ---------- System Toast ---------- */
.system-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(10, 22, 40, 0.9);
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: var(--gold-light);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.system-toast.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.toast-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(201, 168, 76, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.system-toast.success .toast-spinner {
  display: none;
}
.system-toast.success::before {
  content: '✓';
  color: var(--teal-light);
  font-weight: bold;
  font-size: 1.1rem;
}

/* ---------- Keyboard shortcuts hint ---------- */
.shortcuts-hint {
  text-align: center;
  padding: 8px 0 20px;
  font-size: 0.7rem;
  color: var(--white-dim);
  opacity: 0.5;
  letter-spacing: 0.03em;
}

.hint-dot {
  margin: 0 6px;
  opacity: 0.3;
}

/* ============================================
   MEMORY TEST MODE
   ============================================ */
/* Hide image when memory mode is active */
.page-image-container.memory-mode .page-image {
  opacity: 0 !important;
}

.memory-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.memory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.memory-overlay-bg {
  position: absolute;
  inset: 0;
  background: var(--parchment);
  transition: opacity 0.3s ease;
}

.memory-circles {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2;
}

.memory-circle {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.4);
  transition: all 0.2s ease;
  user-select: none;
}

.memory-circle:hover {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 6px 16px rgba(201, 168, 76, 0.6);
  z-index: 50;
}

.circle-number {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--burgundy);
  color: var(--cream-light);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.circle-hint {
  font-family: var(--font-arabic);
  font-size: 1.3rem;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  color: inherit;
  transition: opacity 0.2s ease;
}

/* Marquee Scrolling Text */
.global-marquee {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 260px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  background: rgba(10, 22, 40, 0.95);
  color: var(--gold-light);
  padding: 6px 0;
  border-radius: 25px;
  border: 1px solid rgba(201, 168, 76, 0.6);
  direction: rtl; /* RTL container for correct Arabic scrolling */
  transition: opacity 0.2s ease, left 0.3s ease, top 0.3s ease;
  z-index: 20;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.global-marquee.active {
  opacity: 1;
}

.marquee-text {
  display: inline-block;
  padding-left: 260px; /* Empty space at the end so it fully clears the screen leftwards */
  font-family: var(--font-arabic);
  font-size: 1.5rem;
  line-height: 1.4;
  direction: rtl; /* Real text direction */
  /* Animation properties are now applied dynamically via JS to ensure infinite looping and resets */
}

@keyframes marquee-scroll-rtl {
  0% { transform: translateX(0); } /* Starts right-aligned, first word immediately visible */
  100% { transform: translateX(-100%); } /* Scrolls naturally right-to-left */
}

.memory-circle:hover .circle-hint {
  opacity: 0;
}

.memory-circle:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.memory-circle.revealed {
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  color: var(--white-soft);
  box-shadow: 0 2px 8px rgba(26, 107, 90, 0.3);
  opacity: 0.8;
  z-index: 10;
}

.memory-banner {
  position: fixed;
  top: 100px;
  left: calc(50% - 232px); /* Centers perfectly over the image taking the sidebar width into account */
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(26, 45, 74, 0.95), rgba(16, 30, 54, 0.98));
  border: var(--border-gold);
  color: var(--gold);
  padding: 8px 20px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 90;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}

.peek-controls {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  border-left: 1px solid rgba(201, 168, 76, 0.3);
  padding-left: 12px;
}

.peek-btn {
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.peek-btn:hover, .peek-btn:active {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
}

.peek-btn.active {
  background: rgba(201, 168, 76, 0.25);
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: inset 0 0 8px rgba(201, 168, 76, 0.2);
}

/* Peek states overriding memory mode */
.page-image-container.memory-mode.peek-faded .page-image {
  opacity: 0.15 !important;
}
.page-image-container.memory-mode.peek-faded .memory-overlay-bg {
  opacity: 0;
}

.page-image-container.memory-mode.peek-clear .page-image {
  opacity: 1 !important;
}
.page-image-container.memory-mode.peek-clear .memory-overlay-bg {
  opacity: 0;
}
.page-image-container.memory-mode.peek-clear .memory-circle {
  opacity: 0.15;
  pointer-events: none;
}

/* Hover states take precedence over active toggle states */
.page-image-container.memory-mode.peek-faded-hover .page-image {
  opacity: 0.15 !important;
}
.page-image-container.memory-mode.peek-faded-hover .memory-overlay-bg {
  opacity: 0;
}

.page-image-container.memory-mode.peek-clear-hover .page-image {
  opacity: 1 !important;
}
.page-image-container.memory-mode.peek-clear-hover .memory-overlay-bg {
  opacity: 0;
}
.page-image-container.memory-mode.peek-clear-hover .memory-circle {
  opacity: 0.15;
  pointer-events: none;
}

.memory-circle.dragging {
  cursor: grabbing !important;
  box-shadow: 0 12px 24px rgba(201, 168, 76, 0.8);
  transform: translate(-50%, -50%) scale(1.2) !important;
  z-index: 100;
  transition: none !important;
}

/* Hide marquee and restore hint if dragging */
.memory-circle.dragging .circle-hint {
  opacity: 1 !important;
}

.memory-icon {
  font-size: 1.2rem;
}

/* Update memory mode button active state */
.memory-mode-btn.active {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 0 10px rgba(201, 168, 76, 0.1);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
    align-items: center;
  }
  .memory-banner {
    left: 50%;
    top: 160px; /* Accounts for stacked header height on tablets */
  }
  .ayah-sidebar {
    width: 100%;
    max-width: 720px;
    max-height: none;
    position: static;
  }
  .ayah-list {
    max-height: 300px;
  }
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  .logo-area {
    justify-content: center;
  }
}

/* Phone */
@media (max-width: 600px) {
  .app-container {
    padding: 0 10px;
  }
  .header {
    padding: 16px 0 12px;
  }
  .memory-banner {
    top: 130px; /* Accounts for compact header height on phones */
  }
  .app-title {
    font-size: 1.2rem;
  }
  .logo-icon {
    font-size: 1.5rem;
  }
  .progress-summary {
    padding: 8px 14px;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .stat-number {
    font-size: 1rem;
  }
  .stat-label {
    font-size: 0.6rem;
  }
  .progress-stat + .progress-stat::before {
    display: none;
  }
  .controls-inner {
    padding: 8px 12px;
    gap: 6px;
  }
  .control-btn {
    width: 36px;
    height: 36px;
  }
  .control-btn.primary {
    width: 42px;
    height: 40px;
  }
  .page-input {
    width: 50px;
    font-size: 0.8rem;
  }
  .action-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
  }
  .action-btn span {
    display: none; /* Hide text, show only icon on mobile */
  }
  .ayah-sidebar {
    border-radius: 8px;
  }
  .ayah-text {
    font-size: 1.3rem;
  }
  .shortcuts-hint {
    display: none;
  }
  .page-border {
    padding: 3px;
  }
  .page-corner {
    width: 16px;
    height: 16px;
  }
}

/* ============================================
   SURAH INDEX — Right-Side Panel
   ============================================ */
.surah-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 10, 20, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.surah-panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.surah-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 101;
  width: min(460px, calc(100vw - 48px));
  background: linear-gradient(180deg, var(--navy-light) 0%, var(--navy) 100%);
  border-left: 1px solid rgba(201, 168, 76, 0.25);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.surah-panel.open {
  transform: translateX(0);
}

/* Decorative top border on the panel */
.surah-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold) 20%,
    var(--gold-light) 50%,
    var(--gold) 80%,
    transparent 100%
  );
  opacity: 0.5;
}

.surah-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
  flex-shrink: 0;
}

.surah-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
}

.surah-panel-icon {
  font-size: 1.2rem;
}

.surah-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 8px;
  background: transparent;
  color: var(--white-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.surah-panel-close:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold);
  border-color: rgba(201, 168, 76, 0.4);
}

.surah-panel-search {
  padding: 12px 20px;
  flex-shrink: 0;
}

.surah-search-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 10px;
  color: var(--white-soft);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.surah-search-input::placeholder {
  color: var(--white-dim);
}

.surah-search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.surah-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, 0.2) transparent;
}

.surah-list::-webkit-scrollbar {
  width: 4px;
}
.surah-list::-webkit-scrollbar-track {
  background: transparent;
}
.surah-list::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.2);
  border-radius: 4px;
}

.surah-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.surah-item:hover {
  background: rgba(201, 168, 76, 0.06);
  border-color: rgba(201, 168, 76, 0.15);
  transform: translateX(2px);
}

.surah-item:active {
  transform: translateX(0);
}

.surah-item:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.surah-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(201, 168, 76, 0.12);
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.surah-name-en {
  font-size: 0.85rem;
  color: var(--white-soft);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surah-name-ar {
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  color: var(--gold);
  opacity: 0.7;
  flex-shrink: 0;
  direction: rtl;
}

.surah-page {
  font-size: 0.7rem;
  color: var(--white-dim);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

.surah-list-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--white-dim);
  font-size: 0.85rem;
}

/* Mobile adjustments for surah panel */
@media (max-width: 600px) {
  .surah-panel {
    width: calc(100vw - 32px);
  }
  .surah-panel-header {
    padding: 16px 16px 12px;
  }
  .surah-panel-search {
    padding: 10px 16px;
  }
  .surah-list {
    padding: 0 10px 10px;
  }
  .surah-item {
    padding: 8px 10px;
  }
  .surah-name-en {
    font-size: 0.8rem;
  }
}

/* ============================================
   ENGLISH TRANSLATION TEXT
   ============================================ */
.ayah-translation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(201, 168, 76, 0.12);
  transition: all 0.4s ease;
}

body.memory-mode-active .ayah-translation.hidden {
  display: none;
}

body.memory-mode-active .ayah-translation.revealed {
  animation: fadeInTranslation 0.5s ease forwards;
}

@keyframes fadeInTranslation {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.translation-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-light);
  margin-bottom: 6px;
  opacity: 0.8;
}

.translation-text {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--cream);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
}

.ayah-card.revealed .translation-text {
  color: var(--cream-light);
}

/* ============================================
   SURAH SORT CONTROLS
   ============================================ */
.surah-sort-controls {
  display: flex;
  gap: 4px;
  padding: 0 20px 10px;
  flex-shrink: 0;
}

.sort-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid rgba(201, 168, 76, 0.12);
  border-radius: 8px;
  background: transparent;
  color: var(--white-dim);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-btn:hover {
  background: rgba(201, 168, 76, 0.08);
  border-color: rgba(201, 168, 76, 0.25);
  color: var(--white-muted);
}

.sort-btn.active {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold);
  color: var(--gold);
}

.sort-btn svg {
  flex-shrink: 0;
}

/* Surah length badge */
.surah-length {
  font-size: 0.65rem;
  color: var(--teal-light);
  font-weight: 600;
  background: rgba(26, 107, 90, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  min-width: 30px;
  text-align: center;
}

.surah-item:hover .surah-length {
  background: rgba(26, 107, 90, 0.2);
}

@media (max-width: 600px) {
  .surah-sort-controls {
    padding: 0 16px 8px;
    gap: 3px;
  }
  .sort-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
  }
  .sort-btn span {
    display: none; /* Show only icons on mobile */
  }
  .surah-length {
    font-size: 0.6rem;
    padding: 1px 5px;
    min-width: 24px;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ayah-card {
  animation: fadeInUp 0.3s ease forwards;
  opacity: 0;
}

/* ============================================
   LISTEN MODE WAVEFORM & INDICATOR
   ============================================ */
.waveform-container {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.waveform-container.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.waveform-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 12px;
  background: rgba(10, 22, 40, 0.85);
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.waveform-bar {
  width: 3px;
  background: linear-gradient(to top, #c9a84c, #ffd700) !important;
  border-radius: 2px;
  transform-origin: bottom;
  transition: height 0.05s ease-out; /* Smooth height changes for live audio */
  height: 4px; /* Base resting height */
  box-shadow: 0 0 4px rgba(255, 215, 0, 0.5) !important;
}

.waveform-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.waveform-bar:nth-child(2) { height: 18px; animation-delay: 0.08s; }
.waveform-bar:nth-child(3) { height: 22px; animation-delay: 0.16s; }
.waveform-bar:nth-child(4) { height: 26px; animation-delay: 0.04s; }
.waveform-bar:nth-child(5) { height: 24px; animation-delay: 0.12s; }
.waveform-bar:nth-child(6) { height: 20px; animation-delay: 0.2s; }
.waveform-bar:nth-child(7) { height: 15px; animation-delay: 0.06s; }
.waveform-bar:nth-child(8) { height: 10px; animation-delay: 0.14s; }

@keyframes waveform-bounce {
  0% { height: 4px; opacity: 0.6; }
  50% { opacity: 1; }
  100% { height: 28px; opacity: 0.8; }
}

.listen-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(10, 22, 40, 0.95);
  border: 1px solid rgba(201, 168, 76, 0.45);
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: #ffffff !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.listen-indicator.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.listen-indicator.pulse {
  animation: listen-pulse 0.3s ease;
}

@keyframes listen-pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.6); transform: scale(1); }
  50% { box-shadow: 0 0 20px 4px rgba(201, 168, 76, 0.3); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0); transform: scale(1); }
}

.listen-label {
  color: #ffffff !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
}

.listen-word {
  font-size: 0.9rem;
  color: #f5efe0 !important;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-arabic);
}

.listen-confidence {
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 30px;
  text-align: right;
  color: rgba(255, 255, 255, 0.6) !important;
}

/* ---------- Improved Word Highlighting ---------- */
/* Image Mode (default transparent text overlay) */
.page-text-overlay:not(.active) .word {
  color: transparent !important;
  text-shadow: none !important;
  background: transparent;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  border-radius: 3px;
  position: relative;
  pointer-events: auto;
  cursor: pointer;
}

.page-text-overlay:not(.active) .ayah-number-digit {
  color: transparent !important;
  text-shadow: none !important;
}

.page-text-overlay:not(.active) .word.highlighted {
  background: rgba(201, 168, 76, 0.45) !important;
  color: transparent !important;
  text-shadow: none !important;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.35);
}

/* Text Mode (active text overlay) */
.page-text-overlay.active .word {
  color: var(--cream);
  cursor: pointer;
  border-radius: 4px;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.page-text-overlay.active .word:hover {
  background: rgba(255, 255, 255, 0.05);
}

.page-text-overlay.active .word.highlighted {
  background: linear-gradient(135deg, var(--gold-light), var(--gold)) !important;
  color: var(--navy) !important;
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.6);
  transform: scale(1.03);
}

.word.just-matched {
  animation: word-match-flash 0.4s ease;
}

@keyframes word-match-flash {
  0% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.8); }
  50% { box-shadow: 0 0 25px 8px rgba(201, 168, 76, 0.3); }
  100% { box-shadow: 0 0 12px rgba(201, 168, 76, 0.5); }
}

/* ============================================
   RECORDING BUTTON IMPROVEMENTS
   ============================================ */
.listen-mode-btn.active {
  background: rgba(255, 71, 87, 0.1);
  border-color: #ff4757;
  color: #ff4757;
}

.listen-mode-btn.recording {
  color: #ff4757;
  border-color: #ff4757;
  animation: live-listening-pulse 1.4s ease-in-out infinite alternate;
  background: rgba(255, 71, 87, 0.15) !important;
}

@keyframes live-listening-pulse {
  0% {
    box-shadow: 0 0 5px rgba(255, 71, 87, 0.3);
    background: rgba(255, 71, 87, 0.08) !important;
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 18px 6px rgba(255, 71, 87, 0.6);
    background: rgba(255, 71, 87, 0.25) !important;
    transform: scale(1.05);
  }
}

.word.just-matched {
  animation: word-match-flash 0.4s ease;
}

@keyframes word-match-flash {
  0% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.8); }
  50% { box-shadow: 0 0 25px 8px rgba(201, 168, 76, 0.3); transform: scale(1.06); }
  100% { box-shadow: 0 0 12px rgba(201, 168, 76, 0.5); transform: scale(1.03); }
}

/* ============================================
   THEMATIC MEMORIZER TEACHER STYLES
   ============================================ */
.sidebar-tabs {
  display: flex;
  background: var(--navy-light);
  border-bottom: var(--border-gold);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  flex-wrap: wrap;
}

.sidebar-tab {
  flex: 1 1 auto;
  min-width: 140px;
  background: transparent;
  border: none;
  color: var(--white-muted);
  padding: 12px 6px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-tab:hover {
  color: var(--gold-light);
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-tab.active {
  color: var(--gold) !important;
  background: rgba(201, 168, 76, 0.12) !important;
  border-bottom: 3px solid var(--gold) !important;
  font-weight: 800 !important;
  text-shadow: 0 0 10px rgba(201, 168, 76, 0.3) !important;
}

.sidebar-section {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-section.active {
  display: flex;
}

.teacher-group-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Thematic Group Cards */
.teacher-card {
  background: linear-gradient(145deg, var(--navy-light), var(--navy-mid));
  border: var(--border-gold);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.teacher-card:hover {
  border-color: var(--gold-light);
  box-shadow: 0 4px 15px rgba(201, 168, 76, 0.15);
}

.teacher-card.playing {
  border-color: var(--teal-light);
  box-shadow: 0 0 15px var(--teal-glow);
}

.teacher-card.practicing {
  border-color: var(--gold-light);
  box-shadow: 0 0 15px var(--gold-glow);
}

.teacher-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.teacher-card-theme {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  color: var(--gold-light);
  line-height: 1.3;
}

.teacher-card-subtitle {
  font-size: 0.75rem;
  color: var(--white-muted);
}

.teacher-card-desc {
  font-size: 0.8rem;
  color: var(--white-soft);
  line-height: 1.4;
  margin-top: 4px;
}

.teacher-range-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 22, 40, 0.4);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 4px;
}

.range-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--white-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.range-dropdowns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-select {
  background: var(--navy-mid) !important;
  color: var(--cream) !important;
  border: 1px solid rgba(201, 168, 76, 0.3) !important;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.72rem;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.range-select:hover, .range-select:focus {
  border-color: var(--gold-light) !important;
}

.range-to {
  font-size: 0.72rem;
  color: var(--white-muted);
}

.teacher-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.teacher-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  background: rgba(10, 22, 40, 0.5);
  color: var(--white-soft);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.teacher-btn:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold-light);
  border-color: var(--gold-light);
}

.teacher-btn.active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
  font-weight: 600;
}

.teacher-btn.active-practice {
  background: var(--teal);
  color: var(--cream);
  border-color: var(--teal);
  font-weight: 600;
}

/* Loop Recitation Pulse Glow */
.word.playing-ayah {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  animation: none !important;
}


@keyframes play-pulse {
  0% { box-shadow: 0 0 4px rgba(42, 139, 118, 0.2); }
  100% { box-shadow: 0 0 14px rgba(42, 139, 118, 0.65); }
}

/* Masking overlays for practice mode */
.word.practice-hidden {
  color: transparent !important;
  text-shadow: none !important;
  background: rgba(10, 22, 40, 0.98) !important;
  border-radius: 4px;
}

.page-text-overlay:not(.active) .word.practice-hidden {
  /* Masks the calligraphy underneath in Image Mode */
  background: var(--parchment) !important;
  color: transparent !important;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.05);
  padding: 3px 6px !important;
  margin: -3px -6px !important;
  border-radius: 4px;
}

/* Correct recitation highlight inside Practice Mode */
.word.practice-success {
  background: linear-gradient(135deg, rgba(26, 107, 90, 0.9), rgba(42, 139, 118, 0.85)) !important;
  color: var(--white-soft) !important;
  box-shadow: 0 0 10px rgba(42, 139, 118, 0.5);
  text-shadow: none !important;
}

.page-text-overlay:not(.active) .word.practice-success {
  background: transparent !important;
  border: none !important;
  color: #2bd997 !important; /* Mint green text in dark mode */
  box-shadow: none !important;
  text-shadow: 0 0 2px rgba(43, 217, 151, 0.5) !important;
  padding: 3px 6px !important;
  margin: -3px -6px !important;
  border-radius: 4px;
}

body.light-mode .page-text-overlay:not(.active) .word.practice-success {
  background: transparent !important;
  border: none !important;
  color: var(--teal) !important; /* Emerald green text in light mode */
  box-shadow: none !important;
  text-shadow: none !important;
  padding: 3px 6px !important;
  margin: -3px -6px !important;
  border-radius: 4px;
}

/* Progress bar inside cards */
.teacher-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.teacher-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.teacher-progress-fill {
  height: 100%;
  background: var(--teal-light);
  width: 0%;
  transition: width 0.3s ease;
}

.teacher-status-banner {
  font-size: 0.75rem;
  color: var(--gold-light);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(201, 168, 76, 0.05);
  border-radius: 4px;
  border-left: 2px solid var(--gold);
}

/* Individual Ayah Play Button */
.ayah-play-btn {
  background: rgba(201, 168, 76, 0.2);
  border: 2px solid var(--gold);
  color: var(--gold-light);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.25);
}

.ayah-play-btn:hover {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold-light);
  transform: scale(1.12);
  box-shadow: 0 0 16px rgba(201, 168, 76, 0.5);
}

.ayah-play-btn.playing {
  background: var(--teal);
  color: var(--cream);
  border-color: var(--teal-light);
  box-shadow: 0 0 12px rgba(42, 139, 118, 0.4);
}

/* ---------- Sidebar Audio Player Widget ---------- */
.sidebar-audio-player {
  background: linear-gradient(135deg, var(--navy-light), var(--navy-mid));
  border-bottom: var(--border-gold);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slide-down 0.3s ease;
}

@keyframes slide-down {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sidebar-audio-player.hidden {
  display: none !important;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--gold);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
}

.player-close-btn {
  background: transparent;
  border: none;
  color: var(--white-dim);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.player-close-btn:hover {
  color: var(--gold-light);
}

.player-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-ayah-label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gold-light);
}

.player-reciter {
  font-size: 0.75rem;
  color: var(--white-muted);
}

.player-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.player-control-btn {
  background: var(--gold);
  border: none;
  color: var(--navy);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(201, 168, 76, 0.3);
}

.player-control-btn:hover {
  background: var(--gold-light);
  transform: scale(1.08);
}

.player-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.player-bar-fill {
  height: 100%;
  background: var(--teal-light);
  width: 0%;
  border-radius: 2px;
  position: relative;
}

.player-bar-fill::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
}

.player-bar-track:hover .player-bar-fill::after {
  opacity: 1;
}

.player-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--white-dim);
}

.listen-lang-select {
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: var(--gold-light);
  border-radius: 8px;
  padding: 6px 26px 6px 10px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.25s ease;
  appearance: none; /* Hide default browser arrow */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c9a84c'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.listen-lang-select:hover {
  border-color: var(--gold);
  background-color: rgba(201, 168, 76, 0.08);
}

.listen-lang-select option {
  background: var(--navy-mid);
  color: var(--cream);
}

/* ---------- Top Active Status Banner ---------- */
.top-status-banner {
  background: linear-gradient(135deg, rgba(16, 30, 54, 0.95), rgba(10, 22, 40, 0.98));
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 10px rgba(201, 168, 76, 0.15);
  animation: slide-down 0.3s ease;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-light);
  text-align: center;
  position: sticky;
  top: 10px;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.top-status-banner.hidden {
  display: none !important;
}

.top-status-icon {
  font-size: 1.1rem;
  animation: pulse-gold 2s infinite;
}

.top-status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@keyframes pulse-gold {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; text-shadow: 0 0 8px var(--gold); }
  100% { transform: scale(1); opacity: 0.8; }
}

.top-status-theme-badge {
  font-size: 0.78rem;
  color: var(--gold-light);
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 5px;
  display: inline-block;
  font-family: var(--font-arabic), var(--font-ui);
  text-shadow: none;
  font-weight: 500;
}

/* Reciter Selector Styles */
.reciter-select-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--white-muted);
}

.reciter-select {
  flex: 1;
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: var(--gold-light);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.25s ease;
}

.reciter-select:hover, .reciter-select:focus {
  border-color: var(--gold);
  background-color: rgba(201, 168, 76, 0.08);
}

.reciter-select option {
  background: var(--navy-mid);
  color: var(--cream);
}

/* ===================== THEMATIC VISUALIZER CARD ===================== */
.theme-visualizer-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(10, 22, 40, 0.95), rgba(16, 36, 64, 0.95));
  border: 1px solid var(--gold-light);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 15px rgba(201, 168, 76, 0.15);
  font-family: var(--font-ui);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99;
  backdrop-filter: blur(8px);
  animation: slide-down 0.3s ease;
  position: sticky;
  top: 10px;
}

.top-status-banner:not(.hidden) ~ .theme-visualizer-card {
  top: 72px; /* Stacks nicely below the active status banner when both are visible */
}

.theme-visualizer-card.hidden {
  display: none !important;
}

.theme-visualizer-art {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 50%;
  padding: 5px;
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.2);
}

.theme-visualizer-art svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 4px rgba(201, 168, 76, 0.4));
}

.theme-visualizer-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
}

.theme-visualizer-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold-light);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.theme-visualizer-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--white-muted);
}

/* SVG Theme Animations */
.rotating {
  transform-origin: center;
  animation: svg-spin 15s linear infinite;
}

.pulsing {
  transform-origin: center;
  animation: svg-pulse 3s ease-in-out infinite alternate;
}

.wave {
  transform-origin: center;
  animation: svg-wave-sway 4s ease-in-out infinite alternate;
}

.fire {
  transform-origin: bottom center;
  animation: svg-fire-flicker 1.8s ease-in-out infinite alternate;
}

.lightning-strike {
  animation: svg-lightning 2.5s ease-in-out infinite;
}

.swaying {
  transform-origin: 50% 20px;
  animation: svg-sway 5s ease-in-out infinite alternate;
}

.staff-glow {
  animation: svg-staff 2.5s ease-in-out infinite alternate;
}

@keyframes svg-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes svg-pulse {
  0% { opacity: 0.4; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

@keyframes svg-wave-sway {
  0% { transform: translateY(0) scaleY(1); }
  100% { transform: translateY(4px) scaleY(0.85); }
}

@keyframes svg-fire-flicker {
  0% { transform: scale(0.92) skewX(-2deg); opacity: 0.8; filter: brightness(0.95); }
  50% { transform: scale(1.08) skewX(4deg); opacity: 1; filter: brightness(1.15); }
  100% { transform: scale(0.98) skewX(-1deg); opacity: 0.85; filter: brightness(1.0); }
}

@keyframes svg-lightning {
  0%, 85%, 90%, 94%, 98%, 100% { opacity: 1; filter: brightness(1); }
  88%, 92%, 96% { opacity: 0.15; filter: brightness(2.5) drop-shadow(0 0 8px rgba(255, 100, 100, 0.8)); }
}

@keyframes svg-sway {
  0% { transform: rotate(-6deg); }
  100% { transform: rotate(6deg); }
}

@keyframes svg-staff {
  0% { stroke: #e8c65a; filter: drop-shadow(0 0 1px #e8c65a); }
  100% { stroke: #ffffff; filter: drop-shadow(0 0 8px #e8c65a); }
}

/* ---------- Global Page Loop Button ---------- */
.global-page-loop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: 1px solid var(--gold-light);
  color: var(--navy);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.2);
  transition: all 0.25s ease;
  outline: none;
}

.global-page-loop-btn:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.4);
  transform: translateY(-1px);
}

.global-page-loop-btn.active {
  background: linear-gradient(135deg, var(--teal-light), var(--teal));
  border-color: var(--teal-glow);
  color: var(--cream);
  box-shadow: 0 0 10px var(--teal-glow);
  animation: pulse-teal-button 2s infinite alternate;
}

@keyframes pulse-teal-button {
  0% { box-shadow: 0 0 5px rgba(58, 168, 177, 0.3); }
  100% { box-shadow: 0 0 15px rgba(58, 168, 177, 0.8); }
}

/* ============================================
   TIMED MEMORIZER 40/20 MODE
   ============================================ */
.page-text-overlay.timed-mode-active {
  pointer-events: auto !important;
}

/* 40-Minute Study Phase: Rectangle Highlight */
.page-text-overlay:not(.active) .word.timed-rect-highlight {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  color: transparent !important;
  text-shadow: none !important;
  pointer-events: auto;
}

.page-text-overlay.active .word.timed-rect-highlight {
  background: linear-gradient(135deg, var(--gold-light), var(--gold)) !important;
  color: var(--navy) !important;
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.6);
  pointer-events: auto;
  border-radius: 4px;
}

/* 20-Minute Test Phase: Masking/Blackout */
.word.timed-test-hidden {
  color: transparent !important;
  text-shadow: none !important;
  border-radius: 4px;
  box-shadow: none !important;
  border: none !important;
  pointer-events: auto;
  cursor: pointer;
}

/* Text Mode Blackout */
.page-text-overlay.active .word.timed-test-hidden {
  background: var(--navy) !important;
}

/* Image Mode Blackout: Cover calligraphy with parchment color */
.page-text-overlay:not(.active) .word.timed-test-hidden {
  background: var(--parchment) !important;
  padding: 3px 6px !important;
  margin: -3px -6px !important;
  border-radius: 4px;
}

/* Correct/Revealed Recitations in Test Mode */
.page-text-overlay:not(.active) .word.timed-test-success {
  background: transparent !important;
  border: none !important;
  color: #2bd997 !important; /* Mint green text in dark mode */
  box-shadow: none !important;
  text-shadow: 0 0 2px rgba(43, 217, 151, 0.5) !important;
  border-radius: 4px;
  pointer-events: auto;
  padding: 3px 6px !important;
  margin: -3px -6px !important;
}

body.light-mode .page-text-overlay:not(.active) .word.timed-test-success {
  background: transparent !important;
  border: none !important;
  color: var(--teal) !important; /* Emerald green text in light mode */
  box-shadow: none !important;
  text-shadow: none !important;
  padding: 3px 6px !important;
  margin: -3px -6px !important;
  border-radius: 4px;
}

.page-text-overlay.active .word.timed-test-success {
  background: linear-gradient(135deg, rgba(26, 107, 90, 0.9), rgba(42, 139, 118, 0.85)) !important;
  color: var(--white-soft) !important;
  text-shadow: none !important;
  box-shadow: 0 0 10px rgba(42, 139, 118, 0.5) !important;
  border-radius: 4px;
  pointer-events: auto;
}

/* Sidebar Button Styling */
.teacher-btn.btn-timed {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(201, 168, 76, 0.4);
}

.teacher-btn.btn-timed:hover {
  background: rgba(201, 168, 76, 0.1);
}

.teacher-btn.active-timed {
  background: var(--burgundy-light) !important;
  color: var(--cream) !important;
  border-color: var(--burgundy-light) !important;
  font-weight: 600;
  box-shadow: 0 0 8px rgba(138, 42, 63, 0.5);
  animation: pulse-burgundy 2s infinite alternate;
}

@keyframes pulse-burgundy {
  0% { box-shadow: 0 0 4px rgba(138, 42, 63, 0.3); }
  100% { box-shadow: 0 0 12px rgba(138, 42, 63, 0.8); }
}

/* Status Banner Buttons */
.top-status-timed-banner-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  font-family: var(--font-ui);
}

.top-status-timed-buttons {
  display: flex;
  gap: 8px;
}

.status-action-btn {
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.status-action-btn:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}

.status-action-btn.stop {
  background: var(--burgundy-light);
  color: var(--cream);
}

.status-action-btn.stop:hover {
  background: var(--burgundy);
}

/* Card banners */
.teacher-status-banner.timed-study-banner {
  background: rgba(201, 168, 76, 0.15);
  border-left: 3px solid var(--gold);
  color: var(--gold-light);
}

.teacher-status-banner.timed-test-banner {
  background: rgba(138, 42, 63, 0.15);
  border-left: 3px solid var(--burgundy-light);
  color: var(--cream);
}

/* ============================================
   SIDEBAR BOTTOM CONTROLS STYLING
   ============================================ */
.sidebar-wrapper .bottom-controls {
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(16, 30, 54, 0.95), rgba(10, 22, 40, 0.98));
  border: var(--border-gold);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
  position: static;
  width: 100%;
  max-width: 100%;
  z-index: 10;
}

.sidebar-wrapper .controls-inner {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 6px !important;
  justify-content: center;
}

.sidebar-wrapper .action-btn {
  padding: 6px 10px;
  font-size: 0.72rem;
  height: 32px;
  border-radius: 8px;
}

.sidebar-wrapper .control-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.sidebar-wrapper .page-jumper {
  height: 32px;
  border-radius: 8px;
}

.sidebar-wrapper .page-input {
  width: 48px;
  height: 26px;
  padding: 2px 4px;
  font-size: 0.8rem;
}

.sidebar-wrapper .go-btn {
  height: 26px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.sidebar-wrapper .listen-lang-select {
  height: 32px;
  font-size: 0.72rem;
  border-radius: 8px;
  padding: 4px;
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(201, 168, 76, 0.2);
  color: var(--white-muted);
}

.sidebar-wrapper .controls-divider {
  height: 18px;
  width: 1px;
  background: rgba(201, 168, 76, 0.15);
  margin: 0 2px;
}

/* ============================================
   ABOUT APP SECTION STYLING
   ============================================ */
.about-content-area {
  padding: 18px;
  color: var(--cream);
  font-family: var(--font-ui);
  line-height: 1.65;
  overflow-y: auto;
  flex: 1;
}

.about-main-text {
  font-size: 0.88rem;
  font-style: italic;
  text-align: center;
  color: var(--gold-light);
  background: rgba(10, 22, 40, 0.4);
  border: 1px dashed rgba(201, 168, 76, 0.25);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 20px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.about-references {
  margin-top: 15px;
}

.about-references h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  border-bottom: 1px solid rgba(201, 168, 76, 0.25);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.about-references ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.about-references li {
  font-size: 0.78rem;
  margin-bottom: 10px;
  color: var(--white-muted);
  display: flex;
  align-items: flex-start;
}

.about-references li strong {
  color: var(--cream);
  min-width: 140px;
  display: inline-block;
}

.about-references li::before {
  content: "✦";
  color: var(--gold);
  margin-right: 8px;
}

/* Special rules for Pages 1 and 2 in Close Book Mode (Test Phase) when in Image Mode */
.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 {
  background: var(--parchment) !important;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}

.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 .word:not(.timed-test-hidden) {
  color: var(--navy) !important;
  text-shadow: none !important;
}

.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 .word:not(.timed-test-hidden) .ayah-number-digit {
  color: var(--navy) !important;
}

.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 .word.timed-test-success {
  color: var(--teal) !important;
  background: transparent !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 .word.timed-test-success .ayah-number-digit {
  color: var(--teal) !important;
}

.page-text-overlay:not(.active).timed-test-active .text-overlay-content.page-1-2 .header-line {
  color: var(--navy) !important;
  font-weight: bold;
}

/* Interconnected boxes for other pages than page 1 and 2 in Close Book Mode */
.page-text-overlay:not(.active).timed-test-active .text-overlay-content:not(.page-1-2) .word.timed-test-hidden,
.page-text-overlay:not(.active).timed-test-active .text-overlay-content:not(.page-1-2) .word.timed-test-success {
  padding: 8px 6px !important;
  margin: -8px -6px !important;
  border-radius: 0px !important;
  box-shadow: none !important;
}
.page-text-overlay:not(.active).timed-test-active .text-overlay-content:not(.page-1-2) .word.timed-test-hidden {
  background: var(--parchment) !important;
}
.page-text-overlay:not(.active).timed-test-active .text-overlay-content:not(.page-1-2) .word.timed-test-success {
  background: transparent !important;
}

/* ---------- Text Mode Light Mode Styles ---------- */

.page-text-overlay.active.light-mode {
  background: #fdfbf7 !important;
  background-image: radial-gradient(circle at center, #ffffff 0%, #f7f4eb 100%) !important;
}

.page-text-overlay.active.light-mode .word {
  color: #1d2d44 !important; /* Premium dark navy/slate for text */
}

.page-text-overlay.active.light-mode .basmalah-line .word {
  color: #1a6b5a !important; /* Dark teal for Basmalah */
}

.page-text-overlay.active.light-mode .header-line {
  color: #a8882e !important; /* Premium gold for headers */
}

.page-text-overlay.active.light-mode .ayah-number-digit {
  color: #8c6b23 !important; /* Gold/bronze digit color */
}

.page-text-overlay.active.light-mode .word:hover {
  background: rgba(201, 168, 76, 0.12) !important;
  color: #7c5f18 !important;
  border-color: rgba(201, 168, 76, 0.35) !important;
}

.page-text-overlay.active.light-mode .word.highlighted {
  background: rgba(201, 168, 76, 0.28) !important;
  color: #5c4033 !important;
  border-color: var(--gold) !important;
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.25) !important;
}

.page-text-overlay.active.light-mode .word.playing-ayah {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  animation: none !important;
}


.page-text-overlay.active.light-mode .word.practice-hidden {
  background: #e5dfd4 !important; /* Warm light grey/parchment background */
  color: transparent !important;
  text-shadow: none !important;
  border-color: transparent !important;
}

.page-text-overlay.active.light-mode .word.practice-success {
  background: linear-gradient(135deg, rgba(42, 139, 118, 0.2), rgba(26, 107, 90, 0.15)) !important;
  color: #1a6b5a !important;
  border-color: rgba(26, 107, 90, 0.4) !important;
  box-shadow: 0 2px 6px rgba(26, 107, 90, 0.1) !important;
  text-shadow: none !important;
}

.page-text-overlay.active.light-mode .word.timed-test-hidden {
  background: #e5dfd4 !important; /* Warm light grey/parchment background */
  color: transparent !important;
  text-shadow: none !important;
  border-color: transparent !important;
}

.page-text-overlay.active.light-mode .word.timed-test-success {
  background: linear-gradient(135deg, rgba(42, 139, 118, 0.2), rgba(26, 107, 90, 0.15)) !important;
  color: #1a6b5a !important;
  border-color: rgba(26, 107, 90, 0.4) !important;
  box-shadow: 0 2px 6px rgba(26, 107, 90, 0.1) !important;
  text-shadow: none !important;
}

.page-text-overlay.active.light-mode .word.timed-rect-highlight {
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.22), rgba(201, 168, 76, 0.15)) !important;
  color: #7c5f18 !important;
  border-color: rgba(201, 168, 76, 0.45) !important;
  box-shadow: 0 2px 6px rgba(201, 168, 76, 0.1) !important;
}

/* ---------- Global Theme transitions ---------- */
body, .ayah-sidebar, .top-status-banner, .controls-inner, .sidebar-wrapper .bottom-controls, .theme-visualizer-card, .surah-search-input {
  transition: background 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ---------- Global Light Mode Overrides ---------- */
body.light-mode {
  background-color: #f8f6f0 !important;
  --navy: #f8f6f0;
  --navy-light: #ffffff;
  --navy-mid: #efeae0;
  --cream: #0c1c36; /* Very dark navy for maximum readability */
  --cream-light: #162a4b;
  --white-soft: #0f172a; /* Slate 900 for body text/headings */
  --white-muted: #2d3748; /* Slate 800 for descriptions, subheadings, non-active tabs */
  --white-dim: #4a5568; /* Slate 700 for hints, borders, secondary items */
  --gold: #7c5f18; /* Rich dark bronze/gold for active states, tabs, primary highlight */
  --gold-light: #94711e; /* Lighter high-contrast gold for sub-highlights */
  --gold-dark: #5c430c; /* Deep gold for headers/accents */
  --teal: #0d4f40; /* High contrast dark teal for correct recitations / loops */
  --teal-light: #126351;
  --burgundy: #7a162b; /* High contrast dark burgundy */
  --burgundy-light: #99233b;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
  --border-gold: 1px solid rgba(124, 95, 24, 0.35);
  --border-gold-strong: 1px solid rgba(124, 95, 24, 0.65);
}

body.light-mode .bg-pattern {
  background-color: #f8f6f0 !important;
}

body.light-mode .page-border {
  background: linear-gradient(135deg, #ffffff, #efeae0) !important;
  border-color: rgba(124, 95, 24, 0.35) !important;
}

body.light-mode .ayah-sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 240, 0.98)) !important;
  border-color: rgba(124, 95, 24, 0.3) !important;
}

body.light-mode .ayah-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(239, 234, 224, 0.8)) !important;
  border-color: rgba(124, 95, 24, 0.2) !important;
}

body.light-mode .ayah-card:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(239, 234, 224, 0.95)) !important;
  border-color: rgba(124, 95, 24, 0.45) !important;
}

body.light-mode .ayah-card.revealed {
  background: linear-gradient(135deg, rgba(13, 79, 64, 0.08), rgba(255, 255, 255, 0.9)) !important;
  border-color: rgba(13, 79, 64, 0.4) !important;
}

body.light-mode .controls-inner {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(124, 95, 24, 0.45) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body.light-mode .memory-banner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 240, 0.98)) !important;
  border-color: rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .top-status-banner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 240, 0.98)) !important;
  border-color: rgba(124, 95, 24, 0.5) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05), 0 0 10px rgba(124, 95, 24, 0.12) !important;
}

body.light-mode .sidebar-wrapper .bottom-controls {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 240, 0.98)) !important;
  border-color: rgba(124, 95, 24, 0.3) !important;
}

body.light-mode .theme-visualizer-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 240, 0.95)) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), 0 0 15px rgba(124, 95, 24, 0.12) !important;
}

body.light-mode .surah-search-input {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #0f172a !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .go-btn {
  color: #ffffff !important;
}

body.light-mode .control-btn.primary {
  color: #0c1c36 !important;
}

body.light-mode .action-btn.active {
  background: rgba(124, 95, 24, 0.25) !important;
  border-color: var(--gold) !important;
  color: #0c1c36 !important;
  box-shadow: inset 0 0 10px rgba(124, 95, 24, 0.15) !important;
}

body.light-mode .tab-btn.active {
  color: #0c1c36 !important;
}

body.light-mode .action-btn:hover {
  color: #5c430c !important;
  background: rgba(124, 95, 24, 0.12) !important;
  border-color: rgba(124, 95, 24, 0.45) !important;
}

body.light-mode .reveal-all-btn:hover {
  background: rgba(13, 79, 64, 0.12) !important;
  border-color: var(--teal) !important;
  color: var(--teal) !important;
}

body.light-mode .reset-btn:hover {
  background: rgba(122, 22, 43, 0.12) !important;
  border-color: var(--burgundy) !important;
  color: var(--burgundy) !important;
}

body.light-mode .page-input {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #0f172a !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
}

body.light-mode select option {
  background: #ffffff !important;
  color: #0f172a !important;
}


/* ---------- Word Translation Panel ---------- */
.word-translation-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 600px;
  background: linear-gradient(135deg, rgba(16, 30, 54, 0.98), rgba(10, 22, 40, 0.99));
  border: var(--border-gold-strong);
  border-radius: 12px;
  color: var(--white-soft);
  padding: 18px 24px 20px;
  z-index: 2000;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slide-up-anim 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: all 0.25s ease;
  pointer-events: auto;
}

/* Light mode override for translation panel */
body.light-mode .word-translation-panel {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 246, 240, 0.98)) !important;
  color: #1e293b !important;
  border: 1px solid rgba(201, 168, 76, 0.5) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

@keyframes slide-up-anim {
  from { transform: translate(-50%, 120%); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.word-translation-panel.hidden {
  display: none !important;
}

.translation-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--white-dim);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease, transform 0.2s ease;
}

.translation-close-btn:hover {
  color: var(--gold);
  transform: scale(1.1);
}

body.light-mode .translation-close-btn {
  color: #94a3b8;
}
body.light-mode .translation-close-btn:hover {
  color: #a8882e;
}

.translation-panel-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.word-arabic-title {
  font-family: var(--font-arabic);
  font-size: 2.2rem;
  color: var(--gold-light);
  margin-bottom: 4px;
  text-align: center;
  direction: rtl;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

body.light-mode .word-arabic-title {
  color: #8c6b23;
  text-shadow: none;
}

.word-context-info {
  font-size: 0.72rem;
  color: var(--white-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  font-weight: 600;
}

body.light-mode .word-context-info {
  color: #64748b;
}

.word-english-meaning {
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--cream);
  max-width: 85%;
  font-weight: 400;
}

body.light-mode .word-english-meaning {
  color: #0f172a;
}

/* ========================================================
   MUSHAF-ONLY CLOSE BOOK MODE BLOCK MASKING
   ======================================================== */
.mushaf-masks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.mushaf-block-mask {
  position: absolute;
  background: var(--parchment) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

body.light-mode .mushaf-block-mask {
  background: #e2dac8 !important; /* Rich solid parchment color in light mode */
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

/* Hide individual word borders/backgrounds in Mushaf mode so they do not conflict with the solid block mask */
.page-text-overlay:not(.active) .word.practice-hidden {
  background: transparent !important;
  color: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

.page-text-overlay:not(.active) .word.timed-test-hidden {
  background: transparent !important;
  color: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* ========================================================
   LIGHT MODE CONTRAST AND COLOR VISIBILITY OVERRIDES
   ======================================================== */
body.light-mode .sidebar-tab:hover {
  color: var(--gold) !important;
  background: rgba(124, 95, 24, 0.08) !important;
}

body.light-mode .sidebar-tab.active {
  color: var(--gold) !important;
  background: rgba(124, 95, 24, 0.18) !important;
  border-bottom: 3px solid var(--gold) !important;
  font-weight: 800 !important;
  text-shadow: none !important;
}

body.light-mode .surah-item:hover {
  background: rgba(124, 95, 24, 0.08) !important;
  border-color: rgba(124, 95, 24, 0.25) !important;
}

body.light-mode .surah-num {
  background: rgba(124, 95, 24, 0.15) !important;
  color: var(--gold) !important;
}

/* High visibility buttons in light mode */
body.light-mode .control-btn {
  background: #ffffff !important;
  color: #2d3748 !important;
  border: 1px solid rgba(124, 95, 24, 0.35) !important;
}

body.light-mode .control-btn:hover {
  background: rgba(124, 95, 24, 0.1) !important;
  color: #7c5f18 !important;
  border-color: #7c5f18 !important;
}

body.light-mode .control-btn.primary {
  background: #7c5f18 !important;
  color: #ffffff !important;
  border: 1px solid #7c5f18 !important;
  box-shadow: 0 2px 8px rgba(124, 95, 24, 0.3) !important;
}

body.light-mode .control-btn.primary:hover {
  background: #5c430c !important;
  border-color: #5c430c !important;
  color: #ffffff !important;
}

body.light-mode .action-btn {
  background: #ffffff !important;
  color: #2d3748 !important;
  border: 1px solid rgba(124, 95, 24, 0.35) !important;
}

body.light-mode .action-btn:hover {
  background: rgba(124, 95, 24, 0.1) !important;
  color: #7c5f18 !important;
  border-color: #7c5f18 !important;
}

body.light-mode .action-btn.active {
  background: #7c5f18 !important;
  color: #ffffff !important;
  border-color: #7c5f18 !important;
  box-shadow: 0 2px 8px rgba(124, 95, 24, 0.3) !important;
}

body.light-mode .range-select {
  background: #ffffff !important;
  color: #2d3748 !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .range-select:hover, body.light-mode .range-select:focus {
  border-color: #7c5f18 !important;
}

body.light-mode .teacher-btn {
  background: #ffffff !important;
  color: #2d3748 !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .teacher-btn:hover {
  background: rgba(124, 95, 24, 0.1) !important;
  color: #7c5f18 !important;
  border-color: #7c5f18 !important;
}

body.light-mode .teacher-btn.active {
  background: #7c5f18 !important;
  color: #ffffff !important;
  border-color: #7c5f18 !important;
}

body.light-mode .teacher-btn.active-practice {
  background: #0d4f40 !important;
  color: #ffffff !important;
  border-color: #0d4f40 !important;
}

body.light-mode .teacher-btn.btn-timed {
  background: #ffffff !important;
  color: #7c5f18 !important;
  border: 1px solid rgba(124, 95, 24, 0.45) !important;
}

body.light-mode .teacher-btn.btn-timed:hover {
  background: rgba(124, 95, 24, 0.1) !important;
  color: #5c430c !important;
  border-color: #5c430c !important;
}

body.light-mode .teacher-btn.active-timed {
  background: #7a162b !important;
  color: #ffffff !important;
  border-color: #7a162b !important;
  animation: none !important; /* Stop dark mode flashing colors */
  box-shadow: 0 2px 8px rgba(122, 22, 43, 0.3) !important;
}

body.light-mode .sort-btn {
  background: #ffffff !important;
  color: #4a5568 !important;
  border: 1px solid rgba(124, 95, 24, 0.3) !important;
}

body.light-mode .sort-btn:hover {
  background: rgba(124, 95, 24, 0.08) !important;
  border-color: rgba(124, 95, 24, 0.45) !important;
  color: #2d3748 !important;
}

body.light-mode .sort-btn.active {
  background: #7c5f18 !important;
  border-color: #7c5f18 !important;
  color: #ffffff !important;
}

/* Page jumper adjustments */
body.light-mode .page-jumper {
  background: rgba(255, 255, 255, 0.8) !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .jumper-btn {
  color: #2d3748 !important;
}

body.light-mode .controls-divider {
  background: rgba(124, 95, 24, 0.4) !important;
}

body.light-mode .peek-btn {
  background: rgba(255, 255, 255, 0.9) !important;
  border: 1px solid rgba(124, 95, 24, 0.4) !important;
  color: var(--gold) !important;
}

body.light-mode .peek-btn:hover,
body.light-mode .peek-btn:active {
  background: rgba(124, 95, 24, 0.12) !important;
  border-color: var(--gold) !important;
}

body.light-mode .peek-btn.active {
  background: rgba(124, 95, 24, 0.25) !important;
  border-color: var(--gold) !important;
  color: var(--gold) !important;
  box-shadow: inset 0 0 8px rgba(124, 95, 24, 0.15) !important;
}

/* High contrast scrollbars in light mode */
body.light-mode .surah-list::-webkit-scrollbar-thumb,
body.light-mode .ayah-list::-webkit-scrollbar-thumb,
body.light-mode .teacher-group-list::-webkit-scrollbar-thumb {
  background: rgba(124, 95, 24, 0.35) !important;
  border-radius: 4px;
}

body.light-mode .surah-list::-webkit-scrollbar-thumb:hover,
body.light-mode .ayah-list::-webkit-scrollbar-thumb:hover,
body.light-mode .teacher-group-list::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 95, 24, 0.5) !important;
}

/* Light mode select and status button contrast overrides */
.reciter-select, .listen-lang-select {
  background: #0a1628 !important;
  color: var(--gold-light) !important;
  border: 1px solid rgba(201, 168, 76, 0.4) !important;
}

.reciter-select:hover, .reciter-select:focus,
.listen-lang-select:hover, .listen-lang-select:focus {
  background: #0c1c36 !important;
  border-color: var(--gold) !important;
}

.reciter-select option, .listen-lang-select option {
  background: #0a1628 !important;
  color: #f5efe0 !important;
}

body.light-mode .reciter-select,
body.light-mode .listen-lang-select {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(124, 95, 24, 0.5) !important;
}

body.light-mode .reciter-select:hover,
body.light-mode .reciter-select:focus,
body.light-mode .listen-lang-select:hover,
body.light-mode .listen-lang-select:focus {
  background: #ffffff !important;
  border-color: var(--gold) !important;
}

body.light-mode .reciter-select option,
body.light-mode .listen-lang-select option {
  background: #ffffff !important;
  color: #0f172a !important;
}

.status-action-btn {
  background: var(--gold) !important;
  color: var(--navy) !important;
  border: none;
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.status-action-btn:hover {
  background: var(--gold-light) !important;
  color: var(--navy) !important;
}

.status-action-btn.stop {
  background: var(--burgundy-light) !important;
  color: #ffffff !important;
}

.status-action-btn.stop:hover {
  background: var(--burgundy) !important;
  color: #ffffff !important;
}

body.light-mode .status-action-btn {
  background: var(--gold) !important;
  color: #ffffff !important;
}

body.light-mode .status-action-btn:hover {
  background: var(--gold-dark) !important;
  color: #ffffff !important;
}

body.light-mode .status-action-btn.stop {
  background: var(--burgundy-light) !important;
  color: #ffffff !important;
}

body.light-mode .status-action-btn.stop:hover {
  background: var(--burgundy) !important;
  color: #ffffff !important;
}

/* ============================================
   TIMED MODE TOP STATUS BANNER TEXT & TIMER STYLING
   ============================================ */
.top-status-timed-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
}

.timed-banner-info-section {
  text-align: left;
}

.timed-banner-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timed-banner-title.study {
  color: var(--gold);
}

.timed-banner-title.test {
  color: #ff5555;
  text-shadow: 0 0 8px rgba(255, 85, 85, 0.3);
}

body.light-mode .timed-banner-title.test {
  color: var(--burgundy) !important;
  text-shadow: none !important;
}

.timed-banner-subtitle {
  font-size: 0.78rem;
  color: var(--white-muted);
  margin-top: 2px;
}

.timed-banner-time-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Timer clock block */
.timed-timer-block {
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  padding: 4px 12px !important;
  border-radius: 8px !important;
  font-family: monospace !important;
  line-height: 1 !important;
}

/* Study mode timer (gold theme) */
.timed-timer-block.study {
  color: #ffffff !important;
  background: rgba(201, 168, 76, 0.25) !important;
  border: 2px solid var(--gold) !important;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.3) !important;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.5) !important;
}

/* Test mode timer (red theme) */
.timed-timer-block.test {
  color: #ffffff !important;
  background: rgba(255, 85, 85, 0.25) !important;
  border: 2px solid #ff5555 !important;
  box-shadow: 0 0 8px rgba(255, 85, 85, 0.3) !important;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.5) !important;
}

/* Range text block (Surah & Ayah range) */
.timed-range-block {
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  border-radius: 6px !important;
}

.timed-range-block.study {
  color: var(--gold-light) !important;
  background: rgba(10, 22, 40, 0.6) !important;
  border: 1px solid rgba(201, 168, 76, 0.2) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

.timed-range-block.test {
  color: #ff8888 !important;
  background: rgba(10, 22, 40, 0.6) !important;
  border: 1px solid rgba(255, 85, 85, 0.2) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

.top-status-timed-buttons {
  display: flex;
  gap: 8px;
}

/* --- LIGHT MODE ADJUSTMENTS FOR TIMED BLOCKS --- */
body.light-mode .timed-timer-block.study {
  color: var(--gold) !important;
  background: rgba(124, 95, 24, 0.08) !important;
  border: 2px solid var(--gold) !important;
  box-shadow: 0 2px 6px rgba(124, 95, 24, 0.1) !important;
  text-shadow: none !important;
}

body.light-mode .timed-timer-block.test {
  color: var(--burgundy) !important;
  background: rgba(122, 22, 43, 0.08) !important;
  border: 2px solid var(--burgundy) !important;
  box-shadow: 0 2px 6px rgba(122, 22, 43, 0.1) !important;
  text-shadow: none !important;
}

body.light-mode .timed-range-block.study {
  color: var(--gold-dark) !important;
  background: rgba(124, 95, 24, 0.06) !important;
  border: 1px solid rgba(124, 95, 24, 0.25) !important;
  text-shadow: none !important;
}

body.light-mode .timed-range-block.test {
  color: var(--burgundy) !important;
  background: rgba(122, 22, 43, 0.06) !important;
  border: 1px solid rgba(122, 22, 43, 0.25) !important;
  text-shadow: none !important;
}

/* Light mode overrides for teacher cards' status banners */
body.light-mode .teacher-status-banner.timed-study-banner {
  background: rgba(124, 95, 24, 0.08) !important;
  border-left: 3px solid var(--gold) !important;
  color: var(--gold-dark) !important;
}

body.light-mode .teacher-status-banner.timed-test-banner {
  background: rgba(122, 22, 43, 0.08) !important;
  border-left: 3px solid var(--burgundy) !important;
  color: var(--burgundy) !important;
}

/* Light mode overrides for About App section text block */
body.light-mode .about-main-text {
  background: rgba(124, 95, 24, 0.05) !important;
  color: var(--gold-dark) !important;
  border-color: rgba(124, 95, 24, 0.35) !important;
  box-shadow: none !important;
}

/* ---------- Ayah Start Hints in right margin (glowing and radiating) ---------- */
.ayah-start-hints-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150; /* Super high z-index to stay on top of the page image and all masks/overlays */
}

.ayah-start-hint {
  --hint-glow-color: rgba(0, 230, 118, 0.95);
  --hint-glow-color-subtle: rgba(0, 230, 118, 0.45);
  --hint-color: #00ff88; /* Glowing electric spring green in dark mode */
  
  position: absolute;
  font-family: var(--font-arabic);
  font-size: 2.8cqw; /* Slightly larger and more prominent */
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: var(--hint-color);
  text-shadow: 
    0 0 6px var(--hint-glow-color), 
    0 0 15px var(--hint-glow-color), 
    0 0 25px var(--hint-glow-color-subtle);
  animation: hint-pulse 1.8s infinite ease-in-out;
  transition: all 0.3s ease;
  z-index: 10;
  transform: scale(1);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ayah-start-hint:hover {
  transform: scale(1.18);
  color: #fff;
  text-shadow: 
    0 0 8px #00ff88, 
    0 0 20px #00e676, 
    0 0 35px rgba(255, 255, 255, 1.0);
}

/* Light mode overrides - elegant emerald green */
body.light-mode .ayah-start-hint {
  --hint-glow-color: rgba(26, 107, 90, 0.85);
  --hint-glow-color-subtle: rgba(26, 107, 90, 0.4);
  --hint-color: var(--teal-light); /* Vibrant teal/green in light mode */
}

body.light-mode .ayah-start-hint:hover {
  color: #00ff88;
  text-shadow: 
    0 0 8px var(--hint-glow-color), 
    0 0 20px var(--hint-glow-color), 
    0 0 35px rgba(0, 230, 118, 0.7);
}

/* Adjustments for pages 1 and 2 (which have 15% padding/margins) */
.ayah-start-hints-container.page-1-2 .ayah-start-hint {
  font-size: 3.6cqw;
}

@keyframes hint-pulse {
  0% {
    opacity: 0.75;
    text-shadow: 
      0 0 6px var(--hint-glow-color), 
      0 0 12px var(--hint-glow-color), 
      0 0 20px var(--hint-glow-color-subtle);
  }
  50% {
    opacity: 1;
    text-shadow: 
      0 0 12px var(--hint-glow-color), 
      0 0 24px var(--hint-glow-color), 
      0 0 40px var(--hint-glow-color-subtle);
  }
  100% {
    opacity: 0.75;
    text-shadow: 
      0 0 6px var(--hint-glow-color), 
      0 0 12px var(--hint-glow-color), 
      0 0 20px var(--hint-glow-color-subtle);
  }
}

/* ---------- Teacher Global Actions and Global Timed Mode ---------- */
.teacher-global-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.4);
  border: 1px dashed rgba(201, 168, 76, 0.2);
}

body.light-mode .teacher-global-actions {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(124, 95, 24, 0.2);
}

.global-page-loop-btn {
  margin-top: 0 !important; /* override the margin-top in global-page-loop-btn */
}

.global-timed-controller {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.global-timed-range {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.global-timed-range .range-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.light-mode .global-timed-range .range-label {
  color: #7c5f18;
}

.global-timed-controller .teacher-btn.btn-timed {
  width: 100%;
}

/* Full page calligraphy masking */
.full-page-mask {
  position: absolute;
  inset: 0;
  background: var(--parchment) !important;
  z-index: 3; /* Placed in front of calligraphy page image (z-index: 1) but behind block masks (z-index: 4) and text overlay (z-index: 5) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  border-radius: 5px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

body.light-mode .full-page-mask {
  background: #e2dac8 !important; /* Rich solid parchment color in light mode */
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.08);
}

.page-image-container.hide-page-active .full-page-mask {
  opacity: 1;
}

/* Styling for hide-page-btn toggle states */
.hide-page-btn.active {
  background: rgba(201, 168, 76, 0.2) !important;
  border-color: var(--gold) !important;
  color: var(--gold-light) !important;
}

body.light-mode .hide-page-btn.active {
  background: rgba(168, 120, 30, 0.15) !important;
  border-color: #a8781e !important;
  color: #7c5f18 !important;
}

/* Styling for hide-text-btn, hide-page-btn, and hide-selection-btn toggle states */
.hide-page-btn.active,
.hide-text-btn.active,
.hide-selection-btn.active {
  background: rgba(201, 168, 76, 0.2) !important;
  border-color: var(--gold) !important;
  color: var(--gold-light) !important;
}

body.light-mode .hide-page-btn.active,
body.light-mode .hide-text-btn.active,
body.light-mode .hide-selection-btn.active {
  background: rgba(168, 120, 30, 0.15) !important;
  border-color: #a8781e !important;
  color: #7c5f18 !important;
}
/* Loop Count Badge for Teacher Mode */
.loop-count-badge {
  display: inline-block;
  color: #ff3366 !important; /* Vibrant red */
  font-size: 2.2rem !important;
  font-weight: 900 !important;
  text-shadow: 0 0 12px rgba(255, 51, 102, 0.7) !important;
  margin-left: 10px;
  vertical-align: middle;
  animation: loop-pop-shake 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.light-mode .loop-count-badge {
  color: #d60036 !important; /* Darker red for contrast in light mode */
  text-shadow: 0 0 8px rgba(214, 0, 54, 0.4) !important;
}

@keyframes loop-pop-shake {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  50% { transform: scale(1.4) rotate(10deg); }
  75% { transform: scale(0.9) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
