/* ==========================================================================
 *  我的读书库 · 样式
 * ========================================================================== */

:root {
  --bg: #f6f4ef;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #fffdf8 0%, #f6f4ef 60%);
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --text: #23211c;
  --text-2: #6d685d;
  --text-3: #9c968a;
  --border: #e7e3d9;
  --border-strong: #d8d3c6;
  --accent: #2f5747;
  --accent-2: #3d6f5b;
  --accent-soft: #e9f1ec;
  --gold: #b08d3f;
  --shadow-sm: 0 1px 2px rgba(35, 33, 28, .05), 0 2px 8px rgba(35, 33, 28, .04);
  --shadow-md: 0 4px 12px rgba(35, 33, 28, .07), 0 12px 32px rgba(35, 33, 28, .08);
  --shadow-lg: 0 18px 50px rgba(35, 33, 28, .18);
  --radius: 14px;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #131410;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #1d1e18 0%, #131410 60%);
  --surface: #1c1d17;
  --surface-2: #212319;
  --text: #eae6da;
  --text-2: #a8a396;
  --text-3: #7c786c;
  --border: #2d2f26;
  --border-strong: #3b3d31;
  --accent: #86bfa2;
  --accent-2: #a3d0b8;
  --accent-soft: #243027;
  --gold: #d8b871;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

a { color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------------------------------------------------------------- Hero -- */
.hero { padding: 64px 0 32px; text-align: center; }

.hero .kicker {
  font-size: 12px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: .06em;
  margin: 0 0 12px;
}

.hero p.lede {
  margin: 0 auto;
  max-width: 560px;
  color: var(--text-2);
  font-size: 14.5px;
}

.hero .rule {
  width: 56px;
  height: 2px;
  background: var(--accent);
  margin: 22px auto 0;
  border-radius: 2px;
  opacity: .7;
}

/* -------------------------------------------------------------- Stats -- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 28px 0 8px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat .num {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
}

.stat .lbl {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .1em;
  margin-top: 2px;
}

/* ------------------------------------------------------------ Toolbar -- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin-top: 28px;
  padding: 12px 0;
  background: var(--bg); /* 旧浏览器兜底 */
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.toolbar-inner {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search svg {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 16px;
  height: 16px;
  stroke: var(--text-3);
  fill: none;
  stroke-width: 2;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}

.chip:hover { border-color: var(--border-strong); color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .chip.active { color: #10150f; }

select.sort, select.cat {
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  padding: 0 10px;
  cursor: pointer;
  outline: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .18s ease;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

/* --------------------------------------------------------------- Grid -- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 26px 20px;
  padding: 30px 0 60px;
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  animation: rise .4s ease both;
}

.enter {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, .5);
  padding: 3px 9px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .22s ease, transform .22s ease;
}

.card:hover .enter { opacity: 1; transform: none; }

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

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 8px 10px 10px 8px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  transition: transform .28s cubic-bezier(.2, .8, .3, 1), box-shadow .28s ease;
}

.card:hover .cover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; z-index: 1; }

/* 自动生成的书封 */
.cover .ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 14px 16px 20px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .28);
}

.cover .ph::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 8px;
  background: rgba(0, 0, 0, .28);
}

.cover .ph .ph-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: .04em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover .ph .ph-author {
  font-size: 11.5px;
  opacity: .88;
  letter-spacing: .06em;
  border-top: 1px solid rgba(255, 255, 255, .35);
  padding-top: 8px;
  word-break: break-all;
}

.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  font-size: 11px;
  letter-spacing: .06em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .93);
  color: #2f5747;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
}

.badge.reading { background: rgba(255, 255, 255, .93); color: #a06a12; }
.badge.done    { background: rgba(255, 255, 255, .93); color: #2f5747; }
.badge.wish    { background: rgba(255, 255, 255, .93); color: #6d685d; }

.meta { padding: 12px 2px 0; }

.meta .title {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta .author {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
}

.stars { font-size: 12px; letter-spacing: 1px; color: var(--gold); }
.stars .off { color: var(--border-strong); }

.bar {
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-top: 8px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .5s ease;
}

.bar-txt { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* --------------------------------------------------------------- 空态 -- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 20px;
  color: var(--text-3);
}

.empty .big { font-family: var(--font-serif); font-size: 20px; color: var(--text-2); margin-bottom: 6px; }

/* ------------------------------------------------------------- 书页 -- */
.bp-bar {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.bp-bar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }

.bp-back { font-size: 13.5px; color: var(--text-2); text-decoration: none; }
.bp-back:hover { color: var(--accent); }

.bp { max-width: 780px; padding: 34px 0 20px; }

.bp-head { display: flex; gap: 26px; align-items: flex-start; }

.bp-cover {
  width: 152px; flex: none;
  aspect-ratio: 3 / 4;
  border-radius: 8px 10px 10px 8px;
  overflow: hidden; position: relative;
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
}

.bp-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; z-index: 1; }

.bp-cover .ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 20px 14px 14px 24px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .28);
}

.bp-cover .ph::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: rgba(0, 0, 0, .28); }
.bp-cover .ph .ph-title { font-family: var(--font-serif); font-size: 22px; font-weight: 700; line-height: 1.45; letter-spacing: .03em; }
.bp-cover .ph .ph-author { font-size: 12px; opacity: .88; border-top: 1px solid rgba(255, 255, 255, .35); padding-top: 8px; }

.bp-info { flex: 1; min-width: 0; padding-top: 2px; }

.bp-info h1 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 700; line-height: 1.4;
  margin: 0 0 8px; letter-spacing: .03em;
}

