:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #14211a;
  --ink-2: #61706a;
  --line: #e7ece8;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(20, 33, 26, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #e9ede9;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.phone {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 74px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 18px 10px;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  margin-left: 8px;
  letter-spacing: 0;
}
.ghost {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
}

/* ---------- generic ---------- */
main { flex: 1; padding: 0 14px 8px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.4px;
}
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--ink-2); font-size: 13px; }
.tiny { color: var(--ink-2); font-size: 12px; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.unit { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-left: 3px; }

button.btn {
  border: none;
  border-radius: 12px;
  background: var(--ok);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  width: 100%;
}
button.btn.sec {
  background: var(--ok-soft);
  color: var(--ok);
}
button.btn.ghostline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 500;
}
button.btn:active { transform: scale(0.985); }

input, select {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fbfcfb;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(31,157,85,0.25); border-color: var(--ok); }

label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: conic-gradient(var(--ok) calc(var(--p, 0) * 1%), #edf1ee 0);
  transition: background 0.4s ease;
}
.ring.over { background: conic-gradient(var(--warn) calc(var(--p, 0) * 1%), #edf1ee 0); }
.ring-inner {
  width: 92px; height: 92px; border-radius: 50%;
  background: var(--card);
  display: grid; place-items: center; text-align: center;
  line-height: 1.15;
}
.ring-inner b { font-size: 21px; display: block; }
.ring-inner span { font-size: 10.5px; color: var(--ink-2); }

/* ---------- macros ---------- */
.macro { margin-top: 10px; }
.macro .track {
  height: 7px; border-radius: 99px; background: #edf1ee; overflow: hidden; margin-top: 4px;
}
.macro .fill { height: 100%; border-radius: 99px; background: var(--ok); transition: width 0.35s ease; }
.macro .fill.p { background: #2f80ed; }
.macro .fill.f { background: #d9a300; }

/* ---------- plan ---------- */
.plan-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.plan-row:last-child { border-bottom: none; }
.pill {
  font-size: 11.5px; padding: 2px 8px; border-radius: 99px;
  background: var(--ok-soft); color: var(--ok); font-weight: 600;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.gray { background: #eef1ef; color: var(--ink-2); }
button.pill { border: none; cursor: pointer; font-family: inherit; }
.plan-row.done { opacity: 0.5; }

/* ---------- log list ---------- */
.log-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.log-item:last-child { border-bottom: none; }
.thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: #eef1ef; flex: 0 0 auto;
}
.log-main { flex: 1; min-width: 0; }
.log-main b { font-size: 14px; font-weight: 600; }
.del {
  border: none; background: transparent; color: #b3c0b8;
  font-size: 18px; cursor: pointer; padding: 4px 6px;
}

/* ---------- capture ---------- */
.drop {
  border: 1.5px dashed #cfdad3;
  border-radius: 14px;
  padding: 26px 14px;
  text-align: center;
  color: var(--ink-2);
  background: #fbfcfb;
  cursor: pointer;
}
.drop b { color: var(--ok); }
.shot-btns { display: flex; gap: 8px; margin-top: 10px; }
.shot-btns .btn { padding: 10px 12px; font-size: 14px; }
.preview { width: 100%; border-radius: 14px; display: block; margin-bottom: 10px; }
.empty { text-align: center; color: var(--ink-2); font-size: 13px; padding: 14px 0; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 99px; padding: 7px 13px; font-size: 13.5px; cursor: pointer;
}
.chip.on { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }

/* ---------- sheet ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 25, 19, 0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet {
  width: 100%; max-width: 430px; background: #fff;
  border-radius: 22px 22px 0 0; padding: 18px 18px 22px;
  max-height: 86vh; overflow-y: auto;
  animation: up 0.22s ease;
}
[hidden] { display: none !important; }

@keyframes up { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.cand {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.cand.on { border-color: var(--ok); background: var(--ok-soft); }
.cand .bar { height: 4px; border-radius: 99px; background: #edf1ee; margin-top: 4px; }
.cand .bar i { display: block; height: 100%; border-radius: 99px; background: var(--ok); }

/* ---------- week ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 10px; position: relative; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-align: center; }
.bar-box { position: relative; display: flex; align-items: flex-end; height: 106px; }
.bar-col .b { width: 100%; border-radius: 7px 7px 3px 3px; background: #cfe6d8; min-height: 3px; transition: height 0.3s; }
.bar-col .bv { position: absolute; left: 0; right: 0; font-size: 10px; line-height: 1; color: var(--ink-2); }
.tline { position: absolute; left: 0; right: 0; border-top: 1px dashed #b9cbbf; pointer-events: none; z-index: 2; }
.tline em { position: absolute; left: 0; top: -13px; font-style: normal; font-size: 10px; color: #7c8b83; background: #fff; padding: 0 3px; }
.bar-col .b.hit { background: var(--ok); }
.bar-col .b.over { background: #e8b26a; }
.bar-col span { font-size: 10.5px; color: var(--ink-2); margin-top: 6px; }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

/* ---------- notice ---------- */
.notice {
  background: var(--warn-soft); color: #8a5a08; border-radius: 12px;
  padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px;
}
.notice.bad { background: #fdecec; color: #a11d1d; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #ffffff;
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 12px rgba(20, 33, 26, 0.05);
  z-index: 20;
}
.tabbar button {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit;
  font-size: 12.5px; color: #78877f; padding: 5px 0;
}
.tabbar button.active { color: var(--ok); font-weight: 700; }

.foot { text-align: center; font-size: 11px; color: #9aa8a0; padding: 4px 8px 16px; line-height: 1.5; }

/* ---------- 引导首屏 ---------- */
.hero { padding: 6px 4px 14px; }
.hero h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.22; letter-spacing: -0.4px; font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--ok); }
.hero p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.chips span { font-size: 11.5px; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #edf2ee; padding: 4px; border-radius: 12px; }
.seg button { border: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--ink-2); padding: 9px 0; border-radius: 9px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ok); font-weight: 700; box-shadow: 0 1px 4px rgba(20, 33, 26, 0.1); }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.qchip {
  font: inherit; font-size: 13px;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer;
}
.qchip:active { background: #eef6f0; border-color: #cfe6d8; }

.menu-t { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.plan-row.done .menu-t { font-weight: 500; }
