/* Nutri Power — tokens */
:root {
  --bg: #EEF1EC;
  --surface: #FFFFFF;
  --ink: #13222B;
  --muted: #5E6F67;
  --line: #D3DCD6;
  --line-strong: #A9B8B0;
  --kcal: #D99A1E;
  --kcal-soft: #F4E3BD;
  --prot: #1C9A6E;
  --prot-soft: #CDEBDF;
  --over: #B0265E;
  --focus: #1C9A6E;
  --on-ink: #EEF1EC;

  --f-ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "Sofia Sans Condensed", "Arial Narrow", system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --gutter: 16px;
  --maxw: 560px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D161B;
    --surface: #152129;
    --ink: #E4ECE7;
    --muted: #93A69C;
    --line: #24333B;
    --line-strong: #3A4B55;
    --kcal: #E8B040;
    --kcal-soft: #3D3320;
    --prot: #45D6A4;
    --prot-soft: #173A31;
    --over: #E0588F;
    --focus: #45D6A4;
    --on-ink: #0D161B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D161B; --surface: #152129; --ink: #E4ECE7; --muted: #93A69C; --line: #24333B;
  --line-strong: #3A4B55; --kcal: #E8B040; --kcal-soft: #3D3320; --prot: #45D6A4; --prot-soft: #173A31;
  --over: #E0588F; --focus: #45D6A4; --on-ink: #0D161B; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--f-ui);
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Estructura */
.pagina {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) calc(env(safe-area-inset-bottom) + 112px);
}
.barra {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px;
}
.marca {
  font: 800 22px/1 var(--f-num);
  letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: inherit;
}
.marca-glifo { width: 30px; height: 30px; border-radius: 8px; display: block; }
.titulo { font: 700 26px/1.1 var(--f-num); margin: 0; }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.btn-icono {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%; cursor: pointer; color: var(--ink);
}
.btn-icono:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font: 700 16px/1 var(--f-num);
  text-decoration: none;
}

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 15px; text-decoration: none;
}
.btn-primario { background: var(--ink); color: var(--on-ink); }
.btn-primario:hover { background: color-mix(in srgb, var(--ink) 88%, var(--prot)); }
.btn-secundario { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-peligro { background: transparent; border-color: var(--over); color: var(--over); }
.btn-texto { background: none; border: 0; color: var(--prot); font-weight: 600; cursor: pointer; padding: 8px 0; min-height: 44px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-bloque { width: 100%; }

/* Formularios */
.campo { display: grid; gap: 6px; margin-bottom: 16px; }
.campo > span { font-size: 14px; font-weight: 500; }
.campo small { color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 8px 0 16px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--prot); flex: none; }
.error { color: var(--over); font-size: 14px; margin: 0 0 12px; }

.segmentos { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.segmentos::-webkit-scrollbar { display: none; }
.segmento {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; font-size: 14px; font-weight: 500;
}
.segmento[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* Acceso */
.acceso { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) var(--gutter) 48px; }
.acceso-cabeza { margin-bottom: 32px; }
.acceso-cabeza .marca { font-size: 40px; margin-bottom: 12px; }
.acceso-cabeza .marca-glifo { width: 56px; height: 56px; border-radius: 14px; }
.acceso-cabeza p { color: var(--muted); margin: 0; max-width: 32ch; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab { flex: 1; background: none; border: 0; padding: 12px 0; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.legal { color: var(--muted); font-size: 13px; margin-top: 24px; }

/* Visor de la balanza: el elemento protagonista */
.fecha-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px -10px 0; }
.fecha-nav strong { font-weight: 600; text-transform: capitalize; }
.fecha-nav button:disabled { opacity: .25; }

.visor { padding: 20px 0 8px; }
.visor-etiqueta { font-size: 15px; color: var(--muted); margin: 0; }
.visor-cifra {
  font: 800 clamp(84px, 26vw, 132px)/0.86 var(--f-num);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 10px; margin: 6px 0 18px;
}
.visor-cifra small { font: 600 22px/1 var(--f-num); letter-spacing: 0; color: var(--muted); }
.visor-cifra.excedido { color: var(--over); }

.regla { position: relative; margin-bottom: 26px; }
.regla-pista {
  position: relative; height: 34px; border-bottom: 1.5px solid var(--ink);
  background-image: repeating-linear-gradient(to right, var(--line-strong) 0 1px, transparent 1px 100%);
  background-size: var(--paso, 10%) 10px; background-repeat: repeat-x; background-position: left bottom;
}
.regla-lleno {
  position: absolute; left: 0; bottom: 0; height: 18px; background: var(--kcal);
  transform-origin: left; transition: width .6s cubic-bezier(.2,.8,.2,1);
}
.regla-exceso { position: absolute; bottom: 0; height: 18px; background: var(--over); }
.regla-aguja { position: absolute; bottom: -8px; top: -6px; width: 2px; background: var(--ink); transform: translateX(-1px); }
.regla-aguja::after {
  content: attr(data-label); position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font: 600 13px/1 var(--f-num); white-space: nowrap; color: var(--ink);
}
.regla-escala { display: flex; justify-content: space-between; font: 500 12px/1 var(--f-num); color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.regla-prot { margin-top: 34px; }
.regla-prot .regla-pista { height: 22px; }
.regla-prot .regla-lleno { background: var(--prot); height: 10px; }
.regla-prot .regla-exceso { background: var(--prot); height: 10px; }

.macros { display: flex; gap: 22px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.macros li { display: grid; }
.macros b { font: 700 24px/1.1 var(--f-num); font-variant-numeric: tabular-nums; }
.macros span { font-size: 13px; color: var(--muted); }
.macros .m-kcal b { color: var(--kcal); }
.macros .m-prot b { color: var(--prot); }

.bloque { margin-top: 28px; }
.bloque-cabeza { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1.5px solid var(--ink); padding-bottom: 6px; }
.bloque-cabeza h2 { font: 700 20px/1.2 var(--f-num); margin: 0; }
.bloque-cabeza span { font-size: 13px; color: var(--muted); }

/* Lista de comidas del día */
.comidas { list-style: none; margin: 0; padding: 0; }
.comida {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 4px 12px; align-items: start;
  padding: 14px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.comida:hover .comida-desc { color: var(--ink); }
.comida-tipo { font: 700 17px/1.25 var(--f-num); }
.comida-hora { display: block; font-size: 13px; color: var(--muted); font-weight: 400; font-family: var(--f-ui); }
.comida-desc { color: var(--muted); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.comida-num { text-align: right; font: 700 18px/1.2 var(--f-num); font-variant-numeric: tabular-nums; }
.comida-num small { display: block; color: var(--prot); font-size: 14px; font-weight: 600; }
.estado-borrador { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--over); }
.estado-revision { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--kcal); }
.campo.revision { border-top: 1px solid var(--line); padding-top: 16px; }
.vacio { padding: 28px 0; color: var(--muted); }
.vacio strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

.aviso-legal { color: var(--muted); font-size: 12px; margin-top: 32px; }

/* Barra de acciones inferior */
.acciones {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
}
.acciones-in { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 10px; }
.acciones-in .btn { flex: 1; }
.acciones-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 14px; color: var(--muted); max-width: var(--maxw); margin-inline: auto; }
.acciones-total b { font: 700 22px/1 var(--f-num); color: var(--ink); font-variant-numeric: tabular-nums; }
.acciones-total .t-prot { color: var(--prot); }

/* Editor de comida */
.foto-comida { margin: 12px 0 4px; border-radius: var(--r-md); overflow: hidden; background: var(--line); aspect-ratio: 4 / 3; position: relative; }
.foto-comida img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-comida .btn-icono { position: absolute; top: 8px; right: 8px; background: color-mix(in srgb, var(--bg) 85%, transparent); }
.foto-vacia {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 0 14px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: transparent; color: var(--muted); cursor: pointer; margin-top: 12px;
}

.nota {
  border-left: 3px solid var(--kcal); padding: 10px 14px; margin: 16px 0; background: var(--kcal-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 14px;
}
.nota h3 { margin: 0 0 6px; font-size: 14px; }
.nota ul { margin: 0; padding-left: 18px; }
.nota.alerta { border-color: var(--over); background: color-mix(in srgb, var(--over) 12%, var(--surface)); }

.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item.no-consumido .item-nombre, .item.no-consumido .item-num { text-decoration: line-through; color: var(--muted); }
.item-cabeza { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-nombre { font-weight: 600; }
.item-meta { font-size: 12px; color: var(--muted); }
.item-meta .baja { color: var(--over); font-weight: 600; }
.item-num { text-align: right; font: 700 18px/1.2 var(--f-num); white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-num small { display: block; font-size: 14px; color: var(--prot); }
.item-controles { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gramos { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.gramos button { width: 40px; height: 40px; border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; }
.gramos input { width: 64px; height: 40px; border: 0; text-align: center; background: none; font: 600 17px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.gramos input:focus { outline: none; }
.gramos:focus-within { outline: 2px solid var(--focus); outline-offset: -1px; }
.gramos-u { font-size: 13px; color: var(--muted); padding-right: 10px; }
.porcion { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 13px; cursor: pointer; }
.item-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; cursor: pointer; min-height: 40px; }
.item-toggle input { width: 18px; height: 18px; accent-color: var(--over); }
.item-revisar { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--over); min-height: 40px; cursor: pointer; }
.item-revisar input { width: 18px; height: 18px; accent-color: var(--prot); }

/* Registrar comida */
.tipos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tipo {
  min-height: 52px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.tipo[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.foto-grande {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 16px; margin-top: 8px; cursor: pointer; text-align: left;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink);
}
.foto-grande .ic { width: 32px; height: 32px; color: var(--prot); }
.foto-grande b { display: block; font-size: 16px; }
.foto-grande small { color: var(--muted); font-size: 13px; }
.acciones-alt { display: block; text-align: center; margin: 10px auto 0; color: var(--prot); font-weight: 600; font-size: 14px; text-decoration: none; max-width: var(--maxw); }

/* Preguntas de la IA */
.preguntas { margin: 16px 0; padding: 16px; border-radius: var(--r-md); background: var(--kcal-soft); }
.preguntas h2 { margin: 0 0 8px; font: 700 19px/1.2 var(--f-num); }
.pregunta { margin-bottom: 14px; }
.pregunta p { margin: 0 0 8px; font-weight: 500; }
.segmentos.envolver { flex-wrap: wrap; overflow: visible; }
.segmentos.envolver .segmento { background: var(--surface); }
.segmentos.envolver .segmento[aria-pressed="true"] { background: var(--ink); }
.pregunta .otra { margin-top: 8px; }

/* Buscador */
.buscador { position: relative; margin-top: 16px; }
.buscador .ic { position: absolute; left: 12px; top: 13px; color: var(--muted); pointer-events: none; }
.buscador .input { padding-left: 42px; }
.resultados { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); max-height: 320px; overflow: auto; }
.resultados:empty { display: none; }
.resultado { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.resultado:last-child { border-bottom: 0; }
.resultado:hover, .resultado:focus-visible { background: color-mix(in srgb, var(--prot) 8%, transparent); }
.resultado small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.resultado-grupo { padding: 10px 14px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }

.form-propio { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-top: 12px; background: var(--surface); }
.form-propio h3 { margin: 0 0 12px; font: 700 18px/1.2 var(--f-num); }
.fila-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fila-4 .input { padding: 10px 8px; }

/* Perfil */
.opciones { display: grid; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.opcion { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; border-top: 1px solid var(--line); }
.opcion:first-child { border-top: 0; }
.opcion input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.opcion b { display: block; font-weight: 600; font-size: 15px; }
.opcion small { display: block; color: var(--muted); font-size: 13px; }
.opcion:has(input:checked) { background: color-mix(in srgb, var(--prot) 10%, var(--surface)); }
.avanzado { border-top: 1px solid var(--line); padding-top: 4px; margin-bottom: 8px; }
.avanzado summary { cursor: pointer; font-weight: 600; color: var(--prot); min-height: 44px; display: flex; align-items: center; }
.avanzado[open] summary { margin-bottom: 8px; }
.libro-resumen { margin: 0; padding: 14px 0; font-size: 16px; border-bottom: 1px solid var(--line); }
.libro-resumen .t-kcal { color: var(--kcal); }
.libro-resumen .t-prot { color: var(--prot); }
.libro { margin: 16px 0 8px; border-top: 1.5px solid var(--ink); }
.libro-fila { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.libro-fila span { color: var(--muted); font-size: 14px; }
.libro-fila b { font: 700 22px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.libro-fila.meta b { color: var(--kcal); font-size: 28px; }
.libro-fila.prot b { color: var(--prot); font-size: 28px; }
.seccion { margin-top: 32px; }
.seccion h2 { font: 700 20px/1.2 var(--f-num); margin: 0 0 12px; }
.propios { list-style: none; padding: 0; margin: 0; }
.propios li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 6px 0; }
.propios small { display: block; color: var(--muted); font-size: 13px; }

/* Diálogo */
dialog { border: 0; border-radius: var(--r-md); padding: 24px; max-width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(8 14 18 / .5); }
dialog h2 { margin: 0 0 8px; font: 700 22px/1.2 var(--f-num); }
dialog p { margin: 0 0 20px; color: var(--muted); }
.dialog-botones { display: flex; gap: 10px; justify-content: flex-end; }

/* Estados */
.cargando { display: grid; place-items: center; min-height: 60dvh; color: var(--muted); }
.analizando { text-align: center; padding: 48px 0; }
.analizando .regla-pista { max-width: 260px; margin: 24px auto 0; overflow: hidden; }
.analizando .regla-lleno { width: 30%; animation: pesar 1.4s ease-in-out infinite alternate; }
@keyframes pesar { from { transform: translateX(0); } to { transform: translateX(233%); } }

.aviso {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: var(--r-md);
  font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / .18);
}

@media (min-width: 900px) {
  .pagina { padding-top: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
