/**
 * Kleen.ai Design System
 * Instacart-grade branding + DJI/Oura interaction quality
 * Version 2.0
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* === COLOR — PRIMARY (Kleen Green) === */
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;
  --green-300: #86efac;
  --green-200: #bbf7d0;
  --green-100: #dcfce7;
  --green-50:  #f0fdf4;

  /* Semantic green shortcuts */
  --brand:       var(--green-600);
  --brand-hover: var(--green-500);
  --brand-light: var(--green-100);
  --brand-dim:   rgba(22, 163, 74, 0.08);
  --brand-glow:  rgba(22, 163, 74, 0.22);

  /* === COLOR — AMBER === */
  --amber-600: #d97706;
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --amber-100: #fef3c7;
  --amber-50:  #fffbeb;
  --amber-dim: rgba(245, 158, 11, 0.10);

  /* === COLOR — RED === */
  --red-600:  #dc2626;
  --red-500:  #ef4444;
  --red-400:  #f87171;
  --red-100:  #fee2e2;
  --red-50:   #fff1f2;
  --red-dim:  rgba(239, 68, 68, 0.10);

  /* === COLOR — BLUE (accent) === */
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  /* === NEUTRALS === */
  --gray-950: #0a0a0a;
  --gray-900: #111111;
  --gray-800: #1a1a1a;
  --gray-700: #2d2d2d;
  --gray-600: #404040;
  --gray-500: #606060;
  --gray-400: #737373;
  --gray-300: #a3a3a3;
  --gray-200: #d4d4d4;
  --gray-150: #e5e5e5;
  --gray-100: #f0f0f0;
  --gray-50:  #f9f9f6;
  --white:    #ffffff;

  /* === SURFACES === */
  --bg:         #fafaf5;   /* Page background — warm off-white */
  --bg-alt:     #f5f5f0;   /* Alternate section bg */
  --surface:    #ffffff;   /* Cards, inputs, modals */
  --surface-raised: #ffffff; /* Elevated cards */
  --surface-overlay: rgba(255, 255, 255, 0.96); /* Sticky nav, modals */

  /* === TEXT === */
  --text:       #1a1a1a;   /* Primary body text */
  --text-mid:   #404040;   /* Secondary text */
  --text-dim:   #737373;   /* Muted / captions */
  --text-faint: #a3a3a3;   /* Placeholder / disabled */
  --text-invert:#ffffff;   /* On dark backgrounds */

  /* === BORDERS === */
  --border:       rgba(0, 0, 0, 0.07);
  --border-mid:   rgba(0, 0, 0, 0.12);
  --border-strong:rgba(0, 0, 0, 0.18);
  --border-brand: rgba(22, 163, 74, 0.30);

  /* === SHADOWS (layered, physical depth) === */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:  0 1px 4px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0,0,0,0.03);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 28px rgba(0, 0, 0, 0.09), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-2xl: 0 32px 80px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(0,0,0,0.07);
  --shadow-brand: 0 4px 16px rgba(22, 163, 74, 0.24), 0 1px 4px rgba(22,163,74,0.14);
  --shadow-brand-lg: 0 8px 32px rgba(22, 163, 74, 0.28), 0 2px 8px rgba(22,163,74,0.16);

  /* === RADIUS === */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* === SPACING (4px base grid) === */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* === TYPOGRAPHY === */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Menlo', monospace;

  /* Type scale */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   16px;
  --text-lg:   18px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;
  --text-5xl:  44px;
  --text-6xl:  56px;
  --text-7xl:  68px;

  /* Line heights */
  --leading-tight:   1.1;
  --leading-snug:    1.3;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  /* Letter spacing */
  --tracking-tight:  -0.04em;
  --tracking-snug:   -0.025em;
  --tracking-normal:  0;
  --tracking-wide:    0.02em;
  --tracking-wider:   0.06em;
  --tracking-widest:  0.12em;

  /* Font weights */
  --weight-normal:  400;
  --weight-medium:  500;
  --weight-semibold:600;
  --weight-bold:    700;
  --weight-extrabold:800;

  /* === MOTION (DJI/Oura-quality easing) === */
  --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);        /* Smooth decelerate */
  --ease-in:        cubic-bezier(0.4, 0, 1, 1);           /* Natural accelerate */
  --ease-in-out:    cubic-bezier(0.45, 0, 0.55, 1);       /* Smooth both */
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);    /* Overshoot (spring) */
  --ease-bounce:    cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Bounce */
  --ease-sharp:     cubic-bezier(0.4, 0, 0.6, 1);         /* Sharp material */

  --duration-instant: 80ms;
  --duration-fast:    150ms;
  --duration-normal:  250ms;
  --duration-slow:    350ms;
  --duration-slower:  500ms;
  --duration-crawl:   700ms;

  /* === Z-INDEX SCALE === */
  --z-base:    0;
  --z-raised:  10;
  --z-dropdown:200;
  --z-sticky:  300;
  --z-fixed:   400;
  --z-modal:   500;
  --z-toast:   600;
  --z-tooltip: 700;

  /* === LAYOUT === */
  --max-w-sm:   480px;
  --max-w-md:   640px;
  --max-w-lg:   800px;
  --max-w-xl:   1000px;
  --max-w-2xl:  1100px;
  --max-w-full: 1280px;
  --nav-height: 64px;
}

