/* Active tab look */
@font-face {
  font-family: "KFGQPC Uthman Taha Naskh";
  src: url("./UthmanTN_v2-0.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "KFGQPC Uthman Hafs";
  src: url("./uthmanicHafs.otf") format("truetype");
  font-weight: normal;
  font-style: normal;
}
#navigation-options .is-active {
  background-color: #007bff !important;
  color: #fff !important;
  border-color: #007bff !important;
}

/* Search box styles */
#nav-search-wrap {
  position: sticky;
  top: 0;
  background: #f4f4f4;
  padding-bottom: 0.5rem;
  z-index: 1;
}
#nav-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  margin: 0.25rem 0 0.5rem;
  font-size: 0.95rem;
}
#nav-mini-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
#jump-page {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}
body {
  margin: 0;
  display: flex;
  height: 100vh;
  width: 100vw;
  gap: 0;
  padding: 0;
  flex-direction: column;
}

#side-panel {
  width: 15vw;
  background-color: transparent;
  backdrop-filter: blur(10px);
  display: none;
  padding: 1rem;
  border-right: 1px solid #ccc;
  overflow-y: auto;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  display: none; /* start hidden */
  z-index: 900;
  transition: transform 0.3s ease;
  display: none; /* hidden by default */
  bottom: var(--audio-bar-h); /* <— stops before audio bar */
}

#side-panel.is-open {
  display: block;
}
#optionsContainer {
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  direction: rtl;
  right: 0vw;
  z-index: 999;
}
#optionsContainer button {
}

#main-content {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
  overflow-y: auto;
}

#navigation-options {
  display: flex;
  margin-top: 1rem;
  gap: 1rem; /* Add some space between buttons */
}
#navigation-options button {
  border: 2px solid #ccc; /* Subtle border */
  background-color: #f8f8f8; /* Light background */
  color: #333; /* Darker text for contrast */
  height: 2.5rem; /* Consistent height */
  padding: 0.5rem 1rem; /* Inner spacing for a clean look */
  border-radius: 0.5rem; /* Rounded corners */
  font-size: 1rem; /* Legible text size */
  font-family: "Arial", sans-serif; /* Clean font */
  cursor: pointer; /* Pointer cursor for interactivity */
  transition: all 0.3s ease; /* Smooth transitions for hover effects */
}

#navigation-options button:hover {
  background-color: #e0e0e0; /* Slightly darker background on hover */
  border-color: #999; /* Darken the border */
  color: #000; /* Slightly darker text */
  transform: translateY(-2px); /* Subtle lift effect */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Add a shadow for depth */
}

#navigation-options button:active {
  background-color: #d0d0d0; /* Even darker background for active state */
  transform: translateY(0); /* Reset lift effect */
  box-shadow: none; /* Remove shadow */
}

#navigation-content button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem;
  margin: 0.2rem 0;
  border: none;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}

#navigation-content button:hover {
  background-color: #e0e0e0;
}

#tafseer-container {
  font-size: 2rem;
  margin-top: 3%;
}

#page-container {
  width: 100vw;
  height: 98vh;
  /*font-family: "Amiri Quran", serif;*/
  font-family: "Amiri Quran", serif;
  text-align: justify;
  position: relative;
  direction: rtl;
  margin: 0;
  overflow-y: scroll;
  margin-right: 20vw;
  padding: 50px;
  margin-top: 50px;
  padding-bottom: calc(
    var(--audio-bar-h) + 24px
  ); /* keep content clear of the bar */
  line-height: 1.9;
}

#page-content {
  margin-top: 2%;
}

#page-container span {
  display: inline; /* Ensure inline flow for continuous text */
  direction: rtl; /* Text flows right-to-left */
  /* font-size: 1.5rem;  Adjust size for a comfortable fit */
  margin: 0; /* Remove default margins */
  word-wrap: break-word; /* Allow long words to break */

  line-height: 2.4;
}

#page-container span:hover {
}
.surah-header {
  text-align: center;
  font-weight: bold;
  margin: 1%;
}
.ayah-list button {
  display: block;
  padding: 0.5rem;
  margin: 0.2rem 0;
  border: none;
  background: #f8f8f8;
  border-radius: 4px;
  cursor: pointer;
}

.ayah-list button:hover {
  background-color: #e0e0e0;
}
body.page-dark .highlight {
  color: #fff;
  text-shadow:
    0 0 10px #00f,
    /* Initial glow for blue */ 0 0 20px #00f,
    0 0 30px #00f,
    0 0 40px #00f;
  animation: pulse-glow 2s infinite alternate;
}
@keyframes highlight {
  0% {
    text-shadow:
      0 0 10px #00f,
      0 0 20px #00f;
  }
  50% {
    text-shadow:
      0 0 20px #00f,
      0 0 40px #00f,
      0 0 60px #00f;
  }
  100% {
    text-shadow:
      0 0 10px #00f,
      0 0 20px #00f;
  }
}
.playhighlight {
}
.highlight {
}

body.page-dark .playhighlight {
  color: #fff;
  text-shadow:
    0 0 10px #00f,
    /* Initial glow for blue */ 0 0 20px #00f,
    0 0 30px #00f,
    0 0 40px #00f;
  animation: pulse-glow 2s infinite alternate;
}
#ayah-sidebar {
  width: 15vw;
  background-color: #f9f9f9;
  padding: 1rem;
  border-left: 1px solid #ccc;
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  display: none;
  opacity: 1;
}
#toggle-side {
}

#toggle-side .line {
  display: block;
  width: 100%;
  height: 4px;
  background-color: #333;
  border-radius: 2px;
  transition: all 0.3s ease;
}

#ayah-sidebar h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

#ayah-sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem;
  margin: 0.2rem 0;
  border: none;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}

#ayah-sidebar button:hover {
  background-color: #e0e0e0;
}

/* Bottom audio bar */

.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px; /* Reduced gap between audio player and play button */
}

.nav-button {
  background-color: #007bff; /* Blue */
  color: white;
  border: none;
  padding: 5px 15px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}

.nav-button:hover {
  background-color: #0056b3; /* Darker blue on hover */
}

#nav-holder {
  display: flex;
  justify-content: space-around;
  width: 100vw;
  margin: 10px;
}

#audio-player {
  margin: 0 5px; /* Reduced margin for closer alignment */
  width: 60vw;
}

#play-page-button {
  border: none;
  padding: 5px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

#play-page-button:hover {
  background-color: #4f46e5;
}

#ayahTypeSelector {
  display: none;
  margin: 5%;
  font-size: 1rem;
}

#reciter {
  display: none;
  margin: 5%;
  width: 50%;
  font-size: 1rem;
}

#tafseer {
  display: none;
  margin: 5%;
  width: 50%;
  font-size: 1rem;
}

#textControls {
  display: none;
}
/* In style.css */

.surah-playing {
  background-color: #4caf50 !important; /* green */
  color: white !important;
  font-weight: bold;
}

/* ===== Compact, organized audio bar ===== */
:root {
  --ab-bg: #fff;
  --ab-border: #e7e7e7;
  --ab-muted: #6b7280;
  --ab-text: #1f2937;
  --ab-accent: #4f46e5; /* indigo */
  --ab-accent-2: #22c55e; /* green for CTA hover */
  --audio-bar-h: 72px; /* fallback height; JS below will keep it exact */
}

#audio-bar {
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  inset: auto 0 0 0;
  border-top: 1px solid var(--ab-border);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  direction: rtl; /* your app is RTL */
}

#audio-bar.is-hidden {
  transform: translateY(100%); /* slide it off the screen */
  opacity: 0;
  pointer-events: none; /* clicks pass through */
}
#ab-player {
  width: 100%;
}

#ab-player,
#audio-player {
  width: 100%;
  height: 32px;
}

.ab-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 1.4fr 1fr auto; /* L / C / R */
  gap: 12px;
  align-items: center;
}

@media (max-width: 960px) {
  #page-content {
    margin-top: 7%;
  }
  .ab-wrap {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }
}

