:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --card-2: #eef1ee;
  --text: #121614;
  --text-2: #5d6661;
  --text-3: #8d958f;
  --line: rgba(18, 22, 20, 0.09);
  --line-2: rgba(18, 22, 20, 0.18);
  --accent: #1d9e75;
  --accent-ink: #0f6e56;
  --accent-bg: #e1f5ee;
  --protein: #7f77dd;
  --carbs: #ef9f27;
  --fat: #d85a30;
  --steps: #378add;
  --warn: #b5730f;
  --warn-bg: #faeeda;
  --danger: #c53b3b;
  --danger-bg: #fcebeb;
  --skin: #d4537e;
  --skin-bg: #fbeaf0;
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --card: #1a201d;
    --card-2: #242b27;
    --text: #eef2ef;
    --text-2: #a6afa9;
    --text-3: #727b75;
    --line: rgba(238, 242, 239, 0.08);
    --line-2: rgba(238, 242, 239, 0.18);
    --accent: #3fc296;
    --accent-ink: #7fdcb9;
    --accent-bg: #123528;
    --warn: #f0b55c;
    --warn-bg: #3a2a10;
    --danger: #f08b8b;
    --danger-bg: #3b1717;
    --skin: #ef8fb0;
    --skin-bg: #3a1726;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 0;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
main {
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}
h1 { font-size: 28px; font-weight: 700; margin: 4px 0 2px; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 600; margin: 22px 0 8px; }
h2.row .btn { font-size: 14px; font-weight: 500; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* header */
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; gap: 12px; }
.sub { color: var(--text-2); font-size: 14px; }
.muted { color: var(--text-3); font-size: 13px; }
.small { font-size: 13px; color: var(--text-2); }