/* === DARK MODE SCAFFOLD (ready to activate) === */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"],
  :root[data-theme="dark"] {
    --bg:         #0f1010;
    --bg-alt:     #141515;
    --surface:    #1a1b1b;
    --surface-raised: #222323;
    --surface-overlay: rgba(18, 19, 19, 0.96);
    --text:       #f0f0f0;
    --text-mid:   #c4c4c4;
    --text-dim:   #888888;
    --text-faint: #555555;
    --border:       rgba(255, 255, 255, 0.07);
    --border-mid:   rgba(255, 255, 255, 0.12);
    --border-strong:rgba(255, 255, 255, 0.18);
  }
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
  color: var(--text);
}

p { line-height: var(--leading-normal); }

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

img, svg, video { display: block; max-width: 100%; }

/* ============================================================
   NAVIGATION
   ============================================================ */
.kleen-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  z-index: var(--z-fixed);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: rgba(250, 250, 245, 0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: background var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
  will-change: background, box-shadow;
}

.kleen-nav.scrolled {
  background: rgba(250, 250, 245, 0.96);
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.nav-logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.30);
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-out);
}

.nav-logo:hover .nav-logo-icon {
  transform: scale(1.06) rotate(-3deg);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.38);
}

.nav-logo-icon svg { width: 18px; height: 18px; }

.nav-logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
}

.nav-links {
  display: flex;
  gap: var(--space-1);
  list-style: none;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  padding: 7px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-mid);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 50%; transform: translateX(-50%) scaleX(0);
  width: calc(100% - 20px); height: 1.5px;
  background: var(--brand);
  border-radius: var(--radius-full);
  transition: transform var(--duration-normal) var(--ease-spring);
  transform-origin: center;
}

.nav-links a:hover {
  background: var(--brand-dim);
  color: var(--brand);
}

.nav-links a.active {
  color: var(--brand);
  background: var(--brand-dim);
}

.nav-links a.active::after { transform: translateX(-50%) scaleX(1); }

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   BUTTONS
   ============================================================ */

/* --- Base button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-spring);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ripple */
.btn::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.18);
  border-radius: inherit;
  transition: transform var(--duration-slow) var(--ease-out), opacity 0.4s var(--ease-out);
  opacity: 0;
}

.btn:active::before { transform: translate(-50%, -50%) scale(2.5); opacity: 1; }

/* Primary */
.btn-primary {
  background: var(--brand);
  color: var(--text-invert);
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  background: var(--green-700);
  box-shadow: var(--shadow-brand-lg);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border-mid);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid transparent;
}

.btn-ghost:hover {
  background: var(--brand-dim);
  color: var(--brand);
}

/* Scan / Icon accent */
.btn-scan {
  background: var(--amber-100);
  color: var(--amber-600);
  border: 1.5px solid transparent;
}

.btn-scan:hover {
  background: var(--amber-500);
  color: var(--white);
  transform: translateY(-1px);
}

/* Destructive */
.btn-danger {
  background: var(--red-100);
  color: var(--red-600);
}

.btn-danger:hover {
  background: var(--red-500);
  color: var(--white);
}

/* Sizes */
.btn-xs { padding: 5px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm { padding: 7px var(--space-3); font-size: var(--text-sm); }
.btn-lg { padding: 14px var(--space-8); font-size: var(--text-md); border-radius: var(--radius-lg); }
.btn-xl { padding: 18px 40px; font-size: var(--text-lg); border-radius: var(--radius-xl); }

/* Icon-only */
.btn-icon {
  padding: 9px;
  border-radius: var(--radius-md);
}

/* Full width */
.btn-full { width: 100%; }

/* Loading state */
.btn.loading { opacity: 0.75; pointer-events: none; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 4px;
}

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

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-mid);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.card-interactive:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: var(--space-6); }
.card-sm .card-body { padding: var(--space-4); }
.card-lg .card-body { padding: var(--space-8); }

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* Product card */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}

.product-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-5px) scale(1.01);
  border-color: var(--border-brand);
}

.product-card:active {
  transform: translateY(-2px) scale(1.005);
}

.product-card-image {
  aspect-ratio: 4/3;
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.product-card-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.product-card:hover .product-card-image img {
  transform: scale(1.05);
}

.product-card-body {
  padding: var(--space-4) var(--space-5);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.product-card-brand {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-dim);
}

.product-card-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
  line-height: var(--leading-snug);
  flex: 1;
}

/* ============================================================
   SCORE BADGES (Kleen A-F grades)
   ============================================================ */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-out);
}

.score-badge:hover { transform: scale(1.04); }

.score-badge .score-value { font-size: var(--text-4xl); }
.score-badge .score-label { font-size: var(--text-sm); }
.score-badge .score-letter { font-size: var(--text-5xl); }

/* Score tiers */
.score-excellent,
.score-a { background: var(--green-100); color: var(--green-700); box-shadow: 0 0 0 1px var(--green-200); }
.score-good,
.score-b { background: #d1fae5; color: #065f46; box-shadow: 0 0 0 1px #a7f3d0; }
.score-fair,
.score-c { background: var(--amber-100); color: var(--amber-600); box-shadow: 0 0 0 1px var(--amber-400); }
.score-poor,
.score-d { background: #fed7aa; color: #c2410c; box-shadow: 0 0 0 1px #fdba74; }
.score-avoid,
.score-f { background: var(--red-100); color: var(--red-600); box-shadow: 0 0 0 1px var(--red-400); }

/* Compact score dot */
.score-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-extrabold);
  color: white;
  flex-shrink: 0;
}

.score-dot-sm {
  width: 32px; height: 32px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.score-dot-lg {
  width: 64px; height: 64px;
  font-size: var(--text-3xl);
  border-radius: var(--radius-lg);
}

/* ============================================================
   INGREDIENT PILLS
   ============================================================ */
.pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-out);
}

.pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }

.pill-safe    { background: var(--green-100); color: var(--green-700); }
.pill-caution { background: var(--amber-100); color: var(--amber-600); }
.pill-avoid   { background: var(--red-100);   color: var(--red-600); }
.pill-info    { background: var(--blue-100);  color: var(--blue-600); }
.pill-neutral { background: var(--gray-100);  color: var(--gray-600); }

/* ============================================================
   INPUTS & FORMS
   ============================================================ */
.input {
  width: 100%;
  padding: 12px var(--space-4);
  background: var(--surface);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text);
  line-height: 1.5;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.input::placeholder { color: var(--text-faint); }

.input:hover { border-color: var(--border-strong); }

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14);
}

.input-sm { padding: 8px var(--space-3); font-size: var(--text-sm); }
.input-lg { padding: 14px var(--space-5); font-size: var(--text-md); }

