/* Books */
.app-books { background: var(--surface); container-type: inline-size; position: relative; }
.bk-lib, .bk-read { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bk-lib[hidden], .bk-read[hidden] { display: none; }
.bk-libbar { gap: 8px; }
.bk-libsearch { flex: 0 1 240px; min-width: 120px; }
.bk-libbody { flex: 1; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.bk-empty-ic { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; background: rgba(251, 191, 36, .16); color: #d97706; }
.bk-empty-b { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.bk-note { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 12px; background: rgba(var(--accent-rgb), .1); color: var(--text-2); font-size: 12.5px; line-height: 1.4; }
.bk-note .ic { color: var(--accent); flex: 0 0 auto; }
.bk-note.warn { background: rgba(245, 165, 36, .14); }
.bk-note.warn .ic { color: #d48806; }
.bk-libhead { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.bk-sort { height: 30px; font-size: 12.5px; }

/* covers */
.bk-cover { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(160deg, var(--c1), color-mix(in srgb, var(--c1) 55%, #000)); color: #fff; }
.bk-cover::before { content: ''; position: absolute; left: 7%; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .18); }
.bk-cover-gen { position: absolute; inset: 14% 12% 10% 16%; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.bk-cover-gen b { font: 600 clamp(11px, 1.3em, 17px)/1.2 'Iowan Old Style', Georgia, serif; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bk-cover-gen i { font-size: .72em; font-style: normal; opacity: .8; border-top: 1px solid var(--c2); padding-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.bk-cover.has-img img { opacity: 1; }
.bk-cover.has-img .bk-cover-gen { visibility: hidden; }

.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 22px 16px; }
.bk-book { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 0; border: 0; background: none; color: var(--text); text-align: left; }
.bk-book-cover { position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 4px 10px 10px 4px; overflow: hidden; margin-bottom: 6px; box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .15s var(--ease), box-shadow .15s; }
button.bk-book:hover .bk-book-cover, .bk-cat .bk-book-cover:hover { transform: translateY(-3px); box-shadow: 0 16px 26px -14px rgba(0, 0, 0, .65), 0 0 0 1px rgba(0, 0, 0, .08); }
.bk-book > b { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-book > small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-book .progress { margin-top: 4px; }
.bk-done { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #22c55e; color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.bk-book.skel .bk-book-cover, .bk-book.skel i { background: var(--surface-2); box-shadow: none; animation: bk-pulse 1.2s ease-in-out infinite; }
.bk-book.skel i { display: block; height: 11px; border-radius: 6px; width: 80%; margin-top: 2px; }
.bk-book.skel i:last-child { width: 50%; }
@keyframes bk-pulse { 50% { opacity: .5; } }

.bk-continue { display: flex; align-items: center; gap: 16px; padding: 14px 18px 14px 14px; border: 0; border-radius: 18px; text-align: left; color: var(--text); background: linear-gradient(120deg, rgba(251, 191, 36, .16), rgba(var(--accent-rgb), .08)); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.bk-continue:hover { background: linear-gradient(120deg, rgba(251, 191, 36, .22), rgba(var(--accent-rgb), .12)); }
.bk-continue .bk-cover { border-radius: 3px 8px 8px 3px; flex: 0 0 auto; box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .6); font-size: 10px; }
.bk-continue-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bk-continue-t small { font-size: 11.5px; font-weight: 700; color: #d97706; }
.bk-continue-t b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-continue-t > span:not(.progress) { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-continue-t .progress { max-width: 280px; margin-top: 6px; }
.bk-continue-pct { font: 300 30px var(--font-display); color: var(--text-2); }

/* catalogue */
.bk-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bk-cat-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.bk-cat-src { font-size: 12px; }
.bk-cat-q { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--text-2); }
.bk-cat .bk-book-cover { cursor: default; }
.bk-cat-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-width: 0; }
.bk-cat-row .btn .spinner { width: 12px; height: 12px; }
.bk-cat-dl { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-more { display: flex; justify-content: center; }
.bk-more .spinner { width: 14px; height: 14px; }
.bk-credit { margin: 6px 0 0; font-size: 11.5px; color: var(--text-3); text-align: center; }

/* reader */
.bk-read { position: relative; background: var(--bk-bg, var(--surface)); color: var(--bk-fg, var(--text)); }
.bk-loading { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); }
.bk-rbar { flex: 0 0 auto; height: 50px; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid color-mix(in srgb, var(--bk-fg) 12%, transparent); }
.bk-rbar .icon-btn { color: var(--bk-fg); }
.bk-rbar .icon-btn:hover { background: color-mix(in srgb, var(--bk-fg) 8%, transparent); }
.bk-rbar .icon-btn.on { color: #e11d48; background: none; }
.bk-rbar .bk-bm.on svg { fill: currentColor; }
.bk-rtitle { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 8px; }
.bk-rtitle b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bk-rtitle small { font-size: 11.5px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bk-stage { position: relative; flex: 1; min-height: 0; display: flex; padding: 18px 56px 8px; }
.bk-view { flex: 1; min-width: 0; height: 100%; }
.bk-view iframe { color-scheme: light; }
.bk-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 80px; border: 0; border-radius: 12px; background: none; color: var(--bk-fg); opacity: .35; display: grid; place-items: center; transition: opacity .15s, background .15s; z-index: 2; }
.bk-nav:hover { opacity: .9; background: color-mix(in srgb, var(--bk-fg) 6%, transparent); }
.bk-nav.prev { left: 6px; }
.bk-nav.next { right: 6px; }
.bk-rfoot { flex: 0 0 auto; height: 40px; display: flex; align-items: center; gap: 14px; padding: 0 20px; font-size: 11.5px; }
.bk-foot-l, .bk-foot-r { flex: 0 1 200px; min-width: 0; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.bk-foot-r { text-align: right; }
.bk-slider { flex: 1; height: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--bk-fg) 55%, transparent) var(--p, 0%), color-mix(in srgb, var(--bk-fg) 14%, transparent) var(--p, 0%)); }
.bk-slider:disabled { opacity: .4; }
.bk-slider::-webkit-slider-thumb { width: 13px; height: 13px; }
.bk-read[data-rtheme="dark"] .bk-loading { color: rgba(217, 213, 204, .7); }

.bk-panel { position: absolute; top: 50px; bottom: 0; left: 0; width: min(340px, 92%); z-index: 6; display: flex; flex-direction: column; background: var(--surface); color: var(--text); box-shadow: 12px 0 40px -16px rgba(0, 0, 0, .45); border-right: 1px solid var(--line); animation: bk-in-l .2s var(--ease); }
.bk-panel.right { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line); box-shadow: -12px 0 40px -16px rgba(0, 0, 0, .45); animation-name: bk-in-r; }
.bk-panel[hidden] { display: none; }
@keyframes bk-in-l { from { transform: translateX(-16px); opacity: 0; } }
@keyframes bk-in-r { from { transform: translateX(16px); opacity: 0; } }
.bk-panel-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 16px; }
.bk-panel-h h3 { margin: 0; font-size: 14px; }
.bk-panel-b { flex: 1; padding: 0 8px 16px; display: flex; flex-direction: column; gap: 1px; }
.bk-toc { border: 0; background: none; color: var(--text); text-align: left; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; line-height: 1.35; }
.bk-toc:hover { background: var(--hover); }
.bk-toc.on { background: rgba(var(--accent-rgb), .14); color: var(--accent); font-weight: 600; }
.bk-panel-sec { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 6px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.bk-panel-empty { padding: 8px; font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.bk-panel-empty .ic { display: inline; vertical-align: -2px; }
.bk-note-row { display: flex; align-items: flex-start; gap: 4px; border-radius: 10px; }
.bk-note-row:hover { background: var(--hover); }
.bk-note-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 0; background: none; color: var(--text); text-align: left; }
.bk-note-main small { font-size: 11px; color: var(--text-3); font-weight: 600; }
.bk-note-main span { font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bk-hl-text { padding-left: 8px; border-left: 3px solid var(--hl); }
.bk-note-main em { font-size: 12.5px; color: var(--text-2); }
.bk-note-row .icon-btn { width: 28px; height: 28px; margin-top: 6px; color: var(--text-3); }

.bk-pop { position: absolute; z-index: 8; display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 14px; background: var(--glass-solid) !important; color: var(--text); }
.bk-pop[hidden] { display: none; }
.bk-pop-colors { display: flex; gap: 5px; padding: 0 5px; }
.bk-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); padding: 0; }
.bk-dot:hover { transform: scale(1.12); }
.bk-pop-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 3px; }
.bk-pop-btn { height: 32px; display: inline-flex; align-items: center; gap: 5px; padding: 0 9px; border: 0; border-radius: 9px; background: none; color: var(--text); font-size: 12.5px; font-weight: 600; }
.bk-pop-btn:hover { background: var(--hover); }

.bk-settings { position: absolute; z-index: 9; width: 330px; max-width: calc(100% - 16px); padding: 12px 14px; border-radius: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--glass-solid) !important; color: var(--text); }
.bk-settings[hidden] { display: none; }
.bk-set-row { display: flex; align-items: center; gap: 12px; }
.bk-set-l { flex: 0 0 64px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.bk-set-c { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.bk-set-c .select { flex: 1; min-width: 0; }
.bk-size-l { flex: 1; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.bk-themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; flex: 1; }
.bk-theme { height: 34px; border-radius: 10px; border: 0; font-size: 12px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.bk-theme.on { box-shadow: inset 0 0 0 2px var(--accent); }
.bk-theme.t-auto { background: linear-gradient(135deg, #fbfaf7 50%, #15171c 50%); color: #fff; text-shadow: 0 0 3px #000, 0 0 1px #000; }
.bk-theme.t-light { background: #fbfaf7; color: #1d1c1a; }
.bk-theme.t-sepia { background: #f4ecd8; color: #5b4636; }
.bk-theme.t-dark { background: #15171c; color: #d9d5cc; }

@container (max-width: 640px) {
  .bk-libbody { padding: 12px 12px 22px; }
  .bk-libbar { flex-wrap: wrap; height: auto; padding: 8px 10px; row-gap: 8px; }
  .bk-libsearch { flex: 1 1 140px; order: 3; }
  .bk-import span { display: none; }
  .bk-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; }
  .bk-stage { padding: 10px 14px 4px; }
  .bk-nav { display: none; }
  .bk-cat-src { display: none; }
  .bk-continue-pct { display: none; }
  .bk-rfoot { padding: 0 14px; gap: 10px; }
  .bk-foot-l { display: none; }
  .bk-foot-r { flex: 0 0 auto; }
}
[data-layout="mobile"] .app-books .bk-rfoot { padding-bottom: 14px; height: 52px; }
