:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2b2724;
  --muted: #8a8177;
  --line: #eee6da;
  --accent: #d9480f;
  --accent-dark: #b93a08;
  --accent-soft: #fdeee3;
  --radius: 14px;
  --font: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 var(--font);
}

body::before {
  content: "";
  position: fixed;
  inset: -120px 0 auto;
  height: 320px;
  background: radial-gradient(600px 260px at 18% 0%, #fdeee3 0%, rgba(253, 238, 227, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 1px;
}

.logout {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.flash {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #f6d5bd;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.04);
}

.upload-card { padding: 16px; margin-bottom: 18px; }

.upload-card input[type="file"] {
  width: 100%;
  padding: 14px;
  border: 1.5px dashed #dccfc0;
  border-radius: 10px;
  background: #fffdf9;
  font-size: 14px;
  color: var(--muted);
}

.upload-card .row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  margin: 12px 0;
}

.upload-card select,
.upload-card input[type="text"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fffdf9;
  color: var(--ink);
}

.upload-card button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
}

.upload-card button:active { background: var(--accent-dark); }

.daybar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 14px;
}

.daybar a { color: var(--muted); text-decoration: none; }
.daybar .prev { justify-self: start; }
.daybar .right { justify-self: end; display: flex; gap: 12px; }
.daybar strong { font-size: 16px; }

.day-pick {
  position: relative;
  display: inline-block;
  padding: 6px 10px;
  margin: -6px -10px;
}

.day-pick input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-card select.span2 { grid-column: 1 / -1; }

.extra-note {
  font-size: 13px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 7px 10px;
  margin: 8px 0 0;
  word-break: break-all;
}

.supp-box { margin-top: 10px; }

.supp-box summary {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.supp-form { margin-top: 8px; }

.supp-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
}

.supp-form button { margin-top: 6px; }

.dayjump {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.dayjump input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  color-scheme: light;
}

.weight-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.weight-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.weight-card input[type="number"] {
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  text-align: right;
}

.weight-unit {
  font-size: 13px;
  color: var(--muted);
  margin-right: auto;
}

.daystat {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 14px;
}

.timeline { display: grid; gap: 14px; }

.entry { padding: 12px; }

.photo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(min(100vw, 560px) - 32px);
  margin: 0 auto;
  border-radius: 10px;
  background: #f3ede4;
}

.photo + .photo { margin-top: 10px; }

.entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}

.time { color: var(--muted); font-size: 13px; }

.cal {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
}