.ab-left,
.ab-center,
.ab-right {
  display: flex;
  align-items: center;
}
.ab-left {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.ab-right {
  justify-content: flex-end;
}
.ab-center {
  justify-content: center;
  gap: 10px;
}

/* Labels */
.ab-now {
  font-size: 0.9rem;
  color: var(--ab-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ab-page {
  font-size: 0.9rem;
  color: var(--ab-text);
  font-weight: 600;
}

/* Arrows */
.ab-arrow {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--ab-border);
  background: #fafafa;
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition:
    transform 0.08s,
    background 0.2s;
}
.ab-arrow:hover {
  background: #f0f0f0;
}
.ab-arrow:active {
  transform: scale(0.98);
}

/* Segmented control */
.ab-segment {
  display: flex;
  gap: 0;
  border: 1px solid var(--ab-border);
  border-radius: 999px;
  overflow: hidden;
  background: #f9fafb;
}
.ab-seg {
  padding: 8px 14px;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ab-text);
  transition:
    background 0.2s,
    color 0.2s;
}
.ab-seg:hover {
  background: #eef2ff;
}
.ab-seg.is-active {
  background: var(--ab-accent);
  color: #fff;
}

/* CTA */
.ab-cta {
  background: var(--ab-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: clamp(18px, 2.2vw, 26px);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  transition:
    transform 0.06s,
    background 0.2s,
    box-shadow 0.2s;
}
.ab-cta:hover {
  background: #4338ca;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.35);
}
.ab-cta:active {
  transform: scale(0.98);
}

/* Slim down native audio control area */
#audio-player {
  height: 32px;
}

/* Make bar visually slimmer */
#audio-bar .ab-wrap {
  padding-block: 8px;
}

/* Tafseer floating panel */
#tafseer-container {
  position: fixed;
  right: 16px;
  bottom: calc(var(--audio-bar-h, 72px) + 16px); /* keep above audio bar */
  z-index: 1200;
  max-width: 520px;
  width: calc(100vw - 40px);
  pointer-events: none; /* container ignores clicks; panel handles them */
}

.tafseer-panel {
  position: fixed; /* <— fixed to the viewport */
  right: 16px;
  bottom: calc(var(--audio-bar-h, 72px) + 16px); /* starts above bar */
  z-index: 1500;

  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-rows: auto 1fr auto;

  /* resizable */
  resize: both;
  overflow: auto;
  min-width: 280px;
  min-height: 180px;
  max-width: 90vw;
  max-height: 80vh;
  cursor: default;
}

.tafseer-header {
  cursor: move; /* drag handle */
  user-select: none;
}

.tafseer-header {
  cursor: move; /* indicate you can drag by header */
  user-select: none; /* prevent text selection while dragging */
}

.tafseer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}

.tafseer-body {
  padding: 12px;
  overflow: auto;
  line-height: 1.9;
  direction: rtl;
  text-align: justify;

  /* Independent font: Arabic-friendly but not Quranic calligraphy */
  font-family: "Arial", "Segoe UI", "Tahoma", "Noto Naskh Arabic", sans-serif !important;

  /* Size controlled by zoom */
  font-size: var(--tafseer-font-size, 1.05rem);
}

.tafseer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #fafafa;
  border-top: 1px solid #e5e7eb;
}

.tafseer-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.95rem;
}
.tafseer-btn:hover {
  background: #f3f4f6;
}

.tafseer-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}
.tafseer-close:hover {
  color: #ef4444;
}

/* subtle disabled state */
.tafseer-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.tafseer-zoom {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.tafseer-zoom .tafseer-btn {
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* =========================
   DARK MODE BASE
   ========================= */
body.page-dark {
  background-color: #0f172a; /* dark slate background */
  color: #e2e8f0; /* light gray text */
}

body.page-dark #main-content,
body.page-dark #page-container {
  background-color: #0f172a;
  color: #e2e8f0;
}

/* Fix white strip at top */
body.page-dark #nav-search-wrap,
body.page-dark #nav-mini-actions,
body.page-dark #navigation-content {
  background-color: transparent;
  text-align: center;
  color: #e2e8f0;
}

/* =========================
   NAVIGATION + LISTENING BUTTONS (Purple)
   ========================= */
body.page-dark #navigation-options button {
  background-color: #2e1065;
  border: 1px solid #6d28d9;
  color: #e9d5ff;
}
body.page-dark #navigation-options button:hover {
  background-color: #4c1d95;
  border-color: #7c3aed;
  color: #fff;
}
body.page-dark #navigation-options button.is-active {
  background-color: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
  font-weight: bold;
}

/* Listening mode surah buttons */
body.page-dark #page-content button[data-surah] {
  background-color: #2e1065;
  border: 1px solid #6d28d9;
  color: #e9d5ff;
}
body.page-dark #page-content button[data-surah]:hover {
  background-color: #4c1d95;
  border-color: #7c3aed;
  color: #fff;
}
body.page-dark #page-content button[data-surah].surah-playing {
  background-color: #7c3aed;
  color: #fff;
  font-weight: bold;
}

/* =========================
   AUDIO BAR (Blue Theme)
   ========================= */
body.page-dark #audio-bar {
  background-color: #1e293b; /* dark navy bar */
  border-top: 1px solid #334155;
}

body.page-dark .nav-button,
body.page-dark .ab-seg {
  background-color: #1d4ed8; /* blue */
  border: 1px solid #2563eb;
  color: #f8fafc;
}
body.page-dark .nav-button:hover,
body.page-dark .ab-seg:hover {
  background-color: #2563eb; /* brighter blue */
  border-color: #3b82f6;
}
body.page-dark .nav-button.is-active,
body.page-dark .ab-seg.is-active {
  background-color: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: bold;
}

/* =========================
   SIDEBAR IN DARK MODE
   ========================= */
body.page-dark #side-panel {
  background-color: transparent; /* dark background */
  border-left: 1px solid #334155;
  backdrop-filter: blur(10px);
  color: #e2e8f0;
}

/* Sidebar header buttons (Pages, Surahs, Options) already styled above */

/* Sidebar list buttons (page numbers, surahs, ayahs) */
body.page-dark #navigation-content button,
body.page-dark #ayah-sidebar button {
  background-color: #2e1065;
  border: 1px solid #6d28d9;
  color: #e9d5ff;
}

body.page-dark #navigation-content button:hover,
body.page-dark #ayah-sidebar button:hover {
  background-color: #4c1d95;
  border-color: #7c3aed;
  color: #fff;
}

body.page-dark #navigation-content button.is-active,
body.page-dark #ayah-sidebar button.is-active {
  background-color: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
  font-weight: bold;
}

/* Sidebar search + jump inputs */
body.page-dark #nav-search,
body.page-dark #jump-page {
  background-color: #0f172a;
  border: 1px solid #334155;
  color: #f1f5f9;
}
body.page-dark #nav-search::placeholder,
body.page-dark #jump-page::placeholder {
  color: #94a3b8;
}

/* =========================
   DARK MODE — TAFSEER PANEL
   ========================= */
body.page-dark .tafseer-panel {
  background: #0f172a; /* dark slate body */
  border: 1px solid #334155; /* slate border */
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  color: #e5e7eb; /* light text */
}

body.page-dark .tafseer-header {
  background: #1f2937; /* darker header */
  border-bottom: 1px solid #334155;
  color: #e5e7eb;
}

body.page-dark .tafseer-body {
  background: transparent;
  color: #e5e7eb;
  /* nice selection colors */
  --sel-bg: rgba(124, 58, 237, 0.28); /* purple-ish selection */
  --sel-fg: #f8fafc;
}
body.page-dark .tafseer-body ::selection {
  background: var(--sel-bg);
  color: var(--sel-fg);
}

/* Scrollbar (WebKit) */
body.page-dark .tafseer-body::-webkit-scrollbar {
  width: 10px;
}
body.page-dark .tafseer-body::-webkit-scrollbar-track {
  background: #0b1220;
}
body.page-dark .tafseer-body::-webkit-scrollbar-thumb {
  background: #374151; /* slate thumb */
  border-radius: 8px;
}
body.page-dark .tafseer-body::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

body.page-dark .tafseer-footer {
  background: #111827; /* footer strip */
  border-top: 1px solid #334155;
  color: #cbd5e1;
}

/* Buttons in panel: purple theme to match your UI */
body.page-dark .tafseer-btn {
  background: #2e1065;
  border: 1px solid #6d28d9;
  color: #e9d5ff;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}
body.page-dark .tafseer-btn:hover {
  background: #4c1d95;
  border-color: #7c3aed;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}
body.page-dark .tafseer-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Zoom buttons are also tafseer-btn, so they inherit the purple style */

/* Close button keeps danger affordance */
body.page-dark .tafseer-close {
  color: #cbd5e1;
}
body.page-dark .tafseer-close:hover {
  color: #ef4444; /* red on hover */
}

/* Focus rings (keyboard users) */
body.page-dark .tafseer-btn:focus-visible,
body.page-dark .tafseer-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35); /* blue focus */
  border-color: #3b82f6;
}

