:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #8b92a1;
  --accent: #ff6a3d;
  --accent-2: #ffb03d;
  --ok: #3ddc97;
  --water: #4fb3ff;
  --protein: #c08bff;
  --danger: #ff5c6c;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=number] { -moz-appearance: textfield; text-align: center; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { margin-top: 6px; color: var(--text); }

.brand { font-weight: 900; letter-spacing: .08em; font-size: 18px; }
.brand span { color: var(--accent); }
.brand.big { font-size: 34px; text-align: center; margin-bottom: 24px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card form { display: grid; gap: 14px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(15,17,21,.92); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; border-bottom: 1px solid var(--line);
}
.datebar { display: flex; align-items: center; gap: 4px; }
.date-label { background: none; border: 0; font-weight: 600; padding: 6px 8px; border-radius: 8px; text-transform: capitalize; }
.icon-btn { background: var(--panel-2); border: 1px solid var(--line); width: 34px; height: 34px; border-radius: 10px; font-size: 20px; line-height: 1; }
main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(23,26,33,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar button { background: none; border: 0; padding: 8px 0 10px; font-size: 11px; color: var(--muted); display: grid; gap: 2px; justify-items: center; }
.tabbar .ti { font-size: 18px; }
.tabbar button.active { color: var(--accent); }

/* componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.spacer { height: 8px; }
.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0d07; }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:active { transform: scale(.98); }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); }
.chip.accent { background: rgba(255,106,61,.15); color: var(--accent); border-color: rgba(255,106,61,.4); }
.chip.ok { background: rgba(61,220,151,.12); color: var(--ok); border-color: rgba(61,220,151,.4); }

.hero { background: linear-gradient(135deg, #24160f, #171a21 60%); border-color: #3a2a20; }
.hero .title { font-size: 24px; font-weight: 800; margin: 6px 0 4px; }

.meter { margin: 10px 0; }
.meter .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.meter .lbl b { font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .3s; }
.bar.protein > i { background: var(--protein); }
.bar.water > i { background: var(--water); }
.bar.over > i { background: var(--danger); }

.water-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.water-btns .btn { color: var(--water); }

/* entreno */
.ex { border-top: 1px solid var(--line); padding: 12px 0; }
.ex:first-of-type { border-top: 0; padding-top: 0; }
.ex-name { font-weight: 700; }
.ex-meta { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.prev { font-size: 12px; color: var(--accent-2); margin-bottom: 8px; }
.set { display: grid; grid-template-columns: 54px 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.set .tag { font-size: 12px; color: var(--muted); line-height: 1.2; }
.set .tag b { color: var(--text); font-size: 14px; }
.set.optional .tag { color: var(--accent-2); }
.set input.saved { border-color: rgba(61,220,151,.5); }
.ss-label { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--accent); margin-bottom: 6px; }
.energy { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.energy button { padding: 8px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; }
.energy button.on { background: var(--accent); color: #1a0d07; border-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); font-size: 15px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--ok); }

/* comida */
.meal-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.meal-item:first-of-type { border-top: 0; }
.meal-item .n { font-weight: 600; font-size: 14px; }
.meal-item .k { font-size: 12px; color: var(--muted); }
.x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 8px; }
.result { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--panel-2); margin-bottom: 6px; width: 100%; border: 1px solid transparent; text-align: left; }
.result img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.result.sel { border-color: var(--accent); }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 10px 0; }
.macros div { background: var(--panel-2); border-radius: 10px; padding: 8px 4px; }
.macros b { display: block; font-size: 16px; }
.macros span { font-size: 11px; color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 4px; }
.seg button { background: none; border: 0; padding: 8px 4px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

/* cuerpo */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo span { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 6px; }
.photo .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.55); border-radius: 8px; color: #fff; }
.wlist { display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.wlist div { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* progreso */
.chart-box { position: relative; height: 220px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #000; border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; color: var(--muted); padding: 20px 0; font-size: 14px; }
