  /* Geist alojada en la propia app (variable 400-700): sin Google Fonts, funciona offline. */
  @font-face {
    font-family: 'Geist'; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url(fonts/geist-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: 'Geist'; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url(fonts/geist-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @property --accent {
    syntax: '<color>';
    inherits: true;
    initial-value: #5b8cff;
  }

  :root {
    color-scheme: dark;
    --bg: #0a0c0f;
    --surface: #12151a;
    --surface-2: #191d24;
    --surface-3: #212630;
    --line: #262c36;
    --line-soft: #1d222a;
    --text: #eceff4;
    --muted: #8d96a5;
    --dim: #818a9b; /* contraste ≥ 4,5:1 sobre las superficies oscuras (antes #5f6877, ≈3,3:1) */

    --train: #5b8cff;
    --rest: #2fd3b5;
    --accent: var(--train);

    --prot: #ff7b7b;
    --carb: #f6b94a;
    --fat: #b48cff;

    --ok: #4ade80;
    --warn: #fb923c;
    --danger: #ff6b6b;

    --r-lg: 18px;
    --r: 14px;
    --r-sm: 10px;
    --r-xs: 7px;

    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;

    --tap: 44px;
    --nav-h: 64px;
    --font: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);
  }

  body[data-mode="rest"] { --accent: var(--rest); }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html { -webkit-text-size-adjust: 100%; }
  /* Sensación de app nativa: sin "deslizar para recargar" ni rebote, y sin seleccionar texto en controles */
  html, body { overscroll-behavior-y: none; }
  button, .chip, .day-pill, .nav-btn, .preset, .result, .mode-switch, .meal-head, .tag, label.btn {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  img, svg { -webkit-user-drag: none; }

  body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.4;
    color: var(--text);
    background:
      radial-gradient(900px 360px at 50% -180px, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
      var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    font-variant-numeric: tabular-nums;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s4));
    -webkit-tap-highlight-color: transparent;
  }
  body.sheet-open { overflow: hidden; }

  button, input, select { font: inherit; color: inherit; }
  button { cursor: pointer; border: none; background: none; }
  svg { display: block; }

  input[type="number"], input[type="text"], input[type="search"], input[type="password"], select {
    -webkit-appearance: none; appearance: none;
    width: 100%;
    height: var(--tap);
    padding: 0 var(--s3);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    outline: none;
    font-size: 15px;
    transition: border-color .15s;
  }
  input:focus, select:focus { border-color: var(--accent); }
  input[type="number"] { -moz-appearance: textfield; }
  input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

  /* ---------- Layout ---------- */
  .app { max-width: 1180px; margin: 0 auto; padding: 0 var(--s4); }

  .topbar { padding-top: calc(var(--s3) + env(safe-area-inset-top)); }
  .topbar-row { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); }
  .brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; letter-spacing: -.01em; }
  .logo {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center;
    background: var(--accent); color: #0a0c0f; font-weight: 800; font-size: 15px;
  }
  .brand-name { font-size: 16px; }
  .brand-name small { color: var(--dim); font-weight: 500; font-size: 12px; margin-left: 4px; }

  .date-btn {
    position: relative; margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 var(--s3);
    border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
    font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  }
  .date-btn input {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0;
  }
  .date-btn input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

  .desk-actions { display: none; gap: var(--s2); }

  .week { display: flex; align-items: center; gap: var(--s1); margin-top: var(--s3); }
  .week-strip {
    flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px;
    overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory;
  }
  .week-strip::-webkit-scrollbar { display: none; }
  .day-pill {
    scroll-snap-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px 8px; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--line-soft);
    transition: border-color .2s, background .2s;
  }
  .day-pill .dn { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
  .day-pill .dd { font-size: 15px; font-weight: 700; }
  .day-pill .db { width: 70%; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
  .day-pill .db i { display: block; height: 100%; border-radius: 3px; }
  .day-pill.today .dd { color: var(--accent); }
  .day-pill.active { background: var(--accent); border-color: var(--accent); }
  .day-pill.active .dn, .day-pill.active .dd { color: #0a0c0f; }
  .day-pill.active .db { background: rgba(0,0,0,.2); }
  .day-pill.active .db i { background: #0a0c0f !important; }

  .week-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: var(--s2); font-size: 12px; color: var(--dim); min-height: 22px;
  }
  .link-btn { color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 0; }

  .icon-btn {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
    display: grid; place-items: center; color: var(--muted);
    transition: background .15s, color .15s;
  }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }

  .layout { display: grid; gap: var(--s4); margin-top: var(--s4); }
  .col-left, .col-right { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }

  .card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    padding: var(--s4);
  }

  /* ---------- Hero (Hoy) ---------- */
  .mode-switch {
    position: relative; display: grid; grid-template-columns: 1fr 1fr;
    background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: var(--s4);
  }
  .mode-switch button {
    position: relative; z-index: 1; height: 36px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--muted); transition: color .25s;
  }
  .mode-switch button.on { color: #0a0c0f; }
  .mode-thumb {
    position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
    background: var(--accent); border-radius: 999px;
    transition: transform .35s var(--ease);
  }
  body[data-mode="rest"] .mode-thumb { transform: translateX(100%); }

  .hero-body { display: grid; grid-template-columns: 128px 1fr; gap: var(--s4); align-items: center; }
  .ring-wrap { position: relative; width: 128px; height: 128px; }
  .ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
  .ring-track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
  .ring-fill {
    fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
    transition: stroke-dashoffset .7s var(--ease), stroke .3s;
  }
  .ring-fill.over { stroke: var(--warn); }
  .ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .ring-num { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
  .ring-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
  .ring-label.over { color: var(--warn); }

  .macros { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
  .macro-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); font-size: 13px; }
  .macro-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
  .macro-name i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
  .macro-val { color: var(--muted); white-space: nowrap; }
  .macro-val b { color: var(--text); font-weight: 700; }
  .bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 5px; }
  .bar i { display: block; height: 100%; width: 100%; border-radius: 6px; transform: scaleX(0); transform-origin: left; transition: transform .7s var(--ease); }
  .macro-sub { font-size: 11px; color: var(--dim); margin-top: 4px; display: flex; justify-content: space-between; }
  .macro-sub .over { color: var(--warn); }

  .hero-foot {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line-soft);
    font-size: 12px; color: var(--muted);
  }
  .hero-foot b { color: var(--text); }
  .pct-pill { padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 700; }

  /* ---------- Registro diario ---------- */
  .daily { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s2); padding: var(--s3); }
  .daily-cell { background: var(--surface-2); border-radius: var(--r); padding: var(--s2) var(--s3); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .daily-cell label { font-size: 11px; color: var(--muted); font-weight: 500; }
  .daily-cell input[type="number"] {
    height: 32px; padding: 0; background: none; border: none; font-size: 18px; font-weight: 700; border-radius: 0;
  }
  .unit-input { display: flex; align-items: baseline; gap: 3px; }
  .unit-input input { max-width: 5.2ch; }
  .unit-input span { font-size: 12px; color: var(--dim); }
  .stepper { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
  .stepper input { text-align: center; min-width: 0; flex: 1; font-size: 17px !important; }
  .stepper button {
    width: 26px; height: 30px; border-radius: 8px; background: var(--surface-3); flex-shrink: 0;
    display: grid; place-items: center; font-size: 17px; color: var(--muted);
  }
  .switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; margin-top: 2px; }
  .switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
  .switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
  .switch span::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: var(--muted); transition: transform .25s var(--ease), background .2s;
  }
  .switch input:checked + span { background: var(--accent); }
  .switch input:checked + span::after { transform: translateX(18px); background: #0a0c0f; }
  .switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
  .switch-row small { font-size: 12px; color: var(--muted); }

  /* ---------- Secciones ---------- */
  .section-head { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; }
  .section-head h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
  .text-btn { font-size: 13px; font-weight: 600; color: var(--accent); height: 32px; padding: 0 var(--s2); border-radius: var(--r-xs); }
  .text-btn:hover { background: var(--surface-2); }

  .presets {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(176px, 1fr);
    gap: var(--s2); overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4);
    scroll-snap-type: x mandatory;
  }
  .presets::-webkit-scrollbar { display: none; }
  .preset {
    scroll-snap-align: start;
    text-align: left; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r);
    padding: var(--s3); display: flex; flex-direction: column; gap: 6px; min-height: 104px;
    transition: border-color .15s, transform .1s;
  }
  .preset:hover { border-color: var(--line); }
  .preset:active { transform: scale(.98); }
  .preset .pt { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
  .preset .pd { font-size: 12px; color: var(--muted); line-height: 1.35; flex: 1; }
  .preset .pk { font-size: 12px; color: var(--dim); }
  .preset .pk b { color: var(--text); font-size: 15px; }
  .preset .pk em { display: block; font-style: normal; margin-top: 2px; }
  .preset.all { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
  .preset.all .pt { color: var(--accent); }
  .preset .badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }

  /* ---------- Comidas ---------- */
  .meal { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: hidden; }
  .meal + .meal { margin-top: var(--s3); }
  .meal-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s2) var(--s3) var(--s4); }
  .meal-title { font-weight: 600; font-size: 15px; }
  .meal-title small { display: block; font-size: 12px; color: var(--dim); font-weight: 500; }
  .meal-sum { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
  .meal-sum b { color: var(--text); font-size: 14px; display: block; }
  .add-mini {
    width: var(--tap); height: var(--tap); border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }

  .food-row {
    display: grid; grid-template-columns: 1fr var(--tap); grid-template-areas: "main del" "meta del";
    column-gap: var(--s2); row-gap: 6px; align-items: center;
    padding: var(--s3) var(--s2) var(--s3) var(--s4); border-top: 1px solid var(--line-soft);
  }
  .fr-main { grid-area: main; display: flex; align-items: center; gap: var(--s2); min-width: 0; }
  .fr-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .fr-meta { grid-area: meta; display: flex; align-items: center; gap: var(--s3); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
  .fr-kcal { color: var(--text); font-weight: 600; font-size: 13px; }
  .m-p { color: var(--prot); } .m-c { color: var(--carb); } .m-f { color: var(--fat); }
  .del {
    grid-area: del; width: var(--tap); height: var(--tap); border-radius: 12px;
    display: grid; place-items: center; color: var(--dim); transition: background .15s, color .15s;
  }
  .del:hover, .del:active { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

  .g-input {
    display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 0;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--dim);
  }
  .g-input:focus-within { border-color: var(--accent); }
  .g-input input {
    width: 54px; height: 30px; border: none; background: none; padding: 0 0 0 8px; font-size: 14px; font-weight: 600; text-align: right; color: var(--text);
  }

  .tag { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 5px; flex-shrink: 0; letter-spacing: .02em; }
  .tag-hsn { background: rgba(255,123,123,.12); color: #ff9d9d; }
  .tag-hac { background: rgba(74,222,128,.11); color: #7ee2a0; }
  .tag-base { background: rgba(141,150,165,.14); color: #b5bdc9; }
  .tag-ai { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

  .empty {
    border-top: 1px dashed var(--line); margin: 0 var(--s4); padding: var(--s3) 0 var(--s4);
    display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--dim);
  }
  .empty svg { opacity: .6; }

  /* ---------- Botones ---------- */
  .btn {
    height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-sm);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    font-weight: 600; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line);
    transition: background .15s, border-color .15s, opacity .15s;
  }
  .btn:hover { border-color: var(--dim); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #0a0c0f; }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn.full { width: 100%; }
  .btn:disabled { opacity: .6; cursor: progress; }
  .btn.sm { height: 36px; padding: 0 var(--s3); font-size: 13px; }

  .chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip {
    flex-shrink: 0; height: 34px; padding: 0 var(--s3); border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--muted);
    transition: background-color .15s, border-color .15s, color .15s; white-space: nowrap;
  }
  .chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--text); }
  .chip.sm { height: 30px; font-size: 12px; padding: 0 10px; }

  /* ---------- Hojas / modales ---------- */
  .sheet-backdrop {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
    background: rgba(3, 4, 6, .66); backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
  }
  .sheet-backdrop.open { opacity: 1; visibility: visible; }
  .sheet {
    width: 100%; max-height: 90vh; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-bottom: none;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%); transition: transform .32s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-backdrop.open .sheet { transform: none; }
  .sheet:focus { outline: none; }
  .sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--surface-3); margin: 8px auto 0; flex-shrink: 0; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s3) var(--s2) var(--s4); flex-shrink: 0; }
  .sheet-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
  .sheet-body { overflow-y: auto; padding: var(--s2) var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s4); overscroll-behavior: contain; }
  .sheet-body > * { flex-shrink: 0; }
  .field-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
  .field { display: flex; flex-direction: column; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

  .search { position: relative; flex: 1; }
  .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
  .search input { padding-left: 38px; }
  .add-row { display: flex; gap: var(--s2); }
  .grams-field { position: relative; width: 96px; flex-shrink: 0; }
  .grams-field input { padding-right: 26px; text-align: right; font-weight: 700; }
  .grams-field span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 13px; pointer-events: none; }

  .results { display: flex; flex-direction: column; border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
  .result {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s3);
    padding: 10px var(--s3); min-height: 56px; text-align: left; background: var(--surface); width: 100%;
    transition: background .12s;
  }
  .result + .result { border-top: 1px solid var(--line-soft); }
  .result:hover { background: var(--surface-2); }
  .result:active { background: var(--surface-3); }
  .r-top { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
  .r-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .r-sub { font-size: 11px; color: var(--dim); margin-top: 3px; }
  .r-add {
    display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap;
  }
  .r-empty { padding: var(--s5); text-align: center; color: var(--dim); font-size: 13px; }
  .r-section { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding: 8px var(--s3) 6px; background: var(--surface-2); font-weight: 600; }

  .seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--r-sm); padding: 3px; }
  .seg button { height: 36px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
  .seg button.on.t { color: var(--train); }
  .seg button.on.r { color: var(--rest); }

  .slider-box { background: var(--surface-2); border-radius: var(--r); padding: var(--s3); }
  .slider-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: var(--s2); }
  .slider-top span:last-child { color: var(--muted); }
  .slider-row { display: flex; gap: var(--s3); align-items: center; }
  .slider-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 28px; }
  .slider-row input[type="number"] { width: 78px; height: 38px; text-align: center; font-weight: 700; }
  .carb-auto { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
  .carb-auto b { flex-shrink: 0; }
  .carb-auto b { font-size: 18px; color: var(--carb); }

  .group-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-top: var(--s2); }
  .hint { font-size: 12px; color: var(--dim); line-height: 1.45; }
  .divider { height: 1px; background: var(--line-soft); }

  /* Cantidad por alimento */
  .result.open { background: var(--surface-2); }
  .result.open .r-add { background: var(--accent); color: #0a0c0f; }
  .qty-panel { background: var(--surface-2); padding: 4px var(--s3) var(--s3); display: flex; flex-direction: column; gap: var(--s3); border-top: 1px dashed var(--line); }
  .qty-row { display: flex; align-items: center; gap: var(--s2); }
  .qty-btn { width: var(--tap); height: var(--tap); border-radius: var(--r-sm); background: var(--surface-3); font-size: 22px; color: var(--text); flex-shrink: 0; }
  .qty-field { flex: 1; position: relative; }
  .qty-field input { text-align: center; font-size: 22px !important; font-weight: 700; height: 48px; padding-right: 28px; background: var(--surface); }
  .qty-field span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--dim); }
  .qty-preview { display: flex; gap: var(--s3); align-items: baseline; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
  .qty-preview b { color: var(--text); font-size: 16px; }
  .off-btn {
    display: flex; align-items: center; justify-content: center; gap: var(--s2); width: 100%; min-height: 52px; padding: 0 var(--s3);
    border-top: 1px solid var(--line-soft); background: var(--surface); color: var(--accent); font-size: 13px; font-weight: 600; text-align: center;
  }
  .off-btn:hover { background: var(--surface-2); }
  .scan-btn { width: var(--tap); height: var(--tap); flex-shrink: 0; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); }
  .scan-frame { position: relative; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
  .scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: var(--danger); box-shadow: 0 0 12px var(--danger); opacity: .8; }
  input[type="search"]::-webkit-search-cancel-button { filter: invert(.6); }
  .weigh-note { font-size: 11px; color: var(--dim); line-height: 1.3; }
  .weigh-note.todo { color: var(--accent); font-weight: 600; }

  /* Escáner */
  details.key-box { background: var(--surface-2); border-radius: var(--r); }
  details.key-box summary {
    list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    padding: var(--s3); font-size: 13px; font-weight: 600;
  }
  details.key-box summary::-webkit-details-marker { display: none; }
  details.key-box summary span:last-child { font-size: 12px; color: var(--muted); font-weight: 500; }
  .key-inner { padding: 0 var(--s3) var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
  .key-inner a { color: var(--accent); font-size: 12px; text-decoration: none; }

  .dropzone {
    border: 1.5px dashed var(--line); border-radius: var(--r); padding: var(--s5) var(--s4);
    text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
    display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px;
  }
  .dropzone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
  .dropzone strong { color: var(--text); font-size: 14px; }
  .preview-img { max-width: 100%; max-height: 220px; border-radius: var(--r-sm); margin-top: var(--s2); display: none; }
  kbd { font-family: inherit; font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; }

  .ai-status { display: none; padding: 10px var(--s3); border-radius: var(--r-sm); font-size: 13px; border: 1px solid; background: var(--surface-2); word-break: break-word; }
  .ai-list { border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
  .ai-row {
    display: grid; grid-template-columns: 32px 1fr auto; grid-template-areas: "chk name grams" "chk meta meta";
    gap: 4px var(--s2); align-items: center; padding: 10px var(--s3);
  }
  .ai-row + .ai-row { border-top: 1px solid var(--line-soft); }
  .ai-row input[type="checkbox"] { grid-area: chk; width: 20px; height: 20px; accent-color: var(--accent); }
  .ai-row .ai-name { grid-area: name; font-size: 14px; font-weight: 500; min-width: 0; }
  .ai-row .g-input { grid-area: grams; }
  .ai-row .ai-meta { grid-area: meta; font-size: 12px; color: var(--muted); display: flex; gap: var(--s3); }
  .ai-row.off { opacity: .45; }

  /* Historial */
  .table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--r); }
  .tbl { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
  .tbl th { text-align: left; font-size: 11px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 10px var(--s3); background: var(--surface-2); }
  .tbl td { padding: 10px var(--s3); border-top: 1px solid var(--line-soft); color: var(--muted); }
  .tbl td b { color: var(--text); }
  .tbl td.ok { color: var(--ok); font-weight: 700; }
  .tbl td.warn { color: var(--warn); font-weight: 700; }
  .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
  .dot.t { background: var(--train); } .dot.r { background: var(--rest); }

  /* Sincronización */
  .sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); flex-shrink: 0; display: inline-block; transition: background .3s; }
  .sync-dot.ok { background: var(--ok); }
  .sync-dot.busy { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
  .sync-dot.offline, .sync-dot.idle { background: var(--dim); }
  .sync-dot.err { background: var(--danger); }
  @keyframes pulse { 50% { opacity: .35; } }
  .sync-card { display: flex; align-items: center; gap: var(--s3); background: var(--surface-2); border-radius: var(--r); padding: var(--s3); }
  #syncPanel, #installPanel { display: flex; flex-direction: column; gap: var(--s3); }
  .or { text-align: center; font-size: 12px; color: var(--dim); }
  textarea {
    width: 100%; padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
    font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); outline: none; resize: vertical;
  }
  textarea:focus { border-color: var(--accent); }

  /* ---------- Navegación inferior ---------- */
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--bg);
    border-top: 1px solid var(--line-soft);
  }
  .nav-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 500; color: var(--dim); transition: color .15s;
  }
  .nav-btn > svg { width: 22px; height: 32px; }
  .nav-btn.on { color: var(--accent); }
  .nav-btn.main span.bubble {
    width: 46px; height: 32px; border-radius: 12px; display: grid; place-items: center;
    background: var(--accent); color: #0a0c0f;
  }
  .nav-btn.main { color: var(--text); }

  /* ---------- Toasts ---------- */
  .toast-host {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 80;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s3));
    display: flex; flex-direction: column; gap: var(--s2); width: min(92vw, 420px); pointer-events: none;
  }
  .toast {
    pointer-events: auto; display: flex; align-items: center; gap: var(--s3);
    padding: 10px 10px 10px var(--s4); min-height: 46px; border-radius: var(--r);
    background: #232833; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45);
    font-size: 13px; animation: toastIn .28s var(--ease);
  }
  .toast.err { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
  .toast span { flex: 1; }
  .toast button { color: var(--accent); font-weight: 700; font-size: 13px; padding: 6px 10px; border-radius: 8px; }
  .toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  body.sheet-open .toast-host { bottom: auto; top: calc(env(safe-area-inset-top) + var(--s3)); }

  @media (max-width: 599px) {
    .icon-btn { width: 28px; }
    .tbl th, .tbl td { padding: 10px 8px; font-size: 12px; }
    .tbl .yr, .tbl .tt { display: none; }
  }

  /* ---------- Escritorio ---------- */
  @media (min-width: 900px) {
    body { padding-bottom: var(--s6); }
    .app { padding: 0 var(--s5); }
    .bottom-nav { display: none; }
    .desk-actions { display: flex; }
    .date-btn { margin-left: auto; }
    .layout { grid-template-columns: 380px 1fr; align-items: start; gap: var(--s5); margin-top: var(--s5); }
    .col-left { position: sticky; top: var(--s4); }
    .week-strip { grid-template-columns: repeat(7, 1fr); }
    .day-pill { padding: 9px 4px 10px; }
    .presets { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; overflow: visible; }
    .toast-host { bottom: var(--s5); }
    .sheet-backdrop { align-items: center; padding: var(--s5); }
    .sheet { max-width: 620px; max-height: 86vh; border-radius: 22px; border-bottom: 1px solid var(--line); transform: translateY(16px) scale(.98); }
    .sheet.wide { max-width: 860px; }
    .sheet-handle { display: none; }
    .sheet-head { padding: var(--s4) var(--s4) var(--s2) var(--s5); }
    .sheet-body { padding: var(--s2) var(--s5) var(--s5); }
  }
  @media (max-width: 380px) {
    .hero-body { grid-template-columns: 112px 1fr; gap: var(--s3); }
    .ring-wrap { width: 112px; height: 112px; }
    .ring-num { font-size: 26px; }
  }
  .logo-img { width: 30px; height: 30px; border-radius: 9px; display: block; }

  /* ---------- Editor de comidas fijas ---------- */
  .pe-card { background: var(--surface-2); border-radius: var(--r); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
  .pe-top, .pe-row, .pe-add { display: flex; align-items: center; gap: var(--s2); }
  .pe-top input, .pe-add input { flex: 1; min-width: 0; }
  .pe-n { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pe-opts { display: flex; gap: var(--s4); flex-wrap: wrap; }
  .pe-opts label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

  /* ---------- Animaciones v6.5 (solo transform/opacity) ---------- */
  :root { --spring: cubic-bezier(.34, 1.4, .64, 1); --out: cubic-bezier(.16, 1, .3, 1); }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
  @keyframes swap { from { opacity: 0; transform: translateX(calc(var(--dx, 1) * 18px)); } }
  @keyframes pop { from { transform: scale(.7); } 60% { transform: scale(1.12); } }
  @keyframes sheen { to { transform: translateX(100%); } }
  @keyframes breathe { 50% { opacity: .35; transform: scale(1.06); } }
  @keyframes ping { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.35); } }
  @keyframes drain { to { transform: scaleX(0); } }
  @keyframes flash { from { opacity: 0; transform: translateX(-10px); } }
  @keyframes toastIn { from { opacity: 0; transform: translateY(18px) scale(.94); } }

  body.intro .week-strip, body.intro .card, body.intro .meal {
    animation: rise .6s var(--out) backwards; animation-delay: calc(var(--i, 0) * 60ms);
  }
  .swap { animation: swap .42s var(--out); }
  .food-row.new { animation: flash .7s var(--out); }

  .ring-wrap { isolation: isolate; }
  .ring-wrap::before {
    content: ""; position: absolute; inset: -14px; z-index: -1; border-radius: 50%; pointer-events: none;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 26%, transparent), transparent);
    animation: breathe 4.5s ease-in-out infinite;
  }
  .ring-wrap.ping::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    border: 2px solid var(--accent); animation: ping .9s var(--out) forwards;
  }
  .mode-thumb { transition: transform .5s cubic-bezier(.3, 1.35, .5, 1); }

  .bar i { position: relative; overflow: hidden; }
  .bar i::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
    animation: sheen 1s .45s var(--out) both;
  }

  .sheet-backdrop { transition: opacity .3s, visibility .3s; }
  .sheet { transition: transform .55s var(--out); }
  .sheet-backdrop:not(.open) .sheet { transition-duration: .28s; }
  .sheet-backdrop.enter .sheet-body > * { animation: rise .5s var(--out) backwards; animation-delay: calc(80ms + var(--n, 0) * 40ms); }

  .toast { position: relative; overflow: hidden; animation-duration: .45s; animation-timing-function: var(--spring); }
  .toast::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; opacity: .8;
    background: var(--accent); transform-origin: left; animation: drain var(--dur, 3200ms) linear forwards;
  }
  .toast.out::after { display: none; }

  .nav-btn { position: relative; }
  .nav-btn::after {
    content: ""; position: absolute; top: 0; left: 50%; width: 20px; height: 3px; margin-left: -10px;
    border-radius: 0 0 3px 3px; background: var(--accent); transform: scaleX(0); transition: transform .4s var(--spring);
  }
  .nav-btn.on::after { transform: scaleX(1); }
  .nav-btn.main::after { display: none; }
  .nav-btn.on:not(.main) > svg { animation: pop .45s var(--spring); }

  /* ---------- Animaciones vivas v6.7 ---------- */
  @media (prefers-reduced-motion: no-preference) {
    @keyframes drift1 { to { transform: translate3d(14vmax, 10vmax, 0) scale(1.15); } }
    @keyframes drift2 { to { transform: translate3d(-12vmax, -14vmax, 0) scale(1.1); } }
    @keyframes par { to { translate: 0 -18vh; } }
    @keyframes orbit { to { transform: rotate(360deg); } }
    @keyframes float { 50% { transform: translateY(-4px); } }
    @keyframes ripple { from { opacity: .55; transform: scale(1); } to { opacity: 0; transform: scale(1.5); } }
    @keyframes glint { to { transform: translateX(120%); } }
    @keyframes chr { from { opacity: 0; transform: translateY(.6em); } to { opacity: 1; transform: none; } }
    @keyframes vIn { from { opacity: 0; transform: translateY(26px) scale(.97); } }
    @keyframes vOut { to { opacity: .4; transform: scale(.95); } }

    /* Aurora ambiental con paralaje al hacer scroll */
    body::before, body::after { content: ""; position: fixed; z-index: -1; pointer-events: none; width: 70vmax; height: 70vmax; border-radius: 50%; will-change: transform; }
    body::before {
      top: -35vmax; left: -25vmax;
      background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 17%, transparent), transparent);
      animation: par linear both;
    }
    body::after {
      bottom: -40vmax; right: -30vmax;
      background: radial-gradient(closest-side, color-mix(in srgb, #7621b0 15%, transparent), transparent);
      animation: par linear both;
    }
    body.sheet-open::before, body.sheet-open::after { animation-play-state: paused; }

    /* Satélite orbitando el anillo */
    .orb { position: absolute; inset: 0; pointer-events: none; animation: orbit 9s linear infinite; }
    .orb::before {
      content: ""; position: absolute; top: calc(6.64% - 3.5px); left: 50%; width: 7px; height: 7px; margin-left: -3.5px;
      border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px 2px var(--accent);
    }

    /* Detalles vivos */
    .nav-btn.main .bubble { position: relative; }
    .nav-btn.main .bubble::after { content: ""; position: absolute; inset: 0; border-radius: 12px; border: 2px solid var(--accent); pointer-events: none; animation: ripple 3.2s ease-out infinite; }
    .btn.primary { position: relative; overflow: hidden; }
    .btn.primary::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%); transform: translateX(-120%); animation: glint 4s 1s ease-in-out infinite; }
    .empty svg { animation: float 3.2s ease-in-out infinite; }
    h2.chars span { display: inline-block; opacity: 0; }
    h2.chars.in span { animation: chr .6s var(--out) both; animation-delay: calc(var(--c) * 28ms); }

    /* Scroll: las tarjetas entran y se hunden al salir (solo Chrome/Android reciente) */
    @supports (animation-timeline: view()) {
      .layout .card, .layout .meal {
        animation-name: vIn, vOut; animation-duration: auto; animation-timing-function: linear; animation-fill-mode: both;
        animation-timeline: view(), view(); animation-range: entry 0% entry 35%, exit 60% exit 100%;
      }
      body::before, body::after { animation-timeline: scroll(root); }
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-delay: 0s !important; }
  }

  /* ---------- Objetivos táctiles ≥ 44 px en pantallas táctiles (el aspecto en escritorio no cambia) ---------- */
  @media (pointer: coarse) {
    .btn.sm, .date-btn, .seg button, .mode-switch button, .text-btn, .chip, .chip.sm { height: 44px; }
    .icon-btn { position: relative; }
    .icon-btn::after { content: ""; position: absolute; inset: -4px -8px; }
    .stepper button { width: 40px; height: 44px; }
    .daily { grid-template-columns: 1fr 1.6fr 1fr; }
    .switch input { inset: -8px -4px; width: calc(100% + 8px); height: calc(100% + 16px); }
    .g-input { height: 44px; }
    .g-input input { height: 42px; }
    .link-btn { position: relative; }
    .link-btn::after { content: ""; position: absolute; inset: -14px -8px; }
    .ai-row { grid-template-columns: 44px 1fr auto; }
    .ai-row input[type="checkbox"] { width: 28px; height: 28px; justify-self: center; }
  }
