/* ═══════════════════════════════════════════════════════════════════
   design.css  –  vForma Premium Design System v2
   Glassmorphism · Dark-first · HSL tokens · Micro-animations
   ═══════════════════════════════════════════════════════════════════ */

/* ── Google Fonts preloaded in HTML ── */

/* ── 1. Design Tokens ────────────────────────────────────────────── */
:root {
  /* Colors */
  --teal:        hsl(190, 80%, 45%);
  --teal-dim:    hsl(190, 50%, 35%);
  --teal-glow:   0 0 24px hsl(190 80% 45% / .35);

  --purple:      hsl(280, 100%, 65%);
  --purple-glow: 0 0 24px hsl(280 100% 65% / .3);

  --orange:      hsl(28,  100%, 55%);
  --yellow:      hsl(48,  100%, 52%);
  --green:       hsl(145,  70%, 48%);
  --danger:      hsl(0,    85%, 62%);
  --blue:        hsl(220,  90%, 60%);

  /* Colors */
  --cyan: var(--teal);
  --cyan-dim: var(--teal-dim);
  --cyan-glow: var(--teal-glow);

  --purple:      hsl(280, 100%, 65%);
  --purple-glow: 0 0 24px hsl(280 100% 65% / .3);

  --orange:      hsl(28,  100%, 55%);
  --yellow:      hsl(48,  100%, 52%);
  --green:       hsl(145,  70%, 48%);
  --danger:      hsl(0,    85%, 62%);
  --blue:        hsl(220,  90%, 60%);

  /* Surfaces */
  --bg:              radial-gradient(ellipse at 50% 0%, hsl(240 60% 10%) 0%, hsl(230 40% 4%) 70%);
  --surface-1:       hsl(230 40% 8% / .6);
  --surface-2:       hsl(230 40% 12% / .5);
  --surface-border:  hsl(220 50% 80% / .08);
  --surface-border-h:hsl(190 100% 50% / .25);

  /* Text */
  --text-primary:   hsl(220 20% 97%);
  --text-secondary: hsl(220 15% 60%);
  --text-muted:     hsl(220 15% 38%);

  /* Accent gradient */
  --grad-accent:  linear-gradient(135deg, hsl(190 100% 50%), hsl(240 100% 70%));
  --grad-purple:  linear-gradient(135deg, hsl(280 100% 65%), hsl(310  90% 60%));
  --grad-warm:    linear-gradient(135deg, hsl(28 100% 55%), hsl(48 100% 52%));
  --grad-green:   linear-gradient(135deg, hsl(145 70% 48%), hsl(170 80% 44%));

  /* Typography */
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  /* Spacing */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;
  --sp-4: 16px;  --sp-5: 20px;  --sp-6: 24px;
  --sp-8: 32px;  --sp-10: 40px; --sp-12: 48px;

  /* Radius */
  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-full: 9999px;

  /* Blur */
  --blur-glass: blur(20px) saturate(160%);

  /* Transitions */
  --ease-snappy: cubic-bezier(.4, 0, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast:   .15s;
  --t-normal: .25s;
  --t-slow:   .4s;

  /* Shadows */
  --shadow-card: 0 8px 32px hsl(230 60% 4% / .6),
                 0 2px 8px  hsl(230 60% 4% / .4),
                 inset 0 1px 0 hsl(220 50% 100% / .05);
  --shadow-btn:  0 4px 16px hsl(190 100% 50% / .3);
  --shadow-input-focus: 0 0 0 3px hsl(190 100% 50% / .2),
                        0 0 0 1px hsl(190 100% 50% / .5);
}

/* ── 2. Base Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg);
  background-attachment: fixed;
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 3. Typography ───────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.5px;
}

h2 {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.subtitle, .hint {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.label-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cyan);
}

/* ── 4. Glass Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t-normal) var(--ease-snappy),
              box-shadow  var(--t-normal) var(--ease-snappy);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsl(220 50% 100% / .03) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

.card:hover {
  border-color: var(--surface-border-h);
  box-shadow: var(--shadow-card), var(--cyan-glow);
}

.card-accent {
  border-color: hsl(190 100% 50% / .2);
  background: linear-gradient(135deg, hsl(190 100% 50% / .06), hsl(240 100% 70% / .04));
}

/* ── 5. Buttons ──────────────────────────────────────────────────── */
.btn, button.primary, button.secondary, button.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-5);
  height: 48px;
  border-radius: var(--r-md);
  border: none;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring),
              box-shadow var(--t-normal) var(--ease-snappy),
              background var(--t-normal) var(--ease-snappy),
              opacity var(--t-normal) var(--ease-snappy);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

