:root {
  /* Paleta inspirada en Firebase: ámbar/naranja sobre grises claros, azul marino en modo oscuro */
  --bg: #f8f9fa;
  --card: #ffffff;
  --card-2: #f1f3f4;
  --text: #202124;
  --muted: #5f6368;
  --line: #e0e3e7;
  --accent: #ff9100;
  --accent-strong: #f57c00;
  --accent-ink: #1f1300;
  --accent-soft: #fff3e0;
  --grad: linear-gradient(135deg, #ffc400 0%, #ff9100 55%, #f4511e 100%);
  --danger: #d93025;
  --warn: #b06000;
  --warn-soft: #fef7e0;
  --p: #e8453c;
  --c: #039be5;
  --f: #7cb342;
  --fib: #8e24aa;
  --water: #00acc1;
  --ok: #34a853;
  --ring-track: #eceff1;
  --shadow: 0 1px 2px rgba(60,64,67,.08), 0 2px 8px rgba(60,64,67,.08);
  --radius: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --card: #141d2f;
  --card-2: #1b263b;
  --text: #e8eaed;
  --muted: #9aa4b5;
  --line: #263247;
  --accent: #ffab00;
  --accent-strong: #ffc400;
  --accent-ink: #1f1300;
  --accent-soft: #33280f;
  --danger: #f28b82;
  --warn: #fdd663;
  --warn-soft: #3a3010;
  --p: #f28b82;
  --c: #4fc3f7;
  --f: #aed581;
  --fib: #ce93d8;
  --water: #4dd0e1;
  --ok: #81c995;
  --ring-track: #222d42;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 26px; line-height: 1; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.date-btn { flex: 1; text-align: center; font-weight: 700; font-size: 18px; padding: 8px; border-radius: 12px; }
.settings { color: var(--text); }

.wrap { max-width: 560px; margin: 0 auto; padding: 4px 16px 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }

.install-hint { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: 14px; padding: 10px 14px; font-size: 14px; }
.link { color: var(--accent-strong); font-weight: 600; }

/* Summary */
.summary { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; }
.summary .ring { width: 120px; height: 120px; }
.summary .ring svg { width: 120px; height: 120px; }
.ring { position: relative; width: 132px; height: 132px; }
.ring svg { transform: rotate(-90deg); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-big { font-size: 28px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.ring-sub { font-size: 12px; color: var(--muted); }
.over .ring-big { color: var(--danger); }
.kpis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.kpis b { display: block; font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.macro { margin-top: 8px; }
.macro-head { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; white-space: nowrap; }
.macro-head span:first-child { overflow: hidden; text-overflow: ellipsis; }
.macro-head span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 99px; background: var(--ring-track); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .4s ease; }

/* Meals */
#meals { display: grid; gap: 12px; }
.meal { padding: 14px 16px 8px; }
.meal-head { display: flex; align-items: center; gap: 10px; }
.meal-title { flex: 1; font-weight: 700; }
.meal-kcal { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.add-mini { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-size: 22px; font-weight: 600; }
.entries { list-style: none; margin: 6px 0 0; padding: 0; }
.entry { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 13px; color: var(--muted); }
.entry-kcal { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 14px; padding: 4px 0 8px; }

/* Week */
.week h3 { margin: 0 0 10px; font-size: 15px; }
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 110px; }
.wb { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; text-align: center; font-size: 11px; color: var(--muted); }
.wb-col { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.wb-col i { width: 100%; max-width: 26px; border-radius: 8px 8px 4px 4px; background: var(--accent); opacity: .85; min-height: 3px; }
.wb-col i.over { background: var(--danger); }
.wb.sel { color: var(--text); font-weight: 700; }
.goal-line { position: absolute; left: -4px; right: -4px; border-top: 2px dashed var(--text); opacity: .35; z-index: 1; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(255,145,0,.4);
}
.fab:active { transform: scale(.95); }

/* Sheets */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet {
  background: var(--bg); width: 100%; max-width: 600px;
  max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  animation: up .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.close-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 18px; color: var(--muted); }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: var(--card); border-radius: 14px; padding: 4px; margin: 12px 0; box-shadow: var(--shadow); }
.tab { padding: 8px 2px; border-radius: 10px; font-size: 12px; display: grid; justify-items: center; gap: 2px; color: var(--muted); }
.tab svg { width: 20px; height: 20px; }
.tab.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label, .lbl { font-size: 13px; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 96px; resize: vertical; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn:not(.ghost):not(.danger):not(.google) { background: var(--grad); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.15); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn + .btn { margin-top: 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.examples button { font-size: 13px; padding: 6px 10px; border-radius: 99px; background: var(--card-2); border: 1px dashed var(--line); color: var(--muted); }

.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; margin-bottom: 12px; display: block; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 12px; }
#reader video { border-radius: 14px; }

/* Lists */
.list { display: grid; gap: 8px; margin-top: 12px; }
.li { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px 12px; text-align: left; width: 100%; }
.li img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.li .ph { width: 44px; height: 44px; border-radius: 8px; background: var(--card-2); flex: none; display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-weight: 600; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.li-sub { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; margin-left: 4px; vertical-align: 1px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* Review (resultado IA) */
.review-item { background: var(--card); border-radius: 14px; padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.review-item .nm { font-weight: 600; }
.review-item .qt { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.review-item .mac { font-size: 12px; color: var(--muted); }
.grams { display: flex; align-items: center; gap: 4px; }
.grams input { width: 76px; padding: 8px 10px; text-align: right; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); }
.rm { color: var(--muted); font-size: 20px; width: 30px; height: 30px; }
.total-bar { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 2px 12px; }
.total-bar b { font-size: 22px; }
.notes { font-size: 13px; color: var(--muted); background: var(--card-2); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }

/* Portion */
.portion-kcal { text-align: center; margin: 6px 0 14px; }
.portion-kcal b { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.portion-macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; text-align: center; }
.portion-macros div { background: var(--card); border-radius: 12px; padding: 8px; font-size: 13px; color: var(--muted); }
.portion-macros b { display: block; font-size: 17px; color: var(--text); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.seg { display: flex; gap: 6px; }
.seg .chip { flex: 1; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- v2 ---------- */
.muted { color: var(--muted); }
.splash, .center-screen { min-height: 100dvh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; gap: 8px; }
.splash img { width: 72px; height: 72px; border-radius: 18px; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); opacity: .8; } }
.login { gap: 12px; max-width: 380px; margin: 0 auto; }
.login-logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }
.login h1 { margin: 4px 0 0; font-size: 34px; letter-spacing: -.5px; }
.login p { margin: 0 0 16px; }
.btn.google { background: var(--card); color: var(--text); border: 1px solid var(--line); }

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tb { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); border-radius: 12px; }
.tb svg { width: 24px; height: 24px; }
.tb.on { color: var(--accent-strong); font-weight: 600; }

/* onboarding */
.onb { min-height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 16px); }
.onb-top { display: flex; align-items: center; gap: 10px; }
.onb-prog { flex: 1; height: 6px; border-radius: 99px; background: var(--ring-track); overflow: hidden; }
.onb-prog i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.onb-body { flex: 1; padding: 24px 2px; }
.onb-body h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 8px; letter-spacing: -.4px; }
.onb-body > p { margin: 0 0 20px; }
.onb-foot { display: grid; gap: 8px; }
.err { color: var(--danger); min-height: 18px; margin: 0; text-align: center; }
.opts { display: grid; gap: 10px; margin-top: 8px; }
.opt { display: grid; gap: 2px; text-align: left; padding: 16px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); }
.opt span { color: var(--muted); font-size: 14px; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.big-input-wrap { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin-top: 24px; }
.big-input { width: 180px; border: 0; border-bottom: 3px solid var(--accent); background: transparent; text-align: center; font-size: 56px !important; font-weight: 800; outline: none; padding: 4px; }
.big-input-wrap span { font-size: 22px; color: var(--muted); font-weight: 600; }
.wrap-chips { flex-wrap: wrap; overflow: visible; }
.plan-hero { text-align: center; margin: 4px 0 16px; }
.plan-hero b { display: block; font-size: 52px; font-weight: 800; letter-spacing: -1px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plan-hero span { color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--card); border-radius: 14px; padding: 10px 6px; text-align: center; display: grid; gap: 2px; box-shadow: var(--shadow); }
.tile b { font-size: 18px; }
.tile span { font-size: 12px; color: var(--muted); }
.card .tile { background: var(--card-2); box-shadow: none; }

/* hoy */
.extras { display: grid; gap: 12px; }
.extras-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.extras-grid .macro { margin-top: 0; }
.extras-grid .macro-head { flex-direction: column; }
.water .macro-head span:last-child { color: var(--muted); }
.cups { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.cup { width: 22px; height: 28px; border-radius: 3px 3px 7px 7px; border: 2px solid var(--water); opacity: .45; }
.cup.full { background: var(--water); opacity: 1; }
.cups .add-mini { width: 28px; height: 28px; font-size: 18px; margin-left: 4px; background: color-mix(in srgb, var(--water) 18%, transparent); color: var(--water); }
.suggest { display: flex; align-items: center; gap: 10px; border-top: 1px dashed var(--line); padding: 10px 0 6px; }
.suggest .chip { flex: none; }
.center-input { text-align: center; font-size: 20px !important; font-weight: 700; }

/* semana */
.card-title { margin: 0 0 8px; font-size: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card-2); border-radius: 14px; padding: 10px 12px; display: grid; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12px; color: var(--muted); }
.week-bars { height: 140px; }
.wb { grid-template-rows: auto 1fr auto; }
.wb-val { font-size: 10px; min-height: 13px; }
.wchart svg { display: block; overflow: visible; }
.wchart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.delta b { font-size: 26px; }
.checkin { border: 1.5px solid var(--accent-soft); }

/* plan */
.targets { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; gap: 4px; }
.targets b { display: block; font-size: 16px; }
.targets span { font-size: 11px; color: var(--muted); }
.day-chips .chip { flex: 1; text-align: center; min-width: 44px; }
.day-chips .chip.today:not(.on) { border-color: var(--accent); color: var(--accent-strong); }
.day-total { padding: 0 4px; }
.pmeal-name { font-weight: 700; font-size: 17px; margin: 2px 0; }
.pmeal-prep { font-size: 14px; margin: 6px 0 0; }
.ing { list-style: none; padding: 0; margin: 10px 0 0; }
.ing li { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.btn.sm { padding: 10px; font-size: 14px; }
.shop { display: grid; gap: 2px; }
.shop-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.shop-item input { width: 20px; height: 20px; accent-color: var(--accent); }
.shop-item input:checked + span { text-decoration: line-through; color: var(--muted); }

/* perfil */
.me { display: flex; align-items: center; gap: 14px; }
.me img, .avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.avatar { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 22px; }
.kv { margin: 4px 0 14px; }
.kv-row { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }

/* marca */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.3px; }
.brand img { width: 26px; height: 26px; }
.login h1 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-logo { border-radius: 24px; }
.credit { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 4px; }
.login .credit { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- animaciones ---------- */
:root { --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1); }
@keyframes slideInL { from { opacity: 0; transform: translateX(-26px); } }
@keyframes slideInR { from { opacity: 0; transform: translateX(26px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } }
@keyframes flash { from { background: var(--accent-soft); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fadeOut { to { opacity: 0; } }

/* Contenido que entra al cambiar de día, semana o pestaña (escalonado) */
.anim-l > *, .anim-r > *, .anim-up > * { animation-duration: .38s; animation-timing-function: var(--ease); animation-fill-mode: both; }
.anim-l > * { animation-name: slideInL; }
.anim-r > * { animation-name: slideInR; }
.anim-up > * { animation-name: fadeUp; }
.anim-l > :nth-child(2), .anim-r > :nth-child(2), .anim-up > :nth-child(2) { animation-delay: .04s; }
.anim-l > :nth-child(3), .anim-r > :nth-child(3), .anim-up > :nth-child(3) { animation-delay: .08s; }
.anim-l > :nth-child(4), .anim-r > :nth-child(4), .anim-up > :nth-child(4) { animation-delay: .12s; }
.anim-l > :nth-child(5), .anim-r > :nth-child(5), .anim-up > :nth-child(5) { animation-delay: .16s; }
.anim-l > :nth-child(n+6), .anim-r > :nth-child(n+6), .anim-up > :nth-child(n+6) { animation-delay: .2s; }
.date-btn.anim-l { animation: slideInL .3s var(--ease) both; }
.date-btn.anim-r { animation: slideInR .3s var(--ease) both; }
.date-btn.anim-up { animation: fadeIn .3s ease both; }

/* Respuesta al tocar */
button { transition: transform .15s var(--ease), background-color .2s, color .2s, border-color .2s, opacity .2s; }
.btn:active, .chip:active, .opt:active, .li:active, .entry:active, .add-mini:active, .icon-btn:active, .tab:active, .tb:active { transform: scale(.96); }
.opt.on, .chip.on { animation: pop .3s var(--spring); }
.tb.on svg { animation: pop .35s var(--spring); }
.tab.on svg { animation: pop .35s var(--spring); }

/* Anillo y barras: los valores se animan desde el anterior (ver app.js) */
.ring-fg { transition: stroke-dashoffset .7s var(--ease), stroke .3s; }
.bar i { transition: width .6s var(--ease), background-color .3s; }

/* Agua */
.cup { transition: background-color .25s, opacity .25s, transform .2s; }
.cup.pop { animation: pop .4s var(--spring); }

/* Registro nuevo */
.entry.new { animation: flash 1.2s ease-out, fadeUp .35s var(--ease); border-radius: 10px; }
.btn.pop, .chip.pop { animation: pop .4s var(--spring); }

/* Gráficos de la semana */
.wb-col i { transform-origin: bottom; animation: grow .55s var(--ease) both; }
.wb:nth-child(2) .wb-col i { animation-delay: .04s; } .wb:nth-child(3) .wb-col i { animation-delay: .08s; }
.wb:nth-child(4) .wb-col i { animation-delay: .12s; } .wb:nth-child(5) .wb-col i { animation-delay: .16s; }
.wb:nth-child(6) .wb-col i { animation-delay: .2s; } .wb:nth-child(7) .wb-col i { animation-delay: .24s; }
.wchart polyline { stroke-dasharray: 1; animation: draw 1s var(--ease) both; }
.wchart circle { animation: popIn .3s var(--spring) .5s both; transform-box: fill-box; transform-origin: center; }

/* Lista de compras: tilde con rebote y tachado animado */
.shop-item span:nth-of-type(1) { position: relative; transition: color .25s; }
.shop-item span:nth-of-type(1)::after { content: ""; position: absolute; left: 0; top: 52%; height: 1.5px; width: 0; background: currentColor; transition: width .3s var(--ease); }
.shop-item input:checked + span { text-decoration: none; }
.shop-item input:checked + span::after { width: 100%; }
.shop-item input:checked { animation: pop .3s var(--spring); }

/* Hojas: salida animada */
.overlay.closing { animation: fadeOut .2s ease forwards; }
.overlay.closing .sheet { animation: down .22s ease-in forwards; }

/* Cambio de tema suave */
.theme-anim, .theme-anim * { transition: background-color .35s ease, color .35s ease, border-color .35s ease, fill .35s, stroke .35s !important; }

/* Onboarding */
.onb-body.anim-r > *, .onb-body.anim-l > * { animation-duration: .35s; }

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

/* ---------- cantidad: g / ml y cucharadas ---------- */
.qty-row { display: flex; align-items: center; gap: 6px; }
.qty-row.big { gap: 10px; }
.qty-row.big .input { flex: 1; }
.qty-input { width: 72px; padding: 8px 10px; text-align: right; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); }
.unit-seg { display: inline-flex; flex: none; padding: 2px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
.unit-seg button { padding: 6px 9px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); min-width: 34px; }
.unit-seg button.on { background: var(--accent); color: var(--accent-ink); animation: pop .3s var(--spring); }
.qty-row.big .unit-seg button { padding: 11px 14px; font-size: 15px; min-width: 46px; }
.tbsp-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.tbsp-hint::before { content: "🥄 "; }
.review-item .tbsp-hint { grid-column: 1 / -1; margin-top: 0; }

/* ---------- encabezado de Hoy: título, racha, avatar y tira semanal ---------- */
.top.hoy-top { display: block; padding: calc(env(safe-area-inset-top) + 10px) 16px 6px; }
.hoy-row { display: flex; align-items: center; gap: 14px; max-width: 560px; margin: 0 auto; }
.title-btn { position: relative; flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; cursor: pointer; }
.title-txt { font-size: 30px; font-weight: 800; letter-spacing: -.6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.chev svg { width: 22px; height: 22px; color: var(--muted); display: block; margin-top: 4px; }
.title-btn input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.streak { display: flex; align-items: center; gap: 4px; font-size: 21px; }
.streak svg { width: 22px; height: 26px; fill: var(--muted); opacity: .55; }
.streak svg { transform-origin: 50% 90%; animation: ember 3.2s ease-in-out infinite; }
.streak.on svg { fill: url(#fl-on); opacity: 1; animation: pop .45s var(--spring), flicker 1.8s ease-in-out .45s infinite; filter: drop-shadow(0 0 0 rgba(255,145,0,0)); }
/* Llama viva: se balancea y respira apenas, en loop */
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 1px rgba(255,145,0,.25)); }
  25% { transform: scale(1.06, 1.1) rotate(-3deg); filter: drop-shadow(0 0 4px rgba(255,145,0,.45)); }
  50% { transform: scale(.97, 1.02) rotate(2deg); filter: drop-shadow(0 0 2px rgba(255,145,0,.3)); }
  75% { transform: scale(1.04, 1.07) rotate(-1.5deg); filter: drop-shadow(0 0 5px rgba(255,196,0,.5)); }
}
/* Apagada: respira muy suave */
@keyframes ember { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.avatar-btn { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px var(--card); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 42px; height: 42px; font-size: 18px; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); max-width: 560px; margin: 12px auto 0; touch-action: pan-y; }
.ws-day { display: grid; justify-items: center; gap: 4px; padding: 2px 0 4px; border-radius: 14px; }
.ws-l { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 700; color: var(--muted); transition: background-color .2s, color .2s; }
.ws-n { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background-color .3s; }
.ws-day.sel .ws-l { background: var(--text); color: var(--bg); animation: popIn .25s var(--spring); }
.ws-day.today .ws-n { color: var(--accent-strong); }
.ws-day.logged .ws-dot { background: var(--accent); }
.ws-day.future { opacity: .35; pointer-events: none; }
.week-strip.anim-l > *, .week-strip.anim-r > * { animation-duration: .3s; }

/* ---------- actividad ---------- */
.act-head { display: flex; align-items: center; gap: 8px; }
.act-head .card-title { margin: 0; }
.src { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--card-2); padding: 3px 9px; border-radius: 99px; }
.icon-btn.sm { width: 34px; height: 34px; font-size: 18px; color: var(--muted); }
.steps-line { display: flex; align-items: baseline; gap: 6px; margin-top: 10px; }
.steps-line b { font-size: 28px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.shoe { color: var(--accent); align-self: center; }
.shoe svg { width: 28px; height: 28px; display: block; }
.activity .bar { height: 8px; margin-top: 8px; }
.act-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.act-stats div { background: var(--card-2); border-radius: 12px; padding: 8px 10px; display: grid; }
.act-stats b { font-size: 15px; }
.act-stats span { font-size: 11.5px; color: var(--muted); }
.activity .entries { margin-top: 8px; }
.activity .entry-kcal { color: var(--accent-strong); }
.add-ex { margin-top: 10px; }
.steps-list { padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.token { display: block; word-break: break-all; background: var(--card-2); border: 1px dashed var(--line); padding: 12px; border-radius: 12px; font-size: 15px; margin: 8px 0 10px; user-select: all; -webkit-user-select: all; }

/* ---------- peso por día ---------- */
.w-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 14px 0 12px; }
.w-day { display: grid; justify-items: center; gap: 1px; padding: 6px 0; border-radius: 12px; border: 1px solid transparent; }
.w-day span { font-size: 11px; color: var(--muted); font-weight: 700; }
.w-day b { font-size: 16px; }
.w-day small { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.w-day.has small { color: var(--accent-strong); font-weight: 700; }
.w-day.on { background: var(--accent-soft); border-color: var(--accent); }
.w-del { display: block; margin: 10px auto 0; font-size: 14px; color: var(--danger); }

/* ---------- meta de actividad y festejo ---------- */
.fire { align-self: center; }
.fire svg { width: 24px; height: 28px; display: block; animation: flicker 1.8s ease-in-out infinite; transform-origin: 50% 90%; }
.goal-done { margin-left: auto; align-self: center; font-size: 13px; font-weight: 800; color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); padding: 4px 10px; border-radius: 99px; animation: popIn .45s var(--spring) both; white-space: nowrap; }
.activity.done { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ok) 55%, transparent), var(--shadow); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -20px; animation-name: confetti; animation-timing-function: cubic-bezier(.25,.6,.4,1); animation-fill-mode: forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), 105vh) rotate(var(--r)); opacity: 0; }
}
.steps-line { flex-wrap: wrap; row-gap: 6px; }
.steps-line .muted { white-space: nowrap; }
