/* ============================================================
   Self-hosted fonts
   ============================================================ */

/* Inter — Latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/Inter.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Noto Sans Georgian — Georgian script */
@font-face {
  font-family: 'Noto Sans Georgian';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/NotoSansGeorgian.woff2') format('woff2');
  unicode-range: U+0589, U+10A0-10FF, U+1C90-1CBA, U+1CBD-1CBF, U+205A,
                 U+2D00-2D2F, U+2E31;
}

/* Noto Sans Georgian — Latin fallback */
@font-face {
  font-family: 'Noto Sans Georgian';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/NotoSansGeorgian-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================
   CaloriQ — Design System & Stylesheet
   Project: CcalCulator
   Version: 1.0
   Author: CcalCulator Team
   ============================================================
   TABLE OF CONTENTS
   1.  Design Tokens (CSS Custom Properties)
   2.  Reset & Base
   3.  Typography
   4.  Layout Utilities
   5.  Components — Buttons
   6.  Components — Forms & Inputs
   7.  Components — Cards
   8.  Components — Badges & Pills
   9.  Components — Navigation
   10. Components — Modal
   11. Components — Progress Indicators
   12. Components — Toast / Alerts
   13. Components — Loader
   14. Page — Auth (Login / Register)
   15. Page — Onboarding
   16. Page — Dashboard
   17. Page — Add Food
   18. Page — My Foods
   19. Page — Progress
   20. Page — Settings
   21. Animations & Transitions
   22. Responsive — Tablet (≥768px)
   23. Responsive — Desktop (≥1024px)
   24. Accessibility & Focus
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
  /* --- Brand Colors --- */
  --c-primary:        #0D9488;   /* Teal 600  — main accent */
  --c-primary-dark:   #0F766E;   /* Teal 700  — hover / active */
  --c-primary-darker: #134E4A;   /* Teal 900  — text on light */
  --c-primary-light:  #CCFBF1;   /* Teal 100  — subtle fill */
  --c-primary-mid:    #5EEAD4;   /* Teal 300  — ring track */

  /* --- Neutrals --- */
  --c-bg:        #F8FAFC;   /* Slate 50  — page background */
  --c-surface:   #FFFFFF;   /* White     — card / panel */
  --c-surface-2: #F1F5F9;   /* Slate 100 — secondary surface */
  --c-surface-3: #E2E8F0;   /* Slate 200 — tertiary / input bg */
  --c-border:    #E2E8F0;   /* Slate 200 */
  --c-border-2:  #CBD5E1;   /* Slate 300 */

  /* --- Text --- */
  --c-text:   #0F172A;   /* Slate 900 — primary */
  --c-text-2: #475569;   /* Slate 600 — secondary */
  --c-text-3: #94A3B8;   /* Slate 400 — placeholder / muted */

  /* --- Semantic --- */
  --c-success:       #22C55E;
  --c-success-light: #DCFCE7;
  --c-warning:       #F59E0B;
  --c-warning-light: #FEF3C7;
  --c-error:         #EF4444;
  --c-error-light:   #FEE2E2;
  --c-info:          #3B82F6;
  --c-info-light:    #DBEAFE;

  /* --- Macro Colors --- */
  --c-protein: #3B82F6;   /* Blue  */
  --c-carbs:   #A855F7;   /* Purple */
  --c-fat:     #F97316;   /* Orange */

  /* --- Goal Colors --- */
  --c-goal-over:   #EF4444;   /* > 110% */
  --c-goal-good:   #22C55E;   /* 90–110% */
  --c-goal-under:  #F59E0B;   /* < 90% */
  --c-goal-empty:  #94A3B8;   /* 0% */

  /* --- Typography --- */
  --font: 'Noto Sans Georgian', 'Inter', system-ui, -apple-system,
          BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-xs:   0.6875rem;  /* 11px */
  --text-sm:   0.8125rem;  /* 13px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */
  --text-4xl:  2.25rem;    /* 36px */
  --text-5xl:  3rem;       /* 48px */

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  --lh-tight:  1.25;
  --lh-snug:   1.375;
  --lh-normal: 1.5;
  --lh-relaxed:1.625;

  /* --- Spacing (4px base) --- */
  --sp-1:  0.25rem;   /*  4px */
  --sp-2:  0.5rem;    /*  8px */
  --sp-3:  0.75rem;   /* 12px */
  --sp-4:  1rem;      /* 16px */
  --sp-5:  1.25rem;   /* 20px */
  --sp-6:  1.5rem;    /* 24px */
  --sp-8:  2rem;      /* 32px */
  --sp-10: 2.5rem;    /* 40px */
  --sp-12: 3rem;      /* 48px */
  --sp-16: 4rem;      /* 64px */
  --sp-20: 5rem;      /* 80px */
  --sp-24: 6rem;      /* 96px */

  /* --- Borders & Radii --- */
  --radius-sm:   0.375rem;  /*  6px */
  --radius:      0.625rem;  /* 10px */
  --radius-md:   0.875rem;  /* 14px */
  --radius-lg:   1.25rem;   /* 20px */
  --radius-xl:   1.75rem;   /* 28px */
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .04);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .06);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / .07), 0 2px 4px -2px rgb(0 0 0 / .05);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / .08), 0 4px 6px -4px rgb(0 0 0 / .05);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / .08), 0 8px 10px -6px rgb(0 0 0 / .04);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / .12);

  /* --- Motion --- */
  --ease-out:    cubic-bezier(0.0, 0.0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   120ms;
  --dur-base:   200ms;
  --dur-slow:   350ms;
  --dur-slower: 500ms;

  /* --- Layout --- */
  --nav-height:    3.75rem;  /* 60px  — mobile bottom nav */
  --sidebar-width: 16rem;    /* 256px — desktop sidebar */
  --content-max:   48rem;    /* 768px — content max-width */
  --page-pad:      var(--sp-4);
}

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

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

