:root {
  --bg: #0c0c0e;
  --surface: #161619;
  --surface-2: #212126;
  --line: #2a2a31;
  --text: #f3f1ec;
  --muted: #9d99a3;
  --faint: #6d6a74;
  --accent: #8ef0a8;
  --accent-ink: #0a2414;
  --amber: #f5b547;
  --protein: #7cb8ff;
  --carbs: #c9a2ff;
  --fat: #ff9db0;
  --danger: #ff7a7a;
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 28px);
}

/* ---------- peças comuns ---------- */

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.hint { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 0 20px;
  border-radius: 16px; font-size: 17px; font-weight: 650;
  transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .35; transform: none; }
.btn.ghost { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #45262a; }
.btn svg.i { width: 20px; height: 20px; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px; background: var(--surface); color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 12px; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.top h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; }
.top-title { flex: 1; }

.section-title { font-size: 19px; font-weight: 700; margin: 26px 2px 12px; }

.disclaimer { font-size: 12px; line-height: 1.5; color: var(--faint); text-align: center; margin: 28px 12px 0; }

/* ---------- boas-vindas ---------- */

.intro, .onb {
  min-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 44px);
  display: flex; flex-direction: column;
}
.intro { padding-top: 6vh; }
.intro-logo svg { width: 88px; height: 88px; }
.intro h1 { font-size: 40px; font-weight: 800; letter-spacing: -.03em; margin-top: 22px; }
.lead { font-size: 18px; color: var(--muted); margin-top: 10px; }
.intro-list { list-style: none; display: grid; gap: 16px; margin: 36px 0 auto; padding-bottom: 32px; }
.intro-list li { display: flex; align-items: center; gap: 14px; font-size: 16px; }
.intro-list svg.i { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--surface); color: var(--accent); }

.onb-top { display: flex; align-items: center; gap: 16px; }
.progress { flex: 1; display: flex; gap: 6px; }
.progress i { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-2); transition: background .3s; }
.progress i.on { background: var(--accent); }

.onb-body { flex: 1; padding-top: 36px; }
.onb-body h1 { font-size: 30px; font-weight: 780; line-height: 1.15; letter-spacing: -.02em; margin: 10px 0 8px; }
.onb-foot { display: grid; gap: 10px; padding-top: 20px; }

.choices { display: grid; gap: 10px; margin-top: 28px; }
.choice {
  text-align: left; padding: 18px 18px;
  border-radius: 18px; background: var(--surface); border: 1.5px solid var(--line);
  transition: border-color .15s, background .15s;
}
.choice strong { display: block; font-size: 17px; font-weight: 650; }
.choice span { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }
.choice.on { border-color: var(--accent); background: rgba(142, 240, 168, .08); }

.num-field {
  display: flex; align-items: baseline; gap: 10px;
  margin-top: 40px; padding-bottom: 8px;
  border-bottom: 2px solid var(--line); transition: border-color .2s;
}
.num-field:focus-within { border-color: var(--accent); }
.num-field input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  font-size: 60px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.num-field input::placeholder { color: var(--surface-2); }
.num-field span { font-size: 20px; color: var(--muted); }
.num-field.small { margin-top: 24px; }
.num-field.small input { font-size: 40px; }
.field-error { color: var(--amber); font-size: 14px; min-height: 20px; margin-top: 8px; }

.result { text-align: center; }
.goal-big { display: flex; flex-direction: column; align-items: center; margin: 14px 0 10px; }
.goal-big span { font-size: 76px; font-weight: 850; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.goal-big small { font-size: 16px; color: var(--muted); margin-top: 6px; }
.goal-big.left { align-items: flex-start; }
.goal-big.left span { font-size: 52px; }

.macro-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.macro-pills div { background: var(--surface-2); border-radius: 14px; padding: 12px 8px; text-align: center; }
.card .macro-pills div { background: var(--bg); }
.macro-pills b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.macro-pills span { font-size: 12px; color: var(--muted); }
.pill-p b { color: var(--protein); }
.pill-c b { color: var(--carbs); }
.pill-f b { color: var(--fat); }

/* ---------- entrar ---------- */

.auth .onb-body { padding-top: 24px; }
.auth .intro-logo svg { width: 64px; height: 64px; margin-bottom: 18px; }
.auth-form { display: grid; margin-top: 28px; }
.field-label { font-size: 14px; font-weight: 650; color: var(--muted); margin-bottom: 8px; }
.text-field {
  width: 100%; min-height: 56px; padding: 0 16px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
  font-size: 18px; outline: none; transition: border-color .15s;
}
.text-field:focus { border-color: var(--accent); }
.auth-form .field-error { margin: 8px 2px 14px; }
.notice {
  margin-top: 20px; padding: 12px 14px; border-radius: 14px;
  background: rgba(245, 181, 71, .12); color: var(--amber); font-size: 14px; font-weight: 600;
}

.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp-box {
  width: 100%; min-width: 0; height: 64px; padding: 0;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  text-align: center; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums;
  outline: none; caret-color: var(--accent); transition: border-color .15s;
}
.otp-box:focus { border-color: var(--accent); background: rgba(142, 240, 168, .06); }
.hint.small { font-size: 14px; margin-top: 22px; }
.link-btn {
  display: block; margin: 10px auto 0; padding: 12px 16px;
  font-size: 15px; font-weight: 650; color: var(--accent);
}
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 16px; }
.settings .rows + .btn { margin-top: 14px; }

