/* ==========================================================================
   今日份（Today's Win）· 全局样式
   设计基调：温暖童趣 / 柔和渐变 / 圆角卡片 / 轻微动画 / 玻璃拟态点缀
   ========================================================================== */

:root {
  /* 主色 */
  --c-primary: #FF8A5C;
  --c-primary-deep: #FF6B6B;
  --c-primary-soft: #FFA94D;

  /* 背景与表面 */
  --c-bg: #FFF8F0;
  --c-bg-alt: #FDF0E4;
  --c-surface: #FFFFFF;
  --c-surface-glass: rgba(255, 255, 255, 0.72);

  /* 文字 */
  --c-text: #3D2C29;
  --c-text-soft: #8A6D5E;
  --c-text-faint: #B9A499;
  --c-white: #FFFFFF;

  /* 功能色 */
  --c-mint: #4ECDC4;
  --c-sun: #FFD166;
  --c-coral: #FF6B6B;
  --c-leaf: #88B04B;
  --c-sky: #7AB8F5;
  --c-violet: #A78BFA;

  /* 渐变 */
  --g-warm: linear-gradient(135deg, #FF8A5C 0%, #FF6B6B 100%);
  --g-sun: linear-gradient(135deg, #FFD166 0%, #FFA94D 100%);
  --g-mint: linear-gradient(135deg, #4ECDC4 0%, #7AB8F5 100%);
  --g-page: radial-gradient(1200px 600px at 10% -10%, #FFE9D6 0%, transparent 60%),
            radial-gradient(1000px 500px at 100% 0%, #FFF1DC 0%, transparent 55%),
            linear-gradient(180deg, #FFF8F0 0%, #FDF0E4 100%);

  /* 圆角与阴影 */
  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 10px;
  --r-pill: 999px;

  --sh-sm: 0 4px 12px rgba(255, 138, 92, 0.10);
  --sh-md: 0 10px 28px rgba(255, 138, 92, 0.14);
  --sh-lg: 0 20px 48px rgba(255, 107, 107, 0.18);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.7);

  /* 尺寸 */
  --page-max: 1180px;
  --header-h: 68px;

  /* 字体 */
  --font: 'Alimama FangYuanTi VF', 'PingFang SC', 'Hiragino Sans GB',
          'Microsoft YaHei', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'DIN Alternate', 'Segoe UI', system-ui, sans-serif;

  /* 动效 */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ------------------------------ 基础重置 ------------------------------ */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.page-bg { background: var(--g-page); background-attachment: fixed; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; font-weight: 600; }
p { margin: 0; }
a { color: var(--c-primary-deep); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

::selection { background: rgba(255, 138, 92, 0.25); }

/* 滚动条（Webkit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 138, 92, 0.28);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 138, 92, 0.45); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------ 布局 ------------------------------ */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 20px 96px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--header-h);
  padding: 10px 20px;
  background: var(--c-surface-glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(255, 138, 92, 0.14);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3px;
}

.app-header__logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--g-warm);
  color: #fff;
  font-size: 19px;
  box-shadow: var(--sh-sm);
}

.app-header__spacer { flex: 1; }

.app-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 138, 92, 0.18);
  box-shadow: var(--sh-sm);
}

.app-header__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--c-bg-alt);
}

.app-header__name { font-weight: 600; font-size: 14px; }

/* ------------------------------ 卡片 ------------------------------ */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-md);
  border: 1px solid rgba(255, 138, 92, 0.10);
}

