/* ============================================================
   FUELSYNC — Design System
   Sportlich, dunkel, klar. Optimiert für Mobile-First / PWA.
   ============================================================ */

/* Spinner/Pfeile bei allen number-Inputs global entfernen */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;900&family=Inter:wght@400;500;600&display=swap');

/* ============================================================
   CSS VARIABLEN
   ============================================================ */
:root {
  --color-bg:         #0a0a0f;
  --color-surface:    #12121a;
  --color-surface-2:  #1c1c28;
  --color-surface-3:  #252535;
  --color-border:     #2a2a3d;
  --color-text:       #e8e8f0;
  --color-text-muted: #7878a0;
  --color-accent:     #7c3aed;
  --color-accent-2:   #a855f7;
  --color-accent-glow: rgba(124, 58, 237, 0.3);
  --color-green:      #4ade80;
  --color-blue:       #60a5fa;
  --color-orange:     #f97316;
  --color-red:        #ef4444;
  --color-ring-track:  #4a4a6a;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Inter', sans-serif;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  20px;

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

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app { height: 100%; }

/* Globaler Hover für klickbare Elemente */
a:hover,
label[for]:hover {
  color: var(--color-accent-2);
}

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

.food-result:hover,
.member-item:hover {
  background: rgba(124, 58, 237, 0.12);
  border-radius: 8px;
}

button:not(.btn-primary):not(.btn-accent):not(.day-tab):not(.week-start-tab):not(.search-tab):not(.auth-tab):not(.group-tab):hover {
  background: rgba(124, 58, 237, 0.12);
  color: var(--color-accent-2);
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.25) 0%, transparent 60%),
    var(--color-bg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px var(--color-accent));
}

.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fff 0%, var(--color-accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-logo p {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 1px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.auth-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--color-accent);
  color: #fff;
}

.auth-error {
  color: var(--color-red);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--color-accent-2);
}

.header-center {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: none;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

.view.active { display: block; }

.view-content {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.2s;
}

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

.nav-icon { font-size: 20px; line-height: 1; }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ============================================================
   TYPOGRAFIE & SECTTION HEADER
   ============================================================ */
h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.date-nav, .week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.week-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-accent-glow);
}
.btn-primary:hover { background: var(--color-accent-2); }

.btn-accent {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-outline:hover {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
  color: var(--color-accent-2);
}

.btn-full { width: 100%; margin-top: 12px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--color-accent); color: var(--color-accent-2); }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

/* ============================================================
   KALORIERING
   ============================================================ */
.calorie-ring-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.ring-wrapper {
  position: relative;
  width: 120px;
  flex-shrink: 0;
}

.calorie-ring { width: 120px; height: 120px; }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-accent-2);
}

.ring-label {
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.ring-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ring-stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.ring-stat-lbl {
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

/* ============================================================
   MAKRO-BALKEN
   ============================================================ */
.macro-bar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.macro-bar-track {
  height: 6px;
  background: var(--color-surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ============================================================
   MAHLZEITEN / LOG ENTRIES
   ============================================================ */
.meal-list { display: flex; flex-direction: column; gap: 10px; }

.meal-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.meal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 14px;
}

.meal-kcal {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 400;
}

.meal-entries { padding: 8px 10px; }

.empty-meal {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 6px 4px;
  font-style: italic;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--color-border);
}
.log-entry:last-child { border-bottom: none; }

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

.log-entry-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-entry-amount {
  font-size: 12px;
  color: var(--color-text-muted);
}

.log-entry-nutrients {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--color-text-muted);
}

.nutrient-pill {
  padding: 2px 6px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.nutrient-pill.protein { background: rgba(74, 222, 128, 0.15); color: var(--color-green); }
.nutrient-pill.carbs   { background: rgba(96, 165, 250, 0.15); color: var(--color-blue); }
.nutrient-pill.fat     { background: rgba(249, 115, 22, 0.15);  color: var(--color-orange); }

/* ============================================================
   ADOPT PLAN CARD
   ============================================================ */
.adopt-plan-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(168,85,247,0.08));
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-top: 12px;
}

.adopt-plan-card p { font-size: 14px; margin-bottom: 10px; }

.adopt-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adopt-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.portion-input, .amount-input {
  width: 64px;
  padding: 6px 8px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: center;
}

/* ============================================================
   WOCHENPLAN VIEW
   ============================================================ */
.day-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.day-tab:hover:not(.active) {
  border-color: var(--color-accent);
  color: var(--color-accent-2);
}

.day-tab.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.day-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.plan-meals { display: flex; flex-direction: column; gap: 10px; }

.empty-plan, .no-group-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}
.empty-plan p, .no-group-hint p { margin-bottom: 16px; }

/* ============================================================
   EINKAUFSLISTE
   ============================================================ */
.shopping-list { display: flex; flex-direction: column; gap: 8px; }

.shopping-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shopping-item-name {
  font-weight: 500;
  font-size: 14px;
}

.brand { color: var(--color-text-muted); font-size: 12px; }

