/* Layout: one-column phone app, Happy Scale-style cards on deep violet, floating bottom tab bar. Single dark look by design (Candy palette). */
:root {
  --bg: #221335;
  --surface: #2f1d48;
  --surface-2: #3d285a;
  --line: #4c346c;
  --text: #f3eff8;
  --muted: #b3abc6;
  --violet: #c77dff;
  --pink: #ff70a6;
  --sky: #70d6ff;
  --on-accent: #221335;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 8px; }
.app {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px calc(110px + env(safe-area-inset-bottom, 0px));
}
header.top {
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg); padding-block: 10px;
}
header.top svg { width: 40px; height: 40px; flex: none; }
header.top h1 { font-family: var(--display); font-weight: 800; font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
header.top .sub { color: var(--muted); font-size: 0.85rem; margin: 0; }
header.top .sync { margin-left: auto; font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.dot.on { background: var(--sky); }

main { display: grid; gap: 14px; }
.card { background: var(--surface); border-radius: var(--r); padding: 18px; min-width: 0; }
.card h2 { font-family: var(--display); font-weight: 700; font-size: 1.15rem; margin: 0 0 4px; text-wrap: balance; }
.card .lead { color: var(--muted); margin: 0 0 12px; font-size: 0.92rem; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }

/* Hero arc */
.hero { text-align: center; padding-top: 22px; }
.hero svg.arc { width: min(260px, 80%); height: auto; display: block; margin: 0 auto; }
.hero .big { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; margin-top: -142px; position: relative; }
.hero .bigsub { color: var(--muted); font-size: 0.9rem; margin: 6px auto 0; max-width: 150px; position: relative; }
.hero .after { margin-top: 72px; }

/* Buttons */
.btn { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 700; background: var(--violet); color: var(--on-accent); }
.btn.pink { background: var(--pink); }
.btn.sky { background: var(--sky); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 160px; min-width: 0; }

/* Segmented day picker */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button {
  border: 0; background: var(--surface-2); border-radius: 14px; padding: 8px 0 7px;
  display: grid; gap: 2px; justify-items: center; font-size: 0.72rem; color: var(--muted);
}
.days button b { font-family: var(--display); font-size: 1.05rem; color: var(--text); }
.days button[aria-pressed="true"] { background: var(--violet); color: var(--on-accent); }
.days button[aria-pressed="true"] b { color: var(--on-accent); }
.days button .tick { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.days button .tick.on { background: var(--pink); }

/* Meal rows */
.meals { display: grid; gap: 10px; }
.meal {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: start;
  background: var(--surface-2); border-radius: 16px; padding: 12px 14px; border: 0; text-align: left; width: 100%;
}
.meal .slot { grid-column: 1; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.meal .name { grid-column: 1; font-weight: 700; font-size: 1.02rem; }
.meal .kcal { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 0.85rem; }
.meal .detail { grid-column: 1 / -1; color: var(--muted); font-size: 0.88rem; margin-top: 6px; display: grid; gap: 6px; }
.meal .detail b { color: var(--text); font-weight: 500; }
.total { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 0.9rem; }

.heart { border: 0; background: transparent; padding: 4px; line-height: 0; color: var(--muted); }
.heart svg { width: 22px; height: 22px; }
.heart[aria-pressed="true"] { color: var(--pink); }

/* Shopping */
.progressbar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progressbar i { display: block; height: 100%; background: var(--sky); border-radius: 99px; transition: width .3s; }
.shop-sec h3 { font-family: var(--display); font-size: 1rem; margin: 16px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
.shop-sec h3 span { font-family: var(--body); font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .box {
  width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line); background: transparent; padding: 0;
  display: grid; place-items: center; color: var(--on-accent);
}
.item .box svg { width: 16px; height: 16px; opacity: 0; }
.item.done .box { background: var(--sky); border-color: var(--sky); }
.item.done .box svg { opacity: 1; }
.item .label { min-width: 0; }
.item .label .t { display: block; }
.item .label .es { display: block; font-size: 0.8rem; color: var(--muted); }
.item.done .label .t { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.item .price { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.item .x { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; padding: 0 4px; }
.note { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; font-size: 0.88rem; color: var(--muted); }
.note b { color: var(--text); }
.note.allergy { border-left: 0; box-shadow: inset 0 0 0 2px var(--pink); }

input[type="text"], input[type="number"], input[type="date"], select {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%;
}
label.f { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }

/* Goals */
.goal { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.goal .head { display: grid; gap: 6px; }
.goal .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.goal .head .grow { flex: 1; min-width: 0; }
.goal .t { font-weight: 700; }
.goal .d { color: var(--muted); font-size: 0.88rem; }
.chip { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.chip.food { background: color-mix(in srgb, var(--violet) 22%, transparent); color: var(--violet); }
.chip.move { background: color-mix(in srgb, var(--sky) 20%, transparent); color: var(--sky); }
.chip.care { background: color-mix(in srgb, var(--pink) 20%, transparent); color: var(--pink); }
.chip.bonus { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.slots { display: flex; gap: 8px; flex-wrap: wrap; }
.slots button {
  border: 2px solid var(--line); background: transparent; border-radius: 12px; min-width: 44px; height: 44px; padding: 0 10px;
  font-size: 0.8rem; color: var(--muted); font-weight: 700;
}
.slots button[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: var(--on-accent); }
.goal.met { box-shadow: inset 0 0 0 2px var(--violet); }
.goal .done-line { color: var(--violet); font-weight: 700; font-size: 0.88rem; }
.goals-list { display: grid; gap: 10px; }

.reward { text-align: center; display: grid; gap: 10px; }
.reward .gift { width: 56px; height: 56px; margin: 0 auto; }
.reward .what { font-family: var(--display); font-size: 1.3rem; font-weight: 700; color: var(--pink); }
.reward.earned { box-shadow: inset 0 0 0 2px var(--pink); }

/* Me / weight */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { border-radius: 16px; padding: 12px 10px; background: var(--surface-2); }
.tile .v { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; }
.tile .k { font-size: 0.82rem; color: var(--muted); }
.tile.v1 { background: color-mix(in srgb, var(--violet) 26%, var(--surface)); }
.tile.v2 { background: color-mix(in srgb, var(--sky) 22%, var(--surface)); }
.tile.v3 { background: color-mix(in srgb, var(--pink) 22%, var(--surface)); }
.track { display: flex; align-items: center; gap: 0; margin: 8px 4px 0; }
.track .m { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); flex: none; border: 2px solid var(--line); }
.track .m.done { background: var(--violet); border-color: var(--violet); }
.track .m.here { background: var(--pink); border-color: var(--pink); }
.track .seg { flex: 1; height: 4px; background: var(--surface-2); }
.track .seg.done { background: var(--violet); }
.log { display: grid; gap: 0; }
.log .r { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.log .r:last-child { border-bottom: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch button { width: 52px; height: 30px; border-radius: 99px; border: 0; background: var(--surface-2); position: relative; flex: none; }
.switch button::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: left .2s; }
.switch button[aria-pressed="true"] { background: var(--violet); }
.switch button[aria-pressed="true"]::after { left: 25px; background: var(--on-accent); }

/* Tab bar */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
nav.tabs .bar {
  max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 6px;
}
nav.tabs button {
  border: 0; background: transparent; border-radius: 20px; padding: 7px 0 6px; display: grid; justify-items: center; gap: 2px;
  font-size: 0.72rem; color: var(--muted); font-weight: 500;
}
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button[aria-current="page"] { background: var(--surface-2); color: var(--text); }
nav.tabs button[aria-current="page"] svg { color: var(--violet); }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  background: var(--pink); color: var(--on-accent); font-weight: 700; padding: 10px 18px; border-radius: 99px; max-width: calc(100% - 32px); text-align: center;
}
details summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
