/* Fuel: design tokens + components. Mobile first, light & dark. */

:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface: #ffffff;
  --surface-2: #f2f1ee;
  --surface-3: #e9e8e4;
  --line: #e7e6e2;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8984;
  --ink: #111110;
  --on-ink: #ffffff;
  --carbs: #1baf7a;
  --protein: #4a3aa7;
  --fat: #eb6834;
  --water: #2a78d6;
  --water-soft: #dbe9fb;
  --danger: #d33b3b;
  --danger-soft: #fdecec;
  --good: #11804a;
  --good-soft: #e6f4ec;
  --warn: #b77700;
  --warn-soft: #fdf3dc;
  --shadow: 0 1px 2px rgba(20, 20, 18, .04), 0 4px 16px rgba(20, 20, 18, .04);
  --shadow-lg: 0 10px 40px rgba(20, 20, 18, .18);
  --seg-track: #e9e8e4;
  --seg-active: #ffffff;
  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c29;
    --line: #2b2b28;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8d8c85;
    --ink: #f4f4f1;
    --on-ink: #0b0b0b;
    --carbs: #199e70;
    --protein: #9085e9;
    --fat: #d95926;
    --water: #3987e5;
    --water-soft: #1b2a3d;
    --danger: #e66767;
    --danger-soft: #3a1f1f;
    --good: #3bb273;
    --good-soft: #17301f;
    --warn: #e0a72a;
    --warn-soft: #362c14;
    --shadow: none;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    --seg-track: #232321;
    --seg-active: #3d3d39;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c29;
  --line: #2b2b28;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #8d8c85;
  --ink: #f4f4f1;
  --on-ink: #0b0b0b;
  --carbs: #199e70;
  --protein: #9085e9;
  --fat: #d95926;
  --water: #3987e5;
  --water-soft: #1b2a3d;
  --danger: #e66767;
  --danger-soft: #3a1f1f;
  --good: #3bb273;
  --good-soft: #17301f;
  --warn: #e0a72a;
  --warn-soft: #362c14;
  --shadow: none;
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
  --seg-track: #232321;
  --seg-active: #3d3d39;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { -webkit-appearance: none; appearance: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
#app { min-height: 100dvh; }
.shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}
.screen {
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
  animation: screen-in .28s var(--ease);
}
.screen.no-tabbar { padding-bottom: calc(var(--safe-b) + 28px); }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px;
  position: sticky; top: 0; z-index: 20;
  margin: 0 -16px 4px; padding: calc(var(--safe-t)) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; flex: 1; text-align: center; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .side { min-width: 44px; display: flex; align-items: center; }
