/* NutriSync AI - Premium Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Primary gradient palette */
  --g-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --g-emerald: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --g-coral: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --g-ocean: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --g-gold: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
  --g-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --g-card: linear-gradient(145deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.05) 100%);
  
  /* Colors */
  --clr-bg: #0a0e1a;
  --clr-surface: #111827;
  --clr-surface2: #1f2937;
  --clr-border: rgba(255,255,255,0.08);
  --clr-text: #f9fafb;
  --clr-text2: #9ca3af;
  --clr-text3: #6b7280;
  --clr-primary: #667eea;
  --clr-accent: #38ef7d;
  --clr-danger: #f5576c;
  --clr-warning: #ffd200;
  
  /* Spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 1.5rem;
  --sp-xl: 2rem;
  --sp-2xl: 3rem;
  
  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(102,126,234,0.3);
  --shadow-glow-green: 0 0 30px rgba(56,239,125,0.2);
  
  /* Transitions */
  --t-fast: 0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Safe area */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 72px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* App shell */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--clr-bg);
  position: relative;
  overflow: hidden;
}

/* Pages */
.page {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--t-slow), transform var(--t-slow);
  pointer-events: none;
  display: none;
}
.page.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
  animation: pageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 20px 12px;
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--clr-border);
}
.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--g-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.app-header .subtitle {
  font-size: 0.75rem;
  color: var(--clr-text3);
  margin-top: 2px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 8px 0 var(--safe-bottom);
  background: rgba(17,24,39,0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--clr-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  z-index: 200;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--r-md);
  transition: var(--t-normal);
  position: relative;
  min-width: 52px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg {
  width: 22px; height: 22px;
  stroke: var(--clr-text3);
  transition: var(--t-normal);
}
.nav-item span {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--clr-text3);
  transition: var(--t-normal);
  white-space: nowrap;
}
.nav-item.active svg { stroke: var(--clr-primary); }
.nav-item.active span { color: var(--clr-primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--g-primary);
  border-radius: 0 0 4px 4px;
}
.nav-item:active { transform: scale(0.9); }

/* Cards */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-normal), box-shadow var(--t-normal);
}
.card:active { transform: scale(0.98); }
.card-glass {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
}
.card-gradient {
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  color: white;
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--r-full);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--t-normal);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary {
  background: var(--g-primary);
  color: white;
  box-shadow: 0 4px 20px rgba(102,126,234,0.4);
}
.btn-primary:active { transform: scale(0.96); box-shadow: none; }
.btn-secondary {
  background: var(--clr-surface2);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
}
.btn-secondary:active { transform: scale(0.96); }
.btn-danger {
  background: linear-gradient(135deg, #f5576c, #e84393);
  color: white;
  box-shadow: 0 4px 20px rgba(245,87,108,0.3);
}
.btn-success {
  background: var(--g-emerald);
  color: white;
  box-shadow: var(--shadow-glow-green);
}
.btn-outline {
  background: transparent;
  color: var(--clr-primary);
  border: 1.5px solid var(--clr-primary);
}
.btn-icon {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  flex-shrink: 0;
}
.btn-icon:active { transform: scale(0.9); }
.btn-full { width: 100%; }

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-md);
  color: var(--clr-text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--t-normal);
  -webkit-appearance: none;
}
.input:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(102,126,234,0.15); }
.input::placeholder { color: var(--clr-text3); }
.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 44px; }
.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--clr-text3);
  pointer-events: none;
}
.input-with-icon .input-icon svg { width: 18px; height: 18px; }

