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

:root {
  /* New design system */
  --bg-primary: #FAF8F5;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #7A7A7A;
  --text-tertiary: #ABABAB;
  --accent: #E8603C;
  --accent-soft: rgba(232,96,60,0.10);
  --accent-glow: rgba(232,96,60,0.22);
  --success: #2DB55D;
  --success-bg: #F0FDF4;
  --success-text: #16A34A;
  --error-bg: #FEF2F2;
  --error-text: #DC2626;
  --border: rgba(0,0,0,0.07);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  /* Back-compat aliases so JS-generated HTML still resolves */
  --primary: var(--accent);
  --primary-light: var(--accent-soft);
  --primary-glow: var(--accent-glow);
  --bg: var(--bg-primary);
  --card: var(--bg-surface);
  --text: var(--text-primary);
  --text-2: var(--text-secondary);
  --text-3: var(--text-tertiary);
  --radius: var(--radius-md);
}

html, body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ========================
   Recipe Screen Header
   ======================== */
.recipe-screen-header {
  padding: max(16px, env(safe-area-inset-top)) 20px 0;
  max-width: 480px;
  margin: 0 auto;
}

.header-logo-area {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 0 6px;
}

.logo-text {
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-greeting {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ========================
   Main
   ======================== */
.main {
  padding: 8px 20px 100px;
  max-width: 480px;
  margin: 0 auto;
}

/* ========================
   Input Search Bar
   ======================== */
.input-area {
  margin-bottom: 14px;
}

.input-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 5px 5px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.autocomplete-wrapper {
  flex: 1;
  position: relative;
}

.main-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  padding: 8px 0;
}

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

.input-add-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-add-btn:active { transform: scale(0.88); }

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: -16px;
  right: -8px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 50;
}

.autocomplete-item {
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.autocomplete-item:active,
.autocomplete-item:hover { background: var(--bg-primary); }

.autocomplete-item + .autocomplete-item { border-top: 1px solid var(--border); }

/* Selected Pills */
.selected-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.selected-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 12px 8px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  animation: chipSpringIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
  transition: transform 0.1s;
  overflow: hidden;
}

.selected-pill:active { transform: scale(0.95); }

.selected-pill .remove-x {
  font-size: 11px;
  opacity: 0.7;
  line-height: 1;
  flex-shrink: 0;
}

@keyframes chipSpringIn {
  from { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes chipShrinkOut {
  from { transform: scale(1); opacity: 1; max-width: 200px; padding-left: 14px; padding-right: 12px; }
  to   { transform: scale(0.3); opacity: 0; max-width: 0; padding: 8px 0; }
}

.selected-pill.removing {
  animation: chipShrinkOut 0.22s cubic-bezier(0.25,0.1,0.25,1) both;
  pointer-events: none;
}

/* ========================
   Quick-add Row
   ======================== */
.quick-add-section {
  margin-bottom: 16px;
}

.quick-add-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.quick-add-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.quick-add-scroll::-webkit-scrollbar { display: none; }

.quick-add-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.25,0.1,0.25,1);
}

.quick-add-chip:active {
  transform: scale(0.92);
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================
   Controls Row
   ======================== */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ingredient-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 7px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-toggle-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-badge {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* ========================
   Mode Pill Slider
   ======================== */
.mode-pill-track {
  position: relative;
  display: flex;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: 8px;
}

.mode-pill-slider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: var(--accent);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: left 0.28s cubic-bezier(0.25,0.1,0.25,1), width 0.28s cubic-bezier(0.25,0.1,0.25,1);
  pointer-events: none;
  z-index: 0;
}

.mode-pill-btn {
  flex: 1;
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  border-radius: var(--radius-full);
  padding: 9px 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
  text-align: center;
}

.mode-pill-btn.active { color: #fff; }

.mode-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  line-height: 1.4;
  min-height: 16px;
}

/* ========================
   Collapsible Filter Panel
   ======================== */
.filter-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s cubic-bezier(0.25,0.1,0.25,1);
}

