/*
 * Atproo EDA AI — Design System v2
 * Premium nutrition app visual language.
 * Inspired by: Cal AI, Welmi, Lifesum, Apple Health.
 *
 * ARCHITECTURE
 *  1. Design tokens (CSS custom properties)
 *  2. Reset & base
 *  3. Typography
 *  4. Layout primitives (app shell, sidebar, topbar, bottom nav)
 *  5. Auth screen
 *  6. Onboarding (Welmi-style)
 *  7. Home / Dashboard
 *  8. Scan page
 *  9. History page
 * 10. Profile page
 * 11. Coach / Chat
 * 12. Components (cards, badges, buttons, modals, skeletons)
 * 13. Animations
 * 14. Light mode
 * 15. Reduced-motion
 */

/* ═══════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */
:root {
  /* Background layers */
  --bg:         #09090f;
  --bg2:        #111118;
  --bg3:        #18181f;
  --bg4:        #1e1e28;
  --surface:    rgba(255,255,255,0.04);
  --surface2:   rgba(255,255,255,0.07);
  --border:     rgba(255,255,255,0.08);
  --border2:    rgba(255,255,255,0.13);

  /* Primary brand — electric emerald */
  --g1:  #00e5a0;
  --g2:  #00c87a;
  --g3:  #00f5b0;

  /* Accent palette */
  --purple: #a78bfa;
  --blue:   #60a5fa;
  --or:     #fb923c;
  --rd:     #f87171;
  --yellow: #fbbf24;
  --pink:   #f472b6;

  /* Gradients */
  --grad-brand:   linear-gradient(135deg, #00e5a0 0%, #00b4d8 100%);
  --grad-purple:  linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
  --grad-warm:    linear-gradient(135deg, #fb923c 0%, #f87171 100%);
  --grad-dark:    linear-gradient(180deg, #111118 0%, #09090f 100%);
  --grad-card:    linear-gradient(135deg, rgba(0,229,160,0.12) 0%, rgba(0,180,216,0.06) 100%);

  /* Text */
  --t1: #f8fafc;
  --t2: #94a3b8;
  --t3: #475569;
  --t4: #1e293b;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 36px;
  --r-full: 9999px;

  /* Shadows */
  --sh-sm:  0 2px 8px rgba(0,0,0,0.3);
  --sh:     0 4px 20px rgba(0,0,0,0.4);
  --sh-lg:  0 12px 40px rgba(0,0,0,0.5);
  --sh-glow:0 0 30px rgba(0,229,160,0.2);
  --sh-card:0 1px 3px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15);

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp:    12px;
  --sp-md: 16px;
  --sp-lg: 20px;
  --sp-xl: 24px;
  --sp-2xl:32px;
  --sp-3xl:48px;

  /* Type scale */
  --fs-xs:  11px;
  --fs-sm:  13px;
  --fs-base:15px;
  --fs-md:  17px;
  --fs-lg:  20px;
  --fs-xl:  24px;
  --fs-2xl: 30px;
  --fs-3xl: 38px;
  --fs-4xl: 48px;

  /* Motion */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:  160ms;
  --dur:       240ms;
  --dur-slow:  400ms;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --bottomnav-h: 76px;
  --content-max: 480px;
}

/* ═══════════════════════════════════════════════════════════
   2. RESET & BASE
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--t1);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }
a { color: var(--g1); text-decoration: none; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
.display { font-size: var(--fs-3xl); font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; }
.headline { font-size: var(--fs-xl); font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
.title    { font-size: var(--fs-md); font-weight: 600; line-height: 1.35; }
.body     { font-size: var(--fs-base); line-height: 1.6; }
.caption  { font-size: var(--fs-xs); color: var(--t3); letter-spacing: 0.02em; }
.mono     { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ═══════════════════════════════════════════════════════════
   4. APP SHELL
   ═══════════════════════════════════════════════════════════ */
#app {
  display: flex;
  min-height: 100dvh;
  background: var(--bg);
}

/* ── Pages ── */
.page {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: pageFadeIn var(--dur) var(--ease-smooth);
}
.page.active, .page.on { display: flex; }

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Content scroll area ── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-md) var(--sp-md) calc(var(--bottomnav-h) + 24px);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar — thin, premium */
#content::-webkit-scrollbar { width: 3px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: var(--r-full); }

