/* ═══════════════════════════════════════════════════════════════════════
   MAALTIJDPLANNER – Complete Stylesheet
   Mobile-first dark theme with premium glassmorphism effects
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ────────────────────────────────────────── */
:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12141c;
  --bg-tertiary: #1a1d28;
  --bg-elevated: #222636;
  --bg-hover: #262a3a;

  --accent: #7c5cfc;
  --accent-hover: #6a4ae8;
  --accent-soft: rgba(124, 92, 252, 0.12);
  --accent-glow: rgba(124, 92, 252, 0.25);
  --secondary: #38bdf8;
  --secondary-soft: rgba(56, 189, 248, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(124, 92, 252, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  --header-height: 64px;
  --nav-height: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ─── App Layout ───────────────────────────────────────────────────── */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ─── Header ───────────────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  z-index: 50;
  background: rgba(10, 11, 16, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.header-content {
  padding: 0 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logout-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition);
}

.header-logout-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

#page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: -2px;
}

/* ─── Login Screen ────────────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 28px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 28px;
}

.login-screen .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.login-screen .btn-block {
  margin-top: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: left;
}

/* ─── Main Content ─────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--header-height) + var(--safe-top) + 16px) 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

#main-content::-webkit-scrollbar {
  width: 0;
}

/* ─── Bottom Navigation ────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 50;
  background: rgba(18, 20, 28, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition: all var(--transition);
  position: relative;
  min-width: 72px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-item svg {
  transition: transform var(--transition);
}

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

.nav-item.active svg {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
  transition: transform var(--transition);
}

.nav-item.active::before {
  transform: translateX(-50%) scaleX(1);
}

/* ─── Badge ────────────────────────────────────────────────────────── */
.badge {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

.badge.hidden {
  display: none;
}

/* ─── Week Selector ────────────────────────────────────────────────── */
.week-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.week-nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.week-nav-btn:hover,
.week-nav-btn:active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.week-label {
  flex: 1;
  text-align: center;
}

.week-number {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.week-dates {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.week-today-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.week-today-btn:hover {
  background: var(--accent-glow);
}

.week-today-btn.hidden {
  display: none;
}

/* ─── Day Cards ────────────────────────────────────────────────────── */
.days-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color var(--transition);
  animation: fadeSlideUp 0.3s ease both;
}

.day-card.today {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow-sm);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.day-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

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

.day-card.today .day-name {
  color: var(--accent);
}

.day-card.today .day-date {
  color: var(--accent);
  opacity: 0.7;
}

.meal-slots {
  display: flex;
  flex-direction: column;
}

.meal-slot {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  transition: background var(--transition);
}

.meal-slot + .meal-slot {
  border-top: 1px solid var(--border);
}

.meal-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  min-width: 44px;
}

.meal-add-btn {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  background: none;
}

.meal-add-btn:hover,
.meal-add-btn:active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.meal-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.meal-info:hover,
.meal-info:active {
  background: var(--bg-elevated);
}

.meal-emoji {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.meal-details {
  flex: 1;
  min-width: 0;
}

.meal-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-servings {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
}

.meal-remove-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-xs);
  font-size: 16px;
  font-weight: 700;
  transition: all var(--transition);
  flex-shrink: 0;
}

.meal-remove-btn:hover {
  background: var(--danger);
  color: white;
}

/* ─── Recipe Cards ─────────────────────────────────────────────────── */
.recipes-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all var(--transition);
}

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

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

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.category-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all var(--transition);
  cursor: pointer;
}

.chip:hover {
  background: var(--bg-tertiary);
}

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

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.recipe-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeSlideUp 0.3s ease both;
}

.recipe-card:hover,
.recipe-card:active {
  border-color: var(--border-hover);
  background: var(--bg-tertiary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.recipe-emoji {
  font-size: 36px;
  line-height: 1;
  display: block;
  margin-bottom: 10px;
}

.recipe-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recipe-meta-item {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 3px;
}

.recipe-category-badge {
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
}

/* ─── Grocery List ─────────────────────────────────────────────────── */
.grocery-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.grocery-progress-ring {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.grocery-progress-ring svg {
  transform: rotate(-90deg);
}

.grocery-progress-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 4;
}

.grocery-progress-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.grocery-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.grocery-summary-info {
  flex: 1;
}

.grocery-summary-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.grocery-summary-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
}

.grocery-categories {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grocery-category {
  animation: fadeSlideUp 0.3s ease both;
}

.grocery-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 4px;
}

.grocery-category-icon {
  font-size: 18px;
}

.grocery-category-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.grocery-category-count {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
}

.grocery-items {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  transition: all var(--transition);
  cursor: pointer;
}

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

.grocery-item:active {
  background: var(--bg-tertiary);
}

.grocery-item.checked {
  opacity: 0.5;
}

.grocery-item.checked .grocery-item-name {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.grocery-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-tertiary);
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.grocery-checkbox:checked {
  background: var(--success);
  border-color: var(--success);
}

.grocery-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  animation: checkpop 0.2s ease-out;
}

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

