/* ========== 基础变量 ========== */
:root {
  --paper: #f7f3ec;
  --paper-alt: #efe7d9;
  --ink: #2b2620;
  --ink-soft: #6b6257;
  --accent: #8b5a2b;
  --accent-deep: #6e4420;
  --red: #9b3d2e;
  --gold: #c8a15a;
  --card: #fffdf8;
  --shadow: 0 8px 24px rgba(43, 38, 32, .10);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Songti SC", "STSong", "SimSun", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 13px; }
.center { text-align: center; }

/* ========== 按钮 ========== */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: all .25s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); box-shadow: 0 4px 12px rgba(110, 68, 32, .35); }
.btn-ghost { background: transparent; color: var(--ink); border-color: #c9bda9; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline { background: transparent; color: #fff; border-color: #fff; }
.btn-outline:hover { background: rgba(255, 255, 255, .15); }
.btn-lg { padding: 12px 32px; font-size: 17px; }
.btn-block { width: 100%; }

/* ========== 导航 ========== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247, 243, 236, .96);
  border-bottom: 1px solid #e2d8c6;
  backdrop-filter: blur(6px);
}
.nav-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  height: 62px; display: flex; align-items: center; gap: 28px;
}
.logo { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: 2px; }
.logo span { color: var(--red); }
.logo:hover { text-decoration: none; }
.nav-links { display: flex; gap: 22px; flex: 1; }
.nav-links a { color: var(--ink); font-size: 15px; }
.nav-links a:hover { color: var(--red); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-user .greet { font-size: 14px; color: var(--accent-deep); }

/* ========== 首屏 ========== */
.hero {
  height: 440px;
  background: url("https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=cozy%20vintage%20bookstore%20interior%2C%20warm%20wooden%20bookshelves%20full%20of%20books%2C%20soft%20sunlight%20through%20window%2C%20reading%20corner%20with%20armchair%2C%20cinematic%20lighting%2C%20inviting%20atmosphere&image_size=landscape_16_9") center/cover no-repeat #3a2f24;
}
.hero-mask {
  height: 100%;
  background: linear-gradient(90deg, rgba(30, 22, 14, .78), rgba(30, 22, 14, .25));
  display: flex; align-items: center;
}
.hero-text { max-width: 1180px; margin: 0 auto; padding: 0 20px; color: #fff; width: 100%; }
.hero-text h1 { font-size: 44px; letter-spacing: 6px; margin-bottom: 14px; }
.hero-text p { font-size: 17px; opacity: .9; margin-bottom: 26px; letter-spacing: 1px; }
.hero-actions { display: flex; gap: 14px; }

/* ========== 区块通用 ========== */
.section { max-width: 1180px; margin: 0 auto; padding: 64px 20px; }
.section-alt { max-width: none; background: var(--paper-alt); }
.section-alt > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.section-title {
  text-align: center; font-size: 30px; letter-spacing: 4px; margin-bottom: 8px;
}
.section-title::after {
  content: ""; display: block; width: 56px; height: 3px;
  background: var(--red); margin: 12px auto 0; border-radius: 2px;
}
.section-sub { text-align: center; color: var(--ink-soft); margin-bottom: 36px; font-size: 14px; }

/* ========== 书籍卡片 ========== */
.book-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px;
}
.book-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .25s, box-shadow .25s;
  display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-6px); box-shadow: 0 14px 30px rgba(43, 38, 32, .16); }
.book-card .cover { height: 240px; overflow: hidden; }
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.book-card:hover .cover img { transform: scale(1.06); }
.book-card .info { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tag {
  display: inline-block; font-size: 12px; color: var(--red);
  border: 1px solid var(--red); border-radius: 4px; padding: 1px 8px;
  width: fit-content;
}
.book-card h3 { font-size: 19px; letter-spacing: 1px; }
.book-card .author-line { font-size: 14px; color: var(--ink-soft); }
.book-card .author-line a { font-weight: 600; }
.price { color: var(--red); font-size: 20px; font-weight: 700; }
.price::before { content: "¥"; font-size: 13px; margin-right: 2px; }
.card-btns { display: flex; gap: 8px; margin-top: auto; padding-top: 10px; }
.card-btns .btn { flex: 1; padding: 7px 0; font-size: 14px; }

/* ========== 团购套餐 ========== */
.pkg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.pkg-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
  border-top: 4px solid var(--gold);
  transition: transform .25s;
}
.pkg-card:hover { transform: translateY(-6px); }
.pkg-covers { display: flex; justify-content: center; }
.pkg-covers img {
  width: 88px; height: 118px; object-fit: cover; border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25); border: 2px solid #fff;
}
.pkg-covers img:not(:first-child) { margin-left: -26px; }
.pkg-card h3 { text-align: center; font-size: 20px; letter-spacing: 2px; }
.pkg-card .desc { font-size: 14px; color: var(--ink-soft); text-align: center; min-height: 48px; }
.pkg-price { text-align: center; }
.pkg-price .price { font-size: 30px; }
.pkg-price del { color: var(--ink-soft); margin-left: 8px; font-size: 14px; }
.pkg-save {
  display: block; width: fit-content; margin: 4px auto 0;
  background: var(--red); color: #fff; font-size: 12px;
  padding: 2px 10px; border-radius: 20px;
}

