:root {
  --bg: #14110e;
  --bg-elev: #1c1813;
  --bg-card: #241f18;
  --ink: #f3ead8;
  --ink-dim: #b7a890;
  --gold: #d4b056;
  --gold-deep: #8d7340;
  --line: rgba(212, 176, 86, 0.16);
  --danger: #d4654a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --header-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

img {
  max-width: 100%;
}

#app {
  min-height: 100dvh;
}

.page {
  min-height: 100dvh;
  padding: calc(var(--header-h) + var(--safe-top) + 12px) 16px calc(84px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(20, 17, 14, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
}

.brand h1,
.brand .name {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.12em;
}

.muted {
  color: var(--ink-dim);
}

.page-heading {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
}

.page-lead {
  margin: 0 0 16px;
  color: var(--ink-dim);
  font-size: 15px;
}

.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
}

.boot-brand {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: 0.18em;
}

.boot-copy {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
}

.search {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 0 14px;
  outline: none;
}

.search:focus {
  border-color: var(--gold-deep);
}

.stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
  color: var(--ink-dim);
  font-size: 13px;
}

.continue-card,
.section-title {
  margin: 0 0 14px;
}

.continue-card {
  display: block;
  padding: 16px 18px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 90% 10%, rgba(212, 176, 86, 0.18), transparent 36%),
    linear-gradient(135deg, #2a2218, #1a1612);
  box-shadow: var(--shadow);
}

.continue-card .kicker {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-transform: uppercase;
}

.continue-card h2 {
  margin: 6px 0 4px;
  font-size: 20px;
  font-family: var(--serif);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin: 0 -16px 8px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  background: var(--bg-elev);
  font-size: 13px;
}

.chip.active {
  color: #1b1408;
  background: var(--gold);
  border-color: var(--gold);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.book-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #2b241b;
}

.cover-inner {
  position: absolute;
  inset: 0;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f7efdc;
}

.cover-title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.cover-author {
  font-size: 12px;
  opacity: 0.82;
}

.cover-deco {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.book-card .meta {
  padding: 10px 2px 0;
}

.book-card .meta h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
}

.book-card .meta p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-dim);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: rgba(20, 17, 14, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.bottom-nav a {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--ink-dim);
}

.bottom-nav a.router-link-active {
  color: #1b1408;
  background: var(--gold);
}

.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
}

.hero .cover {
  width: min(42vw, 168px);
}

.book-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.25;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.btn.primary {
  background: var(--gold);
  color: #1b1408;
  border-color: var(--gold);
}

.description {
  color: var(--ink-dim);
  line-height: 1.8;
  font-size: 15px;
}

.volume {
  margin: 18px 0;
}

.volume h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--gold);
}

.chapter-list {
  display: grid;
  gap: 8px;
}

.chapter-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid transparent;
}

.chapter-item.current {
  border-color: var(--gold-deep);
}

.chapter-item .wc {
  color: var(--ink-dim);
  font-size: 12px;
  flex: none;
}

.empty {
  padding: 48px 12px;
  text-align: center;
  color: var(--ink-dim);
}

.reader {
  min-height: 100dvh;
}

.reader-chrome {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(20, 17, 14, 0.94);
  backdrop-filter: blur(16px);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.reader-chrome.top {
  top: 0;
  border-bottom: 1px solid var(--line);
  padding: calc(8px + var(--safe-top)) 10px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-chrome.bottom {
  bottom: 0;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-chrome.hidden {
  opacity: 0;
  pointer-events: none;
}

.reader-chrome.top.hidden {
  transform: translateY(-100%);
}

.reader-chrome.bottom.hidden {
  transform: translateY(100%);
}

.icon-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
}

.crumb {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  font-size: 14px;
}

.crumb a {
  color: var(--gold);
  flex: none;
}

.crumb-sep {
  color: var(--ink-dim);
  flex: none;
}

.crumb > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title {
  min-width: 0;
  flex: 1;
}

.reader-title .crumb a:last-of-type {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-dim);
  font-size: 12px;
  margin-top: 2px;
}

.reader-article {
  max-width: 42rem;
  margin: 0 auto;
  padding: calc(24px + var(--header-h) + var(--safe-top)) 20px calc(96px + var(--safe-bottom));
}

.reader-article h1 {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: 1.5em;
  line-height: 1.4;
  text-align: center;
  font-weight: 600;
}

.reader-article p {
  margin: 0 0 1em;
  text-indent: 2em;
}

.progress-text {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}

.drawer,
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
}

.drawer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, 360px);
  background: var(--bg-elev);
  padding: calc(16px + var(--safe-top)) 14px calc(20px + var(--safe-bottom));
  overflow: auto;
  box-shadow: var(--shadow);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.setting-row input[type="range"] {
  flex: 1;
}

.theme-picks {
  display: flex;
  gap: 8px;
}

.theme-pick {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.theme-pick.active {
  border-color: var(--gold);
}

.reader[data-theme="paper"] {
  --read-bg: #f3ead8;
  --read-ink: #3b2f22;
  background: var(--read-bg);
  color: var(--read-ink);
}

.reader[data-theme="night"] {
  --read-bg: #12110f;
  --read-ink: #d5cbb6;
  background: var(--read-bg);
  color: var(--read-ink);
}

.reader[data-theme="green"] {
  --read-bg: #c7edcc;
  --read-ink: #243126;
  background: var(--read-bg);
  color: var(--read-ink);
}

.reader[data-theme="parchment"] {
  --read-bg: #e7d3ad;
  --read-ink: #3d2b1f;
  background: var(--read-bg);
  color: var(--read-ink);
}

.reader .btn {
  background: color-mix(in srgb, var(--read-ink) 10%, var(--read-bg));
  color: var(--read-ink);
  border-color: color-mix(in srgb, var(--read-ink) 22%, transparent);
}

.reader[data-theme="paper"] .reader-chrome,
.reader[data-theme="green"] .reader-chrome,
.reader[data-theme="parchment"] .reader-chrome {
  background: color-mix(in srgb, var(--read-bg) 88%, #000 12%);
  color: var(--read-ink);
}

@media (min-width: 720px) {
  .page {
    max-width: 1080px;
    margin: 0 auto;
    padding-bottom: 48px;
  }

  .book-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero {
    grid-template-columns: 180px 1fr;
    align-items: start;
  }

  .bottom-nav {
    display: none;
  }

  .desktop-nav {
    display: flex !important;
  }
}

.desktop-nav {
  display: none;
  gap: 8px;
}

.desktop-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-dim);
}

.desktop-nav a.router-link-active {
  color: #1b1408;
  background: var(--gold);
}
