﻿/* =========================================================================
   Wise Human — public site styles
   Logical properties everywhere so RTL (fa, ar, ku, ur) and LTR (en, tr) share one stylesheet.
   ========================================================================= */
/* colours (palettes, light + dark) live in css/theme.css; only the non-colour tokens are here */
:root {
  --danger: #b3382c;
  --r: 16px; --r-s: 10px;
  --header-h: 64px; --tab-h: 0px; --player-h: 0px;
  --font-ui: 'Vazirmatn', 'Inter', system-ui, sans-serif;
  --font-display: 'Vazirmatn', serif;
  --font-read: 'Vazirmatn', serif;
  --read-lh: 2;
  --read-size: 1;
}

/* per-language typography */
html[lang='fa'] { --font-display: 'Noto Nastaliq Urdu', 'Vazirmatn', serif; --font-read: 'Vazirmatn', sans-serif; --read-lh: 2.05; }
html[lang='ar'] { --font-display: 'Amiri', 'Vazirmatn', serif; --font-read: 'Amiri', 'Noto Naskh Arabic', serif; --read-lh: 2.1; }
html[lang='ku'] { --font-display: 'Amiri', 'Vazirmatn', serif; --font-read: 'Noto Naskh Arabic', 'Vazirmatn', serif; --read-lh: 2.1; }
html[lang='ur'] { --font-display: 'Noto Nastaliq Urdu', 'Vazirmatn', serif; --font-read: 'Noto Nastaliq Urdu', 'Vazirmatn', serif; --read-lh: 2.6; }
html[lang='en'], html[lang='tr'] { --font-ui: 'Inter', system-ui, sans-serif; --font-display: 'Playfair Display', Georgia, serif; --font-read: 'Inter', system-ui, sans-serif; --read-lh: 1.8; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-height: 100dvh;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.ic { flex: none; vertical-align: middle; }
[dir='rtl'] .flip { transform: scaleX(-1); }
.container { width: min(1200px, 100% - 32px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.boot img { animation: pulse 1.4s ease-in-out infinite; opacity: .8; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: 1; } }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-top: env(safe-area-inset-top);
}
.site-header .container { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; border-radius: 12px; background: #f8ece1; padding: 3px; box-shadow: var(--shadow-s); }
.main-nav { display: flex; gap: 2px; margin-inline-start: 12px; }
.main-nav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .95rem;
}
.main-nav a:hover { background: var(--bg2); color: var(--ink); text-decoration: none; }
.main-nav a.active { background: var(--brand-soft); color: var(--brand-deep); }
.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--bg2); }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.lang-btn:hover { background: var(--bg2); }
.menu { position: relative; }
.menu-pop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 180px; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-m); z-index: 60; display: none;
}
.menu.open .menu-pop { display: block; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 10px; color: var(--ink); text-align: start;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--bg2); text-decoration: none; }
.menu-pop .on { color: var(--brand); font-weight: 700; }

/* mobile tab bar */
.tabbar { display: none; }
@media (max-width: 900px) {
  :root { --tab-h: 62px; --header-h: 56px; }
  .main-nav, .brand .brand-text.long { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 55; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--muted); min-width: 0; }
  .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 2px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--brand); }
  .tabbar a.active .ic { transform: translateY(-1px); }
  main { padding-bottom: calc(var(--tab-h) + var(--player-h) + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: .98rem; box-shadow: var(--shadow-s); transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-m); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: .9rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); font-size: .82rem; font-weight: 700; }
