/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: #1e293b;
  background: #f8fafc;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a {
  color: #2563eb;
  text-decoration: none;
}
a:hover {
  color: #1d4ed8;
}
img {
  max-width: 100%;
  display: block;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 10000;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.toast.show {
  transform: translateX(0);
}
.toast-success {
  background: #10b981;
}
.toast-error {
  background: #ef4444;
}

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 64px;
  gap: 40px;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}
.logo:hover {
  color: #2563eb;
}
.category-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-nav::-webkit-scrollbar {
  display: none;
}
.cat-link {
  padding: 8px 16px;
  border-radius: 20px;
  color: #64748b;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
}
.cat-link:hover {
  color: #1e293b;
  background: #f1f5f9;
}
.cat-link.active {
  color: #fff;
  background: #2563eb;
}
.cat-count {
  font-size: 12px;
  margin-left: 4px;
  opacity: 0.7;
}

/* ===== Container ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
  width: 100%;
}

/* ===== Book Section ===== */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 22px;
  font-weight: 600;
}
.book-count {
  color: #94a3b8;
  font-size: 14px;
}

/* ===== Book Grid ===== */
.book-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 40px 20px;
}
.book-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s;
}
.book-card:hover {
  transform: translateY(-4px);
}
.book-cover {
  width: 250px;
  height: 345px;
  overflow: hidden;
  background: #f1f5f9;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.book-cover img {
  width: 250px;
  height: 345px;
  object-fit: cover;
  transition: transform 0.3s;
}
.book-card:hover .book-cover img {
  transform: scale(1.05);
}
.book-info {
  padding: 12px 4px 0;
  width: 250px;
}
.book-title {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  text-align: center;
}
.book-author {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.empty-text {
  text-align: center;
  color: #94a3b8;
  padding: 60px 0;
  grid-column: 1 / -1;
  font-size: 16px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
}
.page-btn {
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #475569;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
  border-color: #2563eb;
  color: #2563eb;
}
.page-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-ellipsis {
  color: #94a3b8;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  margin-bottom: 24px;
  font-size: 14px;
  color: #94a3b8;
}
.breadcrumb a {
  color: #64748b;
}
.breadcrumb a:hover {
  color: #2563eb;
}
.breadcrumb .sep {
  margin: 0 8px;
}

/* ===== Book Detail ===== */
.book-detail {
  display: flex;
  gap: 48px;
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.detail-loading,
.detail-error {
  text-align: center;
  padding: 60px;
  color: #94a3b8;
  width: 100%;
}
.detail-error h2 {
  margin-bottom: 12px;
  color: #475569;
}
.detail-sidebar {
  flex-shrink: 0;
  width: 250px;
}
.detail-cover {
  width: 250px;
  height: 345px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
}
.detail-cover img {
  width: 250px;
  height: 345px;
  object-fit: cover;
}
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.meta-label {
  color: #94a3b8;
}
.meta-value {
  color: #1e293b;
  font-weight: 500;
}
.detail-content {
  flex: 1;
  min-width: 0;
}
.detail-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
  line-height: 1.3;
}

/* ===== Markdown Body ===== */
.markdown-body {
  font-size: 16px;
  line-height: 1.8;
  color: #334155;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: #1e293b;
  margin-top: 32px;
  margin-bottom: 16px;
  line-height: 1.4;
}
.markdown-body h1 {
  font-size: 24px;
}
.markdown-body h2 {
  font-size: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.markdown-body h3 {
  font-size: 18px;
}
.markdown-body p {
  margin-bottom: 16px;
}
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.markdown-body li {
  margin-bottom: 6px;
}
.markdown-body blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 4px solid #2563eb;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  color: #475569;
}
.markdown-body code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #e11d48;
}
.markdown-body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px;
  border-radius: 12px;
  margin: 16px 0;
  overflow-x: auto;
}
.markdown-body pre code {
  background: none;
  color: inherit;
  padding: 0;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  text-align: left;
}
.markdown-body th {
  background: #f8fafc;
  font-weight: 600;
}
.markdown-body strong {
  color: #1e293b;
}
.markdown-body a {
  color: #2563eb;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 24px;
  color: #94a3b8;
  font-size: 13px;
  border-top: 1px solid #e2e8f0;
  margin-top: 40px;
}

/* ===== Responsive ===== */
@media (max-width: 1400px) {
  .book-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 1100px) {
  .book-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .book-detail {
    flex-direction: column;
    gap: 24px;
    padding: 24px;
  }
  .detail-sidebar {
    width: 100%;
    display: flex;
    gap: 24px;
  }
  .detail-cover {
    width: 250px;
    flex-shrink: 0;
  }
  .detail-meta {
    flex: 1;
  }
}
@media (max-width: 768px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}
@media (max-width: 480px) {
  .book-grid {
    grid-template-columns: repeat(1, 1fr);
    gap: 20px;
  }
  .header-inner {
    gap: 16px;
  }
  .detail-sidebar {
    flex-direction: column;
  }
  .detail-cover {
    width: 250px;
  }
}
