:root {
  --font:      'Nunito', system-ui, sans-serif;
  --stone:     #1a1a18;
  --peak:      #c8a96e;
  --accent:    #e05c2a;
  --accent2:   rgba(224,92,42,.12);
  --header-bg: #f3ddc8;
  --header-accent: #b5591f;
  --snow:      #f0ede8;
  --bg:        #f2f0ec;
  --card:      #ffffff;
  --border:    #e4e0d8;
  --text:      #1a1a18;
  --text2:     #8a8578;
  --danger:    #e74c3c;
  --radius:    16px;
  --shadow:    0 4px 18px rgba(0,0,0,.09);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

button { font-family: var(--font); cursor: pointer; }
input, textarea { font-family: var(--font); }

/* ── Topbar ── */
.topbar {
  background: var(--header-bg);
  padding: max(env(safe-area-inset-top, 0px), 1.1rem) 1.25rem .9rem;
}
.topbar-top { display: flex; align-items: flex-start; justify-content: space-between; }
.app-greeting {
  font-size: .68rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--header-accent); margin-bottom: 2px;
}
.app-title { font-size: 1.6rem; font-weight: 900; color: var(--stone); line-height: 1; letter-spacing: -.02em; }
.chef-f { position: relative; display: inline-block; }
.chef-hat {
  position: absolute; left: 50%; bottom: 88%;
  width: 1.25em; height: 1.25em;
  transform: translateX(-50%) rotate(-10deg);
  pointer-events: none;
}
.topbar-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.btn-icon {
  background: rgba(26,26,24,.08); border: 1px solid rgba(26,26,24,.12);
  color: var(--stone); border-radius: 10px;
  width: 38px; height: 38px; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.btn-icon:hover  { background: rgba(26,26,24,.14); }
.btn-icon:active { transform: scale(.94); }

/* ── Chips de filtro (siguen pegados a la cabecera) ── */
.chips {
  background: var(--header-bg);
  display: flex; gap: .35rem; padding: 0 1rem .85rem;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: rgba(26,26,24,.06); border: 1px solid rgba(26,26,24,.12);
  color: var(--header-accent); border-radius: 999px;
  padding: .38rem .7rem; font-size: .72rem; font-weight: 700;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── Contenido claro ─────────────────────── */
.content { padding: 1rem 1.25rem 3rem; }

.search-bar { margin-bottom: 1rem; }
.search-bar input {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); padding: .75rem .9rem;
  font-size: .92rem; outline: none; box-shadow: var(--shadow);
  transition: border-color .2s;
}
.search-bar input:focus { border-color: var(--accent); }

/* ── Grid de recetas ────────────────────── */
.recipes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .9rem;
}

.recipe-card {
  background: var(--card); border-radius: 14px; padding: 1.1rem;
  box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s, box-shadow .15s;
  display: flex; flex-direction: column; gap: .5rem;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(0,0,0,.12); }