.grocery-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--transition);
}

.grocery-item-quantity {
  font-size: 12px;
  color: var(--text-tertiary);
}

.grocery-item-delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  opacity: 0;
}

.grocery-item:hover .grocery-item-delete,
.grocery-item:active .grocery-item-delete {
  opacity: 1;
}

.grocery-item-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.grocery-custom-section {
  margin-top: 20px;
}

.grocery-custom-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

/* ─── Add Item Bar ─────────────────────────────────────────────────── */
.add-item-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.add-item-bar .input {
  flex: 1;
}

/* ─── Modal / Bottom Sheet ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.modal-overlay.active {
  pointer-events: all;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-height: 92vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 2px;
  margin: 12px auto 8px;
  opacity: 0.5;
}

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

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

.modal-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 18px;
  transition: all var(--transition);
}

.modal-close-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

/* ─── Forms ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all var(--transition);
}

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

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

/* ─── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-flex {
  flex: 1;
}

/* ─── FAB ──────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  box-shadow: 0 4px 20px var(--accent-glow);
  z-index: 40;
  transition: all var(--transition);
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px var(--accent-glow);
}

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

.fab-secondary {
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 90px);
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-size: 20px;
  z-index: 39;
}

.fab-secondary:hover {
  box-shadow: 0 4px 20px var(--secondary-soft);
  border-color: var(--secondary);
}

/* ─── Toast ────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top) + 12px);
  left: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: all;
  backdrop-filter: blur(12px);
}

.toast.success {
  border-color: rgba(52, 211, 153, 0.3);
  background: linear-gradient(135deg, var(--success-soft), var(--bg-elevated));
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.3);
  background: linear-gradient(135deg, var(--danger-soft), var(--bg-elevated));
}

/* ─── Empty State ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  animation: fadeIn 0.4s ease;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.empty-state-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-tertiary);
  max-width: 280px;
  margin: 0 auto;
}

/* ─── Recipe Detail (Modal) ────────────────────────────────────────── */
.recipe-detail-emoji {
  font-size: 64px;
  text-align: center;
  margin-bottom: 12px;
}

.recipe-detail-name {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.recipe-detail-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.recipe-detail-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.recipe-detail-section {
  margin-bottom: 20px;
}

.recipe-detail-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ingredient-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.ingredient-item-name {
  font-size: 14px;
  color: var(--text-primary);
}

.ingredient-item-qty {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.instructions-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-line;
}

/* ─── Ingredient Form Rows ─────────────────────────────────────────── */
.ingredient-form-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.ingredient-form-row {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ing-form-top {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ing-form-bottom {
  display: grid;
  grid-template-columns: 80px 100px 1fr;
  gap: 8px;
}

.ingredient-form-row .input,
.ingredient-form-row .select {
  padding: 10px 10px;
  font-size: 13px;
}

.ingredient-remove-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  margin-top: 1px;
}

.ingredient-remove-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.add-ingredient-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  width: 100%;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.add-ingredient-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ─── Recipe Selector (in modal) ───────────────────────────────────── */
.recipe-selector-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
}

.recipe-selector-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
}

.recipe-selector-item:hover,
.recipe-selector-item:active {
  background: var(--bg-tertiary);
}

.recipe-selector-emoji {
  font-size: 28px;
  flex-shrink: 0;
}

.recipe-selector-info {
  flex: 1;
}

.recipe-selector-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.recipe-selector-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ─── Servings Selector ────────────────────────────────────────────── */
.servings-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 0;
}

.servings-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all var(--transition);
}

.servings-btn:hover {
  background: var(--accent);
  color: white;
}

.servings-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 48px;
  text-align: center;
}

.servings-label {
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: -8px;
}

/* ─── Animations ───────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes checkpop {
  0% {
    transform: rotate(45deg) scale(0);
    opacity: 0;
  }
  50% {
    transform: rotate(45deg) scale(1.2);
  }
  100% {
    transform: rotate(45deg) scale(1);
    opacity: 1;
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ─── View Transition ──────────────────────────────────────────────── */
.view-enter {
  animation: fadeIn 0.25s ease;
}

/* ─── Utility ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }

/* ─── Desktop Enhancements ─────────────────────────────────────────── */
@media (min-width: 640px) {
  #main-content {
    max-width: 640px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
  }

  .recipes-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-sheet {
    max-width: 500px;
    margin: 0 auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .grocery-item-delete {
    opacity: 0.5;
  }
}

@media (min-width: 1024px) {
  .recipes-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