/* Progress bars */
.progress-bar {
  height: 8px;
  background: var(--clr-surface2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-thin { height: 4px; }
.progress-thick { height: 12px; }

/* Stats ring */
.stat-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat-ring svg { transform: rotate(-90deg); }
.stat-ring .ring-text {
  position: absolute;
  text-align: center;
}

/* Macro pills */
.macro-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--clr-border);
}
.macro-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Meal cards */
.meal-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  transition: var(--t-normal);
}
.meal-card:active { transform: scale(0.98); }
.meal-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.meal-icon svg { width: 22px; height: 22px; }

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--clr-text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-action {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-primary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-primary { background: rgba(102,126,234,0.2); color: #a78bfa; border: 1px solid rgba(102,126,234,0.3); }
.badge-success { background: rgba(56,239,125,0.15); color: #34d399; border: 1px solid rgba(56,239,125,0.3); }
.badge-warning { background: rgba(255,210,0,0.15); color: #fbbf24; border: 1px solid rgba(255,210,0,0.3); }
.badge-danger { background: rgba(245,87,108,0.15); color: #f87171; border: 1px solid rgba(245,87,108,0.3); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--t-normal);
}
.modal-overlay.open { opacity: 1; }
.modal {
  width: 100%;
  max-width: 430px;
  background: var(--clr-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform var(--t-slow);
  max-height: 85dvh;
  overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--clr-border);
  border-radius: var(--r-full);
  margin: 0 auto 20px;
}

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--g-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(102,126,234,0.5);
  z-index: 150;
  transition: var(--t-normal);
  -webkit-tap-highlight-color: transparent;
}
.fab svg { width: 26px; height: 26px; stroke: white; }
.fab:active { transform: scale(0.9); box-shadow: none; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(102,126,234,0.3); }
  50% { box-shadow: 0 0 40px rgba(102,126,234,0.6); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.animate-fade { animation: fadeIn 0.5s ease; }
.animate-slide-up { animation: slideUp 0.4s ease; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-glow { animation: glow-pulse 2s ease-in-out infinite; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--clr-surface) 25%, var(--clr-surface2) 50%, var(--clr-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: all;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-md);
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { background: #065f46; color: #a7f3d0; border: 1px solid #047857; }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.toast-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #1d4ed8; }

/* Auth pages */
.auth-bg {
  min-height: 100dvh;
  background: var(--g-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 32px;
}
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.auth-logo .logo-icon {
  width: 80px; height: 80px;
  border-radius: 24px;
  background: var(--g-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  animation: glow-pulse 3s ease-in-out infinite;
}
.auth-logo .logo-icon svg { width: 44px; height: 44px; stroke: white; }
.auth-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  background: var(--g-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo p {
  font-size: 0.9rem;
  color: var(--clr-text3);
  text-align: center;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-xl);
  padding: 28px 24px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--clr-text3);
  font-size: 0.8rem;
  margin: 16px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--clr-border);
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* Flex utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Spacing utilities */
.p-1 { padding: 4px; } .p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* Text utilities */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-muted { color: var(--clr-text2); }
.text-dim { color: var(--clr-text3); }
.text-primary { color: var(--clr-primary); }
.text-success { color: #34d399; }
.text-danger { color: var(--clr-danger); }
.text-warning { color: var(--clr-warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.gradient-text {
  background: var(--g-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Misc */
.rounded-full { border-radius: var(--r-full); }
.rounded-lg { border-radius: var(--r-lg); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.visible { display: block; }
.opacity-50 { opacity: 0.5; }
.pointer-events-none { pointer-events: none; }

/* Section padding */
.section { padding: 16px 20px; }
.section + .section { padding-top: 0; }

/* List items */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--t-normal);
}
.list-item:active { background: var(--clr-surface2); transform: scale(0.99); }
.list-item + .list-item { margin-top: 8px; }
.list-item .li-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.list-item .li-icon svg { width: 20px; height: 20px; }
.list-item .li-content { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 0.9rem; }
.list-item .li-subtitle { font-size: 0.75rem; color: var(--clr-text3); margin-top: 2px; }
.list-item .li-end { color: var(--clr-text3); flex-shrink: 0; }
.list-item .li-end svg { width: 16px; height: 16px; }

/* Hero gradient card */
.hero-card {
  margin: 16px 20px;
  border-radius: var(--r-xl);
  padding: 24px 20px;
  position: relative;
  overflow: hidden;
  color: white;
}
.hero-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--g-primary);
}
.hero-card::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}
.hero-card > * { position: relative; z-index: 1; }

/* Calorie ring */
.calorie-ring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.calorie-ring {
  position: relative;
  width: 160px; height: 160px;
}
.calorie-ring svg { transform: rotate(-90deg); }
.calorie-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.calorie-ring-text .kcal-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.calorie-ring-text .kcal-label {
  font-size: 0.7rem;
  color: var(--clr-text3);
  margin-top: 2px;
}
.calorie-ring-text .kcal-remaining {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}

/* Macro bars */
.macro-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.macro-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.macro-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.macro-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text2);
}
.macro-value {
  font-size: 0.75rem;
  color: var(--clr-text3);
}

/* AI chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--nav-height) - 60px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.5;
  animation: slideUp 0.3s ease;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--g-primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  border-bottom-left-radius: 4px;
}
.chat-bubble.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 18px;
}
.typing-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--clr-text3);
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.chat-input-bar {
  padding: 12px 16px;
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--clr-surface2);
  border: 1.5px solid var(--clr-border);
  border-radius: 20px;
  color: var(--clr-text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  transition: var(--t-normal);
}
.chat-input:focus { border-color: var(--clr-primary); }
.chat-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--g-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(102,126,234,0.4);
  transition: var(--t-normal);
}
.chat-send:active { transform: scale(0.9); }
.chat-send svg { width: 18px; height: 18px; stroke: white; }

/* Mode selector tabs */
.mode-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--clr-surface);
  border-radius: var(--r-full);
  margin-bottom: 16px;
}
.mode-tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--t-normal);
  color: var(--clr-text3);
  user-select: none;
  border: none;
  background: transparent;
}
.mode-tab.active {
  background: var(--g-primary);
  color: white;
  box-shadow: 0 2px 12px rgba(102,126,234,0.3);
}

/* Onboarding */
.onboarding-page {
  min-height: 100dvh;
  background: var(--clr-bg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}
.onboarding-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 32px;
}
.onboarding-step-dot {
  flex: 1;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--clr-surface2);
  transition: background var(--t-slow);
}
.onboarding-step-dot.active { background: var(--g-primary); }
.onboarding-step-dot.completed { background: var(--clr-accent); }

/* Checkbox custom */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--t-normal);
  user-select: none;
}
.checkbox-item.checked {
  border-color: var(--clr-primary);
  background: rgba(102,126,234,0.1);
}
.checkbox-box {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--clr-text3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--t-normal);
}
.checkbox-item.checked .checkbox-box {
  background: var(--g-primary);
  border-color: transparent;
}
.checkbox-box svg { width: 12px; height: 12px; stroke: white; opacity: 0; transition: var(--t-fast); }
.checkbox-item.checked .checkbox-box svg { opacity: 1; }
.checkbox-label { font-size: 0.9rem; font-weight: 500; }

