:root {
  --bg: #0b0f14;
  --card: #131a23;
  --line: #22303f;
  --ink: #f4f7fb;
  --dim: #a0aec0;
  --faint: #728092;
  --accent: #6ee7c7;
  --warm: #f6b96b;
  --danger: #ff7b72;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(900px 460px at 50% -10%, #132030 0%, var(--bg) 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: contain;
  overflow-x: hidden;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- header */
.top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px rgba(110, 231, 199, .8);
}
.brand h1 { font-size: 15px; margin: 0; letter-spacing: 3px; font-weight: 600; color: var(--dim); }

.round {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .04); color: var(--dim);
  font-size: 17px; line-height: 1; cursor: pointer;
  touch-action: manipulation;
}
.round:active { background: rgba(255, 255, 255, .1); color: var(--ink); }

/* ---------------------------------------------------------------- card */
.card {
  margin-top: 14px;
  border-radius: 22px;
  padding: 20px 18px 16px;
  background: linear-gradient(158deg, #1a2432 0%, #0c111a 100%);
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; width: 210px; height: 210px; border-radius: 50%;
  left: -70px; top: -120px; background: radial-gradient(circle, rgba(110, 231, 199, .18), transparent 70%);
}
.card::after {
  content: ""; position: absolute; width: 210px; height: 210px; border-radius: 50%;
  right: -80px; bottom: -130px; background: radial-gradient(circle, rgba(246, 185, 107, .16), transparent 70%);
}
.card > * { position: relative; }

.daysline { display: flex; align-items: baseline; gap: 8px; }
.daysline b {
  font-size: clamp(42px, 15vw, 62px); line-height: 1.02; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.unit { font-size: 14px; color: var(--dim); }
.ageline { margin-top: 4px; font-size: 12.5px; color: var(--faint); }

.clockline { margin-top: 14px; display: flex; align-items: baseline; gap: 6px; }
.clockline .tag { font-size: 12.5px; color: var(--faint); }
.clockline b {
  font-size: 21px; font-weight: 700; color: var(--warm);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.nextline { margin-top: 2px; font-size: 12px; color: var(--faint); }

.secsline { margin-top: 12px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.secsline b { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.secsline em { font-style: normal; font-size: 12px; color: var(--faint); margin-left: auto; }

.bar {
  margin-top: 14px; height: 7px; border-radius: 99px; overflow: hidden;
  background: rgba(255, 255, 255, .07);
}
.bar i {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #6ee7c7, #f6b96b);
  transition: width .4s ease;
}
.meta {
  margin-top: 10px; display: flex; justify-content: space-between;
  font-size: 12px; color: var(--faint);
}

/* ---------------------------------------------------------------- actions */
.primary {
  width: 100%; min-height: 54px; margin-top: 14px;
  border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, #6ee7c7, #2fbfa0);
  color: #062720; font-size: 16px; font-weight: 700; letter-spacing: 1px;
  font-family: inherit; touch-action: manipulation;
  box-shadow: 0 10px 24px rgba(46, 191, 160, .28);
}
.primary:active { transform: translateY(1px); }

.install { width: 100%; margin-top: 9px; border-style: dashed; color: var(--accent); }
.recent { margin-top: 20px; }
.recent h2 { font-size: 11.5px; letter-spacing: 1.4px; color: var(--faint); font-weight: 600; margin: 0 0 4px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid #18222e; font-size: 13px;
}
.recent li .t { flex: 0 0 46px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.recent li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent li .d { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.empty { color: var(--faint); font-size: 12.5px; line-height: 1.6; margin: 10px 0 0; }
.tip { margin-top: 22px; font-size: 11.5px; line-height: 1.7; color: #5b6b7d; }

.up { color: var(--accent); }
.down { color: var(--warm); }

/* ---------------------------------------------------------------- sheets */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #101822, #0b0f14 60%);
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(102%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheetTop { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheetTitle { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.sheetSub { margin-top: 3px; font-size: 11.5px; color: var(--faint); line-height: 1.5; }

.sum { margin: 14px 0 4px; }
.sumToday { font-size: 25px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.sumToday.neg { color: var(--warm); }
.sumTotal { margin-top: 3px; font-size: 12px; color: var(--faint); }

/* rules grid */
.grid {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  align-content: start;
  padding: 14px 0 8px;
}
.rule {
  min-height: 56px; border-radius: 14px; cursor: pointer;
  background: #1a222f; border: 1px solid rgba(255, 255, 255, .05);
  color: var(--accent); font-family: inherit; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 6px; text-align: center; line-height: 1.3;
  touch-action: manipulation; transition: transform .1s ease, background .15s ease;
}
.rule.neg { color: var(--warm); }
.rule:active { transform: scale(.97); background: #223042; }
.rule small { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.sheetFoot {
  flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 9px;
  /* 内容少的面板（比如设置）把按钮压到底部 */
  margin-top: auto; padding-top: 10px;
}
.ghost {
  min-height: 48px; border-radius: 13px; cursor: pointer;
  background: #232c3a; border: 1px solid rgba(255, 255, 255, .05);
  color: var(--ink); font-family: inherit; font-size: 13.5px;
  touch-action: manipulation;
}
.ghost:active { background: #2c3648; }
.status { flex: 0 0 auto; min-height: 18px; padding-top: 8px; font-size: 11.5px; color: var(--faint); line-height: 1.5; }
.status.bad { color: var(--danger); }

/* rules manager */
.rules {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  list-style: none; margin: 14px 0 0; padding: 0;
}
.rules li {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 8px 10px; margin-bottom: 6px;
  background: #131a23; border: 1px solid rgba(255, 255, 255, .05); border-radius: 11px;
  font-size: 13.5px; cursor: pointer;
}
.rules li.sel { border-color: var(--accent); background: #16242a; }
.rules li .rn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rules li .rv { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; }

/* form */
.form { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.field { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.field > span { flex: 0 0 66px; color: var(--dim); }
.field input, .field select {
  flex: 1 1 auto; min-width: 0; min-height: 44px;
  background: #0d141c; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); font-family: inherit; font-size: 14px; padding: 8px 10px;
}
.field.check { gap: 9px; }
.field.check > span { flex: 1 1 auto; color: var(--ink); font-size: 13.5px; }
.field.check input { flex: 0 0 auto; min-height: 0; width: 20px; height: 20px; accent-color: #2fbfa0; }
.row3 { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 8px; }
.row3 .field { flex-direction: column; align-items: stretch; gap: 4px; }
.row3 .field > span { flex: 0 0 auto; font-size: 11.5px; color: var(--faint); }

@media (min-width: 430px) {
  .daysline b { font-size: 58px; }
}
