/* 拾页 · 暖纸墨色阅读美学 */

:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #fbf7ef;
  --ink: #2b2620;
  --muted: #8d8578;
  --accent: #b5504a;
  --accent-soft: #f3e2df;
  --line: #e7dfcf;
  --shadow: 0 1px 2px rgba(72, 60, 38, .05), 0 10px 30px rgba(72, 60, 38, .08);
  --serif: "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "STSong", "SimSun", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px; }
@media (min-width: 1080px) {
  .wrap { max-width: 1080px; }
}
@media (min-width: 1600px) {
  .wrap { max-width: 1200px; }
  .card-body { padding: 32px 42px 36px; }
}
.main { min-height: calc(100vh - 190px); padding-bottom: 48px; }

/* ---------- 顶栏 ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.bar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand {
  font-family: var(--serif);
  font-size: 24px; font-weight: 700; letter-spacing: .06em;
  color: var(--ink); text-decoration: none;
}
.brand-dot { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 18px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); font-weight: 600; }
.nav a.nav-cta { color: var(--accent); font-weight: 600; }
.nav-sep { width: 1px; height: 16px; background: var(--line); }
.who { color: var(--muted); font-size: 14px; }
.inline { display: inline; }
.linkbtn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 15px; font-family: inherit;
}
.linkbtn:hover { color: var(--ink); }

/* ---------- 每日卡片 ---------- */
/* PC：杂志式双栏（文字左 · 竖版插图右栏全高） */
.card {
  display: flex; flex-direction: row-reverse; align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 36px 0 28px;
}
.card-media {
  flex: 0 0 400px;
  display: flex; align-items: stretch;
  background: var(--surface-2);
  border-left: 1px dashed var(--line);
}
.card-media .media-ill { flex: 1 1 auto; min-width: 0; }
.card-media .media-ill img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 壁纸列：紧贴插画旁，竖幅 9:21 */
.card-media .media-wp {
  flex: 0 0 148px; position: relative;
  border-left: 1px solid var(--surface);
}
.card-media .media-wp img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .media-wp .wp-tag {
  position: absolute; left: 8px; bottom: 8px;
  font-size: 11px; letter-spacing: .1em;
  color: #fff; background: rgba(0,0,0,.45);
  padding: 2px 8px; border-radius: 999px;
}
.card.has-wp .card-media { flex-basis: 548px; max-width: 548px; }
.card-body {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  padding: 28px 34px 30px;
}
.card-body .actions { margin-top: auto; padding-top: 22px; }

/* 今日导读独立区块 */
.intro-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 22px 28px 26px; margin: 0 0 22px;
}
.intro-block .section-title { margin: 0 0 10px; }
.intro-text { margin: 0; font-size: 15.5px; line-height: 1.95; color: color-mix(in srgb, var(--ink) 88%, var(--muted)); }
.intro-block .readlink { margin-top: 12px; }

.card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px; letter-spacing: .08em;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 12px; color: var(--muted); background: var(--surface-2);
}
.rating { margin-left: auto; font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--accent); }
.rating small { font-size: 12px; font-weight: 400; color: var(--muted); }

