/* === Design System === */
:root {
  --bg: #FAF7F2;
  --bg-card: #FFFFFF;
  --text: #2D2A26;
  --text-light: #6B6560;
  --accent: #C1694F;
  --accent-hover: #A8553D;
  --accent-secondary: #7A8B6F;
  --accent-secondary-hover: #647355;
  --border: #E5E0D8;
  --shadow: 0 2px 8px rgba(45,42,38,0.08);
  --shadow-lg: 0 4px 16px rgba(45,42,38,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', -apple-system, sans-serif;
  --nav-height: 56px;
  --bottom-nav-height: 64px;
  /* Sticky stacking for meal-plan overview.
     --mp-sticky-base matches top-nav height (always visible).
     --mp-toolbar-h is measured by JS to account for safe-area. */
  --mp-sticky-base: var(--nav-height);
  --mp-toolbar-h: 44px;
  /* Month sticks directly below toolbar (year is in toolbar now) */
  --mp-month-top: calc(var(--mp-sticky-base) + var(--mp-toolbar-h));
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; height: 100%; overflow: hidden; touch-action: manipulation; }
@media (min-width: 640px) { html { font-size: 18px; } }
@media (min-width: 1200px) { html { font-size: 19px; } }
html, body { overscroll-behavior: none; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg)
    url("data:image/svg+xml,%3Csvg width='8' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M-2 2l4-4M0 8l8-8M6 10l4-4' stroke='%23A09889' stroke-opacity='0.074' stroke-width='1'/%3E%3C/svg%3E");
  line-height: 1.6;
  height: 100%;
  overflow-y: auto;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; line-height: 1.3; }

/* === Top Nav === */
.top-nav {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 0px) 24px 0;
  height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  align-items: center;
  justify-content: center;
}
.nav-dashboard-link {
  position: absolute;
  left: 24px;
  display: flex;
  align-items: center;
  color: var(--text-muted, #888);
  transition: color 0.15s;
}
.nav-dashboard-link:hover { color: var(--accent); }
.nav-dashboard-link[style*="display"] + .nav-brand { left: 24px; }
.nav-brand {
  position: absolute;
  left: 52px;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.brand-break { display: inline; }
.nav-links { display: none; gap: 24px; }
.nav-user-avatar { display: none; }
@media (min-width: 640px) {
  .nav-links { display: flex; }
  .nav-user-avatar { display: block; }
  .brand-break { display: none; }
}
.nav-links a {
  color: var(--text-light);
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* On mobile meal-plan, top nav scrolls away (bottom nav handles navigation) */
@media (max-width: 639px) {
  .route-meal-plan .top-nav {
    position: relative;
  }
  .route-meal-plan {
    --mp-sticky-base: 0px;
    --mp-month-top: var(--mp-toolbar-h);
  }
}

/* === Bottom Nav === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  transition: color 0.2s;
}
.bottom-nav a:hover, .bottom-nav a.active { color: var(--accent); }

/* === Pull to Refresh === */
.ptr-indicator {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}
.ptr-indicator.visible {
  opacity: 1;
}
.ptr-indicator.refreshing {
  transform: translateX(-50%) translateY(12px);
  opacity: 1;
}
.ptr-indicator svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}
.ptr-indicator.refreshing svg {
  animation: ptr-spin 0.6s linear infinite;
}
@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

/* === Main Content === */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

/* === Cards === */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.recipe-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.2s, background 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.recipe-card:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.03);
  z-index: 2;
}
.recipe-card:active {
  transform: scale(0.98);
}
.recipe-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.card-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(145deg, #E8E3DB 0%, #D4CFC7 50%, #C7BFB4 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-light);
  font-size: 2.2rem;
  position: relative;
  overflow: hidden;
}
.card-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(255,255,255,0.3) 0%, transparent 60%);
  pointer-events: none;
}
.card-placeholder-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8A837A;
  max-width: 80%;
  text-align: center;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* PDF dropzone */