.card--flat { box-shadow: var(--sh-sm); }
.card--glass {
  background: var(--c-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}

.card__title small {
  font-weight: 400;
  color: var(--c-text-faint);
  font-size: 12px;
  margin-left: auto;
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  --btn-bg: var(--g-warm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform 0.18s var(--ease-spring), box-shadow 0.2s ease, filter 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(0.3); }

.btn--ghost {
  background: rgba(255, 255, 255, 0.9);
  color: var(--c-primary-deep);
  border: 1.5px solid rgba(255, 107, 107, 0.28);
  box-shadow: none;
}
.btn--ghost:hover { background: #FFF3EC; box-shadow: var(--sh-sm); }

.btn--mint { --btn-bg: var(--g-mint); }
.btn--sun { --btn-bg: var(--g-sun); color: #7A5B12; }
.btn--plain {
  background: transparent;
  color: var(--c-text-soft);
  box-shadow: none;
  border: 1.5px solid rgba(138, 109, 94, 0.2);
}
.btn--danger { --btn-bg: linear-gradient(135deg, #FF6B6B, #E8503F); }
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--xs { padding: 5px 11px; font-size: 12px; }
.btn--block { width: 100%; }
.btn--lg { padding: 14px 30px; font-size: 16px; }

/* ------------------------------ 徽章与标签 ------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--c-bg-alt);
  color: var(--c-text-soft);
  white-space: nowrap;
}
.badge--reward { background: rgba(136, 176, 75, 0.16); color: #5C7C2E; }
.badge--penalty { background: rgba(255, 107, 107, 0.14); color: #C9412F; }
.badge--mint { background: rgba(78, 205, 196, 0.16); color: #2A8F88; }
.badge--sun { background: rgba(255, 209, 102, 0.24); color: #9A7100; }
.badge--violet { background: rgba(167, 139, 250, 0.18); color: #6D4FD1; }
.badge--off { background: rgba(138, 109, 94, 0.14); color: var(--c-text-faint); }

/* 积分徽章 */
.points-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  background: var(--g-sun);
  color: #6B4E06;
  font-weight: 700;
  font-size: 17px;
  box-shadow: 0 8px 20px rgba(255, 169, 77, 0.32);
  font-family: var(--font-num);
}

.points-pill__icon { font-size: 18px; }
.points-pill__unit { font-size: 12px; font-weight: 600; opacity: 0.75; }

/* ------------------------------ 表单 ------------------------------ */
.field { margin-bottom: 14px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-soft);
  margin-bottom: 6px;
}
.field__hint { font-size: 12px; color: var(--c-text-faint); margin-top: 5px; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid rgba(138, 109, 94, 0.18);
  background: #FFFDFA;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 138, 92, 0.14);
}
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--c-text-soft) 50%), linear-gradient(135deg, var(--c-text-soft) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 180px; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: rgba(138, 109, 94, 0.24);
  transition: background 0.25s ease;
  flex: none;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--g-warm); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px rgba(255, 138, 92, 0.2); }

/* 复选组 */
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid rgba(138, 109, 94, 0.18);
  background: #FFFDFA;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
}
.check-chip:hover { border-color: var(--c-primary); }
.check-chip input { display: none; }
.check-chip.is-on {
  border-color: var(--c-primary);
  background: rgba(255, 138, 92, 0.12);
  color: var(--c-primary-deep);
}

/* ------------------------------ 儿童端：首页 ------------------------------ */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 24px;
  align-items: center;
  padding: 26px 28px;
  margin-top: 22px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, #FFF4E8 0%, #FFFBFA 45%, #EEF9F8 100%);
  box-shadow: var(--sh-md);
  border: 1px solid rgba(255, 138, 92, 0.14);
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -40px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.35), transparent 70%);
  pointer-events: none;
}
.hero__greeting { font-size: 13px; color: var(--c-text-soft); letter-spacing: 1px; }
.hero__name { font-size: 30px; margin: 4px 0 10px; }
.hero__name em { font-style: normal; color: var(--c-primary-deep); }
.hero__slogan { color: var(--c-text-soft); font-size: 14px; margin-bottom: 16px; }
.hero__stats { display: flex; flex-wrap: wrap; gap: 10px; }
.hero__stat {
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--sh-sm);
  min-width: 92px;
}
.hero__stat-label { font-size: 12px; color: var(--c-text-faint); }
.hero__stat-value { font-size: 20px; font-weight: 700; font-family: var(--font-num); }

/* ------------------------------ 习惯树 ------------------------------ */
.tree-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, #EAF7F4 0%, #F6FCF4 55%, #FFF7E9 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(78, 205, 196, 0.16);
}
.tree-stage__sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 209, 102, 0.55), transparent 42%),
    radial-gradient(circle at 18% 26%, rgba(255, 255, 255, 0.85), transparent 36%);
  pointer-events: none;
}
.tree-stage__ground {
  position: absolute;
  left: -6%; right: -6%; bottom: -26px;
  height: 96px;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, #C9E8A8 0%, #A8D98A 100%);
  box-shadow: inset 0 8px 18px rgba(120, 168, 88, 0.25);
}
.tree-svg { position: relative; z-index: 1; width: 100%; max-width: 460px; height: auto; display: block; }

