:root {
  --th-paper: #faf5fc;
  --th-paperAlt: #f0e6f5;
  --th-ink: #2b1a38;
  --th-ink2: #573d6b;
  --th-ink3: #836b94;
  --th-line: #d8c4e6;
  --th-primary: #5e2b7a;
  --th-primaryDeep: #3c1852;
  --th-primaryLite: #ead9f2;
  --th-accent: #8a9ea8;
  --th-danger: #c92a2a;
  --th-barTint: #f5ebf8;
  --quran-font: "Amiri Quran", "Amiri", "Scheherazade New", "Noto Naskh Arabic", serif;
  --ui-font: "Cairo", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --quran-size: 30px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; overflow-x: hidden; }
body {
  font-family: var(--ui-font);
  background: var(--th-paper);
  color: var(--th-ink);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 50% -10%, #fffdf5 0%, transparent 65%),
    var(--th-paper);
}

.header {
  background: linear-gradient(180deg, var(--th-paper) 0%, var(--th-barTint) 100%);
  border-bottom: 1px solid var(--th-line);
}
.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 20px 32px 16px;
}
.brand-title {
  margin: 0;
  font-family: var(--quran-font);
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 400;
  line-height: 1;
  color: var(--th-primary);
  text-align: center;
}
.header-links {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--th-ink2);
  font-size: 13px;
}
.header-links.right { justify-content: flex-start; }
.header-links.left { justify-content: flex-end; }
.hl {
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.hl:hover { color: var(--th-primary); border-bottom-color: var(--th-primary); }

.tabs {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 0 24px;
  background: var(--th-barTint);
  border-top: 1px solid var(--th-line);
  overflow-x: auto;
}
.tabs-row { display: flex; gap: 4px; }
.tab {
  appearance: none;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--th-ink2);
  padding: 12px 22px 14px;
  white-space: nowrap;
}
.tab:hover { background: rgba(255,255,255,.38); color: var(--th-ink); }
.tab.is-active {
  background: var(--th-paper);
  color: var(--th-primary);
  font-weight: 700;
  box-shadow: inset 0 2px 0 var(--th-primary), 1px 0 0 var(--th-line), -1px 0 0 var(--th-line);
}
.search-mobile-btn {
  display: none;
  margin-inline-start: auto;
  align-self: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--th-primary);
  color: var(--th-paper);
}

.content {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}
.content.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.side-right .sidebar { order: -1; }
.reader {
  min-width: 0;
  padding: 24px 32px 64px;
}
.reader-toolbar {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.rt-left {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.rt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--th-line);
  border-radius: 999px;
  background: var(--th-paper);
  color: var(--th-ink);
  padding: 8px 14px;
}
.rt-btn:hover { transform: translateY(-1px); }
.rt-btn-amber { color: #95621a; }
.rt-btn-blue { color: #2563eb; }
.rt-btn-cyan { color: #0e7490; }
.rt-btn-purple { color: #7c3aed; }

.panel { display: none; }
.panel.is-active { display: block; }
/* ── wrapper matches page-shell width ── */
.page-nav-shell {
  width: min(760px, 100%);
  margin: 0 auto 10px;
  padding: 0;
}
.page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--th-ink2);
}
.page-nav #suraSelect {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 1.05em;
  border-radius: 6px;
  border: 1px solid var(--th-line);
  background: var(--th-paper);
  color: var(--th-ink);
  font-family: var(--quran-font, 'Amiri', serif);
}
.play-audio-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5em;
  color: var(--th-primary);
  padding: 0 4px;
  line-height: 1;
}
.pn-arrow {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid var(--th-line);
  border-radius: 999px;
  background: var(--th-paper);
  color: var(--th-primary);
  font-size: 16px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, transform 120ms;
  user-select: none;
}
.pn-arrow:hover { background: var(--th-primaryLite); border-color: var(--th-primary); }
.pn-arrow:active { transform: scale(0.92); }
.pn-surah {
  min-width: 120px;
  text-align: center;
  font-family: var(--quran-font);
  font-size: 21px;
  color: var(--th-primary);
}
.pn-num { min-width: 28px; text-align: center; }

