:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}

html.dark {
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --red-light: #450a0a;
  --green-light: #052e16;
  --shadow: 0 1px 4px rgba(0,0,0,.3);
}

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

/* Schlanke, theme-abhängige Scrollbar (Windows zeigt sonst eine klobige weiße Leiste) */
.thin-scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.thin-scroll::-webkit-scrollbar { height: 6px; width: 6px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }
.thin-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.thin-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background .2s, color .2s;
  padding-top: 62px;   /* Platz für die fixierte Topbar */
}

/* ---- Dark mode toggle ---- */
.dark-toggle {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color .15s;
}
.dark-toggle:hover { border-color: var(--green); }
.dark-toggle .icon-moon { display: none; }
.dark-toggle .icon-sun  { display: inline; }
html.dark .dark-toggle .icon-moon { display: inline; }
html.dark .dark-toggle .icon-sun  { display: none; }

/* ---- Auth ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo { font-size: 52px; margin-bottom: 8px; }
.auth-card h1 { font-size: 26px; margin-bottom: 24px; color: var(--text); }
.hint { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.auth-link { margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-link a { color: var(--green); text-decoration: none; }

.auth-topbar {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 100;
}

/* ---- Remember me ---- */
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  margin: 4px 0 12px;
}
.remember-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}
.remember-row label {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0;
  font-weight: 400;
}

/* ---- Forms ---- */
.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--surface);
  transition: border-color .15s, background .2s;
  color: var(--text);
  color-scheme: light dark;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
}

.macros-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ---- Buttons ---- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
  text-decoration: none;
  text-align: center;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary {
  display: inline-block;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  background: none;
}

.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.form-actions .btn-primary { flex: 1; margin-top: 0; }

/* ---- Alerts ---- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  text-align: left;
}
.alert-error { background: var(--red-light); color: var(--red); }
.alert-success { background: var(--green-light); color: var(--green); }

/* ---- Topbar ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 62px;
  transition: background .2s, border-color .2s;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}

/* Logo */
.logo-small {
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Haupt-Navigation */
.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0;
}
.nav-item {
  /* Explizite Größe erzwingt konsistentes Verhalten auf allen Browsern */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 62px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  position: relative;
  white-space: nowrap;
  box-sizing: border-box;
}
.nav-item:hover { color: var(--green); }
.nav-item.active { color: var(--green); border-bottom-color: var(--green); }
.nav-icon {
  font-size: 22px;
  line-height: 22px;
  height: 22px;
  display: block;
  margin-bottom: 4px;
}
.nav-label {
  font-size: 11px;
  line-height: 1;
  display: block;
}

/* Badge */
.nav-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

/* Rechts: dark-toggle + logout */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-logout {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
}
.btn-logout:hover { border-color: var(--red); color: var(--red) !important; }
.back-btn { text-decoration: none; color: var(--green); font-weight: 600; }

.mobile-logout { display: none; }

/* Mittlere Breiten (große Handys, Foldables, kleine Tablets, schmale Fenster):
   Labels aus & Icons gleichmäßig verteilen, damit die 9 Punkte immer ohne Wischen passen. */
@media (max-width: 1080px) {
  .nav-label { display: none; }
  .nav-item { width: auto; min-width: 0; flex: 1 1 0; padding: 0 2px; }
  .main-nav { flex: 1; min-width: 0; gap: 0; justify-content: space-around; }
}

/* Mobile */
@media (max-width: 600px) {
  .mobile-logout { display: inline-block; }
  .nav-label { display: none; }
  .nav-item { width: auto; padding: 0 2px; min-width: 0; flex: 1 1 0; height: 54px; }
  .nav-icon { font-size: 21px; }
  .logo-small { display: none; }
  .btn-logout { display: none; }
  .nav-right { display: none; }
  .topbar { padding: 0 2px; gap: 0; }
  .main-nav { gap: 0; justify-content: space-between; flex: 1; min-width: 0; width: 100%; }
}

/* ---- Container ---- */
.container { max-width: 700px; margin: 0 auto; padding: 20px 16px; }

