:root {
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #e5e5ea;
  --fill: #f5f5f7;
  --paper: #ffffff;
  --brand: #c8382e;
  --brand-soft: #fbeceb;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.6;
}
a { color: inherit; }
button { font: inherit; }
.hidden { display: none !important; }

.bs-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.bs-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.bs-mark {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 18px;
}
.bs-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.bs-brand-text strong { font-size: 15px; }
.bs-brand-text span { font-size: 12px; color: var(--muted); }
.bs-nav { display: flex; gap: 6px; flex: 0 0 auto; }
.bs-link {
  text-decoration: none; font-size: 14px; color: var(--ink-2);
  padding: 7px 12px; border-radius: 999px;
}
.bs-link:hover { background: var(--fill); }

.bs-main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }
.bs-loading, .bs-empty { color: var(--muted); text-align: center; padding: 64px 0; }

.bs-hero { padding: 28px 0 24px; }
.bs-kicker { margin: 0 0 6px; font-size: 13px; letter-spacing: .08em; color: var(--brand); }
.bs-hero h1 { margin: 0; font-size: clamp(26px, 5vw, 40px); line-height: 1.2; letter-spacing: -.01em; }
.bs-hero p { margin: 12px 0 0; max-width: 620px; color: var(--ink-2); font-size: 16px; }
.bs-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.bs-steps li { font-size: 13px; color: var(--ink-2); background: var(--fill); padding: 6px 12px; border-radius: 999px; }

.bs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; margin-top: 12px; }
.bs-card {
  display: flex; flex-direction: column; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bs-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .08); }
