/* ==========================================================================
   Fork & Spoon — web app theme
   Mirrors lib/core/theme/app_theme.dart
   ========================================================================== */

:root {
  /* Colors — primary (AppTheme) */
  --title: #0A2533;
  --accent: #70B9BE;
  --bg-page: #FFEBAB;          /* pageBackgroundLight */
  --bg-card: #FFFFFF;
  --search-bg: #F3F4F6;
  --desc: #6B7280;
  --border: #E5E7EB;
  --light-accent: #EDF3F6;
  --dark: #1B465C;             /* themeOneDark */
  --red: #E56544;              /* themeOneRed */
  --black: #1D1A11;            /* themeOneBlack */
  --grey: #A8A8A8;
  --muted: #748189;
  --star: #FDB022;
  --error: #E57373;
  --success: #4CAF50;
  --warning: #FFA726;
  --light-border: #E8EFF1;
  --tab-bg: #F2F4F5;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-xxl: 24px;
  --r-dialog: 34px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
  --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.1);

  --font: 'Outfit', system-ui, -apple-system, sans-serif;

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--title);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--title); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.2px; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }
img { max-width: 100%; }

/* ── Boot splash ─────────────────────────────────── */
.boot-splash {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.boot-splash img { width: 140px; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(10, 37, 51, 0.15);
  border-top-color: var(--title);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.small { width: 18px; height: 18px; border-width: 2px; }
.spinner.light { border-color: rgba(255,255,255,0.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ───────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid rgba(10, 37, 51, 0.08);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 50;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 22px;
}
.sidebar .logo img { width: 130px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: var(--title);
  font-size: 15px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
  position: relative;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--search-bg); }
.nav-item.active { background: var(--light-accent); font-weight: 600; }
.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar .sidebar-footer { margin-top: auto; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px 80px;
  max-width: 1240px;
  width: 100%;
}

/* Mobile bottom nav — floating white pill, like the app */
.bottom-nav {
  display: none;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 14px;
  background: var(--bg-card);
  border-radius: var(--r-pill);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  z-index: 60;
  padding: 6px 10px;
  justify-content: space-around;
}
.bottom-nav .nav-item {
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  padding: 8px 10px;
  align-items: center;
  width: auto;
  margin: 0;
  border-radius: var(--r-lg);
}
.bottom-nav .nav-item .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  margin: 0;
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 110px; }
  .bottom-nav { display: flex; }
}

/* ── Page header ─────────────────────────────────── */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head .sub { color: var(--desc); margin-top: 4px; font-size: 15px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons (AppTheme button styles) ────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-xl);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  border: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--black); color: #fff; }
.btn-dark { background: var(--title); color: #fff; border-radius: var(--r-md); }
.btn-secondary {
  background: #fff;
  color: var(--title);
  border: 1.5px solid var(--border);
}
.btn-light-accent { background: var(--light-accent); color: var(--title); border-radius: var(--r-md); }
.btn-danger { background: var(--error); color: #fff; }
.btn-text { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn-red { background: var(--red); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--r-md); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--title);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--search-bg); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.plain { border: none; background: transparent; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-light);
  padding: 20px;
}

/* ── Forms ───────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--title);
}
.input, textarea.input, select.input {
  width: 100%;
  background: var(--search-bg);
  border: none;
  outline: none;
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-size: 15px;
  color: var(--title);
}
.input:focus { box-shadow: 0 0 0 2px var(--accent); }
.input::placeholder { color: rgba(10, 37, 51, 0.4); }
textarea.input { resize: vertical; min-height: 90px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: var(--r-md);
  padding: 0 16px;
  box-shadow: var(--shadow-light);
  flex: 1;
  min-width: 200px;
}
.search-bar svg { width: 18px; height: 18px; color: rgba(10, 37, 51, 0.4); flex-shrink: 0; }
.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  padding: 13px 0;
  font-size: 15px;
  width: 100%;
  color: var(--title);
}

/* ── Chips / filters ─────────────────────────────── */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--title);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
}
.chip.active {
  background: var(--title);
  color: #fff;
  border-color: var(--title);
}
.tag {
  background: var(--light-accent);
  color: var(--dark);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  display: inline-block;
}

