/* ========== 全局 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --card-border: #f2dcdc;
  --primary: #e53935;
  --primary-dark: #c62828;
  --danger: #d32f2f;
  --warn: #ffb020;
  --green: #2ecc71;
  --text: #1f2329;
  --text-dim: #8a8f99;
  --radius: 14px;
}

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* 显式启用平滑滚动（避免部分 WebView 因 overflow 组合锁死滚动） */
body {
  padding-bottom: 64px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* ========== 页面容器 ========== */
.page {
  padding: 16px 14px 24px;
  max-width: 520px;
  margin: 0 auto;
  animation: fadeUp .32s ease both;
}

/* 页面内元素错落入场 */
.page > * { animation: fadeUp .4s ease both; }
.page > *:nth-child(1) { animation-delay: .02s; }
.page > *:nth-child(2) { animation-delay: .06s; }
.page > *:nth-child(3) { animation-delay: .1s; }
.page > *:nth-child(4) { animation-delay: .14s; }
.page > *:nth-child(5) { animation-delay: .18s; }
.page > *:nth-child(6) { animation-delay: .22s; }
.page > *:nth-child(7) { animation-delay: .26s; }
.page > *:nth-child(8) { animation-delay: .3s; }
.page > *:nth-child(9) { animation-delay: .34s; }
.page > *:nth-child(n+10) { animation-delay: .38s; }

.header { margin-bottom: 16px; }
.header-title { font-size: 22px; font-weight: 700; }
.header-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

/* ========== 卡片 ========== */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.section-title { font-size: 14px; color: var(--text-dim); margin: 16px 2px 10px; font-weight: 600; }

/* ========== 积分卡片 ========== */
.points-card {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #e53935 0%, #ff6b5e 100%);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 6px;
  box-shadow: 0 8px 24px rgba(229, 57, 53, .25);
  animation: popIn .45s ease both;
}
/* 顶部流光扫过（用 transform 实现，避免 layout 抖动影响滚动性能） */
.points-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
  transform: skewX(-20deg) translateX(-160%);
  animation: cardShine 3.8s ease-in-out infinite;
}
.points-label { font-size: 13px; opacity: .85; }
.points-value {
  font-size: 42px;
  font-weight: 800;
  margin: 6px 0 12px;
  font-variant-numeric: tabular-nums;
  display: inline-block;
}
/* 积分变化脉冲 */
.points-value.pulse { animation: popIn .38s ease; }

/* ========== 功能入口 ========== */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.feature-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  transition: transform .18s, border-color .2s, box-shadow .25s;
}
.feature-card:active {
  transform: scale(.96);
  border-color: var(--primary);
}
.feature-card:active .feature-icon { animation: iconBounce .32s ease; }
.feature-icon { font-size: 30px; display: inline-block; }
.feature-name { font-size: 16px; font-weight: 700; margin-top: 8px; }
.feature-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ========== 规则 ========== */
.rules-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 6px 16px; }
.rule-item { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--card-border); font-size: 14px; }
.rule-item:last-child { border-bottom: none; }
.rule-plus { color: var(--green); font-weight: 700; }
.rule-minus { color: var(--danger); font-weight: 700; }

/* ========== 表单 ========== */
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }
.field-hint { color: #9a9a9a; font-size: 12px; }

/* 查询提示条 */
.query-tip {
  background: rgba(229, 57, 53, 0.05);
  border: 1px solid rgba(229, 57, 53, 0.28);
  border-radius: 8px;
  color: #e05b56;
  font-size: 11px;
  line-height: 1.5;
  padding: 8px 10px;
  margin-bottom: 4px;
}

/* 推广模块 */
.promo-card { text-align: center; padding: 16px; overflow: hidden; }
.promo-img {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 240px;
  height: auto;
  margin: 0 auto 10px;
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
}
.promo-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
  word-break: break-all;
}
.promo-btns { display: flex; gap: 10px; }
.promo-btns .btn { flex: 1; }

.input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: none; }