.tree-stage__label {
  position: absolute;
  z-index: 2;
  left: 18px; top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: var(--sh-sm);
}
.tree-stage__label strong { font-size: 15px; }
.tree-stage__label span { font-size: 12px; color: var(--c-text-soft); }

.tree-progress {
  position: absolute;
  z-index: 2;
  right: 18px; top: 16px;
  width: 116px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: var(--sh-sm);
  text-align: right;
}
.tree-progress__num { font-size: 22px; font-family: var(--font-num); font-weight: 700; color: var(--c-leaf); }
.tree-progress__bar {
  height: 7px;
  border-radius: var(--r-pill);
  background: rgba(136, 176, 75, 0.18);
  overflow: hidden;
  margin-top: 6px;
}
.tree-progress__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #A8D98A, #88B04B);
  width: 0;
  transition: width 0.9s var(--ease-out);
}

/* ------------------------------ 任务列表 ------------------------------ */
.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: #FFFDFA;
  border: 1.5px solid rgba(138, 109, 94, 0.12);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s ease, border-color 0.2s ease;
}
.task-item:hover { transform: translateX(3px); box-shadow: var(--sh-sm); border-color: rgba(255, 138, 92, 0.3); }

.task-item.is-done {
  background: linear-gradient(135deg, rgba(136, 176, 75, 0.10), rgba(78, 205, 196, 0.08));
  border-color: rgba(136, 176, 75, 0.32);
}
.task-item.is-done .task-item__title { color: var(--c-text-soft); text-decoration: line-through; text-decoration-color: rgba(138, 109, 94, 0.4); }

.task-item__icon {
  width: 46px; height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 23px;
  border-radius: 15px;
  background: var(--c-bg-alt);
  box-shadow: var(--sh-inset);
}
.task-item.is-done .task-item__icon { background: rgba(136, 176, 75, 0.16); }

.task-item__body { flex: 1; min-width: 0; }
.task-item__title { font-weight: 600; font-size: 15px; }
.task-item__meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.task-item__meta span { font-size: 12px; color: var(--c-text-faint); }

.task-item__points {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.task-item__points.is-plus { color: #5C7C2E; }
.task-item__points.is-minus { color: #C9412F; }

/* ------------------------------ 商店 ------------------------------ */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 22px 16px 18px;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--sh-sm);
  border: 1.5px solid rgba(255, 138, 92, 0.12);
  transition: transform 0.24s var(--ease-spring), box-shadow 0.24s ease;
}
.product-card:hover { transform: translateY(-6px) rotate(-0.6deg); box-shadow: var(--sh-lg); }
.product-card.is-locked { opacity: 0.62; filter: grayscale(0.4); }
.product-card.is-locked:hover { transform: none; box-shadow: var(--sh-sm); }

.product-card__icon {
  width: 68px; height: 68px;
  display: grid;
  place-items: center;
  font-size: 34px;
  border-radius: 22px;
  background: var(--g-sun);
  box-shadow: var(--sh-sm);
}
.product-card__title { font-weight: 700; font-size: 15px; }
.product-card__desc { font-size: 12px; color: var(--c-text-faint); min-height: 32px; }
.product-card__price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 209, 102, 0.22);
  font-weight: 700;
  font-family: var(--font-num);
  color: #8A6100;
}
.product-card__stock { font-size: 11px; color: var(--c-text-faint); }
.product-card__corner {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(78, 205, 196, 0.18);
  color: #2A8F88;
  font-weight: 600;
}

/* ------------------------------ 转盘 ------------------------------ */
.wheel-wrap {
  display: grid;
  place-items: center;
  gap: 22px;
  padding: 12px 0 4px;
}

.wheel-stage {
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.wheel-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 18px 40px rgba(255, 107, 107, 0.28), inset 0 0 0 10px #fff, inset 0 0 0 14px rgba(255, 138, 92, 0.22);
  will-change: transform;
  transform: rotate(0deg);
}

.wheel-disc.is-spinning { transition: transform 5.2s cubic-bezier(0.12, 0.72, 0.06, 1); }

.wheel-hub {
  position: absolute;
  width: 84px; height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--g-warm);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 22px rgba(255, 107, 107, 0.4), inset 0 0 0 6px #fff;
  cursor: pointer;
  border: none;
  transition: transform 0.18s var(--ease-spring);
  z-index: 2;
}
.wheel-hub:hover { transform: scale(1.06); }
.wheel-hub:active { transform: scale(0.94); }
.wheel-hub:disabled { filter: grayscale(0.5); cursor: not-allowed; }

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid var(--c-coral);
  filter: drop-shadow(0 4px 6px rgba(255, 107, 107, 0.35));
  z-index: 3;
}