.pdf-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pdf-dropzone:hover {
  border-color: var(--accent);
  background: rgba(193, 105, 79, 0.04);
}
.pdf-dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(193, 105, 79, 0.08);
}
.pdf-filename {
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}
/* Recipe hero placeholder (add image) */
.recipe-hero-placeholder {
  width: 100%;
  height: 220px;
  background: linear-gradient(135deg, var(--border) 0%, #D4CFC7 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-light);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.recipe-hero-placeholder:hover {
  background: linear-gradient(135deg, #D4CFC7 0%, var(--border) 100%);
  color: var(--accent);
}
.recipe-hero-placeholder span:first-child {
  font-size: 2rem;
}
.add-image-picker {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px 16px;
  height: auto;
  min-height: 160px;
  cursor: default;
}
.add-image-picker:hover { background: linear-gradient(135deg, var(--border) 0%, #D4CFC7 100%); color: var(--text-light); }
.add-image-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}
.add-image-option:hover { border-color: var(--accent); color: var(--accent); }
.add-image-icon { font-size: 1.8rem; }
.add-image-url-row {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-image-url-row .form-input { flex: 1; }

.card-body {
  padding: 12px 16px 16px;
}
.card-body h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.card-meta span { display: flex; align-items: center; gap: 4px; }

/* === Star ratings === */
.star { font-size: 1rem; line-height: 1; }
.star.full { color: #E8A838; }
.star.half { color: #E8A838; opacity: 0.6; }
.star.empty { color: var(--border); }
.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.85rem;
}
.rating-badge .star { font-size: 0.85rem; }
.rating-num { font-weight: 600; margin-left: 2px; color: var(--text); }
.rating-count { color: var(--text-light); font-size: 0.8rem; margin-left: 1px; }
.recipe-ratings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rating-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  min-width: 80px;
}
.star-picker .star {
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.1s, color 0.1s;
}
.star-picker .star:hover {
  transform: scale(1.2);
}
.star-picker .star.preview {
  color: #E8A838;
}
.rating-clear {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  text-decoration: underline;
}
.rating-clear:hover { color: var(--accent); }

/* Card action buttons — always visible, stacked vertically in top-right.
   .card-actions positions the group; .card-action-btn styles each circle. */
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.card-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
  line-height: 1;
}
.card-action-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}
.card-action-btn:active {
  transform: scale(0.95);
}
.card-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  margin-top: 4px;
}
.card-rating-star { color: #E8A838; }
.card-rating-count { opacity: 0.8; font-size: 0.7rem; }
.card-private-badge { font-size: 0.7rem; margin-right: 4px; opacity: 0.6; }
.rating-adjusted { color: var(--text-light); font-size: 0.78rem; margin-left: 6px; }

/* === Tag Chips === */
.tag-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}
.tag-chip:hover { opacity: 0.85; transform: scale(1.05); }
.tag-chip { transition: opacity 0.15s, transform 0.15s; }
.tag-chip[data-type="protein"] { background: #F3D5C0; color: #8B4513; }
.tag-chip[data-type="cuisine"] { background: #D4E6C3; color: #3D5A27; }
.tag-chip[data-type="dish_type"] { background: #C8D8E8; color: #2C4A6B; }
.tag-chip[data-type="method"] { background: #E8D4E0; color: #6B2C5A; }
.tag-chip[data-type="meal_type"] { background: #E8E0C8; color: #5A4A2C; }
.tag-chip[data-type="dietary"] { background: #C8E8D4; color: #2C6B4A; }
.tag-chip[data-type="season"] { background: #E8C8C8; color: #6B2C2C; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.15s;
  min-height: 44px;
  font-size: 0.95rem;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-secondary); color: #fff; }
.btn-secondary:hover { background: var(--accent-secondary-hover); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: #D9534F; color: #fff; }
.btn-danger:hover { background: #C9302C; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; min-height: 36px; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 1rem;
  transition: border-color 0.2s;
  min-height: 44px;
}
.form-input:focus { outline: none; border-color: var(--accent); }
textarea.form-input { min-height: 100px; resize: vertical; }

/* === Search Bar === */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  background: var(--bg-card);
  min-height: 48px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }

.browse-search-bar {
  display: flex;
  gap: 8px;
}
.browse-search-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  background: var(--bg-card);
  min-height: 44px;
}
.browse-search-bar input:focus { outline: none; border-color: var(--accent); }

/* === Live Search Dropdown === */
.search-bar, .browse-search-bar { position: relative; }
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.search-dropdown-section { padding: 8px 12px; }
.search-dropdown-section + .search-dropdown-section { border-top: 1px solid var(--border); }
.search-dropdown-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 6px;
}
.search-dropdown-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.search-dropdown-tags .tag-chip { cursor: pointer; }
.search-dropdown-tags .tag-count {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-left: 2px;
}
.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.search-dropdown-item:hover { background: var(--bg); }
.search-result-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.search-result-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.search-result-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  font-size: 1.2rem;
}
.search-result-info { min-width: 0; flex: 1; }
.search-result-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-meta {
  font-size: 0.78rem;
  color: var(--text-light);
}

/* Browse related tags (shown above results when searching) */
.browse-related-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
}
.browse-related-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  margin-right: 4px;
}

/* === Filter Pills === */
.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.2s, transform 0.15s;
}
.filter-pill:hover, .filter-pill.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.filter-pill:hover { transform: translateY(-1px); }
.filter-pill:active { transform: translateY(0) scale(0.97); }

/* === Recipe Detail === */
.recipe-hero-wrap {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin-top: calc(-16px - env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  margin-bottom: 0;
  height: calc(320px + env(safe-area-inset-top, 0px));
  overflow: hidden;
}
.recipe-hero {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.recipe-header { position: relative; z-index: 3; padding-top: 24px; }
.recipe-header h1 { font-size: 1.6rem; margin-bottom: 8px; }
.recipe-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 12px;
  cursor: pointer;
}
.recipe-description p { margin: 0; }
.recipe-description.collapsed p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-description.collapsed.clamped::after {
  content: 'more';
  display: block;
  color: var(--primary);
  font-size: 0.85rem;
  margin-top: 4px;
}
.recipe-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.recipe-actions-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.recipe-action-icon {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 4px;
  font-size: 0.8rem;
  min-height: 42px;
  white-space: nowrap;
}
.recipe-action-cook { min-width: 160px; justify-content: center; }
@media (min-width: 640px) {
  .recipe-actions { flex-direction: row; }
  .recipe-action-icon { flex: 0; padding: 6px 14px; font-size: 0.85rem; }
}
.recipe-source-link { color: var(--text-light); text-decoration: none; }
.recipe-source-link:hover { color: var(--accent); }
.recipe-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.recipe-meta span { display: flex; align-items: center; gap: 4px; }

/* Portion Adjuster */
.portion-adjuster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  white-space: nowrap;
}
.portion-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
.portion-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.portion-adjuster button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.portion-adjuster button:hover { border-color: var(--accent); color: var(--accent); }
.portion-count {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
  cursor: pointer;
  border-bottom: 1.5px dashed var(--border);
  padding: 2px 4px;
  border-radius: 4px;
  transition: border-color 0.2s, background 0.2s;
}
.portion-count:hover { border-color: var(--accent); background: rgba(193,105,79,0.06); }
.portion-input {
  width: 56px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
  font-family: var(--font-body);
  background: var(--bg);
  -moz-appearance: textfield;
}
.portion-input::-webkit-inner-spin-button,
.portion-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Ingredients */
.ingredient-list { list-style: none; }
.ingredient-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.ingredient-list li.checked { opacity: 0.5; text-decoration: line-through; }
.ingredient-list input[type="checkbox"] {
  margin-top: 4px;
  width: 20px;
  height: 20px;
  accent-color: var(--accent-secondary);
  flex-shrink: 0;
}

/* Instructions */
.instruction-list { list-style: none; counter-reset: step; }
.instruction-list li {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.instruction-list li.completed { opacity: 0.5; }
.step-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
}
.step-number.done { background: var(--accent-secondary); }
.step-text { flex: 1; padding-top: 6px; }

/* === Sections === */
.section-title {
  font-size: 1.3rem;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.section-link {
  cursor: pointer;
  transition: color 0.2s;
}
.section-link:hover { color: var(--accent); }
.section-link svg { opacity: 0.4; transition: opacity 0.2s, transform 0.2s; }
.section-link:hover svg { opacity: 1; transform: translateX(2px); }

/* === Filter Drawer (mobile) / Sidebar (desktop) === */
.browse-layout { display: flex; flex-direction: column; gap: 16px; }
.filter-drawer {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.filter-drawer h3 { font-size: 1rem; margin-bottom: 12px; }
.filter-drawer.collapsed .filter-content { display: none; }
.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  min-height: 44px;
}
.filter-section { margin-bottom: 16px; }
.filter-section h4 {
  font-size: 0.85rem; color: var(--text-light); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.5px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.filter-section h4 svg { transition: transform 0.2s; flex-shrink: 0; }
.filter-section.section-collapsed h4 svg { transform: rotate(-90deg); }
.filter-section.section-collapsed .tags-row { display: none; }
.filter-hidden { display: none !important; }
.show-more-pill { border-style: dashed !important; color: var(--text-light); font-size: 0.8rem; }
.show-more-pill:hover { border-color: var(--accent) !important; color: var(--accent); }
.active-tags-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-bottom: 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.active-tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 100px;
  background: var(--accent); color: #fff;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  transition: opacity 0.15s;
}
.active-tag-chip:hover { opacity: 0.8; }
.filter-close-handle {
  display: flex; justify-content: center; padding: 12px 0 4px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.filter-close-bar {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); transition: background 0.2s;
}
.filter-close-handle:hover .filter-close-bar { background: var(--accent); }
@media (min-width: 1024px) { .filter-close-handle { display: none; } }

/* === Sort & Results === */
.browse-mode-btns {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}
.browse-mode-btn {
  padding: 6px 14px;
  border: none;
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.browse-mode-btn + .browse-mode-btn { border-left: 1.5px solid var(--border); }
.browse-mode-btn:hover { color: var(--accent); }
.browse-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* === By Ingredients search === */
.ingredient-search-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
}
.ingredient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ingredient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #fff;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-family: var(--font-body);
}
.ingredient-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.85rem;
  opacity: 0.8;
}
.ingredient-chip button:hover { opacity: 1; }
.ingredient-search-area input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}
.ingredient-search-area input:focus { outline: none; border-color: var(--accent); }
.ingredient-search-area { position: relative; }
.ing-suggest-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
}
.ing-suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
}
.ing-suggest-item:hover,
.ing-suggest-item.highlighted {
  background: var(--bg);
}
.ing-suggest-item + .ing-suggest-item {
  border-top: 1px solid var(--border);
}
.ing-suggest-count {
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}
.ingredient-match-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
}
.ingredient-match-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ing-matched {
  font-size: 0.75rem;
  background: #d4edda;
  color: #155724;
  padding: 2px 6px;
  border-radius: 10px;
}
.ing-missing {
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 10px;
}

.browse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.clear-filters-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
}
.clear-filters-btn:hover { color: var(--accent); border-color: var(--accent); }
.result-count { font-size: 0.9rem; color: var(--text-light); }
.sort-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sort-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 0.85rem;
  min-height: 44px;
}
.sort-dir-btn {
  min-height: 44px;
  min-width: 36px;
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}
.sort-dir-btn:hover { border-color: var(--accent); color: var(--accent); }

/* === Tabs === */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 12px 20px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  min-height: 44px;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* === Favorites Row (legacy, kept for non-carousel lists) === */
.favorites-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 6px 16px;
  margin: 0 -6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.favorites-row::-webkit-scrollbar { display: none; }