/* Dark Mode - Listening Mode Surah Buttons (override inline styles) */
body.page-dark #page-content button[data-surah] {
  background-color: #3b0764 !important; /* deep purple */
  color: #f3e8ff !important; /* lavender text */
  border: 1px solid #6d28d9 !important; /* purple border */
}

body.page-dark #page-content button[data-surah]:hover {
  background-color: #5b21b6 !important; /* brighter purple */
  border-color: #7c3aed !important;
}

body.page-dark #page-content button[data-surah].surah-playing {
  background-color: #7c3aed !important; /* active */
  color: #ffffff !important;
  font-weight: 900;
}

/* Images/embeds scale down */
img,
video,
audio,
canvas {
  max-width: 100%;
  height: auto;
}

/* Let the reading area and audio bar shrink on small screens */
#page-container {
  width: 100%;
}

/* iOS safe areas (prevents content under notches/home bar) */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
#audio-bar {
  padding-bottom: calc(8px + var(--safe-bottom));
}

/* ---------- Tablets & small laptops (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  /* Sidebar narrower when open */
  body.sidebar-open #page-container {
    margin-right: 260px; /* instead of 20vw */
  }
  #side-panel {
    width: 260px;
    max-width: 260px;
  }

  /* Audio bar tighter */
  #audio-bar .ab-wrap {
    max-width: 100%;
    padding: 8px;
    grid-template-columns: 1fr 1fr; /* stack a bit */
    row-gap: 8px;
  }

  /* Listening grid: bigger taps */
  #page-content button[data-surah] {
    padding: 0.7rem 0.9rem;
  }
}

/* ---------- Large phones & portrait tablets (≤ 768px) ---------- */
@media (max-width: 768px) {
  /* Sidebar becomes overlay; content uses full width even when open */
  body.sidebar-open #page-container {
    margin-right: 0;
  }
  #side-panel {
    width: 88vw; /* slide-in panel */
    max-width: none;
  }

  /* Reading area padding smaller */
  #page-container {
    padding: 20px;
    padding-bottom: calc(var(--audio-bar-h, 72px) + 24px);
    margin-top: 16px;
  }

  /* Surah headers slightly smaller */
  .surah-header {
  }

  /* Audio bar: single column stack */
  #audio-bar .ab-wrap {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }
  /* Center the page controls row */
  .ab-center {
    justify-content: space-between;
  }

  /* Nav segmented buttons bigger for touch */
  .ab-seg {
    padding: 10px 14px;
  }

  /* Listening grid: fewer columns */
  #page-content > div[style*="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 8px !important;
  }

  /* Make search/jump inputs easier to use */
  #nav-search,
  #jump-page {
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
  }
}

/* ---------- Small phones (≤ 480px) ---------- */
@media (max-width: 480px) {
  #page-content {
    margin-top: 7%;
  }
  /* Bigger tap targets */
  button,
  .nav-button,
  .ab-seg,
  #play-page-button {
    min-height: 42px;
    font-size: 0.95rem;
  }

  /* Tighten the reading padding further */
  #page-container {
    padding: 16px;
  }

  /* Listening grid single/dual column */
  #page-content > div[style*="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
  }

  /* Audio element full width */
  #audio-player {
    width: 100%;
  }
}

/* Base size scales with viewport; your slider still overrides inline sizes */
html {
  font-size: clamp(14px, 2.2vw, 18px);
}

/* Quran line height a bit tighter on phones */
@media (max-width: 480px) {
  #page-content {
    margin-top: 7%;
  }
  #page-container span {
    line-height: 2;
  }
}

/* Only apply hover color on devices that actually have hover */
@media (hover: hover) {
  #page-container span:hover {
  } /* your existing style */
}

/* ---------- Responsive Tafseer panel ---------- */

/* Base variables (already in your CSS, but we reference them here) */
:root {
  --audio-bar-h: 72px; /* JS keeps this in sync */
  --options-h: 56px; /* top navbar height; set by your layout or JS */
  --tafseer-min-w: 280px;
  --tafseer-min-h: 180px;
}

/* Default (desktop) – floating, resizable */
.tafseer-panel {
  position: fixed;
  right: 16px;
  bottom: calc(var(--audio-bar-h, 72px) + 16px);
  z-index: 1500;
  pointer-events: auto;

  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);

  display: grid;
  grid-template-rows: auto 1fr auto;

  resize: both;
  overflow: auto;
  min-width: var(--tafseer-min-w);
  min-height: var(--tafseer-min-h);
  max-width: 90vw;
  max-height: calc(90vh - var(--options-h, 56px) - var(--audio-bar-h, 72px));
}

/* Tablet: slightly wider/taller, bigger touch targets */
@media (max-width: 1024px) {
  .tafseer-panel {
    right: 12px;
    bottom: calc(var(--audio-bar-h, 72px) + 12px);
    max-width: 92vw;
    max-height: calc(88vh - var(--options-h, 56px) - var(--audio-bar-h, 72px));
  }
  .tafseer-header {
    padding: 12px 14px;
  }
  .tafseer-footer {
    padding: 10px 14px;
  }
  .tafseer-btn {
    padding: 8px 12px;
    font-size: 1rem;
  }
}

/* Phone: transform into a bottom-sheet style (still draggable if you want),
   fills width, comfortable height, never under top navbar or audio bar. */
@media (max-width: 768px) {
  #page-content {
    margin-top: 7%;
  }
  .tafseer-panel {
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 96vw; /* nearly full width */
    max-width: 600px; /* cap on large phones */
    bottom: calc(var(--audio-bar-h, 72px) + 8px);
    border-radius: 12px;
    max-height: calc(80vh - var(--options-h, 56px));
  }
  .tafseer-header {
    padding: 12px;
    font-size: 1rem;
  }
  .tafseer-body {
    padding: 12px;
    line-height: 1.9;
    font-size: var(--tafseer-font-size, 1.05rem);
  }
  .tafseer-footer {
    padding: 10px 12px;
    gap: 10px;
  }
  .tafseer-zoom .tafseer-btn {
    padding: 6px 10px;
    font-size: 0.95rem;
  }
}

/* Very small phones: nearly full-screen sheet */
@media (max-width: 420px) {
  #page-content {
    margin-top: 7%;
  }
  .tafseer-panel {
    width: 98vw;
    left: 1vw;
    right: 1vw;
    max-height: calc(88vh - var(--options-h, 56px));
    bottom: calc(var(--audio-bar-h, 72px) + 6px);
  }
}

/* Respect dark mode */
body.dark-page .tafseer-panel {
  background: #0f172a; /* slate-900-ish */
  color: #e5e7eb;
  border-color: #1f2937;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
body.dark-page .tafseer-header {
  background: #111827;
  border-bottom: 1px solid #1f2937;
}
body.dark-page .tafseer-footer {
  background: #0b1220;
  border-top: 1px solid #1f2937;
}
body.dark-page .tafseer-btn {
  background: #1b2540;
  color: #e5e7eb;
  border-color: #2a3550;
}
body.dark-page .tafseer-btn:hover {
  background: #243055;
  border-color: #3a4a74;
}
body.dark-page .tafseer-close:hover {
  color: #f87171; /* soft red */
}

:root {
  --dlg-bg: rgba(255, 255, 255, 0.9);
  --dlg-text: #0f172a;
  --dlg-border: rgba(13, 110, 253, 0.35);
  --dlg-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  --dlg-hover: rgba(13, 110, 253, 0.12);
}

body.page-dark {
  --dlg-bg: rgba(17, 24, 39, 0.9);
  --dlg-text: #e5e7eb;
  --dlg-border: rgba(59, 130, 246, 0.35);
  --dlg-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  --dlg-hover: rgba(59, 130, 246, 0.18);
}

/* ensure the ayah span can anchor an absolute child without changing layout */
#page-content span {
  position: relative;
}

.ayah-dialog {
  z-index: 1000;
  display: inline-block;
  align-items: center;
  margin-left: 5px;
  gap: 6px;
  padding: 6px 8px;
  color: var(--dlg-text);
  background: var(--dlg-bg);
  border: 1px solid var(--dlg-border);
  border-radius: 999px; /* pill */
  box-shadow: var(--dlg-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}

/* Arrow on the right side */
.ayah-dialog::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -6px; /* outside the pill on the right */
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--dlg-bg);
  border-right: 1px solid var(--dlg-border);
  border-top: 1px solid var(--dlg-border);
}

/* Flip below if needed (JS toggles .below) */
.ayah-dialog.below {
  top: auto;
  bottom: -0.5rem;
  transform: translate(-50%, 100%);
}
.ayah-dialog.below::after {
  bottom: auto;
  top: -6px;
  border-right: 1px solid var(--dlg-border);
  border-top: 1px solid var(--dlg-border);
  border-bottom: none;
}