.chip.gold { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden; padding: clamp(28px, 5vw, 72px) 0 clamp(36px, 6vw, 80px);
  background:
    radial-gradient(900px 480px at 88% -8%, color-mix(in srgb, var(--brand) 17%, transparent), transparent 62%),
    radial-gradient(700px 420px at 4% 105%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 62%),
    var(--bg);
}
.hero::before {
  content: ''; position: absolute; inset: 0; opacity: .06; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%230e6e68' stroke-width='1.2'%3E%3Cpath d='M36 4l8.5 14.5L61 12l-6.5 16.5L68 36l-13.5 7.5L61 60l-16.5-6.5L36 68l-8.5-14.5L11 60l6.5-16.5L4 36l13.5-7.5L11 12l16.5 6.5z'/%3E%3C/g%3E%3C/svg%3E");
}
:root[data-theme='dark'] .hero::before { opacity: .08; filter: invert(1) hue-rotate(150deg); }
.hero::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 110px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(24px, 5vw, 72px); align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .85rem; font-weight: 700; color: var(--accent); box-shadow: var(--shadow-s); margin-bottom: 18px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.6rem, 7vw, 5rem); color: var(--brand); margin: 0 0 .15em; line-height: 1.25;
}
html[lang='fa'] .hero h1, html[lang='ur'] .hero h1 { line-height: 1.9; padding-block: .1em; }
.hero .lead { font-size: clamp(1.1rem, 2.2vw, 1.5rem); font-weight: 600; color: var(--ink); margin-bottom: .6em; }
.hero .desc { color: var(--muted); max-width: 56ch; font-size: 1.04rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 320px; }
.hero-art::before {
  content: ''; position: absolute; width: min(88%, 420px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 35%, transparent), color-mix(in srgb, var(--brand) 20%, transparent) 60%, transparent 72%);
  filter: blur(2px);
}
.hero-art img.cover3d { position: relative; width: min(100%, 360px); filter: drop-shadow(0 28px 36px rgba(30, 20, 5, .30)); animation: float 7s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-art { order: -1; min-height: 240px; }
  .hero-art img.cover3d, .hero-art .bookcover { width: min(56vw, 260px); }
  .hero .desc { margin-inline: auto; }
  .cta-row { justify-content: center; }
}

/* generated cover (when an edition has no cover image) */
.bookcover {
  position: relative; aspect-ratio: 3 / 4; width: 100%; border-radius: 6px 14px 14px 6px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center;
  padding: 7% 8% 8%; color: #fff; background: linear-gradient(155deg, #137f78, #0a4a46 70%); box-shadow: var(--shadow-m), inset 0 0 0 1px rgba(255, 255, 255, .08);
}
[dir='rtl'] .bookcover { border-radius: 14px 6px 6px 14px; }
.bookcover::before { content: ''; position: absolute; inset: 5%; border: 1.5px solid rgba(240, 214, 160, .55); border-radius: 8px; pointer-events: none; }
.bookcover .bc-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.1rem, 4.2cqw, 2.2rem); line-height: 1.5; margin-top: 8%; text-wrap: balance; }
.bookcover .bc-sub { font-size: .72rem; opacity: .85; line-height: 1.6; padding-inline: 4%; }
.bookcover .bc-author { font-size: .78rem; font-weight: 700; color: #f0d6a0; }
.bookcover img { width: 38%; background: #f8ece1; border-radius: 50%; padding: 3%; }
.cover-wrap { container-type: inline-size; }
@container (max-width: 190px) {
  .bookcover { padding: 6% 6% 7%; }
  .bookcover .bc-title { font-size: 1rem; margin-top: 4%; }
  .bookcover .bc-sub { display: none; }
  .bookcover img { width: 40%; }
  .bookcover .bc-author { font-size: .68rem; }
}

/* ---------------------------------------------------------------- sections */
.section { padding: clamp(32px, 5vw, 64px) 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 1000px) { .grid.cols-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .grid.cols-5, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } .grid { gap: 12px; } }
@media (max-width: 420px) { .grid.cols-5 .card-lg:last-child { grid-column: span 2; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-s); }
a.card-lg {
  display: flex; flex-direction: column; gap: 10px; padding: 22px 20px; color: var(--ink); transition: transform .18s, box-shadow .18s, border-color .18s;
}
a.card-lg:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-m); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.card-lg .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.card-lg:nth-child(2n) .ico { background: var(--accent-soft); color: var(--accent); }
.card-lg h3 { margin: 4px 0 0; font-size: 1.1rem; }
.card-lg p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.6; }