.fav-card {
  flex-shrink: 0;
  width: 140px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fav-card:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.05);
  z-index: 2;
}
.fav-card img { width: 140px; height: 100px; object-fit: cover; }
.fav-card .card-body { padding: 8px; }
.fav-card h4 {
  font-size: 0.8rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === Discovery Feed === */
.feed-card { width: 160px; }
.feed-card img { width: 160px; height: 110px; object-fit: cover; }
.feed-card-meta {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 2px;
}
#feed-container { margin-top: 8px; }
#feed-sentinel.scroll-spinner {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}
#feed-sentinel.scroll-spinner::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Seasonal Carousel === */
.carousel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.5);
  margin-bottom: 8px;
}
.carousel-track {
  display: flex;
  will-change: transform;
}
.carousel-slide {
  flex: 0 0 var(--carousel-slide, 100%);
  display: flex;
  cursor: pointer;
  height: 180px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  transition: background 0.2s, filter 0.2s;
}
.carousel-slide:hover {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-card));
  filter: brightness(1.04);
}
.carousel-slide:hover .carousel-info h4 {
  color: var(--accent);
}
.carousel-slide + .carousel-slide { border-left: 1px solid rgba(255,255,255,0.4); }
.carousel-slide img {
  width: 45%;
  max-width: 180px;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
}
.carousel-slide .card-placeholder {
  width: 45%;
  max-width: 180px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: rgba(0,0,0,0.04);
  flex-shrink: 0;
}
.carousel-info {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.carousel-info h4 {
  font-size: 1rem;
  font-family: var(--font-heading);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.carousel-info .carousel-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  display: flex;
  gap: 12px;
}
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.7);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  -webkit-tap-highlight-color: transparent;
}
.carousel-arrow:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.carousel-arrow.prev { left: 8px; }
.carousel-arrow.next { right: 8px; }
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 6px;
}
.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
}
.carousel-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}
@media (min-width: 600px) {
  .carousel { --carousel-slide: 50%; }
}
@media (min-width: 900px) {
  .carousel { --carousel-slide: 33.333%; }
}
@media (max-width: 400px) {
  .carousel-slide { min-height: 130px; }
  .carousel-slide img, .carousel-slide .card-placeholder { width: 40%; }
  .carousel-info { padding: 12px; }
  .carousel-info h4 { font-size: 0.9rem; }
}

/* === Infinite Scroll Spinner === */
.scroll-spinner {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}
.scroll-spinner::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Loading / Empty States === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

/* === Confirm Dialog === */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: overlay-in 0.25s ease;
}
.confirm-overlay.closing {
  animation: overlay-out 0.25s ease forwards;
}
.confirm-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
.confirm-dialog h3 { margin-bottom: 12px; }
.confirm-dialog p { margin-bottom: 20px; color: var(--text-light); }
.confirm-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 300;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* Overlay fade + blur in/out */
@keyframes overlay-in {
  from { background: rgba(0,0,0,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
  to { background: rgba(0,0,0,0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
}
@keyframes overlay-out {
  from { background: rgba(0,0,0,0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
  to { background: rgba(0,0,0,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
}

/* === Responsive: Tablet (640px+) === */
@media (min-width: 640px) {
  body { padding-bottom: 0; }
  .ptr-indicator { display: none; }
  .bottom-nav { display: none; }
  #app { padding: 24px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .recipe-hero-wrap { height: 400px; border-radius: var(--radius-lg); margin: 0 0 20px; padding-top: 0; width: 100%; left: auto; transform: none; }
  .recipe-header h1 { font-size: 2rem; }
  .toast { bottom: 24px; }
}

/* === Responsive: Desktop (1024px+) === */
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .browse-layout { flex-direction: row; flex-wrap: wrap; }
  .browse-search-bar { width: 100%; }
  .filter-drawer {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--nav-height) + 24px);
    align-self: flex-start;
    max-height: calc(100vh - var(--nav-height) - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .filter-drawer::-webkit-scrollbar { width: 4px; }
  .filter-drawer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .filter-drawer::-webkit-scrollbar-track { background: transparent; }
  .filter-drawer .filter-content { display: block !important; }
  .filter-toggle svg { display: none; }
  .browse-main { flex: 1; min-width: 0; }
  .recipe-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

/* === Meal Plan === */

.meal-plan-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.meal-plan-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  text-align: center;
  margin: 0 8px;
}

/* Mobile: vertical stack */
.meal-plan-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meal-plan-day {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 12px;
}
.meal-plan-day-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.meal-plan-today .meal-plan-day-header {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  margin: -12px -12px 8px;
  padding: 12px 12px 8px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.meal-plan-day-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
}
.meal-plan-day-date {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Meal slots */
.meal-plan-slot {
  margin-bottom: 8px;
}
.meal-plan-slot-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Entry cards within slots */
.meal-plan-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius);
  transition: background 0.15s;
  position: relative;
  margin-bottom: 4px;
}
.meal-plan-entry:hover {
  background: var(--bg);
}
.meal-plan-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}
.meal-plan-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--border) 0%, #D4CFC7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.meal-plan-entry-info {
  flex: 1;
  min-width: 0;
}
.meal-plan-entry-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.3;
}
.meal-plan-entry-title:hover {
  color: var(--accent);
}
.meal-plan-servings-badge {
  display: inline-block;
  font-size: 0.7rem;
  background: var(--accent-secondary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 100px;
  font-weight: 600;
  margin-top: 2px;
}
.meal-plan-remove {
  opacity: 0;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.meal-plan-entry:hover .meal-plan-remove {
  opacity: 1;
}
.meal-plan-remove:hover {
  color: #D9534F;
}

/* Add button in each slot */
.meal-plan-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-light);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  min-height: 32px;
}
.meal-plan-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Recipe picker modal */
.meal-plan-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: overlay-in 0.25s ease;
}
.meal-plan-picker-overlay.closing {
  animation: overlay-out 0.25s ease forwards;
}
.meal-plan-picker {
  background: var(--bg-card);
  border-radius: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: none;
}
.picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.picker-header h3 {
  font-family: var(--font-heading);
  margin: 0;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-back-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  color: var(--accent);
}
@media (min-width: 640px) {
  .meal-plan-picker-overlay {
    padding: 24px;
  }
  .meal-plan-picker {
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 820px;
    width: 100%;
    height: auto;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
  }
  .picker-back-btn { display: none; }
}
@media (min-width: 1024px) {
  .meal-plan-picker { max-width: 1100px; max-height: 92vh; }
}
.meal-plan-picker-search {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  margin-bottom: 12px;
  min-height: 44px;
  box-sizing: border-box;
}
.meal-plan-picker-search:focus {
  outline: none;
  border-color: var(--accent);
}
/* Section tabs */
.picker-section-tabs {
  display: flex;
  gap: 6px;
  padding: 4px 0 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-card);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.picker-section-tabs::-webkit-scrollbar { display: none; }
.picker-section-tabs:empty { display: none; }
.picker-tab {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.picker-tab:hover {
  background: var(--bg);
  border-color: var(--text-light);
}
.picker-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Hide tabs on desktop where sidebar provides navigation */
@media (min-width: 640px) {
  .picker-section-tabs { display: none; }
}

.meal-plan-picker-results {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.meal-plan-picker-empty {
  text-align: center;
  color: var(--text-light);
  padding: 24px;
  font-size: 0.9rem;
}
.meal-plan-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius);
  position: relative;
}
.meal-plan-picker-item:hover {
  background: var(--bg);
}
.meal-plan-picker-item + .meal-plan-picker-item {
  border-top: 1px solid var(--border);
}
.meal-plan-picker-item img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .meal-plan-picker-item { gap: 12px; padding: 10px 8px; }
  .meal-plan-picker-item img { width: 48px; height: 48px; }
}
.meal-plan-picker-item-info {
  flex: 1;
  min-width: 0;
}
.meal-plan-picker-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meal-plan-picker-item-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* Grid layout for picker items on desktop */
.picker-grid {
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) {
  .picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
  .picker-grid .meal-plan-picker-item + .meal-plan-picker-item {
    border-top: none;
  }
  .picker-grid .meal-plan-picker-item img {
    width: 64px;
    height: 64px;
  }
}
@media (min-width: 1024px) {
  .picker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .picker-grid .meal-plan-picker-item img {
    width: 72px;
    height: 72px;
  }
}

/* Mobile: always show remove button (no hover on touch) */
@media (max-width: 639px) {
  .meal-plan-remove { opacity: 1; }
}

/* Tablet/Desktop: 7-column grid */
@media (min-width: 640px) {
  .meal-plan-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    overflow-x: auto;
  }
  .meal-plan-day {
    min-width: 120px;
  }
  .meal-plan-day-header {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
  }
  .meal-plan-title {
    font-size: 1.25rem;
  }
}

/* === Plan Selector Row === */
.meal-plan-selector-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.meal-plan-selector-row::-webkit-scrollbar { display: none; }