.ayah-dialog button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 150ms ease,
    transform 80ms ease;
}
.ayah-dialog button:hover {
  background: var(--dlg-hover);
}
.ayah-dialog button:active {
  transform: translateY(1px);
}

/* small vertical divider if you want it */
.ayah-dialog .sep {
  width: 1px;
  height: 18px;
  background: rgba(0, 0, 0, 0.08);
}
body.page-dark .ayah-dialog .sep {
  background: rgba(255, 255, 255, 0.12);
}

@keyframes ayah-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -90%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
}

/* motion-friendly */
@media (prefers-reduced-motion: reduce) {
  .ayah-dialog {
    animation: none;
  }
}

/* ===== Options container – friendlier look ===== */
#optionsContainer {
  position: sticky;
  top: 0;
  inset-inline: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #e5e7eb;
  z-index: 1200;
}

#optionsContainer button {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 0.45rem 0.65rem;
  border-radius: 0.6rem;
  cursor: pointer;
  color: black;
}

/* Segmented mode switch */
#mode-switch {
  display: inline-flex;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  overflow: hidden;
  background: #f9fafb;
}
#mode-switch .seg {
  padding: 0.45rem 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}
#mode-switch .seg:hover {
  background: #eef2ff;
}
#mode-switch .seg.is-active {
  background: #4f46e5;
  color: #fff;
}

/* ===== Edge badges (Juzz left / Surah right) ===== */
.edge-badge {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.55rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 1100;
  cursor: pointer;
  font-weight: 700;
  max-width: 24vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edge-left {
  left: 8px;
}
.edge-right {
  right: 8px;
}

/* ===== Big center-left/right page floaters ===== */
.page-floater {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(44px, 5vw, 64px);
  height: clamp(44px, 5vw, 64px);
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: transparent;
  opacity: 0.2;
  display: grid;
  place-items: center;
  font-size: clamp(18px, 2.5vw, 28px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1150;
  cursor: pointer;
  transition:
    transform 0.06s,
    background 0.2s;
}
.page-floater:hover {
  background: #fff;
  opacity: 1;
}
.page-floater:active {
  transform: translateY(-50%) scale(0.98);
}
.page-left {
  left: 16px;
}
.page-right {
  right: 16px;
}

/* Make sure the reading area never hides under the audio bar */
#page-container {
  padding-bottom: calc(var(--audio-bar-h) + 24px);
}

/* Audio bar small layout nips due to left/right swap */
.ab-left {
  align-items: flex-start;
  gap: 6px;
}
.ab-right {
  justify-content: flex-end;
}

body.page-dark #play-page-button:hover {
  background-color: #4f46e5;
}

/* Dark mode variants */
body.page-dark #optionsContainer {
  background: rgba(2, 6, 23, 0.6);
  border-color: #334155;
}
body.page-dark #optionsContainer button {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
body.page-dark #mode-switch {
  border-color: #334155;
  background: #111827;
}
body.page-dark #mode-switch .seg:hover {
  background: #1f2937;
}
body.page-dark .edge-badge,
body.page-dark .page-floater {
  background: #0f172ad9;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* === Pin Juzz & Surah at far left/right; keep others centered === */
#optionsContainer {
  /* keep your sticky/background/etc; we only override layout */
  display: grid !important;
  grid-template-columns: auto 1fr auto; /* left | center | right */
  align-items: center;
  gap: 0.75rem;
}

#options-center {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap; /* avoids squish on small screens */
}

/* ensure badges sit at extremes */
#juzz-badge {
  justify-self: start;
}
#surah-badge {
  justify-self: end;
}

/* simple badge look (if not already styled) */
#optionsContainer .badge {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

/* dark mode */
body.page-dark #optionsContainer .badge {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* small screens: keep center from colliding with edges */
@media (max-width: 600px) {
  #page-content {
    margin-top: 7%;
  }
  #options-center {
    gap: 0.5rem;
  }
  #optionsContainer .badge {
    padding: 0.35rem 0.6rem;
  }
}

/* ===== FINAL OVERRIDE: options bar layout & badge insets ===== */
#optionsContainer {
  /* Strong, predictable layout */
  display: grid !important;
  position: sticky !important;
  grid-template-columns: 1fr auto 1fr !important; /* left | center | right */
  align-items: center !important;

  /* pull bar in from edges a touch */
  padding-inline: clamp(16px, 4vw, 48px) !important;

  /* neutralize RTL flipping for layout math only */
  direction: ltr !important;
}

/* center block (your toggles + mode switch) sits in the middle column */
#options-center {
  grid-column: 2 !important;
  justify-self: center !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  flex-wrap: wrap; /* avoid squish on small screens */
}

/* badges at far sides, slightly inset */
#juzz-badge {
  grid-column: 1 !important;
  justify-self: start !important;
  text-align: center;
}
#surah-badge {
  grid-column: 3 !important;
  justify-self: end !important;
  text-align: center;
}

/* simple badge look (in case other rules conflict) */
#optionsContainer .badge {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

/* dark mode keeps working */
body.page-dark #optionsContainer .badge {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* small screens: tiny tighten */
@media (max-width: 600px) {
  #optionsContainer {
    padding-inline: clamp(10px, 4vw, 28px) !important;
  }
  #juzz-badge {
    margin-left: clamp(8px, 3vw, 20px) !important;
  }
  #surah-badge {
    margin-right: clamp(8px, 3vw, 20px) !important;
  }
}

/* --- Kill the double scrollbar: let the PAGE scroll, not inner divs --- */
html,
body {
  height: auto !important;
}
body {
  min-height: 100vh !important;
  overflow-y: auto !important; /* only the page scrolls */
  overflow-x: hidden !important; /* prevent horizontal jiggle */
}

/* Inner containers should not create their own scrollbars */
#main-content {
  height: auto !important;
  overflow: visible !important;
}

#page-container {
  height: auto !important;
  overflow: visible !important;
  /* keep your existing bottom padding so content doesn't sit under the audio bar */
  /* padding-bottom: calc(var(--audio-bar-h) + 24px); (you already have this) */
}

/* Put the side navigation ABOVE the options container when toggled */
#side-panel {
  position: fixed; /* already, but we assert it */
  top: 0 !important; /* start at the very top so it covers the sticky bar */
  right: 0;
  bottom: var(--audio-bar-h); /* keep your existing stop above audio bar */
  z-index: 2000 !important; /* higher than #optionsContainer (1200) */
}

/* If you also use the old #ayah-sidebar sometimes, lift it too */
#ayah-sidebar {
  z-index: 2000 !important;
}

/* --- Center-only audio bar --- */
:root {
  --audio-bar-h: 76px; /* actual bar height */
  --page-pill-h: 38px; /* height of page number pill */
}

#audio-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
}

/* make the wrapper just center one thing */
#ab-player {
  width: 100%;
} /* safety */
.ab-wrap.simple {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

/* nicer player look (limited by browser controls) */
#audio-player {
  width: min(780px, 92vw);
  height: 40px;
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px #e5e7eb;
  overflow: hidden;
}

/* Dark mode */
body.page-dark #audio-bar {
  background: rgba(15, 23, 42, 0.78);
  border-top-color: #334155;
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.35);
}

/* --- Page number pill just above the bar --- */
#page-number {
  position: sticky;
  bottom: calc(var(--audio-bar-h) + 8px);
  z-index: 1100;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #111827;
  background: transparent;
  opacity: 0.2;
}

#page-number:hover {
  opacity: 1;
}

body.page-dark #page-number {
  color: #e2e8f0;
}

/* keep reading area clear of both the pill and the bar */
#page-container {
  padding-bottom: calc(
    var(--audio-bar-h) + var(--page-pill-h) + 28px
  ) !important;
}

/* === NAV SIDE PANEL: responsive width, no X-scroll === */
#side-panel {
  /* responsive, but never wider than the viewport */
  width: clamp(260px, 28vw, 420px);
  max-width: 92vw;
  overflow-x: hidden !important; /* kill horizontal scroll */
  overflow-y: auto; /* vertical scroll only */
  box-sizing: border-box;
  padding: 1rem; /* keep your padding */
  right: 0; /* stay docked to the right */
  bottom: var(--audio-bar-h); /* stop above audio bar (you already had this) */
}

/* small screens: side panel is a wide sheet but still no X-scroll */
@media (max-width: 768px) {
  #side-panel {
    width: min(88vw, 520px);
  }
}

