:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e242c;
  --border: #2a313b;
  --text: #e7ebf0;
  --muted: #9aa6b2;
  --accent: #4f8cff;
  --accent-press: #3d77e6;
  --good: #3fbf7f;
  --radius: 14px;
  --maxw: 720px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 26px; }
.brand-sm strong { font-size: 17px; letter-spacing: -0.01em; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 6px;
  background: linear-gradient(140deg, var(--accent), #8ab4ff);
  display: inline-block;
}

/* ---------- Auth ---------- */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-sub { color: var(--muted); text-align: center; font-size: 14px; margin-bottom: 22px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.form-error { color: #ff6b6b; font-size: 13px; min-height: 18px; margin: 2px 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  color: var(--text);
  background: var(--surface-2);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-press); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); padding: 7px 12px; font-size: 14px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15,18,22,.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.content {
  flex: 1;
  width: 100%; max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px calc(96px + var(--safe-b));
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(15,18,22,.92);
  backdrop-filter: saturate(160%) blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  z-index: 10;
}
.tab {
  background: none; border: none; color: var(--muted);
  padding: 12px 2px; font-size: 12.5px; font-weight: 550; cursor: pointer;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tab.active { color: var(--text); border-top-color: var(--accent); }

/* ---------- Cards / layout ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 2px 10px; }
.section-title:first-child { margin-top: 4px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .muted { color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

.greeting h2 { font-size: 22px; }
.greeting p { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* progress / protein */
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--good); width: 0; transition: width .3s; }
.metric { font-size: 28px; font-weight: 680; letter-spacing: -0.02em; }
.metric small { font-size: 14px; color: var(--muted); font-weight: 500; }

/* checklist */
.check {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.check:last-child { border-bottom: none; }
.check .box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--border); flex: none;
  display: grid; place-items: center; transition: .15s;
}
.check.on .box { background: var(--good); border-color: var(--good); }
.check.on .box::after { content: ""; width: 6px; height: 11px; border: solid #08130d; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px,-1px); }
.check .label { flex: 1; font-size: 15px; }
.check.on .label { color: var(--muted); }
.check .grams { color: var(--muted); font-size: 13px; }

/* exercise */
.ex { padding: 14px 0; border-bottom: 1px solid var(--border); }
.ex:last-child { border-bottom: none; }
.ex-row { display: flex; gap: 14px; align-items: flex-start; }
.ex-info { flex: 1; min-width: 0; }
.ex-gif {
  flex: none;
  width: 96px; height: 96px;
  border-radius: 12px;
  background: #f4f6f8;
  object-fit: cover;
  border: 1px solid var(--border);
}
@media (min-width: 520px) {
  .ex-gif { width: 120px; height: 120px; }
}
.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ex-name { font-size: 15px; font-weight: 600; }
.ex-meta { color: var(--accent); font-size: 14px; font-weight: 600; white-space: nowrap; }
.ex-tip { color: var(--muted); font-size: 13px; margin-top: 4px; }
.ex-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ex-actions input {
  width: 84px; padding: 7px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
}
.ex-actions input:focus { border-color: var(--accent); }
.link { color: var(--accent); text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* day picker */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.meal-block + .meal-block { margin-top: 4px; }
.meal-tag { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 650; }
.meal-text { font-size: 15px; margin-top: 3px; }
.meal-protein { color: var(--muted); font-size: 13px; margin-top: 2px; }

.input-inline { display: flex; gap: 8px; align-items: center; }
.input-inline input {
  flex: 1; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 15px; outline: none;
}
.input-inline input:focus { border-color: var(--accent); }

.hist-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.hist-row:last-child { border-bottom: none; }
.hist-row .date { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.callout {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; color: var(--muted); margin-bottom: 12px;
}
.callout b { color: var(--text); }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 12px; }
.cal-head strong { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { margin-bottom: 6px; }
.cal-dow span { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  display: flex; align-items: flex-start; justify-content: flex-start;
}
.cal-cell.out { background: transparent; border-color: transparent; cursor: default; }
.cal-cell .cal-num { font-size: 13px; font-weight: 550; padding: 6px 0 0 7px; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-cell.done { background: rgba(63,191,127,.12); }
.cal-tag {
  position: absolute; bottom: 13px; left: 0; right: 0;
  text-align: center;
  font-size: 9.5px; font-weight: 650; color: var(--accent);
  line-height: 1;
}
.cal-dots { position: absolute; top: 5px; right: 5px; display: flex; gap: 3px; }
.dot { width: 6px; height: 6px; border-radius: 99px; display: inline-block; }
.dot.dg { background: var(--good); }
.dot.db { background: var(--accent); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 2px; color: var(--muted); font-size: 13px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Tu semana */
.week-list { display: flex; flex-direction: column; }
.week-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.week-row:last-child { border-bottom: none; }
.week-day { font-weight: 600; font-size: 14px; white-space: nowrap; }
.week-text { color: var(--muted); font-size: 14px; text-align: right; }
.week-row.today { background: rgba(79,140,255,.10); border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.week-row.today .week-day { color: var(--accent); }

/* desktop niceties */
@media (min-width: 760px) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-2 .card { margin-bottom: 0; }
}
