/* Base: tokens, layout, barra superior, pestañas, botones, formularios y
   componentes comunes. Carga siempre, antes de lista.css y recetas.css. */

/* ==================================================================
   Rediseño "cálido tipo recetario" (2026-08-30)
   Tipos: Newsreader (titulares) + Karla (cuerpo), servidas desde
   static/fonts (variables, subconjunto latino; licencia OFL).
   Paleta: crema / verde oliva / terracota / miel. Acentos en oklch con
   croma ~0.11, variando el tono (verde 140°, terracota 40°, miel 75°).
   ========================================================================= */
@font-face {
    font-family: 'Karla'; font-style: normal; font-weight: 200 800; font-display: swap;
    src: url('/static/fonts/karla.woff2') format('woff2');
}

@font-face {
    font-family: 'Newsreader'; font-style: normal; font-weight: 200 800; font-display: swap;
    src: url('/static/fonts/newsreader.woff2') format('woff2');
}

@font-face {
    font-family: 'Newsreader'; font-style: italic; font-weight: 200 800; font-display: swap;
    src: url('/static/fonts/newsreader-italic.woff2') format('woff2');
}

:root {
    --bg: #faf6ee;            /* crema, fondo de página */
    --card-bg: #fffdf8;       /* crema muy claro, tarjetas */
    --text: #2c2722;          /* tinta cálida */
    --text-muted: #7c7267;
    --primary: #4a7c3f;       /* verde oliva */
    --primary-dark: #3d6b33;
    --danger: #c0674c;        /* terracota (prioridad alta, quitar) */
    --warning: #d9a05c;       /* miel (prioridad media) */
    --border: #e9e1d2;        /* línea cálida */
    --radius: 16px;

    --green-soft: #edf1e4;
    --green-ink: #3d6b33;
    --terra-soft: #f6e7df;
    --terra-ink: #a24f37;
    --honey-soft: #f8efdd;
    /* Miel oscura para TEXTO: --warning (#d9a05c) sobre crema da ~2,3:1,
       por debajo de AA. Este tono da ~5,5:1. --warning sigue para puntos
       y fondos, donde no hace falta contraste de texto. */
    --honey-ink: #8a5a1c;
    --ink-bar: #2c2722;

    --serif: "Newsreader", Georgia, "Times New Roman", serif;
    --sans: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Curvas compartidas para transiciones -- las de por defecto del navegador
       son demasiado débiles. Reutilizar estas en vez de inventar otras. */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

    --tabbar-h: 3.6rem;
}

html {
    /* Base grande a propósito -- todo en rem escala con esto, para que se
       lea de un vistazo sin hacer zoom. */
    font-size: 18px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

html, body {
    overscroll-behavior-y: contain;
}

body {
    font-family: var(--sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 1rem;
}

h1, h2, h3, h4 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.16;
}

/* --- Barra superior + menú --- */
.topbar {
    background-color: var(--ink-bar);
    color: #f7f2e7;
    position: sticky;
    top: 0;
    z-index: 10;
    /* En PWA a pantalla completa la barra queda bajo la barra de estado del
       sistema; este relleno la baja para que "Compra" no se corte. */
    padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.1rem;
    min-height: 3.25rem;
}

.brand {
    color: #f7f2e7;
    text-decoration: none;
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Área táctil cómoda + que el tap cuente aunque caiga sobre el icono. */
    margin: -0.4rem -0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
}

.brand:active { background-color: rgba(255, 255, 255, 0.12); }

/* El icono no intercepta el toque: siempre navega el enlace. */
.brand svg { width: 1.25rem; height: 1.25rem; color: #d3b78c; pointer-events: none; }

.menu-toggle {
    background: none;
    border: none;
    color: #d3b78c;
    font-size: 1.6rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
}

.account-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #5a5048;
    color: #d3b78c;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
}

.account-link:active, .account-link.active { background-color: rgba(255, 255, 255, 0.12); }

.navmenu {
    display: none;
    flex-direction: column;
    background-color: #241f1b;
    padding: 0.4rem 0;
}

.navmenu.open { display: flex; }

.navmenu a {
    color: #e7dcc9;
    text-decoration: none;
    padding: 1rem 1.3rem;
    border-bottom: 1px solid #332c26;
    font-size: 1.05rem;
    font-weight: 500;
}

.navmenu a:active { background-color: #332c26; }

@media (min-width: 1100px) {
  /* El truco de superponer el nav a la fila del logo (margin-top negativo)
     solo cabe en una línea con pocos enlaces; con "Comparar precios"/"Mi
     cuenta" ya son 8 y en tablets (768-1024px) se parte en dos líneas que
     se solapan con "Compra". Portátiles reales miden 1280px+, así que el
     corte sube a 1100px: toda tablet (portrait o landscape) sigue usando
     el menú hamburguesa, que no tiene este problema. */
  .menu-toggle, .account-link { display: none; }
  .navmenu {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        background: none;
        gap: 0.35rem;
        padding: 0;
        margin-top: -2.7rem;
        margin-right: 1rem;
        justify-content: flex-end;
    }
  .navmenu a {
        border: none;
        padding: 0.4rem 0.75rem;
        border-radius: 8px;
        font-size: 0.98rem;
    }
  .navmenu a:hover { background-color: rgba(255,255,255,0.12); }
}

/* --- Layout general --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.1rem 1rem 2rem;
}

h2 { margin-bottom: 0.9rem; font-size: 1.62rem; }

h3 { font-size: 1.18rem; margin-bottom: 0.3rem; font-weight: 600; }

.card, .history-section, .recipes-section {
    background: var(--card-bg);
    padding: 1.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(44, 39, 34, 0.05);
    margin-bottom: 1rem;
}

.section-description {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.98rem;
}

.section-description code {
    background-color: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.82rem;
}

/* --- Flash messages --- */
.flash-messages { margin-bottom: 1rem; }

.flash-message {
    background-color: var(--green-soft);
    border: 1px solid #cfdcc0;
    color: var(--green-ink);
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

/* Errores en terracota: antes todo salía en verde y "Contraseña
   incorrecta" parecía un aviso de que había ido bien. */
.flash-message--error {
    background-color: var(--terra-soft);
    border-color: #ebcbbd;
    color: var(--terra-ink);
}

/* --- Botones --- */
.btn {
    padding: 0.9rem 1.3rem;
    min-height: 48px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--serif);
    font-size: 1.06rem;
    font-weight: 600;
    transition: opacity 0.15s, background-color 0.15s;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-decoration: none;
}

.btn:active { opacity: 0.78; }

a.btn:hover { text-decoration: none; }

.btn-primary { background-color: var(--primary); color: #f7f2e7; }

.btn-primary:hover { background-color: var(--primary-dark); }

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background-color: var(--bg); }

.btn-small { padding: 0.55rem 1rem; min-height: 40px; font-size: 0.95rem; }

.btn-block { width: 100%; display: flex; margin-top: 1rem; }

/* Un botón que ocupa dos líneas ("Añadir todo lo que falta esta semana a
   la lista") heredaba el interlineado del texto corrido y las líneas casi
   se tocaban. */
.btn { line-height: 1.2; text-align: center; }

/* Acción secundaria suelta bajo una lista (Actualizar categorías, Regenerar
   semana): mismo .btn-secondary.btn-small, solo con su aire alrededor. */
.btn-inline { margin: 0.2rem 0 1.1rem; }

.card > .btn-inline:last-child, .card > form:last-child > .btn-inline:last-child { margin-bottom: 0; }

.btn:disabled { opacity: 0.55; cursor: default; }

.btn-danger { background-color: var(--danger); color: #fffdf8; }

.btn-danger:hover { opacity: 0.9; }

/* --- Ilustración de producto (macro product_icon) --- */
.pic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--green-soft);
    border: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: background-color 0.15s, border-color 0.15s;
}

.pic svg { width: 66%; height: 66%; display: block; }

/* --- Botón quitar item de la lista --- */
.remove-btn {
    background: none;
    border: none;
    color: #b7ab99;
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    margin: 0 -0.35rem 0 auto;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.remove-btn:active { color: var(--danger); }

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.72rem 1.3rem;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    background-color: transparent;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s, background-color 0.15s;
}

.suggestion-item > .pri-dot { margin-top: 0.7rem; }

.suggestion-item > .remove-btn { margin-top: 0.25rem; }

.suggestion-item.priority-high, .list-item[data-priority="rojo"] { border-left-color: var(--danger); }

.suggestion-item.priority-medium, .list-item[data-priority="naranja"] { border-left-color: var(--warning); }

.list-item[data-priority="verde"] { border-left-color: var(--primary); }

.pri-dot {
    position: relative;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    background: var(--warning);
    transition: background-color 0.15s;
}

/* zona táctil de 40px sin agrandar el punto */
.pri-dot::before { content: ""; position: absolute; inset: -11px; }

.list-item.checked .pri-dot { opacity: 0.5; }

/* El significado del semáforo de prioridad vivía solo en un `title`,
   invisible al tacto -- esta leyenda se ve una vez y se recuerda cerrada
   (localStorage) para no repetirse en cada visita. */
.priority-legend {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.2rem 0.4rem;
    margin: 0 0 0.7rem;
    padding: 0.45rem 0.3rem 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.priority-legend-keys { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; }

.priority-legend-keys span { display: inline-flex; align-items: center; gap: 0.3rem; }

.priority-legend-hint { grid-column: 1; }

/* Único control que marca "comprado" — antes tocar cualquier parte de la
   fila tachaba, y se confundía con quitar/comparar (feedback real). */
.check-dot {
    position: relative;
    width: 24px;
    height: 24px;
    min-width: 24px;
    margin-top: 0.55rem;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

/* zona táctil de 44px sin agrandar el círculo visible */
.check-dot::before { content: ""; position: absolute; inset: -10px; }

.check-dot.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.check-dot.checked::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 46%;
    width: 10px;
    height: 5px;
    border: 2.5px solid #fff;
    border-top: 0;
    border-right: 0;
    transform: translate(-50%, -50%) rotate(-45deg);
}

.suggestion-item.checked {
    opacity: 0.5;
    background-color: #f5f1e9;
}

.suggestion-item.checked .item-content h3 { text-decoration: line-through; }

/* Seleccionado (sugerencias) / comprado (mi lista): el propio icono del
   producto se convierte en una marca de verificación — un solo elemento a
   la izquierda del nombre, no un icono + una casilla. */
.suggestion-item.checked .pic { background: var(--primary); border-color: var(--primary); }

.suggestion-item.checked .pic svg { opacity: 0; }

.suggestion-item.checked .pic::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 47%;
    width: 12px;
    height: 6px;
    border: 2.5px solid #fff;
    border-top: 0;
    border-right: 0;
    transform: translate(-50%, -50%) rotate(-45deg);
}

.item-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.22rem; }

