* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #222;
  --surface3: #2a2a2a;
  --border: #2e2e2e;
  --accent: #4ade80;
  --accent-ink: #0a0a0a;
  --accent-a06: rgba(74,222,128,0.06);
  --accent-a08: rgba(74,222,128,0.08);
  --accent-a12: rgba(74,222,128,0.12);
  --text: #f0f0f0;
  --text2: #bbb;
  --text3: #9a9a9a;
  --red: #f87171;
  --orange: #fb923c;
  --blue: #60a5fa;
  --yellow: #fbbf24;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Empurra o conteúdo abaixo da status bar/notch no mobile (PWA). */
  padding-top: var(--safe-t);
}

/* PWA instalada em mobile (touch): garante folga no topo mesmo quando o
   inset não é reportado (ex.: Android). Não afecta o browser no PC. */
@media (display-mode: standalone) and (pointer: coarse) {
  body { padding-top: max(var(--safe-t), 24px); }
}

/* ── SETUP ── */
#setup-screen {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 32px 24px; gap: 28px;
}
.setup-logo { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .2em; text-transform: uppercase; }
.setup-title { font-size: 26px; font-weight: 600; text-align: center; margin-top: 6px; }
.setup-sub { font-size: 14px; color: var(--text2); text-align: center; line-height: 1.6; max-width: 320px; }
.setup-form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; }

/* ── APP ── */
#app { flex: 1; display: none; flex-direction: column; overflow: hidden; }

/* ── VIEWS ── */
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: none; flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 48px);
  -webkit-overflow-scrolling: touch;
}
.view.active {
  display: flex;
  /* Sem fill forwards: transform retido tornava a view containing block
     do position:fixed (FAB fazia scroll com o conteúdo). */
  animation: viewFadeIn 0.18s ease;
}

/* ── HEADER ── */
.view-header {
  padding: 18px 20px 12px; display: flex;
  align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg);
  z-index: 10; border-bottom: 1px solid var(--border);
}
.view-title { font-family: var(--mono); font-size: 15px; letter-spacing: .12em; color: var(--text); text-transform: uppercase; }
.view-sub { font-family: var(--mono); font-size: 12px; color: var(--text2); margin-top: 3px; }

/* ── DIARY HEADER ── */
.diary-header { align-items: flex-start; }
.diary-head-date { font-family: var(--sans); font-size: 18px; font-weight: 600; color: var(--text); margin-top: 4px; line-height: 1.1; }
.diary-head-weekday { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; }
.diary-date-pill { display: flex; align-items: center; border: 1px solid var(--border); background: var(--surface2); border-radius: 10px; padding: 3px; }
.diary-date-nav { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--text3); font-size: 16px; line-height: 1; cursor: pointer; font-family: var(--mono); }
.diary-date-nav:active { color: var(--text); }
.diary-date-pill-sep { width: 1px; height: 14px; background: var(--border); }
.diary-date-month { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .06em; padding: 0 10px; cursor: pointer; align-self: stretch; display: flex; align-items: center; min-height: 44px; }

/* ── MACRO SUMMARY ── */
.macro-summary { padding: 16px 20px 10px; display: flex; flex-direction: column; gap: 0; border-bottom: 1px solid var(--border); }

/* Header da data + resumo de macros pinados sempre no topo do #view-today.
   O .view-header interno fica estático (a stickiness é do wrapper). */
#today-head-sticky { position: sticky; top: 0; z-index: 20; background: var(--bg); box-shadow: 0 1px 0 var(--border), 0 4px 16px -4px rgba(0,0,0,.18); }
/* A folga da status bar já vem do body (--safe-t) → header com menos padding-top. */
#today-head-sticky .view-header { position: static; padding-top: 14px; }

/* ── DIARY CALORIES ── */
.diary-kcal-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.diary-kcal-num { font-family: var(--mono); font-size: 48px; font-weight: 600; color: var(--accent); line-height: 1; cursor: pointer; }
.diary-kcal-tgt { font-family: var(--mono); font-size: 11px; color: var(--text3); }

