:root {
  --bg: #f5efe3;
  --paper: #fffaf2;
  --ink: #1c140e;
  --muted: #6d5d4f;
  --line: #d7c6b1;
  --accent: #0f766e;
  --accent-soft: #cdebe7;
  --warm: #d97706;
  --shadow: 0 14px 40px rgba(38, 25, 11, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  color: var(--ink);
  background: radial-gradient(circle at 18% 18%, #fff4df 0%, var(--bg) 50%, #eadcc8 100%);
  position: relative;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  border-radius: 999px;
  filter: blur(6px);
  pointer-events: none;
  z-index: -1;
}

.backdrop-a {
  width: 320px;
  height: 320px;
  background: rgba(217, 119, 6, 0.16);
  top: -80px;
  right: -80px;
}

.backdrop-b {
  width: 280px;
  height: 280px;
  background: rgba(15, 118, 110, 0.14);
  bottom: -120px;
  left: -100px;
}

.topbar {
  max-width: 1160px;
  margin: 24px auto 12px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: rise 460ms ease-out;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand-badge {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(140deg, #0f766e, #0b4c47);
  color: #fff;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: 1.36rem;
  letter-spacing: 0.02em;
}

.brand em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.94rem;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.72);
}

.nav a.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #0f4f49;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

#authButton {
  max-width: min(72vw, 340px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
}

.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.93rem;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(9, 74, 68, 0.2);
}

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

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn.slim {
  padding: 6px 12px;
  font-size: 0.88rem;
}

.shell {
  max-width: 1160px;
  padding: 0 18px;
  margin-inline: auto;
}

.page-grid {
  margin-top: 12px;
  margin-bottom: 42px;
  display: grid;
  gap: 18px;
}

.hero-panel h1 {
  margin: 6px 0 10px;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.hero-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0;
  color: var(--warm);
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.hero-actions {
  margin-top: 14px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
}

.stat-card h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.stat-card p {
  margin: 6px 0 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.panel {
  background: color-mix(in srgb, var(--paper) 90%, #fff 10%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 540ms ease-out;
  min-width: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
}

.panel-head h1 {
  margin: 0;
  font-size: 1.5rem;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.search-wrap {
  display: grid;
  gap: 6px;
  margin: 16px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.home-catalog {
  min-width: 0;
}

.search-wrap input,
.search-wrap select,
.auth-card input {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 10px 12px;
  font: inherit;
}

.search-wrap input:focus,
.search-wrap select:focus,
.auth-card input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.empty-list {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
}

.shelf-note {
  margin: 12px 0 4px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.shelf-section {
  margin-top: 16px;
}

.shelf-fold {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px 12px 12px;
}

.shelf-fold + .shelf-fold {
  margin-top: 12px;
}

.shelf-fold summary {
  cursor: pointer;
  font-size: 1.06rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
}

.shelf-fold summary::-webkit-details-marker {
  display: none;
}

.shelf-fold summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  transition: transform 120ms ease;
}

.shelf-fold:not([open]) summary::after {
  transform: rotate(-90deg);
}

.shelf-fold .card-grid {
  margin-top: 10px;
}

.shelf-section h3 {
  margin: 0 0 10px;
  font-size: 1.06rem;
}

.shelf-empty {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
}

.book-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  padding: 14px;
  transition: border-color 120ms ease, transform 120ms ease;
}

.book-card-link {
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line) 55%);
}

.book-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fffcf4 0%, #f2faf9 100%);
}

.book-card h3 {
  margin: 0;
  font-size: 1.06rem;
}

.subtitle {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.book-head {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: start;
  gap: 10px;
  margin-bottom: 10px;
}

.book-cover {
  width: 72px;
  height: 102px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 0 8px 16px rgba(28, 20, 14, 0.08);
  background: #fff;
}

.book-meta {
  min-width: 0;
}

.book-meta h3 {
  margin: 0;
  font-size: 1.06rem;
}

.book-author {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.star-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #9a7d55;
  padding: 0;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, color 120ms ease;
}

.bookmark-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.star-toggle:hover {
  transform: translateY(-1px);
  color: #0f4f49;
}

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

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.78rem;
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}

.kpis article {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
}

.kpis h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.kpis p {
  margin: 7px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.reader-body {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
  min-width: 0;
}

.reader-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.reader-side {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 10px;
}

.reader-control-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  padding: 12px;
}

.reader-control-card h4 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.reader-main {
  min-width: 0;
}

.reader-book-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}

.reader-book-head {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  align-items: start;
  gap: 12px;
}

.reader-book-cover {
  width: 86px;
  height: 122px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 0 10px 18px rgba(28, 20, 14, 0.1);
  background: #fff;
}

.reader-book-meta h3 {
  margin: 0;
  font-size: 1.75rem;
}

.reader-body.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.reader-top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.reader-page {
  margin-top: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line) 64%);
  color: #0f4f49;
}

.meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.meta-item {
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--accent-soft);
  color: #114b45;
}

.book-intro {
  margin: 14px 0;
  line-height: 1.65;
}

.note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.slider-wrap {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.slider-wrap input {
  width: 100%;
  accent-color: var(--warm);
}

.progress-label {
  color: var(--muted);
}

.chapter-controls {
  margin: 14px 0 10px;
  display: grid;
  gap: 8px;
}

.chapter-switch {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chapter-switch select {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 9px 10px;
  font: inherit;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.chapter-switch select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.chapter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chapter-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.chapter-title-wrap {
  min-width: 0;
}

.chapter-article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 20px 18px;
  margin-bottom: 12px;
  --reader-font-size: 20px;
  --reader-line-height: 2;
  --reader-content-width: 860px;
}

.chapter-article h5 {
  margin: 0;
  font-size: 1.16rem;
  line-height: 1.5;
}

.chapter-body {
  max-width: var(--reader-content-width);
  margin: 0 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chapter-article p {
  margin: 0 0 1.05em;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  letter-spacing: 0.01em;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chapter-article p:last-child {
  margin-bottom: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chapter-list {
  margin: 8px 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 6px;
  line-height: 1.5;
}

.reader-settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(35, 24, 12, 0.34);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.reader-settings-modal.hidden {
  display: none;
}

.reader-settings-card {
  width: min(420px, 100%);
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  display: grid;
  gap: 10px;
}

.reader-settings-card h3 {
  margin: 0;
  font-size: 1.08rem;
  padding-right: 36px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(35, 24, 12, 0.34);
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-modal.hidden {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
}

.auth-card h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1.12rem;
  padding-right: 36px;
}

.auth-card p {
  margin-top: 0;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-card label {
  display: block;
  margin-top: 10px;
}

.auth-actions {
  display: flex;
  justify-content: flex-start;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.auth-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.auth-close:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line) 70%);
}

.auth-link {
  margin-left: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.detail-back-link {
  justify-self: start;
}

.book-detail-panel {
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  padding: 14px;
  min-width: 0;
}

.book-detail-hero {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.book-detail-cover {
  width: 128px;
  height: 182px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 20px rgba(26, 20, 14, 0.14);
  background: #fff;
  object-fit: cover;
}

.book-detail-meta h1 {
  margin: 0;
  font-size: 1.48rem;
}

.book-detail-facts {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  gap: 7px;
}

.book-detail-facts li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  color: var(--muted);
}

.book-detail-facts li span {
  width: 60px;
  flex: none;
}

.book-detail-facts li strong {
  color: var(--ink);
  font-weight: 600;
}

.book-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.book-detail-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.book-detail-section h3 {
  margin: 0 0 10px;
  font-size: 1.02rem;
}

.book-detail-copy p {
  margin: 0 0 0.9em;
  line-height: 1.75;
}

.book-detail-copy p:last-child {
  margin-bottom: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .reader-side {
    position: static;
  }

  .chapter-article {
    --reader-content-width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

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

  .book-head {
    grid-template-columns: 60px 1fr auto;
    gap: 8px;
  }

  .book-cover {
    width: 60px;
    height: 86px;
  }

  .reader-book-head {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .reader-book-cover {
    width: 72px;
    height: 102px;
  }

  .reader-book-meta h3 {
    font-size: 1.46rem;
  }

  .reader-top-actions .btn {
    width: auto;
  }

  .reader-top-actions {
    gap: 10px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .book-detail-hero {
    grid-template-columns: 1fr;
  }

  .book-detail-cover {
    width: 96px;
    height: 136px;
  }

  .book-detail-actions .btn {
    flex: 1;
  }

  .reader-body {
    padding: 10px;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  #authButton {
    max-width: 100%;
  }

  .reader-control-card {
    padding: 10px;
  }

  .chapter-actions .btn {
    flex: 1;
    min-height: 42px;
  }

  .chapter-toolbar {
    align-items: stretch;
  }

  .chapter-actions {
    width: 100%;
  }

  .chapter-article {
    padding: 14px 12px;
    --reader-font-size: 18px;
  }

  .chapter-article h5 {
    font-size: 1.06rem;
  }
}
