:root {
  --primary: #065f46;
  --primary-dark: #064e3b;
  --primary-light: #10b981;
  --gold: #d97706;
  --gold-light: #fef3c7;
  --gold-border: #fcd34d;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Segoe UI', Tahoma, 'Amiri', 'Traditional Arabic', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  padding: 18px 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #ffffff;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-text p {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
}

.nav-links {
  display: flex;
  gap: 10px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-btn:hover, .nav-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px;
}

/* Home 2-Menu Cards */
.hero-banner {
  text-align: center;
  margin-bottom: 36px;
}

.hero-banner h2 {
  font-size: 2rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.hero-banner p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.menu-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.menu-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.menu-card:hover::before {
  opacity: 1;
}

.menu-icon-wrapper {
  width: 80px;
  height: 80px;
  background: var(--gold-light);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  margin-bottom: 20px;
}

.menu-card h3 {
  font-size: 1.45rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.menu-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.menu-btn {
  padding: 10px 24px;
  background: var(--primary);
  color: #ffffff;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: auto;
  transition: background 0.2s ease;
}

.menu-card:hover .menu-btn {
  background: var(--primary-dark);
}

/* Focused Page Indicator Badge */
.current-focus-badge {
  margin-top: 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Set Focused View Layout */
.filter-bar {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.tabs {
  display: flex;
  gap: 8px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 9999px;
}

.tab-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.hizb-selector-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hizb-selector-container label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.styled-select {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.styled-select:focus {
  border-color: var(--primary);
}

/* Page Cards Grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.page-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.page-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.page-card.is-focused {
  border: 2px solid var(--gold);
  background: #fffbeb;
}

.focused-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--gold);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.page-thumb-wrapper {
  background: #f1f5f9;
  position: relative;
  overflow: hidden;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.page-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.page-thumb-wrapper:hover .page-thumb {
  transform: scale(1.02);
}

.page-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.page-info .surah {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.page-info .meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-info .thumn-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.set-btn {
  margin-top: 10px;
  padding: 10px;
  width: 100%;
  border: none;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.set-btn:hover {
  background: var(--primary-dark);
}

.page-card.is-focused .set-btn {
  background: var(--gold);
}

/* Focused Viewer View */
.focused-viewer-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.viewer-header {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.page-header-title h2 {
  font-size: 1.4rem;
  color: var(--primary-dark);
}

.page-header-title p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav-buttons {
  display: flex;
  gap: 12px;
}

.nav-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-main);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-action-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Audio Player Bar */
.audio-player-bar {
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.audio-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.play-pause-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #ffffff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, background 0.2s ease;
}

.play-pause-btn:hover {
  transform: scale(1.05);
  background: #b45309;
}

.repeat-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.audio-progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.audio-scrubber {
  flex: 1;
  height: 6px;
  accent-color: var(--gold);
  cursor: pointer;
}

.time-display {
  font-size: 0.85rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.9);
}

/* Page PDF Frame / Canvas Container */
.page-display-frame {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-md);
  min-height: 700px;
}

.page-image-view {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #064e3b;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 9999px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* Multi-Tier Navigation Bar */
.multi-nav-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.nav-tier-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tier-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tier-buttons {
  display: flex;
  gap: 8px;
}

.btn-hizb {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-hizb:hover {
  background: #fde68a;
  color: #78350f;
}

.btn-nisf {
  background: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-nisf:hover {
  background: #99f6e4;
  color: #115e59;
}

.btn-page {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-page:hover {
  background: #a7f3d0;
  color: #064e3b;
}

/* View Mode Toggles */
.view-mode-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 8px;
}

.view-mode-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.view-mode-btn.active, .view-mode-btn:hover {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Minimized Mode */
.page-display-frame.is-minimized {
  min-height: 420px;
  max-height: 480px;
}

.page-display-frame.is-minimized .page-image-view {
  max-height: 400px;
}

/* Fullscreen Mode */
.page-display-frame.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  background: #0f172a;
  border-radius: 0;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-display-frame.is-fullscreen .page-image-view {
  max-height: 98vh;
  max-width: 98vw;
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
  border-radius: 8px;
}

/* Floating controls in Fullscreen */
.fullscreen-floating-bar {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 8px 18px;
  z-index: 100000;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.page-display-frame.is-fullscreen + .fullscreen-floating-bar {
  display: flex;
}

.floating-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.floating-btn:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #ffffff;
}

/* Touch & Drag Swipe Feedback */
.page-display-frame {
  touch-action: pan-y;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.swipe-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

.page-image-view {
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), opacity 0.25s ease;
}

.slide-next-animation {
  animation: slideInNext 0.28s ease-out;
}

.slide-prev-animation {
  animation: slideInPrev 0.28s ease-out;
}

@keyframes slideInNext {
  0% {
    opacity: 0.3;
    transform: translateX(-40px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideInPrev {
  0% {
    opacity: 0.3;
    transform: translateX(40px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    gap: 12px;
  }
  .menu-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .tabs {
    justify-content: center;
  }
  .viewer-header {
    flex-direction: column;
    align-items: stretch;
  }
  .nav-buttons {
    justify-content: space-between;
  }
}

/* Pure Reader View (No Header, Full Screen Centered Page) */
body.pure-reader {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background-color: #f1f5f9;
  display: flex;
  flex-direction: column;
}

.pure-page-container {
  width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  box-sizing: border-box;
  padding: 42px 0 54px 0;
  transition: padding-bottom 0.25s ease;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  background-color: #fdfbf7;
}

.pure-page-container.dock-minimized {
  padding-bottom: 50px;
}

.page-viewport-wrapper {
  position: relative;
  width: 100%;
  max-width: 827px;
  margin: 0 auto;
  display: block;
}

.pure-page-img {
  width: 100%;
  max-width: 827px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
}

.pure-page-img:active {
  cursor: grabbing;
}

/* Smart Audio-Text Highlighting Overlay */
.page-highlight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.page-highlight-overlay.disabled {
  display: none !important;
}

.active-line-glow {
  position: absolute;
  display: none;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0.32) 15%, rgba(245, 158, 11, 0.35) 50%, rgba(245, 158, 11, 0.32) 85%, rgba(245, 158, 11, 0.12) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.65);
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45), inset 0 0 8px rgba(251, 191, 36, 0.25);
  pointer-events: none;
  transition: top 0.28s cubic-bezier(0.16, 1, 0.3, 1), left 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.28s ease, height 0.28s ease;
  z-index: 11;
  mix-blend-mode: multiply;
}

.line-click-targets {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.line-target {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 4px;
  z-index: 12;
  transition: background 0.15s ease;
}

.line-target:hover {
  background: rgba(245, 158, 11, 0.14);
  outline: 1px dashed rgba(245, 158, 11, 0.4);
}

.highlight-toggle-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fef08a;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.highlight-toggle-btn:hover {
  background: var(--gold);
  color: #ffffff;
}

.highlight-toggle-btn.off {
  opacity: 0.55;
  color: #d1d5db;
  background: rgba(0, 0, 0, 0.2);
}

.quick-sparkle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0 4px;
  line-height: 1;
  vertical-align: middle;
  transition: transform 0.2s ease;
  pointer-events: auto;
}

.quick-sparkle-btn:hover {
  transform: scale(1.2);
}

/* Floating Top Title Badge */
.floating-top-title {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 78, 59, 0.9);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 6px 18px;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  z-index: 100;
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  pointer-events: none;
}

/* Fixed Bottom Dock */
.fixed-bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(6, 78, 59, 0.97) 0%, rgba(4, 52, 40, 0.99) 100%);
  backdrop-filter: blur(16px);
  border-top: 2px solid var(--gold);
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  color: #ffffff;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.fixed-bottom-dock.is-collapsed {
  transform: translateY(calc(100% - 44px));
}

.dock-collapse-btn {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: #043428;
  color: #ffffff;
  border: 1.5px solid var(--gold);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  width: 58px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
  transition: background 0.2s;
}

.dock-collapse-btn:hover {
  background: var(--gold);
}

.dock-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dock-row-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.dock-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dock-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.dock-btn:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.dock-btn.primary-nav {
  background: var(--gold);
  border-color: var(--gold-border);
  color: #ffffff;
  padding: 6px 14px;
}

.dock-btn.primary-nav:hover {
  background: #b45309;
}

/* Dropdown Pickers directly on the bar */
.dock-selectors-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dock-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.dock-picker label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fde68a;
  white-space: nowrap;
}

.dock-select-input {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  max-width: 175px;
}

.dock-select-input:focus {
  border-color: var(--gold);
}

/* Audio Player Row in Dock */
.dock-row-audio {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dock-play-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: #ffffff;
  border: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: transform 0.2s, background 0.2s;
  flex-shrink: 0;
}

.dock-play-circle:hover {
  transform: scale(1.08);
  background: #b45309;
}

.dock-repeat-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(217, 119, 6, 0.3);
  border: 1px solid rgba(251, 191, 36, 0.4);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.dock-time-label {
  font-size: 0.8rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.dock-scrubber-bar {
  flex: 1;
  height: 6px;
  accent-color: var(--gold);
  cursor: pointer;
}

.dock-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dock-vol-slider {
  width: 60px;
  accent-color: var(--gold);
  cursor: pointer;
}

@media (max-width: 768px) {
  .pure-page-container {
    padding: 38px 0 50px 0;
  }
  .pure-page-img {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }
  .dock-row-nav {
    justify-content: center;
  }
  .dock-selectors-container {
    justify-content: center;
    width: 100%;
  }
  .dock-select-input {
    max-width: 120px;
    font-size: 0.8rem;
  }
  .dock-row-audio {
    flex-wrap: wrap;
    justify-content: center;
  }
  .dock-scrubber-bar {
    order: 3;
    width: 100%;
  }
}

/* ------------------------------------------------------------- */
/* 3-Part Memorization Mode (وضع التحفيظ وتقسيم الصفحة لـ 3 أجزاء) */
/* ------------------------------------------------------------- */
.memorize-floating-bar {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(6, 78, 59, 0.96) 0%, rgba(4, 52, 40, 0.98) 100%);
  backdrop-filter: blur(12px);
  border: 1.5px solid var(--gold);
  border-radius: 9999px;
  padding: 4px 12px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 1050;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  direction: rtl;
  white-space: nowrap;
  animation: fadeInDown 0.22s ease-out;
}

.memorize-floating-bar.active {
  display: flex;
}

body.memorize-mode-on .pure-page-container {
  padding-top: 86px;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.mem-title-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fde68a;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}

.mem-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.mem-btn:hover {
  background: var(--gold);
  border-color: var(--gold-border);
  color: #ffffff;
}

.mem-btn.is-hidden-state {
  background: rgba(217, 119, 6, 0.35);
  border-color: #fbbf24;
  color: #fef08a;
}

.mem-btn.hide-all-btn {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
.mem-btn.hide-all-btn:hover {
  background: #dc2626;
  color: #ffffff;
}

.mem-btn.reveal-step-btn {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
}
.mem-btn.reveal-step-btn:hover {
  background: #059669;
  color: #ffffff;
}

.mem-btn.close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  padding: 2px 4px;
}
.mem-btn.close-btn:hover {
  color: #ffffff;
}

/* Part Curtains / Masks Container (Legacy overlay mode) */
.page-parts-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

.page-parts-container.is-inactive {
  display: none !important;
}

/* ------------------------------------------------------------- */
/* Separated 3-Part Cards Layout in Memorization Mode */
/* ------------------------------------------------------------- */
.page-memorize-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: var(--page-max-width, 680px);
  margin: 0 auto;
  padding: 8px 12px 140px 12px;
  box-sizing: border-box;
}

.memorize-part-card {
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  border: 1.5px solid rgba(251, 191, 36, 0.45);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.memorize-part-card:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.38);
  border-color: var(--gold);
}

.memorize-part-header {
  background: linear-gradient(135deg, #064e3b 0%, #042f24 100%);
  color: #fef08a;
  padding: 7px 16px;
  font-size: 0.86rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid rgba(251, 191, 36, 0.4);
  user-select: none;
  cursor: pointer;
}

.memorize-part-header .header-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.memorize-part-header .part-lines-badge {
  font-size: 0.76rem;
  color: #a7f3d0;
  font-weight: 600;
}

.memorize-part-header .header-status {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #a7f3d0;
  transition: all 0.2s ease;
}

.memorize-part-header.is-hidden-state .header-status {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

.part-crop-window {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: #fffdf9;
}

.part-crop-img {
  position: absolute;
  left: 0;
  width: 100%;
  display: block;
  pointer-events: none;
}

.part-crop-overlay {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: auto;
}

/* Blank mask to white out cross-part words in shared boundary lines */
.part-blank-mask {
  position: absolute;
  background-color: #ffffff;
  z-index: 2;
  pointer-events: none;
  border-radius: 2px;
  box-shadow: 0 0 2px #ffffff;
}

/* Separation margin / divider between parts */
.memorize-part-separator {
  width: 100%;
  margin: 24px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.sep-line {
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.7), transparent);
}

.sep-badge {
  background: rgba(6, 78, 59, 0.96);
  border: 1.5px solid rgba(251, 191, 36, 0.6);
  color: #fef08a;
  padding: 5px 18px;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 800;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  direction: rtl;
}

.sep-badge .sep-star {
  color: #fbbf24;
  font-size: 0.78rem;
}

/* Curtain mask inside crop window */
.part-crop-window .part-mask-curtain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  background: linear-gradient(180deg, #fdfbf7 0%, #f6f1e3 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  cursor: pointer;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.22s ease;
}

.part-crop-window .part-mask-curtain.revealed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Part Mask Curtain */
.part-mask-curtain {
  position: absolute;
  left: 4%;
  width: 92%;
  background: linear-gradient(180deg, #fdfbf7 0%, #f6f1e3 100%);
  border: 1.5px dashed rgba(180, 83, 9, 0.6);
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.24s cubic-bezier(0.4, 0, 0.2, 1), transform 0.24s ease, visibility 0.24s;
  user-select: none;
  direction: rtl;
  padding: 8px;
  box-sizing: border-box;
  overflow: hidden;
}

.part-mask-curtain:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fffefc 0%, #faf5ea 100%);
  box-shadow: inset 0 2px 12px rgba(217, 119, 6, 0.18), 0 6px 20px rgba(0, 0, 0, 0.2);
}

.part-mask-curtain.revealed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985);
}

.part-mask-badge {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 3px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.part-mask-hint {
  font-size: 0.74rem;
  color: #78350f;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Subtle separator line between parts when revealed */
.part-divider-line {
  position: absolute;
  left: 5%;
  width: 90%;
  height: 1px;
  border-top: 1.5px dashed rgba(217, 119, 6, 0.45);
  pointer-events: none;
  z-index: 12;
}

@media (max-width: 768px) {
  body.memorize-mode-on .pure-page-container {
    padding-top: 76px;
  }
  .page-memorize-container {
    padding: 4px 6px 120px 6px;
  }
  .memorize-part-separator {
    margin: 18px 0;
  }
  .sep-badge {
    padding: 4px 12px;
    font-size: 0.76rem;
  }
  .memorize-part-header {
    padding: 5px 10px;
    font-size: 0.78rem;
  }
  .memorize-part-header .header-status {
    font-size: 0.68rem;
    padding: 1px 6px;
  }
  .memorize-floating-bar {
    top: 44px;
    padding: 3px 6px;
    gap: 3px;
    max-width: 96vw;
  }
  .mem-title-tag {
    display: none;
  }
  .mem-btn {
    padding: 3px 5px;
    font-size: 0.67rem;
    gap: 1px;
  }
  .part-mask-badge {
    font-size: 0.76rem;
    padding: 2px 8px;
  }
  .part-mask-hint {
    font-size: 0.68rem;
    padding: 1px 6px;
  }
}