.meal-plan-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .meal-plan-pill {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 44px;
  }
}
.meal-plan-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.meal-plan-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* === Mode Toggle === */
.meal-plan-header-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 0;
  position: sticky;
  top: var(--mp-sticky-base);
  z-index: 13;
  background: var(--bg);
  margin-left: -16px;
  margin-right: -16px;
  padding: 6px 12px;
}
/* Gradient blur zone above toolbar covering safe-area / dynamic island on iPhone */
@media (max-width: 639px) {
  .route-meal-plan .meal-plan-header-actions::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: calc(env(safe-area-inset-top, 20px) + 12px);
    background: linear-gradient(
      to bottom,
      rgba(250, 247, 242, 0.5) 0%,
      rgba(250, 247, 242, 0.85) 100%
    );
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    pointer-events: none;
  }
}
@media (min-width: 640px) {
  .meal-plan-header-actions {
    margin-left: -24px;
    margin-right: -24px;
    padding: 8px 24px;
  }
}
.meal-plan-mode-toggle {
  display: inline-flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.meal-plan-mode-toggle button {
  padding: 6px 14px;
  border: none;
  background: var(--bg-card);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.2s;
}
@media (min-width: 640px) {
  .meal-plan-mode-toggle button {
    padding: 8px 20px;
    font-size: 0.85rem;
    min-height: 44px;
  }
}
.meal-plan-mode-toggle button.active {
  background: var(--accent);
  color: #fff;
}
.meal-plan-mode-toggle button:not(.active):hover {
  background: var(--bg);
}
/* Standardized action buttons (+ Special, Shop List) */
.mp-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  padding: 5px 10px;
  min-height: 36px;
}
@media (min-width: 640px) {
  .mp-action-btn {
    font-size: 0.85rem;
    padding: 8px 16px;
    min-height: 44px;
  }
}
/* Special plans dropdown */
.mp-special-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 180px;
  overflow: hidden;
}
.mp-special-menu.show { display: flex; flex-direction: column; }
.mp-special-menu-item {
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.mp-special-menu-item:hover { background: var(--bg); }
.mp-special-new {
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-weight: 500;
}


/* Shopping select bar (multi-week selection) */
.shopping-select-bar {
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.shopping-select-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.shopping-select-pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 36px;
}
.shopping-select-pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.shopping-select-pill:not(.selected):hover {
  border-color: var(--accent);
}
.shopping-select-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.shopping-select-count {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* === Meal Plan List View === */
.meal-plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.meal-plan-list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px 12px;
  transition: box-shadow 0.2s, background 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.meal-plan-list-card:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.03);
  z-index: 2;
}
.meal-plan-list-card-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.meal-plan-list-card .meal-plan-thumb,
.meal-plan-list-card .meal-plan-thumb-placeholder {
  width: 60px;
  height: 60px;
}
.meal-plan-list-card-info {
  flex: 1;
  min-width: 0;
}
.meal-plan-list-card-title {
  font-size: 0.9rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.meal-plan-list-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* === Meal Plan Overview (multi-week columns) === */
/* === Overview: Calendar Day Rows === */
/* === Overview: Week Containers === */
.overview-weeks {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.overview-week-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.overview-week-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.4s ease, color 0.4s ease;
  background: color-mix(in srgb, var(--month-color, var(--accent)) 10%, var(--bg-card));
  border-left: 3px solid color-mix(in srgb, var(--month-color, var(--accent)) 40%, transparent);
}
.overview-week-range,
.overview-week-days {
  transition: color 0.4s ease;
}
.overview-week-header:hover { background: color-mix(in srgb, var(--month-color, var(--accent)) 22%, var(--bg-card)); }
.overview-week-box.active .overview-week-header {
  background: var(--month-color, var(--accent));
  color: #fff;
  border-left-color: transparent;
}
.overview-week-box.active .overview-week-header:hover {
  background: color-mix(in srgb, var(--month-color, var(--accent)) 85%, #000);
}
.overview-week-box.active .overview-week-header .overview-week-range,
.overview-week-box.active .overview-week-header .overview-week-days {
  color: rgba(255,255,255,0.75);
}
/* Per-month color variables */
.overview-week-box[data-month="0"]  { --month-color: #5A7DB5; }
.overview-week-box[data-month="1"]  { --month-color: #7A6DB8; }
.overview-week-box[data-month="2"]  { --month-color: #4E966A; }
.overview-week-box[data-month="3"]  { --month-color: #68A54D; }
.overview-week-box[data-month="4"]  { --month-color: #C29538; }
.overview-week-box[data-month="5"]  { --month-color: #CC7A32; }
.overview-week-box[data-month="6"]  { --month-color: #C25A5A; }
.overview-week-box[data-month="7"]  { --month-color: #B34A78; }
.overview-week-box[data-month="8"]  { --month-color: #B06A35; }
.overview-week-box[data-month="9"]  { --month-color: #C07735; }
.overview-week-box[data-month="10"] { --month-color: #7A6445; }
.overview-week-box[data-month="11"] { --month-color: #4D7D97; }
.overview-week-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
}
.overview-week-range {
  font-size: 0.8rem;
  color: var(--text-light);
}
.overview-week-days {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-light);
  opacity: 0.6;
  letter-spacing: 0.02em;
}
.overview-week-holidays {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.week-holiday-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  white-space: nowrap;
}
.overview-week-box.active .week-holiday-badge {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.overview-week-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  align-items: flex-start;
  align-content: flex-start;
  min-height: 160px;
}
@media (min-width: 640px) {
  .overview-week-items { min-height: 200px; }
}
.overview-item {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 200px;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s, background 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), overflow 0s 0s;
  transform-origin: bottom center;
}
.overview-item:hover {
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
  transform: scale(1.05);
  z-index: 2;
  overflow: visible;
}
.overview-item .meal-plan-thumb,
.overview-item .meal-plan-thumb-placeholder {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}
.overview-item .meal-plan-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--border);
}
.overview-item-title {
  font-size: 0.78rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 8px;
  line-height: 1.3;
}
.overview-item:hover .overview-item-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  background: var(--bg-card);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 3;
}
.overview-item-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  opacity: 0;
}
.overview-item:hover .overview-item-remove { opacity: 1; }
.overview-item-remove:hover {
  background: rgba(200,50,50,0.8);
}
.overview-week-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 120px;
  width: 48px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
  background: transparent;
  font-size: 1.2rem;
  color: var(--text-light);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.overview-week-add::after {
  content: '';
  display: block;
  font-size: 0.7rem;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.overview-week-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,0,0,0.02);
}
.overview-week-add:hover::after {
  content: 'Add';
  opacity: 1;
}
.overview-week-items:has(.overview-week-empty-card) {
  justify-content: center;
  align-items: center;
  align-content: center;
}
.overview-week-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 100px;
  max-width: 200px;
  min-height: 120px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  color: var(--text-light);
}
.overview-week-empty-plus {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
}
.overview-week-empty-label {
  font-size: 0.78rem;
  font-style: italic;
}
.overview-week-empty-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,0,0,0.02);
}
/* Year marker — sticky below toolbar, padded to cover flex gap */
/* Year marker — decorative divider in scroll flow (year shown in toolbar) */
.overview-year-marker {
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--text-light);
  height: 40px;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  letter-spacing: 0.06em;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}
/* Toolbar year label — centered between left/right buttons */
.mp-toolbar-year {
  flex: 1;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: 0.06em;
}
.mp-toolbar-spacer { flex: 1; }
.overview-year-marker::before,
.overview-year-marker::after {
  content: '';
  position: absolute;
  bottom: 0;
  height: 2px;
  width: calc(50% - 40px);
  background: var(--border);
}
.overview-year-marker::before { left: 16px; }
.overview-year-marker::after { right: 16px; }

/* Month dividers — sticky banner flush below toolbar */
.overview-month-marker {
  position: sticky;
  top: var(--mp-month-top);
  z-index: 11;
  margin: -8px -16px 0;
  padding: 6px 16px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.overview-month-marker span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
/* Month banner colors */
.overview-month-marker[data-month="0"]  { background: #5A7DB5; }
.overview-month-marker[data-month="1"]  { background: #7A6DB8; }
.overview-month-marker[data-month="2"]  { background: #4E966A; }
.overview-month-marker[data-month="3"]  { background: #68A54D; }
.overview-month-marker[data-month="4"]  { background: #C29538; }
.overview-month-marker[data-month="5"]  { background: #CC7A32; }
.overview-month-marker[data-month="6"]  { background: #C25A5A; }
.overview-month-marker[data-month="7"]  { background: #B34A78; }
.overview-month-marker[data-month="8"]  { background: #B06A35; }
.overview-month-marker[data-month="9"]  { background: #C07735; }
.overview-month-marker[data-month="10"] { background: #7A6445; }
.overview-month-marker[data-month="11"] { background: #4D7D97; }
.overview-sentinel {
  height: 1px;
}
@media (min-width: 640px) {
  .overview-item { flex: 1 1 150px; min-width: 130px; max-width: 240px; }
  .overview-item .meal-plan-thumb,
  .overview-item .meal-plan-thumb-placeholder { height: 110px; }
  .overview-week-empty-card { flex: 1 1 150px; min-width: 130px; max-width: 240px; min-height: 150px; }
  /* Desktop: wider margins */
  .overview-year-marker {
    font-size: 1.5rem;
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
  }
  .overview-year-marker::before { left: 24px; }
  .overview-year-marker::after { right: 24px; }
  .overview-month-marker {
    top: var(--mp-month-top);
    margin: -8px -24px 0;
    padding: 8px 24px;
  }
  .overview-month-marker span {
    font-size: 1.05rem;
  }
  .mp-toolbar-year {
    font-size: 1.7rem;
  }
}

/* === Plan Picker Dropdown === */
.meal-plan-dropdown {
  position: absolute;
  z-index: 120;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  min-width: 280px;
  margin-top: 8px;
}
.meal-plan-mini-cal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meal-plan-mini-cal-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.meal-plan-mini-cal table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  text-align: center;
}
.meal-plan-mini-cal th {
  color: var(--text-light);
  font-weight: 500;
  padding: 2px;
}
.meal-plan-mini-cal td {
  padding: 4px 2px;
  cursor: default;
}
.meal-plan-mini-cal-sunday {
  cursor: pointer !important;
  font-weight: 600;
  color: var(--accent);
}
.meal-plan-mini-cal-sunday:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: var(--radius);
}
.meal-plan-mini-cal tr:hover {
  background: var(--bg);
}
.meal-plan-dropdown-divider {
  border-top: 1px solid var(--border);
  margin: 12px 0 4px;
  padding-top: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}
.meal-plan-dropdown-item {
  padding: 10px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.meal-plan-dropdown-item:hover {
  background: var(--bg);
}

/* === Special Plan Modal === */
.meal-plan-special-form {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
.meal-plan-special-form h3 {
  font-family: var(--font-heading);
  margin-bottom: 16px;
}

/* === Quick Add Popover === */
.quick-add-popover {
  z-index: 150;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 8px;
  max-width: 280px;
}
.quick-add-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  min-height: 44px;
  font-size: 0.85rem;
}
.quick-add-plan-row:hover {
  background: var(--bg);
}

/* .card-quick-add and .card-fav are now styled via .card-action-btn above */

/* === Picker Add/Added Buttons === */
.meal-plan-picker-add-btn,
.meal-plan-picker-added {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.meal-plan-picker-add-btn {
  background: var(--accent);
  color: #fff;
}
.meal-plan-picker-add-btn:hover {
  background: var(--accent-hover);
}
.meal-plan-picker-added {
  background: var(--accent-secondary);
  color: #fff;
}
.meal-plan-picker-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 4px;
}


/* Two-panel body: sidebar + main */
.meal-plan-picker-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.meal-plan-picker-sidebar {
  display: none;
}
.meal-plan-picker-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
}
@media (min-width: 640px) {
  .meal-plan-picker-main { padding: 12px 16px; }
}
@media (min-width: 640px) {
  .meal-plan-picker-sidebar {
    display: flex;
    flex-direction: column;
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding-right: 12px;
    margin-right: 12px;
    gap: 2px;
  }
}
@media (min-width: 1024px) {
  .meal-plan-picker-sidebar { width: 220px; }
}

/* Sidebar collection items (desktop) */
.picker-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.picker-sidebar-item:hover, .picker-sidebar-item.active {
  background: var(--bg);
}
.picker-sidebar-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}
.picker-sidebar-thumb-placeholder {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.picker-sidebar-name {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-sidebar-name small {
  color: var(--text-light);
  margin-left: 4px;
}
.picker-sidebar-addall {
  font-size: 0.7rem;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  min-height: 28px;
  transition: background 0.15s, color 0.15s;
}
.picker-sidebar-addall:hover {
  background: var(--accent);
  color: #fff;
}

/* Mobile collection chips (horizontal scroll) */
.picker-collections-mobile {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.picker-collections-mobile::-webkit-scrollbar { display: none; }
.picker-col-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.85rem;
  min-height: 44px;
  transition: background 0.15s;
}
.picker-col-chip:active { background: var(--border); }
.picker-col-chip-img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}
.picker-col-chip-placeholder {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.picker-col-chip small { color: var(--text-light); font-size: 0.75rem; }
.picker-col-chip-addall {
  padding: 4px 8px;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 640px) {
  .picker-collections-mobile { display: none; }
}

/* Back button + collection drill-in header */
.picker-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
  font-size: 0.85rem;
}
.picker-back button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
}
.picker-back button:hover { background: var(--bg); }
.picker-collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* === Recipe Preview Panel (sub-overlay inside picker) === */
.picker-preview-panel {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0);
  transition: background 0.3s ease;
}
.picker-preview-panel.open {
  background: rgba(0,0,0,0.35);
}
/* When nested inside an already-dimmed overlay (e.g. picker), skip the extra backdrop */
.picker-preview-nested,
.picker-preview-nested.open {
  background: rgba(0,0,0,0.1) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transition: none !important;
}
.picker-preview-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 85vh;
  width: 100%;
  overflow-y: auto;
  position: relative;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  will-change: transform;
}
.picker-preview-panel.open .picker-preview-card {
  transform: translateY(0);
}
.preview-drag-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: pointer;
  touch-action: none;
  flex-shrink: 0;
}
.preview-drag-bar {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.15s;
}
.preview-drag-handle:hover .preview-drag-bar,
.preview-drag-handle:active .preview-drag-bar {
  background: var(--text-light);
}
/* Hide drag handle on desktop where panel slides in from side */
@media (min-width: 1024px) {
  .preview-drag-handle { display: none; }
}
.picker-preview-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.picker-preview-img img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.picker-preview-content {
  padding: 16px 20px 20px;
}
.picker-preview-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin: 0 0 6px;
}
.picker-preview-desc {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0 0 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.picker-preview-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 10px;
}
.picker-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.picker-preview-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-light);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.picker-preview-tag:hover {
  background: var(--border);
}
.picker-preview-tag--protein { border-color: var(--accent); color: var(--accent); }
.picker-preview-tag--cuisine { border-color: var(--accent-secondary); color: var(--accent-secondary); }
.picker-preview-ingredients {
  font-size: 0.85rem;
  padding-left: 18px;
  margin: 0 0 12px;
  max-height: 180px;
  overflow-y: auto;
}
.picker-preview-ingredients li { padding: 2px 0; }
.picker-preview-instructions { display: none; } /* hidden on mobile */
.picker-preview-more {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0 0 12px;
}
.picker-preview-add { width: 100%; }
.picker-preview-added {
  width: 100%;
  background: var(--accent-secondary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.picker-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.picker-preview-actions .btn {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.8rem;
}
.picker-preview-actions .btn-primary { flex: 1 0 100%; }

/* Variation selector pills */
.picker-preview-variations {
  margin-bottom: 12px;
}
.picker-preview-variations h5 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  margin: 0 0 6px;
}
.picker-preview-variation-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.picker-variation-pill {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: none;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 36px;
}
.picker-variation-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.picker-variation-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Desktop: side panel sliding in from right */
@media (min-width: 640px) {
  .picker-preview-panel {
    align-items: stretch;
    justify-content: flex-end;
  }
  .picker-preview-card {
    max-width: 480px;
    width: 45vw;
    min-width: 380px;
    max-height: none;
    height: 100%;
    border-radius: 0;
    transform: translateX(100%);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    will-change: transform;
  }
  .picker-preview-panel.open .picker-preview-card {
    transform: translateX(0);
  }
  .picker-preview-img img {
    max-height: 280px;
    border-radius: 0;
  }
  .picker-preview-content {
    padding: 20px 24px 24px;
  }
  .picker-preview-title {
    font-size: 1.3rem;
  }
  .picker-preview-desc {
    font-size: 0.9rem;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
  .picker-preview-ingredients {
    max-height: none;
    font-size: 0.9rem;
  }
  .picker-preview-instructions {
    display: block;
    margin: 0 0 16px;
  }
  .picker-preview-instructions h5 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    margin: 0 0 8px;
  }
  .picker-preview-instructions ol {
    font-size: 0.85rem;
    padding-left: 20px;
    line-height: 1.5;
  }
  .picker-preview-instructions li {
    padding: 4px 0;
  }
  .picker-preview-actions .btn {
    font-size: 0.85rem;
  }
}

/* Smart recommendation sections */
.picker-smart-section {
  color: var(--accent);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.meal-plan-picker-section-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 0 8px 6px;
  font-style: italic;
}
/* Horizontal scrolling smart pick cards */
.picker-smart-items {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 8px 12px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.picker-smart-items::-webkit-scrollbar {
  height: 4px;
}
.picker-smart-items::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
.smart-pick-card {
  flex-shrink: 0;
  width: 110px;
  cursor: pointer;
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  position: relative;
  scroll-snap-align: start;
  transition: box-shadow 0.15s;
}
.smart-pick-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.smart-pick-card .meal-plan-thumb,
.smart-pick-card .meal-plan-thumb-placeholder {
  width: 100%;
  height: 72px;
  border-radius: var(--radius) var(--radius) 0 0;
}
@media (min-width: 640px) {
  .smart-pick-card { width: 130px; }
  .smart-pick-card .meal-plan-thumb,
  .smart-pick-card .meal-plan-thumb-placeholder { height: 88px; }
}
.smart-pick-card-title {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 8px 24px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.smart-pick-card .smart-pick-card-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  font-size: 1rem;
}

/* Week summary strip */
/* Week summary strip */
.picker-week-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 0 8px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: visible;
}
.picker-week-summary-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}
.picker-week-summary-label small {
  font-weight: 400;
  opacity: 0.7;
}
.picker-week-summary-thumbs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  transition: gap 0.2s ease;
}
.picker-week-summary-thumbs::-webkit-scrollbar { display: none; }

/* Individual thumb wrapper */
.picker-week-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.picker-week-thumb-wrap img,
.picker-week-thumb-wrap .picker-week-summary-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: cover;
  display: block;
  transition: width 0.2s ease, height 0.2s ease;
}
.picker-week-summary-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Remove button — hidden by default, sits inside the thumbnail */
.picker-week-thumb-remove {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Tap-to-remove confirm overlay on thumbnail */
.picker-week-thumb-confirm {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 2;
}
.picker-week-thumb-wrap.confirm-active .picker-week-thumb-confirm {
  display: flex;
}
.picker-week-thumb-wrap.confirm-active .picker-week-thumb-remove {
  display: none !important;
}

/* Expanded state — hover on desktop, tap-activated on mobile */
.picker-week-summary.expanded {
  flex-direction: column;
  align-items: flex-start;
}
.picker-week-summary.expanded .picker-week-summary-thumbs {
  gap: 12px;
  padding-right: 4px;
  width: 100%;
}
.picker-week-summary.expanded .picker-week-thumb-wrap img,
.picker-week-summary.expanded .picker-week-thumb-wrap .picker-week-summary-placeholder {
  width: 72px;
  height: 72px;
}
.picker-week-summary.expanded .picker-week-thumb-remove {
  display: flex;
}

/* Desktop: expand on hover */
@media (hover: hover) {
  .picker-week-summary:hover {
    flex-direction: column;
    align-items: flex-start;
  }
  .picker-week-summary:hover .picker-week-summary-thumbs {
    gap: 12px;
    padding-right: 4px;
    width: 100%;
  }
  .picker-week-summary:hover .picker-week-thumb-wrap img,
  .picker-week-summary:hover .picker-week-thumb-wrap .picker-week-summary-placeholder {
    width: 72px;
    height: 72px;
  }
  .picker-week-summary:hover .picker-week-thumb-remove {
    display: flex;
  }
}

.picker-sidebar-smart {
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 4px;
  cursor: pointer;
}

/* === Unassigned Row === */
.meal-plan-unassigned {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* === Recipe Variations === */
.variations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.variation-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.variation-card-info {
  flex: 1;
}
.variation-card-info h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}
.variation-card-info p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0;
}
.variation-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.variation-banner {
  background: var(--accent-secondary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.variation-banner button {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.6);
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

/* === Shopping List === */
.shopping-header { margin-bottom: 20px; }
.shopping-header h1 { margin-bottom: 4px; }
.shopping-header .subtitle { color: var(--text-light); font-size: 0.9rem; margin-bottom: 12px; }
.shopping-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.shopping-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px 0;
}
.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
}
.shopping-item:last-child { border-bottom: none; }
.shopping-item input[type="checkbox"] { accent-color: var(--accent-secondary); flex-shrink: 0; }
.shopping-item.checked { opacity: 0.45; }
.shopping-item.checked .shopping-item-name { text-decoration: line-through; }
.shopping-amount {
  color: var(--text-light);
  min-width: 80px;
  text-align: right;
  flex-shrink: 0;
  font-size: 0.9rem;
  white-space: pre-line;
}
.shopping-item-name { font-weight: 600; }
.shopping-conflict { font-size: 0.8rem; margin-left: 4px; cursor: help; }
.shopping-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.shopping-section-label:first-child {
  border-top: none;
  margin-top: 0;
}
.shopping-section-pantry {
  color: var(--accent);
  margin-top: 12px;
}

/* === Adapt Recipe Modal === */
.adapt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.adapt-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.adapt-modal h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 8px;
}
.adapt-recipe-name {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.adapt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.adapt-chip {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.adapt-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.adapt-chip--ingredient {
  border-style: dashed;
}
.adapt-loading {
  text-align: center;
  padding: 16px;
  color: var(--text-light);
  font-size: 0.9rem;
}
.adapt-loading-dots::after {
  content: '...';
  animation: adapt-dots 1.2s infinite step-start;
}
@keyframes adapt-dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
}
.adapt-error {
  color: #C0392B;
  font-size: 0.85rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: #FDF0EF;
  border-radius: var(--radius);
  border-left: 3px solid #C0392B;
}
.adapt-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
.variation-card--new {
  animation: variation-highlight 1.5s ease forwards;
}
@keyframes variation-highlight {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(193,105,79,0.2); }
  100% { border-color: var(--border); box-shadow: none; }
}

/* === Recipe Chat Assistant === */
.recipe-chat {
  margin-top: 32px;
  border-top: 2px solid var(--border);
  padding-top: 24px;
}
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  scroll-behavior: smooth;
}
.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  line-height: 1.5;
  font-size: 0.95rem;
}
.chat-message--user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message--assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-message--assistant.streaming {
  border-color: var(--accent);
}
.chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 0.2s;
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chat-chip {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.82rem;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
  color: var(--text-light);
}
.chat-chip:hover {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}
@keyframes cursor-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursor-pulse 0.8s infinite;
}

/* === Cook Mode Overlay === */
.cook-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.cook-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cook-topbar-left, .cook-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cook-topbar-left {
  min-width: 0;
  flex: 1;
}
.cook-topbar-right {
  position: relative;
}
.cook-topbar-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  color: var(--text);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.cook-topbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(193,105,79,0.06);
}
.cook-topbar-label {
  font-size: 0.82rem;
  color: var(--accent-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Settings dropdown */
.cook-settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  min-width: 240px;
  z-index: 10;
  display: none;
}
.cook-settings-menu.open {
  display: block;
}
.cook-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  font-size: 0.9rem;
  gap: 12px;
}
.cook-settings-item + .cook-settings-item {
  border-top: 1px solid var(--border);
}
.cook-settings-btns {
  display: flex;
  gap: 4px;
}
.cook-settings-size {
  width: 40px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.cook-settings-size:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cook-settings-toggle {
  padding: 4px 14px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.cook-settings-toggle.active {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #fff;
}
.cook-speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cook-speed-control span {
  min-width: 2.5em;
  text-align: center;
  font-size: 0.85rem;
}
.cook-voice-select {
  max-width: 55%;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: inherit;
  font-size: 0.82rem;
}

/* Step area */
.cook-step-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 16px;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
/* Kindle-style page turn zones */
.cook-page-turn {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 25%;
  min-width: 60px;
  display: flex;
  align-items: center;
  cursor: pointer;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.cook-page-turn span {
  font-size: 2.4rem;
  color: var(--text-light);
  opacity: 0.25;
  transition: opacity 0.2s, transform 0.15s;
  padding: 16px;
}
.cook-page-turn:hover span {
  opacity: 0.5;
  transform: scale(1.15);
}
.cook-page-turn:active span {
  opacity: 0.7;
  transform: scale(0.95);
}
.cook-page-turn--prev {
  left: 0;
  justify-content: flex-start;
}
.cook-page-turn--next {
  right: 0;
  justify-content: flex-end;
}
.cook-page-turn.disabled {
  pointer-events: none;
}
.cook-page-turn.disabled span {
  opacity: 0;
}
.cook-page-turn--done span {
  color: var(--accent-secondary);
  opacity: 0.6;
  font-size: 1.6rem;
}
.cook-page-turn--done:hover span {
  opacity: 1;
}
.cook-step-card {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 24px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.cook-step-counter {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  text-align: center;
}
.cook-step-text {
  font-size: var(--cook-text-size, 1.4rem);
  line-height: 1.6;
  color: var(--text);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Bottom controls */
.cook-controls {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  padding: 10px 16px;
}
.cook-btn {
  height: 48px;
  padding: 0 32px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
}
.cook-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(193,105,79,0.06);
}
.cook-btn--listen.active {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #fff;
}

/* Compact ingredients strip (always visible during instruction steps) */
.cook-ingredients-strip {
  max-height: 45%;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 16px;
  flex-shrink: 0;
  z-index: 0;
  cursor: pointer;
  transition: max-height 0.3s ease, padding 0.3s ease, z-index 0s;
}
.cook-ingredients-strip ul {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.cook-ingredients-strip li {
  font-size: 0.78rem;
  color: var(--text-light);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: font-size 0.3s, padding 0.3s, color 0.3s;
}

/* Expanded state — fills the step area */
.cook-ingredients-strip.expanded {
  max-height: 80%;
  padding: 12px 20px;
  z-index: 3;
  box-shadow: var(--shadow-lg);
  cursor: default;
}
.cook-ingredients-strip.expanded li {
  font-size: 0.95rem;
  color: var(--text);
  padding: 5px 0;
  white-space: normal;
}

/* Backdrop behind expanded strip */
.cook-ingredients-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 2;
}
.cook-ingredients-backdrop.open {
  display: block;
}

/* Full ingredients page (step -1) */
.cook-step-card--ingredients {
  text-align: left;
}
.cook-step-card--ingredients .cook-step-text {
  display: block;
  overflow-y: auto;
  text-align: left;
}
.cook-full-ingredients {
  list-style: none;
  padding: 0;
}
.cook-full-ingredients li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--cook-text-size, 1.1rem);
  line-height: 1.5;
}
.cook-full-ingredients li:last-child {
  border-bottom: none;
}

/* Assistant sheet (slides up from bottom) */
.cook-assistant-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65%;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 16px rgba(45,42,38,0.12);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cook-assistant-sheet.open {
  transform: translateY(0);
}
.cook-assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cook-assistant-header h3 {
  font-size: 1rem;
  margin: 0;
}
.cook-assistant-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}
.cook-assistant-input-row {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Voice toast */
.voice-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 10;
  white-space: nowrap;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.2s forwards;
}

/* Desktop cook mode adjustments */
@media (min-width: 640px) {
  .cook-overlay { --cook-text-size: 1.6rem; }
  .cook-topbar { padding: 10px 24px; }
  .cook-topbar-btn { padding: 10px 22px; font-size: 1rem; min-height: 48px; }
  .cook-step-area { padding: 16px 32px; }
  .cook-step-card { padding: 32px 48px; max-width: 800px; align-self: center; width: 100%; }
  .cook-step-counter { font-size: 0.85rem; margin-bottom: 12px; }
  .cook-ingredients-strip ul { grid-template-columns: 1fr 1fr 1fr; }
  .cook-page-turn span { font-size: 3rem; padding: 24px; }
  .cook-btn { height: 52px; padding: 0 40px; font-size: 1.1rem; }
  .cook-controls { padding: 14px 24px; }
}

/* === Phase 5: History & Polish === */

/* Stats widget */
.stats-widget {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
@media (min-width: 640px) {
  .stats-widget { grid-template-columns: repeat(4, 1fr); }
}
.stats-tile {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.stats-tile:hover { background: var(--bg); }
.stats-tile-value {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-tile-label {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* History tabs */
.history-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.history-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.history-tab:hover { color: var(--text); }
.history-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* History month header */
.history-month-header {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  padding: 12px 0 6px;
  margin-top: 24px;
  margin-bottom: 8px;
}

/* Cooked badge & compact variant for week view */
.cooked-btn-compact { font-size: 0.65rem; padding: 2px 6px; }
.cooked-badge {
  display: inline-block;
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Cook done banner (inside cook-overlay) */
.cook-done-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
  text-align: center;
  padding: 24px;
}
.cook-done-banner h2 { margin-bottom: 8px; }

/* Edit history toggle */
.edit-history-toggle {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.edit-history-toggle summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 12px 16px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--bg-card);
}
.edit-history-toggle summary:hover { background: var(--bg); }

/* Edit history table */
.edit-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.edit-history-table th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.edit-history-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.edit-history-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}
.edit-history-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* === Profile Picker === */
.profile-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-picker {
  text-align: center;
  max-width: 480px;
  padding: 24px;
}
.profile-picker-heading {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 4px;
}
.profile-picker-sub {
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 1.1rem;
}
.profile-picker-users {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.profile-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 12px;
  border-radius: var(--radius-lg);
  transition: transform 0.15s;
}
.profile-picker-card:hover {
  transform: scale(1.08);
}
.profile-picker-card span {
  font-weight: 600;
  color: var(--text);
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  user-select: none;
}
.profile-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  border: none;
  padding: 0;
  line-height: 1;
}
.profile-avatar-sm.nav-user-avatar { display: none; }
@media (min-width: 640px) {
  .profile-avatar-sm.nav-user-avatar { display: inline-flex; }
}

/* PIN entry */
.profile-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.profile-pin label {
  font-size: 0.85rem;
  color: var(--text-light);
}
.pin-dots {
  display: flex;
  gap: 10px;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-light);
  background: transparent;
  transition: background 0.15s;
}
.pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
}
.pin-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.pin-shake {
  animation: shake 0.4s ease-in-out;
}

