:root {
  --bg-primary: #FAF8F5;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F2EDE4;
  --text-main: #141413;
  --text-muted: #726E65;
  --border-color: #E5DFD5;
  --accent-black: #1E1E1C;
  --accent-gold: #C09A4D;
  --accent-danger: #D9534F;
  --accent-success: #2E7D32;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(20, 20, 19, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 19, 0.08);
  --transition: 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   1. PANTALLA DEDICADA DE AUTENTICACIÓN (Login / Registro / Reset)
   ========================================================================== */
#auth-screen-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: 30px 24px;
  overflow-y: auto;
  transition: opacity var(--transition), transform var(--transition);
}
#auth-screen-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
}
.auth-header {
  text-align: center;
  margin-bottom: 28px;
  margin-top: 20px;
}
.auth-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.auth-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}
.auth-nav {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}
.form-group {
  margin-bottom: 15px;
  position: relative;
}
.form-group label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 5px;
  color: var(--text-muted);
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  background: var(--bg-primary);
  transition: border-color var(--transition);
  color: var(--text-main);
}
.form-group input:focus {
  border-color: var(--text-main);
}
.validation-hint {
  font-size: 11px;
  margin-top: 4px;
  display: block;
}
.validation-hint.valid { color: var(--accent-success); }
.validation-hint.invalid { color: var(--accent-danger); }

.btn-auth-submit {
  width: 100%;
  padding: 14px;
  background: var(--accent-black);
  color: #FFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.auth-forgot-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}

/* ==========================================================================
   2. CONTENEDOR SLIDER SPA
   ========================================================================== */
#app-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100vh - 68px);
  overflow: hidden;
}
.screens-slider {
  display: flex;
  width: 500%;
  height: 100%;
  transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}
.screen {
  width: 20%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 85px 16px;
  -webkit-overflow-scrolling: touch;
}
.screen-header {
  margin-bottom: 18px;
}
.screen-title {
  font-size: 24px;
  font-weight: 700;
}
.screen-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Barra de Búsqueda y Botón Filtros */
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrapper input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 16px 12px 38px;
  font-size: 14px;
  border-radius: var(--radius-md);
  outline: none;
}
.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
}
.btn-filter {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  position: relative;
}
.btn-filter.active::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--accent-gold);
  border-radius: 50%;
}

/* ==========================================================================
   3. HOME (Filas Horizontales - Sin Porciones)
   ========================================================================== */
.brand-logo-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.brand-logo-top .logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.user-tag {
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}
.shelf-section {
  margin-bottom: 26px;
}
.shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.shelf-header h3 {
  font-size: 17px;
}
.shelf-more-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
}
.shelf-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.shelf-carousel::-webkit-scrollbar { display: none; }

.recipe-card-horizontal {
  flex: 0 0 160px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.recipe-card-horizontal img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: var(--bg-subtle);
}
.recipe-card-horizontal .card-info {
  padding: 10px;
}
.card-tags-line {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin: 4px 0 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   4. BUSCADOR (14 recetas por pág + Pro Tools primero)
   ========================================================================== */
.search-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.search-recipe-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.search-recipe-card img {
  width: 100%;
  height: 115px;
  object-fit: cover;
  background: var(--bg-subtle);
}
.search-recipe-card .card-content {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.pro-highlight-card {
  border: 1.5px solid var(--text-main);
  position: relative;
}
.pro-badge-top {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--text-main);
  color: #FFF;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}
.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}
.page-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   5. SELECTOR VISUAL TIPO PILLS (Para Bonos y Bóveda Pro)
   ========================================================================== */
.pills-selector-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.pills-selector-container::-webkit-scrollbar { display: none; }
.pill-item {
  flex: 0 0 auto;
  padding: 9px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.pill-item.active {
  background: var(--accent-black);
  color: #FFF;
  border-color: var(--accent-black);
}

.pro-display-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   6. FICHA DE RECETA: 2 TARJETAS DE TIEMPO + INGREDIENTES/PASOS CON FASES
   ========================================================================== */
#recipe-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow-y: auto;
  padding-bottom: 60px;
}
#recipe-modal.open { transform: translateY(0); }
.recipe-hero {
  position: relative;
  width: 100%;
  height: 260px;
}
.recipe-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.recipe-top-nav {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
}
.round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.recipe-body {
  padding: 20px 18px;
}

/* Dos tarjetas independientes para preparación y cocción */
.time-cards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 20px 0;
}
.time-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}
.time-card .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.time-card .val {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

/* Sub-secciones de Ingredientes y Pasos */
.recipe-subheading {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin: 14px 0 8px 0;
  letter-spacing: 0.03em;
}
.ingredient-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  margin-bottom: 12px;
}
.ingredient-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--bg-subtle);
  font-size: 13px;
}
.ingredient-line:last-child { border-bottom: none; }
.btn-add-ing {
  background: var(--bg-subtle);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 700;
}

/* Pasos con Checkbox sincronizado */
.step-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
  cursor: pointer;
  transition: opacity var(--transition);
}
.step-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--text-main);
}
.step-item.is-completed {
  opacity: 0.55;
}
.step-item.is-completed .step-text {
  text-decoration: line-through;
}

/* ==========================================================================
   7. CALENDARIO Y SÚPER MANUAL
   ========================================================================== */
.super-tabs {
  display: flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
}
.super-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.super-tab.active {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* Calendario */
.calendar-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
}
.cal-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 12px;
}
.cal-day-cell {
  padding: 8px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
}
/* Distinción entre Hoy y Seleccionado */
.cal-day-cell.is-today {
  border: 1.5px solid var(--text-main);
  font-weight: 700;
}
.cal-day-cell.is-selected {
  background: var(--text-main) !important;
  color: #FFF !important;
  font-weight: 700;
}
.cal-day-cell.has-recipe::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent-gold);
  border-radius: 50%;
}

/* Tarjetas de comidas programadas separadas del botón */
.scheduled-recipe-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.btn-add-meal-slot {
  width: 100%;
  padding: 12px;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Lista de Súper Manual */
.manual-item-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.manual-item-form input {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-primary);
  outline: none;
}
.btn-add-manual {
  background: var(--text-main);
  color: #FFF;
  border: none;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Bottom Bar */
#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 68px;
  background: rgba(250, 248, 245, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  width: 20%;
}
.nav-btn.active { color: var(--text-main); }
.nav-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Modales */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(20, 20, 19, 0.45);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 360px;
}

#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: var(--text-main);
  color: #FFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 500;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }