/* ==========================================
   Variables
   ========================================== */
:root {
  --bg: #080808;
  --surface-1: #0f0f0f;
  --surface-2: #161616;
  --surface-3: #1e1e1e;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

  --text-1: #ffffff;
  --text-2: #888888;
  --text-3: #505050;

  --accent: #c8ff00;
  --accent-dim: rgba(200, 255, 0, 0.08);
  --accent-border: rgba(200, 255, 0, 0.3);

  --protein: #ff4444;
  --protein-bg: rgba(255, 68, 68, 0.08);
  --carbs: #00d26a;
  --carbs-bg: rgba(0, 210, 106, 0.08);
  --fat: #ffd60a;
  --fat-bg: rgba(255, 214, 10, 0.08);

  --danger: #ff3b30;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  --transition: 0.18s ease;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================
   Reset & Base
   ========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ==========================================
   App Shell
   ========================================== */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================
   Header
   ========================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 8, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--text-1);
}

.logo-dot { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-display {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text-1);
  border-color: var(--border-hover);
}

/* ==========================================
   Main & Content Wrapper
   ========================================== */
.main {
  flex: 1;
  padding-bottom: calc(32px + var(--safe-bottom));
}

.content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================
   Stats Section
   ========================================== */
.stats-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Calorie Card */
.calories-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.calories-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.35;
}

.calories-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.calories-number {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 88px;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--text-1);
  transition: color 0.3s ease;
}

.calories-number.over-goal { color: var(--danger); }

.calories-unit {
  font-size: 22px;
  font-weight: 300;
  color: var(--text-2);
  letter-spacing: 1px;
  align-self: flex-end;
  margin-bottom: 8px;
}

.calories-meta {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.calories-goal {
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  gap: 4px;
}

.calories-remaining {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

/* Macro Cards */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.macro-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px 14px;
  text-align: center;
}

.macro-top {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  line-height: 1;
}

.macro-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 38px;
  display: inline;
}

.macro-unit {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.macro-label {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.macro-goal-text {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}

.macro-progress {
  height: 2px;
  background: var(--surface-3);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 100%;
}

.macro-card.protein .macro-value { color: var(--protein); }
.macro-card.protein .macro-bar-fill { background: var(--protein); }
.macro-card.carbs .macro-value { color: var(--carbs); }
.macro-card.carbs .macro-bar-fill { background: var(--carbs); }
.macro-card.fat .macro-value { color: var(--fat); }
.macro-card.fat .macro-bar-fill { background: var(--fat); }

/* ==========================================
   Add Section
   ========================================== */
.add-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 36px 13px 42px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: all var(--transition);
}

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

.search-input:focus {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.clear-btn {
  position: absolute;
  right: 10px;
  font-size: 20px;
  color: var(--text-3);
  line-height: 1;
  padding: 4px;
  transition: color var(--transition);
}

.clear-btn:hover { color: var(--text-2); }

.scan-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-2);
  transition: all var(--transition);
  flex-shrink: 0;
}

.scan-btn.camera:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.scan-btn.barcode:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

/* Search Results Dropdown */
.search-results {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.search-results::-webkit-scrollbar { width: 4px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.search-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-3); }

.result-info { flex: 1; min-width: 0; }

.result-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-brand {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

.result-kcal {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

/* Weight inline picker */
.result-weight-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px 14px;
  background: var(--surface-3);
  border-top: 1px solid var(--border);
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-weight-row label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
}

.result-weight-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  min-width: 0;
}

.result-weight-input:focus { border-color: var(--accent-border); }

.result-add-btn {
  background: var(--accent);
  color: #000;
  border-radius: var(--radius-xs);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.result-add-btn:hover { opacity: 0.85; }

/* Quick Add Button */
.quick-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: var(--surface-1);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.5px;
  transition: all var(--transition);
}

.quick-add-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ==========================================
   History Section
   ========================================== */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.entry-count {
  font-size: 11px;
  color: var(--text-3);
}

.food-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
  opacity: 0.3;
  filter: grayscale(1);
}

