*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Brand: matched to athletics-anonymous.com (lime + teal on near-black) */
  --bg:           #080808;
  --surface:      #111111;
  --surface-2:    #181818;
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.18);
  --text:         #F0EDE8;
  --text-muted:   #C8C4BE;
  --text-hint:    #d4f53c;
  --gold:         #d4f53c;                 /* legacy token name → lime */
  --gold-dim:     rgba(212,245,60,0.10);
  --teal:         #00e5c8;
  --teal-dim:     rgba(0,229,200,0.10);
  --red:          #ff5a5a;
  --green:        #00e5c8;                 /* success reads teal on-brand */
  --radius:       12px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  /* Spring-like easing for tap/sheet motion (slight overshoot) */
  --spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Hierarchical floating shadow (multi-layer) */
  --shadow-float: 0 1px 2px rgba(0,0,0,0.30), 0 6px 16px rgba(0,0,0,0.35), 0 12px 32px rgba(0,0,0,0.22);
}

html {
  height: 100%;
  overflow: hidden;          /* html never scrolls → no rubber-band on fixed nav */
  background: var(--bg);     /* keep webview backdrop dark so no white shows through */
  -webkit-text-size-adjust: 100%;     /* don't let iOS resize text */
  touch-action: manipulation;          /* disable double-tap-to-zoom */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow-y: auto;          /* body is the scroll container */
  overflow-x: hidden;
  overscroll-behavior-y: none;        /* kill bounce past the ends */
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;          /* disable double-tap-to-zoom */
  -webkit-tap-highlight-color: transparent;  /* no grey flash on tap */
}

/* ── LAYOUT ── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 1.25rem) 1.25rem calc(var(--safe-bottom) + 5rem);
  min-height: 100vh;
}

.page-full {
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
  min-height: 100vh;
}

/* ── NAV BAR (immersive footer: content fades under a frosted bar) ── */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  /* (5) gradient fade so scrolling content dissolves under the bar */
  background: linear-gradient(to top, rgba(8,8,8,0.98) 62%, rgba(8,8,8,0.82) 88%, rgba(8,8,8,0));
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.6rem 0 calc(var(--safe-bottom) + 0.5rem);
  z-index: 100;
}
/* (10) animated tab icon — active item lifts + scales its glyph */
.nav-item svg { transition: transform 0.25s var(--spring); }
.nav-item.active svg { transform: translateY(-2px) scale(1.12); }

.nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; text-decoration: none;
  color: var(--text-muted); font-size: 0.6rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: color 0.2s;
}
.nav-item.active, .nav-item:hover { color: var(--gold); }
.nav-item svg { width: 22px; height: 22px; }

/* ── TYPOGRAPHY ── */
.serif { font-family: 'DM Serif Display', Georgia, serif; }
h1 { font-family: 'DM Serif Display', serif; font-size: 2rem; line-height: 1.1; }
h2 { font-family: 'DM Serif Display', serif; font-size: 1.4rem; line-height: 1.2; }
h3 { font-size: 0.9rem; font-weight: 500; }

.label {
  font-size: 0.6rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-hint);
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.18);  /* hierarchical lift */
  transition: border-color 0.2s ease, transform 0.18s var(--spring), box-shadow 0.2s ease;
}
.card:hover { border-color: var(--border-hover); }
.card:active { transform: scale(0.992); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: 8px;
  font-size: 0.82rem; font-weight: 500; letter-spacing: 0.04em;
  cursor: pointer; text-decoration: none;
  transition: opacity 0.15s ease, transform 0.18s var(--spring), box-shadow 0.2s ease;
  padding: 0.7rem 1.2rem;
}
.btn:active { opacity: 0.9; transform: scale(0.95); }
.btn-primary { box-shadow: 0 2px 10px rgba(212,245,60,0.25); }
.btn-primary:active { box-shadow: 0 0 0 5px rgba(212,245,60,0.18); }