/* === TOP TABS inside the panel auto-fit (Pages / Surahs / Juzz / Options) === */
#navigation-options {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); /* auto-wrap */
  gap: 0.6rem !important;
  margin: 0.5rem 0 1rem !important;
}
#navigation-options button {
  width: 100%;
  min-width: 0; /* allow shrinking */
  max-width: 100%;
  padding: 0.6rem 0.8rem;
  line-height: 1.2;
  font-size: clamp(16px, 1.6vw, 22px); /* scales with screen */
  white-space: nowrap; /* short labels stay on one line */
}

/* === LIST AREA BUTTONS auto-size and never overflow horizontally === */
#navigation-content {
  overflow-x: hidden;
  background-color: transparent;
  text-align: center;
}
#navigation-content button {
  width: 100%;
  min-width: 0; /* critical for flex/grid shrink */
  max-width: 100%;
  display: block;
  text-align: start;
  padding: 0.6rem 0.8rem;
  line-height: 1.25;
  white-space: normal; /* allow wrapping for long Surah names */
  word-break: break-word; /* Arabic/long words wrap instead of pushing width */
}

/* === Ensure the page itself can’t be pushed wider than the viewport === */
html,
body {
  overflow-x: hidden !important;
}

/* You had a fixed margin that can cause horizontal scroll when the panel is fixed.
   Remove it so the panel overlays instead of forcing the layout wider. */
#page-container {
  margin-right: 0 !important;
  width: 100% !important;
}

/* === ONE-LINE, AUTO-SHRINK OPTIONS BAR === */
#optionsContainer {
  position: fixed !important;
  top: 0;
  inset-inline: 0;

  /* single row, three zones: left | center | right */
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
  align-items: center !important;

  /* shrink-friendly spacing */
  gap: clamp(4px, 1.2vw, 12px) !important;
  padding-inline: clamp(8px, 3vw, 24px) !important;

  /* never wrap to a second line */
  white-space: nowrap !important;
  overflow: hidden !important;

  /* layout math in LTR; your content stays RTL visually */
  direction: ltr !important;

  z-index: 1200;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #e5e7eb;
}

/* center cluster is one line and can shrink */
#options-center {
  grid-column: 2 !important;
  justify-self: center !important;

  display: inline-flex !important;
  align-items: center !important;
  gap: clamp(4px, 1vw, 12px) !important;
  flex-wrap: nowrap !important;

  min-width: 0 !important; /* allow shrinking */
  overflow: hidden !important;
}

/* left/right badges: allow them to shrink and ellipsize */
#juzz-badge {
  grid-column: 1 !important;
  justify-self: start !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
#surah-badge {
  display: flex;
  flex-direction: column;
  justify-self: end !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 0%;
  max-height: 100%;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* make every control shrink-friendly */
#optionsContainer button,
#mode-switch .seg {
  /* scale paddings & font-size with viewport */
  padding: clamp(4px, 0.7vw, 8px) clamp(6px, 1.2vw, 12px) !important;
  font-size: clamp(12px, 1.6vw, 16px) !important;
  line-height: 1 !important;

  /* allow shrinking before overflow */
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 0 1 auto !important;
}

/* segmented control stays on one line and can compress */
#mode-switch {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  min-width: 0 !important;
}
#mode-switch .seg {
  min-width: 0 !important; /* critical to allow shrink */
  white-space: nowrap !important;
}

/* keep icons tight but tappable */
#toggle-side,
#toggle-audio,
#toggle-theme {
  width: auto !important;
  aspect-ratio: auto !important;
}

/* optional: slightly tighter gap on very small screens */
@media (max-width: 420px) {
  #page-content {
    margin-top: 7%;
  }
  #optionsContainer {
    gap: 4px !important;
  }
  #options-center {
    gap: 4px !important;
  }
}

/* Revision mode helpers */
.rev-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.rev-btn {
  padding: 0.35rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  cursor: pointer;
  background: purple;
}
.rev-btn[disabled] {
  opacity: 0.5;
  cursor: default;
}
.rev-btn:hover {
  background: deeppink;
}
.ayah-no {
  opacity: 0.7;
}
.ayah-text.rev-correct {
  color: #16a34a;
} /* green-600 */
.ayah-text.rev-wrong {
  color: #dc2626;
} /* red-600 */
.rev-mark {
  margin-inline-start: 0.35rem;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 1rem;
}
/* NEW: number color when hidden or shown */
.ayah-no.rev-correct {
  color: #16a34a;
}
.ayah-no.rev-wrong {
  color: #dc2626;
}

/* Compact, inline variant of the existing ayah dialog */
.ayah-dialog.rev-dialog {
  position: static; /* sits inline, not absolute */
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.35rem; /* smaller */
  transform: none;
  box-shadow: var(--dialog-shadow, 0 6px 18px rgba(0, 0, 0, 0.07));
  font-size: 0.9em;
  margin-left: 3%;
}

/* keep the same “pill” vibe but smaller */
.ayah-dialog.rev-dialog button {
  background: transparent; /* same visual language as your dialog icons */
  border: 0;
  cursor: pointer;
  line-height: 1;
  padding: 0.15rem 0.25rem;
}

.ayah-dialog.rev-dialog button:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.rev-quiet:hover {
  background: transparent !important;
  box-shadow: none !important;
  color: yellowgreen;
}

/* No hover/hand cursor on ayahs while revising */
#page-content.revise-mode span[data-surah-no][data-ayah-no] {
  cursor: default !important;
}

/* Neutralize any hover highlight effects you may have */
#page-content.revise-mode span[data-surah-no][data-ayah-no]:hover {
  background: transparent !important;
  box-shadow: none !important;
  text-decoration: none !important;
  outline: none !important;
}

/* Keep buttons clickable but avoid accidental text interactions */
#page-content.revise-mode .ayah-text,
#page-content.revise-mode .ayah-no {
  user-select: none;
}
/* Animated reveal for revise mode */
.ayah-text {
  overflow: hidden;
  max-height: 0; /* collapsed */
  opacity: 0;
  transform: translateY(-4px);
  transition:
    max-height 0.28s ease,
    opacity 0.22s ease,
    transform 0.22s ease;
}

/* Expanded state */
.ayah-text.is-open {
  max-height: 2000px; /* big enough for long ayahs */
  opacity: 1;
  transform: none;
}

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .ayah-text {
    transition: none !important;
  }
}

/* --- Filter-driven animation (does NOT conflict with .is-open) --- */

/* Base transition (keeps your existing .is-open behavior intact) */
.ayah-text {
  transition:
    max-height 260ms ease,
    opacity 220ms ease,
    transform 220ms ease,
    margin 220ms ease;
  will-change: max-height, opacity, transform, margin;
}

/* Hidden by filter (master off or category unchecked) */
.ayah-text.is-filtered-out {
  max-height: 0 !important; /* collapse smoothly */
  opacity: 0 !important; /* fade out */
  transform: translateY(-6px); /* slight lift up as it fades */
  margin-top: 0 !important;
  pointer-events: none;
}

/* When becoming visible via filter, play a subtle pop-in */
.ayah-text.filter-reveal {
  animation: ayah-filter-reveal 220ms ease-out;
}
@keyframes ayah-filter-reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Optional: tiny stagger for nicer waves (set via inline style or CSS var) */
.ayah-text[style*="--stagger-idx"] {
  transition-delay: calc(var(--stagger-idx, 0) * 12ms);
}

/* ====== Responsive checkbox chips for revision filters ====== */

/* Grid wrapper */
.rev-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(6px, 1vw, 12px);
  align-items: center;
  justify-items: start;
  max-width: min(100%, 720px);
}

/* Chip label */
.cb-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  padding: clamp(6px, 0.8vw, 10px) clamp(10px, 1.2vw, 14px);
  border-radius: 999px;
  min-height: 40px; /* comfy tap size */
  font-size: clamp(13px, 1.8vw, 15px);
  line-height: 1;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease,
    transform 60ms ease;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* Native checkbox (kept visible for a11y, but styled small) */
.cb-chip > input[type="checkbox"] {
  inline-size: 18px;
  block-size: 18px;
  accent-color: #4f46e5; /* indigo */
  margin: 0; /* align nicely */
  flex: 0 0 auto;
  border-radius: 4px;
}

/* Label text */
.cb-chip > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hover/active */
.cb-chip:hover {
  background: #f9fafb;
  border-color: #c7d2fe; /* light indigo edge */
}
.cb-chip:active {
  transform: translateY(1px);
}

/* Focus ring (keyboard) */
.cb-chip:has(input[type="checkbox"]:focus-visible) {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
  border-color: #6366f1;
}