.shopping-item-amount {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.shopping-check {
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   PROFIL
   ============================================================ */
.profile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.profile-name { font-weight: 600; font-size: 16px; }
.profile-email { font-size: 13px; color: var(--color-text-muted); }

.profile-card .btn { margin-left: auto; }

.goals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.group-item:last-of-type { border-bottom: none; }

.group-name { font-weight: 600; }
.group-code { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.group-members { font-size: 12px; color: var(--color-text-muted); }

/* ============================================================
   FORMULARE
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input, .field select, .field textarea, .search-input {
  padding: 10px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.field 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' viewBox='0 0 24 24' fill='none' stroke='%23a855f7' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.field textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

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

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
}

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 101;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* Food-Edit-Modal: kein Scroll auf modal-body, nur Tag-Picker scrollt */
.food-edit-modal-body {
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(8px + var(--safe-bottom)) !important;
}

.food-edit-modal-body #food-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* Food Search */
.search-tabs, .group-modal-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 14px;
}

.search-tab, .group-tab {
  flex: 1;
  padding: 7px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.search-tab.active, .group-tab.active {
  background: var(--color-accent);
  color: #fff;
}

.search-input {
  margin-bottom: 10px;
}

.food-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.food-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
}
.food-result:hover { border-color: var(--color-accent); }

.food-result-name { font-size: 14px; font-weight: 500; }
.food-result-brand { font-size: 12px; color: var(--color-text-muted); display: block; }
.food-result-kcal { font-size: 13px; color: var(--color-accent-2); font-weight: 600; flex-shrink: 0; }

.selected-food-info {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.selected-food-name { font-weight: 600; font-size: 16px; }
.selected-food-brand { font-size: 13px; color: var(--color-text-muted); margin-bottom: 8px; }

.nutrient-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.modal-feedback { color: var(--color-red); font-size: 13px; margin-top: 8px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 200;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { border-color: var(--color-green); color: var(--color-green); }
.toast-error   { border-color: var(--color-red);   color: var(--color-red);   }
.toast-info    { border-color: var(--color-accent); color: var(--color-accent-2); }

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

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  padding: 24px 0;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-surface-3); border-radius: 99px; }

/* ============================================================
   PWA INSTALL PROMPT (falls benötigt)
   ============================================================ */
@media (display-mode: standalone) {
  .app-header { padding-top: env(safe-area-inset-top); height: calc(var(--header-height) + env(safe-area-inset-top)); }
}

/* ============================================================
   GRUPPENEINSTELLUNGEN
   ============================================================ */
.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section h4 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.member-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-admin {
  background: var(--accent);
  color: white;
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Toggle Switch */
.toggle-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--surface-3, #2a2a3a);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-track {
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent-glow);
}

.toggle-label input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.btn-danger {
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.week-start-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.week-start-tab {
  padding: 0.4rem 0.7rem;
  border-radius: 99px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.week-start-tab.active {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
  color: #fff !important;
  box-shadow: 0 0 8px var(--color-accent-glow);
}

.week-start-tab:hover:not(.active) {
  border-color: var(--color-accent);
  color: var(--color-accent-2);
}

/* ============================================================
   EINKAUFSLISTE — KATEGORIEN
   ============================================================ */
.shopping-category {
  margin-bottom: 1.25rem;
}

.shopping-category-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent-2);
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.5rem;
}

.shopping-item-amount {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ============================================================
   SHOP-KATEGORIEN VERWALTUNG
   ============================================================ */
.shop-cat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.shop-cat-name-input {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  color: var(--color-text);
  font-size: 0.9rem;
}

.shop-cat-name-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.shop-cat-add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.shop-cat-add-row input {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  color: var(--color-text);
  font-size: 0.9rem;
}

.shop-cat-add-row input:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* Lebensmittel-Suchergebnisse */
.food-result-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.food-result-kcal {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ============================================================
   REZEPTE
   ============================================================ */

.recipe-filters {
  margin-bottom: 1rem;
}

.recipe-filter-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.recipe-vis-filter {
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.recipe-vis-filter.active,
.recipe-vis-filter:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.recipe-tag-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.recipe-tag-filter {
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.recipe-tag-filter.active,
.recipe-tag-filter:hover {
  border-color: var(--color-accent-2);
  color: var(--color-accent-2);
}

.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recipe-card {
  background: var(--color-surface-2);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.recipe-card:hover {
  border-color: var(--color-accent);
  background: rgba(124, 58, 237, 0.08);
}

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}

.recipe-card-name {
  font-weight: 700;
  font-size: 1rem;
}

.recipe-fork-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.recipe-card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.recipe-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.recipe-tag {
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  background: rgba(124, 58, 237, 0.15);
  color: var(--color-accent-2);
  font-size: 0.7rem;
  font-weight: 600;
}

.recipe-card-nutrients {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.recipe-visibility-badge {
  font-size: 0.75rem;
  font-weight: 600;
}

.recipe-vis-public { color: #22c55e; }
.recipe-vis-group { color: #3b82f6; }
.recipe-vis-private { color: var(--color-text-muted); }

.favorite-btn {
  color: var(--color-text-muted);
  transition: color 0.15s, transform 0.15s;
  font-size: 1.25rem;
  line-height: 1;
}
.favorite-btn::before { content: '☆'; }
.favorite-btn * { display: none; }  /* hide inner text, use ::before */
.favorite-btn:hover { color: #f59e0b; transform: scale(1.2); }
.favorite-btn.active { color: #f59e0b; }
.favorite-btn.active::before { content: '★'; }

/* Detail */
.recipe-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-detail-card {
  background: var(--color-surface-2);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.recipe-detail-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.recipe-detail-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 0;
}

.recipe-detail-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.recipe-description {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.nutrient-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
  margin-bottom: 0.25rem;
}

.nutrient-summary-item {
  background: var(--color-surface-3);
  border-radius: 8px;
  padding: 0.6rem 0.25rem;
}

.nutrient-value {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-accent-2);
}

.nutrient-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nutrient-per-serving-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ingredient-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.ingredient-name { flex: 1; }
.ingredient-amount { color: var(--color-text-muted); font-size: 0.8rem; }
.ingredient-kcal { color: var(--color-accent-2); font-size: 0.8rem; min-width: 60px; text-align: right; }

/* Formular */
.recipe-tag-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag-checkbox {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.tag-checkbox input { display: none; }

.tag-checkbox span {
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  transition: all 0.15s;
}

.tag-checkbox input:checked + span {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.ingredient-row-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.ingredient-food-display { flex: 1; min-width: 150px; }
.ingredient-food-name { font-weight: 600; font-size: 0.9rem; }

.ingredient-amount-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.ingredient-amount-row:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.ingredient-amount-input {
  width: 64px;
  padding: 6px 8px 6px 12px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  text-align: right;
}

/* Pfeile beim number-input ausblenden */
.ingredient-amount-input::-webkit-outer-spin-button,
.ingredient-amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ingredient-amount-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.ingredient-unit-select {
  padding: 6px 28px 6px 6px;
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23a855f7' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: none;
  border-left: 1px solid var(--color-border);
  color: var(--color-accent-2);
  font-size: 0.8rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ingredient-remove-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.ingredient-remove-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.nutrient-preview {
  background: var(--color-surface-3);
}

.nutrient-preview h4 {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.nutrient-preview-grid {
  display: flex;
  gap: 1rem;
  font-weight: 600;
  color: var(--color-accent-2);
}

/* ============================================================
   STEPPER INPUT
   ============================================================ */
.stepper-input {
  display: flex;
  align-items: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}

.stepper-input:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.stepper-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--color-accent-2);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.stepper-btn:hover {
  background: rgba(124, 58, 237, 0.12);
}

.stepper-value {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  width: 0; /* flex handles width */
}

.stepper-value::-webkit-outer-spin-button,
.stepper-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-value[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ============================================================
   REZEPT-EINTRAG IM WOCHENPLAN
   ============================================================ */
.recipe-plan-entry {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}

.log-entry-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.5rem;
  width: 100%;
}

.log-entry-main .log-entry-info { flex: 1; }

.log-entry-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.recipe-entry-name {
  color: var(--color-accent-2);
  font-weight: 700;
}

.expand-recipe-entry-btn {
  font-size: 1rem;
  color: var(--color-text-muted);
  transition: color 0.15s;
}
.expand-recipe-entry-btn:hover { color: var(--color-accent-2); }

.recipe-entry-ingredients {
  border-top: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.local-ingredient {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.25rem;
  border-radius: 6px;
  transition: background 0.1s;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.local-ingredient:hover {
  background: rgba(124, 58, 237, 0.07);
}

.local-ingredient-name { flex: 1; font-weight: 500; }

.local-ingredient-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.local-ingredient-amount {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  min-width: 40px;
  text-align: right;
}

.local-ingredient-kcal {
  color: var(--color-accent-2);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

.btn-danger-soft {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}
.btn-danger-soft:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: transparent;
}

/* kcal als Pill */
.nutrient-pill.kcal {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* Portionen-Zeile im aufgeklappten Rezept */
.recipe-entry-portions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.25rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}

.recipe-entry-portions-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stepper-inline {
  height: 32px;
  border-radius: 99px;
}

.stepper-inline .stepper-btn {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
}

.stepper-inline .stepper-value {
  font-size: 0.9rem;
  min-width: 32px;
}

/* Rezept-Eintrag: Name oben, Nährwerte darunter */
.recipe-entry-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
}

.recipe-entry-body .log-entry-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   HOVER auf Log/Plan-Einträge
   ============================================================ */
.log-entry:hover,
.recipe-plan-entry:hover {
  background: rgba(124, 58, 237, 0.07);
  border-radius: 8px;
  transition: background 0.15s;
}

/* ============================================================
   FROM-PLAN: farbliche Kennzeichnung
   ============================================================ */
.log-entry.from-plan,
.recipe-plan-entry.from-plan {
  border-left: 3px solid var(--color-accent);
  padding-left: 6px;
}

.from-plan-badge {
  font-size: 0.75rem;
  margin-right: 3px;
  opacity: 0.8;
}

/* ============================================================
   BOTTOM SHEET: Auswahl Lebensmittel / Rezept
   ============================================================ */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.bottom-sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.bottom-sheet {
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  padding: 1rem 1.25rem 2rem;
  width: 100%;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bottom-sheet-overlay.open .bottom-sheet {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 0.5rem;
}

.bottom-sheet-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin: 0;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
  text-align: left;
}

.choice-btn:hover {
  background: rgba(124, 58, 237, 0.12);
  border-color: var(--color-accent);
}

.choice-icon {
  font-size: 1.5rem;
}

.choice-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
}

/* ============================================================
   RECIPE PICKER im Log (readonly ingredients)
   ============================================================ */
.local-ingredient.readonly {
  cursor: default;
  pointer-events: none;
}

/* ============================================================
   DESKTOP LAYOUT (≥1024px)
   ============================================================ */
@media (min-width: 1024px) {

  /* Shell umstrukturieren: Sidebar + Content nebeneinander */
  .app-shell {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar main";
    height: 100vh;
    overflow: hidden;
  }

  /* Header auf Desktop ausblenden */
  .app-header { display: none; }

  /* Bottom-Nav wird zur vertikalen Sidebar */
  .bottom-nav {
    grid-area: sidebar;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    height: 100vh;
    padding: 0;
    border-right: 1px solid var(--color-border);
    border-top: none;
    background: var(--color-surface);
    padding-top: 0;
  }

  /* Logo oben in der Sidebar */
  .bottom-nav::before {
    content: '⚡ FuelSync';
    display: block;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--color-accent-2);
    padding: 1rem 1rem 1rem;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }

  /* Header-Logo verstecken (steht jetzt in Sidebar) */
  .header-logo { display: none; }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.65rem;
    padding: 0.4rem 0.75rem 0.4rem 0.9rem;
    border-radius: 6px;
    margin: 1px 8px;
    font-size: 0.875rem;
    border-bottom: none;
    border-left: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    color: var(--color-text-muted);
  }

  .nav-item.active {
    background: rgba(124, 58, 237, 0.12);
    border-left-color: var(--color-accent);
    color: var(--color-accent-2);
  }

  .nav-item:hover:not(.active) {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text);
  }

  .nav-icon { font-size: 1rem; }
  .nav-label { font-size: 0.85rem; font-weight: 500; }

  .nav-svg-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
  }

  .nav-item.active .nav-svg-icon { opacity: 1; }

  .nav-group-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    opacity: 0.45;
    padding: 0.9rem 1.1rem 0.2rem;
    pointer-events: none;
  }

  .bottom-nav .nav-group-label:first-child {
    padding-top: 0.4rem;
  }

  /* Main-Bereich */
  .app-main {
    grid-area: main;
    overflow: hidden;
    height: 100vh;
    padding-bottom: 0;
  }

  .view { height: 100%; overflow: hidden; padding-bottom: 0; }
  .view-content {
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    max-width: none;
    margin: 0;
  }

  /* ──────────────────────────────────────────────────────────
     PLAN-VIEW: 2-Spalten-Dashboard
     ────────────────────────────────────────────────────────── */
  #plan-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
  }

  /* Moden-Umschalter (Gruppenplan/Öffentliche Pläne) — immer Zeile 1 */
  #plan-content > .plan-mode-toggle {
    grid-row: 1;
    grid-column: 1 / -1;
    padding: 1rem 1.5rem 0;
    margin-bottom: 0;
  }

  /* Section-Header spannt beide Spalten — immer Zeile 2 */
  #plan-content > .section-header {
    grid-row: 2;
    grid-column: 1 / -1;
    padding: 1rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0;
  }

  /* Öffentliche-Pläne-Bereich: kein .section-header-Geschwister, füllt ab Zeile 2 den Rest */
  #plan-content > #public-plan-content {
    grid-row: 2 / -1;
    grid-column: 1 / -1;
    padding: 1rem 1.5rem 2rem;
    overflow-y: auto;
  }

  /* Leere Plan / no-group Meldung — immer Zeile 3 */
  #plan-content > .empty-plan,
  #plan-content > .no-group-hint {
    grid-row: 3;
    grid-column: 1 / -1;
    padding: 2rem;
  }

  /* Mitglieder-Panel (links) — immer Zeile 3 */
  .desktop-member-panel {
    grid-row: 3;
    grid-column: 1;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 1rem 1rem 2rem 1.5rem;
  }

  /* Member-Cards untereinander */
  .desktop-member-panel .member-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Plan-Inhalt (rechts) */
  .desktop-plan-panel {
    grid-row: 3;
    grid-column: 2;
    overflow-y: auto;
    padding: 1rem 1.5rem 2rem 1rem;
  }

  /* Day-Tabs im Plan-Panel */
  .desktop-plan-panel .day-tabs { margin-bottom: 0.5rem; }

  /* Member-Card */
  .member-nutrition-card {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
    position: relative;
  }

  .member-nutrition-card:hover { border-color: var(--color-accent); }

  .member-nutrition-card.selected {
    border-color: var(--color-accent);
    background: rgba(124,58,237,0.1);
    box-shadow: 0 0 0 1px var(--color-accent);
  }

  .member-card-check {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
  }

  .member-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
  }

  .member-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
  }

  .member-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    flex: 1;
  }

  .member-card-total {
    font-size: 0.8rem;
    color: var(--color-text-muted);
  }

  /* Fortschrittsbalken pro Nährstoff */
  .member-nutrient-row {
    margin-bottom: 0.5rem;
  }

  .member-nutrient-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
  }

  .member-nutrient-header .pct {
    font-weight: 600;
    color: var(--color-text);
  }

  .member-nutrient-track {
    height: 6px;
    background: var(--color-surface-3);
    border-radius: 3px;
    overflow: hidden;
  }

  .member-nutrient-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
  }

  .member-nutrient-fill.calories { background: var(--color-accent-2); }
  .member-nutrient-fill.protein  { background: var(--color-green); }
  .member-nutrient-fill.carbs    { background: var(--color-blue); }
  .member-nutrient-fill.fat      { background: var(--color-orange); }

  .member-nutrient-fill.over {
    background: var(--color-red);
  }

  /* Panel-Titel */
  .desktop-panel-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
  }

  /* Plan-View: kein Außen-Padding, füllt die volle Breite */
  #plan-content.view-content { padding: 0; }

  /* Sidebar: Spacer und Profil-Button */
  .sidebar-spacer { flex: 1; }
  .sidebar-profile-btn { border-top: 1px solid var(--color-border); }

  /* header-right im Header ausblenden (Profil ist unten in der Sidebar) */
  .header-right { display: none; }

  /* Emoji-Icons auf Desktop ausblenden, SVG-Icons anzeigen */
  .nav-icon { display: none; }
  .nav-svg-icon { display: block; }

  /* Mobile-Header auf Desktop ausblenden */
  .mobile-only-header { display: none !important; }

  /* Kein Padding mehr auf der Haupt-View-Content */
  #plan-content .section-header h2 {
    font-size: 1.1rem;
  }
}

