/* 七星阁 - 小程序小清新风格 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500;700&family=ZCOOL+XiaoWei&family=Nunito:wght@400;600;700&display=swap');

:root {
  --brand: #3d9b8f;
  --brand-dark: #2d7a71;
  --brand-soft: #e6f5f2;
  --brand-mid: #7ec4bb;
  --ink: #2c3a3a;
  --ink-soft: #5a6b6b;
  --muted: #8a9a9a;
  --line: #e4eeec;
  --bg: #f3f8f6;
  --bg-warm: #faf7f2;
  --card: #ffffff;
  --danger: #e06b6b;
  --warn: #e8a85a;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(45, 122, 113, 0.08);
  --shadow-sm: 0 2px 10px rgba(45, 122, 113, 0.06);
  --font-display: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  --font-serif: "Noto Serif SC", serif;
  --font-sans: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;
  --max: 1100px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, rgba(126, 196, 187, 0.18), transparent 45%),
    radial-gradient(ellipse at top right, rgba(250, 220, 180, 0.2), transparent 40%),
    linear-gradient(180deg, #f7fbf9 0%, var(--bg) 40%, #eef6f3 100%);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; transition: color .2s; }
a:hover { color: var(--brand); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.container { width: min(100% - 32px, var(--max)); margin: 0 auto; }

/* Top bar - mini program style */
.topbar {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(14px);
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(228,238,236,.8);
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  height: 58px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 22px; color: var(--ink); white-space: nowrap;
}
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; box-shadow: var(--shadow-sm);
}
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 8px 12px; border-radius: 999px; color: var(--ink-soft);
  font-size: 14px; white-space: nowrap;
}
.nav a:hover, .nav a.active {
  background: var(--brand-soft); color: var(--brand-dark);
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: none; cursor: pointer;
  font-weight: 600; font-size: 14px; transition: .2s transform, .2s box-shadow, .2s background;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #4aaea1);
  color: #fff; box-shadow: 0 6px 16px rgba(61,155,143,.28);
}
.btn-primary:hover { color: #fff; filter: brightness(1.05); }
.btn-ghost {
  background: var(--brand-soft); color: var(--brand-dark);
}
.btn-outline {
  background: #fff; color: var(--brand-dark);
  border: 1px solid var(--brand-mid);
}
.btn-danger { background: #fde8e8; color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* Hero */
.hero {
  padding: 28px 0 8px;
  animation: fadeUp .5s ease both;
}
.hero-panel {
  position: relative; overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(61,155,143,.92), rgba(90,170,150,.85)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.08'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  color: #fff; padding: 36px 28px 32px;
  box-shadow: var(--shadow);
}
.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 52px);
  letter-spacing: 2px; margin: 0 0 8px;
  text-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.hero-desc {
  margin: 0 0 22px; max-width: 520px;
  opacity: .92; font-size: 15px;
}
.hero-search {
  display: flex; gap: 8px; max-width: 520px;
  background: rgba(255,255,255,.95);
  border-radius: 999px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.hero-search select, .hero-search input {
  border: none; outline: none; background: transparent;
  padding: 10px 14px; color: var(--ink);
}
.hero-search select { max-width: 100px; color: var(--ink-soft); }
.hero-search input { flex: 1; min-width: 0; }
.hero-search .btn { border-radius: 999px; }

/* Sections */
.section { padding: 28px 0 8px; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.section-title {
  margin: 0; font-family: var(--font-serif);
  font-size: 22px; font-weight: 700; color: var(--ink);
}
.section-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.more-link { color: var(--brand); font-size: 13px; font-weight: 600; }

/* Category chips */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--card); color: var(--ink-soft);
  box-shadow: var(--shadow-sm); font-size: 14px;
  border: 1px solid transparent; transition: .2s;
}
.chip:hover {
  border-color: var(--brand-mid); color: var(--brand-dark);
  transform: translateY(-2px);
}
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-mid);
}

/* Book grids - no heavy cards, soft panels */
.book-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.book-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: .25s transform, .25s box-shadow;
  animation: fadeUp .45s ease both;
}
.book-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.book-cover {
  aspect-ratio: 3/4; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #d9efe9, #f3ebe0);
  margin-bottom: 12px; position: relative;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 22px; color: var(--brand-dark);
  padding: 12px; text-align: center; line-height: 1.3;
}
.book-title {
  margin: 0 0 4px; font-size: 15px; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--ink);
}
.book-meta { font-size: 12px; color: var(--muted); }
.book-intro {
  margin: 8px 0 0; font-size: 12px; color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Soft list */
.soft-list { display: grid; gap: 10px; }
.soft-row {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border-radius: var(--radius-sm);
  padding: 12px 14px; box-shadow: var(--shadow-sm);
  transition: .2s;
}
.soft-row:hover { transform: translateX(3px); box-shadow: var(--shadow); }
.soft-row .rank {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--brand-soft); color: var(--brand-dark);
}
.soft-row .rank.top { background: linear-gradient(135deg, #f0c27a, #e8a85a); color: #fff; }
.soft-row .thumb {
  width: 44px; height: 58px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--brand-soft);
}
.soft-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.soft-row .body { flex: 1; min-width: 0; }
.soft-row .body h4 { margin: 0 0 4px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soft-row .body p { margin: 0; font-size: 12px; color: var(--muted); }

/* Two columns */
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.panel {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}

/* Author */
.author-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.author-item {
  text-align: center; padding: 18px 12px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: .2s;
}
.author-item:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--brand-soft), #f5e6d3);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 20px; color: var(--brand-dark);
}
.author-item h4 { margin: 0 0 4px; font-size: 15px; }
.author-item p { margin: 0; font-size: 12px; color: var(--muted); }

