@font-face { font-family: "Noto Nastaliq Urdu"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/nastaliq-400.woff2") format("woff2"); }
@font-face { font-family: "Noto Nastaliq Urdu"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/nastaliq-600.woff2") format("woff2"); }
@font-face { font-family: "Noto Nastaliq Urdu"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/nastaliq-700.woff2") format("woff2"); }
@font-face { font-family: "Noto Naskh Arabic"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/naskh-400.woff2") format("woff2"); }
@font-face { font-family: "Noto Naskh Arabic"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/naskh-600.woff2") format("woff2"); }
@font-face { font-family: "Noto Naskh Arabic"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/naskh-700.woff2") format("woff2"); }
:root {
  --bg: #f6f1e6;
  --paper: #fffdf8;
  --ink: #1d2a24;
  --muted: #5d6b63;
  --line: #e2d9c6;
  --green: #1d5440;
  --green-deep: #133a2c;
  --gold: #b08a3e;
  --gold-soft: #efe2c2;
  --hl: #fff2c9;
  --shadow: 0 1px 2px rgba(19, 58, 44, .06), 0 8px 24px rgba(19, 58, 44, .08);
  --radius: 14px;
  --nastaliq: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", serif;
  --naskh: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101814; --paper: #16211c; --ink: #e9e4d8; --muted: #a3b0a8; --line: #2a3a32;
    --green: #6fbf98; --green-deep: #0c1511; --gold: #d4b26a; --gold-soft: #3a3322; --hl: #3d3519;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #101814; --paper: #16211c; --ink: #e9e4d8; --muted: #a3b0a8; --line: #2a3a32;
  --green: #6fbf98; --green-deep: #0c1511; --gold: #d4b26a; --gold-soft: #3a3322; --hl: #3d3519;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--naskh); font-size: 17px; line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.num { font-family: "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { font-family: var(--nastaliq); font-size: 22px; color: var(--green-deep); line-height: 1; display: flex; align-items: center; gap: 10px; }
:root[data-theme="dark"] .brand { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand { color: var(--ink); } }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.nav { margin-inline-start: auto; display: flex; gap: 6px; }
.nav a { color: var(--ink); padding: 6px 12px; border-radius: 999px; font-size: 15px; }
.nav a:hover { background: var(--gold-soft); text-decoration: none; }
@media (max-width: 640px) { .nav a.opt { display: none; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent;
  padding: 10px 20px; border-radius: 999px; font: inherit; font-size: 16px; cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--green); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #0c1511; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0c1511; } }
.btn-ghost { border-color: var(--line); color: var(--ink); background: var(--paper); }
.btn small { opacity: .75; font-size: 13px; }

/* Hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero::before {
  content: ""; position: absolute; inset: 0; opacity: .5; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23b08a3e' stroke-opacity='.18' stroke-width='1'%3E%3Cpath d='M40 4l10 26 26 10-26 10-10 26-10-26L4 40l26-10z'/%3E%3Ccircle cx='40' cy='40' r='12'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: linear-gradient(to bottom, #000 0%, transparent 95%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 95%);
}
.hero .wrap { position: relative; display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; padding-top: 56px; padding-bottom: 64px; }
.eyebrow { color: var(--gold); font-size: 15px; letter-spacing: 0; margin: 0 0 4px; }
.hero h1 {
  font-family: var(--nastaliq); font-weight: 700; color: var(--green-deep);
  font-size: clamp(44px, 8vw, 76px); line-height: 1.9; margin: 0;
}
:root[data-theme="dark"] .hero h1 { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero h1 { color: var(--ink); } }
.hero .sub { font-family: var(--nastaliq); font-size: clamp(18px, 2.6vw, 22px); line-height: 2.3; color: var(--muted); margin: 0 0 6px; }
.hero .author { font-size: 18px; margin: 0 0 28px; }
.hero .author b { font-family: var(--nastaliq); font-weight: 600; color: var(--green); }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; }
.stats { display: flex; gap: 28px; margin-top: 36px; padding: 0; list-style: none; }
.stats li { display: flex; flex-direction: column; line-height: 1.5; }
.stats strong { font-size: 26px; color: var(--green); }
.stats span { font-size: 14px; color: var(--muted); }

.book { justify-self: center; position: relative; width: min(280px, 70vw); aspect-ratio: 461 / 914; transform: rotate(-2deg); }
.book img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 4px 10px 10px 4px; background: #fff;
  box-shadow: 0 30px 60px -20px rgba(19,58,44,.45), 0 0 0 1px rgba(0,0,0,.06); }
.book::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 14px; border-radius: 0 10px 10px 0;
  background: linear-gradient(to left, var(--green-deep), var(--green)); }

@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; padding-top: 32px; gap: 28px; }
  .book { width: 170px; order: -1; }
}

/* Sections */
section { padding: 56px 0; }
.sec-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h2 { font-family: var(--nastaliq); font-size: 32px; line-height: 2; margin: 0; color: var(--green-deep); font-weight: 700; }
:root[data-theme="dark"] h2 { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) h2 { color: var(--ink); } }
.lead { color: var(--muted); margin: 0; }

/* Search */
.search { position: relative; width: min(420px, 100%); }
.search input {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 44px 12px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); outline: none;
}
.search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.search svg { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.count { font-size: 14px; color: var(--muted); margin: 8px 4px 0; min-height: 1.5em; }

/* TOC */
.front { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { display: inline-flex; gap: 8px; align-items: center; padding: 4px 14px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; color: var(--ink); font-size: 15px; }
.chip:hover { border-color: var(--gold); text-decoration: none; }
.chip .num { color: var(--muted); font-size: 13px; }

.chapter { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.chapter > summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 16px;
  padding: 14px 20px;
}
.chapter > summary::-webkit-details-marker { display: none; }
.ch-no { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-weight: 700; font-size: 18px; }
.ch-title { display: flex; flex-direction: column; line-height: 1.6; }
.ch-title small { color: var(--gold); font-size: 14px; }
.ch-title b { font-family: var(--nastaliq); font-size: 22px; line-height: 2.1; font-weight: 600; }
.ch-meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.chev { transition: transform .2s ease; color: var(--muted); }
.chapter[open] .chev { transform: rotate(180deg); }
@media (max-width: 560px) { .ch-meta { display: none; } .chapter > summary { grid-template-columns: auto 1fr auto; padding: 12px 14px; gap: 12px; } }

.topics { list-style: none; margin: 0; padding: 4px 8px 12px; border-top: 1px solid var(--line); columns: 2; column-gap: 8px; }
@media (max-width: 760px) { .topics { columns: 1; } }
.topics li { break-inside: avoid; }
.topics a {
  display: flex; align-items: baseline; gap: 10px; padding: 7px 12px; border-radius: 10px; color: var(--ink);
}
.topics a:hover { background: var(--bg); text-decoration: none; }
.topics .t { flex: 1; }
.topics .dots { flex: 1; border-bottom: 1px dotted var(--line); min-width: 12px; transform: translateY(-5px); }
.topics .t { flex: 0 1 auto; }
.topics .num { color: var(--muted); font-size: 14px; }
.topics .idx { color: var(--gold); font-size: 13px; min-width: 22px; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; display: none; }

/* About */
.about { background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.about .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 8px; }
@media (max-width: 760px) { .about .grid { grid-template-columns: 1fr; } }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.card h3 { margin: 0 0 4px; font-size: 18px; color: var(--green); }
.card p { margin: 0; color: var(--muted); font-size: 16px; }

footer { padding: 28px 0 40px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.theme-btn { background: none; border: 1px solid var(--line); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }

/* Reader */
body.reader { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.rbar { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; background: var(--paper); border-bottom: 1px solid var(--line); flex: none; }
.rbar .brand { font-size: 19px; }
.rbar .now { flex: 1; min-width: 0; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.rbar .now b { color: var(--ink); font-weight: 600; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; white-space: nowrap; }
.icon-btn:hover { border-color: var(--gold); text-decoration: none; }
@media (max-width: 600px) { .icon-btn .lbl { display: none; } .rbar .brand span { display: none; } }
.rmain { flex: 1; display: flex; min-height: 0; position: relative; }
.rmain iframe { flex: 1; border: 0; width: 100%; height: 100%; background: #525659; }
.drawer {
  width: 340px; flex: none; background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.drawer[hidden] { display: none; }
.drawer .dhead { padding: 12px; border-bottom: 1px solid var(--line); }
.drawer .search { width: 100%; }
.drawer .search input { padding-top: 9px; padding-bottom: 9px; }
.dlist { overflow-y: auto; flex: 1; padding: 6px 6px 24px; }
.dlist h4 { margin: 14px 10px 4px; font-size: 14px; color: var(--gold); font-weight: 600; }
.dlist h4 b { display: block; font-family: var(--nastaliq); color: var(--green); font-size: 18px; line-height: 2; font-weight: 600; }
.dlist a { display: flex; gap: 8px; justify-content: space-between; padding: 6px 10px; border-radius: 8px; color: var(--ink); font-size: 15px; line-height: 1.7; }
.dlist a:hover { background: var(--bg); text-decoration: none; }
.dlist a.cur { background: var(--gold-soft); }
.dlist .num { color: var(--muted); font-size: 13px; }
@media (max-width: 900px) {
  .drawer { position: absolute; inset: 0 0 0 auto; width: min(360px, 88vw); z-index: 5; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
}