.lang-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; text-align: start; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-s); transition: transform .18s, box-shadow .18s; }
.lang-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-m); }
.lang-card.current { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.lang-card .ln { font-size: .82rem; color: var(--muted); font-weight: 600; }
.lang-card .lt { font-size: 1.35rem; font-weight: 800; line-height: 1.5; }
.lang-card .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--bg2); color: var(--muted); }
.badge.on { background: var(--brand-soft); color: var(--brand-deep); }

.live-banner {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: clamp(22px, 4vw, 40px); border-radius: 24px; color: #fff;
  background: radial-gradient(600px 300px at 100% 0, rgba(240, 214, 160, .25), transparent 60%), linear-gradient(135deg, #0e6e68, #083f3c);
  box-shadow: var(--shadow-m);
}
.live-banner h2 { margin: 6px 0 4px; font-size: clamp(1.3rem, 3vw, 1.9rem); }
.live-banner p { margin: 0; opacity: .85; }
.live-banner .btn { background: #fff; color: #0a4a46; border-color: #fff; }
@media (max-width: 700px) { .live-banner { flex-direction: column; align-items: flex-start; } }
.live-dot { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 10px; border-radius: 999px; background: #d8352a; color: #fff; font-size: .78rem; font-weight: 800; letter-spacing: .04em; }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------------------------------------------------------------- page chrome */
.page-head { padding: clamp(24px, 4vw, 48px) 0 8px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 6px; font-family: var(--font-display); color: var(--brand); }
html[lang='fa'] .page-head h1, html[lang='ur'] .page-head h1 { line-height: 1.8; }
.page-head p { color: var(--muted); margin: 0; max-width: 70ch; }
.empty { text-align: center; padding: 56px 20px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--surface2); margin-block: 24px; }
.empty .ic { color: var(--accent); margin-bottom: 10px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 46ch; margin-inline: auto; }
.empty .cta-row { justify-content: center; }
.skeleton { background: linear-gradient(90deg, var(--bg2), var(--surface2), var(--bg2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r); min-height: 140px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* edition cards (PDF / read library) */
.edition { display: flex; gap: 18px; padding: 18px; align-items: stretch; }
.edition .cover-wrap { width: 120px; flex: none; }
.edition .info { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.edition h3 { margin: 0; font-family: var(--font-display); font-size: 1.3rem; color: var(--brand); }
.edition .meta { color: var(--muted); font-size: .88rem; }
.edition .actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.cover-img { border-radius: 6px 12px 12px 6px; box-shadow: var(--shadow-m); aspect-ratio: 3/4; object-fit: contain; background: transparent; }
[dir='rtl'] .cover-img { border-radius: 12px 6px 6px 12px; }

/* ---------------------------------------------------------------- reader */
.reader { --rbg: transparent; --rink: var(--ink); --rline: var(--line); }
.reader.sepia { --rbg: #f4ecd8; --rink: #3b3226; --rline: #dfd2b3; }
.reader.dark { --rbg: #101a19; --rink: #dfe9e7; --rline: #27393a; }
.reader-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; padding-block: 20px 48px; }
.toc { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 40px); overflow: auto; padding: 14px; }
.toc h3 { font-size: 1rem; margin: 0 0 8px; padding-inline: 8px; color: var(--muted); }
.toc a { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); font-size: .95rem; line-height: 1.5; }
.toc a:hover { background: var(--bg2); text-decoration: none; }
.toc a.active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 700; }
.toc .n { flex: none; width: 24px; color: var(--muted); font-variant-numeric: tabular-nums; }
.reader-main { background: var(--rbg); color: var(--rink); border-radius: var(--r); min-width: 0; }
.reader.sepia .reader-main, .reader.dark .reader-main { box-shadow: var(--shadow-s); }
.reader-bar { position: sticky; top: var(--header-h); z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 16px; }
.reader-bar .title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.reader-bar .progress { position: absolute; inset-inline: 12px; bottom: -1px; height: 3px; border-radius: 3px; background: transparent; overflow: hidden; }
.reader-bar .progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .1s; }
.reader-bar .toc-btn { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: .82rem; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--brand-soft); color: var(--brand-deep); }
.prose { font-family: var(--font-read); font-size: calc(1.1rem * var(--read-size)); line-height: var(--read-lh); padding: clamp(16px, 4vw, 44px); max-width: 760px; margin-inline: auto; overflow-wrap: anywhere; }
.prose h1, .prose h2 { font-family: var(--font-display); color: var(--brand); font-size: 1.7em; margin-top: 0; line-height: 1.6; }
.prose h3 { font-size: 1.2em; margin-top: 1.6em; }
.prose p { margin-bottom: 1.1em; }
.prose blockquote { margin: 1.4em 0; padding: 14px 20px; border-inline-start: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; }
[dir='rtl'] .prose blockquote { border-radius: 12px 0 0 12px; }
.prose blockquote.ayah { background: var(--brand-soft); border-color: var(--brand); text-align: center; font-weight: 600; }
.prose .center { text-align: center; font-size: 1.3em; color: var(--accent); }
.prose ol, .prose ul { padding-inline-start: 1.6em; }
.prose li { margin-bottom: .5em; }
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; padding: 0 clamp(16px, 4vw, 44px) 28px; max-width: 760px; margin-inline: auto; }
.chapter-nav a { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--rline); border-radius: 14px; background: var(--surface); color: var(--ink); }
.chapter-nav a:hover { text-decoration: none; border-color: var(--brand); }
.chapter-nav small { color: var(--muted); font-weight: 600; }
.chapter-nav .next { text-align: end; }
.toc-scrim { display: none; }
@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; padding-top: 12px; }
  .toc { position: fixed; z-index: 70; inset-block: 0; inset-inline-start: 0; width: min(86vw, 340px); max-height: none; border-radius: 0; transform: translateX(-105%); transition: transform .25s; padding-top: calc(16px + env(safe-area-inset-top)); }
  [dir='rtl'] .toc { transform: translateX(105%); }
  .toc-open .toc { transform: none; }
  .toc-open .toc-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 65; }
  .reader-bar .toc-btn { display: inline-grid; }
  .reader-bar { top: var(--header-h); }
}