/* ── MOTION: entrances, spring taps, floating cards ── */
@keyframes aa-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes aa-pop {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
/* Page header/content eases in on load */
.page, .page-full, [class*="page-header"], .header { animation: aa-fade-up 0.34s var(--spring) both; }

/* (2) STAGGERED ENTRANCE — JS adds .aa-stagger to a list container;
   each direct child cascades in. */
.aa-stagger > * { animation: aa-fade-up 0.4s var(--spring) both; }
.aa-stagger > *:nth-child(1) { animation-delay: 0.02s; }
.aa-stagger > *:nth-child(2) { animation-delay: 0.06s; }
.aa-stagger > *:nth-child(3) { animation-delay: 0.10s; }
.aa-stagger > *:nth-child(4) { animation-delay: 0.14s; }
.aa-stagger > *:nth-child(5) { animation-delay: 0.18s; }
.aa-stagger > *:nth-child(6) { animation-delay: 0.22s; }
.aa-stagger > *:nth-child(7) { animation-delay: 0.26s; }
.aa-stagger > *:nth-child(8) { animation-delay: 0.30s; }
.aa-stagger > *:nth-child(n+9) { animation-delay: 0.34s; }

/* (3) SPRING tap feedback on tiles/chips */
.quick-card:active, .more-card:active, .snap-card:active,
.food-chip:active, .pill-btn:active, .serving-opt:active,
.suggestion-item:active { transform: scale(0.95); }
.quick-card, .more-card, .snap-card, .food-chip, .pill-btn, .serving-opt, .suggestion-item {
  transition: transform 0.18s var(--spring), border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

/* (1) HIERARCHICAL SHADOWS — gold/featured tiles physically float */
.quick-card.gold, .more-card.gold, .snap-card.highlight {
  box-shadow: var(--shadow-float);
}

/* Value pop when a number updates (add .aa-pop via JS) */
.aa-pop { animation: aa-pop 0.4s var(--spring); }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.btn-primary { background: var(--gold); color: #0A0A0A; width: 100%; justify-content: center; padding: 0.9rem; font-size: 0.9rem; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); width: 100%; justify-content: center; padding: 0.9rem; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 0.5rem; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.75rem; }
.btn-danger { background: rgba(224,82,82,0.15); color: var(--red); border: 1px solid rgba(224,82,82,0.2); }

/* ── INPUTS ── */
.input-group { margin-bottom: 1rem; }
.input-group label { display: block; margin-bottom: 0.4rem; font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
input, textarea, select {
  width: 100%; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  padding: 0.75rem 0.9rem; outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ── TAG / BADGE ── */
.tag {
  display: inline-block; font-size: 0.58rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
  background: var(--gold-dim); color: var(--gold);
}
.tag-green { background: rgba(82,192,122,0.12); color: var(--green); }
.tag-muted { background: var(--surface-2); color: var(--text-muted); }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }

/* ── PILL TABS ── */
.tabs {
  display: flex; gap: 6px; margin-bottom: 1.25rem;
  background: var(--surface); border-radius: 10px; padding: 4px;
}
.tab {
  flex: 1; text-align: center; padding: 0.5rem;
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: 7px; cursor: pointer; color: var(--text-muted);
  transition: all 0.2s; border: none; background: transparent;
}
.tab.active { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ── SECTION HEADER ── */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}

/* ── SPINNER ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: calc(var(--safe-bottom) + 80px); left: 50%;
  transform: translateX(-50%) translateY(20px) scale(0.96);
  /* (4) frosted material */
  background: rgba(26,26,26,0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 0.65rem 1.25rem;
  font-size: 0.82rem; color: var(--text);
  box-shadow: var(--shadow-float);
  opacity: 0; transition: all 0.32s var(--spring); pointer-events: none;
  white-space: nowrap; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.toast.success { border-color: rgba(82,192,122,0.4); color: var(--green); }
.toast.error { border-color: rgba(224,82,82,0.4); color: var(--red); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 0.85rem; }
.empty-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.4; }

/* ── AVATAR ── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; color: var(--gold);
  flex-shrink: 0;
}

/* ── ROW ── */
.row { display: flex; gap: 0.75rem; }
.row .input-group { flex: 1; }

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 4px; background: var(--surface-2);
  border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--gold);
  border-radius: 2px; transition: width 0.4s;
}
