/* ==========================================================================
   Nutribram app — estilos de la calculadora (solo index.html)
   Usa las variables de css/styles.css (:root). Índice:
   1. Fondo y estructura   2. Navegación de la app   3. Paneles (vidrio)
   4. Tablero              5. Alimentos              6. Nutrición y agua
   7. Estadísticas         8. Comidas                9. Perfil
   10. Hoja de porción     11. Bienvenida            12. Aviso (toast)
   13. Escritorio (rejilla tipo dashboard)
   ========================================================================== */

/* 1. FONDO Y ESTRUCTURA ---------------------------------------------------- */
.app-body {
  background: linear-gradient(160deg, var(--pastel-mint) 0%, #F2F5EA 48%, var(--pastel-peach) 100%) fixed;
}
.app-body .site-header { background: rgba(244, 249, 241, 0.82); }
.app-body .site-footer { position: relative; z-index: 2; padding-bottom: calc(var(--space-6) + 84px + env(safe-area-inset-bottom)); }

.app {
  position: relative;
  padding: var(--space-4) 0 calc(104px + env(safe-area-inset-bottom));
  min-height: 70vh;
}
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Fotografía decorativa de frutas en los bordes (solo donde sobra espacio a los lados) */
.app-decor { display: none; }
@media (min-width: 1440px) {
  .app-decor {
    display: block;
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    z-index: 0;
    width: min(calc((100vw - 1240px) / 2 + 24px), 420px);
    height: calc(100vh - var(--header-h));
    object-fit: cover;
    object-position: left center;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 40%, transparent 100%);
  }
  .app-decor-left { left: 0; }
  .app-decor-right { right: 0; transform: scaleX(-1); }
}