/* Ripple effect on click */
.btn::after, button.primary::after, button.secondary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%),
    hsl(0 0% 100% / .25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}
.btn:active::after, button:active::after { opacity: 1; }

.btn:active, button:active { transform: scale(.96); }
.btn:disabled, button:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

/* Primary */
.btn.primary, button.primary {
  background: var(--grad-accent);
  color: hsl(230 60% 8%);
  box-shadow: var(--shadow-btn);
  font-weight: 700;
}
.btn.primary:hover, button.primary:hover {
  box-shadow: var(--shadow-btn), var(--cyan-glow);
}

/* Secondary */
.btn.secondary, button.secondary {
  background: hsl(220 40% 100% / .05);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
}
.btn.secondary:hover, button.secondary:hover {
  background: hsl(220 40% 100% / .09);
  border-color: var(--surface-border-h);
}

/* Danger */
.btn.danger, button.danger {
  background: hsl(0 85% 60% / .12);
  color: var(--danger);
  border: 1px solid hsl(0 85% 60% / .25);
}
.btn.danger:hover, button.danger:hover {
  background: hsl(0 85% 60% / .2);
}

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

/* Icon button */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-sm);
  border: none;
  background: hsl(220 40% 100% / .05);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-normal) var(--ease-snappy);
}
.btn-icon:hover {
  background: hsl(220 40% 100% / .1);
  color: var(--text-primary);
}
.btn-icon:active { transform: scale(.92); }

/* ── 6. Form Inputs ──────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .7px;
}

input[type=text], input[type=number], input[type=email],
input[type=time], input[type=date], select, textarea {
  height: 48px;
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--surface-border);
  padding: 0 var(--sp-4);
  background: hsl(220 40% 100% / .04);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: border-color var(--t-normal) var(--ease-snappy),
              background    var(--t-normal) var(--ease-snappy),
              box-shadow    var(--t-normal) var(--ease-snappy);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
  background: hsl(220 40% 100% / .07);
  box-shadow: var(--shadow-input-focus);
}

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

textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: 1.6;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: var(--sp-8);
  cursor: pointer;
}

option { background: hsl(230 40% 8%); }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-3);
}

/* ── 7. Badge / Tag ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
}

.badge-cyan   { background: hsl(190 100% 50% / .12); color: var(--cyan);   border: 1px solid hsl(190 100% 50% / .2); }
.badge-green  { background: hsl(145  70% 48% / .12); color: var(--green);  border: 1px solid hsl(145  70% 48% / .2); }
.badge-orange { background: hsl(28  100% 55% / .12); color: var(--orange); border: 1px solid hsl(28  100% 55% / .2); }
.badge-red    { background: hsl(0    85% 62% / .12); color: var(--danger); border: 1px solid hsl(0   85% 62% / .2); }
.badge-purple { background: hsl(280 100% 65% / .12); color: var(--purple); border: 1px solid hsl(280 100% 65% / .2); }

/* ── 8. Stat Row ─────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.stat-unit {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── 9. Progress Bar ─────────────────────────────────────────────── */
.progress-track {
  height: 6px;
  background: hsl(220 40% 100% / .07);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  width: 0;
  transition: width .9s var(--ease-snappy);
}
.progress-fill.cyan   { background: var(--grad-accent); box-shadow: 0 0 8px var(--cyan); }
.progress-fill.orange { background: var(--grad-warm); }
.progress-fill.green  { background: var(--grad-green); }