/* ---- Greeting ---- */
.greeting { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

/* ---- Date nav ---- */
.date-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.date-nav::-webkit-scrollbar { display: none; }

.day-chip {
  /* 7 Tage füllen genau die Sichtbreite; Kalender-Chip liegt dahinter (einwischbar) */
  flex: 0 0 auto;
  width: min(calc((100vw - 68px) / 7), 92px);
  scroll-snap-align: start;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 2px;
  border-radius: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 12px;
  transition: all .15s;
}
.day-chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.day-name { font-weight: 600; font-size: 11px; }
.day-num  { font-size: 15px; font-weight: 700; margin-top: 2px; }

/* Desktop/Maus: kein Wischen → 7 Tage gleichmäßig über die Breite, Wisch-Kalender-Chip weg
   (Datum wird per Klick auf die große Datumszeile gewechselt) */
@media (pointer: fine) {
  .date-nav { overflow-x: visible; }
  .date-nav .day-chip { flex: 1 1 0; width: auto; min-width: 0; }
  .date-nav .cal-chip { display: none; }
}

/* Kalender-Chip am Ende der Tagesleiste (rechts einwischbar, zeigt heutiges Datum) */
.cal-chip {
  width: auto;
  min-width: 170px;
  padding: 8px 22px;
  cursor: pointer;
  font-family: inherit;
  /* normaler Rahmen wie die Tage (erbt border/background von .day-chip) */
}
.cal-chip .cal-date { font-size: 18px; font-weight: 800; white-space: nowrap; color: var(--text); }

.date-picker {
  flex-shrink: 0;
  width: auto;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 600;
}
.date-picker::-webkit-datetime-edit,
.date-picker::-webkit-datetime-edit-fields-wrapper,
.date-picker::-webkit-datetime-edit-text,
.date-picker::-webkit-datetime-edit-day-field,
.date-picker::-webkit-datetime-edit-month-field,
.date-picker::-webkit-datetime-edit-year-field {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
}

/* ---- Summary bar ---- */
.summary-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.summary-date { width: 100%; font-size: 16px; font-weight: 700; }
.summary-cals { flex: 1; font-size: 14px; color: var(--text-muted); }
.cal-num { font-size: 22px; font-weight: 800; color: var(--green); }

.btn-add {
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-add:hover { background: var(--green-dark); }

/* ---- Meal sections ---- */
.meal-section {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.meal-header h2 { font-size: 15px; font-weight: 700; }
.add-meal-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-light);
  color: var(--green);
  border-radius: 50%;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.empty-meal {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Entry rows ---- */
.entry-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  align-items: start;
}
.entry-row:last-child { border-bottom: none; }

.entry-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}
.entry-note { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 1px; }

.entry-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-left: 12px;
}

