/* ── Reset & Variables ──────────────────────────────────────── */
:root {
  /* Vivid Sunset — índigo profundo */
  --bg:          #111125;
  --surface:     #1e1e32;
  --surface2:    #28283d;
  --surface3:    #333348;
  --surface-low: #1a1a2e;
  --surface-lowest: #0c0c1f;

  /* Bordes */
  --border:      #58413e;
  --border-dim:  rgba(255,111,97,.1);

  /* Texto */
  --text:        #e2e0fc;
  --text-muted:  #b0adc8;

  /* Acento principal — coral/sunset */
  --primary:     #ff6f61;
  --primary-dim: rgba(255,111,97,.12);
  --primary-light: #ffb4aa;

  /* Alias para retrocompatibilidad JS/HTML */
  --green:       #ff6f61;
  --green-mid:   #ffb4aa;
  --green-dim:   rgba(255,111,97,.12);

  /* Macros */
  --macro-pro:   #ffb77b;
  --macro-carb:  #ebc23e;
  --macro-fat:   #ffb4ab;

  /* Utilidades */
  --blue:        #ebc23e;
  --orange:      #fb8c00;
  --red:         #ff8a80;

  --radius:      20px;
  --nav-h:       72px;

  /* Glass */
  --glass-bg:    rgba(30,30,50,.65);
  --glass-blur:  blur(16px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Glow ambiental superior */
body::before {
  content: "";
  position: fixed;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 50vh;
  background: radial-gradient(ellipse at center,
    rgba(255,111,97,.12) 0%,
    rgba(255,111,97,.04) 40%,
    transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}

button { cursor: pointer; background: none; border: none; color: inherit; font: inherit; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface3);
  border: none;
  border-radius: 14px;
  outline: none;
  transition: box-shadow .15s;
}
input:focus, select:focus {
  box-shadow: 0 0 0 2px rgba(255,111,97,.4);
}
input::placeholder { color: var(--text-muted); opacity: .6; }

/* ── Layout ─────────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: var(--nav-h);
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.screen { display: none; padding: 20px 16px 8px; }
.screen.active { display: block; }

/* ── Header ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.greeting {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
}
.page-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -.02em;
}

.icon-btn {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 14px;
  border: 1px solid var(--border-dim);
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255,111,97,.15); border-color: rgba(255,111,97,.25); }
.icon-btn:active { transform: scale(.93); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* ── Summary / Donut ────────────────────────────────────────── */
.summary-card { display: flex; align-items: center; gap: 20px; }

.donut-container { position: relative; flex-shrink: 0; width: 108px; height: 108px; }

.donut { width: 100%; height: 100%; transform: rotate(-90deg); }

.donut-track {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 11;
}
.donut-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dasharray .6s ease;
  filter: drop-shadow(0 0 8px rgba(255,111,97,.6));
}

.donut-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1.1;
}
.donut-label span:first-child {
  font-size: 1.2rem; font-weight: 800;
  color: var(--text);
}
.kcal-unit { font-size: .6rem; color: var(--text-muted); font-weight: 600; letter-spacing: .06em; }
.kcal-goal { font-size: .58rem; color: var(--text-muted); margin-top: 1px; }

/* ── Macros ──────────────────────────────────────────────────── */
.macros-row { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.macro { display: flex; align-items: center; gap: 8px; }

.macro-bar-wrap {
  flex: 1; height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.macro-bar {
  height: 100%; border-radius: 99px;
  transition: width .5s ease;
}
.proteins { background: var(--macro-pro); }
.carbs    { background: var(--macro-carb); }
.fat      { background: var(--macro-fat); }

.macro-label { font-size: .68rem; color: var(--text-muted); width: 58px; font-weight: 600; }
.macro-value { font-size: .75rem; font-weight: 700; width: 36px; text-align: right; }

/* ── Food Log ────────────────────────────────────────────────── */
.meal-group { margin-bottom: 24px; }

.meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}
.meal-header-name {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
}
.meal-header-kcal {
  font-size: .7rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-dim);
  padding: 2px 10px;
  border-radius: 9999px;
}

/* Fallback: cuando meal-header es un string directo (sin sub-elementos) */
.meal-header:not(:has(.meal-header-name)) {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  display: block;
}

.food-item {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: background .15s, border-color .15s;
}
.food-item:active { background: rgba(255,111,97,.08); border-color: var(--border-dim); }

