/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --paper: #f3ecdc;
  --card: #faf6ea;
  --ink: #2c2820;
  --ink-soft: #7a7263;
  --line: #ded2b8;
  --accent: #24424a;
  --accent-dark: #1a3238;
  --gold: #b9954f;
  --gold-soft: #d9c08a;
  --night: #12191b;
  --danger: #a34a3a;
  --font-serif: "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
  --font-hand: "Ma Shan Zheng", "Kaiti SC", cursive;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(255,255,255,.5), transparent 60%), var(--paper);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }
input, button, textarea, select { font: inherit; }
#app { min-height: 100vh; }
.page { padding-bottom: 118px; }

/* ============ 顶部栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(243,236,220,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--font-serif); }
.brand-mark { font-size: 22px; color: var(--gold); }
.brand-name { font-size: 17px; font-weight: 600; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-item { font-size: 14px; color: var(--ink-soft); min-height: 44px; display: inline-flex; align-items: center; }
.topbar-item.topbar-hide-mobile { display: none; }
.topbar-avatar { display: block; border-radius: 50%; border: 2px solid transparent; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 26px; border-radius: 40px; border: 1px solid transparent;
  font-family: var(--font-body); font-size: 15px; cursor: pointer; transition: all .25s;
  letter-spacing: 1px; min-height: 44px; touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: #f6efdd; box-shadow: 0 6px 18px rgba(36,66,74,.25); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(163,74,58,.5); }
.btn-small { padding: 6px 16px; font-size: 13px; border-radius: 20px; min-height: 38px; }
.btn-block { width: 100%; }
.btn-file { position: relative; overflow: hidden; }

/* ============ 头像 ============ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden; flex: none;
  background: var(--accent); color: #f6efdd;
  font-family: var(--font-serif); font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.size-38 { width: 38px; height: 38px; font-size: 17px; }
.size-36 { width: 36px; height: 36px; font-size: 16px; }
.size-56 { width: 56px; height: 56px; font-size: 24px; }
.size-96 { width: 96px; height: 96px; font-size: 40px; }

/* ============ 书封面 ============ */
.landing {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background:
    radial-gradient(1000px 700px at 70% 20%, rgba(232,195,106,.12), transparent 60%),
    radial-gradient(900px 600px at 20% 90%, rgba(36,66,74,.5), transparent 60%),
    var(--night);
  perspective: 1400px;
}
.cover-scene { display: flex; flex-direction: column; align-items: center; gap: 30px; animation: rise 1.1s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(34px); } to { opacity: 1; transform: translateY(0); } }
.book-cover {
  width: min(76vw, 320px); height: auto; aspect-ratio: 340 / 472;
  border-radius: 6px 14px 14px 6px;
  background: linear-gradient(160deg, #27464e 0%, #16282d 70%);
  box-shadow: 0 24px 60px rgba(0,0,0,.5), 10px 0 26px rgba(0,0,0,.3), inset 0 0 60px rgba(0,0,0,.35);
  position: relative; transform-style: preserve-3d; transform-origin: left center;
  transition: transform .9s cubic-bezier(.6,.1,.2,1), opacity .9s;
}
.book-cover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
  background: linear-gradient(90deg, rgba(0,0,0,.35), transparent 70%);
  border-right: 1px solid rgba(255,255,255,.08); z-index: 2;
}
.cover-inner {
  position: relative; height: 100%; padding: 24px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  border: 1px solid rgba(240,228,196,.35); border-radius: inherit;
}
.cover-top { font-family: var(--font-hand); font-size: 16px; color: rgba(240,228,196,.85); letter-spacing: 5px; }
.cover-illus { width: 100%; }
.cover-illus svg { width: 100%; height: auto; display: block; }
.cover-title {
  font-family: var(--font-serif); font-size: 48px; font-weight: 700;
  color: #f2e7cf; letter-spacing: 10px; text-shadow: 0 3px 20px rgba(0,0,0,.4);
}
.cover-sub { font-family: var(--font-serif); font-size: 12px; color: var(--gold-soft); letter-spacing: 5px; }
.cover-line { width: 70%; height: 1px; background: linear-gradient(90deg, transparent, rgba(240,228,196,.7), transparent); }
.cover-bottom { font-family: var(--font-hand); font-size: 15px; color: rgba(240,228,196,.8); letter-spacing: 3px; }
.book-cover.turning { transform: rotateY(-112deg); opacity: 0; }
.btn-cover {
  font-family: var(--font-hand); font-size: 19px; letter-spacing: 6px;
  color: #f2e7cf; background: transparent; border: 1px solid rgba(240,228,196,.45);
  padding: 12px 40px; border-radius: 40px; cursor: pointer; min-height: 52px; touch-action: manipulation;
}
@media (max-height: 560px) {
  .cover-scene { gap: 16px; }
  .book-cover { width: min(52vh, 280px); }
  .btn-cover { padding: 8px 32px; font-size: 16px; }
}

