/* ================= بانک کتاب ================= */
.justify, .prose p, .rd-text p { text-align: justify; font-kerning: none; }
.kicker { color: var(--brand); font-weight: 700; margin: 24px 0 -4px; font-size: .9rem; }
.books-hero .hero-lead { max-width: 44em; opacity: .9; text-align: justify; font-kerning: none; }

/* book grid */
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
.bcard { display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none !important; }
.bcover { position: relative; display: block; aspect-ratio: 2 / 3; background: var(--brand-soft); border-radius: 6px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 18px rgba(16,32,43,.10); transition: transform .15s ease, box-shadow .15s ease; }
.bcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bcard:hover .bcover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 12px 26px rgba(16,32,43,.16); }
.bbadge { position: absolute; top: 8px; inset-inline-start: 8px; background: var(--ok); color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.bbody { display: flex; flex-direction: column; gap: 2px; }
.btitle { font-weight: 700; color: var(--ink); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bmeta { font-size: .82rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: .25em .9em; color: var(--text); font-size: .9rem; cursor: pointer; }
.chip small { color: var(--muted); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on small { color: rgba(255,255,255,.8); }
.small-chips .chip { font-size: .8rem; }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.catcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.catcard:hover { border-color: var(--brand); text-decoration: none; }
.catcard small { color: var(--muted); }
.catcard span { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.alphabet { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 20px; }
.alphabet a { min-width: 30px; text-align: center; padding: .15em .4em; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.alphabet a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager { display: flex; gap: 6px; justify-content: center; margin: 26px 0; flex-wrap: wrap; }
.pager a { padding: .3em .8em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* book page */
.book-head { display: grid; grid-template-columns: 220px 1fr; gap: 32px; margin: 18px 0 8px; align-items: start; }
.book-cover img { width: 100%; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 14px 30px rgba(16,32,43,.18); display: block; background: var(--brand-soft); }
.book-info h1 { font-size: 1.6rem; margin-bottom: .15em; }
.book-sub { font-size: 1.05rem; color: var(--muted); margin: 0 0 .4em; }
.book-kv { margin: 14px 0; }
.ltr-inline { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.book-cta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 8px; }
.book-cta .notice { margin: 0; }
.read-progress { display: grid; gap: 4px; max-width: 360px; margin-top: 10px; }
.book-body { display: grid; grid-template-columns: 1fr 320px; gap: 32px; align-items: start; }
.book-side { display: grid; gap: 14px; position: sticky; top: 130px; }
.book-side .panel-title { margin: 0 0 8px; padding: 0; border: 0; }
.cite { font-size: .9rem; line-height: 1.9; background: var(--soft); padding: 10px 12px; border-radius: 8px; }
.toc { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.toc li { display: flex; align-items: baseline; gap: 12px; padding: .5em 1em; border-bottom: 1px solid var(--line); }
.toc li:last-child { border-bottom: 0; }
.toc li a { flex: 1; color: var(--text); }
.toc li a:hover span:first-child { color: var(--brand); }
.toc li.lv1 a { font-weight: 700; }
.toc li.lv2 { padding-inline-start: 2.2em; font-size: .94rem; }
.toc li.lv3, .toc li.lv4 { padding-inline-start: 3.4em; font-size: .9rem; }
.toc-page { color: var(--muted); font-size: .88rem; min-width: 2.5em; text-align: left; }
.book-search-results { margin-top: 10px; display: grid; gap: 6px; }
.hit { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: .92rem; line-height: 1.9; }
.hit:hover { border-color: var(--brand); text-decoration: none; }
.hit b { color: var(--brand); white-space: nowrap; }
mark { background: #fff1b8; color: inherit; padding: 0 2px; border-radius: 3px; }
.hitgroup { padding: 12px; margin-bottom: 14px; display: grid; gap: 6px; }
.hitbook { display: flex; gap: 12px; align-items: center; color: var(--ink); margin-bottom: 4px; }
.hitbook img { width: 44px; border-radius: 4px; }
.hitbook span { display: flex; flex-direction: column; }

/* my library */
.reading-list { display: grid; gap: 10px; }
.reading-row { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: var(--text); }
.reading-row:hover { border-color: var(--brand); text-decoration: none; }
.reading-row img { width: 54px; border-radius: 4px; }
.reading-row .grow { display: flex; flex-direction: column; gap: 4px; }
.q-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 12px; align-items: center; }
.meter.wide { height: 10px; }

/* admin */
.thumb-sm { width: 38px; border-radius: 3px; display: block; }
.cover-preview { width: 120px; border-radius: 6px; box-shadow: var(--shadow); }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); transition: width .4s; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
pre.mono { background: var(--soft); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre; }
.daybars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 10px; }
.daybars span { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.daybars i { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 10px; }

/* ================= reader ================= */
.reader-body { background: #e9ecea; }
.reader { --rd-bar: 56px; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.rd-bar { height: var(--rd-bar); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--stage); color: var(--stage-text); }
.rd-back { color: var(--stage-text); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; }
.rd-back:hover { background: rgba(255,255,255,.1); }
.rd-title { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.rd-title b, .rd-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-title small { opacity: .75; font-size: .78rem; }
.rd-nav { display: flex; align-items: center; gap: 4px; }
.rd-go { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.rd-go input { width: 58px; text-align: center; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; padding: .25em .3em; font: inherit; }
.rd-tools { display: flex; align-items: center; gap: 2px; }
.rd-btn { background: transparent; border: 0; color: var(--stage-text); width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.rd-btn:hover, .rd-btn.on { background: rgba(255,255,255,.12); }
.rd-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.rd-quota { font-size: .75rem; background: rgba(255,255,255,.1); border-radius: 99px; padding: 2px 10px; white-space: nowrap; margin-inline-start: 6px; }
.rd-quota.warn { background: var(--warn); color: #fff; }
.rd-main { flex: 1; min-height: 0; display: flex; }
.rd-stage { flex: 1; overflow: auto; padding: 18px 12px 24px; outline: none; }
.rd-page { position: relative; margin: 0 auto; width: calc(min(100%, 900px) * var(--rd-zoom, 1)); max-width: none; min-height: 60vh; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.10); }
.rd-page img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rd-label { text-align: center; color: var(--muted); font-size: .85rem; margin: 10px 0 0; }
.rd-spin { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.rd-spin::after { content: ''; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: rdspin .8s linear infinite; }
@keyframes rdspin { to { transform: rotate(360deg); } }
.rd-block { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 30px; text-align: center; background: linear-gradient(180deg, #fff 0%, #f3f6f4 100%); }
.rd-block p { max-width: 30em; font-size: 1.02rem; color: var(--ink); }
.rd-panel { width: 360px; flex: none; background: var(--surface); border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.rd-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rd-panel-body { padding: 12px 14px; overflow: auto; flex: 1; }
.rd-toc li { padding: .4em .6em; }
.rd-toc a.on span:first-child { color: var(--brand); }
.rd-results { display: grid; gap: 6px; margin-top: 10px; }
.rd-results a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: .88rem; line-height: 1.85; }
.rd-results a.on, .rd-results a:hover { border-color: var(--brand); text-decoration: none; }
.rd-results b { color: var(--brand); }
.rd-text { font-size: 1rem; line-height: 2.1; }
@media (max-width: 900px) {
  .rd-panel { position: fixed; inset: var(--rd-bar) 0 0 0; width: auto; z-index: 30; border: 0; }
  .rd-title small { display: none; }
}
@media (max-width: 640px) {
  .reader { --rd-bar: 96px; }
  .rd-bar { flex-wrap: wrap; height: auto; min-height: var(--rd-bar); padding: 6px 8px; row-gap: 4px; }
  .rd-title { flex-basis: calc(100% - 48px); }
  .rd-nav { order: 3; }
  .rd-tools { order: 4; margin-inline-start: auto; }
  .rd-quota { display: none; }
  .rd-stage { padding: 8px 0 16px; }
  .rd-page { width: calc(100% * var(--rd-zoom, 1)); box-shadow: none; }
  .book-head { grid-template-columns: 110px 1fr; gap: 16px; }
  .book-info h1 { font-size: 1.25rem; }
  .book-body { grid-template-columns: 1fr; }
  .book-side { position: static; }
  .bgrid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 18px 12px; }
  .two-col { grid-template-columns: 1fr; }
  .hit { grid-template-columns: 1fr; gap: 0; }
  .q-row { grid-template-columns: 60px 1fr; }
  .q-row b { grid-column: 1 / -1; font-size: .85rem; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .book-body { grid-template-columns: 1fr; }
  .book-side { position: static; }
}
.searchrow { display: flex; gap: 8px; margin: 8px 0; align-items: center; }
.searchrow input { flex: 1; min-width: 0; }
.rd-panel[hidden], .rd-panel-body[hidden], .rd-block[hidden], .rd-spin[hidden], .rd-quota[hidden] { display: none !important; }
#rdPage { width: 64px; text-align: center; padding: .25em .3em; border-radius: 6px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; }
#rdPage:focus { border-color: #fff; box-shadow: none; }
.rd-go span { white-space: nowrap; }
@media (max-width: 640px) {
  #rdZoomIn, #rdZoomOut { display: none; }
  .rd-btn { width: 34px; height: 34px; }
  .rd-nav { gap: 2px; }
}

/* ================= APA-style browse & record ================= */
.browse { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: start; margin-top: 8px; }
.browse-side { display: grid; gap: 14px; position: sticky; top: 130px; }
.bs-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.bs-box h3 { margin: 0; background: var(--brand); color: #fff; font-size: .95rem; padding: .55em .9em; }
.bs-box a { padding: .4em .9em; color: var(--text); font-size: .9rem; border-bottom: 1px solid var(--line); }
.bs-box a:last-child { border-bottom: 0; }
.bs-box a.on { background: var(--brand-soft); font-weight: 700; color: var(--brand-dark); }
.bs-box label.check { padding: .35em .9em; font-size: .9rem; }
.browse-title { font-size: 1.3rem; margin: 0; }
.browse-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 12px 0; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.az { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.az a { min-width: 24px; text-align: center; padding: 0 .3em; border-radius: 4px; font-size: .88rem; color: var(--brand); }
.az a.on { background: var(--brand); color: #fff; }
.az-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.browse-tools { display: flex; gap: 6px; align-items: center; }
.browse-tools select { width: auto; padding: .3em .5em; }
.browse-tools input { width: 190px; padding: .35em .7em; }
.browse-count { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; }
.pager-sm { display: flex; gap: 4px; }
.pager-sm a { min-width: 28px; text-align: center; padding: .1em .45em; border-radius: 4px; color: var(--brand); }
.pager-sm a.on { background: var(--brand); color: #fff; }
.blist { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.brow { display: flex; gap: 16px; padding: 14px; border-bottom: 1px dashed var(--line); }
.brow:last-child { border-bottom: 0; }
.brow-cover { flex: none; width: 70px; height: 104px; display: block; }
.brow-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.noimg { display: grid; place-items: center; width: 100%; height: 100%; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; padding: 6px; border-radius: 3px; line-height: 1.6; }
.brow-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.brow-title { font-size: 1.08rem; font-weight: 700; color: var(--brand-dark); line-height: 1.6; }
.brow-meta { font-size: .88rem; color: var(--muted); }
.brow-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.tag-btn { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: .1em .6em; font-size: .8rem; color: var(--brand-dark); cursor: pointer; }
.tag-btn:hover { border-color: var(--brand); text-decoration: none; }
.glist { columns: 2; column-gap: 28px; list-style: none; padding: 12px 16px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.glist li { break-inside: avoid; padding: .3em 0; border-bottom: 1px dashed var(--line); }

.rec { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; margin: 12px 0 30px; }
.rec-title { font-size: 1.55rem; color: var(--brand-dark); margin: 4px 0 8px; line-height: 1.6; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 8px 0 12px; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.rec-actions a, .rec-actions .linkbtn { font-weight: 600; }
.rec-db { color: var(--muted); font-size: .85rem; margin-inline-start: auto; }
.rec-people { margin: 12px 0; line-height: 2; }
.rec-people a { text-decoration: underline; text-underline-offset: 3px; }
.rec-sec { margin: 18px 0; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.rec-sec h2 { font-size: 1.1rem; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.rec-cite { line-height: 2; margin: 0 0 8px; }
.rec-full { margin: 18px 0; }
.rec-full > summary { font-size: 1.1rem; font-weight: 700; color: var(--brand); cursor: pointer; padding: 6px 0; }
.rec-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .92rem; }
.rec-table tr:nth-child(odd) { background: var(--soft); }
.rec-table th { width: 170px; text-align: right; vertical-align: top; padding: 12px 14px; font-weight: 700; color: var(--ink); }
.rec-table td { padding: 12px 14px; line-height: 1.95; }
.rec-toc { list-style: none; padding: 0; margin: 0; }
.rec-toc li { padding: 2px 0; }
.rec-toc li.lv2 { padding-inline-start: 1.4em; }
.rec-toc li.lv3, .rec-toc li.lv4 { padding-inline-start: 2.6em; }
.rec-side { display: grid; gap: 14px; }
.rec-cover { max-width: 190px; margin: 0 auto; aspect-ratio: 2/3; width: 100%; }
.rec-cover img { width: 100%; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 12px 28px rgba(16,32,43,.16); }
.rec-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.rec-box h3 { font-size: 1rem; margin: 0 0 8px; color: var(--ink); }
.rec-cta { display: grid; gap: 8px; text-align: center; }
.rec-link { font-weight: 600; }
.rec-meta { font-size: .85rem; color: var(--muted); }
.rec-related, .rec-terms { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .9rem; }
.side-toc li { padding: .35em .6em; font-size: .88rem; }
.side-toc li.lv2 { padding-inline-start: 1.6em; }
.rec-pn { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: .9rem; }
@media (max-width: 900px) {
  .browse { grid-template-columns: 1fr; }
  .browse-side { position: static; grid-template-columns: 1fr 1fr; }
  .rec { grid-template-columns: 1fr; }
  .rec-side { order: -1; }
  .glist { columns: 1; }
}
@media (max-width: 640px) {
  .browse-side { grid-template-columns: 1fr; }
  .rec-table th { width: 110px; padding: 10px 8px; }
  .rec-table td { padding: 10px 8px; }
  .browse-tools input { width: 130px; }
}
@media (max-width: 900px) { #toc-side { display: none; } }