.empty-state p {
  font-size: 13px;
  letter-spacing: 0.3px;
}

.food-entry {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition);
  animation: entryIn 0.2s ease;
}

@keyframes entryIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.food-entry:hover { border-color: var(--border-hover); }

.food-entry-main { flex: 1; min-width: 0; }

.food-entry-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-entry-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.food-entry-cal {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.food-entry-weight {
  font-size: 11px;
  color: var(--text-3);
}

.food-entry-macros {
  display: flex;
  gap: 8px;
}

.fem {
  font-size: 11px;
  font-weight: 500;
}

.fem.p { color: var(--protein); }
.fem.c { color: var(--carbs); }
.fem.f { color: var(--fat); }

.food-entry-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.food-entry-time {
  font-size: 11px;
  color: var(--text-3);
}

.food-entry-delete {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 15px;
  transition: all var(--transition);
}

.food-entry-delete:hover {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

/* ==========================================
   Modals
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: overlayIn 0.15s ease;
}

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

.modal-sheet {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  padding-bottom: max(20px, var(--safe-bottom));
  animation: sheetIn 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

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

.modal-sheet::-webkit-scrollbar { width: 4px; }
.modal-sheet::-webkit-scrollbar-track { background: transparent; }
.modal-sheet::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  margin: 12px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-header h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 1.5px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  line-height: 1;
  transition: all var(--transition);
}

.modal-close:hover {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

.modal-body {
  padding: 20px;
}

/* ==========================================
   Forms
   ========================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.form-label small {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  opacity: 0.7;
  margin-left: 4px;
}

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: all var(--transition);
  width: 100%;
}

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

.form-input:focus {
  border-color: var(--accent-border);
  background: var(--surface-3);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.form-group.full { grid-column: 1 / -1; }

/* ==========================================
   Macros Preview Block
   ========================================== */
.macros-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}

.preview-item { display: flex; flex-direction: column; gap: 3px; }

.preview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
}

.preview-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
}

.preview-item.p .preview-value { color: var(--protein); }
.preview-item.c .preview-value { color: var(--carbs); }
.preview-item.f .preview-value { color: var(--fat); }

/* ==========================================
   Buttons
   ========================================== */
.btn-primary {
  background: var(--accent);
  color: #000;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary.full { width: 100%; }
.btn-primary.sm { padding: 10px 16px; font-size: 13px; }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-1); }

.btn-danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger:hover { background: rgba(255, 59, 48, 0.18); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions > * { flex: 1; }

/* ==========================================
   Camera Modal
   ========================================== */
.camera-area {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
}

.camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
}

.camera-placeholder svg { opacity: 0.35; }
.camera-placeholder p { font-size: 13px; }

.camera-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cam-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--transition);
  cursor: pointer;
}

.cam-btn:hover { border-color: var(--border-hover); color: var(--text-1); }
.upload-label { cursor: pointer; }

.cam-btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}

.cam-btn.primary:hover { opacity: 0.88; }

.analyzing-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--text-2);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

/* ==========================================
   AI Confirm Modal
   ========================================== */
.ai-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ==========================================
   Barcode Modal
   ========================================== */
.barcode-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.barcode-result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  animation: slideDown 0.15s ease;
}

.barcode-product-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.barcode-product-brand {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 10px;
}

.barcode-product-macros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}

.barcode-product-macros span { font-weight: 600; }

.barcode-weight-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.barcode-weight-row .form-group { flex: 1; }

/* Barcode camera scan */
.barcode-cam-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: var(--surface-2);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.5px;
  transition: all var(--transition);
  margin-bottom: 14px;
}

.barcode-cam-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

.barcode-cam-area {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  aspect-ratio: 4/3;
}

.barcode-cam-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.barcode-scan-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.barcode-scan-frame::before {
  content: '';
  width: 72%;
  height: 38%;
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.45);
}

.barcode-scan-line {
  position: absolute;
  width: 68%;
  height: 2px;
  background: var(--accent);
  opacity: 0.85;
  border-radius: 1px;
  animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
  0%   { transform: translateY(-40px); }
  50%  { transform: translateY(40px); }
  100% { transform: translateY(-40px); }
}

