:root {
  /* Colors */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --header-gradient: linear-gradient(135deg, #7c3aed, #6366f1);
  --text-dark: #1f2937;
  --text-medium: #4b5563;
  --text-light: #6b7280;
  --bg-white: #fff;
  --bg-gray: #f9fafb;
  --bg-gray-alt: #f3f4f6;
  --border-light: #e5e7eb;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --success: #22c55e;
  --macro-p: #3b82f6;
  --macro-c: #22c55e;
  --macro-f: #f59e0b;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Border radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  /* Font sizes */
  --font-xs: 11px;
  --font-sm: 12px;
  --font-base: 13px;
  --font-md: 14px;
  --font-lg: 15px;
  --font-xl: 16px;
  --font-2xl: 18px;

  /* Layout */
  --header-height: 56px;
  --tabs-height: 50px;

  /* Badge colors */
  --badge-breakfast-bg: #fef3c7;
  --badge-breakfast-text: #b45309;
  --badge-lunch-bg: #d1fae5;
  --badge-lunch-text: #047857;
  --badge-dinner-bg: #dbeafe;
  --badge-dinner-text: #1e40af;
  --badge-snack-bg: #e9d5ff;
  --badge-snack-text: #7c3aed;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg-gray);
  overflow-x: hidden;
  font-size: var(--font-lg);
  line-height: 1.5;
  color: var(--text-dark);
}

body.modal-open {
  overflow: hidden;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg-gray);
  min-height: 100vh;
  min-height: 100dvh;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Header */
.header {
  padding: 12px 16px;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-gradient);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  height: var(--header-height);
}

.header h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}

.logo-icon {
  margin-right: 8px;
}

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

.info-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s;
}

.info-btn:hover {
  background: rgba(255, 255, 255, .35);
}

.info-btn:active {
  background: rgba(255, 255, 255, .45);
}

/* Sync Indicator */
.sync-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.3s;
}

.sync-indicator.synced {
  background: #22c55e;
}

.sync-indicator.syncing {
  background: #fbbf24;
  animation: pulse 1s ease-in-out infinite;
}

.sync-indicator.offline {
  background: #ef4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  height: var(--tabs-height);
}

.tab {
  flex: 1;
  padding: 14px 8px;
  font-size: var(--font-md);
  font-weight: 600;
  text-align: center;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s;
}

.tab:hover {
  color: var(--text-medium);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Content */
.content {
  padding: var(--spacing-sm);
  padding-bottom: 100px;
  touch-action: pan-y;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 8px 16px;
  font-size: var(--font-base);
  font-weight: 600;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-chip:hover {
  border-color: var(--primary-light);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-trash {
  margin-left: auto;
  padding: 8px 12px;
  font-size: 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-trash:hover {
  border-color: var(--danger);
  background: #fef2f2;
}

/* Meal Cards */
.meals-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.meal-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.meal-card:active {
  transform: scale(0.98);
}

.meal-card-header {
  padding: var(--spacing-md);
  cursor: pointer;
}

.meal-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-xs);
}

/* Unified type badge - used in both meals and plan tabs */
.type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-gray-alt);
  color: var(--text-light);
}

.type-badge.breakfast { background: var(--badge-breakfast-bg); color: var(--badge-breakfast-text); }
.type-badge.lunch { background: var(--badge-lunch-bg); color: var(--badge-lunch-text); }
.type-badge.dinner { background: var(--badge-dinner-bg); color: var(--badge-dinner-text); }
.type-badge.snack { background: var(--badge-snack-bg); color: var(--badge-snack-text); }

.meal-card-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.meal-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-gray);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-md);
  transition: background-color 0.2s;
}

.meal-action-icon:hover {
  background: var(--border-light);
}

.meal-action-icon.danger:hover {
  background: #fecaca;
}

.meal-card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
  margin-bottom: var(--spacing-sm);
}

.meal-card-ingredients {
  font-size: var(--font-base);
  color: var(--text-medium);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--spacing-sm);
}

.meal-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.meal-card-macros {
  font-size: var(--font-sm);
  font-family: "SF Mono", "Menlo", monospace;
  font-weight: 600;
}

