:root {
  --primary: #ff7a45;
  --primary-dark: #e85d26;
  --green: #22c55e;
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1f2329;
  --muted: #8a919e;
  --line: #eceef1;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 12px 40px; }

/* 顶部 */
.topbar {
  background: linear-gradient(135deg, var(--primary), #ff9a6c);
  color: #fff;
  padding: 14px 16px;
}
.topbar .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar .who { font-size: 13px; opacity: 0.92; }
.linkbtn { background: rgba(255,255,255,.22); border: 0; color: #fff; padding: 5px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* Tab */
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tabs button {
  flex: 1; padding: 9px 4px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }

/* 目标进度 */
.goal-head { display: flex; align-items: baseline; justify-content: space-between; }
.goal-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.goal-num span { font-size: 14px; color: var(--muted); font-weight: 400; }
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width .3s; }
.bar.full > i { background: var(--green); }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.stat {
  flex: 1; min-width: 78px; background: #fafbfc; border-radius: 8px; padding: 8px; text-align: center;
}
.stat b { display: block; font-size: 17px; color: var(--text); }
.stat span { font-size: 11px; color: var(--muted); }

/* 表单 */
label { display: block; font-size: 13px; color: #5a6270; margin: 10px 0 5px; font-weight: 500; }
input[type='text'], input[type='number'], input[type='date'], select, textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 15px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  font-size: 14px; color: #5a6270; cursor: pointer;
}
.seg button.on { background: #fff3ee; border-color: var(--primary); color: var(--primary); font-weight: 600; }

button.primary {
  width: 100%; padding: 12px; background: var(--primary); color: #fff; border: 0;
  border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 12px;
}
button.primary:disabled { background: #ffc7b2; cursor: not-allowed; }
button.primary:active { background: var(--primary-dark); }
button.ghost {
  padding: 8px 12px; background: #fff; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; color: #5a6270; cursor: pointer;
}
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: #5a6270; }
button.danger { color: #e5484d; border-color: #ffd9da; }

/* 图片上传 */
.img-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.img-picker .thumb { position: relative; width: 76px; height: 76px; }
.img-picker .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.img-picker .thumb .del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: #e5484d; color: #fff; border: 0; font-size: 13px; line-height: 1; cursor: pointer; padding: 0;
}
.img-add {
  width: 76px; height: 76px; border: 1px dashed #c8cdd4; border-radius: 8px; background: #fafbfc;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 24px; cursor: pointer;
}

/* 动态 feed */
.feed-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.feed-item:last-child { border-bottom: 0; }
.feed-head { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.feed-head .type { background: #fff3ee; color: var(--primary); padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.feed-head .val { color: var(--green); font-weight: 600; }
.feed-head .date { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: auto; }
.feed-body { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.feed-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.feed-images img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--line); }
.feed-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.like-btn { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: #5a6270; }
.like-btn.on { background: #fff3ee; border-color: var(--primary); color: var(--primary); }
.comments { margin-top: 8px; background: #fafbfc; border-radius: 8px; padding: 8px 10px; }
.comment { font-size: 13px; padding: 3px 0; word-break: break-word; }
.comment b { color: #4a5563; }
.comment .t { color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment-form { display: flex; gap: 6px; margin-top: 6px; }
.comment-form input { flex: 1; padding: 7px 10px; font-size: 14px; }

/* 排行榜 */
.rank-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rank-item:last-child { border-bottom: 0; }
.rank-no { width: 26px; height: 26px; border-radius: 50%; background: var(--line); color: #5a6270;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.rank-item.top1 .rank-no { background: #ffb020; color: #fff; }
.rank-item.top2 .rank-no { background: #b8bfc9; color: #fff; }
.rank-item.top3 .rank-no { background: #d99a6c; color: #fff; }
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 14px; }
.rank-bar { height: 6px; background: var(--line); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.rank-bar > i { display: block; height: 100%; background: var(--green); }
.rank-info { text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.rank-info b { display: block; font-size: 15px; color: var(--text); }
.tag-met { background: #e8f8ee; color: var(--green); font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-left: 4px; }

/* 我的记录 */
.mine-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mine-item:last-child { border-bottom: 0; }
.mine-item .d { color: var(--muted); font-size: 12px; min-width: 52px; }
.mine-item .t { flex: 1; }
.mine-item .v { color: var(--green); font-weight: 600; }

.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 22px 0; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 9px 18px; border-radius: 20px;
  font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.toast.show { opacity: 1; }
/* 图片查看器 */
.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.viewer img { max-width: 100%; max-height: 100%; border-radius: 6px; }
/* 表格（管理页） */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; }
td b { color: var(--text); }

/* ===== emoji 表情面板 ===== */
.emoji-btn { padding: 3px 8px; font-size: 13px; }
.emoji-panel {
  position: absolute; z-index: 1001; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; width: 304px; max-width: 92vw;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-item {
  border: 0; background: transparent; font-size: 21px; padding: 5px 0;
  cursor: pointer; border-radius: 6px; line-height: 1.2;
}
.emoji-item:active { background: #f0f1f3; }

/* ===== 点评表情图 ===== */
.comment-img {
  max-width: 130px; max-height: 130px; border-radius: 8px; margin-top: 5px;
  cursor: pointer; border: 1px solid var(--line); display: block;
}
.cmt-preview { position: relative; display: inline-block; margin-top: 6px; }
.cmt-preview img {
  width: 58px; height: 58px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
}
.cmt-preview .del {
  position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; border-radius: 50%;
  background: #e5484d; color: #fff; border: 0; font-size: 12px; line-height: 1;
  cursor: pointer; padding: 0;
}