body {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background-color: var(--c-bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--c-primary);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out);
}
a:hover { color: var(--c-primary-dark); }

ul, ol { list-style: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

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

/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */
.t-xs    { font-size: var(--text-xs);   line-height: var(--lh-normal); }
.t-sm    { font-size: var(--text-sm);   line-height: var(--lh-normal); }
.t-base  { font-size: var(--text-base); line-height: var(--lh-normal); }
.t-lg    { font-size: var(--text-lg);   line-height: var(--lh-snug);   }
.t-xl    { font-size: var(--text-xl);   line-height: var(--lh-snug);   }
.t-2xl   { font-size: var(--text-2xl);  line-height: var(--lh-tight);  }
.t-3xl   { font-size: var(--text-3xl);  line-height: var(--lh-tight);  }
.t-4xl   { font-size: var(--text-4xl);  line-height: var(--lh-tight);  }

.fw-regular { font-weight: var(--fw-regular); }
.fw-medium  { font-weight: var(--fw-medium);  }
.fw-semi    { font-weight: var(--fw-semi);    }
.fw-bold    { font-weight: var(--fw-bold);    }

.c-muted    { color: var(--c-text-2); }
.c-placeholder { color: var(--c-text-3); }
.c-primary  { color: var(--c-primary); }
.c-error    { color: var(--c-error); }
.c-success  { color: var(--c-success); }

.text-center  { text-align: center; }
.text-left    { text-align: left;   }
.text-right   { text-align: right;  }

/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

.container--wide  { max-width: 72rem; }
.container--narrow { max-width: 28rem; }

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-end  { justify-content: flex-end; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }
.gap-8  { gap: var(--sp-8); }
.grow   { flex-grow: 1; }

.grid      { display: grid; }
.grid-2    { grid-template-columns: repeat(2, 1fr); }
.grid-3    { grid-template-columns: repeat(3, 1fr); }

.mt-auto   { margin-top: auto; }
.mb-auto   { margin-bottom: auto; }
.ml-auto   { margin-left: auto; }
.mr-auto   { margin-right: auto; }

.mt-2  { margin-top: var(--sp-2); }
.mt-4  { margin-top: var(--sp-4); }
.mt-6  { margin-top: var(--sp-6); }
.mt-8  { margin-top: var(--sp-8); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-6  { margin-bottom: var(--sp-6); }
.mb-8  { margin-bottom: var(--sp-8); }

.p-4   { padding: var(--sp-4); }
.p-6   { padding: var(--sp-6); }
.px-4  { padding-inline: var(--sp-4); }
.py-2  { padding-block: var(--sp-2); }
.py-4  { padding-block: var(--sp-4); }

.hidden       { display: none !important; }
.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;
}

.divider {
  height: 1px;
  background: var(--c-border);
  border: none;
  margin-block: var(--sp-6);
}

/* ============================================================
   5. COMPONENTS — BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.6875rem var(--sp-6);
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  line-height: 1;
  border-radius: var(--radius-full);
  border: 1.5px solid transparent;
  transition:
    background-color var(--dur-base) var(--ease-out),
    color            var(--dur-base) var(--ease-out),
    border-color     var(--dur-base) var(--ease-out),
    box-shadow       var(--dur-base) var(--ease-out),
    transform        var(--dur-fast) var(--ease-spring);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }

/* Primary */
.btn-primary {
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgb(13 148 136 / .3);
}
.btn-primary:hover {
  background: var(--c-primary-dark);
  box-shadow: 0 4px 12px rgb(13 148 136 / .35);
  color: #fff;
}

/* Secondary */
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border-2);
  color: var(--c-text);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--c-text-2);
}
.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

/* Danger */
.btn-danger {
  background: var(--c-error-light);
  color: var(--c-error);
  border-color: transparent;
}
.btn-danger:hover {
  background: var(--c-error);
  color: #fff;
}

/* Google OAuth */
.btn-google {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-2);
  box-shadow: var(--shadow-sm);
  width: 100%;
}
.btn-google:hover {
  background: var(--c-surface-2);
  box-shadow: var(--shadow);
  color: var(--c-text);
}
.btn-google .google-icon {
  width: 1.125rem;
  height: 1.125rem;
}