/* ── Sidebar (desktop ≥768px) ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  padding: var(--sp-xl) 0;
  position: sticky;
  top: 0;
  height: 100dvh;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .sidebar { display: flex; }
  #content { padding-bottom: var(--sp-2xl); }
}

.sb-logo {
  padding: 0 var(--sp-md) var(--sp-xl);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sb-user {
  margin: 0 var(--sp-sm) var(--sp-lg);
  padding: var(--sp);
  background: var(--surface);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: var(--sp);
}

.sb-av {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm);
  color: #000;
  flex-shrink: 0;
}

.sb-nm { font-size: var(--fs-sm); font-weight: 600; color: var(--t1); }
.sb-pl { font-size: var(--fs-xs); color: var(--t3); margin-top: 2px; }

.sb-nav { flex: 1; padding: 0 var(--sp-sm); display: flex; flex-direction: column; gap: 2px; }

.sb-item, .sdi {
  display: flex; align-items: center; gap: var(--sp);
  padding: 10px var(--sp);
  border-radius: var(--r);
  color: var(--t2);
  font-size: var(--fs-sm); font-weight: 500;
  transition: background var(--dur-fast) var(--ease-smooth),
              color var(--dur-fast) var(--ease-smooth);
  cursor: pointer;
}
.sb-item:hover, .sdi:hover { background: var(--surface); color: var(--t1); }
.sb-item.active, .sdi.active {
  background: rgba(0,229,160,0.1);
  color: var(--g1);
}

/* ── Top bar (mobile) ── */
.topbar {
  height: var(--topbar-h);
  background: rgba(9,9,15,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-md);
  gap: var(--sp);
}

.tb-logo {
  font-size: 18px; font-weight: 800; letter-spacing: -0.02em;
  background: var(--grad-brand);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}

#tb-av {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #000;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
}
#tb-av:active { transform: scale(0.9); }

.tb-bell {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t2); cursor: pointer;
  border-radius: var(--r-full);
  transition: background var(--dur-fast);
}
.tb-bell:hover { background: var(--surface); }
#tb-bell-dot {
  width: 8px; height: 8px;
  background: var(--rd);
  border-radius: var(--r-full);
  position: absolute; top: 4px; right: 4px;
  border: 2px solid var(--bg);
  display: none;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }

/* ── Bottom navigation (mobile) ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: rgba(9,9,15,0.92);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 var(--sp-sm) env(safe-area-inset-bottom);
  z-index: 200;
}

@media (min-width: 768px) { .bottom-nav { display: none; } }

.bn-item, .nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-sm) var(--sp);
  border-radius: var(--r);
  color: var(--t3);
  font-size: 9px; font-weight: 500; letter-spacing: 0.03em;
  transition: color var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
  cursor: pointer; flex: 1;
}
.bn-item:active, .nav-item:active { transform: scale(0.88); }
.bn-item.active, .nav-item.active, .bn-item.on, .nav-item.on { color: var(--g1); }

.bn-ico { font-size: 20px; line-height: 1; }

/* Active indicator pill */
.bn-item.active .bn-ico::after,
.nav-item.active .bn-ico::after {
  content: '';
  display: block;
  width: 4px; height: 4px;
  background: var(--g1);
  border-radius: var(--r-full);
  margin: 2px auto 0;
}

/* ═══════════════════════════════════════════════════════════
   5. AUTH SCREEN
   ═══════════════════════════════════════════════════════════ */
#auth-screen {
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl) var(--sp-md);
  position: relative;
  overflow: hidden;
}

