/* Diario de entreno — estilo apple-design, base mobile-native */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: #d2d2d7;
  --fill: #e8e8ed;
  --fill-2: #dfdfe4;
  --accent: #0066cc;
  --accent-2: #0071e3;
  --accent-soft: rgba(0, 102, 204, .1);
  --warn: #f56300;
  --warn-soft: #fae9e1;
  --danger: #b64400;
  --bar-bg: rgba(245, 245, 247, .8);
  --shadow-float: 2px 4px 16px #00000029;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .06);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --r-card: 17px;
  --r-input: 12px;
  --r-pill: 980px;
  --tabbar-h: 64px;
  --tabbar-bg: rgba(250, 250, 252, .88);
  --tabbar-pill: #e8e8ed;
  --tabbar-ink: #1d1d1f;
  --tabbar-active: #f56300;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1d1d1f;
    --text: #f5f5f7;
    --text-2: #86868b;
    --text-3: #6e6e73;
    --sep: #333336;
    --fill: #272729;
    --fill-2: #333336;
    --accent: #2997ff;
    --accent-2: #2997ff;
    --accent-soft: rgba(41, 151, 255, .16);
    --warn: #ff791b;
    --warn-soft: #471e00;
    --danger: #ff791b;
    --bar-bg: rgba(22, 22, 23, .8);
    --tabbar-bg: rgba(29, 29, 31, .88);
    --tabbar-pill: #333336;
    --tabbar-ink: #f5f5f7;
    --tabbar-active: #ff791b;
    --shadow-card: none;
  }
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.4 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button, [role="button"], .tab, .chip, label.check, .grab {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
input, select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--text);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent;
  transition: border-color 200ms ease;
}
.top.scrolled { border-bottom-color: var(--sep); }
.top-in {
  max-width: 640px; margin: 0 auto;
  height: 48px; padding: 0 8px;
  display: grid; grid-template-columns: 44px 1fr 44px 44px; align-items: center;
}
.top.no-nav #prevDay, .top.no-nav #nextDay { visibility: hidden; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-pill);
  display: grid; place-items: center; color: var(--accent);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.icon-btn:active { transform: scale(0.92); background: var(--accent-soft); }