/* Sizes */
.btn-sm {
  padding: 0.4375rem var(--sp-4);
  font-size: var(--text-sm);
}
.btn-lg {
  padding: 0.875rem var(--sp-8);
  font-size: var(--text-lg);
}
.btn-icon {
  padding: var(--sp-2);
  border-radius: var(--radius-full);
  width: 2.25rem;
  height: 2.25rem;
}
.btn-icon svg { width: 1.125rem; height: 1.125rem; }

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

/* FAB — floating action button */
.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--sp-5));
  right: var(--sp-5);
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 4px 16px rgb(13 148 136 / .4);
  z-index: 50;
  transition:
    transform  var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-base) var(--ease-out);
}
.btn-fab svg { width: 1.5rem; height: 1.5rem; }
.btn-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgb(13 148 136 / .5);
}
.btn-fab:active { transform: scale(0.95); }

/* ============================================================
   6. COMPONENTS — FORMS & INPUTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text);
}
.form-label .required {
  color: var(--c-error);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 0.6875rem var(--sp-4);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border-2);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--c-text);
  outline: none;
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow   var(--dur-base) var(--ease-out),
    background   var(--dur-base) var(--ease-out);
  -webkit-appearance: none;
}
.form-control::placeholder { color: var(--c-text-3); }
.form-control:hover:not(:focus) { border-color: var(--c-border-2); }
.form-control:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgb(13 148 136 / .15);
}

/* States */
.form-control.is-error {
  border-color: var(--c-error);
  background: var(--c-error-light);
}
.form-control.is-error:focus {
  box-shadow: 0 0 0 3px rgb(239 68 68 / .15);
}
.form-control.is-success {
  border-color: var(--c-success);
}
.form-control.is-success:focus {
  box-shadow: 0 0 0 3px rgb(34 197 94 / .15);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.form-error-msg {
  font-size: var(--text-xs);
  color: var(--c-error);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1rem;
}
.form-error-msg:empty { display: none; }

/* Input with icon */
.input-wrapper {
  position: relative;
}
.input-wrapper .input-icon {
  position: absolute;
  top: 50%; left: var(--sp-4);
  transform: translateY(-50%);
  color: var(--c-text-3);
  pointer-events: none;
  width: 1.125rem; height: 1.125rem;
  transition: color var(--dur-base) var(--ease-out);
}
.input-wrapper .form-control { padding-left: 2.75rem; }
.input-wrapper:focus-within .input-icon { color: var(--c-primary); }

.input-wrapper .input-action {
  position: absolute;
  top: 50%; right: var(--sp-3);
  transform: translateY(-50%);
  color: var(--c-text-3);
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  display: flex;
  cursor: pointer;
}
.input-wrapper .input-action:hover { color: var(--c-text); }

/* Select */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* Radio cards (for onboarding) */
.radio-card-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: var(--sp-3);
}
.radio-card input[type="radio"] { display: none; }
.radio-card label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
  background: var(--c-surface);
  transition:
    border-color var(--dur-base) var(--ease-out),
    background   var(--dur-base) var(--ease-out),
    color        var(--dur-base) var(--ease-out),
    box-shadow   var(--dur-base) var(--ease-out);
}
.radio-card label .icon {
  font-size: 1.75rem;
  line-height: 1;
}
.radio-card input:checked + label {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
  color: var(--c-primary-darker);
  box-shadow: 0 0 0 3px rgb(13 148 136 / .12);
}
.radio-card label:hover {
  border-color: var(--c-primary);
  color: var(--c-text);
}

/* Checkbox */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}
.form-checkbox input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--c-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  background: var(--c-surface-3);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.lang-toggle button {
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  color: var(--c-text-3);
  transition:
    background var(--dur-base) var(--ease-out),
    color      var(--dur-base) var(--ease-out);
}
.lang-toggle button.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-xs);
}

/* ============================================================
   7. COMPONENTS — CARDS
   ============================================================ */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: var(--sp-6); }
.card-header {
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semi);
  color: var(--c-text);
}

/* Interactive card */
.card-interactive {
  cursor: pointer;
  transition:
    box-shadow  var(--dur-base) var(--ease-out),
    transform   var(--dur-fast) var(--ease-spring),
    border-color var(--dur-base) var(--ease-out);
}
.card-interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-primary-mid);
  transform: translateY(-1px);
}
.card-interactive:active { transform: translateY(0); }

/* ============================================================
   8. COMPONENTS — BADGES & PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  line-height: 1.5;
  white-space: nowrap;
}
.badge-primary { background: var(--c-primary-light); color: var(--c-primary-darker); }
.badge-success { background: var(--c-success-light); color: #166534; }
.badge-warning { background: var(--c-warning-light); color: #92400E; }
.badge-error   { background: var(--c-error-light);   color: #991B1B; }
.badge-neutral { background: var(--c-surface-3);     color: var(--c-text-2); }

/* Macro color dots */
.macro-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.macro-dot.protein { background: var(--c-protein); }
.macro-dot.carbs   { background: var(--c-carbs);   }
.macro-dot.fat     { background: var(--c-fat);      }

/* Macro mini rings */
.macro-ring {
  flex-shrink: 0;
  display: block;
}
.macro-ring-track { opacity: .15; }
.macro-ring-track.protein,
.macro-ring-fill.protein  { color: var(--c-protein); }
.macro-ring-track.carbs,
.macro-ring-fill.carbs    { color: var(--c-carbs); }
.macro-ring-track.fat,
.macro-ring-fill.fat      { color: var(--c-fat); }
.macro-ring-track.over,
.macro-ring-fill.over     { color: var(--c-error); }