/* Vistas: en móvil se muestra una a la vez */
.view { display: none; }
.view.is-active { display: grid; gap: var(--space-4); animation: view-in 0.3s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.app h2 { font-size: 1.15rem; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.app h2:focus { outline: none; }
.app svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app .chart-donut, .app .chart-ring, .app .chart-bars { stroke-linecap: butt; }

/* 2. NAVEGACIÓN DE LA APP ----------------------------------------------------- */
.app-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 -6px 24px rgba(47, 107, 58, 0.08);
}
.app-nav a {
  flex: 1;
  max-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 14px;
  color: var(--color-muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
}
.app-nav a svg { width: 24px; height: 24px; }
.app-nav a[aria-current="page"] { color: var(--color-primary); font-weight: 600; }
.app-nav a[aria-current="page"] svg { stroke-width: 2.4; }
.app-nav .rail-only { display: none; }
.app-nav-add {
  flex: 0 0 auto;
  width: 60px; height: 60px;
  margin-top: -30px;
  display: grid; place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(47, 107, 58, 0.35), 0 0 0 6px rgba(143, 217, 154, 0.18);
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}
.app-nav-add svg { width: 28px; height: 28px; stroke-width: 2.6; }
.app-nav-add:hover { background: var(--color-primary-dark); transform: translateY(-2px); }

/* 3. PANELES (VIDRIO) ------------------------------------------------------------ */
.panel {
  min-width: 0;
  padding: var(--space-5) var(--space-4);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-app);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 30px rgba(47, 107, 58, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
@media (min-width: 560px) { .panel { padding: var(--space-5); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.panel-sub { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--color-muted); }
.see-all { flex-shrink: 0; font-size: var(--text-sm); font-weight: 600; text-decoration: none; padding: 6px 0; }
.see-all:hover { text-decoration: underline; }

.p-note { margin: 0; padding: 0 var(--space-2); font-size: 0.8rem; color: var(--color-muted); text-align: center; }

/* Visual de alimento: emoji en burbuja pastel (o foto si existe) */
.food-visual {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #EEF4EA;
  font-size: 24px;
  line-height: 1;
  overflow: hidden;
}
.food-visual img { width: 100%; height: 100%; object-fit: cover; }
.food-visual.sm { width: 34px; height: 34px; font-size: 18px; }
.food-visual.lg { width: 58px; height: 58px; font-size: 30px; }
.food-visual.xl { width: 72px; height: 72px; font-size: 40px; }
.food-visual[data-cat="fruits"] { background: #FFE6DD; }
.food-visual[data-cat="vegetables"] { background: #E1F1D8; }
.food-visual[data-cat="grains"] { background: #FBEFD3; }
.food-visual[data-cat="proteins"] { background: #F9E2DF; }
.food-visual[data-cat="dairy"] { background: #E5EDF9; }
.food-visual[data-cat="drinks"] { background: #DDF0F3; }
.food-visual[data-cat="snacks"] { background: #F4E6D6; }

/* Botones redondos */
.round-add, .round-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}
.round-add { border: 0; background: var(--color-primary); color: #fff; box-shadow: 0 4px 12px rgba(47, 107, 58, 0.28); }
.round-add:hover { background: var(--color-primary-dark); }
.round-add svg, .round-btn svg { width: 20px; height: 20px; stroke-width: 2.4; }
.round-add.sm { width: 32px; height: 32px; }
.round-add.sm svg { width: 16px; height: 16px; }
.round-add.is-added { animation: added 0.6s var(--ease); }
@keyframes added { 40% { transform: scale(1.25); background: var(--color-secondary); } }
.round-btn.ghost { border: 1.5px solid #B9C9B2; background: rgba(255, 255, 255, 0.7); color: var(--color-primary); }
.round-btn.ghost:hover { border-color: var(--color-primary); }
.round-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--color-accent); color: var(--color-primary); }

/* Chips */
.chips { display: flex; gap: var(--space-2); overflow-x: auto; padding: 2px 2px var(--space-2); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(47, 107, 58, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--color-text);
  font: 500 0.875rem/1 var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.chip:hover { border-color: var(--color-secondary); }
.chip[aria-checked="true"], .chip.is-on, .chip-radio:has(input:checked) { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.chip-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radio:has(input:focus-visible) { outline: 3px solid var(--color-secondary); outline-offset: 2px; }

/* Barras de progreso */
.progress { height: 8px; border-radius: 999px; background: var(--ring-track); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--color-secondary), var(--color-primary)); transition: width 0.5s var(--ease); }

/* 4. TABLERO --------------------------------------------------------------------- */
.greet-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.greet-sub { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }
.greet-row .greet-title { font-size: clamp(1.5rem, 1.3rem + 1vw, 1.9rem); font-weight: 600; }
.avatar {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), #FDE8DA);
  border: 2px solid #fff;
  color: var(--color-primary);
  font: 600 1.2rem var(--font-heading);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(47, 107, 58, 0.12);
}
.avatar svg { width: 24px; height: 24px; }

.search { position: relative; }
.search-icon { position: absolute; left: 16px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--color-muted); pointer-events: none; }
.search input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px 0 46px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
  color: var(--color-text);
  box-shadow: 0 4px 14px rgba(47, 107, 58, 0.06);
}
.search input::placeholder { color: #6D7C70; }
.search input:focus-visible { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(90, 158, 75, 0.25); }
.search-results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  z-index: 30;
  max-height: 340px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 40px rgba(30, 42, 34, 0.16);
}
.search-results li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--color-tint); }
.sr-name { flex: 1; font-weight: 500; }
.sr-kcal { font-size: 0.8rem; color: var(--color-muted); text-align: right; }
.sr-empty { color: var(--color-muted); cursor: default !important; }
.date-return {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin-top: var(--space-3);
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(252, 227, 211, 0.6);
  font-size: var(--text-sm);
}
.date-return .btn-text { min-height: 32px; }

.goal { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.goal-info { flex: 1; min-width: 0; }
.goal-num { margin: 0; font-family: var(--font-heading); }
.goal-num strong { font-size: 2.1rem; font-weight: 600; line-height: 1; }
.goal-num span { font-size: 1rem; color: var(--color-muted); }
.goal-eaten { margin: 2px 0 var(--space-3); font-size: var(--text-sm); color: var(--color-muted); }
.goal-eaten strong { color: var(--color-text); }
.goal-msg { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--color-primary); font-weight: 500; }
.goal-ring { position: relative; flex-shrink: 0; width: 128px; height: 128px; }
.goal-ring svg { display: block; }
.goal-pct { position: absolute; inset: 0; display: grid; place-items: center; font: 600 1.6rem var(--font-heading); color: var(--color-primary); }
.ring-value { transition: stroke-dasharray 0.6s var(--ease); }

.macro-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.macro-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}
.macro-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 22%, white);
  font-size: 18px;
}
.macro-text { display: flex; flex-direction: column; min-width: 0; }
.macro-label { font-size: 0.75rem; line-height: 1.25; color: var(--color-muted); -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word; }
.macro-text strong { font-size: 1rem; }

.top-row { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.top-row li { flex: 0 0 86px; scroll-snap-align: start; }
.top-food {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px;
  border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  font: inherit; color: inherit;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.top-food:hover { background: #fff; transform: translateY(-2px); }
.top-name { font-size: 0.78rem; font-weight: 600; text-align: center; line-height: 1.2; }
.top-kcal { font-size: 0.72rem; color: var(--color-muted); }

.p-about { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: inherit; text-decoration: none; transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease); }
.p-about:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(47, 107, 58, 0.14); color: inherit; }
.p-about img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; }
.p-about-body { display: flex; flex-direction: column; gap: 4px; padding: var(--space-4) var(--space-5) var(--space-5); }
.p-about-title { font: 600 1.1rem/1.25 var(--font-heading); }
.p-about-text { font-size: var(--text-sm); color: var(--color-muted); }
.p-about-link { margin-top: 4px; font-size: var(--text-sm); font-weight: 600; color: var(--color-primary); }

/* 5. ALIMENTOS ------------------------------------------------------------------- */
.p-foods .chips { margin-bottom: var(--space-3); }
.food-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 560px) { .food-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.food-card { position: relative; }
.food-open {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--space-4) var(--space-3) 52px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  font: inherit; color: inherit; text-align: center;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
.food-open:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(47, 107, 58, 0.1); }
.food-name { font-weight: 600; font-size: 0.92rem; line-height: 1.25; margin-top: 4px; }
.food-kcal { font-size: 0.75rem; color: var(--color-muted); line-height: 1.3; }
.food-card .round-add { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; }
.food-card .round-add svg { width: 17px; height: 17px; }

/* 6. NUTRICIÓN Y AGUA -------------------------------------------------------------- */
.date-nav { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.date-step {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--color-primary);
  cursor: pointer;
}
.date-step svg { width: 20px; height: 20px; }
.date-step:disabled { opacity: 0.35; cursor: not-allowed; }
.date-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(47, 107, 58, 0.06);
}
.date-pill svg { width: 18px; height: 18px; color: var(--color-primary); }
.date-pill:focus-within { outline: 3px solid var(--color-secondary); outline-offset: 2px; }
.date-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.date-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.date-nav-compact { justify-content: flex-start; margin-bottom: var(--space-3); }