.topbar .side.right { justify-content: flex-end; }
.page-title { font-size: 30px; font-weight: 750; letter-spacing: -.025em; margin: 6px 0 2px; }
.page-sub { color: var(--text-2); font-size: 15px; margin: 0 0 14px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.filled { background: var(--surface); box-shadow: var(--shadow); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar-inner {
  max-width: 520px; margin: 0 auto; height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 550; color: var(--text-3);
  height: 100%; justify-content: center;
}
.tab.active { color: var(--text); }
.tab-fab {
  justify-self: center;
  width: 54px; height: 54px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  transform: translateY(-6px);
  transition: transform .2s var(--ease);
}
.tab-fab:active { transform: translateY(-6px) scale(.94); }

/* ---------- cards & lists ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-action { font-size: 14px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 2px; }
.section-label { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 8px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.center { text-align: center; }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px;
  border-top: 1px solid var(--line);
  width: 100%; text-align: left;
  background: transparent;
  transition: background .12s;
}
.list-item:first-child { border-top: 0; }
.list-item:active { background: var(--surface-2); }
.list-item .title { font-size: 15px; font-weight: 550; }
.list-item .sub { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.list-item .trail { text-align: right; flex-shrink: 0; }
.list-item .chev { color: var(--text-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 20px; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 650; letter-spacing: -.005em;
  background: var(--ink); color: var(--on-ink);
  transition: transform .12s, opacity .12s, background .12s;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.md { height: 44px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .12s;
}
.chip.active { background: var(--ink); color: var(--on-ink); }
.chip.outline { background: transparent; border-color: var(--line); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--seg-track); border-radius: 12px; padding: 3px; gap: 2px;
}
.segmented button {
  height: 34px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: background .15s, color .15s;
}
.segmented button.active { background: var(--seg-active); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 2px 6px; }
.input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid transparent;
  font-size: 16px; outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--text); background: var(--surface); }
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }
.input-wrap .input { padding-right: 52px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.switch {
  position: relative; width: 50px; height: 30px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-3); transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .22s var(--ease);
}
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }

.search-bar {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 6px 0 14px; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow);
  border: 1.5px solid transparent;
}
.search-bar:focus-within { border-color: var(--text); }
.search-bar input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; height: 100%; }
.search-bar .faint { flex-shrink: 0; }
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* ---------- sheets / modals ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, .38);
  animation: fade-in .2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81;
  max-width: 520px; margin: 0 auto;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(var(--safe-b) + 18px);
  box-shadow: var(--shadow-lg);
  animation: sheet-in .32s var(--ease);
}
.sheet .grabber { width: 38px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 2px auto 10px; }
.sheet h2 { font-size: 19px; font-weight: 700; margin: 4px 0 14px; letter-spacing: -.015em; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 92px; border-radius: 18px; background: var(--surface-2);
  font-size: 13px; font-weight: 600;
  transition: transform .12s;
}
.action:active { transform: scale(.96); }
.action .action-ico { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--surface); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 120;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  width: calc(100% - 32px); max-width: 488px;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--on-ink);
  border-radius: 16px; padding: 12px 12px 12px 16px;
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s var(--ease);
}
.toast .toast-action { font-weight: 700; padding: 6px 10px; border-radius: 9px; background: color-mix(in srgb, var(--on-ink) 14%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- dashboard ---------- */
.home-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.home-head .greet { font-size: 13px; color: var(--text-2); font-weight: 550; }
.home-head .title { font-size: 28px; font-weight: 750; letter-spacing: -.025em; line-height: 1.1; }
.streak-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px;
  border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  font-weight: 700; font-size: 15px;
}
.streak-chip svg { color: #f2711c; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 7px 0 8px; border-radius: 14px; font-size: 12px; font-weight: 600; color: var(--text-3);
}
.week-day.selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.week-day .dnum { font-size: 13px; color: var(--text); font-weight: 650; }
.week-day.future { opacity: .4; }

.cal-hero { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.cal-side { text-align: center; }
.cal-side .v { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.cal-side .l { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; gap: 4px; justify-content: center; align-items: center; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center .big { font-size: 40px; font-weight: 760; letter-spacing: -.035em; line-height: 1; }
.ring-center .cap { font-size: 12px; color: var(--text-2); font-weight: 600; margin-top: 4px; }
.over { color: var(--danger); }

.macro-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.macro-col .name { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.macro-col .val { font-size: 15px; font-weight: 650; margin-top: 2px; }
.macro-col .goal { font-size: 12px; color: var(--text-3); font-weight: 550; }
.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; flex-shrink: 0; }

.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 7px; position: relative; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; transition: width .5s var(--ease); }
.meter.lg { height: 10px; }

.water-row { display: flex; align-items: center; gap: 14px; }
.water-glasses { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.glass { width: 22px; height: 28px; border-radius: 4px 4px 7px 7px; background: var(--surface-3); position: relative; overflow: hidden; }
.glass > i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--water); transition: height .3s var(--ease); }
.round-btn {
  width: 44px; height: 44px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text);
  transition: transform .12s;
}
.round-btn:active { transform: scale(.92); }
.round-btn.ink { background: var(--ink); color: var(--on-ink); }
.round-btn.sm { width: 34px; height: 34px; }

.meal-line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.meal-line:first-of-type { border-top: 0; padding-top: 2px; }
.meal-ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--surface-2);
}

