:root {
  --bg: #0f1115; --card: #191c23; --field: #11141a; --line: #2a2f3a; --track: #262a33;
  --text: #eef0f4; --muted: #9aa1b0; --acc: #4ade80; --acc-dim: #1c2b22; --on-acc: #06210f;
  --p: #60a5fa; --f: #fbbf24; --c: #f472b6; --neg: #f87171;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 Manrope, -apple-system, system-ui, sans-serif; }
body { padding-top: env(safe-area-inset-top); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { opacity: .3; cursor: default; }
input, select { font: inherit; font-size: 16px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; min-height: 48px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
h2 { margin: 0; font-size: 22px; font-weight: 800; }

.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 11px; }
.b6 { font-weight: 600; } .b7 { font-weight: 700; } .block { display: block; }
.pad { padding: 10px 2px; } .pad16 { padding: 0 16px 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb { margin-bottom: 10px; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; }
.grow { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row-gap { display: flex; align-items: center; gap: 10px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--acc); } .warn { color: var(--neg); }
.label { color: var(--muted); font-size: 13px; font-weight: 600; margin: 14px 2px 2px; }
.lbl { display: block; margin-bottom: 8px; }

#view { padding-bottom: calc(110px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.head { display: flex; justify-content: space-between; align-items: flex-end; padding: 18px 20px 14px; gap: 12px; }
.sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.card { margin: 0 16px 12px; background: var(--card); border-radius: 24px; padding: 16px; }
.card.list { padding: 6px 16px; }
.card.list > .b7.mb { margin: 10px 0 4px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; background: var(--acc); color: var(--on-acc); font-weight: 800; padding: 12px; border-radius: 16px; margin-top: 8px; }
.btn.big { min-height: 54px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 700; }
.btn.sm { width: auto; margin: 0; padding: 0 18px; min-height: 44px; white-space: nowrap; }
.btn.h48 { min-height: 48px; border-radius: 14px; }
.btn.pillbtn { border-radius: 22px; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; flex: none; }
.iconbtn.sm { width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); }
.plus { width: 44px; height: 44px; border-radius: 22px; background: var(--acc-dim); color: var(--acc); display: flex; align-items: center; justify-content: center; flex: none; }
.stepper { width: 48px; height: 48px; border-radius: 14px; background: var(--track); display: flex; align-items: center; justify-content: center; flex: none; }

.ring { position: relative; flex: none; }
.ring svg { display: block; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.15; }
.ring-big { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.ring-big.sm { font-size: 30px; }
.ring-in b { font-size: 13px; font-weight: 800; }
.ring-in b.big17 { font-size: 17px; } .ring-in b.big18 { font-size: 18px; }
.ring-legend { display: flex; justify-content: center; gap: 18px; margin: 6px 0 16px; }
.ring-legend b { color: var(--text); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mring { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }

.meal { border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: 0; }
.meal-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.meal-main { flex: 1; min-width: 0; text-align: left; min-height: 44px; }
.meal-main:disabled { opacity: 1; }
.items { padding: 0 0 8px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0 8px 12px; border-left: 2px solid var(--line); font-size: 15px; }
.card.list > .item { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); }

.install { background: #1e3a2a; color: #c7f9d4; padding: 8px 8px 8px 16px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.install .iconbtn.sm { color: #c7f9d4; }

.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 536px; margin: 0 auto; height: 64px; display: flex; align-items: center; gap: 2px; padding: 0 6px; background: rgba(27,30,38,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 32px; z-index: 5; }
.tabs button { flex: 1; height: 52px; border-radius: 26px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; }
.tabs button.on { flex: 1.4; background: var(--acc); color: var(--on-acc); }

.seg { display: flex; background: var(--field); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 38px; border-radius: 11px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--line); color: var(--text); }

.bigfield { display: flex; align-items: center; background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; height: 52px; }
.bigfield input { border: 0; background: transparent; padding: 0; min-height: 0; font-size: 22px; font-weight: 800; flex: 1; min-width: 0; outline: none; }
.bigfield span { color: var(--muted); font-weight: 600; }
.bigfield.centered { justify-content: center; gap: 4px; }
.bigfield.centered input { flex: none; width: 80px; text-align: right; }
.bigfield:focus-within { border-color: var(--acc); }
input.date { width: auto; min-height: 40px; padding: 8px 12px; font-size: 15px; }

.stat { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.stat.sm { font-size: 22px; }
.stat span { font-size: 14px; color: var(--muted); font-weight: 600; }
.pill { background: var(--track); color: var(--text); border-radius: 99px; padding: 6px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill.g { background: var(--acc-dim); color: var(--acc); }
.chart { width: 100%; height: auto; display: block; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tile { background: var(--field); border-radius: 12px; padding: 8px 4px; text-align: center; }
.tile b { font-size: 15px; font-weight: 800; }
.stats { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.week { display: flex; justify-content: space-between; margin-top: 14px; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dot { width: 34px; height: 34px; border-radius: 17px; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; }
.dot.on { border: 0; background: var(--acc); color: var(--on-acc); }
.friend { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.friend.me { background: var(--acc-dim); border-radius: 16px; border-bottom-color: transparent; margin: 0 -10px; padding: 10px; }
.rank { width: 22px; text-align: center; font-weight: 800; color: var(--muted); font-size: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 20px; background: var(--track); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.streak { display: flex; align-items: center; gap: 4px; font-weight: 800; color: #fb923c; }
.btn.iconed { gap: 8px; }

.opt { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 8px; border-radius: 16px; text-align: left; border: 1px solid var(--line); }
.opt.on { border: 2px solid var(--acc); background: var(--acc-dim); }
.opt .radio { width: 20px; height: 20px; border-radius: 10px; border: 2px solid var(--muted); flex: none; }
.opt.on .radio { border: 6px solid var(--acc); }
.opt .right { text-align: right; }

.form { display: flex; flex-direction: column; gap: 12px; }
.onb { max-width: 560px; margin: 0 auto; padding-bottom: 30px; }

.auth { max-width: 380px; margin: 0 auto; padding: 60px 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; align-items: stretch; }
.auth h1 { margin-top: 8px; }
.logo { display: flex; justify-content: center; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: calc(100% - 50px); overflow-y: auto; border-radius: 28px 28px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 20px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; height: 48px; margin: 12px 0 2px; color: var(--muted); }
.search input { border: 0; background: transparent; padding: 0; min-height: 0; outline: none; }
.search:focus-within { border-color: var(--acc); }
.food { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.food-main { flex: 1; min-width: 0; text-align: left; min-height: 44px; }
.kc { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.chips button { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.chips button.on { border-color: var(--acc); background: var(--acc-dim); color: var(--acc); }
.mealseg { display: flex; gap: 6px; }
.mealseg button { flex: 1; min-height: 42px; border-radius: 12px; background: var(--field); color: var(--muted); font-size: 13px; font-weight: 700; }
.mealseg button.on { background: var(--line); color: var(--text); }
#reader { width: 100%; border-radius: 16px; overflow: hidden; background: #000; min-height: 220px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2a2f3a; padding: 10px 16px; border-radius: 14px; z-index: 20; font-size: 14px; font-weight: 600; max-width: 90vw; }
.streak.muted { color: var(--muted); }

/* ---- AI ---- */
textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; resize: none; flex: 1; min-width: 0; min-height: 48px; max-height: 120px; line-height: 1.35; }
textarea:focus { outline: 2px solid var(--acc); outline-offset: 1px; }
.filebtn { cursor: pointer; flex-direction: row; color: var(--text); font-size: 15px; }
.ai-log { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; min-height: 260px; }
.ai-intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 8px; color: var(--acc); }
.ai-intro .b7 { color: var(--text); font-size: 17px; }
.chips.col { flex-direction: column; align-items: stretch; width: 100%; margin-top: 12px; }
.chips.col button { color: var(--text); text-align: left; padding: 10px 14px; border-radius: 14px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 15px; }
.bubble.me { align-self: flex-end; background: var(--acc-dim); color: #dcfce7; border-bottom-right-radius: 6px; }
.bubble.me img { display: block; width: 180px; max-width: 100%; border-radius: 12px; margin-bottom: 6px; }
.bubble.ai { align-self: flex-start; background: var(--field); border: 1px solid var(--line); border-bottom-left-radius: 6px; width: 100%; max-width: 100%; }
.bubble.err { color: var(--neg); }
.dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-items { margin-top: 10px; }
.ai-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.ai-item.off { opacity: .45; }
.chk { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center; flex: none; }
.chk.on { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.gfield { display: flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; height: 36px; }
.gfield input { width: 46px; border: 0; background: transparent; padding: 0; min-height: 0; text-align: right; font-weight: 700; font-size: 16px; outline: none; }
.gfield span { font-size: 12px; color: var(--muted); }
.kcalw { width: 44px; text-align: right; flex: none; }
.ai-bar { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 8px; background: var(--card); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); margin-bottom: calc(-20px - env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.ai-bar .iconbtn, .ai-bar .plus { height: 48px; width: 48px; border-radius: 24px; cursor: pointer; }
.send { background: var(--acc); color: var(--on-acc); }

/* ---- QR ---- */
.invite { padding-bottom: 16px; }
.qr { background: #fff; border-radius: 18px; padding: 10px; line-height: 0; }
.qr svg { display: block; }
.linktxt { max-width: 100%; }
#sheet-tabs { position: sticky; top: -10px; background: var(--card); z-index: 2; padding: 6px 0 2px; }