/* ============================================================
   9. COMPONENTS — NAVIGATION
   ============================================================ */

/* -- Top bar (mobile) -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  height: 3.5rem;
  display: flex;
  align-items: center;
  padding-inline: var(--sp-4);
  gap: var(--sp-3);
  box-shadow: 0 1px 0 var(--c-border);
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
}
.topbar-logo .logo-mark {
  width: 2rem; height: 2rem;
  background: var(--c-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
}
.topbar-logo .logo-name {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  letter-spacing: -0.02em;
}
.topbar-logo .logo-name span { color: var(--c-primary); }

/* -- Bottom navigation (mobile) -- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 40;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  height: var(--nav-height);
  display: flex;
  align-items: stretch;
  box-shadow: 0 -4px 16px rgb(0 0 0 / .05);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--c-text-3);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
  padding-block: var(--sp-2);
  position: relative;
  transition: color var(--dur-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a svg { width: 1.375rem; height: 1.375rem; }
.bottom-nav a span { line-height: 1; }
.bottom-nav a.active { color: var(--c-primary); }
.bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2rem;
  height: 2px;
  background: var(--c-primary);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* -- Sidebar (desktop) -- */
.sidebar {
  display: none;
}

/* -- App layout wrapper -- */
.app-layout {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + var(--sp-4));
}
.page-content {
  padding: var(--sp-4) var(--sp-4) var(--sp-8);
}

/* ============================================================
   10. COMPONENTS — MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / .5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 32rem;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  box-shadow: var(--shadow-xl);
}
.modal-overlay.is-open .modal {
  transform: translateY(0);
}

/* Drag handle */
.modal-handle {
  width: 2.5rem;
  height: 4px;
  background: var(--c-border-2);
  border-radius: var(--radius-full);
  margin: var(--sp-3) auto var(--sp-2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-6) var(--sp-4);
}
.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--fw-semi);
}
.modal-body { padding: 0 var(--sp-6) var(--sp-8); }

/* ============================================================
   11. COMPONENTS — PROGRESS INDICATORS
   ============================================================ */

/* -- Circular Ring -- */
.ring-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ring-svg {
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--c-surface-3);
}
.ring-fill {
  fill: none;
  stroke: var(--c-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-slower) var(--ease-out);
}
.ring-fill.over-goal  { stroke: var(--c-goal-over); }
.ring-fill.near-goal  { stroke: var(--c-goal-good); }
.ring-fill.under-goal { stroke: var(--c-warning); }

.ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.ring-percent {
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  line-height: 1;
  letter-spacing: -0.03em;
}
.ring-sub {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  font-weight: var(--fw-medium);
}

/* -- Macro Progress Bars -- */
.macro-bars { display: flex; flex-direction: column; }
.macro-bars .macro-bar-item + .macro-bar-item {
  border-top: 1px solid var(--c-border);
}
.macro-bar-item {
  display: flex;
  flex-direction: column;
  padding: var(--sp-3) 0;
}
.macro-bar-item:first-child { padding-top: 0; }
.macro-bar-item:last-child  { padding-bottom: 0; }
.macro-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}
.macro-bar-label { 
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-base);
 }
.macro-bar-track {
  height: 6px;
  background: var(--c-surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.macro-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--dur-slower) var(--ease-out);
  max-width: 100%;
}
.macro-bar-fill.protein { background: var(--c-protein); }
.macro-bar-fill.carbs   { background: var(--c-carbs);   }
.macro-bar-fill.fat     { background: var(--c-fat);      }

/* -- Step / Onboarding progress -- */
.step-progress {
  display: flex;
  align-items: center;
  gap: 0;
}
.step-progress-track {
  height: 4px;
  background: var(--c-surface-3);
  border-radius: var(--radius-full);
  position: relative;
  flex: 1;
  overflow: hidden;
}
.step-progress-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: var(--radius-full);
  transition: width var(--dur-slow) var(--ease-out);
}

/* Step dots */
.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-border-2);
  transition:
    background var(--dur-base) var(--ease-out),
    transform  var(--dur-base) var(--ease-spring),
    width      var(--dur-base) var(--ease-out);
}
.step-dot.active {
  background: var(--c-primary);
  width: 20px;
  border-radius: var(--radius-full);
}
.step-dot.done { background: var(--c-primary-mid); }

/* ============================================================
   12. COMPONENTS — TOAST / ALERTS
   ============================================================ */
.toast-container {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  left: var(--sp-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border);
  pointer-events: all;
  animation: toastIn var(--dur-slow) var(--ease-spring);
  max-width: 28rem;
  margin-left: auto;
}
.toast.toast-success { border-left: 3px solid var(--c-success); }
.toast.toast-error   { border-left: 3px solid var(--c-error);   }
.toast.toast-warning { border-left: 3px solid var(--c-warning); }
.toast.toast-info    { border-left: 3px solid var(--c-info);    }