/* El nombre del producto es contenido, no un titular: sans, no serif, y
   como mucho 2 líneas con elipsis para que nunca desborde la tarjeta. */
.item-content h3 {
    font-family: var(--sans);
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category {
    display: inline-block;
    background-color: #efe7d8;
    color: #6b5d48;
    padding: 0.14rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
}

.confidence {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* --- Mi Lista: barra de accesos rápidos + hoja inferior (2026-09-14).
   Las 4 formas de añadir un producto (a mano, foto/captura, sugeridas,
   historial) caben en una barra fina arriba del todo; cada una abre una
   hoja que sube desde abajo en vez de ocupar sitio en el flujo de la
   página -- así "Mi lista" queda siempre pegada a la barra, sin importar
   cuántas sugerencias o historial haya. Validado con un canvas de diseño
   antes de implementarlo (feedback del usuario: las dos disposiciones
   anteriores -- todo apilado arriba, o solo "a mano" arriba -- no
   encajaban). --- */
/* "Foto" o "Sugeridas" solos no bastaban -- gente probando la app no
   entendía que los 4 botones eran formas de añadir un producto (feedback
   real). Este rótulo da el contexto que faltaba sin repetirlo en cada
   botón. */
/* --- F9.2: selector de listas (chips) + formularios inline de crear/
   renombrar + menú "⋯" + diálogo de borrar. Reutiliza el vocabulario ya
   validado de .filter-chip (mismo look, mismo scroll horizontal contenido
   en su propia fila) y de .add-sheet-backdrop (fondo del modal). ---*/
.list-chips-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.45rem;
    margin: 0 -1rem 0.9rem;
    padding: 0 1rem;
}

.list-chips-row::-webkit-scrollbar { display: none; }

.list-chip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.05rem;
    min-height: 40px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}

.list-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #f7f2e7;
}

.list-chip-count {
    background: rgba(44, 39, 34, 0.1);
    color: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    min-width: 1.3rem;
    text-align: center;
}

.list-chip.active .list-chip-count { background: rgba(247, 242, 231, 0.28); }

.list-chip-shared { flex-shrink: 0; opacity: 0.75; }

.list-chip-owner { font-size: 0.75rem; opacity: 0.8; }

.list-inline-form-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.7rem;
}

.list-inline-form-actions .btn { margin-top: 0; flex: 1; }

.list-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

/* Si el nombre no cabe junto a los botones, los botones bajan a la línea
   de abajo en vez de partir el nombre a mitad de palabra. */
.list-title-row h2 { margin-bottom: 0; flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }

.list-title-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

/* Botón «Compartir» junto al nombre de la lista (antes vivía en ⋯). */
.list-share-open {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 40px;
    padding: 0 0.85rem;
    border-radius: 999px;
    border: 1.5px solid var(--primary);
    background: var(--green-soft);
    color: var(--green-ink);
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.list-share-open:active { background: #e1e8d4; }

.list-shared-avatars { display: flex; }

.list-shared-avatars span {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--card-bg);
    background: var(--warning);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-shared-avatars span + span { margin-left: -8px; background: var(--green-soft); }

.list-icon-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-icon-btn:active { background: var(--bg); }

.list-icon-danger { color: var(--danger); }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44, 39, 34, 0.45);
    z-index: 30;
    /* Un gesto sobre el fondo no desplaza la página de detrás. Se hace
       aquí y no con overflow:hidden en body: tocar el overflow de la
       página ya rompió una vez el scroll táctil real en producción. */
    touch-action: none;
    overscroll-behavior: contain;
}

.modal-box {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 31;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.3rem;
    box-shadow: 0 12px 30px rgba(44, 39, 34, 0.22);
    width: min(90vw, 22rem);
}