/* ── 10. Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 9900;
  width: min(90vw, 360px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: hsl(230 40% 12% / .95);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px hsl(0 0% 0% / .5), var(--cyan-glow);
  opacity: 0;
  transform: translateY(12px) scale(.96);
  transition: all .3s var(--ease-spring);
  pointer-events: all;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.toast-success { border-color: hsl(145 70% 48% / .35); }
.toast.toast-error   { border-color: hsl(0 85% 62% / .35); }
.toast.toast-warning { border-color: hsl(48 100% 52% / .35); }
.toast.toast-info    { border-color: var(--surface-border-h); }

/* ── 11. Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: hsl(230 60% 4% / .7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 9800;
  padding: 0 var(--sp-4) var(--sp-6);
  animation: backdrop-in .25s var(--ease-snappy) both;
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: hsl(230 40% 10%);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  width: min(100%, 440px);
  box-shadow: 0 -4px 48px hsl(0 0% 0% / .6);
  animation: sheet-up .3s var(--ease-spring) both;
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-border);
  margin: 0 auto var(--sp-5);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.modal-footer {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}
.modal-footer .btn { flex: 1; }

/* ── 12. Offline Banner ──────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9700;
  background: hsl(48 100% 52% / .12);
  border-bottom: 1px solid hsl(48 100% 52% / .3);
  color: var(--yellow);
  font-size: 12.5px;
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  backdrop-filter: blur(8px);
  transform: translateY(-100%);
  transition: transform .3s var(--ease-snappy);
}
#offline-banner.show { transform: translateY(0); }

/* ── 13. Bottom Tab Bar ──────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  display: flex;
  justify-content: space-around;
  background: hsl(230 40% 5% / .9);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border-top: 1px solid var(--surface-border);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 8px));
  z-index: 900;
  box-shadow: 0 -12px 40px hsl(0 0% 0% / .5);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  font-family: var(--font-display);
  flex: 1;
  padding: 4px 0;
  border: none;
  background: transparent;
  height: auto;
  cursor: pointer;
  transition: color var(--t-normal) var(--ease-snappy);
  position: relative;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  transition: transform var(--t-normal) var(--ease-spring);
}

.tab-btn.active {
  color: var(--cyan);
}

.tab-btn.active svg {
  transform: translateY(-2px) scale(1.08);
  filter: drop-shadow(0 0 5px hsl(190 100% 50% / .5));
}

/* Active dot indicator */
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

/* ── 14. Tab Content Transitions ─────────────────────────────────── */
.tab-content {
  display: none;
  flex-direction: column;
  gap: var(--sp-4);
  animation: tab-in .3s var(--ease-snappy) both;
}
.tab-content.active { display: flex; }

@keyframes tab-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 15. Meal List ───────────────────────────────────────────────── */
.meal-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: hsl(220 40% 100% / .03);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-md);
  transition: background var(--t-normal) var(--ease-snappy),
              border-color var(--t-normal) var(--ease-snappy);
  animation: slide-in .25s var(--ease-spring) both;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.meal-item:hover { background: hsl(220 40% 100% / .05); }

.meal-emoji {
  font-size: 24px;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(220 40% 100% / .04);
  border-radius: var(--r-sm);
}

.meal-info { flex: 1; min-width: 0; }
.meal-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.meal-kcal {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--cyan);
  flex-shrink: 0;
}

/* ── 16. Scanner HUD ─────────────────────────────────────────────── */
.scanner-hud {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: hsl(230 60% 4%);
  border: 1px solid var(--surface-border);
}

.scanner-hud video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-dim {
  position: absolute;
  inset: 0;
  background: hsl(230 60% 4% / .45);
}

.hud-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-box {
  position: relative;
  width: 70%;
  aspect-ratio: 1.6;
  box-shadow: 0 0 0 9999px hsl(230 60% 4% / .5);
  border-radius: 4px;
}

