/* ==========================================================================
   笔趣阁 · 免费小说阅读网
   设计方向：纸与墨 —— 编辑级排版 + 朱砂红书签细节
   ========================================================================== */

:root {
  color-scheme: light;

  /* 纸与墨 */
  --paper: oklch(0.968 0.008 84);
  --paper-2: oklch(0.988 0.005 84);
  --paper-3: oklch(0.935 0.012 84);
  --ink: oklch(0.24 0.012 60);
  --ink-2: oklch(0.44 0.014 60);
  --ink-3: oklch(0.6 0.012 60);
  --line: oklch(0.87 0.01 70);
  --line-soft: oklch(0.92 0.008 70);

  /* 朱砂 */
  --seal: oklch(0.54 0.165 28);
  --seal-2: oklch(0.62 0.15 30);
  --seal-soft: oklch(0.94 0.03 30);

  /* 辅助 */
  --jade: oklch(0.55 0.075 175);

  --shadow-sm: 0 1px 2px oklch(0.24 0.01 60 / 0.06), 0 2px 8px oklch(0.24 0.01 60 / 0.05);
  --shadow-md: 0 2px 6px oklch(0.24 0.01 60 / 0.07), 0 12px 28px -8px oklch(0.24 0.01 60 / 0.16);
  --shadow-lg: 0 6px 18px oklch(0.24 0.01 60 / 0.1), 0 30px 60px -20px oklch(0.24 0.01 60 / 0.24);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --w: 1180px;
  --header-h: 64px;

  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif CN", serif;
  --font-num: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

[data-theme='dark'] {
  color-scheme: dark;
  --paper: oklch(0.185 0.008 70);
  --paper-2: oklch(0.225 0.009 70);
  --paper-3: oklch(0.27 0.01 70);
  --ink: oklch(0.92 0.008 80);
  --ink-2: oklch(0.76 0.01 80);
  --ink-3: oklch(0.6 0.012 80);
  --line: oklch(0.33 0.01 70);
  --line-soft: oklch(0.29 0.008 70);
  --seal: oklch(0.68 0.14 30);
  --seal-2: oklch(0.72 0.13 32);
  --seal-soft: oklch(0.3 0.05 30);
  --jade: oklch(0.7 0.08 175);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 2px 8px oklch(0 0 0 / 0.36);
  --shadow-lg: 0 20px 48px -16px oklch(0 0 0 / 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 纸张纹理：极淡的斜纹，制造"纸"的触感 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: repeating-linear-gradient(
    112deg,
    color-mix(in oklch, var(--ink) 3%, transparent) 0 1px,
    transparent 1px 7px
  );
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

#importBox {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  outline: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
}
#importBox:focus {
  border-color: var(--seal);
}

::selection {
  background: color-mix(in oklch, var(--seal) 24%, transparent);
}

/* ------------------------------------------------------------------ 布局 */

.wrap {
  width: 100%;
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

.page {
  padding: 26px 0 80px;
  position: relative;
  z-index: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.muted {
  color: var(--ink-3);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ 页眉 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in oklch, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

/* 品牌图标：logo.png（朱红印章「笔」字），图片本身自带底色与圆角 */
.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex: none;
  display: block;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  border-left: 1px solid var(--line);
  padding-left: 9px;
  margin-left: 2px;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.site-nav a {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.site-nav a:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.site-nav a.active {
  color: var(--seal);
  background: var(--seal-soft);
  font-weight: 600;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s;
}

.icon-btn:hover {
  border-color: var(--seal-2);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.menu-toggle {
  display: none;
}

/* ------------------------------------------------------------------ 搜索框 */

.searchbar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 5px 5px 16px;
  min-width: 260px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.searchbar:focus-within {
  border-color: var(--seal-2);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--seal) 12%, transparent);
}

.searchbar input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  min-width: 0;
}

.searchbar input::placeholder {
  color: var(--ink-3);
}

.searchbar .go {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-2);
  padding: 8px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}

.searchbar .go:hover {
  background: var(--seal);
}

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s var(--ease), background 0.16s, border-color 0.16s, color 0.16s;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--ink-3);
}

.btn-primary {
  background: var(--seal);
  border-color: var(--seal);
  color: oklch(0.99 0 0);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--seal-2);
  border-color: var(--seal-2);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 6px 13px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ------------------------------------------------------------------ 书卡 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 24px 18px;
}