/* ========== 今日运势 ========== */
.fortune-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.fortune-tube { position: relative; width: 120px; height: 170px; cursor: pointer; }
.tube-body {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 110px; height: 110px; border-radius: 10px 10px 26px 26px;
  background: linear-gradient(160deg, #b3563f, var(--red) 60%, #7c2d20);
  box-shadow: var(--shadow), inset 0 -8px 16px rgba(0, 0, 0, .25);
  display: flex; align-items: center; justify-content: center;
}
.tube-body span {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--gold); color: #5b3a12;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.stick {
  position: absolute; bottom: 96px; width: 10px; border-radius: 5px 5px 0 0;
  background: linear-gradient(#e8d5a8, #d9bf8a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.stick.s1 { left: 22px; height: 62px; transform: rotate(-8deg); }
.stick.s2 { left: 40px; height: 74px; transform: rotate(-3deg); }
.stick.s3 { left: 56px; height: 80px; }
.stick.s4 { left: 72px; height: 70px; transform: rotate(4deg); }
.stick.s5 { left: 88px; height: 58px; transform: rotate(9deg); }
.fortune-tube.shake { animation: shake .8s ease; }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-9deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}
.fortune-result {
  max-width: 460px; width: 100%; min-height: 120px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 30px; text-align: center;
}
.fortune-tip { color: var(--ink-soft); }
.fortune-result .level {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 14px; letter-spacing: 3px; padding: 2px 14px; border-radius: 20px;
}
.fortune-result h3 { font-size: 24px; letter-spacing: 4px; margin: 10px 0 6px; }
.fortune-result .poem { color: var(--accent-deep); font-size: 16px; margin-bottom: 10px; }
.fortune-result .jie { font-size: 14px; color: var(--ink-soft); margin-bottom: 12px; }
.fortune-result .lucky-book { font-size: 14px; }
.fortune-result .lucky-book a { font-weight: 700; }
.fortune-date { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }

/* ========== 购物抽奖 ========== */
.lottery-wrap { display: flex; gap: 40px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.wheel-box { position: relative; width: 340px; height: 340px; flex: none; }
#wheelCanvas {
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(43, 38, 32, .25), 0 0 0 10px #fffdf8, 0 0 0 14px var(--gold);
  transition: transform 4.2s cubic-bezier(.15, .9, .25, 1);
}
.wheel-pointer {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 2;
  border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-top: 26px solid var(--red);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
}
.wheel-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fffdf8;
  background: radial-gradient(circle at 35% 30%, #d96a52, var(--red));
  color: #fff; font-size: 19px; font-family: inherit; font-weight: 700;
  letter-spacing: 2px; cursor: pointer; z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}
.wheel-center:hover { filter: brightness(1.08); }
.wheel-center:disabled { filter: grayscale(.5); cursor: not-allowed; }
.lottery-side { display: flex; flex-direction: column; gap: 16px; width: 300px; }
.lottery-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px;
}
.lottery-card h3 { font-size: 17px; letter-spacing: 2px; margin-bottom: 8px; color: var(--accent-deep); }
.prize-list { list-style: none; font-size: 14px; }
.prize-list li { padding: 3px 0; border-bottom: 1px dashed #e5dcc9; }
.prize-list li:last-child { border-bottom: none; }
.prize-list .time { color: var(--ink-soft); font-size: 12px; margin-left: 6px; }

/* ========== 留言墙 ========== */
.wall-form {
  max-width: 620px; margin: 0 auto 36px;
  display: flex; flex-direction: column; gap: 12px;
}
.wall-form input, .wall-form textarea {
  font-family: inherit; font-size: 15px; padding: 10px 14px;
  border: 1px solid #d8cbb3; border-radius: 8px; background: var(--card);
  resize: vertical;
}
.wall-form input:focus, .wall-form textarea:focus { outline: none; border-color: var(--accent); }
.wall-form .btn { align-self: flex-end; }
.wall-grid { columns: 3; column-gap: 20px; }
.wall-note {
  break-inside: avoid; margin-bottom: 20px; padding: 18px 20px;
  border-radius: 4px 4px 18px 4px; box-shadow: var(--shadow);
  position: relative;
}
.wall-note::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 16px; background: rgba(200, 161, 90, .55); border-radius: 2px;
}
.wall-note .text { font-size: 15px; margin-bottom: 10px; word-break: break-word; }
.wall-note .meta { font-size: 12px; color: var(--ink-soft); text-align: right; }
.wall-note.c0 { background: #fdf3e0; }
.wall-note.c1 { background: #eef3e2; }
.wall-note.c2 { background: #fdeaea; }
.wall-note.c3 { background: #e8f0f7; }
.wall-note.c4 { background: #f4ecF6; }

/* ========== 页脚 ========== */
.footer {
  background: #2b2620; color: #cfc6b8; text-align: center;
  padding: 30px 20px; margin-top: 20px;
}
.footer .muted { color: #8d8477; }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(30, 24, 16, .55);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 30px; position: relative;
  animation: pop .25s ease;
}
.modal-sm { max-width: 420px; }
@keyframes pop {
  from { transform: scale(.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-close {
  position: absolute; top: 12px; right: 16px; z-index: 2;
  background: none; border: none; font-size: 28px; color: var(--ink-soft);
  cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--red); }
.modal-title { letter-spacing: 3px; margin-bottom: 16px; }

/* 登录注册 */
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid #e5dcc9; }
.auth-tab {
  flex: 1; background: none; border: none; font-family: inherit;
  font-size: 17px; letter-spacing: 4px; padding: 10px 0; cursor: pointer;
  color: var(--ink-soft); border-bottom: 3px solid transparent;
}
.auth-tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  font-family: inherit; font-size: 15px; padding: 11px 14px;
  border: 1px solid #d8cbb3; border-radius: 8px; background: #fff;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }

/* 作者弹窗 */
.author-box { display: flex; gap: 24px; }
.author-box img {
  width: 190px; height: 190px; object-fit: cover;
  border-radius: 12px; flex: none; box-shadow: var(--shadow);
}
.author-info h3 { font-size: 24px; letter-spacing: 2px; margin-bottom: 8px; }
.author-info h4 { margin: 14px 0 8px; color: var(--accent-deep); letter-spacing: 2px; }
.author-info p { font-size: 14.5px; text-align: justify; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-row span {
  background: var(--paper-alt); color: var(--accent-deep);
  font-size: 13px; padding: 3px 12px; border-radius: 20px;
}
#authorBooks a { display: inline-block; margin-right: 16px; font-weight: 600; }

/* 书籍详情弹窗 */
.book-box { display: flex; gap: 24px; }
.book-box > img {
  width: 220px; height: 290px; object-fit: cover;
  border-radius: 10px; flex: none; box-shadow: var(--shadow);
}
.book-info h3 { font-size: 26px; letter-spacing: 2px; margin: 6px 0 2px; }
.book-info .summary { font-size: 14.5px; margin: 12px 0; text-align: justify; }
.book-info h4 { color: var(--accent-deep); letter-spacing: 2px; margin-bottom: 8px; }
#bmQuotes blockquote {
  border-left: 3px solid var(--gold); padding: 4px 0 4px 14px;
  margin-bottom: 10px; font-size: 14.5px; color: #4a4238;
  background: linear-gradient(90deg, rgba(200, 161, 90, .10), transparent);
}
.buy-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.buy-row .price { font-size: 28px; }

/* 购买弹窗 */
.buy-covers { display: flex; justify-content: center; margin-bottom: 12px; }
.buy-covers img {
  width: 76px; height: 100px; object-fit: cover; border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .22); border: 2px solid #fff;
}
.buy-covers img:not(:first-child) { margin-left: -20px; }
.buy-name { text-align: center; font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.buy-detail > .muted { text-align: center; margin: 4px 0 10px; }
.qty-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
.qty-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid #d8cbb3;
  background: #fff; font-size: 17px; cursor: pointer;
}
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
#buyQty {
  width: 52px; text-align: center; font-size: 15px; font-family: inherit;
  border: 1px solid #d8cbb3; border-radius: 6px; padding: 4px 0;
}
.buy-total {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--paper-alt); border-radius: 8px; padding: 10px 16px; margin: 12px 0;
  font-size: 14px;
}
.buy-total .price { font-size: 24px; }
.ext-links { text-align: center; margin-top: 12px; font-size: 13px; }
.ext-links a { margin: 0 6px; }

/* ========== 轻提示 ========== */
.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%) translateY(20px);
  background: rgba(43, 38, 32, .92); color: #fff;
  padding: 11px 26px; border-radius: 24px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 300;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== 响应式 ========== */
@media (max-width: 960px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
  .pkg-grid { grid-template-columns: 1fr; }
  .wall-grid { columns: 2; }
  .book-box, .author-box { flex-direction: column; align-items: center; }
  .book-box > img { width: 170px; height: 225px; }
}
@media (max-width: 620px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .nav-links { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; gap: 14px; }
  .hero { height: 340px; }
  .hero-text h1 { font-size: 30px; }
  .book-grid { grid-template-columns: 1fr; }
  .wall-grid { columns: 1; }
  .lottery-wrap { gap: 24px; }
  .wheel-box { width: 300px; height: 300px; }
  #wheelCanvas { width: 300px; height: 300px; }
}