.wheel-result {
  min-height: 78px;
  width: min(420px, 100%);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-sm);
  border: 1.5px dashed rgba(255, 138, 92, 0.35);
}
.wheel-result__label { font-size: 22px; font-weight: 700; }
.wheel-result__sub { font-size: 13px; color: var(--c-text-soft); margin-top: 4px; }

.probability-list { display: flex; flex-direction: column; gap: 8px; }
.probability-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.probability-row__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.probability-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.probability-row__val { font-family: var(--font-num); font-weight: 700; color: var(--c-text-soft); }

/* ------------------------------ 底部标签栏 ------------------------------ */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 14px 34px rgba(255, 107, 107, 0.22);
  border: 1px solid rgba(255, 138, 92, 0.16);
}

.tabbar__btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-text-soft);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.22s var(--ease-out);
}
.tabbar__btn:hover { background: rgba(255, 138, 92, 0.1); color: var(--c-primary-deep); }
.tabbar__btn.is-active { background: var(--g-warm); color: #fff; box-shadow: var(--sh-sm); }
.tabbar__icon { font-size: 17px; }

/* ------------------------------ 视图切换 ------------------------------ */
.view { animation: fadeUp 0.4s var(--ease-out) both; }

/* ------------------------------ 弹窗 ------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(61, 44, 41, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.22s ease both;
}

.modal {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 26px;
  border-radius: var(--r-xl);
  background: #fff;
  box-shadow: var(--sh-lg);
  animation: popIn 0.34s var(--ease-spring) both;
}

.modal--wide { width: min(760px, 100%); }
.modal__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal__icon { font-size: 34px; line-height: 1; }
.modal__title { font-size: 20px; font-weight: 700; }
.modal__sub { font-size: 13px; color: var(--c-text-soft); margin-top: 4px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.modal__actions .btn { min-width: 96px; }

/* 确认框强调 */
.confirm-highlight {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 209, 102, 0.16);
  border: 1.5px dashed rgba(255, 169, 77, 0.45);
  margin: 14px 0;
  font-size: 14px;
}

/* ------------------------------ Toast ------------------------------ */
.toast-host {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: rgba(61, 44, 41, 0.9);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sh-lg);
  animation: toastIn 0.42s var(--ease-spring) both;
  backdrop-filter: blur(10px);
}
.toast.is-out { animation: toastOut 0.3s ease both; }
.toast--success { background: linear-gradient(135deg, rgba(136, 176, 75, 0.96), rgba(78, 205, 196, 0.96)); }
.toast--error { background: linear-gradient(135deg, rgba(255, 107, 107, 0.96), rgba(232, 80, 63, 0.96)); }
.toast--info { background: linear-gradient(135deg, rgba(255, 138, 92, 0.96), rgba(255, 169, 77, 0.96)); }

/* 积分飘字 */
.float-points {
  position: fixed;
  z-index: 400;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 22px;
  pointer-events: none;
  animation: floatUp 1.15s var(--ease-out) both;
}
.float-points.is-plus { color: #6FA02F; text-shadow: 0 2px 10px rgba(136, 176, 75, 0.45); }
.float-points.is-minus { color: #E8503F; text-shadow: 0 2px 10px rgba(255, 107, 107, 0.4); }

/* 撒花 */
.confetti {
  position: fixed;
  z-index: 390;
  width: 10px; height: 14px;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiFall 1.5s linear both;
}

/* ------------------------------ 空状态 ------------------------------ */
.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 44px 20px;
  text-align: center;
  color: var(--c-text-faint);
}
.empty__icon { font-size: 46px; opacity: 0.7; }
.empty__text { font-size: 14px; }

/* ------------------------------ 骨架屏 ------------------------------ */
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, rgba(138, 109, 94, 0.08) 25%, rgba(138, 109, 94, 0.14) 37%, rgba(138, 109, 94, 0.08) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  min-height: 60px;
}