/* cards */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; border: 0.5px solid var(--line); }
a.card { display: block; text-decoration: none; color: inherit; }
.card.tint { background: var(--accent-bg); border-color: transparent; }
.card.warn { background: var(--warn-bg); border-color: transparent; }
.label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.big { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.huge { font-size: 42px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.unit { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row.base { align-items: baseline; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > .card { margin: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stack-v > * + * { margin-top: 8px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; margin: 8px 0 6px; }
.bar > div { height: 100%; border-radius: 4px; transition: width .3s; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--card-2); color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--accent-bg); color: var(--accent-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.skin { background: var(--skin-bg); color: var(--skin); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* lists */
.list { background: var(--card); border-radius: var(--radius); border: 0.5px solid var(--line); overflow: hidden; margin-bottom: 10px; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 0.5px solid var(--line); min-height: 50px; }
.li:first-child { border-top: none; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-size: 15px; }
.li .s { font-size: 13px; color: var(--text-2); }
.li.tap { cursor: pointer; }
.li.tap:active { background: var(--card-2); }
.li-head { padding: 10px 16px 6px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 15px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* checks */
.check { width: 26px; height: 26px; border-radius: 50%; border: 1.8px solid var(--line-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: none; padding: 0; color: transparent; }
.check svg { width: 15px; height: 15px; }
.done .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.skipped .check { border-style: dashed; }
.done .t, .skipped .t { color: var(--text-3); }

/* buttons */
.btn { text-decoration: none; border: 0.5px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent-ink); padding: 6px 8px; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--card); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); border: 0.5px solid var(--line); }
.iconbtn svg { width: 20px; height: 20px; }

/* forms */
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], input[type=password], select, textarea {
  width: 100%; background: var(--card-2); border: 0.5px solid transparent; border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.seg { display: flex; background: var(--card-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: none; background: none; padding: 7px 0; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 0.5px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip.on { background: var(--accent-bg); color: var(--accent-ink); border-color: var(--accent); }
.setrow { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 0.5px solid var(--line); gap: 12px; min-height: 50px; }
.setrow:first-child { border-top: none; }
.setrow input, .setrow select { width: 120px; text-align: right; padding: 7px 10px; }
.setrow .lbl { font-size: 15px; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 12px; }
.actions button { border: 0.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 550; color: var(--text); }
.actions button svg { width: 22px; height: 22px; color: var(--accent); }
.actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions button.primary svg { color: #fff; }
.actions button:active { transform: scale(.96); }

.actions.three { grid-template-columns: repeat(3, 1fr); }

/* food rows: swipe left to delete, hold to drag */
.swipe { position: relative; overflow: hidden; border-top: 0.5px solid var(--line); }
.li-head + .swipe { border-top: 0.5px solid var(--line); }
.swipe .entry { position: relative; z-index: 1; background: var(--card); border-top: none; transition: transform .2s ease-out;
  touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
.swipe-del { visibility: hidden; position: absolute; inset: 0 0 0 auto; width: 92px; border: none; background: var(--danger); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; }
.swipe.open .swipe-del { visibility: visible; }
.swipe-del svg { width: 20px; height: 20px; }
.entry.lifted { opacity: .35; }
.entry.ghost { position: fixed; z-index: 70; pointer-events: none; border-radius: 14px; border: 1px solid var(--accent);
  background: var(--card); box-shadow: 0 10px 30px rgba(0,0,0,.25); transform: scale(1.03); }
.meal { transition: box-shadow .15s; }
.meal.drop { box-shadow: 0 0 0 2px var(--accent); }
.meal-add { width: 100%; border: none; background: none; text-align: left; color: var(--text); font-weight: 600; min-height: 52px; }
.meal-add .small { font-weight: 400; color: var(--accent-ink); }
details.vit summary { list-style: none; cursor: pointer; }
details.vit summary::-webkit-details-marker { display: none; }

/* saved meals */
.saved-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.saved-row::-webkit-scrollbar { display: none; }
.saved-chip { flex-shrink: 0; border: 0.5px solid var(--line-2); background: var(--card); border-radius: 14px; padding: 9px 13px; text-align: left; display: flex; flex-direction: column; gap: 1px; max-width: 200px; }
.saved-chip b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-chip span { font-size: 12px; color: var(--text-2); }
.saved-chip:active { transform: scale(.97); }
.iconbtn.starred { color: var(--warn); border-color: transparent; background: var(--warn-bg); }
.iconbtn.starred svg { fill: currentColor; }

/* notes */
.note-row { text-decoration: none; color: inherit; }
.note-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg); padding: 6px 0 10px; margin-top: -6px; }
.note-body { width: 100%; border: none; outline: none; resize: none; background: transparent; color: var(--text);
  font-family: inherit; font-size: 17px; line-height: 1.55; padding: 4px 0 40px; overflow: hidden; }
.note-body::first-line { font-size: 24px; font-weight: 700; }

/* saved (starred) foods */
.btn.starred, .iconbtn.starred { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.btn.starred svg, .iconbtn.starred svg { fill: currentColor; }

/* progress photos */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.pp-wrap { aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: var(--card-2); }
.pp-wrap img, .pp { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.thumb { flex-shrink: 0; width: 76px; border: 2px solid transparent; border-radius: 12px; padding: 0; background: none; overflow: hidden; }
.thumb.on { border-color: var(--accent); }
.thumb img { height: 96px; }
.thumb span { display: block; font-size: 11px; color: var(--text-2); padding: 3px 0; }

/* tabs */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 0.5px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#tabs a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-3); text-decoration: none; padding: 4px 0; font-weight: 500; }
#tabs a svg { width: 23px; height: 23px; }
#tabs a.on { color: var(--accent); }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0); transition: background .25s; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap.open { background: rgba(0,0,0,.4); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s ease-out;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 17px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); opacity: 0; transition: all .25s; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 60; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* calendar */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.month .wd { font-size: 11px; color: var(--text-3); padding: 4px 0; font-weight: 600; }
.month .d { border: none; background: none; padding: 4px 0 6px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 46px; }
.month .d .n { font-size: 15px; width: 30px; height: 30px; line-height: 30px; border-radius: 50%; }
.month .d.other .n { color: var(--text-3); }
.month .d.hol .n { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.month .d.today .n { background: var(--accent); color: #fff; font-weight: 700; }
.month .d.sel { background: var(--card-2); }
.month .dots { display: flex; gap: 2px; height: 6px; }
.month .dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.agenda .li { align-items: flex-start; }
.agenda .time { width: 50px; flex-shrink: 0; font-size: 13px; color: var(--text-2); padding-top: 2px; font-variant-numeric: tabular-nums; }

/* week strip */
.week { display: flex; justify-content: space-between; gap: 4px; }
.week .w { flex: 1; text-align: center; }
.week .c { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 4px; display: flex; align-items: center; justify-content: center; font-size: 12px; border: 1.5px dashed var(--line-2); }
.week .c.full { background: var(--accent); color: #fff; border: none; }
.week .c.part { background: var(--warn-bg); color: var(--warn); border: none; }
.week .c.today { border-style: solid; border-color: var(--text-2); }
.week .c svg { width: 15px; height: 15px; }

/* login */
.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.logo { width: 64px; height: 64px; border-radius: 16px; }

.spark { width: 100%; height: 56px; display: block; }
.empty { text-align: center; padding: 22px 12px; color: var(--text-2); font-size: 14px; }
.sep { height: 1px; background: var(--line); margin: 10px 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 10px; }