/* Auf Mobile: member-panel und desktop-panel ausblenden / normales Layout */
@media (max-width: 1023px) {
  /* SVG-Icons in der Mobile Bottom-Nav */
  .nav-svg-icon {
    display: block;
    width: 22px;
    height: 22px;
    margin: 0 auto 2px;
  }
  .nav-item {
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-top: 3px solid transparent;
  }
  .nav-item.active {
    border-left: none;
    border-top-color: var(--color-accent);
  }
  .desktop-member-panel { display: none; }
  .desktop-plan-panel { display: contents; }
  .sidebar-spacer { display: none; }
  .sidebar-profile-btn { display: none; }
  .nav-group-label { display: none; }
  .nav-icon { display: none; }
  .mobile-only-header { display: flex; }
  .today-sidebar-header { display: none; }
  .today-ring-row { display: none; }
  .today-macro-grid { display: none; }
  .today-kcal-stats { display: none; }

  /* Heute-View: Kopf/Ring/Makros fixiert, nur die Mahlzeitenliste scrollt.
     Wrapper-Divs komplett aus dem Layout-Baum entfernen (display:contents), damit
     #today-content.view-content der EINZIGE Flex-Container ist — keine verschachtelten
     min-height:0-Übergänge nötig. */
  .today-desktop-layout,
  .today-sidebar,
  .today-meals-col {
    display: contents;
  }

  #view-today.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #today-content.view-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #today-content .mobile-only-header,
  #today-content .mobile-only-stats {
    flex-shrink: 0;
  }

  #today-content .meal-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 16px;
  }

  /* Mahlzeiten-Kästchen dürfen nicht schrumpfen — sonst schneidet ihr eigenes
     overflow:hidden den Inhalt ab, statt dass .meal-list scrollt */
  #today-content .meal-section {
    flex-shrink: 0;
  }
}