.donut-wrap { position: relative; width: 200px; margin: 0 auto var(--space-4); }
.donut-wrap svg { display: block; width: 100%; height: auto; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font: 600 2.1rem/1 var(--font-heading); }
.donut-center span { font-size: var(--text-sm); color: var(--color-muted); }
.donut-sm { width: 130px; margin: 0; }

.legend { display: grid; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-label { flex: 1; }
.legend-value { font-weight: 600; }
.legend-value span { font-weight: 400; color: var(--color-muted); }
.legend-compact li { font-size: 0.85rem; }

.water-top { display: flex; align-items: center; gap: var(--space-3); }
.water-drop { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: #DDEFF8; font-size: 22px; flex-shrink: 0; }
.water-count { flex: 1; margin: 0; display: flex; flex-direction: column; }
.water-count strong { font-size: 1.05rem; }
.water-count span { font-size: 0.78rem; color: var(--color-muted); }
.water-actions { display: flex; gap: var(--space-2); }
.glasses { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-4) 0 var(--space-3); }
.glass svg { width: 28px; height: 28px; color: #9FC3D6; stroke-width: 1.6; }
.glass .glass-water { fill: transparent; stroke: none; transition: fill 0.3s var(--ease); }
.glass.is-full svg { color: #4E95BC; }
.glass.is-full .glass-water { fill: #8CC8E8; }
.water-bar { height: 8px; border-radius: 999px; background: #E1EEF4; overflow: hidden; }
.water-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8CC8E8, #4E95BC); transition: width 0.4s var(--ease); }

/* 7. ESTADÍSTICAS ------------------------------------------------------------------ */
.tabs { display: flex; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.65); margin-bottom: var(--space-4); }
.tabs button {
  flex: 1;
  min-height: 38px;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--color-primary); color: #fff; box-shadow: 0 4px 12px rgba(47, 107, 58, 0.25); }
.stats-kicker { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }
.stats-kicker span { font-weight: 600; color: var(--color-text); }
.stats-total { margin: 2px 0 0; font-family: var(--font-heading); color: var(--color-muted); }
.stats-total strong { font-size: 2.1rem; font-weight: 600; color: var(--color-text); }
.stats-avg { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }
.stats-avg strong { color: var(--color-text); }
.stats-empty { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--color-primary); }

.bars-wrap { position: relative; margin: var(--space-4) 0 var(--space-5); min-height: 210px; }
.chart-bars { display: block; overflow: visible; }
.bar { cursor: pointer; outline: none; }
.bar-hit { fill: transparent; stroke: none; }
.bar-fill { fill: #CFE4C6; stroke: none; transition: fill 0.2s var(--ease); }
.bar.is-empty .bar-fill { fill: #E3EEDD; }
.bar.is-highlight .bar-fill { fill: var(--color-primary); filter: drop-shadow(0 4px 8px rgba(47, 107, 58, 0.35)); }
.bar:hover .bar-fill { fill: var(--color-secondary); }
.bar:focus-visible .bar-fill { fill: var(--color-secondary); stroke: var(--color-text); stroke-width: 2; }
.bars-goal { stroke: #9DB89A; stroke-width: 1.5; stroke-dasharray: 5 5; }
.bars-label { fill: var(--color-muted); stroke: none; font: 500 11px var(--font-body); }
.bars-label.is-highlight { fill: var(--color-primary); font-weight: 700; }
.bars-tooltip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -100%);
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--color-primary-dark);
  color: #fff;
  font-size: 0.8rem; font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(30, 42, 34, 0.2);
}
.bars-tooltip::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--color-primary-dark); }
.stats-ratio { padding-top: var(--space-4); border-top: 1px solid rgba(47, 107, 58, 0.1); }
.stats-ratio h3 { font-size: 1rem; margin-bottom: var(--space-3); }
.ratio-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-4) var(--space-5); }
.ratio-row .legend { flex: 1 1 220px; }

