/* Mein Ernährungs-Tagebuch — mobiles Design */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #1c2420;
  --muted: #6b7570;
  --line: #e3e8e4;
  --green: #16a34a;
  --green-dark: #128040;
  --protein: #2563eb;
  --carbs: #f59e0b;
  --fat: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 4px rgba(0,0,0,.07);
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { font-size: 1.15rem; font-weight: 700; }

main {
  flex: 1;
  padding: 14px 14px 90px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

h2 { font-size: 1.05rem; margin: 18px 0 8px; }
h3 { font-size: 1.05rem; margin-bottom: 10px; }
h4 { font-size: .95rem; margin: 12px 0 6px; }

.tab { display: none; }
.tab.active { display: block; }

/* Untere Tab-Leiste */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0 6px;
  font-size: 1.25rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.tab-btn span { font-size: .68rem; font-weight: 600; }
.tab-btn.active { color: var(--green-dark); }

/* Datum */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.date-label { font-weight: 700; font-size: 1.05rem; }

.icon-btn {
  border: none;
  background: rgba(255,255,255,.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
}
.app-header .icon-btn { background: rgba(255,255,255,.18); border: none; color: #fff; }

/* Tages-Summen */
.totals-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.kcal-ring { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.kcal-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#kcal-value { font-size: 1.5rem; font-weight: 800; }
.kcal-unit { font-size: .7rem; color: var(--muted); }

.macro-list { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.macro b { float: right; margin-left: 8px; }
.macro-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.macro-dot.protein { background: var(--protein); }
.macro-dot.carbs { background: var(--carbs); }
.macro-dot.fat { background: var(--fat); }
.goal-line { color: var(--muted); margin-top: 4px; }
.mini-link {
  border: none; background: none;
  color: var(--green-dark);
  text-decoration: underline;
  cursor: pointer;
  font-size: .82rem;
}

/* Buttons */
.add-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.big-btn.active-rate { background: #e2f5e9; border-color: var(--green); }
.big-btn.active-bad { background: #fde8e8; border-color: var(--fat); }
.big-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 12px 10px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.big-btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.big-btn.small { flex: 0 0 auto; padding: 9px 14px; font-size: .85rem; }
.big-btn:active { transform: scale(.98); }

/* Eintrags-Listen */
.entry-list { list-style: none; }
.entry-list li {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-sub { font-size: .78rem; color: var(--muted); }
.entry-kcal { font-weight: 700; white-space: nowrap; }
.entry-del {
  border: none; background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
}
.entry-list li.clickable { cursor: pointer; }
.entry-list li.checked .entry-name { text-decoration: line-through; color: var(--muted); }

.entry-list li.list-head {
  background: none;
  box-shadow: none;
  padding: 6px 6px 2px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

.empty-hint {
  color: var(--muted);
  font-size: .88rem;
  text-align: center;
  padding: 18px 10px;
  line-height: 1.5;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 12px;
}
.section-head h2 { margin: 0; }

/* Körper-Tab */
.input-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.input-card input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 1rem;
}
.unit { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.chart-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  margin-bottom: 8px;
}
.chart-card svg { width: 100%; height: 160px; display: block; }

/* Overlays */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10,15,12,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }
.overlay-box {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.overlay-box > .big-btn { width: 100%; margin-top: 10px; }

.scan-box { text-align: center; }
#scan-video {
  width: 100%;
  max-height: 42dvh;
  border-radius: 12px;
  background: #000;
  object-fit: cover;
}
.scan-status { color: var(--muted); font-size: .85rem; margin: 8px 0; min-height: 1.2em; }

.manual-ean {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.manual-ean input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  font-size: 1rem;
}

.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-grid label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-grid input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 1rem;
  color: var(--ink);
}

.quiz-grid { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.quiz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}
.quiz-label { font-size: .92rem; font-weight: 600; }
.quiz-header {
  margin: 10px 2px 2px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.stars { display: inline-flex; gap: 2px; }
.star {
  border: none;
  background: none;
  font-size: 1.35rem;
  line-height: 1;
  color: #d5dbd6;
  cursor: pointer;
  padding: 2px;
}
.star.on { color: #f59e0b; }
.stars.small .star { font-size: 1.1rem; }

.plan-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.plan-date { font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-kcal { font-size: .74rem; color: var(--green-dark); font-weight: 600; white-space: nowrap; }
.plan-kcal.over { color: var(--fat); }
.plan-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}
.plan-slot-label { flex: 0 0 132px; font-size: .82rem; color: var(--muted); }
.plan-slot-main { flex: 1; font-size: .88rem; font-weight: 600; min-width: 0; }
.plan-slot-main small { color: var(--muted); font-weight: 400; }
.plan-slot-main.empty { color: var(--muted); font-weight: 400; }
.plan-slot-main.eaten { text-decoration: line-through; color: var(--muted); }
.portion-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 14px 0 4px;
}
#portion-value { font-size: 2.2rem; font-weight: 800; min-width: 70px; }
.portion-stepper .big-btn { flex: 0 0 auto; width: 56px; font-size: 1.4rem; }

.katalog-fav {
  border: none;
  background: none;
  font-size: 1.5rem;
  color: #d5dbd6;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
}
.katalog-fav.on { color: #f59e0b; }

.plan-btn {
  border: none;
  background: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 2px 4px;
}

.form-grid select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
}

input[type=checkbox].shop-check {
  width: 22px; height: 22px;
  accent-color: var(--green);
  flex-shrink: 0;
}
