/* 她律 · 减脂看板 —— 紫罗兰毛玻璃（沿用 v8 视觉） */
:root {
  --bg1: #f7f4fc;
  --bg2: #efe9f7;
  --bg3: #f5f1fb;
  --card: rgba(255, 255, 255, 0.62);
  --card-border: rgba(255, 255, 255, 0.72);
  --line: rgba(139, 127, 212, 0.14);
  --line-soft: rgba(139, 127, 212, 0.08);
  --title: #4b4388;
  --sub: #6b5fae;
  --sec: #5f5399;
  --text: #2d2a3d;
  --text-2: #3a3550;
  --text-3: #4a4560;
  --mut: #8a8499;
  --mut-2: #a39bb8;
  --mut-3: #c9c2d8;
  --ok: #1f9d57;
  --ok-soft: rgba(31, 157, 87, 0.12);
  --amber: #e69b00;
  --amber-soft: rgba(230, 155, 0, 0.14);
  --danger: #d63031;
  --shadow: 0 8px 26px rgba(120, 108, 190, 0.10), 0 2px 6px rgba(120, 108, 190, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; overflow-x: hidden; }
body {
  background: linear-gradient(160deg, #f7f4fc 0%, #efe9f7 48%, #f5f1fb 100%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(620px 420px at 12% 6%, rgba(164, 146, 235, 0.22), transparent 62%),
    radial-gradient(520px 400px at 90% 16%, rgba(139, 127, 212, 0.16), transparent 62%),
    radial-gradient(720px 520px at 52% 96%, rgba(199, 184, 244, 0.20), transparent 62%);
}
button, input { touch-action: manipulation; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; position: relative; }

/* Header */
header { padding: calc(20px + env(safe-area-inset-top)) 16px 10px; }
h1 { font-size: 20px; letter-spacing: 0.5px; color: var(--title); font-weight: 800; }
.tagline { color: var(--sub); font-size: 12.5px; margin-top: 3px; }
.meta { color: var(--mut); font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sync { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ok); background: var(--ok-soft); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.sync .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }
.refresh-btn {
  margin-left: auto; border: 1px solid rgba(139, 127, 212, 0.3);
  background: rgba(255, 255, 255, 0.6); color: var(--sub);
  font-size: 12px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.refresh-btn:active { transform: scale(0.96); }

main { flex: 1; padding: 0 max(14px, env(safe-area-inset-left)) 96px max(14px, env(safe-area-inset-right)); }
.view { display: none; animation: fade 0.25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 日历 */
.cal-wrap { margin: 10px 0 12px; }
.cal-scroll { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.cal-scroll::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 46px; text-align: center; padding: 7px 0 6px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(255, 255, 255, 0.75);
  cursor: pointer; scroll-snap-align: start; transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(120, 108, 190, 0.06); user-select: none; -webkit-user-select: none;
}
.day .dw { font-size: 10px; color: var(--mut-2); font-weight: 600; }
.day .dn { font-size: 15px; font-weight: 800; color: var(--text-2); margin-top: 1px; }
.day .dl { font-size: 9px; color: var(--mut-3); margin-top: 1px; white-space: nowrap; }
.day.has-data { border-color: rgba(31, 157, 87, 0.35); }
.day.has-data .dn { color: var(--ok); }
.day.sel { background: var(--ok); border-color: var(--ok); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(31, 157, 87, 0.35); }
.day.sel .dw, .day.sel .dn, .day.sel .dl { color: #fff; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 18px;
  padding: 16px 18px; margin-bottom: 12px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; font-weight: 800; color: var(--sec); margin-bottom: 12px; }
.sec { font-size: 15px; font-weight: 800; color: var(--sec); margin: 20px 0 10px; display: flex; align-items: center; gap: 6px; }
.note { font-size: 11.5px; color: var(--mut); margin-top: 8px; }
.empty { padding: 20px 10px; text-align: center; color: var(--mut-2); font-size: 13px; }

/* 阶段卡（侧滑里程碑） */
.stage-card { padding: 12px 14px 10px; }
.stage-hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.stage-title { font-weight: 800; font-size: 13px; color: var(--title); }
.stage-progress { font-size: 10.5px; color: var(--sub); background: rgba(139, 127, 212, 0.10); padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.stage-swiper { position: relative; overflow: hidden; margin: 0 -2px; }
.stage-track { display: flex; transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
.stage-page { flex: 0 0 100%; min-width: 0; }
.stage-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 2px; }
.stage-col { flex: 1 1 0; text-align: center; min-width: 0; }
.stage-col .big-num { font-size: 22px; }
.stage-col .label { font-size: 10px; margin-top: 3px; }
.big-num { font-size: 22px; font-weight: 800; color: var(--text-2); line-height: 1; letter-spacing: -0.5px; }
.label { font-size: 10px; color: var(--mut); margin-top: 3px; font-weight: 500; }
.stage-gauge { position: relative; text-align: center; flex: 0 0 126px; min-width: 0; }
.gauge-svg { display: block; margin: 0 auto; max-width: 126px; width: 100%; }
.gauge-num { position: absolute; top: 52%; left: 50%; transform: translate(-50%, -50%); font-size: 19px; font-weight: 800; color: var(--text-2); line-height: 1; }
.stage-arrows {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(139, 127, 212, 0.25);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--sub);
  box-shadow: 0 2px 6px rgba(120, 108, 190, 0.12);
}
.stage-arrows svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.stage-arr-l { left: 2px; }
.stage-arr-r { right: 2px; }
.stage-dots { display: flex; justify-content: center; gap: 5px; margin-top: 7px; }
.stage-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(139, 127, 212, 0.25); transition: all 0.25s; cursor: pointer; }
.stage-dot.on { background: var(--ok); width: 16px; border-radius: 3px; }
.stage-foot { margin-top: 8px; padding-top: 6px; border-top: 1px dashed rgba(139, 127, 212, 0.20); color: var(--sub); font-size: 11px; text-align: center; line-height: 1.4; }

/* 5 环 */
.rings-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ring-card { text-align: center; padding: 2px; }
.ring-svg-wrap { position: relative; width: 100%; max-width: 100px; margin: 0 auto; }
.ring-svg { width: 100%; display: block; }
.ring-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; width: 86%; }
.ring-big { font-size: 24px; font-weight: 800; color: var(--text-2); line-height: 1.05; }
.ring-sub { font-size: 11px; color: var(--mut); font-weight: 600; line-height: 1.05; margin-top: 2px; }
.ring-label { font-size: 12px; color: var(--sub); font-weight: 600; margin-top: 5px; }
.ring-goal { font-size: 11.5px; color: var(--mut); font-weight: 600; margin-top: 1px; }

/* 营养汇总 */
.nutrition-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.nutr-item { border-radius: 14px; background: rgba(139, 127, 212, 0.08); padding: 12px; }
.nutr-item .label { font-size: 12px; color: var(--mut); }
.nutr-item .values { margin-top: 6px; font-size: 14px; }
.nutr-item .consumed { font-weight: 700; color: var(--title); }
.nutr-item .target { color: var(--mut); font-size: 12px; }
.nutr-item .remain { margin-top: 4px; font-size: 12px; color: var(--ok); }
.nutr-item .remain.over { color: var(--danger); }

/* 分餐明细 */
.meal-detail .meal-group { margin-bottom: 12px; }
.meal-detail .meal-title { font-size: 13px; font-weight: 600; color: var(--title); margin-bottom: 6px; }
.meal-detail .meal-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 2px; border-bottom: 1px dashed var(--line-soft); }
.meal-detail .meal-row .name { flex: 1; }
.meal-detail .meal-row .meta { color: var(--mut); font-size: 12px; }

/* 图表 */
.chart { width: 100%; overflow-x: auto; }
.chart svg { width: 100%; min-width: 320px; height: auto; display: block; }
.chart .axis-text { font-size: 10px; fill: var(--mut-2); }
.chart .grid-line { stroke: rgba(139, 127, 212, 0.10); stroke-width: 1; }
.chart .line { fill: none; stroke: #7c6fc0; stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: url(#areaGrad); }
.chart .bar { fill: rgba(139, 127, 212, 0.5); }
.chart .bar-target { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 4 3; fill: none; }
.chart .dot { fill: #7c6fc0; }

/* 里程碑 */
.milestones .current-line { display: flex; gap: 16px; margin-bottom: 14px; }
.milestones .stat { flex: 1; background: rgba(139, 127, 212, 0.08); border-radius: 12px; padding: 10px; text-align: center; }
.milestones .stat .n { font-size: 20px; font-weight: 700; color: var(--title); }
.milestones .stat .t { font-size: 11px; color: var(--mut); }
.milestone-track { display: flex; align-items: center; justify-content: space-between; position: relative; margin: 18px 0 6px; }
.milestone-chip { text-align: center; font-size: 11px; color: var(--mut); }
.milestone-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(139, 127, 212, 0.3); margin: 0 auto 4px; }
.milestone-chip.achieved .dot { background: var(--ok); }
.milestone-chip.next .dot { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.milestone-chip .val { font-weight: 600; }
.milestone-progress { height: 8px; border-radius: 999px; background: rgba(139, 127, 212, 0.12); overflow: hidden; margin-top: 8px; }
.milestone-progress .fill { height: 100%; background: linear-gradient(90deg, var(--ok), #7c6fc0); border-radius: 999px; }

/* 复盘卡片（iframe 展开） */
.rv-card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 16px;
  padding: 12px 14px; margin-bottom: 10px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow); cursor: pointer;
}
.rv-hd { display: flex; justify-content: space-between; align-items: center; }
.rv-title { font-weight: 700; font-size: 14px; color: var(--title); }
.rv-badge { color: var(--sub); font-size: 11px; background: rgba(139, 127, 212, 0.10); padding: 2px 9px; border-radius: 10px; }
.rv-sum { color: var(--mut); font-size: 11.5px; margin-top: 4px; }
.rv-body-wrap { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.rv-body-wrap.open { max-height: none; margin-top: 10px; }
.rv-body-wrap iframe { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* KV */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.kv .kv-item { font-size: 13px; display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line-soft); padding: 6px 0; }
.kv .kv-item .k { color: var(--mut); }
.kv .kv-item .v { font-weight: 600; color: var(--text-2); }

/* 底部 Tab */
.tabbar {
  position: fixed; bottom: 0; left: 0; width: 100%; z-index: 50; display: flex;
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(139, 127, 212, 0.18); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar .tb {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px;
  cursor: pointer; color: var(--mut); transition: color 0.2s ease; min-height: 56px; justify-content: center;
  background: transparent; border: none;
}
.tabbar .tb svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; padding: 5px; box-sizing: content-box; border-radius: 12px; transition: background 0.2s ease, color 0.2s ease; }
.tabbar .tb .tt { font-size: 10.5px; font-weight: 700; line-height: 1; }
.tabbar .tb.active { color: var(--ok); background: transparent; }
.tabbar .tb.active svg { background: var(--ok-soft); }
.tabbar .tb.mid { box-shadow: 0 -1px 0 rgba(139, 127, 212, 0.12); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(59, 51, 90, 0.94); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 响应式 */
@media (min-width: 560px) { #app { max-width: 520px; } .tabbar { max-width: 520px; left: 50%; transform: translateX(-50%); border-radius: 20px 20px 0 0; } }
@media (min-width: 768px) {
  #app { max-width: 600px; box-shadow: 0 0 60px rgba(96, 74, 166, 0.08); }
  .tabbar { max-width: 600px; }
  header { padding: 28px 22px 14px; }
  main { padding: 0 20px 108px; }
  .card { padding: 18px 22px; }
  .ring-big { font-size: 26px; } .ring-sub { font-size: 12px; }
  .big-num { font-size: 24px; } h1 { font-size: 22px; }
  .sec { font-size: 16px; }
  .day { flex: 0 0 52px; }
  .rv-card:hover, .day:hover { transform: translateY(-2px); }
}
@media (min-width: 1080px) { #app { max-width: 660px; } .tabbar { max-width: 660px; } }
@media (max-width: 480px) {
  main { padding: 0 12px 90px; }
  h1 { font-size: 18px; }
  .stage-arrows { display: none; }
  .stage-row { gap: 2px; }
  .stage-col .big-num { font-size: 20px; }
  .stage-col .label { font-size: 10px; }
  .stage-gauge { flex-basis: 116px; }
  .gauge-svg { max-width: 116px; }
  .gauge-num { font-size: 17px; }
  .stage-dots { margin-top: 6px; }
  .stage-foot { font-size: 10.5px; line-height: 1.4; }
  .rings-row { gap: 3px; }
  .ring-big { font-size: 20px; } .ring-sub { font-size: 10px; }
  .ring-label { font-size: 11px; } .ring-goal { font-size: 10.5px; }
  .ring-svg-wrap { max-width: 92px; }
  .day { flex: 0 0 42px; padding: 6px 0 5px; }
  .day .dn { font-size: 13.5px; }
  .sec { font-size: 14px; margin: 16px 0 8px; }
}
@media (max-width: 380px) { .ring-big { font-size: 18px; } .ring-sub { font-size: 9.5px; } .stage-col .big-num { font-size: 18px; } .stage-gauge { flex-basis: 106px; } .gauge-svg { max-width: 106px; } }

/* ===== 阶段卡奖牌 / 完成日期 ===== */
.stage-page { position: relative; }
.stage-medal { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-size: 22px; z-index: 2; }
.gauge-num.medal { font-size: 24px; }
.tag-new { display: inline-block; font-size: 10px; background: rgba(230,155,0,.14); color: #e69b00; padding: 1px 7px; border-radius: 10px; font-weight: 700; margin-left: 4px; vertical-align: 1px; }

/* ===== 分餐明细表格 ===== */
.meal-group { margin-bottom: 12px; }
.meal-title { font-size: 13px; font-weight: 600; color: #4b4388; margin-bottom: 6px; }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mini-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 430px; }
.mini-tbl th { color: #5f5399; font-weight: 700; font-size: 10.5px; background: rgba(139,127,212,.10); text-align: right; padding: 6px 5px; border-bottom: 1px solid rgba(139,127,212,.16); white-space: nowrap; }
.mini-tbl th:first-child, .mini-tbl td:first-child { text-align: left; padding-left: 8px; }
.mini-tbl td { padding: 6px 5px; text-align: right; border-bottom: 1px solid rgba(139,127,212,.07); white-space: nowrap; }
.total-line { margin-top: 10px; background: rgba(139,127,212,.10); border: 1px solid #ddd3f5; border-radius: 14px; padding: 9px 13px; font-size: 12.5px; }

/* ===== BMI 卡 ===== */
.bmi-card { display: flex; justify-content: space-between; align-items: center; background: rgba(31,157,87,.08); border: 1px solid rgba(31,157,87,.20); border-radius: 16px; padding: 14px 16px; }
.bmi-left { min-width: 0; }
.bmi-right { text-align: right; min-width: 0; }
.bmi-num { font-size: 32px; font-weight: 800; color: #1f9d57; line-height: 1; letter-spacing: -1px; }
.bmi-label { font-size: 10.5px; color: #8a8499; margin-top: 4px; font-weight: 600; }
.bmi-badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 4px 12px; border-radius: 14px; }
.bmi-note { font-size: 10px; color: #8a8499; margin-top: 6px; }

/* ===== 个人档案 ===== */
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.pf-item { background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.7); border-radius: 13px; padding: 10px 12px; }
.pf-item .k { font-size: 10.5px; color: #8a8499; font-weight: 600; }
.pf-item .v { font-size: 15px; font-weight: 800; color: #3a3550; margin-top: 2px; }
.pf-item .v small { font-size: 11px; color: #8a8499; font-weight: 600; }
.trend-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 11px; white-space: nowrap; }
.trend-tbl th { background: rgba(139,127,212,.09); color: #6b5fae; font-weight: 800; font-size: 10px; padding: 7px 2px; text-align: center; border-bottom: 1px solid rgba(139,127,212,.20); }
.trend-tbl td { padding: 7px 2px; text-align: center; color: #3a3550; font-weight: 600; border-bottom: 1px dashed rgba(139,127,212,.12); }
.trend-tbl th:first-child, .trend-tbl td:first-child { text-align: left; padding-left: 8px; color: #8a8499; font-weight: 700; width: 52px; }
.trend-tbl td.blank { color: #c9c2d8; font-weight: 400; }
.trend-tbl tr:last-child td { border-bottom: none; }
.trend-item { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 2px; border-bottom: 1px dashed rgba(139,127,212,.14); color: #4a4560; }
.trend-item:last-child { border: none; }
.trend-item .dv { font-weight: 700; color: #3a3550; }
.food-list { display: flex; flex-wrap: wrap; gap: 6px; }
.food-chip { font-size: 11px; color: #6b5fae; background: rgba(139,127,212,.10); padding: 4px 10px; border-radius: 20px; font-weight: 600; }
