/* ════════════════════════════════════════════════════════
   Meal Planner — RTL Hebrew Family App
   Design: "The Kitchen Table" — Warm Terracotta + Cream
   Mobile-first · Heebo · RTL-first
   ════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700;800;900&display=swap');

/* ─── Design Tokens ──────────────────────────────────────── */
:root {
  /* Core palette — Terracotta + Cream */
  --clay:          #C4593A;   /* primary action — warm terracotta */
  --clay-dark:     #A0422A;   /* hover / deep state */
  --clay-mid:      #E07A5A;   /* lighter terracotta */
  --clay-soft:     #FAE8E2;   /* very light blush — card fill */
  --clay-tint:     #FDF3EF;   /* near-white warm background */

  --amber:         #D4924A;   /* secondary accent — warm amber */
  --amber-soft:    #FBF0E1;   /* amber fill */

  --sage:          #6B8F71;   /* muted sage — ingredient tags */
  --sage-soft:     #E8F0E9;   /* sage fill */

  /* Surfaces */
  --bg:            #F7F3EE;   /* warm parchment — body background */
  --surface:       #FEFCF9;   /* card background — warm white */
  --surface-warm:  #FAF4EE;   /* slightly warmer surface */

  /* Text */
  --text:          #2C1A0E;   /* deep warm brown — primary text */
  --text-mid:      #5C3D2A;   /* medium brown */
  --text-soft:     #9C7B6A;   /* muted warm text */
  --text-ghost:    #C4A898;   /* placeholder / disabled */

  /* Structure */
  --border:        #E8DDD5;   /* warm border */
  --border-strong: #D4C4B8;   /* stronger separator */
  --divider:       rgba(196, 89, 58, 0.12); /* clay-tinted divider */

  /* Elevation */
  --shadow-sm:     0 1px 3px rgba(44, 26, 14, 0.06), 0 1px 8px rgba(44, 26, 14, 0.04);
  --shadow-md:     0 4px 12px rgba(44, 26, 14, 0.10), 0 2px 4px rgba(44, 26, 14, 0.06);
  --shadow-card:   0 2px 8px rgba(44, 26, 14, 0.08);
  --shadow-float:  0 8px 24px rgba(44, 26, 14, 0.14), 0 2px 6px rgba(44, 26, 14, 0.08);

  /* Geometry */
  --radius:        14px;
  --radius-sm:     9px;
  --radius-xs:     6px;
  --radius-pill:   100px;

  /* Touch */
  --touch:         48px;

  /* Motion */
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:   cubic-bezier(0.45, 0, 0.55, 1);
  --t-fast:        0.15s;
  --t-base:        0.22s;
  --t-slow:        0.35s;
}

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

html {
  direction: rtl;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: 'Heebo', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: 'Heebo', sans-serif;
  direction: rtl;
}

/* ─── App Shell ──────────────────────────────────────────── */
#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 0 88px 0;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────── */
.app-header {
  background: var(--clay);
  color: #FEFCF9;
  padding: 18px 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);

  /* Subtle warm texture via layered gradient */
  background-image:
    radial-gradient(ellipse at 110% -20%, rgba(255, 220, 180, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at -10% 120%, rgba(160, 66, 42, 0.4) 0%, transparent 50%);
}

/* Noise texture overlay on header */
.app-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
  border-radius: inherit;
}

.header-wordmark {
  display: flex;
  flex-direction: column;
}

.app-header h1,
.app-header .app-header-h1,
#header-context {
  font-size: 1.35rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.03em;
  line-height: 1.2 !important;
  color: #FEFCF9 !important;
}

.header-sub {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #FEFCF9;
}

/* Header logo mark */
.header-logo {
  font-size: 1.4rem;
  margin-left: 6px; /* RTL: visual right side */
  display: inline-block;
  transform: rotate(-8deg);
  line-height: 1;
}

.btn-bank {
  background: rgba(255, 255, 255, 0.15);
  color: #FEFCF9;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t-base) var(--ease-out), border-color var(--t-base);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-bank:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-bank:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.97);
}

/* ─── Views (toggle visibility) ─────────────────────────── */
.view {
  display: none;
  padding: 20px 16px;
  animation: viewFadeIn 0.28s var(--ease-out);
}

.view.active {
  display: block;
}

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

/* ─── Section Title ──────────────────────────────────────── */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── View 1: Planning ───────────────────────────────────── */
.plan-intro {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--surface-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-right: 3px solid var(--amber);
}