.food-item-thumb {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface2);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
img.food-item-thumb {
  object-fit: cover;
  display: block;
}

.food-item-info { flex: 1; min-width: 0; }
.food-item-name { font-size: .9rem; font-weight: 700; }
.food-item-meta { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }
.food-item-kcal {
  font-size: .88rem; font-weight: 800;
  color: var(--primary); white-space: nowrap;
}
.food-item-delete {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.food-item-delete:hover { background: rgba(255,138,128,.15); color: var(--red); }
.food-item-delete svg { width: 16px; height: 16px; }

.empty-log {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.6;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; }
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-sheet {
  position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: rgba(17,17,37,.92);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255,255,255,.08);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 12px 20px 44px;
  max-height: 90dvh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}

.modal-handle {
  width: 40px; height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 99px;
  margin: 0 auto 6px;
}
.modal-title {
  font-size: 1.15rem; font-weight: 800;
  letter-spacing: -.01em;
}

/* ── Search ──────────────────────────────────────────────────── */
.search-row { display: flex; gap: 8px; }

.search-input {
  flex: 1;
  padding: 13px 16px;
  border-radius: 14px;
  font-size: .9rem;
  background: var(--surface3);
  border: none;
}

.search-results { display: flex; flex-direction: column; gap: 6px; }