.toast-icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--c-text);
}
.toast-msg {
  font-size: var(--text-xs);
  color: var(--c-text-2);
  margin-top: 2px;
}

/* Alert (inline) */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.alert-error   { background: var(--c-error-light);   color: #991B1B; }
.alert-success { background: var(--c-success-light); color: #166534; }
.alert-warning { background: var(--c-warning-light); color: #92400E; }
.alert-info    { background: var(--c-info-light);    color: #1E40AF; }

/* ============================================================
   13. COMPONENTS — LOADER
   ============================================================ */
.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--c-border-2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 1rem; height: 1rem; }
.spinner-lg { width: 2rem; height: 2rem; border-width: 3px; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-surface-3) 25%,
    var(--c-border)    50%,
    var(--c-surface-3) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   14. PAGE — AUTH (LOGIN / REGISTER)
   Split-screen layout: teal hero left, white form right.
   Mobile: stacked (hero top, form bottom).
   ============================================================ */

/* ── Outer wrapper ── */
.auth-split {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
}

/* ── Hero panel (teal) ── */
.auth-split-hero {
  background: linear-gradient(
    150deg,
    var(--c-primary-darker) 0%,
    var(--c-primary)        55%,
    #14B8A6                 100%
  );
  padding: var(--sp-12) var(--sp-6) var(--sp-10);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Decorative blobs */
.auth-split-hero::before {
  content: '';
  position: absolute;
  width: 22rem; height: 22rem;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  top: -7rem; right: -6rem;
  pointer-events: none;
}
.auth-split-hero::after {
  content: '';
  position: absolute;
  width: 14rem; height: 14rem;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -4rem; left: -4rem;
  pointer-events: none;
}

.auth-split-hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
}

/* Brand mark */
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.auth-brand-icon {
  width: 3rem; height: 3rem;
  background: rgba(255,255,255,.18);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  backdrop-filter: blur(8px);
}
.auth-brand-name {
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: #fff;
  letter-spacing: -0.03em;
}
.auth-brand-name span { color: rgba(255,255,255,.65); }

/* Hero headline */
.auth-headline {
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: #fff;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-4);
}
.auth-subline {
  font-size: var(--text-base);
  color: rgba(255,255,255,.75);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-6);
}

/* Feature chips */
.auth-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: #fff;
  backdrop-filter: blur(4px);
}

/* ── Form panel (white) ── */
.auth-split-form {
  background: var(--c-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
  flex: 1;
}
.auth-split-form-inner {
  width: 100%;
  max-width: 24rem;
}

.auth-form-title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-1);
}
.auth-form-sub {
  font-size: var(--text-sm);
  color: var(--c-text-3);
  margin-bottom: var(--sp-6);
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--c-text-3);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── Desktop: side by side ── */
@media (min-width: 768px) {
  .auth-split {
    flex-direction: row;
  }
  .auth-split-hero {
    flex: 1;
    padding: var(--sp-16);
    min-height: 100dvh;
  }
  .auth-split-form {
    width: 26rem;
    flex-shrink: 0;
    min-height: 100dvh;
    overflow-y: auto;
    border-left: 1px solid var(--c-border);
    padding: var(--sp-12) var(--sp-8);
  }
}

/* ============================================================
   15. PAGE — ONBOARDING
   ============================================================ */
.onboarding-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
}
.onboarding-header {
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.onboarding-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.onboarding-step-label {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.onboarding-body {
  flex: 1;
  padding: var(--sp-8) var(--sp-6);
  display: flex;
  flex-direction: column;
}

.step-header {
  margin-bottom: var(--sp-8);
}
.step-emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: var(--sp-4);
  display: block;
}
.step-title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin-bottom: var(--sp-2);
  line-height: var(--lh-tight);
}
.step-subtitle {
  font-size: var(--text-base);
  color: var(--c-text-2);
}

.onboarding-fields { display: flex; flex-direction: column; gap: var(--sp-5); }

.onboarding-footer {
  padding: var(--sp-4) var(--sp-6) calc(var(--sp-6) + env(safe-area-inset-bottom, 0));
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: var(--sp-3);
}