/* Ambient gradient orbs */
#auth-screen::before {
  content: '';
  position: absolute; top: -120px; left: -80px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,229,160,0.12) 0%, transparent 70%);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}
#auth-screen::after {
  content: '';
  position: absolute; bottom: -80px; right: -60px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(167,139,250,0.1) 0%, transparent 70%);
  pointer-events: none;
  animation: orbFloat 10s ease-in-out infinite reverse;
}
@keyframes orbFloat {
  0%,100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(20px,-20px) scale(1.05); }
}

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  box-shadow: var(--sh-lg);
  position: relative; z-index: 1;
  animation: authCardIn 0.5s var(--ease-spring) both;
}
@keyframes authCardIn {
  from { opacity: 0; transform: scale(0.94) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--sp-2xl);
}
.auth-logo-text {
  font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.03em;
  background: var(--grad-brand);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo-sub { font-size: var(--fs-sm); color: var(--t3); margin-top: 4px; }

.auth-tabs {
  display: flex;
  background: var(--bg3);
  border-radius: var(--r);
  padding: 3px;
  margin-bottom: var(--sp-xl);
  gap: 3px;
}
.auth-tab {
  flex: 1; text-align: center;
  padding: 8px;
  border-radius: calc(var(--r) - 3px);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--t3);
  transition: all var(--dur-fast) var(--ease-smooth);
  cursor: pointer;
}
.auth-tab.active {
  background: var(--bg4);
  color: var(--t1);
  box-shadow: var(--sh-sm);
}

/* Field */
.fi, .auth-field {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 13px var(--sp-md);
  font-size: var(--fs-base); color: var(--t1);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  margin-bottom: var(--sp);
}
.fi:focus, .auth-field:focus {
  border-color: var(--g1);
  box-shadow: 0 0 0 3px rgba(0,229,160,0.12);
}
.fi::placeholder, .auth-field::placeholder { color: var(--t3); }

/* Primary button */
.btn-primary, #login-btn, .auth-submit {
  width: 100%;
  padding: 14px;
  background: var(--grad-brand);
  color: #000;
  font-size: var(--fs-base); font-weight: 700;
  border-radius: var(--r);
  border: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-fast);
  box-shadow: 0 4px 20px rgba(0,229,160,0.3);
  letter-spacing: 0.01em;
}
.btn-primary:hover, #login-btn:hover, .auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(0,229,160,0.4);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Social buttons */
.social-row { display: flex; gap: var(--sp); margin-top: var(--sp); }
.btn-social {
  flex: 1; padding: 11px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--t2);
  font-size: var(--fs-sm); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--dur-fast);
}
.btn-social:hover { background: var(--surface2); color: var(--t1); border-color: var(--border2); }

.auth-divider {
  display: flex; align-items: center; gap: var(--sp);
  color: var(--t3); font-size: var(--fs-xs);
  margin: var(--sp-md) 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ═══════════════════════════════════════════════════════════
   6. ONBOARDING — Welmi-style
   ═══════════════════════════════════════════════════════════ */
.ob-shell {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ── */
.ob-topbar {
  display: flex; align-items: center;
  padding: max(env(safe-area-inset-top), 12px) var(--sp-md) var(--sp);
  gap: var(--sp);
  flex-shrink: 0;
}

.ob-back {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--t2);
  transition: all var(--dur-fast) var(--ease-spring);
  flex-shrink: 0;
}
.ob-back:hover { background: var(--surface2); color: var(--t1); }
.ob-back:active { transform: scale(0.88); }

.ob-progress-wrap {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.ob-progress-track {
  height: 4px;
  background: var(--bg3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%;
  background: var(--grad-brand);
  border-radius: var(--r-full);
  transition: width 0.4s var(--ease-smooth);
}
.ob-progress-label { font-size: var(--fs-xs); color: var(--t3); text-align: center; }

.ob-skip {
  color: var(--t3); font-size: var(--fs-sm); font-weight: 500;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--r);
  transition: color var(--dur-fast);
  flex-shrink: 0;
}
.ob-skip:hover { color: var(--t1); }

/* ── Body ── */
.ob-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-lg) var(--sp-md);
  display: flex; flex-direction: column; gap: var(--sp-lg);
  will-change: opacity, transform;
}
.ob-body::-webkit-scrollbar { display: none; }