/* ── DIARY MACRO GRID ── */
.macro-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--border); margin-top: 14px; }
.macro-cell { padding: 12px 0 10px; border-right: 1px solid var(--border); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.macro-cell:last-child { border-right: none; }
.macro-cell:nth-child(2), .macro-cell:nth-child(3) { padding-left: 12px; }
.macro-cell:active { opacity: .8; }
.macro-cell-label { font-family: var(--mono); font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .1em; }
.macro-cell-val { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1; }
.macro-cell-tgt { font-family: var(--mono); font-size: 11px; color: var(--text3); }

/* ── MACRO SECONDARY CHIPS (.msc) — used by Treino wellness/week chips ── */
.macro-secondary { display: flex; gap: 8px; }
.msc { flex: 1; padding: 10px 10px 11px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 4px; }
.msc-tap { cursor: pointer; }
.msc-tap:active { background: var(--surface3); }
/* Grid de 4 cards display-only (Forma actual, Última pesagem) */
.stat-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-row-4 > .msc { min-width: 0; }

/* ── ACTIVITY DETAIL SHEET (resumo 7 dias) ── */
.act-detail-list {
  overflow-y: auto;
  max-height: 60vh;
  padding-bottom: 16px;
}
.act-detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.act-detail-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.act-detail-info {
  flex: 1;
  min-width: 0;
}
.act-detail-name {
  display: block;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.act-detail-date {
  display: block;
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}
.act-detail-val {
  font-size: 14px;
  color: var(--text3);
  font-family: var(--mono);
  flex-shrink: 0;
}
.act-detail-val--highlight {
  color: var(--accent);
}
.act-detail-val--muted {
  color: var(--text2);
  font-size: 14px;
  font-family: var(--mono);
  flex-shrink: 0;
}
.act-detail-sep {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text3);
  background: var(--surface2);
  letter-spacing: 0.05em;
  font-family: var(--mono);
}
.act-detail-row--gym .act-detail-gym-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.act-detail-gym-vol {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── MEAL SECTIONS ── */
#diary-container { padding-top: 2px; }
.meal-section { border-radius: 12px; overflow: hidden; margin: 8px 12px; border: 1px solid var(--border); }
.meal-header { display: flex; align-items: stretch; border-top: 1px solid var(--surface3); }
.meal-header-left { flex: 1; padding: 8px 0 8px 14px; background: var(--surface2); min-height: 52px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; }
.meal-header-right { flex: 0 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: center; background: var(--accent-a06); min-height: 52px; cursor: pointer; transition: background .15s ease, transform .12s var(--ease-out-quart); }
.meal-header-right:active { background: var(--accent-a12); transform: scale(0.96); }
/* Toggle de recolher/expandir refeição (chevron). */
.meal-collapse-btn { position: relative; flex-shrink: 0; align-self: center; margin: 0 8px; width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; background: var(--surface3); border: 1px solid var(--border); border-radius: 8px; color: var(--text3); cursor: pointer; transition: transform .12s var(--ease-out-quart), background .15s ease; }
.meal-collapse-btn:active { transform: scale(0.92); }
/* Alvo de toque ≥44×44 (uso a uma mão) sem mudar o visual de 28px. */
.meal-collapse-btn::before { content: ''; position: absolute; inset: -8px; }
.meal-collapse-btn svg { width: 16px; height: 16px; transition: transform .26s var(--ease-out-quart); }
/* Chevron base aponta ▼ (expandir); refeição aberta roda para ▲ (recolher). */
.meal-section:not(.collapsed) .meal-collapse-btn svg { transform: rotate(180deg); }
/* Expand/collapse animado por grid-template-rows (não por height). */
.meal-entries { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .28s var(--ease-out-quart); }
.meal-entries-inner { overflow: hidden; min-height: 0; }
.meal-section.collapsed .meal-entries { grid-template-rows: 0fr; }
.meal-log-label { color: var(--accent); font-family: var(--mono); font-size: 13px; letter-spacing: .06em; }
.meal-head-line { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; overflow: hidden; }
.meal-name { font-size: 12px; font-family: var(--mono); color: var(--text); font-weight: 500; text-transform: uppercase; letter-spacing: .12em; }
.meal-kcal-val { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); }
.meal-kcal { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 600; }
.meal-macros { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ── MEAL BREAKDOWN SHEET ── */
.meal-bd-content { padding: 0 0 24px; }
.meal-bd-food-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); gap: 12px; cursor: pointer; }
.meal-bd-food-row:active { background: var(--surface2); }
.meal-bd-food-name { flex: 1; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-bd-food-meta { font-family: var(--mono); font-size: 12px; color: var(--text2); white-space: nowrap; }
.meal-donut-legend { display: flex; justify-content: center; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
.meal-donut-legend-item { display: flex; align-items: center; gap: 4px; font-size: 12px; font-family: var(--mono); color: var(--text2); }
.meal-donut-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.diary-entry {
  padding: 8px 14px; display: flex; align-items: center;
  justify-content: space-between; border-top: 1px solid var(--border); gap: 12px;
}
.diary-entry:active { background: var(--surface); }
.diary-entry:nth-child(odd)  { background: transparent; }
.diary-entry:nth-child(even) { background: rgba(255,255,255,0.03); }
.entry-info { flex: 1; min-width: 0; }
.entry-name { font-size: 13px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-detail { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; }
.entry-kcal { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text3); min-width: 40px; text-align: right; }
.entry-tara-flag { font-size: 11px; color: var(--orange); margin-top: 3px; font-family: var(--mono); }

/* ── TARA checkbox (sheets de log e edição) ── */
.tara-check-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; border-top: 1px solid var(--border); transition: opacity .08s ease; }
.tara-check-row:active { opacity: 0.65; }
.tara-box { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--border); background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .18s ease, border-color .18s ease, transform .12s var(--ease-out-quart); }
.tara-box.checked { border-color: var(--orange); background: rgba(251,146,60,0.12); }
.tara-box.checked::after { content: '✓'; color: var(--orange); font-size: 13px; line-height: 1; margin-top: 1px; }
.tara-check-label { font-size: 13px; color: var(--text3); transition: color .18s ease; }
.tara-check-label.checked { color: var(--orange); }
.no-entries { padding: 10px 20px; font-size: 13px; color: var(--text3); border-top: 1px solid var(--border); font-style: italic; }

