:root {
  --bg: #f6f1e6;
  --paper: #fffaf0;
  --paper-deep: #eee3cf;
  --ink: #231f19;
  --muted: #746a5d;
  --line: #d8c8ac;
  --accent: #a13c2f;
  --accent-strong: #78271f;
  --gold: #d6a84f;
  --shadow: 0 24px 60px rgba(67, 47, 24, .14);
  --reader-width: 860px;
}

[data-theme="dark"] {
  --bg: #15130f;
  --paper: #211d17;
  --paper-deep: #2d281f;
  --ink: #f1e7d3;
  --muted: #b9aa92;
  --line: #4a3d2d;
  --accent: #e27a67;
  --accent-strong: #ffb39f;
  --gold: #e0b85f;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Microsoft YaHei", serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(161, 60, 47, .06) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(circle at 10% 0%, rgba(214, 168, 79, .18), transparent 32rem),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
summary {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 20px;
  align-items: center;
  min-height: 72px;
  padding: 12px clamp(18px, 5vw, 64px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
}

.brand-name {
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.desktop-nav,
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.desktop-nav a {
  padding: 8px 10px;
  color: var(--muted);
}

.desktop-nav a:hover {
  color: var(--accent);
}

.header-actions {
  justify-content: end;
  gap: 8px;
}

.category-drawer summary {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.category-drawer summary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.script-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 58px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}

.script-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 28px;
  border-radius: 999px;
  background: var(--ink);
  transition: transform .18s ease, background .18s ease;
}

.script-switch:hover {
  border-color: var(--accent);
}

.script-switch[data-state="繁"]::before {
  transform: translateX(27px);
}

.script-option {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 28px;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1;
}

.script-switch[data-state="简"] .script-simple,
.script-switch[data-state="繁"] .script-traditional {
  color: var(--paper);
}

.theme-switch {
  display: inline-grid;
  width: 58px;
  height: 40px;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.switch-track {
  position: relative;
  display: block;
  width: 52px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-deep);
  transition: background .18s ease, border-color .18s ease;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(35, 31, 25, .18);
  transition: transform .18s ease, background .18s ease;
}

[data-theme="dark"] .switch-track {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line));
  background: color-mix(in srgb, var(--accent) 22%, var(--paper-deep));
}

[data-theme="dark"] .switch-knob {
  transform: translateX(24px);
  background: var(--ink);
}

.category-drawer {
  position: relative;
  display: none;
}

.category-drawer summary {
  list-style: none;
}

.category-drawer summary::-webkit-details-marker {
  display: none;
}

.category-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  gap: 8px;
  width: min(72vw, 220px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper) 92%, var(--gold) 8%), var(--paper));
  box-shadow: 0 18px 42px rgba(67, 47, 24, .16);
}

.category-panel::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 15px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, var(--gold) 8%);
  transform: rotate(45deg);
}

.category-panel-links {
  display: grid;
}

.category-panel-links a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--muted);
  line-height: 1.2;
}

.category-panel-links a + a {
  border-top: 1px solid color-mix(in srgb, var(--line) 58%, transparent);
}

.category-panel-links a:hover {
  border-top-color: transparent;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.category-panel .friend-links {
  justify-items: stretch;
  padding: 8px 4px 4px;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  text-align: left;
}

.category-panel .friend-links-title {
  padding: 0 6px;
  font-size: .76rem;
}

.category-panel .friend-links-list {
  display: grid;
  gap: 2px;
  justify-content: stretch;
  margin-top: 4px;
}

.category-panel .friend-links-list a {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 7px 6px;
  border-radius: 5px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.15;
  text-align: left;
}

.category-panel .friend-links-list a::before {
  content: "";
  width: 9px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 0, 0 10px, 3px 8px, 4px 12px, 6px 11px, 5px 7px, 9px 7px);
  transform: translateY(1px) rotate(-8deg);
}

.category-panel .friend-links-list a:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hamburger-icon {
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.hamburger-icon::before {
  top: -6px;
}

.hamburger-icon::after {
  top: 6px;
}

.site-main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(16px, 3vw, 36px) 0 clamp(28px, 6vw, 72px);
}

.home-index {
  width: min(100%, 860px);
  margin: 0 auto clamp(18px, 5vh, 52px);
}

.list-title {
  margin-bottom: 12px;
}

.list-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.2;
}

.home-list {
  display: grid;
  width: 100%;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.search-panel {
  display: grid;
  margin-bottom: 12px;
}

.search-field {
  position: relative;
}

.search-field::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 13px;
  width: 11px;
  height: 11px;
  border: 1.7px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-58%);
}

.search-field::after {
  content: "";
  position: absolute;
  top: calc(50% + 5px);
  left: 23px;
  width: 7px;
  height: 1.7px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(45deg);
}

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 8px 14px 8px 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  color: var(--ink);
  font: inherit;
  outline: none;
}

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.search-status {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.search-results-block {
  margin: 0 0 18px;
  padding: 12px 14px 14px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 92%, var(--accent) 8%);
}

.search-results:empty {
  border-bottom: 0;
}

.search-results {
  border-top: 1px solid color-mix(in srgb, var(--line) 66%, transparent);
}

.spotlight-card {
  display: block;
  width: 100%;
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}

.spotlight-card picture,
.spotlight-card img {
  display: block;
  width: 100%;
}

.spotlight-card img {
  height: auto;
  aspect-ratio: 6 / 1;
  object-fit: cover;
}

.spotlight-card:hover {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
}

.reader-page > .spotlight-card {
  margin: 0 0 clamp(24px, 4vw, 38px);
}

.reader-page > .novel-body + .spotlight-card {
  margin: clamp(30px, 5vw, 46px) 0 0;
}

