/*
 * BodyMap webapp shell — design v2
 * Mobile-first. Desktop ≥880px: phone frame centered.
 */
:root {
  --white: #FFFFFF;
  --off-white: #F7F4ED;
  --light: #ECE6D8;
  --mid: #C5BBA8;
  --dark: #15140F;
  --charcoal: #2A2926;
  --muted: #807B70;
  --green: #2D5016;
  --green-mid: #4A7A28;
  --green-light: #7AAF4A;
  --green-pale: #DBEAC4;
  --accent: #E8622A;
  --gold: #C4922A;
  --shadow-sm: 0 2px 8px rgba(21,20,15,0.06);
  --shadow-md: 0 12px 28px rgba(21,20,15,0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--off-white);
  color: var(--dark);
  min-height: 100vh;
  padding-bottom: 84px;
  -webkit-font-smoothing: antialiased;
}

/* ── DESKTOP: phone frame ── */
@media (min-width: 880px) {
  body {
    background: linear-gradient(145deg, #18170E 0%, #2A2924 100%);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    padding: 32px;
    gap: 56px;
  }
  .desktop-side { display: flex; flex-direction: column; gap: 28px; max-width: 300px; }
  .desktop-side .ds-kicker {
    font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--green-light);
  }
  .desktop-side h2 {
    font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700;
    color: #fff; line-height: 1.15; letter-spacing: -0.4px;
  }
  .desktop-side h2 em { font-style: italic; color: var(--green-light); font-weight: 400; }
  .desktop-side p { font-size: 13px; color: rgba(255,255,255,0.55); line-height: 1.65; }
  .desktop-side ul { list-style: none; margin-top: 4px; }
  .desktop-side li {
    font-size: 13px; color: rgba(255,255,255,0.65); padding: 7px 0;
    display: flex; gap: 10px; line-height: 1.45;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .desktop-side li::before { content: '→'; color: var(--green-light); font-size: 12px; flex-shrink: 0; }
  .phone-shell {
    width: 390px; background: #0A0A08;
    border-radius: 50px; padding: 12px;
    box-shadow:
      0 0 0 1.5px #232220,
      0 0 0 2.5px #181714,
      0 50px 100px -28px rgba(0,0,0,0.7),
      0 28px 60px -30px rgba(0,0,0,0.5);
    position: relative; flex-shrink: 0;
  }
  .phone-shell::before {
    content: '';
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    width: 100px; height: 26px;
    background: #0A0A08; border-radius: 100px; z-index: 10;
  }
  .phone-screen {
    background: var(--off-white);
    border-radius: 38px;
    overflow: hidden;
    height: 830px;
    display: flex; flex-direction: column;
  }
  .phone-screen > .app-header { padding-top: 56px; }
  .phone-screen > .app-main { flex: 1; overflow-y: auto; }
  .phone-screen > .app-main::-webkit-scrollbar { display: none; }
  .phone-screen > .bottom-nav { position: static; flex-shrink: 0; }
  body { padding-bottom: 0; }
}

@media (max-width: 879px) {
  .phone-shell, .phone-screen { display: contents; }
  .desktop-side { display: none; }
}

/* ── APP HEADER ── */
.app-header {
  background: var(--off-white);
  padding: 18px 20px 14px;
  display: flex; flex-direction: column; align-items: stretch;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--light);
}
.greeting-row {
  display: flex; justify-content: space-between; align-items: flex-start; width: 100%;
}
.greeting {
  font-family: 'Playfair Display', serif;
  font-size: 21px; font-weight: 600; line-height: 1.1; letter-spacing: -0.3px;
}
.greeting em { font-style: italic; color: var(--green-mid); }
.date-sub {
  font-family: 'DM Mono', monospace;
  font-size: 10px; color: var(--muted); margin-top: 4px; letter-spacing: 0.04em;
}
.streak-badge {
  background: var(--green-pale); color: var(--green);
  padding: 5px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 700; white-space: nowrap; letter-spacing: 0.01em;
}
.app-brand { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 18px; }
.app-brand em { font-style: italic; color: var(--green-mid); }

/* ── APP MAIN / BOTTOM NAV ── */
.app-main { max-width: 480px; margin: 0 auto; padding: 16px 16px 24px; }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--light);
  display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}
