/* ============================================================
   Main stylesheet — LTR | light + dark
   ============================================================ */

/* ---------- Fonts (self-hosted for speed) ---------- */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/cairo-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/cairo-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F;
}

/* ---------- Color variables ---------- */
:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17212f;
  --text-2: #5a6b7f;
  --border: #e3e9f0;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: #ccfbf1;
  --accent: #059669;
  --accent-strong: #047857;
  --hero-grad-a: #ecfdf9;
  --hero-grad-b: #eef4ff;
  --shadow: 0 1px 3px rgba(23, 33, 47, .06), 0 4px 14px rgba(23, 33, 47, .06);
  --shadow-lg: 0 6px 24px rgba(23, 33, 47, .13);
  --radius: 14px;
  --header-h: 64px;
}
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2e;
  --surface-2: #1a2540;
  --text: #e8eef7;
  --text-2: #93a4bb;
  --border: #223050;
  --primary: #2dd4bf;
  --primary-strong: #5eead4;
  --primary-soft: #103433;
  --accent: #34d399;
  --accent-strong: #6ee7b7;
  --hero-grad-a: #0d1a2b;
  --hero-grad-b: #101a33;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .45);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-bottom: 56px; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-strong); }
::selection { background: var(--primary); color: #fff; }
.container { width: min(1200px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(820px, 100% - 32px); }
.skip-link {
  position: absolute; top: -48px; right: 12px; z-index: 200;
  background: var(--primary); color: #fff; padding: 8px 18px; border-radius: 0 0 10px 10px;
}
.skip-link:focus { top: 0; color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 22px;
  height: var(--header-h);
}
.logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 21px; color: var(--text);
  flex-shrink: 0;
}
.logo:hover { color: var(--primary); }
.logo-icon { width: 27px; height: 27px; color: var(--primary); flex-shrink: 0; }
.main-nav { display: flex; gap: 4px; }
.main-nav a {
  color: var(--text-2); font-weight: 600; font-size: 15px;
  padding: 7px 13px; border-radius: 9px;
}
.main-nav a:hover { color: var(--primary); background: var(--primary-soft); }

.header-search { position: relative; flex: 1; max-width: 420px; margin-inline-start: auto; }
.header-search svg {
  position: absolute; inset-inline-start: 13px; top: 50%; translate: 0 -50%;
  width: 17px; height: 17px; color: var(--text-2); pointer-events: none;
}
.header-search input {
  width: 100%; height: 40px;
  padding-inline: 40px 16px;
  border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .2s, background .2s;
}
.header-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.header-search input::placeholder { color: var(--text-2); }

/* Live search results */
.live-results {
  position: absolute; top: calc(100% + 8px); inset-inline: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow-lg);
  overflow: hidden; max-height: 380px; overflow-y: auto;
}
.live-results a {
  display: flex; gap: 11px; align-items: center;
  padding: 9px 13px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.live-results a:last-child { border-bottom: 0; }
.live-results a:hover, .live-results a.active { background: var(--surface-2); }
.live-results img { width: 34px; height: 50px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.live-results .lr-title { font-weight: 700; font-size: 13.5px; line-height: 1.4; }
.live-results .lr-author { font-size: 12px; color: var(--text-2); }
.live-results .lr-empty { padding: 14px; text-align: center; color: var(--text-2); font-size: 13.5px; }

/* Dark-mode toggle */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 11px;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  transition: color .2s, border-color .2s;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle svg { width: 19px; height: 19px; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* Mobile menu */
.burger {
  display: none; flex-direction: column; gap: 5px;
  width: 40px; height: 40px; padding: 10px 9px;
  border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--surface); cursor: pointer;
}
.burger span { height: 2px; background: var(--text); border-radius: 2px; transition: .25s; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(700px 320px at 85% -60px, var(--hero-grad-a), transparent),
    radial-gradient(700px 320px at 12% -80px, var(--hero-grad-b), transparent);
  border-bottom: 1px solid var(--border);
  padding: 58px 0 46px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800; line-height: 1.45;
  max-width: 780px; margin-inline: auto;
}
.hero-sub {
  color: var(--text-2); font-size: clamp(14px, 2vw, 17px);
  max-width: 640px; margin: 10px auto 0;
}
.hero-search {
  display: flex; gap: 10px;
  max-width: 620px; margin: 26px auto 0;
}
.hero-search input {
  flex: 1; height: 52px; padding-inline: 20px;
  border: 1.5px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 15.5px;
  box-shadow: var(--shadow);
}
.hero-search input:focus { outline: none; border-color: var(--primary); }
.hero-search button {
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding-inline: 26px;
  background: var(--primary); color: #fff;
  border: 0; border-radius: 14px;
  font: inherit; font-size: 15.5px; font-weight: 700;
  cursor: pointer; transition: background .2s, transform .15s;
}
.hero-search button:hover { background: var(--primary-strong); }
.hero-search button:active { transform: scale(.97); }
.hero-search button svg { width: 18px; height: 18px; }
[data-theme="dark"] .hero-search button { color: #06251f; }
.hero-search.inline { margin: 22px 0 34px; max-width: 560px; }
.hero-stats {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 24px; color: var(--text-2); font-size: 14.5px;
}
.hero-stats strong { color: var(--text); font-weight: 800; font-size: 16px; }
.hero-stats .dot { width: 4px; height: 4px; background: var(--border); border-radius: 50%; }

/* ---------- Sections ---------- */
.section { margin-top: 46px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 20px;
}
.section-head h2 {
  font-size: clamp(19px, 2.6vw, 24px); font-weight: 800;
  position: relative; padding-inline-start: 14px;
}
.section-head h2::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px;
  width: 4.5px; border-radius: 3px; background: var(--primary);
}
.see-all { font-weight: 700; font-size: 14px; }

/* ---------- Book cards ---------- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 22px 18px;
}
.books-grid.large { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); }
.book-card { min-width: 0; }
.card-cover {
  position: relative; display: block;
  aspect-ratio: 2 / 3; border-radius: 11px; overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card:hover .card-cover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.card-downloads {
  position: absolute; bottom: 8px; inset-inline-start: 8px;
  display: flex; align-items: center; gap: 4px;
  background: rgba(10, 18, 30, .72); color: #fff;
  backdrop-filter: blur(4px);
  font-size: 11.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}
.card-downloads svg { width: 12px; height: 12px; }
.card-title {
  margin-top: 11px; font-size: 14.5px; font-weight: 700; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--primary); }
.card-author { font-size: 12.5px; margin-top: 2px; }
.card-author a { color: var(--text-2); }
.card-author a:hover { color: var(--primary); }

/* ---------- Category cards ---------- */
.cats-band {
  background: var(--surface);
  border-block: 1px solid var(--border);
  padding: 40px 0 44px;
}
.cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 14px;
}
.cats-grid.full { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 22px 14px 18px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: transform .2s, border-color .2s, box-shadow .2s;
  text-align: center;
}
.cat-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow-lg); }
.cat-icon { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.cat-name { font-weight: 800; font-size: 15.5px; color: var(--text); }
.cat-count { font-size: 12.5px; color: var(--text-2); }
.tone-0 .cat-icon { filter: hue-rotate(0deg); }
.cats-band .cat-card { background: var(--bg); }

/* ---------- Author cards ---------- */
.authors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.author-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.author-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); }
.author-avatar {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-strong);
  font-weight: 800; font-size: 19px;
  border-radius: 50%;
}
.author-name { font-weight: 700; font-size: 14.5px; color: var(--text); flex: 1; line-height: 1.4; }
.author-count { font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* ---------- Book page ---------- */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  font-size: 13px; color: var(--text-2);
  padding: 18px 0 4px;
}
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .current { color: var(--text); font-weight: 600; }
.book-page {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow);
  padding: clamp(18px, 3.5vw, 34px);
  margin-top: 14px;
}
.book-main {
  display: grid; grid-template-columns: 280px 1fr;
  gap: clamp(20px, 3.5vw, 40px);
}
.book-cover-col { position: relative; }
.book-cover {
  width: 100%; border-radius: 13px;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 2 / 3; object-fit: cover;
  position: sticky; top: calc(var(--header-h) + 16px);
}
.book-info h1 {
  font-size: clamp(21px, 3vw, 28px); font-weight: 800; line-height: 1.5;
}
.book-author-line { margin-top: 6px; color: var(--text-2); font-size: 15.5px; }
.book-author-line a { font-weight: 700; }
/* Book meta: compact side-by-side cards — each value beside its label */
.book-meta {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 9px;
  margin: 20px 0;
}
.book-meta li {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 11px; padding: 6px 13px;
  font-size: 13.5px; line-height: 1.6;
}
.book-meta li span { color: var(--text-2); }
.book-meta li span::after { content: ':'; }
.book-meta li strong { font-weight: 800; }
@media (max-width: 640px) {
  .book-meta { justify-content: center; gap: 8px; }
  .book-meta li { padding: 5px 11px; font-size: 12.5px; }
}
.chip {
  background: var(--primary-soft); color: var(--primary-strong);
  padding: 2px 11px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700;
}
.chip:hover { background: var(--primary); color: #fff; }
.download-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 10px 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; font-weight: 800; font-size: 17px; white-space: nowrap;
  border-radius: 14px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.download-btn small { font-weight: 600; opacity: .85; font-size: 13px; }
.download-btn svg { width: 22px; height: 22px; }
.download-btn:hover { transform: translateY(-2px); filter: brightness(1.06); color: #fff; }
.download-btn:active { transform: none; }
[data-theme="dark"] .download-btn { color: #04251a; }
.file-missing {
  display: inline-block; padding: 12px 22px;
  background: var(--surface-2); color: var(--text-2);
  border-radius: 12px; font-weight: 600; font-size: 14px;
}
.share-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-top: 22px; font-size: 13.5px; color: var(--text-2);
}
.share {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  transition: .2s;
}
.share svg { width: 18px; height: 18px; }
.share:hover { color: #fff; transform: translateY(-2px); }
.share.whatsapp:hover { background: #25d366; }
.share.telegram:hover { background: #2aabee; }
.share.twitter:hover { background: #1a1a1a; }
.share.facebook:hover { background: #1877f2; }

.book-desc { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--border); }
.book-desc h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.prose { color: var(--text); font-size: 15.5px; }
.prose p { margin-bottom: 14px; }
.prose h2, .prose h3 { margin: 22px 0 10px; font-weight: 800; }
.prose ul, .prose ol { margin: 0 22px 14px 0; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose blockquote {
  border-inline-start: 3.5px solid var(--primary);
  background: var(--bg); padding: 12px 18px;
  border-radius: 8px; margin-bottom: 14px;
}

/* ---------- Page headers ---------- */
.page-head { padding: 34px 0 8px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; }
.page-sub { color: var(--text-2); margin: 6px 0 14px; max-width: 720px; font-size: 15px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 7px; flex-wrap: wrap;
  margin-top: 40px;
}
.page-btn {
  min-width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  padding-inline: 13px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text); font-weight: 700; font-size: 14px;
  transition: .2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .page-btn.current { color: #06251f; }
.page-dots { color: var(--text-2); }

/* ---------- Empty states & 404 ---------- */
.empty-state {
  text-align: center; padding: 70px 20px;
  color: var(--text-2); font-size: 16px;
}
.btn-link {
  display: inline-block; margin-top: 16px;
  background: var(--primary); color: #fff;
  padding: 10px 26px; border-radius: 11px; font-weight: 700;
}
.btn-link:hover { background: var(--primary-strong); color: #fff; }
[data-theme="dark"] .btn-link { color: #06251f; }
.not-found { text-align: center; padding: 60px 16px 30px; }
.nf-code {
  font-size: clamp(70px, 14vw, 120px); font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.not-found h1 { font-size: clamp(20px, 3vw, 27px); margin: 8px 0; }
.not-found p { color: var(--text-2); }
.not-found .hero-search { margin-inline: auto; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 30px;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 34px; padding: 44px 0 34px;
}
.footer-logo { font-size: 19px; margin-bottom: 10px; }
.footer-about p { color: var(--text-2); font-size: 14px; max-width: 340px; }
.footer-col h3 { font-size: 15.5px; font-weight: 800; margin-bottom: 14px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-col ul a { color: var(--text-2); font-size: 14px; }
.footer-col ul a:hover { color: var(--primary); }
.social-links { display: flex; gap: 9px; margin-top: 16px; }
.social-links a {
  width: 37px; height: 37px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  transition: .2s;
}
.social-links a:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.social-links svg { width: 17px; height: 17px; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 0; text-align: center;
  color: var(--text-2); font-size: 13.5px;
}
.footer-bottom a { font-weight: 700; }

/* ---------- Back-to-top button ---------- */
.back-top {
  position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 90;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: #fff;
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; translate: 0 8px;
  transition: .25s;
}
.back-top.show { opacity: 1; visibility: visible; translate: 0 0; }
.back-top svg { width: 20px; height: 20px; }
[data-theme="dark"] .back-top { color: #06251f; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  /* Two-row header: logo and buttons on top, full-width search below */
  .header-inner {
    flex-wrap: wrap; height: auto; min-height: var(--header-h);
    padding: 9px 0; gap: 10px 12px;
  }
  .logo { margin-inline-end: auto; }
  .header-search {
    order: 5; flex-basis: 100%; max-width: 100%; margin-inline-start: 0;
  }
  .main-nav {
    position: absolute; top: 100%; inset-inline: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 10px 16px 16px; gap: 2px;
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px 14px; font-size: 15.5px; }
  /* Buttons in the logo row (opposite the site name), full-width search below */
  .theme-toggle { order: 2; }
  .burger { display: flex; order: 3; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 26px; }
}
@media (max-width: 640px) {
  .header-search input { height: 44px; font-size: 14.5px; padding-inline: 42px 14px; }
  .header-search svg { inset-inline-start: 14px; width: 18px; height: 18px; }
  .live-results { inset-inline: 0; top: calc(100% + 6px); }
  .logo { font-size: 18px; }
  .logo-icon { width: 25px; height: 25px; }
  .books-grid, .books-grid.large { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 16px 12px; }
  .book-main { grid-template-columns: 1fr; }
  .book-cover { position: static; max-width: 230px; margin-inline: auto; }
  .cover-frame { position: static; max-width: 240px; margin-inline: auto; }
  .book-cover-col .dl-form, .book-cover-col .read-btn { display: none; } /* The fixed bottom bar is enough (includes the read button) */
  .book-info h1 { text-align: center; font-size: 21px; }
  .book-author-line { text-align: center; }
  .download-btn { width: 100%; }
  .hero { padding: 38px 0 32px; }
  .hero-search { flex-direction: column; }
  .hero-search button { justify-content: center; }
  .footer-grid { grid-template-columns: 1fr; gap: 22px; padding: 32px 0 26px; }
  .cats-grid, .cats-grid.full { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ---------- Fixed mobile download bar ---------- */
.mobile-dl-bar { display: none; }
@media (max-width: 640px) {
  .mobile-dl-bar {
    display: flex; gap: 10px; align-items: stretch;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 95;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .1);
  }
  .mobile-dl-bar form { flex: 1; margin: 0; }
  .mobile-dl-bar .download-btn { width: 100%; min-height: 52px; font-size: 16px; }
  .mdl-read { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; min-height: 52px; border: 1.5px solid var(--primary); border-radius: 12px; color: var(--primary-strong); background: var(--surface); text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
  .mdl-read svg { width: 20px; height: 20px; }
  .mobile-dl-bar:has(.mdl-read) .download-btn small { display: none; } /* Hide the size to save space when the read button is present */
  body:has(.mobile-dl-bar) { padding-bottom: 78px; }
  body:has(.mobile-dl-bar) .chat-widget { bottom: 84px; }
  body:has(.mobile-dl-bar) .install-btn { bottom: 84px; }
}

/* ---------- Member accounts: header links ---------- */
.nav-account { display: inline-flex; align-items: center; gap: 6px; }
.nav-account svg { width: 16px; height: 16px; }
.nav-cta {
  color: var(--primary-strong) !important; background: var(--primary-soft); font-weight: 700;
}
.nav-cta:hover { background: var(--primary); color: #fff !important; }
.nav-logout { margin: 0; display: inline-flex; }
.nav-logout button {
  color: var(--text-2); font: inherit; font-weight: 600; font-size: 15px;
  padding: 7px 13px; border-radius: 9px; background: none; cursor: pointer; transition: .18s;
}
.nav-logout button:hover { color: var(--primary); background: var(--primary-soft); }

/* ---------- "Add to My Library" button on the book page ---------- */
.fav-row { margin: 14px 0 4px; }
.fav-form { margin: 0; }
.fav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; min-height: 44px;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 14.5px; cursor: pointer; transition: .18s;
}
.fav-btn svg { width: 19px; height: 19px; color: var(--primary); }
.fav-btn:hover { border-color: var(--primary); color: var(--primary-strong); transform: translateY(-1px); }
.fav-btn.is-fav { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }
.fav-btn.is-fav svg { color: var(--primary-strong); }

/* ---------- Sign in / Sign up pages ---------- */
.auth-wrap { max-width: 460px; padding-top: 40px; padding-bottom: 52px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 34px 30px; box-shadow: var(--shadow-lg);
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head svg { width: 42px; height: 42px; color: var(--primary); }
.auth-head h1 { font-size: 24px; font-weight: 800; margin: 10px 0 6px; }
.auth-head p { color: var(--text-2); font-size: 14px; line-height: 1.7; }
.auth-alert {
  background: color-mix(in srgb, #ef4444 12%, transparent); color: #b91c1c;
  border: 1px solid color-mix(in srgb, #ef4444 30%, transparent);
  border-radius: 11px; padding: 11px 15px; font-size: 14px; font-weight: 600;
  margin-bottom: 18px; text-align: center;
}
[data-theme="dark"] .auth-alert { color: #fca5a5; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field span { font-weight: 700; font-size: 14px; }
.auth-field input {
  height: 48px; padding: 0 15px;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; transition: .18s;
}
.auth-field input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.auth-field small { color: var(--text-2); font-size: 12.5px; }
.auth-btn {
  margin-top: 6px; min-height: 50px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff; font-weight: 800; font-size: 16px; border-radius: 12px; cursor: pointer; transition: .18s;
}
.auth-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
[data-theme="dark"] .auth-btn { color: #04251a; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-2); }
.auth-alt a { font-weight: 700; }
.captcha-field .captcha-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.captcha-img { border: 1.5px solid var(--border); border-radius: 10px; background: #f5f7fa; display: block; }
.captcha-reload { flex-shrink: 0; width: 44px; height: 44px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); font-size: 19px; cursor: pointer; transition: .18s; }
.captcha-reload:hover { border-color: var(--primary); color: var(--primary-strong); }
.auth-closed { text-align: center; padding: 6px 0 2px; }
.auth-closed p { color: var(--text-2); margin-bottom: 18px; line-height: 1.8; }
.auth-closed .auth-btn { display: inline-block; padding: 13px 30px; text-decoration: none; }

/* ---------- My Library (personal shelf) ---------- */
.library-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.library-logout { margin: 0; }
.library-logout button {
  padding: 9px 16px; border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text-2); font: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: .18s;
}
.library-logout button:hover { border-color: var(--primary); color: var(--primary-strong); }

@media (max-width: 960px) {
  .nav-logout { width: 100%; }
  .nav-logout button { width: 100%; text-align: start; padding: 12px 14px; font-size: 15.5px; }
}
@media (max-width: 640px) {
  .fav-row { text-align: center; }
}

/* ---------- Forms: submit a book / request a book ---------- */
.submit-wrap { max-width: 640px; }
.submit-form { display: flex; flex-direction: column; gap: 15px; margin-top: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.auth-field textarea, .auth-field select {
  padding: 12px 15px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; width: 100%; transition: .18s;
}
.auth-field textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
.auth-field select { height: 48px; }
.auth-field textarea:focus, .auth-field select:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.auth-field input[type="file"] { padding: 11px; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2); font-size: 14px; width: 100%; cursor: pointer; }
.submit-hint { color: var(--text-2); font-size: 13px; margin: -4px 0 2px; }
.auth-btn.ghost { background: none; border: 1.5px solid var(--border); color: var(--text); }
.auth-btn.ghost:hover { border-color: var(--primary); color: var(--primary-strong); filter: none; }
.submit-done { text-align: center; padding: 32px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); }
.submit-done svg { width: 56px; height: 56px; color: var(--primary); }
.submit-done h2 { font-size: 22px; font-weight: 800; margin: 12px 0 8px; }
.submit-done p { color: var(--text-2); line-height: 1.8; }
.submit-done-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.btn-link.ghost { background: none; border: 1.5px solid var(--border); }
.hp-field { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Contact box ---------- */
.contact-box { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--border); }
.contact-box h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.contact-form { display: flex; flex-direction: column; gap: 15px; max-width: 620px; }
.contact-ok { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-strong); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: 11px; padding: 12px 15px; font-weight: 600; margin-bottom: 16px; }

/* ---------- Book comments & reviews ---------- */
.book-comments-sec { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--border); }
.book-comments-sec h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.comment-form textarea { padding: 12px 15px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; line-height: 1.7; resize: vertical; }
.comment-form textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.comment-form .auth-btn { align-self: flex-start; padding: 0 26px; min-height: 44px; }
.comment-login { color: var(--text-2); margin-bottom: 20px; }
.comments-list { display: flex; flex-direction: column; gap: 14px; }
.comment-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.comment-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.comment-head span { color: var(--text-2); font-size: 12.5px; }
.comment-item p { line-height: 1.9; color: var(--text); }
.comments-empty { color: var(--text-2); }

/* ---------- Report a broken link ---------- */
.report-line { margin-top: 16px; font-size: 13.5px; }
.report-line summary { color: var(--text-2); cursor: pointer; width: fit-content; }
.report-line summary:hover { color: var(--primary-strong); }
.report-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.report-form input { flex: 1; min-width: 180px; height: 40px; padding: 0 12px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; }
.report-form button { padding: 0 16px; height: 40px; border-radius: 10px; background: var(--surface-2); border: 1.5px solid var(--border); color: var(--text); font-weight: 700; cursor: pointer; }
.report-form button:hover { border-color: var(--primary); color: var(--primary-strong); }
.report-thanks { margin-top: 10px; color: var(--primary-strong); font-weight: 600; }

/* ---------- Email verification banner ---------- */
.verify-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fef3c7; border: 1px solid #f7d774; color: #92610a; border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-weight: 600; }
.verify-banner button { padding: 8px 14px; border-radius: 9px; border: 1.5px solid #d9a441; background: #fff; color: #92610a; font-weight: 700; cursor: pointer; }
[data-theme="dark"] .verify-banner { background: #3a2e10; color: #f5d488; border-color: #5a4718; }
[data-theme="dark"] .verify-banner button { background: #2a2109; color: #f5d488; border-color: #5a4718; }

@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Curated lists (smart collections) ---------- */
.collection-intro { max-width: 760px; margin-bottom: 26px; }
.collections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.collection-card { display: block; background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px; padding: 22px; transition: .18s; }
.collection-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.collection-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.collection-card p { color: var(--text-2); font-size: 14px; line-height: 1.7; margin-bottom: 12px; }
.collection-count { color: var(--primary-strong); font-weight: 700; font-size: 13.5px; }

/* ---------- Reader-submitted quote ---------- */
.quotes-empty-hint { color: var(--text-2); margin-bottom: 14px; }
.quote-add-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; max-width: 620px; }
.quote-add-form textarea { padding: 12px 15px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; line-height: 1.8; resize: vertical; }
.quote-add-form textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.quote-add-form .auth-btn { align-self: flex-start; padding: 0 24px; min-height: 42px; }
.quote-add-login { color: var(--text-2); margin-top: 16px; }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .back-top, .share-row, .download-btn { display: none !important; }
}

/* ============================================================
   Extras — book ideas, FAQ, smart search, chat
   ============================================================ */

/* ---------- Cover frame and download button ---------- */
.cover-frame {
  position: relative;
  border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--surface-2);
}
.book-cover-col .book-cover { position: static; width: 100%; box-shadow: none; border-radius: 0; }
.dl-form { margin-top: 16px; }
.dl-form .download-btn { width: 100%; }
.dl-note {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 10px; color: var(--text-2); font-size: 12.5px;
}
.dl-note svg { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Book key ideas ---------- */
.key-ideas {
  margin: 22px 0 4px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.key-ideas h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800; margin-bottom: 12px;
}
.key-ideas h2 svg { width: 20px; height: 20px; color: var(--primary); }
.key-ideas ul { list-style: none; display: grid; gap: 9px; }
.key-ideas li {
  position: relative; padding-inline-start: 26px;
  font-size: 14.5px; line-height: 1.7;
}
.key-ideas li::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 9px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); opacity: .18;
}
.key-ideas li::after {
  content: ''; position: absolute; inset-inline-start: 4px; top: 13px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}

/* ---------- FAQ (accordion) ---------- */
.book-faq { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--border); }
.book-faq h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  transition: border-color .2s;
}
.faq-item[open] { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; cursor: pointer;
  font-weight: 700; font-size: 15px; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: var(--primary); }
.faq-item summary svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform .25s; color: var(--text-2); }
.faq-item[open] summary svg { transform: rotate(180deg); color: var(--primary); }
.faq-answer {
  padding: 0 18px 16px; color: var(--text-2);
  font-size: 14.5px; line-height: 1.8;
}

/* ---------- Smart search in the hero ---------- */
.ai-search { margin-top: 20px; }
.ai-search-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary-strong);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 30px; padding: 9px 18px;
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: .2s;
}
.ai-search-toggle:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.ai-search-toggle svg { width: 18px; height: 18px; }
.ai-search-box {
  max-width: 620px; margin: 14px auto 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
}
.ai-search-box form { display: flex; gap: 8px; }
.ai-search-box input {
  flex: 1; height: 46px; padding-inline: 16px;
  border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14.5px;
}
.ai-search-box input:focus { outline: none; border-color: var(--primary); }
.ai-search-box > form > button {
  height: 46px; padding-inline: 20px; border: 0; border-radius: 11px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.ai-search-results { margin-top: 4px; }
.ai-search-results .ai-intro {
  padding: 12px 4px 8px; color: var(--text-2); font-size: 14px; text-align: start;
}
.ai-search-results .ai-hit {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 11px; color: var(--text);
  border: 1px solid transparent; text-align: start;
}
.ai-search-results .ai-hit:hover { background: var(--bg); border-color: var(--border); }
.ai-search-results .ai-hit img { width: 42px; height: 62px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.ai-search-results .ai-hit .h-title { font-weight: 700; font-size: 14.5px; }
.ai-search-results .ai-hit .h-author { font-size: 12.5px; color: var(--text-2); }
.ai-loading { text-align: center; padding: 18px; color: var(--text-2); font-size: 14px; }
.ai-spin {
  display: inline-block; width: 18px; height: 18px; vertical-align: middle; margin-inline-end: 8px;
  border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: aispin .7s linear infinite;
}
@keyframes aispin { to { transform: rotate(360deg); } }

/* ---------- Floating chat assistant ---------- */
.chat-widget { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 120; }
.chat-fab {
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-strong));
  color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow-lg);
  transition: transform .2s;
}
[data-theme="dark"] .chat-fab { color: #04251a; }
.chat-fab:hover { transform: scale(1.06); }
.chat-fab svg { width: 26px; height: 26px; position: absolute; transition: opacity .2s, transform .2s; }
.chat-fab .ic-close { opacity: 0; transform: rotate(-90deg); }
.chat-widget.open .chat-fab .ic-open { opacity: 0; transform: rotate(90deg); }
.chat-widget.open .chat-fab .ic-close { opacity: 1; transform: rotate(0); }
.chat-panel {
  position: absolute; bottom: 72px; inset-inline-end: 0;
  width: min(360px, calc(100vw - 44px)); height: 500px; max-height: calc(100vh - 120px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: chatIn .22s ease;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(12px); } }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
}
[data-theme="dark"] .chat-head { color: #eafffb; }
.chat-head-title { display: flex; align-items: center; gap: 10px; }
.chat-head-title strong { display: block; font-size: 14.5px; }
.chat-head-title small { font-size: 11.5px; opacity: .85; }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px #4ade8040; }
.chat-min { background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; opacity: .9; }
.chat-min svg { width: 20px; height: 20px; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.chat-msg {
  max-width: 84%; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.7; white-space: normal;
}
.chat-msg.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-right-radius: 4px; }
.chat-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
[data-theme="dark"] .chat-msg.user { color: #04251a; }
.chat-msg a { color: var(--primary-strong); font-weight: 700; text-decoration: underline; }
.chat-msg.user a { color: #fff; }
.chat-msg.typing { color: var(--text-2); font-style: italic; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input input {
  flex: 1; height: 42px; padding-inline: 14px;
  border: 1.5px solid var(--border); border-radius: 21px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.chat-input input:focus { outline: none; border-color: var(--primary); }
.chat-input button {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center;
}
[data-theme="dark"] .chat-input button { color: #04251a; }
.chat-input button svg { width: 20px; height: 20px; }
.chat-input button:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 640px) {
  .chat-widget { bottom: 16px; inset-inline-end: 16px; }
  .back-top { bottom: 16px; inset-inline-start: 16px; }
  .chat-panel { bottom: 68px; }
}

/* ---------- Community feed: post cards ---------- */
.fkra-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.fkra-grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.fkra-post {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
  transition: border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 11px;
}
.fkra-post:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.fkra-head { display: flex; align-items: center; gap: 10px; }
.fkra-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.fkra-avatar.ph {
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-strong);
  font-weight: 800; font-size: 17px;
}
.fkra-meta { min-width: 0; display: flex; flex-direction: column; }
.fkra-name {
  font-weight: 700; font-size: 14.5px; color: var(--text);
  display: inline-flex; align-items: center; gap: 4px;
}
.fkra-verified { width: 15px; height: 15px; color: var(--primary); }
.fkra-user { font-size: 12px; color: var(--text-2); }
.fkra-body {
  color: var(--text); font-size: 14.5px; line-height: 1.75;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.fkra-body:hover { color: var(--text); }
.fkra-img { display: block; border-radius: 10px; overflow: hidden; }
.fkra-img img { width: 100%; max-height: 220px; object-fit: cover; }
.share.fkra:hover { background: var(--primary); color: #fff; }
.ai-intro-line { background: var(--primary-soft); color: var(--primary-strong); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; margin-bottom: 20px; }
.hero-search.inline.ai > button { background: linear-gradient(135deg,#7c3aed,#4f46e5); color:#fff; }

/* ---------- PWA install button (in the back-to-top spot) ---------- */
.install-btn {
  position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 90;
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 24px;
  background: var(--primary); color: #fff; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: instIn .3s ease;
}
[data-theme="dark"] .install-btn { color: #04251a; }
.install-btn:hover { background: var(--primary-strong); }
.install-btn svg { width: 20px; height: 20px; }
@keyframes instIn { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 640px) { .install-btn span { display: none; } .install-btn { padding: 0; width: 46px; justify-content: center; } }

/* ---------- Full assistant page ---------- */
.lib-page { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.lib-thread { padding: 18px; display: flex; flex-direction: column; gap: 11px; min-height: 300px; max-height: 60vh; overflow-y: auto; background: var(--bg); }
.lib-thread .chat-msg { max-width: 82%; padding: 11px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.75; }
.lib-thread .chat-msg.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-right-radius: 4px; }
.lib-thread .chat-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
[data-theme="dark"] .lib-thread .chat-msg.user { color: #04251a; }
.lib-thread .chat-msg a { color: var(--primary-strong); font-weight: 700; text-decoration: underline; }
.lib-thread .chat-msg.user a { color: #fff; }
.lib-form { display: flex; gap: 9px; padding: 14px; border-top: 1px solid var(--border); background: var(--surface); }
.lib-form input { flex: 1; height: 46px; padding-inline: 16px; border: 1.5px solid var(--border); border-radius: 23px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
.lib-form input:focus { outline: none; border-color: var(--primary); }
.lib-form button { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; background: var(--primary); color: #fff; border: 0; cursor: pointer; display: grid; place-items: center; }
[data-theme="dark"] .lib-form button { color: #04251a; }
.lib-form button svg { width: 20px; height: 20px; }

/* ---------- Embedded assistant window ---------- */
.chat-frame { flex: 1; width: 100%; border: 0; background: var(--bg); display: block; }
.chat-full { margin-inline-start: auto; background: none; border: 0; color: #fff; cursor: pointer; padding: 5px; opacity: .9; display: grid; place-items: center; text-decoration: none; }
.chat-full:hover { opacity: 1; color: #fff; }
.chat-full svg { width: 18px; height: 18px; }
[data-theme="dark"] .chat-head .chat-full { color: #eafffb; }

/* ---------- Star rating ---------- */
.book-rating { margin: 6px 0 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.rating-summary { display: inline-flex; align-items: center; gap: 8px; }
.rating-num { font-size: 22px; font-weight: 800; color: var(--text); }
.stars-static { position: relative; display: inline-block; direction: ltr; color: var(--border); font-size: 20px; line-height: 1; letter-spacing: 2px; }
.stars-static::before { content: "★★★★★"; position: absolute; top: 0; left: 0; width: var(--pct, 0%); overflow: hidden; white-space: nowrap; color: #f59e0b; letter-spacing: 2px; }
.rating-count { font-size: 13px; color: var(--text-2); }
.rating-form { display: inline-flex; align-items: center; gap: 8px; }
.rate-label { font-size: 14px; color: var(--text-2); }
.star-input { display: inline-flex; direction: ltr; flex-direction: row-reverse; justify-content: flex-end; }
.star-btn { background: none; border: 0; cursor: pointer; padding: 0 2px; font-size: 26px; line-height: 1; color: var(--border); transition: color .12s, transform .12s; }
.star-input .star-btn:hover, .star-input .star-btn:hover ~ .star-btn { color: #f59e0b; }
.star-btn:hover { transform: scale(1.12); }
.rating-thanks { margin: 6px 0 14px; font-size: 15px; font-weight: 700; color: var(--primary-strong); }

/* ---------- Authors page: search + alphabetical index ---------- */
.authors-search { display: flex; max-width: 420px; margin: 0 0 16px; position: relative; }
.authors-search input { flex: 1; height: 46px; padding-inline: 16px 46px; border: 1.5px solid var(--border); border-radius: 24px; background: var(--surface); color: var(--text); font: inherit; }
.authors-search input:focus { outline: none; border-color: var(--primary); }
.authors-search button { position: absolute; inset-inline-end: 5px; top: 5px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--primary); color: #fff; cursor: pointer; display: grid; place-items: center; }
.authors-search button svg { width: 18px; height: 18px; }
.alpha-index { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.alpha-index a { min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2); font-size: 15px; font-weight: 600; text-decoration: none; transition: all .15s; }
.alpha-index a:hover { border-color: var(--primary); color: var(--primary-strong); }
.alpha-index a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .alpha-index a.active { color: #04251a; }

/* ---------- Quotes ---------- */
.book-quotes { margin-top: 26px; }
.quotes-list { display: grid; gap: 14px; }
.quote-card { position: relative; margin: 0; padding: 18px 20px 18px 20px; background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); border-radius: 12px; }
.quote-card p { margin: 0; font-size: 16px; line-height: 1.95; color: var(--text); font-weight: 500; }
.quote-card .q-mark { position: absolute; inset-block-start: 12px; inset-inline-end: 14px; width: 26px; height: 26px; color: var(--primary); opacity: .18; }
.quotes-hub { display: grid; gap: 22px; }
.quotes-book { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.qb-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.qb-cover img { width: 60px; height: 90px; object-fit: cover; border-radius: 8px; box-shadow: var(--shadow); }
.qb-meta h2 { margin: 0 0 4px; font-size: 18px; }
.qb-meta h2 a { color: var(--text); text-decoration: none; }
.qb-meta h2 a:hover { color: var(--primary-strong); }
.qb-author { margin: 0 0 6px; font-size: 13.5px; color: var(--text-2); }
.qb-dl { font-size: 13.5px; font-weight: 700; color: var(--primary-strong); text-decoration: none; }
.quotes-book .quotes-list { gap: 10px; }
.quotes-book .quote-card { padding: 12px 15px; background: var(--bg); }
.quotes-book .quote-card p { font-size: 15px; }

/* ---------- Series ---------- */
.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.series-card { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.series-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.series-icon { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: rgba(13,148,136,.12); color: var(--primary-strong); }
.series-icon svg { width: 24px; height: 24px; }
.series-card .series-name { font-weight: 700; font-size: 16px; display: block; }
.series-card .series-count { font-size: 13px; color: var(--text-2); }
.series-badge { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 14px; padding: 8px 14px; background: rgba(13,148,136,.10); border: 1px solid var(--border); border-radius: 10px; font-size: 14.5px; color: var(--text-2); }
.series-badge svg { width: 18px; height: 18px; color: var(--primary-strong); flex-shrink: 0; }
.series-badge a { color: var(--primary-strong); font-weight: 700; text-decoration: none; }
.series-badge a:hover { text-decoration: underline; }
.series-part { color: var(--text-2); font-weight: 600; }

/* ---------- Read-online button ---------- */
.read-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--primary); color: var(--primary-strong); font-weight: 700; font-size: 15px; text-decoration: none; transition: background .15s; }
.read-btn:hover { background: rgba(13,148,136,.08); }
.read-btn svg { width: 20px; height: 20px; }

/* ---------- Advanced filters (all-books page) ---------- */
.book-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 22px; }
.book-filters select {
  height: 42px; padding: 0 34px 0 14px; border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6b7f' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.book-filters select:focus { outline: none; border-color: var(--primary); }
.surprise-btn {
  height: 42px; display: inline-flex; align-items: center; gap: 6px; padding: 0 16px;
  border: 1.5px solid var(--primary); border-radius: 11px; color: var(--primary-strong);
  background: var(--primary-soft); font-weight: 700; font-size: 14px; text-decoration: none; transition: .18s;
}
.surprise-btn:hover { background: var(--primary); color: #fff; }
[data-theme="dark"] .surprise-btn:hover { color: #04251a; }
.filters-clear { color: var(--text-2); font-size: 13.5px; font-weight: 600; margin-inline-start: 2px; }
.filters-clear:hover { color: var(--primary); }

/* ---------- Book of the Day ---------- */
.botd {
  display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; color: var(--text);
}
.botd:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: var(--text); }
.botd-cover img { width: 150px; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); }
.botd-info h3 { font-size: 20px; font-weight: 800; line-height: 1.4; }
.botd-author { color: var(--text-2); font-size: 14.5px; margin-top: 3px; }
.botd-desc { color: var(--text-2); font-size: 14.5px; line-height: 1.75; margin-top: 10px; }
.botd-cta { display: inline-block; margin-top: 12px; color: var(--primary-strong); font-weight: 700; font-size: 14.5px; }
@media (max-width: 560px) {
  .botd { grid-template-columns: 100px 1fr; gap: 16px; padding: 16px; }
  .botd-cover img { width: 100px; }
  .botd-info h3 { font-size: 17px; }
  .botd-desc { display: none; }
}
.epub-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--border); color: var(--text); font-weight: 700; font-size: 15px; text-decoration: none; transition: border-color .15s, background .15s, color .15s; }
.epub-btn:hover { border-color: var(--primary); color: var(--primary-strong); background: rgba(13,148,136,.06); }
.epub-btn svg { width: 20px; height: 20px; }
.epub-btn small { font-weight: 600; opacity: .8; font-size: 12.5px; }
.buy-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; background: #f59e0b; border: 1.5px solid #f59e0b; color: #3a2a06; font-weight: 800; font-size: 15px; text-decoration: none; transition: filter .15s, transform .15s; }
.buy-btn:hover { filter: brightness(1.06); transform: translateY(-1px); color: #3a2a06; }
.buy-btn svg { width: 20px; height: 20px; }
.ad-zone { margin: 16px 0; text-align: center; overflow: hidden; }
.ad-zone img { display: inline-block; }
.ad-in-content { margin: 26px 0; padding-top: 20px; border-top: 1px solid var(--border); }
.ad-footer-banner { padding: 18px 0; background: var(--surface); border-top: 1px solid var(--border); }

/* ---------- Memberships & donations ---------- */
.member-status { background: var(--primary-soft); color: var(--primary-strong); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: 14px; padding: 14px 18px; font-size: 15px; line-height: 1.7; margin-bottom: 20px; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.plan-card { position: relative; background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; padding: 26px 22px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.plan-card.featured { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.plan-badge { position: absolute; top: -12px; inset-inline-start: 22px; background: linear-gradient(135deg, var(--primary), var(--accent-strong)); color: #fff; font-size: 12px; font-weight: 800; padding: 4px 12px; border-radius: 20px; }
[data-theme="dark"] .plan-badge { color: #04251a; }
.plan-name { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.plan-price { font-size: 34px; font-weight: 800; color: var(--text); margin-bottom: 16px; }
.plan-price span { font-size: 15px; font-weight: 600; color: var(--text-2); }
.plan-perks { list-style: none; display: flex; flex-direction: column; gap: 9px; margin-bottom: 20px; flex: 1; }
.plan-perks li { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; line-height: 1.5; }
.plan-perks svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.plan-sub summary { cursor: pointer; }
.plan-sub[open] summary { margin-bottom: 12px; }
.plan-sub-body .hint { font-size: 13px; color: var(--text-2); line-height: 1.7; margin-bottom: 10px; }
.auth-btn.ghost { background: none; border: 1.5px solid var(--border); color: var(--text); }
.auth-btn.ghost:hover { border-color: var(--primary); color: var(--primary-strong); filter: none; }
.members-lock { text-align: center; background: var(--bg); border: 1.5px dashed var(--border); border-radius: 14px; padding: 22px 18px; margin-top: 4px; }
.members-lock svg { width: 34px; height: 34px; color: var(--primary); }
.members-lock strong { display: block; font-size: 16px; margin: 8px 0 4px; }
.members-lock p { color: var(--text-2); font-size: 14px; line-height: 1.6; margin-bottom: 14px; }
.donate-form { max-width: 560px; }
.donate-amounts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.donate-amt { position: relative; }
.donate-amt input[type=radio] { position: absolute; opacity: 0; }
.donate-amt > span { display: inline-flex; align-items: center; gap: 6px; padding: 12px 18px; border: 1.5px solid var(--border); border-radius: 12px; font-weight: 700; cursor: pointer; transition: .15s; background: var(--surface); }
.donate-amt input[type=radio]:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.donate-amt.custom span input { width: 90px; border: 0; border-bottom: 1.5px solid var(--border); background: none; font: inherit; padding: 2px 4px; color: var(--text); }
.donate-amt.custom span input:focus { outline: none; border-color: var(--primary); }

/* ---------- Send to Kindle ---------- */
.kindle-box { margin-top: 10px; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.kindle-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; cursor: pointer; font-weight: 700; font-size: 14px; color: var(--text); list-style: none; }
.kindle-toggle::-webkit-details-marker { display: none; }
.kindle-toggle svg { width: 18px; height: 18px; color: var(--primary); }
.kindle-toggle:hover { color: var(--primary); }
.kindle-form { display: flex; gap: 8px; padding: 0 12px 10px; }
.kindle-form input { flex: 1; height: 40px; padding: 0 12px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; }
.kindle-form input:focus { outline: none; border-color: var(--primary); }
.kindle-form button { padding: 0 16px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; border: 0; font-weight: 700; cursor: pointer; }
[data-theme="dark"] .kindle-form button { color: #04251a; }
.kindle-hint { padding: 0 12px 12px; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.kindle-msg { padding: 6px 12px 0; font-size: 13px; font-weight: 600; }
.kindle-msg.ok { color: var(--accent-strong, #047857); }
.kindle-msg.err { color: #b91c1c; }

/* ============ Cover watermark (CSS fallback when GD baking is unavailable) ============ */
.cover-wm {
  position: absolute; inset-inline: 0; bottom: 0;
  text-align: center; direction: ltr;
  font-family: system-ui, Arial, sans-serif; font-weight: 800;
  letter-spacing: .6px; color: #fff; white-space: nowrap;
  background: rgba(13, 148, 136, .92);
  padding: 4px 6px; pointer-events: none; user-select: none;
}
.card-cover .cover-wm { font-size: 9px; padding: 2px 4px; letter-spacing: .3px; }
.cover-frame .cover-wm { font-size: 15px; }

/* ============ Uploaded site logo + branding preview in admin ============ */
.logo-img { max-height: 40px; width: auto; display: block; }
.brand-preview { display: inline-flex; align-items: center; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; }

/* ============ Publish-with-us page + invite band ============ */
.publish-block { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin-bottom: 18px; }
.publish-block h2 { margin: 0 0 8px; font-size: 20px; }
.publish-block p { color: var(--text-2); line-height: 1.9; margin: 0 0 16px; }
.publish-why { margin: 26px 0; }
.publish-features { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.publish-features li { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.publish-features strong { font-size: 15px; }
.publish-features span { color: var(--text-2); font-size: 13.5px; }
.publish-rights { background: linear-gradient(135deg, rgba(13,148,136,.06), rgba(15,118,110,.04)); border: 1px solid var(--border); border-radius: 16px; padding: 20px 24px; }
.publish-rights h2 { font-size: 18px; margin: 0 0 8px; }
.publish-rights p { color: var(--text-2); line-height: 1.9; margin: 0; }
.btn-link.ghost { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.publish-cta { border-top: 1px solid var(--border); background: var(--surface-2); }
.publish-cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 0; flex-wrap: wrap; }
.publish-cta strong { display: block; font-size: 17px; margin-bottom: 3px; }
.publish-cta span { color: var(--text-2); font-size: 14px; }
@media (max-width: 640px) { .publish-features { grid-template-columns: 1fr; } .publish-cta-inner { flex-direction: column; align-items: flex-start; } }

/* ============ Topic/tag chips ============ */
.book-tags { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.book-tags-label { color: var(--text-2); font-size: 13.5px; font-weight: 700; }
.tag-chip { display: inline-block; padding: 5px 13px; border-radius: 20px; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600; text-decoration: none; transition: .15s; }
.tag-chip:hover { background: var(--primary); color: #fff; }
[data-theme="dark"] .tag-chip:hover { color: #04251a; }