/* 发现页：卡片放大一号。
   默认 .grid 是 7 列（每张约 147px），书架那种书目够用；发现页是"挑书"场景，
   封面看不清就没有点击欲，所以单独放大到 5 列（每张约 210px）。 */
.grid-lg {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 30px 22px;
}

.grid-lg .card .c-title {
  font-size: 15.5px;
}

.grid-lg .card .c-meta {
  font-size: 12.5px;
}

/* 首页分类模块：一行 6 本（1140 容器下每本约 180px）。
   以前是 112px → 挤到 9 本一行，封面只剩指甲盖大，书名也两行都放不下。
   列数由 home.js 的 colsFor 同步计算，改这里必须同时改它。 */
.grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 12px;
}

.grid-sm .card {
  gap: 9px;
}

.grid-sm .card .cover {
  border-radius: 8px;
}

.grid-sm .card .c-title {
  font-size: 14px;
}

.grid-sm .card .c-meta {
  font-size: 12px;
}

/* 分类模块首行之外的书：纯文字列表，不显示封面图 */
.hlist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  margin-top: 18px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}

.hrow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 8px 6px;
  border-radius: var(--r-sm);
  transition: background 0.16s var(--ease);
}

.hrow:hover {
  background: var(--paper-2);
}

.hrow .hr-num {
  flex: none;
  width: 20px;
  font-size: 12px;
  color: var(--ink-3);
}

.hrow:hover .hr-num {
  color: var(--seal);
}

.hrow .hr-name {
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hrow .hr-sub {
  flex: none;
  max-width: 46%;
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
}

.card .cover {
  position: relative;
  /* 封面比例用 padding-top 百分比撑，**不要用 aspect-ratio**：
     .card 是 flex 列，宽度来自交叉轴 stretch，Chrome 无法据此反推 aspect-ratio 的高度，
     会把封面算成整张卡片那么高（实测 302px 而不是 240px），于是书名被顶出卡片、
     压到下面的内容上（就是"书名与下面内容重叠"）。
     padding-top 的百分比是按宽度算的，任何布局里都准。
     配套：封面内的 img / .fallback 必须绝对定位，否则会把这 0 高度的盒子撑开。 */
  width: 100%;
  height: 0;
  padding-top: 133.333%; /* 3 : 4 */
  flex: none;
  border-radius: var(--r);
  overflow: hidden;
  background: linear-gradient(160deg, var(--paper-3), var(--paper-2));
  box-shadow: var(--shadow-sm);
  transition: transform 0.32s var(--ease), box-shadow 0.32s var(--ease);
}

.card:hover .cover {
  transform: translateY(-4px) scale(1.012);
  box-shadow: var(--shadow-md);
}

.card .cover img {
  /* 绝对定位：封面盒子靠 padding-top 撑高（padding 区域不参与内容流），
     图片必须脱离文档流铺满它，否则会把盒子顶高 */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 兜底封面：绝对填充父容器。
   之前这条只写在 .card 下，导致换个容器（列表项 / 详情页 / 缩略图）兜底就错位 —— 
   封面必须在任何容器里表现一致，所以定位上提到通用规则。 */
.cover .fallback {
  position: absolute;
  inset: 0;
  z-index: 0; /* 兜底图始终在真图之下，见 .cover-img */
  place-items: center;
  padding: 8px;
  overflow: hidden;
  text-align: center;
  line-height: 1.3;
  color: var(--ink-3);
  font-family: var(--font-serif);
}

.card .cover .fallback {
  font-size: 26px;
}

/* 缩略封面（继续阅读 / 阅读历史）：与大封面同一套兜底与补图，只是尺寸小一号 */
.mini-cover {
  position: relative;
  display: block;
  flex: none;
  overflow: hidden;
  border-radius: 4px;
  background: var(--paper-3);
}

.mini-cover .fallback {
  padding: 2px;
  line-height: 1.25;
}

.card .c-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  /* 书名固定占 2 行高度（2 × 1.4em）：1 行的书也占满 2 行，
     同一行卡片的封面/文字基线就都对齐，不会因为书名长短一高一低。 */
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .c-meta {
  font-size: 12px;
  color: var(--ink-3);
  /* 同理固定 1 行：有的书没有作者/字数，缺了也不会让卡片矮一截 */
  min-height: 1.4em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--ink) 72%, transparent);
  color: var(--paper-2);
  backdrop-filter: blur(6px);
  letter-spacing: 0.02em;
}