/* ============ 通用页面头 ============ */
.page-head { text-align: center; padding: 40px 16px 22px; }
.page-head .eyebrow { display: block; font-family: var(--font-hand); font-size: 18px; color: var(--gold); margin-bottom: 8px; letter-spacing: 4px; }
.page-head h1 { font-family: var(--font-serif); font-size: 30px; font-weight: 700; letter-spacing: 5px; }
.page-head p { color: var(--ink-soft); margin-top: 8px; font-size: 14px; }
.breadcrumb { padding: 14px 16px 0; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb a:hover { color: var(--gold); }
.notfound { text-align: center; padding: 100px 20px; color: var(--ink-soft); font-family: var(--font-serif); font-size: 18px; }
.empty-hint { text-align: center; color: var(--ink-soft); font-family: var(--font-serif); font-size: 15px; padding: 46px 20px; }

/* ============ 登录 ============ */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px 22px;
  box-shadow: 0 20px 60px rgba(70,60,40,.12);
}
.login-head { text-align: center; margin-bottom: 26px; }
.login-cat { font-size: 34px; color: var(--gold); }
.login-head h2 { font-family: var(--font-serif); font-size: 26px; letter-spacing: 4px; margin-top: 6px; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }
.login-tabs { display: flex; gap: 10px; margin-bottom: 22px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: transparent;
  border-radius: 30px; font-size: 14px; color: var(--ink-soft); cursor: pointer; min-height: 44px;
}
.tab.active { background: var(--accent); color: #f6efdd; border-color: var(--accent); }
#loginForm label { display: block; font-size: 13px; color: var(--ink-soft); margin: 16px 0 6px; }
#loginForm input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: #fffdf7; font-size: 16px; color: var(--ink); min-height: 48px;
}
#loginForm input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,66,74,.12); }
#confirmRow { display: none; }
#loginForm.register-mode #confirmRow { display: block; }
.login-error { min-height: 20px; margin-top: 12px; color: var(--danger); font-size: 13px; }
#loginForm .btn { margin-top: 14px; }
.demo-tip {
  margin-top: 24px; padding: 14px 16px; background: #f5eeda;
  border: 1px dashed var(--gold-soft); border-radius: 10px; font-size: 12px; color: var(--ink-soft);
}
.demo-tip p { margin: 4px 0; }

