
:root {
  --bg: #faf8f5;
  --bg-elevated: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-tertiary: #999999;
  --border: #e8e4df;
  --border-light: #f0ede8;
  --surface: #f5f2ee;
  --surface-hover: #ede9e3;
  --accent: #c17f4e;
  --accent-light: #f5e6d3;
  --accent-dark: #a06a3f;
  --danger: #c9372d;
  --success: #2d7d46;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --bg-elevated: #1a1a1a;
    --text: #f0ebe5;
    --text-secondary: #b0a99f;
    --text-tertiary: #6b655d;
    --border: #2a2a2a;
    --border-light: #222222;
    --surface: #1c1c1c;
    --surface-hover: #252525;
    --accent: #d4a574;
    --accent-light: #3d2e1f;
    --accent-dark: #e8c9a0;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ===== VISTAS ===== */
.view { display: none; }
.view.active { display: block; animation: viewIn .35s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px);} to { opacity: 1; transform: none;} }

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  padding-top: calc(20px + env(safe-area-inset-top));
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(193,127,78,0.25);
}
.app-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.header-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
}
.btn-fab {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(193,127,78,0.35);
  transition: all .2s cubic-bezier(0.22, 1, 0.36, 1);
}
.btn-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(193,127,78,0.45); }
.btn-fab:active { transform: scale(0.95); }

/* ===== BÚSQUEDA ===== */
.search-wrap { margin-bottom: 20px; }
.search-box {
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 14px 16px 14px 46px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  font-size: 16px;
  outline: none;
  color: var(--text);
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ===== FILTROS ===== */
.filter-section { margin-bottom: 18px; }
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.filter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}
.chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(193,127,78,0.3);
}
.chip-emoji { font-size: 15px; }

/* ===== GRID RECETAS ===== */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding-bottom: 20px;
}
@media (min-width: 560px) {
  .recipes-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}

.recipe-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all .25s cubic-bezier(0.22, 1, 0.36, 1);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  position: relative;
}
.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.recipe-card:active { transform: scale(0.97); }

.recipe-img-wrap {
  width: 100%; height: 150px;
  position: relative;
  overflow: hidden;
}
.recipe-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.recipe-card:hover .recipe-img-wrap img { transform: scale(1.05); }

.recipe-img-placeholder {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--surface), var(--border));
  display: flex; align-items: center; justify-content: center;
}
.recipe-img-placeholder svg {
  width: 36px; height: 36px;
  color: var(--text-tertiary);
  opacity: 0.5;
}

.recipe-time-badge {
  position: absolute;
  top: 10px; left: 10px;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-body { padding: 14px; }
.recipe-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
}
.recipe-meta-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.recipe-type-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== DETALLE ===== */
.detail-hero {
  position: relative;
  width: 100%;
  height: 320px;
  margin: -16px -16px 0;
  width: calc(100% + 32px);
  background: linear-gradient(135deg, var(--surface), var(--border));
  overflow: hidden;
}
.detail-hero img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.detail-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}
.btn-back-float {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: all .2s ease;
}
.btn-back-float:hover { background: rgba(0,0,0,0.5); }
.detail-hero-actions {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}
.btn-hero-action {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
}
.btn-hero-action:hover { background: rgba(0,0,0,0.5); }

.detail-body {
  padding: 24px 0 40px;
}
.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.detail-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.detail-tags-row {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.detail-tag {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1.5px solid transparent;
}
.detail-tag.time {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.section { margin-bottom: 32px; }
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.section-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.section h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 15px;
  transition: background .15s ease;
}
.ingredient-item:last-child { border-bottom: none; }
.ingredient-item:hover { background: var(--surface); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--radius-sm); }
.ingredient-check {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s ease;
}
.ingredient-check:hover { border-color: var(--accent); }
.ingredient-check.checked {
  background: var(--success);
  border-color: var(--success);
}
.ingredient-check.checked svg { display: block; }
.ingredient-check svg { display: none; width: 14px; height: 14px; color: #fff; }
.ingredient-text { transition: all .15s ease; }
.ingredient-text.checked { text-decoration: line-through; color: var(--text-tertiary); }

.step-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.step-item:last-child { border-bottom: none; }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(193,127,78,0.25);
}
.step-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
  padding-top: 4px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .3s ease;
}
.modal-overlay.open {
  display: flex;
  opacity: 1;
}
.modal-sheet {
  background: var(--bg-elevated);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0 20px 32px;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}
.modal-drag-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 12px auto 8px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 4px;
}
.modal-header h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.btn-icon-ghost {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.btn-icon-ghost:hover { background: var(--surface); color: var(--text); }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 2px;
}
.tab {
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-tertiary);
  position: relative;
  font-weight: 500;
  transition: color .2s ease;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text-secondary); background: var(--surface); }
.tab.active {
  color: var(--accent);
  font-weight: 600;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 2.5px;
  background: var(--accent);
  border-radius: 2px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }

/* ===== IMAGE UPLOAD ===== */
.image-upload-area {
  position: relative;
  width: 100%;
  height: 180px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: all .2s ease;
  margin-bottom: 20px;
}
.image-upload-area:hover, .image-upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.image-upload-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
  padding: 20px;
  text-align: center;
}
.image-upload-placeholder span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.image-upload-placeholder small {
  font-size: 12px;
  color: var(--text-tertiary);
}
.image-upload-placeholder svg {
  color: var(--text-tertiary);
  opacity: 0.6;
}
.image-preview {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
.image-preview.show { display: block; }
.btn-change-image {
  position: absolute;
  bottom: 10px; right: 10px;
  padding: 6px 14px;
  border-radius: 100px;
  border: none;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  z-index: 5;
}

/* ===== FORM ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.form-group label small {
  font-weight: 400;
  color: var(--text-tertiary);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  font-size: 16px;
  outline: none;
  color: var(--text);
  transition: all .2s ease;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-tertiary); }
.form-group textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(193,127,78,0.3);
}
.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(193,127,78,0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-loader {
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg);} }

/* ===== MIC ===== */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px dashed var(--border);
}
.mic-btn {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(193,127,78,0.35);
  transition: all .3s ease;
}
.mic-btn:hover { transform: scale(1.08); }
.mic-btn.recording {
  background: linear-gradient(135deg, var(--danger), #a02820);
  box-shadow: 0 4px 20px rgba(201,55,45,0.4);
  animation: micPulse 1.5s ease infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(201,55,45,0.4); }
  50% { box-shadow: 0 4px 30px rgba(201,55,45,0.6), 0 0 0 12px rgba(201,55,45,0.1); }
}
.mic-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all .3s ease;
}
.mic-btn.recording .mic-ring {
  border-color: rgba(201,55,45,0.3);
  animation: ringPulse 1.5s ease infinite;
}
@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.5; }
}
.mic-label {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text);
  color: var(--bg);
  padding: 14px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all .4s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== EMPTY ===== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-size: 36px;
}
.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  line-height: 1.5;
}