/* 「新」角标：嵌在 seal 里，用 emphasis 色区分于名次本身 */
.tag-new {
  display: inline-block;
  padding: 0 4px;
  border-radius: 4px;
  background: oklch(0.99 0 0 / 0.9);
  color: var(--seal);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: 1px;
}

.card .badge.seal {
  background: color-mix(in oklch, var(--seal) 88%, transparent);
  color: oklch(0.99 0 0);
}

/* 列表行（搜索结果用） */
.list-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item .thumb {
  width: 92px;
  aspect-ratio: 3 / 4;
  flex: none;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--paper-3);
  position: relative;
}

.list-item .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item .li-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item .li-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
}

.list-item .li-intro {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------------ 芯片 */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}

.chip:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.chip.active {
  background: var(--seal);
  border-color: var(--seal);
  color: oklch(0.99 0 0);
  font-weight: 600;
}

.tag {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--paper-3);
  color: var(--ink-2);
  white-space: nowrap;
}

.tag.seal {
  background: var(--seal-soft);
  color: var(--seal);
}

/* ------------------------------------------------------------------ 章节标题语言 */

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 38px 0 16px;
}

.sec-head h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin: 0;
  letter-spacing: 0.02em;
}

.sec-head .hint {
  font-size: 12.5px;
  color: var(--ink-3);
}

.sec-head .more {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
}

.sec-head .more:hover {
  color: var(--seal);
}

/* 章节号（衬线数字） */
.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ 首页 Hero */

.hero {
  padding: 34px 0 10px;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 40px;
  align-items: center;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.22;
  margin: 0 0 14px;
  letter-spacing: 0.01em;
}

.hero h1 em {
  font-style: normal;
  color: var(--seal);
  position: relative;
}

.hero p.lead {
  color: var(--ink-2);
  font-size: 15px;
  margin: 0 0 22px;
  max-width: 46ch;
}

.hero-search {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-search .searchbar {
  flex: 1;
  min-width: 240px;
}

.hero-side {
  display: grid;
  gap: 12px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.stat-strip div {
  background: var(--paper-2);
  padding: 14px 12px;
  text-align: center;
}

.stat-strip b {
  display: block;
  font-family: var(--font-num);
  font-size: 22px;
  color: var(--seal);
}

.stat-strip span {
  font-size: 12px;
  color: var(--ink-3);
}

/* 横向滚动货架 */
.shelf-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.shelf-strip > * {
  scroll-snap-align: start;
}

.shelf-strip::-webkit-scrollbar {
  height: 6px;
}

.shelf-strip::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

/* 榜单（编辑风：数字 + 书名） */
.rank-list {
  display: grid;
  gap: 2px;
}

.rank-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 8px;
  border-radius: var(--r-sm);
  transition: background 0.16s;
}

.rank-item:hover {
  background: var(--paper-2);
}

.rank-item .idx {
  font-family: var(--font-num);
  font-size: 17px;
  color: var(--ink-3);
  text-align: center;
}

.rank-item.top .idx {
  color: var(--seal);
  font-weight: 700;
}

.rank-item .rk-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-item .rk-meta {
  font-size: 12px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ 详情页 */

.book-hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 22px 0 6px;
  position: relative;
}

.book-hero .bcover {
  aspect-ratio: 3 / 4;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--paper-3);
}

.book-hero .bcover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.4vw, 34px);
  margin: 2px 0 10px;
  letter-spacing: 0.01em;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--ink-2);
  font-size: 13.5px;
  margin-bottom: 14px;
}

.book-meta b {
  color: var(--ink);
  font-weight: 600;
}

.book-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
}

.intro-box {
  margin-top: 20px;
  padding: 18px 20px;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.85;
  white-space: pre-wrap;
  position: relative;
}

.intro-box::before {
  content: '简介';
  position: absolute;
  top: -10px;
  left: 18px;
  background: var(--seal);
  color: oklch(0.99 0 0);
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 2px 9px;
  border-radius: 4px;
}

.toc-panel {
  margin-top: 26px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  overflow: hidden;
}