/* BMI / calculated result chip */
.calc-result {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--c-primary-light);
  border-radius: var(--radius-md);
  border: 1px solid rgb(13 148 136 / .2);
  margin-top: var(--sp-4);
}
.calc-result .result-icon {
  width: 2.5rem; height: 2.5rem;
  background: var(--c-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.calc-result .result-value {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-primary-darker);
}
.calc-result .result-label {
  font-size: var(--text-xs);
  color: var(--c-primary);
  font-weight: var(--fw-medium);
}

/* ============================================================
   16. PAGE — DASHBOARD
   ============================================================ */
.dashboard-summary {
  background: linear-gradient(
    145deg,
    var(--c-primary-darker),
    var(--c-primary)
  );
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  padding: var(--sp-6) var(--sp-6) var(--sp-8);
  margin-bottom: calc(-1 * var(--sp-6));
  position: relative;
  overflow: hidden;
}
.dashboard-summary::before {
  content: '';
  position: absolute;
  width: 14rem; height: 14rem;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -5rem; right: -4rem;
}
.dashboard-summary.is-over {
  background: linear-gradient(145deg, #7f1d1d, #b91c1c);
}
.dashboard-summary.is-over .ring-fill.over-goal {
  stroke: #fca5a5;
}
.dashboard-summary.is-over .ring-track {
  stroke: rgba(255,255,255,.2);
}
.dashboard-summary.is-over .ring-percent {
  color: #fca5a5;
}

.summary-date {
  font-size: var(--text-sm);
  color: rgba(255,255,255,.7);
  margin-bottom: var(--sp-4);
  font-weight: var(--fw-medium);
}
.summary-ring-row {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}
.summary-ring-row .ring-percent { color: #fff; }
.summary-ring-row .ring-sub { color: rgba(255,255,255,.6); }
.summary-ring-row .ring-track { stroke: rgba(255,255,255,.15); }
.summary-ring-row .ring-fill  { stroke: rgba(255,255,255,.9); }

.summary-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-stat-val {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: #fff;
  line-height: 1;
}
.summary-stat-label {
  font-size: var(--text-xs);
  color: rgba(255,255,255,.6);
  font-weight: var(--fw-medium);
}

/* Date navigation bar */
.dash-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.dash-day-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
  z-index: 1;
}
.dash-day-link:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.dash-date-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  color: #fff;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
  z-index: 1;
}
.dash-date-btn:hover {
  background: rgba(255,255,255,.15);
}
.dash-day-spacer {
  width: 60px;
}
.date-picker-hidden {
  position: fixed;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* Dashboard content sections */
.dash-section {
  margin-top: var(--sp-8);
}

/* Macro amount label */
.macro-amount {
  color: var(--c-text-2);
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.macro-amount strong {
  color: var(--c-text);
}
.macro-amount--over strong {
  color: var(--c-error);
}
.macro-over-badge {
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  color: var(--c-error);
  background: color-mix(in srgb, var(--c-error) 10%, transparent);
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

/* Meal group */
.meal-group {
  margin-bottom: var(--sp-4);
}

/* Food log icon image */
.food-log-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Delete log entry button */
.btn-log-delete {
  color: var(--c-text-3);
}

/* Macro card */
.macro-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  position: relative;
  z-index: 1;
}

/* Food log */
.food-log { display: flex; flex-direction: column; gap: var(--sp-1); }

.food-log-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  transition:
    background  var(--dur-fast) var(--ease-out),
    box-shadow  var(--dur-fast) var(--ease-out);
}
.food-log-item:hover {
  background: var(--c-surface-2);
  box-shadow: var(--shadow-xs);
}
.food-log-icon {
  width: 2.25rem; height: 2.25rem;
  background: var(--c-primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}
.food-log-info { flex: 1; min-width: 0; }
.food-log-name {
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.food-log-meta {
  font-size: var(--text-sm);
  color: var(--c-text-3);
  display: flex;
  align-items: center;
}
.food-log-meta .sep { opacity: .5; }
.food-log-cal {
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  color: var(--c-text);
  flex-shrink: 0;
}
.food-log-time {
  font-size: var(--text-sm);
  color: var(--c-text-3);
  flex-shrink: 0;
  min-width: 2.5rem;
  text-align: right;
}

/* Section heading */
.section-title {
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  color: var(--c-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title a {
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
}

/* Meal group */
.meal-group-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
}

/* ============================================================
   17. PAGE — ADD FOOD
   ============================================================ */
.food-search-bar {
  position: sticky;
  top: 0;
  background: var(--c-surface);
  padding-bottom: var(--sp-4);
  z-index: 10;
}

.food-results { display: flex; flex-direction: column; gap: var(--sp-1); }

.food-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  transition:
    background   var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.food-result-item:hover {
  background: var(--c-surface-2);
  border-color: var(--c-primary-mid);
}
.food-result-info { flex: 1; min-width: 0; }
.food-result-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text);
}
.food-result-meta {
  font-size: var(--text-xs);
  color: var(--c-text-3);
}
.food-result-cal {
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--c-primary);
  white-space: nowrap;
}

/* Quick-add chip */
.quick-add-btn {
  width: 2rem; height: 2rem;
  border-radius: var(--radius-full);
  background: var(--c-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background var(--dur-fast) var(--ease-out),
    transform  var(--dur-fast) var(--ease-spring);
}
.quick-add-btn:hover  { background: var(--c-primary-dark); }
.quick-add-btn:active { transform: scale(0.9); }
.quick-add-btn svg    { width: 1rem; height: 1rem; }

/* Portion selector */
.portion-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.portion-stepper {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-surface-2);
  border-radius: var(--radius-full);
  padding: var(--sp-1);
}
.portion-stepper button {
  width: 1.75rem; height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--c-surface);
  color: var(--c-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  transition:
    background var(--dur-fast) var(--ease-out),
    transform  var(--dur-fast) var(--ease-spring);
}
.portion-stepper button:hover    { background: var(--c-border); }
.portion-stepper button:active   { transform: scale(0.92); }
.portion-stepper span {
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  min-width: 2.5rem;
  text-align: center;
}

/* Tabs (Recent / Favorites) */
.food-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1.5px solid var(--c-border);
  margin-bottom: var(--sp-4);
}
.food-tab {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-3);
  text-align: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition:
    color        var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}