.macro-p { color: var(--macro-p); }
.macro-c { color: var(--macro-c); }
.macro-f { color: var(--macro-f); }

.add-to-plan-btn {
  padding: 8px 16px;
  font-size: var(--font-base);
  font-weight: 600;
  border-radius: var(--radius-xl);
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s;
}

.add-to-plan-btn:hover {
  background: var(--primary-dark);
}

.add-to-plan-btn:disabled {
  background: var(--bg-gray-alt);
  color: var(--text-light);
  cursor: not-allowed;
}

/* Add Meal Button */
.add-meal-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 30;
}

.add-meal-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.add-meal-fab:active {
  transform: scale(0.95);
}

/* Meal Plan View */
.plan-empty {
  text-align: center;
  padding: var(--spacing-lg) * 2;
  color: var(--text-light);
}

.plan-empty-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
}

.plan-empty-text {
  font-size: 16px;
  margin-bottom: var(--spacing-sm);
}

.plan-empty-hint {
  font-size: var(--font-md);
}

.plan-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.plan-card-header {
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  background: #eef1f5;
}

.plan-card-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fecaca;
  color: #991b1b;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.plan-card-remove:hover {
  background: #fca5a5;
}

.plan-card-name {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.plan-card-footer {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-white);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* .plan-card-type removed - use unified .type-badge class instead */

.servings-control {
  display: flex;
  align-items: center;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.servings-wrapper {
  display: flex;
  align-items: center;
}

.servings-label {
  font-size: var(--font-base);
  color: var(--text-medium);
  margin-right: var(--spacing-sm);
}

.servings-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-gray-alt);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: background-color 0.2s;
}

.servings-btn:hover {
  background: var(--border-light);
}

.servings-btn:active {
  background: #d1d5db;
}

.servings-btn:disabled {
  color: var(--text-light);
  cursor: not-allowed;
}

.servings-value {
  width: 40px;
  text-align: center;
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-dark);
}


/* Shopping View */
.shop-sticky-header {
  position: sticky;
  top: calc(var(--header-height) + var(--tabs-height));
  z-index: 35;
  background: var(--bg-white);
  padding: var(--spacing-sm) var(--spacing-md);
  margin: calc(-1 * var(--spacing-sm));
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

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

.shop-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.cart-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-gray-alt);
  color: var(--text-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.cart-btn:hover {
  background: var(--border-light);
}

.cart-count {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.shop-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
}

.shop-info-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-gray-alt);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  flex-shrink: 0;
  font-weight: 600;
}

.shop-info-text {
  font-size: var(--font-sm);
  color: var(--text-light);
}

.shop-empty {
  text-align: center;
  padding: var(--spacing-lg) * 2;
  color: var(--text-light);
}

.shop-category {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
}

.shop-category h4 {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-gray);
}

.shop-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--bg-gray);
  cursor: pointer;
  gap: var(--spacing-sm);
  transition: background-color 0.2s;
}

.shop-item:last-child {
  border: none;
}

.shop-item:hover {
  background: var(--bg-gray);
}

.shop-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  font-size: var(--font-sm);
  color: transparent;
}

.shop-item.checked .shop-check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.shop-item-name {
  flex: 1;
  font-size: var(--font-md);
  color: var(--text-dark);
}

.shop-item-qty {
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text-light);
  font-family: "SF Mono", "Menlo", monospace;
  text-align: right;
  min-width: 50px;
}

.shop-item-macros {
  font-size: 11px;
  color: var(--text-light);
  font-family: "SF Mono", "Menlo", monospace;
}

.shop-item-info {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-gray-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-light);
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s;
}

.shop-item-info:hover {
  background: var(--border-light);
}

.shop-item.checked .shop-item-name,
.shop-item.checked .shop-item-qty {
  text-decoration: line-through;
  color: var(--text-light);
}

/* Items in someone else's cart */
.shop-item.others .shop-check {
  background: var(--text-light);
  border-color: var(--text-light);
  color: #fff;
}

.shop-item.others .shop-item-name,
.shop-item.others .shop-item-qty {
  text-decoration: line-through;
  color: #9ca3af;
}