/* Auth tabs & form */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-error {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 8px;
  text-align: center;
}

/* User dropdown */
.user-dropdown {
  position: fixed;
  z-index: 150;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 180px;
}
.user-dropdown-header {
  padding: 8px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
}
.user-dropdown button:hover {
  background: var(--bg);
}
.bottom-nav-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.bottom-nav-profile:hover, .bottom-nav-profile.active { color: var(--accent); }
.bottom-nav-profile-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

/* Color swatches */
.color-swatches {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  padding: 0;
}
.color-swatch:hover {
  transform: scale(1.1);
}
.color-swatch.selected {
  border-color: var(--text);
  transform: scale(1.15);
}

/* Profile add form */
.profile-add-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.profile-add-form input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: 1rem;
  width: 200px;
}

/* Profile settings page */
.profile-settings {
  max-width: 400px;
  margin: 0 auto;
}
.profile-settings h2 {
  margin-bottom: 24px;
}
.profile-settings .form-group {
  margin-bottom: 20px;
}
.profile-settings label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.profile-settings input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}
.profile-settings .avatar-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.pin-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Activity feed */
.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { flex-shrink: 0; width: 20px; text-align: center; }
.activity-link, .activity-item > span:not(.activity-icon):not(.activity-time) {
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-link:hover { color: var(--accent); }
.activity-plan-link {
  flex-shrink: 0;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  margin-left: 4px;
}
.activity-plan-link:hover { text-decoration: underline; }
.activity-time {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-light);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* === Notes === */

/* Recipe header two-column layout: main (actions/meta/tags/servings) + notes sidebar */
.recipe-header-columns {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.recipe-header-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.recipe-header-tags .tags-row {
  justify-content: center;
}
.recipe-header-main .portion-adjuster {
  align-self: stretch;
  justify-content: center;
}

/* Notes section */
.recipe-notes-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  max-width: 400px;
}
.recipe-notes-section.has-notes {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-card));
}
.notes-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
.notes-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
}
.notes-input-row textarea {
  flex: 1;
  resize: none;
  overflow: hidden;
  min-height: 36px;
  font-size: 0.88rem;
}
.notes-submit-btn {
  flex-shrink: 0;
}
#notes-list:not(:empty) {
  margin-top: 6px;
  width: 100%;
}
.notes-show-all {
  width: 100%;
  margin-top: 4px;
}

