/* Layout: una columna tipo app móvil; el "plato" (anillos concéntricos) es la pieza central de Hoy; navegación inferior fija. */
:root {
  --bg: #EEF2EA;
  --surface: #FFFFFF;
  --surface-2: #E4EADF;
  --ink: #17251D;
  --muted: #5B6B61;
  --line: #D3DBCE;
  --track: #E6ECE2;
  --accent: #E0533A;
  --accent-2: #F28C4C;
  --accent-ink: #FFFFFF;
  --prot: #C63F68;
  --carb: #E59B2F;
  --fat: #6A9A3A;
  --water: #2C8AD3;
  --fast: #6656D2;
  --good: #2F8F5B;
  --warn: #C9821A;
  --bad: #C7392F;
  --hero: #1D3326;
  --hero-ink: #F2F6EE;
  --hero-muted: #A8BBAE;
  --hero-track: rgba(255,255,255,.10);
  --shadow: 0 1px 2px rgba(23,37,29,.06), 0 8px 24px rgba(23,37,29,.06);
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1712; --surface: #18221C; --surface-2: #213028; --ink: #E8EFE6; --muted: #98A99E;
    --line: #2C3A32; --track: #243229; --accent: #FF6B4E; --accent-2: #FF9A5C; --accent-ink: #1A0C08;
    --prot: #EC6A93; --carb: #F3B44F; --fat: #93C65E; --water: #5AB0F2; --fast: #9487F4;
    --good: #5BC78A; --warn: #F0B04A; --bad: #FF7A6E;
    --hero: #1B2C22; --hero-ink: #F2F6EE; --hero-muted: #9DB2A4; --hero-track: rgba(255,255,255,.09);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1712; --surface: #18221C; --surface-2: #213028; --ink: #E8EFE6; --muted: #98A99E;
  --line: #2C3A32; --track: #243229; --accent: #FF6B4E; --accent-2: #FF9A5C; --accent-ink: #1A0C08;
  --prot: #EC6A93; --carb: #F3B44F; --fat: #93C65E; --water: #5AB0F2; --fast: #9487F4;
  --good: #5BC78A; --warn: #F0B04A; --bad: #FF7A6E;
  --hero: #1B2C22; --hero-ink: #F2F6EE; --hero-muted: #9DB2A4; --hero-track: rgba(255,255,255,.09);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

.app { max-width: 560px; margin: 0 auto; padding-block: 18px 120px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 16px; }

/* Cabecera */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { flex: none; }
.brand h1 { font-size: 22px; font-weight: 800; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fast); }
.chip.fasting .dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.datebar h2 { font-size: 26px; font-weight: 700; text-transform: capitalize; }
.datebar .sub { font-size: 13px; color: var(--muted); text-transform: capitalize; }
.round-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; }
.round-btn:hover { border-color: var(--muted); }
.round-btn[disabled] { opacity: .35; cursor: default; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--carb) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--carb) 40%, var(--line)); font-size: 13.5px; }
.banner b { display: block; }
.banner .tag { flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--carb); color: #2A1A00; padding: 3px 7px; border-radius: 6px; margin-top: 1px; }

/* Héroe: el plato */
.hero { background: var(--hero); color: var(--hero-ink); border-radius: 28px; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); pointer-events: none; }
.plate-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; }
.plate { width: 190px; max-width: 100%; aspect-ratio: 1; position: relative; }
.plate svg { width: 100%; height: 100%; display: block; }
.plate-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.plate-center .big { font-family: var(--f-display); font-size: 38px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.plate-center small { font-size: 12px; color: var(--hero-muted); margin-top: 4px; display: block; }
.plate-center.over .big { color: var(--accent-2); }
.hero-stats { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hstat { display: flex; flex-direction: column; }
.hstat span { font-size: 12px; color: var(--hero-muted); }
.hstat b { font-family: var(--f-display); font-size: 21px; font-weight: 700; }
.hstat b small { font-family: var(--f-body); font-size: 12px; font-weight: 500; color: var(--hero-muted); }
.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; position: relative; z-index: 1; }
.macro .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--hero-muted); }
.macro .lbl i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.macro .val { font-family: var(--f-display); font-size: 17px; font-weight: 700; margin-top: 2px; }
.macro .val small { font-family: var(--f-body); font-size: 11.5px; font-weight: 500; color: var(--hero-muted); }
.bar { height: 6px; border-radius: 6px; background: var(--hero-track); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 6px; }

