/* —— 星星银行 · 样式 —— */
:root {
  --bg1: #f6f1ff;
  --bg2: #fff4f5;
  --card: #ffffff;
  --ink: #3b3355;
  --ink2: #8d86a8;
  --violet: #8b5cf6;
  --violet-soft: #ede9fe;
  --rose: #fb7185;
  --rose-soft: #ffe4e9;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --green: #34d399;
  --green-soft: #d9fbe9;
  --line: #f0ecf8;
  --shadow: 0 6px 24px rgba(139, 92, 246, .10);
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(86px + env(safe-area-inset-bottom));
}

.loading { text-align: center; color: var(--ink2); padding: 80px 0; }

/* —— 卡片 —— */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* —— 顶部英雄卡 —— */
.hero {
  text-align: center;
  padding: 26px 16px 22px;
  background: linear-gradient(140deg, #9f7cf3 0%, #e86fa5 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero-name, .hero-sub { text-shadow: 0 1px 6px rgba(80, 40, 90, .35); }
.hero::after {
  content: '✦';
  position: absolute;
  top: -12px; right: 18px;
  font-size: 60px;
  opacity: .18;
}
.hero-emoji { font-size: 44px; line-height: 1; margin-bottom: 4px; }
.hero-name { font-size: 14px; opacity: .92; }
.hero-balance {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 1px;
  margin: 2px 0;
  text-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.hero-balance .star { font-size: 34px; margin-right: 6px; }
.hero-sub { font-size: 13px; opacity: .95; }
.hero-sub .dot { margin: 0 6px; opacity: .6; }

/* —— 徽标 —— */
.crown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gold-soft);
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}
.badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

/* —— 任务格子 —— */
.grid-tasks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.task {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  background: #fff;
  transition: transform .15s, border-color .15s, background .15s;
  position: relative;
}
.task:active { transform: scale(.96); }
.task .t-emoji { font-size: 26px; }
.task .t-name { font-size: 13px; margin-top: 4px; font-weight: 600; }
.task .t-pts { font-size: 12px; color: var(--gold); font-weight: 700; }
.task.done { background: var(--green-soft); border-color: transparent; }
.task.done .t-name { color: #0f9d6c; }
.task.clickable { cursor: pointer; }
.task .t-check {
  position: absolute; top: 6px; right: 8px;
  font-size: 13px;
}
.task.done .t-pts { color: #0f9d6c; }

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--violet-soft);
  color: var(--violet);
  transition: transform .12s, opacity .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .45; }
.btn-primary { background: linear-gradient(135deg, var(--violet) 0%, #a78bfa 100%); color: #fff; }
.btn-rose { background: var(--rose); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-ghost { background: #f4f1fb; color: var(--ink2); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* —— 礼物商店 —— */
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gift {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px 12px 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.gift .g-emoji { font-size: 40px; line-height: 1.1; }
.gift .g-name { font-weight: 700; font-size: 14px; margin-top: 8px; }
.gift .g-cost { color: var(--gold); font-weight: 800; font-size: 16px; margin-top: 2px; }
.gift .btn { margin-top: 10px; width: 100%; }
.gift.affordable { border: 2px solid var(--gold-soft); }
.gift.affordable::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(245, 158, 11, .08), transparent 60%);
  pointer-events: none;
}

/* —— 记录列表 —— */
.day-label {
  font-size: 12px;
  color: var(--ink2);
  font-weight: 700;
  margin: 14px 4px 6px;
}
.tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 10px rgba(139, 92, 246, .06);
}
.tx-row .x-reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-row .x-pts { font-weight: 800; white-space: nowrap; }
.tx-earn .x-pts { color: #0f9d6c; }
.tx-spend .x-pts, .tx-redeem .x-pts { color: var(--rose); }
.tx-row .x-time { font-size: 12px; color: var(--ink2); white-space: nowrap; }
.tx-row .x-del {
  border: none; background: none; cursor: pointer;
  color: #d9d3ea; font-size: 16px; padding: 2px 4px; font-family: inherit;
}
.tx-row .x-del:active { color: var(--rose); }

.status-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
}
.status-pending { background: var(--gold-soft); color: #b45309; }
.status-approved { background: var(--green-soft); color: #0f9d6c; }
.status-rejected { background: #f1eef7; color: var(--ink2); }

.pending-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.pending-item:last-child { border-bottom: none; padding-bottom: 0; }
.pending-item .p-info { flex: 1; min-width: 0; }
.pending-item .p-name { font-weight: 700; }
.pending-item .p-cost { font-size: 12px; color: var(--gold); font-weight: 700; }
.pending-item .p-acts { display: flex; gap: 8px; }
.pending-item .p-acts .btn { padding: 6px 14px; font-size: 13px; }

/* —— 家长面板 —— */
.pin-wrap { text-align: center; padding: 30px 20px; }
.pin-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.pin-sub { color: var(--ink2); font-size: 13px; margin-bottom: 20px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 8px; height: 20px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  background: #ddd5f2;
  border: 1.5px solid #c9bdf0;
  transition: background .15s, transform .15s;
}
.pin-dots i.on { background: var(--violet); transform: scale(1.15); }
.pin-msg { height: 20px; font-size: 13px; color: var(--rose); margin-bottom: 6px; }
.pinpad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 12px;
  justify-content: center;
}
.pinpad button {
  height: 62px;
  border: none;
  border-radius: 18px;
  font-size: 24px;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 12px rgba(139, 92, 246, .12);
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s;
}
.pinpad button:active { transform: scale(.93); background: var(--violet-soft); }
.pinpad button.wide { font-size: 17px; }

.admin-section { margin-bottom: 14px; }
.admin-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 800; margin: 18px 4px 10px;
}
.admin-title .btn { padding: 5px 12px; font-size: 12px; }
.manage-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 14px;
  padding: 10px 14px; margin-bottom: 8px;
  box-shadow: 0 2px 10px rgba(139, 92, 246, .06);
}
.manage-row.off { opacity: .55; }
.manage-row .m-emoji { font-size: 22px; }
.manage-row .m-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-row .m-pts { color: var(--gold); font-weight: 800; white-space: nowrap; }
.manage-row .m-acts { display: flex; gap: 6px; }
.manage-row .m-acts .btn { padding: 5px 11px; font-size: 12px; }

.seg { display: flex; background: #f4f1fb; border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.seg button {
  flex: 1; border: none; border-radius: 999px; padding: 8px 0;
  background: transparent; color: var(--ink2); font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink2); font-weight: 700; margin-bottom: 5px; }
.field input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 16px;
  font-family: inherit;
  background: #faf8ff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--violet); background: #fff; }
.quick-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-chips button {
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit;
}
.quick-chips button.on { border-color: var(--violet); background: var(--violet-soft); color: var(--violet); }

/* —— 底部导航 —— */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tabbar button {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ink2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
.tabbar .tb-icon { font-size: 22px; line-height: 1.2; }
.tabbar button.on { color: var(--violet); }
.tabbar button.on .tb-icon { transform: scale(1.12); }

/* —— 弹窗 —— */
#modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(59, 51, 85, .45);
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: auto;
  animation: fadeIn .18s;
}
.modal-box {
  background: #fff;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 520px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp .22s;
}
.modal-title { font-size: 17px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.modal-sub { text-align: center; color: var(--ink2); font-size: 13px; margin-bottom: 16px; }
.modal-acts { display: flex; gap: 10px; margin-top: 16px; }
.modal-acts .btn { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(60px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }

/* —— 提示条 —— */
#toast {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(59, 51, 85, .92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  z-index: 120;
  animation: fadeIn .2s;
  max-width: 86vw;
  text-align: center;
}

/* —— 表情雨 —— */
.fx-emoji {
  position: fixed;
  top: -40px;
  font-size: 26px;
  z-index: 110;
  pointer-events: none;
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0) scale(.8); opacity: 1; }
  100% { transform: translateY(85vh) rotate(340deg) scale(1.15); opacity: 0; }
}

.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

.empty { text-align: center; color: var(--ink2); font-size: 13px; padding: 24px 0; }

@media (min-width: 560px) {
  body { font-size: 16px; }
  #app { padding-top: 28px; }
}