/* ============================================================
   MEMBER CARD — KCAL RING (voller Kreis, wie Heute-Ansicht)
   ============================================================ */

  /* Ring-Row: Kreis links, Stats rechts */
  .mc-ring-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0 0.75rem;
  }

  .mc-ring-wrap {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
  }

  .mc-ring-svg {
    width: 100%;
    height: 100%;
  }

  .mc-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
  }

  .mc-ring-val {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--color-accent-2);
    letter-spacing: -0.02em;
  }

  .mc-ring-lbl {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .mc-ring-stats {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .mc-ring-stat-val {
    display: block;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
  }

  .mc-ring-stat-lbl {
    display: block;
    font-size: 0.7rem;
    color: var(--color-text-muted);
  }

/* ============================================================
   HEUTE-VIEW — DESKTOP 2-SPALTEN LAYOUT
   ============================================================ */
@media (min-width: 1024px) {

  #today-content.view-content {
    padding: 0;
    height: 100%;
    overflow: hidden;
    max-width: none;
    margin: 0;
  }

  .today-desktop-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100%;
    overflow: hidden;
    align-items: stretch;
  }

  /* ── Linke Sidebar ── */
  .today-sidebar {
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem 2rem;
    gap: 1.25rem;
    background: var(--color-surface);
    height: 100%;
  }

  .today-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .today-sidebar-header h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
  }

  /* ── Ring + kcal Stats nebeneinander ── */
  .today-ring-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
  }

  .today-ring-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
  }

  .today-ring-svg {
    width: 100%;
    height: 100%;
    display: block;
  }

  .today-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
  }

  .today-ring-val {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 900;
    color: var(--color-accent-2);
    line-height: 1;
    letter-spacing: -0.02em;
  }

  .today-ring-lbl {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .today-kcal-stats {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }



  .today-kcal-val {
    display: block;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
  }

  .today-kcal-lbl {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  /* ── 3 kompakte Makro-Karten ── */
  .today-macro-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .today-macro-card {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    column-gap: 0.5rem;
    align-items: center;
  }

  .today-macro-card-val {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    grid-column: 1;
    grid-row: 1;
  }

  .today-macro-card-lbl {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    grid-column: 1;
    grid-row: 2;
  }

  .today-macro-card-goal {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    grid-column: 2;
    grid-row: 1 / 3;
    text-align: right;
    align-self: center;
  }

  .today-macro-track {
    height: 4px;
    background: var(--color-surface-3);
    border-radius: 99px;
    overflow: hidden;
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0.4rem;
  }

  .today-macro-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s ease;
  }

  /* ── Rechte Spalte: Mahlzeiten ── */
  .today-meals-col {
    overflow-y: auto;
    padding: 1.5rem 2rem 2rem;
    background: var(--color-bg);
  }

  .today-meals-col .meal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
}

/* Mobile-only Stats (Ring + Makros im Log) */
@media (min-width: 1024px) {
  .mobile-only-stats { display: none; }
}



/* ============================================================
   REZEPT-PICKER — Portionsauswahl
   ============================================================ */
.recipe-portion-bar {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.recipe-portion-bar.hidden { display: none; }

.recipe-portion-bar-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  min-width: 120px;
}

.recipe-portion-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-portion-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.recipe-portion-input {
  width: 56px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 4px 6px;
}

.food-result.recipe-pick-result.selected {
  background: rgba(124, 58, 237, 0.12);
  border-left: 3px solid var(--color-accent);
}

/* ============================================================
   LOG ENTRY — Portionskontrolle
   ============================================================ */
.log-portions-control {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 4px;
}

.log-portions-input {
  width: 38px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  background: transparent;
  border: none;
  color: var(--color-accent-2);
  padding: 2px 0;
}

/* ============================================================
   LOG ENTRY — Deaktiviert / Plan-Schutz
   ============================================================ */

/* Deaktivierter Eintrag: ausgegraut */
.log-entry-disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
  background: var(--color-surface) !important;
  border-left: 3px solid var(--color-text-muted) !important;
}

.log-entry-disabled .log-entry-name {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Reaktivieren-Button: grünlich */
.btn-icon.entry-reactivate,
.btn-icon.li-reactivate {
  color: var(--color-green);
  opacity: 0.8;
}
.btn-icon.entry-reactivate:hover,
.btn-icon.li-reactivate:hover { opacity: 1; }

/* Deaktivieren-Button: gedimmt */
.btn-icon.entry-disable,
.btn-icon.li-deactivate {
  color: var(--color-text-muted);
}
.btn-icon.entry-disable:hover,
.btn-icon.li-deactivate:hover { color: var(--color-orange); }

/* Deaktivierte Zutat: durchgestrichen */
.local-ingredient.li-disabled {
  opacity: 0.45;
}
.local-ingredient.li-disabled .local-ingredient-name {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Aktiver Toggle-Button: gefüllter Kreis lila */
.btn-icon.entry-active {
  color: var(--color-accent-2);
  font-size: 0.7rem;
}
.btn-icon.entry-active:hover { color: var(--color-text-muted); }

/* ============================================================
   ZUTATEN-VERWALTUNG
   ============================================================ */
.foods-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.foods-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  overflow-y: auto;
}

.foods-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.food-cat-list {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.5rem;
  gap: 2px;
}

.food-cat-btn {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.food-cat-btn:hover { background: rgba(124,58,237,0.07); color: var(--color-text); }
.food-cat-btn.active { background: rgba(124,58,237,0.15); color: var(--color-accent-2); font-weight: 600; }

.foods-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.foods-main-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.foods-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem 2rem;
}

.foods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.food-th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.food-th-num { text-align: right; }

.food-td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.food-td-num { text-align: right; color: var(--color-text-muted); font-size: 0.8rem; }
.food-td-cat { color: var(--color-text-muted); font-size: 0.8rem; }
.food-td-actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.food-brand { color: var(--color-text-muted); font-size: 0.8rem; }

.food-row:hover { background: rgba(124,58,237,0.05); }

/* Food-Edit-Formular */
.food-edit-form { display: flex; flex-direction: column; gap: 0.75rem; }

.food-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.food-form-row label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.food-form-row input,
.food-form-row select {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.food-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.food-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s;
}

.confirm-overlay.open { opacity: 1; }

.confirm-dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-width: 300px;
  max-width: 400px;
  transform: scale(0.95);
  transition: transform 0.15s;
}

