/* ==========================================================================
   人生必看书籍 — 站点样式（全站唯一 CSS）
   设计方向：暖白纸质底 / 衬线标题 / 低饱和砖红点缀 / 大留白 / 轻边框
   结构说明：
     - 首页 index.html 的卡片由 app.js 依据 data/books.js 生成；
     - 详情页 <id>.html 为纯静态 HTML，「推荐书籍」位于主内容之后（页面底部），
       由 assets/js/book-sidebar.js 随机填充为 4 本封面，窄屏下可横向滑动；
     - 桌面与移动端共用单栏布局，仅调整列数、字号与首屏信息密度。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计 Tokens
   -------------------------------------------------------------------------- */
:root {
  /* 颜色：整体比旧版更冷一点的白，边框与文字对比更柔和 */
  --bg: #f7f6f2;
  --bg-soft: #f1efe9;
  --paper: #fffefb;
  --ink: #2f2b26;
  --ink-soft: #5b564f;
  --ink-faint: #979085;
  --line: #eae7df;
  --line-strong: #dcd7cb;
  --accent: #a9573c;
  --accent-deep: #8b4229;
  --accent-soft: #f6ece6;
  --accent-tint: #fbf5f1;
  --accent-faint: #c2895f;
  --danger: #a63a2a;
  --danger-soft: #faece8;
  --danger-line: #e8cbc2;

  /* 间距 */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 56px;

  /* 圆角 */
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --radius-pill: 999px;

  /* 阴影：更淡的双层投影，避免厚重 */
  --shadow-card: 0 1px 2px rgba(47, 40, 30, .04), 0 6px 16px rgba(47, 40, 30, .05);
  --shadow-lift: 0 16px 34px rgba(47, 40, 30, .10), 0 4px 10px rgba(47, 40, 30, .05);

  /* 字体 */
  --font-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", SimSun, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  /* 布局 */
  --page-width: 1140px;
  --reading-width: 960px;
  --gutter: clamp(16px, 4vw, 32px);
  --tap: 44px;
}

/* --------------------------------------------------------------------------
   2. 基础
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink);
  background-color: var(--bg);
  /* 移动端不使用 fixed 背景，避免 iOS 滚动抖动 */
  background-image: linear-gradient(180deg, #fbfaf7 0%, var(--bg) 42%, #f2f0e9 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

img { display: block; max-width: 100%; }

a { color: var(--accent-deep); }

button, input { font: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-deep); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

[hidden] { display: none !important; }

main { flex: 1 0 auto; }

.container {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3. 页头（品牌 / 搜索 / 返回书单）
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(250, 249, 245, .88);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

.header-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  min-height: 64px;
  padding-block: 11px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1;
  color: #fffaf5;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .26), 0 2px 8px rgba(139, 66, 41, .22);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}

/* 返回书单（详情页） */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 8px 18px;
  font-size: .88rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.back-link:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-tint);
}

/* --------------------------------------------------------------------------
   4. 按钮
   -------------------------------------------------------------------------- */
.btn { cursor: pointer; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 9px 20px;
  font-size: .9rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  transition: color .2s ease, border-color .2s ease, transform .18s ease, box-shadow .2s ease;
}

.btn-ghost:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-tint);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.btn-ghost:active { transform: translateY(0); }

.btn-icon { font-size: 1.02rem; line-height: 1; }

/* --------------------------------------------------------------------------
   5. 首页：引导区 / 列表工具条 / 消息区 / 网格
   -------------------------------------------------------------------------- */
.page-intro { padding: clamp(32px, 5.5vw, 64px) 0 clamp(24px, 3.6vw, 40px); }

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4.2vw, 2.75rem);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: .015em;
}

.page-lead {
  max-width: 38em;
  margin-top: var(--space-sm);
  font-size: 1rem;
  line-height: 1.95;
  color: var(--ink-soft);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.list-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.list-title::before {
  content: "";
  flex: none;
  width: 3px;
  height: 1.05em;
  border-radius: 2px;
  background: var(--accent);
}

/* 书籍网格：桌面 4 列，逐级降到 3 / 2 列 */
.book-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(14px, 1.6vw, 22px);
  margin-top: clamp(20px, 3vw, 30px);
  transition: opacity .3s ease, transform .3s ease;
}

/* 「换一批」时的过渡态 */
.book-grid.is-refreshing {
  opacity: .18;
  transform: translateY(8px);
}