.recipe-card h3 { font-size: 1.05rem; font-weight: 800; line-height: 1.25; color: var(--stone); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.recipe-card .card-metodos { display: flex; gap: .35rem; flex-wrap: wrap; }
.metodo-badge {
  font-size: .72rem; font-weight: 700; color: var(--accent);
  background: var(--accent2); border-radius: 999px; padding: .2rem .55rem;
}
.recipe-card .card-ing-count { font-size: .78rem; color: var(--text2); flex-shrink: 0; white-space: nowrap; }

.empty-state { text-align: center; color: var(--text2); padding: 3rem 1rem; }
.hidden { display: none !important; }

/* ── Modales ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,26,24,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 24px 24px 0 0; box-shadow: 0 8px 48px rgba(0,0,0,.25);
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  padding: 1.75rem 1.5rem 2rem; position: relative;
  animation: slideUp .25s ease;
}
@media (min-width: 640px) {
  .modal { border-radius: 24px; }
}
@keyframes slideUp { from { opacity:0; transform: translateY(24px); } to { opacity:1; transform: translateY(0); } }

.btn-close {
  position: absolute; top: 1.1rem; right: 1.1rem;
  background: var(--snow); border: 1px solid var(--border);
  color: var(--text2); border-radius: 8px; width: 32px; height: 32px;
}

.modal h2 { font-size: 1.4rem; font-weight: 900; margin-bottom: .75rem; padding-right: 2.5rem; color: var(--stone); }

.detail-metodos { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.section-label { font-size: .78rem; font-weight: 800; color: var(--peak); text-transform: uppercase; letter-spacing: .08em; margin: 1.1rem 0 .5rem; }

.ingredient-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.ingredient-list li {
  display: flex; align-items: center; gap: .55rem;
  background: var(--snow); border-radius: 10px; padding: .5rem .7rem;
  font-size: .9rem; color: var(--text);
}
.ingredient-list .ing-emoji { font-size: 1.1rem; }

.instrucciones { white-space: pre-wrap; line-height: 1.55; font-size: .92rem; color: var(--text); }

.detail-admin-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }

/* ── Formularios ────────────────────────── */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; }
.field label { font-size: .78rem; font-weight: 700; color: var(--text2); }

input[type="text"], input[type="search"], textarea {
  background: var(--snow); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: .65rem .85rem;
  font-size: .9rem; width: 100%; outline: none; transition: border-color .2s;
}
input[type="text"]:focus, input[type="search"]:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }

.metodo-checks { display: flex; flex-wrap: wrap; gap: .75rem; }
.metodo-checks label {
  display: flex; align-items: center; gap: .35rem;
  font-size: .85rem; color: var(--text);
  background: var(--snow); border: 1px solid var(--border);
  border-radius: 10px; padding: .45rem .7rem;
}
.metodo-checks input { accent-color: var(--accent); }

.ingredient-suggestions {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-top: -.3rem; max-height: 180px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.ingredient-suggestions .suggestion {
  padding: .55rem .8rem; font-size: .88rem; display: flex; gap: .5rem; align-items: center;
}
.ingredient-suggestions .suggestion:hover { background: var(--snow); cursor: pointer; }

.btn-link {
  background: none; border: none; color: var(--accent);
  font-size: .82rem; font-weight: 700; text-align: left; padding: .3rem 0;
}

.new-product-form {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--snow); border: 1px solid var(--border);
  border-radius: 12px; padding: .75rem; margin-top: .4rem;
}

.selected-ingredients { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.selected-ingredients li {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--snow); border-radius: 10px; padding: .45rem .7rem; font-size: .88rem;
}
.selected-ingredients .btn-remove {
  background: none; border: none; color: var(--danger); font-size: .95rem; padding: 0 .3rem;
}

.btn-primary {
  background: var(--accent); border: none; cursor: pointer;
  color: #fff; font-size: .95rem; font-weight: 800;
  padding: .8rem 1.5rem; border-radius: 10px; width: 100%;
  transition: opacity .2s, transform .1s; margin-top: .25rem;
}
.btn-primary:hover  { opacity: .9; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  background: var(--snow); border: 1px solid var(--border); color: var(--text);
  font-size: .88rem; font-weight: 700; padding: .65rem 1.1rem; border-radius: 10px; flex: 1;
}
.btn-danger {
  background: rgba(231,76,60,.1); border: 1px solid rgba(231,76,60,.3); color: var(--danger);
  font-size: .88rem; font-weight: 700; padding: .65rem 1.1rem; border-radius: 10px; flex: 1;
}

.msg-error {
  background: rgba(231,76,60,.1); border: 1px solid rgba(231,76,60,.3); color: var(--danger);
  padding: .6rem 1rem; border-radius: 8px; font-size: .84rem; font-weight: 600;
  text-align: center; margin-top: .75rem; display: none;
}

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--stone); color: #fff;
  padding: .7rem 1.2rem; border-radius: 999px; font-size: .88rem; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 200;
}