.result-item {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 16px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .15s, background .15s;
}
.result-item:hover { background: rgba(255,111,97,.07); }
.result-item.selected {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.result-img {
  width: 44px; height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}
.result-info { flex: 1; }
.result-name { font-size: .85rem; font-weight: 700; }
.result-brand { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.result-kcal {
  font-size: .8rem; font-weight: 700;
  color: var(--primary); white-space: nowrap;
}

.search-loading, .search-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: .85rem;
}

/* ── Portion form ────────────────────────────────────────────── */
.portion-form { display: flex; flex-direction: column; gap: 12px; }
.portion-form.hidden { display: none; }

.portion-name { font-size: .95rem; font-weight: 700; color: var(--primary); }

.portion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.portion-row label { font-size: .85rem; color: var(--text-muted); }
.portion-row select,
.portion-row input[type="number"] {
  padding: 8px 12px;
  width: 150px;
}

.portion-preview {
  background: var(--surface2);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #5a0003;
  font-weight: 800;
  font-size: .95rem;
  border-radius: 9999px;
  letter-spacing: .01em;
  box-shadow: 0 8px 24px rgba(255,111,97,.3), 0 2px 8px rgba(255,111,97,.2);
  transition: opacity .15s, transform .12s, box-shadow .15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { opacity: .92; box-shadow: 0 12px 32px rgba(255,111,97,.45); }
.btn-primary:active { transform: scale(.97); }

.btn-danger {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1px solid rgba(255,138,128,.35);
  color: var(--red);
  font-weight: 700;
  font-size: .95rem;
  border-radius: 9999px;
  margin-top: 8px;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(255,138,128,.08); }

/* ── Bottom Nav ──────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-h);
  background: rgba(12,12,31,.85);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-top: 1px solid rgba(255,255,255,.07);
  border-radius: 24px 24px 0 0;
  display: flex;
  align-items: center;
  padding: 0 8px 4px;
  z-index: 50;
  box-shadow: 0 -8px 32px rgba(0,0,0,.3);
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 16px;
  color: var(--text-muted);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: color .15s, background .2s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active {
  color: var(--primary);
  background: rgba(255,111,97,.12);
}
.nav-item:hover:not(.active) { color: var(--text); }

/* ── Spinner ─────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--surface3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}

/* ── Auth screens ────────────────────────────────────────────── */
.auth-screen {
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 24px 52px;
  gap: 28px;
}

.auth-brand {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

.auth-logo {
  font-size: 2.2rem; line-height: 1;
  width: 72px; height: 72px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,111,97,.2);
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(255,111,97,.18), 0 8px 24px rgba(0,0,0,.3);
}

.auth-brand h1 {
  font-size: 2rem; font-weight: 800; letter-spacing: -.03em;
  color: var(--text);
}
.auth-tagline { font-size: .88rem; color: var(--text-muted); font-weight: 500; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label {
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding-left: 4px;
}
.field-group input, .field-group select {
  padding: 15px 16px;
  border-radius: 16px;
  font-size: .95rem;
  background: var(--surface3);
  border: none;
  width: 100%;
  transition: box-shadow .15s, background .15s;
}
.field-group input:focus, .field-group select:focus {
  background: var(--surface2);
  box-shadow: 0 0 0 2px rgba(255,111,97,.4);
}
.field-hint { font-size: .72rem; color: var(--text-muted); padding-left: 4px; }

.auth-error {
  font-size: .82rem;
  color: var(--red);
  background: rgba(255,138,128,.08);
  border: 1px solid rgba(255,138,128,.2);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
}
.auth-error.hidden { display: none; }

.auth-links {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.link-btn {
  font-size: .85rem; color: var(--primary);
  font-weight: 600;
  transition: opacity .15s;
}
.link-btn:hover { opacity: .75; }

/* ── Profile screen ──────────────────────────────────────────── */
.profile-card {
  display: flex; align-items: center; gap: 16px;
}
.profile-avatar {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: rgba(255,111,97,.15);
  border: 2px solid rgba(255,111,97,.3);
  color: var(--primary);
  font-size: 1.4rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-name { font-size: 1rem; font-weight: 700; }
.profile-email { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.section-title {
  font-size: .7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

#form-profile { display: flex; flex-direction: column; gap: 20px; }
.goals-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.goals-grid .field-group label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Shopping lists ──────────────────────────────────────────── */
.list-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background .15s, border-color .15s;
}
.list-card:hover { background: rgba(255,111,97,.07); border-color: rgba(255,111,97,.18); }
.list-card:active { transform: scale(.99); }

.list-card-info { flex: 1; min-width: 0; }
.list-card-name {
  font-size: .95rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-card-meta { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

.list-card-progress {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex-shrink: 0;
}
.list-card-count { font-size: .8rem; font-weight: 700; color: var(--primary); }
.list-progress-bar {
  width: 60px; height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.list-progress-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }

.list-delete-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--text-muted); flex-shrink: 0;
  transition: background .15s, color .15s;
}
.list-delete-btn:hover { background: rgba(255,138,128,.15); color: var(--red); }
.list-delete-btn svg { width: 16px; height: 16px; }

/* ── Shopping detail ─────────────────────────────────────────── */
.members-row {
  display: flex; align-items: center;
  padding: 0 4px 16px;
  flex-wrap: wrap; gap: 6px;
}
.member-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,111,97,.15);
  border: 2px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  color: var(--primary);
}

.shop-section-header {
  font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-muted);
  padding: 8px 4px;
  display: flex; align-items: center; gap: 12px;
}
.shop-section-header::after {
  content: "";
  flex: 1; height: 1px;
  background: rgba(255,255,255,.06);
}

/* Items como cards */
.shop-item {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 16px;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: opacity .2s, background .15s;
}
.shop-item.checked { opacity: .5; }
.shop-item.checked .shop-item-name { text-decoration: line-through; }

/* Checkbox circular con glow */
.shop-item-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,111,97,.4);
  background: transparent;
  flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.shop-item-check.checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(255,111,97,.5);
}
.shop-item-check.checked::after {
  content: "✓"; color: #5a0003; font-size: .78rem; font-weight: 900;
}

.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name {
  font-size: .9rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shop-item-qty { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }

.shop-item-del {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-muted); flex-shrink: 0;
  transition: background .15s, color .15s;
}
.shop-item-del:hover { background: rgba(255,138,128,.15); color: var(--red); }
.shop-item-del svg { width: 15px; height: 15px; }

/* Barra inferior — estilo contenedor */
.add-item-bar {
  position: fixed; bottom: var(--nav-h); left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  padding: 10px 14px;
  z-index: 40;
  background: rgba(12,12,31,.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,.06);
}
.add-item-bar-inner {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface2);
  border-radius: 18px;
  padding: 6px 8px 6px 14px;
  border: 1px solid rgba(255,255,255,.06);
}
.add-item-bar #new-item-input {
  flex: 1; background: transparent; border: none;
  padding: 8px 0; font-size: .9rem;
  box-shadow: none;
}
.add-item-bar #new-item-qty {
  width: 64px; background: var(--surface3);
  padding: 8px 10px; border-radius: 10px; font-size: .85rem; text-align: center;
  border: none; box-shadow: none;
}
.add-item-bar .icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  box-shadow: 0 4px 12px rgba(255,111,97,.35);
  flex-shrink: 0;
  color: #5a0003;
}
.add-item-bar .icon-btn svg { stroke: currentColor; }