.barcode-cam-stop {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--transition);
}

.barcode-cam-stop:hover { background: rgba(255,59,48,0.55); }

/* ==========================================
   Settings Modal
   ========================================== */
.settings-section { margin-bottom: 24px; }

.settings-section:last-of-type { margin-bottom: 0; }

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 7px;
  line-height: 1.5;
}

/* ==========================================
   Language Selector
   ========================================== */
.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lang-btn {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  transition: all var(--transition);
  cursor: pointer;
}

.lang-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-1);
}

.lang-btn.active {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ==========================================
   Toast Notification
   ========================================== */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-hover);
  border-radius: 100px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
}

.toast.success { border-color: rgba(200, 255, 0, 0.3); color: var(--accent); }
.toast.error { border-color: rgba(255, 59, 48, 0.3); color: var(--danger); }

/* ==========================================
   Desktop Layout
   ========================================== */
@media (min-width: 720px) {
  .header-inner { padding: 18px 32px; }
  .logo { font-size: 36px; }
  .date-display { font-size: 12px; }

  .content-wrapper {
    padding: 32px 32px;
    gap: 28px;
  }

  .stats-section {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
  }

  .calories-card {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 28px;
  }

  .macros-grid {
    flex: 1;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr;
  }

  .macro-card { padding: 20px 14px 18px; }
  .macro-value { font-size: 46px; }
  .calories-number { font-size: 96px; }

  .modal-overlay { align-items: center; }
  .modal-sheet {
    border-radius: var(--radius);
    max-height: 88vh;
    margin: 0 16px;
  }
  .modal-handle { display: none; }

  .search-input { padding: 14px 40px 14px 44px; }
  .scan-btn { width: 50px; height: 50px; }

  .food-entry { padding: 16px 18px; }
}

@media (min-width: 1024px) {
  .content-wrapper {
    max-width: 1100px;
    padding: 40px 48px;
    gap: 32px;
  }

  .calories-card { flex: 0 0 300px; padding: 40px 32px; }
  .calories-number { font-size: 110px; }
  .macro-value { font-size: 52px; }
  .macro-card { padding: 24px 16px 22px; }

  .logo { font-size: 40px; }
  .header-inner { padding: 20px 48px; }

  .section-title { font-size: 20px; }
}

/* ==========================================
   Scrollbars (webkit)
   ========================================== */
body::-webkit-scrollbar { width: 6px; }
body::-webkit-scrollbar-track { background: var(--bg); }
body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ==========================================
   Login / Register Overlay
   ========================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 8, 8, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.login-overlay.hidden { display: none; }

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.4rem;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--text-1);
}

.login-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  line-height: 1.45;
  animation: pulse-glow 2.6s ease-in-out infinite;
}

.login-heading.no-glow {
  color: var(--text-1);
  animation: none;
}

@keyframes pulse-glow {
  0%, 100% {
    text-shadow:
      0 0 8px rgba(200, 255, 0, 0.5),
      0 0 22px rgba(200, 255, 0, 0.25);
  }
  50% {
    text-shadow:
      0 0 18px rgba(200, 255, 0, 1),
      0 0 42px rgba(200, 255, 0, 0.6),
      0 0 72px rgba(200, 255, 0, 0.24);
  }
}

#loginForm, #registerForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-error {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.28);
  border-radius: var(--radius-xs);
  color: var(--danger);
  font-size: 0.83rem;
  padding: 10px 14px;
  text-align: center;
  line-height: 1.4;
}

.login-switch {
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-2);
  padding-top: 2px;
}

.login-switch-btn {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.login-switch-btn:hover { opacity: 0.75; }

/* ==========================================
   Account section in Settings
   ========================================== */
.account-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 2px;
}

.account-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-1);
}

.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.btn-logout {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.25);
  color: var(--danger);
  border-radius: var(--radius-xs);
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}

.btn-logout:hover { background: rgba(255, 59, 48, 0.2); }