.confirm-overlay.open .confirm-dialog { transform: scale(1); }

.confirm-message {
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-danger {
  background: var(--color-red);
  color: #fff;
  border-color: var(--color-red);
}

.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.confirm-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

/* ============================================================
   EINKAUFSLISTE (neu)
   ============================================================ */
.shop-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.shop-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.shop-counter {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.shop-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}



.shop-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 0 0.25rem;
  margin-bottom: 0.4rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: opacity 0.2s;
}

.shop-item-checked {
  opacity: 0.45;
}

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

.shop-check-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: #fff;
}

.shop-check-btn.checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.shop-check-btn:hover:not(.checked) {
  border-color: var(--color-accent);
}

.shop-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.shop-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.shop-item-amount {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.shop-item-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.shop-plan-badge {
  font-size: 0.7rem;
  margin-left: 4px;
  opacity: 0.7;
}

.shop-carry-badge {
  font-size: 0.7rem;
  margin-left: 4px;
  color: var(--color-accent-2);
}

/* ============================================================
   TAG PICKER im Food-Modal
   ============================================================ */
.food-tag-picker {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.tag-pick-row {
  display: flex;
  align-items: center;
}

.tag-pick-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--color-text);
  width: 100%;
  border-radius: var(--radius-sm);
}

.tag-pick-label:hover { background: rgba(124,58,237,0.07); }

.tag-pick-cb:checked + span { color: var(--color-accent-2); font-weight: 600; }

/* ============================================================
   TAG-VERWALTUNG in der Zutaten-Sidebar
   ============================================================ */
.tag-tree-list {
  padding: 0.25rem 0.5rem;
}

.tag-tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  border-radius: var(--radius-sm);
}

.tag-tree-row:hover { background: rgba(124,58,237,0.07); }

.tag-tree-name {
  font-size: 0.82rem;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-tree-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.tag-tree-row:hover .tag-tree-actions { opacity: 1; }
.tag-tree-root-header:hover .tag-tree-actions { opacity: 1; }

/* Tag-Pills in der Tabelle */
.food-td-tags { max-width: 200px; }

.food-tag-pill {
  display: inline-block;
  background: rgba(124,58,237,0.12);
  color: var(--color-accent-2);
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 99px;
  margin: 1px 2px;
  white-space: nowrap;
}

/* ============================================================
   TAG MODAL — Farbauswahl
   ============================================================ */
.tag-color-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tag-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.tag-color-swatch:hover { transform: scale(1.15); }
.tag-color-swatch.selected {
  border-color: var(--color-text);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px currentColor;
}

.tag-color-custom-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.tag-color-input {
  width: 40px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 0;
}

/* Vorschau-Pill */
.tag-preview-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
}

/* Farbpunkt im Tag-Tree */
.tag-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* Tag-Picker Pills */
.tag-pick-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ============================================================
   TAG PICKER — Accordion
   ============================================================ */
.food-tag-picker {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0;
  height: 160px;
  overflow-y: auto;
  flex-shrink: 0;
}

.tag-pick-group {
  border-bottom: 1px solid var(--color-border);
}
.tag-pick-group:last-child { border-bottom: none; }

.tag-pick-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  background: var(--color-surface-2);
  user-select: none;
}
.tag-pick-group-header:hover { background: rgba(124,58,237,0.06); }

.tag-pick-chevron {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tag-pick-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-pick-group-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.tag-pick-count {
  font-size: 0.72rem;
  color: var(--color-accent-2);
  font-weight: 600;
}

.tag-pick-group-body {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0.5rem 0.75rem 0.6rem;
  background: var(--color-surface);
}

.tag-pick-child-row {
  display: contents;
}

.tag-pick-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tag-pick-pill:hover { opacity: 0.85; }

.tag-check { font-size: 0.72rem; }

/* ============================================================
   TAG TREE — klappbare Root-Tags
   ============================================================ */
.tag-tree-root { border-bottom: 1px solid var(--color-border); }
.tag-tree-root:last-child { border-bottom: none; }

.tag-tree-root-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
}
.tag-tree-root-header:hover { background: rgba(124,58,237,0.07); }

.tag-tree-chevron {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 10px;
}

.tag-tree-children {
  padding-left: 8px;
  padding-bottom: 4px;
}

/* Klickbare Food-Zeilen */
.food-row-clickable { cursor: pointer; }
.food-row-clickable:hover { background: rgba(124,58,237,0.08); }

/* Root-Pill im Tag-Picker leicht abgehoben */
.tag-pick-root-pill {
  border-style: dashed !important;
  font-size: 0.8rem !important;
}

/* ============================================================
   FOOD COMPONENTS — Bestandteile im Modal
   ============================================================ */