.modal-box h3 { margin-bottom: 0.5rem; }

.modal-box p { color: var(--text-muted); margin-bottom: 0.9rem; }

.quick-add-label {
    margin: 0 0 0.4rem;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.quick-add-bar {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.quick-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    min-height: 44px;
    transition: transform 150ms ease-out, background-color 150ms ease;
}

.quick-btn:active { background: var(--bg); transform: scale(0.94); }

@media (prefers-reduced-motion: reduce) {
  .quick-btn { transition: background-color 120ms ease; }
  .quick-btn:active { transform: none; }
}

.quick-btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--green-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 5 botones (Foto y Captura separados): «Sugeridas» debe caber entera; solo
   con letra muy grande se parte, y por sílaba, no por cualquier letra. */
.quick-btn-label { font-size: 0.7rem; font-weight: 600; max-width: 100%; hyphens: auto; overflow-wrap: break-word; text-align: center; }

/* El scale(0.94) de .quick-btn:active no llega a pintarse en un tap corto
   (el navegador nunca renderiza el frame "presionado"). Esta animación la
   dispara JS en pointerdown y se reproduce entera pase lo que pase con el
   dedo, así que un toque rápido se nota igual que uno largo. */
@keyframes quickBtnTap {
    0% { transform: scale(1); }
    35% { transform: scale(0.8); }
    100% { transform: scale(1); }
}

@keyframes quickBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 124, 63, 0.35); }
    50% { box-shadow: 0 0 0 7px rgba(74, 124, 63, 0); }
}

.add-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44, 39, 34, 0.45);
    z-index: 20;
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.add-sheet-backdrop.is-open { opacity: 1; }

/* Antes el sheet aparecía de golpe con hidden=true/false; ahora sube desde
   donde vive el botón que lo abrió (coherencia espacial de un bottom sheet).
   El JS retrasa hidden=true en el cierre hasta que la transición termina. */
.add-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    padding: 0.9rem 1.3rem calc(1.3rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgba(44, 39, 34, 0.18);
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 280ms var(--ease-drawer);
}

.add-sheet.is-open { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .add-sheet-backdrop { transition: opacity 150ms ease; }
  .add-sheet {
        transform: none;
        opacity: 0;
        transition: opacity 150ms ease;
    }
  .add-sheet.is-open { opacity: 1; }
}

.add-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 0.7rem;
    flex-shrink: 0;
}

.add-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.7rem;
    flex-shrink: 0;
}

.add-sheet-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.add-sheet-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: none;
    background: var(--green-soft);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.add-sheet-panel .section-description { margin-bottom: 0.8rem; }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 1.03rem;
}

.nutrition-gaps-more { margin-top: 0.4rem; }

.nutrition-gaps-more > summary { font-size: 0.82rem; color: var(--text-muted); cursor: pointer; margin-bottom: 0.35rem; }

/* --- Formularios --- */
#addItemForm { display: flex; flex-direction: column; gap: 0.6rem; }

#addItemForm input, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], input[type="number"], input[type="search"], textarea {
    padding: 0.9rem;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1.03rem;
    width: 100%;
    -webkit-appearance: none;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 63, 0.14);
}

.recipe-time {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recipe-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.2rem 0; }

.recipe-instructions {
    font-size: 0.93rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    white-space: pre-wrap;
}

summary { cursor: pointer; }

a { color: var(--primary-dark); }

a:hover { color: var(--primary); }

/* --- Micrófono (añadir por voz) --- */
.input-with-mic { position: relative; margin-bottom: 0.6rem; }

.input-with-mic input {
    padding-right: 3rem !important;
    margin-bottom: 0 !important;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192, 103, 76, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(192, 103, 76, 0); }
}

.mic-hint {
    margin: 0.75rem 0 0.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Aviso flotante de la entrada por voz ("Añadido: leche, huevos, pan") */
.voice-toast {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 1rem);
    max-width: min(92vw, 30rem);
    padding: 0.7rem 1rem;
    border-radius: 0.6rem;
    background: var(--primary);
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.3;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.voice-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.voice-toast.error {
    background: var(--danger);
}

/* --- Tablas (histórico) --- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

.history-table th {
    background-color: var(--ink-bar);
    color: #f7f2e7;
    padding: 0.75rem 0.7rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.history-table td {
    padding: 0.75rem 0.7rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.94rem;
}

.history-table tr:nth-child(even) td { background-color: #fbf7ef; }

/* --- Histórico agrupado por genérico --- */
.history-hint { color: var(--text-muted); font-size: 0.9rem; margin: 0.2rem 0 0.8rem; }

/* --- Acciones con panel (Histórico: ticket / registrar; Recetas: foto de
   un plato). Botones lado a lado como la barra "Añadir desde" de Mi Lista;
   el elegido abre su panel debajo y cierra el de al lado (initActionTiles
   en script.js). Sustituye a los <details> sueltos, que tenían cada uno su
   estilo y relleno doble dentro de .card. --- */
.action-group { margin-bottom: 1rem; }

.card > .action-group:last-child { margin-bottom: 0; }

/* auto-fit en vez de una columna por botón: con 3 botones (Histórico) y
   letra grande, cada columna se quedaba más estrecha que «Escanear» y la
   palabra se cortaba; ahora pasan a otra fila. */
.action-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
    gap: 0.5rem;
}

/* Icono y texto arriba (no space-between): con etiquetas de 2 y 3 líneas
   cada botón dejaba el texto a una altura distinta. */
.action-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.45rem;
    hyphens: auto;
    overflow-wrap: break-word;
    min-height: 84px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-bg);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.action-tile svg { color: var(--primary); flex: none; }

.action-tile:hover { text-decoration: none; color: var(--text); background: var(--bg); }

.action-tile:active { background: var(--bg); }

.action-tile[aria-expanded="true"] {
    border-color: var(--primary);
    background: var(--green-soft);
    color: var(--primary-dark);
}

