/* ============================================================
   Get Fit by Tito Fit — Design tokens & base styles
   ============================================================ */

:root {
  /* Tone — bold but minimal */
  --bg: oklch(0.99 0.003 95);
  --bg-soft: oklch(0.97 0.005 95);
  --bg-sunken: oklch(0.95 0.006 95);
  --line: oklch(0.91 0.006 95);
  --line-soft: oklch(0.94 0.005 95);
  --fg: oklch(0.16 0.01 95);
  --fg-muted: oklch(0.48 0.01 95);
  --fg-dim: oklch(0.65 0.008 95);

  /* Accent — lime (default) */
  --accent: oklch(0.89 0.22 128);
  --accent-ink: oklch(0.22 0.05 128);
  --accent-soft: oklch(0.95 0.10 128);

  /* Macros (data viz) */
  --m-protein: oklch(0.70 0.18 30);
  --m-carbs:   oklch(0.78 0.16 75);
  --m-fat:     oklch(0.72 0.14 280);

  /* Type */
  --f-sans: "Geist", "Inter", system-ui, sans-serif;
  --f-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Spacing scale */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;

  /* Density */
  --density: 1;
}

/* Dark mode */
:root[data-theme="dark"] {
  --bg: oklch(0.14 0.005 95);
  --bg-soft: oklch(0.18 0.006 95);
  --bg-sunken: oklch(0.21 0.007 95);
  --line: oklch(0.27 0.008 95);
  --line-soft: oklch(0.22 0.007 95);
  --fg: oklch(0.97 0.005 95);
  --fg-muted: oklch(0.65 0.01 95);
  --fg-dim: oklch(0.45 0.01 95);
  --accent-ink: oklch(0.99 0.02 128);
  --accent-soft: oklch(0.28 0.08 128);
}

/* Accent variants */
:root[data-accent="orange"] { --accent: oklch(0.78 0.20 55); --accent-ink: oklch(0.22 0.06 55); --accent-soft: oklch(0.95 0.08 55); }
:root[data-accent="electric"] { --accent: oklch(0.78 0.20 250); --accent-ink: oklch(0.99 0.02 250); --accent-soft: oklch(0.95 0.06 250); }
:root[data-accent="magenta"] { --accent: oklch(0.72 0.24 340); --accent-ink: oklch(0.99 0.02 340); --accent-soft: oklch(0.95 0.07 340); }
:root[data-accent="lime"]    { --accent: oklch(0.89 0.22 128); --accent-ink: oklch(0.22 0.05 128); --accent-soft: oklch(0.95 0.10 128); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100vh; min-height: 100dvh; }
html {
  overflow-x: hidden; /* prevent any element from widening the viewport */
}
body {
  font-family: var(--f-sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
  overscroll-behavior-y: none;        /* no rubber-band background */
  overflow-x: hidden;                 /* belt-and-suspenders: no horizontal page scroll */
  max-width: 100%;                    /* never let body widen past viewport */
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; padding: 0; touch-action: manipulation; }
input, textarea { background: none; border: none; outline: none; font-size: 16px; }  /* 16px prevents iOS auto-zoom */
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

/* ============================================================
   Type rhythm
   ============================================================ */
.h-display {
  font-family: var(--f-sans);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.9;
  font-size: clamp(64px, 11vw, 168px);
}
.h-hero { font-weight: 800; letter-spacing: -0.035em; line-height: 0.95; font-size: clamp(40px, 5vw, 72px); }
.h-section { font-weight: 800; letter-spacing: -0.03em; font-size: 36px; line-height: 1; }
.h-card { font-weight: 700; letter-spacing: -0.02em; font-size: 22px; line-height: 1.1; }
.h-data { font-family: var(--f-mono); font-weight: 600; font-size: 40px; letter-spacing: -0.02em; }
.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.mono { font-family: var(--f-mono); }
.muted { color: var(--fg-muted); }
.dim { color: var(--fg-dim); }

/* ============================================================
   Primitives
   ============================================================ */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: calc(20px * var(--density));
}
.card.sunken { background: var(--bg-soft); }
.card.flush { padding: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1 1 0; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.03); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-dark { background: var(--fg); color: var(--bg); }
.btn-dark:hover { filter: brightness(1.1); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.btn-sm { padding: 9px 14px; font-size: 13px; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
}
.chip.solid { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.dark { background: var(--fg); color: var(--bg); border-color: transparent; }
.chip.dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field-label {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.field-input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field-input:focus { border-color: var(--fg); background: var(--bg); }

.seg {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 2px;
}
.seg button {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
}
.seg button.on {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Striped image placeholder — never hand-drawn art */
.ph {
  position: relative;
  background:
    repeating-linear-gradient(135deg,
      var(--bg-soft) 0 10px,
      var(--bg-sunken) 10px 20px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph::after {
  content: attr(data-label);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  text-transform: lowercase;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--line);
}

/* Brand mark */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 28px; height: 28px;
  background: var(--fg);
  border-radius: 8px;
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: auto 4px 4px auto;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
}
.brand-wordmark {
  display: flex; flex-direction: column;
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-weight: 900;
  font-size: 13px;
}
.brand-wordmark span:last-child { color: var(--fg-muted); font-weight: 600; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }

/* Avatar */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex: none;
}

/* Progress ring */
.ring-track { stroke: var(--line); }
.ring-fill { stroke: var(--accent); transition: stroke-dashoffset 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* Scrollbar (subtle) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }
::-webkit-scrollbar-track { background: transparent; }

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex; flex-direction: column;
  gap: 4px;
  position: sticky; top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-soft); color: var(--fg); }
.nav-item.active { background: var(--fg); color: var(--bg); }
.nav-item.active .nav-icon { background: var(--accent); }
.nav-icon {
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--line);
  flex: none;
}
.main {
  padding: 32px 40px 80px;
  max-width: 1400px;
  width: 100%;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

/* Drag-drop */
.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft) !important; }
.dragging { opacity: 0.4; }

