:root {
  /* Palette */
  --bg:        #FCFEF9;
  --ink:       #0C0C0C;
  --ink-2:     #313131;
  --ink-3:     #494949;
  --accent:    #D0ED93;
  --accent-deep:#A6CE4E;

  /* Derived surfaces */
  --card:      #FFFFFF;
  --card-2:    #F4F6EF;
  --line:      #ECEEE6;
  --line-2:    #E2E6D8;

  /* Type */
  --font-display: "DM Sans", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;

  /* Shape */
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --shadow: 0 10px 30px -12px rgba(12,12,12,.16);
  --shadow-soft: 0 2px 10px -4px rgba(12,12,12,.10);

  --maxw: 480px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.02em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--ink); }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

.view {
  padding: 22px 18px calc(120px + var(--safe-b));
  animation: fade .28s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Top header ---------- */
.topbar { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom: 18px; }
.topbar .eyebrow { font-size: 12px; font-weight:600; letter-spacing:.14em; text-transform:uppercase; color: var(--ink-3); }
.topbar h1 { font-size: 28px; font-weight:700; margin-top:2px; }
.topbar .sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* Weight ring (header) */
.ring-mini { width: 76px; height: 76px; flex: none; position: relative; }
.ring-mini .val { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.ring-mini .val b { font-family: var(--font-display); font-size: 17px; font-weight:700; line-height:1; }
.ring-mini .val span { font-size: 9px; color: var(--ink-3); margin-top: 2px; letter-spacing:.04em; }

/* ---------- Week strip ---------- */
.weekstrip { display:flex; gap:8px; margin: 0 -18px 20px; padding: 0 18px; overflow-x:auto; scrollbar-width:none; }
.weekstrip::-webkit-scrollbar { display:none; }
.day-pill {
  flex: none; width: 52px; padding: 10px 0; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
  display:flex; flex-direction:column; align-items:center; gap:4px;
  transition: .18s ease;
}
.day-pill .dow { font-size: 11px; color: var(--ink-3); font-weight:500; }
.day-pill .dom { font-family: var(--font-display); font-size: 17px; font-weight:600; }
.day-pill .dot { width:5px; height:5px; border-radius:50%; background: transparent; }
.day-pill.has .dot { background: var(--accent-deep); }
.day-pill.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.day-pill.active .dow { color: rgba(252,254,249,.7); }
.day-pill.active .dot { background: var(--accent); }
.day-pill.future { opacity: .42; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-soft); border: 1px solid var(--line); }
.card + .card { margin-top: 14px; }
.section-head { display:flex; align-items:center; justify-content:space-between; margin: 26px 2px 12px; }
.section-head h2 { font-size: 19px; font-weight:600; }
.section-head .link { font-size: 13px; color: var(--ink-3); font-weight:600; }

/* Stat row */
.stat-row { display:grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.stat {
  background: var(--card); border:1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 12px; text-align:left; display:flex; flex-direction:column; gap:6px;
  transition: .15s ease;
}
.stat:active { transform: scale(.97); }
.stat .ico { width:30px; height:30px; border-radius:10px; display:grid; place-items:center; }
.stat .ico svg { width:17px; height:17px; }
.stat .big { font-family: var(--font-display); font-size: 21px; font-weight:700; line-height:1; }
.stat .lbl { font-size: 11px; color: var(--ink-3); font-weight:500; }
.ico.sleep { background:#E9EDFA; color:#5B73C4; }
.ico.water { background:#E2F1FB; color:#4AA3DD; }
.ico.mood  { background:#F1E9FB; color:#9067C6; }
.ico.fast  { background:#FBEDE2; color:#D58A4A; }

/* Meal card */
.meal {
  display:flex; gap:14px; align-items:center; padding: 12px;
  background: var(--card); border:1px solid var(--line); border-radius: var(--r-md);
}
.meal + .meal { margin-top: 10px; }
.meal .thumb {
  width: 58px; height: 58px; border-radius: 14px; flex:none; object-fit:cover;
  background: var(--card-2); display:grid; place-items:center; overflow:hidden;
}
.meal .thumb svg { width: 24px; height:24px; color: var(--accent-deep); }
.meal .body { flex:1; min-width:0; }
.meal .body .t { display:flex; align-items:center; gap:8px; }
.meal .body h3 { font-size: 15px; font-weight:600; }
.meal .body .time { font-size: 12px; color: var(--ink-3); font-family: var(--font-display); font-weight:500; }
.meal .body .desc { font-size: 13px; color: var(--ink-3); margin-top:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.meal .kcal { font-size:12px; color: var(--ink-2); font-weight:600; }
.chip-type { font-size: 10px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; padding:3px 8px; border-radius:999px; background: var(--accent); color: var(--ink); }
.chip-type.snack { background: var(--card-2); color: var(--ink-3); }

.empty {
  border: 1.5px dashed var(--line-2); border-radius: var(--r-md);
  padding: 18px; text-align:center; color: var(--ink-3); font-size: 13px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  min-height: 92px;
}

/* Reflection */
.reflect textarea {
  width:100%; border:none; resize:none; background:transparent; min-height: 70px; line-height:1.5;
}
.reflect textarea:focus { outline:none; }

/* ---------- Progress ---------- */
.weight-hero { background: linear-gradient(135deg, #DCEFA8 0%, #C5E47F 100%); color: var(--ink); border:none; }
.weight-hero .now { display:flex; align-items:flex-end; gap:8px; }
.weight-hero .now b { font-family: var(--font-display); font-size: 46px; font-weight:700; line-height:.9; }
.weight-hero .now span { font-size: 15px; font-weight:600; padding-bottom:6px; }
.weight-hero .meta { display:flex; justify-content:space-between; margin-top:16px; font-size:12px; }
.weight-hero .meta b { font-family: var(--font-display); font-size: 15px; display:block; }
.progress-track { height: 10px; border-radius:999px; background: rgba(12,12,12,.12); margin-top:14px; overflow:hidden; }
.progress-fill { height:100%; border-radius:999px; background: var(--ink); transition: width .6s cubic-bezier(.4,0,.2,1); }

.chart-card h3 { font-size: 16px; font-weight:600; margin-bottom: 4px; }
.chart-card .cap { font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }
.legend { display:flex; gap:16px; margin-bottom: 12px; }
.legend span { font-size: 12px; color: var(--ink-3); display:flex; align-items:center; gap:6px; }
.legend i { width:10px; height:10px; border-radius:3px; display:inline-block; }

/* Weekly compare */
.compare-row { display:flex; align-items:center; justify-content:space-between; padding:11px 0; border-bottom:1px solid var(--line); font-size:14px; }
.compare-row:last-child { border-bottom:none; }
.compare-row .k { color: var(--ink-2); display:flex; align-items:center; gap:9px; }
.compare-row .v { font-family: var(--font-display); font-weight:600; display:flex; align-items:center; gap:8px; }
.delta { font-size: 11px; font-weight:600; padding:2px 7px; border-radius:999px; }
.delta.up { background: var(--accent); color: var(--ink); }
.delta.down { background:#FBE2E2; color:#C45B5B; }
.delta.flat { background: var(--card-2); color: var(--ink-3); }

/* ---------- Journal ---------- */
.journal-day { margin-bottom: 18px; }
.journal-day .jd-head { display:flex; align-items:baseline; gap:10px; margin: 0 2px 10px; }
.journal-day .jd-head b { font-family: var(--font-display); font-size: 16px; font-weight:600; }
.journal-day .jd-head span { font-size: 12px; color: var(--ink-3); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left:50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: var(--maxw);
  display:flex; align-items:center; justify-content:space-around;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(252,254,249,.86); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); z-index: 40;
}
.tab { display:flex; flex-direction:column; align-items:center; gap:3px; color: var(--ink-3); font-size: 10px; font-weight:500; padding: 4px 8px; }
.tab svg { width: 23px; height:23px; }
.tab.active { color: var(--ink); }
.tab.fab {
  width: 54px; height:54px; border-radius: 18px; background: var(--ink); color: var(--accent);
  justify-content:center; margin-top: -14px; box-shadow: var(--shadow);
}
.tab.fab svg { width: 26px; height:26px; }
.tab.fab:active { transform: scale(.94); }

/* ---------- Bottom sheet ---------- */
.scrim { position: fixed; inset:0; background: rgba(12,12,12,.45); z-index: 50; opacity:0; animation: scrim .2s forwards; }
@keyframes scrim { to { opacity:1; } }
.sheet {
  position: fixed; left:50%; transform: translateX(-50%); bottom:0;
  width:100%; max-width: var(--maxw); background: var(--bg);
  border-radius: 26px 26px 0 0; z-index: 51; padding: 8px 18px calc(24px + var(--safe-b));
  max-height: 92dvh; overflow-y: auto; animation: rise .32s cubic-bezier(.16,1,.3,1);
}
@keyframes rise { from { transform: translate(-50%, 100%);} to { transform: translate(-50%,0);} }
.sheet .grab { width: 38px; height:4px; border-radius:999px; background: var(--line-2); margin: 8px auto 16px; }
.sheet h2 { font-size: 21px; font-weight:700; margin-bottom: 4px; }
.sheet .sub { font-size: 13px; color: var(--ink-3); margin-bottom: 18px; }

/* Form bits */
.field { margin-bottom: 16px; }
.field > label { display:block; font-size: 12px; font-weight:600; color: var(--ink-2); margin-bottom: 7px; letter-spacing:.02em; }
.input, .textarea {
  width:100%; background: var(--card); border:1px solid var(--line-2); border-radius: 14px;
  padding: 13px 14px; outline:none; transition:.15s;
}
.input:focus, .textarea:focus { border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(166,206,78,.18); }
.textarea { resize:vertical; min-height: 64px; }
.row2 { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display:flex; gap:8px; }
.seg button {
  flex:1; padding: 11px; border-radius: 13px; border:1px solid var(--line-2);
  background: var(--card); font-weight:600; font-size: 13px; color: var(--ink-3); transition:.15s;
}
.seg button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.photo-pick {
  position:relative; border:1.5px dashed var(--line-2); border-radius: 16px; aspect-ratio: 16/10;
  display:grid; place-items:center; overflow:hidden; background: var(--card-2); color: var(--ink-3);
}
.photo-pick img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.photo-pick .ph { display:flex; flex-direction:column; align-items:center; gap:8px; font-size:13px; }
.photo-pick svg { width:30px; height:30px; }
.photo-pick input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.photo-pick .retake { position:absolute; right:10px; bottom:10px; background: rgba(12,12,12,.7); color:#fff; font-size:11px; padding:6px 12px; border-radius:999px; font-weight:600; z-index:2; }

.btn-primary {
  width:100%; background: var(--ink); color: var(--bg); padding: 16px; border-radius: 16px;
  font-weight:600; font-size: 15px; margin-top: 6px;
}
.btn-primary:active { transform: scale(.98); }
.btn-ghost { width:100%; padding: 14px; border-radius:16px; font-weight:600; color: var(--ink-3); font-size:14px; }

/* Reflection save — secondary, black */
.reflect-actions { display:flex; justify-content:flex-end; margin-top: 10px; }
.btn-secondary {
  background: var(--ink); color: var(--bg); padding: 11px 24px; border-radius: 999px;
  font-weight:600; font-size: 14px;
}
.btn-secondary:active { transform: scale(.97); }

/* Weigh-in — green pill, bottom */
.weigh-wrap { display:flex; justify-content:center; margin-top: 24px; }
.btn-pill {
  background: var(--accent); color: var(--ink); padding: 14px 30px; border-radius: 999px;
  font-weight:600; font-size: 14px;
}
.btn-pill:active { transform: scale(.97); }

.stepper { display:flex; align-items:center; gap:14px; }
.stepper button { width:42px; height:42px; border-radius:13px; background: var(--card); border:1px solid var(--line-2); font-size:20px; font-weight:600; display:grid; place-items:center; }
.stepper .num { font-family: var(--font-display); font-size: 28px; font-weight:700; min-width: 70px; text-align:center; }
.stepper .num small { font-size: 13px; color: var(--ink-3); font-weight:500; }

.rating { display:flex; gap:6px; flex-wrap:wrap; }
.rating button { width: 34px; height:34px; border-radius:11px; border:1px solid var(--line-2); background:var(--card); font-weight:600; font-size:13px; color:var(--ink-3); }
.rating button.on { background: var(--accent); border-color: var(--accent-deep); color: var(--ink); }

.toast {
  position: fixed; left:50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-size:13px;
  font-weight:600; z-index: 60; box-shadow: var(--shadow); animation: pop .25s ease;
}
@keyframes pop { from { opacity:0; transform: translate(-50%,8px);} to {opacity:1; transform: translate(-50%,0);} }

.muted { color: var(--ink-3); }
.center-empty { text-align:center; color: var(--ink-3); padding: 60px 20px; }
.center-empty svg { width:46px; height:46px; color: var(--line-2); margin-bottom:12px; }

/* ---------- Sliders ---------- */
.slider { margin-bottom: 22px; }
.slider:last-child { margin-bottom: 6px; }
.slider-top { display:flex; align-items:center; gap:10px; margin-bottom: 12px; }
.slider-top .s-ico { width:32px; height:32px; border-radius:10px; display:grid; place-items:center; flex:none; }
.slider-top .s-ico svg { width:18px; height:18px; }
.slider-top .s-label { font-size:14px; font-weight:600; color: var(--ink-2); }
.slider-top .s-val { margin-left:auto; font-family: var(--font-display); font-size:18px; font-weight:700; }
.slider-top .s-val.unset { color: var(--ink-3); font-weight:600; font-size:14px; }
input[type=range] {
  -webkit-appearance:none; appearance:none; width:100%; height:8px; border-radius:999px;
  background: var(--line-2); outline:none; margin:0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none; width:26px; height:26px; border-radius:50%;
  background: var(--ink); border:4px solid var(--bg); box-shadow:0 2px 6px rgba(12,12,12,.25); cursor:pointer;
}
input[type=range]::-moz-range-thumb {
  width:22px; height:22px; border-radius:50%; background: var(--ink); border:4px solid var(--bg);
  box-shadow:0 2px 6px rgba(12,12,12,.25); cursor:pointer;
}
.slider-ends { display:flex; justify-content:space-between; margin-top:8px; font-size:11px; color: var(--ink-3); font-weight:500; }

/* metric accent backgrounds (reused for tiles & slider icons) */
.m-sleep   { background:#E9EDFA; color:#5B73C4; }
.m-energy  { background:#FBF4E0; color:#D9A22B; }
.m-water   { background:#E2F1FB; color:#4AA3DD; }
.m-mood    { background:#F1E9FB; color:#9067C6; }
.m-nervous { background:#E6F3EC; color:#4FAE7B; }
.m-cal     { background:#FBEDE2; color:#D58A4A; }
.m-gym     { background:#EDEAE4; color:#6B6256; }
.m-cycle   { background:#E2F1FB; color:#4AA3DD; }

/* ---------- Daily check-in summary card ---------- */
.checkin { display:grid; grid-template-columns: repeat(5,1fr); gap:8px; }
.checkin .ci {
  display:flex; flex-direction:column; align-items:center; gap:6px; padding:12px 4px;
  background: var(--card); border:1px solid var(--line); border-radius:16px; text-align:center;
}
.checkin .ci .ci-ico { width:30px; height:30px; border-radius:9px; display:grid; place-items:center; }
.checkin .ci .ci-ico svg { width:16px; height:16px; }
.checkin .ci .ci-val { font-family: var(--font-display); font-size:15px; font-weight:700; line-height:1; }
.checkin .ci .ci-val.empty { color: var(--line-2); }
.checkin .ci .ci-lbl { font-size:9px; color: var(--ink-3); font-weight:500; }

/* ---------- Exercise card ---------- */
.ex .thumb svg { color: var(--ink-3); }
.chip-type.gym { background: var(--accent); color: var(--ink); }
.chip-type.cycle { background:#E2F1FB; color:#2C6F9E; }

/* ---------- Add chooser ---------- */
.chooser { display:flex; flex-direction:column; gap:12px; }
.chooser button {
  display:flex; align-items:center; gap:14px; padding:16px; border-radius:18px;
  background: var(--card); border:1px solid var(--line-2); text-align:left;
}
.chooser button:active { transform: scale(.99); }
.chooser .c-ico { width:44px; height:44px; border-radius:13px; display:grid; place-items:center; flex:none; }
.chooser .c-ico svg { width:22px; height:22px; }
.chooser .c-txt b { display:block; font-size:15px; font-weight:600; }
.chooser .c-txt span { font-size:12px; color: var(--ink-3); }

/* inline metric chip (journal / compare) */
.ci-inline { display:inline-flex; align-items:center; gap:5px; }
.ci-inline svg { width:14px; height:14px; }