.page-shell {
  display: flex;
  justify-content: center;
  width: min(760px, 100%);
  margin: 0 auto;
}
.page-frame {
  --tk: 38px;
  --frame-bg: var(--th-primary);
  --top-uri: none;
  --left-uri: none;
  --corner-uri: none;
  --inner-trim: var(--th-accent);
  position: relative;
  width: 100%;
  min-height: calc(100dvh - 210px);
  padding: var(--tk);
  background: var(--th-paper);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 18px 50px -22px rgba(0,0,0,.25);
}
.frame-edge, .frame-corner {
  position: absolute;
  background-color: var(--frame-bg);
  background-repeat: repeat;
  pointer-events: none;
}
.frame-top, .frame-bottom {
  left: var(--tk);
  right: var(--tk);
  height: var(--tk);
  background-image: var(--top-uri);
}
.frame-top { top: 0; }
.frame-bottom { bottom: 0; transform: scaleY(-1); }
.frame-left, .frame-right {
  top: var(--tk);
  bottom: var(--tk);
  width: var(--tk);
  background-image: var(--left-uri);
}
.frame-left { left: 0; }
.frame-right { right: 0; transform: scaleX(-1); }
.frame-corner {
  width: var(--tk);
  height: var(--tk);
  background-image: var(--corner-uri);
  background-size: var(--tk) var(--tk);
  background-repeat: no-repeat;
}
.frame-tl { top: 0; left: 0; }
.frame-tr { top: 0; right: 0; transform: scaleX(-1); }
.frame-bl { bottom: 0; left: 0; transform: scaleY(-1); }
.frame-br { bottom: 0; right: 0; transform: scale(-1, -1); }
.frame-inner-trim {
  position: absolute;
  inset: var(--tk);
  border: 1px solid var(--inner-trim);
  opacity: .35;
  pointer-events: none;
}
.page-inner {
  position: relative;
  z-index: 1;
  min-height: calc(100dvh - 210px - (var(--tk) * 2));
  padding: clamp(20px, 4%, 44px) clamp(18px, 4%, 40px);
  background: var(--th-paper);
  overflow: visible;
}