.action-panel {
    margin-top: 0.5rem;
    padding: 0.9rem;
    border: 1px solid var(--primary);
    border-radius: 14px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.action-panel .section-description { margin: 0; font-size: 0.92rem; }

.action-panel .btn-block { margin-top: 0; }

.action-panel .flash-message { margin: 0; }

#addItemForm .btn-block { margin-top: 0; }

.history-groups { display: flex; flex-direction: column; gap: 0.5rem; }

.history-group {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    /* impide que una tabla ancha empuje el grupo (flex item) más allá del
       ancho de la columna y desborde la página en móvil */
    min-width: 0;
}

.history-group > summary {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    list-style: none;
}

.history-group > summary::-webkit-details-marker { display: none; }

.hg-count {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--green-soft);
    color: var(--primary-dark);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

.history-group[open] .hg-count { background: var(--primary); color: #f7f2e7; }

.hg-main { display: flex; flex-direction: column; min-width: 0; }

.hg-name {
    font-weight: 600; color: var(--text); line-height: 1.3;
    overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.hg-name::first-letter { text-transform: uppercase; }

.hg-last { color: var(--text-muted); font-size: 0.82rem; }

.history-group[open] > summary { border-bottom: 1px solid var(--border); background: #fbf7ef; }

.history-group .table-scroll { margin: 0.5rem 1rem 0.8rem; }

.history-group .history-table { min-width: 0; }

.history-group .history-table th { background: #efe7d6; color: var(--text); font-size: 0.82rem;
                                   padding: 0.5rem 0.6rem; white-space: normal; }

.history-group .history-table td { padding: 0.55rem 0.6rem; font-size: 0.9rem; }

/* la fecha en una sola línea; el resto de columnas pueden partir */
.history-group .history-table th:first-child, .history-group .history-table td:first-child { white-space: nowrap; }

/* --- Importar ticket --- */
.upload-form { display: flex; flex-direction: column; }

.file-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed #dcd0ba;
    border-radius: var(--radius);
    padding: 2rem 1rem;
    cursor: pointer;
    color: var(--text-muted);
    background: #fdfbf5;
}

.file-drop input[type="file"] { display: none; }

.scan-camera-btn { margin-top: .5rem; }

.field-hint { display: block; font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }

/* Contraseña con botón de ver/ocultar (macro password_input). El botón va
   dentro del campo, a la derecha; el padding deja sitio para que el texto
   no quede debajo del ojo. */
/* Mi cuenta -> Mi dieta */
.diet-form { display: flex; flex-direction: column; gap: .35rem; }

.diet-option { display: flex; gap: .6rem; align-items: center; font-weight: 400; min-height: 40px; }

.diet-option input { width: auto; min-height: 0; accent-color: var(--primary); }

.diet-warning { margin: .4rem 0 .6rem; }

.pw-field { position: relative; display: block; }

.pw-field input { padding-right: 3.2rem; }

.pw-toggle {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 3rem; display: flex; align-items: center; justify-content: center;
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--text-muted); border-radius: 0 10px 10px 0;
}

.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--text); }

.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; }

.pw-toggle .pw-eye-off { display: none; }

.pw-toggle[aria-pressed="true"] .pw-eye { display: none; }

.pw-toggle[aria-pressed="true"] .pw-eye-off { display: block; }

/* Indicador de "analizando": el POST de /import y /photo es síncrono y
   Gemini tarda 10-30 s. Sin esto parece un cuelgue. Compartido por los
   formularios de escaneo de Histórico (ticket), Mi Lista (papel/captura)
   y Recetas (foto de plato) -- antes vivía en la extinta pantalla
   /escanear. */
.upload-form.is-submitting button { opacity: 0.6; }

.analyzing-overlay {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border, #d8cdb8);
    border-radius: 8px;
    background: var(--card-bg, #fbf7ee);
    text-align: center;
}

.analyzing-overlay.is-visible { display: block; }

.analyzing-overlay .spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 0.6rem;
    border: 3px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--primary, #7a5c3e);
    border-radius: 50%;
    animation: analyzing-spin 0.9s linear infinite;
}

@keyframes analyzing-spin { to { transform: rotate(360deg); } }