.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: transform .12s, opacity .12s, box-shadow .25s;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(.96); opacity: .9; }
.btn-primary { background: var(--primary); }
.btn-danger { background: var(--danger); }
.btn-warn { background: var(--warn); color: #1a1a1a; }
.btn-sm { flex: 0 0 auto; padding: 9px 18px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .5; transform: none; }
/* 签到成功庆祝 */
.btn.celebrate { animation: btnCelebrate .55s ease; }
/* 复制成功 */
.invite-code.copied {
  animation: codeCopied .6s ease;
  border-color: var(--green);
  color: var(--green);
}

/* ========== 进度 ========== */
.progress-bar { height: 10px; background: #f3e2e2; border-radius: 6px; overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #ff8a80, var(--primary));
  background-size: 200% 100%;
  border-radius: 6px;
  transition: width .35s ease;
  animation: progressFlow 1.6s linear infinite;
}
/* 任务结束：进度条变绿并停止流动 */
.progress-fill.done {
  background: linear-gradient(90deg, var(--green), #5ce89a);
  background-size: 100% 100%;
  animation: none;
}
.progress-stats { display: flex; justify-content: space-between; margin-top: 12px; font-size: 13px; color: var(--text-dim); }
.progress-stats b { color: var(--text); }
.c-green { color: var(--green) !important; }
.c-red { color: var(--danger) !important; }
.progress-status { margin-top: 10px; font-size: 13px; color: var(--text-dim); text-align: center; }

/* ========== 邀请码 ========== */
.invite-box { display: flex; gap: 10px; align-items: center; }
.invite-code {
  flex: 1;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary);
  background: #fff5f5;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-family: "SF Mono", Consolas, monospace;
}
.invite-stats { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.invite-stats b { color: var(--text); }

/* ========== 积分明细 ========== */
.ledger { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); overflow: hidden; }
.ledger-empty { text-align: center; color: var(--text-dim); padding: 24px 0; font-size: 13px; }
.ledger-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  animation: fadeUp .3s ease both;
}
.ledger-item:nth-child(2) { animation-delay: .04s; }
.ledger-item:nth-child(3) { animation-delay: .08s; }
.ledger-item:nth-child(4) { animation-delay: .12s; }
.ledger-item:nth-child(5) { animation-delay: .16s; }
.ledger-item:nth-child(6) { animation-delay: .2s; }
.ledger-item:nth-child(7) { animation-delay: .24s; }
.ledger-item:nth-child(8) { animation-delay: .28s; }
.ledger-item:last-child { border-bottom: none; }
.ledger-reason { font-size: 14px; }
.ledger-time { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.ledger-change-plus { color: var(--green); font-weight: 700; font-size: 16px; }
.ledger-change-minus { color: var(--danger); font-weight: 700; font-size: 16px; }

/* ========== 查询结果 ========== */
.query-result {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  color: var(--text-dim);
  background: #faf5f5;
  border-radius: 10px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  animation: fadeUp .35s ease both;
}

/* ========== 底部导航 ========== */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #ffffff;
  border-top: 1px solid var(--card-border);
  display: flex;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.tab-item {
  flex: 1;
  text-align: center;
  padding: 4px 0;
  cursor: pointer;
  color: var(--text-dim);
  transition: color .2s;
  position: relative;
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 20px; display: inline-block; transition: transform .25s; }
.tab-item.active .tab-icon {
  transform: translateY(-3px) scale(1.15);
  animation: tabPop .35s ease;
}
/* 激活指示条 */
.tab-item.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--primary);
  animation: fadeIn .3s ease;
}
.tab-name { font-size: 11px; margin-top: 2px; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 999;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: toastIn .3s cubic-bezier(.34, 1.56, .64, 1);
}

/* ========== 动画库 ========== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popIn {
  0% { opacity: 0; transform: scale(.9); }
  60% { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes iconBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.3) rotate(-8deg); }
  100% { transform: scale(1); }
}
@keyframes cardShine {
  0% { transform: skewX(-20deg) translateX(-160%); }
  55%, 100% { transform: skewX(-20deg) translateX(420%); }
}
@keyframes progressFlow {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}
@keyframes tabPop {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.25); }
  100% { transform: translateY(-3px) scale(1.15); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.9); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes btnCelebrate {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(.95); }
  100% { transform: scale(1); }
}
@keyframes codeCopied {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
/* 尊重系统"减少动态效果"设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}