.surah {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.surah-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 24px;
}
.surah-orn {
  color: var(--th-accent);
  font-size: 22px;
}
.surah-cartouche {
  padding: 6px 8px;
  background: linear-gradient(180deg, transparent, transparent 6px, var(--th-primary) 6px, var(--th-primary) 7px, transparent 7px, transparent calc(100% - 7px), var(--th-primary) calc(100% - 7px), var(--th-primary) calc(100% - 6px), transparent calc(100% - 6px));
}
.surah-cartouche-inner {
  padding: 6px 32px;
  border: 1.5px solid var(--th-primary);
  border-radius: 4px;
  background: var(--th-paper);
  font-family: var(--quran-font);
  font-size: 24px;
  color: var(--th-primary);
}
.bism {
  margin: 0 0 16px;
  text-align: center;
  font-family: var(--quran-font);
  font-size: calc(var(--quran-size) * .92);
  color: var(--th-primary);
}
.surah-body,
.quranText {
  font-family: var(--quran-font);
  font-size: var(--quran-size);
  line-height: 2.35;
  color: var(--quran-color, var(--th-ink));
  text-align: justify;
  text-align-last: center;
}
.aya {
  display: inline;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.aya:hover { background: rgba(176, 138, 62, .12); }
.aya.selected {
  background: var(--th-primaryLite) !important;
  box-shadow: 0 0 0 4px var(--th-primaryLite), 0 2px 4px rgba(0, 0, 0, 0.05);
  border-bottom: 2px solid var(--th-accent) !important;
  border-radius: 4px;
}
.ayaNumber,
.result-body .ayaNumber {
  position: relative;
  display: inline-block !important;
  width: 2.9em;
  min-width: 2.9em;
  height: 1.64em;
  margin: 0 .16em;
  padding: 0 !important;
  border: 1px solid var(--th-accent);
  border-radius: 999px;
  background: var(--th-paperAlt);
  color: var(--th-accent) !important;
  font-family: var(--quran-font);
  font-size: .56em;
  font-variant-numeric: tabular-nums;
  line-height: 0 !important;
  text-align: center;
  text-align-last: center;
  white-space: nowrap;
  vertical-align: middle;
  direction: ltr;
  unicode-bidi: isolate;
  transform: translateY(-.05em);
  overflow: hidden;
}
.ayaNumber-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.ayaNumber-svg text {
  fill: var(--th-accent);
  font-family: var(--quran-font);
  line-height: 1;
}
.ayaNumber-svg .ayaNumber-orn {
  font-size: 24px;
}
.ayaNumber-svg .ayaNumber-digit {
  font-size: 17px;
}
.highlight-word {
  background: #fff2a8;
  color: #1f2937;
  border-radius: 4px;
  padding: 0 .14em;
}
.highlight-verb { color: #7c3aed !important; font-weight: 700; }
.highlight-noun { color: #2563eb !important; font-weight: 700; }
.highlight-prep { color: #0e7490 !important; font-weight: 700; }
.rt-btn.is-active {
  box-shadow: inset 0 0 0 2px currentColor;
  background: var(--th-primaryLite);
}

.result-frame {
  width: min(920px, 100%);
  margin: 0 auto;
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paper);
  box-shadow: 0 18px 45px -30px rgba(0,0,0,.25);
  overflow: visible;
}
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--th-barTint);
  border-bottom: 1px solid var(--th-line);
}
.result-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--th-primary);
}
.result-body {
  min-height: 420px;
  max-height: none;
  overflow: visible;
  padding: 22px;
  direction: rtl;
}
.result-body h4 {
  margin-top: 10px;
  margin-bottom: 5px;
}
.result-body .word-carousel-container {
  margin-top: 5px;
  padding: 10px 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.05);
  text-align: center;
  text-align-last: auto;
  font-family: var(--ui-font);
  font-size: 16px;
  line-height: 1.55;
}
.result-body .word-card {
  display: none;
  padding: 10px 20px;
  animation: fadeIn .3s ease;
}
.result-body .word-card.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-body .word-display {
  margin-bottom: 10px;
  font-family: var(--quran-font);
  font-size: 2.5em;
  color: var(--th-primary);
}
.result-body .analysis-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}
.result-body .analysis-btn {
  border: 1px solid #d4e5b8;
  border-radius: 20px;
  background: #f8f9fa;
  color: var(--th-primary);
  padding: 6px 15px;
  font-family: var(--quran-font);
  font-size: 1em;
}
.result-body .analysis-btn:hover {
  background: #e8f5d1;
  border-color: var(--th-primary);
}
.result-body .analysis-btn.active {
  background: var(--th-primary);
  color: #fff;
  border-color: var(--th-primary);
}
.result-body .royal-button,
.result-body .nav-btn,
.result-body button[onclick^="addTag"],
.result-body button[onclick^="saveExtras"],
.result-body .analysis-btn.active {
  color: #fff !important;
}
.result-body .root-display {
  display: inline-block;
  margin-bottom: 15px;
  border-radius: 15px;
  background: #f8f9fa;
  color: #666;
  padding: 2px 10px;
  font-size: 1.1em;
}
.result-body .meaning-display {
  margin-bottom: 20px;
  border: 1px solid #d4e5b8;
  border-radius: 8px;
  background: #f7fce3;
  color: #333;
  padding: 15px;
  font-size: 1.2em;
  line-height: 1.6;
}
.result-body .grammar-display {
  margin-bottom: 20px;
  border: 1px solid #b8daff;
  border-radius: 8px;
  background: #eef6fc;
  color: #333;
  padding: 15px;
  text-align: right;
  direction: rtl;
  font-size: 1.1em;
  line-height: 1.6;
}
.result-body .carousel-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
  border-top: 1px solid #eee;
  padding-top: 15px;
}
.result-body .nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--th-primary);
  color: #fff;
  font-size: 18px;
}
.result-body .nav-btn:hover {
  background: #3a6b3f;
  transform: scale(1.08);
}
.result-body .carousel-counter {
  color: #666;
  font-family: var(--quran-font);
  font-size: 1.2em;
}
.analysis-divider {
  height: 1px;
  margin: 16px 0;
  background: var(--th-line);
}
.inline-filter {
  width: min(260px, 45vw);
  border: 1px solid var(--th-line);
  border-radius: 6px;
  background: var(--th-paper);
  padding: 8px 10px;
}

