/* R117 积分打卡系 — style.css */
:root, [data-theme="light"] {
  --primary: #FF6B35;
  --accent: #FFD700;
  --success: #4CAF50;
  --danger: #F44336;
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --text: #2D2D2D;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --nav-height: 56px;
  --contact-footer-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --transition: 300ms ease;
  --font-xs: 12px;
  --font-sm: 14px;
  --font-md: 16px;
  --font-lg: 20px;
  --font-xl: 28px;
  --font-xxl: 36px;
  --max-width: 480px;
}

[data-theme="dark"] {
  --bg: #121212;
  --card: #1E1E1E;
  --text: #E0E0E0;
  --text-secondary: #9E9E9E;
  --border: #333333;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="brand"] {
  --bg: #FF6B35;
  --card: #FFFFFF;
  --text: #FFFFFF;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + var(--contact-footer-h) + var(--safe-bottom) + 8px);
}
body.has-contact-footer { padding-bottom: calc(var(--nav-height) + var(--contact-footer-h) + var(--safe-bottom) + 8px); }

#app { max-width: var(--max-width); margin: 0 auto; }

.page { display: none; }
.page.active { display: block; }

.section-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 12px 14px;
  padding: 14px;
}
.section-title { margin: 0 0 12px; font-size: var(--font-md); }

/* Hero */
.hero-section {
  text-align: center;
  padding: 24px 16px 8px;
  position: relative;
}
.hero-slogan { color: var(--text-secondary); font-size: var(--font-sm); margin: 0 0 12px; }
.streak-wrap { font-size: var(--font-md); margin-bottom: 16px; }
.streak-flame { display: inline-block; animation: flamePulse 2s ease-in-out infinite; }
.checkin-btn {
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: var(--font-md); font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,107,53,0.4);
  position: relative; overflow: hidden;
}
.checkin-btn:not(.checked) { animation: breathe 3s ease-in-out infinite; }
.checkin-btn.checked { background: var(--success); animation: none; }
.today-points-wrap { margin-top: 14px; font-size: var(--font-sm); color: var(--text-secondary); }
.today-points { color: var(--primary); font-weight: 700; font-size: var(--font-lg); }

/* Dashboard */
.points-widget {
  margin: 0 14px 8px; padding: 16px; border-radius: var(--radius-lg);
  text-align: center; background: var(--card); box-shadow: var(--shadow);
}
.points-widget.glass {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
[data-theme="dark"] .points-widget.glass { background: rgba(30,30,30,0.85); }
.points-big { font-size: var(--font-xxl); font-weight: 800; color: var(--primary); line-height: 1.1; }
.points-trend { font-size: var(--font-sm); color: var(--success); margin-top: 4px; }

.dashboard-cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 0 14px 12px;
}
.dash-card {
  background: var(--card); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; box-shadow: var(--shadow);
}
.dash-card__value { font-size: var(--font-lg); font-weight: 700; color: var(--primary); }
.dash-card__label { font-size: var(--font-xs); color: var(--text-secondary); margin-top: 4px; }