/* ── Recipe grid ─────────────────────────────────── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}
@media (max-width: 600px) {
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

.recipe-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-light);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-medium); }
.recipe-card .thumb {
  aspect-ratio: 3 / 2;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.recipe-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .thumb svg { width: 36px; height: 36px; color: var(--accent); }
.recipe-card .thumb .rating-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--title);
}
.recipe-card .body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.recipe-card .title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--dark);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: auto;
}
.recipe-card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.recipe-card .meta svg { width: 13px; height: 13px; }

/* ── Recipe detail ───────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1020px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.detail-hero {
  border-radius: var(--r-xxl);
  overflow: hidden;
  aspect-ratio: 21 / 9;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  position: relative;
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero svg { width: 56px; height: 56px; color: var(--accent); }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-light);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.stat svg { width: 16px; height: 16px; color: var(--accent); }
.stat .lbl { color: var(--muted); font-weight: 500; }

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.nutrition-grid .cell {
  background: var(--light-accent);
  border-radius: var(--r-md);
  padding: 12px 8px;
  text-align: center;
}
.nutrition-grid .cell b { display: block; font-size: 16px; }
.nutrition-grid .cell span { font-size: 11.5px; color: var(--muted); }

.ingredient-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--light-border);
  font-size: 14.5px;
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row .amt { font-weight: 700; white-space: nowrap; }
.ingredient-row .note { color: var(--muted); font-size: 12.5px; }
.ingredient-section {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  margin: 14px 0 2px;
}

.servings-stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--light-accent);
  border-radius: var(--r-pill);
  padding: 6px;
}
.servings-stepper button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-size: 17px;
  font-weight: 700;
  color: var(--title);
  display: flex;
  align-items: center;
  justify-content: center;
}
.servings-stepper .value { font-weight: 700; min-width: 70px; text-align: center; font-size: 14px; }

.step-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--light-border);
}
.step-item:last-child { border-bottom: none; }
.step-item .num {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--title);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-item .step-ing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.step-item .step-ing .tag { background: var(--search-bg); color: var(--muted); font-weight: 500; }

.stars { display: inline-flex; gap: 3px; }
.stars svg { width: 22px; height: 22px; color: #D8DDE0; }
.stars svg.on { color: var(--star); }
.stars.clickable svg { cursor: pointer; }

/* ── Cook mode ───────────────────────────────────── */
.cook-mode {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 28px;
}
.cook-mode .cook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.cook-mode .progress {
  flex: 1;
  height: 6px;
  background: rgba(10, 37, 51, 0.12);
  border-radius: 3px;
  overflow: hidden;
}
.cook-mode .progress i {
  display: block;
  height: 100%;
  background: var(--title);
  border-radius: 3px;
  transition: width 0.25s ease;
}
.cook-mode .cook-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  gap: 22px;
}
.cook-mode .step-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--red);
}
.cook-mode .instruction { font-size: clamp(22px, 3.2vw, 34px); font-weight: 600; line-height: 1.35; }
.cook-mode .cook-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* ── Recipe card: add-to-day affordance ──────────── */
.recipe-card .thumb { position: relative; }
.card-add-day {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--title);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-light);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  z-index: 2;
}
.recipe-card:hover .card-add-day { opacity: 1; transform: scale(1); }
.card-add-day:hover { background: var(--title); color: #fff; }
.card-add-day svg { width: 16px; height: 16px; }
@media (hover: none) {
  .card-add-day { opacity: 1; transform: scale(1); }
}
.card-day-tags {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  z-index: 2;
}
.card-day-tag {
  background: var(--title);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 6px;
}

/* ── Day picker (Pick a day) ─────────────────────── */
.day-pick-list { display: flex; flex-direction: column; gap: 8px; }
.day-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(229, 231, 235, 0.7);
  background: #fff;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.day-pick-row:hover:not(:disabled) { border-color: var(--accent); background: var(--light-accent); }
.day-pick-row:active:not(:disabled) { transform: scale(0.99); }
.day-pick-row.today { background: var(--dark); border-color: var(--dark); }
.day-pick-row.today .dp-name { color: #fff; }
.day-pick-row.full { opacity: 0.55; cursor: default; }
.day-pick-row .dp-name { font-size: 15px; font-weight: 600; color: var(--title); }
.day-pick-row .dp-today {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: var(--r-sm);
}
.dp-thumbs { margin-left: auto; display: flex; align-items: center; }
.dp-thumbs img, .dp-thumbs .dp-ph {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  margin-left: -8px;
  border: 2px solid #fff;
  background: var(--search-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.day-pick-row.today .dp-thumbs img, .day-pick-row.today .dp-thumbs .dp-ph { border-color: var(--dark); }
.dp-thumbs .dp-ph svg { width: 14px; height: 14px; color: var(--grey); }
.dp-add {
  margin-left: 12px;
  display: inline-flex;
  color: var(--accent);
}
.day-pick-row.today .dp-add { color: rgba(255, 255, 255, 0.85); }
.dp-add svg { width: 20px; height: 20px; }
.dp-full { margin-left: 12px; font-size: 11px; font-weight: 600; color: var(--muted); }

/* ── Week menu — calendar grid ───────────────────── */
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}
.cal-day { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cal-day-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 2px;
}
.cal-dow {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-date { font-size: 13px; font-weight: 700; color: var(--title); }
.cal-day.today .cal-dow { color: var(--red); }
.cal-day.today .cal-date { color: var(--red); }
.cal-today-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  align-self: center;
}
.cal-cells { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cal-cell.filled { box-shadow: var(--shadow-light); background: var(--light-accent); }
.cal-cell.filled:hover { transform: translateY(-2px); box-shadow: var(--shadow-medium); }
.cal-cell.filled img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cal-cell .cell-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.cal-cell .cell-ph svg { width: 28px; height: 28px; color: var(--accent); }
.cal-cell .cell-title {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 8px 7px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.74), transparent);
  overflow: hidden;
}
.cal-cell .cell-title > span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}
.cal-cell .cell-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--title);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.cal-cell.filled:hover .cell-remove { opacity: 1; transform: scale(1); }
.cal-cell .cell-remove svg { width: 13px; height: 13px; }
.cal-cell.empty {
  border: 2px dashed rgba(10, 37, 51, 0.28);
  background: rgba(10, 37, 51, 0.015);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.cal-cell.empty:hover { border-color: var(--accent); color: var(--accent); background: var(--light-accent); }
.cal-cell.empty svg { width: 24px; height: 24px; }

@media (hover: none) {
  .cal-cell .cell-remove { opacity: 1; transform: scale(1); }
}

/* Mobile: transpose columns into per-day rows with a horizontal cell strip */
@media (max-width: 720px) {
  .cal { grid-template-columns: 1fr; gap: 14px; }
  .cal-day {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-light);
    padding: 10px 12px;
  }
  .cal-day.today { box-shadow: 0 0 0 2px var(--red), var(--shadow-light); }
  .cal-day-head {
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 42px;
    flex-shrink: 0;
  }
  .cal-cells {
    flex-direction: row;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .cal-cells::-webkit-scrollbar { display: none; }
  .cal-cell {
    width: 84px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
  }
}

.meal-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--search-bg);
  border-radius: var(--r-md);
  padding: 8px;
  cursor: pointer;
}
.meal-slot:hover { background: var(--light-accent); }
.meal-slot img, .meal-slot .ph {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.meal-slot .ph svg { width: 18px; height: 18px; color: var(--accent); }
.meal-slot .name {
  font-size: 13px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meal-slot .remove { margin-left: auto; }
.meal-slot.empty { border: 1.5px dashed var(--border); background: transparent; color: var(--muted); justify-content: center; font-size: 13px; }
.meal-slot.empty:hover { border-color: var(--accent); color: var(--accent); }
.meal-slot .ms-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meal-slot .ms-days { display: flex; flex-wrap: wrap; gap: 4px; }
.meal-slot .ms-day {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--light-accent);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.6;
}
.meal-slot .ms-add {
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--accent);
  flex-shrink: 0;
}
.meal-slot:hover .ms-add { opacity: 1; }