.sidebar {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-inline-start: 1px solid var(--th-line);
  background: var(--th-paper);
  padding: 18px;
  transition: padding 0.3s ease, border 0.3s ease;
  overflow: visible;
}
.content.sidebar-collapsed .sidebar {
  padding: 0;
  border: none;
  overflow: visible;
}
.content.sidebar-collapsed .sidebar .sb-body,
.content.sidebar-collapsed .sidebar .sb-head .sb-title,
.content.sidebar-collapsed .sidebar .sb-head .sb-collapse-btn {
  display: none !important;
}
.content.sidebar-collapsed .sidebar .sb-expand-btn {
  display: flex !important;
}
.sb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -18px -18px 0;
  padding: 10px 14px;
  background: var(--th-primary);
  color: var(--th-paper);
  border-radius: 0;
}
.sb-toggle {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: rgba(255,255,255,.1);
  color: var(--th-paper);
}
.sb-title { flex: 1; font-weight: 700; }
.sb-bullet {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--th-accent);
}
.sb-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sb-card {
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paperAlt);
  padding: 14px;
}
.sb-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--th-primary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.sb-card-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}
.collapse-icon {
  transition: transform 0.2s ease;
  font-size: 14px;
}
.sb-card.is-collapsed .sb-card-body {
  display: none;
}
.sb-card.is-collapsed .collapse-icon {
  transform: rotate(90deg);
}
.sb-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--th-ink2);
  font-size: 13px;
}
.sb-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--th-line);
  border-radius: 6px;
  background: var(--th-paper);
  color: var(--th-ink);
  padding: 0 10px;
}
.sb-input:focus,
.inline-filter:focus {
  outline: none;
  border-color: var(--th-primary);
  box-shadow: 0 0 0 3px rgba(26,77,58,.13);
}
.sb-search-btn,
.small-btn {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--th-primary);
  color: var(--th-paper);
  font-weight: 700;
  padding: 8px 14px;
}
.sb-search-btn { white-space: nowrap; }
.sb-body .sb-search-btn { width: 100%; }
.button-row { display: flex; gap: 8px; }
.small-btn { flex: 1; }
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0;
}
.mode-btn {
  border: 1px solid var(--th-line);
  border-radius: 6px;
  background: var(--th-paper);
  color: var(--th-ink2);
  padding: 7px 8px;
  font-size: 12px;
}
.mode-btn.is-active {
  border-color: var(--th-primary);
  background: var(--th-primaryLite);
  color: var(--th-primaryDeep);
  font-weight: 700;
}
.range { width: 100%; accent-color: var(--th-primary); }
.notice {
  border-radius: 6px;
  padding: 10px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}
.notice.error {
  background: #fff5f5;
  color: var(--th-danger);
  border-color: #fecaca;
}

.frame-picker {
  position: fixed;
  inset: auto 24px 24px auto;
  z-index: 30;
  width: min(440px, calc(100vw - 32px));
  max-height: 60dvh;
  overflow: auto;
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paper);
  box-shadow: 0 20px 70px -28px rgba(0,0,0,.35);
  padding: 12px;
}
.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.frame-choice {
  border: 1px solid var(--th-line);
  border-radius: 6px;
  background: var(--th-paperAlt);
  padding: 8px;
  color: var(--th-ink);
}
.frame-choice.is-active {
  border-color: var(--th-primary);
  box-shadow: inset 0 0 0 1px var(--th-primary);
}