/* Share members list */
.share-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.share-member-row:last-child { border-bottom: none; }
.share-member-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,111,97,.12); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.share-member-info { flex: 1; }
.share-member-name { font-size: .88rem; font-weight: 600; }
.share-member-role { font-size: .72rem; color: var(--text-muted); }
.share-member-remove {
  color: var(--text-muted); padding: 4px 8px;
  font-size: .75rem; border-radius: 8px;
  transition: background .15s, color .15s;
}
.share-member-remove:hover { background: rgba(255,138,128,.12); color: var(--red); }

.empty-lists {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: .9rem;
  line-height: 1.6;
}

/* ── Familia ─────────────────────────────────────────────────── */
.family-name-display {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 4px;
}
.btn-family-share {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  width: 100%; margin-top: 14px; padding: 13px;
  background: var(--primary-dim);
  border-radius: 9999px;
  color: var(--primary); font-size: .9rem; font-weight: 700;
  border: 1px solid rgba(255,111,97,.2);
  transition: background .15s;
}
.btn-family-share:active { background: rgba(255,111,97,.2); }
.btn-family-share.hidden { display: none; }

/* ── Menús semanales ─────────────────────────────────────────── */
.menu-list-card {
  display: flex; align-items: center;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; gap: 12px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.menu-list-card:hover { background: rgba(255,111,97,.07); border-color: rgba(255,111,97,.18); }

#menu-week-grid { padding: 0 0 100px; }

.menu-day-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden;
}
.menu-day-header {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--primary);
  padding: 12px 16px 8px;
}
.menu-slot-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,.05);
}
.menu-slot-label {
  font-size: .75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  width: 52px; flex-shrink: 0;
}
.menu-slot-value {
  flex: 1; text-align: left; font-size: .92rem;
  padding: 7px 12px; border-radius: 10px;
  background: var(--surface2); color: var(--text);
  transition: background .15s;
}
.menu-slot-value:active { background: var(--surface3); }
.menu-slot-value.empty { color: var(--text-muted); }
.menu-slot-placeholder { font-style: italic; font-size: .85rem; }

/* ── Barcode scanner ─────────────────────────────────────────── */
#modal-barcode {
  position: fixed; inset: 0;
  background: #000;
  z-index: 250;
  display: flex; flex-direction: column;
}
#modal-barcode.hidden { display: none; }

.barcode-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
}
.barcode-header p { flex: 1; font-size: .95rem; color: rgba(255,255,255,0.8); }
.barcode-close-btn {
  width: 36px; height: 36px;
  border-radius: 50%; background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff;
  transition: background .15s;
}

.barcode-viewfinder {
  flex: 1; position: relative; overflow: hidden;
}
#barcode-video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.barcode-frame {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(260px, 80vw); height: min(160px, 50vw);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  pointer-events: none;
  transition: box-shadow .2s;
}
.barcode-frame::before, .barcode-frame::after,
.barcode-frame > span::before, .barcode-frame > span::after {
  content: ""; position: absolute;
  width: 28px; height: 28px;
  border-color: var(--primary); border-style: solid;
}
.barcode-frame::before    { top: -2px;  left: -2px;  border-width: 3px 0 0 3px; border-radius: 10px 0 0 0; }
.barcode-frame::after     { top: -2px;  right: -2px; border-width: 3px 3px 0 0; border-radius: 0 10px 0 0; }
.barcode-frame > span::before { bottom: -2px; left: -2px;  border-width: 0 0 3px 3px; border-radius: 0 0 0 10px; }
.barcode-frame > span::after  { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 10px 0; }

.barcode-scan-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: scan-sweep 2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(255,111,97,.8);
}
@keyframes scan-sweep {
  0%   { top: 10%; opacity: 1; }
  50%  { top: 88%; opacity: 1; }
  100% { top: 10%; opacity: 1; }
}

.barcode-hint {
  padding: 18px 20px;
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: .82rem;
  background: rgba(0,0,0,0.6);
}
#barcode-status {
  color: var(--primary); font-weight: 700; margin-top: 4px;
  min-height: 18px; font-size: .85rem;
}

/* ── Loading overlay ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
#loading-overlay.hidden { display: none; }

/* ── Recetarios ──────────────────────────────────────────────── */
.recipe-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: background .15s, border-color .15s;
}
.recipe-card:hover { background: rgba(255,111,97,.07); border-color: rgba(255,111,97,.18); }

.recipe-card-icon {
  flex-shrink: 0;
  width: 46px; height: 46px;
  background: rgba(251,140,0,.15);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--orange);
}
.recipe-card-icon svg { width: 22px; height: 22px; }

