/* Unaizio — sistema de diseño.
   Base de GymLog (negro real, un acento, táctil) con modo claro desde el primer día (§12.3).
   Verde esmeralda como marca (YAZIO es naranja: diferenciarse). Colores por macro coherentes
   en toda la app. Pasarse del objetivo es ámbar, nunca rojo (§12.2.10). */

:root {
  --bg: #0b0d0c;
  --surface: #131716;
  --surface-2: #1a1f1d;
  --surface-3: #232a27;
  --text: #eef2f0;
  --text-dim: #97a39d;
  --border: #262d2a;
  --accent: #10b981;
  --accent-2: #34d399;
  --accent-ink: #03140d;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --danger: #f87171;
  --warn: #f59e0b;
  --prot: #f472b6;
  --carb: #60a5fa;
  --fat: #a78bfa;
  --fiber: #34d399;
  --water: #38bdf8;
  --radius: 14px;
  --radius-s: 10px;
  --sombra: 0 10px 30px rgba(0, 0, 0, 0.35);
  --tabbar-h: 64px;
  color-scheme: dark;
}

:root[data-theme="claro"] {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --surface-3: #e5eae7;
  --text: #0f1512;
  --text-dim: #5d6862;
  --border: #dde3df;
  --accent: #059669;
  --accent-2: #10b981;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --warn: #d97706;
  --sombra: 0 10px 30px rgba(15, 21, 18, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="oscuro"]) {
    --bg: #f5f7f6;
    --surface: #ffffff;
    --surface-2: #f0f3f1;
    --surface-3: #e5eae7;
    --text: #0f1512;
    --text-dim: #5d6862;
    --border: #dde3df;
    --accent: #059669;
    --accent-2: #10b981;
    --accent-ink: #ffffff;
    --danger: #dc2626;
    --warn: #d97706;
    --sombra: 0 10px 30px rgba(15, 21, 18, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

/* Cifras tabulares en toda la interfaz con números alineados (§12.3). */
.num, .anillo, .macros, .entrada .kcal, .tabla-nutrientes, .micro { font-variant-numeric: tabular-nums; }

h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-dim); }
h3 { font-size: 17px; }
a { color: var(--accent-2); }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.mini { font-size: 12px; }
.centro { text-align: center; }
.oculto-visual { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

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

/* ── Layout ─────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header .logo { width: 26px; height: 26px; }
.app-header h1 { font-size: 18px; letter-spacing: 0.2px; flex: 1; }
.app-header .estado-red { font-size: 12px; color: var(--warn); }

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card > h2 { margin-bottom: 10px; }
.card-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-cab h2 { margin: 0; }

.fila { display: flex; gap: 8px; align-items: center; }
.fila > .crece { flex: 1; min-width: 0; }
.rejilla-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rejilla-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.separador { height: 1px; background: var(--border); margin: 12px 0; }

/* ── Barra inferior: el escáner en el centro, destacado (§12.1) ─────── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar-h);
  background: none;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.activa { color: var(--accent-2); }
.tabbar .tab-escaner { position: relative; }
.tabbar .tab-escaner .burbuja {
  width: 58px;
  height: 58px;
  margin-top: -26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
  border: 4px solid var(--bg);
}
.tabbar .tab-escaner .burbuja svg { width: 28px; height: 28px; }

/* ── Controles ──────────────────────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }

.campo {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  outline: none;
}
.campo:focus { border-color: var(--accent); }
.campo.aviso { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface-2)); }
select.campo { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea.campo { min-height: 96px; resize: vertical; }
label.etiqueta { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--text-dim); }

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-weight: 550;
}
.boton:active { transform: translateY(1px); }
.boton:disabled { opacity: 0.55; cursor: default; }
.boton-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; width: 100%; }
.boton-peligro { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.boton-texto { background: none; border: 0; color: var(--accent-2); min-height: 44px; padding: 8px; }
.boton-mini { min-height: 44px; min-width: 44px; padding: 8px 12px; font-size: 14px; }
.boton-icono { min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); }
.boton-icono svg { width: 22px; height: 22px; }
.boton-bloque { width: 100%; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.activa { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }

.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.interruptor input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; flex: 0 0 auto; transition: background 0.15s; }
.interruptor input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.interruptor input:checked { background: var(--accent); }
.interruptor input:checked::after { transform: translateX(18px); }

/* ── Diario: navegación de fecha ────────────────────────────────────── */
.fecha-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.fecha-nav .titulo { flex: 1; text-align: center; font-weight: 650; }
.fecha-nav .titulo small { display: block; font-weight: 400; color: var(--text-dim); font-size: 12px; }

/* ── Anillo de calorías ─────────────────────────────────────────────── */
.resumen-kcal { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.resumen-kcal .lado { text-align: center; }
.resumen-kcal .lado b { display: block; font-size: 20px; }
.resumen-kcal .lado span { font-size: 12px; color: var(--text-dim); }
.anillo { position: relative; width: 168px; height: 168px; }
.anillo svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anillo .pista { stroke: var(--surface-3); }
.anillo .progreso { stroke: var(--accent); transition: stroke-dashoffset 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.3s; }
.anillo.pasado .progreso { stroke: var(--warn); }
.anillo .centro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.anillo .centro b { font-size: 34px; line-height: 1; letter-spacing: -0.5px; }
.anillo .centro span { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.macro .nombre { font-size: 12px; color: var(--text-dim); display: flex; justify-content: space-between; }
.macro .barra { height: 6px; border-radius: 999px; background: var(--surface-3); margin: 6px 0 4px; overflow: hidden; }
.macro .barra i { display: block; height: 100%; border-radius: inherit; transition: width 0.6s ease; }
.macro.prot .barra i { background: var(--prot); }
.macro.carb .barra i { background: var(--carb); }
.macro.fat .barra i { background: var(--fat); }
.macro .valor { font-size: 13px; }
.macro.pasado .valor { color: var(--warn); }

/* ── Comidas y entradas ─────────────────────────────────────────────── */
.comida .card-cab h3 { font-size: 16px; }
.comida .card-cab .kcal { color: var(--text-dim); font-size: 14px; }
.comida .acciones { display: flex; gap: 6px; }
.lista-entradas { list-style: none; margin: 0; padding: 0; }
.entrada {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  touch-action: pan-y;
  transition: transform 0.18s ease;
  cursor: pointer;
}
.entrada .info { flex: 1; min-width: 0; }
.entrada .nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entrada .detalle { font-size: 12px; color: var(--text-dim); }
.entrada .kcal { font-size: 14px; white-space: nowrap; }
.entrada-fondo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 16px; color: #fff; background: var(--danger); border-radius: 8px; }
.envoltorio-entrada { position: relative; overflow: hidden; }
.boton-anadir { width: 100%; justify-content: flex-start; color: var(--accent-2); background: none; border: 0; border-top: 1px dashed var(--border); border-radius: 0; margin-top: 4px; min-height: 48px; }
.vacio { text-align: center; color: var(--text-dim); padding: 14px 8px; font-size: 14px; }

/* ── Agua ───────────────────────────────────────────────────────────── */
.vasos { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.vaso { width: 28px; height: 36px; border-radius: 4px 4px 8px 8px; border: 2px solid color-mix(in srgb, var(--water) 55%, var(--border)); position: relative; overflow: hidden; }
.vaso.lleno::after { content: ''; position: absolute; inset: 30% 0 0; background: var(--water); }

/* ── Consejos y apoyo ───────────────────────────────────────────────── */
.consejo { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--radius-s); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); margin-bottom: 8px; font-size: 14px; }
.consejo .icono { flex: 0 0 auto; }
.apoyo { font-size: 14px; border-color: color-mix(in srgb, var(--water) 35%, var(--border)); }

/* ── Buscador ───────────────────────────────────────────────────────── */
.buscador { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-bottom: 8px; }
.buscador .campo { padding-left: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397a39d' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px 50%; background-size: 20px; }
.capa h2 { margin: 14px 0 6px; }
.lista-alimentos { list-style: none; margin: 0; padding: 0; }
.fila-alimento { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.fila-alimento:active { background: var(--surface-2); }
.fila-alimento .miniatura { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 8px; background: var(--surface-2) center / cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 18px; }
.fila-alimento .info { flex: 1; min-width: 0; }
.fila-alimento .nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-alimento .detalle { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-alimento .mas { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--accent-2); font-size: 22px; line-height: 1; cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; font-size: 10px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-dim); vertical-align: 1px; margin-left: 4px; }
.badge.verificado { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.badge.estimado { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.nutriscore { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 5px; font-size: 12px; font-weight: 800; color: #fff; text-transform: uppercase; }
.nutriscore.a { background: #038141; } .nutriscore.b { background: #85bb2f; } .nutriscore.c { background: #fecb02; color: #222; } .nutriscore.d { background: #ee8100; } .nutriscore.e { background: #e63e11; }

/* ── Hoja modal (bottom sheet) ──────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.sheet-backdrop.visible { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--sombra);
}
.sheet.abierta { transform: translateY(0); }
.sheet.alta { height: 92dvh; }
.sheet .asa { width: 40px; height: 5px; border-radius: 999px; background: var(--surface-3); margin: 0 auto 10px; }
.sheet .sheet-cab { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.sheet .sheet-cab .titulo { flex: 1; min-width: 0; }
.sheet .sheet-cab h3 { font-size: 18px; }

/* ── Detalle de alimento y selector de cantidad ─────────────────────── */
.cabecera-alimento { display: flex; gap: 12px; align-items: center; }
.cabecera-alimento img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 10px; }
.cantidad { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.cantidad .campo { font-size: 22px; font-weight: 650; text-align: center; }
.rapidas { display: flex; gap: 6px; margin-top: 8px; }
.rapidas button { flex: 1; min-height: 44px; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.rapidas button.activa { border-color: var(--accent); color: var(--accent-2); }
.porcion-resumen { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 6px; text-align: center; }
.porcion-resumen div { background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 4px; }
.porcion-resumen b { display: block; font-size: 18px; }
.porcion-resumen span { font-size: 11px; color: var(--text-dim); }
.porcion-resumen .prot b { color: var(--prot); } .porcion-resumen .carb b { color: var(--carb); } .porcion-resumen .fat b { color: var(--fat); }

.tabla-nutrientes { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla-nutrientes td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.tabla-nutrientes td:last-child { text-align: right; white-space: nowrap; }
.tabla-nutrientes tr.sub td:first-child { padding-left: 14px; color: var(--text-dim); }
.tabla-nutrientes .grupo td { padding-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); border-bottom: 0; }
.estimado-valor { color: var(--text-dim); }
.estimado-valor::after { content: '*'; color: var(--warn); }

/* ── Micronutrientes con % VRN ──────────────────────────────────────── */
.micro { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.micro .barra { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.micro .barra i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.micro.bajo .barra i { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.micro.elevado .barra i, .micro.excesivo .barra i { background: var(--warn); }
.micro .pct { color: var(--text-dim); font-size: 13px; }
.micro .nota { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); }

/* ── Escáner ────────────────────────────────────────────────────────── */
/* Por encima de la barra inferior (20) y por debajo del fondo de las hojas (30): las hojas que
   abre el escáner (escribir el código) tienen que quedar encima de la cámara. */
.escaner { position: fixed; inset: 0; z-index: 25; background: #000; color: #fff; display: flex; flex-direction: column; }
.escaner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.escaner .capa-ui { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100%; padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.escaner .barra-sup { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.escaner .boton-icono { background: rgba(0, 0, 0, 0.45); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.escaner .boton-icono.activo { background: #fff; color: #000; }
.escaner .marco { position: relative; margin: auto; width: min(78vw, 340px); aspect-ratio: 1.6; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
.escaner .marco::before, .escaner .marco::after { content: ''; position: absolute; inset: 0; border-radius: inherit; border: 3px solid rgba(255, 255, 255, 0.9); }
.escaner .marco::after { border-color: var(--accent-2); opacity: 0; transition: opacity 0.12s; }
.escaner .marco.detectado::after { opacity: 1; }
.escaner .linea { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); animation: barrido 1.8s ease-in-out infinite; }
@keyframes barrido { 0%, 100% { transform: translateY(-40px); } 50% { transform: translateY(40px); } }
/* Sin cámara no se finge que se escanea. */
.escaner.sin-camara .linea { display: none; }
.escaner.sin-camara .marco { opacity: 0.35; }
.escaner .mensaje { text-align: center; font-size: 15px; min-height: 44px; margin: 10px 0; text-shadow: 0 1px 3px #000; }
.escaner .ayuda { text-align: center; font-size: 13px; opacity: 0.85; }
.escaner .bandeja { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.escaner .bandeja .item { flex: 0 0 auto; max-width: 160px; background: rgba(255, 255, 255, 0.12); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.escaner .pie { display: flex; gap: 8px; }
.escaner .pie .boton { flex: 1; background: rgba(0, 0, 0, 0.5); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.escaner .pie .boton-primario { background: var(--accent); color: var(--accent-ink); }

/* ── Onboarding ─────────────────────────────────────────────────────── */
.onb { min-height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom)); }
.onb .progreso { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 6px 0 22px; }
.onb .progreso i { display: block; height: 100%; background: var(--accent); transition: width 0.3s ease; }
.onb h2 { font-size: 24px; letter-spacing: -0.3px; text-transform: none; color: var(--text); margin-bottom: 8px; }
.onb .sub { color: var(--text-dim); margin: 0 0 20px; }
.onb .cuerpo { flex: 1; }
.onb .opciones { display: grid; gap: 10px; }
.onb .opcion { display: flex; gap: 12px; align-items: center; text-align: left; padding: 16px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; min-height: 64px; }
.onb .opcion .emoji { font-size: 26px; }
.onb .opcion small { display: block; color: var(--text-dim); font-size: 13px; }
.onb .opcion.activa { border-color: var(--accent); background: var(--accent-soft); }
.onb .grande { font-size: 44px; font-weight: 700; text-align: center; letter-spacing: -1px; }
.onb .grande small { font-size: 18px; color: var(--text-dim); font-weight: 500; }
.onb input[type="range"] { width: 100%; accent-color: var(--accent); height: 44px; }
.onb .pie { display: flex; gap: 10px; margin-top: 18px; }
.onb .pie .boton-primario { flex: 1; }
.onb .aviso { font-size: 14px; padding: 12px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); margin-top: 12px; }

.resultado { text-align: center; }
.resultado .kcal-grande { font-size: 64px; font-weight: 750; letter-spacing: -2px; line-height: 1; margin: 10px 0 2px; color: var(--accent-2); }
.resultado .fecha-meta { font-size: 18px; margin: 18px 0; }
.resultado .fecha-meta b { color: var(--accent-2); }
.resultado .reparto { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.resultado .reparto div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px; }
.resultado .reparto b { display: block; font-size: 20px; }
.aparece { animation: aparece 0.5s ease both; }
@keyframes aparece { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ── Ayuno ──────────────────────────────────────────────────────────── */
.reloj { position: relative; width: 220px; height: 220px; margin: 8px auto; }
.reloj svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.reloj .pista { stroke: var(--surface-3); }
.reloj .progreso { stroke: var(--water); transition: stroke-dashoffset 1s linear; }
.reloj.completo .progreso { stroke: var(--accent); }
.reloj .centro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.reloj .centro b { font-size: 34px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.reloj .centro span { font-size: 13px; color: var(--text-dim); }
.fase { padding: 12px; border-radius: var(--radius-s); background: var(--surface-2); font-size: 14px; }
.mini-ayuno { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.mini-ayuno .circulo { width: 44px; height: 44px; flex: 0 0 auto; margin: 0; }
.mini-ayuno .crece { flex: 1; min-width: 0; }

/* ── Progreso ───────────────────────────────────────────────────────── */
.cifra-grande { font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1.1; }
.grafica-wrap { position: relative; height: 220px; margin: 10px 0 4px; }
.grafica-wrap.baja { height: 170px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px; }
.kpi b { display: block; font-size: 18px; }
.kpi span { font-size: 12px; color: var(--text-dim); }
.hitos { display: flex; flex-wrap: wrap; gap: 6px; }
.hito { padding: 6px 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--border); color: var(--text-dim); }
.hito.conseguido { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }

/* ── Recetas ────────────────────────────────────────────────────────── */
.receta-fila { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.receta-fila .icono { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: 0 0 auto; }
.receta-fila .info { flex: 1; min-width: 0; }
.receta-fila .etq { font-size: 12px; color: var(--text-dim); }
.ingrediente { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ingrediente .crece { flex: 1; min-width: 0; }
.ingrediente input { width: 84px; text-align: right; }
.pasos { padding-left: 20px; margin: 8px 0; }
.pasos li { margin-bottom: 8px; }

/* ── Registrar alimento con foto (OCR) ──────────────────────────────── */
.ocr-foto { display: block; width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius-s); background: #000; }
.barra-progreso { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 14px 0 8px; }
.barra-progreso i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.3s ease; }
.caja-ocr { border: 2px solid color-mix(in srgb, var(--accent) 55%, var(--border)); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.caja-ocr .cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.caja-ocr .valor { display: grid; grid-template-columns: 1fr 128px; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.caja-ocr .valor label { display: flex; flex-direction: column; font-size: 15px; }
.caja-ocr .valor.sub .nombre { padding-left: 14px; color: var(--text-dim); font-size: 14px; }
.caja-ocr .valor .estado { font-size: 11px; color: var(--text-dim); }
.caja-ocr .valor.sub .estado { padding-left: 14px; }
.caja-ocr .valor.ok .estado { color: var(--accent-2); }
.caja-ocr .valor.falta .estado, .caja-ocr .valor.revisar .estado { color: var(--warn); }
.caja-ocr .entrada-valor { display: flex; align-items: center; gap: 6px; }
.caja-ocr .entrada-valor span { width: 30px; font-size: 13px; color: var(--text-dim); }
.caja-ocr .entrada-valor .campo { min-height: 42px; padding: 8px; text-align: right; font-size: 17px; font-weight: 650; }
.caja-ocr .valor.ok .campo { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.caja-ocr .valor.falta .campo, .caja-ocr .valor.revisar .campo { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface-2)); }
.campo.invalido { border-color: var(--danger) !important; }
.texto-ocr { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12px; line-height: 1.5; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 260px; overflow: auto; margin: 8px 0 0; }

/* ── Toast y snackbar con «Deshacer» (§12.2.4) ──────────────────────── */
.toast, .snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  box-shadow: var(--sombra);
}
.toast.visible, .snackbar.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.error { border-color: var(--danger); }
.snackbar { display: flex; align-items: center; gap: 14px; border-radius: 12px; }
.snackbar button { background: none; border: 0; color: var(--accent-2); font-weight: 700; cursor: pointer; min-height: 36px; }

.banner-red { position: sticky; top: 0; z-index: 9; text-align: center; font-size: 13px; padding: 6px 12px; background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--text); border-bottom: 1px solid var(--border); }

/* ── Login ──────────────────────────────────────────────────────────── */
.login-body { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px 22px; text-align: center; }
.login-card .logo { width: 56px; height: 56px; margin-bottom: 10px; }
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.login-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 10px 0 0; }
.aviso-salud { font-size: 12px; color: var(--text-dim); margin: 16px 0 0; }

/* ── Carga ──────────────────────────────────────────────────────────── */
.esqueleto { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: brillo 1.2s linear infinite; border-radius: 8px; min-height: 18px; }
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