/* ---------------------------------------------------------------- PDF viewer */
.pdf-shell { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h) - var(--tab-h) - var(--player-h)); min-height: 420px; }
.pdf-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pdf-bar .title { flex: 1; min-width: 120px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-bar input { width: 64px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); text-align: center; font: inherit; }
.pdf-scroll { flex: 1; overflow: auto; background: color-mix(in srgb, var(--bg2) 92%, #888); padding: 18px 10px 60px; scroll-behavior: auto; }
.pdf-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .18); border-radius: 3px; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 1.2rem; }
.pdf-msg { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- audio */
.track-list { display: flex; flex-direction: column; gap: 10px; }
.track { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.track .play { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; transition: transform .15s; }
.track .play:hover { transform: scale(1.07); }
.track.current { border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 60%, var(--surface)); }
.track .tt { flex: 1; min-width: 0; font-weight: 700; }
.track .ts { color: var(--muted); font-size: .85rem; font-weight: 500; }
.eq { display: none; gap: 2px; align-items: end; height: 16px; }
.track.current.playing .eq { display: inline-flex; }
.eq i { width: 3px; background: var(--brand); border-radius: 2px; animation: eq 1s infinite ease-in-out; }
.eq i:nth-child(1) { height: 60%; } .eq i:nth-child(2) { height: 100%; animation-delay: .2s; } .eq i:nth-child(3) { height: 40%; animation-delay: .4s; }
@keyframes eq { 50% { transform: scaleY(.4); } }

/* global mini player */
.miniplayer {
  position: fixed; z-index: 54; inset-inline: 0; bottom: 0; display: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(0, 0, 0, .12);
}
.miniplayer.show { display: block; }
.mp-inner { width: min(1000px, 100%); margin-inline: auto; display: flex; align-items: center; gap: 12px; }
.mp-art { width: 44px; height: 44px; border-radius: 10px; background: #f8ece1; padding: 3px; flex: none; }
.mp-meta { min-width: 0; flex: 1; }
.mp-title { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-time { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-seek { width: 100%; accent-color: var(--brand); margin: 2px 0 0; direction: ltr; }
.mp-ctrl { display: flex; align-items: center; gap: 2px; }
.mp-ctrl .play-main { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); }
.mp-ctrl .play-main:hover { background: var(--brand); filter: brightness(1.1); }
.mp-rate { font-size: .8rem; font-weight: 800; width: auto; padding: 0 10px; }
@media (max-width: 900px) { .miniplayer { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: 8px; } .mp-rate, .mp-ctrl .hide-s { display: none; } }

/* ---------------------------------------------------------------- video + live */
.video-frame { position: relative; aspect-ratio: 16 / 9; width: 100%; background: #000; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-m); }
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.video-frame .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff; padding: 20px; background: rgba(0, 0, 0, .65); }
.video-frame .live-dot { position: absolute; top: 14px; inset-inline-start: 14px; z-index: 2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.chips button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: .92rem; color: var(--muted); }
.chips button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.vgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.vcard { display: flex; flex-direction: column; text-align: start; padding: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-s); transition: transform .15s, box-shadow .15s; }
.vcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-m); }
.vcard.on { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.vcard .th { position: relative; aspect-ratio: 16 / 9; background: #111 center / cover no-repeat; }
.vcard .th::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0, 0, 0, .45)); }
.vcard .pl { position: absolute; z-index: 1; inset-inline-end: 10px; bottom: 10px; width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #0a4a46; display: grid; place-items: center; }
.vcard .vt { padding: 10px 12px 12px; font-weight: 700; font-size: .93rem; line-height: 1.5; }
.vcard .vd { padding: 0 12px 12px; margin-top: -6px; color: var(--muted); font-size: .8rem; }
.channel-card { display: flex; align-items: center; gap: 16px; padding: 18px; flex-wrap: wrap; }
.channel-card img { width: 64px; height: 64px; border-radius: 50%; background: #f8ece1; padding: 6px; box-shadow: var(--shadow-s); }
.channel-card .ci { flex: 1; min-width: 200px; }
.channel-card h3 { margin: 0; }

/* socials */
.socials { display: flex; flex-wrap: wrap; gap: 10px; }
.social { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-s); transition: transform .15s, background .15s, color .15s; }
.social:hover { transform: translateY(-3px); background: var(--brand); color: var(--brand-ink); text-decoration: none; }
.store-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.store { display: inline-flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 14px; background: #111; color: #fff; border: 1px solid #333; font-weight: 700; }
.store small { display: block; font-size: .68rem; font-weight: 500; opacity: .75; line-height: 1.1; }
.store:hover { text-decoration: none; background: #000; }
.about-grid { display: grid; grid-template-columns: 280px 1fr; gap: 36px; align-items: start; }
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; } .about-grid .cover-wrap { max-width: 240px; margin-inline: auto; } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 18px 0; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; font-weight: 700; }

/* search */
.searchbox { display: flex; gap: 8px; margin: 16px 0 24px; }
.searchbox input { flex: 1; height: 52px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 1.05rem; box-shadow: var(--shadow-s); }
.result { display: block; padding: 16px 18px; color: var(--ink); margin-bottom: 12px; }
.result:hover { text-decoration: none; border-color: var(--brand); }
.result .rt { font-weight: 800; margin: 4px 0; }
.result .rs { color: var(--muted); font-size: .92rem; }
mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }

/* footer */
.site-footer { margin-top: 24px; background: var(--brand-deep); color: #e8f5f3; padding: 44px 0 28px; }
:root[data-theme='dark'] .site-footer { background: #0a1211; border-top: 1px solid var(--line); color: var(--ink); }
.site-footer a { color: inherit; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 { font-size: .95rem; letter-spacing: .02em; opacity: .8; margin-bottom: 12px; }
.site-footer .brand { color: inherit; margin-bottom: 10px; }
.site-footer .social { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; box-shadow: none; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.copy { margin-top: 28px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: .85rem; opacity: .75; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

.in-app .footer-grid > div:last-child, .in-app #install-btn { display: none !important; }
.toast { position: fixed; z-index: 100; inset-inline: 0; bottom: calc(var(--tab-h) + var(--player-h) + 24px); margin-inline: auto; width: max-content; max-width: 90vw; padding: 12px 20px; border-radius: 999px; background: #111; color: #fff; box-shadow: var(--shadow-l); font-weight: 600; animation: pop .2s ease-out; }
.modal { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .75); padding: 16px; }
.modal .video-frame { width: min(960px, 100%); }
.modal .close { position: absolute; top: 14px; inset-inline-end: 14px; background: rgba(255, 255, 255, .15); color: #fff; }

/* =========================================================================
   v2: reader toolbar, library cards, video details
   ========================================================================= */
.reader { --rbg: var(--surface); }
.reader.sepia { --rbg: #f4ecd8; --rink: #3b3226; --rline: #dfd2b3; }
.reader.dark { --rbg: #101a19; --rink: #dfe9e7; --rline: #27393a; }
.reader-bar { gap: 10px; padding: 8px 10px; }
.reader-bar .title { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; flex: 1; }
.reader-bar .title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-bar .title small { color: var(--muted); font-weight: 600; font-size: .75rem; }
.reader-bar .tools { display: flex; gap: 6px; flex: none; }
.tool { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--bg2); color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; font-size: .95rem; transition: background .15s; }
.tool:hover { background: var(--brand-soft); color: var(--brand-deep); }
.tool.on { background: var(--accent); color: #fff; }
.tool.on .ic { fill: currentColor; }
@media (max-width: 520px) { .reader-bar .tools { gap: 4px; } .tool { width: 36px; height: 36px; border-radius: 10px; } .reader-bar .title small { display: none; } }
.toc a .tt { flex: 1; }
.toc a .bmk { color: var(--accent); }
.toc a .bmk .ic { fill: currentColor; }
.prose .book-line { text-align: center; color: var(--muted); font-weight: 700; font-size: .8em; margin-bottom: .3em; }
.prose h1.ch-title { font-family: var(--font-display); color: var(--brand); text-align: center; font-size: 1.9em; line-height: 1.7; margin: 0 0 1em; padding-bottom: .5em; border-bottom: 2px solid var(--accent-soft); }
.prose h2 { color: var(--brand); border-inline-start: 5px solid var(--accent); padding-inline-start: .6em; font-size: 1.35em; margin: 1.8em 0 .7em; }
.prose h3 { color: var(--accent); font-weight: 800; font-size: 1.15em; }
.prose ol > li::marker, .prose ul > li::marker { color: var(--accent); font-weight: 800; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .92em; }
.prose td, .prose th { border: 1px solid var(--rline, var(--line)); padding: .5em .7em; vertical-align: top; }
.prose th { background: var(--brand-soft); }
.prose hr { border: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); margin: 2em 0; }
.chapter-nav { display: flex; gap: 14px; max-width: none; padding: 0; margin: 16px 0 0; }
.chapter-nav .ph { flex: 1; }
.chapter-nav a { flex: 1; display: flex; align-items: center; gap: 12px; padding: 16px 20px; border: 0; border-radius: 16px; color: #fff; font-weight: 800; line-height: 1.5; box-shadow: var(--shadow-m); transition: transform .15s; min-width: 0; }
.chapter-nav a:hover { text-decoration: none; transform: translateY(-2px); }
.chapter-nav a span { display: flex; flex-direction: column; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chapter-nav a small { opacity: .85; font-weight: 600; }
.chapter-nav a.prev { background: linear-gradient(135deg, #c28a3e, #94621f); }
.chapter-nav a.next { background: linear-gradient(135deg, #0e8a80, #0a4e4a); justify-content: flex-end; text-align: end; }
.chapter-nav a.next span { align-items: flex-end; }
@media (max-width: 560px) { .chapter-nav { flex-direction: column-reverse; } }

.lib-hero { margin-top: 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: clamp(20px, 4vw, 34px); border-radius: 22px; color: #fff;
  background: radial-gradient(520px 240px at 100% 0, rgba(240, 214, 160, .28), transparent 60%), linear-gradient(135deg, #0e8a80, #0a4e4a); box-shadow: var(--shadow-m); }
.lib-hero h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 3.4vw, 2.2rem); display: flex; align-items: center; gap: 10px; font-family: var(--font-display); }
html[lang='fa'] .lib-hero h1, html[lang='ur'] .lib-hero h1 { line-height: 1.8; }
.lib-hero p { margin: 0; opacity: .88; }
.lib-search { display: flex; align-items: center; gap: 8px; background: #fff; color: #1c2b2a; border-radius: 14px; padding: 0 14px; flex: 1; min-width: min(100%, 280px); max-width: 440px; height: 50px; }
.lib-search input { border: 0; outline: 0; background: none; flex: 1; font: inherit; color: inherit; min-width: 0; }
.lib-count { margin: 18px 4px 10px; }
.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
@media (max-width: 480px) { .bk-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
.bk { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-s); color: var(--ink); transition: transform .18s, box-shadow .18s; }
a.bk:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-m); }
.bk-cover { position: relative; padding: 22px 6px 4px; }
.bk-cover .cover-wrap { width: 100%; max-width: 190px; margin-inline: auto; }
.bk-badges { position: absolute; top: 0; inset-inline: 0; display: flex; justify-content: space-between; pointer-events: none; }
.bk-badges i { font-style: normal; font-weight: 800; font-size: .7rem; letter-spacing: .05em; padding: 3px 9px; border-radius: 8px; color: #fff; }
.bk-badges .word { background: #2b5fb3; }
.bk-badges .pdf { background: #c0392b; margin-inline-start: auto; }
.bk-cover .bk-badge { position: absolute; bottom: 6px; inset-inline-end: 8px; background: var(--brand); color: var(--brand-ink); padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.bk-title { margin: 4px 0 0; font-size: 1.02rem; text-align: center; line-height: 1.6; }
.bk-meta { text-align: center; color: var(--muted); font-size: .84rem; margin-top: -4px; }
.bk > .btn { width: 100%; }
.dls { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.dl { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 12px; font-weight: 700; font-size: .86rem; border: 1px solid var(--line); color: var(--ink); }
.dl.pdf { background: color-mix(in srgb, #c0392b 9%, var(--surface)); border-color: color-mix(in srgb, #c0392b 32%, var(--line)); }
.dl.word { background: color-mix(in srgb, #2b5fb3 9%, var(--surface)); border-color: color-mix(in srgb, #2b5fb3 32%, var(--line)); }
.dl:hover { text-decoration: none; filter: brightness(.96); }
.dl-l { display: inline-flex; align-items: center; gap: 6px; }
.dl small { font-weight: 500; opacity: .7; }
.dl-n { font-size: .74rem; color: var(--muted); font-weight: 600; }

.vinfo { margin-top: 18px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-s); }
.vinfo h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--brand); }
.vabout b { color: var(--accent); font-size: .9rem; }
.vabout p { margin: 4px 0 0; line-height: 1.9; }
.vd2 { padding: 0 12px 12px; margin-top: -6px; color: var(--muted); font-size: .82rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; }

@media print {
  .site-header, .site-footer, .tabbar, .miniplayer, .toc, .toc-scrim, .reader-bar, .chapter-nav, .toast { display: none !important; }
  body { background: #fff; }
  .reader-layout { display: block; padding: 0; }
  .reader-main { box-shadow: none !important; background: #fff !important; color: #000 !important; }
  .prose { max-width: none; padding: 0; }
}

/* v2 fixes */
.reader-col { min-width: 0; }
@media (max-width: 900px) { .reader-layout { grid-template-columns: minmax(0, 1fr); } }
.prose h2, .prose h3 { font-family: var(--font-read); }
.prose table { display: block; overflow-x: auto; }
.prose img { max-width: 100%; height: auto; }
.cover-img { box-shadow: none; border-radius: 0; background: transparent; filter: drop-shadow(0 8px 12px rgba(30, 20, 5, .28)); }

.share-box { width: min(440px, 100%); background: var(--surface); color: var(--ink); border-radius: 20px; padding: 22px; box-shadow: var(--shadow-l); }
.share-box h3 { margin: 0 0 6px; }
.share-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.vsearch { margin: 0 0 16px; max-width: 460px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