.recipe-card-info { flex: 1; min-width: 0; }
.recipe-card-title {
  font-size: .95rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recipe-card-date { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.recipe-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.recipe-open-btn, .recipe-delete-btn {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  transition: background .15s;
}
.recipe-open-btn { color: var(--blue); }
.recipe-delete-btn { color: var(--red); }
.recipe-open-btn:hover { background: rgba(235,194,62,.12); }
.recipe-delete-btn:hover { background: rgba(255,138,128,.15); }
.recipe-open-btn svg, .recipe-delete-btn svg { width: 17px; height: 17px; }

.recipe-upload-progress {
  font-size: .85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0;
}

/* ── Navegación de días ──────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}
.date-nav-label {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.date-nav-btn {
  width: 32px; height: 32px;
  background: transparent;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
}
.date-nav-btn:hover { background: var(--surface2); }
.date-nav-btn svg { width: 16px; height: 16px; }

/* ── Historial ───────────────────────────────────────────────── */
.history-row {
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  cursor: pointer;
  transition: opacity .15s;
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { opacity: .72; }

.history-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.history-day-label {
  font-size: .9rem;
  font-weight: 600;
  text-transform: capitalize;
}
.history-kcal {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
}
.history-kcal-empty {
  color: var(--text-muted);
  font-weight: 400;
}
.history-bar-wrap {
  height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.history-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
  min-width: 0;
}

/* ── Gráfica historial ───────────────────────────────────────── */
.history-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--surface2);
  padding: 2px 0;
}

/* ── Alimentos recientes ─────────────────────────────────────── */
.recent-section-header {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 2px 8px;
}

/* ── Botón reintentar búsqueda ───────────────────────────────── */
.search-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 0 12px;
}
.btn-retry {
  padding: 10px 28px;
  border-radius: 99px;
  background: var(--primary-dim);
  color: var(--primary);
  font-size: .9rem;
  font-weight: 700;
  border: 1px solid rgba(255,111,97,.25);
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-retry:active { transform: scale(.96); }

/* ── Categorías lista de la compra ───────────────────────────── */
.shop-category-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px 5px;
}
.shop-cat-icon {
  font-size: 1rem;
  line-height: 1;
}
.shop-cat-name {
  font-size: .74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.shop-cat-count {
  margin-left: auto;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface3);
  padding: 1px 8px;
  border-radius: 99px;
}
.done-section {
  padding: 12px 16px 5px;
  font-size: .74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Chef IA — Chat ──────────────────────────────────────────── */
#screen-chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: calc(var(--nav-h) + 80px);
}

/* Pantalla de bienvenida */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 32px 8px 0;
  flex: 1;
}
.chat-welcome-icon { font-size: 3rem; line-height: 1; }
.chat-welcome-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}
.chat-welcome-sub {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.chat-suggestion {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-dim);
  color: var(--text);
  border-radius: 99px;
  padding: 8px 16px;
  font-size: .83rem;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.chat-suggestion:active { transform: scale(.96); }

/* Burbujas de chat */
.chat-bubble {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
}
.chat-bubble-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-bubble-assistant { align-self: flex-start; }

.chat-avatar {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.chat-bubble-content {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: .92rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-bubble-user .chat-bubble-content {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-assistant .chat-bubble-content {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-dim);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Estilos para el markdown renderizado */
.chat-bubble-content p  { margin: 0 0 6px; }
.chat-bubble-content p:last-child { margin-bottom: 0; }
.chat-bubble-content ol,
.chat-bubble-content ul { padding-left: 18px; margin: 4px 0 6px; }
.chat-bubble-content li { margin-bottom: 3px; }
.chat-bubble-content strong { font-weight: 700; }

/* Indicador "escribiendo..." */
.chat-typing .chat-bubble-content {
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* Barra de input */
.chat-input-bar {
  position: fixed;
  bottom: var(--nav-h);
  left: 0; right: 0;
  padding: 8px 12px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border-dim);
  z-index: 10;
}
.chat-input-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface2);
  border-radius: 22px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--border-dim);
}
.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .95rem;
  line-height: 1.45;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  padding: 3px 0;
  font-family: inherit;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.chat-send-btn:disabled { opacity: .4; }
.chat-send-btn:active:not(:disabled) { transform: scale(.92); }
.chat-send-btn svg { width: 16px; height: 16px; }