/* Day Cards */
.day-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1.5px solid var(--border);
  border-right: 4px solid var(--border);  /* RTL: visual left accent */
  transition:
    border-color var(--t-base) var(--ease-out),
    background var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    transform var(--t-fast) var(--ease-out);

  /* Staggered entrance animation */
  opacity: 0;
  animation: cardSlideIn 0.4s var(--ease-out) forwards;
}

.day-card:nth-child(1) { animation-delay: 0.05s; }
.day-card:nth-child(2) { animation-delay: 0.10s; }
.day-card:nth-child(3) { animation-delay: 0.15s; }
.day-card:nth-child(4) { animation-delay: 0.20s; }
.day-card:nth-child(5) { animation-delay: 0.25s; }
.day-card:nth-child(6) { animation-delay: 0.30s; }
.day-card:nth-child(7) { animation-delay: 0.35s; }

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

.day-card:active {
  transform: scale(0.99);
}

/* Filled state — meal chosen */
.day-card.has-meal {
  background: var(--clay-tint);
  border-color: var(--clay-mid);
  border-right-color: var(--clay);
  box-shadow: var(--shadow-card), inset 0 0 0 0 transparent;
}

.day-card.has-meal:active {
  transform: scale(0.99);
}

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

.day-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.day-date {
  font-size: 0.76rem;
  color: var(--text-ghost);
  margin-top: 1px;
  font-weight: 400;
}

.day-meal {
  font-size: 0.88rem;
  color: var(--clay);
  font-weight: 600;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-meal.empty {
  color: var(--text-ghost);
  font-weight: 400;
  font-style: italic;
}

/* ─── Buttons — Planning View ────────────────────────────── */
.btn-change {
  background: var(--clay-soft);
  color: var(--clay-dark);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 40px;
  min-width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast);
  flex-shrink: 0;
  border: 1px solid rgba(196, 89, 58, 0.18);
}

.btn-change:hover {
  background: #F5D5CC;
}

.btn-change:active {
  transform: scale(0.96);
}

.btn-choose {
  background: var(--clay);
  color: #FEFCF9;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 40px;
  min-width: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast), box-shadow var(--t-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(196, 89, 58, 0.30);
}

.btn-choose:hover {
  background: var(--clay-dark);
  box-shadow: 0 3px 10px rgba(196, 89, 58, 0.40);
}

.btn-choose:active {
  transform: scale(0.96);
}

/* Primary CTA — full width, prominent */
.btn-primary {
  background: var(--clay);
  color: #FEFCF9;
  border-radius: var(--radius);
  padding: 16px 24px;
  font-size: 1.05rem;
  font-weight: 800;
  width: 100%;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  letter-spacing: -0.01em;
  transition:
    background var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    transform var(--t-fast);
  box-shadow: 0 4px 14px rgba(196, 89, 58, 0.38), 0 1px 3px rgba(196, 89, 58, 0.2);
  position: relative;
  overflow: hidden;
}

/* Shine sweep on primary button */
.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  right: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  transition: right 0.5s ease;
  pointer-events: none;
}

.btn-primary:hover::before {
  right: 120%;
}

.btn-primary:hover {
  background: var(--clay-dark);
  box-shadow: 0 6px 20px rgba(196, 89, 58, 0.42), 0 2px 6px rgba(196, 89, 58, 0.22);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(196, 89, 58, 0.30);
}

.btn-primary:disabled {
  background: var(--border-strong);
  color: var(--text-ghost);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary:disabled::before {
  display: none;
}

/* ─── View 2: Shopping List ──────────────────────────────── */
.list-header-info {
  background: var(--amber-soft);
  border-radius: var(--radius);
  border: 1px solid rgba(212, 146, 74, 0.25);
  border-right: 4px solid var(--amber);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  color: var(--text-mid);
  font-weight: 600;
  line-height: 1.45;
}

/* Shopping section — chip-style headers */
.shopping-section {
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.shopping-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--surface);
  background: var(--clay-mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Category icon dot */
.shopping-section-header::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  flex-shrink: 0;
}

/* Shopping items */
.shopping-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast), opacity var(--t-base);
  position: relative;
}

.shopping-item:last-child {
  border-bottom: none;
}

.shopping-item:active {
  background: var(--clay-tint);
}

/* Custom checkbox */
.shopping-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface);
  transition:
    background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    transform var(--t-fast);
  position: relative;
}

