*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  background: #050816;
  color: #f9fafb;
}

/* Remove all link underlines */
a {
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

a:focus {
  text-decoration: none;
}

a:visited {
  text-decoration: none;
}

body {
  min-height: 100vh;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

@media (max-width: 540px) {
  #app {
    padding: 16px;
  }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: transparent;
}

@media (max-width: 768px) {
  .page-header {
    background: transparent;
    border-radius: 0;
    margin-bottom: 20px;
    padding: 14px 16px;
  }
  
  .header-right {
    gap: 8px;
  }
  
  .user-icon-btn {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  }
  
  .user-menu-dropdown {
    top: 42px;
  }
}

/* Header menu */
.menu-container {
  position: relative;
}

.menu-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: #f9fafb;
  color: #030712;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.5);
}

.menu-button svg {
  display: block;
}

.menu-dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  min-width: 160px;
  padding: 8px 0;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  display: none;
  z-index: 40;
}

.menu-dropdown.open {
  display: block;
}

.menu-item {
  display: block;
  padding: 8px 14px;
  font-size: 14px;
  color: #e5e7eb;
  text-decoration: none;
  white-space: nowrap;
}

.menu-item:hover {
  background: rgba(31, 41, 55, 0.95);
  color: #f9fafb;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f9fafb;
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-text {
  color: #f9fafb;
}

@media (max-width: 768px) {
  .logo-icon {
    background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
    color: #ffffff;
  }
  
  .logo-text {
    color: #f9fafb;
  }
}

.logo:hover {
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu-container {
  position: relative;
}

.user-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.user-menu-dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  min-width: 180px;
  padding: 8px 0;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  display: none;
  z-index: 40;
}

.user-menu-dropdown.open {
  display: block;
}

.user-menu-item {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: #e5e7eb;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.user-menu-item:hover {
  background: rgba(31, 41, 55, 0.95);
  color: #f9fafb;
}

@media (max-width: 768px) {
  .user-icon-btn {
    background: rgba(255, 255, 255, 0.2);
  }
}

.badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: #e5e7eb;
}

.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
}

.section-subaction {
  font-size: 12px;
  color: #9ca3af;
}

.view-all-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #ec4899;
  text-decoration: none;
  transition: color 0.2s ease;
}

.view-all-link:hover {
  color: #f472b6;
}

.view-all-link svg {
  transition: transform 0.2s ease;
}

.view-all-link:hover svg {
  transform: translateX(2px);
}

.best-carousel-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(236, 72, 153, 0.3) transparent;
  margin: 0 -16px;
  padding: 0 16px;
}

.best-carousel-wrapper::-webkit-scrollbar {
  height: 6px;
}

.best-carousel-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.best-carousel-wrapper::-webkit-scrollbar-thumb {
  background: rgba(236, 72, 153, 0.3);
  border-radius: 3px;
}

.best-carousel-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 72, 153, 0.5);
}

.best-carousel {
  display: flex;
  gap: 16px;
  padding-bottom: 8px;
}

.best-grid {
  display: flex;
  gap: 16px;
  min-width: min-content;
}

@media (max-width: 540px) {
  .best-grid {
    gap: 12px;
  }
}

.book-card {
  background: transparent;
  border-radius: 12px;
  padding: 0;
  cursor: pointer;
  transition: transform 0.16s ease;
  flex-shrink: 0;
  width: 160px;
}


@media (max-width: 540px) {
  .book-card {
    width: calc((100vw - 48px) / 3);
    max-width: 100px;
    min-width: 80px;
  }
  
  .best-carousel {
    gap: 6px;
  }
}

.book-card:hover {
  transform: scale(1.05);
}

.book-cover {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 7 !important;
  max-height: none !important;
  border-radius: 10px;
  object-fit: cover;
  background: #020617;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}


.book-title {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #f9fafb;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
  text-align: center;
}

@media (max-width: 540px) {
  .book-title {
    font-size: 11px;
    margin-top: 6px;
    min-height: 32px;
  }
}

.badge-small {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Home page: reserve realistic space for async content to reduce CLS */
#bestGrid {
  min-height: 150px; /* Single row carousel */
}

@media (max-width: 540px) {
  #bestGrid {
    min-height: 130px;
  }
}

#topList {
  min-height: 760px; /* 6 items visible initially */
}

/* Skeleton helpers */
.skeleton-card {
  height: 540px;
}