/* ── BOTTOM NAV ── */
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: flex-start; padding-top: 8px; z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 4px 0; cursor: pointer; color: var(--text3);
  border: none; background: none; font-family: var(--sans); transition: color .15s;
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }
.nav-label { font-size: 12px; letter-spacing: .02em; }

/* ── BOTTOM SHEET ── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 200;
  display: flex; align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
  visibility: visible;
}
.sheet {
  width: 100%; background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(24px + var(--safe-b));
  max-height: 93dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.sheet-overlay.open .sheet {
  transform: translateY(0);
}
.sheet-handle { width: 36px; height: 4px; background: var(--surface3); border-radius: 2px; margin: 12px auto 0; }
.sheet-header {
  padding: 14px 20px 12px; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.sheet-title { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text2); }
.sheet-close { color: var(--text3); font-size: 22px; cursor: pointer; line-height: 1; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; margin: -8px -8px -8px 0; }

/* ── FORMS ── */
.form-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; }
.lt { font-family: var(--mono); font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: .08em; }
input, select {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: var(--sans); font-size: 15px;
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="number"] { font-family: var(--mono); }
.r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.divider { height: 1px; background: var(--border); margin: 2px 0; }
.section-label { font-family: var(--mono); font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; }

/* ── BUTTONS ── */
.btn {
  padding: 14px 20px; border-radius: 12px; font-family: var(--sans);
  font-size: 15px; font-weight: 500; cursor: pointer; border: none;
  transition: opacity .15s, transform .1s; width: 100%;
}
.btn:active { opacity: .8; transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }

/* ── SEARCH ── */
.search-wrap { padding: 12px 20px; position: sticky; top: 53px; background: var(--bg); z-index: 5; }
.search-results { max-height: 320px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sr-item {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.sr-item:active { background: var(--surface2); }
.sr-name { font-size: 14px; font-weight: 500; }
.sr-detail { font-size: 12px; color: var(--text2); margin-top: 2px; font-family: var(--mono); }
.sr-kcal { font-family: var(--mono); font-size: 12px; color: var(--text2); white-space: nowrap; }

.food-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.food-group-name {
  font-size: 15px;
  color: var(--text);
}

.food-group-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.food-group-count {
  font-size: 11px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 10px;
}

.food-group-chevron {
  color: var(--text3);
  font-size: 16px;
  transition: transform 0.2s ease;
  display: inline-block;
}

.food-group-chevron.open {
  transform: rotate(90deg);
}

.food-group-brands {
  background: var(--surface);
}

.food-brand-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px 11px 28px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.food-brand-item:active {
  background: var(--surface2);
}

.food-brand-name {
  font-size: 14px;
  color: var(--text2);
}

.food-brand-kcal {
  font-size: 13px;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── FOOD LIST ── */
.food-item {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.food-item:active { background: var(--surface); }
.fi-info { flex: 1; min-width: 0; }
.fi-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-detail { font-size: 14px; color: var(--text2); margin-top: 3px; font-family: var(--mono); }
.fi-kcal { font-family: var(--mono); font-size: 14px; color: var(--text2); white-space: nowrap; }

/* ── SORT CHIPS ── */
.sort-chips {
  display: flex; gap: 6px; padding: 8px 20px 10px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  position: sticky; top: 118px; background: var(--bg); z-index: 4;
  flex-shrink: 0;
}
.sort-chips::-webkit-scrollbar { display: none; }
.sort-chip {
  padding: 5px 12px; border-radius: 20px; font-size: 12px;
  font-weight: 500; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--border); background: transparent;
  color: var(--text3); font-family: var(--sans); transition: all .15s;
  flex-shrink: 0;
}
.sort-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ── DATE PICKER WEEKEND ── */
.cal-weekend { background: rgba(255,255,255,0.04) !important; }

/* ── DATE PICKER DOTS ── */
.cal-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 2px;
  flex-shrink: 0;
}

/* ── NUTRIENT ANALYSIS SHEET ── */
.nutri-rank-item { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.nutri-rank-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px; gap: 8px;
}
.nutri-rank-name {
  font-size: 14px; font-weight: 500; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nutri-rank-val { font-family: var(--mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.nutri-rank-bar-row { display: flex; align-items: center; gap: 8px; }
.nutri-rank-track { flex: 1; height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.nutri-rank-fill { height: 100%; border-radius: 2px; }
.nutri-rank-pct { font-family: var(--mono); font-size: 11px; color: var(--text3); width: 30px; text-align: right; }
.nutri-rank-chevron { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.nutri-rank-subs { padding: 2px 0; }
.nutri-rank-sub {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0 5px 12px; border-top: 1px solid var(--border);
}
.nutri-rank-sub-meal { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.nutri-rank-sub-val  { font-family: var(--mono); font-size: 11px; color: var(--text2); }

/* ── SELECTED FOOD CARD ── */
.food-card { background: var(--surface2); border-radius: 12px; padding: 14px; }
.food-card-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.food-card-sub { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.macro-preview { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.mp-chip { flex: 1; text-align: center; }
.mp-val { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.mp-val.kcal { color: var(--accent); }
.mp-val.prot { color: var(--blue); }
.mp-val.carb { color: var(--yellow); }
.mp-val.fat, .mp-val.g  { color: var(--orange); }
.mp-val.a    { color: #e879f9; }
.mp-val.f    { color: var(--accent); }
.mp-lbl { font-size: 11px; color: var(--text3); font-family: var(--mono); text-transform: uppercase; margin-top: 2px; }

/* ── FAB ── */
.fab {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 300;
  box-shadow: 0 4px 20px rgba(74,222,128,.25); z-index: 50; transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ── LOG STAGES ── */
#log-stage-search, #log-stage-grams { display: none; }
#log-stage-search.active, #log-stage-grams.active { display: block; }

/* ── TARGETS ── */
.target-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.target-section-title { font-family: var(--mono); font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
/* ── SETTINGS (rows estilo iOS: label + valor/toggle + chevron) ── */
.settings-section-title {
  font-family: var(--mono); font-size: 11px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 20px 16px 6px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.settings-row:active { background: var(--surface2); }
.settings-row--static { cursor: default; }
.settings-row--static:active { background: none; }
.settings-row--danger { margin-top: 16px; border-top: 1px solid var(--border); }
.settings-row-label { font-size: 15px; color: var(--text); }
.settings-row-value { font-family: var(--mono); font-size: 14px; color: var(--text3); }
.settings-chevron { color: var(--text3); font-size: 18px; margin-left: 8px; }
.settings-toggle-inline {
  font-family: var(--mono); font-size: 12px;
  padding: 2px 8px; margin-right: 8px;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer;
}
.countdown-badge { font-family: var(--mono); font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; padding: 6px 10px; background: var(--accent-a08); border-radius: 6px; display: inline-block; }
.countdown-badge-empty { color: var(--text3); background: transparent; }
.blocks-warning { font-family: var(--mono); font-size: 11px; color: var(--red); padding: 8px 10px; margin-top: 8px; background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: 6px; }
/* ── LOG VIEW ── */
.log-meal-wrap { padding: 0 20px 4px; }
.log-meal-label { font-family: var(--mono); font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }

/* ── EMPTY ── */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; color: var(--text3); text-align: center; }
.empty-icon { font-size: 36px; opacity: .5; }
.empty-text { font-size: 13px; line-height: 1.5; }

/* ── TREINO ── */
.treino-section-label { font-family: var(--mono); font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.treino-chart { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }

/* ── LOADING ── */
.loading { padding: 24px 20px; font-family: var(--mono); font-size: 11px; color: var(--text3); text-align: center; }

/* ── TOAST ── */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(8px); }
}
#toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; padding: 10px 18px;
  border-radius: 100px; z-index: 400; opacity: 0;
  white-space: nowrap; pointer-events: none;
}
#toast.show   { animation: toastIn  0.22s ease forwards; }
#toast.hiding { animation: toastOut 0.28s ease forwards; }

/* ── DESKTOP SCALING ── */
@media (min-width: 768px) {
  body { font-size: 25px; }
  .kcal-num { font-size: 78px; }
  .macro-cell-val { font-size: 33px; }
  .view-title { font-size: 18px; }
  .view-sub { font-size: 14px; }
  .meal-name { font-size: 16px; }
  .meal-macros { font-size: 12px; }
  .meal-kcal { font-size: 15px; }
  .macro-cell-label { font-size: 13px; }
  .macro-cell-tgt { font-size: 13px; }
  .entry-name { font-size: 19px; }
  .entry-detail { font-size: 16px; }
  .entry-kcal { font-size: 18px; }
  .fi-name { font-size: 16px; }
  .fi-detail { font-size: 14px; }
  .fi-kcal { font-size: 14px; }
  nav { height: calc(96px + var(--safe-b)); }
  .nav-btn svg { width: 33px; height: 33px; }
  .nav-label { font-size: 15px; }
  .lt { font-size: 13px; }
  input, select { font-size: 16px; padding: 14px 16px; }
  .btn { font-size: 22px; padding: 21px; }
  .sheet-title { font-size: 16px; }
  .sr-name { font-size: 16px; }
  .sr-detail { font-size: 13px; }
  .sr-kcal { font-size: 14px; }
  .food-card-name { font-size: 18px; }
  .food-card-sub { font-size: 13px; }
  .mp-val { font-size: 20px; }
  .mp-lbl { font-size: 11px; }
  .no-entries { font-size: 14px; }
  .loading { font-size: 13px; }
  .target-section-title { font-size: 12px; }
  .setup-title { font-size: 32px; }
  .setup-sub { font-size: 16px; }
  .setup-logo { font-size: 13px; }
  .macro-summary { padding: 16px 24px 10px; }
  .view-header { padding: 22px 24px 14px; }
  .meal-header-left { padding: 14px 0 12px 24px; }
  .meal-header-right { padding: 14px 24px 12px 12px; }
  .meal-collapse-btn { width: 34px; height: 34px; margin: 0 12px; }
  .meal-collapse-btn svg { width: 20px; height: 20px; }
  .meal-log-label { font-size: 15px; }
  .diary-entry { padding: 12px 24px; }
  .food-item { padding: 16px 24px; }
  .search-wrap { padding: 14px 24px; }
  .form-body { padding: 20px 24px; gap: 16px; }
}

/* ── FOODS SUB-TABS ── */
.foods-subtabs { display: flex; padding: 0 20px 0; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.foods-subtab { flex: 1; padding: 10px 0; font-size: 13px; font-family: var(--mono); color: var(--text3); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; letter-spacing: .04em; transition: color .15s, border-color .15s; }
.foods-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── MEAL TEMPLATE LIST ── */
.empty-meals { padding: 24px 20px; font-size: 13px; color: var(--text3); font-style: italic; }
.meal-tpl-row { display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.meal-tpl-info { flex: 1; min-width: 0; cursor: pointer; }
.meal-tpl-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-tpl-sub  { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 3px; }
.meal-tpl-del  { background: none; border: none; color: var(--text3); font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 6px; flex-shrink: 0; }
.meal-tpl-del:active { color: var(--red); background: var(--surface2); }

/* ── CREATE MEAL SHEET ── */
.mc-item { background: var(--surface2); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.mc-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-item-name { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-food-search { width: 100%; margin-top: 4px; }
.mc-search-results { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 160px; overflow-y: auto; }
.mc-food-option { padding: 8px 10px; background: var(--surface3); border-radius: 6px; cursor: pointer; }
.mc-food-option:active { background: var(--surface); }

/* ── LOG TYPE CHIPS ── */
.log-type-chips { display: flex; gap: 8px; padding: 14px 20px 0; }
.log-type-chip { flex: 1; padding: 12px 0; font-size: 13px; font-family: var(--mono); text-align: center; background: var(--surface2); color: var(--text2); border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; letter-spacing: .03em; }
.log-type-chip:active { background: var(--surface3); color: var(--text); border-color: var(--accent); }

/* ── COLLAPSED MEAL SELECTOR ── */
#meal-selector { padding: 0 0 4px; }
.meal-selector-collapsed { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface2); border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s; }
.meal-selector-collapsed:active { background: var(--surface3); }
#meal-selector-label { font-size: 14px; color: var(--text); font-weight: 500; }
#meal-selector-chevron { font-size: 13px; color: var(--text3); }
.meal-selector-expanded { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 0; overflow: hidden; transition: max-height .25s ease, margin-top .2s ease; margin-top: 0; }
.meal-selector-expanded.open { max-height: 240px; margin-top: 8px; }
.meal-selector-opt { padding: 11px 6px; font-size: 12px; font-family: var(--mono); background: var(--surface2); border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; color: var(--text2); transition: background .15s, border-color .15s, color .15s; text-align: center; letter-spacing: .03em; }
.meal-selector-opt.active { color: var(--accent); border-color: var(--accent); background: var(--surface2); }
.meal-selector-opt:active { background: var(--surface3); }

/* ── APPLY MEAL SHEET ── */
.apply-meal-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.apply-meal-item:last-of-type { border-bottom: none; }
.apply-meal-item-name { font-size: 14px; font-weight: 500; }
.apply-meal-item-detail { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 3px; }
.apply-meal-total { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 600; padding-top: 10px; text-align: right; }

/* ── SHEET: MAIS ── */
.mais-item { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 16px; }
.mais-item:active { background: var(--surface2); }
.mais-item-label { font-weight: 500; }
.mais-item-arrow { color: var(--text3); font-size: 18px; }

/* ── Targets display rows ───────────────────────────────────────────────── */
.t-row { display: flex; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.t-row:last-child { border-bottom: none; }
.t-row-label { flex: 1; font-size: 14px; color: var(--text2); }
.t-row-value { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); }
.t-row-unit { font-family: var(--mono); font-size: 12px; color: var(--text3); width: 16px; }
.block-chip { padding: 4px 10px; border-radius: 20px; font-family: var(--mono); font-size: 11px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }

/* ── Stats view ─────────────────────────────────────────────────────────── */
.stats-section { margin-bottom: 28px; }
.stats-section-title { font-family: var(--mono); font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
.stats-empty { font-size: 14px; color: var(--text3); padding: 8px 0; }

.stats-row { margin-bottom: 14px; }
.stats-label { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.stats-values { display: flex; align-items: baseline; gap: 4px; margin-bottom: 5px; font-family: var(--mono); font-size: 14px; }
.stats-of { color: var(--text3); font-size: 12px; }
.stats-pct { font-size: 12px; margin-left: auto; }
.stats-bar-track { height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.stats-bar-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }

.stats-dots { display: flex; justify-content: space-between; gap: 6px; }
.stats-dot-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.stats-dot { width: 100%; aspect-ratio: 1; border-radius: 50%; min-width: 28px; max-width: 40px; }
.stats-dot-label { font-family: var(--mono); font-size: 10px; color: var(--text3); }

.stats-top-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stats-top-item:last-child { border-bottom: none; }
.stats-top-rank { font-family: var(--mono); font-size: 11px; color: var(--text3); width: 16px; text-align: center; flex-shrink: 0; }
.stats-top-name { flex: 1; font-size: 14px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top-meta { font-family: var(--mono); font-size: 12px; color: var(--text3); flex-shrink: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  outline: none;
  padding: 0;
  border: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ── QTY / PORÇÃO / TARA compact layout ── */
.qty-section { display: flex; flex-direction: column; }
.qty-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.qty-row { display: flex; gap: 6px; }
.qty-row input { flex: 1.4; min-width: 0; }
.qty-portion-btn {
  flex: 1; min-width: 0; width: auto;
  font-size: 12px; padding: 6px 4px; min-height: 44px;
  white-space: normal; line-height: 1.25; text-align: center;
}
.qty-eval-btn { width: 46px; flex-shrink: 0; padding: 8px 0; font-size: 15px; min-height: 44px; }
.tara-check-row--compact { border-top: none; padding: 0; gap: 6px; flex-shrink: 0; }
.tara-check-row--compact .tara-box { width: 16px; height: 16px; border-radius: 4px; }
.tara-check-row--compact .tara-check-label { font-size: 11px; }

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