.ob-head {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-md); text-align: center;
}

.ob-illo {
  font-size: 64px; line-height: 1;
  animation: illoPop 0.5s var(--ease-spring) both 0.1s;
  filter: drop-shadow(0 8px 24px rgba(0,229,160,0.2));
}
@keyframes illoPop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.ob-title {
  font-size: var(--fs-2xl); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.15;
  color: var(--t1);
}

.ob-subtitle {
  font-size: var(--fs-sm); color: var(--t3); line-height: 1.6;
  max-width: 280px;
}

/* ── Option cards ── */
.ob-cards {
  display: flex; flex-direction: column; gap: var(--sp);
}
.ob-cards-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp);
}

.ob-card {
  display: flex; align-items: center; gap: var(--sp);
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  text-align: left;
  transition: all var(--dur-fast) var(--ease-smooth);
  position: relative; overflow: hidden;
}
.ob-card::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad-card);
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.ob-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.ob-card:hover::before { opacity: 1; }
.ob-card.selected {
  border-color: var(--g1);
  background: rgba(0,229,160,0.06);
  box-shadow: 0 0 0 1px rgba(0,229,160,0.2), var(--sh-glow);
}
.ob-card.selected::before { opacity: 1; }
.ob-card:active { transform: scale(0.97); }

.ob-card-icon { font-size: 28px; flex-shrink: 0; position: relative; z-index: 1; }

.ob-card-text { flex: 1; position: relative; z-index: 1; }
.ob-card-label { font-size: var(--fs-base); font-weight: 600; color: var(--t1); }
.ob-card-desc  { font-size: var(--fs-xs); color: var(--t3); margin-top: 2px; }

.ob-card-check {
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  transition: all var(--dur-fast);
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.ob-card.selected .ob-card-check {
  background: var(--g1);
  border-color: var(--g1);
  color: #000;
}

/* Big 2-column card variant (gender) */
.ob-card-big {
  flex-direction: column; gap: var(--sp-sm);
  padding: var(--sp-xl) var(--sp-md);
  align-items: center; text-align: center;
}
.ob-card-big-icon { font-size: 48px; }

/* ── Multi-select chips ── */
.ob-multi-hint { font-size: var(--fs-xs); color: var(--t3); text-align: center; }
.ob-chips {
  display: flex; flex-wrap: wrap; gap: var(--sp-sm);
  justify-content: center;
}

.ob-chip {
  padding: 9px var(--sp-md);
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 500; color: var(--t2);
  transition: all var(--dur-fast) var(--ease-smooth);
  display: flex; align-items: center; gap: 6px;
}
.ob-chip:hover { border-color: var(--border2); color: var(--t1); }
.ob-chip.selected {
  background: rgba(0,229,160,0.1);
  border-color: var(--g1);
  color: var(--g1);
}
.ob-chip:active { transform: scale(0.93); }

/* ── Number wheel ── */
.ob-wheel-wrap {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-xl);
}
.ob-wheel-track {
  display: flex; align-items: center; gap: var(--sp-xl);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-lg) var(--sp-2xl);
}
.ob-wheel-display {
  text-align: center;
  min-width: 100px;
}
.ob-wheel-val {
  display: block;
  font-size: var(--fs-4xl); font-weight: 800;
  letter-spacing: -0.04em;
  background: var(--grad-brand);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform 0.1s var(--ease-spring);
}
.ob-wheel-unit { font-size: var(--fs-base); color: var(--t3); }