/* Anim */
@keyframes fadeIn { from { opacity: 0.001; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.4s ease both; }

/* Utility */
.full { width: 100%; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.tag-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}

/* ============================================================
   Layout patterns (used inline-replacement in screens)
   ============================================================ */
.auth-split { display: grid; grid-template-columns: 1fr 480px; min-height: 100vh; min-height: 100dvh; }
.auth-split.wide { grid-template-columns: 1fr 540px; }

.today-strip { display: grid; grid-template-columns: repeat(5, 1fr); }
.today-strip > button {
  text-align: left; padding: 20px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  transition: background .15s;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 200px;
}
.today-strip > button:last-child { border-right: none; }
.today-strip > button.on { background: var(--accent-soft); }

.meal-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 20px; align-items: center;
}

.week-grid { display: grid; grid-template-columns: 100px repeat(7, 1fr); }

.split-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

.landing-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--line); }
.landing-stats > div {
  padding: 32px 24px;
  border-right: 1px solid var(--line);
}
.landing-stats > div:last-child { border-right: none; }

.landing-cta {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-xl);
  padding: 80px 60px;
  position: relative;
  overflow: hidden;
}

/* Landing extras */
.marquee {
  display: flex; gap: 32px;
  font-family: var(--f-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-muted);
  padding: 14px 0;
  border-block: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
}
.marquee-inner {
  display: inline-flex;
  gap: 32px;
  animation: marquee 30s linear infinite;
}
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.marquee-inner span::before { content: "●"; color: var(--accent); margin-right: 32px; }

/* Onboarding stepper */
.stepper { display: flex; gap: 8px; }
.stepper > div {
  height: 4px; flex: 1; background: var(--line); border-radius: 2px;
}
.stepper > div.on { background: var(--accent); }
.stepper > div.done { background: var(--fg); }

/* ============================================================
   Mobile — hide desktop-only chrome by default at viewport
   ============================================================ */
.mobile-only { display: none; }

