/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --dark: #0b1220;
  --dark-2: #16213a;
  --lime: #c8f031;
  --lime-ink: #1a2b00;
  --carbs: #f59e0b;
  --prot: #2563eb;
  --fat: #e11d48;
  --warn-bg: #fff7e6;
  --warn-line: #f5c26b;
  --radius: 18px;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(11, 18, 32, .04), 0 8px 24px rgba(11, 18, 32, .06);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.08; letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid var(--prot); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--lime); color: var(--ink); z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.noscript { background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 1rem; border-radius: 12px; margin-bottom: 1rem; }

/* =============================================================
   4. Header & hero
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 18, 32, .96);
  backdrop-filter: saturate(140%) blur(8px);
  color: #fff;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .55rem; text-decoration: none; font-family: var(--display); font-size: 1.6rem; font-weight: 700; letter-spacing: .01em; }
.logo b { color: var(--lime); font-weight: 800; }
.header-nav { display: none; gap: 1.4rem; font-size: .9rem; }
.header-nav a { text-decoration: none; color: #cbd5e1; transition: color .2s; }
.header-nav a:hover { color: var(--lime); }

.hero {
  background:
    radial-gradient(900px 300px at 85% -20%, rgba(200, 240, 49, .22), transparent 60%),
    linear-gradient(180deg, var(--dark) 0%, var(--dark-2) 100%);
  color: #fff;
  padding: 1.4rem 0 4.6rem;
}
.hero h1 {
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(2.2rem, 7vw, 4rem);
  letter-spacing: .005em;
}
.hero-sub { color: #cbd5e1; margin-top: .4rem; max-width: 62ch; font-size: .98rem; }
.privacy-chip {
  display: inline-flex; align-items: center; gap: .45rem; margin-top: .8rem;
  font-size: .8rem; color: var(--lime); background: rgba(200, 240, 49, .1);
  border: 1px solid rgba(200, 240, 49, .3); padding: .3rem .7rem; border-radius: 999px;
}

/* =============================================================
   5. Components
   ============================================================= */
.tool-wrap { margin-top: -3.6rem; }
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
  margin-bottom: 1.1rem;
}
.tool-main { display: grid; gap: 1.2rem; padding: 0; overflow: hidden; }
.panel { padding: 1.15rem; }
.results-panel { background: linear-gradient(180deg, #fbfcfd, #f5f8fb); border-top: 1px solid var(--line); }
.panel-title {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--display); font-weight: 700; font-size: 1.45rem; text-transform: uppercase; letter-spacing: .01em;
  margin-bottom: .9rem;
}
.step {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--ink); color: var(--lime); font-size: 1rem; font-weight: 800;
}
.card-head { margin-bottom: 1rem; }
.card-head .panel-title { margin-bottom: .3rem; }
.card-sub { color: var(--muted); font-size: .92rem; }

