/* ============ 趋势猫读书 - 前台样式 ============ */
:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fff1e6;
  --blue: #3b82f6;
  --blue-light: #eff6ff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #ede7dd;
  --shadow: 0 2px 12px rgba(120, 90, 40, 0.08);
  --shadow-hover: 0 8px 24px rgba(120, 90, 40, 0.16);
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- 演示模式提示条 ---------- */
.demo-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}
.demo-banner code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- 顶部 ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow);
}
.brand-text h1 {
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--text);
}
.slogan {
  font-size: 12.5px;
  color: var(--text-light);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.search-box {
  position: relative;
  flex: 0 1 320px;
  min-width: 220px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}
#search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
}
#search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
  background: #fff;
}

.btn-random {
  border: none;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
  transition: all 0.18s;
}
.btn-random:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.42);
}
.btn-random:active { transform: translateY(0); }
.btn-random:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- 主体 ---------- */
.container {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
}

.filter-section { margin-bottom: 18px; }
.filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}
.dot-blue { background: var(--blue); }

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pill {
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.pill:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  transform: translateY(-1px);
}
.pill .count {
  font-size: 11.5px;
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--text-light);
}
.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}
.pill.active .count { background: rgba(255,255,255,0.25); color: #fff; }

.pill-blue.active {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ---------- 统计条 ---------- */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 18px;
  font-size: 13.5px;
  color: var(--text-light);
}
.filter-text {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12.5px;
}

/* ---------- 书籍卡片 ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.book-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(237, 231, 221, 0.6);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.35s ease both;
}
.book-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), #fbbf24);
  opacity: 0;
  transition: opacity 0.2s;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.book-card:hover::before { opacity: 1; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.book-no {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background: var(--blue-light); color: #1d4ed8; }

.book-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}
.book-idea {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  font-size: 12px;
  color: #c9c2b6;
  margin-top: auto;
  padding-top: 4px;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-light);
}
.empty-emoji { font-size: 52px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
.empty-hint { font-size: 13px; margin-top: 6px; color: #b3aca0; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}
.page-btn {
  border: 1.5px solid var(--border);
  background: var(--card);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.18s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13.5px; color: var(--text-light); padding: 0 8px; }

/* ---------- 详情弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, 0.45);
  backdrop-filter: blur(2px);
}
.modal-body {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 30px 30px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: popIn 0.25s ease both;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-right: 44px; /* 给右上角关闭按钮让位，避免挡住最后一个标签 */
}
.modal-no {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}
.modal-tags { display: flex; gap: 6px; }
.modal-body h2 {
  font-size: 24px;
  line-height: 1.4;
  margin-bottom: 4px;
}
.modal-divider {
  height: 3px;
  width: 44px;
  background: linear-gradient(90deg, var(--primary), #fbbf24);
  border-radius: 3px;
  margin: 12px 0 16px;
}
.modal-idea {
  font-size: 15px;
  line-height: 2;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-foot {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.btn-copy {
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-copy:hover { background: var(--primary); color: #fff; }
.modal-close-bottom {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  font-size: 22px;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
  flex: 0 0 auto;
  transition: all 0.15s;
}
.modal-close-bottom:hover { background: #fee2e2; color: #dc2626; }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 22px 16px 28px;
  color: #b3aca0;
  font-size: 13px;
}
.site-footer a { color: #c9a06c; text-decoration: none; }
.site-footer a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- 动画 ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.loading-mini { color: var(--text-light); font-size: 13px; padding: 6px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .header-inner { padding: 12px 16px; }
  .logo { width: 46px; height: 46px; }
  .brand-text h1 { font-size: 19px; }
  .search-box { flex: 1 1 100%; order: 3; }
  .btn-random { flex: 0 0 auto; padding: 9px 14px; font-size: 13px; }
  .container { padding: 18px 14px 40px; }
  .tag-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .tag-pills::-webkit-scrollbar { display: none; }
  .book-grid { grid-template-columns: 1fr; gap: 14px; }
  .modal-body { padding: 24px 20px 20px; }
}

/* ---------- 头部用户区 ---------- */
.header-right { display: flex; align-items: center; gap: 10px; }
.btn-ghost {
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.18s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-dark); }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-name {
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 14px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-status {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 阅读状态筛选 ---------- */
.dot-green { background: #10b981; }

/* ---------- 卡片标记 ---------- */
.badge-read { background: #d1fae5; color: #047857; }
.badge-fav { background: #fef3c7; color: #b45309; }

/* ---------- 收藏按钮 ---------- */
.btn-fav {
  border: 1.5px solid #fbbf24;
  background: #fffbeb;
  color: #b45309;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-fav:hover { background: #fbbf24; color: #fff; }
.btn-fav.faved { background: #fbbf24; color: #fff; border-color: #f59e0b; }

/* ---------- 登录 / 注册弹窗 ---------- */
.auth-body { max-width: 380px; }
.auth-body h2 { font-size: 22px; text-align: center; margin-bottom: 16px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1;
  padding: 9px 0;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.18s;
}
.auth-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.auth-fields { display: flex; flex-direction: column; gap: 12px; }
.auth-fields input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
}
.auth-fields input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}
.auth-submit {
  border: none;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s;
}
.auth-submit:hover { opacity: 0.95; }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-error { color: #dc2626; font-size: 13px; text-align: center; }
.auth-tip { color: var(--text-light); font-size: 12.5px; text-align: center; }
.auth-notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 8px;
  text-align: center;
}

/* ---------- AI 读书问答 ---------- */
.ai-chat {
  background: linear-gradient(135deg, #fff7ed, #fff);
  border: 1.5px solid #fde68a;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}
.ai-chat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ai-chat-icon { font-size: 30px; line-height: 1; }
.ai-chat-head h2 { font-size: 18px; margin: 0; color: var(--text); }
.ai-chat-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-light); }
.ai-chat-samples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ai-sample {
  padding: 6px 13px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
}
.ai-sample:hover { border-color: var(--primary); color: var(--primary-dark); }
.ai-chat-input { display: flex; gap: 10px; }
.ai-chat-input input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  color: var(--text);
  transition: border-color 0.2s;
}
.ai-chat-input input:focus { border-color: var(--primary); }
#ai-send {
  padding: 0 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#ai-send:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-answer { margin-top: 16px; padding: 14px 16px; background: #fff; border-radius: 12px; border: 1px solid #f3efe7; }
.ai-answer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ai-answer-label { font-size: 13px; color: var(--text-light); }
.ai-copy {
  padding: 5px 13px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
}
.ai-copy:hover { border-color: var(--primary); color: var(--primary-dark); }
.ai-answer-text { font-size: 14.5px; line-height: 1.75; white-space: pre-wrap; color: var(--text); }
.ai-answer-err { font-size: 13.5px; color: #dc2626; }
.ai-loading { font-size: 13.5px; color: var(--text-light); }
.ai-books { margin-top: 12px; }
.ai-books-title { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.ai-book {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  margin: 0 8px 8px 0;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-book:hover { border-color: var(--primary); }
.ai-book-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.ai-book-tag { font-size: 12px; color: #b45309; }

/* ---------- 个人中心 ---------- */
.pc-section { margin-bottom: 36px; }
.pc-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.pc-count { font-size: 13px; color: var(--text-light); font-weight: 400; }

@media (max-width: 640px) {
  .header-right { flex-wrap: wrap; }
}