.progress-rings {
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 14px 16px; flex-wrap: wrap;
}
.progress-ring { position: relative; text-align: center; }
.progress-ring__bg { fill: none; stroke: var(--border); stroke-width: 6; }
.progress-ring__circle {
  fill: none; stroke-width: 6; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset 800ms cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-ring__label { display: block; font-size: 10px; color: var(--text-secondary); margin-top: -6px; }

/* Calendar */
.calendar-nav {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.cal-nav-btn {
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: var(--bg); color: var(--text); font-size: 18px; cursor: pointer;
}
.cal-title { font-weight: 600; }
.calendar-header { font-size: var(--font-sm); color: var(--text-secondary); margin-bottom: 10px; }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-day-header {
  text-align: center; font-size: 10px; color: var(--text-secondary); padding: 4px 0;
}
.calendar-cell {
  aspect-ratio: 1; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: var(--font-xs);
}
.calendar-cell.checked { background: #C8E6C9; color: #2E7D32; }
.calendar-cell.missed { border: 1px dashed #EF9A9A; color: #C62828; }
.calendar-cell.missed.clickable { cursor: pointer; }
.calendar-cell.makeup { background: #FFE0B2; color: #E65100; }
.calendar-cell.future { opacity: 0.35; color: var(--text-secondary); }
.calendar-cell.today { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 700; }
.calendar-cell.empty { visibility: hidden; }

/* Shop */
.shop-balance {
  margin: 12px 14px; padding: 14px 16px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); box-shadow: var(--shadow);
}
.shop-balance.glass {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
}
.shop-balance__num { font-size: var(--font-xl); color: var(--primary); }

.shop-tabs, .leaderboard-tabs, .task-tabs, .stats-period-tabs {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
  scrollbar-width: none;
}
.shop-tabs::-webkit-scrollbar, .task-tabs::-webkit-scrollbar { display: none; }
.shop-tab, .lb-tab, .task-tab, .stats-tab {
  flex-shrink: 0; padding: 6px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--bg);
  font-size: var(--font-xs); cursor: pointer;
}
.shop-tab.active, .lb-tab.active, .task-tab.active, .stats-tab.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

#shop-grid { padding: 0 14px 12px; }
.shop-grid-inner {
  column-count: 2; column-gap: 10px;
}
@supports not (column-count: 2) {
  .shop-grid-inner { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
.shop-card {
  break-inside: avoid; margin-bottom: 10px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.shop-card__img { width: 100%; display: block; aspect-ratio: 3/2; object-fit: cover; }
.shop-card__body { padding: 10px; }
.shop-card__name { font-size: var(--font-sm); font-weight: 600; }
.shop-card__price { color: var(--primary); font-weight: 700; margin: 4px 0; }
.shop-card__price.insufficient { color: var(--text-secondary); }
.shop-card__stock { font-size: var(--font-xs); color: var(--text-secondary); }
.shop-card__btn {
  width: 100%; margin-top: 8px; padding: 8px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: var(--font-sm); cursor: pointer;
}
.shop-card__btn:disabled { background: var(--border); color: var(--text-secondary); }

/* Level */
.level-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.level-icon { font-size: 40px; }
.level-name { font-size: var(--font-lg); font-weight: 700; }
.level-next { font-size: var(--font-xs); color: var(--text-secondary); margin-top: 4px; }
.level-progress-bar {
  height: 10px; background: var(--border); border-radius: var(--radius-full);
  position: relative; overflow: visible;
}
.level-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius-full); transition: width 300ms ease;
}
.level-progress-text { font-size: var(--font-xs); color: var(--text-secondary); margin-top: 6px; text-align: right; }
.milestone-node {
  position: absolute; top: 50%; width: 6px; height: 6px;
  background: var(--accent); border-radius: 50%; transform: translate(-50%, -50%);
}

/* Tasks */
.task-list { display: none; }
.task-list.active { display: block; }
.task-item {
  display: grid; grid-template-columns: 36px 1fr auto auto;
  gap: 8px; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-icon { font-size: 24px; text-align: center; }
.task-title { font-size: var(--font-sm); font-weight: 600; }
.task-desc { font-size: var(--font-xs); color: var(--text-secondary); }
.task-progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; }
.task-progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 300ms; }
.task-points { font-size: var(--font-sm); color: var(--success); font-weight: 700; }
.task-btn {
  padding: 6px 10px; border: none; border-radius: 8px; font-size: 11px; cursor: pointer;
  background: var(--primary); color: #fff;
}
.task-btn.goto { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.task-btn.claimed, .task-btn:disabled { background: var(--border); color: var(--text-secondary); }
.task-celebration {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #fff; padding: 10px; border-radius: var(--radius); text-align: center;
  margin-bottom: 10px; font-size: var(--font-sm);
}
.task-empty { text-align: center; color: var(--text-secondary); font-size: var(--font-sm); padding: 20px; }

/* Leaderboard */
.leaderboard-top3 {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 8px; margin-bottom: 8px;
}
.lb-card {
  flex: 0 0 100px; scroll-snap-align: start;
  border-radius: var(--radius); padding: 12px 8px; text-align: center; color: #fff;
}
.lb-card--top1 { background: linear-gradient(135deg, #FFD700, #FFA000); }
.lb-card--top2 { background: linear-gradient(135deg, #C0C0C0, #9E9E9E); }
.lb-card--top3 { background: linear-gradient(135deg, #CD7F32, #8D6E63); }
.lb-medal { font-size: 24px; }
.lb-row {
  display: grid; grid-template-columns: 28px 28px 1fr auto auto;
  gap: 8px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: var(--font-sm);
}
.lb-row--me { background: rgba(255,107,53,0.08); border-radius: 8px; padding: 8px; }
.lb-rank { font-weight: 700; color: var(--text-secondary); }
.lb-score { font-weight: 700; color: var(--primary); }

/* Badges */
.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge-item {
  text-align: center; padding: 10px 4px; border-radius: var(--radius);
  border: 2px solid var(--border);
}
.badge-item.locked { filter: grayscale(1); opacity: 0.5; }
.badge-item.unlocked.rarity-rare { border-color: #42A5F5; }
.badge-item.unlocked.rarity-epic { border-color: #AB47BC; }
.badge-icon { font-size: 28px; }
.badge-name { font-size: 10px; margin-top: 4px; }

/* History */
.history-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--font-sm);
}
.history-item.income .history-amount { color: var(--success); }
.history-item.expense .history-amount { color: var(--danger); }
.history-time { grid-column: 1 / -1; font-size: var(--font-xs); color: var(--text-secondary); }

/* Stats */
.bar-chart {
  display: flex; align-items: flex-end; justify-content: space-around;
  height: 140px; gap: 4px; padding-top: 8px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-fill {
  width: 100%; max-width: 28px; background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 4px 4px 0 0; margin-top: auto; min-height: 4px;
}
.bar-label, .bar-value { font-size: 10px; color: var(--text-secondary); margin-top: 4px; }
.stats-summary {
  display: flex; justify-content: space-around; margin-top: 12px;
  font-size: var(--font-sm); color: var(--text-secondary);
}

/* Share */
.share-card { text-align: center; }
.share-rank { font-weight: 700; color: var(--primary); }
.btn-primary {
  padding: 10px 20px; border: none; border-radius: var(--radius-full);
  background: var(--primary); color: #fff; font-size: var(--font-md); cursor: pointer;
}

/* Theme toggle */
.theme-toggle { display: flex; align-items: center; justify-content: space-between; }
.theme-btns { display: flex; gap: 6px; }
.theme-btns button {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: var(--font-xs); cursor: pointer;
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: var(--contact-footer-h); left: 0; right: 0;
  height: var(--nav-height); padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch; justify-content: space-around;
  background: var(--card); box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 100; max-width: var(--max-width); margin: 0 auto;
}
.bottom-nav button {
  flex: 1; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--text-secondary); cursor: pointer;
}
.bottom-nav button span { font-size: 11px; }
.bottom-nav button.active { color: var(--primary); font-weight: 600; }

/* Contact footer */
.contact-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-bottom));
}
.contact-footer__btns { display: flex; gap: 8px; max-width: var(--max-width); margin: 0 auto; }
.contact-footer__cta {
  flex: 1; text-align: center; padding: 8px; border-radius: 8px;
  background: var(--primary); color: #fff; text-decoration: none; font-size: var(--font-sm);
}
.contact-footer__btn {
  flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: var(--font-sm); text-align: center;
  text-decoration: none; color: var(--text); cursor: pointer;
}
.contact-footer__brand {
  text-align: center; font-size: 10px; color: var(--text-secondary);
  margin: 6px 0 0; max-width: var(--max-width); margin-left: auto; margin-right: auto;
}

/* Modal */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: flex-end; z-index: 200;
}
#modal-overlay.show { display: flex; }
.modal-sheet {
  width: 100%; max-width: var(--max-width); margin: 0 auto;
  background: var(--card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px; padding-bottom: calc(24px + var(--safe-bottom));
  animation: slideUp 300ms ease forwards;
}
.modal-title { font-size: var(--font-lg); font-weight: 700; margin-bottom: 8px; }
.modal-content { color: var(--text-secondary); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; padding: 12px; border: none; border-radius: var(--radius);
  font-size: var(--font-md); cursor: pointer;
}
.modal-btn--cancel { background: var(--bg); color: var(--text); }
.modal-btn--confirm { background: var(--primary); color: #fff; }
#modal-overlay.loading .modal-btn--confirm { opacity: 0.6; }

.level-up__container { text-align: center; color: #fff; padding: 40px 20px; }
.level-up__old { font-size: 48px; opacity: 0.5; transform: scale(0.8); }
.level-up__new { font-size: 72px; animation: bounceIn 600ms 400ms both; }
.level-up__name { font-size: var(--font-lg); margin-top: 16px; }

/* Toast */
#global-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--contact-footer-h) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.82); color: #fff;
  padding: 10px 24px; border-radius: var(--radius-full);
  font-size: var(--font-sm); opacity: 0; transition: opacity 300ms, transform 300ms;
  z-index: 300; pointer-events: none; max-width: 90%;
}
#global-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Animations */
@keyframes burst {
  0% { transform: translate(0,0) scale(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.5); opacity: 0; }
}
.particle {
  position: absolute; font-size: 20px; pointer-events: none;
  animation: burst 800ms cubic-bezier(0.25,0.46,0.45,0.94) var(--delay) forwards;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
.ripple {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; background: rgba(255,255,255,0.4);
  transform: scale(0); animation: ripple 600ms ease-out forwards; pointer-events: none;
}
@keyframes flamePulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes popupFade {
  0% { opacity: 0; transform: translateY(0) scale(0.8); }
  30% { opacity: 1; transform: translateY(-10px) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.9); }
}
.points-popup {
  position: absolute; font-weight: bold; color: var(--success);
  animation: popupFade 1.5s ease-out forwards; pointer-events: none;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 360px) {
  .checkin-btn { width: 120px; height: 120px; font-size: var(--font-sm); }
  .badges-grid { grid-template-columns: repeat(3, 1fr); }
}