.arc { transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.anim .arc { animation: draw 1s cubic-bezier(.2,.8,.2,1) both; }
@keyframes draw { from { stroke-dashoffset: var(--c); } }

/* Botón añadir grande */
.quick-add { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 18px; border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); text-align: left; }
.quick-add .plus { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; font-size: 24px; font-weight: 600; }
.quick-add b { display: block; font-family: var(--f-display); font-size: 16px; }
.quick-add span { font-size: 13px; color: var(--muted); }

/* Comidas */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 4px; }
.section-head h3 { font-size: 19px; font-weight: 700; }
.meals { display: flex; flex-direction: column; gap: 10px; }
.meal { background: var(--surface); border-radius: 20px; padding: 14px 14px 10px; box-shadow: var(--shadow); }
.meal-head { display: flex; align-items: center; gap: 12px; }
.meal-badge { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.meal-badge svg { width: 22px; height: 22px; }
.meal-title { flex: 1; min-width: 0; }
.meal-title h4 { margin: 0; font-family: var(--f-display); font-size: 16.5px; font-weight: 700; }
.meal-title span { font-size: 12.5px; color: var(--muted); }
.meal-kcal { text-align: right; font-family: var(--f-display); font-weight: 700; font-size: 17px; }
.meal-kcal small { display: block; font-family: var(--f-body); font-size: 11.5px; color: var(--muted); font-weight: 500; }
.add-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--surface-2); font-size: 22px; line-height: 1; display: grid; place-items: center; flex: none; color: var(--ink); }
.add-btn:hover { background: var(--accent); color: var(--accent-ink); }
.items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; }
.item { border-top: 1px solid var(--line); }
.item-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; width: 100%; background: none; border: none; text-align: left; }
.em { font-size: 24px; width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.it-main { flex: 1; min-width: 0; }
.it-main b { display: block; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.it-main span { font-size: 12.5px; color: var(--muted); }
.it-k { font-weight: 700; font-size: 14px; white-space: nowrap; }
.it-detail { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 2px 12px 46px; }
.mini-macros { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); flex: 1; min-width: 0; flex-wrap: wrap; }
.mini-macros i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: 1px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { width: 32px; height: 30px; border: none; background: none; font-size: 17px; }
.stepper button:hover { background: var(--surface-2); }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-size: 13.5px; }
.del { border: none; background: none; color: var(--bad); font-size: 13px; font-weight: 600; padding: 6px 4px; }
.empty-meal { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 2px 4px; font-size: 13.5px; color: var(--muted); }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; }

