:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface2: #2a2a2a;
  --accent: #7c3aed;
  --accent-dim: #5b21b6;
  --green: #10b981;
  --text: #f0f0f0;
  --subtext: #999999;
  --border: #333333;
  --shared-bg: #1a1040;
  --shared-border: #5b21b6;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface2: #ebebeb;
    --accent: #6d28d9;
    --accent-dim: #7c3aed;
    --green: #059669;
    --text: #111111;
    --subtext: #555555;
    --border: #cccccc;
    --shared-bg: #ede9fe;
    --shared-border: #7c3aed;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
}

#app { max-width: 480px; margin: 0 auto; }

/* Header */
.app-header {
  background: var(--surface);
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.app-title { font-size: 22px; font-weight: 900; letter-spacing: 1px; margin-bottom: 10px; }
.profile-tabs { display: flex; }
.profile-tab {
  flex: 1; text-align: center; padding: 10px 0;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  color: var(--subtext); border-bottom: 3px solid transparent;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Banners */
.review-banner {
  background: var(--accent); color: #fff;
  padding: 10px 16px; display: flex;
  justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700;
}
.review-actions { display: flex; gap: 8px; }
.btn-confirm {
  background: #fff; color: var(--accent);
  border: none; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; font-weight: 900;
  cursor: pointer;
}
.btn-discard {
  background: transparent; color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.4); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-weight: 700;
  cursor: pointer;
}
.waiting-banner {
  background: var(--surface2); color: var(--subtext);
  padding: 10px 16px; text-align: center;
  font-size: 14px; font-weight: 600; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

/* Day nav */
.day-nav {
  display: flex; gap: 8px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.day-btn {
  flex: 1; text-align: center; padding: 9px 0;
  border-radius: 8px; font-size: 14px; font-weight: 800;
  letter-spacing: 1px; background: var(--surface2);
  color: var(--subtext); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-btn.active { background: var(--accent); color: #fff; }

/* Main content */
.main-content { padding: 12px 16px 100px; display: flex; flex-direction: column; gap: 8px; }

/* Meal cards */
.meal-card { border-radius: 10px; overflow: hidden; }
.meal-card.shared { border: 1.5px solid var(--shared-border); }
.meal-card.personal { border: 1px solid var(--border); }

.meal-header {
  padding: 13px 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.meal-card.shared .meal-header { background: var(--shared-bg); }
.meal-card.personal .meal-header { background: var(--surface); }

.meal-label {
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--accent); margin-bottom: 4px;
  text-transform: uppercase; display: flex; align-items: center; gap: 6px;
}
.meal-card.shared .meal-label { color: var(--shared-border); }
.shared-badge {
  font-size: 8px; font-weight: 900; letter-spacing: 1px;
  background: var(--shared-border); color: #fff;
  border-radius: 3px; padding: 1px 5px;
}
.meal-name { font-size: 18px; font-weight: 700; color: var(--text); }
.meal-macros { font-size: 14px; color: var(--subtext); margin-top: 2px; }
.expand-arrow { font-size: 13px; color: var(--subtext); transition: transform 0.2s; flex-shrink: 0; }
.meal-card.open .expand-arrow { transform: rotate(180deg); }

/* Swap controls (review mode) */
.swap-controls {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.swap-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 16px;
  cursor: pointer; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.swap-label { font-size: 11px; color: var(--subtext); }

/* Recipe drawer */
.recipe-drawer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.meal-card.open .recipe-drawer { max-height: 800px; }
.recipe-inner {
  padding: 14px; border-top: 1px solid var(--border);
  background: var(--surface2);
}
.recipe-inner.shared-inner { background: #150d35; }
@media (prefers-color-scheme: light) { .recipe-inner.shared-inner { background: #f3f0ff; } }

.recipe-section { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: var(--subtext); text-transform: uppercase; margin-bottom: 8px; }
.ingredient-list { list-style: none; margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.ingredient-list li { font-size: 15px; color: var(--text); padding-left: 16px; position: relative; }
.ingredient-list li::before { content: "·"; position: absolute; left: 0; color: var(--accent); font-weight: 900; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; gap: 10px; }
.step-num {
  font-size: 11px; font-weight: 900; color: var(--accent);
  background: var(--surface); border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; margin-top: 1px;
}
.step-text { font-size: 15px; color: var(--text); line-height: 1.5; }

/* Totals card */
.totals-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.totals-title {
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--subtext); margin-bottom: 12px; text-transform: uppercase;
}
.macro-row { display: flex; justify-content: space-between; margin-bottom: 5px; }
.macro-label { font-size: 15px; font-weight: 600; }
.macro-value { font-size: 15px; font-weight: 800; color: var(--accent); }
.macro-value.green { color: var(--green); }
.bar-bg { background: var(--surface2); border-radius: 3px; height: 6px; margin-bottom: 12px; }
.bar-fill { height: 6px; border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.bar-fill.green { background: var(--green); }

/* Action buttons */
.gen-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 16px; font-size: 15px;
  font-weight: 900; letter-spacing: 1px; width: 100%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gen-btn:active { opacity: 0.85; }

/* No plan state */
.no-plan { text-align: center; padding: 40px 20px; color: var(--subtext); }
.no-plan h2 { font-size: 20px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.no-plan p { font-size: 15px; margin-bottom: 24px; }

/* Pantry tab */
.pantry-section { margin-bottom: 4px; }
.pantry-category {
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--subtext); text-transform: uppercase;
  padding: 10px 0 6px;
}
.pantry-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 13px 14px; margin-bottom: 6px;
}
.pantry-item-name { font-size: 16px; font-weight: 600; }
.toggle {
  width: 48px; height: 28px; border-radius: 14px;
  background: var(--border); position: relative;
  cursor: pointer; transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  border: none;
}
.toggle.on { background: var(--green); }
.toggle-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; position: absolute; top: 3px; left: 3px;
  transition: transform 0.2s;
}
.toggle.on .toggle-thumb { transform: translateX(20px); }

/* Bottom nav */
.bottom-nav {
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 0 18px; position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 10;
}
.nav-item {
  text-align: center; font-size: 11px; font-weight: 800;
  letter-spacing: 1px; color: var(--subtext); padding: 4px 24px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 24px; display: block; margin-bottom: 2px; }

/* Utilities */
.hidden { display: none !important; }