.shop-item-owner {
  display: block;
  font-size: var(--font-xs);
  color: #9ca3af;
  font-weight: normal;
  text-decoration: none;
  margin-top: 2px;
}

/* Button loading states */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin-top: -7px;
  margin-left: -7px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.shop-item-not-found {
  font-size: 10px;
  color: var(--danger);
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

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

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

.modal-close {
  font-size: 28px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-dark);
}

/* Meal Form Modal */
.meal-form-modal {
  max-height: 95vh;
}

.meal-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.form-group label {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: var(--font-lg);
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-hint {
  font-size: var(--font-sm);
  color: var(--text-light);
}

/* Ingredient Search */
.ingredient-search-container {
  position: relative;
}

.ingredient-search {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: var(--font-lg);
  font-family: inherit;
  transition: border-color 0.2s;
}

.ingredient-search:focus {
  outline: none;
  border-color: var(--primary);
}

.ingredient-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.ingredient-dropdown.open {
  display: block;
}

.ingredient-option {
  padding: 10px 12px;
  cursor: pointer;
  font-size: var(--font-md);
  transition: background-color 0.15s;
}

.ingredient-option:hover {
  background: var(--bg-gray);
}

.ingredient-option.add-new {
  color: var(--primary);
  font-weight: 600;
  border-top: 1px solid var(--border-light);
}

.ingredient-no-results {
  padding: 10px 12px;
  color: var(--text-light);
  font-size: var(--font-md);
}

/* Text button (for "Look up nutrition") */
.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: var(--font-md);
  cursor: pointer;
  padding: 4px 8px;
}
.btn-text:hover {
  text-decoration: underline;
}
.btn-text:disabled {
  color: var(--text-light);
  cursor: default;
  text-decoration: none;
}

/* Open Food Facts results */
.off-results {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-md);
}
.off-result {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
}
.off-result:last-child {
  border-bottom: none;
}
.off-result:hover {
  background: var(--bg-gray);
}
.off-result-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}
.off-result-macros {
  font-size: var(--font-sm);
  color: var(--text-light);
  white-space: nowrap;
}
.off-no-results {
  padding: 12px;
  color: var(--text-light);
  text-align: center;
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.ingredient-line {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 4px var(--spacing-sm);
  background: var(--bg-gray);
  border-radius: var(--radius-sm);
}

.ingredient-line-name {
  flex: 1;
  font-size: var(--font-md);
  font-weight: 500;
  color: var(--text-dark);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ingredient-line-amount {
  width: 75px;
  padding: 1px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: var(--font-md);
  text-align: center;
  background: var(--bg-white);
}

.ingredient-line-amount:focus {
  outline: none;
  border-color: var(--primary);
}

.ingredient-line-unit {
  width: 70px;
  padding: 1px 4px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  background: var(--bg-white);
  cursor: pointer;
}

.ingredient-line-unit:focus {
  outline: none;
  border-color: var(--primary);
}

.ingredient-line-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-light);
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background-color 0.15s;
}

.ingredient-line-remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

.form-row {
  display: flex;
  gap: var(--spacing-sm);
}

.form-row .form-group {
  flex: 1;
  min-width: 0;
}

.label-hint {
  font-weight: 400;
  color: var(--text-light);
  font-size: 11px;
}

.recipe-editor {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  padding: var(--spacing-xs) 0;
}

.recipe-step {
  display: flex;
  align-items: center;
  padding: 2px var(--spacing-sm);
}

.recipe-step-num {
  color: var(--text-light);
  font-size: var(--font-md);
  width: 24px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 6px;
  user-select: none;
}

.recipe-step-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--font-lg);
  font-family: inherit;
  padding: 8px 4px;
  background: transparent;
}

.recipe-step-input::placeholder {
  color: var(--text-light);
  opacity: 0.6;
}

.recipe-step-placeholder {
  opacity: 0.7;
}

.recipe-step-num-placeholder {
  color: var(--primary);
  font-weight: 600;
}

.recipe-step-input-placeholder {
  font-style: italic;
}

.recipe-step-input-placeholder::placeholder {
  color: var(--text-light);
  font-style: italic;
}

/* Disabled save button */
.btn-primary.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary.btn-disabled:hover {
  transform: none;
}