/* 首页随机书单一次最多展示 4 行：桌面 4 列 × 4 行 = 16 本（移动端 2 列 × 4 行 = 8 本，见 720px 媒体查询） */
.book-grid .book-card:nth-child(n + 17) {
  display: none;
}

/* --------------------------------------------------------------------------
   6. 书籍卡片
   -------------------------------------------------------------------------- */
.book-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px 13px 15px;
  color: inherit;
  text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  transition: transform .28s cubic-bezier(.22, .61, .36, 1), box-shadow .28s ease, border-color .28s ease;
  animation: card-in .5s cubic-bezier(.22, .61, .36, 1) both;
  /* 50 张卡片时封顶，避免最后一张等太久才出现 */
  animation-delay: min(calc(var(--i, 0) * 40ms), 360ms);
}

.book-card:active { transform: translateY(-2px); }

.book-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 封面（首页卡片 / 详情页共用） */
.book-cover,
.detail-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--bg-soft);
  container-type: inline-size;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.22, .61, .36, 1);
}

/* 设计版文字封面（图片缺失 / 加载失败时显示） */
.cover-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 16px 16px;
  text-align: center;
  background-color: var(--cover-accent, var(--accent));
  background-image:
    radial-gradient(120% 78% at 84% 4%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 62%),
    linear-gradient(168deg,
      color-mix(in srgb, var(--cover-accent, var(--accent)) 86%, #ffffff) 0%,
      var(--cover-accent, var(--accent)) 52%,
      color-mix(in srgb, var(--cover-accent, var(--accent)) 58%, #17110a) 100%);
}

.cover-fallback::before {
  content: "";
  flex: none;
  width: 26px;
  height: 1px;
  background: rgba(255, 250, 240, .5);
}

.cover-fallback-title {
  writing-mode: vertical-rl;
  max-height: 70%;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(16px, 10.5cqw, 30px);
  line-height: 1.15;
  letter-spacing: .16em;
  color: #fdfaf3;
  text-shadow: 0 1px 2px rgba(28, 18, 8, .4), 0 3px 14px rgba(28, 18, 8, .22);
}

.cover-fallback-author {
  max-width: 88%;
  padding-top: 8px;
  font-size: clamp(10px, 3.6cqw, 13px);
  letter-spacing: .06em;
  color: rgba(255, 250, 240, .84);
  border-top: 1px solid rgba(255, 250, 240, .3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图片加载失败：隐藏图片、显示文字封面 */
.book-cover.img-error .cover-img,
.detail-cover.img-error .cover-img { display: none; }

.book-cover.img-error .cover-fallback,
.detail-cover.img-error .cover-fallback { display: flex; }

/* 未渲染 <img> 时同样兜底显示文字封面 */
.book-cover:not(:has(.cover-img)) .cover-fallback,
.detail-cover:not(:has(.cover-img)) .cover-fallback { display: flex; }

/* 卡片文字信息 */
.book-meta {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  padding: 0 2px;
}

.book-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-family: var(--font-serif);
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .01em;
}

.book-author {
  font-size: .8rem;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-rating {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.score {
  font-family: var(--font-serif);
  font-size: 1.16rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.rating-label {
  font-size: .74rem;
  letter-spacing: .08em;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   7. 详情页：单栏布局，「推荐书籍」位于主内容之后
   -------------------------------------------------------------------------- */
.detail-layout {
  display: grid;
  justify-items: center;
  gap: clamp(40px, 6vw, 68px);
  padding-top: clamp(24px, 3.6vw, 44px);
}

.detail-main {
  width: 100%;
  min-width: 0;
  max-width: var(--reading-width);
}

/* 底部推荐书籍：一排封面，放不下时横向滑动 */
.book-sidebar {
  width: 100%;
  min-width: 0; /* 否则封面滑轨的固有宽度会撑破窄屏网格轨道 */
  max-width: var(--reading-width);
  padding: clamp(18px, 2.6vw, 26px) clamp(16px, 2.6vw, 24px) clamp(20px, 2.8vw, 28px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}

.sidebar-heading {
  padding: 0 2px 12px;
  font-family: var(--font-serif);
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

/* 推荐书籍：少量封面，容器放不下时横向滑动 */
.sidebar-list {
  display: flex;
  justify-content: space-between;
  gap: clamp(12px, 2.2vw, 20px);
  margin-top: 18px;
  padding: 2px 3px 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sidebar-list::-webkit-scrollbar { display: none; }

.sidebar-link {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
  width: clamp(110px, 25vw, 184px);
  scroll-snap-align: start;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-decoration: none;
}

.sidebar-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 小封面：复用首页 .book-cover 基础结构 */
.sidebar-cover {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease;
}

/* 文字封面在小尺寸下改成横排，避免竖排书名被裁切 */
.sidebar-cover .cover-fallback {
  gap: 5px;
  padding: 8px 7px;
}

.sidebar-cover .cover-fallback::before { display: none; }

.sidebar-cover .cover-fallback-title {
  max-height: none;
  font-size: clamp(11px, 15cqw, 15px);
  line-height: 1.35;
  letter-spacing: .04em;
  writing-mode: horizontal-tb;
}

.sidebar-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-align: center;
}

/* --------------------------------------------------------------------------
   8. 详情页：头部信息
   -------------------------------------------------------------------------- */
.detail-hero {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 44px);
  align-items: start;
}

.detail-cover {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

.detail-info { min-width: 0; }

.detail-title {
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 3.4vw, 2.3rem);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: .015em;
}

.detail-en {
  margin-top: 6px;
  font-size: .93rem;
  font-style: italic;
  color: var(--ink-faint);
}

.detail-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 30px;
  margin-top: var(--space-md);
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 84px;
}

.fact-label {
  font-size: .74rem;
  letter-spacing: .1em;
  color: var(--ink-faint);
}

.fact-value {
  font-size: .95rem;
  line-height: 1.5;
  color: var(--ink);
}

.detail-intro {
  margin-top: var(--space-md);
  font-size: 1rem;
  line-height: 2;
  color: var(--ink-soft);
  text-align: justify;
}

/* 简介「展开 / 收起」按钮：默认隐藏，仅在移动端且简介溢出两行时由 JS 显示 */
.detail-intro-toggle {
  display: none;
  margin-top: 6px;
  padding: 6px 2px;
  font-size: .88rem;
  letter-spacing: .04em;
  color: var(--accent-deep);
  background: none;
  border: 0;
  cursor: pointer;
}

.detail-intro-toggle:active { color: var(--accent); }

/* --------------------------------------------------------------------------
   9. 详情页：「五分钟看懂这本书」框架模块（网站特色）
   -------------------------------------------------------------------------- */
.framework-section {
  margin-top: clamp(40px, 5.6vw, 68px);
  padding-top: clamp(26px, 3.6vw, 40px);
  border-top: 1px solid var(--line);
}

.framework-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.32rem, 2.4vw, 1.68rem);
  font-weight: 600;
  letter-spacing: .03em;
}

.framework-heading::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.framework-heading::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), rgba(220, 215, 203, 0));
}

/* 一句话速览（引文式） */
.framework-tagline {
  margin-top: var(--space-md);
  padding: 18px 22px;
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 1.8vw, 1.24rem);
  line-height: 1.8;
  color: var(--ink);
  background: linear-gradient(90deg, var(--accent-soft), rgba(246, 236, 230, .28));
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
}

/* 核心思想 */
.framework-core {
  position: relative;
  margin-top: var(--space-md);
  padding-left: 18px;
  font-size: 1.01rem;
  line-height: 2.05;
  color: var(--ink-soft);
  text-align: justify;
}

.framework-core::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  bottom: .55em;
  width: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}