.shopping-item input[type="checkbox"]:checked {
  background: var(--clay);
  border-color: var(--clay);
  transform: scale(1.05);
}

/* Checkmark via pseudo-element */
.shopping-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 5px;
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
  animation: checkPop 0.15s var(--ease-out);
}

@keyframes checkPop {
  from { transform: rotate(-45deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(-45deg) scale(1); opacity: 1; }
}

.shopping-item label {
  flex: 1;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.shopping-item.checked {
  opacity: 0.55;
}

.shopping-item.checked label {
  text-decoration: line-through;
  color: var(--text-soft);
}

.item-name {
  font-weight: 600;
  transition: color var(--t-base);
}

.item-qty {
  color: var(--text-soft);
  font-size: 0.82rem;
  white-space: nowrap;
  font-weight: 400;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

/* WhatsApp CTA — hero button */
.btn-whatsapp {
  background: #25D366;
  color: #fff;
  border-radius: var(--radius);
  padding: 17px 24px;
  font-size: 1.05rem;
  font-weight: 800;
  width: 100%;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  letter-spacing: -0.01em;
  transition:
    background var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    transform var(--t-fast);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.38), 0 1px 3px rgba(37, 211, 102, 0.2);
}

.btn-whatsapp:hover {
  background: #1EAF56;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.46);
}

.btn-whatsapp:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.30);
}

.btn-secondary {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 24px;
  font-size: 0.92rem;
  font-weight: 600;
  width: 100%;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  transition: border-color var(--t-base), color var(--t-base), background var(--t-fast);
}

.btn-secondary:hover {
  border-color: var(--clay-mid);
  color: var(--clay-dark);
  background: var(--clay-tint);
}

.btn-secondary:active {
  transform: scale(0.99);
}

/* ─── View 3: Meal Bank ──────────────────────────────────── */
.bank-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.search-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  min-height: var(--touch);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  background: var(--surface);
  color: var(--text);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, 0.10);
}

.btn-add-meal {
  background: var(--clay);
  color: #FEFCF9;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 800;
  min-height: var(--touch);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast), box-shadow var(--t-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(196, 89, 58, 0.28);
}

.btn-add-meal:hover {
  background: var(--clay-dark);
  box-shadow: 0 3px 10px rgba(196, 89, 58, 0.38);
}

.btn-add-meal:active {
  transform: scale(0.96);
}

/* Meal Cards */
.meal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 15px 18px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-right: 4px solid var(--clay-soft);  /* colored accent stripe */
  transition:
    border-right-color var(--t-base),
    box-shadow var(--t-base),
    transform var(--t-fast);

  opacity: 0;
  animation: cardSlideIn 0.4s var(--ease-out) forwards;
}

.meal-card:nth-child(1) { animation-delay: 0.04s; }
.meal-card:nth-child(2) { animation-delay: 0.09s; }
.meal-card:nth-child(3) { animation-delay: 0.14s; }
.meal-card:nth-child(4) { animation-delay: 0.19s; }
.meal-card:nth-child(5) { animation-delay: 0.24s; }
.meal-card:nth-child(6) { animation-delay: 0.29s; }
.meal-card:nth-child(n+7) { animation-delay: 0.34s; }

.meal-card:hover {
  border-right-color: var(--clay);
  box-shadow: var(--shadow-md);
}

.meal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.meal-card-name {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--text);
  letter-spacing: -0.015em;
}

.meal-card-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: var(--bg);
  color: var(--text-mid);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 36px;
  border: 1px solid var(--border);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}

.btn-icon:hover {
  background: var(--clay-soft);
  color: var(--clay-dark);
  border-color: rgba(196, 89, 58, 0.25);
}

.btn-icon:active {
  transform: scale(0.94);
}

.btn-icon.delete:hover {
  background: #FFEEEE;
  color: #C62828;
  border-color: rgba(198, 40, 40, 0.2);
}

/* Ingredient tags */
.meal-ingredients {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ingredient-tag {
  background: var(--sage-soft);
  color: var(--sage);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid rgba(107, 143, 113, 0.2);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 26, 14, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: backdropIn 0.22s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-backdrop.hidden {
  display: none;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: sheetSlideUp 0.32s var(--ease-out);

  /* Drag handle indicator */
  background-image: none;
}

/* Drag handle visual */
.modal::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  margin: 10px auto 0;
  flex-shrink: 0;
}

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

.modal-header {
  padding: 16px 20px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.btn-close {
  background: var(--bg);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}

.btn-close:hover {
  background: var(--clay-soft);
  border-color: var(--clay-mid);
  color: var(--clay-dark);
}

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

.modal-search {
  padding: 12px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.modal-search input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  min-height: var(--touch);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  background: var(--bg);
  color: var(--text);
}

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

.modal-search input:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, 0.10);
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
  overscroll-behavior: contain;
}