/* Required field hints */
.required-hints {
  margin-bottom: var(--spacing-sm);
}

.required-hint {
  font-size: var(--font-sm);
  color: #dc2626;
  margin-bottom: 2px;
}

.form-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.btn-primary {
  flex: 1;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-lg);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  flex: 1;
  padding: 14px;
  background: var(--bg-gray-alt);
  color: var(--text-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-lg);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-danger {
  flex: 1;
  padding: 14px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-lg);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-delete-meal {
  width: 100%;
  margin-top: var(--spacing-lg);
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  padding-top: var(--spacing-md);
  padding-bottom: var(--spacing-md);
}

/* Confirm Modal */
.confirm-modal {
  max-width: 380px;
}

.confirm-text {
  font-size: var(--font-lg);
  line-height: 1.6;
  margin-bottom: var(--spacing-sm);
}

.confirm-subtext {
  font-size: var(--font-base);
  color: var(--text-light);
  margin-bottom: var(--spacing-lg);
}

.confirm-actions {
  display: flex;
  gap: var(--spacing-sm);
}

/* Cart Modal */
.cart-modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.cart-list {
  margin-bottom: var(--spacing-md);
}

.cart-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--bg-gray);
  gap: var(--spacing-sm);
}

.cart-item:last-child {
  border: none;
}

.cart-item-delete {
  width: 28px;
  height: 28px;
  background: #fecaca;
  color: #991b1b;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.cart-item-delete:hover {
  background: #fca5a5;
}

.cart-item-name {
  flex: 1;
  font-size: var(--font-md);
  font-weight: 500;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.cart-qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-light);
  background: var(--bg-gray);
  color: var(--text-dark);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.cart-qty-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.cart-qty-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.cart-qty-btn:hover {
  background: var(--border-light);
}

.cart-item-qty {
  width: 70px;
  padding: 6px 4px;
  border: 1px solid var(--border-light);
  border-left: none;
  border-right: none;
  font-size: var(--font-base);
  font-weight: 600;
  text-align: center;
  color: var(--text-dark);
  font-family: "SF Mono", "Menlo", monospace;
}

.cart-item-qty:focus {
  outline: none;
  background: var(--bg-gray);
}