.hud-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--cyan);
  border-style: solid;
  filter: drop-shadow(0 0 6px var(--cyan));
}
.hud-corner.tl { top: -1px; left: -1px;  border-width: 3px 0 0 3px; border-top-left-radius: 4px; }
.hud-corner.tr { top: -1px; right: -1px; border-width: 3px 3px 0 0; border-top-right-radius: 4px; }
.hud-corner.bl { bottom: -1px; left: -1px;  border-width: 0 0 3px 3px; border-bottom-left-radius: 4px; }
.hud-corner.br { bottom: -1px; right: -1px; border-width: 0 3px 3px 0; border-bottom-right-radius: 4px; }

.hud-laser {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--cyan);
  animation: laser 2s ease-in-out infinite;
}
@keyframes laser {
  0%   { top: 10%; opacity: 1; }
  48%  { top: 90%; opacity: 1; }
  50%  { opacity: 0; }
  52%  { top: 10%; opacity: 0; }
  54%  { opacity: 1; }
  100% { top: 90%; opacity: 1; }
}

/* ── 17. Quick Food Tags ─────────────────────────────────────────── */
.quick-foods {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-block: var(--sp-2);
}

.quick-tag {
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: hsl(220 40% 100% / .04);
  border: 1px solid var(--surface-border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-snappy);
}

.quick-tag:hover, .quick-tag:active {
  color: var(--cyan);
  border-color: hsl(190 100% 50% / .3);
  background: hsl(190 100% 50% / .06);
  transform: scale(1.03);
}

/* ── 18. BMI Badge ───────────────────────────────────────────────── */
.bmi-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
}
.bmi-normal   { background: hsl(145 70% 48% / .1); color: var(--green);  border: 1px solid hsl(145 70% 48% / .25); }
.bmi-over     { background: hsl(28 100% 55% / .1);  color: var(--orange); border: 1px solid hsl(28 100% 55% / .25); }
.bmi-obese    { background: hsl(0 85% 62% / .1);    color: var(--danger); border: 1px solid hsl(0 85% 62% / .25); }
.bmi-under    { background: hsl(220 90% 60% / .1);  color: var(--blue);   border: 1px solid hsl(220 90% 60% / .25); }

/* ── 19. Spinner / Loader ────────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid hsl(220 40% 100% / .08);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg,
    hsl(220 40% 100% / .04) 25%,
    hsl(220 40% 100% / .08) 50%,
    hsl(220 40% 100% / .04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 20. Search Results ──────────────────────────────────────────── */
.search-results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: hsl(220 40% 100% / .03);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-snappy);
}
.search-result-item:hover {
  background: hsl(190 100% 50% / .06);
  border-color: hsl(190 100% 50% / .2);
}

.search-result-name { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.search-result-kcal { font-size: 12px; color: var(--cyan); font-weight: 600; }

/* ── 21. Responsive & App Shell ──────────────────────────────────── */
#app-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Mobile‑first breakpoints */
@media (max-width: 600px) {
  #app-container {padding: var(--sp-3); padding-bottom: 80px;}
  h1 {font-size: clamp(20px,6vw,24px);}
  .btn {height: 44px; font-size: 14px;}
  .tab-bar {height: 60px;}
}

/* ── 22. Micro-interactions ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Pulse on new entry */
@keyframes pulse-once {
  0%   { box-shadow: 0 0 0 0 hsl(190 100% 50% / .4); }
  70%  { box-shadow: 0 0 0 10px hsl(190 100% 50% / 0); }
  100% { box-shadow: 0 0 0 0 hsl(190 100% 50% / 0); }
}
.pulse { animation: pulse-once .6s var(--ease-snappy) both; }

/* Number count-up animation helper */
.count-anim { transition: all .6s var(--ease-snappy); }

/* ── 23. Smart Logger & Menu Generator ──────────────────────────── */

/* Quick-tag chips (smart food input) */
.quick-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 20px;
  background: hsl(var(--hue-cyan) 90% 50% / .08);
  border: 1px solid hsl(var(--hue-cyan) 80% 60% / .18);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s, transform .1s var(--ease-snappy);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.quick-tag:hover  { background: hsl(var(--hue-cyan) 80% 55% / .14); color: var(--text-primary); }
.quick-tag:active { transform: scale(.94); }

/* Accent card (hero input wrapper) */
.card-accent {
  border-color: hsl(var(--hue-cyan) 80% 55% / .22);
  background: hsl(220 35% 12% / .85);
}
.card-accent:focus-within {
  border-color: hsl(var(--hue-cyan) 80% 55% / .45);
  box-shadow: 0 0 0 3px hsl(var(--hue-cyan) 80% 55% / .1),
              var(--shadow-card);
}

/* Smart textarea focus */
#smart-food-input:focus {
  border-color: hsl(var(--hue-cyan) 80% 55% / .6) !important;
  box-shadow: 0 0 0 3px hsl(var(--hue-cyan) 80% 55% / .12);
}