/* Search input */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: var(--space-1);
  box-shadow: var(--shadow-lg);
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.search-bar:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.10), var(--shadow-xl);
}

.search-bar-icon {
  padding: 12px 8px 12px var(--space-4);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color var(--duration-fast) var(--ease-out);
}

.search-bar:focus-within .search-bar-icon { color: var(--brand); }

.search-bar-icon svg { width: 20px; height: 20px; }

.search-bar-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--text-md);
  font-family: var(--font-sans);
  padding: 13px var(--space-2);
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.search-bar-input::placeholder { color: var(--text-faint); }

/* ============================================================
   TAGS & BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.6;
  letter-spacing: var(--tracking-wide);
}

.badge-green   { background: var(--green-100); color: var(--green-700); }
.badge-amber   { background: var(--amber-100); color: var(--amber-600); }
.badge-red     { background: var(--red-100);   color: var(--red-600); }
.badge-blue    { background: var(--blue-100);  color: var(--blue-600); }
.badge-neutral { background: var(--gray-100);  color: var(--gray-600); }

/* Live badge with pulse */
.badge-live {
  background: var(--green-100);
  color: var(--green-700);
  padding-left: 6px;
}

.badge-live::before {
  content: '';
  width: 7px; height: 7px;
  background: var(--green-500);
  border-radius: 50%;
  animation: pulse-live 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-6);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.stat-number {
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: var(--weight-extrabold);
  color: var(--brand);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  margin-bottom: var(--space-2);
  display: block;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-dim);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

/* ============================================================
   SECTION LAYOUT
   ============================================================ */
.section {
  max-width: var(--max-w-2xl);
  margin: 0 auto;
  padding: var(--space-20) var(--space-6);
}

.section-sm { padding: var(--space-12) var(--space-6); }
.section-lg { padding: 100px var(--space-6); }

.section-header {
  text-align: center;
  margin-bottom: var(--space-16);
}

.section-label {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--brand);
  margin-bottom: var(--space-3);
}

.section-header h2 {
  font-size: clamp(var(--text-3xl), 4vw, var(--text-5xl));
  letter-spacing: var(--tracking-snug);
  margin-bottom: var(--space-4);
  line-height: var(--leading-tight);
}

.section-header p {
  font-size: var(--text-lg);
  color: var(--text-mid);
  max-width: 600px;
  margin: 0 auto;
  line-height: var(--leading-relaxed);
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--gray-100) 25%,
    var(--gray-50) 50%,
    var(--gray-100) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 16px;
  border-radius: var(--radius-xs);
}

.skeleton-title {
  height: 28px;
  border-radius: var(--radius-sm);
}

.skeleton-avatar {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-xl);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--text);
  color: var(--text-invert);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toast-in var(--duration-slow) var(--ease-spring);
}

.toast.toast-exit {
  animation: toast-out var(--duration-normal) var(--ease-in) forwards;
}

.toast-success { background: var(--green-700); }
.toast-error   { background: var(--red-600); }
.toast-warning { background: var(--amber-600); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(100%) scale(0.9); }
}

/* ============================================================
   MODAL / SHEET
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  animation: overlay-in var(--duration-normal) var(--ease-out);
}

.modal-overlay.closing {
  animation: overlay-out var(--duration-fast) var(--ease-in) forwards;
}

@keyframes overlay-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlay-out { from { opacity: 1; } to { opacity: 0; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in var(--duration-slow) var(--ease-spring);
  overscroll-behavior: contain;
}

.modal-overlay.closing .modal {
  animation: modal-out var(--duration-fast) var(--ease-in) forwards;
}

@keyframes modal-in  { from { opacity: 0; transform: scale(0.94) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes modal-out { from { opacity: 1; transform: scale(1) translateY(0); } to { opacity: 0; transform: scale(0.96) translateY(8px); } }

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ============================================================
   SCROLL-TRIGGERED ANIMATIONS
   ============================================================ */