.filter-panel.open {
  max-height: 700px;
  margin-bottom: 14px;
}

.filter-panel-inner {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* ========================
   Panel Utilities
   ======================== */
.panel-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.panel-label-gap { margin-top: 14px; }

.panel-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.4;
}

/* Toggle Group (Time Flex) */
.toggle-group {
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.toggle-btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Chip Group (Cook Time / Cuisine) */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Cuisine Filter */
.cuisine-row { display: flex; flex-direction: column; gap: 8px; }

.cuisine-custom-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.cuisine-custom-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.cuisine-custom-input::placeholder { color: var(--text-tertiary); }

/* Range */
.range-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--accent-glow);
}

.range-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 24px;
  text-align: center;
}

/* ========================
   Picker Section
   ======================== */
.picker-section {
  margin-bottom: 20px;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.picker-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.filter-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: #FEF3C7;
  border-color: #F59E0B;
  color: #B45309;
}

.picker-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.picker-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.picker-pill:active { transform: scale(0.95); }

.picker-pill.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.picker-pill .fav-star {
  font-size: 11px;
  color: #D6D3D1;
  cursor: pointer;
  padding: 2px;
  transition: color 0.15s;
  line-height: 1;
}

.picker-pill .fav-star.favorited { color: #F59E0B; }

.picker-pill .use-count {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-left: 1px;
}

.show-more-btn {
  display: block;
  margin-top: 10px;
  background: none;
  border: none;
  padding: 6px 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

/* ========================
   Search Button
   ======================== */
.search-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 17px;
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.2px;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s, box-shadow 0.2s;
}

.search-btn:active { transform: scale(0.97); box-shadow: 0 2px 10px var(--accent-glow); }
.search-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Error */
.error-box {
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.error-box p {
  color: var(--error-text);
  font-size: 14px;
  font-weight: 500;
}

/* Cached Banner */
.cached-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.cached-badge {
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cached-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Filtered Info */
.filtered-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filtered-badge {
  background: #FEF3C7;
  color: #B45309;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filtered-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ========================
   Recipe List (Vertical)
   ======================== */
.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 8px;
}

.recipe-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s cubic-bezier(0.25,0.1,0.25,1), box-shadow 0.15s;
  animation: cardFadeIn 0.3s cubic-bezier(0.25,0.1,0.25,1) both;
}

.recipe-card:active {
  transform: scale(0.984);
  box-shadow: var(--shadow-sm);
}

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

/* Staggered entrance */
.recipe-card:nth-child(2) { animation-delay: 0.06s; }
.recipe-card:nth-child(3) { animation-delay: 0.12s; }
.recipe-card:nth-child(4) { animation-delay: 0.18s; }
.recipe-card:nth-child(5) { animation-delay: 0.22s; }

.recipe-card-visual {
  position: relative;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  user-select: none;
  overflow: hidden;
}

/* Cuisine-based gradients */
.cuisine-italian     { background: linear-gradient(135deg, #FFF0E8, #FFD4B8); }
.cuisine-asian       { background: linear-gradient(135deg, #E8F8F0, #B8EDD4); }
.cuisine-mexican     { background: linear-gradient(135deg, #FFFBE8, #FFE8A8); }
.cuisine-american    { background: linear-gradient(135deg, #E8F0FF, #B8D0FF); }
.cuisine-mediterranean { background: linear-gradient(135deg, #EBF8FF, #B8E4FF); }
.cuisine-indian      { background: linear-gradient(135deg, #FFF5E8, #FFD8A0); }
.cuisine-french      { background: linear-gradient(135deg, #F8E8FF, #E0B8FF); }
.cuisine-middle-eastern { background: linear-gradient(135deg, #FFF8E0, #FFECAA); }
.cuisine-default     { background: linear-gradient(135deg, rgba(232,96,60,0.08), rgba(232,96,60,0.18)); }

.recipe-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.88);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #D6D3D1;
  transition: color 0.15s, transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-sm);
}

.recipe-card-fav.favorited { color: #F59E0B; }
.recipe-card-fav:active { transform: scale(1.28); }

.recipe-card-body {
  padding: 16px 18px 18px;
}

.recipe-name {
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.3px;
  margin-bottom: 5px;
}

.recipe-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 14px;
}

.cook-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.recipe-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: capitalize;
  letter-spacing: 0.2px;
}

.badge-cuisine { background: #EFF6FF; color: #2563EB; }
.badge-easy { background: var(--success-bg); color: var(--success-text); }
.badge-medium { background: #FEF3C7; color: #B45309; }
.badge-hard { background: var(--error-bg); color: var(--error-text); }

.recipe-match-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: auto;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 4px;
}

.list-item {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  padding-left: 4px;
}

.unused-ingredients {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
  font-style: italic;
}

.recipe-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.tiktok-btn {
  flex: 1;
  background: #010101;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.tiktok-btn:active { opacity: 0.8; }

/* Old carousel stubs: always off */
#carouselWrapper, #carouselTrack, #carouselDots, #carouselPullHint {
  display: none !important;
}

/* ========================
   More CTA
   ======================== */
.more-cta {
  text-align: center;
  padding: 24px 0 10px;
}

.more-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Primary Button (shared) */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px var(--accent-glow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.more-btn { width: auto; display: inline-flex; }

/* ========================
   Empty State
   ======================== */
.empty-state {
  text-align: center;
  padding-top: 40px;
}

.empty-emoji {
  font-size: 52px;
  margin-bottom: 14px;
  line-height: 1;
}

.empty-text {
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ========================
   Tab Views
   ======================== */
.tab-views { position: relative; }

.tab-view { display: none; }

.tab-view.active {
  display: block;
  animation: tabFadeIn 0.22s cubic-bezier(0.25,0.1,0.25,1) both;
}

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

/* ========================
   Bottom Navigation
   ======================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 5px 14px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 0.2s;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.nav-tab.active { color: var(--accent); }

.nav-tab svg { width: 22px; height: 22px; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ========================
   View Content (Fridge & Shopping & Settings)
   ======================== */
.view-content {
  padding: 0 20px 160px;
  padding-top: max(16px, env(safe-area-inset-top));
  max-width: 480px;
  margin: 0 auto;
}

.view-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-top: 10px;
}

.view-title {
  font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
  display: block;
  margin-top: 3px;
}

/* View Empty State */
.view-empty-state {
  text-align: center;
  padding: 56px 0;
}

/* Item Count Badge */
.item-count-badge {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* View Action Button */
.view-action-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
}

.view-action-btn:active { opacity: 0.85; transform: scale(0.97); }

/* ========================
   Inventory Grid (Fridge)
   ======================== */
.inventory-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.item-tile {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  cursor: pointer;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.15s;
  min-height: 80px;
  user-select: none;
}

.item-tile:active,
.item-tile.long-pressing {
  transform: scale(0.94);
  box-shadow: none;
}

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

.item-tile.removing {
  animation: slideOutRight 0.28s cubic-bezier(0.25,0.1,0.25,1) forwards;
}

.tile-emoji { font-size: 26px; line-height: 1; }

.tile-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}

.tile-action {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 16px;
  color: var(--text-tertiary);
}

/* ========================
   Shopping Categories
   ======================== */
.shopping-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  margin-bottom: 4px;
  box-shadow: var(--shadow-sm);
}

.category-header.collapsed { margin-bottom: 0; }

.category-icon { font-size: 18px; line-height: 1; }

.category-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.category-count {
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.category-arrow {
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.25s cubic-bezier(0.25,0.1,0.25,1);
}

.category-header.collapsed .category-arrow { transform: rotate(-90deg); }

.category-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s cubic-bezier(0.25,0.1,0.25,1);
}

.category-items.collapsed { max-height: 0 !important; }

/* ========================
   Bottom Fixed Inputs
   ======================== */
.view-bottom-input {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(250,248,245,0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bottom-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 12px 18px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bottom-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.bottom-add-btn {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
}

.bottom-add-btn:active { transform: scale(0.88); }

/* Shopping Input Area */
.shopping-input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: rgba(250,248,245,0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.shopping-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* Recent Items Panel */
.recent-items-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.25,0.1,0.25,1);
}

.recent-items-panel.visible { max-height: 140px; }

.recent-items-header { padding: 10px 20px 4px; }

.recent-items-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.recent-items-list {
  display: flex;
  gap: 8px;
  padding: 6px 20px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.recent-items-list::-webkit-scrollbar { display: none; }

.recent-item-chip {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}

.recent-item-chip:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================
   View Mode Toggle
   ======================== */
.view-mode-toggle {
  display: inline-flex;
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.view-mode-btn {
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.15s;
  padding: 0;
}

.view-mode-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.view-mode-btn:active { transform: scale(0.92); }

/* View Mode Variants (Fridge) */
.inventory-grid.view-list { grid-template-columns: 1fr; }
.inventory-grid.view-list .item-tile { flex-direction: row; align-items: center; text-align: left; padding: 12px 14px; gap: 10px; }
.inventory-grid.view-list .tile-emoji { font-size: 22px; }
.inventory-grid.view-list .tile-name { font-size: 15px; }
.inventory-grid.view-list .tile-action { position: static; font-size: 18px; color: var(--text-tertiary); }

.inventory-grid.view-tile { grid-template-columns: 1fr 1fr; }

.inventory-grid.view-grid { grid-template-columns: 1fr 1fr 1fr; }
.inventory-grid.view-grid .item-tile { padding: 10px 4px; gap: 4px; }
.inventory-grid.view-grid .tile-emoji { font-size: 22px; }
.inventory-grid.view-grid .tile-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.inventory-grid.view-grid .tile-action { position: absolute; top: 2px; right: 4px; font-size: 12px; }

/* Shopping view mode variants */
.category-items.view-list { display: flex; flex-direction: column; }
.category-items.view-list .item-tile { flex-direction: row; align-items: center; text-align: left; padding: 12px 14px; gap: 10px; }

.category-items.view-tile { display: grid; grid-template-columns: 1fr 1fr; }
.category-items.view-tile .item-tile { flex-direction: column; align-items: center; text-align: center; padding: 14px 8px; gap: 6px; }
.category-items.view-tile .tile-emoji { font-size: 26px; }
.category-items.view-tile .tile-name { font-size: 13px; font-weight: 600; }

.category-items.view-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.category-items.view-grid .item-tile { padding: 10px 4px; gap: 4px; }
.category-items.view-grid .tile-emoji { font-size: 22px; }
.category-items.view-grid .tile-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ========================
   Action Menu
   ======================== */
.action-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.action-menu {
  position: fixed;
  z-index: 310;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: menuScaleIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes menuScaleIn {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.action-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.action-menu-item:active { background: var(--bg-primary); }
.action-menu-item + .action-menu-item { border-top: 1px solid var(--border); }
.action-menu-item.destructive { color: var(--error-text); }

.action-menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/* ========================
   Settings Tab
   ======================== */
.settings-content { padding-bottom: 100px; }

.settings-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 20px 0 8px;
  display: block;
}

.settings-group {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 52px;
}

.settings-row + .settings-row { border-top: 1px solid var(--border); }

.settings-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 16px;
}

.settings-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-row-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.settings-row-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.settings-row-value {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: auto;
  text-align: right;
}

.settings-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.settings-key-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'Plus Jakarta Sans', monospace;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-key-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.settings-key-input::placeholder { color: var(--text-tertiary); }

/* ========================
   Fridge item count in header
   ======================== */
#fridgeItemCount { font-size: 13px; color: var(--text-tertiary); }