.roots-list,
.favorites-list {
  display: grid;
  gap: 10px;
  font-family: var(--ui-font);
}
.root-item,
.favorite-item,
.favorite-entry {
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px 12px;
}
.root-word {
  font-family: var(--quran-font);
  font-size: 22px;
  color: var(--th-primary);
}
.favorite-entry {
  margin-top: 8px;
  cursor: pointer;
}
.favorite-entry:hover { border-color: var(--th-primary); }

.roots-letters-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 18px;
  justify-content: center;
  background: var(--th-barTint);
  border-bottom: 1px solid var(--th-line);
  direction: rtl;
}
.letter-btn {
  font-family: var(--ui-font);
  background: var(--th-paper);
  color: var(--th-ink2);
  border: 1px solid var(--th-line);
  border-radius: 6px;
  padding: 4px 10px;
  min-width: 34px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  user-select: none;
}
.letter-btn:hover {
  border-color: var(--th-primary);
  background: var(--th-primaryLite);
  color: var(--th-primaryDeep);
}
.letter-btn.is-active {
  background: var(--th-primary) !important;
  color: #fff !important;
  border-color: var(--th-primary) !important;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(0,0,0,.32);
}

.verse-note-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .45);
}
.verse-note-overlay[hidden] {
  display: none;
}
.verse-note-dialog {
  width: min(560px, 100%);
  max-height: min(720px, 92dvh);
  overflow: auto;
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paper);
  color: var(--th-ink);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .28);
  direction: rtl;
}
.verse-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--th-line);
}
.verse-note-head h3 {
  margin: 0;
  font-size: 18px;
  color: var(--th-primary);
}
.verse-note-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--th-line);
  border-radius: 999px;
  background: var(--th-paperAlt);
  color: var(--th-ink2);
}
.verse-note-body {
  padding: 16px 18px 18px;
}
.verse-note-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.verse-note-tab,
.verse-note-btn {
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paperAlt);
  color: var(--th-ink);
  padding: 9px 13px;
}
.verse-note-tab.is-active,
.verse-note-btn.primary {
  border-color: var(--th-primary);
  background: var(--th-primary);
  color: var(--th-paper);
}
.verse-note-btn.danger {
  border-color: var(--th-danger);
  background: var(--th-danger);
  color: var(--th-paper);
}
.verse-note-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}
.verse-note-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--th-paperAlt);
  color: var(--th-ink);
  padding: 12px;
  line-height: 1.7;
  direction: rtl;
}
.verse-note-actions,
.voice-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.voice-note-existing {
  margin-bottom: 14px;
}
.voice-note-empty,
.voice-note-status {
  border: 1px dashed var(--th-line);
  border-radius: 8px;
  background: var(--th-paperAlt);
  color: var(--th-ink2);
  padding: 12px;
}
.voice-note-card audio {
  width: 100%;
}
.voice-note-meta,
.voice-note-transcription {
  margin-top: 8px;
  color: var(--th-ink2);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .header-top {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }
  .header-links { justify-content: center !important; flex-wrap: wrap; }
  .content { grid-template-columns: 1fr; }
  .reader { padding: 18px 14px 80px; }
  .search-mobile-btn { display: grid; place-items: center; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(360px, 88vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    overflow: auto;
    box-shadow: 12px 0 40px rgba(0,0,0,.25);
  }
  .sidebar.is-open { transform: translateX(0); }
  .drawer-backdrop.is-open { display: block; }
  .sb-collapse-btn, .sb-expand-btn { display: none !important; }
  .page-frame {
    min-height: calc(100dvh - 190px);
  }
  .surah-body, .quranText { line-height: 2.05; }
}

@media (max-width: 620px) {
  .tabs { padding: 0 10px; }
  .tab { padding: 10px 13px; }
  .mode-grid { grid-template-columns: 1fr; }
  .result-head { align-items: stretch; flex-direction: column; }
  .inline-filter { width: 100%; }
  .page-inner { padding: 18px 16px; }
}

/* Highlight Modal and Tooltips */
.scope-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.scope-modal {
    background: var(--th-paperAlt, #fff);
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-family: 'Amiri', serif;
    direction: rtl;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.scope-modal-header {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--th-primary, #000);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--th-line, #ccc);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.scope-close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--th-ink3, #666);
}
.hl-modal-group {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--th-line, #eee);
}
.hl-modal-label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--th-ink, #000);
}
.hl-controls-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}
.hl-select {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--th-line, #ccc);
    border-radius: 4px;
    font-family: 'Amiri', serif;
    background: var(--th-paper, #fff);
    color: var(--th-ink, #000);
}
.hl-color-input {
    width: 40px;
    height: 30px;
    border: 1px solid var(--th-line, #ccc);
    border-radius: 4px;
    cursor: pointer;
    background: var(--th-paper, #fff);
}
.hl-add-btn {
    background: var(--th-primary, #2c5530);
    color: var(--th-paper, #fff);
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
}
.active-rules-list {
    margin-top: 10px;
    background: var(--th-paper, #f9f9f9);
    padding: 10px;
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--th-line, #ddd);
}
.rule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--th-paperAlt, #fff);
    padding: 5px 8px;
    margin-bottom: 5px;
    border: 1px solid var(--th-line, #ddd);
    border-radius: 4px;
    font-size: 0.9em;
}
.rule-remove {
    cursor: pointer;
    color: var(--th-ink3, #999);
}
.rule-remove:hover {
    color: darkred;
}
.scope-btn {
    background: var(--th-primary, #2c5530);
    color: var(--th-paper, #fff);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    font-family: 'Arial', sans-serif;
}
.tooltips-off .word-span {
    cursor: default;
}

/* Search Scope Styles */
.scope-option-group {
    margin-bottom: 15px;
}
.scope-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: bold;
    color: var(--th-ink, #333);
}
.scope-details {
    margin-right: 25px;
    padding: 10px;
    background: var(--th-paper, #f9fcf6);
    border: 1px solid var(--th-line, #d4e5b8);
    border-radius: 5px;
    display: none;
}
.scope-select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--th-line, #ccc);
    border-radius: 4px;
    margin-top: 5px;
    font-family: 'Amiri', serif;
    background: var(--th-paperAlt, #fff);
    color: var(--th-ink, #000);
}
.range-inputs {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}
.range-group {
    flex: 1;
}
.scope-trigger-btn {
    background: var(--th-paperAlt);
    border: 1px solid var(--th-line);
    color: var(--th-primary);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    margin-top: 5px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Amiri', serif;
    transition: background 0.2s;
}
.scope-trigger-btn:hover {
    background: var(--th-paper);
}

/* ── Export Bar (Search Results) ── */
.export-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--th-barTint);
  border-bottom: 1px solid var(--th-line);
  border-radius: 6px 6px 0 0;
  flex-wrap: wrap;
}
.export-bar-label {
  font-size: 12px;
  color: var(--th-ink3);
  font-family: var(--ui-font);
  white-space: nowrap;
  margin-inline-end: 4px;
}
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--th-line);
  border-radius: 999px;
  background: var(--th-paper);
  color: var(--th-ink2);
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--ui-font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.export-btn:hover {
  background: var(--th-primaryLite);
  border-color: var(--th-primary);
  color: var(--th-primaryDeep);
  transform: translateY(-1px);
}
.export-btn.fav-star-btn {
  margin-inline-start: auto;
  color: var(--th-primary);
  border-color: var(--th-accent);
  background: var(--th-paper);
}
.export-btn.fav-star-btn:hover {
  background: var(--th-primaryLite);
  border-color: var(--th-primary);
  color: var(--th-primaryDeep);
}
.export-btn:active { transform: scale(0.96); }

/* ── Export Dropdown (Analysis Tab) ── */
.export-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  color: var(--th-ink3);
  transition: color 0.2s, transform 0.15s;
  padding: 0 2px;
  line-height: 1;
}
.export-icon-btn:hover { color: var(--th-primary); transform: translateY(-1px); }

.export-dropdown-wrap {
  position: relative;
  display: inline-block;
}
.export-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  min-width: 140px;
  background: var(--th-paper);
  border: 1px solid var(--th-line);
  border-radius: 8px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.25);
  padding: 6px;
  flex-direction: column;
  gap: 4px;
}
.export-dropdown.is-open { display: flex; }
.export-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--th-ink2);
  font-size: 13px;
  font-family: var(--ui-font);
  cursor: pointer;
  text-align: right;
  direction: rtl;
  transition: background 0.12s, color 0.12s;
}
.export-dropdown-item:hover {
  background: var(--th-primaryLite);
  color: var(--th-primaryDeep);
}

/* ── Quran Floating Verse Toolbar (Confluence Style) ── */
.quran-verse-toolbar {
  position: absolute;
  z-index: 10000;
  display: flex;
  align-items: center;
  background: var(--th-paper);
  border: 1px solid var(--th-line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 4px;
  transform: translate(-50%, -100%);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: auto;
  opacity: 0;
  gap: 0;
  direction: rtl;
  font-family: var(--ui-font), "Amiri", serif;
}
@supports (backdrop-filter: blur(12px)) {
  .quran-verse-toolbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}
.quran-verse-toolbar.is-active {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-6px);
}
.quran-verse-toolbar .toolbar-btn {
  background: transparent;
  border: none;
  padding: 8px 12px;
  color: var(--th-ink2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.quran-verse-toolbar .toolbar-btn:hover {
  background: var(--th-primaryLite);
  color: var(--th-primaryDeep);
}
.quran-verse-toolbar .toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--th-line);
  margin: 0 4px;
}

/* ── Quran Modal Styles (For Add To Favorites) ── */
.quran-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.quran-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.quran-modal-overlay.is-active .quran-modal-backdrop {
  opacity: 1;
}
.quran-modal-content {
  position: relative;
  width: min(450px, 92%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--th-paper);
  border: 1px solid var(--th-line);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 24px;
  pointer-events: auto;
  transform: scale(0.9) translateY(30px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.quran-modal-overlay.is-active .quran-modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.quran-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--th-line);
  padding-bottom: 12px;
  direction: rtl;
}
.quran-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--th-primaryDeep);
}
.quran-modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--th-ink3);
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s ease;
}
.quran-modal-close:hover {
  color: #d9534f;
}
.quran-modal-body {
  overflow-y: auto;
  flex-grow: 1;
}

/* Search Root Filters */
.filter-dropdown-container {
  position: relative;
  display: inline-block;
}
.filter-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1000;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--th-paper);
  border: 1px solid var(--th-line);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 8px 12px;
  direction: rtl;
}
.filter-dropdown-menu.is-open {
  display: block;
}
.filter-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  color: var(--th-ink2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
  border-radius: 4px;
}
.filter-item-label:hover {
  background: var(--th-paperAlt);
  color: var(--th-primaryDeep);
}
.filter-item-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--th-primary);
  cursor: pointer;
}
.filter-dropdown-title-bold {
  font-weight: 700;
  border-bottom: 1px solid var(--th-line);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

/* Extras and Tags Dropdown Item styling */
.extras-dropdown-item,
.tags-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-family: 'Amiri', serif;
  font-size: 14px;
  color: var(--th-ink);
  transition: background 0.15s, color 0.15s;
  text-align: right;
}
.extras-dropdown-item:hover,
.tags-dropdown-item:hover {
  background: var(--th-primaryLite) !important;
  color: var(--th-primaryDeep) !important;
}
.extras-dropdown-item.is-active,
.tags-dropdown-item.is-active {
  background: var(--th-primary) !important;
  color: var(--th-paper) !important;
  font-weight: bold;
}







