:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface2: #F0EDE6;
  --border: #E2DDD5;
  --text: #1A1814;
  --text-muted: #7A746A;
  --text-faint: #B0AA9F;
  --accent: #2D5A3D;
  --accent-light: #E8F2EB;
  --accent-mid: #4A8C60;
  --green: #3B7A4F;
  --green-bg: #EAF4ED;
  --yellow: #8A6D20;
  --yellow-bg: #FDF5DC;
  --red: #8A2B2B;
  --red-bg: #FCEAEA;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 99px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247,245,240,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); }

.nav-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
}

/* ── HERO ── */
.hero {
  padding: 5rem 2rem 3rem;
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid rgba(45,90,61,0.15);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-tag::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 1rem;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-sub {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 2.5rem;
  font-weight: 300;
  line-height: 1.7;
}

/* ── MAIN LAYOUT ── */
.main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 700px) {
  .main { grid-template-columns: 1fr; }
  .hero { padding: 3rem 1.5rem 2rem; }
  nav { padding: 0 1.25rem; }
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 15px; height: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── PROFILE FIELDS ── */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.field input, .field select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}

.field input:focus, .field select:focus {
  border-color: var(--accent-mid);
  background: var(--surface);
}

.field-full { grid-column: 1 / -1; }

/* ── OBJETIVO PILLS ── */
.objetivo-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 7px 6px;
  font-size: 11.5px;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-weight: 500;
  line-height: 1.3;
}

.pill-btn:hover { border-color: var(--accent-mid); color: var(--accent); }
.pill-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ── INGREDIENTS ── */
.ing-headers {
  display: grid;
  grid-template-columns: 1fr 72px 82px 28px;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding: 0 2px;
}

.ing-row {
  display: grid;
  grid-template-columns: 1fr 72px 82px 28px;
  gap: 6px;
  margin-bottom: 7px;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.ing-row input, .ing-row select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.ing-row input:focus, .ing-row select:focus {
  border-color: var(--accent-mid);
  background: var(--surface);
}

.del-btn {
  width: 28px; height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.del-btn:hover { background: var(--red-bg); color: var(--red); }

.add-ing-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: all 0.15s;
}

.add-ing-btn:hover {
  border-color: var(--accent-mid);
  color: var(--accent);
  background: var(--accent-light);
}

/* ── ANALYZE BTN ── */
.analyze-btn {
  width: 100%;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.analyze-btn:hover { background: #234d33; transform: translateY(-1px); }
.analyze-btn:active { transform: translateY(0); }
.analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── LOADING ── */
.loading-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESULTS ── */
.result-section { margin-top: 2rem; }

.semaforo-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}

@media (max-width: 500px) {
  .semaforo-strip { grid-template-columns: repeat(2, 1fr); }
}

.s-cell {
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}

.s-cell.verde { background: var(--green-bg); }
.s-cell.amarillo { background: var(--yellow-bg); }
.s-cell.rojo { background: var(--red-bg); }

.s-cell .s-num {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  margin-bottom: 3px;
}

.s-cell.verde .s-num { color: var(--green); }
.s-cell.amarillo .s-num { color: var(--yellow); }
.s-cell.rojo .s-num { color: var(--red); }

.s-cell .s-lbl {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.s-cell.verde .s-lbl { color: var(--green); }
.s-cell.amarillo .s-lbl { color: var(--yellow); }
.s-cell.rojo .s-lbl { color: var(--red); }

.overall-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 1rem;
}

.overall-badge.verde { background: var(--green-bg); color: var(--green); }
.overall-badge.amarillo { background: var(--yellow-bg); color: var(--yellow); }
.overall-badge.rojo { background: var(--red-bg); color: var(--red); }

.macro-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.macro-row:last-child { border-bottom: none; }
.macro-row .m-name { color: var(--text-muted); }
.macro-row .m-val { font-weight: 500; }

.porcion-highlight {
  background: var(--accent-light);
  border: 1px solid rgba(45,90,61,0.15);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.porcion-highlight .ph-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 4px;
}

.porcion-highlight .ph-sub {
  font-size: 13px;
  color: var(--accent-mid);
}

.consejos-list {
  list-style: none;
  padding: 0;
}

.consejos-list li {
  font-size: 13.5px;
  color: var(--text-muted);
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  line-height: 1.5;
}

.consejos-list li:last-child { border-bottom: none; }

.consejos-list li::before {
  content: '→';
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 500;
}

.error-msg {
  background: var(--red-bg);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  margin-top: 1rem;
}

/* ── SIDEBAR STICKY ── */
.sidebar { position: sticky; top: 72px; }

/* ── FOOTER ── */
footer {
  text-align: center;
  padding: 2rem;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ── DIVIDER ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.section-mini-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

a {
    all: unset;
    cursor: pointer;
}