/* ── Shopping list ───────────────────────────────── */
.shop-section { margin-bottom: 14px; }
.drag-handle {
  cursor: grab;
  color: var(--grey);
  font-size: 13px;
  letter-spacing: -2px;
  user-select: none;
  padding: 0 2px;
}
.shop-item.dragging, .shop-section.dragging { opacity: 0.4; }
.shop-item.drop-above { box-shadow: 0 -2px 0 var(--accent); }
.shop-section.drop-above { outline: 2px solid var(--accent); outline-offset: 2px; }
.shop-section.drop-into { outline: 2px dashed var(--accent); outline-offset: 2px; }
.sec-head .drag-handle { cursor: grab; }
.shop-section .sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--light-border);
}
.shop-item:last-child { border-bottom: none; }
.shop-item .check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.shop-item .check svg { width: 14px; height: 14px; color: #fff; }
.shop-item.checked .check { background: var(--accent); border-color: var(--accent); }
.shop-item.checked .name { text-decoration: line-through; color: var(--muted); }
.shop-item .amount { color: var(--muted); font-size: 13px; white-space: nowrap; }
.shop-item .del { margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.shop-item:hover .del { opacity: 1; }
@media (max-width: 900px) { .shop-item .del { opacity: 1; } }

/* ── Chat ────────────────────────────────────────── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 420px;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 16px;
}
.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: var(--r-xl);
  font-size: 14.5px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.bubble.user {
  align-self: flex-end;
  background: var(--title);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.model {
  align-self: flex-start;
  background: #fff;
  box-shadow: var(--shadow-light);
  border-bottom-left-radius: 6px;
}
.chat-input-row {
  display: flex;
  gap: 10px;
  background: #fff;
  border-radius: var(--r-pill);
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow-medium);
  align-items: center;
}
.chat-input-row input { flex: 1; border: none; outline: none; font-size: 15px; background: transparent; color: var(--title); }
.chat-input-row .send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--red);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-input-row .send svg { width: 18px; height: 18px; }

.menu-proposal-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--light-border);
}
.menu-proposal-row:last-of-type { border-bottom: none; }
.menu-proposal-row img, .menu-proposal-row .ph {
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.menu-proposal-row .ph svg { width: 18px; height: 18px; color: var(--accent); }

/* ── Auth ────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-page);
}
.auth-page .logo { width: 180px; margin-bottom: 10px; }
.auth-page .tagline { color: var(--title); opacity: 0.75; margin-bottom: 28px; font-size: 15px; text-align: center; }
.auth-card {
  background: #fff;
  border-radius: var(--r-xxl);
  box-shadow: var(--shadow-medium);
  width: 100%;
  max-width: 420px;
  padding: 32px;
}
.auth-card h2 { margin-bottom: 20px; text-align: center; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--desc); }
.auth-switch a { font-weight: 600; cursor: pointer; }
.social-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--title);
}
.social-btn.apple { background: var(--black); color: #fff; border-color: var(--black); }
.social-btn .social-icon { display: inline-flex; width: 18px; height: 18px; }
.social-btn .social-icon svg { width: 18px; height: 18px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12.5px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--light-border);
}

.form-error {
  background: rgba(229, 115, 115, 0.12);
  color: #C0392B;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--r-dialog);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal.wide { max-width: 760px; }
.modal h3 { margin-bottom: 16px; font-size: 20px; }
.modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}

/* ── Toast ───────────────────────────────────────── */
#toast-root {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--title);
  color: #fff;
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-medium);
  animation: toast-in 0.25s ease;
  max-width: 90vw;
}
.toast.error { background: var(--error); }
.toast.success { background: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Home ────────────────────────────────────────── */
.hero-card {
  background: var(--dark);
  color: #fff;
  border-radius: var(--r-xxl);
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 240px;
  cursor: pointer;
}
.hero-card .hero-text { padding: 30px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.hero-card .hero-text .kicker {
  color: var(--bg-page);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.hero-card .hero-text h2 { color: #fff; font-size: 26px; }
.hero-card .hero-text p { color: rgba(255,255,255,0.75); font-size: 14px; }
/* The image is taken out of flow so a tall photo can never stretch the
   card — the text column decides the height and the photo crops to fit. */
.hero-card .hero-img { background: var(--light-accent); position: relative; min-height: 0; }
.hero-card .hero-img svg { width: 56px; height: 56px; color: var(--accent); }
.hero-card .hero-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@media (max-width: 700px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-card .hero-img { order: -1; aspect-ratio: 2 / 1; }
}

/* ── Today's menu (home hero) ─────────────────────────
   One card that adapts to 0–4 planned dishes. */
.today-menu {
  background: var(--dark);
  color: #fff;
  border-radius: var(--r-xxl);
  padding: 24px;
  overflow: hidden;
}
.today-menu .tm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.today-menu .tm-head .kicker {
  color: var(--bg-page);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.today-menu .tm-head h2 { color: #fff; font-size: 24px; margin-top: 4px; }
.tm-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.tm-link:hover { color: #fff; }
.tm-link svg { width: 15px; height: 15px; }

/* Dish tiles — count class drives columns; container height stays fixed so
   the card never towers on days with only 1–2 dishes. */
.tm-dishes {
  display: grid;
  gap: 14px;
  height: 230px;     /* same height regardless of dish count */
}
.tm-dishes.count-1 { grid-template-columns: 1fr; height: 270px; }
.tm-dishes.count-2 { grid-template-columns: repeat(2, 1fr); }
.tm-dishes.count-3 { grid-template-columns: repeat(3, 1fr); }
.tm-dishes.count-4 { grid-template-columns: repeat(4, 1fr); }

.tm-dish {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  background: var(--light-accent);
  /* height fills the grid row — no aspect-ratio needed */
}
.tm-dish img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.tm-dish:hover img { transform: scale(1.05); }
.tm-dish .tm-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tm-dish .tm-ph svg { width: 40px; height: 40px; color: var(--accent); }
.tm-grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.28) 48%, rgba(0, 0, 0, 0) 78%);
}
.tm-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tm-title {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tm-dishes.count-1 .tm-title { font-size: 26px; }
.tm-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12.5px;
  font-weight: 500;
}
.tm-time svg { width: 13px; height: 13px; }

/* Empty state — looks intentional, not broken. */
.today-menu.empty .tm-empty {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.tm-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.tm-empty-icon svg { width: 26px; height: 26px; color: var(--bg-page); }
.tm-empty > div { flex: 1; min-width: 180px; }
.tm-empty-title { color: #fff; font-size: 17px; font-weight: 600; }
.tm-empty-sub { color: rgba(255, 255, 255, 0.7); font-size: 13.5px; margin-top: 2px; }
.tm-cta { background: #fff; color: var(--title); flex-shrink: 0; }

/* Mobile: any count becomes a tidy snap-scroll row (single stays full-width).
   Selectors are scoped under .today-menu so they outrank the .count-N rules. */
@media (max-width: 700px) {
  .today-menu { padding: 18px; }
  .today-menu .tm-dishes {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 72%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -18px;
    padding: 0 18px 4px;
    height: auto;          /* override fixed desktop height */
  }
  .today-menu .tm-dishes .tm-dish { scroll-snap-align: start; aspect-ratio: 16 / 11; }
  .today-menu .tm-dishes.count-1 {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    margin: 0;
    padding: 0;
    height: auto;
  }
  .today-menu .tm-dishes.count-1 .tm-dish { aspect-ratio: 16 / 10; }
  .today-menu.empty .tm-empty { flex-direction: column; align-items: flex-start; }
  .tm-cta { width: 100%; }
}

/* Recipe-detail variant of the hero card */
.hero-card.recipe-hero {
  cursor: default;
  grid-template-columns: 1fr 1.1fr;
  min-height: 320px;
  margin-bottom: 20px;
}
.hero-card.recipe-hero .hero-text { padding: 34px; gap: 12px; }
.hero-card.recipe-hero .hero-text h2 { font-size: clamp(24px, 2.6vw, 34px); }
.hero-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--title);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.hero-pill svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.hero-pill .lbl { color: var(--muted); font-weight: 500; }
.hero-pill.soft {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.hero-card .hero-text .stars svg { width: 17px; height: 17px; color: rgba(255,255,255,0.25); }
.hero-card .hero-text .stars svg.on { color: var(--star); }
.hero-card .hero-text .src { font-size: 12.5px; color: rgba(255,255,255,0.55); }
.hero-card .hero-text .src a { color: var(--bg-page); }
@media (max-width: 700px) {
  .hero-card.recipe-hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-card.recipe-hero .hero-text { padding: 22px; }
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.quick-action {
  background: #fff;
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-light);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--title);
  transition: transform 0.15s ease;
}
.quick-action:hover { transform: translateY(-2px); }
.quick-action .qa-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quick-action .qa-icon svg { width: 21px; height: 21px; color: #fff; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0 14px;
}
.section-head a { font-size: 13.5px; font-weight: 600; cursor: pointer; }

/* ── Cookbooks (collage cards, like the app's sheet) ── */
.cookbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.cookbook-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-light);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cookbook-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-medium); }
.cookbook-card .collage {
  aspect-ratio: 16 / 10;
  display: flex;
  gap: 1px;
  background: var(--light-accent);
  overflow: hidden;
}
.cookbook-card .collage img { width: 100%; height: 100%; object-fit: cover; min-width: 0; flex: 1; }
.cookbook-card .collage.three > img { flex: 6; }
.cookbook-card .collage.three .col {
  flex: 4;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.cookbook-card .collage.three .col img { flex: 1; height: 50%; }
.cookbook-card .empty-collage { align-items: center; justify-content: center; }
.cookbook-card .empty-collage svg { width: 38px; height: 38px; color: rgba(10, 37, 51, 0.25); }
.cookbook-card .cb-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 10px 12px 14px;
}
.cookbook-card .cb-name { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.cookbook-card .cb-count { font-size: 12px; color: rgba(10, 37, 51, 0.5); font-weight: 500; margin-top: 3px; }
.cookbook-card .cb-options {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
}
.cookbook-card .cb-options svg { width: 14px; height: 14px; }

/* ── Notifications ───────────────────────────────── */
.notif-item {
  display: flex;
  gap: 14px;
  padding: 16px;
  align-items: flex-start;
}
.notif-item.unread { background: var(--light-accent); border-radius: var(--r-md); }
.notif-item .notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-item.unread .notif-icon { background: #fff; }
.notif-item .notif-icon svg { width: 18px; height: 18px; color: var(--accent); }
.notif-item .time { font-size: 12px; color: var(--muted); }

/* ── Profile ─────────────────────────────────────── */
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--light-border);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .lbl { font-weight: 600; font-size: 14.5px; }
.profile-row .val { color: var(--muted); font-size: 14px; }

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--light-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: var(--shadow-light);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar svg { width: 26px; height: 26px; color: var(--accent); }

.avatar-row { display: flex; gap: 12px; flex-wrap: wrap; }
.avatar-choice {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid transparent;
  background: var(--light-accent);
  padding: 0;
  overflow: hidden;
}
.avatar-choice img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-choice.selected { border-color: var(--accent); }

.subscription-card { cursor: pointer; transition: transform 0.15s ease; }
.subscription-card:hover { transform: translateY(-2px); }
.subscription-card > .row svg { width: 22px; height: 22px; color: var(--red); }

.credit-banner {
  background: var(--dark);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.credit-banner b { font-size: 26px; }
.credit-banner span { color: rgba(255,255,255,0.75); font-size: 13px; }

/* ── Recipe editor ───────────────────────────────── */
.editor-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--light-border);
}
.editor-section-head:first-child { margin-top: 0; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 14px; height: 14px; }

.editor-image-preview {
  aspect-ratio: 3 / 2;
  border-radius: var(--r-md);
  background: var(--light-accent);
  overflow: hidden;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.editor-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.editor-image-preview .ph svg { width: 32px; height: 32px; color: var(--accent); }

/* ── Misc ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty-state svg { width: 44px; height: 44px; color: var(--accent); margin-bottom: 12px; }
.empty-state h3 { color: var(--title); margin-bottom: 6px; }

.loading-block { display: flex; justify-content: center; padding: 60px 0; }

.divider { height: 1px; background: var(--light-border); margin: 18px 0; border: none; }

.seg-control {
  display: inline-flex;
  background: var(--tab-bg);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 2px;
}
.seg-control button {
  border: none;
  background: transparent;
  border-radius: 9px;
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.seg-control button.active { background: #fff; color: var(--title); box-shadow: var(--shadow-light); }

.row { display: flex; gap: 10px; align-items: center; }
.row > svg { width: 16px; height: 16px; flex-shrink: 0; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.ai-glow {
  background: linear-gradient(120deg, var(--red), #f0925f);
  color: #fff;
}
