/* ============================================
   MACROVA - Cal AI Style CSS
   ============================================ */

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

:root {
  --black: #000;
  --white: #fff;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #E8E8ED;
  --gray-300: #D1D1D6;
  --gray-400: #AEAEB2;
  --gray-500: #8E8E93;
  --gray-600: #636366;
  --protein: #FF6B6B;
  --carbs: #4ECDC4;
  --fats: #FFE66D;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --safe-top: env(safe-area-inset-top, 44px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--white);
  color: var(--black);
  line-height: 1.4;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--white);
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  background: var(--white);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: flex;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */
.splash {
  justify-content: center;
  align-items: center;
  background: var(--black);
}

.splash-logo {
  width: 80px;
  height: 80px;
  background: var(--white);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* ============================================
   WELCOME SCREEN
   ============================================ */
.welcome {
  padding: 60px 24px var(--safe-bottom);
  justify-content: space-between;
}

.welcome-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.welcome h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
}

.welcome p {
  font-size: 17px;
  color: var(--gray-500);
  max-width: 280px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--black);
  color: var(--white);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--black);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--black);
}

.btn-text {
  background: none;
  color: var(--gray-500);
  font-weight: 500;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-icon img, .btn-icon svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   ONBOARDING SCREENS
   ============================================ */
.onboarding {
  padding: calc(var(--safe-top) + 16px) 24px var(--safe-bottom);
}

.ob-header {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
}

.back-btn {
  width: 40px;
  height: 40px;
  background: var(--gray-100);
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ob-progress {
  flex: 1;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin-left: 16px;
}

.ob-progress-fill {
  height: 100%;
  background: var(--black);
  border-radius: 2px;
  transition: width 0.3s;
}

.ob-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ob-subtitle {
  font-size: 16px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.ob-content {
  flex: 1;
}

.ob-footer {
  padding-top: 16px;
}

/* Options */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opt {
  padding: 20px;
  background: var(--gray-50);
  border: 2px solid transparent;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.opt:hover {
  background: var(--gray-100);
}

.opt.selected {
  border-color: var(--black);
  background: var(--white);
}

.opt-icon {
  font-size: 28px;
}

.opt-text strong {
  display: block;
  font-size: 17px;
  margin-bottom: 2px;
}

.opt-text span {
  font-size: 14px;
  color: var(--gray-500);
}

/* Picker */
.picker-container {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.picker {
  height: 200px;
  width: 80px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  background: var(--gray-50);
  border-radius: 12px;
  position: relative;
}

.picker::-webkit-scrollbar {
  display: none;
}

.picker-item {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--gray-400);
  scroll-snap-align: center;
  transition: all 0.2s;
}

.picker-item.active {
  color: var(--black);
  font-weight: 600;
  transform: scale(1.1);
}

.picker-highlight {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 40px;
  transform: translateY(-50%);
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  pointer-events: none;
}

/* Unit Toggle */
.unit-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.unit {
  padding: 8px 20px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.unit.active {
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ============================================
   LOADING SCREEN
   ============================================ */
.loading-screen {
  justify-content: center;
  align-items: center;
  padding: 40px;
  text-align: center;
}

.loading-ring {
  width: 180px;
  height: 180px;
  position: relative;
  margin-bottom: 32px;
}

.loading-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.loading-ring circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}

.loading-ring .bg {
  stroke: var(--gray-200);
}

.loading-ring .progress {
  stroke: var(--black);
  stroke-dasharray: 502;
  stroke-dashoffset: 502;
  transition: stroke-dashoffset 0.5s ease;
}

.loading-pct {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: 700;
}

.loading-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 15px;
  color: var(--gray-500);
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
.results {
  padding: calc(var(--safe-top) + 40px) 24px var(--safe-bottom);
  text-align: center;
}

.results-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.results h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.results > p {
  color: var(--gray-500);
  margin-bottom: 32px;
}

.results-card {
  background: var(--gray-50);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
}

.cal-result {
  margin-bottom: 24px;
}

.cal-result span {
  font-size: 14px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-result strong {
  display: block;
  font-size: 48px;
  font-weight: 700;
  margin: 4px 0;
}

.cal-result small {
  font-size: 14px;
  color: var(--gray-500);
}

.macro-results {
  display: flex;
  justify-content: space-around;
}

.macro-result {
  text-align: center;
}

.macro-result span {
  font-size: 24px;
  font-weight: 700;
}

.macro-result.protein span { color: var(--protein); }
.macro-result.carbs span { color: var(--carbs); }
.macro-result.fats span { color: var(--fats); }

.macro-result small {
  display: block;
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ============================================
   AUTH SCREEN
   ============================================ */
.auth {
  padding: calc(var(--safe-top) + 40px) 24px var(--safe-bottom);
}

.auth-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.auth > p {
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 32px;
}

.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-footer {
  text-align: center;
  padding-top: 24px;
}

.auth-footer p {
  font-size: 13px;
  color: var(--gray-500);
}

.auth-footer a {
  color: var(--black);
}

/* ============================================
   PAYWALL
   ============================================ */
.paywall {
  padding: calc(var(--safe-top) + 24px) 24px var(--safe-bottom);
}

.paywall-header {
  text-align: center;
  margin-bottom: 24px;
}

.paywall-close {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  right: 16px;
  width: 32px;
  height: 32px;
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.paywall-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.paywall h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.paywall-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.paywall-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}

.paywall-feature svg {
  flex-shrink: 0;
}

.plans {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.plan {
  padding: 20px;
  border: 2px solid var(--gray-200);
  border-radius: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.plan.selected {
  border-color: var(--black);
}

.plan-radio {
  width: 24px;
  height: 24px;
  border: 2px solid var(--gray-300);
  border-radius: 50%;
  margin-right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plan.selected .plan-radio {
  border-color: var(--black);
  background: var(--black);
}

.plan.selected .plan-radio::after {
  content: '✓';
  color: var(--white);
  font-size: 14px;
}

.plan-info {
  flex: 1;
}

.plan-info strong {
  display: block;
  font-size: 17px;
}

.plan-info span {
  font-size: 14px;
  color: var(--gray-500);
}

.plan-price {
  text-align: right;
}

.plan-price strong {
  display: block;
  font-size: 20px;
}

.plan-price span {
  font-size: 13px;
  color: var(--gray-500);
}

.plan-badge {
  position: absolute;
  top: -10px;
  right: 16px;
  background: var(--black);
  color: var(--white);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 80px);
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dash-greeting h1 {
  font-size: 28px;
  font-weight: 700;
}

.dash-greeting p {
  font-size: 15px;
  color: var(--gray-500);
}

.dash-avatar {
  width: 44px;
  height: 44px;
  background: var(--gray-200);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* Week Calendar */
.week-cal {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.week-cal::-webkit-scrollbar {
  display: none;
}

.week-day {
  flex: 1;
  min-width: 48px;
  padding: 12px 8px;
  text-align: center;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.week-day:hover {
  background: var(--gray-50);
}

.week-day.today {
  background: var(--black);
  color: var(--white);
}

.week-day.has-data:not(.today)::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--success);
  border-radius: 50%;
}

.day-name {
  display: block;
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.day-num {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

/* Calorie Ring */
.cal-card {
  background: var(--gray-50);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 20px;
}

.cal-top {
  display: flex;
  align-items: center;
  gap: 24px;
}

.cal-ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.cal-ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.cal-ring-wrap circle {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
}

.cal-ring-wrap .bg {
  stroke: var(--gray-200);
}

.cal-ring-wrap .ring {
  stroke: var(--black);
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.5s ease;
}

.cal-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.cal-num {
  font-size: 28px;
  font-weight: 700;
  display: block;
}

.cal-label {
  font-size: 12px;
  color: var(--gray-500);
}

.cal-info {
  flex: 1;
}

.cal-info h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.cal-info p {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

/* Macros */
.macros {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.macro {
  flex: 1;
  background: var(--white);
  padding: 14px;
  border-radius: 14px;
}

.macro-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.macro-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.macro.protein .macro-dot { background: var(--protein); }
.macro.carbs .macro-dot { background: var(--carbs); }
.macro.fats .macro-dot { background: var(--fats); }

.macro-name {
  font-size: 13px;
  color: var(--gray-500);
}

.macro-val {
  font-size: 20px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}

.macro-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.macro.protein .macro-bar-fill { background: var(--protein); }
.macro.carbs .macro-bar-fill { background: var(--carbs); }
.macro.fats .macro-bar-fill { background: var(--fats); }

/* Meals Section */
.meals-section {
  margin-top: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.section-header a {
  color: var(--gray-500);
  font-size: 14px;
  text-decoration: none;
}

.empty-meals {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.empty-meals svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-meals p {
  font-size: 15px;
}

.meal-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.meal-card:hover {
  background: var(--gray-100);
}

.meal-icon {
  width: 44px;
  height: 44px;
  background: var(--white);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.meal-details {
  flex: 1;
}

.meal-details strong {
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

.meal-details span {
  font-size: 13px;
  color: var(--gray-500);
}

.meal-cals {
  text-align: right;
}

.meal-cals strong {
  display: block;
  font-size: 18px;
}

.meal-cals span {
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================
   FAB & MENU
   ============================================ */
.fab-container {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 70px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

.fab {
  width: 60px;
  height: 60px;
  background: var(--black);
  border: none;
  border-radius: 50%;
  color: var(--white);
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab.active {
  transform: rotate(45deg);
}

.fab-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 99;
}

.fab-bg.active {
  opacity: 1;
  visibility: visible;
}

.fab-menu {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.fab-menu.active {
  opacity: 1;
  visibility: visible;
}

.fab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.fab-item button {
  width: 50px;
  height: 50px;
  background: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.fab-item span {
  background: var(--white);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ============================================
   BOTTOM NAV
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 10px 20px calc(var(--safe-bottom) + 10px);
  display: flex;
  justify-content: space-around;
  z-index: 90;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.nav-item.active {
  opacity: 1;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
}

/* ============================================
   SCANNER SCREEN
   ============================================ */
.scanner {
  background: var(--black);
}

.scanner-header {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.scanner-close {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  color: var(--white);
  font-size: 20px;
  cursor: pointer;
}

.scanner-flash {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-view {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  border: 3px solid var(--white);
  border-radius: 24px;
  opacity: 0.8;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--white), transparent);
  animation: scan 2s infinite;
}

@keyframes scan {
  0%, 100% { top: 10%; }
  50% { top: 90%; }
}

.scanner-controls {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 40px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

.gallery-btn {
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-btn {
  width: 80px;
  height: 80px;
  background: var(--white);
  border: 4px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.capture-btn:active {
  transform: scale(0.95);
}

.capture-btn-inner {
  width: 100%;
  height: 100%;
  background: var(--white);
  border-radius: 50%;
}

.scanner-hint {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 150px);
  left: 0;
  right: 0;
  text-align: center;
  color: var(--white);
  font-size: 16px;
  opacity: 0.8;
}

/* ============================================
   FOOD LOG SCREEN
   ============================================ */
.food-log {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--gray-100);
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.search-bar svg {
  color: var(--gray-400);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-size: 16px;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--gray-400);
}

.log-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.log-tab {
  padding: 8px 16px;
  background: var(--gray-100);
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.log-tab.active {
  background: var(--black);
  color: var(--white);
}

.food-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.food-categories::-webkit-scrollbar {
  display: none;
}

.food-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--gray-100);
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.food-cat.active {
  background: var(--black);
  color: var(--white);
}

.cat-icon {
  font-size: 16px;
}

.food-list-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-600);
}

.food-list {
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.food-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.food-item:hover {
  background: var(--gray-100);
}

.food-item-info strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.food-item-info span {
  font-size: 13px;
  color: var(--gray-500);
}

.food-item-cal {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

/* ============================================
   MANUAL ENTRY
   ============================================ */
.manual-entry {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--black);
}

.meal-types {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meal-type {
  padding: 10px 18px;
  background: var(--gray-100);
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.meal-type.active {
  background: var(--black);
  color: var(--white);
}

.macro-inputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ============================================
   DAY DETAIL SCREEN
   ============================================ */
.day-detail {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.day-summary-card {
  text-align: center;
  padding: 24px;
  margin-bottom: 24px;
}

.day-cal-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto 16px;
  position: relative;
}

.day-cal-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.day-cal-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.day-cal-num {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 700;
}

.day-cal-label {
  font-size: 14px;
  color: var(--gray-500);
}

.day-macros {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
}

.day-macro {
  text-align: center;
}

.day-macro span {
  font-size: 20px;
  font-weight: 700;
  display: block;
}

.day-macro span.protein { color: var(--protein); }
.day-macro span.carbs { color: var(--carbs); }
.day-macro span.fats { color: var(--fats); }

.day-macro small {
  font-size: 12px;
  color: var(--gray-500);
}

.no-data-msg {
  text-align: center;
  padding: 40px;
  color: var(--gray-500);
}

.no-data-msg p {
  font-size: 16px;
  font-weight: 500;
  margin: 12px 0 4px;
}

.no-data-msg span {
  font-size: 13px;
}

.day-meals-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.day-meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: 12px;
  margin-bottom: 8px;
}

.day-meal-item .meal-info strong {
  display: block;
  font-size: 15px;
}

.day-meal-item .meal-info span {
  font-size: 13px;
  color: var(--gray-500);
}

.day-meal-item .meal-cal {
  font-weight: 600;
}

/* ============================================
   PROGRESS PAGE
   ============================================ */
.progress-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 80px);
}

.progress-page h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 20px;
}

.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1;
  background: var(--gray-50);
  padding: 16px;
  border-radius: 16px;
  text-align: center;
}

.stat-card span {
  font-size: 24px;
  font-weight: 700;
  display: block;
}

.stat-card small {
  font-size: 12px;
  color: var(--gray-500);
}

.progress-section {
  background: var(--gray-50);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
}

.progress-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.period-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.period-btn {
  padding: 6px 14px;
  background: var(--gray-200);
  border: none;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.period-btn.active {
  background: var(--black);
  color: var(--white);
}

.weight-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.ws-item {
  background: var(--white);
  padding: 12px;
  border-radius: 12px;
}

.ws-item small {
  font-size: 12px;
  color: var(--gray-500);
  display: block;
  margin-bottom: 4px;
}

.ws-item strong {
  font-size: 18px;
}

#weight-chart, #macro-chart {
  display: block;
  margin: 0 auto;
}

.no-data {
  text-align: center;
  padding: 32px;
  color: var(--gray-400);
}

.no-data svg {
  margin-bottom: 8px;
}

.no-data p {
  font-size: 14px;
}

.macro-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}

.ml-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ml-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.ml-dot.protein { background: var(--protein); }
.ml-dot.carbs { background: var(--carbs); }
.ml-dot.fats { background: var(--fats); }

.cal-history-bars {
  display: flex;
  justify-content: space-between;
  height: 150px;
  align-items: flex-end;
  padding-top: 20px;
}

.cal-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.cal-bar {
  flex: 1;
  width: 24px;
  background: var(--gray-200);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.cal-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--black);
  border-radius: 12px;
  transition: height 0.3s;
}

.cal-bar-fill.over {
  background: var(--danger);
}

.cal-bar-target {
  position: absolute;
  left: -4px;
  right: -4px;
  height: 2px;
  background: var(--warning);
}

.cal-bar-day {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 8px;
}

.cal-bar-val {
  font-size: 10px;
  color: var(--gray-400);
}

/* ============================================
   PROFILE PAGE
   ============================================ */
.profile-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 80px);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 70px;
  height: 70px;
  background: var(--gray-200);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.profile-info h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}

.profile-info p {
  font-size: 14px;
  color: var(--gray-500);
}

.pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: var(--black);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
}

.profile-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.profile-stat {
  flex: 1;
  background: var(--gray-50);
  padding: 16px;
  border-radius: 16px;
  text-align: center;
}

.profile-stat strong {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

.profile-stat span {
  font-size: 12px;
  color: var(--gray-500);
}

.settings-section {
  margin-bottom: 24px;
}

.settings-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-left: 4px;
}

.settings-card {
  background: var(--gray-50);
  border-radius: 16px;
  overflow: hidden;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background 0.2s;
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item:hover {
  background: var(--gray-100);
}

.setting-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.setting-icon {
  width: 36px;
  height: 36px;
  background: var(--white);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.setting-text strong {
  display: block;
  font-size: 15px;
  font-weight: 500;
}

.setting-text span {
  font-size: 13px;
  color: var(--gray-500);
}

.setting-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-value {
  font-size: 14px;
  color: var(--gray-500);
}

.setting-item.danger .setting-text strong {
  color: var(--danger);
}

/* ============================================
   MILESTONES PAGE
   ============================================ */
.milestones-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.ms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.ms-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.ms-count {
  font-size: 14px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 6px 14px;
  border-radius: 20px;
}

.milestones-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.milestone-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 16px;
  transition: all 0.2s;
}

.milestone-card.earned {
  background: var(--white);
  border: 2px solid var(--gray-200);
}

.milestone-card.locked {
  opacity: 0.6;
}

.ms-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.milestone-card.locked .ms-icon {
  background: var(--gray-200) !important;
  filter: grayscale(1);
}

.ms-info {
  flex: 1;
}

.ms-info strong {
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

.ms-info span {
  font-size: 13px;
  color: var(--gray-500);
}

.ms-check {
  width: 28px;
  height: 28px;
  background: var(--success);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.ms-lock {
  font-size: 18px;
}

/* ============================================
   GROUPS PAGE
   ============================================ */
.groups-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.groups-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.groups-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.create-group-btn {
  width: 40px;
  height: 40px;
  background: var(--black);
  border: none;
  border-radius: 12px;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.group-card:hover {
  background: var(--gray-100);
}

.group-card.locked {
  opacity: 0.7;
}

.group-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
}

.group-avatar.locked {
  filter: grayscale(0.5);
}

.group-info {
  flex: 1;
}

.group-info strong {
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

.group-info span {
  font-size: 13px;
  color: var(--gray-500);
}

.pro-lock {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: var(--black);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.groups-divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
}

.groups-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--gray-200);
}

.groups-divider span {
  background: var(--white);
  padding: 0 12px;
  font-size: 13px;
  color: var(--gray-500);
  position: relative;
}

/* ============================================
   GOALS & WEIGHT PAGES
   ============================================ */
.goals-page, .weight-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 700;
}

.goals-form, .weight-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.weight-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
}

.weight-history h4 {
  margin-bottom: 12px;
  font-size: 16px;
}

/* ============================================
   HEALTH & FITNESS PAGES
   ============================================ */
.health-page, .fitness-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

.health-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 20px;
}

.fitness-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #34C759, #30D158);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 20px;
}

.health-info, .fitness-info {
  text-align: center;
  margin-bottom: 24px;
}

.health-info h2, .fitness-info h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.health-info p, .fitness-info p {
  font-size: 14px;
  color: var(--gray-500);
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 12px;
  margin-bottom: 10px;
}

.toggle-item span {
  font-size: 15px;
}

.toggle-switch {
  width: 50px;
  height: 30px;
  background: var(--gray-300);
  border-radius: 15px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch.active {
  background: var(--success);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: var(--white);
  border-radius: 50%;
  transition: left 0.2s;
}

.toggle-switch.active::after {
  left: 23px;
}

/* ============================================
   MODALS
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  width: 100%;
  max-width: 430px;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px 24px calc(var(--safe-bottom) + 24px);
  transform: translateY(100%);
  transition: transform 0.3s;
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.modal p {
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 20px;
}

/* Analyzing Modal */
.analyzing {
  text-align: center;
  padding: 40px 20px;
}

.analyzing-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Food Modal */
.food-detected {
  text-align: center;
  margin-bottom: 20px;
}

.food-detected h3 {
  font-size: 24px;
}

.food-serving {
  color: var(--gray-500);
  font-size: 14px;
}

.food-macros {
  display: flex;
  justify-content: space-around;
  background: var(--gray-50);
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 20px;
}

.fm {
  text-align: center;
}

.fm-val {
  font-size: 22px;
  font-weight: 700;
  display: block;
}

.fm-val.protein { color: var(--protein); }
.fm-val.carbs { color: var(--carbs); }
.fm-val.fats { color: var(--fats); }

.fm-label {
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================
   NOTIFICATIONS PAGE
   ============================================ */
.notifications-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--black);
  color: var(--white);
  padding: 14px 24px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-12 { gap: 12px; }