.bp-sub { font-size: 13.5px; color: var(--text-2); line-height: 1.85; }
.bp-tags { margin-top: 12px; }
.bp-progress { margin-top: 18px; max-width: 280px; }

.bp .d-section { margin-top: 30px; }
.bp .notes { font-size: 14.5px; }
.bp .quote { font-size: 15px; }

.bp-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-top: 46px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.bp-nav-item {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.bp-nav-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.bp-nav-item.prev { text-align: center; }
.bp-nav-item.next { text-align: right; }
.bp-nav-item.disabled { opacity: .4; border-style: dashed; color: var(--text-3); }

.bp-nav-lbl { display: block; font-size: 11px; letter-spacing: .16em; color: var(--text-3); margin-bottom: 3px; }
.bp-nav-ttl {
  display: block; font-family: var(--font-serif); font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.bp-footer {
  display: flex; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--border);
  padding: 22px 0 46px;
  color: var(--text-3);
  font-size: 12.5px;
}

.bp-footer a { color: var(--text-3); text-decoration: none; }
.bp-footer a:hover { color: var(--accent); }

@media (max-width: 720px) {
  .bp-head { gap: 16px; }
  .bp-cover { width: 104px; }
  .bp-nav { grid-template-columns: 1fr; }
  .bp-nav-item.next, .bp-nav-item.prev { text-align: left; }
}

.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin: 8px 6px 0 0;
}

.d-section { margin-top: 26px; }

.d-section h4 {
  font-size: 11.5px;
  letter-spacing: .2em;
  color: var(--text-3);
  margin: 0 0 8px;
  font-weight: 600;
  text-transform: uppercase;
}

.d-section p { margin: 0; color: var(--text); font-size: 14.5px; }

.quote {
  border-left: 3px solid var(--gold);
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.75;
}

.notes {
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
}

.kv { display: grid; grid-template-columns: 74px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); }

.d-link {
  display: inline-block;
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 2px;
}

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

/* ------------------------------------------------------------- 页脚 -- */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 46px;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
}

footer code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}

/* --------------------------------------------------------- 响应式 -- */
@media (max-width: 720px) {
  .hero { padding: 42px 0 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 14px; }
  .wrap { padding: 0 16px; }
  .drawer { padding: 24px 20px 50px; }
  .d-head { gap: 14px; }
  .d-cover { width: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