.bottom-nav a {
  text-decoration: none; color: var(--muted);
  font-size: 10px; font-weight: 500; letter-spacing: 0.02em;
  text-align: center; padding: 4px 14px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: color 0.15s;
}
.bottom-nav a.active { color: var(--green); font-weight: 700; }
.bottom-nav a svg { width: 22px; height: 22px; display: block; }
.bottom-nav a .nav-icon { font-size: 20px; line-height: 1; }

/* ── CARD ── */
.card {
  background: var(--white); border-radius: 18px;
  padding: 18px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--light);
}

/* ── DAY HERO ── */
.day-hero {
  background: linear-gradient(140deg, var(--dark) 0%, var(--charcoal) 100%);
  color: var(--white); border-radius: 22px; padding: 22px;
  margin-bottom: 16px; position: relative; overflow: hidden; border: 0;
}
.day-hero::after {
  content: '';
  position: absolute; top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(74,122,40,0.25), transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.dh-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; position: relative; z-index: 1;
}
.dh-meta { font-family: 'DM Mono', monospace; font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.55; margin-bottom: 5px; }
.dh-day { font-family: 'Playfair Display', serif; font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.dh-day-num { color: var(--green-light); }
.dh-total { font-size: 15px; opacity: 0.45; font-weight: 400; }
.dh-progress-ring { width: 52px; height: 52px; position: relative; }
.dh-progress-ring svg { transform: rotate(-90deg); display: block; }
.dh-progress-ring circle { fill: none; stroke-width: 4; }
.dh-progress-ring .ring-bg { stroke: rgba(255,255,255,0.12); }
.dh-progress-ring .ring-fill { stroke: var(--green-light); transition: stroke-dashoffset 0.5s ease; }
.ring-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 10.5px; font-weight: 600;
}
.dh-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; position: relative; z-index: 1;
}
.dh-stat {
  background: rgba(255,255,255,0.07); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.dh-stat-num { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 700; line-height: 1; }
.dh-stat-lbl { font-size: 8.5px; letter-spacing: 0.08em; opacity: 0.55; text-transform: uppercase; margin-top: 4px; }

/* ── SECTION LABEL ── */
.sec-label {
  font-family: 'DM Mono', monospace;
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
  margin: 20px 0 10px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ── MEAL CARDS ── */
.meal-card {
  background: var(--white); border-radius: 16px; padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow-sm);
  display: flex; gap: 13px; align-items: flex-start;
  border: 1.5px solid transparent; cursor: pointer;
  position: relative; transition: all 0.18s ease;
}
.meal-card:hover { border-color: var(--light); }
.meal-card.done {
  background: var(--green-pale); border-color: rgba(122,175,74,0.4);
}
.meal-card.done .meal-name { color: var(--green); text-decoration: line-through; opacity: 0.6; }
.meal-card.done .meal-desc { opacity: 0.4; }
.meal-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--mid); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px; transition: all 0.15s;
}
.meal-card.done .meal-check {
  background: var(--green-mid); border-color: var(--green-mid); color: var(--white);
}
.meal-check::after { content: '✓'; font-size: 12px; font-weight: 700; opacity: 0; }
.meal-card.done .meal-check::after { opacity: 1; }
.meal-body { flex: 1; min-width: 0; }
.meal-top-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.meal-name { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--dark); }
.meal-time {
  font-family: 'DM Mono', monospace; font-size: 10px;
  color: var(--gold); letter-spacing: 0.1em; flex-shrink: 0;
}
.meal-desc { font-size: 12px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; }
.meal-macros { display: flex; gap: 5px; flex-wrap: wrap; }
.mpill {
  font-family: 'DM Mono', monospace; font-size: 9px;
  padding: 2px 7px; border-radius: 100px;
  background: var(--off-white); color: var(--muted); font-weight: 500;
}
.mpill.kcal { background: rgba(45,80,22,0.1); color: var(--green); font-weight: 600; }
.meal-swap {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--off-white); display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); border: none; cursor: pointer;
  transition: background 0.15s;
}
.meal-swap:hover { background: var(--light); }

