/* Weight Journey — mobile-first dark theme */
:root {
  --bg: #0f1115;
  --bg-soft: #151821;
  --card: #1a1e28;
  --card-edge: #262b38;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --green: #4ade80;
  --green-dim: #22c55e;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 0.25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; color: var(--green); }
h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
p { margin: 0.5rem 0; }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Header ---------- */
.site-header {
  padding: 18px 16px 4px;
  max-width: 720px;
  margin: 0 auto;
}
.site-header .brand {
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
}
.site-header .goal-chip {
  float: right;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--green);
  background: rgba(74, 222, 128, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.card h2 { margin-top: 0; }
.card h3 { margin-top: 0; }

/* Phase banner */
.banner {
  background: linear-gradient(135deg, #1e3a5f, #14532d);
  border: 1px solid #2c4a6e;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  font-weight: 600;
}
.banner .big { font-size: 1.3rem; display: block; }

/* ---------- Meal cards ---------- */
.meal {
  display: block;
}
.meal .meal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.meal .meal-num {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meal .macros {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pill {
  background: var(--bg-soft);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.cal { color: var(--amber); }
.pill.pro { color: var(--green); }
.pill.fat { color: var(--blue); }

ul, ol { padding-left: 1.25rem; margin: 0.5rem 0; }
li { margin: 0.3rem 0; }

/* ---------- Stat grid (dashboard) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}
.stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.stat .value {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 2px;
}
.stat .value.green { color: var(--green); }
.stat .value.blue { color: var(--blue); }

/* Progress bar */
.bar-wrap {
  background: var(--bg-soft);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  border-radius: 999px;
  min-width: 6px;
  transition: width 0.6s ease;
}

/* Chart */
.chart-box {
  position: relative;
  height: 300px;
  margin: 8px 0;
}

/* ---------- Tables → stacked on mobile ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--card-edge);
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Shopping checklist ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { margin: 0; }
.checklist label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--card-edge);
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.checklist li:last-child label { border-bottom: none; }
.checklist input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
  flex-shrink: 0;
}
.checklist input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
}
.reset-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin: 16px 0;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Rules list (cruise) ---------- */
.rule {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.rule .num {
  background: var(--green);
  color: #052e16;
  font-weight: 800;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-edge);
  display: flex;
  z-index: 100;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  min-height: 44px;
}
.tabbar a .ico { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--green); }

/* ---------- Desktop ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 0; font-size: 17px; }
  h1 { font-size: 2rem; }
  .tabbar {
    position: sticky;
    top: 0;
    bottom: auto;
    height: 56px;
    border-top: none;
    border-bottom: 1px solid var(--card-edge);
  }
  .tabbar a { flex-direction: row; gap: 8px; font-size: 0.85rem; }
  main { padding: 24px 16px; }
  .stats { gap: 14px; }
  .stat .value { font-size: 2rem; }
  .chart-box { height: 380px; }
}