.ob-wheel-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  background: var(--surface2);
  border: 1px solid var(--border2);
  font-size: var(--fs-xl); font-weight: 300; color: var(--t1);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-spring);
  flex-shrink: 0;
}
.ob-wheel-btn:hover { background: var(--bg3); border-color: var(--g1); color: var(--g1); }
.ob-wheel-btn:active { transform: scale(0.88); }

.ob-slider {
  width: min(320px, 100%);
  appearance: none;
  height: 4px;
  background: var(--bg3);
  border-radius: var(--r-full);
  outline: none;
  cursor: pointer;
}
.ob-slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  background: var(--g1);
  box-shadow: 0 2px 8px rgba(0,229,160,0.4);
  cursor: grab;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.ob-slider::-webkit-slider-thumb:active { transform: scale(1.2); cursor: grabbing; }
.ob-slider::-moz-range-thumb {
  width: 22px; height: 22px; border: none;
  border-radius: var(--r-full); background: var(--g1);
}

/* ── Registration form ── */
.ob-form { display: flex; flex-direction: column; gap: var(--sp); }
.ob-field-group { display: flex; flex-direction: column; gap: var(--sp); }

.ob-field {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 13px var(--sp-md);
  font-size: var(--fs-base); color: var(--t1);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.ob-field:focus {
  border-color: var(--g1);
  box-shadow: 0 0 0 3px rgba(0,229,160,0.1);
}
.ob-field::placeholder { color: var(--t3); }

.ob-pass-wrap { position: relative; }
.ob-pass-wrap .ob-field { padding-right: 48px; }
.ob-eye {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--t3); font-size: 16px;
  transition: color var(--dur-fast);
}
.ob-eye:hover { color: var(--t1); }

/* Password strength */
.ob-pass-strength {
  display: flex; flex-direction: column; gap: 4px;
  min-height: 28px;
}
.ps-bar {
  height: 3px;
  background: var(--bg3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.ps-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.3s var(--ease-smooth), background 0.3s;
}
.ps-label { font-size: var(--fs-xs); font-weight: 600; }

.ob-terms {
  display: flex; align-items: flex-start; gap: var(--sp-sm);
  font-size: var(--fs-sm); color: var(--t2); line-height: 1.5;
  cursor: pointer;
}
.ob-terms input[type="checkbox"] {
  width: 18px; height: 18px;
  border-radius: var(--r-xs);
  accent-color: var(--g1);
  cursor: pointer;
  flex-shrink: 0; margin-top: 1px;
}
.ob-link { color: var(--g1); }

/* ── Footer button ── */
.ob-footer {
  padding: var(--sp-md) var(--sp-md) max(env(safe-area-inset-bottom), var(--sp-md));
  flex-shrink: 0;
}
.ob-next-btn {
  width: 100%;
  padding: 15px;
  background: var(--grad-brand);
  color: #000;
  font-size: var(--fs-base); font-weight: 700;
  border-radius: var(--r-lg);
  border: none; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-fast), opacity var(--dur-fast);
  box-shadow: 0 4px 24px rgba(0,229,160,0.35);
  letter-spacing: 0.01em;
}
.ob-next-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,229,160,0.45); }
.ob-next-btn:active { transform: scale(0.97); }
.ob-next-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ═══════════════════════════════════════════════════════════
   7. HOME / DASHBOARD
   ═══════════════════════════════════════════════════════════ */

/* Hero greeting */
.hero-wrap {
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
  position: relative; overflow: hidden;
}
.hero-wrap::after {
  content: '';
  position: absolute; top: -40px; right: -30px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(0,229,160,0.15) 0%, transparent 70%);
  pointer-events: none;
}
#hero-greeting { font-size: var(--fs-sm); color: var(--t3); font-weight: 500; }
#hero-name { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; color: var(--t1); margin-top: 4px; }

