/* Books */
.books-root { height: 100%; background: #fbf8f3; color: #2a2620; display: flex; flex-direction: column; }
.books-root .hidden { display: none !important; }

/* Library */
.books-library { flex: 1; overflow-y: auto; padding: 26px 30px 36px; }
.books-title { font-size: 26px; font-weight: 800; margin-bottom: 20px; }
.books-shelf { display: flex; flex-direction: column; gap: 22px; }
.book-card { display: flex; gap: 20px; background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 16px; padding: 18px; box-shadow: 0 4px 14px rgba(0,0,0,0.06); }
.book-cover {
  width: 132px; height: 196px; flex: 0 0 auto; border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28); cursor: default;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center; color: #fff; position: relative; overflow: hidden;
  transition: transform 0.15s ease;
}
.book-cover:hover { transform: translateY(-3px) rotate(-1deg); }
.book-cover::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: rgba(0,0,0,0.22); }
.book-cover-emoji { font-size: 38px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.book-cover-title { font-size: 14px; font-weight: 700; line-height: 1.2; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.book-cover-author { font-size: 11px; opacity: 0.9; }
.book-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.book-name { font-size: 19px; font-weight: 700; }
.book-author { font-size: 13px; color: #9a7b3f; font-weight: 500; }
.book-blurb { font-size: 13.5px; color: #6b6358; line-height: 1.5; margin: 6px 0 12px; }
.book-open { align-self: flex-start; margin-top: auto; padding: 8px 20px; border-radius: 18px; background: #ff8a3d; color: #fff; font-size: 13.5px; font-weight: 600; }
.book-open:hover { filter: brightness(1.06); }
.books-foot { font-size: 12px; color: #a39a8c; text-align: center; margin-top: 26px; }

/* Reader */
.books-reader { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; background: #fbf6ec; }
.reader-loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #8a8175; font-size: 15px; padding: 40px; text-align: center; }
.reader-spinner { width: 30px; height: 30px; border: 3px solid rgba(0,0,0,0.12); border-top-color: #ff8a3d; border-radius: 50%; animation: bspin 0.8s linear infinite; }
@keyframes bspin { to { transform: rotate(360deg); } }

.reader-bar { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 0.5px solid rgba(0,0,0,0.1); background: rgba(251,246,236,0.95); backdrop-filter: blur(10px); }
.reader-bar-title { flex: 1; text-align: center; font-size: 13px; font-weight: 600; color: rgba(0,0,0,0.5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-bar-tools { display: flex; gap: 4px; }
.reader-btn { padding: 5px 11px; border-radius: 7px; font-size: 13px; color: #5a5247; background: rgba(0,0,0,0.05); }
.reader-btn:hover:not(:disabled) { background: rgba(0,0,0,0.1); }
.reader-btn:disabled { opacity: 0.35; }

.reader-page {
  flex: 1; overflow-y: auto; padding: 34px clamp(20px, 8%, 90px) 60px;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  line-height: 1.72; color: #322d25; max-width: 760px; margin: 0 auto; width: 100%;
}
.reader-ch-title { font-size: 1.5em; font-weight: 700; text-align: center; margin-bottom: 1.2em; color: #4a4236; }
.reader-p { margin: 0 0 1em; text-indent: 1.4em; text-align: justify; }
.reader-p:first-of-type { text-indent: 0; }

.reader-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 0.5px solid rgba(0,0,0,0.1); background: rgba(251,246,236,0.95); }
.reader-progress { font-size: 12.5px; color: #9a9082; font-variant-numeric: tabular-nums; }

.reader-toc {
  position: absolute; top: 44px; left: 0; bottom: 0; width: min(280px, 80%);
  background: #fff; border-right: 0.5px solid rgba(0,0,0,0.12); box-shadow: 6px 0 20px rgba(0,0,0,0.12);
  overflow-y: auto; z-index: 5; animation: tocIn 0.18s ease;
}
@keyframes tocIn { from { transform: translateX(-100%); } to { transform: none; } }
.reader-toc-head { padding: 14px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #a39a8c; }
.reader-toc-row { padding: 9px 16px; font-size: 13.5px; color: #3a342b; cursor: default; border-bottom: 0.5px solid rgba(0,0,0,0.05); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-toc-row:hover { background: rgba(0,0,0,0.04); }
.reader-toc-row.active { background: #fff3e6; color: #d2691e; font-weight: 600; }

@media (max-width: 640px) {
  .book-card { flex-direction: column; align-items: center; text-align: center; }
  .book-meta { align-items: center; }
  .book-open { align-self: center; }
  .reader-page { padding: 24px 20px 50px; }
}
