/* Pantallas de comida: alimentos, calendario, recetas, lista de la compra e inicio.
   Usa las variables y componentes de base.css (card, row, chip, btn, btns, chips, sub, f, warn, alert, icon-btn).
   Todas las clases propias llevan prefijo cm- para no chocar con otras vistas. */

.cm-vista { display: block; }
.cm-mt0 { margin-top: 0; }
.cm-mt4 { margin-top: 4px; }
.cm-mt6 { margin-top: 6px; }
.cm-mt8 { margin-top: 8px; }
.cm-block { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Entrada suave de las tarjetas de inicio, escalonada con --i */
.cm-entra { animation: cm-entra .45s cubic-bezier(.2,.7,.3,1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes cm-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Pastillas de estado */
.cm-pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 600; background: var(--soft); color: var(--fg); margin: 2px 4px 2px 0; }
.cm-pill.cm-gris { background: color-mix(in srgb, var(--gris, #A9A7B0) 28%, transparent); }
.cm-pill.cm-ambar { background: color-mix(in srgb, var(--ambar, #E4A02D) 32%, transparent); }
.cm-pill.cm-verde { background: color-mix(in srgb, var(--verde, #3FA974) 28%, transparent); }
.cm-pill.cm-rojo { background: color-mix(in srgb, var(--rojo, #DC4B57) 30%, transparent); }
.cm-pill.cm-azul { background: color-mix(in srgb, var(--azul, #6FB1E6) 34%, transparent); }
.cm-tags { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0; }
.cm-tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 6px 4px 11px; font-size: .82rem; background: var(--soft); margin: 2px 4px 2px 0; }
.cm-x { border: 0; background: transparent; color: inherit; cursor: pointer; min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; border-radius: 999px; }
.cm-x:focus-visible { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-x .ic { width: 14px; height: 14px; }

/* Imágenes */
.cm-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.cm-img-min { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--soft); flex: none; }
.cm-img-min .cm-img, .cm-img-min .il { width: 100%; height: 100%; }
.cm-th { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--soft); flex: none; }
.cm-th .cm-img, .cm-th .il { width: 100%; height: 100%; }
.cm-imgbox { height: 190px; border-radius: 24px; overflow: hidden; background: var(--soft); display: grid; place-items: center; margin: 10px 0 0; }
.cm-imgbox .il { width: 150px; height: 150px; }
.cm-foto-grande { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-credito, .cm-fuente { font-size: .72rem; color: var(--muted); margin: 6px 2px 0; line-height: 1.4; }
.cm-fuente { margin-top: 10px; }

/* Cabecera y búsqueda */
.cm-cab { margin-bottom: 12px; }
.cm-buscar { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 0 12px; min-height: 46px; }
.cm-buscar .ic { width: 18px; height: 18px; color: var(--muted); flex: none; }
.cm-buscar input { border: 0; background: transparent; color: var(--fg); font: inherit; width: 100%; min-height: 44px; padding: 0; outline: none; }
.cm-buscar:focus-within { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-barra { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.cm-barra-cal { margin: 0 0 8px; }
.cm-cuenta { margin: 4px 2px 10px; }
.cm-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cm-dos > div { min-width: 0; }
.cm-err { color: var(--rojo, #DC4B57); font-size: .85rem; margin: 8px 0; }

/* Filas y mosaicos */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cm-tile { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px; min-width: 0; color: inherit; font: inherit; min-height: 44px; transition: transform .2s ease, box-shadow .2s ease; }
.cm-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.cm-tile-img { height: 96px; border-radius: 12px; overflow: hidden; background: var(--soft); display: grid; place-items: center; }
.cm-tile-img .cm-img, .cm-tile-img .il { width: 100%; height: 100%; }
.cm-tile b { font-size: .9rem; overflow-wrap: anywhere; }
.cm-row { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 14px; margin-bottom: 8px; cursor: pointer; width: 100%; text-align: left; color: inherit; font: inherit; min-height: 44px; transition: background .2s ease; }
.cm-row:hover { background: var(--soft); }
.cm-row .cm-tx, .cm-tx { min-width: 0; flex: 1; display: block; }
.cm-row .cm-tx b, .cm-tx b { display: block; font-size: .95rem; overflow-wrap: anywhere; }
.cm-em { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; flex: none; }
.cm-em .ic { width: 22px; height: 22px; }
.cm-receta .cm-rwarn { margin-top: 6px; }
.cm-rwarn { background: color-mix(in srgb, var(--ambar, #E4A02D) 22%, var(--card)); border-radius: 10px; padding: 6px 8px; font-size: .78rem; margin-top: 4px; display: flex; gap: 6px; align-items: flex-start; }
.cm-rwarn .ic { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.cm-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 14px; margin-bottom: 6px; }
.cm-item-tx { min-width: 0; flex: 1; }
.cm-item-tx b { display: block; font-size: .95rem; overflow-wrap: anywhere; }
.cm-item-img { flex: none; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--soft); }
.cm-item-img .il, .cm-item-img img { width: 100%; height: 100%; object-fit: cover; }
.il { max-width: 100%; }
.cm-btns-compactos { margin: -2px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.cm-h3 { font-family: var(--display, inherit); font-size: 1rem; margin: 12px 0 4px; }
.cm-lineas { list-style: none; margin: 0 0 8px; padding: 0; font-size: .88rem; }
.cm-lineas li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.cm-hist { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .88rem; flex-wrap: wrap; }
.cm-hist-btns { display: flex; gap: 6px; }
.cm-reac { color: var(--rojo, #DC4B57); font-size: .85rem; margin: 4px 0; }
.cm-ing { margin: 0; padding-left: 18px; font-size: .9rem; line-height: 1.7; }
.cm-pasos { margin: 0; padding-left: 20px; font-size: .92rem; line-height: 1.6; }
.cm-link { border: 0; background: transparent; color: var(--fg); font: inherit; text-decoration: underline; text-decoration-color: var(--acc, #F2A199); text-underline-offset: 3px; cursor: pointer; padding: 6px 2px; min-height: 32px; }
.cm-link:focus-visible { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-rf-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; align-items: center; }
.cm-check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 10px 0; cursor: pointer; min-height: 44px; }
.cm-check input { width: 20px; height: 20px; }
.cm-upl { cursor: pointer; }
.cm-upl input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* Typeahead (buscador con lista) */
.cm-ta { position: relative; }
.cm-ta input { font: inherit; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); min-height: 44px; }
.cm-ta-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cm-ta-lista:empty { display: none; }
.cm-ta-item { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; cursor: pointer; text-align: left; color: inherit; font: inherit; min-height: 48px; }
.cm-ta-item:hover, .cm-ta-item:focus-visible { background: var(--soft); outline: none; }
.cm-ta-item .cm-tx { min-width: 0; }
.cm-ta-item .cm-tx b { font-size: .9rem; }
.cm-ta-item .sub { font-size: .76rem; }
.cm-ta-item .cm-pill { margin-left: auto; }

/* Oferta: caras de gusto */
.cm-gusto { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 4px; }
.cm-gusto button { border: 2px solid transparent; background: var(--soft); border-radius: 20px; padding: 10px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font: inherit; color: inherit; min-height: 44px; transition: transform .2s ease; }
.cm-gusto button:active { transform: scale(.95); }
.cm-gusto button small { font-size: .72rem; color: var(--muted); }
.cm-gusto button[aria-pressed="true"] { border-color: var(--fg); background: var(--card); }
.cm-gusto button:focus-visible { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-gusto svg, .cm-gusto span { font-size: 1.8rem; line-height: 1; }

/* Calendario */
.cm-cal-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cm-cal-titulo { margin: 0; font-family: var(--display, inherit); font-size: 1.1rem; text-align: center; }
.cm-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cm-dow { font-size: .7rem; color: var(--muted); text-align: center; padding: 2px 0; font-weight: 600; }
.cm-dia { aspect-ratio: 1 / 1.08; border-radius: 15px; border: 0; background: var(--soft); padding: 5px 3px 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; cursor: pointer; min-width: 0; font: inherit; font-size: .82rem; color: inherit; transition: transform .15s ease; }
.cm-dia:active { transform: scale(.94); }
.cm-dia.hoy { background: var(--acc, #F2A199); color: var(--acc-fg, #4A2420); font-weight: 700; }
.cm-dia.sel { outline: 2.5px solid var(--fg); outline-offset: 1px; }
.cm-dia:focus-visible { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; min-height: 10px; }
.cm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--gris, #A9A7B0); vertical-align: middle; flex: none; }
.cm-dot.cm-verde { background: var(--verde, #3FA974); }
.cm-dot.cm-ambar { background: var(--ambar, #E4A02D); }
.cm-dot.cm-rojo { background: var(--rojo, #DC4B57); }
.cm-dot.cm-azul { background: var(--azul, #6FB1E6); }
.cm-dot.cm-gris { background: var(--gris, #A9A7B0); }
.cm-dot.cm-plan { background: transparent; border: 2px solid var(--gris, #A9A7B0); }
.cm-dot.cm-plan.cm-ambar { border-color: var(--ambar, #E4A02D); background: transparent; }
.cm-leyenda { display: flex; gap: 10px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin: 8px 0 0; }
.cm-leyenda > span { display: inline-flex; align-items: center; gap: 4px; }
.cm-semana { display: flex; flex-direction: column; gap: 6px; }
.cm-sem-dia { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px; cursor: pointer; text-align: left; color: inherit; font: inherit; min-height: 44px; }
.cm-sem-dia.hoy { border-color: var(--fg); }
.cm-sem-dia.sel { background: var(--soft); }
.cm-sem-cab { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.cm-sem-cont { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: .86rem; }
.cm-sem-item { display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.cm-sem-item.cm-prev { color: var(--muted); font-style: italic; }
.cm-panel { margin-top: 12px; }

/* Ficha de inicio, hero y tarjetas de alerta suave */
.cm-hero { margin: 4px 0 14px; }
.cm-saludo { font-family: var(--display, inherit); font-size: 1.55rem; margin: 4px 0 2px; }
.cm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.cm-stat { background: var(--soft); border-radius: 14px; padding: 10px 6px; text-align: center; min-width: 0; }
.cm-stat b { display: block; font-family: var(--display, inherit); font-size: 1.25rem; line-height: 1.1; }
.cm-stat span { font-size: .72rem; color: var(--muted); line-height: 1.25; display: block; }
.cm-alerta-suave { border-color: var(--ambar, #E4A02D); animation: cm-respira 2.8s ease-in-out infinite; }
@keyframes cm-respira { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ambar, #E4A02D) 0%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ambar, #E4A02D) 18%, transparent); } }
.cm-proximo { margin: -4px 2px 12px; }
.cm-rapido { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cm-rapido .btn { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; font-size: .85rem; min-height: 64px; }
.cm-rapido .ic { width: 22px; height: 22px; }
.cm-aviso { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.cm-aviso:last-child { border-bottom: 0; }
.cm-aviso .sub { display: block; font-size: .82rem; }

/* Registro de lista de la compra */
.cm-compra { list-style: none; margin: 0 0 8px; padding: 0; }
.cm-compra-item { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.cm-compra-item.hecho .cm-compra-txt { text-decoration: line-through; color: var(--muted); }
.cm-compra-txt { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .95rem; }
.cm-marca { width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none; color: var(--verde, #3FA974); padding: 0; }
.cm-marca .ic { width: 22px; height: 22px; }
.cm-marca[aria-pressed="true"] { background: var(--soft); border-color: var(--verde, #3FA974); }
.cm-marca:focus-visible, .cm-quitar:focus-visible { outline: 3px solid var(--focus, #2F6FED); outline-offset: 2px; }
.cm-quitar { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 999px; flex: none; }
.cm-quitar .ic { width: 16px; height: 16px; }
.cm-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.cm-add input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); min-height: 44px; }
.cm-add .btn { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.cm-add .ic { width: 16px; height: 16px; }

/* Ficha de hoja: ajustes para contenidos largos */
.cm-hoja h2 { font-size: 1.2rem; }
.cm-hoja .btns { flex-wrap: wrap; }
.cm-hoja .ic { width: 1em; height: 1em; vertical-align: -0.15em; }
.cm-hoja .cm-tags .ic { width: 14px; height: 14px; }

/* Modo cocina: pantalla completa */
.cm-cocina { position: fixed; inset: 0; z-index: 70; background: var(--bg); color: var(--fg); overflow-y: auto; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(20px, env(safe-area-inset-bottom, 0px)); animation: cm-entra .3s ease both; }
.cm-cocina-in { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; gap: 14px; }
.cm-cocina-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.cm-cocina-tit { font-family: var(--display, inherit); font-size: 1.2rem; margin: 0; }
.cm-cocina-paso { font-size: clamp(1.4rem, 5vw, 2.1rem); line-height: 1.4; margin: 12px 0; flex: 1; overflow-wrap: anywhere; }
.cm-cocina-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cm-cocina-nav .btn { min-height: 64px; font-size: 1.1rem; }
.cm-cocina-nav .btn[disabled] { opacity: .45; }
.cm-temp { border: 1.5px solid var(--line); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--card); }
.cm-temp-num { font-family: var(--display, inherit); font-size: clamp(2.6rem, 12vw, 4rem); font-variant-numeric: tabular-nums; line-height: 1; }
.cm-temp .btns { justify-content: center; margin-top: 0; }
.cm-temp .btn { min-height: 48px; }

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .cm-entra, .cm-alerta-suave, .cm-cocina { animation: none !important; }
  .cm-tile, .cm-dia, .cm-gusto button { transition: none !important; }
}

/* Móvil primero: sin desbordes horizontales */
.cm-vista, .cm-vista * { max-width: 100%; }
.cm-vista img { max-width: 100%; }
@media (min-width: 900px) {
  .cm-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
