:root {
  --bg: #0f1222;
  --panel: #171b31;
  --panel-2: #1f2442;
  --line: #2a3158;
  --text: #eef0ff;
  --muted: #9aa0c7;
  --xp: #45e08a;
  --gold: #ffcc33;
  --protein: #ff7a59;
  --carbs: #5aa9ff;
  --fat: #c38cff;
  --danger: #ff5c7a;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main, .top, .foot { max-width: 520px; margin: 0 auto; padding: 0 16px; }
h2 { font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.brand b { color: var(--xp); }
.icon-btn { background: none; border: 0; font-size: 20px; padding: 6px; border-radius: 10px; line-height: 1; }
.icon-btn:hover { background: var(--panel-2); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

/* Level */
.hero { display: flex; align-items: center; gap: 14px; }
.level-badge {
  flex: none; width: 62px; height: 62px; display: grid; place-items: center; align-content: center;
  background: linear-gradient(180deg, #2d2a14, #1d1b0c); border: 3px solid var(--gold); border-radius: 14px;
  box-shadow: 0 0 0 3px #3a3210, 0 0 18px rgba(255, 204, 51, .25);
}
.level-badge small { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--gold); }
.level-badge strong { font-size: 26px; line-height: 1; color: #fff3c4; }
.level-info { flex: 1; min-width: 0; }
.title { font-weight: 800; margin-bottom: 6px; }
.xpbar { height: 14px; background: #0b0e1c; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.xpbar span {
  display: block; height: 100%; width: 0; border-radius: 6px; transition: width .6s ease;
  background: repeating-linear-gradient(-45deg, var(--xp) 0 8px, #36c776 8px 16px);
  background-size: 22px 22px; animation: stripes 1.2s linear infinite;
}
@keyframes stripes { to { background-position: 22px 0; } }
.xptext { font-size: 12px; color: var(--muted); margin-top: 5px; }
.streak { flex: none; display: grid; justify-items: center; font-size: 20px; line-height: 1.1; }
.streak b { font-size: 18px; }
.streak small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.streak .freezes { text-transform: none; letter-spacing: 0; color: #9fd8ff; margin-top: 2px; }

/* Today */
.today { display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; flex: none; width: 128px; height: 128px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: #0b0e1c; }
.ring-fg { stroke: var(--xp); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-fg.over { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text strong { font-size: 26px; line-height: 1; }
.ring-text small { font-size: 12px; color: var(--muted); }
.macros { flex: 1; min-width: 0; display: grid; gap: 9px; }
.macro { display: flex; align-items: center; gap: 8px; }
.m-ico { font-size: 18px; }
.m-body { flex: 1; min-width: 0; }
.m-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.m-head span:last-child { color: var(--muted); }
.bar { height: 7px; background: #0b0e1c; border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .6s ease; }
.protein .bar span { background: var(--protein); }
.carbs .bar span { background: var(--carbs); }
.fat .bar span { background: var(--fat); }
.eaten { font-size: 12px; color: var(--muted); }
/* Fiber and sugar under Carbs. The Carbs row is a button, 44 px tall to tap; its padding is taken back by the margin,
   so the row sits and looks as it did, plus the small arrow. The rows under it are marked "kc": hidden with the
   calorie numbers. */
.carbs-btn { width: calc(100% + 12px); min-height: 44px; margin: -8px -6px; padding: 8px 6px; border: 0; border-radius: 10px; background: none; text-align: left; }
.carbs-btn:disabled { cursor: default; }
.carbs-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
@media (hover: hover) { .carbs-btn:enabled:hover { background: var(--panel-2); } }
.carbs-btn .bar { display: block; }
.sub-arrow { width: 12px; height: 12px; margin-left: 5px; vertical-align: -1px; color: var(--muted); transition: transform .2s ease; }
.carbs-btn[aria-expanded="true"] .sub-arrow { transform: rotate(180deg); }
.subs { display: grid; gap: 6px; margin-left: 10px; padding-left: 20px; border-left: 2px solid var(--line); }
.subs[hidden] { display: none; }
.subs .m-head { font-size: 12px; }
.subs .m-head:last-child { margin-bottom: 0; }
.subs .bar { height: 4px; }
.subs .bar span { background: var(--xp); }
.subs-note { margin: 0; font-size: 11px; color: var(--muted); white-space: pre-line; }

/* Scan button */
.scan-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 16px;
  padding: 18px; border-radius: var(--radius); font-size: 20px; font-weight: 800; color: #062814;
  background: linear-gradient(180deg, #5cf09d, var(--xp)); box-shadow: 0 5px 0 #23995a, 0 10px 24px rgba(69, 224, 138, .25);
  cursor: pointer; user-select: none; transition: transform .08s ease, box-shadow .08s ease;
}
.scan-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #23995a; }
.scan-btn:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Free ways to log */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: -4px 0 16px; }
.quick-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 15px; white-space: nowrap;
}
.quick-btn:hover { background: var(--panel-2); }
/* The narrowest phones (320 px): three buttons side by side need smaller words, or the page scrolls sideways. */
@media (max-width: 350px) { .quick-btn { font-size: 13px; padding: 13px 4px; gap: 4px; } }
.quick-btn:focus-visible, .chip:focus-visible, .results button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ico { width: 20px; height: 20px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  flex: none; display: grid; text-align: left; gap: 1px; max-width: 190px; padding: 9px 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--xp); }
.chip-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-kcal { font-size: 12px; color: var(--gold); }

.text-input {
  width: 100%; font: inherit; color: var(--text); background: #0b0e1c; border: 1px solid var(--line); border-radius: 10px; padding: 11px;
}
.text-input:focus { outline: 2px solid var(--xp); outline-offset: 0; }
.sheet .row label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 50dvh; overflow: auto; }
.results button {
  width: 100%; display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--panel-2);
}
.results button:hover { background: #283057; }
.r-name { font-weight: 700; font-size: 14px; }
.r-kcal { font-size: 12px; color: var(--muted); }
.r-kcal b { color: var(--gold); }
.r-group { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 2px 0; }
.r-group:first-child { padding-top: 0; }
.portion-sub { margin: -4px 0 6px; }
.credit { font-size: 11px; color: var(--muted); margin: 10px 0 0; }

.cam { position: relative; background: #000; aspect-ratio: 4 / 3; max-height: 40dvh; width: 100%; overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-frame {
  position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid var(--xp); border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(5, 7, 16, .45);
}
.code-form { display: flex; gap: 8px; margin: 10px 0; }
.code-form .text-input { flex: 1; min-width: 0; }
.code-form .btn { flex: none; }
.photo-link { display: inline-flex; gap: 6px; font-size: 14px; color: var(--xp); cursor: pointer; text-decoration: underline; }
#barcode-status.error { color: var(--danger); }

/* Accounts and the upgrade screen */
.top-actions { display: flex; gap: 4px; }
.scan-btn { position: relative; }
.scan-left {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 800;
  background: rgba(6, 40, 20, .18); color: #062814; padding: 4px 8px; border-radius: 999px;
}
.scan-left.out { background: #062814; color: var(--gold); }
.pw { text-align: center; }
.pw-badge { font-size: 46px; line-height: 1; margin: 4px 0 6px; }
.pw-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; text-align: left; }
.pw-list li { display: flex; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; font-size: 14px; }
.plans { display: grid; gap: 8px; margin-bottom: 12px; text-align: left; }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #0b0e1c; cursor: pointer; }
.plan small { flex-basis: 100%; color: var(--muted); }
.plan input:checked + span { border-color: var(--gold); background: #2d2a14; }
.plan input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.wide { width: 100%; flex: 1 1 100%; }
.btn.danger { background: #3a1420; color: #ffd0da; border: 1px solid #6b2236; }
.link { background: none; border: 0; padding: 0; color: var(--xp); text-decoration: underline; font-weight: 700; }
.center { text-align: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #0b0e1c; padding: 4px; border-radius: 12px; margin: 10px 0 12px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.acct-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.acct-form label[hidden] { display: none; }
.acct-form .btn { margin-top: 4px; }
#del-form { margin-top: 14px; }
.acct-email { font-weight: 800; font-size: 18px; margin: 0 0 4px; word-break: break-all; }
.vcode-input { font-family: Consolas, Menlo, monospace; font-size: 22px; letter-spacing: 6px; text-transform: uppercase; text-align: center; }

.wo-kcal small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quest { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; }
.quest .q-label { flex: 1; }
.quest .q-xp { font-size: 13px; font-weight: 800; color: var(--gold); white-space: nowrap; }
.quest.done { opacity: .75; }
.quest.done .q-label { text-decoration: line-through; text-decoration-color: var(--xp); }
.quest.done .q-xp { color: var(--xp); }
.bonus { margin: 10px 2px 0; font-size: 13px; color: var(--muted); }
.bonus b { color: var(--gold); }

.meal { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; }
.meal-main { flex: 1; min-width: 0; display: grid; }
.meal-time { font-size: 11px; color: var(--muted); }
.meal-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-macros { font-size: 12px; color: var(--muted); }
.meal-kcal { text-align: right; font-weight: 800; }
.meal-kcal small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.empty { color: var(--muted); margin: 4px 0 0; }
.empty b { color: var(--gold); }

.foot { font-size: 12px; color: var(--muted); text-align: center; padding-top: 4px; padding-bottom: 28px; }

/* Sheets (scan result, goal setup) */
.sheet {
  width: min(520px, 100vw); max-height: 92dvh; margin: auto auto 0; padding: 0; border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; background: var(--panel); color: var(--text); overflow: auto;
}
.sheet::backdrop { background: rgba(5, 7, 16, .7); }
@media (min-width: 560px) { .sheet { margin: auto; border-radius: 22px; } }
.sheet-body { padding: 16px; }
.sheet h2 { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 8px; }
.sheet-photo { position: relative; background: #000; }
.sheet-photo img { display: block; width: 100%; max-height: 34dvh; object-fit: cover; }
.scanning { position: absolute; inset: 0; display: none; overflow: hidden; background: rgba(15, 18, 34, .25); }
.scanline {
  position: absolute; left: 0; right: 0; height: 40%; top: -40%;
  background: linear-gradient(180deg, transparent, rgba(69, 224, 138, .45) 85%, var(--xp));
  animation: scan 1.4s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
.scan-status { display: none; font-weight: 700; color: var(--xp); margin: 0 0 12px; }
.scan-status small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.sheet.loading .scanning, .sheet.loading .scan-status { display: block; }
.sheet.loading .result, .sheet.failed .result { display: none; }
.sheet.loading #sheet-log, .sheet.failed #sheet-log { display: none; }

.demo-flag { font-size: 13px; background: #2d2a14; color: #ffe08a; border: 1px solid #5a4b16; border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; }
.items { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.item { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; }
.item-top, .item-bottom { display: flex; align-items: center; gap: 8px; }
.item-bottom { margin-top: 6px; }
.item-name { flex: 1; min-width: 0; font-weight: 700; }
.item-kcal { font-weight: 800; white-space: nowrap; }
.item-macros { flex: 1; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.conf-high .dot { background: var(--xp); }
.conf-medium .dot { background: var(--gold); }
.conf-low .dot { background: var(--danger); }
.stepper { display: flex; align-items: center; background: #0b0e1c; border-radius: 10px; }
.stepper button { width: 34px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 800; color: var(--xp); }
.stepper span { min-width: 58px; text-align: center; font-size: 14px; }
.notes { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.sheet-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.sheet-total strong { font-size: 20px; }
.sheet-total .muted { flex-basis: 100%; font-size: 13px; }
.error { color: var(--danger); font-weight: 700; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; padding: 13px 16px; border-radius: 12px; border: 0; font-weight: 800; font-size: 16px; white-space: nowrap; }
.sheet-actions .btn.ghost { flex: none; }
.btn.primary { background: var(--xp); color: #062814; }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); }

/* Your plan (⚙️) */
.plan-sum { display: grid; gap: 2px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: #123522; border: 1px solid #1f6b40; }
.plan-sum strong { color: var(--xp); font-size: 20px; }
.plan-sum small { color: var(--muted); font-size: 13px; }
.set-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.set-list button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 12px;
  border: 0; border-radius: 12px; background: var(--panel-2);
}
.set-list button:hover { background: #283057; }
.set-list button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.set-list span:first-child { flex: none; color: var(--muted); font-size: 14px; }
.set-list b { flex: 1; min-width: 0; text-align: right; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-list .chev { color: var(--muted); font-size: 20px; line-height: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { border: 0; padding: 0; margin: 0 0 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.seg legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.seg label { flex: 1; margin: 0; display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 10px; background: #0b0e1c; border: 1px solid var(--line); color: var(--text); font-weight: 700; cursor: pointer; }
.seg input:checked + span { border-color: var(--xp); background: #123522; color: var(--xp); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Save progress (guests) */
.save-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: #2d2a14; color: #ffe08a; border: 1px solid #5a4b16;
}
.save-pill:hover { border-color: var(--gold); }
.save-pill.signed-in { background: none; border-color: transparent; font-size: 20px; padding: 6px; }
.save-pill.signed-in:hover { background: var(--panel-2); }
.save-pill:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.save-banner { display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 14px; border-color: #5a4b16; background: linear-gradient(180deg, #24210f, var(--panel)); }
.save-banner[hidden] { display: none; }
.save-banner p { flex: 1; margin: 0; font-size: 13px; color: var(--muted); }
.save-banner p b { color: var(--text); display: block; font-size: 14px; }
.save-banner .btn { flex: none; padding: 10px 16px; }
.sb-ico { font-size: 24px; }
.sb-x { flex: none; font-size: 14px; color: var(--muted); }
.acct-why { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; background: #123522; border: 1px solid #1f6b40; font-weight: 700; }

/* Opening questions */
body.in-open { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: radial-gradient(120% 60% at 50% 0%, #1b2150, var(--bg) 60%) var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.intro[hidden] { display: none; }
.in-wrap { max-width: 520px; min-height: 100%; margin: 0 auto; padding: 12px 16px 0; display: flex; flex-direction: column; }
.in-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.in-top[hidden], .in-top [hidden] { display: none; }
.in-bar { flex: 1; height: 12px; }
.in-count { font-size: 12px; font-weight: 800; color: var(--muted); min-width: 34px; text-align: right; }
.in-close { margin-left: auto; }
.in-title { font-size: 26px; line-height: 1.2; margin: 18px 0 6px; outline: none; }
.in-sub { color: var(--muted); margin: 0 0 16px; }
.in-sub[hidden] { display: none; }
.in-content { display: grid; gap: 10px; }
.in-multi { grid-template-columns: 1fr 1fr; }
.in-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line); transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.in-opt:hover { border-color: #3d4680; }
.in-opt:active { transform: scale(.98); }
.in-opt[aria-checked="true"] { border-color: var(--xp); background: #123522; }
.in-opt:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.in-ico { flex: none; width: 34px; text-align: center; font-size: 24px; }
.in-lab { display: grid; gap: 2px; min-width: 0; }
.in-lab b { font-size: 16px; }
.in-lab small { color: var(--muted); font-size: 13px; }
.in-multi .in-opt { padding: 12px 10px; gap: 8px; }
.in-multi .in-ico { width: 26px; font-size: 20px; }
.in-multi .in-lab b { font-size: 14px; }
.in-reflect {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: #16203f; border-left: 4px solid var(--xp);
  font-weight: 700; animation: rise .25s ease;
}
.in-reflect[hidden] { display: none; }
.in-reflect.bad { border-left-color: var(--danger); color: #ffd0da; background: #2a1420; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.in-foot { position: sticky; bottom: 0; margin-top: auto; padding: 16px 0 20px; background: linear-gradient(transparent, var(--bg) 30%); }
.in-foot[hidden] { display: none; }
.in-foot .btn { font-size: 18px; padding: 15px; }

.in-nums { display: flex; gap: 10px; flex-wrap: wrap; }
.in-num { flex: 1 1 120px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.in-num-box { display: flex; align-items: baseline; gap: 6px; padding: 10px 14px; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); }
.in-num-box:focus-within { border-color: var(--xp); }
.in-num-box input { width: 100%; min-width: 0; font: inherit; font-size: 30px; font-weight: 800; color: var(--text); background: none; border: 0; outline: none; }
.in-num-box small { color: var(--muted); font-size: 15px; font-weight: 700; }
.in-units { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; background: #0b0e1c; border-radius: 12px; justify-self: start; }
.in-units button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.in-units button[aria-checked="true"] { background: var(--panel-2); color: var(--text); }

.in-hero { display: grid; place-items: center; margin: 4px 0 6px; }
.in-hero img { filter: drop-shadow(0 0 24px rgba(69, 224, 138, .35)); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.in-perks, .in-loop { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.in-perks li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--panel); font-weight: 700; }
.in-perks span { font-size: 22px; }
.in-loop li {
  display: grid; grid-template-columns: 34px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
}
.in-loop li > span { grid-row: span 2; font-size: 24px; text-align: center; }
.in-loop b { font-size: 15px; }
.in-loop small { grid-column: 2; color: var(--muted); font-size: 13px; }
.in-loop em { grid-column: 3; grid-row: 1 / span 2; font-style: normal; font-weight: 900; color: var(--gold); font-size: 13px; white-space: nowrap; }

.build-bar { height: 16px; margin: 8px 0 18px; }
.build-bar span { width: 0; transition: width .5s ease; }
.build-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.build-list li { display: flex; gap: 10px; align-items: center; color: var(--muted); opacity: .35; transition: opacity .3s ease, color .3s ease; font-weight: 700; }
.build-list li::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); }
.build-list li.done { opacity: 1; color: var(--text); }
.build-list li.done::before { border-color: var(--xp); background: var(--xp); box-shadow: inset 0 0 0 4px #123522; }

.plan-card { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 2px solid var(--gold); box-shadow: 0 0 30px rgba(255, 204, 51, .15); display: grid; gap: 12px; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.plan-top { display: flex; align-items: center; gap: 14px; }
.plan-kcal strong { font-size: 40px; line-height: 1; color: var(--xp); }
.plan-macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pm { display: grid; padding: 10px; border-radius: 12px; background: #0b0e1c; text-align: center; border-top: 3px solid; }
.pm b { font-size: 18px; }
.pm small { color: var(--muted); font-size: 12px; }
.pm.protein { border-color: var(--protein); }
.pm.carbs { border-color: var(--carbs); }
.pm.fat { border-color: var(--fat); }
.plan-line { margin: 0; font-weight: 700; display: flex; gap: 8px; }
.plan-save { margin: 18px 0 24px; }
.plan-save h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 4px; }
.plan-save .acct-form { margin-top: 10px; }
.plan-save .center { margin: 10px 0 0; }
.muted-link { color: var(--muted); font-weight: 600; }
.fine { font-size: 12px; color: var(--muted); margin: 16px 0 0; text-align: center; }
.fine a, .foot a { color: var(--muted); }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 2px 0 12px; }
.check[hidden] { display: none !important; }
.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--xp); }
.check a { color: var(--muted); }
.in-detail { margin: -6px 0 14px; }
.in-detail[hidden] { display: none; }
.in-detail a { color: var(--muted); }
.in-facts { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.in-facts li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); font-size: 14px; }
.in-skip { display: block; margin: 12px auto 0; padding: 4px 10px; }
.in-skip[hidden] { display: none; }

/* Level up */
.levelup { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 16, .78); z-index: 50; padding: 16px; }
.levelup[hidden] { display: none; }
.lu-card {
  width: min(320px, 100%); text-align: center; display: grid; gap: 6px; justify-items: center; padding: 26px 20px 20px;
  background: var(--panel); border: 3px solid var(--gold); border-radius: 22px; box-shadow: 0 0 40px rgba(255, 204, 51, .35);
  animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.lu-star { font-size: 54px; animation: spin 1.2s ease-out; }
.lu-card small { font-weight: 900; letter-spacing: .2em; color: var(--gold); }
.lu-card strong { font-size: 56px; line-height: 1; }
.lu-card .btn { width: 100%; margin-top: 10px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes spin { from { transform: rotate(-200deg) scale(.3); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--gold); color: #2a2000; font-weight: 900; padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .today { flex-direction: column; align-items: stretch; }
  .ring-wrap { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.item-src { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* "Something missing or wrong?" under a scan: chips + a note, one free re-read of the same photo. */
.blindspot { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.fix { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.fix[hidden] { display: none; }
.fix summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--xp); }
.fix-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.fix-chips button { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 10px; font-size: 13px; }
.fix-chips button.on { border-color: var(--xp); color: var(--xp); }
.fix-row { display: flex; gap: 8px; }
.fix-row .text-input { flex: 1; min-width: 0; }
.fix-row .btn { flex: 0 0 auto; padding: 10px 14px; }

/* Meal sheet as an editor: logged meals open without the photo; amounts can be typed; counted foods show pieces. */
.sheet.editing .sheet-photo, .sheet.editing .blindspot, .sheet.editing .fix { display: none; }
.stepper .amt { display: flex; align-items: baseline; justify-content: center; gap: 3px; min-width: 66px; }
.stepper .amt span { min-width: 0; color: var(--muted); font-size: 12px; }
.stepper input { width: 44px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; font-weight: 700; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.add-food { width: 100%; margin: 0 0 10px; padding: 10px 14px; }

/* Apple Health / Health Connect (phone app only, engine/client/health.js) */
.btn-gap { width: 32px; flex: none; }
.meal.dup .wo-kcal { color: var(--muted); text-decoration: line-through; }
.health-box { padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.health-box p { margin: 0 0 8px; }
.health-head { font-size: 15px; }
.health-state { color: var(--xp); font-size: 13px; font-weight: 700; margin-left: 4px; }

/* Quick add (⭐ saved meals, copy yesterday), describe a meal, portions and typed calories (engine/client/meals.js) */
.meal .icon-btn { padding: 6px 4px; }
.icon-btn.star:not(.on) { filter: grayscale(1); opacity: .35; }
.chip.copy { border-style: dashed; }
.sheet-name { display: flex; align-items: center; gap: 6px; }
.sheet-name input { flex: 1; min-width: 0; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px dashed transparent; border-radius: 0; padding: 2px 0; }
.sheet-name input:hover, .sheet-name input:focus { border-bottom-color: var(--muted); outline: none; }
.sheet-name span { font-size: 14px; opacity: .55; pointer-events: none; }
.portions { display: flex; align-items: center; gap: 6px; margin: 10px 0; }
.portions[hidden] { display: none; }
.portions span { font-size: 13px; color: var(--muted); margin-right: 2px; }
.portions button { min-width: 44px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 10px; font-size: 14px; font-weight: 700; }
.portions button.on { border-color: var(--xp); color: var(--xp); }
.kcal-box { display: inline-flex; align-items: baseline; gap: 3px; margin-left: auto; white-space: nowrap; }
.kcal-box input { width: 56px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 8px; background: #0b0e1c; color: var(--text); font: inherit; font-size: 16px; font-weight: 800; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.kcal-box input::-webkit-outer-spin-button, .kcal-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.kcal-box input:focus { outline: 2px solid var(--xp); outline-offset: 0; }
.kcal-box input:disabled { border-color: transparent; background: none; }
.kcal-box span { font-size: 12px; color: var(--muted); }
.sheet-total .kcal-box { margin-left: 0; }
.kcal-box.big input { width: 76px; font-size: 20px; }
.results .r-special { border: 1px solid var(--xp); }
.results .r-special .r-name { color: var(--xp); font-weight: 800; }
.results .r-special:disabled { border-color: var(--line); opacity: .6; }
.sheet.described .sheet-photo, .sheet.described .blindspot, .sheet.described .fix { display: none; }

/* Your day (Settings): day start, hide calorie numbers, quiet mode */
.set-h { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.day-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 4px; font-weight: 700; }
.day-row select { width: auto; min-width: 150px; }
#hide-help a { color: var(--xp); }
.seg[hidden] { display: none; }
/* "Don't estimate" (fiber and sugar for photo meals) is the longest choice: one line, also on a 320 px phone. */
#subs-seg span { white-space: nowrap; }
@media (max-width: 350px) { #subs-seg span { font-size: 14px; padding: 10px 4px; } }
/* Hide calorie numbers: every calorie and macro figure goes; amounts (grams, pieces) and the ring and bars stay. */
.hide-kcal .kc, .hide-kcal .meal-kcal, .hide-kcal .item-macros, .hide-kcal .kcal-box,
.hide-kcal #sheet-total, .hide-kcal #portion-per100, .hide-kcal #pt-macros, .hide-kcal #eaten-line,
.hide-kcal #p-text, .hide-kcal #c-text, .hide-kcal #f-text, .hide-kcal #wo-total, .hide-kcal .plan-kcal { display: none !important; }
.hide-kcal .ring-text small { font-size: 15px; font-weight: 700; color: var(--text); }
/* Quiet mode: nothing game-like moves (the scan line still shows a photo is being read). */
.quiet *:not(.scanline), .quiet *::before, .quiet *::after { animation: none !important; transition: none !important; }
