/* =========================================
   反信息流卡片 - 样式表
   风格：克制、清爽、低干扰、手机端优先
   ========================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 色彩系统 - 温暖中性 */
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --bg-elevated: #f5f4f0;
  --bg-takeaway: #f0efeb;

  --text-primary: #1a1a18;
  --text-secondary: #6b6b65;
  --text-tertiary: #9e9e96;
  --text-on-accent: #ffffff;

  --accent: #3d6b5e;
  --accent-light: #e8f0ec;
  --accent-hover: #345c51;

  --border: #e8e7e3;
  --border-light: #f0efeb;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

  /* 分类色 */
  --cat-ai-tip: #3d6b5e;
  --cat-ai-term: #5a6b8a;
  --cat-english: #8a6b5a;
  --cat-photo: #6b5a8a;
  --cat-finance: #5a8a6b;
  --cat-product: #8a5a6b;

  /* 布局 */
  --max-width: 420px;
  --page-padding: 20px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Pages --- */
.page {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.page.active {
  display: flex;
}

/* --- 首页 --- */
.home-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 48px;
}

.home-header {
  text-align: center;
}

.home-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.home-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-weight: 300;
}

.home-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-draw {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.btn-draw:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.btn-draw-number {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  font-family: 'Inter', sans-serif;
}

.btn-draw-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.home-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn-text:active {
  color: var(--accent);
}

.home-stats {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* --- 卡片页 --- */
.card-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  flex-shrink: 0;
}

#card-progress-text {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  white-space: nowrap;
}

.progress-bar {
  flex: 1;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* 卡片 */
.card-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-start;
  padding: 8px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  animation: cardFadeIn 0.3s ease;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  color: var(--text-on-accent);
  background: var(--cat-ai-tip);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.card-category[data-cat="AI技巧"] { background: var(--cat-ai-tip); }
.card-category[data-cat="AI名词"] { background: var(--cat-ai-term); }
.card-category[data-cat="英语"] { background: var(--cat-english); }
.card-category[data-cat="摄影"] { background: var(--cat-photo); }
.card-category[data-cat="理财"] { background: var(--cat-finance); }
.card-category[data-cat="产品运营"] { background: var(--cat-product); }

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 16px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-body {
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 20px;
  word-break: break-word;
}

.card-takeaway {
  background: var(--bg-takeaway);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.takeaway-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 500;
}

.takeaway-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.5;
}

/* 为什么适合我 - 折叠 */
.card-why {
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

.why-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  -webkit-tap-highlight-color: transparent;
}

.why-arrow {
  transition: transform 0.2s ease;
}

.why-arrow.open {
  transform: rotate(180deg);
}

.why-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0;
}

.why-content.open {
  max-height: 200px;
  padding: 8px 0;
}

/* 底部操作栏 */
.card-actions {
  display: flex;
  gap: 8px;
  padding: 16px 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.btn-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-action span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.btn-action svg {
  color: var(--text-tertiary);
}

.btn-action:active {
  transform: scale(0.96);
}

.btn-not-for-me:active {
  border-color: #d4a0a0;
  background: #fdf5f5;
}
.btn-not-for-me:active svg { color: #c07070; }

.btn-save:active {
  border-color: var(--accent);
  background: var(--accent-light);
}
.btn-save:active svg { color: var(--accent); }

.btn-save.saved {
  border-color: var(--accent);
  background: var(--accent-light);
}
.btn-save.saved svg {
  color: var(--accent);
  fill: var(--accent);
}

.btn-next {
  border-color: var(--accent);
  background: var(--accent);
}

.btn-next span {
  color: var(--text-on-accent);
}

.btn-next svg {
  color: var(--text-on-accent);
}

.btn-next:active {
  background: var(--accent-hover);
}

/* --- 结束页 --- */
.end-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 36px;
}

.end-header {
  text-align: center;
}

.end-check {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin: 0 auto 12px;
  font-weight: 600;
}

.end-title {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-primary);
}

.end-stats {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.end-stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
}

.end-stat-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.end-stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  font-family: 'Inter', sans-serif;
}

.end-stat-unit {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.end-categories {
  padding: 4px 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.end-cat-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
  background: var(--accent-hover);
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary:active {
  border-color: var(--text-tertiary);
}

/* --- 收藏页 --- */
.saved-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--page-padding);
  min-height: 100vh;
  min-height: 100dvh;
}

.saved-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.btn-back {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}

.btn-back:active {
  background: var(--bg-elevated);
}

.saved-title {
  font-size: 1.1rem;
  font-weight: 500;
  flex: 1;
}

.saved-count {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 2px 10px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
}

.saved-list {
  padding: 8px 0;
}

.saved-empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-tertiary);
}

.saved-empty p {
  margin-bottom: 4px;
}

.saved-empty-hint {
  font-size: 0.82rem;
}

.saved-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.saved-item-category {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-on-accent);
  margin-bottom: 8px;
}

.saved-item-title {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 6px;
  line-height: 1.4;
}

.saved-item-takeaway {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.saved-item-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn-unsave {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn-unsave:active {
  color: #c07070;
}

/* --- 反馈提示 --- */
.toast {
  position: fixed;
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- 桌面端适配 --- */
@media (min-width: 480px) {
  .home-container,
  .card-container,
  .end-container,
  .saved-container {
    padding: 24px;
  }

  .btn-draw {
    width: 100px;
    height: 100px;
  }

  .btn-draw-number {
    font-size: 1.8rem;
  }
}

/* --- 暗色模式（跟随系统） --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-card: #242424;
    --bg-elevated: #2a2a2a;
    --bg-takeaway: #2e2e2a;

    --text-primary: #e8e8e4;
    --text-secondary: #a0a098;
    --text-tertiary: #6e6e68;
    --text-on-accent: #ffffff;

    --accent: #6aaa94;
    --accent-light: #2a3a34;
    --accent-hover: #7abba5;

    --border: #363630;
    --border-light: #2e2e28;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  }
}
