/* ========== 轻帆 设计系统：低饱和、柔和、反焦虑 ========== */
:root {
  --bg: #FAF8F5;
  --card: #FFFFFF;
  --ink: #3B3A36;
  --ink-2: #8A867E;
  --line: #EFEAE2;
  --primary: #7FA98E;
  --primary-deep: #5E8A6F;
  --primary-soft: #EAF1EC;
  --amber-bg: #FBF4E4;
  --amber-ink: #96742A;
  --terra: #C26B60;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(90, 80, 60, 0.06);
  --tabbar-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100%; }

#view {
  padding: 0 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
}
#view.no-tab { padding-bottom: 32px; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 14px;
}
.page-head .back {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  flex: none;
}
.page-head h1 { font-size: 19px; margin: 0; font-weight: 600; }
.page-head .spacer { flex: 1; }

.home-head {
  display: flex; align-items: center;
  padding: 22px 0 16px;
}
.home-head .logo { font-size: 24px; font-weight: 700; letter-spacing: 1px; color: var(--primary-deep); }
.home-head .icon-btn { margin-left: auto; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  cursor: pointer;
  border: none;
}
.icon-btn svg, .back svg { width: 20px; height: 20px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: none; border-radius: 999px;
  padding: 15px 20px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-deep); }
.btn-ghost { background: transparent; color: var(--ink-2); font-weight: 500; }
.btn-soft { background: var(--primary-soft); color: var(--primary-deep); }
.btn svg { width: 20px; height: 20px; }

.hint {
  background: var(--amber-bg);
  color: var(--amber-ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- 首页 ---------- */
.goal-card { cursor: pointer; }
.goal-card .row { display: flex; align-items: baseline; gap: 8px; }
.goal-card .num { font-size: 26px; font-weight: 700; color: var(--primary-deep); }
.goal-card .num small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.goal-card .chev { margin-left: auto; color: var(--ink-2); align-self: center; }

.trend-card { cursor: pointer; }
.trend-card .title { display: flex; align-items: center; margin-bottom: 6px; }
.trend-card .title h2 { font-size: 15px; margin: 0; font-weight: 600; }
.trend-card .title .chev { margin-left: auto; color: var(--ink-2); }
canvas.trend { width: 100%; display: block; }

.latest-line { text-align: center; margin: 6px 0 18px; color: var(--ink-2); font-size: 14px; }
.latest-line b { color: var(--ink); font-size: 16px; }

.empty {
  text-align: center;
  padding: 44px 24px 36px;
}
.empty .art { font-size: 44px; margin-bottom: 12px; }
.empty p { color: var(--ink-2); margin: 0 0 22px; }

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 520px; margin: 0 auto;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
}
#tabbar.hide { display: none; }
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 11px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--primary-deep); font-weight: 600; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }

.input, textarea.input, select.input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #FDFCFA;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  appearance: none;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 84px; }

.weight-input {
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
  padding: 10px 0 4px;
}
.weight-input input {
  width: 150px;
  border: none; outline: none; background: transparent;
  font-size: 44px; font-weight: 700; text-align: center;
  color: var(--primary-deep);
  font-family: inherit;
  border-bottom: 2px solid var(--line);
  padding-bottom: 4px;
}
.weight-input input:focus { border-color: var(--primary); }
.weight-input .unit { color: var(--ink-2); font-size: 15px; }
.weight-input input::placeholder { color: #D8D3C8; font-weight: 500; }

.datetime-row {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-2); font-size: 14px;
  cursor: pointer;
}
.datetime-row svg { width: 17px; height: 17px; }

.collapse { margin-bottom: 12px; }
.collapse > summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px;
  cursor: pointer;
  font-weight: 600; font-size: 15px;
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary .ico { color: var(--primary-deep); display: grid; place-items: center; }
.collapse > summary .ico svg { width: 19px; height: 19px; }
.collapse > summary .arrow { margin-left: auto; color: var(--ink-2); transition: transform .18s; }
.collapse[open] > summary .arrow { transform: rotate(90deg); }
.collapse > summary .arrow svg { width: 16px; height: 16px; }
.collapse .body { padding: 2px 16px 16px; }
.collapse .badge {
  margin-left: 6px;
  font-size: 12px; font-weight: 500;
  background: var(--primary-soft); color: var(--primary-deep);
  border-radius: 999px; padding: 1px 9px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  border: 1.5px solid var(--line);
  background: #FDFCFA;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.chip.on {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-deep);
  font-weight: 600;
}

