/* ============ 设计 Tokens ============ */
:root {
  --c-primary: #FF8A65;
  --c-primary2: #FFB74D;
  --c-mint: #4DB6AC;
  --c-berry: #EF5350;
  --c-sky: #4FC3F7;
  --c-bg: #FDF8F3;
  --c-text: #3E2F2A;
  --c-sub: #9A8B85;
  --c-card: rgba(255,255,255,.78);
  --radius: 20px;
  --shadow: 0 6px 24px rgba(255,138,101,.12);
  --grad: linear-gradient(135deg, #FF8A65, #FFB74D);
}
:root.dark {
  --c-bg: #2A2320;
  --c-text: #F3ECE8;
  --c-sub: #A79A93;
  --c-card: rgba(60,50,45,.78);
  --shadow: 0 6px 24px rgba(0,0,0,.3);
}

/* Vant 主题覆盖 */
:root {
  --van-primary-color: #FF8A65;
  --van-nav-bar-background: transparent;
  --van-nav-bar-title-font-size: 17px;
  --van-tabbar-item-active-color: #FF8A65;
  --van-cell-background: transparent;
}

* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #EFE9E4; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--c-text);
}
#app { min-height: 100vh; }

/* 移动优先：480px 居中模拟 App */
.page-wrap {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--c-bg);
  position: relative;
  overflow-x: hidden;
}
.page { padding: 12px 14px 90px; }
.page.tab-page { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

/* 通用卡片 */
.card {
  background: var(--c-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.card-title .more { margin-left: auto; font-size: 12px; color: var(--c-sub); font-weight: 400; cursor: pointer; }

/* 渐变头图 */
.hero {
  background: var(--grad);
  border-radius: 0 0 28px 28px;
  margin: -12px -14px 14px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.hero h2 { margin: 0 0 4px; font-size: 20px; }
.hero p { margin: 0; font-size: 13px; opacity: .9; }
.hero .hero-pet {
  position: absolute; right: 16px; bottom: 8px;
  width: 84px; height: 84px; object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.15));
}

/* 数字 */
.big-num { font-size: 34px; font-weight: 700; line-height: 1.1; }
.big-num small { font-size: 14px; font-weight: 400; color: var(--c-sub); margin-left: 4px; }
.diff-down { color: var(--c-mint); }
.diff-up { color: var(--c-berry); }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  background: rgba(255,255,255,.25); color: inherit;
}

/* 首页宫格入口 */
.grid-entries { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-entry {
  background: var(--c-card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px 4px; text-align: center; cursor: pointer; transition: transform .15s;
}
.grid-entry:active { transform: scale(.94); }
.grid-entry img { width: 34px; height: 34px; }
.grid-entry div { font-size: 12px; margin-top: 4px; color: var(--c-text); }

/* 悬浮 AI 球 */
.ai-fab {
  position: fixed;
  right: calc(50% - 240px + 16px);
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--grad); border: none; cursor: pointer;
  box-shadow: 0 8px 20px rgba(255,138,101,.4);
  display: flex; align-items: center; justify-content: center;
  animation: breathe 3s ease-in-out infinite;
  z-index: 50;
}
@media (max-width: 520px) { .ai-fab { right: 16px; } }
.ai-fab img { width: 38px; height: 38px; }
.ai-fab .dot {
  position: absolute; top: 2px; right: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: #EF5350; border: 2px solid #fff;
}
@keyframes breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* 宠物换色（药水 hue） */
.pet-hue { filter: hue-rotate(var(--hue, 0deg)) saturate(1.1); }

/* 榜单 */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed rgba(0,0,0,.06); }
.rank-row:last-child { border-bottom: none; }
.rank-no { width: 28px; font-weight: 700; font-size: 16px; text-align: center; color: var(--c-sub); }
.rank-no.r1 { color: #FFB300; } .rank-no.r2 { color: #90A4AE; } .rank-no.r3 { color: #A1887F; }
.rank-row img.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #FFE0B2; }
.rank-row .name { flex: 1; font-size: 14px; }
.rank-row .pct { font-weight: 700; color: var(--c-mint); }
.rank-row.is-me { background: linear-gradient(90deg, rgba(255,138,101,.12), transparent); border-radius: 12px; padding: 10px 8px; }

/* 签到日历 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 13px; background: rgba(0,0,0,.04); color: var(--c-sub);
  position: relative;
}
.cal-cell.done { background: var(--grad); color: #fff; font-weight: 600; }
.cal-cell.today { outline: 2px solid var(--c-primary); }
.cal-cell .tick { position: absolute; top: 2px; right: 4px; font-size: 10px; }

/* ============ AI 聊天面板（豆包风格） ============ */
.dtk { height: 100%; display: flex; flex-direction: column; background: #F7F7FA; border-radius: 18px 18px 0 0; overflow: hidden; }

/* 头部 */
.dtk-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px calc(10px + env(safe-area-inset-top));
  background: #fff; border-bottom: 1px solid #F0F0F3; flex: none;
}
.dtk-logo { width: 34px; height: 34px; border-radius: 50%; }
.dtk-name { display: flex; flex-direction: column; line-height: 1.25; }
.dtk-name b { font-size: 16px; color: #1A1A1E; }
.dtk-status { font-size: 11px; color: #9CA0A8; display: flex; align-items: center; gap: 4px; }
.dtk-status i { width: 6px; height: 6px; border-radius: 50%; background: #34C77B; display: inline-block; }
.dtk-quota {
  margin-left: auto; font-size: 11px; color: #FF8A65;
  background: rgba(255,138,101,.1); padding: 4px 10px; border-radius: 999px; flex: none;
}
.dtk-new {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  border: 1px solid #E5E6EB; background: #fff; color: #4E5259;
  font-size: 12px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.dtk-new:active { background: #F5F5F8; }

/* 空状态 */
.dtk-empty { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 6vh 20px 20px; }
.dtk-hero { width: 84px; height: 84px; border-radius: 24px; box-shadow: 0 10px 24px rgba(255,138,101,.28); }
.dtk-title { font-size: 24px; font-weight: 700; color: #1A1A1E; margin-top: 18px; }
.dtk-title span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dtk-sub { font-size: 13px; color: #9CA0A8; margin: 8px 0 26px; }
.dtk-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.dtk-card {
  background: #fff; border: 1px solid #F0F0F3; border-radius: 16px;
  padding: 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  transition: transform .12s; box-shadow: 0 2px 10px rgba(17,17,17,.03);
}
.dtk-card:active { transform: scale(.97); }
.dtk-card .ic { font-size: 22px; line-height: 1; }
.dtk-card .tt { font-size: 14px; font-weight: 600; color: #1A1A1E; }
.dtk-card .ds { font-size: 11px; color: #9CA0A8; }

/* 对话区 */
.dtk-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; }
.dtk-row { margin-bottom: 18px; }
.dtk-row.me { display: flex; justify-content: flex-end; }
.dtk-bubble {
  max-width: 76%; background: #F2F3F7; color: #1A1A1E;
  padding: 11px 14px; border-radius: 4px 18px 18px 18px;
  font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.dtk-row.ai { display: flex; gap: 9px; }
.dtk-ava { width: 28px; height: 28px; border-radius: 50%; flex: none; margin-top: 2px; }
.dtk-ai { flex: 1; min-width: 0; }
.dtk-text {
  font-size: 15px; line-height: 1.7; color: #1A1A1E;
  white-space: pre-wrap; word-break: break-word;
}
.dtk-acts { display: flex; gap: 16px; margin-top: 8px; }
.dtk-acts span {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #9CA0A8; cursor: pointer; user-select: none;
}
.dtk-acts span:active { color: var(--c-primary); }

/* 输入区 */
.dtk-input { flex: none; background: #F7F7FA; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.dtk-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #E9E9EE; border-radius: 24px; padding: 6px 6px 6px 16px;
  box-shadow: 0 2px 12px rgba(17,17,17,.04);
}
.dtk-box:focus-within { border-color: var(--c-primary); }
.dtk-box input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; color: #1A1A1E; }
.dtk-send {
  width: 36px; height: 36px; border-radius: 50%; border: none; flex: none;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 3px 8px rgba(255,138,101,.4);
}
.dtk-send:disabled { opacity: .4; box-shadow: none; }
.dtk-disclaim { text-align: center; font-size: 10px; color: #C2C5CB; padding-top: 6px; }
.cursor-blink::after { content: '▌'; animation: blink 1s step-start infinite; color: var(--c-primary); }
@keyframes blink { 50% { opacity: 0; } }

/* 后台 */
.admin-layout { display: flex; max-width: 960px; margin: 0 auto; min-height: 100vh; }
.admin-side { width: 150px; background: #fff; padding: 14px 8px; flex: none; }
.admin-side a { display: block; padding: 10px 14px; border-radius: 10px; color: var(--c-sub); text-decoration: none; font-size: 14px; margin-bottom: 4px; }
.admin-side a.on { background: rgba(255,138,101,.14); color: var(--c-primary); font-weight: 600; }
.admin-main { flex: 1; padding: 16px; min-width: 0; }
.admin-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; position: sticky; top: 0; z-index: 5; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.stat-card .v { font-size: 24px; font-weight: 700; color: var(--c-primary); }
.stat-card .k { font-size: 12px; color: var(--c-sub); margin-top: 2px; }

/* 表格窄屏转卡片 */
.table { width: 100%; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #F3EDE8; white-space: nowrap; }
.table th { background: #FBF6F1; color: var(--c-sub); font-weight: 500; }
@media (max-width: 560px) {
  .table table, .table thead, .table tbody, .table tr { display: block; }
  .table thead { display: none; }
  .table tr { background: #fff; border-radius: 12px; margin-bottom: 8px; padding: 6px 4px; }
  .table td { display: flex; justify-content: space-between; border: none; padding: 4px 10px; white-space: normal; }
  .table td::before { content: attr(data-k); color: var(--c-sub); margin-right: 12px; flex: none; }
}

/* 背包/商店小卡 */
.bag-item {
  width: 78px; padding: 8px 4px; border-radius: 14px; text-align: center;
  background: rgba(0,0,0,.04); border: 2px solid transparent; cursor: pointer;
}
.bag-item.on { border-color: var(--c-primary); background: rgba(255,138,101,.1); }

/* 菜单行 */
.menu-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; font-size: 14px; border-bottom: 1px dashed rgba(0,0,0,.06); cursor: pointer; }
.menu-row:last-child { border-bottom: none; }

/* 输入行 */
.field-line { margin-bottom: 12px; }
.field-line > label { display: block; font-size: 12px; color: var(--c-sub); margin-bottom: 5px; }
.native-input {
  width: 100%; box-sizing: border-box; border: none; background: rgba(0,0,0,.05);
  border-radius: 12px; padding: 10px 12px; font-size: 14px; outline: none; color: var(--c-text);
}
.num-input { display: flex; align-items: baseline; gap: 6px; background: rgba(0,0,0,.05); border-radius: 12px; padding: 8px 14px; }
.num-input input { flex: 1; border: none; background: transparent; outline: none; font-size: 26px; font-weight: 700; color: var(--c-text); width: 40px; }
.num-input span { color: var(--c-sub); }
.photo-btn { display: inline-block; padding: 8px 14px; border-radius: 12px; background: rgba(255,138,101,.14); color: var(--c-primary); font-size: 13px; cursor: pointer; }

.muted { color: var(--c-sub); font-size: 12px; }
.chip { padding: 6px 12px; border-radius: 999px; background: rgba(255,138,101,.14); color: var(--c-primary); font-size: 12px; cursor: pointer; border: none; }
.center { text-align: center; }
.mt10 { margin-top: 10px; }
.flex { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
/* 日期条（记录页） */
.date-strip { display: flex; align-items: center; gap: 6px; padding: 10px 8px; }
.week-nav {
  border: none; background: rgba(0,0,0,.05); color: var(--c-sub); width: 26px; height: 52px;
  border-radius: 10px; font-size: 18px; cursor: pointer; flex: none;
}
.week-nav:disabled { opacity: .3; }
.week-days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-cell {
  display: flex; flex-direction: column; align-items: center; padding: 6px 0; border-radius: 12px;
  cursor: pointer; position: relative; background: rgba(0,0,0,.04);
}
.day-cell .wd { font-size: 10px; color: var(--c-sub); }
.day-cell .dn { font-size: 15px; font-weight: 600; color: var(--c-text); }
.day-cell.future { opacity: .35; cursor: default; }
.day-cell.sel { background: var(--grad); box-shadow: 0 4px 10px rgba(255,138,101,.35); }
.day-cell.sel .wd, .day-cell.sel .dn { color: #fff; }
.td-dot { position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--c-primary); }
.day-cell.sel .td-dot { background: #fff; }

/* 宠物阶段徽章 */
.stage-badge {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  background: var(--grad); color: #fff; font-size: 10px; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 6px rgba(255,138,101,.4);
}

/* 排行榜领奖台 */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; padding: 8px 0 4px; }
.pod-col { display: flex; flex-direction: column; align-items: center; width: 96px; }
.pod-crown { font-size: 20px; line-height: 1; margin-bottom: 2px; }
.pod-name { font-size: 12px; color: var(--c-text); max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-pct { font-size: 12px; font-weight: 700; color: var(--c-mint); margin: 2px 0 6px; }
.pod-pct.pct1 { color: var(--c-primary); font-size: 14px; }
.pod-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.12); }
.pod-avatar.ava1 { width: 58px; height: 58px; border: 3px solid #FFD54F; }
.pod-avatar.ava2 { border-color: #CFD8DC; }
.pod-avatar.ava3 { border-color: #BCAAA4; }
.pod-block {
  width: 100%; margin-top: -14px; border-radius: 12px 12px 0 0;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 8px;
  font-size: 12px; font-weight: 700; color: #fff;
}
.pod-block.b1 { height: 84px; background: var(--grad); }
.pod-block.b2 { height: 62px; background: linear-gradient(180deg, #B0BEC5, #90A4AE); }
.pod-block.b3 { height: 46px; background: linear-gradient(180deg, #BCAAA4, #A1887F); }

.link { color: var(--c-primary); cursor: pointer; }