.cart-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.cart-copy-btn {
  flex: 1;
  padding: 12px;
  background: var(--text-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-md);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.cart-copy-btn:hover {
  opacity: .9;
}

.cart-empty {
  text-align: center;
  padding: var(--spacing-lg);
  color: var(--text-light);
}

/* Ingredient Modal */
.ingredient-popup {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  max-width: 320px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.ingredient-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.ingredient-popup h4 {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.ingredient-popup-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.ingredient-popup-close:hover {
  color: var(--text-dark);
}

.ingredient-popup-subheading {
  font-size: var(--font-sm);
  color: var(--text-light);
  margin-bottom: var(--spacing-xs);
}

.ingredient-popup-list {
  font-size: var(--font-base);
  color: var(--text-medium);
  margin-bottom: var(--spacing-sm);
}

.ingredient-popup-item {
  padding: 4px 0 4px 8px;
}

.ingredient-macros {
  font-size: var(--font-sm);
  font-family: "SF Mono", "Menlo", monospace;
  padding: var(--spacing-sm);
  background: var(--bg-gray);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-sm);
}

.btn-edit-ingredient {
  width: 100%;
  padding: 10px;
  background: var(--bg-gray-alt);
  color: var(--text-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-edit-ingredient:hover {
  background: var(--border-light);
}

.ingredient-edit-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: var(--spacing-xs);
}

/* Meal Detail Modal */
.meal-detail-modal {
  max-height: 90vh;
}

.meal-detail-section {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--border-light);
}

.meal-detail-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.meal-detail-section h4 {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: var(--spacing-sm);
}

.meal-detail-section p,
.meal-detail-section li {
  font-size: var(--font-md);
  color: var(--text-medium);
  line-height: 1.7;
}

.meal-detail-section ol {
  padding-left: 20px;
  margin: 0;
}

.meal-detail-section ol li {
  margin-bottom: var(--spacing-xs);
}

.meal-detail-macros {
  display: flex;
  gap: var(--spacing-md);
  font-size: var(--font-md);
  font-family: "SF Mono", "Menlo", monospace;
  font-weight: 600;
}

.scaled-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: #dbeafe;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.meal-detail-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

/* Deleted Meals */
.deleted-empty {
  text-align: center;
  padding: var(--spacing-lg);
  color: var(--text-light);
}

.restore-btn {
  padding: 8px 16px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.restore-btn:hover {
  opacity: 0.9;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-dark);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: var(--font-md);
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.toast-undo {
  margin-left: var(--spacing-sm);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-weight: 600;
}

.toast-undo:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Loading */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, .8);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Swipe drag effect */
#meals-view,
#plan-view,
#shop-view {
  will-change: transform, opacity;
}

/* Tab transition animation */
@keyframes slideInFromRight {
  from {
    transform: translateX(50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.tab-animate-right {
  animation: slideInFromRight 0.2s ease-out;
}

.tab-animate-left {
  animation: slideInFromLeft 0.2s ease-out;
}

/* Legacy swipe indicators (hidden, kept for compatibility) */
.swipe-indicator {
  display: none;
}

/* Responsive */
@media (max-width: 400px) {
  .header h1 {
    font-size: 18px;
  }

  .tab {
    font-size: var(--font-base);
    padding: 12px 4px;
  }

  .meal-card-name {
    font-size: var(--font-lg);
  }

  .add-meal-fab {
    width: 48px;
    height: 48px;
    font-size: 24px;
    bottom: 16px;
    right: 16px;
  }
}

/* Tighten macro inputs on small screens */
@media (max-width: 480px) {
  .meal-form .form-row {
    gap: var(--spacing-xs);
  }

  .meal-form .form-row .form-group input {
    padding: 10px 8px;
  }
}

/* Info Modal */
.info-modal {
  max-height: 85vh;
  overflow-y: auto;
}

.info-content {
  padding: var(--spacing-md);
}

.info-section {
  margin-bottom: var(--spacing-lg);
}

.info-section h3 {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.info-section li {
  padding: 6px 0;
  font-size: var(--font-md);
  color: var(--text-medium);
  line-height: 1.5;
}

.info-section li strong {
  color: var(--text-dark);
}

.info-section li .sync-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.info-section-footer {
  border-top: 1px solid var(--border-light);
  padding-top: var(--spacing-md);
  text-align: center;
}

.info-hint {
  font-size: var(--font-sm);
  color: var(--text-light);
  margin-top: var(--spacing-xs);
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: var(--font-md);
  cursor: pointer;
  padding: var(--spacing-sm) var(--spacing-md);
}

.btn-text-danger:hover {
  text-decoration: underline;
}

/* Welcome Modal - CUSTOMIZATION: Modify styles here */
.welcome-modal {
  max-width: 340px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.welcome-header {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  padding: var(--spacing-lg);
}

.welcome-header .modal-title {
  font-size: var(--font-xl);
}

.welcome-content {
  padding: var(--spacing-lg);
  text-align: center;
}

.welcome-text {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: var(--spacing-xs);
}

.welcome-hint {
  font-size: var(--font-sm);
  color: var(--text-light);
  margin-bottom: var(--spacing-md);
  line-height: 1.4;
}

.welcome-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  text-align: center;
  transition: border-color 0.2s;
}

.welcome-input:focus {
  outline: none;
  border-color: var(--primary);
}

.welcome-input::placeholder {
  color: #9ca3af;
}

.welcome-btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-md);
  margin-bottom: var(--spacing-sm);
}

.welcome-skip {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: var(--font-sm);
  cursor: pointer;
  padding: var(--spacing-xs);
}

.welcome-skip:hover {
  color: var(--text-medium);
  text-decoration: underline;
}

/* Sync dots for info modal */
.sync-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.synced {
  background: #22c55e;
}

.sync-dot.syncing {
  background: #fbbf24;
}

.sync-dot.offline {
  background: #ef4444;
}

@media (max-width: 400px) {
  .info-content {
    padding: var(--spacing-sm);
  }

  .info-section h3 {
    font-size: var(--font-base);
  }

  .info-section li {
    font-size: var(--font-base);
  }
}
