* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #08080A;
  --surface: #16161B;
  --surface-2: #1F1F26;
  --line: #2A2A33;
  --text: #EDEDF0;
  --muted: #86868F;
  --dim: #55555E;
  --fit: #4ADE80;
  --diet: #38BDF8;
  --porn: #A78BFA;
  --smoke: #FB7185;
  --sleep: #FBBF24;
  --nav-h: 62px;
}
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* 手机全屏；宽屏上居中成 420px 一列，不至于拉成一条横幅 */
.screen {
  max-width: 420px;
  margin: 0 auto;
  padding: 6px 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}

.nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch;
  background: rgba(8,8,10,.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav button {
  flex: 1; background: none; border: none; color: var(--dim);
  font-size: 12px; font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: color .18s;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--text); }

/* ---------- header ---------- */
.hd { padding: 14px 4px 16px; }
.hd .date { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
  margin-bottom: 11px;
  transition: border-color .2s;
}
.card.done { border-color: #2f3a33; }
.card-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.card-hd .name { font-size: 15px; font-weight: 600; }
.state {
  margin-left: auto; font-size: 11px; padding: 3px 8px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--dim); white-space: nowrap;
}
.state.ok { color: var(--fit); border-color: #234032; background: rgba(74,222,128,.08); }

/* stepper */
.step { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.step button {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-size: 22px; cursor: pointer; line-height: 1;
  transition: background .15s, transform .1s;
}
.step button:active:not(:disabled) { transform: scale(.94); }
.step button:disabled { opacity: .25; cursor: default; }
.num { flex: 1; text-align: center; font-variant-numeric: tabular-nums; }
.num .v { font-size: 34px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.num .v.empty { color: var(--dim); font-weight: 400; }
.num .u { font-size: 12px; color: var(--muted); margin-top: 4px; }
.verdict { text-align: center; font-size: 12px; font-weight: 600; margin-top: 8px; min-height: 16px; }

.chip {
  background: none; border: 1px dashed var(--line); color: var(--muted);
  border-radius: 9px; padding: 9px 12px; font-size: 12.5px; font-family: inherit;
  cursor: pointer; width: 100%; margin-top: 9px; transition: all .15s;
}
.chip:active { border-color: var(--dim); color: var(--text); }

/* weight input */
.wrow { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.wrow input {
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--text); font-size: 32px; font-weight: 700; width: 112px;
  font-family: inherit; font-variant-numeric: tabular-nums; outline: none;
  padding-bottom: 3px; transition: border-color .15s;
}
.wrow input::placeholder { color: #3a3a44; font-weight: 400; }
.wrow input:focus { border-color: var(--diet); }
.wrow .unit { font-size: 13px; color: var(--muted); }
.delta { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--dim); }

/* note */
textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); font-family: inherit; font-size: 16px;
  padding: 10px 12px; resize: none; outline: none; line-height: 1.55;
  min-height: 42px; overflow: hidden; margin-top: 10px; transition: border-color .15s;
}
textarea:focus { border-color: #3d3d48; }
textarea::placeholder { color: var(--dim); }

/* 睡眠：八格半小时档位，一次点击填完，不开系统时间盘 */
.sleepgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.sleepgrid button {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-family: inherit; font-size: 13px; padding: 12px 0;
  font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background .15s, transform .1s;
}
.sleepgrid button:active { transform: scale(.95); }
.sleepgrid button.on {
  background: rgba(251,191,36,.13); border-color: var(--sleep); color: var(--sleep); font-weight: 600;
}
.sleepnow { font-size: 11.5px; color: var(--dim); margin-top: 9px; }

/* ---------- history ---------- */
.mhead { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px 14px; }
.mhead .t { font-size: 17px; font-weight: 600; }
.mhead button {
  width: 34px; height: 34px; border-radius: 9px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 17px;
}
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 6px; }
.cal .wk { font-size: 10.5px; color: var(--dim); text-align: center; padding-bottom: 2px; }
.cell {
  aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  background: var(--surface); border: 1px solid transparent; font-size: 11px;
  color: var(--dim); transition: all .13s; position: relative;
}
.cell.blank { background: #101014; }
.cell.has { color: var(--text); }
.cell.today { border-color: #4a4a58; }
.cell.sel { box-shadow: inset 0 0 0 1.6px #8b8b9c; }
.cell .marks { display: flex; gap: 2.5px; }
.cell i { width: 4px; height: 4px; border-radius: 50%; display: block; }
.leg { font-size: 11px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 2px 2px; }
.leg span { display: inline-flex; align-items: center; gap: 4px; }
.leg i { width: 6px; height: 6px; border-radius: 50%; }

/* 选中日：标题 + 与今日页同一套卡片，所以这里只管标题 */
.dayhead { font-size: 15px; font-weight: 600; padding: 18px 4px 11px; }
.dayhead .empty { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 7px; }

.blk { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 15px; margin-bottom: 12px; }
.blk h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.blk .big { font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.blk .big small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.blk .sub { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.cmp { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.cmp > span { font-size: 12px; color: var(--muted); width: 30px; flex-shrink: 0; }
.tracks { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.tr { display: flex; align-items: center; gap: 7px; height: 14px; }
.tr i { height: 9px; border-radius: 4px; display: block; min-width: 4px; transition: width .3s; }
.tr b { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.tr i.bad { background: rgba(251,113,133,.75); }
.tr i.good { background: rgba(74,222,128,.65); }
.cmpwho { display: flex; gap: 14px; font-size: 10.5px; margin-top: 9px; padding-left: 40px; }
.cmpwho .bad { color: var(--smoke); }
.cmpwho .good { color: var(--fit); }
.punch { font-size: 12.5px; line-height: 1.6; color: #c9c9d1; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.punch b { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.caveat { font-size: 10.5px; color: var(--dim); line-height: 1.6; margin-top: 8px; }
svg.chart { display: block; width: 100%; margin-top: 12px; }

/* ---------- 数据与备份 ---------- */
.dbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.dbtn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 12.5px; padding: 9px 13px; cursor: pointer;
}
.dbtn:active { border-color: var(--dim); }
.dbtn.prime { border-color: #2b4b60; color: var(--diet); }
.dnote { font-size: 11px; color: var(--dim); line-height: 1.65; margin-top: 10px; }
.dmsg { font-size: 12px; margin-top: 9px; min-height: 16px; }
.dmsg.ok { color: var(--fit); }
.dmsg.bad { color: var(--smoke); }

.foot { font-size: 11px; color: var(--dim); text-align: center; padding: 14px 0 6px; line-height: 1.7; }
.foot b { color: var(--muted); font-weight: 600; }