/* Form */
.field { display: block; border: 0; padding: 0; margin: 0 0 .9rem; min-width: 0; }
.field legend, .lbl { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; padding: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.input-unit { position: relative; display: block; }
.input-unit input, select {
  width: 100%; height: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  padding: 0 .75rem; font-size: 1rem; font-weight: 600; transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.input-unit input { padding-right: 2.6rem; }
.input-unit em { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); font-style: normal; font-size: .78rem; color: var(--muted); pointer-events: none; }
select { appearance: none; padding-right: 2.2rem; font-weight: 500; font-size: .95rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; }
.input-unit input:focus, select:focus { outline: none; border-color: var(--prot); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input-unit input:invalid, .input-unit input.is-invalid { border-color: var(--fat); }
.form-error { color: var(--fat); font-size: .88rem; font-weight: 500; }

/* Segmented controls */
.seg { display: grid; gap: .4rem; }
.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-4 { grid-template-columns: repeat(2, 1fr); }
.seg label { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: .35rem .5rem; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
  font-size: .9rem; font-weight: 600; line-height: 1.15; cursor: pointer;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out), color .2s;
}
.seg span small { font-weight: 500; font-size: .7rem; color: var(--muted); }
.seg span:hover { border-color: #94a3b8; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:checked + span small { color: var(--lime); }
.seg input:focus-visible + span { outline: 3px solid var(--prot); outline-offset: 2px; }
#comidas .seg-4 { grid-template-columns: repeat(4, 1fr); }

/* Results */
.big-result { display: flex; flex-direction: column; background: var(--ink); color: #fff; border-radius: 16px; padding: 1rem 1.2rem; position: relative; overflow: hidden; }
.big-result::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(200,240,49,.35), transparent 70%); }
.big-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #cbd5e1; font-weight: 600; }
.big-num { font-family: var(--display); font-size: 1.6rem; font-weight: 700; color: #cbd5e1; line-height: 1; margin-top: .2rem; }
.big-num b { font-size: 3.8rem; color: var(--lime); font-weight: 800; }
.big-meta { font-size: .85rem; color: #cbd5e1; margin-top: .25rem; }
.kcal-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .8rem 0; }
.kcal-row > div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; }
.kcal-row b { font-family: var(--display); font-size: 1.7rem; font-weight: 700; }
.kcal-row small { color: var(--muted); }
.mini-label { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.macros { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: center; justify-items: center; }
.macros .macro-list { width: 100%; }
.donut-wrap canvas { width: 130px; height: 130px; }
.macro-list { list-style: none; padding: 0; display: grid; gap: .45rem; }
.macro-list li { display: grid; grid-template-columns: 12px 1fr auto 3.2rem; align-items: center; gap: .5rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .45rem .65rem; font-size: .9rem; }
.macro-list i { width: 12px; height: 12px; border-radius: 4px; }
.macro-list b { font-family: var(--display); font-size: 1.3rem; font-weight: 700; white-space: nowrap; }
.macro-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.macro-list em { font-style: normal; color: var(--muted); text-align: right; font-size: .85rem; }
.m-carbs i { background: var(--carbs); }
.m-prot i { background: var(--prot); }
.m-fat i { background: var(--fat); }
.note { font-size: .82rem; color: var(--muted); margin-top: .8rem; }
.note.warn { color: #9a3412; background: var(--warn-bg); border: 1px solid var(--warn-line); padding: .5rem .7rem; border-radius: 10px; }

.disclaimer {
  display: flex; gap: .8rem; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: #7c4a03;
  padding: .9rem 1rem; border-radius: 14px; margin-bottom: 1.1rem; font-size: .9rem;
}
.disclaimer svg { flex: none; margin-top: .1rem; }

/* Week */
.week-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; }
.day-card { border: 1.5px solid var(--line); border-radius: 14px; padding: .6rem .65rem; background: #fff; border-top: 5px solid var(--c, #94a3b8); }
.day-card .day-name { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: .9rem; }
.day-card .day-carbs { font-family: var(--display); font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.day-card .day-carbs small { font-size: .85rem; color: var(--muted); font-weight: 600; }
.day-card select { height: 38px; font-size: .82rem; border-radius: 10px; margin-top: .35rem; padding-left: .55rem; }
.day-card .day-kcal { font-size: .75rem; color: var(--muted); }
.chart-box { margin-top: 1rem; position: relative; }
.chart-box canvas { width: 100%; height: 260px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--ink-2); margin-top: .5rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.week-summary { margin-top: .8rem; font-size: .9rem; background: var(--bg); border-radius: 12px; padding: .65rem .85rem; }

/* Meals */
.meal-controls { display: grid; gap: .2rem; }
.day-tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .8rem; scrollbar-width: thin; }
.day-tab { flex: none; padding: .45rem .75rem; border-radius: 999px; border: 1.5px solid var(--line); font-size: .85rem; font-weight: 600; background: #fff; }
.day-tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.day-tab i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.meal-list { display: grid; gap: .5rem; }
.meal-head { font-size: .9rem; color: var(--ink-2); margin-bottom: .2rem; }
.meal-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .3rem .8rem; border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; background: #fff; }
.meal-row.is-pre, .meal-row.is-post { border-color: #f5c26b; background: #fffaf0; }
.meal-name { font-weight: 600; }
.meal-tag { display: inline-block; margin-left: .4rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; padding: .1rem .45rem; border-radius: 999px; background: var(--carbs); color: #fff; font-weight: 700; vertical-align: middle; }
.meal-row.is-post .meal-tag { background: #ea580c; }
.meal-g { font-family: var(--display); font-size: 1.45rem; font-weight: 800; }
.meal-g small { font-size: .8rem; color: var(--muted); font-weight: 600; }
.meal-bar { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.meal-bar span { display: block; height: 100%; background: var(--carbs); border-radius: 99px; transition: width .35s var(--ease-out); }
.meal-food { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }

/* Converter */
.conv-controls { display: grid; gap: 0 .7rem; }
.conv-result { background: var(--ink); color: #fff; border-radius: 16px; padding: 1rem 1.2rem; margin: .2rem 0 .9rem; }
.conv-result .cr-num { font-family: var(--display); font-size: 3rem; font-weight: 800; color: var(--lime); line-height: 1; }
.conv-result .cr-num small { font-size: 1.3rem; color: #cbd5e1; }
.conv-result p { color: #cbd5e1; font-size: .92rem; margin-top: .3rem; }
.conv-result strong { color: #fff; }
.conv-table-wrap summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: .3rem 0; }
.table-scroll { overflow-x: auto; }
.conv-table, .data-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: .5rem; }
.conv-table th, .conv-table td, .data-table th, .data-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.conv-table th, .data-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.conv-table tr.is-sel td { background: #f7fde4; font-weight: 600; }

/* Download */
.download-card { display: grid; gap: 1rem; background: linear-gradient(135deg, #fff 0%, #f7fde4 100%); }
.dl-buttons { display: grid; gap: .6rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 54px; padding: .7rem 1.3rem; border-radius: 14px; font-weight: 700; font-size: 1rem;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), background .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--lime); color: var(--lime-ink); box-shadow: 0 6px 18px rgba(160, 200, 20, .35); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-small { min-height: 42px; font-size: .92rem; }
.dl-status { font-size: .85rem; color: var(--muted); min-height: 1.2em; }

/* Ads (placeholders) */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  border: 2px dashed #b6c0cf; border-radius: 12px; background: repeating-linear-gradient(45deg, #eef1f5, #eef1f5 10px, #e8ecf1 10px, #e8ecf1 20px);
  color: #7b8798; text-align: center;
}
.ad-slot[hidden] { display: none !important; }
.ad-slot span { font-weight: 800; letter-spacing: .2em; font-size: .9rem; }
.ad-slot small { font-size: .72rem; }
.ad-leaderboard { min-height: 100px; margin: .6rem 0 2.2rem; }
.ad-incontent { min-height: 250px; margin: 2rem 0; }
.ad-rect { width: 100%; max-width: 300px; height: 250px; margin: .8rem auto; }
.ad-small { width: 100%; height: 100px; }

.ad-dialog {
  margin: auto; border: 0; border-radius: 18px; padding: 1.4rem 1.2rem 1.2rem; width: min(360px, calc(100% - 32px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35); text-align: center; color: var(--ink);
}
.ad-dialog::backdrop { background: rgba(11, 18, 32, .6); }
.ad-dialog-msg { font-weight: 700; padding-right: 1.4rem; }
.ad-dialog .btn { width: 100%; }
.ad-close {
  position: absolute; top: .45rem; right: .45rem; width: 34px; height: 34px; border-radius: 50%;
  font-size: 1.4rem; line-height: 1; background: var(--bg); color: var(--ink);
}
.ad-close:hover { background: var(--line); }
.ad-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(300px, calc(100% - 32px));
  background: #fff; border-radius: 14px; padding: 2.2rem .6rem .6rem; box-shadow: 0 16px 40px rgba(11, 18, 32, .25);
  border: 1px solid var(--line); animation: toast-in .5s var(--ease-out);
}
.ad-toast::before { content: "Publicidad"; position: absolute; top: .7rem; left: .8rem; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px); } }

/* =============================================================
   6. Content sections
   ============================================================= */
.content-section { padding: 3rem 0; }
.content-section.alt { background: #fff; border-block: 1px solid var(--line); }
.content-section h2 { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: clamp(1.8rem, 4.5vw, 2.6rem); margin-bottom: 1.2rem; }
.prose { max-width: 820px; }
.prose h3 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
.prose p, .prose li { color: var(--ink-2); }
.prose p + p { margin-top: .8rem; }
.formula { background: var(--ink); color: #e2e8f0; border-radius: 12px; padding: .9rem 1rem .9rem 2rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; }
.formula li { color: #e2e8f0; }
.formula b { color: var(--lime); }
.steps { list-style: none; padding: 0; display: grid; gap: 1rem; }
.steps li { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.steps svg { color: var(--prot); margin-bottom: .6rem; }
.steps h3 { font-size: 1.1rem; margin-bottom: .35rem; }
.steps p { color: var(--ink-2); font-size: .95rem; }
.ideas { display: grid; gap: .9rem; }
.idea { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--lime); border-radius: 14px; padding: 1.1rem 1.2rem; }
.idea h3 { font-size: 1.05rem; margin-bottom: .3rem; }
.idea p { color: var(--ink-2); font-size: .94rem; }
#faq details { border-bottom: 1px solid var(--line); padding: .9rem 0; }
#faq summary { cursor: pointer; font-weight: 600; font-size: 1.02rem; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
#faq summary::-webkit-details-marker { display: none; }
#faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--prot); transition: transform .25s var(--ease-out); }
#faq details[open] summary::after { transform: rotate(45deg); }
#faq details p { margin-top: .6rem; }

.site-footer { background: var(--dark); color: #94a3b8; padding: 2rem 0 5rem; font-size: .88rem; }
.site-footer a { color: #e2e8f0; }
.site-footer p + nav, .site-footer nav + p { margin-top: .7rem; }
.footer-disclaimer { max-width: 70ch; }

/* Legal pages */
.legal { padding: 2.5rem 0 4rem; }
.legal h1 { font-family: var(--display); text-transform: uppercase; font-size: 2.4rem; margin-bottom: 1rem; }
.legal h2 { font-size: 1.2rem; margin: 1.5rem 0 .4rem; }
.legal p { color: var(--ink-2); margin-bottom: .6rem; }
.todo { background: #fff3cd; padding: 0 .3rem; border-radius: 4px; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .week-grid { grid-template-columns: repeat(4, 1fr); }
  .seg-4 { grid-template-columns: repeat(4, 1fr); }
  .form-panel .seg-4 { grid-template-columns: repeat(2, 1fr); }
  .dl-buttons { grid-template-columns: 1fr 1fr; }
  .conv-controls { grid-template-columns: 1.3fr 1.3fr 1fr; }
  .macros { grid-template-columns: 150px 1fr; justify-items: stretch; }
  .donut-wrap canvas { width: 150px; height: 150px; }
}
@media (min-width: 720px) {
  .tool-card { padding: 1.5rem; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .ideas { grid-template-columns: repeat(2, 1fr); }
  .meal-controls { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .meal-list { grid-template-columns: repeat(2, 1fr); }
  .meal-head { grid-column: 1 / -1; }
  .hero { padding-top: 2.2rem; }
}
@media (min-width: 960px) {
  .header-nav { display: flex; }
  .tool-main { grid-template-columns: 1.05fr 1fr; gap: 0; }
  .results-panel { border-top: 0; border-left: 1px solid var(--line); }
  .panel { padding: 1.6rem; }
  .week-grid { grid-template-columns: repeat(7, 1fr); }
  .ideas { grid-template-columns: repeat(3, 1fr); }
  .download-card { grid-template-columns: 1fr auto; align-items: center; }
  .dl-status { grid-column: 1 / -1; }
  .meal-list { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) and (max-width: 1279px) {
  .macros { grid-template-columns: 1fr; justify-items: center; }
}
@media (min-width: 1280px) {
  .form-panel .seg-4 { grid-template-columns: repeat(4, 1fr); }
}

/* =============================================================
   9. Reduced motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .ad-toast { animation: none; }
}

@media print {
  .site-header, .ad-slot, .ad-toast, .ad-dialog, .dl-buttons, .content-section, .site-footer { display: none !important; }
}