/* Checked state: stronger pill */
.cb-chip:has(input[type="checkbox"]:checked) {
  background: #eef2ff; /* indigo-50 */
  border-color: #6366f1; /* indigo-500 */
  color: #111827;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15) inset;
}

/* Disabled state (if you ever disable master from JS) */
.cb-chip:has(input[disabled]) {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Tighten on very small screens */
@media (max-width: 420px) {
  .rev-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .cb-chip {
    min-height: 38px;
    padding: 6px 10px;
  }
}

/* Dark mode */
body.page-dark .cb-chip {
  background: #0f172a; /* slate-900 */
  border-color: #334155; /* slate-700 */
  color: #e2e8f0; /* slate-200 */
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
body.page-dark .cb-chip:hover {
  background: #111827; /* slate-800 */
  border-color: #475569; /* slate-600 */
}
body.page-dark .cb-chip:has(input[type="checkbox"]:checked) {
  background: #1e293b; /* slate-800/700 */
  border-color: #7c3aed; /* purple-600 to match your theme */
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.28) inset;
  color: #f3e8ff; /* lavender text */
}
body.page-dark .cb-chip:has(input[type="checkbox"]:focus-visible) {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35); /* blue focus */
  border-color: #3b82f6;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cb-chip {
    transition: none !important;
  }
}

/* If your options bar squishes: allow the chip row to shrink gracefully */
#options-center .rev-filters {
  min-width: 0;
}

/* ===== Responsive Rev Buttons ===== */

.rev-toolbar {
  display: flex;
  flex-wrap: nowrap; /* wrap on small screens */
  gap: clamp(6px, 1vw, 10px);
  align-items: center;
}

/* Base button */
.rev-btn {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  /* Responsive sizing */
  font-size: clamp(13px, 1.6vw, 15px);
  padding: clamp(6px, 0.9vw, 10px) clamp(10px, 1.4vw, 14px);
  min-height: 40px; /* comfy tap target */
  min-width: clamp(92px, 14vw, 140px);

  transition:
    transform 60ms ease,
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* Hover/active */
.rev-btn:hover {
  background: #f9fafb;
  border-color: #c7d2fe;
}
.rev-btn:active {
  transform: translateY(1px);
}

/* Focus (keyboard) */
.rev-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
  border-color: #6366f1;
}

/* Disabled */
.rev-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Icon-only (square) */
.rev-btn.rev-icon {
  min-width: auto;
  width: clamp(38px, 6vw, 44px);
  height: clamp(38px, 6vw, 44px);
  padding: 0;
  border-radius: 12px;
}

/* Block (full-width on small screens) */
@media (max-width: 520px) {
  .rev-btn.rev-block {
    width: 100%;
    min-width: 0;
  }
}

/* Size variants */
.rev-btn.rev-sm {
  font-size: clamp(12px, 1.4vw, 14px);
  min-height: 36px;
  padding: 6px 10px;
  min-width: clamp(84px, 12vw, 120px);
}
.rev-btn.rev-lg {
  font-size: clamp(14px, 1.9vw, 16px);
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 12px;
  min-width: clamp(110px, 18vw, 160px);
}

/* Color variants (match your palette) */
.rev-btn.rev-primary {
  background: #4f46e5; /* indigo */
  color: #fff;
  border-color: #4f46e5;
}
.rev-btn.rev-primary:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.rev-btn.rev-ghost {
  background: transparent;
  color: #374151;
  border-color: #d1d5db;
}
.rev-btn.rev-ghost:hover {
  background: #f3f4f6;
}

.rev-btn.rev-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.rev-btn.rev-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Compact groups (no double borders when adjacent) */
.rev-toolbar .rev-btn {
  position: relative;
}
.rev-toolbar .rev-btn + .rev-btn {
  margin-inline-start: 0;
}

/* Dark mode */
body.page-dark .rev-btn {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
body.page-dark .rev-btn:hover {
  background: #111827;
  border-color: #475569;
}
body.page-dark .rev-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35); /* blue focus */
  border-color: #3b82f6;
}
body.page-dark .rev-btn.rev-primary {
  background: #7c3aed; /* your purple accent */
  border-color: #7c3aed;
  color: #fff;
}
body.page-dark .rev-btn.rev-primary:hover {
  background: #6d28d9;
  border-color: #6d28d9;
}
body.page-dark .rev-btn.rev-ghost {
  background: transparent;
  border-color: #334155;
  color: #e2e8f0;
}
body.page-dark .rev-btn.rev-ghost:hover {
  background: #1f2937;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .rev-btn {
    transition: none !important;
  }
}

/* Keep the three zones, but let center flex and badges be capped */
#optionsContainer {
  grid-template-columns: max-content 1fr max-content !important;
}

/* Kill the big offsets that push badges over the center */
#juzz-badge {
  margin-left: 0% !important;
  min-width: 0 !important;
  max-inline-size: clamp(90px, 28vw, 42vw); /* cap width on small screens */
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center;
  font-size: clamp(12px, 1.6vw, 16px);
}
/* Kill the big offsets that push badges over the center */
#surah-badge {
  margin-right: 0% !important;
  margin-inline-end: clamp(
    20px,
    4vw,
    40px
  ) !important; /* small gap from edge */
  min-width: 0 !important;
  max-inline-size: clamp(90px, 28vw, 42vw); /* cap width on small screens */
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center;
  font-size: clamp(12px, 0.2vw, 16px) !important;
}

/* Center cluster must be allowed to shrink instead of forcing overlap */
#options-center {
  min-width: 0 !important;
  overflow: hidden; /* trims if needed, avoids pushing badges */
}

/* Tiny phones: cap badges a bit more */
@media (max-width: 420px) {
  #juzz-badge,
  #surah-badge {
    max-inline-size: clamp(80px, 24vw, 36vw);
  }
}
/* Help tooltip */
.rev-help-wrap {
  position: relative;
  display: inline-block;
}

.rev-help {
  border: 1px solid #ccc;
  background: #fff;
  cursor: default;
  padding: 0.2rem 0.45rem;
  border-radius: 0.45rem;
  font-weight: 700;
  line-height: 1;
}

.rev-help-tip {
  direction: ltr;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  display: none;
  z-index: 1000;

  /* wider tooltip so each shortcut fits on one line */
  width: 520px; /* increase if you want even wider */
  max-width: none;

  background: #111;
  color: #fff;
  padding: 0.8rem 0.9rem;
  border-radius: 0.55rem;
  border: 3px solid #444; /* thicker border by default */
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.95rem;
}

.rev-help-wrap:hover .rev-help-tip {
  display: block;
  border-width: 4px; /* larger border width on hover */
}

/* List layout: keep each shortcut on a single line */
.rev-help-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.rev-help-list li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap; /* force single line per item */
}

/* Keyboard key styling */
.rev-help-tip kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #222;
  color: #fff;
  padding: 0.06rem 0.4rem;
  border-radius: 0.3rem;
  border: 1px solid #333;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}
/* Hide the ? help on touch/mobile by default */
.rev-help-wrap {
  display: none;
}

/* Show it only on desktop-like devices (hover + fine pointer = mouse) */
@media (hover: hover) and (pointer: fine) {
  .rev-help-wrap {
    display: inline-block;
  }
}
/* Default: HIDE everywhere */
.rev-help-wrap {
  display: none !important;
}

/* Show ONLY on desktop-like devices (mouse + hover) */
@media (any-hover: hover) and (any-pointer: fine) {
  .rev-help-wrap {
    display: inline-flex !important; /* or inline-block */
  }
}

/* Optional extra guard for tiny screens */
@media (max-width: 799px) {
  .rev-help-wrap {
    display: none !important;
  }
}
.typing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 1.5rem;
}
.tp-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.3rem 0;
}
.tp-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  opacity: 0.85;
  font-size: 0.9em;
}
.tp-input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #bbb;
  border-radius: 0.5rem;
  font-size: inherit;
  background: #fff;
}
.tp-input.tp-ok {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15) inset;
}
.tp-input.tp-partial {
  border-color: #ca8a04;
  box-shadow: 0 0 0 2px rgba(202, 138, 4, 0.15) inset;
}
.tp-input.tp-bad {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12) inset;
}

@keyframes tpShake {
  0% {
    transform: translateX(0);
  }
  40% {
    transform: translateX(-2px);
  }
  70% {
    transform: translateX(2px);
  }
  100% {
    transform: translateX(0);
  }
}
.tp-shake {
  animation: tpShake 0.12s linear;
}