/* ------------------------------ 登录页 ------------------------------ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: var(--g-page);
  background-attachment: fixed;
}

.login-card {
  width: min(560px, 100%);
  padding: 34px 30px 30px;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--sh-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  animation: popIn 0.6s var(--ease-spring) both;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 66px; height: 66px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: var(--g-warm);
  font-size: 32px;
  color: #fff;
  box-shadow: var(--sh-md);
  animation: floatY 3.6s ease-in-out infinite;
}

.login-title { text-align: center; font-size: 27px; }
.login-sub { text-align: center; color: var(--c-text-soft); font-size: 14px; margin-top: 6px; }

.kid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 14px;
  margin: 24px 0 6px;
}

.kid-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px 14px;
  border-radius: var(--r-lg);
  background: #fff;
  border: 2px solid transparent;
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: transform 0.24s var(--ease-spring), border-color 0.24s ease, box-shadow 0.24s ease;
}
.kid-card:hover { transform: translateY(-6px) scale(1.03); border-color: rgba(255, 138, 92, 0.5); box-shadow: var(--sh-md); }
.kid-card.is-selected { border-color: var(--c-primary); box-shadow: 0 0 0 5px rgba(255, 138, 92, 0.16), var(--sh-md); }
.kid-card__avatar {
  width: 62px; height: 62px;
  display: grid;
  place-items: center;
  font-size: 31px;
  border-radius: 50%;
  background: var(--c-bg-alt);
}
.kid-card__name { font-weight: 600; font-size: 14px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--c-text-faint);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(138, 109, 94, 0.22), transparent);
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 16px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(138, 109, 94, 0.16);
  transition: all 0.2s var(--ease-spring);
}
.pin-dot.is-filled { background: var(--g-warm); transform: scale(1.18); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 290px;
  margin: 0 auto;
}
.keypad__btn {
  padding: 15px 0;
  border: none;
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--sh-sm);
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-num);
  cursor: pointer;
  transition: transform 0.14s var(--ease-spring), background 0.2s ease;
}
.keypad__btn:hover { background: #FFF3EC; }
.keypad__btn:active { transform: scale(0.92); background: rgba(255, 138, 92, 0.16); }
.keypad__btn--wide { grid-column: span 1; font-size: 15px; }

/* ------------------------------ 后台 ------------------------------ */
.admin-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 22px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}

.admin-side {
  position: sticky;
  top: 88px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-md);
  border: 1px solid rgba(255, 138, 92, 0.12);
}

.admin-side__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  color: var(--c-text-soft);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s var(--ease-out);
}
.admin-side__item:hover { background: rgba(255, 138, 92, 0.1); color: var(--c-primary-deep); transform: translateX(3px); }
.admin-side__item.is-active {
  background: var(--g-warm);
  color: #fff;
  box-shadow: var(--sh-sm);
}
.admin-side__icon { font-size: 17px; width: 20px; text-align: center; }

.admin-main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.admin-page { display: none; flex-direction: column; gap: 18px; }
.admin-page.is-active { display: flex; animation: fadeUp 0.36s var(--ease-out) both; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 18px;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--sh-sm);
  border: 1px solid rgba(255, 138, 92, 0.1);
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s ease;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.stat-card__label { font-size: 12px; color: var(--c-text-faint); display: flex; align-items: center; gap: 5px; }
.stat-card__value { font-size: 27px; font-weight: 700; font-family: var(--font-num); margin-top: 4px; }
.stat-card__value small { font-size: 13px; font-weight: 600; color: var(--c-text-faint); margin-left: 3px; }