.food-tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* ============================================================
   18. PAGE — MY FOODS
   ============================================================ */
.my-foods-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top:0.7rem;
}
.food-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  transition:
    box-shadow   var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}
.food-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--c-border-2);
}
.food-card-icon {
  width: 2.5rem; height: 2.5rem;
  background: var(--c-primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  overflow: hidden;
}
.food-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.food-card-info { flex: 1; min-width: 0; }
.food-card-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.food-card-macros {
  display: flex;
  gap: var(--sp-2);
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--c-text-3);
  font-weight: var(--fw-medium);
}
.food-card-cal {
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  flex-shrink: 0;
  line-height: 1;
  text-align: right;
}
.food-card-cal-unit {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  font-weight: var(--fw-regular);
}
.food-card-actions {
  flex-shrink: 0;
  position: static;
}
.food-card-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-3);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.food-card-menu-btn:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}
.food-card-dropdown {
  position: fixed;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 200;
  overflow: hidden;
  display: none;
}
.food-card-dropdown.open {
  display: block;
}
.food-card-dropdown a,
.food-card-dropdown button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  color: var(--c-text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out);
  font-family: inherit;
  text-align: left;
}
.food-card-dropdown a:hover,
.food-card-dropdown button:hover {
  background: var(--c-surface-2);
}
.food-card-dropdown .dropdown-danger {
  color: var(--c-error);
}
.food-card-dropdown .dropdown-danger:hover {
  background: color-mix(in srgb, var(--c-error) 8%, transparent);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  gap: var(--sp-4);
}
.empty-state-icon {
  font-size: 4rem;
  line-height: 1;
  opacity: .5;
}
.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--fw-semi);
  color: var(--c-text);
}
.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--c-text-2);
  max-width: 20rem;
  line-height: var(--lh-relaxed);
}

/* ============================================================
   19. PAGE — PROGRESS
   ============================================================ */
.progress-header-tabs {
  display: flex;
  background: var(--c-surface-3);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.progress-tab {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-3);
  text-align: center;
  transition:
    background var(--dur-base) var(--ease-out),
    color      var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.progress-tab.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-sm);
}

/* Chart container */
.chart-container {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.chart-canvas {
  width: 100%;
  height: 14rem;
}

/* Progress legend */
.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  margin-top: var(--sp-4);
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-dot.good  { background: var(--c-goal-good); }
.legend-dot.under { background: var(--c-goal-under); }
.legend-dot.over  { background: var(--c-goal-over); }

/* Stats summary row */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.progress-stat-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  padding: var(--sp-4);
  text-align: center;
}
.progress-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  line-height: 1;
}
.progress-stat-label {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  margin-top: var(--sp-1);
  font-weight: var(--fw-medium);
}