.date-btn {
  justify-self: center; height: 32px; padding: 0 14px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 17px;
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.date-btn:active { transform: scale(0.97); background: var(--fill); }
.date-btn.not-today { background: var(--accent-soft); color: var(--accent); }

/* ---------- Vista ---------- */
.view {
  max-width: 640px; margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 32px);
}
.view.enter { animation: viewIn 180ms var(--ease-out); }
.view.enter-l { animation: viewInL 200ms var(--ease-out); }
.view.enter-r { animation: viewInR 200ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes viewInL { from { opacity: 0; transform: translateX(-16px); } }
@keyframes viewInR { from { opacity: 0; transform: translateX(16px); } }

.lt { padding: 8px 4px 16px; }
.lt h1 { margin: 0; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.lt .sub { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }

.section-title {
  margin: 28px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-2);
  display: flex; justify-content: space-between; align-items: baseline;
}
.section-title .aside { text-transform: none; letter-spacing: 0; font-weight: 400; }

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 12px;
}
.card.flush { padding: 0; overflow: hidden; }
.cap { font-size: 13px; color: var(--text-2); }
.muted { color: var(--text-2); }
.tnum { font-variant-numeric: tabular-nums; }
.pos { color: var(--accent); }
.neg { color: var(--warn); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 16px;
  background: var(--accent-2); color: #fff;
  transition: transform 140ms var(--ease-out), opacity 140ms ease;
}
.btn:active { transform: scale(0.97); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: var(--fill); color: var(--text); }
.btn.danger { background: var(--warn-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 15px; }
.btn[disabled] { background: var(--fill); color: var(--text-3); }
.link { color: var(--accent); font-size: 15px; font-weight: 500; padding: 8px 0; }
.link:active { opacity: .6; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.action {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: 14px 8px 12px; display: grid; justify-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; text-align: center; line-height: 1.2;
  transition: transform 140ms var(--ease-out);
}
.action:active { transform: scale(0.96); }
.action .ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- Anillo de hoy ---------- */
.ring-card { display: grid; gap: 16px; }
.ring-wrap { position: relative; width: 196px; height: 196px; margin: 4px auto 0; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap .track { stroke: var(--fill); }
.ring-wrap .prog {
  stroke: var(--accent); stroke-linecap: round;
  transition: stroke-dashoffset 600ms var(--ease-out), stroke 200ms ease;
}
.ring-wrap .prog.over { stroke: var(--warn); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center .big { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; border-top: .5px solid var(--sep); padding-top: 12px; }
.stats3 > div + div { border-left: .5px solid var(--sep); }
.stats3 .num { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.meter { height: 8px; border-radius: var(--r-pill); background: var(--fill); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; transition: transform 500ms var(--ease-out); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row + .row { margin-top: 8px; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; font-size: 15px; }
.kv + .kv { border-top: .5px solid var(--sep); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Semana */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; margin-top: 12px; }
.week .col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; text-align: center; }
.week .barbox { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.week .bar { width: 100%; max-width: 28px; border-radius: 6px; background: var(--accent); transform-origin: bottom; animation: grow 400ms var(--ease-out) both; }
.week .bar.neg { background: var(--warn); }
.week .bar.nodata { background: var(--fill); height: 4px; }
.week .col.sel .d { color: var(--text); font-weight: 600; }
.week .d { font-size: 12px; color: var(--text-3); }
@keyframes grow { from { transform: scaleY(0.2); opacity: 0; } }

/* ---------- Comida ---------- */
.sum-strip {
  position: sticky; top: calc(48px + env(safe-area-inset-top, 0px)); z-index: 5;
  margin: 0 -16px 12px; padding: 8px 20px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  display: flex; justify-content: space-between; font-size: 15px;
}
.sum-strip b { font-variant-numeric: tabular-nums; }
.meal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.meal-title { font-size: 19px; font-weight: 600; line-height: 1.25; margin-top: 2px; }
.pill {
  flex: none; height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--fill); font-size: 14px; font-weight: 500; color: var(--text);
  transition: transform 140ms var(--ease-out);
}
.pill:active { transform: scale(0.95); }
.ings { list-style: none; margin: 8px 0 0; padding: 0; }
.ings li + li { border-top: .5px solid var(--sep); }
label.check {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center;
  min-height: 48px; padding: 6px 0; cursor: pointer;
}
label.check input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  width: 24px; height: 24px; border-radius: var(--r-pill);
  border: 1.6px solid var(--sep); display: grid; place-items: center;
  transition: background-color 160ms ease, border-color 160ms ease, transform 140ms var(--ease-out);
}
.box svg { width: 14px; height: 14px; }
.box path { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 200ms var(--ease-out); }
label.check:active .box { transform: scale(0.88); }
label.check input:checked + .box { background: var(--accent-2); border-color: var(--accent-2); }
label.check input:checked + .box path { stroke-dashoffset: 0; }
label.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.ing-name { font-size: 16px; line-height: 1.3; transition: color 160ms ease; }
.ing-k { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
label.check input:not(:checked) ~ .ing-name { color: var(--text); }
.meal-foot { display: flex; justify-content: space-between; align-items: center; border-top: .5px solid var(--sep); margin-top: 4px; padding-top: 4px; }
.meal-foot .tot { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.meal-foot .tot b { color: var(--text); font-weight: 600; }
.add-snack { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--fill); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.chip small { color: var(--text-2); font-weight: 400; }
.chip:active { transform: scale(0.95); background: var(--fill-2); }
.extra-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.extra-row + .extra-row { border-top: .5px solid var(--sep); }
.extra-row .n { flex: 1; font-size: 16px; }
.extra-row .k { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 15px; }
.del {
  width: 32px; height: 32px; border-radius: var(--r-pill); display: grid; place-items: center;
  color: var(--text-3); transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.del:active { transform: scale(0.9); background: var(--warn-soft); color: var(--danger); }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 12px; }
.field > span { font-size: 13px; color: var(--text-2); padding-left: 4px; }
.input, .select, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border-radius: var(--r-input); border: 0;
  background: var(--fill); outline: none;
  transition: box-shadow 140ms ease, background-color 140ms ease;
}
.input:focus, .select:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.4; }
.inline-form { display: grid; grid-template-columns: 1fr 84px; gap: 8px; margin-top: 12px; }
.inline-form .full { grid-column: 1 / -1; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 10px; padding: 2px; position: relative; }
.seg button { position: relative; z-index: 1; height: 32px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text); transition: color 160ms ease; }
.seg .thumb { position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 2px; border-radius: 8px; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: transform 240ms var(--ease-out); }

/* ---------- Entreno ---------- */
.session-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.session-head .t { flex: 1; font-size: 19px; font-weight: 600; min-width: 0; }
.session-head .kc { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.block { border-top: .5px solid var(--sep); padding: 12px 0 4px; }
.block-head { display: flex; align-items: center; gap: 8px; }
.tag-select {
  appearance: none; -webkit-appearance: none; border: 0;
  height: 28px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600;
  field-sizing: content; max-width: 50%;
}
.block-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text); background: transparent; border: 0; padding: 4px 0; outline: none; text-overflow: ellipsis; }
.block-kc { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.block-meta { display: grid; grid-template-columns: 96px 1fr; gap: 8px; margin: 8px 0; }
.mini { display: grid; gap: 2px; }
.mini span { font-size: 12px; color: var(--text-2); padding-left: 4px; }
.mini .input { min-height: 40px; padding: 8px 12px; }
.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 8px 0; }
.item + .item { border-top: .5px solid var(--fill); }
.item-row { display: grid; grid-template-columns: 52px 1fr 72px 28px; gap: 8px; align-items: center; }
.item-row .reps { min-height: 36px; padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.item-row .nm { min-height: 36px; padding: 6px 10px; }
.item-row .kg { min-height: 36px; padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 60px; }
.set { display: flex; align-items: center; gap: 4px; background: var(--fill); border-radius: 10px; padding: 2px 4px 2px 8px; }
.set .r { width: 28px; border: 0; background: transparent; text-align: center; padding: 4px 0; font-size: 16px; font-variant-numeric: tabular-nums; }
.set .x { color: var(--text-3); font-size: 13px; }
.set .w { width: 52px; border: 0; background: var(--surface); border-radius: 8px; text-align: right; padding: 4px 6px; font-size: 16px; font-variant-numeric: tabular-nums; }
.hint { margin: 6px 0 0 60px; font-size: 13px; color: var(--text-2); }
.hint b { color: var(--accent); font-weight: 600; }
.act-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.empty {
  text-align: center; padding: 32px 16px; color: var(--text-2); font-size: 15px;
}
.empty .ico { width: 56px; height: 56px; border-radius: var(--r-pill); background: var(--fill); display: grid; place-items: center; margin: 0 auto 12px; color: var(--text-3); }

/* ---------- Progreso ---------- */
.big-stat { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big-stat small { font-size: 17px; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.chart { width: 100%; height: auto; margin-top: 12px; overflow: visible; }
.chart .grid { stroke: var(--fill); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.soft { stroke: var(--text-3); stroke-width: 1.6; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: var(--accent-soft); }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 700ms var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 56px; padding: 8px 16px; transition: background-color 140ms ease;
}
.list-row + .list-row { border-top: .5px solid var(--sep); }
.list-row:active { background: var(--fill); }
.list-row .main { flex: 1; min-width: 0; }
.list-row .t { font-size: 16px; font-weight: 500; }
.list-row .s { font-size: 13px; color: var(--text-2); }
.list-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.chev { color: var(--text-3); }
.weight-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--accent); vertical-align: middle; margin-right: 6px; }
.legend i.soft { background: var(--text-3); }

/* ---------- Barra inferior ---------- */
/* Píldora flotante: solo iconos, la pestaña activa en naranja sobre una cápsula gris que se desliza */
.tabbar {
  --pad: 6px;
  position: fixed; z-index: 30;
  /* Pegada al borde: en iPhone con barra de inicio queda a ~20 px, justo por encima del indicador */
  left: 16px; right: 16px; bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) - 14px));
  max-width: 440px; margin: 0 auto;
  height: var(--tabbar-h); padding: var(--pad);
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-radius: var(--r-pill);
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 2px 4px 16px #00000014, 0 0 0 .5px rgba(0, 0, 0, .04);
}
.tab-pill {
  position: absolute; top: var(--pad); bottom: var(--pad); left: var(--pad);
  width: calc((100% - var(--pad) * 2) / 4);
  border-radius: var(--r-pill); background: var(--tabbar-pill);
}
.tabbar.ready .tab-pill { transition: transform 280ms var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .tabbar.ready .tab-pill { transition: none; } }
.tab {
  position: relative; z-index: 1; border-radius: var(--r-pill);
  display: grid; place-items: center;
  color: var(--tabbar-ink);
  transition: color 160ms ease;
}
.tab svg { width: 28px; height: 28px; transition: transform 140ms var(--ease-out); }
.tab:active svg { transform: scale(0.88); }
.tab[aria-selected="true"] { color: var(--tabbar-active); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Hoja inferior ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 1000; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity 240ms ease; }
.sheet-layer.open .backdrop { opacity: 1; transition-duration: 360ms; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 17px 17px 0 0;
  box-shadow: var(--shadow-float);
  transform: translateY(100%);
  transition: transform 240ms var(--ease-out);
  will-change: transform;
}
.sheet.tall { height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px); }
.sheet-layer.open .sheet { transform: translateY(0); transition: transform 420ms var(--ease-drawer); }
.grab { height: 20px; display: grid; place-items: center; cursor: grab; touch-action: none; flex: none; }
.grab span { width: 36px; height: 5px; border-radius: var(--r-pill); background: var(--fill-2); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px 20px; touch-action: none; flex: none; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
.sheet-body .card { box-shadow: none; }
.preview-img { width: 100%; max-height: 240px; object-fit: cover; object-position: top; border-radius: 12px; display: block; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--accent); animation: spin 700ms linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 24px 0; color: var(--text-2); font-size: 15px; }
.note { font-size: 13px; color: var(--text-2); line-height: 1.45; margin: 8px 4px 0; }
.err { background: var(--warn-soft); color: var(--danger); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; left: 50%; z-index: 1001;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: var(--r-pill); font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow-float); max-width: calc(100vw - 32px); text-align: center;
  transition: transform 240ms var(--ease-out), opacity 200ms ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Solo con ratón ---------- */
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--accent-soft); }
  .chip:hover, .pill:hover { background: var(--fill-2); }
  .list-row:hover { background: var(--fill); }
  .btn:hover { opacity: .9; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .view.enter, .view.enter-l, .view.enter-r { animation: fadeOnly 150ms ease; }
  @keyframes fadeOnly { from { opacity: 0; } }
  .sheet, .sheet-layer.open .sheet { transition: none; }
  .week .bar { animation: none; }
  .chart .draw { animation: none; stroke-dashoffset: 0; }
  .ring-wrap .prog, .meter > i { transition: none; }
  .toast { transform: translate(-50%, 0); }
}