.toc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.toc-bar input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 7px 14px;
  outline: 0;
  font-size: 13.5px;
}

.toc-bar input:focus {
  border-color: var(--seal-2);
}

.toc-list {
  max-height: 560px;
  overflow-y: auto;
  padding: 0;
}

/* 目录：3 列网格分组（《书名》最新章节 / 《书名》正文）。
   单元格之间用虚线分隔，整体像一张表格 —— 一屏能扫到几十章，
   比一行一章的列表找起来快得多。 */
.toc-grid-head {
  text-align: center;
  padding: 9px 16px;
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 13.5px;
  letter-spacing: 0.02em;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}

.toc-grid:first-child .toc-grid-head {
  border-top: 0;
}

.toc-grid-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toc-cell {
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px dashed var(--line-soft);
  border-right: 1px dashed var(--line-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-cell:nth-child(3n) {
  border-right: 0;
}

.toc-cell:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.toc-cell.reading {
  background: var(--seal-soft);
  color: var(--seal);
  font-weight: 600;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.toc-item:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.toc-item .ci {
  font-family: var(--font-num);
  font-size: 12.5px;
  color: var(--ink-3);
  width: 42px;
  flex: none;
  text-align: right;
}

.toc-item .cn {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-item .ct {
  font-size: 11.5px;
  color: var(--ink-3);
  flex: none;
}

.toc-item.reading {
  border-left-color: var(--seal);
  background: var(--seal-soft);
  color: var(--ink);
}

/* ------------------------------------------------------------------ 阅读器 */

.reader {
  --rd-bg: oklch(0.976 0.006 85);
  --rd-fg: oklch(0.24 0.012 60);
  --rd-size: 19px;
  --rd-lh: 1.95;
  --rd-measure: 40em;
  --rd-indent: 2em;
  min-height: 100vh;
  background: var(--rd-bg);
  color: var(--rd-fg);
}

.reader[data-rd-theme='sepia'] {
  --rd-bg: oklch(0.925 0.035 82);
  --rd-fg: oklch(0.28 0.02 60);
}
.reader[data-rd-theme='green'] {
  --rd-bg: oklch(0.94 0.022 140);
  --rd-fg: oklch(0.26 0.015 140);
}
.reader[data-rd-theme='dark'] {
  --rd-bg: oklch(0.17 0.008 70);
  --rd-fg: oklch(0.82 0.012 80);
}

.reader-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: color-mix(in oklch, var(--rd-bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in oklch, var(--rd-fg) 12%, transparent);
  color: var(--rd-fg);
}

.reader-bar .rb-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
}

.reader-bar button {
  border: 1px solid color-mix(in oklch, var(--rd-fg) 18%, transparent);
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
}

.reader-bar button:hover {
  border-color: color-mix(in oklch, var(--rd-fg) 42%, transparent);
}

.reader-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--seal);
  z-index: 60;
  width: 0;
  transition: width 0.1s linear;
}

.rd-wrap {
  max-width: var(--rd-measure);
  margin: 0 auto;
  padding: 34px 22px 120px;
  font-family: var(--reader-serif, var(--font-serif));
  font-size: var(--rd-size);
  line-height: var(--rd-lh);
  letter-spacing: 0.012em;
}

.rd-wrap[data-font='sans'] {
  font-family: var(--font-ui);
}

.rd-title {
  font-size: calc(var(--rd-size) * 1.28);
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
  position: relative;
  padding-left: 14px;
}

.rd-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 3px;
  border-radius: 2px;
  background: var(--seal);
}

.rd-sub {
  font-size: 12.5px;
  opacity: 0.55;
  margin-bottom: 26px;
  font-family: var(--font-ui);
}

.rd-body p {
  text-indent: var(--rd-indent);
  margin: 0 0 0.55em;
  text-align: justify;
  word-break: break-word;
}

.rd-body img {
  max-width: 100%;
  margin: 14px auto;
  border-radius: 6px;
}

/* 分页模式 */
.reader.paged .rd-wrap {
  padding-bottom: 40px;
}

