:root {
  --red: #E30613;
  --red-dark: #c20510;
  --yellow: #FFD100;
  --dark: #1A1A1A;
  --bg: #faf8f7;
  --green: #1aa563;
  --green-dark: #157a49;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Nunito', sans-serif; color: var(--dark); }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 8px; }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--red) var(--p, 40%), #f0e2e2 var(--p, 40%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; height: 26px; width: 26px; margin-top: -9px; border-radius: 50%; background: #fff; border: 4px solid var(--red); box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; }
input[type=range]::-moz-range-track { height: 8px; border-radius: 8px; background: #f0e2e2; }
input[type=range]::-moz-range-progress { height: 8px; border-radius: 8px; background: var(--red); }
input[type=range]::-moz-range-thumb { height: 26px; width: 26px; border-radius: 50%; background: #fff; border: 4px solid var(--red); box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes bounceDots { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

#root { font-family: 'Nunito', sans-serif; color: var(--dark); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

.d1-logo { width: 42px; height: 42px; flex: none; display: block; }
.d1-logo--lg { width: 76px; height: 76px; }
.d1-logo--md { width: 48px; height: 48px; }

/* ===== LANDING ===== */
.landing { flex: 1; display: flex; flex-direction: column; background: radial-gradient(120% 90% at 50% -10%, #ffe7e8 0%, #faf8f7 55%); }
.landing-inner { flex: 1; max-width: 980px; width: 100%; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.landing-logo-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; animation: floatY 4s ease-in-out infinite; }
.landing-badge { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #FFE9A8; padding: 7px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; color: #8a6d00; margin-bottom: 22px; box-shadow: 0 4px 16px rgba(0,0,0,.04); }
.dot-yellow { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.landing-title { font-weight: 900; font-size: clamp(38px, 7vw, 64px); line-height: 1.02; letter-spacing: -1.5px; margin: 0 0 18px; max-width: 760px; }
.accent-red { color: var(--red); }
.landing-sub { font-size: clamp(16px, 2.4vw, 20px); color: #555; font-weight: 600; max-width: 560px; margin: 0 0 36px; line-height: 1.5; }
.btn-cta-landing { background: var(--red); color: #fff; border: none; font-family: 'Nunito'; font-weight: 900; font-size: 20px; padding: 18px 40px; border-radius: 16px; cursor: pointer; box-shadow: 0 12px 30px rgba(227,6,19,.32); letter-spacing: .2px; }
.btn-cta-landing:hover { background: var(--red-dark); }
.landing-features { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 48px; max-width: 720px; }
.feature-card { flex: 1; min-width: 200px; background: #fff; border: 1px solid #eee; border-radius: 16px; padding: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.04); text-align: left; }
.feature-emoji { font-size: 24px; margin-bottom: 8px; }
.feature-title { font-weight: 900; font-size: 16px; margin-bottom: 4px; }
.feature-desc { font-weight: 600; font-size: 14px; color: #888; }

/* ===== HEADER ===== */
.topbar-disclaimer { background: #1A1A1A; color: #f5f5f5; font-weight: 700; font-size: 11.5px; letter-spacing: .2px; text-align: center; padding: 6px 14px; line-height: 1.35; }
.landing .topbar-disclaimer { border-radius: 0 0 12px 12px; }
.app-header { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid #eee; box-shadow: 0 1px 10px rgba(0,0,0,.03); }
.header-row { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.header-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.header-title { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.header-app-name { font-weight: 900; font-size: 20px; letter-spacing: -.3px; }
.header-app-sub { font-weight: 700; font-size: 11px; color: var(--red); letter-spacing: 1.5px; text-transform: uppercase; }
.header-spacer { flex: 1; }
.header-chip { display: flex; align-items: center; gap: 7px; background: #FFF8DB; border: 1px solid #FFE9A8; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 12px; color: #8a6d00; white-space: nowrap; flex: none; }
.dot-yellow-sm { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }

.progress-wrap { max-width: 1120px; margin: 0 auto; padding: 2px 16px 14px; overflow-x: auto; }
.progress-steps { display: flex; align-items: center; gap: 6px; min-width: 520px; }
.progress-step { display: flex; align-items: center; flex: 1; gap: 6px; }
.progress-btn { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; font-family: Nunito; padding: 4px 2px; }
.progress-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; color: #fff; transition: all .2s; }
.progress-label { font-size: 14px; white-space: nowrap; }
.progress-connector { flex: 1; height: 3px; border-radius: 3px; }

/* ===== MAIN ===== */
.main { max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px 16px 190px; }
.step-panel.hidden { display: none; }

/* ===== STEP 1 ===== */
.step1-inner { max-width: 680px; margin: 0 auto; }
.step1-title { font-weight: 900; font-size: clamp(26px, 6.5vw, 32px); margin: 0 0 6px; letter-spacing: -.5px; }
.step1-sub { font-size: 16px; color: #666; margin: 0 0 28px; font-weight: 600; }
.card { background: #fff; border: 1px solid #eee; border-radius: 18px; padding: 22px; box-shadow: 0 4px 16px rgba(0,0,0,.04); margin-bottom: 16px; }
.card-label { display: block; font-weight: 800; font-size: 15px; margin-bottom: 12px; }

.budget-row { display: flex; align-items: center; border: 2px solid #eee; border-radius: 14px; overflow: hidden; max-width: 320px; }
.budget-prefix { background: var(--red); color: #fff; font-weight: 900; font-size: 22px; padding: 14px 18px; }
.budget-input { border: none; outline: none; font-family: 'Nunito'; font-weight: 800; font-size: 22px; padding: 12px 14px; width: 100%; color: var(--dark); }
.budget-helper { margin-top: 8px; font-weight: 700; font-size: 14px; color: #888; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-btn { min-width: 46px; padding: 10px 16px; border-radius: 12px; font-family: Nunito; font-weight: 800; font-size: 15px; cursor: pointer; transition: all .15s ease; border: 2px solid #eee; background: #fff; color: #555; }
.pill-btn.active { border-color: var(--red); background: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(227,6,19,.25); }

.cal-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.cal-value { font-weight: 900; font-size: 24px; color: var(--red); }
.cal-unit { font-size: 14px; color: #888; }
.cal-scale { display: flex; justify-content: space-between; font-weight: 700; font-size: 12px; color: #aaa; margin-top: 8px; }

.diet-pill { padding: 10px 16px; border-radius: 999px; font-family: Nunito; font-weight: 800; font-size: 14px; cursor: pointer; transition: all .15s ease; border: 2px solid #eee; background: #fff; color: #555; }
.diet-pill.active { border-color: var(--yellow); background: var(--yellow); color: #5a4a00; }

.feasibility-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.feasibility-label { font-weight: 800; font-size: 15px; }
.feasibility-total { font-weight: 900; font-size: 22px; }
.feasibility-sub { font-weight: 700; font-size: 13px; color: #888; margin-top: 2px; }
.feasibility-ok { display: flex; align-items: center; gap: 8px; margin-top: 14px; background: #eaf8f0; border: 1px solid #c5ebd6; border-radius: 12px; padding: 12px 14px; }
.feasibility-ok-icon { font-weight: 900; color: var(--green); font-size: 18px; }
.feasibility-ok-text { font-weight: 800; font-size: 14px; color: var(--green-dark); }
.feasibility-low { margin-top: 14px; background: #fdeaea; border: 1px solid #f6c9cc; border-radius: 12px; padding: 14px; }
.feasibility-low-row { display: flex; align-items: flex-start; gap: 9px; }
.feasibility-low-icon { font-weight: 900; color: var(--red); font-size: 18px; line-height: 1; }
.feasibility-low-title { font-weight: 900; font-size: 14px; color: var(--red-dark); margin-bottom: 2px; }
.feasibility-low-text { font-weight: 700; font-size: 13px; color: #9a4044; line-height: 1.45; }
.feasibility-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-fix-budget { border: none; font-family: Nunito; font-weight: 800; font-size: 13px; padding: 10px 14px; border-radius: 10px; cursor: pointer; background: var(--red); color: #fff; }
.btn-fix-days { border: 2px solid var(--red); font-family: Nunito; font-weight: 800; font-size: 13px; padding: 8px 14px; border-radius: 10px; cursor: pointer; background: #fff; color: var(--red); }

.btn-generate { width: 100%; background: var(--red); color: #fff; border: none; font-family: 'Nunito'; font-weight: 900; font-size: 19px; padding: 18px; border-radius: 16px; cursor: pointer; box-shadow: 0 8px 22px rgba(227,6,19,.28); letter-spacing: .2px; }
.btn-generate:hover { background: var(--red-dark); }

/* ===== STEP 2 ===== */
.step2-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.step2-title { font-weight: 900; font-size: clamp(24px, 6vw, 30px); margin: 0 0 4px; letter-spacing: -.5px; }
.step2-sub { font-size: 15px; color: #666; margin: 0; font-weight: 600; }
.btn-go-shopping { background: var(--dark); color: #fff; border: none; font-family: 'Nunito'; font-weight: 800; font-size: 15px; padding: 12px 20px; border-radius: 12px; cursor: pointer; }
.btn-go-plan { background: var(--red); color: #fff; border: none; font-family: 'Nunito'; font-weight: 800; font-size: 15px; padding: 12px 20px; border-radius: 12px; cursor: pointer; white-space: nowrap; }
.btn-go-plan:hover { background: var(--red-dark); }
.step3-head-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.plan-budget-note { display: flex; align-items: center; gap: 10px; background: #fff7e0; border: 1px solid #FFE9A8; color: #6b5600; font-weight: 700; font-size: 14px; line-height: 1.4; padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; }
.plan-budget-warn { display: flex; align-items: center; gap: 10px; background: #fdeaea; border: 1px solid #f5b5b5; color: #9a1414; font-weight: 700; font-size: 14px; line-height: 1.4; padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; }
.plan-cal-note { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; line-height: 1.4; padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; }
.plan-cal-note.ok { background: #e9f8f0; border: 1px solid #b6e6cf; color: #15784a; }
.plan-cal-note.warn { background: #fdeaea; border: 1px solid #f5b5b5; color: #9a1414; }
.list-aviso { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; line-height: 1.45; padding: 13px 16px; border-radius: 14px; margin-bottom: 18px; }
.list-aviso.ok { background: #e9f8f0; border: 1px solid #b6e6cf; color: #15784a; }
.list-aviso.warn { background: #fff7e0; border: 1px solid #FFE9A8; color: #6b5600; }
.recipe-wip { display: flex; gap: 8px; background: #fff7e0; border: 1px solid #FFE9A8; color: #6b5600; font-weight: 700; font-size: 13px; line-height: 1.4; padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; }
.plan-budget-icon { font-size: 20px; flex: none; }
.item-tienda { display: inline-block; background: #fff0d0; color: #8a6d00; font-weight: 800; font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: middle; }
.plan-row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.day-card { flex: none; width: 300px; background: #fff; border: 1px solid #eee; border-radius: 18px; box-shadow: 0 4px 16px rgba(0,0,0,.04); overflow: hidden; display: flex; flex-direction: column; }
.day-card-head { background: var(--red); color: #fff; padding: 12px 16px; display: flex; align-items: baseline; justify-content: space-between; }
.day-card-name { font-weight: 900; font-size: 16px; }
.day-card-num { font-weight: 700; font-size: 12px; opacity: .85; }
.day-card-meals { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.meal-card { border: 1px solid #f0f0f0; border-radius: 13px; padding: 12px; background: #fcfbfa; }
.meal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.meal-type { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #999; }
.meal-cal-badge { background: var(--yellow); color: #5a4a00; font-weight: 900; font-size: 11px; padding: 3px 9px; border-radius: 999px; }
.meal-name { font-weight: 800; font-size: 15px; line-height: 1.25; margin-bottom: 8px; }
.meal-bottom { display: flex; align-items: center; justify-content: space-between; }
.meal-cost { font-weight: 900; font-size: 15px; color: var(--dark); }
.meal-recipe-link { color: var(--red); font-weight: 800; font-size: 13px; cursor: pointer; text-decoration: none; background: none; border: none; font-family: Nunito; padding: 0; }
.day-card-foot { border-top: 1px dashed #eee; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; background: #fff; }
.day-card-foot-label { font-weight: 700; font-size: 13px; color: #666; }
.day-card-foot-value { font-weight: 900; font-size: 17px; color: var(--red); }

/* ===== STEP 3 ===== */
.step3-inner { max-width: 780px; margin: 0 auto; }
.step3-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.step3-title { font-weight: 900; font-size: clamp(24px, 6vw, 30px); margin: 0 0 4px; letter-spacing: -.5px; }
.step3-sub { font-size: 15px; color: #666; margin: 0; font-weight: 600; }
.btn-copy { border: none; font-family: Nunito; font-weight: 800; font-size: 14px; padding: 11px 18px; border-radius: 12px; cursor: pointer; white-space: nowrap; transition: all .15s; background: var(--dark); color: #fff; }
.btn-copy.copied { background: var(--green); }
.cat-list { display: flex; flex-direction: column; gap: 18px; }
.cat-card { background: #fff; border: 1px solid #eee; border-radius: 18px; box-shadow: 0 4px 16px rgba(0,0,0,.04); overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #f3f3f3; }
.cat-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--red); }
.cat-name { font-weight: 900; font-size: 16px; }
.cat-count { font-weight: 700; font-size: 13px; color: #aaa; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #f6f6f6; cursor: pointer; transition: background .15s; }
.item-row.have { background: #fafafa; }
.item-row:last-child { border-bottom: none; }
.item-box { flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid #ddd; background: #fff; color: #fff; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.item-box.have { border-color: var(--green); background: var(--green); }
.item-name-col { flex: 1; min-width: 0; }
.item-name { font-weight: 800; font-size: 15px; color: var(--dark); }
.item-name.have { text-decoration: line-through; color: #bbb; }
.item-qty { font-weight: 700; font-size: 12px; color: #aaa; }
.item-sub { flex: none; font-weight: 900; font-size: 15px; white-space: nowrap; color: var(--dark); }
.item-sub.have { color: #ccc; text-decoration: line-through; }

.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid #eee; box-shadow: 0 -4px 24px rgba(0,0,0,.08); }
.sticky-bar-inner { max-width: 780px; margin: 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.sticky-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sticky-total-label { font-weight: 700; font-size: 12px; color: #888; }
.sticky-total-value { font-weight: 900; font-size: clamp(20px, 5vw, 24px); margin-left: 6px; }
.sticky-budget-label { font-weight: 700; font-size: 11px; color: #888; text-align: right; }
.sticky-budget-value { font-weight: 900; font-size: 15px; text-align: right; }
.sticky-bar-track { height: 12px; background: #f0eeed; border-radius: 999px; overflow: hidden; }
.sticky-bar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.sticky-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.sticky-budget-msg { font-weight: 800; font-size: 13px; }

/* ===== FOOTER ===== */
.footer { margin-top: auto; padding: 22px 20px 26px; text-align: center; border-top: 1px solid #f0eeed; background: #fff; }
.footer-line { font-weight: 800; font-size: 14px; color: #777; }
.footer-name { color: var(--dark); }
.footer-brand { color: var(--red); }
.footer-heart { color: var(--red); }
.footer-sub { font-weight: 700; font-size: 12px; color: #bbb; margin-top: 4px; }

/* ===== LOADING ===== */
.loading-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(255,255,255,.96); display: flex; flex-direction: column; align-items: center; justify-content: center; animation: overlayIn .2s ease; }
.loading-spinner-wrap { position: relative; width: 96px; height: 96px; margin-bottom: 28px; }
.loading-spinner { position: absolute; inset: 0; border: 6px solid #f3dcdd; border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-logo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; animation: pulse 1.2s ease-in-out infinite; }
.loading-msg { font-weight: 900; font-size: 20px; color: var(--dark); margin-bottom: 14px; }
.loading-dots { display: flex; gap: 7px; }
.loading-dots span { width: 10px; height: 10px; border-radius: 50%; display: block; animation: bounceDots 1.4s ease-in-out infinite; }
.loading-dots span:nth-child(1) { background: var(--red); }
.loading-dots span:nth-child(2) { background: var(--yellow); animation-delay: .2s; }
.loading-dots span:nth-child(3) { background: var(--red); animation-delay: .4s; }

/* ===== RECIPE MODAL ===== */
.recipe-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20,10,10,.45); display: flex; justify-content: flex-end; animation: overlayIn .25s ease; }
.recipe-panel { width: min(480px, 100%); height: 100%; background: #fff; overflow-y: auto; animation: slideIn .3s cubic-bezier(.2,.8,.2,1); box-shadow: -10px 0 40px rgba(0,0,0,.2); }
.recipe-header { position: sticky; top: 0; background: var(--red); color: #fff; padding: 20px 22px; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.recipe-meta { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: .85; }
.recipe-name { font-weight: 900; font-size: 24px; margin: 4px 0 0; line-height: 1.1; }
.recipe-close-btn { flex: none; background: rgba(255,255,255,.2); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; font-weight: 900; cursor: pointer; line-height: 1; }
.recipe-body { padding: 22px; }
.recipe-nutrition { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 24px; }
.nut-cell { border-radius: 12px; padding: 12px 8px; text-align: center; background: #fcfbfa; border: 1px solid #f0f0f0; }
.nut-cell.cal { background: #FFF8DB; border-color: #FFE9A8; }
.nut-value { font-weight: 900; font-size: 18px; color: var(--dark); }
.nut-cell.cal .nut-value { color: #8a6d00; }
.nut-label { font-weight: 700; font-size: 11px; color: #aaa; }
.nut-cell.cal .nut-label { color: #a98c2e; }
.section-title { font-weight: 900; font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.dot-red { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.recipe-ingredients { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.ing-row { display: flex; align-items: center; gap: 10px; background: #fcfbfa; border: 1px solid #f0f0f0; border-radius: 10px; padding: 10px 12px; }
.dot-yellow-tiny { width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); flex: none; }
.ing-text { font-weight: 700; font-size: 14px; }
.recipe-steps { display: flex; flex-direction: column; gap: 14px; }
.step-row { display: flex; gap: 12px; }
.step-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.step-text { margin: 2px 0 0; font-weight: 600; font-size: 14px; line-height: 1.5; color: #333; }