/* 8. COMIDAS --------------------------------------------------------------------- */
.meal-group { padding: var(--space-3) 0; border-bottom: 1px solid rgba(47, 107, 58, 0.1); }
.meal-group:last-child { border-bottom: 0; }
.meal-head { display: flex; align-items: center; gap: var(--space-2); }
.meal-head h3 { margin: 0; font-size: 1rem; }
.meal-kcal { margin-left: auto; font-size: var(--text-sm); color: var(--color-muted); font-weight: 500; }
.meal-list { display: grid; gap: 4px; margin-top: var(--space-2); }
.meal-item { display: flex; align-items: center; gap: var(--space-3); padding: 6px 4px 6px 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.55); }
.meal-item-text { flex: 1; min-width: 0; }
.meal-item-name { margin: 0; font-weight: 500; font-size: 0.92rem; line-height: 1.3; }
.meal-item-meta { margin: 0; font-size: 0.78rem; color: var(--color-muted); }
.meal-item-actions { display: flex; }
.meal-empty { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--color-muted); }
.day-progress { margin-top: var(--space-4); padding: var(--space-4); border-radius: 16px; background: rgba(255, 255, 255, 0.65); }
.day-progress-head { display: flex; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--color-muted); }
.day-progress-head strong { color: var(--color-text); }

/* 9. PERFIL --------------------------------------------------------------------- */
.profile-form { display: grid; gap: var(--space-2); }
.profile-form .field { margin-bottom: var(--space-3); }
.form-row { display: grid; gap: 0 var(--space-3); }
@media (min-width: 560px) {
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.profile-form input[type="number"] { width: 100%; min-height: 48px; padding: 0.7rem 0.9rem; font: inherit; color: var(--color-text); background: var(--color-surface); border: 1.5px solid #B9C9B2; border-radius: var(--radius-sm); }
.profile-form input[type="number"]:focus-visible { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(90, 158, 75, 0.25); }
.field-hint { margin: var(--space-1) 0 0; font-size: 0.8rem; color: var(--color-muted); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.7); }
.segmented label, .segmented button {
  position: relative;
  display: inline-flex; align-items: center;
  min-height: 38px;
  padding: 0 16px;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked), .segmented button[aria-checked="true"] { background: var(--color-primary); color: #fff; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--color-secondary); outline-offset: 2px; }
.estimate-result { display: grid; gap: 4px; padding: var(--space-3) var(--space-4); border-radius: 14px; background: var(--color-tint); margin-bottom: var(--space-3); }
.estimate-value { font-size: 1rem; }
.estimate-value strong { font-family: var(--font-heading); font-size: 1.3rem; color: var(--color-primary); }
.estimate-note { font-size: 0.8rem; color: var(--color-muted); }
.profile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-2) 0 var(--space-3); }
.profile-actions .form-status { margin: 0; }
.profile-extra { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding-top: var(--space-3); margin-top: var(--space-3); border-top: 1px solid rgba(47, 107, 58, 0.1); }
.profile-form .p-note { text-align: left; padding: 0; }