.reader.paged .rd-body {
  column-width: var(--rd-measure);
  column-gap: 60px;
  height: calc(100vh - 200px);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.reader.paged .rd-body p {
  break-inside: avoid;
}

.rd-foot {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid color-mix(in oklch, var(--rd-fg) 14%, transparent);
  font-family: var(--font-ui);
}

.rd-foot button {
  flex: 1;
  padding: 13px;
  border-radius: var(--r);
  border: 1px solid color-mix(in oklch, var(--rd-fg) 18%, transparent);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.18s;
}

.rd-foot button:hover:not([disabled]) {
  background: color-mix(in oklch, var(--rd-fg) 8%, transparent);
}

.rd-foot button[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ------------------------------------------------- 阅读页：左侧章节栏 + 全屏 */

.reader-frame {
  display: flex;
  align-items: flex-start;
}

.rd-sidebar {
  flex: none;
  width: 280px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  background: var(--rd-bg);
  border-right: 1px solid color-mix(in oklch, var(--rd-fg) 12%, transparent);
  overflow: hidden;
  transition: width 0.24s var(--ease), border-color 0.24s var(--ease);
}

.rd-side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid color-mix(in oklch, var(--rd-fg) 10%, transparent);
}

.rd-side-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
}

.rd-side-head .muted {
  flex: 1;
}

.rd-side-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  width: 26px;
  height: 26px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.6;
}
.rd-side-close:hover {
  background: color-mix(in oklch, var(--rd-fg) 8%, transparent);
  opacity: 1;
}

.rd-side-search {
  padding: 10px 14px;
  border-bottom: 1px solid color-mix(in oklch, var(--rd-fg) 10%, transparent);
}
.rd-side-search input {
  width: 100%;
  border: 1px solid color-mix(in oklch, var(--rd-fg) 16%, transparent);
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  outline: 0;
  font-size: 13px;
  color: inherit;
}
.rd-side-search input::placeholder {
  color: color-mix(in oklch, var(--rd-fg) 42%, transparent);
}

.rd-side-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.rs-item {
  display: flex;
  gap: 10px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--rd-fg);
  font-family: var(--font-ui);
}
.rs-item:hover {
  background: color-mix(in oklch, var(--rd-fg) 7%, transparent);
}
.rs-item.reading {
  color: var(--seal);
  background: color-mix(in oklch, var(--seal) 12%, transparent);
  font-weight: 600;
}
.rs-num {
  flex: none;
  min-width: 2.6em;
  text-align: right;
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
}
.rs-item.reading .rs-num {
  opacity: 0.8;
}
.rs-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rd-main {
  flex: 1;
  min-width: 0;
}

/* 收起态：侧栏缩成 0 宽 */
.reader.sidebar-collapsed .rd-sidebar {
  width: 0;
  border-right-width: 0;
}

/* 全屏阅读：隐藏统一导航 / 左侧栏 / 工具条 */
.reader.fullscreen-read .site-header,
.reader.fullscreen-read .rd-sidebar,
.reader.fullscreen-read .reader-bar {
  display: none;
}
.reader.fullscreen-read .reader-frame {
  min-height: 100vh;
}

/* 窄屏：左侧栏隐藏（目录走抽屉） */
@media (max-width: 980px) {
  .rd-sidebar {
    display: none;
  }
}

/* 抽屉 / 弹层 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease);
  z-index: 70;
}

.drawer-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  z-index: 80;
  background: var(--paper-2);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  transition: transform 0.34s var(--ease);
}

.drawer.side {
  top: 0;
  left: 0;
  bottom: 0;
  width: min(420px, 88vw);
  transform: translateX(-102%);
  box-shadow: var(--shadow-lg);
}

.drawer.side.open {
  transform: none;
}

.drawer.bottom {
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  transform: translateY(102%);
  box-shadow: var(--shadow-lg);
  max-height: 76vh;
}

.drawer.bottom.open {
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head h3 {
  margin: 0;
  font-size: 15px;
  font-family: var(--font-serif);
  flex: 1;
}

.drawer-body {
  overflow-y: auto;
  padding: 14px 18px 26px;
}

.rd-setting {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line-soft);
}

.rd-setting:last-child {
  border-bottom: 0;
}

.rd-setting > span {
  font-size: 13px;
  color: var(--ink-3);
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.seg button {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s;
}

.seg button.active {
  background: var(--seal);
  border-color: var(--seal);
  color: oklch(0.99 0 0);
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid var(--line);
  cursor: pointer;
}

.swatch.active {
  border-color: var(--seal);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--seal) 18%, transparent);
}

/* ------------------------------------------------------------------ 表 / 书源页 */

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.src-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}