.skeleton-top-item {
  height: 120px;
}

.top-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(55, 65, 81, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.16s ease, transform 0.12s ease, box-shadow 0.12s ease,
    background 0.16s ease;
}

@media (max-width: 768px) {
  .top-item {
    position: relative;
  }
}

.top-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.85);
  border-color: #ec4899;
  background: rgba(15, 23, 42, 0.98);
}

.top-cover {
  flex-shrink: 0;
  width: 72px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  background: #020617;
}

.top-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.top-content {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 768px) {
  .top-content {
    padding-right: 10px;
  }
}

.top-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-title {
  font-size: 16px;
  font-weight: 700;
  color: #f9fafb;
  margin-bottom: 6px;
  line-height: 1.3;
}

@media (max-width: 768px) {
  .top-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.3em * 2);
  }
}

.top-score {
  font-size: 12px;
  color: #fbbf24;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #9ca3af;
}

.top-summary {
  margin-top: 4px;
  margin-bottom: 6px;
  font-size: 13px;
  color: #e5e7eb;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.top-score-block {
  flex-shrink: 0;
  text-align: center;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

@media (max-width: 768px) {
  .top-score-block {
    position: absolute;
    bottom: 12px;
    right: 14px;
    min-width: auto;
  }
}

.top-score-icon {
  color: #ec4899;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.top-score-icon svg {
  width: 100%;
  height: 100%;
}

.top-score-main {
  font-size: 16px;
  font-weight: 700;
  color: #ec4899;
  line-height: 1;
}

.top-score-sub {
  margin-top: 2px;
  font-size: 10px;
  color: #9ca3af;
}

.chips {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.95);
  color: #9ca3af;
}

.chip--hot {
  background: rgba(248, 113, 113, 0.15);
  color: #fecaca;
}

.chip--new {
  background: rgba(52, 211, 153, 0.16);
  color: #a7f3d0;
}

.chip--complete {
  background: rgba(59, 130, 246, 0.16);
  color: #bfdbfe;
}

/* Simple footer (legacy pages) */
.footer {
  margin-top: 24px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}

.footer a {
  color: #9ca3af;
  text-decoration: none;
}

.footer a:hover {
  color: #e5e7eb;
}

/* New global site footer */
.site-footer {
  margin-top: 40px;
  padding-top: 40px;
  border-top: 1px solid rgba(31, 41, 55, 0.9);
  font-size: 13px;
  color: #cbd5e1;
}

.site-footer-top {
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.site-footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: space-between;
}

.site-footer-col {
  min-width: 180px;
  max-width: 360px;
}

.site-footer-title {
  font-size: 18px;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 12px;
}

.site-footer-text {
  margin: 0;
  line-height: 1.7;
  color: #cbd5e1;
}

.site-footer-heading {
  font-size: 14px;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 10px;
}

.site-footer-link {
  display: block;
  font-size: 13px;
  color: #e5e7eb;
  text-decoration: none;
  margin-bottom: 6px;
}

.site-footer-link:hover {
  color: #f9fafb;
  text-decoration: none;
}

.site-footer-link:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.9);
  outline-offset: 3px;
  border-radius: 6px;
}

.site-footer-bottom {
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.site-footer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: center;
}

.site-footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #e5e7eb;
}

.site-footer-meta {
  font-size: 12px;
  color: #cbd5e1;
  text-align: center;
}

.site-footer-meta-sub {
  margin-top: 4px;
  line-height: 1.6;
  color: #94a3b8;
}

@media (max-width: 768px) {
  .site-footer-grid {
    justify-content: center;
    text-align: center;
    flex-direction: column;
    align-items: center;
  }

  .site-footer-col {
    text-align: center;
    max-width: 100%;
    width: 100%;
  }

  .site-footer-link {
    justify-content: center;
  }
}

/* Detail page */

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.95);
  cursor: pointer;
  margin-bottom: 14px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 540px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.detail-cover {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #020617;
}

.detail-cover img {
  width: 100%;
  display: block;
  object-fit: cover;
}

/* Override for Best Sellers carousel */
.best-carousel .book-card .detail-cover {
  width: 100% !important;
  height: 0 !important;
  padding-bottom: 150% !important; /* 更矮的比例：高度是宽度的1.5倍 */
  overflow: hidden !important;
  border-radius: 10px !important;
  position: relative !important;
  background: #020617;
}