/* Calendar heatmap row */
.cal-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-1);
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  cursor: default;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.cal-day:hover { transform: scale(1.08); }
.cal-day.good   { background: var(--c-success-light); color: #166534; }
.cal-day.under  { background: var(--c-warning-light); color: #92400E; }
.cal-day.over   { background: var(--c-error-light);   color: #991B1B; }
.cal-day.empty  { opacity: .35; }
.cal-day.today  { outline: 2px solid var(--c-primary); outline-offset: -1px; }

/* ============================================================
   20. PAGE — SETTINGS / PROFILE
   ============================================================ */
.settings-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) 0 var(--sp-4);
}
.avatar {
  width: 5rem; height: 5rem;
  border-radius: 50%;
  background: var(--c-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  border: 3px solid var(--c-surface);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  position: relative;
  transition: transform var(--dur-base) var(--ease-spring);
}
.avatar:hover { transform: scale(1.04); }
.avatar-edit-badge {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 1.5rem; height: 1.5rem;
  background: var(--c-primary);
  border-radius: 50%;
  border: 2px solid var(--c-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.avatar-edit-badge svg { width: 0.625rem; height: 0.625rem; }

/* Settings section */
.settings-section {
  margin-bottom: var(--sp-6);
}
.settings-section-title {
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--sp-4) var(--sp-2);
}
.settings-list {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.settings-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  text-decoration: none;
  color: inherit;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: var(--c-surface-2); }
.settings-item-icon {
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.settings-item-icon.teal   { background: var(--c-primary-light); color: var(--c-primary); }
.settings-item-icon.blue   { background: var(--c-info-light);    color: var(--c-info); }
.settings-item-icon.orange { background: var(--c-warning-light); color: var(--c-warning); }
.settings-item-icon.red    { background: var(--c-error-light);   color: var(--c-error); }
.settings-item-icon.gray   { background: var(--c-surface-3);     color: var(--c-text-2); }
.settings-item-icon svg    { width: 1.125rem; height: 1.125rem; }

.settings-item-info { flex: 1; }
.settings-item-label {
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--c-text);
}
.settings-item-value {
  font-size: var(--text-xs);
  color: var(--c-text-3);
  margin-top: 1px;
}
.settings-item-chevron {
  color: var(--c-text-3);
  flex-shrink: 0;
}
.settings-item-chevron svg { width: 1rem; height: 1rem; }

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--c-border-2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 1.125rem; width: 1.125rem;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-base) var(--ease-spring);
  box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--c-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(1.25rem); }

/* ============================================================
   21. ANIMATIONS & TRANSITIONS
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(1rem); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes ringPop {
  0%   { transform: scale(0.8) rotate(-90deg); opacity: 0; }
  70%  { transform: scale(1.05) rotate(-90deg); }
  100% { transform: scale(1) rotate(-90deg); opacity: 1; }
}

.animate-fade-in  { animation: fadeIn  var(--dur-slow) var(--ease-out); }
.animate-slide-up { animation: slideUp var(--dur-slow) var(--ease-out); }
.animate-scale-in { animation: scaleIn var(--dur-slow) var(--ease-spring); }

/* Stagger children */
.stagger > * { animation: slideUp var(--dur-slow) var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay:  40ms; }
.stagger > *:nth-child(2) { animation-delay:  80ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 160ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 240ms; }

/* ============================================================
   22. RESPONSIVE — TABLET (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {
  :root {
    --page-pad: var(--sp-8);
  }

  .modal-overlay {
    align-items: center;
    padding: var(--sp-8);
  }
  .modal {
    border-radius: var(--radius-xl);
    transform: scale(0.95) translateY(1rem);
    max-height: 80vh;
  }
  .modal-overlay.is-open .modal {
    transform: scale(1) translateY(0);
  }

  .grid-2-md { grid-template-columns: repeat(2, 1fr); }
  .grid-3-md { grid-template-columns: repeat(3, 1fr); }

  .auth-page {
    flex-direction: row;
    align-items: stretch;
  }
  .auth-hero {
    flex: 1;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--sp-16);
  }
  .auth-hero-logo { justify-content: flex-start; }
  .auth-hero-tagline { text-align: left; }
  .auth-hero-sub     { text-align: left; }
  .auth-card {
    flex: 1;
    border-radius: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 28rem;
    box-shadow: none;
    border-left: 1px solid var(--c-border);
  }

  .summary-ring-row { gap: var(--sp-8); }
  .summary-stat-val  { font-size: var(--text-2xl); }

  .progress-stats { grid-template-columns: repeat(4, 1fr); }

  .cal-row { gap: var(--sp-2); }
}

/* ============================================================
   23. RESPONSIVE — DESKTOP (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .btn-fab { display: none; }   /* Use inline add button on desktop */

  .bottom-nav { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    z-index: 40;
    overflow-y: auto;
    padding: var(--sp-6) var(--sp-3);
  }
  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-3) var(--sp-6);
    text-decoration: none;
  }
  .sidebar-logo .logo-mark {
    width: 2.25rem; height: 2.25rem;
    background: var(--c-primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: var(--fw-bold);
    font-size: var(--text-base);
    flex-shrink: 0;
  }
  .sidebar-logo .logo-name {
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    color: var(--c-text);
    letter-spacing: -0.02em;
  }
  .sidebar-logo .logo-name span { color: var(--c-primary); }

  .sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: var(--sp-1); }
  .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    color: var(--c-text-2);
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    text-decoration: none;
    transition:
      background var(--dur-fast) var(--ease-out),
      color      var(--dur-fast) var(--ease-out);
  }
  .sidebar-nav a svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }
  .sidebar-nav a:hover {
    background: var(--c-surface-2);
    color: var(--c-text);
  }
  .sidebar-nav a.active {
    background: var(--c-primary-light);
    color: var(--c-primary-darker);
    font-weight: var(--fw-semi);
  }
  .sidebar-nav .nav-label {
    font-size: var(--text-xs);
    font-weight: var(--fw-semi);
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--sp-4) var(--sp-4) var(--sp-2);
  }
  .sidebar-footer {
    border-top: 1px solid var(--c-border);
    padding-top: var(--sp-4);
    margin-top: var(--sp-4);
  }

  .app-layout {
    margin-left: var(--sidebar-width);
    padding-bottom: 0;
  }
  .page-content {
    padding: var(--sp-8) var(--sp-8);
    max-width: calc(var(--content-max) + var(--sp-16));
  }

  .topbar { padding-inline: var(--sp-8); }

  .dashboard-summary {
    border-radius: var(--radius-xl);
    margin-bottom: 0;
  }

  /* Desktop grid layout for dashboard */
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-6);
    align-items: start;
  }
  .dashboard-grid .dashboard-summary { grid-column: 1 / -1; }
}

/* ============================================================
   24. ACCESSIBILITY & FOCUS
   ============================================================ */

/* Skip to content */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  background: var(--c-primary);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  z-index: 9999;
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: var(--sp-4); }

/* Visible focus ring for keyboard nav */
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* High contrast improvements */
@media (prefers-contrast: high) {
  :root {
    --c-border:   #000;
    --c-border-2: #000;
    --c-text-2:   var(--c-text);
  }
}

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

/* ============================================================
   UTILITY — Print (hide nav)
   ============================================================ */
@media print {
  .bottom-nav, .sidebar, .btn-fab, .topbar { display: none; }
  .app-layout { margin-left: 0; padding-bottom: 0; }
}