/* Knowledge */
.know-list { display: grid; gap: 10px; }
.know-item {
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-warm), #fff);
  border: 1px solid var(--line);
  transition: .2s;
}
.know-item:hover { border-color: var(--brand-mid); transform: translateX(4px); }
.know-item h4 { margin: 0 0 6px; font-size: 15px; }
.know-item p { margin: 0; font-size: 12px; color: var(--muted); }

/* Book detail */
.detail-hero {
  display: grid; grid-template-columns: 160px 1fr; gap: 24px;
  background: var(--card); border-radius: 20px; padding: 24px;
  box-shadow: var(--shadow); margin-top: 20px;
}
.detail-cover {
  aspect-ratio: 3/4; border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, #d9efe9, #f3ebe0);
  box-shadow: var(--shadow-sm);
}
.detail-cover .placeholder {
  height: 100%; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 28px; color: var(--brand-dark);
  padding: 16px; text-align: center;
}
.detail-title {
  margin: 0 0 8px; font-family: var(--font-serif); font-size: 28px;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px 16px; color: var(--ink-soft); font-size: 13px; margin-bottom: 12px; }
.detail-intro { color: var(--ink-soft); font-size: 14px; line-height: 1.8; margin: 0 0 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pill {
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--brand-soft); color: var(--brand-dark);
}

.chapter-panel { margin: 20px 0; background: var(--card); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-sm); }
.chapter-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  max-height: 480px; overflow: auto;
}
.chapter-link {
  padding: 12px 14px; border-radius: 10px; color: var(--ink);
  background: var(--bg); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-link:hover { background: var(--brand-soft); color: var(--brand-dark); }

/* Reader */
.read-body {
  background: #f7f3ea;
  min-height: 100vh;
  background-image:
    linear-gradient(180deg, #faf6ee, #f3ebe0);
}
.read-top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid #eadfce;
  padding: 12px 0;
}
.read-top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.read-content {
  max-width: 720px; margin: 0 auto; padding: 28px 20px 100px;
}
.read-content h1 {
  font-family: var(--font-serif); font-size: 26px; text-align: center;
  margin: 0 0 8px;
}
.read-book-name { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.read-text {
  font-family: var(--font-serif); font-size: 18px; line-height: 2;
  color: #3a342c; white-space: pre-wrap; word-break: break-word;
}
.read-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-top: 1px solid #eadfce; padding: 12px 16px;
  display: flex; justify-content: center; gap: 12px;
}

/* Auth / forms */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: min(100%, 400px); background: var(--card);
  border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow);
  animation: fadeUp .4s ease both;
}
.auth-card h1 {
  margin: 0 0 6px; font-family: var(--font-display); font-size: 28px; text-align: center;
}
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fafcfb; outline: none;
  transition: .2s border, .2s box-shadow;
}
.form-control:focus {
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(61,155,143,.15);
  background: #fff;
}
.form-tip { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

/* User center */
.user-hero {
  margin-top: 20px; border-radius: 20px; padding: 24px;
  background: linear-gradient(135deg, #3d9b8f, #6bb8a8);
  color: #fff; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.user-hero .avatar {
  width: 64px; height: 64px; background: rgba(255,255,255,.2); color: #fff;
}
.user-hero h2 { margin: 0 0 4px; font-size: 22px; }
.user-hero p { margin: 0; opacity: .9; font-size: 13px; }
.user-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0;
}
.stat-box {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-box .num { font-size: 22px; font-weight: 700; color: var(--brand-dark); }
.stat-box .label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.menu-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px;
}
.menu-item {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 18px 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px; color: var(--ink);
  transition: .2s;
}
.menu-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: var(--ink); }
.menu-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-size: 18px;
}

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: 12px; margin: 12px 0; font-size: 14px;
}
.alert-success { background: #e7f7ef; color: #2d7a55; }
.alert-error { background: #fdeaea; color: #c45c5c; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }

/* Pager */
.pager { display: flex; justify-content: center; gap: 8px; padding: 24px 0; flex-wrap: wrap; }
.pager-btn {
  min-width: 36px; height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--card); color: var(--ink-soft);
  box-shadow: var(--shadow-sm); font-size: 13px;
}
.pager-btn.active, .pager-btn:hover {
  background: var(--brand); color: #fff;
}

/* Footer */
.footer {
  margin-top: 48px; padding: 32px 0 40px;
  text-align: center; color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--line);
}
.footer a { color: var(--brand-dark); }

/* Empty */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

/* Toast-ish flash fixed */
.toast-stack { position: fixed; top: 70px; right: 16px; z-index: 200; width: min(320px, calc(100% - 32px)); }

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

@media (max-width: 900px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .author-grid { grid-template-columns: repeat(2, 1fr); }
  .nav { display: none; }
  .detail-hero { grid-template-columns: 120px 1fr; }
  .chapter-grid { grid-template-columns: 1fr; }
  .user-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .hero-panel { padding: 28px 18px; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-cover { max-width: 160px; margin: 0 auto; }
  .menu-grid { grid-template-columns: 1fr; }
}

/* ===== 回到顶部 ===== */
.backtop {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 1200;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: .9;
  transition: background .2s, opacity .2s, transform .2s;
}
.backtop:hover { background: var(--brand-dark); opacity: 1; transform: translateY(-3px); }
.backtop.is-show { display: flex; }
.backtop svg { width: 18px; height: 18px; }