/* ============================================================
   MOBILE BREAKPOINT (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  body { font-size: 14px; }

  .desktop-only { display: none !important; }
  .mobile-only  { display: initial; }

  /* Type — pull display sizes down so they don't overflow */
  .h-display { font-size: clamp(48px, 14vw, 80px); }
  .h-hero    { font-size: clamp(32px, 8vw, 44px) !important; }
  .h-section { font-size: 28px; }
  .h-data    { font-size: 32px; }
  .h-card    { font-size: 18px; }

  /* Cards & padding */
  .card { padding: 16px; border-radius: 18px; }

  /* Grids collapse */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; gap: 14px; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .split-2 { grid-template-columns: 1fr; }
  .landing-stats { grid-template-columns: 1fr 1fr; }
  .landing-stats > div { padding: 22px 16px; border-right: none; border-bottom: 1px solid var(--line); }
  .landing-stats > div:nth-child(odd) { border-right: 1px solid var(--line); }

  /* App shell → bottom tab bar
     min-width:0 / minmax(0,1fr) prevents intrinsic min-content of inner
     wide elements (today-strip, week-grid) from forcing horizontal scroll. */
  .app-shell { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .main { min-width: 0; overflow-x: hidden; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: auto; top: auto;
    flex-direction: row;
    border-right: none; border-top: 1px solid var(--line);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    gap: 0; z-index: 20;
    background: var(--bg);
  }
  .sidebar > div:first-child,           /* brand */
  .sidebar > div:last-child,            /* membership + logout block */
  .sidebar > .nav-item.logout { display: none; }

  .sidebar nav { display: flex; flex-direction: row; flex: 1; gap: 0; }
  .nav-item {
    flex: 1; flex-direction: column; gap: 4px;
    padding: 8px 4px; font-size: 11px;
    text-align: center; align-items: center; justify-content: center;
    border-radius: 12px;
  }
  .nav-item.active { background: var(--bg-soft); color: var(--fg); }
  .nav-item.active .nav-icon { background: transparent; }
  .nav-item span { font-size: 11px; }
  .nav-item svg { margin: 0 auto; }
  .nav-item svg + span { margin-top: 2px; }
  .nav-item .nav-icon { display: none; }
  .nav-item > svg:last-child { display: none; } /* hide trailing arrow */

  /* Main content */
  .main {
    padding: 20px 18px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .topbar {
    padding-bottom: 16px; margin-bottom: 20px;
    flex-wrap: wrap; gap: 12px;
  }
  .topbar > .row:first-child > span:nth-child(2) { display: none; } /* hide last weigh-in */

  /* Auth screens — stack panels */
  .auth-split, .auth-split.wide {
    grid-template-columns: 1fr !important;
    min-height: auto;
  }
  .auth-split > div:first-child {
    padding: 32px 24px !important;
    padding-top: calc(32px + env(safe-area-inset-top)) !important;
    min-height: 280px;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
  }
  .auth-split > div:last-child {
    padding: 32px 24px !important;
  }

  /* Today's plan — horizontal scroll */
  .today-strip {
    display: flex; overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    width: 100%;          /* pin to card width so iOS doesn't expand the strip */
    max-width: 100%;
  }
  .today-strip > button {
    flex: 0 0 75%;
    scroll-snap-align: start;
    border-right: 1px solid var(--line);
    min-width: 240px;
  }

  /* Meal rows — stack image above content */
  .meal-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .meal-row > div:first-child {   /* drag handle */
    display: flex; flex-direction: row !important; gap: 12px; align-items: center;
  }
  .meal-row .ph { width: 100% !important; height: 160px !important; aspect-ratio: auto; }
  .meal-row > .col:last-child {
    flex-direction: row !important; min-width: 0 !important;
  }
  .meal-row > .col:last-child .btn { flex: 1; }

  /* Week view — card wrapper (overflow-x: auto) scrolls; grid fills natural width */
  .week-grid {
    grid-template-columns: 70px repeat(7, minmax(120px, 1fr));
    min-width: max-content; /* let grid be as wide as it needs; parent card scrolls */
  }

  /* Hero data row gap */
  body section { padding-left: 20px !important; padding-right: 20px !important; }

  /* Landing nav — hide center links, keep brand + CTAs */
  header nav { display: none !important; }
  header {
    padding: 14px 18px !important;
    padding-top: calc(14px + env(safe-area-inset-top)) !important;
  }

  /* Marquee — keep but reduce gap */
  .marquee-inner { gap: 20px; }

  /* Buttons — reduce padding */
  .btn { padding: 12px 16px; font-size: 13px; }
  .btn-sm { padding: 8px 12px; font-size: 12px; }

  /* Big CTA section */
  section .h-display { font-size: clamp(40px, 11vw, 64px) !important; }

  /* Profile tabs — let them wrap */
  .seg { flex-wrap: wrap; }

  /* Gallery upload card */
  .ph { font-size: 11px; }

  /* Onboarding — adjust ring inside the coaching panel */
  .stepper { gap: 4px; }

  /* TDEE black section — smaller padding */
  section[id="tdee"] { padding: 60px 20px !important; }

  /* CTA card */
  .landing-cta { padding: 40px 24px !important; }
  /* Tweaks panel — lift above bottom tab bar */
  .twk-panel {
    bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    right: 12px !important;
  }
}
@media (max-width: 420px) {
  .h-display { font-size: clamp(40px, 13vw, 64px); }
  .landing-stats { grid-template-columns: 1fr; }
  .landing-stats > div { border-right: none !important; }
  .grid-4 { grid-template-columns: 1fr; }
  .today-strip > button { flex-basis: 85%; }
}