.best-carousel .book-card .detail-cover img.book-cover {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 10px !important;
}

.detail-main-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-author {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.detail-meta {
  font-size: 13px;
  color: #9ca3af;
}

.detail-section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 6px;
}

.detail-summary {
  font-size: 14px;
  color: #e5e7eb;
  line-height: 1.55;
  white-space: pre-line;
}

.detail-raw-wrap {
  margin-top: 12px;
}

.detail-raw-toggle {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  cursor: pointer;
}

.detail-raw {
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  font-size: 11px;
  padding: 10px;
  border-radius: 10px;
  background: #020617;
  border: 1px solid rgba(31, 41, 55, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 32px 18px;
  text-align: center;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px dashed rgba(55, 65, 81, 0.9);
  font-size: 13px;
  color: #9ca3af;
}

.skeleton {
  background: linear-gradient(90deg, #111827, #1f2937, #111827);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Book Detail Page Styles */
.book-detail-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100vh;
}

.book-detail-back {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s ease;
}

.book-detail-back:hover {
  opacity: 0.7;
}

.book-detail-header {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.book-detail-cover-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: #020617;
}

.book-detail-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-detail-cover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  color: #ffffff;
}

.book-detail-cover-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.book-detail-cover-subtitle {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.book-detail-cover-subtitle span {
  color: #ffffff;
  font-weight: 700;
}

.book-detail-cover-author {
  font-size: 11px;
  font-style: italic;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.book-detail-info {
  flex: 1;
  min-width: 0;
}

.book-detail-title {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.book-detail-author {
  font-size: 15px;
  color: #e5e7eb;
  margin-bottom: 8px;
}

.book-detail-meta {
  font-size: 14px;
  color: #9ca3af;
}

.book-detail-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.book-detail-stat-card {
  flex: 1;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(55, 65, 81, 0.7);
}

.book-detail-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.book-detail-stat-value span {
  color: #ffffff;
  margin-right: 2px;
}

.book-detail-star {
  margin-left: 4px;
}

.book-detail-stat-label {
  font-size: 13px;
  color: #9ca3af;
}

.book-detail-summary-section {
  margin-bottom: 0;
}

.book-detail-summary-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 12px 0;
}

.book-detail-summary-text {
  font-size: 15px;
  color: #e5e7eb;
  line-height: 1.6;
  margin: 0;
}

/* PC端按钮wrapper正常显示 */
.book-detail-read-btn-wrapper {
  margin: 0;
  padding: 0;
}

.book-detail-read-btn {
  width: 100%;
  max-width: 500px;
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin: 16px auto 32px;
  display: block;
  text-align: center;
}

.book-detail-read-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(236, 72, 153, 0.4);
}

.book-detail-read-btn:active {
  transform: translateY(0);
}

@media (max-width: 540px) {
  .book-detail-container {
    padding: 0 16px 100px;
  }

  .book-detail-header {
    flex-direction: column;
  }

  .book-detail-cover-wrapper {
    width: 100%;
    max-width: 200px;
    height: auto;
    aspect-ratio: 3 / 4;
    margin: 0 auto;
  }

  .book-detail-title {
    font-size: 20px;
  }

  /* Fix Read Now button wrapper at bottom on mobile */
  .book-detail-read-btn-wrapper {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 16px !important;
    background: linear-gradient(to top, rgba(17, 24, 39, 0.95) 0%, rgba(17, 24, 39, 0.8) 70%, transparent 100%) !important;
    z-index: 1000 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .book-detail-read-btn {
    width: 100% !important;
    max-width: 500px !important;
    margin: 0 !important;
  }

  /* Hide footer on mobile for book detail pages */
  #app .book-detail-container ~ .site-footer {
    display: none;
  }
}

/* Visually hide SEO link section but keep it in DOM for crawlers */
.seo-link-section {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Legal pages (Privacy / Terms / Contact) */
.legal-container {
  max-width: 900px;
  margin: 24px auto 0;
  padding: 24px 22px 32px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(55, 65, 81, 0.9);
  font-size: 14px;
  line-height: 1.7;
}

.legal-container h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 16px 0;
  color: #e5e7eb;
}

.legal-container p {
  margin: 0 0 12px 0;
  color: #e5e7eb;
}

.legal-container strong {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-weight: 700;
  color: #f9fafb;
}

@media (max-width: 640px) {
  .legal-container {
    padding: 18px 14px 24px;
  }
}
