/* Paleta clara (sem modo escuro, por pedido). */
:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f1f2ee;
  --surface-3: #e8eae4;
  --text: #17201b;
  --muted: #5f6b64;
  --faint: #8a948e;
  --line: #e3e5df;
  --accent: #1f6b4a;
  --accent-hover: #185a3e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ec;
  --info-bg: #fff4e8;
  --info-line: #f6d9b8;
  --info-ink: #7a4410;
  --star: #e0a100;
  --danger: #c2412d;
  /* cores dos macronutrientes (inspiradas em Alma/BitePal) */
  --prot: #e0664f;
  --hc: #e8a33a;
  --gord: #4c86e0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(23 32 27 / .05), 0 2px 10px rgb(23 32 27 / .05);
  --shadow-lg: 0 8px 30px rgb(23 32 27 / .14);
  --tabbar: 54px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
svg { flex: none; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; }

/* ================================================================ cabeçalho */
.top {
  position: sticky; top: 0; z-index: 20;
  /* sem backdrop-filter: criaria um bloco de contenção e a barra de abas
     (position: fixed, filha deste cabeçalho) deixaria de ficar no fundo do ecrã */
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
}
.top__inner { max-width: 1160px; margin: 0 auto; display: grid; gap: 10px; grid-template-columns: 1fr; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand__logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand__logo svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 5; }
.brand__logo circle + circle { fill: #fff; stroke: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.brand__text strong { font-size: 16px; letter-spacing: -.01em; }
.brand__text small { color: var(--muted); font-size: 12px; }

.search { position: relative; }
.search input {
  width: 100%;
  font-size: 16px; /* ≥16px evita zoom automático no iOS */
  height: 46px;
  padding: 0 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  -webkit-appearance: none; appearance: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search__icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search__kbd { position: absolute; right: 12px; top: 50%; translate: 0 -50%; font: 12px/1 ui-monospace, monospace; color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; background: var(--surface); display: none; pointer-events: none; }
.search__clear { position: absolute; right: 5px; top: 50%; translate: 0 -50%; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.search__clear[hidden] { display: none; }
.search__clear svg { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.search__clear:hover { background: var(--surface-3); }

/* navegação: barra inferior no telemóvel (padrão Noom/Yazio), no topo no computador */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgb(255 255 255 / .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar); text-decoration: none; color: var(--faint); font-size: 10.5px; font-weight: 600; line-height: 1.1;
}
.nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav a[aria-current="page"] svg { stroke-width: 2.3; }
.nav__badge {
  position: absolute; top: 4px; left: calc(50% + 5px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--prot); color: #fff; font-size: 10px; line-height: 16px; text-align: center;
}
.nav__badge[hidden] { display: none; }

@media (min-width: 1024px) {
  .top__inner { grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: 20px; }
  .brand { min-width: auto; }
  .search__kbd { display: block; }
  .search input:focus ~ .search__kbd, .search input:not(:placeholder-shown) ~ .search__kbd { display: none; }
  .nav { position: static; display: flex; justify-content: flex-end; gap: 4px; background: none; border: 0; backdrop-filter: none; padding: 0; }
  .nav a { flex-direction: row; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; gap: 7px; color: var(--muted); }
  .nav a:hover { background: var(--surface-2); color: var(--text); }
  .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .nav svg { width: 18px; height: 18px; }
  .nav__badge { position: static; margin-left: -2px; }
}
@media (min-width: 1024px) and (max-width: 1180px) {
  .brand__text small { display: none; }
}

main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 16px 16px 32px; }
main:focus { outline: none; }

/* ================================================================ elementos comuns */
.info {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-ink);
  border-radius: var(--radius); padding: 14px 14px 14px 16px; margin-bottom: 16px; font-size: 14.5px;
}
.info svg { width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.info p { margin: 0; flex: 1; }
.info strong { display: block; font-size: 15px; margin-bottom: 2px; color: #5a300a; }
.info__close { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; margin: -4px -4px 0 0; color: var(--info-ink); font-size: 22px; line-height: 1; flex: none; }
.info__close:hover { background: rgb(122 68 16 / .08); }

.note { display: flex; gap: 8px; background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-ink); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin: 0 0 16px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-title h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.section-title span { color: var(--muted); font-size: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) { .chips { flex-wrap: wrap; overflow: visible; } }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  height: 36px; padding: 0 14px; font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--text);
}
.chip:hover { border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }
.chip .n { opacity: .6; margin-left: 5px; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--danger { color: var(--danger); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"] { color: var(--star); border-color: color-mix(in srgb, var(--star) 50%, var(--line)); background: #fff8e0; }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); max-width: 420px; margin: 0 auto; }
.empty__icon { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.empty__icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty strong { display: block; color: var(--text); font-size: 19px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

.meta { color: var(--muted); font-size: 14px; margin: 12px 0 10px; }

/* ================================================================ lista de alimentos (linhas com "+") */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
@media (max-width: 420px) { .list { grid-template-columns: 1fr; } }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius); padding: 8px 10px 8px 8px; box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.row:hover { box-shadow: var(--shadow-lg); }
.row__img { width: 104px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 11px; background: var(--surface-2); flex: none; }
.row__body { flex: 1; min-width: 0; }
.row__name { font-weight: 650; font-size: 15px; line-height: 1.25; }
.row__name a { color: inherit; text-decoration: none; }
.row__name a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); } /* linha inteira clicável */
.row__meta { font-size: 13px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.row__meta .star { color: var(--star); }
.row__add {
  position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--accent);
  transition: background .15s, transform .1s;
}
.row__add svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.row__add:hover { background: var(--accent-soft); border-color: var(--accent); }
.row__add:active { transform: scale(.92); }
.row__add[data-added="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* recentes: carrossel horizontal */
.recent { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.recent::-webkit-scrollbar { display: none; }
.recent a { flex: none; width: 132px; text-decoration: none; color: inherit; scroll-snap-align: start; }
.recent img { width: 132px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: var(--surface-2); }
.recent span { font-size: 13px; font-weight: 600; line-height: 1.25; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ================================================================ detalhe */
.back { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--muted); padding: 6px 8px 6px 0; font-weight: 600; font-size: 15px; }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { color: var(--text); }
.head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 2px 0 14px; }
.head h1 { font-size: clamp(24px, 5vw, 32px); line-height: 1.12; margin: 0; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: 14px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { display: inline-block; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }

.detail { display: grid; gap: 16px; }
.detail > * { min-width: 0; } /* deixa a tabela larga rolar dentro do painel */
@media (min-width: 720px) {
  .detail { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
  .detail__media { position: sticky; top: 124px; } /* abaixo do cabeçalho em 2 linhas */
}
@media (min-width: 1024px) { .detail { gap: 24px; } .detail__media { top: 90px; } }

.photo { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; }
.photo__badge {
  position: absolute; left: 12px; top: 12px; background: rgb(255 255 255 / .94); color: var(--text);
  border-radius: 10px; padding: 5px 10px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; box-shadow: var(--shadow);
}
.photo__badge b { color: var(--accent); }
.photo__zoom { position: absolute; right: 12px; bottom: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .94); display: grid; place-items: center; box-shadow: var(--shadow); }
.photo__zoom svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.photo__missing { aspect-ratio: 4 / 3; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 16px; }

.strip { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.strip button {
  border: 2px solid transparent; border-radius: 12px; background: var(--surface); padding: 0 0 5px; overflow: hidden;
  display: flex; flex-direction: column; align-items: stretch; box-shadow: var(--shadow);
}
.strip button[aria-pressed="true"] { border-color: var(--accent); }
.strip img, .strip .ph { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; background: var(--surface-2); }
.strip b { font-size: 13px; margin-top: 3px; }
.strip span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
.panel + .panel { margin-top: 16px; }
.label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 6px; }

/* controlo segmentado (padrão Cal AI) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.segmented button { border: 0; background: transparent; height: 36px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; min-width: 44px; height: 40px; padding: 0 10px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pills button:hover { border-color: var(--faint); }
.pills button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* stepper − valor + (padrão Bevel) */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--accent); }
.stepper button:hover { background: var(--surface-2); }
.stepper input { width: 80px; height: 44px; border: 0; border-inline: 1px solid var(--line); text-align: center; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; background: transparent; }
.stepper input:focus { outline: none; background: var(--accent-soft); }
.stepper-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 10px; }

/* resumo energia + macros (padrão BitePal/Alma) */
.summary { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.summary--flat { margin-top: 0; padding-top: 0; border-top: 0; }
.summary__kcal { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.summary__kcal strong { font-size: 40px; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary__kcal strong small { font-size: 16px; color: var(--muted); font-weight: 600; margin-left: 4px; letter-spacing: 0; }
.summary__kcal span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.macrobar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-3); margin: 12px 0; gap: 2px; }
.macrobar i { display: block; height: 100%; }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.macro small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.macro small::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.macro strong { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.macro strong span { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.macro em { display: block; font-style: normal; font-size: 12px; color: var(--faint); }
.weights { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.weights div { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.weights small { display: block; font-size: 12px; color: var(--muted); }
.weights strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.nut { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 14px; }
.nut caption { text-align: left; }
.nut td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.nut td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.nut tr:last-child td { border-bottom: 0; }
.nut .sub td:first-child { padding-left: 16px; color: var(--muted); }

/* botão "Adicionar à refeição": fixo no fundo no telemóvel (padrão Yazio) */
.addbar { margin-top: 16px; }
@media (max-width: 1023px) {
  .addbar {
    position: fixed; z-index: 25; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
    margin: 0; padding: 10px 16px; background: rgb(255 255 255 / .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  body.has-addbar main { padding-bottom: 96px; }
}
.addbar { display: flex; gap: 8px; }
.addbar .btn { height: 50px; font-size: 16px; flex: 1; min-width: 0; }
.addbar .btn span { overflow: hidden; text-overflow: ellipsis; }
.addbar__meal {
  flex: 0 1 42%; min-width: 0; height: 50px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); padding: 0 10px; font-size: 15px; font-weight: 600; text-overflow: ellipsis;
}
.addbar .btn span { opacity: .8; font-weight: 500; }

/* tabela completa */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.full { border-collapse: collapse; font-size: 14px; width: 100%; min-width: 640px; font-variant-numeric: tabular-nums; }
table.full th, table.full td { padding: 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.full th { font-size: 12px; color: var(--muted); font-weight: 650; vertical-align: bottom; white-space: normal; }
table.full th:first-child, table.full td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.full tbody tr { cursor: pointer; }
table.full tbody tr:hover td { background: var(--surface-2); }
table.full tbody tr[aria-selected="true"] td { background: var(--accent-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* ================================================================ refeição (padrão Noom/Yazio "Create meal") */
.meal { display: grid; gap: 16px; }
.meal > * { min-width: 0; }
@media (min-width: 720px) { .meal { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: 20px; } .meal__side { position: sticky; top: 124px; } }
@media (min-width: 1024px) { .meal { gap: 24px; } .meal__side { top: 90px; } }
.meal__name { width: 100%; border: 0; border-bottom: 2px dashed var(--line); background: transparent; font-size: clamp(24px, 5vw, 30px); font-weight: 750; letter-spacing: -.02em; padding: 4px 0; border-radius: 0; }
.meal__name:focus { outline: none; border-bottom-color: var(--accent); }
.meal__hint { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.item img, .item .ph { width: 84px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.item__name { font-weight: 650; font-size: 15px; line-height: 1.25; }
.item__name a { color: inherit; text-decoration: none; }
.item__name a:hover { text-decoration: underline; }
.item__meta { font-size: 13px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.item__controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item select { height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); padding: 0 6px; font-size: 14px; }
.item__side { display: flex; flex-direction: column; align-items: flex-end; }
.item__kcal { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item__kcal small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.item__remove { margin-top: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--faint); display: inline-grid; place-items: center; }
.item__remove:hover { background: #fdecea; color: var(--danger); }
.item__remove svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.add-more { margin-top: 10px; border: 1.5px dashed var(--line); background: transparent; border-radius: var(--radius); height: 56px; width: 100%; color: var(--accent); font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.add-more:hover { background: var(--accent-soft); border-color: var(--accent); }
.add-more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.actions .btn--primary, .actions .btn--danger { grid-column: 1 / -1; }
.actions--single { grid-template-columns: 1fr; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.saved { list-style: none; margin: 0; padding: 0; }
.saved li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.saved li:last-child { border-bottom: 0; }
.saved div { flex: 1; min-width: 0; }
.saved b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved span { font-size: 13px; color: var(--muted); }
.saved .btn { height: 36px; padding: 0 12px; font-size: 14px; }

/* destino do "+" nas listas */
.target { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; font-size: 14px; color: var(--muted); }
.target > svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.target a { font-weight: 650; }
.target select { height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); padding: 0 6px; font-size: 14px; max-width: 100%; }

/* lista de refeições (padrão Yazio/Lifesum) */
.meals { display: grid; gap: 16px; }
.meals > * { min-width: 0; }
@media (min-width: 720px) { .meals { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: 20px; } .meals__side { position: sticky; top: 124px; } }
@media (min-width: 1024px) { .meals { gap: 24px; } .meals__side { top: 90px; } }
.mealcards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mealcard {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 8px 10px 10px;
  text-decoration: none; color: inherit; transition: box-shadow .15s;
}
.mealcard:hover { box-shadow: var(--shadow-lg); }
.mealcard__thumbs { width: 72px; height: 54px; border-radius: 10px; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--surface-2); }
.mealcard__thumbs img { width: 100%; height: 100%; object-fit: cover; }
.mealcard__thumbs img:only-child { grid-column: 1 / -1; }
.mealcard__thumbs span { grid-column: 1 / -1; display: grid; place-items: center; color: var(--faint); }
.mealcard__thumbs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mealcard__body b { display: block; font-size: 16px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mealcard__body small { display: block; color: var(--muted); font-size: 13px; }
.mealcard__kcal { font-weight: 750; font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.mealcard__kcal small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.mealcard__go svg { width: 18px; height: 18px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill-active { display: inline-block; vertical-align: 2px; margin-left: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; }
.macrobar--sm { height: 5px; margin: 6px 0 0; max-width: 180px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.presets .chip { display: inline-flex; align-items: center; gap: 4px; }
.presets .chip svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.empty + .presets { justify-content: center; }

/* ================================================================ medidas caseiras */
.mlist { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.mcard { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: inherit; transition: box-shadow .15s; }
.mcard:hover { box-shadow: var(--shadow-lg); }
.mcard img { width: 100%; background: #111; }
.mcard div { padding: 12px 14px; }
.mcard b { display: block; }
.mcard span { font-size: 13px; color: var(--muted); }
.mphoto { border-radius: var(--radius); overflow: hidden; background: #111; cursor: zoom-in; box-shadow: var(--shadow); }
.bigval { margin-top: 16px; background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; }
.bigval small { display: block; color: var(--muted); font-size: 13px; }
.bigval strong { font-size: 32px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bigval strong span { font-size: 16px; color: var(--muted); margin-left: 4px; }

/* ================================================================ sobre */
.prose { max-width: 70ch; }
.prose h1 { font-size: 28px; letter-spacing: -.02em; margin-top: 4px; }
.prose h2 { font-size: 19px; margin-top: 28px; }
.prose li { margin: 6px 0; }

/* ================================================================ toast (padrão Garmin "Saved to My Meals") */
.toast {
  position: fixed; z-index: 40; left: 50%; translate: -50% 0;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
  width: min(560px, calc(100% - 24px));
  background: #17201b; color: #fff; border-radius: 14px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); font-size: 14.5px;
  animation: toast-in .2s ease-out;
}
.toast[hidden] { display: none; }
body.has-addbar .toast { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 84px); }
@media (min-width: 1024px) { .toast, body.has-addbar .toast { bottom: 24px; } }
.toast p { margin: 0; flex: 1; min-width: 0; }
.toast a, .toast button { color: #9fe0bf; font-weight: 700; background: none; border: 0; text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.toast a:hover, .toast button:hover { background: rgb(255 255 255 / .08); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================================================================ zoom */
.zoom { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; }
.zoom::backdrop { background: rgb(10 14 12 / .92); }
.zoom[open] { display: grid; place-items: center; align-content: center; }
.zoom img { max-width: 96vw; max-height: 82dvh; object-fit: contain; border-radius: 10px; }
.zoom__cap { color: #fff; margin: 10px 16px 0; text-align: center; font-weight: 600; }
.zoom button { position: fixed; border: 0; background: rgb(255 255 255 / .16); color: #fff; width: 48px; height: 48px; border-radius: 50%; font-size: 30px; line-height: 1; }
.zoom__close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
.zoom__prev { left: 8px; top: 50%; }
.zoom__next { right: 8px; top: 50%; }

/* ================================================================ rodapé */
.foot {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 22px 16px calc(22px + var(--tabbar) + env(safe-area-inset-bottom));
  text-align: center; font-size: 13.5px; color: var(--muted);
}
@media (min-width: 1024px) { .foot { padding-bottom: 24px; } }
.foot p { max-width: 760px; margin: 4px auto; }
.foot__credit { font-size: 15px; color: var(--text); }
.foot__links { margin: 0 auto 10px; font-size: 14px; }
.foot__links a { color: var(--text); }
.foot a { font-weight: 650; }
.foot__src { font-size: 12px; color: var(--faint); }
@media (max-width: 480px) {
  .addbar .btn span { display: none; } /* a quantidade já aparece no resumo acima */
}