.entry-macros { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }
.macro {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 20px;
  font-weight: 600;
}
.macro.p { background: #dbeafe; color: #1d4ed8; }
.macro.c { background: #fef9c3; color: #92400e; }
.macro.f { background: #fee2e2; color: #dc2626; }
html.dark .macro.p { background: #1e3a5f; color: #93c5fd; }
html.dark .macro.c { background: #451a03; color: #fcd34d; }
html.dark .macro.f { background: #450a0a; color: #fca5a5; }

.entry-cals { font-size: 20px; font-weight: 900; color: var(--green); white-space: nowrap; }
.entry-actions { display: flex; gap: 10px; }
.entry-actions a { text-decoration: none; font-size: 17px; opacity: .65; }
.entry-actions a:hover { opacity: 1; }

/* ---- Entry form ---- */
.entry-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---- Stats ---- */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-val { font-size: 28px; font-weight: 800; color: var(--green); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stats-table th, .stats-table td {
  padding: 10px 14px;
  font-size: 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.stats-table th { font-size: 12px; color: var(--text-muted); background: var(--bg); font-weight: 600; }
.stats-table td:first-child, .stats-table th:first-child { text-align: left; }
.stats-table a { color: var(--green); text-decoration: none; font-weight: 600; }
.stats-table tr:last-child td { border-bottom: none; }

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

/* ---- Search ---- */
.search-form { display: flex; gap: 10px; margin-bottom: 24px; }
.search-form input { flex: 1; margin: 0; }
.section-heading { font-size: 15px; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; font-size: 12px; }

/* ---- User cards (Explore) ---- */
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.user-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
    flex-shrink: 0; text-decoration: none;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: 15px; text-decoration: none; color: var(--text); display: block; }
.user-bio  { font-size: 13px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta { font-size: 12px; color: var(--text-muted); }

.btn-follow {
    padding: 7px 18px;
    border-radius: 20px;
    border: 2px solid var(--green);
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}
.btn-follow.following {
    background: none;
    color: var(--green);
}
.btn-follow:hover { opacity: .85; }

/* ---- Profile ---- */
.profile-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 24px; color: #fff;
    flex-shrink: 0;
}
.profile-name { font-size: 22px; font-weight: 800; }
.profile-bio  { font-size: 14px; color: var(--text-muted); margin: 4px 0 8px; }
.profile-stats { display: flex; gap: 20px; font-size: 14px; color: var(--text-muted); }
.profile-stats strong { color: var(--text); }
.profile-actions { display: flex; gap: 10px; margin-bottom: 20px; }

/* ---- Social entries ---- */
.social-entry {
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.social-entry-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.social-avatar-sm {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: #fff;
    flex-shrink: 0;
}
.social-avatar-xs {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 10px; color: #fff;
    flex-shrink: 0;
}
.social-entry-name { font-weight: 700; font-size: 14px; display: block; }
.social-entry-meta { font-size: 12px; color: var(--text-muted); }
.social-entry-body { padding: 14px 16px; }
.social-food-name  { font-size: 16px; font-weight: 700; }
.social-notes      { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.social-actions    { display: flex; gap: 12px; padding: 8px 16px 12px; }

.like-btn {
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: var(--text-muted); padding: 4px 8px;
    border-radius: 20px; transition: background .1s;
}
.like-btn:hover, .like-btn.liked { background: var(--red-light); color: var(--red); }
.comment-toggle {
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: var(--text-muted); padding: 4px 8px; border-radius: 20px;
}
.comment-toggle:hover { background: var(--bg); }

.comment-list { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.comment-row  { display: flex; gap: 8px; align-items: flex-start; }
.comment-content { background: var(--bg); border-radius: 12px; padding: 7px 12px; font-size: 13px; }
.comment-author   { font-weight: 700; margin-right: 6px; }
.comment-form     { display: flex; gap: 8px; padding: 8px 16px 12px; }
.comment-form input { margin: 0; padding: 8px 12px; font-size: 13px; }

/* ---- Color picker ---- */
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-option input { display: none; }
.color-swatch {
    width: 36px; height: 36px;
    border-radius: 50%; cursor: pointer;
    border: 3px solid transparent;
    transition: transform .1s, border-color .1s;
    display: block;
}
.color-option input:checked + .color-swatch {
    border-color: var(--text);
    transform: scale(1.15);
}

@media (max-width: 480px) {
  .macros-row { grid-template-columns: 1fr; }
  .stats-cards { grid-template-columns: 1fr 1fr; }
  .entry-macros { display: none; }
  .auth-card { padding: 28px 20px; }
}

/* ── Social-Media-Leiste ── */
.social-bar { display: flex; gap: 12px; align-items: center; justify-content: center; }
.social-bar a {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); color: var(--text-muted);
  transition: all .15s;
}
.social-bar a:hover { color: #fff; background: linear-gradient(135deg,#16a34a,#0891b2); border-color: transparent; transform: translateY(-2px); }
/* Breite Variante: füllt die ganze Zeile (z.B. im Profil) */
.social-bar.social-wide { gap: 8px; }
.social-bar.social-wide a { flex: 1 1 0; width: auto; height: 46px; border-radius: 12px; }

/* ── Moderne Seiten-Überschrift ── */
.page-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 0 20px;
}
.page-head .ph-bar { display: none; }
.page-head .ph-emoji {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(22,163,74,.16), rgba(8,145,178,.16));
  border: 1px solid rgba(22,163,74,.22);
}
.page-head h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.2px;
  margin: 0;
  line-height: 1.2;
}