@media (min-width: 768px) {
  .recipe-header-columns {
    flex-direction: row;
    gap: 16px;
    align-items: stretch;
  }
  .recipe-header-main {
    flex: 1;
    min-width: 0;
  }
  .recipe-header-tags .tags-row {
    justify-content: flex-start;
  }
  .recipe-header-main .portion-adjuster {
    align-self: stretch;
  }
  .recipe-notes-section {
    width: 40%;
    max-width: none;
    flex-shrink: 0;
  }
}

.note-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.note-text {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 6px;
}
.note-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-light);
  flex-wrap: wrap;
}
.note-time {
  flex-shrink: 0;
}
.note-edited {
  font-style: italic;
  opacity: 0.7;
}
.note-source {
  color: var(--primary);
  text-decoration: none;
}
.note-source:hover {
  text-decoration: underline;
}
.note-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.note-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.note-action-btn:hover {
  background: var(--border);
  color: var(--text);
}
.note-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.empty-notes {
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 8px 0;
}
.notes-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 16px;
}
.notes-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
/* Plan notes inline (list/week views) */
.plan-notes-inline {
  margin-bottom: 12px;
  max-width: 600px;
}

/* Plan note add form (modal) */
.plan-note-form {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 420px;
  width: 90vw;
}
.plan-note-form h3 {
  margin-bottom: 12px;
  font-family: var(--font-heading);
}
.plan-note-form textarea {
  width: 100%;
  resize: vertical;
  margin-bottom: 12px;
}
.plan-note-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Overview week header with note */
.overview-week-header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}
.overview-week-note {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  transition: white-space 0.3s, max-height 0.3s;
}
/* When the week card is active, show full note text */
.overview-week-box.active .overview-week-note {
  color: rgba(255,255,255,0.75);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
.overview-week-note-btn,
.mp-add-note-btn {
  flex-shrink: 0;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.overview-week-note-btn svg,
.mp-add-note-btn svg {
  width: 1em;
  height: 1em;
  font-size: 1rem;
}
.overview-week-header:hover .overview-week-note-btn,
.overview-week-box.active .overview-week-note-btn,
.overview-week-note-btn:hover,
.mp-add-note-btn:hover {
  opacity: 1;
}
.home-notes-list {
  max-width: 600px;
}

/* === Collections === */
.card-action-btn.in-collection {
  background: rgba(193, 105, 79, 0.2);
  color: var(--accent);
}
.card-action-btn.in-collection svg { stroke: var(--accent); }

/* Collection popover — same structure as quick-add-popover */
.collection-popover {
  z-index: 150;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 8px;
  max-width: 280px;
}
.collection-popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  min-height: 40px;
  font-size: 0.85rem;
  cursor: pointer;
}
.collection-popover-row:hover { background: var(--bg); }
.collection-popover-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.collection-popover-row label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.collection-popover-row .col-count {
  color: var(--text-light);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.collection-popover-new {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}
.collection-popover-new input {
  flex: 1;
  font-size: 0.82rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.collection-popover-new button {
  flex-shrink: 0;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.collection-popover-new button:hover { opacity: 0.85; }

/* Collection scroll rows on home page */
.collection-scroll-row {
  position: relative;
  margin: 0 -6px;
  padding: 0 6px;
}
.scroll-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 6px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab;
}
.scroll-track::-webkit-scrollbar { display: none; }
.scroll-track.grabbing {
  cursor: grabbing;
  user-select: none;
}
.scroll-track.grabbing > * { pointer-events: none; }

.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  opacity: 0;
}
.collection-scroll-row:hover .scroll-arrow { opacity: 1; }
.scroll-arrow:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.scroll-arrow.prev { left: 2px; }
.scroll-arrow.next { right: 2px; }
.scroll-arrow.hidden { display: none; }

/* Hide arrows on touch devices */
@media (hover: none) {
  .scroll-arrow { display: none; }
}

/* Collection detail header */
.collection-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.collection-detail-header h1 { margin: 0; }
.collection-detail-header p {
  color: var(--text-light);
  margin: 4px 0 0;
  font-size: 0.9rem;
}
.collection-detail-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Collection grid cards */
.collection-grid-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.collection-grid-card:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
}
.collection-grid-card img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
}
.collection-grid-card .card-placeholder {
  width: 100%;
  aspect-ratio: 3/2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 2rem;
}
.collection-grid-card .card-body {
  padding: 12px;
}
.collection-grid-card h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}
.collection-grid-card .card-meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Collection add-recipes panel */
.col-add-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 20px;
}
.col-add-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.col-add-search-row input {
  flex: 1;
  min-width: 0;
}
.col-add-results-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.col-add-result-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.col-add-result-card:hover { background: var(--bg); }
.col-add-result-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.col-add-result-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.col-add-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 1.2rem;
}
.col-add-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.col-add-result-title {
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-add-result-meta {
  font-size: 0.75rem;
  color: var(--text-light);
}
.col-add-result-card .btn {
  flex-shrink: 0;
  min-width: 60px;
}
.col-add-added { color: var(--text-light); }
.col-add-section {
  margin-top: 12px;
}
.col-add-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px 8px;
}