.src-row:last-child {
  border-bottom: 0;
}

.src-name {
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.src-desc {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}

.src-vars {
  margin-top: 10px;
}

.src-vars input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  outline: 0;
}

.switch {
  position: relative;
  width: 44px;
  height: 25px;
  border-radius: 999px;
  background: var(--line);
  border: 0;
  cursor: pointer;
  transition: background 0.2s var(--ease);
  flex: none;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease);
}

.switch.on {
  background: var(--jade);
}

.switch.on::after {
  transform: translateX(19px);
}

/* ------------------------------------------------------------------ 状态 */

.skeleton {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--paper-3) 25%, var(--paper-2) 37%, var(--paper-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
}

.empty .glyph {
  font-family: var(--font-serif);
  font-size: 46px;
  color: var(--line);
  line-height: 1;
  margin-bottom: 12px;
}

.error-box {
  border: 1px solid color-mix(in oklch, var(--seal) 32%, transparent);
  background: var(--seal-soft);
  color: var(--seal);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: 13.5px;
  margin: 14px 0;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: color-mix(in oklch, var(--ink) 92%, transparent);
  color: var(--paper-2);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.32s var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* 加载条 */
.topbar-loading {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--seal);
  z-index: 200;
  transition: width 0.3s var(--ease), opacity 0.3s;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 34px 0 0;
}

.footer {
  border-top: 1px solid var(--line-soft);
  padding: 26px 0 44px;
  color: var(--ink-3);
  font-size: 12.5px;
  position: relative;
  z-index: 1;
}

.footer .row {
  flex-wrap: wrap;
  gap: 14px;
}

/* ------------------------------------------------------- 封面（含兜底） */

.cover {
  position: relative;
  width: 100%;
  height: 100%;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* 真图压在兜底图之上。兜底图始终渲染（见 app.js 的 coverBox），
     图没下来时它就是占位背景，下来了就把它盖住 —— 全程不闪空白。 */
  position: relative;
  z-index: 1;
}

.list-item .thumb .cover {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

/* ------------------------------------------------------- 顶栏：下载 APP 入口 */

.header-tools .user-btn,
.header-tools .app-btn {
  width: auto;
  min-width: 36px;
  padding: 0 10px;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.header-tools .user-btn .uname,
.header-tools .app-btn .uname {
  font-size: 13px;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-tools .app-btn {
  border-color: color-mix(in oklch, var(--seal) 34%, transparent);
  color: var(--seal);
}

.header-tools .app-btn:hover {
  background: var(--seal-soft);
}

.header-tools .user-btn.signed {
  border-color: var(--seal-2);
  background: var(--seal-soft);
  color: var(--seal);
}

/* ------------------------------------------------------- 弹层 */

.modal-mask {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--ease);
  z-index: 90;
}

.modal-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  z-index: 95;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h3 {
  margin: 0;
  flex: 1;
  font-family: var(--font-serif);
  font-size: 17px;
}

.modal-close {
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
}

.modal-body {
  padding: 18px;
}

/* ------------------------------------------------------- 账号表单 */

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--paper-3);
  border-radius: 999px;
  margin-bottom: 18px;
}

.auth-tabs button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 0.16s var(--ease);
}

.auth-tabs button.active {
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r);
  padding: 10px 13px;
  font-size: 14px;
  outline: 0;
  transition: border-color 0.16s;
}

.field input:focus {
  border-color: var(--seal-2);
}

.captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.captcha-row input {
  flex: 1;
  min-width: 0;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.captcha-img {
  flex: none;
  width: 132px;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--line);
  line-height: 0;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
  border-radius: var(--r);
}

.auth-note {
  font-size: 12px;
  line-height: 1.7;
  margin: 14px 0 0;
  text-align: center;
}

.auth-me {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.auth-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--seal);
  color: oklch(0.99 0 0);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 4px;
}

.auth-stats div {
  background: var(--paper);
  padding: 12px 8px;
  text-align: center;
}

.auth-stats b {
  display: block;
  font-family: var(--font-num);
  font-size: 20px;
  color: var(--seal);
}

.auth-stats span {
  font-size: 12px;
  color: var(--ink-3);
}