/* 各内容区块容器 */
.framework-blocks {
  display: grid;
  gap: clamp(26px, 3.4vw, 38px);
  margin-top: clamp(28px, 3.6vw, 42px);
}

.fb-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-family: var(--font-serif);
  font-size: 1.13rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.fb-title::before {
  content: "";
  flex: none;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.fb-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

.fb-item-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
}

.fb-item-text {
  margin-top: 5px;
  font-size: .91rem;
  line-height: 1.9;
  color: var(--ink-soft);
}

/* 概念卡（ideas） */
.fb-ideas .fb-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 14px;
}

.fb-ideas .fb-item {
  padding: 17px 19px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: 0 1px 2px rgba(47, 40, 30, .04);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.fb-ideas .fb-item-title::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 8px;
  vertical-align: 2px;
  border-radius: 50%;
  background: var(--accent-faint);
}

/* 编号脉络（chapters） */
.fb-chapters .fb-items {
  display: grid;
  gap: 20px;
  margin-left: 4px;
  padding-left: 52px;
  border-left: 1px solid var(--line);
  counter-reset: fb-chapter;
}

.fb-chapters .fb-item {
  position: relative;
  counter-increment: fb-chapter;
}

.fb-chapters .fb-item::before {
  content: counter(fb-chapter, decimal-leading-zero);
  position: absolute;
  left: -52px;
  top: 1px;
  width: 38px;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-faint);
}