/* Typing inputs in dark mode */
body.page-dark .tp-input {
  background: #2e1065;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
body.page-dark .tp-input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

/* Always size inputs to their container and include padding/border in width */
.tp-input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Mobile: keep everything inside the layout, no bleed, no clipping */
@media (max-width: 768px) {
  /* Ensure the containers don't cause horizontal clipping/scroll */
  #page-container,
  #main-content,
  #page-content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* The typing row should not shift or extend past its parent */
  .tp-row {
    position: static; /* remove any left/transform hacks */
    width: 100%;
    max-width: 100%;
    padding: 0; /* let the container’s padding handle spacing */
    margin: 0.25rem 0;
  }

  .tp-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 0.75rem;
    font-size: 16px; /* avoids iOS zoom */
  }
}

/* Dark mode color (kept) */
body.page-dark .tp-input {
  background: #2e1065;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
body.page-dark .tp-input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}
.tp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin: 0.25rem 0 0.5rem;
}

.tp-mark-correct {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  background: #fff;
  cursor: pointer;
}

.tp-mark-correct:hover {
  background: #f3f3f3;
}

.tp-retype:hover {
  background: #f3f3f3;
}
.tp-row {
  display: grid;
  gap: 0.35rem;
  align-items: start;
}
.tp-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.tp-main {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.tp-ghost {
  opacity: 0.85;
  font-size: 0.95em;
  line-height: 1.6;
  padding-inline-start: 0.25rem;
}
.tp-reveal {
  padding: 0.15rem 0.45rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.tp-row {
  display: grid;
  gap: 0.35rem;
  align-items: start;
}
.tp-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.tp-main {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.tp-reveal-inline {
  padding: 0.15rem 0.45rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

/* ================================
   1) AUDIO PLAYER — DARK MODE PURPLE
   ================================ */

/* Firefox has limited theming for <audio>; this at least aligns form accents */
body.page-dark input[type="range"] {
  accent-color: #2e1065;
}

/* =============== AUDIO: DARK-MODE IMMERSIVE SKIN =============== */
/* Theme tokens */
body.page-dark {
  --ap-bg: rgba(2, 6, 23, 0.72); /* slate-950-ish glass */
  --ap-stroke: #334155; /* slate-700 border */
  --ap-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  --ap-accent: #7c3aed; /* purple accent (matches your UI) */
  --ap-accent-2: #a78bfa; /* softer purple for hover/shine */
  --ap-text: #e5e7eb; /* slate-200 */
}

/* Wrapper look (works across browsers) */
body.page-dark #audio-bar #audio-player {
  background: var(--ap-bg) !important; /* ← removes the white gradient */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ap-stroke);
  border-radius: 14px;
  box-shadow:
    var(--ap-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  height: 42px; /* a bit taller, cleaner */
  overflow: hidden;
  color-scheme: dark; /* help Firefox choose dark UI */
}

/* Subtle hover focus to feel “alive” */
body.page-dark #audio-bar #audio-player:hover,
body.page-dark #audio-bar #audio-player:focus-visible {
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(124, 58, 237, 0.24),
    /* purple edge */ inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  outline: none;
}

/* Accent color for sliders (Firefox & some UAs) */
body.page-dark #audio-bar #audio-player,
body.page-dark #audio-bar #audio-player * {
  accent-color: var(--ap-accent);
}

/* ---------- WebKit (Chrome/Edge/Brave/Safari) controls tint ---------- */
/* Kill native light gradient & panels */
body.page-dark audio#audio-player::-webkit-media-controls-enclosure {
  background: transparent !important; /* ← main gradient killer */
  border-radius: 14px;
  box-shadow: none !important;
}
body.page-dark audio#audio-player::-webkit-media-controls-panel {
  background: transparent !important; /* ← secondary gradient killer */
}
/* Replace the earlier big filter you had on all controls */
body.page-dark audio#audio-player::-webkit-media-controls-play-button,
body.page-dark audio#audio-player::-webkit-media-controls-mute-button,
body.page-dark audio#audio-player::-webkit-media-controls-seek-back-button,
body.page-dark audio#audio-player::-webkit-media-controls-seek-forward-button,
body.page-dark audio#audio-player::-webkit-media-controls-fullscreen-button,
body.page-dark
  audio#audio-player::-webkit-media-controls-return-to-realtime-button {
  /* Purple-ish icon tint */
  filter: hue-rotate(295deg) saturate(170%) brightness(1.08) !important;
}

/* Time labels color */
body.page-dark audio#audio-player::-webkit-media-controls-current-time-display,
body.page-dark
  audio#audio-player::-webkit-media-controls-time-remaining-display {
  color: var(--ap-text);
  text-shadow: 0 0 8px rgba(124, 58, 237, 0.35);
  font-weight: 600;
}

/* Timeline & volume rails – subtle purple glow */
body.page-dark audio#audio-player::-webkit-media-controls-timeline,
body.page-dark audio#audio-player::-webkit-media-controls-volume-slider {
  background: linear-gradient(
    90deg,
    rgba(124, 58, 237, 0.25),
    rgba(167, 139, 250, 0.18)
  ) !important;
  border-radius: 999px;
}

/* Panel hit-area polish */
body.page-dark audio#audio-player::-webkit-media-controls {
  color: var(--ap-text);
}

/* Focus ring for keyboard users (WebKit) */
body.page-dark
  audio#audio-player:focus-visible::-webkit-media-controls-enclosure {
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.35) !important;
  border-radius: 14px;
}

/* ---------- Compact center layout you’re using ---------- */
body.page-dark #audio-bar {
  background: rgba(15, 23, 42, 0.78);
  border-top-color: #334155;
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.35);
}
body.page-dark .ab-wrap.simple:hover #audio-player {
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(124, 58, 237, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Optional: soft animated sheen on hover (tasteful) */
@media (hover: hover) {
  body.page-dark #audio-bar #audio-player {
    position: relative;
    overflow: hidden;
  }
  body.page-dark #audio-bar #audio-player::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
      120% 160% at -10% 50%,
      rgba(124, 58, 237, 0.12),
      transparent 60%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  body.page-dark #audio-bar #audio-player:hover::after {
    opacity: 1;
  }
}

/* === Remove the purplish center border/gradient on the audio player === */

/* 1) Kill any inset/outline glows on the <audio> itself */
body.page-dark #audio-bar #audio-player {
  /* keep the glass look, but drop inner borders */
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45) !important;
  border: 1px solid #334155 !important;
}
body.page-dark #audio-bar #audio-player:hover,
body.page-dark #audio-bar #audio-player:focus-visible {
  /* remove the purple ring on hover/focus */
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55) !important;
  outline: none !important;
}

/* 2) Remove the purple rail gradient on timeline + volume */
body.page-dark audio#audio-player::-webkit-media-controls-timeline,
body.page-dark audio#audio-player::-webkit-media-controls-volume-slider {
  background: none !important; /* no gradient */
  filter: none !important; /* no hue-rotate tint */
  border-radius: 999px !important;
}

/* 3) Make sure the enclosure/panel aren’t adding their own sheen */
body.page-dark audio#audio-player::-webkit-media-controls-enclosure,
body.page-dark audio#audio-player::-webkit-media-controls-panel {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}

/* 4) Remove the decorative purple overlay we added */
body.page-dark #audio-bar #audio-player::after {
  display: none !important;
}

/* 5) Keep icons purple (but only the icons), not the rails */
body.page-dark audio#audio-player::-webkit-media-controls-play-button,
body.page-dark audio#audio-player::-webkit-media-controls-mute-button,
body.page-dark audio#audio-player::-webkit-media-controls-seek-back-button,
body.page-dark audio#audio-player::-webkit-media-controls-seek-forward-button,
body.page-dark audio#audio-player::-webkit-media-controls-fullscreen-button,
body.page-dark
  audio#audio-player::-webkit-media-controls-return-to-realtime-button {
  filter: hue-rotate(295deg) saturate(170%) brightness(1.08) !important;
}

/* Optional: neutral time labels (drop purple glow) */
body.page-dark audio#audio-player::-webkit-media-controls-current-time-display,
body.page-dark
  audio#audio-player::-webkit-media-controls-time-remaining-display {
  color: #e5e7eb !important;
  text-shadow: none !important;
  font-weight: 600;
}

/* ===============================
   LIGHT MODE — YELLOWISH PAPER
   =============================== */
body:not(.page-dark) {
  /* Soft cream parchment */
  --paper-bg: #f7f1d4; /* warm paper (not neon) */
  --paper-ink: #0f172a; /* deep slate ink */
  --paper-stroke: #e6dcbb; /* warm edge */
  --paper-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
  --paper-glass: rgba(247, 241, 212, 0.86); /* translucent warm paper */
  color: var(--paper-ink);
  background: var(--paper-bg) !important;
}

