:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1c2333;
  --muted: #5b6577;
  --border: #e3e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.07);
  --shadow-lg: 0 12px 30px rgba(20, 30, 60, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(20, 30, 60, 0.05);
}

.header-top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }

.brand-logo {
  height: 40px;
  max-width: 240px;
  width: auto;
  display: block;
}

.brand-wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 550;
  letter-spacing: -0.3px;
  color: #18256d;
  line-height: 1;
}

.header-search {
  flex: 1;
  display: flex;
  max-width: 560px;
  margin-left: auto;
}
.header-search input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px 0 0 10px;
  font-size: 14px;
  outline: none;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.header-search input:focus {
  border-color: var(--primary);
  background: #fff;
}
.header-search button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 18px;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  font-size: 15px;
}
.header-search button:hover { background: var(--primary-dark); }

.header-nav {
  display: flex;
  gap: 18px;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.header-nav a { color: var(--muted); }
.header-nav a:hover { color: var(--primary); }
.header-nav a.active { color: var(--primary); }

.catnav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0 10px;
  scrollbar-width: thin;
}
.catnav a {
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.catnav a:hover { background: var(--surface-2); color: var(--primary); }
.catnav a.active { background: var(--primary); color: #fff; }

/* ---------- Main ---------- */
.main { padding: 28px 20px 60px; min-height: 60vh; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1000px 400px at 80% -10%, rgba(245, 158, 11, 0.18), transparent 60%),
    radial-gradient(900px 400px at 10% -20%, rgba(37, 99, 235, 0.22), transparent 60%),
    linear-gradient(135deg, #0f2a5f 0%, #1d4ed8 55%, #2563eb 100%);
  color: #fff;
  border-radius: 18px;
  padding: 56px 40px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "\1F4DA";
  position: absolute;
  right: -20px;
  bottom: -30px;
  font-size: 180px;
  opacity: 0.12;
  transform: rotate(-12deg);
}
.hero-inner { max-width: 640px; position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  margin: 0 0 12px;
  letter-spacing: -0.5px;
}
.hero h1 span { color: #ffd479; }
.hero p { font-size: 17px; opacity: 0.92; margin: 0 0 24px; }

.hero-search {
  display: flex;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  max-width: 560px;
}
.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 8px;
}
.hero-search button {
  border: none;
  background: var(--accent);
  color: #1c2333;
  font-weight: 700;
  padding: 0 26px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
.hero-search button:hover { filter: brightness(1.06); }

.hero-links { margin-top: 18px; display: flex; gap: 20px; font-weight: 600; font-size: 14px; }
.hero-links a { color: #fff; border-bottom: 1px dashed rgba(255,255,255,0.5); }
.hero-links a:hover { color: #ffd479; border-color: #ffd479; }

/* ---------- Sections ---------- */
.section { margin-bottom: 44px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.3px;
}
.section-head p { margin: 0; color: var(--muted); }
.section-head .view-all { margin-left: auto; font-size: 14px; font-weight: 600; }

/* ---------- Category grid ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  color: var(--text);
}
.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  color: var(--text);
}
.cat-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 12px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.cat-card:hover .cat-icon { background: #dbeafe; }
.cat-name { font-weight: 700; font-size: 15px; }
.cat-count { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- Book grid / cards ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.book-cover {
  display: block;
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
  overflow: hidden;
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.book-card:hover .book-cover img { transform: scale(1.04); }

.book-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.book-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-title a { color: var(--text); }
.book-title a:hover { color: var(--primary); }

.book-author {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta { display: flex; gap: 6px; }
.tag {
  display: inline-block;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.book-stats {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Page heads ---------- */
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 6px 0 4px; font-size: 30px; letter-spacing: -0.4px; }
.page-head p { margin: 0; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); }

.inline-search {
  display: flex;
  max-width: 480px;
  margin-bottom: 24px;
}
.inline-search input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px 0 0 10px;
  font-size: 14px;
  outline: none;
}
.inline-search input:focus { border-color: var(--primary); }
.inline-search button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  font-weight: 600;
}

/* ---------- Book detail ---------- */
.book-detail .crumb { display: inline-block; margin-bottom: 18px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.detail-top { display: flex; gap: 28px; }

.detail-cover {
  width: 240px;
  flex-shrink: 0;
}
.detail-cover img {
  width: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.detail-info h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -0.4px; line-height: 1.2; }
.detail-author { margin: 0 0 20px; color: var(--muted); font-size: 16px; }
.detail-author strong { color: var(--text); }

.fact-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin-bottom: 20px;
}
.fact { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--border); padding-bottom: 6px; font-size: 14px; }
.fact span { color: var(--muted); }
.fact b { text-align: right; font-weight: 600; }

.download-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.download-box.disabled { opacity: 0.7; }

.btn-download {
  display: inline-block;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 26px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-download:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(22, 163, 74, 0.42); color: #fff; }
.btn-download.disabled { background: #94a3b8; box-shadow: none; cursor: not-allowed; }

.download-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.popularity { font-size: 12px; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 4px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #f97316); border-radius: 999px; }

.about {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.about h2 { margin: 0 0 10px; font-size: 20px; }
.about p { margin: 0 0 16px; color: #333c4e; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Sidebar */
.side-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.side-box h3 { margin: 0 0 12px; font-size: 15px; }

.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li + li { border-top: 1px solid var(--border); }
.side-list a {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  color: var(--text);
  align-items: center;
}
.side-list a:hover { color: var(--primary); }
.side-list img { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.side-list strong { display: block; font-size: 13px; line-height: 1.3; }
.side-list small { color: var(--muted); font-size: 12px; }

.side-box > p { margin: 0; color: var(--muted); font-size: 14px; }

.share-row { display: flex; gap: 10px; }
.share-row a {
  flex: 1;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.share-row a:hover { border-color: var(--primary); color: var(--primary); }

.similar-section { margin-top: 44px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 36px 0 10px;
  flex-wrap: wrap;
}
.pagination a,
.pagination .current {
  min-width: 38px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}
.empty-state p { font-size: 54px; margin: 0 0 8px; }
.empty-state h1, .empty-state h3 { color: var(--text); margin: 0 0 8px; }
.empty-state .btn-download { margin-top: 18px; }

/* ---------- Footer ---------- */
.site-footer {
  background: #121a2b;
  color: #cbd3e1;
  padding: 48px 0 28px;
  margin-top: 20px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
}
.site-footer h4 { color: #fff; margin: 0 0 12px; font-size: 15px; }
.site-footer p { margin: 0; font-size: 14px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: #cbd3e1; font-size: 14px; }
.site-footer a:hover { color: #fff; }
.copyright { margin-top: 32px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 13px; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .header-top { flex-wrap: wrap; gap: 12px; }
  .header-search { order: 3; max-width: none; width: 100%; }
}

@media (max-width: 560px) {
  .detail-top { flex-direction: column; }
  .detail-cover { width: 100%; max-width: 280px; margin: 0 auto; }
  .fact-list { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .hero { padding: 40px 24px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}