/* .btn base (used alongside class="btn primary|secondary") */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 18px;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .18s var(--ease-snappy);
  -webkit-tap-highlight-color: transparent;
}
.btn.primary {
  background: var(--grad-accent);
  color: hsl(230 60% 8%);
}
.btn.primary:hover  { filter: brightness(1.08); }
.btn.primary:active { transform: scale(.97); }

.btn.secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
}
.btn.secondary:hover  { background: hsl(220 40% 100%/.08); }
.btn.secondary:active { transform: scale(.97); }

/* Icon button (close/dismiss) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: hsl(220 40% 100%/.06);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: hsl(220 40% 100%/.12); color: var(--text-primary); }

/* Spinner (loading indicator) */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid hsl(220 40% 100%/.12);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* Purple gradient variable (used by menu generator card) */
:root {
  --grad-purple: linear-gradient(135deg, hsl(270 70% 60%), hsl(290 80% 50%));
}

/* Details/summary for collapsed scanner */
details > summary::marker,
details > summary::-webkit-details-marker { display: none; }
details > summary { list-style: none; }
details[open] > summary { color: var(--text-secondary); }

/* Sync loader overlay */
#sync-loader {
  position: fixed;
  inset: 0;
  background: hsl(230 30% 5%/.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#sync-loader.show {
  opacity: 1;
  pointer-events: auto;
}

/* ── 24. hue variables shorthands ──────────────────────────────── */
:root {
  --hue-cyan: var(--hue-teal);
  --hue-purple: 270;
}

/* ── 25. Diary Premium Styles ───────────────────────────────────── */

/* Macro chip (tiny pill with custom color) */
.macro-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: color-mix(in srgb, var(--mc, #00f2fe) 15%, transparent);
  color: var(--mc, #00f2fe);
  border: 1px solid color-mix(in srgb, var(--mc, #00f2fe) 25%, transparent);
  white-space: nowrap;
}

/* Meal item in diary */
.meal-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 12px 14px;
  background: hsl(220 35% 8% / .4);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  cursor: default;
  transition: background .15s;
}
.meal-item:hover { background: hsl(220 40% 100% / .03); }

.meal-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.meal-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meal-delete-btn:hover {
  color: hsl(0 80% 65%);
  background: hsl(0 80% 50% / .1);
}

/* Gradient variants needed by diary bar */
:root {
  --grad-danger: linear-gradient(90deg, hsl(0 80% 55%), hsl(20 90% 50%));
  --grad-warn:   linear-gradient(90deg, hsl(38 90% 55%), hsl(28 100% 55%));
}

/* slide-in animation for diary items */
@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 26. UI/UX Portions, Swaps & Constructor Styles ───────────────── */

/* Ambient glow effects */
.app-bg-glow {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, hsl(190 100% 50% / .12) 0%, transparent 70%);
  top: -80px;
  left: -80px;
  z-index: -1;
  pointer-events: none;
}
.app-bg-glow-2 {
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: radial-gradient(circle, hsl(280 100% 65% / .08) 0%, transparent 70%);
  top: 400px;
  right: -100px;
  z-index: -1;
  pointer-events: none;
}

/* Logger tabs styling */
.logger-tabs {
  display: flex;
  background: hsl(220 40% 100% / .03);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: var(--sp-4);
  gap: 2px;
}
.logger-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  padding: 10px 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-snappy);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: auto;
}
.logger-tab-btn.active {
  background: hsl(220 40% 100% / .06);
  color: var(--cyan);
  box-shadow: 0 4px 12px hsl(0 0% 0% / .2);
}
.logger-tab-btn:active {
  transform: scale(.97);
}