/* 10. HOJA DE PORCIÓN --------------------------------------------------------------- */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #F6FBF3, #FFF7F1);
  color: var(--color-text);
  box-shadow: 0 -10px 40px rgba(30, 42, 34, 0.2);
  overflow-y: auto;
}
.sheet[open] { animation: sheet-up 0.3s var(--ease); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop, .welcome::backdrop { background: rgba(30, 42, 34, 0.42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-inner { position: relative; padding: var(--space-3) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.sheet-handle { width: 44px; height: 5px; margin: 0 auto var(--space-4); border-radius: 999px; background: #C9D6C6; }
.sheet .dialog-close { top: var(--space-3); right: var(--space-3); }
.sheet .dialog-close svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet-title { font-size: 1.45rem; font-weight: 600; margin: 0 48px 2px 0; }
.sheet-sub { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }
.sheet-food { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.sheet-change { min-height: 32px; font-size: var(--text-sm); }
.sheet .segmented-sm { display: flex; width: 100%; margin-bottom: var(--space-3); }
.sheet .segmented-sm button { flex: 1; justify-content: center; }
.presets { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.presets .chip { min-height: 34px; padding: 0 12px; font-size: 0.8rem; }
.amount-row { display: flex; align-items: center; justify-content: center; gap: var(--space-4); }
.amount-field { display: flex; align-items: baseline; gap: 8px; }
.amount-field input {
  width: 110px;
  min-height: 56px;
  padding: 0 8px;
  border: 1.5px solid #B9C9B2;
  border-radius: 16px;
  background: #fff;
  font: 600 1.7rem var(--font-heading);
  text-align: center;
  color: var(--color-text);
}
.amount-field input:focus-visible { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(90, 158, 75, 0.25); }
.amount-unit { font-size: var(--text-sm); color: var(--color-muted); min-width: 64px; }
.sheet .field-error { text-align: center; }
.sheet-summary { margin: var(--space-4) 0; padding: var(--space-4); border-radius: 18px; background: rgba(255, 255, 255, 0.8); box-shadow: inset 0 0 0 1px rgba(47, 107, 58, 0.08); }
.sum-kcal { margin: 0 0 var(--space-3); font-family: var(--font-heading); color: var(--color-muted); text-align: center; }
.sum-kcal strong { font-size: 2.2rem; color: var(--color-primary); }
.sum-kcal span { font-family: var(--font-body); font-size: var(--text-sm); }
.sum-macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); text-align: center; }
.sum-macros li { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; color: var(--color-muted); line-height: 1.25; }
.sum-macros li::before { content: ""; width: 8px; height: 8px; margin: 0 auto 2px; border-radius: 50%; background: var(--accent); }
.sum-macros strong { font-size: 0.95rem; color: var(--color-text); }
.sheet-meals { margin: 0 0 var(--space-4); padding: 0; border: 0; min-width: 0; }
.sheet-meals legend { padding: 0; margin-bottom: var(--space-2); font-weight: 600; font-size: var(--text-sm); }
.sheet-meals .chips { flex-wrap: wrap; }
.sheet-note { margin: var(--space-3) 0 0; font-size: 0.78rem; color: var(--color-muted); text-align: center; }
.search-sheet { margin: var(--space-4) 0 var(--space-3); }
.pick-list { display: grid; gap: 6px; max-height: 52vh; overflow-y: auto; }
.pick-item {
  width: 100%;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 12px 8px 8px;
  border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  font: inherit; color: inherit; text-align: left;
  cursor: pointer;
}
.pick-item:hover { background: #fff; }
.pick-name { flex: 1; font-weight: 600; font-size: 0.95rem; }
.pick-kcal { font-size: 0.78rem; color: var(--color-muted); text-align: right; }
.pick-empty { padding: var(--space-4); color: var(--color-muted); text-align: center; }

@media (min-width: 768px) {
  .sheet { margin: auto; border-radius: 26px; max-height: 86vh; }
  .sheet-handle { display: none; }
  .sheet-inner { padding-top: var(--space-6); }
}

/* 11. BIENVENIDA ------------------------------------------------------------------ */
.welcome {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: linear-gradient(170deg, var(--pastel-mint), #F6F6EC 55%, var(--pastel-peach));
  color: var(--color-text);
  overflow-y: auto;
}
.welcome[open] { animation: view-in 0.4s var(--ease); }
.welcome-inner { min-height: 100%; display: flex; flex-direction: column; }
.welcome-img { width: 100%; aspect-ratio: 4 / 3.2; object-fit: cover; object-position: 50% 70%; border-radius: 0 0 32px 32px; }
.welcome-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.welcome-body h2 { font-size: clamp(2.2rem, 1.8rem + 2vw, 3rem); font-weight: 600; line-height: 1.08; margin-bottom: var(--space-3); }
.welcome-body > p { color: var(--color-muted); font-size: 1.05rem; }
.welcome-form { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.welcome-form label { font-size: var(--text-sm); font-weight: 600; }
.welcome-form .btn { margin-top: var(--space-2); min-height: 54px; }
.welcome-note { margin-top: var(--space-3); font-size: 0.8rem; color: var(--color-muted); text-align: center; }
@media (min-width: 900px) {
  .welcome { width: min(980px, calc(100% - 4rem)); height: auto; max-height: calc(100vh - 4rem); margin: auto; border-radius: 32px; box-shadow: 0 30px 80px rgba(30, 42, 34, 0.3); }
  .welcome-inner { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 560px; }
  .welcome-img { height: 100%; aspect-ratio: auto; border-radius: 0; object-position: 50% 80%; }
  .welcome-body { padding: var(--space-7); }
}

/* 12. AVISO (TOAST) --------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin-inline: auto;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  background: var(--color-text);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(30, 42, 34, 0.3);
  animation: toast-in 0.25s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast-undo { min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: var(--color-glow); font: 600 0.85rem var(--font-body); cursor: pointer; }
.toast-undo:hover { background: rgba(255, 255, 255, 0.24); }

/* 13. ESCRITORIO: REJILLA TIPO DASHBOARD -------------------------------------------- */
@media (min-width: 1024px) {
  .app { padding-bottom: var(--space-8); }
  .app-body .site-footer { padding-bottom: var(--space-6); }
  .toast { bottom: var(--space-6); }

  .app-shell { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--space-5); align-items: start; padding-top: var(--space-2); }

  /* Riel lateral */
  .app-nav {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: 12px 8px;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-app);
    background: var(--glass);
    box-shadow: 0 10px 30px rgba(47, 107, 58, 0.08);
  }
  .app-nav a { max-width: none; width: 100%; padding: 10px 4px; font-size: 0.72rem; }
  .app-nav a:hover { background: rgba(255, 255, 255, 0.7); }
  .app-nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.9); box-shadow: 0 4px 12px rgba(47, 107, 58, 0.1); }
  .app-nav .rail-only { display: flex; }
  .app-nav-add { margin: 6px 0; width: 56px; height: 56px; border-width: 3px; }

  /* Todas las vistas a la vez, organizadas por áreas */
  .app-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "greet     greet     goal"
      "overview  overview  goal"
      "top       top       about"
      "nutrition water     meals"
      "stats     stats     stats"
      "foods     foods     foods"
      "profile   profile   profile"
      "note      note      note";
    gap: var(--space-5);
    align-items: stretch;
  }
  .view, .view.is-active { display: contents; animation: none; }
  .p-greet { grid-area: greet; }
  .p-goal { grid-area: goal; }
  .p-overview { grid-area: overview; }
  .p-top { grid-area: top; }
  .p-about { grid-area: about; }
  .p-note { grid-area: note; }
  .p-foods { grid-area: foods; }
  .p-nutrition { grid-area: nutrition; }
  .p-water { grid-area: water; }
  .p-stats { grid-area: stats; }
  .p-meals { grid-area: meals; }
  .p-profile { grid-area: profile; }
  .panel { scroll-margin-top: calc(var(--header-h) + var(--space-4)); }

  .p-goal .goal { flex-direction: column-reverse; align-items: stretch; text-align: left; }
  .p-goal .goal-ring { align-self: center; width: 150px; height: 150px; }
  .p-goal .goal-ring svg { width: 150px; height: 150px; }
  .macro-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .top-row { overflow: visible; }
  .top-row li { flex: 1 1 0; min-width: 0; }
  .p-about img { aspect-ratio: auto; flex: 1; min-height: 110px; }
  .food-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    max-height: 640px;
    overflow-y: auto;
    padding: 4px 6px 4px 2px;
    overscroll-behavior: contain;
  }
  .p-water { display: flex; flex-direction: column; }
  .p-water .water { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .p-water .water-top { flex-wrap: wrap; }
  .profile-form { max-width: 820px; }
}

/* Laptops chicas y iPad horizontal (1024–1279 px): tablero de 2 columnas, más holgado */
@media (min-width: 1024px) and (max-width: 1279px) {
  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "greet     goal"
      "overview  goal"
      "top       about"
      "nutrition meals"
      "water     meals"
      "stats     stats"
      "foods     foods"
      "profile   profile"
      "note      note";
  }
  .macro-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-row { overflow-x: auto; }
  .top-row li { flex: 0 0 86px; }
}

/* 14. ESTADÍSTICAS EN DOS COLUMNAS (tableta y escritorio) ----------------------------- */
@media (min-width: 768px) {
  .stats-body {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
    grid-template-areas: "summary ratio" "bars ratio";
    column-gap: var(--space-6);
    align-items: start;
  }
  .stats-summary { grid-area: summary; }
  .bars-wrap { grid-area: bars; margin-bottom: 0; }
  .stats-ratio { grid-area: ratio; align-self: stretch; padding: 0 0 0 var(--space-6); border-top: 0; border-left: 1px solid rgba(47, 107, 58, 0.1); }
  .ratio-row { flex-direction: column; align-items: stretch; }
  .ratio-row .donut-sm { align-self: center; }
  .ratio-row .legend { flex: none; }
}

/* 15. TABLETA (640–1023 px): dos columnas dentro de cada vista y barra flotante ------- */
@media (min-width: 640px) and (max-width: 1023px) {
  .app { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  .app-body .site-footer { padding-bottom: calc(var(--space-6) + 100px + env(safe-area-inset-bottom)); }

  .view.is-active { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .view.is-active > * { grid-column: 1 / -1; }
  .view.is-active > .p-goal, .view.is-active > .p-overview,
  .view.is-active > .p-nutrition, .view.is-active > .p-water { grid-column: auto; }

  .p-goal .goal { flex-direction: column-reverse; align-items: stretch; gap: var(--space-3); }
  .p-goal .goal-ring { align-self: center; }
  .p-overview .macro-cards { grid-template-columns: 1fr; gap: var(--space-2); }
  .p-overview .macro-card { padding: 10px 12px; }
  .p-about { flex-direction: row; }
  .p-about img { width: 46%; aspect-ratio: auto; min-height: 180px; }
  .p-about-body { justify-content: center; }
  .p-water { display: flex; flex-direction: column; }
  .p-water .water { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .food-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .meals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-6); }
  .meals .meal-group:nth-last-child(-n + 2) { border-bottom: 0; }

  /* Barra de navegación flotante tipo "píldora" */
  .app-nav {
    left: 50%; right: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: min(560px, calc(100% - 32px));
    transform: translateX(-50%);
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    box-shadow: 0 14px 36px rgba(47, 107, 58, 0.18);
  }
  .app-nav-add { margin-top: -34px; }
  .toast { bottom: calc(112px + env(safe-area-inset-bottom)); }
}

/* 16. TELÉFONO EN HORIZONTAL (poca altura) ------------------------------------------ */
@media (orientation: landscape) and (max-height: 520px) {
  .app { padding-top: var(--space-3); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .app-nav { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .app-nav a { padding: 4px; font-size: 0.65rem; }
  .app-nav a svg { width: 20px; height: 20px; }
  .app-nav-add { width: 50px; height: 50px; margin-top: -20px; }
  .app-nav-add svg { width: 24px; height: 24px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

  .welcome-inner { display: grid; grid-template-columns: 1fr 1fr; min-height: 100%; }
  .welcome-img { height: 100%; aspect-ratio: auto; border-radius: 0 28px 28px 0; object-position: 50% 80%; }
  .welcome-body { padding: var(--space-5); }
  .welcome-body h2 { font-size: 1.9rem; }
  .welcome-body > p { font-size: 0.95rem; margin-bottom: 0; }
  .welcome-form { margin-top: var(--space-3); }
  .welcome-form .btn { min-height: 46px; }
  .welcome-note { margin-top: var(--space-2); }

  .sheet { max-height: 94vh; }
  .sheet-handle { margin-bottom: var(--space-2); }
}

/* 17. TELÉFONOS PEQUEÑOS (≤ 380 px) ------------------------------------------------- */
@media (max-width: 380px) {
  .sum-macros { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-3); }
  .goal-ring, .goal-ring svg { width: 112px; height: 112px; }
  .goal-num strong { font-size: 1.8rem; }
  .sheet-inner { padding-inline: var(--space-4); }
  .sheet-food .food-visual.xl { width: 60px; height: 60px; font-size: 32px; }
  .amount-row { gap: var(--space-2); }
  .amount-field input { width: 90px; }
  .app-nav a { font-size: 0.62rem; }
}

/* Encabezado y pie alineados con el ancho de la app */
.app-body .container { max-width: calc(1240px); }

@media (prefers-reduced-motion: reduce) {
  .view.is-active, .sheet[open], .welcome[open], .toast { animation: none; }
}