/* Agua y ejercicio */
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.panel { background: var(--surface); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.panel h4 { margin: 0; font-family: var(--f-display); font-size: 15.5px; font-weight: 700; }
.panel .big { font-family: var(--f-display); font-size: 24px; font-weight: 800; }
.panel .big small { font-family: var(--f-body); font-size: 12px; font-weight: 500; color: var(--muted); }
.glasses { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.glass { border: none; background: none; padding: 0; aspect-ratio: 3/4; max-width: 100%; }
.glass svg { width: 100%; height: 100%; display: block; }
.ex-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.ex-list li { display: flex; justify-content: space-between; gap: 6px; }
.ex-form { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.ex-form select, .ex-form input { min-width: 0; flex: 1 1 90px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 13px; }
.ex-form input { flex: 0 1 70px; }

/* Coach */
.coach { background: color-mix(in srgb, var(--fast) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--fast) 28%, var(--line)); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.coach p { margin: 0; white-space: pre-wrap; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.dark { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

/* Navegación inferior */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 560px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 14px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.nav a svg { width: 23px; height: 23px; }
.nav a[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); }

/* Hoja inferior */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8,14,10,.45); animation: fade .2s ease both; }
.sheet-panel { position: relative; width: 100%; max-width: 560px; max-height: 90%; overflow-y: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; animation: rise .28s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 42px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-top h2 { font-size: 21px; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.seg button { border: none; background: none; padding: 8px 4px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.composer { display: flex; flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; min-height: 76px; resize: vertical; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--bg); font-size: 15px; }
.composer textarea:focus { border-color: var(--accent); outline: none; }
.composer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.composer-actions .btn { flex: 1 1 140px; }
.photo-thumb { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.photo-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; }
.status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.matches { display: flex; flex-direction: column; gap: 2px; }
.match { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border: none; background: none; border-radius: 12px; text-align: left; width: 100%; }
.match:hover { background: var(--surface-2); }
.match .plus-s { margin-left: auto; color: var(--accent); font-weight: 700; font-size: 20px; }
.draft { background: var(--bg); border-radius: 18px; padding: 6px 12px; }
.draft .item:first-child { border-top: none; }
.draft-total { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 6px; border-top: 1px solid var(--line); font-weight: 700; }
.note { font-size: 12.5px; color: var(--muted); }

/* Ayuno */
.fast-card { background: var(--surface); border-radius: 28px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.plans { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.plans button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.plans button[aria-pressed="true"] { background: var(--fast); color: #fff; border-color: transparent; }
.fast-ring { width: 250px; max-width: 100%; aspect-ratio: 1; position: relative; }
.fast-ring svg { width: 100%; height: 100%; display: block; }
.fast-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.fast-center .state { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--fast); }
.fast-center .clock { font-family: var(--f-display); font-size: 40px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fast-center .left { font-size: 13px; color: var(--muted); }
.fast-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.fast-meta div { background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.fast-meta span { font-size: 12px; color: var(--muted); display: block; }
.fast-meta b { font-family: var(--f-display); font-size: 17px; }
.fast-meta input { width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.phases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.phase { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; position: relative; padding-bottom: 14px; }
.phase:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 26px; bottom: 0; width: 2px; background: var(--line); }
.phase .pdot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); }
.phase.done .pdot { background: var(--fast); border-color: var(--fast); color: #fff; }
.phase.now .pdot { border-color: var(--fast); color: var(--fast); box-shadow: 0 0 0 5px color-mix(in srgb, var(--fast) 18%, transparent); }
.phase b { font-family: var(--f-display); font-size: 15px; }
.phase b small { font-family: var(--f-body); font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.phase p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* Plan */
.plan-meal { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.plan-meal-top { display: flex; gap: 14px; padding: 16px; align-items: center; }
.plan-emoji { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 34px; flex: none; }
.plan-meal-top h4 { margin: 2px 0 4px; font-family: var(--f-display); font-size: 17px; font-weight: 700; line-height: 1.2; }
.pills { display: flex; gap: 5px; flex-wrap: wrap; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.p { background: color-mix(in srgb, var(--prot) 16%, var(--surface)); color: var(--prot); }
.pill.c { background: color-mix(in srgb, var(--carb) 20%, var(--surface)); color: color-mix(in srgb, var(--carb) 70%, var(--ink)); }
.pill.f { background: color-mix(in srgb, var(--fat) 18%, var(--surface)); color: color-mix(in srgb, var(--fat) 80%, var(--ink)); }
.plan-meal details { border-top: 1px solid var(--line); }
.plan-meal summary { padding: 11px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
.plan-meal summary::-webkit-details-marker { display: none; }
.plan-meal summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; }
.plan-meal details[open] summary::after { content: "−"; }
.plan-body { padding: 0 16px 14px; display: grid; gap: 10px; font-size: 13.5px; }
.plan-body ul, .plan-body ol { margin: 0; padding-left: 20px; }
.plan-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 16px 14px; }
.prefs textarea { width: 100%; min-height: 64px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); resize: vertical; }
.shop { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.shop h5 { margin: 0 0 4px; font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.shop label { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 14px; cursor: pointer; }
.shop input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 1px; flex: none; }
.shop label.done span { text-decoration: line-through; color: var(--muted); }
.shop .q { color: var(--muted); font-size: 12.5px; }
.skeleton { border-radius: 22px; height: 96px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Progreso */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.stat span { font-size: 12px; color: var(--muted); display: block; }
.stat b { font-family: var(--f-display); font-size: 22px; font-weight: 800; display: block; }
.stat em { font-style: normal; font-size: 11.5px; font-weight: 700; }
.chart-card { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.chart-card svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chart-card h4 { margin: 0; font-family: var(--f-display); font-size: 16.5px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.split { display: flex; height: 14px; border-radius: 8px; overflow: hidden; }
.split i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* Perfil */
.form { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); min-width: 0; width: 100%; }
.field textarea { min-height: 60px; resize: vertical; }
.calc { background: var(--hero); color: var(--hero-ink); border-radius: 22px; padding: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.calc div span { display: block; font-size: 12px; color: var(--hero-muted); }
.calc div b { font-family: var(--f-display); font-size: 22px; font-weight: 800; }
.calc div b small { font-family: var(--f-body); font-size: 12px; font-weight: 500; color: var(--hero-muted); }
.calc .wide { grid-column: 1 / -1; font-size: 12.5px; color: var(--hero-muted); border-top: 1px solid var(--hero-track); padding-top: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; animation: rise .25s ease both; }

@media (max-width: 420px) {
  .hero { padding: 16px; }
  .plate-wrap { gap: 12px; }
  .plate { width: 172px; }
  .plate-center .big { font-size: 28px; }
  .plate-center small { font-size: 10.5px; }
  .hstat b { font-size: 18px; }
  .datebar h2 { font-size: 22px; }
  .duo { grid-template-columns: minmax(0, 1fr); }
  .stat b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- App instalable ---------- */
html { padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
.em-photo { width: 38px; height: 38px; border-radius: 12px; object-fit: cover; flex: none; }
.meal-badge img { width: 100%; height: 100%; object-fit: cover; border-radius: 13px; }
.profile-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); text-decoration: none; flex: none; }
.profile-btn svg { width: 20px; height: 20px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* Botón central de cámara en la navegación */
.nav li.fab-li { display: flex; justify-content: center; }
.fab { width: 60px; height: 60px; margin-top: -26px; border-radius: 20px; border: none; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 0 5px var(--bg); }
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.95); }

/* Atajo grande "foto" en Hoy */
.snap-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; }
.snap { display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 120px; padding: 16px; border-radius: 22px; border: none; text-align: left; position: relative; overflow: hidden; }
.snap b { font-family: var(--f-display); font-size: 17px; display: block; }
.snap span { font-size: 12.5px; opacity: .85; }
.snap svg { width: 30px; height: 30px; }
.snap.photo { background: linear-gradient(150deg, var(--accent-2), var(--accent)); color: var(--accent-ink); }
.snap.photo::after { content: ""; position: absolute; width: 130px; height: 130px; right: -40px; bottom: -50px; border-radius: 50%; border: 18px solid rgba(255,255,255,.14); }
.snap.write { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.snap.write svg { color: var(--accent); }

/* Cámara */
.cam { position: fixed; inset: 0; z-index: 50; background: #050806; color: #fff; overflow: hidden; }
.cam video, .cam > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; max-width: none; }
.cam-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(12px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 12px max(14px, env(safe-area-inset-left, 0px)); display: flex; gap: 10px; align-items: center; background: linear-gradient(rgba(0,0,0,.55), transparent); z-index: 2; }
.cam-round { width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(0,0,0,.45); color: #fff; font-size: 17px; flex: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cam-seg { flex: 1; background: rgba(0,0,0,.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cam-seg button { color: rgba(255,255,255,.75); }
.cam-seg button[aria-pressed="true"] { background: #fff; color: #17251D; }
.cam-frame { position: absolute; left: 50%; top: 46%; width: min(78vw, 360px); aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; }
.cam-frame span { position: absolute; width: 38px; height: 38px; border: 3.5px solid #fff; opacity: .9; }
.cam-frame span:nth-child(1) { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 16px 0 0 0; }
.cam-frame span:nth-child(2) { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 16px 0 0; }
.cam-frame span:nth-child(3) { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 16px; }
.cam-frame span:nth-child(4) { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 16px 0; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(26px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: linear-gradient(transparent, rgba(0,0,0,.7)); z-index: 2; }
.cam-side { justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; background: none; border: none; font-size: 12px; font-weight: 600; cursor: pointer; }
.cam-side svg { width: 26px; height: 26px; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; }
.shutter i { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .12s; }
.shutter:active i { transform: scale(.88); }
.cam-fallback { position: absolute; inset: 0; display: grid; place-content: center; gap: 16px; text-align: center; padding: 0 32px; z-index: 1; }
.cam-fallback p { margin: 0; color: rgba(255,255,255,.8); max-width: 30ch; }
.cam-scan { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: rgba(0,0,0,.25); }
.cam-scan i { position: absolute; left: 0; right: 0; height: 120px; background: linear-gradient(transparent, color-mix(in srgb, var(--accent-2) 55%, transparent), transparent); animation: scan 1.8s ease-in-out infinite alternate; }
@keyframes scan { from { top: 8%; } to { top: 70%; } }
.cam-result { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; max-height: 78%; overflow-y: auto; background: var(--surface); color: var(--ink); border-radius: 28px 28px 0 0; padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; animation: rise .3s cubic-bezier(.2,.8,.2,1) both; }
.res-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.res-head h3 { font-size: 21px; line-height: 1.15; }
.res-kcal { text-align: right; flex: none; }
.res-kcal b { font-family: var(--f-display); font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; color: var(--accent); }
.res-kcal small { display: block; font-size: 12px; color: var(--muted); }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-top: 6px; }
.conf i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.res-macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.res-macros div { border-radius: 14px; padding: 9px 10px; }
.res-macros span { display: block; font-size: 11.5px; font-weight: 600; }
.res-macros b { font-family: var(--f-display); font-size: 19px; }
.res-fix { display: flex; gap: 8px; }
.res-fix input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.res-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
.analyzing { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 8px; text-align: center; }
.analyzing b { font-family: var(--f-display); font-size: 18px; }

/* Ajustes */
.settings { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.settings h4 { margin: 0; font-family: var(--f-display); font-size: 16.5px; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.model-opts { display: flex; flex-direction: column; gap: 6px; }
.model-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.model-opt input { accent-color: var(--accent); margin-top: 3px; }
.model-opt b { display: block; font-size: 14px; }
.model-opt span { font-size: 12.5px; color: var(--muted); }
.model-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }
.btn.danger { color: var(--bad); }
.ok-text { color: var(--good); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }

/* Fotos del menú */
.plan-photo { position: relative; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; display: grid; place-items: center; }
.plan-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade .4s ease both; }
.plan-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0,0,0,.45)); pointer-events: none; }
.plan-photo-emoji { font-size: 64px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.18)); }
.plan-photo-emoji.loading { animation: pulse 1.4s ease-in-out infinite; }
.plan-photo-tag { position: absolute; left: 12px; top: 12px; z-index: 1; padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: rgba(255,255,255,.9); color: #17251D; }
.plan-photo-credit { position: absolute; right: 10px; bottom: 8px; z-index: 1; font-size: 10.5px; color: rgba(255,255,255,.9); text-decoration: none; }
.plan-meal-top h4 { margin-top: 0; }
.plan-meal + .plan-meal, .plan-meal + .coach, .plan-meal + .shop, .coach + .shop { margin-top: 14px; }