/* ── WORKOUT CARD ── */
.workout-card {
  background: var(--dark); color: var(--white);
  border-radius: 20px; padding: 20px;
  margin-bottom: 14px; border: 0; position: relative; overflow: hidden;
}
.workout-card.done { background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%); }
.workout-card::after {
  content: '';
  position: absolute; bottom: -30px; right: -30px;
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.04); pointer-events: none;
}
.wc-tag {
  font-family: 'DM Mono', monospace; font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--green-light); margin-bottom: 8px;
}
.wc-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; margin-bottom: 4px; line-height: 1.15; }
.wc-sub { font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 16px; }
.wc-stats { display: flex; gap: 20px; margin-bottom: 16px; }
.wc-stat-num { font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 600; color: var(--white); }
.wc-stat-lbl { font-size: 9px; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.wc-btn {
  width: 100%; background: rgba(255,255,255,0.12);
  color: var(--white); padding: 13px;
  border-radius: 100px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.15); cursor: pointer;
  transition: background 0.15s;
}
.wc-btn:hover { background: rgba(255,255,255,0.2); }
.workout-card.done .wc-btn { background: rgba(255,255,255,0.18); border-color: transparent; }

/* ── WATER ── */
.water-card {
  background: var(--white); border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow-sm); margin-bottom: 14px; border: 1px solid var(--light);
}
.water-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.water-label { font-size: 13px; font-weight: 600; }
.water-amount { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); }
.water-amount strong { color: var(--green-mid); }
.water-cups { display: flex; gap: 5px; }
.cup {
  flex: 1; height: 32px; border-radius: 8px 8px 4px 4px;
  background: var(--off-white); border: 1.5px solid var(--light);
  cursor: pointer; transition: all 0.15s;
}
.cup.filled {
  background: linear-gradient(to top, #63ADE0 0%, #9ACFEF 100%);
  border-color: #58A0D4;
}

/* ── ADJUSTMENT BANNER ── */
.adjust-banner {
  background: linear-gradient(135deg, #FFFAE8 0%, #FEF0C5 100%);
  border-left: 3px solid var(--gold); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.adjust-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.adjust-text { font-size: 12.5px; line-height: 1.55; color: #6B4A05; }
.adjust-text strong { color: var(--gold); font-weight: 600; }

/* ── WEEK SCREEN ── */
.week-hero-title { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; line-height: 1.1; margin-bottom: 6px; letter-spacing: -0.5px; }
.week-hero-title em { font-style: italic; color: var(--green-mid); font-weight: 400; }
.week-hero-sub { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); letter-spacing: 0.08em; margin-bottom: 18px; }
.week-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.week-stat-card {
  background: var(--white); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--light);
}
.ws-num { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1; letter-spacing: -0.5px; }
.ws-num small { font-size: 14px; color: var(--muted); font-weight: 400; }
.ws-num.down { color: var(--accent); }
.ws-lbl { font-family: 'DM Mono', monospace; font-size: 9.5px; color: var(--muted); margin-top: 5px; letter-spacing: 0.06em; }

/* ── CALENDAR ── */
.calendar {
  background: var(--white); border-radius: 20px; padding: 16px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--light);
}
.cal-week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 5px; }
.cal-day-head {
  font-family: 'DM Mono', monospace; font-size: 9px; font-weight: 500;
  letter-spacing: 0.08em; color: var(--muted); text-align: center; text-transform: uppercase; padding-bottom: 6px;
}
.cal-day {
  aspect-ratio: 1; border-radius: 10px; background: var(--off-white);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; border: 1.5px solid transparent; transition: all 0.15s;
}
.cal-day-num { font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 600; color: var(--charcoal); }
.cal-day-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--mid); margin-top: 3px; }
.cal-day.done { background: var(--green-pale); }
.cal-day.done .cal-day-num { color: var(--green); }
.cal-day.done .cal-day-dot { background: var(--green-mid); }
.cal-day.partial { background: #FFF5E6; }
.cal-day.partial .cal-day-dot { background: var(--gold); }
.cal-day.today { background: var(--dark); border-color: var(--green-light); }
.cal-day.today .cal-day-num { color: var(--white); }
.cal-day.today .cal-day-dot { background: var(--green-light); }
.cal-day.future { opacity: 0.35; cursor: default; }
.cal-day.cal-empty { visibility: hidden; pointer-events: none; }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px 2px 0; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── PROGRESS SCREEN ── */
.prog-hero-title { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; line-height: 1.1; margin-bottom: 6px; letter-spacing: -0.5px; }
.prog-hero-title em { font-style: italic; color: var(--green-mid); font-weight: 400; }
.prog-hero-sub { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); letter-spacing: 0.08em; margin-bottom: 18px; }
.weight-card {
  background: var(--white); border-radius: 20px; padding: 20px;
  box-shadow: var(--shadow-sm); margin-bottom: 14px; border: 1px solid var(--light);
}
.wt-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.wt-num { font-family: 'Playfair Display', serif; font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -1.5px; color: var(--dark); }
.wt-unit { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.wt-delta {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-pale); color: var(--green);
  padding: 5px 11px; border-radius: 100px; font-size: 12px; font-weight: 700;
}
.wt-delta.neg { background: #FFE9E6; color: var(--accent); }
.wt-chart { width: 100%; height: 80px; display: block; overflow: visible; }
.wt-log-btn {
  width: 100%; background: var(--off-white); color: var(--green-mid); padding: 12px;
  border-radius: 14px; font-size: 13px; font-weight: 600; margin-top: 12px;
  border: 1.5px dashed var(--mid); cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.wt-log-btn:hover { background: var(--green-pale); border-color: var(--green-mid); }
.coach-card-pro {
  background: linear-gradient(140deg, #232320 0%, #15140F 100%);
  color: var(--white); border-radius: 20px; padding: 20px; margin-bottom: 14px;
}
.coach-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(122,175,74,0.12); color: var(--green-light);
  padding: 4px 10px; border-radius: 100px; font-size: 9px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 12px;
}
.coach-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green-light); }
.coach-msg { font-size: 13px; line-height: 1.6; color: rgba(255,255,255,0.82); }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ach-card {
  background: var(--white); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow-sm); text-align: center; border: 1px solid var(--light);
  transition: transform 0.15s;
}
.ach-card:not(.locked):hover { transform: translateY(-2px); }
.ach-card.locked { opacity: 0.38; }
.ach-icon { font-size: 26px; margin-bottom: 8px; }
.ach-title { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.ach-sub { font-size: 10px; color: var(--muted); line-height: 1.4; }

/* ── ONBOARDING ── */
.onb-steps { display: flex; gap: 6px; margin-bottom: 24px; }
.onb-step-dot { flex: 1; height: 3px; border-radius: 3px; background: var(--light); transition: background 0.3s; }
.onb-step-dot.on { background: var(--green-mid); }
.onb-panel { display: none; animation: fadeSlide 0.22s ease; }
.onb-panel.active { display: block; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chip-btn {
  padding: 9px 14px; border-radius: 100px; border: 1.5px solid var(--light);
  background: var(--white); font-size: 13px; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.chip-btn:hover { border-color: var(--mid); }
.chip-btn.on { background: var(--green-pale); border-color: var(--green-mid); color: var(--green); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.unit-toggle { display: flex; gap: 8px; margin-top: 10px; }
.unit-toggle button {
  flex: 1; padding: 12px; border-radius: 12px; border: 1.5px solid var(--light);
  background: var(--white); cursor: pointer; font-weight: 600; font-family: inherit; font-size: 14px;
  transition: all 0.15s;
}
.unit-toggle button.on { background: var(--green-pale); border-color: var(--green-mid); color: var(--green); }

/* ── AUTH WRAP ── */
.auth-wrap { max-width: 400px; margin: 32px auto; padding: 24px; }
.auth-wrap h1 {
  font-family: 'Playfair Display', serif;
  font-size: 28px; margin-bottom: 10px; letter-spacing: -0.4px;
}
.auth-wrap h1 em { font-style: italic; color: var(--green-mid); }
.auth-wrap p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.auth-wrap input {
  width: 100%; padding: 15px 16px; border: 1.5px solid var(--light);
  border-radius: 14px; font-size: 15px; font-family: inherit; margin-bottom: 12px;
  background: var(--white); color: var(--dark); transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-wrap input:focus { outline: none; border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(74,122,40,0.1); }
.auth-wrap button {
  width: 100%; padding: 15px; background: var(--dark); color: var(--white);
  border: none; border-radius: 100px; font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.auth-wrap button:hover { background: var(--charcoal); }
.auth-err { color: var(--accent); font-size: 13px; margin-bottom: 12px; display: none; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--dark); color: var(--white); padding: 11px 20px;
  border-radius: 100px; font-size: 13px; font-weight: 500; z-index: 200;
  opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none;
  white-space: nowrap; max-width: calc(100vw - 40px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; }

/* ── CONFETTI ── */
.confetti-piece {
  position: fixed; width: 8px; height: 8px; top: -10px; z-index: 300;
  border-radius: 2px;
  animation: confettiFall 2.2s ease-out forwards; pointer-events: none;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(900deg); opacity: 0; }
}
