/* علمِ دین کے فضائل — ایک کتاب ایپ (المدینہ لائبریری ڈیزائن) */
:root {
  --green: #0f5132;
  --green-hover: #0a3a24;
  --green-light: #e6f4ea;
  --gold: #c59b27;
  --gold-light: #fef9e7;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --panel: #edf2ef;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --highlight: #fef08a;
  --highlight-text: #713f12;
  --danger: #b91c1c;
  --radius: 14px;
  --font-urdu: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif;
  --font-latin: "Plus Jakarta Sans", system-ui, sans-serif;
}
body[data-theme="dark"] {
  --bg: #0a0f1d;
  --surface: #111827;
  --panel: #1a2436;
  --border: #243449;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --green-light: #123524;
  --gold-light: #2a2305;
}
body[data-theme="parchment"] {
  --bg: #f3ead3;
  --surface: #fdf6e3;
  --panel: #efe3c2;
  --border: #d9c9a3;
  --text: #3b2f1a;
  --muted: #7a6a4a;
  --green-light: #e3eedd;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-urdu), var(--font-latin);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 2;
}
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* اوپر کی پٹی */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  background: var(--green); color: #fff;
  padding: 10px 12px;
}
#topbar button {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  width: 42px; height: 42px; border-radius: 10px; font-size: 22px; line-height: 1;
}
#topTitle { flex: 1; text-align: center; font-weight: 700; font-size: 20px; line-height: 1.8; }

/* مینیو (ڈراور) */
#drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 30;
  width: min(78vw, 320px);
  background: var(--surface); border-inline-start: 1px solid var(--border);
  padding: 70px 12px 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: -4px 0 18px rgba(0,0,0,.18);
}
#drawer.hidden, #backdrop.hidden { display: none; }
#drawer button {
  text-align: right; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 18px;
}
#backdrop {
  position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.4);
}

main { flex: 1; padding: 16px 14px 28px; }
.screen { display: none; }
.screen.active { display: block; }
.screen-title { color: var(--green); margin: 4px 0 14px; font-size: 24px; }
.muted { color: var(--muted); font-size: 15px; line-height: 1.9; }
.small { font-size: 13px; }
.warn {
  background: var(--gold-light); border: 1px solid var(--gold);
  border-radius: 10px; padding: 12px; color: var(--text);
}
.hidden { display: none !important; }

/* ہوم */
.home-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 18px; text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.home-ornament { color: var(--gold); font-size: 30px; line-height: 1; }
.book-title { color: var(--green); font-size: 34px; line-height: 2; margin: 6px 0 0; }
.publisher { font-size: 17px; margin: 0; }
.edition { color: var(--muted); font-size: 14px; margin: 2px 0 18px; }
.home-buttons { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 14px; }
.big-btn {
  border: none; border-radius: 12px; padding: 16px; font-size: 21px; font-weight: 700;
}
.big-btn.primary { background: var(--green); color: #fff; }
.big-btn.primary:active { background: var(--green-hover); }
.big-btn.gold { background: var(--gold); color: #fff; }
.small-link {
  background: none; border: none; color: var(--green); font-size: 16px;
  text-decoration: underline;
}
.offline-note { color: var(--muted); font-size: 13px; margin-top: 16px; line-height: 1.8; }

/* ریڈر */
.reader-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.reader-tools button {
  background: var(--green-light); color: var(--green); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-size: 15px; white-space: nowrap;
}
.progress-wrap { flex: 1; height: 8px; background: var(--panel); border-radius: 6px; overflow: hidden; }
#progressBar { height: 100%; width: 12%; background: var(--gold); border-radius: 6px; transition: width .3s; }
.page-text {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 18px; min-height: 50vh;
  font-size: 22px; line-height: 2.4; white-space: pre-wrap; word-wrap: break-word;
}
body[data-font="small"] .page-text { font-size: 18px; }
body[data-font="large"] .page-text { font-size: 27px; line-height: 2.6; }
.page-text mark, mark { background: var(--highlight); color: var(--highlight-text); border-radius: 3px; padding: 0 2px; }
.reader-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px;
}
.reader-nav button {
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 10px 14px; font-size: 16px;
}
.reader-nav button:disabled { opacity: .45; }
.jump { font-size: 15px; display: flex; align-items: center; gap: 4px; }
.jump select {
  padding: 6px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px;
  font-family: var(--font-latin);
}

/* فہرست */
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.toc-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.toc-list li.heading { background: var(--green-light); color: var(--green); font-weight: 700; text-align: center; }
.toc-list button {
  width: 100%; display: flex; justify-content: space-between; gap: 10px;
  background: none; border: none; color: var(--text);
  padding: 12px 14px; font-size: 18px; text-align: right;
}
.toc-list .pg { font-family: var(--font-latin); color: var(--muted); white-space: nowrap; }

/* تلاش */
.search-box { display: flex; gap: 8px; }
.search-box input, .key-box input, #aiModelInput, #aiQuestionInput {
  flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 17px; width: 100%;
}
.primary-btn {
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 12px 18px; font-size: 17px; white-space: nowrap;
}
.primary-btn.big { width: 100%; margin-top: 10px; padding: 14px; font-size: 19px; }
.primary-btn:disabled { opacity: .5; }
.results-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font-size: 17px; line-height: 2;
}
.results-list .pg { color: var(--green); font-weight: 700; font-family: var(--font-latin); }

/* اے آئی */
.key-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin: 12px 0;
}
.key-box label, #aiAskArea label { display: block; margin: 10px 0 4px; font-weight: 700; }
.key-row { display: flex; gap: 8px; margin-top: 10px; }
.danger-btn {
  background: none; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 10px; padding: 12px 14px; font-size: 16px;
}
#aiAnswer {
  margin-top: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; line-height: 2.1; font-size: 18px;
  white-space: pre-wrap;
}
#aiAnswer:empty { display: none; }
#aiAnswer blockquote {
  border-inline-start: 3px solid var(--gold); margin: 10px 0; padding: 6px 12px;
  background: var(--gold-light); font-size: 16px;
}

/* ترتیبات */
.setting-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.setting-group h3 { margin: 0 0 10px; color: var(--green); font-size: 19px; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); font-size: 16px;
}
.seg button.active { background: var(--green); color: #fff; border-color: var(--green); }
.book-info p { margin: 4px 0; font-size: 16px; }

@media (min-width: 600px) {
  .home-buttons { flex-direction: row; }
  .big-btn { flex: 1; }
}