.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-thumb {
  width: 76px; height: 76px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  position: relative;
}
.photo-cell { position: relative; width: 76px; height: 76px; }
.photo-cell .del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(59,58,54,.75); color: #fff;
  border: none; font-size: 14px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.photo-add {
  width: 76px; height: 76px;
  border: 1.5px dashed #D8D3C8;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  display: grid; place-items: center;
  cursor: pointer;
}
.photo-add svg { width: 24px; height: 24px; }

/* ---------- 记录列表 ---------- */
.search-box { position: relative; margin-bottom: 12px; }
.search-box svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--ink-2);
}
.search-box .input { padding-left: 38px; border-radius: 999px; }

.filter-chips { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.filter-chips .chip { flex: none; padding: 7px 15px; font-size: 13px; }

.date-group { margin: 18px 0 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }

.record-card { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.record-card .w { font-size: 19px; font-weight: 700; color: var(--primary-deep); white-space: nowrap; }
.record-card .w small { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.record-card .meta { flex: 1; min-width: 0; }
.record-card .snippet {
  color: var(--ink-2); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.record-card .time { font-size: 12px; color: var(--ink-2); }
.record-card .picon { color: var(--ink-2); display: flex; align-items: center; gap: 3px; font-size: 12px; }
.record-card .picon svg { width: 15px; height: 15px; }

/* ---------- 报告 ---------- */
.seg {
  display: flex;
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 12px;
}
.seg button {
  flex: 1;
  border: none; background: transparent;
  border-radius: 999px;
  padding: 8px 0;
  font-size: 14px; color: var(--ink-2);
  cursor: pointer; font-family: inherit;
}
.seg button.on { background: var(--card); color: var(--primary-deep); font-weight: 600; box-shadow: var(--shadow); }

.weekly .wtitle { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.weekly .wtitle h2 { font-size: 15px; margin: 0; font-weight: 600; }
.weekly .wtitle .ico { color: var(--primary-deep); }
.weekly .wtitle .ico svg { width: 18px; height: 18px; }
.weekly p { margin: 6px 0; line-height: 1.7; }
.weekly .btn { margin-top: 12px; padding: 11px 16px; font-size: 14px; }

.timeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.timeline .cell { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; }
.timeline img { width: 100%; height: 100%; object-fit: cover; display: block; }
.timeline .cap { font-size: 11px; color: var(--ink-2); text-align: center; margin-top: 3px; }

/* ---------- 我的 ---------- */
.me-row {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px;
  cursor: pointer;
  border-radius: var(--radius);
}
.me-row + .me-row { border-top: 1px solid var(--line); border-radius: 0; }
.me-row .ico { color: var(--primary-deep); display: grid; place-items: center; flex: none; }
.me-row .ico svg { width: 20px; height: 20px; }
.me-row .txt { flex: 1; }
.me-row .txt .sub { font-size: 12px; color: var(--ink-2); }
.me-row .chev { color: var(--ink-2); }
.me-row .chev svg { width: 16px; height: 16px; }
.me-card { padding: 0; overflow: hidden; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl {
  position: absolute; inset: 0;
  background: #DDD8CE; border-radius: 999px;
  transition: .2s; cursor: pointer;
}
.switch .sl::before {
  content: ""; position: absolute;
  width: 21px; height: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.switch input:checked + .sl { background: var(--primary); }
.switch input:checked + .sl::before { transform: translateX(19px); }

.remind-detail { padding: 4px 16px 16px; display: none; }
.remind-detail.open { display: block; }
.remind-detail .row { display: flex; align-items: center; gap: 12px; }
.remind-detail input[type="time"] {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #FDFCFA;
  padding: 9px 12px;
  font-size: 15px; font-family: inherit; color: var(--ink);
}

.danger { color: var(--terra); }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0;
  background: rgba(59, 55, 48, .45);
  z-index: 100;
  display: grid; place-items: center;
  padding: 28px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  background: var(--card);
  border-radius: 20px;
  padding: 22px 20px 16px;
  width: 100%; max-width: 340px;
  max-height: 76vh; overflow-y: auto;
}
.dialog h3 { margin: 0 0 10px; font-size: 16px; }
.dialog .content { color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.dialog .actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog .actions .btn { padding: 11px 0; font-size: 15px; }
.dialog .btn-danger { background: var(--terra); color: #fff; }

.viewer {
  position: fixed; inset: 0;
  background: rgba(20,19,17,.92);
  z-index: 200;
  display: grid; place-items: center;
  cursor: zoom-out;
}
.viewer img { max-width: 94%; max-height: 88%; border-radius: 8px; }

#toast-root {
  position: fixed; left: 50%; bottom: 110px;
  transform: translateX(-50%);
  z-index: 300; pointer-events: none;
}
.toast {
  background: rgba(59,58,54,.88);
  color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  margin-top: 8px;
  animation: toast-in .2s ease;
  white-space: nowrap;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