.food-components-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.food-components-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.food-form-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.food-override-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.food-components-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.food-component-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.food-comp-name {
  flex: 1;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-comp-amount {
  width: 64px;
  text-align: right;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 2px 6px;
  font-size: 0.85rem;
}

.food-comp-unit {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  width: 16px;
}

.food-comp-empty {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
  padding: 4px 2px;
}

/* Composite Badge in der Tabelle */
.food-composite-badge {
  font-size: 0.68rem;
  background: rgba(168, 85, 247, 0.15);
  color: var(--color-accent-2);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 99px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.food-amount-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.food-amount-row .amount-input {
  flex: 1;
  min-width: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.food-unit-select {
  width: 140px;
  flex-shrink: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

/* ============================================================
   REZEPT-DETAIL — Zutaten mit Makros
   ============================================================ */
.ingredient-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

.ingredient-pills {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.ingredient-row:last-child { border-bottom: none; }

.ingredient-name {
  font-size: 0.9rem;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ingredient-amount {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-align: right;
  white-space: nowrap;
  justify-self: end;
  min-width: 90px;
}

.ingredient-row .nutrient-pill {
  justify-self: end;
  min-width: 56px;
  text-align: center;
  white-space: nowrap;
}

/* ============================================================
   REZEPT-DETAIL — Desktop einzeiliges Layout
   ============================================================ */
@media (min-width: 1024px) {
  .ingredient-amount {
    min-width: 100px;
  }

  /* Nährstoff-Kacheln nebeneinander kompakter */
  .nutrient-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
  }
}

/* Mobile: Name+Menge oben, Pillen in einer Reihe darunter */
@media (max-width: 640px) {
  .ingredient-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 6px;
    column-gap: 0.5rem;
  }

  .ingredient-name {
    grid-column: 1;
    grid-row: 1;
  }

  .ingredient-amount {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  .ingredient-pills {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .ingredient-row .nutrient-pill {
    min-width: 0;
  }
}

/* ============================================================
   REZEPT-FORM — Fixer Header, scrollbare Zutaten
   ============================================================ */
.recipe-form-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Mobile: padding-bottom des View wegräumen damit Höhe stimmt */
@media (max-width: 1023px) {
  #view-recipes:has(.recipe-view-layout),
  #view-recipes:has(.recipe-form-layout) {
    padding-bottom: 0;
  }
}

.recipe-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-bg);
}

.recipe-form-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.recipe-form-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.recipe-form-meta {
  flex-shrink: 0;
  overflow: visible;
}

.recipe-form-ingredients {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding-right: 0;
}

.recipe-ingredients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.ingredient-rows-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Nährwertvorschau unten fixiert */
#nutrient-preview {
  flex-shrink: 0;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* Mobile: meta-Block weniger hoch */
@media (max-width: 1023px) {
  .recipe-form-body {
    padding: 0.75rem 1rem;
  }


}

/* ============================================================
   REZEPT-DETAIL — Gleiches Layout wie Bearbeiten-Form
   ============================================================ */

/* Wenn rezept-layout aktiv: View selbst darf nicht scrollen */
#recipes-content:has(.recipe-view-layout),
#recipes-content:has(.recipe-form-layout) {
  padding: 0;
  max-width: none;
  height: 100%;
  overflow: hidden;
}

/* Eltern-View ebenfalls kein Scroll */
#view-recipes:has(.recipe-view-layout),
#view-recipes:has(.recipe-form-layout) {
  overflow: hidden;
}

.recipe-view-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.recipe-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.recipe-view-meta {
  flex-shrink: 0;
  overflow: visible;
  margin: 1rem 1.5rem 0;
}

.recipe-view-ingredients {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  margin: 1rem 1.5rem 0;
  padding-right: 0; /* Scrollbar liegt innerhalb des Containers */
}

.ingredient-list-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.recipe-view-footer {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* Mobile: weniger Padding + Bottom-Nav Abstand */
@media (max-width: 1023px) {
  .recipe-view-header {
    padding: 0.6rem 1rem;
  }

  .recipe-view-meta {
    margin: 0.5rem 0.75rem 0;
  }

  .recipe-view-ingredients {
    margin: 0.5rem 0.75rem 0;
  }

  .recipe-view-footer {
    padding: 0.6rem 1rem;
    padding-bottom: calc(0.6rem + var(--nav-height, 60px) + var(--safe-bottom, 0px));
  }

  .recipe-form-body {
    padding: 0.75rem;
  }
}

/* ============================================================
   CUSTOM SCROLLBAR — dezent, passend zum Dark-Theme
   ============================================================ */

/* Gilt für alle scrollbaren Bereiche */
.ingredient-list-scroll,
.ingredient-rows-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.4) transparent;
  padding-right: 8px;  /* Platz für Scrollbar reservieren */
}

.ingredient-list-scroll::-webkit-scrollbar,
.ingredient-rows-scroll::-webkit-scrollbar {
  width: 4px;
}

.ingredient-list-scroll::-webkit-scrollbar-track,
.ingredient-rows-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.ingredient-list-scroll::-webkit-scrollbar-thumb,
.ingredient-rows-scroll::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.35);
  border-radius: 99px;
}

.ingredient-list-scroll::-webkit-scrollbar-thumb:hover,
.ingredient-rows-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.6);
}

/* Global für alle anderen scrollbaren Bereiche in der App */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.3) transparent;
}

*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.3);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.55);
}

/* Prompt-Input im Confirm-Dialog */
.prompt-input {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.prompt-input:focus { border-color: var(--color-accent); }
.prompt-input.input-error { border-color: var(--color-red); }

/* ============================================================
   KATEGORIE-LISTE — mit Edit/Delete Buttons
   ============================================================ */
.food-cat-item {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.food-cat-item:hover { background: rgba(124,58,237,0.07); }
.food-cat-item.active { background: rgba(124,58,237,0.15); }

.food-cat-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  padding-right: 4px;
}

.food-cat-item:hover .food-cat-actions { opacity: 1; }

/* ============================================================
   MOBILE FIXES — Zutaten, Einkauf, allgemein
   ============================================================ */
@media (max-width: 1023px) {

  /* ── ZUTATEN ──────────────────────────────────────────── */
  .foods-layout {
    flex-direction: column;
    overflow: hidden;
    height: 100%;
  }

  /* Sidebar: fix oben, kein eigener Scroll (Inhalt passt rein) */
  .foods-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    flex-shrink: 0;
    overflow: visible;
  }

  .foods-sidebar-header {
    padding: 0.5rem 0.75rem;
  }

  /* Tag-Baum auf Mobile verstecken */
  .tag-tree-desktop { display: none !important; }

  /* Tag-Pill-Strip auf Mobile: wie Kategorien */
  .tag-pills-mobile {
    display: flex !important;
    overflow-x: auto;
    padding: 0.4rem 0.75rem 0.5rem;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.4) rgba(124,58,237,0.08);
  }
  .tag-pills-mobile::-webkit-scrollbar { display: block; height: 3px; }
  .tag-pills-mobile::-webkit-scrollbar-track { background: rgba(124,58,237,0.08); border-radius: 99px; }
  .tag-pills-mobile::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 99px; }

  /* Tabelle: nimmt restliche Höhe, scrollt intern */
  .foods-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .foods-main-header {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
  }

  .foods-table-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 0.5rem 1rem;
  }

  /* Kategorien horizontal scrollbar */
  .food-cat-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.4rem 0.75rem 0.9rem;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.4) rgba(124,58,237,0.08);
  }
  .food-cat-list::-webkit-scrollbar { display: block; height: 3px; margin-top: 4px; }
  .food-cat-list::-webkit-scrollbar-track { background: rgba(124,58,237,0.08); border-radius: 99px; margin: 0 0.75rem; }
  .food-cat-list::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 99px; }

  .food-cat-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    border-radius: 99px;
    border: 1px solid var(--color-border);
    font-size: 0.8rem;
  }
  .food-cat-btn.active {
    background: rgba(124,58,237,0.2);
    border-color: var(--color-accent);
    color: var(--color-accent-2);
  }

  .food-cat-item {
    flex-shrink: 0;
  }
  .food-cat-actions { display: none; } /* Auf Mobile kein Edit/Delete in der Kategorieleiste */

  /* Tags-Bereich auf Mobile: zeigen, aber kompakter */
  .tag-tree-list { display: block; }

  /* Tabelle vereinfachen */
  .foods-main {
    flex: 1;
    min-height: 0;
  }

  .foods-main-header {
    padding: 0.6rem 0.75rem;
  }

  .foods-table-wrap {
    padding: 0 0.5rem 1rem;
  }

  /* Spalten ausblenden die auf Mobile nicht passen */
  /* Behalte: Name + kcal. Verstecke: P, K, F, Kategorie, Tags */
  .food-td-tags,
  .food-td-cat { display: none; }

  /* Tabelle kompakter */
  .foods-table { font-size: 0.8rem; }
  .food-td, .food-th { padding: 0.45rem 0.4rem; }
  .food-td-actions { gap: 2px; }

  /* ── EINKAUF ──────────────────────────────────────────── */
  .shop-toolbar {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .shop-toolbar .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }

  .shop-list {
    padding: 0.75rem 0.75rem 5rem;
  }

  .shop-item {
    padding: 0.5rem 0.5rem;
  }

  /* ── REZEPTE LISTE ────────────────────────────────────── */
  .recipe-list {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  /* ── WOCHENPLAN ───────────────────────────────────────── */
  .section-header {
    padding: 0.6rem 0.75rem;
  }

  /* ── ALLGEMEIN ────────────────────────────────────────── */
  .card {
    border-radius: var(--radius-md);
    padding: 0.75rem;
  }

  .view-content {
    padding: 8px;
  }
}