/* === Add Sheet (quick-action bottom sheet) === */

.bottom-nav-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.bottom-nav-add:hover, .bottom-nav-add.active { color: var(--accent); }

.add-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.add-sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.add-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}
.add-sheet.open {
  transform: translateY(0);
}

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

.add-sheet-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.add-sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.add-sheet-option:hover, .add-sheet-option:active {
  background: var(--bg-offset, rgba(0,0,0,0.04));
}
.add-sheet-option svg {
  flex-shrink: 0;
  color: var(--text-light);
}
.add-sheet-option div {
  display: flex;
  flex-direction: column;
}
.add-sheet-option strong {
  font-size: 0.95rem;
  font-weight: 600;
}
.add-sheet-option span {
  font-size: 0.8rem;
  color: var(--text-light);
}

.add-sheet-ai svg {
  color: var(--accent);
}

/* === AI Recipe Generation === */

.ai-draft-card {
  margin-top: 20px;
  padding: 20px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ai-draft-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-draft-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.ai-draft-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.ai-draft-desc {
  color: var(--text-light);
  margin: 0 0 12px;
}

.ai-draft-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.ai-draft-meta span::before {
  content: "\b7  ";
}

.ai-draft-meta span:first-child::before {
  content: "";
}

.ai-draft-section {
  margin-bottom: 16px;
}

.ai-draft-section h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.ai-draft-section ul,
.ai-draft-section ol {
  margin: 0;
  padding-left: 20px;
}

.ai-draft-section li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.ai-draft-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ai-draft-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-similar-recipes {
  margin-top: 16px;
  margin-bottom: 8px;
  padding: 14px;
  border-radius: 10px;
  background: var(--bg-offset, var(--bg-card));
  border: 1px solid var(--border);
}

.ai-similar-item {
  display: block;
  padding: 6px 0;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

.ai-similar-item:hover {
  text-decoration: underline;
}