/* 流程 / 时间线（flow） */
.fb-flow .fb-items { display: grid; }

.fb-flow .fb-item {
  position: relative;
  padding: 0 0 22px 30px;
}

.fb-flow .fb-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent-faint);
  border-radius: 50%;
  background: var(--paper);
}

.fb-flow .fb-item::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 21px;
  bottom: 0;
  width: 1px;
  background: var(--line-strong);
}

.fb-flow .fb-item:last-child { padding-bottom: 2px; }
.fb-flow .fb-item:last-child::after { display: none; }

/* 金句（quotes） */
.fb-quotes .fb-items { display: grid; gap: 14px; }

.fb-quote {
  position: relative;
  padding: 4px 6px 4px 50px;
  font-family: var(--font-serif);
  font-size: clamp(.98rem, 1.5vw, 1.08rem);
  line-height: 1.9;
  color: var(--ink);
}

.fb-quote::before {
  content: "\201C";
  position: absolute;
  left: 6px;
  top: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  line-height: 1.15;
  color: var(--accent-faint);
  opacity: .55;
}

/* 适合谁读（audience） */
.fb-audience .fb-items { display: grid; gap: 11px; }

.fb-audience-item {
  position: relative;
  padding-left: 25px;
  font-size: .94rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

.fb-audience-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: .72em;
  width: 7px;
  height: 7px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-faint);
  border-radius: 2px;
  transform: rotate(45deg);
}

/* 框架内容缺失时的提示 */
.framework-empty {
  margin-top: var(--space-lg);
  padding: clamp(28px, 5vw, 44px) 24px;
  font-size: .96rem;
  text-align: center;
  color: var(--ink-faint);
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-l);
}

/* --------------------------------------------------------------------------
   10. 页脚
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: clamp(44px, 6.5vw, 80px);
  background: rgba(255, 254, 251, .58);
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  /* 只设置上下内边距，左右留给 .container 的 padding-inline（gutter），避免被重置为 0 */
  padding-block: 24px calc(26px + env(safe-area-inset-bottom, 0px));
  font-size: .86rem;
  color: var(--ink-faint);
}

.footer-brand {
  font-family: var(--font-serif);
  letter-spacing: .06em;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   11. 悬停效果：只在真正有指针的设备上生效，避免移动端「粘住」的 hover 态
   -------------------------------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
  .book-card:hover {
    transform: translateY(-5px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lift);
  }

  .book-card:hover .cover-img { transform: scale(1.04); }

  .sidebar-link:hover .sidebar-cover {
    transform: translateY(-4px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lift);
  }

  .sidebar-link:hover .sidebar-name { color: var(--accent-deep); }

  .fb-ideas .fb-item:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-card);
  }
}

/* --------------------------------------------------------------------------
   12. 响应式
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* 3 列下保持 4 行：最多展示 12 本 */
  .book-grid .book-card:nth-child(n + 13) { display: none; }
}