/* Macro ring summary */
.macro-rings {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.macro-ring {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp);
  text-align: center;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.macro-ring:active { transform: scale(0.94); }
.macro-ring-val { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.02em; }
.macro-ring-lbl { font-size: 9px; color: var(--t3); font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; margin-top: 2px; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp);
}
.section-title { font-size: var(--fs-base); font-weight: 700; color: var(--t1); }
.section-link  { font-size: var(--fs-sm); color: var(--g1); font-weight: 500; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════
   8. SCAN PAGE
   ═══════════════════════════════════════════════════════════ */
#liveAI {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  margin-top: var(--sp-md);
  animation: slideUp var(--dur-slow) var(--ease-spring);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   9. HISTORY PAGE
   ═══════════════════════════════════════════════════════════ */
.hist-item {
  display: flex; align-items: center; gap: var(--sp);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp) var(--sp-md);
  margin-bottom: var(--sp-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
  position: relative; overflow: hidden;
}
.hist-item::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--surface);
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.hist-item:hover { border-color: var(--border2); }
.hist-item:hover::before { opacity: 1; }
.hist-item:active { transform: scale(0.98); }

.hist-thumb {
  width: 48px; height: 48px;
  border-radius: var(--r);
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden;
  flex-shrink: 0;
}
.hist-thumb img { width: 100%; height: 100%; object-fit: cover; }

.hist-info { flex: 1; min-width: 0; }
.hist-name {
  font-size: var(--fs-sm); font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-date { font-size: var(--fs-xs); color: var(--t3); margin-top: 2px; }

.hist-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex-shrink: 0;
}
.hist-cal { font-size: var(--fs-sm); font-weight: 700; color: var(--t1); }

.hist-del {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--t3);
  transition: all var(--dur-fast);
}
.hist-del:hover { background: rgba(248,113,113,0.12); color: var(--rd); }

/* ═══════════════════════════════════════════════════════════
   10. PROFILE PAGE
   ═══════════════════════════════════════════════════════════ */
.prof-hero {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp);
  padding: var(--sp-2xl) var(--sp-md);
  text-align: center;
}
#profAv {
  width: 80px; height: 80px;
  border-radius: var(--r-full);
  background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-2xl); font-weight: 800; color: #000;
  box-shadow: 0 8px 32px rgba(0,229,160,0.3);
}
#profName { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
#profPlan { font-size: var(--fs-sm); color: var(--t3); }

.prof-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.prof-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-md);
  text-align: center;
}
.prof-stat-val { font-size: var(--fs-xl); font-weight: 800; color: var(--g1); }
.prof-stat-lbl { font-size: 10px; color: var(--t3); font-weight: 500; margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════
   11. COACH / CHAT
   ═══════════════════════════════════════════════════════════ */
.chat-bubble {
  max-width: 82%;
  padding: var(--sp) var(--sp-md);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm); line-height: 1.6;
  animation: bubbleIn var(--dur) var(--ease-spring);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.9) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.chat-bubble.user {
  background: var(--g1);
  color: #000; font-weight: 500;
  border-bottom-right-radius: var(--r-xs);
  align-self: flex-end;
}
.chat-bubble.ai {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--t1);
  border-bottom-left-radius: var(--r-xs);
  align-self: flex-start;
}

/* ═══════════════════════════════════════════════════════════
   12. COMPONENTS
   ═══════════════════════════════════════════════════════════ */