.book-title {
  font-family: var(--serif);
  font-size: 30px; font-weight: 700; letter-spacing: .02em;
  line-height: 1.35; margin: 16px 0 4px;
}
.book-author { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.passage { margin: 0 0 22px; padding: 22px 24px; background: var(--surface-2); border-radius: 12px; position: relative; }

/* PC：编辑部式引文排版（去底色，朱砂引号悬浮，细强调线） */
@media (min-width: 901px) {
  .passage {
    background: none; border-radius: 0;
    padding: 16px 0 10px 38px; margin: 0 0 28px;
    border-left: 3px solid var(--accent-soft);
  }
  .passage blockquote { font-size: 19px; line-height: 2.1; }
  .passage blockquote::before {
    position: absolute; left: 4px; top: -4px;
    font-size: 46px; line-height: 1;
  }
  .passage { margin-top: auto; margin-bottom: auto; padding-top: 20px; padding-bottom: 8px; }
  .passage figcaption { margin-top: 14px; }
  .intro-block { margin-top: 4px; }
}
.passage blockquote {
  margin: 0; font-family: var(--serif);
  font-size: 17.5px; line-height: 2.0; letter-spacing: .02em;
}
.passage blockquote::before {
  content: "「"; display: block;
  font-size: 30px; color: var(--accent); line-height: 1;
  margin-bottom: 6px;
}
.passage figcaption { margin-top: 12px; font-size: 12.5px; color: var(--muted); }

.intro { border-top: 1px dashed var(--line); padding-top: 18px; }
.intro-label {
  display: inline-block; font-size: 12.5px; letter-spacing: .12em;
  color: var(--accent); margin-bottom: 4px; font-weight: 600;
}
.intro p { margin: 0; font-size: 15.5px; color: color-mix(in srgb, var(--ink) 88%, var(--muted)); }

.readlink {
  display: inline-block; margin-top: 16px;
  font-size: 14px; color: var(--accent); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.readlink:hover { border-bottom-color: var(--accent); }

.feedback-note { color: var(--muted); font-size: 14px; margin: 18px 0 0; }

/* ---------- 操作按钮 ---------- */
.actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.act {
  font-family: inherit; font-size: 15px;
  padding: 8px 22px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); transition: all .15s ease;
}
.act:hover { border-color: var(--muted); transform: translateY(-1px); }
.act:disabled { opacity: .55; cursor: wait; transform: none; }
.act.like.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.act.dislike.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.act.reroll { margin-left: auto; color: var(--muted); }
.act.reroll.used { cursor: default; opacity: .55; transform: none; }
.act.reroll.used:hover { border-color: var(--line); transform: none; }
.act.reroll.solo { margin-left: auto; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.act-icon { margin-right: 2px; }

/* 按钮内小 spinner（换一个/壁纸进行时） */
.btn-spin {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: btnspin .7s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }

/* 卡片入场渐显（刷新/换一个后更顺滑） */
@keyframes cardin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card { animation: cardin .45s ease both; }
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .btn-spin { animation-duration: 1.4s; }
}

/* ---------- 最近一览 ---------- */
.recent { margin-top: 8px; }
.section-title { font-size: 14px; font-weight: 600; letter-spacing: .1em; color: var(--muted); margin: 0 0 14px; }
.strip {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.thumb {
  flex: 0 0 auto; width: 108px; text-decoration: none; color: var(--muted);
  font-size: 12px; text-align: center;
}
.thumb img {
  width: 108px; height: 72px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
  transition: transform .15s ease;
}
.thumb:hover img { transform: translateY(-2px); }
.thumb span { display: block; margin-top: 6px; }

/* ---------- 回看 ---------- */
.page-title { font-family: var(--serif); font-size: 26px; margin: 36px 0 0; }
.page-sub { color: var(--muted); font-size: 14px; margin: 2px 0 26px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.grid-item { position: relative; }
.grid-card {
  display: block;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .15s ease;
}
.grid-card:hover { transform: translateY(-3px); }
.grid-media { aspect-ratio: 3 / 4; background: var(--surface-2); }
.grid-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-body { padding: 12px 14px 14px; }
.grid-title { font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1.4; }
.grid-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.grid-del {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 999px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s ease;
}
.grid-item:hover .grid-del, .grid-del:focus { opacity: 1; }
.grid-del:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
@media (hover: none) { .grid-del { opacity: 1; } } /* 触屏设备无 hover，常显 */

.detail-nav { margin-top: 28px; }
.detail-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.detail-nav a:hover { color: var(--ink); }
.detail-nav + .card { margin-top: 16px; }

/* ---------- 登录 / 注册 ---------- */
.auth-card {
  max-width: 380px; margin: 64px auto 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow);
  padding: 36px 38px 30px;
}
.auth-title { font-family: var(--serif); font-size: 26px; margin: 0; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.btn-primary {
  font: inherit; font-weight: 600; font-size: 15px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 999px; padding: 11px 0;
  cursor: pointer; margin-top: 6px;
}
.btn-primary:hover { filter: brightness(1.05); }
.form-error { color: var(--accent); font-size: 14px; margin: 0 0 14px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--muted); margin: 20px 0 0; }
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ---------- 手机壁纸 ---------- */
.wallpaper {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 22px 28px 26px; margin: 0 0 32px;
}
.wp-desc { color: var(--muted); font-size: 13.5px; margin: 8px 0 16px; }
.wp-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wp-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.wp-seg-btn {
  font: inherit; font-size: 13.5px; border: none; cursor: pointer;
  padding: 6px 16px; background: transparent; color: var(--muted);
}
.wp-seg-btn.on { background: var(--accent); color: #fff; }
.wp-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink); cursor: pointer; user-select: none;
}
.wp-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.wp-status { color: var(--muted); font-size: 13.5px; }
.wp-box { margin-top: 18px; text-align: center; }
.wp-img-phone {
  max-width: 100%; max-height: 64vh;
  border-radius: 14px; border: 1px solid var(--line); margin-bottom: 12px;
}
.wp-img-desktop {
  width: 100%; height: auto;
  border-radius: 14px; border: 1px solid var(--line); margin-bottom: 12px;
}

/* ---------- 管理端 ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 20px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.stat b { display: block; font-size: 22px; font-family: var(--serif); color: var(--ink); }
.stat span { font-size: 12px; color: var(--muted); }
.admin-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0 10px; }
.admin-sources { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.tag-src {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.admin-h2 { font-family: var(--serif); font-size: 19px; margin: 34px 0 12px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 720px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
.admin-table td { color: var(--ink); }
.admin-table td:not(.cell-trunc) { white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; }
.cell-trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-prompt { color: var(--muted); font-style: italic; }
.admin-thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.admin-thumb.wp { width: 26px; height: 56px; display: inline-block; margin-right: 4px; }
.tag-guest, .tag-admin, .tag-like, .tag-dis {
  display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--line);
}
.tag-guest { color: var(--muted); }
.tag-admin { color: var(--accent); border-color: var(--accent); }
.tag-like { color: var(--accent); border-color: var(--accent); }
.tag-dis { color: var(--muted); background: var(--surface-2); }

/* ---------- 个人页 & 发现页 ---------- */
.profile-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 24px 28px 28px; margin: 0 0 22px;
}
.profile-card .auth-form { max-width: 420px; }
.wr-status { margin-top: 14px; }
.wr-status p { margin: 4px 0; }

