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

:root {
  --bg: #FFF7E6;
  --card: #FFFFFF;
  --ink: #5B4A3A;
  --pink: #FF9EC4;
  --blue: #7EC8FF;
  --orange: #FFB86B;
  --green: #8FE3A8;
  --purple: #C9A7FF;
  --yellow: #FFD95E;
  --red: #FF7B7B;
  --shadow: 0 6px 18px rgba(91, 74, 58, 0.14);
}

html, body {
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "ZCOOL KuaiLe", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  /* 底部导航固定覆盖：内容底部留出导航高度+安全区，避免最后一行被遮挡 */
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

/* 可爱圆角背景点缀 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 158, 196, 0.25) 0 60px, transparent 60px),
    radial-gradient(circle at 88% 14%, rgba(126, 200, 255, 0.25) 0 80px, transparent 80px),
    radial-gradient(circle at 20% 85%, rgba(143, 227, 168, 0.22) 0 70px, transparent 70px),
    radial-gradient(circle at 85% 80%, rgba(255, 216, 94, 0.25) 0 90px, transparent 90px);
  pointer-events: none;
  z-index: 0;
}

/* ============ 应用容器 ============ */
/* 注：.app 的底部留白定义在 body 规则之后（见上方 .app 规则），避免重复 */

.view { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

/* ============ 顶部标题 ============ */
.page-header { text-align: center; margin: 4px 0 10px; }

.page-title {
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.8);
}

.weekly-summary {
  display: inline-block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  background: var(--card);
  border-radius: 999px;
  padding: 6px 20px;
  box-shadow: var(--shadow);
  color: var(--orange);
}

/* ============ 排行榜 ============ */
.member-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.member-row {
  background: var(--card);
  border-radius: 22px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 3px solid transparent;
  animation: pop 0.3s ease;
}
@keyframes pop { 0% { transform: scale(0.96); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

.row-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 星星区：占满整行宽度，紧接信息区下方 */
.row-stars {
  margin-top: 6px;
  width: 100%;
}

.member-row.rank-1 { border-color: var(--yellow); }
.member-row.rank-2 { border-color: #E8E8F0; }
.member-row.rank-3 { border-color: var(--orange); }

.rank-badge {
  font-size: 34px;
  min-width: 44px;
  text-align: center;
  font-weight: 900;
  color: var(--orange);
}

.avatar {
  width: 84px;
  height: 96px;
  min-width: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #FFE9F2, #E4F2FF);
  border: 5px solid #FFF;
  box-shadow: 0 4px 10px rgba(91, 74, 58, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  user-select: none;
}

.avatar-wrap {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.avatar-wrap img { display: block; }

.edit-hint {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 32px;
  height: 32px;
  background: var(--card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 3px 8px rgba(91, 74, 58, 0.25);
  border: 3px solid var(--orange);
}

.member-info { flex: 1; min-width: 0; }

.member-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.member-name {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
}

.role-tag {
  font-size: 17px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
  color: #FFF;
}
.role-tag.child { background: var(--pink); }
.role-tag.parent { background: var(--blue); }

.star-count {
  font-size: 20px;
  font-weight: 900;
  color: var(--orange);
  background: #FFF3DF;
  border-radius: 999px;
  padding: 1px 10px;
  display: inline-block;
  white-space: nowrap;
  line-height: 1.4;
}

.star-count::before { content: "⭐ "; font-size: 16px; }

.star-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
  align-items: center;
}
.star-strip .star { font-size: 24px; line-height: 1.1; animation: starPop 0.3s ease; }
.star-strip .star-more {
  font-size: 18px;
  font-weight: 900;
  color: var(--orange);
  background: #FFF3DF;
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 4px;
  line-height: 1.4;
}
@keyframes starPop { 0% { transform: scale(0); } 80% { transform: scale(1.3); } 100% { transform: scale(1); } }

.actions { display: flex; flex-direction: row; gap: 8px; }
.btn-star {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  color: #FFF;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.08s, box-shadow 0.08s;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-star:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.btn-plus { background: var(--green); }
.btn-minus { background: var(--red); }

.btn-add-member {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 14px;
  font-size: 26px;
  font-weight: 900;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #FFF;
  box-shadow: 0 5px 0 #E8A23A;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-add-member:active { transform: translateY(3px); box-shadow: 0 2px 0 #E8A23A; }

/* ============ 空状态 ============ */
.empty-hint {
  text-align: center;
  margin-top: 40px;
  font-size: 30px;
  font-weight: 700;
  color: #B8A48F;
  line-height: 1.8;
}

/* ============ 通用标题 ============ */
.section-title {
  font-size: 30px;
  font-weight: 900;
  margin: 24px 0 12px;
  color: var(--ink);
}

/* ============ 心愿商店 ============ */
.wish-member-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.wish-member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 4px solid transparent;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
}
.wish-member-chip.active { border-color: var(--pink); }
.wish-member-chip .chip-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; font-size: 26px; display:flex; align-items:center; justify-content:center; background:#FFF2F8; }

.wish-progress {
  background: var(--card);
  border-radius: 24px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  font-size: 28px;
  font-weight: 800;
}

.wish-card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 4px solid transparent;
}
.wish-card.affordable { border-color: var(--green); }

.wish-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wish-name { font-size: 30px; font-weight: 900; }
.wish-cost { font-size: 26px; font-weight: 800; color: var(--orange); white-space: nowrap; }

.wish-progress-bar {
  height: 26px;
  background: #F3EADB;
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
}
.wish-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.wish-progress-text { font-size: 22px; margin-top: 6px; color: #A08D76; font-weight: 700; }

.wish-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

.btn-add-wish {
  width: 100%;
  margin-top: 6px;
  padding: 18px;
  font-size: 30px;
  font-weight: 900;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #FFF;
  box-shadow: 0 6px 0 #C77EC8;
}
.btn-add-wish:active { transform: translateY(4px); box-shadow: 0 2px 0 #C77EC8; }

/* ============ 流水 ============ */
.history-filter { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-chip {
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--card);
  border: 4px solid transparent;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.filter-chip.active { border-color: var(--blue); }

.history-item {
  background: var(--card);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-avatar { width: 56px; height: 56px; min-width: 56px; border-radius: 50%; object-fit: cover; font-size: 32px; display:flex; align-items:center; justify-content:center; background:#FFF2F8; }
.history-main { flex: 1; min-width: 0; }
.history-text { font-size: 24px; font-weight: 700; line-height: 1.4; }
.history-time { font-size: 18px; color: #A08D76; margin-top: 2px; }
.history-delta {
  font-size: 30px;
  font-weight: 900;
  white-space: nowrap;
}
.history-delta.plus { color: var(--green); }
.history-delta.minus { color: var(--red); }

/* ============ 设置 ============ */
.settings-block { display: flex; flex-direction: column; gap: 10px; }

.setting-member-row, .rule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.setting-avatar { width: 56px; height: 56px; min-width: 56px; border-radius: 50%; object-fit: cover; font-size: 30px; display:flex; align-items:center; justify-content:center; background:#FFF2F8; }
.setting-name { flex: 1; font-size: 26px; font-weight: 800; }

.rule-row .rule-label { flex: 1; font-size: 24px; font-weight: 700; }
.rule-row .rule-points { font-size: 22px; color: var(--orange); font-weight: 800; margin-right: 8px; }

.btn-row { flex-direction: row; flex-wrap: wrap; gap: 12px; }

.add-rule-row { display: flex; gap: 10px; margin-top: 12px; }
.text-input {
  flex: 1;
  padding: 14px 18px;
  font-size: 24px;
  border: 3px solid #EFE2CE;
  border-radius: 16px;
  outline: none;
  background: var(--card);
}
.text-input:focus { border-color: var(--blue); }

/* ============ 按钮 ============ */
.btn-small {
  padding: 12px 22px;
  font-size: 24px;
  font-weight: 800;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: var(--blue);
  color: #FFF;
  box-shadow: 0 4px 0 #5FA8E0;
}
.btn-small:active { transform: translateY(3px); box-shadow: 0 1px 0 #5FA8E0; }
.btn-small.btn-danger { background: var(--red); box-shadow: 0 4px 0 #D65B5B; }
.btn-small.btn-green { background: var(--green); box-shadow: 0 4px 0 #63C97F; }
.btn-small.btn-orange { background: var(--orange); box-shadow: 0 4px 0 #E08F3A; }
.btn-small.btn-purple { background: var(--purple); box-shadow: 0 4px 0 #A97FD0; }

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -4px 20px rgba(91, 74, 58, 0.12);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 0;
  border-radius: 18px;
}
.nav-icon { font-size: 34px; }
.nav-text { font-size: 20px; font-weight: 800; color: #B8A48F; }
.nav-btn.active { background: #FFF3DF; }
.nav-btn.active .nav-text { color: var(--orange); }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(91, 74, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  background: var(--card);
  border-radius: 32px;
  width: calc(100% - 40px);
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.25);
  animation: modalUp 0.25s ease;
  z-index: 101;
}
@keyframes modalUp { from { transform: translate(-50%, -50%) translateY(40px) scale(0.96); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }

.modal-title {
  font-size: 34px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 16px;
}

.modal-sub { text-align: center; font-size: 26px; font-weight: 700; color: #8A7660; margin-bottom: 16px; }

/* 弹窗里的成员大头像 */
.modal-avatar {
  width: 110px;
  height: 110px;
  margin: 0 auto 14px;
  border-radius: 50%;
  object-fit: cover;
  border: 6px solid #FFF;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  background: linear-gradient(135deg, #FFE9F2, #E4F2FF);
}

/* 理由按钮 */
.reason-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 14px; }
.reason-btn {
  padding: 12px 18px;
  font-size: 24px;
  font-weight: 800;
  border: 4px solid #EFE2CE;
  border-radius: 999px;
  background: #FFFDF8;
  cursor: pointer;
  transition: all 0.12s;
}
.reason-btn.selected { border-color: var(--orange); background: #FFF0D8; }
.reason-btn.minus-kind { border-color: #FBDCDC; }
.reason-btn.minus-kind.selected { border-color: var(--red); background: #FFE4E4; }

/* 数量选择 */
.amount-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0; }
.amount-btn {
  width: 64px; height: 64px;
  border: none;
  border-radius: 18px;
  font-size: 36px;
  font-weight: 900;
  background: var(--blue);
  color: #FFF;
  cursor: pointer;
  box-shadow: 0 4px 0 #5FA8E0;
}
.amount-btn:active { transform: translateY(3px); }
.amount-value { font-size: 44px; font-weight: 900; min-width: 70px; text-align: center; color: var(--orange); }

/* 弹窗表单 */
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.modal-field input[type="text"], .modal-field input[type="number"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 26px;
  border: 3px solid #EFE2CE;
  border-radius: 16px;
  outline: none;
}

.modal-btns { display: flex; gap: 12px; margin-top: 18px; }
.modal-btns .btn-small { flex: 1; padding: 16px; font-size: 28px; }

/* 身份选择大按钮 */
.role-pick { display: flex; gap: 14px; margin-bottom: 14px; }
.role-pick-btn {
  flex: 1;
  padding: 26px 10px;
  border: 5px solid #EFE2CE;
  border-radius: 24px;
  background: #FFFDF8;
  cursor: pointer;
  font-size: 30px;
  font-weight: 900;
  color: var(--ink);
  transition: all 0.12s;
}
.role-pick-btn.selected { border-color: var(--pink); background: #FFEFF6; }
.role-pick-btn.parent-role.selected { border-color: var(--blue); background: #EFF7FF; }
.role-pick-btn .role-emoji { display: block; font-size: 52px; margin-bottom: 6px; }

/* 头像选择 */
.avatar-pick { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 10px; }
.avatar-option {
  width: 64px; height: 64px;
  border-radius: 50%;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF2F8;
  border: 4px solid transparent;
  cursor: pointer;
}
.avatar-option.selected { border-color: var(--orange); background: #FFE9C9; transform: scale(1.1); }
.avatar-option.photo {
  font-size: 26px;
  background: #EAF6FF;
  border: 4px dashed var(--blue);
  border-radius: 16px;
  width: auto;
  padding: 0 14px;
  min-height: 56px;
}

/* 上传照片预览 */
.photo-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin: 8px auto;
  border: 4px solid var(--green);
  display: block;
}

/* 确认弹窗 */
.confirm-text { text-align: center; font-size: 30px; font-weight: 800; line-height: 1.6; margin-bottom: 10px; }
.confirm-sub { text-align: center; font-size: 22px; color: #A08D76; margin-bottom: 14px; }

/* 成员行展开（编辑删除） */
.member-edit-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(91, 74, 58, 0.92);
  color: #FFF;
  font-size: 26px;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 999px;
  animation: toastIn 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-16px); } to { opacity: 1; transform: translateX(-50%); } }

/* ============ 窄屏自适应（手机） ============ */
@media (max-width: 480px) {
  .page-title { font-size: 34px; }
  .member-row { padding: 12px 12px; }
  .row-main { gap: 10px; }
  .avatar { width: 64px; height: 64px; min-width: 64px; font-size: 36px; border-width: 4px; }
  .rank-badge { font-size: 28px; min-width: 38px; }
  .member-name { font-size: 26px; }
  .star-count { font-size: 17px; padding: 1px 8px; }
  .star-count::before { font-size: 14px; }
  .btn-star { width: 48px; height: 48px; font-size: 24px; border-radius: 15px; }
  .btn-add-member { font-size: 26px; padding: 14px; }
  .star-strip .star { font-size: 22px; }
  .star-strip .star-more { font-size: 16px; padding: 1px 8px; }
  .role-tag { font-size: 15px; padding: 1px 10px; }
  .nav-icon { font-size: 28px; }
  .nav-text { font-size: 17px; }
  .weekly-summary { font-size: 22px; padding: 6px 18px; }
  .section-title { font-size: 26px; }
  .modal-title { font-size: 30px; }
  .wish-name { font-size: 26px; }
  .history-text { font-size: 21px; }
}

@media (max-width: 360px) {
  .avatar { width: 56px; height: 56px; min-width: 56px; font-size: 32px; }
  .member-name { font-size: 24px; }
  .btn-star { width: 44px; height: 44px; font-size: 22px; }
  .rank-badge { font-size: 25px; min-width: 32px; }
  .member-row { padding: 10px 10px; }
  .row-main { gap: 8px; }
}