/* ============================================================
   ZUTATEN-TABELLE — farbige Nährwerte
   ============================================================ */
.food-td-kcal  { color: var(--color-accent-2) !important; }
.food-td-protein { color: var(--color-green)   !important; }
.food-td-carbs   { color: var(--color-blue)    !important; }
.food-td-fat     { color: var(--color-orange)  !important; }

/* Header etwas dezenter */
.food-th.food-td-kcal    { color: rgba(167,139,250,0.8) !important; }
.food-th.food-td-protein { color: rgba(74,222,128,0.8)  !important; }
.food-th.food-td-carbs   { color: rgba(96,165,250,0.8)  !important; }
.food-th.food-td-fat     { color: rgba(249,115,22,0.8)  !important; }

/* ── MOBILE: sichtbare Scrollbar im Kategorie-Strip ─────── */
@media (max-width: 1023px) {
  .food-cat-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.4) rgba(124,58,237,0.08);
    padding-bottom: 0.9rem; /* Platz für Scrollbar */
  }

  .food-cat-list::-webkit-scrollbar {
    display: block;
    height: 3px;
  }

  .food-cat-list::-webkit-scrollbar-track {
    background: rgba(124,58,237,0.08);
    border-radius: 99px;
  }

  .food-cat-list::-webkit-scrollbar-thumb {
    background: rgba(124,58,237,0.4);
    border-radius: 99px;
  }
}

/* ============================================================
   TAG FILTER STRIP
   ============================================================ */
.tag-filter-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0.25rem 0;
}

/* Desktop: Tag-Rows als vertikale Liste (wie Kategorien) */
.tag-strip-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-strip-row-sub {
  padding-left: 1rem;
  border-left: 2px solid var(--color-border);
  margin-left: 0.75rem;
}

/* Mobile: horizontal scrollbar */
@media (max-width: 1023px) {
  .tag-filter-strip {
    flex-direction: column;
    gap: 4px;
    padding: 0.4rem 0.75rem;
    border-top: 1px solid var(--color-border);
  }

  .tag-strip-row {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.4) rgba(124,58,237,0.08);
  }

  .tag-strip-row::-webkit-scrollbar { height: 3px; display: block; }
  .tag-strip-row::-webkit-scrollbar-track { background: rgba(124,58,237,0.08); border-radius: 99px; }
  .tag-strip-row::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 99px; }

  .tag-strip-row-sub {
    padding-left: 0.5rem;
    margin-left: 0.25rem;
  }
}

.food-tag-filter-btn {
  white-space: nowrap;
  flex-shrink: 0;
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

.food-tag-filter-btn:hover {
  background: rgba(124,58,237,0.07);
  color: var(--color-text);
}

.food-tag-filter-btn.active {
  background: rgba(124,58,237,0.15);
  color: var(--color-accent-2);
  font-weight: 600;
}

.food-tag-filter-sub {
  font-size: 0.82rem;
}

/* Mobile: Pill-Stil */
@media (max-width: 1023px) {
  .food-tag-filter-btn {
    width: auto;
    padding: 0.3rem 0.65rem;
    border-radius: 99px;
    border: 1px solid var(--color-border);
    font-size: 0.78rem;
  }

  .food-tag-filter-btn:hover {
    border-color: var(--color-accent);
    background: transparent;
  }

  .food-tag-filter-btn.active {
    background: rgba(124,58,237,0.15);
    border-color: var(--color-accent);
  }
}

/* Desktop: Strip immer sichtbar */
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 1023px) {
  .mobile-only { display: flex; }
  .desktop-only { display: none; }

  .tag-filter-strip {
    padding: 0.4rem 0.75rem;
  }
}

/* Tag-Namen im Baum als Filter klickbar */
.tag-tree-filter-btn {
  cursor: pointer;
  flex: 1;
}
.tag-tree-filter-btn:hover {
  color: var(--color-text);
}

.tag-tree-active .tag-tree-name {
  font-weight: 600;
}

.tag-tree-root-header.tag-tree-active,
.tag-tree-row.tag-tree-active {
  border-radius: var(--radius-sm);
}

/* Tag-Baum nur Desktop, Pills nur Mobile */
.tag-tree-desktop { display: block; }
.tag-pills-mobile { display: none; }

/* Aktive Tag-Pill Farbe */
.tag-pills-mobile .food-cat-btn.active {
  background: rgba(124,58,237,0.15);
  color: var(--color-accent-2);
  border-color: var(--color-accent);
}

/* ============================================================
   FOODS VIEW — kein Scroll auf View-Ebene
   ============================================================ */
#view-foods {
  overflow: hidden !important;
  display: none;
  flex-direction: column;
}

#view-foods.active {
  display: flex;
}

#foods-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
}

/* Sicherstellen dass Nährwert-Farben nicht durch mobile CSS überschrieben werden */
#foods-content .food-td-kcal    { color: var(--color-accent-2) !important; }
#foods-content .food-td-protein { color: var(--color-green)    !important; }
#foods-content .food-td-carbs   { color: var(--color-blue)     !important; }
#foods-content .food-td-fat     { color: var(--color-orange)   !important; }

@media (max-width: 1023px) {
  #view-foods {
    padding-bottom: 0 !important;
  }
}

/* Farbige Tag-Pills auf Mobile */
.food-tag-pill-mobile {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.3rem 0.65rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.food-tag-pill-mobile:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

/* Tag-Pills Mobile — zwei Zeilen */
.tag-pills-row1,
.tag-pills-row2 {
  display: none;
}

@media (max-width: 1023px) {
  /* Äußerer Container scrollt horizontal — Scrollbar erscheint ganz unten */
  .tag-pills-wrap {
    display: block;
    overflow-x: auto;
    padding: 0.3rem 0.75rem 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.4) rgba(124,58,237,0.08);
  }
  .tag-pills-wrap::-webkit-scrollbar { height: 3px; display: block; }
  .tag-pills-wrap::-webkit-scrollbar-track { background: rgba(124,58,237,0.08); border-radius: 99px; margin: 0 0.75rem; }
  .tag-pills-wrap::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 99px; }

  /* Zeilen selbst scrollen nicht */
  .tag-pills-row1,
  .tag-pills-row2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: max-content; /* Breite passt sich dem Inhalt an */
    margin-bottom: 4px;
  }

  /* Zeile 2: leicht eingerückt mit Strich */
  .tag-pills-row2 {
    padding-left: 0.75rem;
    border-left: 2px solid var(--color-border);
    margin-left: 0.5rem;
  }
}

