:root {
  --bg: #faf7f2;
  --text: #201b16;
  --muted: #6f665c;
  --accent: #241d17;
  --card: #ffffff;
  --border: #ded5ca;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Serif SC", "PingFang SC", "Microsoft YaHei", serif;
  background: radial-gradient(circle at top, #fffdf9 0%, var(--bg) 48%, #f2ebe1 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(1120px, 92%);
  margin: 28px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* 顶栏：左品牌 | 中间搜索 | 右导航，同一行 */
.topbar--with-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 20px;
}

.topbar--with-search .brand {
  flex-shrink: 0;
}

.site-search {
  margin: 0;
  min-width: 0;
  width: 100%;
  max-width: 420px;
  justify-self: center;
}

.site-search-shell {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.site-search-shell:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), 0 1px 3px rgba(15, 23, 42, 0.06);
}

.site-search input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 10px 16px 10px 18px;
  border: none;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.site-search input[type="search"]::placeholder {
  color: #94a3b8;
}

.site-search input[type="search"]:focus {
  outline: none;
}

.site-search-btn {
  flex-shrink: 0;
  margin: 4px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.site-search-btn:hover {
  background: #334155;
}

.site-search-btn:active {
  background: #0f172a;
}

.nav--topbar {
  flex-shrink: 0;
  justify-self: end;
  flex-wrap: nowrap;
}

.section-title-hint {
  font-size: 0.65em;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.35em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 18px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 24px;
  font-size: 15px;
}

.nav a {
  opacity: 0.8;
}

.nav a.active,
.nav a:hover {
  opacity: 1;
}

.nav-user {
  font-size: 13px;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout-form {
  display: inline;
  margin: 0;
}

.nav-logout {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 15px;
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
}

.nav-logout:hover {
  opacity: 1;
}

.my-login-card {
  max-width: 420px;
  margin-top: 16px;
}

.my-login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
}

.my-app-error {
  color: #b42318;
  margin: 12px 0 0;
}

.my-app-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.my-app-status {
  font-weight: 600;
}

.my-app-status--pending {
  color: #b45309;
}

.my-app-status--ok {
  color: #047857;
}

.my-app-status--bad {
  color: #b91c1c;
}

.my-app-reject-reason {
  display: inline-block;
  margin-top: 6px;
  color: #7f1d1d;
  font-size: 13px;
  line-height: 1.5;
}

.my-app-douyin-link {
  word-break: break-all;
  color: #7a4b2a;
  font-size: 13px;
}

.my-app-row {
  align-items: flex-start;
}

@media (max-width: 720px) {
  .nav {
    flex-wrap: wrap;
    row-gap: 8px;
  }
}

.hero {
  width: min(1120px, 92%);
  margin: 0 auto;
  text-align: center;
  padding: 72px 0 88px;
}

.hero-title {
  margin: 0;
  font-size: clamp(36px, 7vw, 72px);
  letter-spacing: 4px;
}

.hero-desc {
  margin: 24px auto 0;
  max-width: 720px;
  font-size: clamp(16px, 2.4vw, 20px);
  color: var(--muted);
  line-height: 1.75;
  text-align: center;
}

.hero-desc p {
  margin: 0;
}

.hero-desc p + p {
  margin-top: 1.15em;
}

.hero-desc-legal {
  font-size: clamp(14px, 2vw, 17px);
  color: #5a524a;
  padding-top: 0.25em;
  border-top: 1px dashed var(--border);
}

.hero-actions {
  margin-top: 40px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  font-size: 15px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
}

.btn:hover {
  transform: translateY(-1px);
}

.section {
  width: min(1120px, 92%);
  margin: 28px auto 56px;
}

.section-title {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
}

.section-desc {
  color: var(--muted);
  margin-top: 12px;
}

.book-filter-form {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
}

.book-filter-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.book-filter-form select {
  min-width: 110px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 10px;
  font-family: inherit;
}

.book-filter-btn,
.book-filter-reset {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.book-filter-reset {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.pager {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pager-info {
  font-size: 13px;
  color: var(--muted);
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 12px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}

.pager-btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.tabs {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* 书卡列表：不用 1fr，避免只有 1 本书时整行被撑满 */
.grid {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: stretch;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 18px;
  box-shadow: 0 6px 18px rgba(30, 22, 10, 0.04);
}

.rank {
  font-size: 22px;
  font-weight: 700;
  color: #8c3e18;
}

.book-title {
  margin: 10px 0 6px;
  font-size: 19px;
}

.book-meta {
  color: var(--muted);
  font-size: 14px;
}

.book-link {
  display: flex;
  flex: 0 0 232px;
  width: 232px;
  max-width: 100%;
}

@media (max-width: 520px) {
  .book-link {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* 带封面的书卡（首页 / 书库 / 排行榜） */
.book-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.book-link:hover .book-card {
  box-shadow: 0 10px 28px rgba(30, 22, 10, 0.08);
  transform: translateY(-2px);
}

.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #e8e0d6;
  border-bottom: 1px solid var(--border);
}

.book-cover--placeholder {
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 2px;
  background: linear-gradient(145deg, #3d3429, #6b5a48);
}

.book-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 134px;
}

.book-card .book-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: calc(1.35em * 2);
}

.book-card .rank {
  margin: 0;
}

.book-summary {
  margin: auto 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: calc(1.55em * 2);
}

.book-card .book-meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.45em;
}

/* 排行榜（Top10） */
.ranking-board {
  margin-top: 20px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.ranking-item {
  display: grid;
  grid-template-columns: 52px 54px 1fr;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
}

.ranking-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(30, 22, 10, 0.08);
}

.ranking-item.is-top {
  border-color: #facc15;
  background: linear-gradient(90deg, #fffdf5 0%, #ffffff 70%);
}

.ranking-rank {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: #8c3e18;
}

.ranking-cover-wrap {
  width: 54px;
}

.ranking-cover {
  width: 54px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #e8e0d6;
}

.ranking-cover--placeholder {
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #3d3429, #6b5a48);
}

.ranking-main {
  min-width: 0;
}

.ranking-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.ranking-summary {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}

.detail-wrap {
  width: min(1120px, 92%);
  margin: 18px auto 56px;
}

.crumb {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: start;
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(30, 22, 10, 0.04);
}

.cover {
  border-radius: 12px;
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  max-height: 290px;
  background: linear-gradient(145deg, #372e23, #6e5b42);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #ede5da;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 28px;
  letter-spacing: 2px;
}

.detail-title {
  margin: 0;
  font-size: clamp(30px, 4vw, 42px);
}

.meta-row {
  margin-top: 10px;
  color: var(--muted);
}

.intro {
  margin-top: 16px;
  line-height: 1.8;
}

.intro.is-collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.intro-toggle {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: #7a4b2a;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.intro-toggle:hover {
  text-decoration: underline;
}

.detail-actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.apply-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(22, 17, 12, 0.46);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 18px;
}

.apply-modal {
  width: min(560px, 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(30, 22, 10, 0.22);
  padding: 18px;
}

.apply-modal-title {
  margin: 0 0 12px;
  font-size: 24px;
}

.apply-modal-hint {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.apply-modal-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: #fef2f2;
  border: 1px solid #f5c4c4;
  color: #991b1b;
}

.detail-notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.detail-notice--pending {
  background: #fff8e6;
  border: 1px solid #f0d9a8;
  color: #6b4f1d;
}

.detail-notice--reject {
  background: #fef2f2;
  border: 1px solid #f5c4c4;
  color: #7f1d1d;
}

.apply-modal-form p {
  margin: 10px 0;
}

.apply-modal-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.apply-modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.hidden {
  display: none !important;
}

.chapter-list {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  padding: 12px 18px;
}

.chapter-item {
  padding: 14px 4px;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.chapter-item:last-child {
  border-bottom: none;
}

.chapter-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.8;
}

/* 试读：章节末尾文字渐隐（与章节卡片背景衔接） */
.chapter-preview-fade {
  position: relative;
  margin: 0;
}

.chapter-preview-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.8;
}

.chapter-preview-fade-mask {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5.5em;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--card) 55%, transparent) 42%,
    var(--card) 100%
  );
}

.foot {
  width: min(1120px, 92%);
  margin: auto auto 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar--with-search {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    justify-items: stretch;
  }

  .topbar--with-search .site-search {
    justify-self: stretch;
    max-width: none;
    order: 2;
  }

  .topbar--with-search .brand {
    order: 1;
  }

  .topbar--with-search .nav--topbar {
    order: 3;
    justify-self: stretch;
    flex-wrap: wrap;
    gap: 12px 18px;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .topbar {
    margin-top: 20px;
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .cover {
    height: 240px;
  }
}