/* Interactive portion editor controls */
.portion-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.btn-portion {
  background: hsl(220 40% 100% / .04);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  height: 25px;
  min-width: 40px;
  padding: 0 var(--sp-2);
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-snappy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-portion:hover {
  background: hsl(190 100% 50% / .1);
  border-color: hsl(190 100% 50% / .3);
  color: var(--cyan);
}
.btn-portion:active {
  transform: scale(.9);
}
.btn-portion.delete-item {
  color: var(--danger);
  border-color: hsl(0 85% 62% / .18);
  min-width: 28px;
}
.btn-portion.delete-item:hover {
  background: hsl(0 85% 62% / .12);
  border-color: hsl(0 85% 62% / .4);
}

/* Animated fluid Water Cup */
.water-widget {
  overflow: visible;
}
.glass-container {
  position: relative;
  width: 82px;
  height: 104px;
  border: 3.5px solid hsl(220 50% 100% / .15);
  border-top: 0;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  background: linear-gradient(180deg, hsl(220 50% 100% / .02) 0%, hsl(220 50% 100% / .05) 100%);
  box-shadow: 0 10px 25px hsl(0 0% 0% / .35),
              inset 0 0 12px hsl(220 50% 100% / .03);
  overflow: hidden;
  transition: border-color var(--t-normal) var(--ease-snappy);
}
.glass-container:hover {
  border-color: hsl(190 100% 50% / .3);
}
.glass-water {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, hsl(195, 90%, 55%) 0%, hsl(205, 100%, 45%) 100%);
  box-shadow: 0 0 15px hsl(195 90% 55% / .4);
  transition: height 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.wave {
  position: absolute;
  top: -12px;
  left: 0;
  width: 200%;
  height: 20px;
  background: hsl(195, 90%, 55%);
  border-radius: 38%;
  animation: wave-motion 5s linear infinite;
  opacity: 0.85;
  pointer-events: none;
}
.wave-back {
  position: absolute;
  top: -16px;
  left: -50%;
  width: 200%;
  height: 20px;
  background: hsl(205, 100%, 45%);
  border-radius: 40%;
  animation: wave-motion-back 7s linear infinite;
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}
@keyframes wave-motion {
  0% { transform: translateX(0) rotate(0deg); }
  100% { transform: translateX(-50%) rotate(360deg); }
}
@keyframes wave-motion-back {
  0% { transform: translateX(0) rotate(360deg); }
  100% { transform: translateX(50%) rotate(0deg); }
}

/* Menu Constructor options */
.constructor-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--surface-border);
}
.constructor-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.constructor-meal-card {
  display: flex;
  flex-direction: column;
  background: hsl(220 40% 100% / .02);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 14px;
  transition: all var(--t-normal) var(--ease-snappy);
  animation: slide-in .25s var(--ease-spring) both;
}
.constructor-meal-card.checked {
  border-color: hsl(190 100% 50% / .22);
  background: linear-gradient(135deg, hsl(190 100% 50% / .03) 0%, hsl(240 100% 70% / .02) 100%);
}
.constructor-meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}
.constructor-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-display);
}

/* Custom visual checkbox */
.custom-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--surface-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s var(--ease-snappy);
  background: hsl(220 40% 100% / .03);
}
.custom-checkbox::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid hsl(230 60% 8%);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .2s var(--ease-spring);
  margin-bottom: 2px;
}
input[type=checkbox]:checked + .custom-checkbox {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: var(--cyan-glow);
}
input[type=checkbox]:checked + .custom-checkbox::after {
  transform: rotate(45deg) scale(1);
}
.constructor-meal-card:hover {
  border-color: var(--surface-border-h);
}