.note { margin: 8px 2px 0; font-size: 14px; color: #5c554d; }

.model-tag {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: 1px;
}

.backlog { text-align: center; margin-bottom: 14px; }

.backlog button,
.mini-btn,
.entry-actions button,
.entry-actions .op-link {
  border: 1px solid var(--line);
  background: #fffdf9;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.5;
}

.backlog button:active,
.mini-btn:active,
.entry-actions button:active,
.entry-actions .op-link:active { background: var(--accent-soft); }

.op-del {
  color: #b3402a !important;
  border-color: #eec4b8 !important;
}

.op-del:active { background: #fbe9e7 !important; }

button.busy, .mini-btn.busy {
  background: #7d95b5 !important;
  border-color: #7d95b5 !important;
  color: #fff !important;
  cursor: wait;
}

.locked-hint {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.75;
  align-self: center;
}

.report-card { padding: 16px; margin-bottom: 16px; }

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.report-head strong { font-size: 15px; }

.report-total { margin: 10px 2px 0; font-weight: 600; color: var(--accent-dark); }

.report-assess { margin: 6px 2px 0; font-size: 14px; }

.report-sugg { margin: 8px 2px 0; padding-left: 20px; font-size: 14px; color: #5c554d; }

.report-sugg li { margin-bottom: 4px; }

.report-empty { margin: 10px 2px 2px; font-size: 13px; color: var(--muted); }

.report-time { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }

.cal.pending { color: var(--muted); font-weight: 400; }

.entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.entry-actions form { margin: 0; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.foot-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
}

.login-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card { width: 100%; max-width: 340px; padding: 28px 24px; }

.login-card h1 {
  font-size: 20px;
  margin: 0 0 6px;
  text-align: center;
  letter-spacing: 2px;
}

.login-card p { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.login-card input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  margin-bottom: 12px;
  background: #fffdf9;
}

.login-card button {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---- 底部 Tab 导航 ---- */
.wrap.has-tabbar { padding-bottom: 76px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
}

.tabbar a .ticon { font-size: 18px; line-height: 1.2; }

.tabbar a.on { color: var(--accent-dark); font-weight: 600; }

/* ---- 每周分析 ---- */
.wk-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.wm {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}

.wm .v { font-size: 18px; font-weight: 700; color: var(--ink); }

.wm .v.hot { color: var(--accent-dark); }

.wm .k { color: var(--muted); font-size: 12px; margin-top: 2px; }

.sec-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 108px;
  padding-top: 14px;
}

.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }

.bar {
  width: 100%;
  max-width: 30px;
  border-radius: 6px 6px 2px 2px;
  background: var(--accent-soft);
  position: relative;
  align-self: flex-end;
}

.bar.peak { background: var(--accent); }

.bar .bv {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
}

.bar-col .bl { color: var(--muted); font-size: 12px; margin-top: 5px; }

.mrow { display: flex; align-items: center; gap: 10px; padding: 4px 0; }

.mrow .mn { width: 34px; color: var(--muted); font-size: 13px; flex-shrink: 0; }

.mrow .track {
  flex: 1;
  height: 9px;
  background: #f4efe7;
  border-radius: 999px;
  overflow: hidden;
}

.mrow .fill { height: 100%; border-radius: 999px; background: var(--accent); opacity: 0.75; }

.mrow .pc { width: 38px; text-align: right; color: var(--muted); font-size: 13px; flex-shrink: 0; }

.top-dishes { margin: 0; padding-left: 22px; font-size: 14px; }

.top-dishes li { margin-bottom: 6px; }

.top-dishes .freq { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* ---- 分享 ---- */
.share-btn {
  border: 1px solid var(--accent);
  background: #fffdf9;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.share-btn:active { background: var(--accent-soft); }

.share-banner {
  text-align: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---- 我的 ---- */
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-head .avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-head .who strong { font-size: 17px; }

.profile-head .who p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.profile-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

.field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.field .flabel {
  width: 40px;
  color: var(--muted);
  font-size: 14px;
  flex-shrink: 0;
}

.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }

.pill-radio input { position: absolute; opacity: 0; pointer-events: none; }

.pill-radio span {
  display: inline-block;
  padding: 7px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.pill-radio input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.unit-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  padding: 0 12px;
}

.unit-box input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px 0;
  font: inherit;
  min-width: 0;
  outline: none;
}

.unit-box span { color: var(--muted); font-size: 13px; }

.primary-btn {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:active { background: var(--accent-dark); }

.share-list { list-style: none; margin: 0; padding: 0; }

.share-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.share-list li:first-child { border-top: 0; }

.share-list a {
  flex: 1;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-list a:hover { color: var(--accent-dark); }

.s-kind {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.s-kind.week { background: #eef4fd; color: #2f6fb3; }

.copy-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: #fffdf9;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.copy-btn.ok {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

/* ---- 注册 ---- */
.pw-rule {
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.alt-link {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.alt-link a { color: var(--accent-dark); text-decoration: none; font-weight: 600; }

/* ---- 分享页复制 ---- */
.share-banner .banner-copy {
  display: block;
  margin: 8px auto 0;
  border: 1px solid var(--accent-dark);
  background: #fff;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 20px;
  border-radius: 999px;
  cursor: pointer;
}

.share-banner .banner-copy.ok {
  background: var(--accent-dark);
  color: #fff;
}

.share-banner .banner-acts {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.share-banner .banner-acts .banner-copy {
  display: inline-block;
  margin: 0;
  text-decoration: none;
}

/* ---- 详细分析 ---- */
.detail-req { margin-top: 8px; }

.detail-pending {
  margin: 10px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

.detail-box {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.detail-box summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  user-select: none;
  list-style-position: inside;
}

.detail-body {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.85;
  color: #5c554d;
  white-space: pre-wrap;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

/* ---- 编辑记录页 ---- */
.edit-photo-item { margin-bottom: 12px; }

.edit-photo {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.photo-del {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: #b93a08;
  cursor: pointer;
}

.row-hint {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
}

.edit-cancel {
  display: block;
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

/* ---- 分析页子Tab ---- */
.subtabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #efe7db;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}

.subtabs a {
  text-align: center;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.subtabs a.on {
  background: var(--card);
  color: var(--accent-dark);
  box-shadow: 0 1px 3px rgba(60, 40, 20, 0.08);
}

.bars.month { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }

.bars.month .bl { font-size: 9px; }

/* ---- 体重趋势 ---- */
.spark-wrap { padding: 4px 0 0; }

.spark-wrap svg {
  width: 100%;
  height: 110px;
  display: block;
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-dot { fill: var(--card); stroke: var(--accent); stroke-width: 2; }

.spark-dot.last { fill: var(--accent); }

.spark-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.wt-list { list-style: none; margin: 0; padding: 0; }

.wt-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.wt-list li:last-child { border-bottom: 0; }

.wt-day { color: var(--muted); }

.wt-val { font-weight: 600; }

.wt-delta { margin-left: auto; font-size: 13px; color: var(--muted); }

.wt-delta.up { color: #b3402a; }

.wt-delta.down { color: #2e7d32; }

.empty-sub { font-size: 13px; opacity: 0.8; }

/* ---- AI 问答 ---- */
.ask-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
}

.ask-form button {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
}

.ask-form button:active { background: var(--accent-dark); }

.qa-card { margin-top: 14px; }

.qa-list { display: grid; gap: 14px; }

.qa-item { border-bottom: 1px solid var(--line); padding-bottom: 12px; }

.qa-item:last-child { border-bottom: 0; padding-bottom: 0; }

.qa-q {
  font-size: 14px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

.qa-a {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  background: #f7f4ee;
  border-radius: 10px;
  padding: 10px 12px;
}

.qa-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- 管理后台 ---- */
.admin-card + .admin-card { margin-top: 14px; }

.admin-list { list-style: none; margin: 0; padding: 0; }

.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.admin-user:first-child { border-top: 0; }

.admin-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-user .who { flex: 1; min-width: 0; }

.admin-user .who strong { font-size: 15px; }

.admin-user .who p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.admin-actions form { margin: 0; }

.ok-btn {
  border-color: #b8dcc6 !important;
  color: #2e7d4f !important;
}

.ok-btn:active { background: #e7f5ec !important; }

.danger-btn {
  border-color: #eec4b8 !important;
  color: #b3402a !important;
}

.danger-btn:active { background: #fbe9e7 !important; }

.badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.active { background: #e7f5ec; color: #2e7d4f; }
.badge.disabled { background: #fbe9e7; color: #b3402a; }
.badge.admin { background: #eef4fd; color: #2f6fb3; }

/* ---- 注册审核提示 ---- */
.alt-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