.search-bar { display: flex; gap: 12px; margin: 18px 0 8px; }
.search-bar input {
  flex: 1; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 22px; outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar .btn-primary { padding: 11px 30px; margin: 0; }
.search-results { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.search-card {
  display: flex; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px;
}
.sc-cover {
  width: 84px; height: 118px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); flex: 0 0 auto; background: var(--surface-2);
}
.sc-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sc-author { font-size: 13.5px; color: var(--muted); }
.sc-intro { font-size: 13.5px; color: color-mix(in srgb, var(--ink) 75%, var(--muted)); line-height: 1.7; }
.sc-gen { align-self: flex-start; margin-top: 8px; }

/* ---------- 生成中加载视图 ---------- */
.loading-card { min-height: 62vh; display: flex; align-items: center; justify-content: center; }
.loading-stage { text-align: center; padding: 48px 24px; width: 100%; max-width: 380px; }

.book {
  position: relative; width: 74px; height: 56px; margin: 0 auto 26px;
  perspective: 420px;
}
.book-cover {
  position: absolute; left: 0; bottom: 0; width: 56px; height: 44px;
  background: var(--accent); border-radius: 4px 8px 8px 4px;
  box-shadow: inset -3px 0 6px rgba(0,0,0,.18);
}
.book-page {
  position: absolute; bottom: 3px; left: 28px; width: 24px; height: 38px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 0 4px 4px 0;
  transform-origin: left bottom;
  animation: pageflip 2.4s ease-in-out infinite;
}
.book-page.p2 { animation-delay: .3s; }
.book-page.p3 { animation-delay: .6s; }
@keyframes pageflip {
  0%   { transform: rotateY(0);     opacity: 1; }
  55%  { transform: rotateY(-150deg); opacity: .9; }
  100% { transform: rotateY(-150deg); opacity: 0; }
}

.loading-title { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.loading-hint { font-size: 13px; color: var(--muted); margin: 0 0 26px; animation: hintfade 1.2s ease; }
@keyframes hintfade { from { opacity: 0; } to { opacity: 1; } }

.skeleton { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.sk {
  height: 13px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 45%, var(--surface-2) 65%);
  background-size: 240% 100%;
  animation: shimmer 1.6s linear infinite;
}
.sk-line.w60 { width: 60%; }
.sk-line.w90 { width: 90%; }
.sk-line.w80 { width: 80%; }
.sk-line.w40 { width: 40%; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---------- 空态 & 页脚 ---------- */
.err-code {
  font-family: var(--serif); font-size: 44px; color: var(--accent);
  margin: 8px 0 4px; opacity: .55;
}
.empty-state {
  text-align: center; padding: 80px 20px;
  border: 1px dashed var(--line); border-radius: 18px; margin-top: 36px;
}
.empty-state p { margin: 4px 0; }
.muted { color: var(--muted); }
.empty-state a { color: var(--accent); }

.foot {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 26px 20px 34px; border-top: 1px solid var(--line);
  margin-top: 20px;
}

@media (max-width: 900px) {
  .card { flex-direction: column; }
  .card-media { order: 2; flex: none; width: 100%; aspect-ratio: 2 / 3; border-left: none; border-top: 1px dashed var(--line); }
  .card-media .media-wp { display: none; }
  .card.has-wp .card-media { flex-basis: auto; }
  .card-body .actions { margin-top: 20px; padding-top: 0; }
  .intro-block { padding: 18px 16px 20px; margin: 0 0 14px; }
  .intro-text { font-size: 15px; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .main { padding-bottom: 36px; }

  /* 顶栏：紧凑单行，触控目标加大 */
  .bar-inner { height: 52px; }
  .brand { font-size: 20px; }
  .nav { gap: 11px; font-size: 13.5px; }
  .nav a, .nav .linkbtn { padding: 7px 2px; }
  .nav-sep, .who { display: none; }
  .linkbtn { font-size: 13.5px; }

  /* 卡片：文字在前（第一屏沉浸），竖版插图垫底 */
  .card { margin: 20px 0 14px; border-radius: 14px; }
  .card-body { padding: 20px 18px 22px; }
  .book-title { font-size: 23px; }
  .passage { padding: 18px 16px; }
  .passage blockquote { font-size: 16.5px; line-height: 1.9; }
  .intro p { font-size: 15px; }
  .wallpaper { margin: 0 0 22px; }

  /* 操作按钮：三等分铺满，触控友好 */
  .actions { gap: 10px; margin-top: 20px; }
  .actions .act { flex: 1; padding: 11px 4px; text-align: center; white-space: nowrap; }
  .actions .act.reroll { margin-left: 0; }

  /* 回看 */
  .page-title { font-size: 22px; margin-top: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .grid-title { font-size: 14.5px; }
  .thumb { width: 88px; }
  .thumb img { width: 88px; height: 58px; }

  /* 发现 & 个人 & 详情 */
  .search-bar { gap: 8px; }
  .search-bar .btn-primary { padding: 11px 18px; }
  .search-card { padding: 12px; gap: 12px; }
  .sc-cover { width: 72px; height: 100px; }
  .sc-intro { font-size: 13px; }
  .sc-gen { padding: 8px 14px; }
  .auth-card { margin-top: 26px; padding: 26px 22px 24px; }
  .wallpaper { padding: 18px 16px 20px; }
  .wp-box img { max-height: 60vh; }
  .wp-row { gap: 10px; }
  .wp-check { font-size: 13.5px; }

  /* 管理端表格横滑 */
  .admin-table { font-size: 12px; min-width: 660px; }
  .admin-table th, .admin-table td { padding: 7px 8px; }
  .admin-stats { gap: 8px; }
  .stat { padding: 10px 4px; }
  .stat b { font-size: 19px; }

  .foot { font-size: 12px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .empty-state { padding: 56px 16px; }
}

@media (max-width: 380px) {
  .nav { gap: 9px; font-size: 13px; }
  .book-title { font-size: 21px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .rating { font-size: 17px; }
}