.novel-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  min-height: 52px;
  padding: 11px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
}

.novel-row:last-child {
  border-bottom: 0;
}

.novel-title-link:hover {
  color: var(--accent);
}

.novel-title {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(.98rem, 1.8vw, 1.08rem);
  font-weight: 700;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.category-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reader-tags {
  justify-content: flex-start;
  margin-top: 16px;
}

.novel-cover-head {
  margin-bottom: 18px;
}

.novel-cover-head h1 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.22;
}

.novel-cover .intro {
  max-width: 680px;
  color: var(--muted);
  font-size: .96rem;
  line-height: 1.9;
}

.chapter-index {
  margin-top: 0;
}

.chapter-number {
  color: var(--muted);
  font-size: .82rem;
  white-space: nowrap;
}

.list-pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: .86rem;
}

.list-pager a,
.list-pager .is-disabled,
.pager-count {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  line-height: 1;
}

.list-pager a {
  color: var(--accent);
}

.list-pager a:hover {
  border-color: var(--accent);
}

.list-pager .is-disabled {
  opacity: .5;
}

.home-hero {
  min-height: clamp(250px, 42vw, 430px);
  display: grid;
  align-items: center;
  border-block: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--paper) 82%, transparent), transparent),
    repeating-linear-gradient(90deg, transparent 0 38px, color-mix(in srgb, var(--line) 42%, transparent) 38px 39px);
}

.home-hero > div {
  max-width: 720px;
  padding: clamp(24px, 5vw, 54px);
}

.eyebrow,
.book-type,
.back-link {
  color: var(--accent);
  font-weight: 700;
}

.reader-nav {
  display: flex;
  margin-bottom: 14px;
}

.back-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 52%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--paper));
  font-size: .78rem;
  line-height: 1;
}

.back-link::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  transform: rotate(45deg);
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.5rem, 8vw, 5.8rem);
  line-height: .98;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 0;
}

.hero-copy {
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.9;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  margin-top: 34px;
}

.section-block,
.novel-index,
.reader-page {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  box-shadow: var(--shadow);
}

.section-block {
  padding: clamp(20px, 3vw, 34px);
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-heading a {
  color: var(--accent);
  font-size: .95rem;
}

.book-list,
.chapter-list {
  display: grid;
  gap: 12px;
}

.book-list.wide {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.book-card,
.chapter-list a {
  display: grid;
  gap: 8px;
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.book-card:hover,
.chapter-list a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.book-card strong {
  font-size: 1.2rem;
  line-height: 1.35;
}

.book-card small,
.chapter-list small,
.reader-meta,
.empty-state {
  color: var(--muted);
}

.empty-state {
  margin: 0;
  line-height: 1.8;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--accent-strong);
}

.novel-index,
.reader-page {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 54px);
}

.page-title {
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: clamp(2.2rem, 6vw, 4.2rem);
}

.reader-head h1 {
  margin-bottom: 14px;
  font-size: clamp(1.28rem, 2.8vw, 1.85rem);
  line-height: 1.28;
}

.reader-page {
  width: min(100%, var(--reader-width));
  border-radius: 12px;
}

.reader-head {
  margin-bottom: clamp(28px, 5vw, 52px);
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: .95rem;
}

.reader-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 14px;
  color: var(--line);
}

.prose {
  font-size: clamp(1.05rem, 2vw, 1.18rem);
  line-height: 2.15;
}

.prose p {
  margin-bottom: 1.25em;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.intro {
  color: var(--muted);
}

.chapter-pager {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: clamp(36px, 7vw, 68px);
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.pager-link {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--accent);
}

.pager-link span {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager-link.next {
  text-align: right;
}

.pager-link.center {
  text-align: center;
}

.pager-link.disabled {
  color: var(--muted);
  opacity: .62;
}

.site-footer {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 34px 18px 46px;
  color: var(--muted);
  font-size: .94rem;
}

.friend-links {
  display: grid;
  gap: 8px;
  justify-items: center;
  max-width: 860px;
}

.friend-links-title {
  color: var(--ink);
  font-size: .86rem;
  font-weight: 800;
}

.friend-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
}

.friend-links-list a {
  color: var(--muted);
  line-height: 1.4;
}

.friend-links-list a:hover {
  color: var(--accent);
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand-name {
    font-size: 1.22rem;
  }

  .desktop-nav {
    display: none;
  }

  .category-drawer {
    display: block;
  }

  .header-actions {
    gap: 6px;
  }

  .category-drawer summary {
    width: 38px;
    height: 38px;
  }

  .script-switch {
    width: 56px;
    height: 34px;
  }

  .script-switch::before {
    width: 26px;
    height: 28px;
  }

  .script-switch[data-state="繁"]::before {
    transform: translateX(26px);
  }

  .script-option {
    height: 28px;
  }

  .theme-switch {
    width: 54px;
    height: 38px;
  }

  .switch-track {
    width: 48px;
    height: 26px;
  }

  .switch-knob {
    width: 18px;
    height: 18px;
  }

  [data-theme="dark"] .switch-knob {
    transform: translateX(22px);
  }

  .spotlight-card img {
    aspect-ratio: 4 / 1;
  }

  .site-main {
    width: min(100% - 22px, 1120px);
    padding: 10px 0 42px;
  }

  .novel-row {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 58px;
    padding: 14px 2px;
  }

  .category-tags {
    justify-content: flex-start;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: 280px;
  }

  .chapter-pager {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 34px;
    padding-top: 16px;
  }

  .pager-link,
  .pager-link.next,
  .pager-link.center {
    min-height: 42px;
    padding: 9px 6px;
    align-content: center;
    justify-items: center;
    text-align: center;
    font-size: .78rem;
  }

  .pager-link span {
    display: none;
  }
}