/* Select chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1.5px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text2);
  cursor: pointer;
  transition: var(--t-normal);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chip.selected {
  background: rgba(102,126,234,0.2);
  border-color: var(--clr-primary);
  color: #a78bfa;
}
.chip:active { transform: scale(0.95); }

/* Loader */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
  background: var(--g-dark);
}
.loader-ring {
  width: 60px; height: 60px;
  border: 3px solid rgba(102,126,234,0.2);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader-text {
  font-size: 0.9rem;
  color: var(--clr-text3);
  animation: pulse 2s infinite;
}

/* Fridge items */
.fridge-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  transition: var(--t-normal);
}
.fridge-item.expiring-soon { border-color: rgba(255,210,0,0.4); background: rgba(255,210,0,0.05); }
.fridge-item.expired { border-color: rgba(245,87,108,0.4); background: rgba(245,87,108,0.05); }
.expiry-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

/* Water tracker */
.water-tracker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.water-glass {
  position: relative;
  width: 80px; height: 120px;
  border: 3px solid rgba(79,172,254,0.5);
  border-top: none;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  background: transparent;
}
.water-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(0,242,254,0.6), rgba(79,172,254,0.9));
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 0 17px 17px;
}

/* Misc patterns */
.divider { height: 1px; background: var(--clr-border); margin: 16px 0; }
.tag { 
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 0.7rem; font-weight: 600;
  background: var(--clr-surface2); color: var(--clr-text2);
}

/* Safe area spacer */
.safe-area-bottom { height: calc(var(--nav-height) + 16px + var(--safe-bottom)); }

/* Print / accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