.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-tile { background: var(--surface); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.stat-tile .l { font-size: 12px; color: var(--text-2); font-weight: 600; }
.stat-tile .v { font-size: 20px; font-weight: 720; letter-spacing: -.02em; margin-top: 2px; }
.stat-tile .d { font-size: 12px; font-weight: 600; color: var(--text-3); }

.insight { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.insight:first-of-type { border-top: 0; padding-top: 0; }
.insight .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ---------- diary ---------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 4px 0 12px; }
.date-nav .date-btn { font-size: 17px; font-weight: 700; letter-spacing: -.01em; padding: 8px 12px; border-radius: 12px; position: relative; }
.date-nav .date-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; }
.equation { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1.2fr; align-items: center; text-align: center; gap: 2px; }
.equation .v { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.equation .l { font-size: 11px; color: var(--text-3); font-weight: 600; }
.equation .op { color: var(--text-3); font-size: 15px; font-weight: 600; }
.equation .res .v { font-size: 20px; }

.meal-card .meal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.meal-card .meal-head .t { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.meal-card .meal-head .m { font-size: 12px; color: var(--text-2); font-weight: 550; }
.entry {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 16px; border-top: 1px solid var(--line); min-height: 58px;
  transition: background .12s;
}
.entry:active { background: var(--surface-2); }
.entry .ename { font-size: 15px; font-weight: 550; }
.entry .esub { font-size: 13px; color: var(--text-2); }
.entry .ekcal { font-size: 15px; font-weight: 650; flex-shrink: 0; }
.entry .check { width: 24px; height: 24px; border-radius: 99px; border: 2px solid var(--surface-3); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.entry .check.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.add-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 13px 16px; border-top: 1px solid var(--line);
  font-size: 15px; font-weight: 650; color: var(--text-2);
}
.add-row:active { background: var(--surface-2); }

.food-thumb {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  font-size: 21px; overflow: hidden;
}
.food-thumb img { width: 100%; height: 100%; object-fit: cover; }
.food-thumb.lg { width: 64px; height: 64px; font-size: 32px; border-radius: 16px; }

.select-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  width: calc(100% - 32px); max-width: 488px;
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px;
  background: var(--ink); color: var(--on-ink); border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: toast-in .25s var(--ease);
}
.select-bar button { color: var(--on-ink); font-weight: 650; font-size: 14px; padding: 8px 10px; border-radius: 10px; display: inline-flex; align-items: center; gap: 4px; }
.select-bar button:active { background: color-mix(in srgb, var(--on-ink) 14%, transparent); }

/* ---------- food search / detail ---------- */
.search-head { position: sticky; top: 0; z-index: 25; background: var(--bg); margin: 0 -16px; padding: calc(var(--safe-t) + 8px) 16px 10px; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); min-height: 64px;
  transition: background .12s;
}
.result:first-child { border-top: 0; }
.result:active { background: var(--surface-2); }
.result .rname { font-size: 15px; font-weight: 580; line-height: 1.3; }
.result .rsub { font-size: 13px; color: var(--text-2); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.macro-mini { display: inline-flex; gap: 7px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.macro-mini b { font-weight: 650; }
.add-btn {
  width: 38px; height: 38px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text);
  transition: transform .12s, background .15s;
}
.add-btn:active { transform: scale(.9); }
.add-btn.done { background: var(--good); color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-2);
}
.badge.verified { background: var(--good-soft); color: var(--good); }
.badge.check { background: var(--warn-soft); color: var(--warn); }
.badge.poor { background: var(--danger-soft); color: var(--danger); }
.badge.alert { background: var(--danger-soft); color: var(--danger); }
.nutriscore { display: inline-flex; border-radius: 6px; overflow: hidden; font-size: 11px; font-weight: 800; }
.nutriscore span { width: 17px; height: 20px; display: flex; align-items: center; justify-content: center; color: #fff; opacity: .35; }
.nutriscore span.on { opacity: 1; transform: scale(1.12); border-radius: 4px; }

.amount-box { display: flex; align-items: stretch; gap: 10px; }
.amount-input {
  width: 120px; flex-shrink: 0; height: 56px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid transparent; outline: none;
  font-size: 26px; font-weight: 700; text-align: center; letter-spacing: -.02em;
}
.amount-input:focus { border-color: var(--text); background: var(--surface); }
.unit-select {
  flex: 1; min-width: 0; height: 56px; border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 0 36px 0 14px; font-size: 15px; font-weight: 600;
  border: 0; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a8984' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.nutri-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nutri-table td { padding: 9px 0; border-top: 1px solid var(--line); }
.nutri-table tr:first-child td { border-top: 0; }
.nutri-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.nutri-table tr.sub td:first-child { padding-left: 14px; color: var(--text-2); }
.nutri-table tr.strong td { font-weight: 700; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; margin-bottom: 12px; }
.banner.warn { background: var(--warn-soft); color: var(--text); }
.banner.warn svg { color: var(--warn); }
.banner.danger { background: var(--danger-soft); }
.banner.danger svg { color: var(--danger); }
.banner.good { background: var(--good-soft); }
.banner.good svg { color: var(--good); }
.banner.info { background: var(--surface-2); }
.banner svg { flex-shrink: 0; margin-top: 1px; }

.sticky-cta {
  position: sticky; bottom: 0; z-index: 10;
  margin: 12px -16px 0; padding: 12px 16px calc(var(--safe-b) + 12px);
  background: linear-gradient(to bottom, transparent, var(--bg) 24%);
}

.empty { text-align: center; padding: 34px 20px; color: var(--text-2); }
.empty .ico { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.empty h3 { margin: 0 0 4px; font-size: 16px; color: var(--text); }
.empty p { margin: 0; font-size: 14px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 20px; height: 20px; border-radius: 99px; border: 2.5px solid var(--surface-3); border-top-color: var(--text); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- charts ---------- */
.chart { position: relative; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.chart svg text { font-family: var(--font); }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-weight: 500; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--ink); color: var(--on-ink);
  border-radius: 10px; padding: 7px 10px; font-size: 12px; font-weight: 600;
  white-space: nowrap; transform: translate(-50%, -100%); box-shadow: var(--shadow-lg);
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); font-weight: 550; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-weight: 600; color: var(--text-3); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.data-table td:not(:first-child), .data-table th:not(:first-child) { text-align: right; }

/* ---------- onboarding ---------- */
.ob { min-height: 100dvh; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 10px) 20px calc(var(--safe-b) + 20px); }
.ob-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.ob-progress { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ob-progress span { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .4s var(--ease); }
.ob-cta { position: sticky; bottom: 0; z-index: 5; margin: 0 -20px calc(-1 * (var(--safe-b) + 20px)); padding: 14px 20px calc(var(--safe-b) + 20px); background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.ob-body { flex: 1; padding-top: 18px; animation: screen-in .3s var(--ease); }
.ob h1 { font-size: 30px; font-weight: 760; letter-spacing: -.03em; line-height: 1.12; margin: 6px 0 8px; }
.ob .lead { color: var(--text-2); font-size: 16px; margin: 0 0 22px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px; border-radius: 18px; margin-bottom: 10px;
  background: var(--surface); box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: border-color .15s, transform .12s;
}
.choice:active { transform: scale(.99); }
.choice.on { border-color: var(--ink); }
.choice .ct { font-size: 16px; font-weight: 650; }
.choice .cd { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.choice .emo { font-size: 26px; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.big-number { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 26px 0 14px; }
.big-number input {
  min-width: 2.6ch; border: 0; outline: 0; background: transparent; text-align: center; padding: 0;
  font-size: 64px; font-weight: 780; letter-spacing: -.04em;
  border-bottom: 3px solid var(--surface-3);
}
.big-number input:focus { border-bottom-color: var(--ink); }
.big-number .unit { font-size: 22px; font-weight: 650; color: var(--text-2); }
.range { width: 100%; height: 36px; background: transparent; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 99px; background: var(--ink); margin-top: -11px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
.range::-moz-range-thumb { width: 28px; height: 28px; border-radius: 99px; background: var(--ink); border: 0; }
.welcome-mark {
  width: 76px; height: 76px; border-radius: 24px; background: var(--ink); color: var(--on-ink);
  display: flex; align-items: center; justify-content: center; margin: 40px 0 26px;
}
.feature { display: flex; gap: 12px; align-items: center; margin: 14px 0; font-size: 15px; }
.feature .fi { width: 36px; height: 36px; border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.plan-kcal { font-size: 60px; font-weight: 790; letter-spacing: -.045em; line-height: 1; }
.calc-steps { font-size: 14px; }
.calc-steps .row { padding: 7px 0; border-top: 1px solid var(--line); }
.calc-steps .row:first-child { border-top: 0; }

/* ---------- scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 90; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .scan-top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-t) + 10px) 14px 10px; }
.scanner .scan-top .icon-btn { color: #fff; background: rgba(0, 0, 0, .35); }
.scan-window {
  position: absolute; z-index: 1; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(78vw, 340px); height: min(46vw, 200px); border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5);
}
.scan-window::before, .scan-window::after { content: ""; position: absolute; inset: 0; border-radius: 22px; border: 3px solid rgba(255, 255, 255, .9); clip-path: polygon(0 0, 22% 0, 22% 100%, 0 100%, 0 0, 100% 0, 100% 100%, 78% 100%, 78% 0); }
.scan-line { position: absolute; left: 8%; right: 8%; height: 2px; background: #ff3b30; top: 50%; box-shadow: 0 0 12px #ff3b30; animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-60px); } 50% { transform: translateY(60px); } }
.scan-bottom { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(var(--safe-b) + 22px); text-align: center; }
.scan-bottom .hint { font-size: 15px; font-weight: 600; margin-bottom: 14px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.scan-bottom .btn.secondary { background: rgba(255, 255, 255, .16); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

/* ---------- misc ---------- */
.kv { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-size: 15px; }
.kv:first-child { border-top: 0; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 650; }
.pill-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.pill-tabs::-webkit-scrollbar { display: none; }
.allergen-chip { text-transform: capitalize; }
.hidden { display: none !important; }

@media (min-width: 560px) {
  .shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
