/* ===== 主题变量 ===== */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-input: #f1f3f5;
  --border: #e9ecef;
  --text: #212529;
  --text-secondary: #868e96;
  --text-muted: #adb5bd;
  --accent: #ff6b6b;
  --accent-light: #fff5f5;
  --like: #51cf66;
  --like-light: #f0fff4;
  --dislike: #ff6b6b;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  --bg: #1a1b1e;
  --bg-card: #25262b;
  --bg-input: #2c2e33;
  --border: #373a40;
  --text: #e9ecef;
  --text-secondary: #909296;
  --text-muted: #5c5f66;
  --accent: #ff6b6b;
  --accent-light: rgba(255, 107, 107, 0.1);
  --like: #51cf66;
  --like-light: rgba(81, 207, 102, 0.1);
  --dislike: #ff6b6b;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ===== 页面管理 ===== */
.page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}
.page.active {
  display: flex;
}

/* ===== 首页 ===== */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.home-title {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.home-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.input-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
textarea {
  height: 80px;
  resize: none;
}

.start-btn {
  width: 100%;
  padding: 15px;
  background: var(--text);
  border: none;
  border-radius: 12px;
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}
.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.disclaimer {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.home-favorites-btn {
  margin-top: 20px;
  padding: 12px 24px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.home-favorites-btn:hover {
  color: var(--accent);
}

/* ===== 推荐页 ===== */
.recommend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}
.back-btn:hover {
  background: var(--bg-input);
  color: var(--text);
}

.favorites-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.favorites-link:hover {
  background: var(--bg-input);
  color: var(--accent);
}

/* ===== 卡片容器 ===== */
.card-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ===== 加载中 ===== */
.loading-card {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 书籍卡片 ===== */
.book-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.35s ease;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.preloading-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.mini-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.card-author {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.card-synopsis {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 16px;
  background: var(--bg-input);
  border-radius: 12px;
  margin-bottom: 20px;
}

.card-reason {
  margin-bottom: 28px;
}

.reason-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-reason p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* ===== 操作按钮 ===== */
.card-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 28px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.action-btn.dislike {
  border-color: var(--dislike);
  color: var(--dislike);
}
.action-btn.dislike:hover {
  background: var(--accent-light);
  transform: scale(1.1);
}
.action-btn.like {
  border-color: var(--like);
  color: var(--like);
}
.action-btn.like:hover {
  background: var(--like-light);
  transform: scale(1.1);
}
.action-btn:active {
  transform: scale(0.95);
}

/* ===== 收藏页 ===== */
.favorites-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 16px;
  font-weight: 600;
}

.clear-all-btn {
  padding: 6px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.clear-all-btn:hover {
  border-color: var(--dislike);
  color: var(--dislike);
}

.favorites-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 15px;
}

.favorite-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}
.favorite-item:hover {
  border-color: var(--accent);
}

.favorite-info {
  flex: 1;
}

.favorite-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.favorite-author {
  font-size: 13px;
  color: var(--text-secondary);
}

.remove-btn {
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.remove-btn:hover {
  border-color: var(--dislike);
  color: var(--dislike);
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  .home-title { font-size: 32px; }
  .input-card { padding: 24px; }
  .book-card { padding: 24px; }
  .card-title { font-size: 24px; }
  .action-btn { width: 64px; height: 64px; font-size: 24px; }
}