/* Constructor sub-items */
.constructor-meal-item-row {
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px dashed hsl(220 40% 100% / .04);
}
.constructor-meal-item-row:last-child {
  border-bottom: none;
}

/* Interactive Weight Slider styles */
.weight-slider-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0 1rem;
}
.weight-display {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
  margin-bottom: 0.5rem;
}
.weight-display span {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}
.weight-slider-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
}
.weight-adjust-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface-2);
  color: var(--fg);
  font-size: 1.1rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.weight-adjust-btn:active {
  transform: scale(0.85);
  background: var(--cyan);
  color: #000;
  border-color: var(--cyan);
}
.weight-range-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-border);
  outline: none;
}
.weight-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--purple) 100%);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
  transition: transform 0.1s;
}
.weight-range-input::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

/* Body Measurements Grid */
.measurements-toggle {
  text-align: center;
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin: 10px 0;
  text-decoration: underline;
}
.measurements-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.measurements-grid.show {
  max-height: 80px;
  margin-top: 8px;
  margin-bottom: 12px;
}
.measurement-field {
  display: flex;
  flex-direction: column;
}
.measurement-field label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
  text-align: center;
}
.measurement-field input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  font-size: 13px;
  text-align: center;
}
.measurement-field input:focus {
  border-color: var(--cyan);
  outline: none;
}

/* Interactive SVG Chart Tooltip styling */
.chart-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: #fff;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: translate(-50%, -100%) scale(0.8);
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(0, 242, 254, 0.1);
}
.chart-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.95) transparent transparent;
  display: block;
  width: 0;
}
.chart-tooltip.show {
  opacity: 1;
  transform: translate(-50%, -115%) scale(1);
}
.chart-tooltip-date {
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chart-tooltip-weight {
  font-weight: 700;
  font-family: var(--font-display);
}
.chart-tooltip-diff {
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}
.chart-tooltip-diff.loss {
  color: #10b981 !important; /* Green */
}
.chart-tooltip-diff.gain {
  color: #8b5cf6 !important; /* Purple */
}

/* Highlighted point pulse effect */
@keyframes pulse-point {
  0% { r: 4; stroke-width: 2; opacity: 1; }
  50% { r: 7; stroke-width: 3; opacity: 0.5; }
  100% { r: 4; stroke-width: 2; opacity: 1; }
}
.pulse-circle {
  animation: pulse-point 2s infinite;
}

/* Segmented Control Redesign (Premium & Mobile-adapted) */
.segmented-control {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 3px;
  gap: 3px;
  width: 100%;
}
.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 4px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  white-space: nowrap;
  min-height: unset;
  height: auto;
  line-height: 1.2;
}
.segment-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.segment-btn:active {
  transform: scale(0.96);
}

/* Weight Range Slider (Volume-style & Satisfyingly tactile) */
.weight-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
}
.weight-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  cursor: pointer;
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.1s ease;
  border: none;
}
.weight-range-slider::-webkit-slider-thumb:active {
  transform: scale(1.4);
  background: #ffffff;
  box-shadow: 0 0 15px #ffffff;
}
.weight-range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  border: none;
  cursor: pointer;
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.1s ease;
}
.weight-range-slider::-moz-range-thumb:active {
  transform: scale(1.4);
  background: #ffffff;
  box-shadow: 0 0 15px #ffffff;
}



@media (max-width: 600px) {
  /* Mobile layout tweaks */
  #app-container {
    padding: var(--sp-3);
    max-width: 100%;
  }
  .segmented-control {
    flex-direction: column;
    gap: 6px;
  }
  .segment-btn {
    font-size: 14px;
    padding: 8px 4px;
  }
  .btn, button.primary, button.secondary, button.danger {
    height: 48px;
    font-size: 15px;
  }
  .card, .card-accent {
    margin: var(--sp-2);
  }
}

/* ── 23. Enhanced Modal Backdrop ───────────────────────────────────── */
.modal-backdrop {
  backdrop-filter: blur(8px);
}