/* ------------------------------------------------------- 紧凑榜单（首页侧栏） */

.rank-compact {
  display: grid;
  gap: 1px;
}

.rank-compact .rank-item {
  grid-template-columns: 22px 1fr;
  gap: 9px;
  padding: 6px 6px;
}

.rank-compact .rank-item .idx {
  font-size: 14px;
}

.rank-compact .rank-item .rk-name {
  font-size: 13px;
}

/* ------------------------------------------------------- 历史记录行 */

.hist-item {
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.hist-item:last-child {
  border-bottom: 0;
}

.hist-item .h-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-item .h-sub {
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-item .h-time {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .book-hero {
    grid-template-columns: 132px 1fr;
    gap: 20px;
  }
  .brand-sub {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --header-h: 58px;
  }
  .wrap {
    padding: 0 14px;
  }
  .site-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    transform: translateY(-130%);
    transition: transform 0.3s var(--ease);
    z-index: 39;
    box-shadow: var(--shadow-md);
  }
  .site-nav.open {
    transform: none;
  }
  .site-nav a {
    padding: 12px 14px;
    border-radius: 8px;
  }
  .menu-toggle {
    display: grid;
  }
  .header-tools .searchbar {
    display: none;
  }
  .header-tools .user-btn .uname,
  .header-tools .app-btn .uname {
    display: none;
  }
  .header-tools .user-btn,
  .header-tools .app-btn {
    padding: 0;
    justify-content: center;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 18px 12px;
  }
  .grid-lg {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 20px 14px;
  }
  .grid-sm {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 14px 10px;
  }
  .hlist {
    grid-template-columns: 1fr;
  }
  .hrow {
    padding: 7px 4px;
  }
  .card .c-title {
    font-size: 13px;
  }
  .list-item .thumb {
    width: 78px;
  }
  .hero h1 {
    font-size: 27px;
  }
  .toc-list {
    max-height: 60vh;
  }
  /* 窄屏放不下 3 列，章节名会被截得只剩几个字 —— 退回单列 */
  .toc-grid-body {
    grid-template-columns: 1fr;
  }
  .toc-cell {
    border-right: 0;
  }
  .rd-wrap {
    padding: 22px 16px 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ 发现页布局 */

.discover-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}

.disc-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  max-height: calc(100vh - var(--header-h) - 36px);
  overflow-y: auto;
  padding-right: 4px;
}

.disc-side-head {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.disc-side-head h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  margin: 0 0 4px;
}
.disc-side-head .hint {
  font-size: 12px;
  color: var(--ink-3);
}

.side-group + .side-group {
  margin-top: 18px;
}
.side-group-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  padding: 6px 10px;
  font-weight: 500;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink-1);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.4;
}
.side-link:hover {
  background: var(--paper-2, var(--line-soft));
  color: var(--seal);
}
.side-link.active {
  background: var(--seal-soft);
  color: var(--seal);
  font-weight: 500;
}
/* 发现页书行：无封面，书名 / 作者 / 最新章节 / 更新时间 四列 */
/* 发现页瀑布流：卡片不等高，用 CSS columns 错落排列 */
.flow-grid {
  column-width: 200px;
  column-gap: 16px;
}

.flow-card {
  break-inside: avoid;
  margin-bottom: 16px;
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.flow-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.flow-card .cover {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 133.333%; /* 3:4 封面，比例盒子（别用 aspect-ratio，见 .card .cover 的坑） */
}

.flow-card .cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flow-card .cover .fallback {
  font-size: 20px;
}

.flow-body {
  padding: 10px 12px 12px;
}

.flow-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.4;
}