/* Fade up (applied by JS IntersectionObserver) */
.fade-up {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration-slower) var(--ease-out),
              transform var(--duration-slower) var(--ease-out);
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Fade in */
.fade-in {
  opacity: 0;
  transition: opacity var(--duration-slower) var(--ease-out);
}

.fade-in.visible { opacity: 1; }

/* Stagger children */
.stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--duration-slower) var(--ease-out),
              transform var(--duration-slower) var(--ease-out);
}

.stagger.visible > *:nth-child(1)  { opacity: 1; transform: none; transition-delay: 0ms; }
.stagger.visible > *:nth-child(2)  { opacity: 1; transform: none; transition-delay: 80ms; }
.stagger.visible > *:nth-child(3)  { opacity: 1; transform: none; transition-delay: 160ms; }
.stagger.visible > *:nth-child(4)  { opacity: 1; transform: none; transition-delay: 240ms; }
.stagger.visible > *:nth-child(5)  { opacity: 1; transform: none; transition-delay: 320ms; }
.stagger.visible > *:nth-child(6)  { opacity: 1; transform: none; transition-delay: 400ms; }
.stagger.visible > *:nth-child(n+7){ opacity: 1; transform: none; transition-delay: 480ms; }

/* Scale in */
.scale-in {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slower) var(--ease-out),
              transform var(--duration-slower) var(--ease-spring);
}

.scale-in.visible { opacity: 1; transform: scale(1); }

/* ============================================================
   DIVIDERS
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

.divider-heavy { background: var(--border-mid); }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--brand-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--brand);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm  { width: 28px; height: 28px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.avatar-lg  { width: 56px; height: 56px; font-size: var(--text-xl); border-radius: var(--radius-lg); }
.avatar-circle { border-radius: var(--radius-full); }

/* ============================================================
   LISTS (scorecard ingredients, etc.)
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  position: relative;
}

.list-item::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  background: var(--brand);
  transform: scaleY(0);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.list-item:hover {
  background: var(--gray-50);
  transform: translateX(4px);
}

.list-item:hover::after { transform: scaleY(1); }

/* ============================================================
   FOOTER
   ============================================================ */
.kleen-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-10) var(--space-6);
}

.kleen-footer-inner {
  max-width: var(--max-w-2xl);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-links {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--text-dim);
  transition: color var(--duration-fast) var(--ease-out);
}

.footer-links a:hover { color: var(--brand); }

.footer-copy {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

/* ============================================================
   PROGRESS BAR (for scores)
   ============================================================ */
.progress {
  width: 100%;
  height: 6px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--brand);
  transform-origin: left;
  transition: width 0.8s var(--ease-out);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-brand   { color: var(--brand); }
.text-dim     { color: var(--text-dim); }
.text-mid     { color: var(--text-mid); }
.text-faint   { color: var(--text-faint); }
.text-invert  { color: var(--text-invert); }
.text-success { color: var(--green-600); }
.text-warning { color: var(--amber-600); }
.text-danger  { color: var(--red-600); }

.font-display { font-family: var(--font-display); }
.font-bold    { font-weight: var(--weight-bold); }
.font-semibold{ font-weight: var(--weight-semibold); }
.font-medium  { font-weight: var(--weight-medium); }

.rounded      { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.surface      { background: var(--surface); }
.border-card  { border: 1px solid var(--border); }

.shadow-sm    { box-shadow: var(--shadow-sm); }
.shadow-md    { box-shadow: var(--shadow-md); }
.shadow-lg    { box-shadow: var(--shadow-lg); }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   RESPONSIVE UTILITIES
   ============================================================ */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hide-mobile { display: none !important; }

  .section {
    padding: var(--space-12) var(--space-4);
  }

  .section-header {
    margin-bottom: var(--space-8);
  }

  .kleen-footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links { justify-content: center; }
  .toast-container { right: var(--space-3); left: var(--space-3); bottom: var(--space-4); }
  .toast { min-width: unset; max-width: unset; }
}

@media (max-width: 480px) {
  .hide-xs { display: none !important; }
  .btn-xl  { padding: 15px var(--space-8); font-size: var(--text-base); }
}