.bs-cover {
  position: relative; aspect-ratio: 3 / 4; display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px; color: #fff; overflow: hidden;
}
.bs-cover::after {
  content: ""; position: absolute; inset: auto -20% -30% auto; width: 80%; aspect-ratio: 1;
  border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.bs-cover-mark { font-size: 64px; font-weight: 700; line-height: 1; }
.bs-cover-title { position: relative; z-index: 1; font-size: 17px; font-weight: 700; line-height: 1.35; }
.bs-cover-author { position: relative; z-index: 1; font-size: 12px; opacity: .82; margin-top: 6px; }
.bs-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.bs-card-body h2 { margin: 0; font-size: 16px; line-height: 1.4; }
.bs-meta { font-size: 13px; color: var(--muted); }
.bs-price-row { margin-top: auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 6px; }
.bs-price { font-size: 18px; font-weight: 700; white-space: nowrap; }
.bs-list-price { font-size: 13px; color: var(--faint); text-decoration: line-through; margin-left: 6px; font-weight: 400; }
.bs-tag { font-size: 12px; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.bs-tag.owned { color: var(--ink); background: var(--fill); }

.bs-detail { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 32px; align-items: start; }
.bs-detail .bs-cover { border-radius: var(--radius); }
.bs-detail h1 { margin: 0; font-size: clamp(24px, 4vw, 32px); line-height: 1.25; }
.bs-subtitle { margin: 6px 0 0; color: var(--ink-2); }
.bs-summary { margin: 16px 0 0; color: var(--ink-2); font-size: 16px; }
.bs-highlights { margin: 14px 0 0; padding-left: 1.2em; color: var(--ink-2); }
.bs-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.bs-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font-size: 15px;
}
.bs-btn:hover { background: var(--fill); }
.bs-btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.bs-btn.primary:hover { background: #000; }
.bs-btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.bs-btn[disabled] { opacity: .5; cursor: default; }
.bs-pending { margin-top: 12px; font-size: 14px; color: var(--ink-2); background: var(--fill); padding: 10px 14px; border-radius: 10px; }

.bs-toc { margin-top: 36px; border-top: 1px solid var(--line); }
.bs-toc h2 { font-size: 17px; margin: 22px 0 8px; }
.bs-toc ol { list-style: none; margin: 0; padding: 0; }
.bs-toc li a, .bs-toc li .bs-toc-locked {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.bs-toc-title { font-size: 15px; }
.bs-toc-sum { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.bs-toc-locked { color: var(--faint); cursor: pointer; }
.bs-lock { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* Reader */
.bs-reader-bar {
  position: sticky; top: 55px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 720px; margin: 0 auto; padding: 8px 0; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.bs-reader-bar a { text-decoration: none; color: var(--ink-2); }
.bs-reader-bar .bs-crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bs-article {
  position: relative; max-width: 720px; margin: 0 auto; padding: 28px 0 24px;
  font-size: 17px; line-height: 1.9; color: var(--ink);
  -webkit-touch-callout: none;
}
.bs-article h1 { font-size: 26px; line-height: 1.35; margin: 0 0 6px; }
.bs-article .bs-chapter-sum { color: var(--muted); margin: 0 0 24px; font-size: 15px; }
.bs-article h2 { font-size: 20px; margin: 32px 0 10px; }
.bs-article h3 { font-size: 17px; margin: 24px 0 8px; }
.bs-article p { margin: 0 0 14px; }
.bs-article blockquote { margin: 18px 0; padding: 10px 16px; border-left: 3px solid var(--brand); background: var(--fill); border-radius: 0 10px 10px 0; color: var(--ink-2); }
.bs-article ul, .bs-article ol { padding-left: 1.4em; margin: 0 0 14px; }
.bs-article table { border-collapse: collapse; margin: 14px 0; font-size: 15px; display: block; overflow-x: auto; }
.bs-article th, .bs-article td { border: 1px solid var(--line); padding: 6px 10px; }
.bs-article img { max-width: 100%; height: auto; }
.bs-article .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.bs-watermark {
  pointer-events: none; position: absolute; inset: 0; z-index: 2;
  background-repeat: repeat; opacity: .07;
}
.bs-pager { max-width: 720px; margin: 8px auto 0; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bs-ask {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.bs-locked-box { max-width: 560px; margin: 48px auto; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 24px; }
.bs-locked-box h2 { margin: 0 0 8px; font-size: 20px; }
.bs-locked-box p { color: var(--ink-2); margin: 0 0 18px; }

.bs-dialog { border: none; border-radius: 18px; padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.bs-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.bs-dialog-body { padding: 22px; }
.bs-dialog h2 { margin: 0 0 6px; font-size: 19px; }
.bs-buy-book { margin: 0 0 14px; color: var(--ink-2); }
.bs-providers { display: grid; gap: 8px; }
.bs-provider { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.bs-provider:has(input:checked) { border-color: var(--ink); }
.bs-provider small { display: block; color: var(--muted); font-size: 12px; }
.bs-note { font-size: 13px; color: var(--muted); margin: 12px 0 0; min-height: 1em; }
.bs-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.bs-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
}

@media (max-width: 720px) {
  .bs-main { padding-top: 16px; }
  .bs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .bs-cover { padding: 14px; }
  .bs-cover-mark { font-size: 46px; }
  .bs-cover-title { font-size: 15px; }
  .bs-detail { grid-template-columns: 1fr; gap: 20px; }
  .bs-detail .bs-cover { max-width: 200px; }
  .bs-article { font-size: 17px; padding-top: 20px; }
  .bs-brand-text span { display: none; }
}
@media (max-width: 380px) { .bs-grid { grid-template-columns: 1fr; } }
@media print { .bs-article { display: none; } body::after { content: "本书仅供在线阅读。"; } }

/* Page books */
.bs-cover-img { padding: 0; }
.bs-cover-img::after { display: none; }
.bs-cover-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bs-reader-bar-wide { max-width: 860px; }
.bs-mode { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; flex: 0 0 auto; }
.bs-mode button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.bs-mode button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.bs-chapter-head { max-width: 860px; margin: 0 auto; padding: 20px 0 8px; }
.bs-chapter-head h1 { margin: 0; font-size: 24px; line-height: 1.35; }
.bs-chapter-head .bs-chapter-sum { margin: 4px 0 0; color: var(--muted); }
.bs-pages { max-width: 860px; margin: 0 auto; display: grid; gap: 16px; padding: 8px 0 24px; }
.bs-page { position: relative; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.bs-page img { display: block; width: 100%; height: auto; aspect-ratio: 1048 / 1475; background: var(--fill); -webkit-user-drag: none; user-select: none; }
.bs-page figcaption { position: absolute; right: 10px; bottom: 6px; font-size: 11px; color: var(--faint); }
.bs-page-error img { aspect-ratio: auto; min-height: 120px; }
.bs-text-view { max-width: 720px; }
.bs-text-note { font-size: 13px; color: var(--muted); background: var(--fill); padding: 8px 12px; border-radius: 10px; }
.bs-text-page { padding: 6px 0 10px; border-bottom: 1px dashed var(--line); }
.bs-text-pno { font-size: 12px; color: var(--faint); margin: 8px 0; }
.bs-text-page p { margin: 0 0 10px; text-indent: 0; }
@media (max-width: 720px) { .bs-pages { gap: 10px; } .bs-page { border-radius: 4px; } .bs-chapter-head h1 { font-size: 21px; } }