.flow-chapter {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-chapter:empty {
  display: none;
}

.flow-intro {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.65;
  margin-top: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.flow-intro:empty {
  display: none;
}

.flow-sentinel {
  text-align: center;
  padding: 14px 0 26px;
  min-height: 20px;
}

.book-rows {
  border-top: 1px solid var(--line-soft);
}

.brow {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) 108px minmax(150px, 2fr);
  gap: 12px;
  align-items: center;
  padding: 11px 6px;
  border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
}

.brow:hover {
  background: var(--paper-2, rgba(0, 0, 0, 0.02));
}

.brow .b-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brow .b-author,
.brow .b-chapter,
.brow .b-time {
  color: var(--ink-3);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brow .b-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.brow-head {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

@media (max-width: 720px) {
  .brow-head {
    display: none;
  }
}

.brow .b-author::before {
  content: '作者 ';
  opacity: 0.55;
}

@media (max-width: 720px) {
  .brow {
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 10px 2px;
  }
  .brow .b-name {
    font-size: 14.5px;
  }
  .brow .b-author {
    text-align: right;
  }
  .brow .b-chapter {
    grid-column: 1 / -1;
    font-size: 12px;
  }
  .brow .b-time {
    grid-column: 2;
    grid-row: 1;
    font-size: 11.5px;
  }
  .brow .b-author::before {
    content: '';
  }
}

/* 内容与其它频道重复的频道：书源发现页多半已失效，置灰提示 */
.side-link.dup {
  opacity: 0.5;
}

.side-link .badge-dup {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-4, var(--ink-3));
  font-family: var(--font-sans);
}

.side-link .badge-new {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  background: var(--seal);
  color: #fff;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.disc-main {
  min-width: 0;
}

/* 移动端：sidebar 折叠到顶部横向滚动 chips */
@media (max-width: 720px) {
  .discover-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .disc-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
  .disc-side-head {
    display: none;
  }
  #sideNav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .side-group {
    flex: 0 0 auto;
    margin-top: 0;
  }
  .side-group-title {
    display: none;
  }
  .side-link {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    padding: 7px 12px;
    background: var(--line-soft);
  }
  .side-link.active {
    background: var(--seal-soft);
  }
}

/* ------------------------------------------------------- APP 下载页 */

.app-hero {
  text-align: center;
  padding: 22px 0 6px;
}

.app-hero-logo {
  /* 全局有 img { display:block }，块级元素不会再被 text-align 居中，得自己给 margin */
  display: block;
  margin: 0 auto;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.app-hero h1 {
  font-family: var(--font-serif);
  font-size: 30px;
  margin: 16px 0 8px;
  letter-spacing: 0.02em;
}

.app-hero-sub {
  color: var(--ink-3);
  font-size: 14px;
  margin: 0 0 22px;
}

.app-hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.app-hero-note {
  font-size: 13px;
  margin-top: 14px;
}

.app-hero-note code,
.steps code {
  background: var(--paper-3);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: 999px;
}

.btn.is-disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-page .panel {
  margin-top: 18px;
}

.app-page .panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-family: var(--font-serif);
}

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 9px 14px;
  font-size: 14px;
  color: var(--ink-2);
}

.kv .k {
  color: var(--ink-3);
}

.steps {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.95;
  color: var(--ink-2);
}

.faq {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-2);
}

.faq p {
  margin: 0 0 10px;
}

.faq p:last-child {
  margin-bottom: 0;
}

.faq b {
  color: var(--ink);
}

@media (max-width: 720px) {
  .app-hero h1 {
    font-size: 23px;
  }
  .app-hero-logo {
    width: 76px;
    height: 76px;
  }
}

/* 书源体检面板（书源管理页） */
.ck-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ck-chip {
  font-size: 12.5px;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  line-height: 1.5;
}

.ck-ok {
  background: color-mix(in oklch, #2e8b57 14%, transparent);
  border-color: color-mix(in oklch, #2e8b57 42%, transparent);
  color: #2e8b57;
}

.ck-warn {
  background: color-mix(in oklch, #b8860b 14%, transparent);
  border-color: color-mix(in oklch, #b8860b 42%, transparent);
  color: #a06a00;
}

.ck-bad {
  background: color-mix(in oklch, var(--seal) 14%, transparent);
  border-color: color-mix(in oklch, var(--seal) 42%, transparent);
  color: var(--seal);
}

.ck-pulse {
  font-size: 12px;
  color: #2e8b57;
  font-weight: 600;
}

.ck-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 10px;
}

.ck-bar i {
  display: block;
  height: 100%;
  background: var(--seal);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* 下载地址条目（APP 下载弹窗里），整块可点 */
.dl-item {
  display: block;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.dl-item:hover {
  border-color: var(--seal-2);
  background: var(--paper-3);
}

.dl-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14.5px;
}

.dl-tag {
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--seal-soft);
  color: var(--seal);
}

.dl-item-go {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--seal);
}