/* Meal picker list items */
.modal-meal-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  position: relative;
}

.modal-meal-item:last-child {
  border-bottom: none;
}

/* Left accent on hover */
.modal-meal-item::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3px;
  background: var(--clay);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform var(--t-fast) var(--ease-out);
  transform-origin: center;
}

.modal-meal-item:hover::before,
.modal-meal-item:active::before {
  transform: scaleY(1);
}

.modal-meal-item:hover,
.modal-meal-item:active {
  background: var(--clay-tint);
}

.modal-meal-name {
  font-size: 0.98rem;
  font-weight: 600;
  flex: 1;
  color: var(--text);
}

.modal-meal-count {
  font-size: 0.78rem;
  color: var(--text-ghost);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-add-new-meal {
  background: transparent;
  color: var(--clay-dark);
  border: 2px dashed var(--clay-mid);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  width: 100%;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.btn-add-new-meal:hover {
  background: var(--clay-soft);
  border-color: var(--clay);
}

/* ─── Meal Form (add/edit) ───────────────────────────────── */
.form-modal .modal {
  max-height: 95vh;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  min-height: var(--touch);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  background: var(--surface);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, 0.10);
}

.form-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.ingredients-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 10px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px 36px;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.ingredient-row input,
.ingredient-row select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.85rem;
  min-height: 40px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.ingredient-row input:focus,
.ingredient-row select:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, 0.08);
}

.btn-remove-ing {
  background: #FFF0F0;
  color: #C62828;
  border-radius: var(--radius-xs);
  width: 36px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background var(--t-fast), transform var(--t-fast);
  border: 1px solid rgba(198, 40, 40, 0.12);
}

.btn-remove-ing:hover {
  background: #FFD7D7;
}

.btn-remove-ing:active {
  transform: scale(0.92);
}

.btn-add-ingredient {
  background: var(--sage-soft);
  color: var(--sage);
  border-radius: var(--radius-xs);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 40px;
  transition: background var(--t-fast), transform var(--t-fast);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(107, 143, 113, 0.2);
}

.btn-add-ingredient:hover {
  background: #D4E6D6;
}

.btn-add-ingredient:active {
  transform: scale(0.96);
}

.form-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-save {
  background: var(--clay);
  color: #FEFCF9;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  flex: 1;
  min-height: var(--touch);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  box-shadow: 0 2px 8px rgba(196, 89, 58, 0.30);
}

.btn-save:hover {
  background: var(--clay-dark);
  box-shadow: 0 4px 12px rgba(196, 89, 58, 0.40);
}

.btn-save:active {
  transform: scale(0.98);
}

.btn-cancel {
  background: var(--bg);
  color: var(--text-mid);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  min-width: 80px;
  min-height: var(--touch);
  transition: border-color var(--t-base), background var(--t-fast);
}

.btn-cancel:hover {
  border-color: var(--text-soft);
  background: var(--surface);
}

/* ─── Empty States ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-soft);
}

.empty-state .empty-icon {
  font-size: 3.2rem;
  margin-bottom: 14px;
  opacity: 0.7;
  display: block;
}

.empty-state p {
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 240px;
  margin: 0 auto;
}

/* ─── Toast Notification ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--clay-tint);
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow-float);
  transition: transform 0.28s var(--ease-out), opacity 0.28s ease;
  opacity: 0;
  pointer-events: none;

  /* Left dot accent */
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clay-mid);
  flex-shrink: 0;
}

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

/* ─── Responsive — Desktop ───────────────────────────────── */
@media (min-width: 600px) {
  .app-header {
    border-radius: 0;
  }

  .modal-backdrop {
    align-items: center;
  }

  .modal {
    border-radius: var(--radius);
    max-height: 80vh;
    box-shadow: var(--shadow-float);
  }

  .modal::before {
    display: none; /* no drag handle on desktop */
  }

  .ingredient-row {
    grid-template-columns: 1fr 110px 140px 36px;
  }

  .day-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
}

/* ─── Reduced Motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .day-card, .meal-card {
    opacity: 1;
    animation: none;
  }
}

/* ─── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