/* ============================================================
   EINKAUFSLISTE — Tag-Gruppen mit Rahmen
   ============================================================ */
.shop-tag-group {
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: var(--radius-md);
  padding: 0.5rem 0 0.25rem;
  margin: 1.1rem 0 0.5rem;
  position: relative;
}

.shop-tag-label {
  position: absolute;
  top: -0.55rem;
  left: 0.75rem;
  background: var(--color-bg);
  padding: 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(167,139,250,0.95);
  z-index: 1;
}

/* Items innerhalb der Tag-Gruppe: kein eigener Rahmen */
.shop-tag-group .shop-item {
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
}
.shop-tag-group .shop-item:last-child {
  border-bottom: none;
}

/* Itemlabel mit Quellen */
.shop-item-name {
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.4;
}

/* ============================================================
   PER-MITGLIED PLAN-ANPASSUNGEN
   ============================================================ */
.member-exclusive-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(124,58,237,0.15);
  color: var(--color-accent-2);
  margin-left: 6px;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.member-override-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.member-override-row:last-child { border-bottom: none; }

.member-override-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
}

.member-override-input {
  width: 70px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.member-override-unit {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  width: 60px;
}

.member-override-row.selected {
  background: rgba(124,58,237,0.08);
  border-radius: var(--radius-md);
  padding-left: 6px;
  padding-right: 6px;
}

.member-override-bulk {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(124,58,237,0.1);
  font-size: 0.85rem;
}
.member-override-bulk span { flex: 1; }

.btn-link {
  background: none;
  border: none;
  color: var(--color-accent-2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.member-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 8px 10px;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(124,58,237,0.1);
}

.member-panel-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.target-member-hint {
  font-size: 0.82rem;
  color: var(--color-accent-2);
  font-weight: 600;
  margin: 0.25rem 0;
}

/* ============================================================
   ÖFFENTLICHE PLÄNE
   ============================================================ */
.plan-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.plan-mode-btn {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.plan-mode-btn:hover:not(.active) {
  border-color: var(--color-accent);
  color: var(--color-accent-2);
}
.plan-mode-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.public-plan-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.public-plan-tab {
  padding: 0.6rem 0.9rem;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.public-plan-tab.active {
  color: var(--color-accent-2);
  border-bottom-color: var(--color-accent);
}

.public-plan-discover, .public-plan-mine {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.public-plan-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.public-plan-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.public-plan-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.public-plan-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
}

.public-plan-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(124,58,237,0.15);
  color: var(--color-accent-2);
}
.public-plan-badge.draft { background: rgba(148,163,184,0.2); color: var(--color-text-muted); }
.public-plan-badge.published { background: rgba(34,197,94,0.15); color: #22c55e; }

.public-plan-card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.public-plan-card-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.public-plan-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.public-plan-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.public-plan-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.public-plan-detail-title {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.public-plan-detail-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.public-plan-name-input {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* ============================================================
   DRUCKANSICHT — EINKAUFSLISTE ALS PDF EXPORTIEREN
   ============================================================ */
@media print {
  /* App-Chrome ausblenden — nur die Liste soll gedruckt werden */
  .bottom-nav,
  .app-header,
  #shop-generate-btn,
  #shop-add-item-btn,
  #shop-export-btn,
  #shop-prev-week,
  #shop-next-week,
  .shop-item-actions,
  .modal-backdrop,
  .modal,
  .toast {
    display: none !important;
  }

  /* Layout auf natürlichen Dokumentfluss umstellen statt Viewport-Scroll */
  html, body, #app, .app-shell, .app-main,
  .view.active, .view-content, #shopping-content, .shop-layout, .shop-list {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
    display: block !important;
    background: #fff !important;
  }

  body { color: #000; }

  /* Kein eigener Seitenkopf — die Liste soll ganz oben auf Seite 1 beginnen, damit der Browser
     column-fill:auto ab einer vollen, eindeutigen Seitenhöhe berechnen kann (mit vorangehendem
     Inhalt springt Chromium sonst auf Seite 2, da die Resthöhe auf Seite 1 nicht sicher genug
     für die Spaltenberechnung ist). Titel/Datum/Uhrzeit zeigt ohnehin die Browser-eigene
     Druck-Kopf-/Fußzeile an.  */
  .shop-toolbar,
  .section-header {
    display: none !important;
  }

  .shop-list {
    display: block !important;
    column-count: 2;
    column-fill: auto;
    column-gap: 0.75rem;
    column-rule: 1px solid var(--color-accent);
  }

  /* Nur die kleinen, atomaren Einheiten am Umbruch hindern — .shop-group NICHT, sonst
     springt bei zu wenig Restplatz (z.B. nach dem Header auf Seite 1) der komplette Inhalt
     auf die nächste Spalte/Seite und lässt Seite 1 fast leer zurück. */
  .shop-tag-group,
  .shop-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* .shop-list ist jetzt display:block (Mehrspalten) — gap wirkt nur zwischen den Spalten,
     nicht mehr zwischen den Gruppen innerhalb einer Spalte, daher hier explizit per margin */
  .shop-group {
    margin-bottom: 0.55rem;
  }

  /* Hauptkategorien: klare lila Trennlinie, etwas größer/luftiger */
  .shop-group-label {
    color: var(--color-accent) !important;
    font-size: 0.7rem;
    border-bottom: 1.5px solid var(--color-accent);
    padding-bottom: 0.2rem;
    margin-bottom: 0.3rem;
  }

  /* Tag-Untergruppen: keine eigene Box mehr (führte zu uneinheitlicher Artikel-Optik,
     da Artikel darin keinen eigenen Rahmen hatten) — stattdessen ein schmaler linker
     Akzentstrich + Unterüberschrift im normalen Textfluss. Die Artikel selbst sehen
     dadurch überall identisch aus, egal ob frei oder in einer Tag-Gruppe. */
  .shop-tag-group {
    border: none !important;
    background: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    padding-left: 0.5rem !important;
    margin: 0.55rem 0 0.4rem !important;
    border-left: 2px solid var(--color-accent) !important;
  }
  .shop-tag-label {
    position: static !important;
    display: block !important;
    background: none !important;
    color: var(--color-accent) !important;
    font-size: 0.6rem !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem !important;
  }

  /* Einzelne Artikel: identischer Rahmen/Optik überall, ob frei oder in einer Tag-Gruppe */
  .shop-item {
    background: #fff !important;
    border: 1px solid #444 !important;
    border-radius: 999px !important;
    padding: 0.3rem 0.6rem !important;
    gap: 0.4rem !important;
    color: #000 !important;
    margin-bottom: 0.25rem !important;
  }

  .shop-item-checked { opacity: 1 !important; }
  .shop-item-name,
  .shop-item-amount,
  .shop-item-checked .shop-item-name {
    font-size: 0.72rem !important;
    line-height: 1.25 !important;
    color: #000 !important;
  }

  .shop-check-btn {
    width: 14px !important;
    height: 14px !important;
    font-size: 0.55rem !important;
    border-color: var(--color-accent) !important;
    border-width: 1.5px !important;
    background: #fff !important;
    color: var(--color-accent) !important;
  }
  .shop-check-btn.checked {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: #fff !important;
  }
}