@media (max-width: 720px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* 移动端首页随机书单最多展示 4 行（2 列 × 4 行 = 8 本） */
  .book-grid .book-card:nth-child(n + 9) { display: none; }

  /* 详情页首屏：封面缩小后左浮，书名与基本信息绕着封面排，
     简介从封面下方起用满整行宽度，避免正文被挤成窄条 */
  .detail-hero { display: block; }

  .detail-cover {
    float: left;
    width: 104px;
    margin: 0 16px 12px 0;
  }

  .detail-title { font-size: 1.34rem; }
  .detail-en { margin-top: 4px; font-size: .82rem; }

  .detail-facts {
    gap: 10px 20px;
    margin-top: 14px;
    padding: 12px 0;
  }

  .fact { min-width: 68px; }
  .fact-value { font-size: .9rem; }

  .detail-intro {
    clear: both;
    margin-top: 14px;
    font-size: .95rem;
    line-height: 1.85;
  }

  /* 简介默认收缩为两行，点击「展开全文」后恢复完整高度 */
  .detail-intro:not(.is-expanded) {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  .detail-intro-toggle:not([hidden]) { display: inline-block; }

  .framework-section { margin-top: 36px; padding-top: 24px; }
  .framework-tagline { padding: 14px 16px; line-height: 1.75; }
  .framework-core { padding-left: 14px; line-height: 1.95; }
  .fb-title { margin-bottom: 14px; font-size: 1.06rem; }
}

@media (max-width: 560px) {
  .header-inner { padding-block: 8px 10px; }

  .page-intro { padding: 24px 0 20px; }
  .page-lead { font-size: .95rem; line-height: 1.85; }
  .list-toolbar { padding-bottom: 14px; }
  .list-title { font-size: 1.1rem; }

  .book-card { gap: 10px; padding: 10px 10px 13px; border-radius: var(--radius-m); }
  .book-name { font-size: .98rem; }
  .book-author { font-size: .76rem; }
  .score { font-size: 1.08rem; }

  .btn-ghost, .back-link { min-height: var(--tap); }

  .fb-chapters .fb-items { padding-left: 42px; }
  .fb-chapters .fb-item::before { left: -42px; width: 32px; font-size: .92rem; }
  .fb-flow .fb-item { padding-left: 26px; }
  .fb-flow .fb-item::after { left: 6px; }
  .fb-quote { padding-left: 36px; }
  .fb-quote::before { left: 0; font-size: 2rem; }
  .fb-audience-item { padding-left: 22px; font-size: .92rem; }
}

/* 超窄屏（≤360px）：首屏改成封面居上的两行结构 */
@media (max-width: 360px) {
  .detail-cover { float: none; width: 112px; margin-bottom: 14px; }
  .book-grid { gap: 10px; }
}

/* --------------------------------------------------------------------------
   13. 减少动画偏好
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .book-card {
    animation: none !important;
    animation-delay: 0s !important;
  }

  .book-grid,
  .book-card,
  .cover-img,
  .btn-ghost,
  .back-link,
  .sidebar-cover,
  .fb-ideas .fb-item {
    transition: none !important;
  }

  .book-card:hover,
  .book-card:active,
  .fb-ideas .fb-item:hover,
  .btn-ghost:hover { transform: none; }

  .sidebar-link:hover .sidebar-cover { transform: none; }

  .book-card:hover .cover-img { transform: none; }

  .book-grid.is-refreshing { transform: none; }
}

/* --------------------------------------------------------------------------
   14. 书籍总列表（SEO 静态链接，由 optimize_seo.py 注入，折叠展示）
   -------------------------------------------------------------------------- */
.book-index {
  margin: var(--space-lg) 0 var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
}

.book-index summary {
  cursor: pointer;
  font-size: .9rem;
  letter-spacing: .04em;
  color: var(--ink-faint);
  list-style: none;
  user-select: none;
}

.book-index summary::-webkit-details-marker { display: none; }

.book-index summary::before { content: "▸ "; }

.book-index[open] summary::before { content: "▾ "; }

.book-index-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.book-index-list a {
  font-size: .86rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.book-index-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   15. 首页右下角悬浮按钮（刷新随机书单 / 复制站长微信）
   -------------------------------------------------------------------------- */
.fab-stack {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: calc(clamp(14px, 3vw, 28px) + env(safe-area-inset-bottom, 0px));
  z-index: 40; /* 低于吸顶头部（50），滚动时被头部盖住而不是叠在上面 */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none; /* 容器透明区域不挡页面点击，按钮自身恢复可点 */
}

.fab-stack > * { pointer-events: auto; }

.fab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 9px 16px;
  font-size: .88rem;
  letter-spacing: .05em;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease,
    transform .18s ease, box-shadow .2s ease;
}

.fab:active { transform: translateY(1px); }

.fab .btn-icon { font-size: 1rem; line-height: 1; }

.fab-svg { flex: none; }

/* 复制成功后的短暂高亮态 */
.fab.is-copied {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.copy-toast {
  margin: 0;
  padding: 8px 14px;
  font-size: .82rem;
  letter-spacing: .02em;
  color: var(--accent-deep);
  background: var(--paper);
  border: 1px solid var(--accent);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-lift);
  animation: toast-in .22s ease both;
}

.copy-toast.is-error {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) and (pointer: fine) {
  .fab:hover {
    color: var(--accent-deep);
    border-color: var(--accent);
    background: var(--accent-tint);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lift);
  }
}

@media (max-width: 720px) {
  .fab-stack { gap: 8px; }
  .fab { padding: 8px 13px; font-size: .84rem; }
}

/* 首页存在右下角悬浮按钮：页脚底部留出按钮高度空间，避免滚动到底时遮挡页脚文字 */
body[data-page="home"] .footer-inner {
  padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-reduced-motion: reduce) {
  .fab,
  .copy-toast {
    transition: none !important;
    animation: none !important;
  }

  .fab:hover,
  .fab:active { transform: none; }
}