.analyzing-overlay small { color: var(--text-muted, #8a7d66); }

.review-form { display: flex; flex-direction: column; gap: 1rem; }

.field-row label {
    display: block;
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.review-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* Fase 2: una tarjeta por ticket cuando se suben varios a la vez. */
/* Va dentro de otra .card: relleno corto para que en el móvil el nombre
   del producto no se quede en cuatro letras. */
.review-group {
    margin-bottom: 1rem;
    border: 1px solid var(--border, #d8cdb8);
    padding: 0.7rem;
    box-shadow: none;
}

.review-group h3 { margin-top: 0; }

.review-group h3 small { color: var(--text-muted); font-weight: 400; }

.review-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
}

.review-checkbox input { width: 26px; height: 26px; accent-color: var(--primary); }

.review-fields { flex: 1; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.review-name { font-size: 1rem; padding: 0.5rem !important; }

.review-category {
    font-size: 0.9rem !important;
    padding: 0.4rem !important;
    color: var(--text-muted);
}

.review-generico {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Campo editable: ancho fijo para que no le robe sitio al nombre del
   producto, que es lo que de verdad se lee de un vistazo. Va con
   `.review-item` delante porque `input[type="text"]` (más específico que
   una clase sola) le ponía width: 100% y se comía la fila entera. 16px
   para que iOS no haga zoom al tocarlo. */
.review-item .review-price {
    font-size: 1rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 600;
    width: 4.8rem;
    min-height: 40px;
    flex: 0 0 auto;
    text-align: right;
    padding: 0.4rem 0.35rem;
}

.review-price-suffix {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    flex: 0 0 auto;
    margin-left: -0.35rem;
}

/* --- Recetas: filtros y grid --- */
.filter-chips {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.45rem;
    margin: 0 -1rem 1rem;
    padding: 0 1rem;
}

.filter-chips::-webkit-scrollbar { display: none; }

.filter-chip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.05rem;
    min-height: 40px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #f7f2e7;
}

@keyframes recipeCardHighlight {
    0% { background-color: var(--green-soft); }
    100% { background-color: var(--card-bg); }
}

.recipe-card-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 10px;
    background: var(--bg);
}

.suggestions-highlight {
    background: linear-gradient(135deg, rgba(74, 124, 63, 0.09), rgba(74, 124, 63, 0.02));
    border: 1px solid rgba(74, 124, 63, 0.25);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.6rem;
}

.suggestions-highlight h2 { color: var(--primary-dark); }

.recipes-section-title {
    margin-top: 0.4rem;
    padding-top: 1.3rem;
    border-top: 1px solid var(--border);
}

/* El desplegable de celda (ingredientes) no usa el mismo triángulo ▾ que
   el de día (colapsar/expandir el día entero) -- eran visualmente
   idénticos en dos profundidades distintas, ver crítica de diseño. Aquí
   la pista es un texto pequeño en vez de un glifo genérico. */
.menu-cell-toggle-hint {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: none;
    letter-spacing: normal;
}

.menu-source-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 1rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Antes usaba --text-muted sobre --border (~3.6:1, por debajo del mínimo
   AA de 4.5:1) -- justo el badge que más conviene poder leer bien, ya que
   señala "esto no es tuyo, revísalo". Terra ya se usa en la app para
   acentos cálidos con buen contraste (missed-ing-label). */
.menu-source-base {
    background: var(--terra-soft);
    color: var(--terra-ink);
}

.menu-cell-time {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.used-ing { color: var(--primary-dark); font-size: 0.9rem; }

.missed-ing-label { color: var(--terra-ink); font-size: 0.9rem; margin-bottom: 0.3rem; }

.missed-ing-list { list-style: none; padding: 0; margin: 0 0 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; }

.missed-ing-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    font-size: 0.9rem; color: var(--terra-ink);
}

/* =========================================================================
   Inicio (home.html) -- estilos movidos aquí desde el <style> inline
   ========================================================================= */
.home-food-strip {
    /* Decoración pura: sin marco de tarjeta, atenuada y NO interactiva, para
       que no se lea como una fila de botones. */
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 2px 0 4px;
    margin-bottom: 16px;
    opacity: 0.38;
    pointer-events: none;
}

.home-food-strip svg { flex: none; }

.home-primary { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }

.home-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    min-height: 76px;
    box-shadow: 0 1px 2px rgba(44, 39, 34, 0.05);
    border: 1px solid var(--border);
    position: relative;
    text-decoration: none;
    color: var(--text);
}

.home-icon {
    width: 52px; height: 52px; min-width: 52px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    background: var(--green-soft);
}

.home-icon svg { color: var(--primary); }

.home-icon-sm { width: 44px; height: 44px; min-width: 44px; border-radius: 11px; }

.home-card-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.home-card-title { font-family: var(--serif); font-size: 1.18rem; font-weight: 600; color: var(--text); }

.home-card-sub { font-size: 0.92rem; color: var(--text-muted); }

.home-chevron { margin-left: auto; flex-shrink: 0; color: #cebfa4; }

.home-badge {
    position: absolute; top: 12px; right: 12px;
    background: var(--danger); color: #fff;
    font-size: 0.78rem; font-weight: 700;
    min-width: 22px; height: 22px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 6px;
}

.home-section-label {
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin: 0 0 12px 2px;
}

/* Primeros pasos (cuenta nueva) -- ver src/logic/onboarding.py */
.first-steps {
    background: var(--honey-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 16px 8px;
    margin-bottom: 18px;
}

.first-steps-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.first-steps-head h2 { font-family: var(--serif); font-size: 1.22rem; font-weight: 600; margin: 0; color: var(--text); }

.first-steps-head form { margin: 0; }

.first-steps-close {
    width: 32px; height: 32px; border: 0; border-radius: 50%;
    background: transparent; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.first-steps-intro { font-size: 0.92rem; color: var(--text-muted); margin: 4px 0 10px; }

.first-steps-list { list-style: none; margin: 0; padding: 0; }

.first-step + .first-step { border-top: 1px solid var(--border); }

.first-step a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; min-height: 48px;
    text-decoration: none; color: var(--text);
}

.first-step-mark {
    width: 28px; height: 28px; min-width: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    background: var(--card-bg); color: var(--honey-ink); border: 1.5px solid var(--warning);
}

.first-step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.first-step-title { font-weight: 600; }

.first-step-sub { font-size: 0.86rem; color: var(--text-muted); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.home-grid-card {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--card-bg); border-radius: var(--radius); padding: 18px;
    min-height: 96px;
    box-shadow: 0 1px 2px rgba(44, 39, 34, 0.05); border: 1px solid var(--border);
    position: relative;
    text-decoration: none; color: var(--text);
}

.home-grid-card.span2 {
    grid-column: span 2;
    flex-direction: row; align-items: center; gap: 16px; padding: 16px 18px;
    min-height: 76px;
}

.home-grid-card .home-card-title { font-size: 1.05rem; }

.home-grid-card .home-card-sub { font-size: 0.88rem; margin-top: -6px; }

.home-grid-card.span2 .home-card-sub { margin-top: 0; }

.app-footer {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.85rem;
}

.app-footer a { color: var(--text-muted); text-decoration: none; }

.app-footer a:hover { text-decoration: underline; }

/* =========================================================================
   Rediseño 2026-10 "densidad y navegación"
   A partir de una crítica de diseño sobre capturas a 390px: Mi Lista
   ocupaba ~2,5 pantallas con 11 productos, las secciones vivían tras el ☰
   y cada receta llevaba dos botones a ancho completo. Este bloque va al
   final a propósito: sobrescribe reglas anteriores sin tocarlas, así el
   cambio se revisa (y se revierte) de una pieza.
   ========================================================================= */
/* --- Barra de pestañas inferior --- */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(44, 39, 34, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: var(--tabbar-h);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.tabbar .tab svg {
    /* Mismo hueco en todas las pestañas; la activa solo cambia el fondo,
       así ninguna etiqueta se desplaza. */
    width: 1.3rem;
    height: 1.3rem;
    padding: 0.12rem 0.85rem;
    box-sizing: content-box;
    border-radius: 999px;
}

.tabbar .tab.active { color: var(--primary-dark); }

.tabbar .tab.active svg { background: var(--green-soft); }

.tabbar .tab:active { background: var(--bg); }

/* Que el contenido y el pie no queden debajo de la barra, y que el aviso
   de "Deshacer" flote por encima de ella. */
body:has(.tabbar) { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }

/* Las hojas inferiores y los modales tapan la barra (z-index mayor). */
.add-sheet-backdrop, .modal-backdrop { z-index: 30; }

.add-sheet, .modal-box { z-index: 31; }

@media (min-width: 1100px) {
  .tabbar { display: none; }
  body:has(.tabbar) { padding-bottom: 0; }
}

/* --- Mi Lista: una fila por producto ---
   Rejilla fija: [comprado] [icono] [nombre] [prioridad] [quitar].
   El punto de prioridad pasa a la derecha, separado del círculo de
   comprado: antes estaban pegados y sus zonas táctiles se solapaban. El
   orden del DOM no cambia (script.js construye filas con el mismo marcado),
   solo su colocación. */
.list-item {
    display: grid;
    grid-template-columns: 24px 34px minmax(0, 1fr) auto auto;
    grid-template-areas: "check pic content pri remove";
    align-items: center;
    column-gap: 0.5rem;
    padding: 0.5rem 0.7rem 0.5rem 1rem;
}

.list-item > .check-dot { grid-area: check; margin-top: 0; }

.list-item > .pic { grid-area: pic; width: 34px; height: 34px; min-width: 34px; border-radius: 10px; }

.list-item > .item-content { grid-area: content; }

.list-item > .pri-dot { grid-area: pri; margin-top: 0; width: 14px; height: 14px; min-width: 14px; }

.list-item > .pri-dot::before { inset: -13px; }

.list-item > .remove-btn { grid-area: remove; width: 30px; min-width: 30px; margin: 0; }

/* Nombre hasta 2 líneas con elipsis. */
.list-item .item-content { gap: 0.05rem; }

.list-item .item-content h3 { -webkit-line-clamp: 2; }

/* Leyenda de prioridades: una sola franja baja en vez de una tarjeta. */
.priority-legend { font-size: 0.78rem; }

.missed-ing-summary { color: var(--terra-ink); font-size: 0.9rem; margin: 0; }

/* En la ficha la tarjeta es columna flex: sin esto el badge "de catálogo"
   se estiraba a todo el ancho como una barra. */
.recipe-card > .sug-source-badge { align-self: flex-start; margin-left: 0; }

.recipe-meta { font-size: 0.82rem; color: var(--text-muted); }

.recipe-card-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    margin-top: auto; padding-top: 0.5rem;
    font-size: 0.88rem;
}

.recipe-card-have { color: var(--text-muted); }

.recipes-title { margin: 0 0 0.6rem; }

.recipes-new { margin-bottom: 0.2rem; }

.recipe-search-btn {
    position: absolute; right: 0.25rem; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; min-height: 0; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; color: var(--text-muted); cursor: pointer;
}

.recipes-pills { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1rem; }

.recipes-pill {
    display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%;
    min-height: 36px; padding: 0.3rem 0.8rem; border-radius: 999px;
    font: inherit; font-size: 0.88rem; line-height: 1.2; text-decoration: none; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.recipes-pill-diet { background: var(--green-soft); color: var(--green-ink); border: 1px solid transparent; }

.recipes-pill-diet:hover { text-decoration: none; color: var(--green-ink); }

.recipes-pill-gaps { background: var(--honey-soft); color: var(--honey-ink); border: 1px solid #ecdcbd; }

.add-sheet-panel .action-group { margin-bottom: 0; }

.recipe-card-cta {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 0.2rem;
    color: var(--primary-dark); font-weight: 700; white-space: nowrap;
}

.menu-today {
    font-family: var(--sans);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--green-ink);
    background: var(--green-soft);
    padding: 0.08rem 0.45rem;
    border-radius: 999px;
}

.menu-day-preview {
    grid-area: preview;
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-source-badge { margin-left: 0; }

.menu-cell-toggle-hint { flex-basis: 100%; margin-top: 0; font-size: 0.75rem; }

/* --- Inicio --- */
.home-primary { margin-bottom: 16px; }

.home-food-strip { margin-bottom: 10px; }

/* --- Pulido general --- */
/* Los chips del Histórico son <a> y heredaban el subrayado de enlace. */
.filter-chip { text-decoration: none; }

a.filter-chip:hover { text-decoration: none; }

/* Aviso del histórico de precios común en la revisión del ticket. */
.price-notice {
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    background: var(--honey-soft);
    color: var(--honey-ink);
    font-size: 0.9rem;
}

.price-notice a { color: inherit; font-weight: 700; }

/* --- "¿Dónde compro?" con precios de tickets: compra repartida --- */
.split-saving {
    display: inline-block;
    margin: 0 0 0.8rem;
    padding: 0.4rem 0.75rem;
    border-radius: 12px;
    background: var(--green-soft);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.88rem;
}

.split-group + .split-group { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }

.split-store {
    display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem;
    font-family: var(--sans); font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.split-total { color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 0; }

.split-items { list-style: none; display: flex; flex-direction: column; gap: 0.15rem; }

.split-items li { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.95rem; }

.split-price { font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }

.split-missing { margin-top: 0.7rem; font-size: 0.85rem; color: var(--text-muted); }

.split-estimate {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline;
    gap: 0.1rem 0.6rem; margin-bottom: 0.8rem;
}

.split-estimate span { font-weight: 600; }

.split-estimate strong { font-family: var(--serif); font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.split-estimate small { grid-column: 1 / -1; color: var(--text-muted); font-size: 0.82rem; }

.item-price { color: var(--text-muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.suggestion-item.checked .item-price { display: none; }

/* --- Páginas de texto largo (privacidad, términos, borrar cuenta) ---
   Los h3 iban pegados al párrafo anterior y las viñetas de las listas se
   salían del margen de la tarjeta. */
.card > h3:not(:first-child) { margin-top: 1.3rem; }

.card > p + p { margin-top: 0.6rem; }

.card > ul, .card > ol { margin: 0.5rem 0 0.6rem; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.3rem; }

@media (max-width: 520px) {
  /* Histórico desplegado en móvil: Categoría repite el mismo dato en todas
     las filas del grupo y Fuente es un dato técnico ("ticket-upload"); las
     dos le robaban sitio al nombre del producto, que se partía en 4 líneas. */
  .history-group .history-table th:nth-child(n+3), .history-group .history-table td:nth-child(n+3) { display: none; }
}

/* Enlaces compartidos (/s/<token>) y landing /app */
.share-card { max-width: 560px; margin-left: auto; margin-right: auto; }

.share-kicker { margin: 0 0 0.25rem; font-size: 0.85rem; color: var(--text-muted, #7a6f63); text-transform: uppercase; letter-spacing: 0.04em; }

.share-items { padding-left: 1.2rem; margin: 0.5rem 0 1rem; }

.share-items li { margin: 0.25rem 0; }

.share-cat { font-size: 0.8rem; color: var(--text-muted, #7a6f63); }

.share-alt { margin-top: 1rem; text-align: center; font-size: 0.95rem; }

/* Ficha de receta: Compartir, Guardar y vídeo bajo el título (opción A de
   la revisión de interfaz, 2026-10-13); Eliminar se queda al pie. */
.recipe-actions--top {
    flex-wrap: wrap;
    border-top: none;
    padding-top: 0;
    margin: 0.2rem 0 0.4rem;
}

/* --- Inicio como centro (opción B de la revisión de interfaz, 2026-10-13) --- */
.home-list { padding: 0; overflow: hidden; }

.home-list-link {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 1.1rem 0.7rem;
    color: var(--text);
    text-decoration: none;
}

.home-list-head { display: flex; align-items: baseline; gap: 0.6rem; }

.home-list-name { flex: 1 1 auto; font-family: var(--serif); font-size: 1.45rem; font-weight: 600; }

.home-list-count { font-size: 0.88rem; color: var(--text-muted); white-space: nowrap; }

.home-list-preview { font-size: 0.95rem; color: var(--text); opacity: 0.85; }

.home-list-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.4rem 1.1rem 0.8rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    text-decoration: none;
}

.home-list-share-text { flex: 1 1 auto; min-width: 0; }

.home-list-share-cta { color: var(--green-ink); font-weight: 700; white-space: nowrap; }

.home-suggestions { margin-bottom: 1rem; }

.home-suggestions-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

.home-suggestions-head h2 { margin: 0; font-size: 1.2rem; }

.home-suggestions-more {
    color: var(--green-ink);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}

.home-menu {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--text);
    text-decoration: none;
}

.home-menu-label {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--honey-ink);
}

.home-menu-row { font-size: 0.97rem; }

.home-menu-cta { font-size: 0.9rem; font-weight: 700; color: var(--green-ink); margin-top: 0.15rem; }

/* Compras: «Escanear ticket» a lo ancho y en verde; las otras dos debajo. */
.action-tiles--ticket { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.action-tiles--ticket .action-tile { min-height: 52px; }

.action-tile--main {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.action-tile--main svg { color: #fff; }

.action-tile--main:hover, .action-tile--main:active { background: var(--primary-dark); color: #fff; }

.account-links { display: flex; flex-direction: column; }

.account-links > a:not(.btn) {
    display: flex;
    align-items: center;
    min-height: 44px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.account-links > a:not(.btn)::after { content: '›'; margin-left: auto; color: var(--text-muted); }

.account-links .btn { margin-top: 0.9rem; }

/* =========================================================================
   Remaquetación 2026-10-13 (maquetas «Remaquetación de Compra&Cocina»).
   - Con sesión, fuera la barra oscura de marca en el móvil: cada pantalla
     abre con su título grande (.page-head) y la barra de pestañas de abajo
     hace de menú. En escritorio (>=1100 px) la barra sigue, con el menú.
   - Menos tarjetas dentro de tarjetas: el contenido va a lo ancho y las
     tarjetas quedan para lo que se toca (una receta, Mi lista en Inicio).
   - La acción principal de cada pantalla, fija encima de las pestañas
     (.list-dock, .history-dock, .sticky-cta).
   Va al final a propósito, como los rediseños anteriores: sobrescribe sin
   tocar lo de arriba, así se revisa y se revierte de una pieza.
   ========================================================================= */
:root { --dock-h: 4.1rem; }

@media (max-width: 1099px) {
  /* --- Base --- */
  body.has-session > .topbar { display: none; }
  body.has-session > .container { padding-top: calc(0.4rem + env(safe-area-inset-top, 0px)); }
}

body.has-session > .container { padding-bottom: 2.5rem; }

.page-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 0 0.7rem;
}

.page-head-text { flex: 1 1 auto; min-width: 0; }

.page-title {
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: -0.01em;
    margin: 0;
    text-wrap: balance;
}

.page-sub { margin: 0.2rem 0 0; color: var(--text-muted); font-size: 0.86rem; }

.page-sub strong { color: var(--text); font-variant-numeric: tabular-nums; }

.page-head-actions { display: flex; align-items: center; gap: 0.45rem; flex: none; }

.head-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    padding: 0;
    list-style: none;
    text-decoration: none;
}

.head-btn::-webkit-details-marker { display: none; }

.head-btn:active { background: var(--bg); }

.head-btn--accent { background: var(--green-soft); border-color: #d3dfc6; color: var(--green-ink); }

.link-btn {
    border: none;
    background: none;
    padding: 0.4rem 0;
    min-height: 40px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--green-ink);
    cursor: pointer;
}

/* Encabezado de sección: título a la izquierda, enlace a la derecha. */
.home-eyebrow {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    margin: 1.3rem 0 0.55rem;
}

.home-eyebrow h2 {
    margin: 0;
    font-family: var(--sans);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.home-eyebrow a {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--green-ink);
    text-decoration: none;
    white-space: nowrap;
}

/* Fijo encima de la barra de pestañas (o del borde, en escritorio). */
.history-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    padding: 0.7rem 1rem;
    background: linear-gradient(to top, var(--bg) 72%, rgba(250, 246, 238, 0));
}

.history-dock { max-width: 720px; margin-inline: auto; }

@media (min-width: 1100px) {
  .history-dock { bottom: 0; }
}

body:has(.sticky-cta, .list-dock, .history-dock) > .container { padding-bottom: calc(var(--dock-h) + 1.5rem); }


/* Mientras se analiza una foto: una tarjeta centrada encima de todo (el
   botón que la abrió puede estar en una hoja o fijo abajo). */
.analyzing-overlay.is-visible {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    max-width: 26rem;
    margin: 0 auto;
    padding: 1.4rem 1.2rem;
    border-radius: 18px;
    box-shadow: 0 0 0 100vmax rgba(44, 39, 34, 0.45), 0 16px 40px rgba(0, 0, 0, 0.2);
}

/* Bloque de color con la inicial cuando la receta no tiene foto; con foto,
   la imagen lo tapa. El tono sale del nombre (macro recipe_photo). */
.rphoto {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--rp1), var(--rp2));
    flex: none;
}

.rphoto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.rphoto-initial {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-size: 2.2rem;
    color: rgba(255, 253, 248, 0.85);
}

.rphoto--honey { --rp1: #f3dda9; --rp2: #cf9a52; }

.rphoto--olive { --rp1: #dce6c8; --rp2: #8aa66a; }

.rphoto--terra { --rp1: #f2cfb9; --rp2: #c0674c; }

.rphoto--wheat { --rp1: #efe2c2; --rp2: #b8925a; }

.rphoto--sage { --rp1: #e3e8d6; --rp2: #9aaa86; }

.rphoto--clay { --rp1: #ead6c7; --rp2: #a77c62; }

/* --- Inicio --- */
.home-food-strip { display: none; }

.first-steps {
    margin: 0.2rem 0 0;
    padding: 0;
    background: var(--honey-soft);
    border: 1px solid #eedfc0;
    border-radius: var(--radius);
}

.first-steps-strip {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    list-style: none;
    cursor: pointer;
}

.first-steps-strip::-webkit-details-marker { display: none; }

.first-steps-ring { color: var(--honey-ink); flex: none; }

.first-steps-ring text { font: 700 10px var(--sans); fill: currentColor; }

.first-steps-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.first-steps-text strong { font-size: 0.9rem; }

.first-steps-text span { font-size: 0.8rem; color: var(--text-muted); }

.first-steps[open] .first-steps-strip .home-chevron { transform: rotate(180deg); }

.first-steps .first-steps-intro, .first-steps .first-steps-list, .first-steps-dismiss { padding: 0 0.9rem; }

.first-steps-dismiss { padding-bottom: 0.4rem; }

.first-steps .first-steps-intro { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.3rem; }

.home-list.card { padding: 0; margin-bottom: 0; }

.home-list-link { padding: 0.9rem 1rem 0.6rem; gap: 0.55rem; }

.home-list-head { align-items: baseline; }

.home-list-total { font-family: var(--serif); font-size: 1.75rem; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

.home-list-count { margin-left: auto; }

.home-list-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 0.85rem;
    font-weight: 600;
}

.chip--muted { color: var(--text-muted); }

.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.home-list-actions { display: flex; gap: 0.5rem; padding: 0 1rem 0.9rem; }

.home-list-actions .btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 42px;
    padding: 0 0.6rem;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.home-list-actions .btn-share { color: var(--green-ink); }

.home-list-actions .list-shared-avatars span { width: 22px; height: 22px; font-size: 0.65rem; }

.home-menu.card { padding: 0.15rem 1rem; gap: 0; margin-bottom: 0; }

.home-menu-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    color: var(--text);
    text-decoration: none;
}

.home-menu-row + .home-menu-row { border-top: 1px solid var(--border); }

.home-menu-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.home-menu-slot { font-size: 0.78rem; color: var(--text-muted); }

.home-menu-name { font-family: var(--serif); font-size: 1.06rem; font-weight: 500; line-height: 1.2; }

.home-menu-missing { font-size: 0.8rem; color: var(--terra-ink); }

.home-chevron { color: #b5aa98; flex: none; }

.home-menu--empty { padding: 0.9rem 1rem; gap: 0.3rem; }

.home-suggestions { margin-bottom: 0.5rem; }

.recipe-card-photo { width: 100%; aspect-ratio: 1 / 1; height: auto; margin-bottom: 0.35rem; }

/* Rejilla de baldosas de las hojas (añadir a la lista, nueva receta). */
.sheet-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }

.sheet-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.sheet-tile:hover { text-decoration: none; color: var(--text); }

.sheet-tile:active { background: var(--green-soft); }

.sheet-tile-icon {
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green-soft);
    color: var(--green-ink);
}

.rphoto--hero { width: 100%; aspect-ratio: 16 / 10; max-height: 46vh; border-radius: 0; }

.rphoto--hero .rphoto-initial { font-size: 4rem; }

@media (min-width: 600px) {
  .rphoto--hero { border-radius: var(--radius); }
}

.home-list-chips-row { margin-bottom: 0.6rem; }

/* --- Compras --- */
.history-section { background: none; border: none; box-shadow: none; padding: 0; }

.history-search { position: relative; display: flex; align-items: center; margin: 0.1rem 0 0.6rem; }

.history-search svg { position: absolute; left: 0.85rem; color: var(--text-muted); pointer-events: none; }

.history-search input { flex: 1; min-width: 0; padding-left: 2.6rem; min-height: 46px; border-radius: 14px; }

.history-section .filter-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -1rem 0.3rem; padding: 0 1rem 0.2rem; }

.history-section .filter-chips::-webkit-scrollbar { display: none; }

.history-section .filter-chip { flex: none; }

.history-bucket {
    margin: 1rem 0 0.1rem;
    font-family: var(--sans);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.history-groups { gap: 0; display: block; }

.history-group { border: none; border-bottom: 1px solid var(--border); border-radius: 0; background: none; box-shadow: none; margin: 0; }

.history-group > summary { padding: 0.7rem 0; gap: 0.75rem; }

.history-group .hg-name { font-weight: 600; }

.history-group .hg-count {
    margin-left: auto;
    min-width: 2.6rem;
    padding: 0.1rem 0.45rem;
    border-radius: 8px;
    font-size: 0.82rem;
}

.history-section .action-panel.card { margin: 0.2rem 0 0.8rem; }

.history-dock { display: flex; gap: 0.5rem; }

.history-dock-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 50px;
    box-shadow: 0 6px 18px rgba(61, 107, 51, 0.25);
}

.dock-square {
    width: 50px;
    height: 50px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    min-height: 0;
}

/* Con una palabra debajo: el icono solo no decía qué hacía cada botón. */
.history-dock .dock-square { width: 58px; flex-direction: column; gap: 1px; }

.dock-square-label { font-size: 0.66rem; font-weight: 600; line-height: 1; }

.dock-square[aria-expanded="true"] { background: var(--green-soft); color: var(--green-ink); border-color: #d3dfc6; }

/* --- Cuenta --- */
.account-head { gap: 0.9rem; padding-top: 1.1rem; }

.account-avatar {
    width: 3.2rem;
    height: 3.2rem;
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green-soft);
    color: var(--green-ink);
    font-family: var(--serif);
    font-size: 1.5rem;
}

.account-head .page-title { font-size: 1.5rem; overflow-wrap: anywhere; }

.set-title {
    margin: 1.2rem 0 0.45rem;
    font-family: var(--sans);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.set {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.set--spaced { margin-top: 1.4rem; }

.set-row, .set-row > summary {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 56px;
    padding: 0.55rem 0.95rem;
    color: var(--text);
    text-decoration: none;
    margin: 0;
}

.set-row:hover { text-decoration: none; color: var(--text); }

/* «Salir» es un <form method=post> con un <button class="set-row"> */
.set-logout { margin: 0; }
.set-logout > .set-row {
    width: 100%; background: none; border: 0; font: inherit;
    text-align: left; cursor: pointer;
}
.set-logout + .set-row { border-top: 1px solid var(--border); }

.set > .set-row + .set-row { border-top: 1px solid var(--border); }

.set-row--expand { display: block; padding: 0; }

.set-row--expand > summary { list-style: none; cursor: pointer; }

.set-row--expand > summary::-webkit-details-marker { display: none; }

.set-row--expand[open] > summary .set-chev { transform: rotate(90deg); }

.set-row--expand > :not(summary) { margin-left: 0.95rem; margin-right: 0.95rem; }

.set-row--expand > :last-child { margin-bottom: 0.95rem; }

.set-row--block { display: block; padding: 0.9rem 0.95rem; }

.set-icon { width: 20px; height: 20px; flex: none; color: var(--green-ink); }

.set-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.set-text strong { font-weight: 600; font-size: 0.98rem; }

.set-text > span { font-size: 0.82rem; color: var(--text-muted); }

.set-chev { color: #b5aa98; flex: none; transition: transform 0.2s var(--ease-out); }

.set-row--danger > summary { color: var(--terra-ink); }

.set .account-links, .account-links.set { display: block; }

.account-links.set > a:not(.btn) { min-height: 56px; border-bottom: none; }

.account-links.set > a:not(.btn)::after { content: none; }

.diet-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }

.diet-chips .diet-option { margin: 0; padding: 0; border: none; }

.diet-chips .diet-option input { position: absolute; opacity: 0; pointer-events: none; }

.diet-chips .diet-option span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.diet-chips .diet-option input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }

.diet-chips .diet-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.switch {
    position: relative;
    width: 48px;
    height: 28px;
    flex: none;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #d9d0c1;
    cursor: pointer;
    min-height: 0;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s var(--ease-out);
}

.switch[aria-checked="true"] { background: var(--primary); }

.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Compras: nombre a la izquierda y el contador a la derecha. */
.history-section .history-group > summary { grid-template-columns: minmax(0, 1fr) auto; }

.history-section .history-group .hg-count { width: auto; height: 32px; }

.history-section .history-group[open] > summary { background: none; }

.history-section .history-group .table-scroll { margin: 0.3rem 0 0.8rem; }

.home-list-shared { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.55rem; font-size: 0.84rem; color: var(--text-muted); }

/* Receta sin foto: el dibujo de su ingrediente principal en vez de la inicial. */
.rphoto > .pic { position: absolute; inset: 0; width: auto; height: auto; min-width: 0; margin: auto; border: none; border-radius: 0; background: none; }

.rphoto > .pic svg { width: 46%; height: 46%; max-width: 6rem; max-height: 6rem; opacity: 0.9; }

/* Casillas y radios con el verde de la app, no el azul del navegador. */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

/* --- Entrar, Crear cuenta y contraseña (2026-10-15) ---
   Sin la barra oscura: la marca va como título grande, igual que el resto
   de pantallas desde la remaquetación (ver auth_brand en _macros.html). */
body.auth-page > .topbar { display: none; }

body.auth-page > .container { padding-top: calc(1.2rem + env(safe-area-inset-top, 0px)); }

.auth-brand { display: flex; align-items: center; gap: 0.8rem; max-width: 420px; margin: 0.6rem auto 1.1rem; }

.auth-brand-mark {
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--green-soft);
    color: var(--green-ink);
}

.auth-brand-name { margin: 0; font-family: var(--serif); font-size: 1.9rem; font-weight: 500; line-height: 1.05; letter-spacing: -0.01em; color: var(--text); }

.auth-brand-sub { margin: 0.2rem 0 0; font-size: 0.88rem; color: var(--text-muted); }

.auth-card { max-width: 420px; margin: 0 auto 2rem; border-radius: 18px; }

.auth-card h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; }

@keyframes cook-pulse { 50% { transform: scale(1.05); } }

/* Prueba cerrada (1.0.1): tarjeta de Inicio que pide comentarios y enlaza
   a Novedades (templates/home.html, src/logic/novedades.py). */
.beta-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin: 0.2rem 0 0.8rem;
    padding: 0.8rem 0.9rem;
    background: var(--green-soft);
    border: 1px solid #cfdcc0;
    border-radius: var(--radius);
}
.beta-card-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 12rem; flex: 1; }
.beta-card-text span { font-size: 0.85rem; color: var(--text-muted); }
.beta-card-actions { display: flex; align-items: center; gap: 0.6rem; }
.beta-card-actions form { margin: 0; }
.beta-card-close {
    background: none;
    border: 0;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    color: var(--text-muted);
    cursor: pointer;
}
.novedades-fecha { font-weight: normal; color: var(--text-muted); font-size: 0.9rem; }
.novedades-version ul { margin: 0.4rem 0 0.6rem 1.1rem; padding: 0; }
.novedades-probar { font-size: 0.9rem; margin: 0; }

/* Cuenta > Apariencia (1 nov 2026): claro / oscuro / automático. */
.tema-form { display: block; }
.tema-opciones {
    display: flex;
    gap: 0.3rem;
    padding: 0.25rem;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
}
.tema-opcion {
    flex: 1 1 0;
    min-height: 40px;
    border: none;
    border-radius: 11px;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
}
.tema-opcion.is-active { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 4px rgba(44, 39, 34, 0.12); }
.tema-form .field-hint { margin: 0.5rem 0 0; }