/* ---------- Comida: selector de vista, semana y mes ---------- */
.food-seg { margin: -4px 0 12px; }
.week-sum { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.week-sum > div + div { border-left: .5px solid var(--sep); }
.week-sum .num { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.plan-day { padding: 0; overflow: hidden; }
.plan-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.plan-day-head {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  min-height: 52px; padding: 8px 12px 8px 16px; border-bottom: .5px solid var(--sep);
  transition: background-color 140ms ease;
}
.plan-day-head:active { background: var(--fill); }
.pd-date { flex: 1; min-width: 0; font-size: 16px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pd-date b { font-weight: 600; }
.pd-k { font-size: 14px; color: var(--text-2); white-space: nowrap; }
.pd-k b { color: var(--text); font-weight: 600; }
.today-pill { font-size: 12px; font-weight: 600; color: #fff; background: var(--accent-2); border-radius: var(--r-pill); padding: 1px 8px; }
.plan-meals { list-style: none; margin: 0; padding: 0 0 4px; }
.plan-meal {
  width: 100%; display: grid; grid-template-columns: 84px 1fr; gap: 8px; align-items: baseline; text-align: left;
  min-height: 40px; padding: 8px 16px; transition: background-color 140ms ease;
}
.plan-meal:active { background: var(--fill); }
.pm-slot { font-size: 13px; color: var(--text-2); }
.pm-name { font-size: 15px; line-height: 1.3; }
.month { padding: 12px; }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mgrid.head { margin-bottom: 4px; }
.mgrid.head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3); }
.mc {
  position: relative; min-height: 56px; border-radius: 10px; padding: 4px 2px 6px;
  display: grid; align-content: start; justify-items: center; gap: 2px;
  background: var(--bg); transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.mc.empty { background: transparent; }
.mc:active { transform: scale(0.94); }
.mc-n { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 3px; }
.mc-a { font-size: 9px; line-height: 1.15; letter-spacing: -0.02em; color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc.today { background: var(--accent-2); }
.mc.today .mc-n, .mc.today .mc-a { color: #fff; }
.mc.sel:not(.today) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.mc .tr, .legend .dot.tr { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); display: inline-block; }
.mc.today .tr { background: #fff; }
.mc-s { position: absolute; bottom: 4px; width: 14px; height: 3px; border-radius: 2px; }
.mc-s.ok, .legend .dot.ok { background: var(--accent); }
.mc-s.over, .legend .dot.over { background: var(--warn); }
.mc.today .mc-s { background: #fff; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
@media (hover: hover) and (pointer: fine) {
  .plan-day-head:hover, .plan-meal:hover { background: var(--fill); }
  .mc:not(.empty):not(.today):hover { background: var(--fill); }
}

/* ---------- Interruptor ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 16px; cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 52px; height: 32px; border-radius: var(--r-pill); background: var(--fill-2);
  position: relative; cursor: pointer; transition: background-color 200ms ease;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 240ms var(--ease-out);
}
.switch:checked { background: var(--accent-2); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Lista de la compra ---------- */
.food-seg button { font-size: 13px; }
.shop-sum-row { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.shop-sum-row > div + div { border-left: .5px solid var(--sep); }
.shop-sum-row .num { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.shop-sum .meter > i { transition: transform 300ms var(--ease-out); }
.shop-list { padding-top: 4px; padding-bottom: 4px; }
.shop-item + .shop-item { border-top: .5px solid var(--sep); }
.si-main { display: grid; gap: 2px; min-width: 0; }
.si-sub { font-size: 13px; color: var(--text-2); line-height: 1.35; }
.si-buy { font-size: 14px; font-weight: 600; color: var(--accent); }
label.shop-item input:checked ~ .si-main .si-buy { color: var(--text-3); }
.shop-home { display: grid; gap: 2px; padding: 10px 0; }
.shop-home + .shop-home { border-top: .5px solid var(--sep); }
.shop-home .ing-name { color: var(--text-2); }
label.shop-item input:checked ~ .si-main .ing-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
label.shop-item input:checked ~ .ing-k { color: var(--text-3); }

/* ---------- Tooltips de gráficas ---------- */
:root { --tip-bg: #1d1d1f; --tip-fg: #f5f5f7; --tip-pos: #2997ff; --tip-neg: #ff791b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tip-bg: #f5f5f7; --tip-fg: #1d1d1f; --tip-pos: #0066cc; --tip-neg: #b64400; } }
.tipzone { position: relative; }
.tip {
  position: absolute; z-index: 5; left: 0; top: 0; pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px)) scale(0.96); transform-origin: 50% 100%;
  opacity: 0; background: var(--tip-bg); color: var(--tip-fg);
  font-size: 13px; line-height: 1.4; padding: 8px 12px; border-radius: 12px;
  white-space: nowrap; box-shadow: var(--shadow-float); font-variant-numeric: tabular-nums;
  transition: opacity 150ms ease, transform 150ms var(--ease-out), left 150ms var(--ease-out), top 150ms var(--ease-out);
}
.tip.show { opacity: 1; transform: translate(-50%, calc(-100% - 8px)) scale(1); }
.tip .t { font-weight: 600; }
.tip .tone-pos { color: var(--tip-pos); font-weight: 600; }
.tip .tone-neg { color: var(--tip-neg); font-weight: 600; }
.week .col { background: none; border-radius: 8px; padding: 0; }
.week .bar { transition: opacity 150ms ease; }
.week.has-active .col:not(.active) .bar { opacity: .35; }
.week .col.active .d { color: var(--text); font-weight: 600; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.tipzone.has-active .chart .dot { opacity: .5; }
.chart .hit.active { fill: var(--accent-soft); }
@media (prefers-reduced-motion: reduce) {
  .tip, .tip.show { transition: opacity 150ms ease; transform: translate(-50%, calc(-100% - 8px)); }
}

/* ================= v0.8 · Pulido de diseño ================= */
/* Título grande: fecha en versalitas encima, etiquetas debajo */
.lt { padding: 12px 4px 16px; }
.lt-date { margin: 0 0 2px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.lt h1 { font-size: 34px; letter-spacing: -0.025em; }
.lt .sub { margin-top: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--fill); color: var(--text); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
  gap: 0.28em; white-space: nowrap;
}
.tag-warm { background: var(--warm-soft); color: var(--warm); }

/* Anillos: calorías (exterior) y proteína (interior) */
:root { --warm: #f56300; --warm-soft: #fae9e1; --over: #b64400; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --warm: #ff791b; --warm-soft: #471e00; --over: #ff791b; } }
.ring-card { padding: 20px 16px 16px; gap: 20px; }
.ring-wrap { width: 212px; height: 212px; margin: 0 auto; }
.ring-wrap .track.t2 { stroke: var(--warm-soft); }
.ring-wrap .prog.p2 { stroke: var(--warm); transition: stroke-dashoffset 700ms var(--ease-out) 80ms; }
.ring-wrap .prog.over { stroke: var(--over); }
.ring-center .big { font-size: 38px; }
.ring-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ring-legend > div { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.ring-legend i { width: 10px; height: 10px; border-radius: 50%; grid-row: span 2; }
.ring-legend .dot-k { background: var(--accent); }
.ring-legend .dot-p { background: var(--warm); }
.ring-legend b { font-size: 15px; font-weight: 600; }
.stats3 { padding-top: 16px; }

/* Comida: franja fija con dos barras finas */
.sum-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 10px 20px 12px; border-bottom: .5px solid var(--sep); }
.ms-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.ms-top b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.mbar { display: block; height: 6px; margin-top: 6px; border-radius: var(--r-pill); background: var(--fill); overflow: hidden; }
.mbar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; transition: transform 400ms var(--ease-out), background-color 200ms ease; }
.mbar i.over { background: var(--over); }
.mbar.p { background: var(--warm-soft); }
.mbar.p i { background: var(--warm); }

/* Tarjetas de comida: cabecera más clara y filas más aireadas */
.meal { padding-bottom: 8px; }
.meal-title { font-size: 20px; letter-spacing: -0.01em; }
.ing-k { font-size: 14px; }

/* Entreno: campos más ligeros dentro de las tarjetas */
.session .input { background: var(--bg); }
.session .input:focus { background: var(--surface); }
.session-head .t { font-size: 20px; letter-spacing: -0.01em; }
.session-head .kc { background: var(--accent-soft); padding: 4px 10px; border-radius: var(--r-pill); font-size: 15px; }
.block { padding-top: 14px; }
.item-row .reps { background: var(--fill); font-weight: 600; }
.action { padding: 16px 8px 14px; }
.action .ico { width: 44px; height: 44px; border-radius: 14px; }
.action:nth-child(1) .ico { background: var(--warm-soft); color: var(--warm); }

/* Progreso */
.weight-form .input { background: var(--bg); }
.big-stat { font-size: 40px; }

/* Secciones */
.section-title { margin-top: 28px; }
.card { border-radius: 20px; }
.ring-legend > div, .ms { min-width: 0; }