/* ── Card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  box-shadow: var(--sh-card);
}
.card-glass {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
}

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}
.b-green { background: rgba(0,229,160,0.15); color: var(--g1); }
.b-or    { background: rgba(251,146,60,0.15); color: var(--or); }
.b-red   { background: rgba(248,113,113,0.15); color: var(--rd); }
.b-purple{ background: rgba(167,139,250,0.15); color: var(--purple); }
.b-blue  { background: rgba(96,165,250,0.15); color: var(--blue); }

/* ── Button variants ── */
.btn {
  padding: 10px var(--sp-md);
  border-radius: var(--r);
  font-size: var(--fs-sm); font-weight: 600;
  transition: all var(--dur-fast) var(--ease-spring);
  cursor: pointer;
}
.btn:active { transform: scale(0.94); }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--t2);
}
.btn-ghost:hover { background: var(--surface2); color: var(--t1); }
.btn-danger {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  color: var(--rd);
}
.btn-primary-sm {
  padding: 8px var(--sp-md);
  background: var(--grad-brand);
  color: #000; font-size: var(--fs-sm); font-weight: 700;
  border-radius: var(--r);
  transition: all var(--dur-fast) var(--ease-spring);
}
.btn-primary-sm:hover { transform: translateY(-1px); box-shadow: var(--sh-glow); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.on { display: flex; animation: modalBgIn var(--dur) var(--ease-smooth); }
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%; max-width: var(--content-max);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: var(--sp-xl) var(--sp-md) max(env(safe-area-inset-bottom), var(--sp-xl));
  animation: sheetUp 0.38s var(--ease-spring);
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: var(--r-full);
  margin: 0 auto var(--sp-lg);
}