/* ---------- tela do dia ---------- */

.has-dock { padding-bottom: 130px; }

.summary .kcal-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kcal-big { font-size: 60px; font-weight: 850; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.kcal-of { font-size: 17px; color: var(--muted); }
.bar.big { height: 14px; margin: 18px 0 10px; }
.status { font-size: 15px; color: var(--muted); }
.status-soft { font-size: 13px; color: var(--muted); margin-top: 2px; }
.summary.over .bar.big i { background: var(--amber); }
.summary.over .status { color: var(--amber); font-weight: 600; }

.macros { display: grid; gap: 14px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.macro-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.macro-head b { color: var(--text); font-variant-numeric: tabular-nums; }
.m-protein .bar i { background: var(--protein); }
.m-carbs .bar i { background: var(--carbs); }
.m-fat .bar i { background: var(--fat); }

.period { margin-top: 26px; }
.period h2 {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 0 4px 10px;
}
.meal {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px 10px 10px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  transition: transform .12s;
}
.meal:active { transform: scale(.99); }
.meal img, .meal-ph { width: 68px; height: 68px; border-radius: 13px; object-fit: cover; flex: none; }
.meal-ph { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.meal-info { flex: 1; min-width: 0; }
.meal-info strong {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meal-info span { font-size: 13px; color: var(--muted); }
.meal-kcal { font-size: 18px; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meal-kcal small { font-size: 12px; font-weight: 500; color: var(--muted); }

.empty { text-align: center; padding: 40px 20px 0; }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--surface); color: var(--accent); margin-bottom: 16px; }
.empty-icon svg.i { width: 30px; height: 30px; }
.empty p { font-size: 16px; }
.empty .muted { font-size: 14px; margin-top: 8px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-around;
  padding: 26px 20px calc(var(--safe-b) + 14px);
  background: linear-gradient(to top, var(--bg) 62%, rgba(12, 12, 14, 0));
}
.camera {
  width: 82px; height: 82px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 34px rgba(142, 240, 168, .28), 0 0 0 7px rgba(142, 240, 168, .1);
  transition: transform .12s;
}
.camera:active { transform: scale(.93); }
.camera svg.i { width: 36px; height: 36px; stroke-width: 2.1; }
.dock-side {
  width: 76px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.dock-side svg.i { width: 26px; height: 26px; color: var(--text); }

/* ---------- analisando ---------- */

.analyzing {
  min-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 44px);
  display: flex; flex-direction: column; justify-content: center; gap: 28px;
}
.scan {
  position: relative; overflow: hidden;
  aspect-ratio: 1 / 1; border-radius: 28px; background: var(--surface);
}
.scan img { width: 100%; height: 100%; object-fit: cover; }
.scan.active::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(12, 12, 14, .18);
}
.scan.active::after {
  content: ""; position: absolute; left: 0; right: 0; height: 38%;
  background: linear-gradient(to bottom, rgba(142, 240, 168, 0), rgba(142, 240, 168, .32));
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 6px 24px rgba(142, 240, 168, .55);
  animation: scan 2.2s cubic-bezier(.45, 0, .55, 1) infinite;
}
@keyframes scan {
  from { top: -38%; }
  to { top: 100%; }
}
.scan-text { aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 32px; border: 1px solid var(--line); }
.scan-text blockquote, .hero-text blockquote { font-size: 22px; font-weight: 650; line-height: 1.35; text-align: center; }
.an-msg { text-align: center; }
.an-msg h1 { font-size: 22px; font-weight: 750; }
.an-msg p { color: var(--muted); margin-top: 6px; }

/* ---------- confirmar ---------- */

.confirm { margin: calc(-1 * (var(--safe-t) + 16px)) -16px 0; }
.hero { position: relative; aspect-ratio: 1 / 1; max-height: 56vh; width: 100%; background: var(--surface); overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%;
  background: linear-gradient(to bottom, rgba(12, 12, 14, 0), var(--bg));
  pointer-events: none;
}
.hero-text {
  aspect-ratio: auto; display: grid; place-items: center;
  padding: calc(var(--safe-t) + 80px) 28px 70px;
  background: radial-gradient(120% 90% at 50% 0%, #1d2a21 0%, var(--bg) 70%);
}
.icon-btn.floating {
  position: absolute; z-index: 2;
  top: calc(var(--safe-t) + 12px); left: 12px;
  background: rgba(12, 12, 14, .55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.badge {
  position: absolute; z-index: 2;
  top: calc(var(--safe-t) + 21px); right: 12px;
  padding: 5px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: rgba(245, 181, 71, .18); color: var(--amber);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

.panel { position: relative; z-index: 1; margin-top: -34px; padding: 0 16px calc(var(--safe-b) + 120px); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 10px 16px; border-radius: 99px;
  font-size: 14px; font-weight: 650; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.item {
  padding: 14px 14px 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.item-top { display: flex; align-items: flex-start; gap: 10px; }
.item-name { flex: 1; font-size: 16px; font-weight: 600; line-height: 1.3; padding-top: 2px; }
.item-kcal { font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 2px; }
.item-trash { width: 36px; height: 36px; margin: -6px -6px 0 0; display: grid; place-items: center; border-radius: 10px; color: var(--faint); }
.item-trash svg.i { width: 19px; height: 19px; }
.item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 13px; flex: none; }
.stepper button { width: 42px; height: 40px; display: grid; place-items: center; color: var(--text); }
.stepper button svg.i { width: 18px; height: 18px; }
.stepper .grams {
  width: 46px; background: none; border: 0; outline: none;
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stepper .unit { font-size: 14px; color: var(--muted); margin-left: 3px; }
.item-mac { font-size: 12px; color: var(--muted); text-align: right; }

.add { margin-top: 4px; }
.note { font-size: 14px; color: var(--muted); background: var(--surface); border-radius: 14px; padding: 12px 14px; margin-top: 14px; }
.panel .btn.danger { margin-top: 22px; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px calc(var(--safe-b) + 14px);
  background: rgba(22, 22, 25, .9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.savebar .btn { width: auto; flex: none; padding: 0 26px; }
.tot { flex: 1; min-width: 0; }
.tot-kcal { display: block; font-size: 26px; font-weight: 850; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tot-kcal small { font-size: 14px; font-weight: 500; color: var(--muted); }
.tot-mac { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- histórico ---------- */

.chart-card svg { width: 100%; height: auto; display: block; overflow: visible; }
.c-bar { fill: var(--accent); }
.c-bar.over { fill: var(--amber); }
.c-bar.empty { fill: var(--surface-2); }
.c-goal { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-legend i { width: 18px; border-top: 1px dashed var(--muted); }
.c-val { fill: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.c-lbl { fill: var(--muted); font-size: 11px; font-weight: 600; }
.c-lbl.today { fill: var(--text); }
.chart-sum { font-size: 14px; color: var(--muted); margin-top: 14px; }
.chart-sum b { color: var(--text); }

.day-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px 14px 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.day-info { flex: 1; min-width: 0; }
.day-info strong { display: block; font-weight: 650; }
.day-info span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-row svg.i { width: 18px; height: 18px; color: var(--faint); }
.pill { font-size: 12px; font-weight: 650; padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.pill-ok { background: rgba(142, 240, 168, .12); color: var(--accent); }
.pill-over { background: rgba(245, 181, 71, .14); color: var(--amber); }
.empty-list { font-size: 14px; padding: 0 2px; }

/* ---------- ajustes ---------- */

.settings .card .eyebrow { margin-bottom: 6px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.btn-row .btn { font-size: 15px; min-height: 48px; padding: 0 10px; }
.rows { display: grid; }
.rows div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rows div:last-child { border-bottom: 0; padding-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { font-weight: 600; }
.settings .card .hint + .btn { margin-top: 16px; }

/* ---------- folha de baixo ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .6);
  opacity: 0; transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 480px;
  padding: 10px 16px calc(var(--safe-b) + 16px);
  background: var(--surface); border-radius: 26px 26px 0 0; border-top: 1px solid var(--line);
  transform: translateY(40px); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-backdrop.open .sheet { transform: none; }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 16px; }
.sheet h2 { font-size: 21px; font-weight: 750; margin-bottom: 4px; }
.sheet textarea, .sheet input {
  width: 100%; margin-top: 16px; padding: 14px 16px;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 16px;
  font-size: 17px; outline: none; resize: none;
}
.sheet textarea:focus, .sheet input:focus { border-color: var(--accent); }
.sheet .field-error { min-height: 0; margin: 8px 0; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ex { padding: 8px 12px; border-radius: 99px; background: var(--surface-2); font-size: 13px; color: var(--muted); text-align: left; }

/* ---------- aviso rápido ---------- */

#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); z-index: 100;
  transform: translate(-50%, -20px);
  padding: 10px 18px; border-radius: 99px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 650;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .scan.active::after { animation-duration: 6s; }
}
