body { font-family: "Public Sans", sans-serif; }
.soft-scroll { scrollbar-width: thin; scrollbar-color: #3e4552 #1e2329; }
.soft-scroll::-webkit-scrollbar { width: 8px; }
.soft-scroll::-webkit-scrollbar-track { background: #1e2329; }
.soft-scroll::-webkit-scrollbar-thumb { background: #3e4552; border-radius: 9999px; }
.soft-scroll::-webkit-scrollbar-thumb:hover { background: #4a5361; }

.books-toolbar {
  border-bottom: 1px solid #1f2937;
  padding: 0;
  background: #1a1e23;
}

.books-topbar-track {
  height: 64px;
  min-height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.books-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 0;
}

.books-logo-link {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #4f46e5;
  padding: 4px;
  text-decoration: none;
  flex: 0 0 auto;
}

.books-logo-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.books-topbar-middle {
  position: relative;
  min-width: 280px;
  flex: 0 1 50%;
  max-width: 50%;
}

.books-topbar-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.books-topbar-tabs::-webkit-scrollbar {
  height: 6px;
}

.books-topbar-meta {
  color: #d1d5db;
  font-size: 0.93rem;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.books-user-avatar {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 9999px;
  border: 2px solid #374151;
  flex: 0 0 auto;
}

.books-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.books-user-menu {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.books-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 224px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.books-user-menu:hover .books-dropdown-menu,
.books-user-menu:focus-within .books-dropdown-menu {
  opacity: 1;
  visibility: visible;
}

.books-dropdown-panel {
  background: #2d333b;
  border: 1px solid #3e4552;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
  overflow: hidden;
  padding: 4px 0;
}

.books-dropdown-link,
.books-dropdown-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #d1d5db;
  text-decoration: none;
  background: transparent;
  border: 0;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
}

.books-dropdown-link:hover,
.books-dropdown-btn:hover {
  background: #373e47;
}

.books-dropdown-btn {
  cursor: pointer;
}

.books-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex: 0 0 auto;
  min-width: 0;
}

@media (max-width: 1024px) {
  .books-topbar-track {
    height: 64px;
    min-height: 64px;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
  }

  .books-topbar-middle {
    order: 0;
    flex: 1 1 auto;
    max-width: 100%;
    min-width: 0;
  }

  .books-topbar-right {
    gap: 6px;
    flex: 0 0 auto;
  }
}

/* Calibre-style preview shell */
.preview-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; border: 1px solid #3e4552; border-radius: 12px; overflow: hidden; min-height: 70vh; background: #101418; }
.preview-sidebar { background: #1c2027; color: #cfd3dc; border-right: 1px solid #0f1216; display: flex; flex-direction: column; }
.preview-sidebar-header { padding: 16px; border-bottom: 1px solid #2a2f36; }
.preview-sidebar h3 { color: #fff; font-weight: 700; margin: 0; }
.preview-search { display: flex; align-items: center; gap: 8px; background: #0f1216; border: 1px solid #2a2f36; border-radius: 10px; padding: 10px 12px; color: #cfd3dc; }
.preview-search input { width: 100%; background: transparent; border: none; outline: none; color: inherit; font-size: 14px; }
.preview-toc { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.preview-toc-item { cursor: pointer; padding: 12px 14px; border-bottom: 1px solid #161a20; color: #cfd3dc; transition: background 150ms ease, color 150ms ease, border-left 150ms ease; border-left: 4px solid transparent; }
.preview-toc-item:hover { background: #222833; color: #fff; }
.preview-toc-item.active { background: #303845; color: #fff; border-left-color: #4a90e2; }
.preview-reader { position: relative; background: #f5f5f0; color: #2b241c; min-height: 70vh; }
.preview-frame { width: 100%; height: 100%; min-height: 70vh; border: 0; background: #f5f5f0; }
.preview-columns { column-count: 2; column-gap: 64px; column-rule: 1px solid #e0e0d0; text-align: justify; line-height: 1.7; max-width: 1500px; margin: 0 auto; }
.preview-columns h1, .preview-columns h2, .preview-columns h3 { column-span: all; text-align: center; margin: 0 0 28px; font-weight: 700; }
.preview-chapter { break-inside: avoid; margin-bottom: 64px; }
.preview-chapter .chapter-meta { column-span: all; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: #5a5244; margin-bottom: 8px; text-align: center; }
.preview-progress { position: absolute; right: 16px; bottom: 14px; width: fit-content; background: rgba(16,20,24,0.92); color: #e5e7eb; padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); z-index: 2; }
.preview-book-frame { position: relative; min-height: 60vh; background: linear-gradient(135deg, #f9f7f3 0%, #f0ede7 100%); border-radius: 12px; box-shadow: inset 0 1px 0 #f7f5f0, 0 18px 38px rgba(0,0,0,0.25); }
.preview-book-frame::before, .preview-book-frame::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: #e0d6c8; }
.preview-book-frame::before { left: 50%; opacity: 0.9; }
.preview-book-frame::after { left: calc(50% + 1px); opacity: 0.35; }
@media (max-width: 1024px) {
  .preview-shell { grid-template-columns: 1fr; }
  .preview-reader { min-height: 52vh; }
  .preview-columns { column-count: 1; }
  .preview-book-frame::before, .preview-book-frame::after { display: none; }
}
@media (max-width: 640px) {
  .preview-reader { min-height: 48vh; }
  .preview-columns { column-gap: 28px; }
}