/* History detail modal */
.hd-header { display: flex; gap: var(--sp-md); align-items: center; margin-bottom: var(--sp-lg); }
.hd-thumb {
  width: 64px; height: 64px; border-radius: var(--r-lg);
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 32px; overflow: hidden; flex-shrink: 0;
}
.hd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hd-name  { font-size: var(--fs-md); font-weight: 700; }
.hd-date  { font-size: var(--fs-sm); color: var(--t3); margin-top: 4px; }
.hd-macros{
  display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.hd-macro { text-align: center; background: var(--bg3); border-radius: var(--r); padding: var(--sp); }
.hd-macro-val{ font-size: var(--fs-md); font-weight: 800; color: var(--g1); }
.hd-macro-lbl{ font-size: 10px; color: var(--t3); margin-top: 2px; }
.hd-advice { font-size: var(--fs-sm); color: var(--t2); line-height: 1.6; }
.hd-score  { margin-top: var(--sp-sm); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: calc(var(--bottomnav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 10px var(--sp-lg);
  font-size: var(--fs-sm); font-weight: 500;
  white-space: nowrap;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(16px);
  box-shadow: var(--sh-lg);
  transition: opacity var(--dur), transform var(--dur) var(--ease-spring);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-ok  { border-color: rgba(0,229,160,0.4); color: var(--g1); }
#toast.toast-err { border-color: rgba(248,113,113,0.4); color: var(--rd); }
#toast.toast-inf { color: var(--t1); }

@media (min-width: 768px) {
  #toast { bottom: 24px; }
}

/* ── XP bar ── */
.xp-bar-wrap {
  background: var(--bg3); border-radius: var(--r-full);
  height: 6px; overflow: hidden; margin: var(--sp-sm) 0;
}
.xp-bar-fill {
  height: 100%;
  background: var(--grad-brand);
  border-radius: var(--r-full);
  transition: width 0.6s var(--ease-smooth);
}

/* ── Streak days ── */
.streak-row  { display: flex; gap: var(--sp-sm); justify-content: center; }
.streak-day  { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.streak-circle{
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700; color: var(--t3);
  transition: all var(--dur-fast);
}
.streak-circle.done  { background: var(--g1); border-color: var(--g1); color: #000; }
.streak-circle.today { background: rgba(0,229,160,0.15); border-color: var(--g1); color: var(--g1); }
.streak-lbl { font-size: 9px; color: var(--t3); }

/* ── Skeleton loading ── */
.skel {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skel-row   { display: flex; align-items: center; gap: var(--sp); margin-bottom: var(--sp); }
.skel-thumb { width: 48px; height: 48px; border-radius: var(--r); flex-shrink: 0; }
.skel-info  { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skel-line  { height: 12px; }
.skel-w70   { width: 70%; }
.skel-w40   { width: 40%; }
.skel-badge { width: 36px; height: 20px; border-radius: var(--r-full); }

/* ── Empty state ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp);
  padding: var(--sp-3xl) var(--sp-md);
  text-align: center;
}
.empty-state-sm {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-sm); padding: var(--sp-2xl); text-align: center;
}
.empty-ico   { font-size: 48px; }
.empty-title { font-size: var(--fs-md); font-weight: 700; }
.empty-sub   { font-size: var(--fs-sm); color: var(--t3); }
.empty-txt   { font-size: var(--fs-sm); color: var(--t3); }

/* ── G2 grid helper ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp); }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp); }

/* ── Progress bar (generic) ── */
.prog-track {
  height: 6px; background: var(--bg3); border-radius: var(--r-full); overflow: hidden;
}
.prog-fill {
  height: 100%; border-radius: var(--r-full);
  background: var(--grad-brand);
  transition: width 0.6s var(--ease-smooth);
}

/* ═══════════════════════════════════════════════════════════
   13. ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
@keyframes fadeIn       { from{opacity:0}to{opacity:1} }
@keyframes slideInUp    { from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)} }
@keyframes slideInRight { from{opacity:0;transform:translateX(16px)}to{opacity:1;transform:translateX(0)} }
@keyframes scaleIn      { from{opacity:0;transform:scale(0.92)}to{opacity:1;transform:scale(1)} }
@keyframes bounceIn     { 0%{transform:scale(0.8);opacity:0}60%{transform:scale(1.05)}100%{transform:scale(1);opacity:1} }

.anim-fade  { animation: fadeIn var(--dur) var(--ease-smooth) both; }
.anim-up    { animation: slideInUp var(--dur) var(--ease-smooth) both; }
.anim-scale { animation: scaleIn var(--dur) var(--ease-spring) both; }

/* Stagger delay helpers */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }

/* Floating card effect */
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.float { animation: float 3s ease-in-out infinite; }

/* ═══════════════════════════════════════════════════════════
   14. LIGHT MODE
   ═══════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: light) {
  :root {
    --bg:      #f8fafc;
    --bg2:     #ffffff;
    --bg3:     #f1f5f9;
    --bg4:     #e2e8f0;
    --surface: rgba(0,0,0,0.03);
    --surface2:rgba(0,0,0,0.06);
    --border:  rgba(0,0,0,0.07);
    --border2: rgba(0,0,0,0.12);
    --t1: #0f172a;
    --t2: #475569;
    --t3: #94a3b8;
    --sh-sm:  0 2px 8px rgba(0,0,0,0.08);
    --sh:     0 4px 20px rgba(0,0,0,0.1);
    --sh-lg:  0 12px 40px rgba(0,0,0,0.15);
    --sh-glow:0 0 30px rgba(0,229,160,0.15);
    --sh-card:0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
  }
  #auth-screen { background: var(--bg); }
  #auth-screen::before {
    background: radial-gradient(circle, rgba(0,229,160,0.08) 0%, transparent 70%);
  }
}

/* Force dark if user has toggled theme in-app (data-theme attribute) */
[data-theme="dark"]  { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* ═══════════════════════════════════════════════════════════
   15. REDUCED MOTION
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   16. RESPONSIVE TWEAKS
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  :root { --content-max: 580px; }
  .ob-title { font-size: var(--fs-3xl); }
  .auth-card { padding: var(--sp-3xl); }
  #content { padding-top: var(--sp-2xl); }
}

@media (min-width: 1024px) {
  :root { --content-max: 640px; }
  .ob-shell { align-items: center; justify-content: center; background: rgba(9,9,15,0.6); }
  .ob-topbar, .ob-body, .ob-footer {
    max-width: 480px; width: 100%;
  }
  .ob-body { max-height: 70dvh; }
}

/* ── Safe-area insets for notched devices ── */
.ob-topbar { padding-top: max(env(safe-area-inset-top), 12px); }
.ob-footer { padding-bottom: max(env(safe-area-inset-bottom), 16px); }
.bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 0px); }