/* 数据表 */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 560px;
}
table.data-table th {
  text-align: left;
  padding: 11px 12px;
  color: var(--c-text-soft);
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 138, 92, 0.07);
  white-space: nowrap;
}
table.data-table th:first-child { border-top-left-radius: var(--r-sm); }
table.data-table th:last-child { border-top-right-radius: var(--r-sm); }
table.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(138, 109, 94, 0.1);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.16s ease; }
table.data-table tbody tr:hover { background: rgba(255, 209, 102, 0.09); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.list-toolbar__spacer { flex: 1; }

/* 权重条（转盘） */
.weight-bar {
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(138, 109, 94, 0.12);
  overflow: hidden;
  min-width: 70px;
}
.weight-bar__fill { height: 100%; border-radius: var(--r-pill); transition: width 0.5s var(--ease-out); }

/* 调试/信息块 */
.info-block {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(78, 205, 196, 0.1);
  border-left: 4px solid var(--c-mint);
  font-size: 13px;
  color: #256B66;
  line-height: 1.6;
}
.info-block--warn {
  background: rgba(255, 209, 102, 0.16);
  border-left-color: var(--c-sun);
  color: #8A6100;
}

/* 可滚动弹窗内的表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* ------------------------------ 动画 ------------------------------ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px) scale(0.96); } }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px) scale(0.7); } 25% { opacity: 1; transform: translateY(-8px) scale(1.12); } 100% { opacity: 0; transform: translateY(-70px) scale(1); } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--dx, 0px), 88vh, 0) rotate(var(--rot, 540deg)); }
}
@keyframes leafSway { 0%, 100% { transform: rotate(-1.4deg); } 50% { transform: rotate(1.4deg); } }
/* 叶子出现：只动 opacity。切勿在这里使用 transform —— CSS transform 会覆盖
   SVG path 自身的 translate/rotate/scale 定位，导致叶子全部堆到原点。 */
@keyframes leafIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes leafDrop {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(64px) rotate(120deg); }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.is-shaking { animation: shake 0.42s ease; }

/* 树的摇摆（仅树冠；transform-box 让旋转以自身包围盒底部为中心） */
.tree-crown {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: leafSway 5.5s ease-in-out infinite;
}
.tree-leaf-group { transition: opacity 0.6s ease; }
.tree-svg { overflow: visible; }

/* ------------------------------ 低功耗模式 ------------------------------ */
html.low-power *,
html.low-power *::before,
html.low-power *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.06s !important;
}
html.low-power .tree-crown,
html.low-power .login-logo { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding: 10px;
  }
  .admin-side__item { white-space: nowrap; }
  .admin-side__item:hover { transform: none; }
}

@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .page { padding: 0 14px 108px; }
  h1 { font-size: 23px; }
  .app-header { padding: 8px 12px; gap: 8px; }
  .app-header__brand span.brand-text { display: none; }
  .app-header__user { padding: 4px 10px 4px 4px; gap: 7px; }
  .app-header__avatar { width: 30px; height: 30px; font-size: 16px; }
  .app-header__name {
    font-size: 13px;
    white-space: nowrap;
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-header .btn--sm { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
  .app-header .switch__track { width: 42px; height: 24px; }
  .app-header .switch__track::after { width: 18px; height: 18px; }
  .app-header .switch input:checked + .switch__track::after { transform: translateX(18px); }
  .hero { padding: 20px 18px; border-radius: var(--r-lg); }
  .hero__name { font-size: 25px; }
  .hero__stat { flex: 1 1 40%; min-width: 0; }
  .tree-stage { min-height: 250px; }
  .tree-stage__label { left: 12px; top: 12px; padding: 7px 10px; max-width: 46%; }
  .tree-stage__label strong { font-size: 13px; }
  .tree-stage__label span { font-size: 11px; }
  .tree-progress { right: 12px; top: 12px; width: 88px; padding: 7px 10px; }
  .tree-progress__num { font-size: 18px; }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 12px; }
  .product-card { padding: 18px 12px 14px; }
  .product-card__icon { width: 56px; height: 56px; font-size: 27px; border-radius: 18px; }
  .tabbar { bottom: 12px; width: calc(100% - 24px); justify-content: space-between; }
  .tabbar__btn { flex: 1; justify-content: center; padding: 10px 8px; font-size: 13px; }
  .modal { padding: 20px; border-radius: var(--r-lg); }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
  .kid-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .login-card { padding: 26px 20px 22px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); }
  table.data-table { min-width: 480px; }
  .wheel-stage { width: min(280px, 74vw); }
  .wheel-hub { width: 72px; height: 72px; font-size: 13px; }
}

@media (max-width: 420px) {
  .task-item { padding: 12px; gap: 10px; }
  .task-item__icon { width: 40px; height: 40px; font-size: 20px; }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}

/* 横屏矮屏时收紧底部留白 */
@media (max-height: 520px) {
  .tabbar { bottom: 8px; }
  .page { padding-bottom: 84px; }
}

/* 窄屏：把实时状态徽章收缩成一个小圆点，避免顶栏拥挤 */
@media (max-width: 640px) {
  .app-header #connBadge {
    font-size: 0;
    width: 12px;
    height: 12px;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    flex: none;
  }
  .app-header #connBadge.badge--mint { background: var(--c-mint); }
  .app-header #connBadge.badge--sun { background: var(--c-sun); }
  .app-header #connBadge.badge--penalty { background: var(--c-coral); }
  .app-header #connBadge.badge--off { background: rgba(138, 109, 94, 0.3); }
}
