/* ============================================================
   API novel library — 22-chapter grid
   Appended for the D1-backed version. Older two-card styles remain
   above for reference, but these rules take precedence.
   ============================================================ */

.novel-select {
  padding-bottom: 44px;
}

.novel-hero {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin: 0 4px 18px;
  padding: 18px 22px;
  overflow: hidden;
  border: 1px solid rgba(224, 192, 139, .18);
  border-radius: 4px 18px 4px 18px;
  background:
    radial-gradient(ellipse at 88% 15%, rgba(221, 178, 102, .13), transparent 22%),
    linear-gradient(110deg, rgba(19, 49, 48, .94), rgba(8, 27, 33, .94));
}

.novel-hero::after {
  content: "灯";
  position: absolute;
  right: 18px;
  bottom: -49px;
  color: rgba(232, 190, 119, .045);
  font-family: "Songti SC", "STSong", serif;
  font-size: 138px;
  line-height: 1;
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.hero-kicker {
  color: var(--n-gold);
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: 9px;
  letter-spacing: .24em;
}

.hero-copy h2 {
  margin: 6px 0 5px;
  color: #f0e1c2;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .1em;
}

.hero-copy p {
  margin: 0;
  color: #8ea9a1;
  font-family: "Songti SC", "STSong", serif;
  font-size: 11px;
  line-height: 1.8;
  letter-spacing: .03em;
}

.hero-side {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.hero-stats {
  display: flex;
  gap: 16px;
}

.hero-stats span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #6f8e86;
  font-size: 9px;
  letter-spacing: .1em;
  white-space: nowrap;
}

.hero-stats b {
  color: #e6c68d;
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: .02em;
}

.hero-btn {
  padding: 9px 14px;
  border: 1px solid rgba(224, 182, 112, .48);
  border-radius: 2px 9px 2px 9px;
  background: rgba(184, 137, 70, .16);
  color: #efd39f;
  font-family: "Songti SC", "STSong", serif;
  font-size: 11px;
  letter-spacing: .1em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s ease, transform .2s ease;
}

.hero-btn:hover,
.hero-btn:focus-visible {
  background: rgba(208, 161, 91, .28);
  transform: translateY(-1px);
  outline: none;
}

.hero-btn.is-ghost {
  border-color: rgba(196, 216, 206, .18);
  background: rgba(255, 255, 255, .025);
  color: #94ada5;
}

.novel-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chapter-tile {
  --tone: #d3a465;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 196px;
  padding: 17px 16px 14px;
  overflow: hidden;
  border: 1px solid rgba(212, 193, 158, .13);
  border-radius: 4px 16px 4px 16px;
  background:
    linear-gradient(160deg, rgba(17, 44, 44, .9), rgba(7, 23, 29, .94));
  cursor: pointer;
  outline: none;
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), border-color .25s ease, background .25s ease;
}

.chapter-tile::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(235, 207, 155, .045);
  border-radius: 2px 11px 2px 11px;
  pointer-events: none;
}

.chapter-tile:hover,
.chapter-tile:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--tone) 55%, transparent);
  background:
    linear-gradient(160deg, rgba(23, 55, 53, .94), rgba(8, 27, 33, .97));
  box-shadow: 0 18px 36px rgba(0, 0, 0, .28);
}

.chapter-tile:focus-visible {
  box-shadow: 0 0 0 2px rgba(240, 202, 132, .62);
}

.chapter-tile.is-reading {
  border-color: rgba(232, 190, 119, .44);
}

.chapter-tile.is-read {
  border-color: rgba(151, 198, 170, .17);
}

.tile-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tile-no {
  color: var(--tone);
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: 10px;
  letter-spacing: .18em;
}

.tile-read {
  color: #6e8b83;
  font-size: 9px;
  letter-spacing: .04em;
  white-space: nowrap;
}

.tile-read.is-done {
  color: #94c7a8;
}

.tile-read.is-new {
  color: #d5b477;
}

.tile-glyph {
  position: absolute;
  right: -3px;
  bottom: -31px;
  z-index: 0;
  color: color-mix(in srgb, var(--tone) 12%, transparent);
  font-family: "Songti SC", "STSong", serif;
  font-size: 112px;
  line-height: 1;
  pointer-events: none;
  transition: color .25s ease, transform .25s ease;
}

.chapter-tile:hover .tile-glyph {
  color: color-mix(in srgb, var(--tone) 19%, transparent);
  transform: translateY(-3px);
}

.tile-glyph em {
  font-style: normal;
  font-size: 88px;
}

.chapter-tile h3 {
  position: relative;
  z-index: 2;
  margin: 14px 0 5px;
  color: #efdfc1;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: .05em;
  line-height: 1.35;
}

.tile-summary {
  position: relative;
  z-index: 2;
  display: -webkit-box;
  margin: 0 0 12px;
  overflow: hidden;
  color: #8da39b;
  font-family: "Songti SC", "STSong", serif;
  font-size: 10.5px;
  line-height: 1.75;
  letter-spacing: .02em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tile-meta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  color: #607d76;
  font-size: 9px;
  letter-spacing: .03em;
}

.tile-meta i {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #9b7847;
}

.tile-cta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  color: var(--tone);
  font-family: "Songti SC", "STSong", serif;
  font-size: 10.5px;
  letter-spacing: .1em;
}

.tile-cta em {
  font-style: normal;
  transition: transform .2s ease;
}

.chapter-tile:hover .tile-cta em {
  transform: translateX(3px);
}

.novel-loading,
.novel-error {
  grid-column: 1 / -1;
  padding: 42px 20px;
  border: 1px dashed rgba(208, 182, 137, .2);
  border-radius: 4px 18px 4px 18px;
  color: #90a8a0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 13px;
  line-height: 1.9;
  text-align: center;
}

.novel-error {
  border-color: rgba(198, 112, 92, .3);
  color: #c8a49a;
}

.novel-error code {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .22);
  color: #d9b890;
  font-family: Consolas, monospace;
  font-size: 11px;
}

@media (max-width: 1180px) {
  .novel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .novel-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
    padding: 16px 17px;
  }

  .hero-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
    justify-content: initial;
  }

  .hero-stats {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .hero-btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 700px) {
  .novel-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .novel-hero {
    margin: 0 0 12px;
    padding: 14px 14px 13px;
  }

  .hero-copy h2 {
    font-size: 18px;
  }

  .hero-copy p {
    font-size: 10px;
  }

  .hero-side {
    gap: 10px;
  }

  .hero-stats {
    gap: 12px;
  }

  .hero-stats b {
    font-size: 16px;
  }

  .hero-btn {
    padding: 8px 10px;
    font-size: 10px;
  }

  .chapter-tile {
    min-height: 168px;
    padding: 14px 14px 13px;
  }

  .chapter-tile h3 {
    margin-top: 11px;
    font-size: 18px;
  }

  .tile-summary {
    margin-bottom: 8px;
    font-size: 10px;
    -webkit-line-clamp: 2;
  }

  .tile-glyph {
    right: 4px;
    bottom: -24px;
    font-size: 92px;
  }

  .tile-glyph em {
    font-size: 72px;
  }

  .reading-path,
  .novel-note {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 390px) {
  .hero-stats {
    gap: 9px;
  }

  .hero-stats span {
    font-size: 8px;
  }

  .hero-stats b {
    font-size: 15px;
  }

  .hero-btn {
    padding: 7px 8px;
    letter-spacing: .04em;
  }

  .chapter-tile h3 {
    font-size: 17px;
  }
}