/* Reading surface */
body:not(.page-dark) #main-content,
body:not(.page-dark) #page-container {
  background: var(--paper-bg) !important;
  color: var(--paper-ink) !important;
}

/* Sticky bars: glassy warm paper */
body:not(.page-dark) #optionsContainer,
body:not(.page-dark) #nav-search-wrap,
body:not(.page-dark) #navigation-content {
  background: var(--paper-glass) !important;
  border-color: var(--paper-stroke) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Inputs */
body:not(.page-dark) #nav-search,
body:not(.page-dark) #jump-page {
  background: #fbf6dd !important; /* slightly lighter than bg */
  border: 1px solid #e9e0bf !important;
  color: var(--paper-ink) !important;
}

/* ===============================
   AUDIO BAR — WARM PAPER THEME
   =============================== */
body:not(.page-dark) #audio-bar {
  background: var(--paper-glass) !important;
  border-top: 1px solid var(--paper-stroke) !important;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.06) !important;
}

body:not(.page-dark) #audio-bar #audio-player {
  background: var(--paper-bg) !important; /* same warm paper */
  border: 1px solid var(--paper-stroke) !important;
  border-radius: 14px !important;
  height: 42px !important;
  box-shadow:
    var(--paper-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35) !important;
  color-scheme: light;
  overflow: hidden;
}

/* Hover polish (no colored ring) */
body:not(.page-dark) #audio-bar #audio-player:hover,
body:not(.page-dark) #audio-bar #audio-player:focus-visible {
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45) !important;
  outline: none !important;
}

/* WebKit: keep panels neutral (no native gradients) */
body:not(.page-dark) audio#audio-player::-webkit-media-controls-enclosure,
body:not(.page-dark) audio#audio-player::-webkit-media-controls-panel {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}

/* Icons: keep that subtle purple brand tint */
body:not(.page-dark) audio#audio-player::-webkit-media-controls-play-button,
body:not(.page-dark) audio#audio-player::-webkit-media-controls-mute-button,
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-seek-back-button,
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-seek-forward-button,
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-fullscreen-button,
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-return-to-realtime-button {
  filter: hue-rotate(295deg) saturate(140%) brightness(1.02) !important;
}

/* Timeline & volume rails: warm neutral (no green / no purple stripe) */
body:not(.page-dark) audio#audio-player::-webkit-media-controls-timeline,
body:not(.page-dark) audio#audio-player::-webkit-media-controls-volume-slider {
  background: linear-gradient(
    90deg,
    #eee4bf,
    #e6d9a9
  ) !important; /* warm beige */
  border-radius: 999px !important;
  filter: none !important;
}

/* Time labels */
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-current-time-display,
body:not(.page-dark)
  audio#audio-player::-webkit-media-controls-time-remaining-display {
  color: #1f2937 !important;
  text-shadow: none !important;
  font-weight: 600;
}

/* Cross-browser accent */
body:not(.page-dark) #audio-bar #audio-player,
body:not(.page-dark) #audio-bar #audio-player * {
  accent-color: #7c3aed !important;
}

/* Audio bar layout: buttons left/right, player centered */
#audio-bar .ab-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
}

/* Keep the <audio> wide but leave room for buttons */
#audio-player {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
}

/* Icon button (🏠) — minimal chrome */
.ab-icon {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 10px;
}

/* Donate CTA — subtle, modern */
.ab-cta {
  border: 0;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Light mode */
:root:not(.dark) .ab-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}
:root:not(.dark) .ab-cta {
  background: #5b4bff0f;
  color: #4b3cff;
  box-shadow: 0 0 0 1px #4b3cff1a inset;
}
:root:not(.dark) .ab-cta:hover {
  background: #4b3cff14;
}

/* Dark mode */
:root.dark .ab-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}
:root.dark .ab-cta {
  background: #6d5cff22;
  color: #cbbdff;
  box-shadow: 0 0 0 1px #cbbdff22 inset;
}
:root.dark .ab-cta:hover {
  background: #6d5cff30;
}

/* Small screens: ensure buttons remain tappable */
@media (max-width: 520px) {
  #audio-bar .ab-wrap {
    gap: 8px;
    padding: 6px 8px;
  }
  .ab-cta {
    padding: 7px 12px;
  }
}

@media (max-width: 768px) {
  #prev-page-button,
  #next-page-button {
    display: none !important;
  }
}

/* Light mode ayah glow (click/active/selected) */
:root {
  --ayah-glow-light-bg: rgba(214, 255, 107, 0.28); /* greenish-yellow wash */
  --ayah-glow-light-ring: rgba(148, 199, 0, 0.55); /* ring */
  --ayah-glow-light-bloom: rgba(214, 255, 107, 0.85); /* outer glow */
}

/* If your dark mode uses a body class like .dark-mode, this targets only light */
body:not(.dark-mode) .ayah-span.is-active,
body:not(.dark-mode) .ayah-span.selected,
body.light-mode .ayah-span.is-active,
body.light-mode .ayah-span.selected,
body:not(.dark-mode) .ayah.is-active,
body:not(.dark-mode) .ayah.selected {
  background: linear-gradient(
    0deg,
    var(--ayah-glow-light-bg),
    var(--ayah-glow-light-bg)
  );
  box-shadow:
    0 0 0 2px var(--ayah-glow-light-ring),
    0 0 16px 2px var(--ayah-glow-light-bloom);
  border-radius: 0.35rem;
  transition:
    box-shadow 0.15s ease,
    background 0.15s ease;
  outline: none;
}

/* Light mode: soft greenish-yellow TEXT glow (no border, no fill) */
:root {
  --ayah-glow: rgba(214, 255, 107, 0.85); /* glow color */
  --ayah-glow-soft: rgba(214, 255, 107, 0.45);
}

body:not(.page-dark) .highlight,
body:not(.page-dark) .playhighlight {
  background: transparent !important; /* no wash */
  box-shadow: none !important; /* no border-like ring */
  text-shadow:
    0 0 6px var(--ayah-glow-soft),
    0 0 12px var(--ayah-glow),
    0 0 22px var(--ayah-glow),
    0 0 34px var(--ayah-glow-soft); /* layered bloom */
  animation: none !important;
  outline: none !important;
  border-radius: 0 !important;
}

/* In revision mode, show filtered ayahs but blur them (no layout jump) */
#page-content.revise-mode .ayah-text.is-filtered-out,
#page-content.revise-mode span[data-surah-no][data-ayah-no].is-filtered-out {
  max-height: none !important; /* undo collapse */
  opacity: 1 !important; /* keep visible */
  transform: none !important; /* undo lift */
  filter: blur(4px); /* ← the blur */
  pointer-events: none; /* not interactive while blurred */
}

/* Optional: dim the ayah number too */
#page-content.revise-mode .ayah-no.is-filtered-out {
  filter: blur(2px);
  opacity: 0.6;
}

/* --- REVISION MODE: blur instead of hide --- */
#page-content.revise-mode .ayah-text.is-filtered-out {
  max-height: none !important; /* don't collapse */
  opacity: 1 !important; /* keep visible */
  filter: blur(12px); /* ← blur it */
  pointer-events: none; /* not interactive while blurred */
}
#page-content.revise-mode .ayah-no.is-filtered-out {
  filter: blur(2px);
  opacity: 0.6;
}

/* --- Dialog color by mark --- */
.ayah-dialog.rev-dialog.rev-correct {
  background: #e9fbe8 !important; /* soft green */
  border-color: #86efac !important;
  color: #065f46 !important;
  box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.35);
}
.ayah-dialog.rev-dialog.rev-wrong {
  background: #ffe4e6 !important; /* rose/pink */
  border-color: #fca5a5 !important;
  color: #7f1d1d !important;
  box-shadow: 0 0 0 2px rgba(252, 165, 165, 0.35);
}

/* Dialog colors via CSS variables so the arrow (::after) matches too */
.ayah-dialog.rev-dialog.rev-correct {
  --dlg-bg: #e9fbe8; /* soft green */
  --dlg-border: #86efac; /* green-300 */
  --dlg-text: #065f46; /* emerald-800 */
  box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.35);
}

.ayah-dialog.rev-dialog.rev-wrong {
  --dlg-bg: #ffe4e6; /* rose-100 */
  --dlg-border: #fca5a5; /* red-300 */
  --dlg-text: #7f1d1d; /* red-900 */
  box-shadow: 0 0 0 2px rgba(252, 165, 165, 0.35);
}

#page-content.revise-mode .ayah-text {
  transition: none !important;
}
#page-content.revise-mode .ayah-text.filter-reveal {
  animation: none !important;
}
