:root {
  --gruen: #2a9d6f;
  --gruen-dunkel: #1e7a55;
  --gruen-hell: #e3f2ea;
  --orange: #e8873a;
  --rot: #d9534f;
  --blau: #4a7fb5;
  --bg: #f6f7f5;
  --karte: #ffffff;
  --text: #22302a;
  --text-2: #5f6f66;
  --linie: #e2e7e3;
  --schatten: 0 1px 4px rgba(20, 40, 30, .08);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --gruen: #3db486;
    --gruen-dunkel: #2a9d6f;
    --gruen-hell: #1c3329;
    --bg: #121815;
    --karte: #1c2420;
    --text: #e8eee9;
    --text-2: #93a399;
    --linie: #2b352f;
    --schatten: 0 1px 4px rgba(0, 0, 0, .4);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.view { flex: 1; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.35rem; margin-bottom: 2px; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
h3 { font-size: .95rem; margin: 10px 0 6px; }
.untertitel { color: var(--text-2); font-size: .88rem; margin-bottom: 14px; }

.karte {
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 14px;
  margin-bottom: 12px;
}

/* Tab-Leiste */
.tabbar[hidden] { display: none; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 640px; margin: 0 auto;
  display: flex;
  background: var(--karte);
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--text-2);
  font-size: .68rem; padding: 8px 0 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit;
}
.tabbar button .ico { font-size: 1.25rem; line-height: 1.1; }
.tabbar button.aktiv { color: var(--gruen); font-weight: 600; }

/* Formulare */
label.feld { display: block; margin-bottom: 12px; font-size: .88rem; color: var(--text-2); }
label.feld > span { display: block; margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--linie); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gruen); outline-offset: -1px; }
.zeile { display: flex; gap: 10px; }
.zeile > * { flex: 1; }

button.primaer, button.sekundaer, button.klein, button.gefahr {
  font-family: inherit; cursor: pointer; border-radius: 10px; border: 0;
  font-size: .95rem; font-weight: 600;
}
button.primaer { background: var(--gruen); color: #fff; padding: 12px 18px; width: 100%; }
button.primaer:active { background: var(--gruen-dunkel); }
button.sekundaer { background: var(--gruen-hell); color: var(--gruen-dunkel); padding: 10px 14px; }
button.klein { background: var(--gruen-hell); color: var(--gruen-dunkel); padding: 6px 10px; font-size: .82rem; }
button.gefahr { background: none; color: var(--rot); padding: 6px 10px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; }

/* Kopfzeile mit Datum */
.datum-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.datum-nav button { background: var(--karte); border: 1px solid var(--linie); border-radius: 10px; width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.datum-nav .datum { font-weight: 600; font-size: 1rem; text-align: center; }
.datum-nav .datum small { display: block; color: var(--text-2); font-weight: 400; font-size: .75rem; }

/* Energie-Ring */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap svg { flex-shrink: 0; }
.ring-text { text-align: center; }
.ring-text .gross { font-size: 1.5rem; font-weight: 700; display: block; line-height: 1.1; }
.ring-text small { color: var(--text-2); font-size: .72rem; }
.ring-info { flex: 1; display: grid; gap: 6px; font-size: .85rem; }
.ring-info div { display: flex; justify-content: space-between; }
.ring-info .wert { font-weight: 600; }

/* Fortschrittsbalken */
.balken { margin-bottom: 10px; }
.balken .kopf { display: flex; justify-content: space-between; font-size: .84rem; margin-bottom: 3px; }
.balken .kopf .name { font-weight: 500; }
.balken .kopf .zahlen { color: var(--text-2); }
.balken .spur { height: 8px; border-radius: 5px; background: var(--linie); overflow: hidden; }
.balken .spur { display: flex; }
.balken .fuellung { height: 100%; border-radius: 5px; background: var(--gruen); transition: width .3s; }
/* Supplement-Anteil sitzt sichtbar abgesetzt auf dem Anteil aus der Ernährung */
.balken .fuellung.supplement {
  background: repeating-linear-gradient(45deg, var(--blau), var(--blau) 3px,
    color-mix(in srgb, var(--blau) 55%, white) 3px, color-mix(in srgb, var(--blau) 55%, white) 6px);
}
.balken.limit .fuellung { background: var(--blau); }
.balken.warnung .fuellung { background: var(--orange); }
.balken.ueber .fuellung { background: var(--rot); }
.balken .hinweis { font-size: .74rem; color: var(--text-2); margin-top: 2px; }

/* Mikronährstoff-Raster */
.mikro-raster { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
@media (max-width: 420px) { .mikro-raster { grid-template-columns: 1fr; } }

/* Einträge-Liste */
.eintrag {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--linie);
}
.eintrag:last-child { border-bottom: 0; }
.eintrag .info { flex: 1; min-width: 0; }
.eintrag .name { font-size: .92rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eintrag .detail { font-size: .78rem; color: var(--text-2); }
.eintrag .kcal { font-size: .88rem; font-weight: 600; white-space: nowrap; }
.slot-titel { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.slot-titel h3 { margin: 0; }
.slot-titel small { color: var(--text-2); }

/* Suche */
.suchfeld { position: sticky; top: 0; background: var(--bg); padding: 6px 0 10px; z-index: 5; }
.treffer { cursor: pointer; }
.treffer:hover { background: var(--gruen-hell); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button {
  border: 1px solid var(--linie); background: var(--karte); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer; font-family: inherit;
}
.chips button.aktiv { background: var(--gruen); color: #fff; border-color: var(--gruen); }

/* Modal */
.modal-hintergrund {
  position: fixed; inset: 0; background: rgba(10, 20, 15, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal {
  background: var(--karte); border-radius: 18px 18px 0 0;
  width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .modal-hintergrund { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal h2 { margin-top: 0; }
.modal .schliessen { float: right; background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--text-2); }

/* Toast */
#toast-root { position: fixed; bottom: 90px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 60; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .88rem; box-shadow: var(--schatten); animation: toast-ein .25s ease;
}
@keyframes toast-ein { from { opacity: 0; transform: translateY(8px); } }

.leer { text-align: center; color: var(--text-2); padding: 28px 10px; font-size: .9rem; }
.hinweis-box { background: var(--gruen-hell); border-radius: 10px; padding: 10px 12px; font-size: .84rem; margin: 10px 0; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .85rem; }
.tabelle td { padding: 6px 4px; border-bottom: 1px solid var(--linie); }
.abzeichen { display: inline-block; background: var(--gruen-hell); color: var(--gruen-dunkel); border-radius: 6px; padding: 1px 7px; font-size: .72rem; font-weight: 600; }
