﻿/* ============ 螃蟹书城 全局样式 ============ */
:root {
  --primary: #e8601c;
  --primary-dark: #c94a10;
  --gold: #f0a72c;
  --ink: #2b2119;
  --ink-soft: #6b5d50;
  --bg: #f7f3ec;
  --card: #ffffff;
  --line: #e8e0d3;
  --ok: #1e9e5a;
  --danger: #d63c3c;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(43, 33, 25, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6; min-height: 100vh;
  display: flex; flex-direction: column;
}
body > main, body > .container { flex: 1 0 auto; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
code { background: #f3ede2; padding: 2px 6px; border-radius: 6px; font-size: .92em; word-break: break-all; }

/* ============ 顶部导航 ============ */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 18px; height: 60px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; letter-spacing: .5px; }
.logo-crab { font-size: 26px; }
.logo-lg { font-size: 28px; justify-content: center; }
.main-nav { display: flex; gap: 4px; }
.main-nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink-soft); font-size: 15px; font-weight: 600; }
.main-nav a:hover { background: #fdf0e6; color: var(--primary); }
.main-nav .admin-link { color: var(--primary); }
.header-search { flex: 1; max-width: 320px; display: flex; gap: 6px; }
.header-search input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  background: var(--bg); font-size: 14px; outline: none;
}
.header-search input:focus { border-color: var(--primary); background: #fff; }
.header-search button { border: none; background: var(--primary); color: #fff; border-radius: 10px; padding: 0 14px; font-size: 14px; cursor: pointer; }
.header-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-size: 14px; color: var(--ink-soft); font-weight: 600; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; padding: 10px 20px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s; line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-gold { background: linear-gradient(135deg, #f7b733, #f0a72c); color: #5c3d00; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: #fdf6ee; }
.btn-danger { background: #fdecec; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

/* ============ Hero ============ */
.hero { background: linear-gradient(135deg, #ff9a56 0%, #e8601c 55%, #c94a10 100%); color: #fff; }
.hero-inner { display: flex; align-items: center; justify-content: space-between; padding: 44px 16px; gap: 20px; }
.hero-text h1 { font-size: 30px; margin-bottom: 10px; letter-spacing: 1px; }
.hero-text p { opacity: .92; margin-bottom: 20px; font-size: 15px; }
.hero-search { display: flex; gap: 8px; max-width: 460px; }
.hero-search input {
  flex: 1; border: none; border-radius: 12px; padding: 13px 18px; font-size: 15px; outline: none; box-shadow: var(--shadow);
}
.hero-search button { border: none; border-radius: 12px; padding: 0 24px; background: #2b2119; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
.hero-crab { font-size: 110px; line-height: 1; filter: drop-shadow(0 8px 16px rgba(0,0,0,.25)); animation: wave 3.2s ease-in-out infinite; }
@keyframes wave { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }

/* ============ 分类 & 标题 ============ */
.cat-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 22px 0 4px; }
.cat-chip { padding: 7px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.cat-chip.active, .cat-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.section-title { font-size: 20px; margin: 26px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-count { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

/* ============ 书籍网格 ============ */
.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding-bottom: 30px; }
@media (min-width: 640px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .book-grid { grid-template-columns: repeat(5, 1fr); } }
.book-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s; display: block; }
.book-card:hover { transform: translateY(-4px); }
.book-cover { position: relative; aspect-ratio: 3/4; background: linear-gradient(160deg, #f8e8d8, #f0d5b8); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; color: #a05a20; font-weight: 700; font-size: 16px; }
.cover-fallback-lg { font-size: 22px; }
.cover-badge { position: absolute; left: 8px; top: 8px; background: rgba(232, 96, 28, .92); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.cover-badge-unlocked { background: rgba(30, 158, 90, .92); }
.cover-badge-sold { background: rgba(139, 63, 184, .92); }
.book-meta { padding: 12px; }
.book-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-author { font-size: 13px; color: var(--ink-soft); margin: 3px 0 8px; }
.book-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: #fdf0e6; color: var(--primary); font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.tag-gray { background: #f0ece4; color: var(--ink-soft); }
.tag-free { background: #fff3d6; color: #a06b00; }
.tag-unlocked { background: #e3f6ec; color: var(--ok); }
.tag-sold { background: #f3e8f8; color: #8b3fb8; }

/* ============ 书籍详情 ============ */
.breadcrumb { padding: 16px 0 4px; font-size: 13px; color: var(--ink-soft); }
.breadcrumb a { color: var(--ink-soft); }
.book-detail { display: grid; grid-template-columns: 150px 1fr; gap: 22px; background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin: 14px 0 8px; }
@media (min-width: 720px) { .book-detail { grid-template-columns: 230px 1fr; } }
.book-detail-cover { border-radius: 12px; overflow: hidden; aspect-ratio: 3/4; background: linear-gradient(160deg, #f8e8d8, #f0d5b8); }
.book-detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-detail-info h1 { font-size: 24px; }
.book-detail-author { color: var(--ink-soft); margin: 6px 0 10px; }
.book-detail-intro { color: var(--ink-soft); font-size: 14px; margin: 14px 0; white-space: pre-line; }
.book-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.notice { background: #fdf6ee; border: 1px solid #f3dfc8; border-radius: 12px; padding: 10px 14px; font-size: 13px; color: var(--ink-soft); }
.notice-ok { background: #e3f6ec; border-color: #bfe6d0; color: var(--ok); }
.notice a { font-weight: 700; }

/* ============ 章节列表 ============ */
.chapter-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 40px; }
.chapter-item { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #f2ecdf; color: var(--ink); }
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: #fdf6ee; }
.chapter-num { min-width: 30px; height: 30px; border-radius: 50%; background: #fdf0e6; color: var(--primary); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.chapter-title { flex: 1; font-size: 15px; }
.chapter-go { color: var(--ink-soft); font-size: 13px; }
.chapter-item.locked { opacity: .62; cursor: not-allowed; background: #faf7f1; }
.chapter-lock { font-size: 12px; color: #b08a4e; font-weight: 700; }

/* ============ 阅读页 ============ */
.reader-body { background: #f4efe6; }
.reader-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.reader-header-inner { display: flex; align-items: center; gap: 12px; min-height: 54px; flex-wrap: wrap; padding: 6px 16px; }
.reader-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reader-book { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-chapter { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-controls { display: flex; gap: 6px; }
.reader-main { max-width: 780px; padding-top: 26px; padding-bottom: 50px; }
.reader-chapter-title { font-size: 23px; text-align: center; margin-bottom: 26px; }
.reader-content { font-size: 17px; line-height: 2; font-family: Georgia, "Songti SC", "STSong", "SimSun", serif; }
.reader-content p { text-indent: 2em; margin-bottom: 1.1em; }
.reader-nav { display: flex; justify-content: space-between; gap: 12px; margin: 36px 0 20px; }
.reader-toc { background: var(--card); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.reader-toc summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.reader-toc-list { margin-top: 10px; list-style: none; display: grid; grid-template-columns: 1fr; gap: 2px; max-height: 320px; overflow-y: auto; }
@media (min-width: 720px) { .reader-toc-list { grid-template-columns: 1fr 1fr; } }
.reader-toc-list a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink-soft); font-size: 14px; }
.reader-toc-list a:hover { background: #fdf0e6; color: var(--primary); }
.reader-toc-list a.current { background: var(--primary); color: #fff; font-weight: 700; }

/* ============ 锁定页 ============ */
.locked-box { text-align: center; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 48px 24px; margin: 40px auto; max-width: 560px; }
.locked-icon { font-size: 64px; margin-bottom: 14px; }
.locked-box h1 { font-size: 24px; margin-bottom: 10px; }
.locked-box p { color: var(--ink-soft); margin-bottom: 22px; }
.locked-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ 弹窗 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(30, 22, 15, .55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-mask.hidden { display: none; }
.hidden { display: none !important; }
.modal { background: var(--card); border-radius: 18px; padding: 26px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { font-size: 19px; margin-bottom: 8px; }
.modal-tip { color: var(--ink-soft); font-size: 13px; margin-bottom: 14px; }
.modal input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; font-size: 16px; letter-spacing: 1px; outline: none; }
.modal input:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* ============ 认证页 ============ */
.auth-body { background: linear-gradient(160deg, #ff9a56, #e8601c 60%, #c94a10); align-items: center; justify-content: center; }
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border-radius: 22px; padding: 36px 30px; width: 100%; max-width: 420px; box-shadow: 0 24px 70px rgba(60, 25, 0, .35); }
.auth-card h1 { font-size: 24px; margin-top: 20px; }
.auth-sub { color: var(--ink-soft); font-size: 14px; margin: 4px 0 20px; }
.auth-card label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none; }
.auth-card input:focus { border-color: var(--primary); }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-soft); }

/* ============ 空状态 & 面板 ============ */
.empty-box { text-align: center; background: var(--card); border-radius: var(--radius); padding: 50px 20px; box-shadow: var(--shadow); margin-bottom: 40px; color: var(--ink-soft); }
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px; }
.panel h3 { font-size: 17px; margin-bottom: 14px; }
.panel-narrow { max-width: 560px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.panel label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 6px; }
.panel input[type="text"], .panel input[type="password"], .panel input[type="number"], .panel input[type="search"], .panel select, .panel textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; background: #fff;
}
.panel input:focus, .panel select:focus, .panel textarea:focus { border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-full { grid-column: 1 / -1; } }
.form-stack { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.form-stack input, .form-stack select { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none; }
.inline-form { display: inline; }
.inline-details { display: inline-block; position: relative; }
.inline-details summary { list-style: none; cursor: pointer; }
.inline-details-body { position: absolute; right: 0; top: 36px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 280px; box-shadow: var(--shadow); }
.cover-row { display: flex; gap: 18px; align-items: center; }
.cover-sm { width: 96px; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, #f8e8d8, #f0d5b8); }
.chapter-edit { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
.chapter-edit summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.chapter-edit summary::-webkit-details-marker { display: none; }
.chapter-edit-tools { margin-left: auto; }
.chapter-edit .form-grid { padding: 0 14px 14px; }

/* ============ 管理后台 ============ */
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-nav a { padding: 9px 16px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.admin-nav a.active, .admin-nav a:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-align: center; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid #f2ecdf; text-align: left; vertical-align: middle; }
.table th { font-size: 13px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fdfaf5; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: #e3f6ec; color: var(--ok); }
.badge-gray { background: #f0ece4; color: var(--ink-soft); }
.badge-admin { background: #fdf0e6; color: var(--primary); }
.badge-sold { background: #f3e8f8; color: #8b3fb8; }

/* ============ 页脚 ============ */
.site-footer { background: #2b2119; color: #cbb9a8; text-align: center; padding: 26px 16px; margin-top: 30px; font-size: 13px; }
.site-footer p { margin: 4px 0; }
.footer-muted { opacity: .75; font-size: 12px; }

/* 响应式调整 */
@media (max-width: 720px) {
  .header-inner { height: auto; padding: 10px 16px; gap: 10px; }
  .header-search { order: 4; max-width: none; flex-basis: 100%; }
  .hero-text h1 { font-size: 24px; }
  .hero-crab { font-size: 72px; }
  .book-detail { grid-template-columns: 110px 1fr; padding: 16px; }
  .book-detail-info h1 { font-size: 19px; }
}