/* ============ 书架 ============ */
.menu-hero { text-align: center; padding: 40px 16px 22px; }
.menu-greet { font-family: var(--font-serif); font-size: 26px; letter-spacing: 4px; }
.menu-quote { margin-top: 12px; color: var(--ink-soft); font-size: 13.5px; font-family: var(--font-serif); }
.quote-author { display: block; margin-top: 4px; font-size: 12.5px; color: var(--gold); }
.menu-cards { max-width: 880px; margin: 24px auto 0; padding: 0 16px; display: grid; grid-template-columns: 1fr; gap: 16px; }
.menu-card {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 22px 20px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  overflow: hidden; transition: transform .25s, box-shadow .25s; touch-action: manipulation;
}
.menu-main { background: linear-gradient(135deg, #24424a, #16282d); color: #f2e7cf; border-color: transparent; box-shadow: 0 14px 36px rgba(22,40,45,.4); }
.menu-card-badge {
  position: absolute; top: 0; left: 0; padding: 6px 16px;
  background: var(--gold); color: #2b2820; font-size: 12px; font-weight: 700;
  border-radius: 0 0 12px 0; letter-spacing: 2px;
}
.menu-card-content h3 { font-family: var(--font-serif); font-size: 20px; letter-spacing: 3px; }
.menu-main .menu-card-content h3 { font-size: 26px; }
.menu-card-content p { font-size: 13px; opacity: .8; margin-top: 6px; }
.menu-card-meta {
  display: inline-block; margin-top: 14px; font-size: 12.5px; opacity: .8;
  border: 1px solid rgba(255,255,255,.35); padding: 3px 12px; border-radius: 20px;
}
.menu-card-icon { font-size: 30px; color: var(--gold); flex: none; }
.menu-main .menu-card-icon { font-size: 38px; }
.menu-card-arrow { margin-left: auto; font-size: 26px; opacity: .7; }

/* ============ 章节 / 节列表 ============ */
.chapter-list { max-width: 680px; margin: 26px auto 0; padding: 0 16px; display: grid; gap: 16px; }
.chapter-card {
  display: flex; align-items: center; gap: 14px; padding: 20px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; min-height: 60px; touch-action: manipulation;
}
.chapter-num { font-family: var(--font-hand); font-size: 22px; color: var(--gold); min-width: 84px; }
.chapter-body h3 { font-family: var(--font-serif); font-size: 19px; letter-spacing: 2px; }
.chapter-body p { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.chapter-arrow { margin-left: auto; color: var(--gold); font-size: 20px; }
.section-list { max-width: 680px; margin: 24px auto 0; padding: 0 16px; display: grid; gap: 12px; }
.section-card {
  display: flex; align-items: center; gap: 18px; padding: 18px 20px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; min-height: 56px; touch-action: manipulation;
}
.section-index { font-family: var(--font-hand); font-size: 24px; color: var(--accent); min-width: 42px; text-align: center; }
.section-body h3 { font-size: 16.5px; font-family: var(--font-serif); letter-spacing: 1px; }
.section-body p { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.section-arrow { margin-left: auto; color: var(--gold); }

/* ============ 个人章 / 设定卡片 ============ */
.article-grid { max-width: 760px; margin: 26px auto 0; padding: 0 16px; display: grid; grid-template-columns: 1fr; gap: 16px; }
.article-card { padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; touch-action: manipulation; }
.article-card .card-ico { font-size: 26px; margin-bottom: 12px; color: var(--gold); }
.article-card h3 { font-family: var(--font-serif); font-size: 20px; letter-spacing: 2px; }
.article-card p { font-size: 13px; color: var(--ink-soft); margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-card .card-meta { font-size: 12px; color: var(--gold); margin-top: 12px; }

/* ============ 阅读页 ============ */
.reading {
  max-width: 720px; margin: 16px 12px 0; padding: 32px 22px 34px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(70,60,40,.08); touch-action: pan-y;
}
.reading-head { text-align: center; margin-bottom: 26px; }
.reading-head .eyebrow { font-family: var(--font-hand); font-size: 17px; color: var(--gold); letter-spacing: 3px; }
.reading-head h1 { font-family: var(--font-serif); font-size: 26px; letter-spacing: 3px; margin-top: 10px; }
.reading-divider { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; color: var(--gold-soft); }
.reading-divider::before, .reading-divider::after { content: ""; height: 1px; width: 60px; }
.reading-divider::before { background: linear-gradient(90deg, transparent, var(--gold-soft)); }
.reading-divider::after { background: linear-gradient(90deg, var(--gold-soft), transparent); }
.reading-content { font-family: var(--font-serif); }
.reading-content p { margin: 0 0 1.4em; line-height: 2.05; text-align: justify; font-size: clamp(15.5px, 4.6vw, 17px); color: #33302a; text-indent: 2em; }
.reading-content .char-block p { text-indent: 0; }
.char-block { background: #faf5e7; border: 1px solid #e8dcc0; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.char-name { font-size: 18px; font-weight: 700; color: var(--accent); }
.char-note { font-size: 13px; color: var(--gold); margin-left: 6px; font-family: var(--font-body); font-weight: 500; }
.char-meta { font-size: 13px; color: var(--ink-soft); margin: 6px 0 10px; font-family: var(--font-body); }
.char-desc { line-height: 1.95; }
.reading-foot { text-align: center; margin-top: 20px; color: var(--gold); font-family: var(--font-hand); font-size: 16px; letter-spacing: 4px; }
.reading-nav { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 20px; border-top: 1px dashed var(--line); }
.reading-swipe-hint { display: block; text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 16px; opacity: .7; }

/* ============ 留言 ============ */
.comments { max-width: 720px; margin: 26px auto 0; padding: 0 12px; }
.comments-title { font-family: var(--font-serif); font-size: 21px; letter-spacing: 2px; margin-bottom: 16px; }
.comments-count { font-size: 13px; color: var(--gold); }
.comment-login-tip { background: var(--card); border: 1px dashed var(--line); padding: 18px; border-radius: 12px; text-align: center; color: var(--ink-soft); font-size: 14px; margin-bottom: 16px; }
.comment-form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 20px; }
.comment-form-head { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 12px; }
.comment-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; padding: 12px 14px; font-family: var(--font-body); font-size: 16px; resize: vertical; min-height: 84px; }
.comment-form textarea:focus { outline: none; border-color: var(--accent); }
.comment-form-foot { text-align: right; margin-top: 10px; }
.comments-list { display: grid; gap: 14px; }
.comment { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.comment-name { font-weight: 600; font-size: 14px; }
.comment-time { font-size: 12px; color: var(--ink-soft); }
.comment-head { display: flex; align-items: baseline; gap: 10px; }
.comment-content { margin-top: 6px; font-size: 14.5px; line-height: 1.8; }
.comments-empty { text-align: center; color: var(--ink-soft); font-size: 14px; padding: 30px 0; }

/* ============ 个人中心 ============ */
.profile-card { max-width: 520px; margin: 28px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 34px 22px; text-align: center; }
.profile-card h2 { font-family: var(--font-serif); font-size: 26px; margin-top: 14px; letter-spacing: 3px; }
.profile-role { display: inline-block; margin-top: 8px; font-size: 12px; background: rgba(36,66,74,.1); color: var(--accent); padding: 3px 14px; border-radius: 20px; }
.profile-since { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }
.profile-avatar-edit { text-align: left; margin-top: 30px; padding-top: 24px; border-top: 1px dashed var(--line); }
.profile-avatar-edit h3 { font-size: 16px; font-family: var(--font-serif); }
.profile-avatar-edit .hint { font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 14px; }
.avatar-edit-row { margin: 10px 0; }
.avatar-edit-row input[type=text] { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; font-size: 16px; min-height: 48px; }
.avatar-preview { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--ink-soft); }
.profile-actions { margin-top: 30px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ 管理后台 ============ */
.admin-nav { display: flex; gap: 8px; justify-content: center; margin-top: 26px; }
.admin-nav a { padding: 8px 22px; border: 1px solid var(--line); border-radius: 30px; font-size: 14px; color: var(--ink-soft); background: var(--card); min-height: 44px; display: inline-flex; align-items: center; }
.admin-nav a.active { background: var(--accent); color: #f6efdd; border-color: var(--accent); }
.admin-head { max-width: 900px; margin: 26px auto 14px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-head h2 { font-family: var(--font-serif); font-size: 24px; letter-spacing: 2px; }
.admin-table-wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 13px; min-width: 620px; }
.admin-table th, .admin-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table th { background: #f0e7d2; font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .td-title { font-family: var(--font-serif); max-width: 180px; white-space: normal; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; }
.tag-main { background: rgba(36,66,74,.12); color: var(--accent); }
.tag-personal { background: rgba(185,149,79,.16); color: #8a6a2f; }
.tag-settings { background: rgba(122,114,99,.14); color: var(--ink-soft); }
.admin-form-wrap { max-width: 720px; margin: 26px auto 0; padding: 0 12px; }
.admin-form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px 20px; }
.form-row { margin-bottom: 20px; }
.form-row label { display: block; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 7px; }
.form-row .hint { color: var(--gold); }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; font-size: 16px; font-family: var(--font-body); min-height: 48px; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { outline: none; border-color: var(--accent); }
.form-row textarea { resize: vertical; line-height: 1.8; min-height: 200px; }
.form-row.inline { display: flex; flex-direction: column; gap: 0; }
.form-row.inline > div { flex: 1; }
.denied { text-align: center; padding: 100px 20px; color: var(--ink-soft); font-family: var(--font-serif); font-size: 18px; }

/* ============ 底部导航 ============ */
.bottom-nav {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(250,246,234,.97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
}
.bottom-nav .bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 9px 0 7px; color: var(--ink-soft); font-size: 11px; letter-spacing: 1px;
  min-height: 56px; touch-action: manipulation;
}
.bottom-nav .bn-item .bn-ico { font-size: 19px; line-height: 1; }
.bottom-nav .bn-item.active { color: var(--accent); font-weight: 700; }
.bottom-nav .bn-item.active .bn-ico { color: var(--gold); }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: var(--accent); color: #f6efdd; padding: 12px 26px; border-radius: 40px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .35s;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (max-width: 360px) {
  .reading { margin: 12px 8px 0; padding: 26px 18px 30px; }
  .menu-card-content h3 { font-size: 18px; }
}