/* Kalorien – Oberfläche. Hell und dunkel, je nach Systemeinstellung. */

:root {
  --grund: #f4f6f9;
  --karte: #ffffff;
  --karte-rand: #e3e7ee;
  --text: #171b22;
  --text-leise: #6b7482;
  --text-still: #99a1ae;

  --kcal: #2f7d6b;
  --kcal-hell: #d9ece7;
  --eiweiss: #3563b8;
  --eiweiss-hell: #dde6f7;
  --fett: #c2820e;
  --fett-hell: #f8ecd2;
  --kh: #8250b8;
  --kh-hell: #ebe1f7;

  --gut: #2f7d4a;
  --warn: #b4531a;
  --fehler: #b3382f;
  --schatten: 0 1px 2px rgba(18, 24, 33, .06), 0 4px 14px rgba(18, 24, 33, .05);
  --rund: 14px;
  --leiste: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #12151b;
    --karte: #1a1f27;
    --karte-rand: #2a313c;
    --text: #e8ecf2;
    --text-leise: #9aa4b2;
    --text-still: #6d7787;

    --kcal: #4fbfa3;
    --kcal-hell: #1d3a34;
    --eiweiss: #6d9ded;
    --eiweiss-hell: #1c2a44;
    --fett: #e2ad4a;
    --fett-hell: #3a2f16;
    --kh: #b58ae8;
    --kh-hell: #2e2340;

    --gut: #5cc07f;
    --warn: #e0913f;
    --fehler: #e57366;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 calc(var(--leiste) + env(safe-area-inset-bottom, 0px));
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--grund);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

.huelle { max-width: 640px; margin: 0 auto; padding: 0 14px; }

/* ------------------------------------------------------------ Kopfzeile */

header.kopf {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--grund) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--karte-rand);
  padding-top: env(safe-area-inset-top, 0px);
}
.kopf-innen {
  max-width: 640px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.kopf h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
.kopf .datum-zeile { display: flex; align-items: center; gap: 4px; flex: 1; }
.kopf .datum-zeile h1 { flex: none; }
.kopf .heute-tag {
  font-size: 11px; font-weight: 600; color: var(--kcal);
  background: var(--kcal-hell); padding: 2px 7px; border-radius: 20px;
}

.pfeil {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  color: var(--text-leise); text-decoration: none; font-size: 17px;
  border: 1px solid transparent;
}
.pfeil:hover { background: var(--karte); border-color: var(--karte-rand); }

/* --------------------------------------------------------------- Karten */

.karte {
  background: var(--karte); border: 1px solid var(--karte-rand);
  border-radius: var(--rund); box-shadow: var(--schatten);
  margin: 12px 0; padding: 16px;
}
.karte.schmal { padding: 12px 14px; }
.karte h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-leise); margin: 0 0 10px; font-weight: 600;
}

/* ------------------------------------------------------------ Tagesring */

.ring-block { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .spur { stroke: var(--kcal-hell); }
.ring .fuellung {
  stroke: var(--kcal); stroke-linecap: round;
  transition: stroke-dasharray .5s ease;
}
.ring.ueber .fuellung { stroke: var(--warn); }
.ring-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.ring-zahl { font-size: 29px; font-weight: 650; letter-spacing: -.02em; }
.ring-eti { font-size: 11px; color: var(--text-leise); }

.makros { flex: 1; display: flex; flex-direction: column; gap: 11px; }
.makro-kopf {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; margin-bottom: 4px;
}
.makro-name { font-weight: 600; }
.makro-wert { color: var(--text-leise); font-variant-numeric: tabular-nums; }
.balken {
  height: 7px; border-radius: 4px; overflow: hidden; background: var(--karte-rand);
}
.balken i { display: block; height: 100%; border-radius: 4px; transition: width .5s ease; }
.makro.eiweiss .balken { background: var(--eiweiss-hell); }
.makro.eiweiss .balken i { background: var(--eiweiss); }
.makro.fett .balken { background: var(--fett-hell); }
.makro.fett .balken i { background: var(--fett); }
.makro.kh .balken { background: var(--kh-hell); }
.makro.kh .balken i { background: var(--kh); }

/* Über dem Ziel – genauso gekennzeichnet wie der Kalorienring. */
.makro.ueber .balken i { background: var(--warn); }
.makro.ueber .makro-wert b { color: var(--warn); font-weight: 650; }

@media (max-width: 430px) {
  .ring-block { flex-direction: column; gap: 14px; }
  .makros { width: 100%; }
}

/* ------------------------------------------------------------- Mahlzeit */

.mahlzeit + .mahlzeit { margin-top: 10px; }
.mahlzeit-kopf {
  display: flex; align-items: baseline; gap: 8px; padding: 0 2px 6px;
}
.mahlzeit-kopf h3 { margin: 0; font-size: 14px; font-weight: 650; }
.mahlzeit-kopf .summe {
  margin-left: auto; font-size: 13px; color: var(--text-leise);
  font-variant-numeric: tabular-nums;
}

.eintrag {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--karte); border: 1px solid var(--karte-rand);
  border-radius: 11px; margin-bottom: 6px;
}
/* Einträge lassen sich antippen und öffnen dann den Bearbeiten-Dialog. */
.eintrag[data-eintrag] { cursor: pointer; transition: border-color .12s ease; }
.eintrag[data-eintrag]:hover { border-color: var(--kcal); }
.eintrag[data-eintrag]:focus-visible {
  outline: 2px solid var(--kcal); outline-offset: 2px;
}
.eintrag .zeit {
  font-size: 12px; color: var(--text-still); width: 40px; flex: none;
  font-variant-numeric: tabular-nums;
}
.eintrag .mitte { flex: 1; min-width: 0; }
.eintrag .name {
  font-weight: 550; font-size: 15px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.eintrag .unter {
  font-size: 12px; color: var(--text-leise); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eintrag .kcal {
  font-weight: 600; font-variant-numeric: tabular-nums; flex: none;
  font-size: 15px;
}
.eintrag .weg {
  border: 0; background: none; color: var(--text-still); cursor: pointer;
  font-size: 17px; padding: 4px 2px; line-height: 1; flex: none;
}
.eintrag .weg:hover { color: var(--fehler); }

.leer {
  text-align: center; color: var(--text-still); font-size: 14px;
  padding: 26px 16px;
}

/* -------------------------------------------------------------- Wochen */

.wochenbalken {
  display: flex; align-items: stretch; gap: 8px; height: 152px;
  padding: 8px 2px 0;
}
.wochentag {
  flex: 1; height: 100%; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
/* Der Link umschließt Säule und Beschriftung, ohne das Raster zu stören. */
.wochentag > a {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 100%; height: 100%;
}
.wochentag .saeule {
  width: 100%; background: var(--kcal-hell); border-radius: 6px;
  display: flex; align-items: flex-end; overflow: hidden;
  flex: 1; min-height: 4px; position: relative;
}
.wochentag .saeule i {
  display: block; width: 100%; background: var(--kcal);
  border-radius: 6px; transition: height .5s ease;
}
.wochentag.ueber .saeule i { background: var(--warn); }
.wochentag.zukunft .saeule { opacity: .4; }
.wochentag .tag-name { font-size: 11px; color: var(--text-leise); }
.wochentag.heute .tag-name { color: var(--kcal); font-weight: 700; }
.wochentag a { text-decoration: none; color: inherit; }
.ziel-linie {
  position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-still);
  opacity: .55;
}

.werte-gitter {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  text-align: center;
}
.werte-gitter .zelle { padding: 8px 4px; }
.werte-gitter .gross {
  font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.werte-gitter .klein { font-size: 11px; color: var(--text-leise); margin-top: 2px; }
.werte-gitter .kcal-farbe { color: var(--kcal); }
.werte-gitter .eiweiss-farbe { color: var(--eiweiss); }
.werte-gitter .fett-farbe { color: var(--fett); }
.werte-gitter .kh-farbe { color: var(--kh); }

/* ------------------------------------------------------------ Bedienung */

button, .knopf {
  font: inherit; font-weight: 550; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--karte-rand); background: var(--karte);
  color: var(--text); padding: 10px 15px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
button:hover, .knopf:hover { border-color: var(--text-still); }
button:disabled { opacity: .5; cursor: not-allowed; }
.knopf.wichtig, button.wichtig {
  background: var(--kcal); border-color: var(--kcal); color: #fff;
}
.knopf.wichtig:hover, button.wichtig:hover { filter: brightness(1.08); }
.knopf.gefahr, button.gefahr { color: var(--fehler); }
.knopf.klein, button.klein { padding: 6px 11px; font-size: 13px; }
.knopf.voll, button.voll { width: 100%; }

input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--karte-rand); background: var(--grund);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--kcal); outline-offset: -1px; border-color: transparent;
}
label { display: block; font-size: 13px; color: var(--text-leise); margin-bottom: 5px; }
.feld { margin-bottom: 13px; }
.feld-reihe { display: flex; gap: 10px; }
.feld-reihe > * { flex: 1; }

/* ------------------------------------------------------------ Fußleiste */

nav.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--karte) 94%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--karte-rand);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.leiste-innen {
  max-width: 640px; margin: 0 auto; height: var(--leiste);
  display: flex; align-items: center; justify-content: space-around;
}
.leiste a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-still); text-decoration: none; font-size: 10.5px;
  padding: 6px 12px; border-radius: 10px; min-width: 58px;
}
.leiste a.aktiv { color: var(--kcal); }
.leiste a svg { width: 21px; height: 21px; }

/* Mikrofon in der Mitte der Leiste */
.mikro-knopf {
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  background: var(--kcal); color: #fff; border: 0;
  box-shadow: 0 3px 14px color-mix(in srgb, var(--kcal) 45%, transparent);
  display: flex; align-items: center; justify-content: center;
  margin-top: -18px; transition: transform .15s ease;
}
.mikro-knopf:active { transform: scale(.93); }
.mikro-knopf svg { width: 24px; height: 24px; }

/* ------------------------------------------------------------- Overlay */

.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(10, 13, 18, .55); backdrop-filter: blur(3px);
  align-items: flex-end; justify-content: center;
}
.overlay.auf { display: flex; }
.blatt {
  background: var(--karte); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 18px 16px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh; overflow-y: auto;
  animation: hoch .22s cubic-bezier(.22, 1, .36, 1);
}
@keyframes hoch { from { transform: translateY(100%); } to { transform: none; } }
.blatt-griff {
  width: 38px; height: 4px; border-radius: 3px; background: var(--karte-rand);
  margin: -6px auto 14px;
}
.blatt h2 { font-size: 16px; margin: 0 0 12px; text-transform: none;
            letter-spacing: 0; color: var(--text); }

/* ------------------------------------------------------- Sprachaufnahme */

.aufnahme { text-align: center; padding: 8px 0 4px; }
.puls {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--kcal); color: #fff; display: flex;
  align-items: center; justify-content: center; border: 0;
}
.puls svg { width: 34px; height: 34px; }
.puls.laeuft { animation: pulsieren 1.5s ease-in-out infinite; }
@keyframes pulsieren {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--kcal) 50%, transparent); }
  50% { box-shadow: 0 0 0 18px transparent; }
}
.gehoert {
  font-size: 17px; min-height: 52px; padding: 10px 12px; text-align: center;
  color: var(--text); background: var(--grund); border-radius: 11px;
  margin: 12px 0;
}
.gehoert:empty::before {
  content: attr(data-leer); color: var(--text-still); font-size: 15px;
}
.gehoert .vorlaeufig { color: var(--text-still); }
.aufnahme-hinweis { font-size: 13px; color: var(--text-leise); }

/* --------------------------------------------------------- Vorschlaege */

.vorschlag {
  border: 1px solid var(--karte-rand); border-radius: 12px;
  padding: 12px 13px; margin-bottom: 9px; background: var(--grund);
}
.vorschlag.unsicher { border-color: var(--warn); }
.vorschlag-kopf { display: flex; align-items: center; gap: 8px; }
.vorschlag-kopf .raus {
  border: 0; background: none; color: var(--text-still); cursor: pointer;
  font-size: 19px; line-height: 1; padding: 2px 4px; flex: none;
}
.vorschlag-kopf .raus:hover { color: var(--fehler); }
.vorschlag-kopf .name { font-weight: 600; flex: 1; }
.vorschlag-kopf .kcal { font-weight: 650; font-variant-numeric: tabular-nums; }
.vorschlag .zeile2 {
  display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap;
}
.vorschlag .zeile2 input { width: 88px; padding: 6px 9px; font-size: 14px; }
.vorschlag .zeile2 select { width: auto; padding: 6px 9px; font-size: 14px; }
/* Auch außerhalb der Vorschau genutzt, etwa auf der Scanner-Seite. */
.makro-mini {
  font-size: 12px; color: var(--text-leise); margin-top: 7px;
  display: flex; gap: 11px; flex-wrap: wrap; align-items: baseline;
}
.vorschlag .hinweis {
  font-size: 12px; color: var(--warn); margin-top: 6px;
}
.wahl-punkt {
  display: inline-block; padding: 4px 9px; border-radius: 16px; font-size: 12px;
  border: 1px solid var(--karte-rand); background: var(--karte);
  cursor: pointer; margin: 4px 4px 0 0;
}
.wahl-punkt.gewaehlt { border-color: var(--kcal); color: var(--kcal); font-weight: 600; }

/* Deutlicher Hinweis, wenn der Eintrag nicht auf heute fällt. */
.tag-hinweis {
  font-size: 13px; font-weight: 550; color: var(--warn);
  background: var(--fett-hell); border: 1px solid var(--fett);
  border-radius: 9px; padding: 8px 11px; margin: -4px 0 12px;
  display: flex; align-items: center; gap: 7px;
}
/* „display: flex“ würde das hidden-Attribut sonst überstimmen. */
.tag-hinweis[hidden] { display: none; }

/* Bezeichnung im Vorschlag ist überschreibbar. */
.vorschlag .name-feld {
  font-weight: 600; font-size: 15px; flex: 1; min-width: 0;
  border: 1px solid transparent; background: transparent;
  padding: 4px 6px; margin: -4px 0 -4px -6px; border-radius: 7px;
}
.vorschlag .name-feld:hover { border-color: var(--karte-rand); }
.vorschlag .name-feld:focus {
  background: var(--karte); border-color: var(--kcal); outline: none;
}
/* Drei schmale Zahlenfelder nebeneinander – in der Sprachvorschau wie im
   Bearbeiten-Dialog. */
.werte-felder {
  display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap;
}
.werte-felder label { margin: 0 0 3px; font-size: 11px; }
.werte-felder > div { flex: 1; min-width: 62px; }
.werte-felder input { width: 100%; padding: 6px 8px; font-size: 14px; }

/* ------------------------------------------------------------- Meldungen */

.meldung {
  padding: 11px 14px; border-radius: 11px; margin: 10px 0; font-size: 14px;
  border: 1px solid;
}
.meldung.gut { background: var(--kcal-hell); border-color: var(--kcal); }
.meldung.fehler { background: color-mix(in srgb, var(--fehler) 12%, transparent);
                  border-color: var(--fehler); }
.meldung.hinweis { background: var(--fett-hell); border-color: var(--fett); }

.brot {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--leiste) + 16px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--grund); padding: 11px 18px;
  border-radius: 22px; font-size: 14px; z-index: 80; box-shadow: var(--schatten);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
.brot.zeigen { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* --------------------------------------------------------------- Listen */

.liste-eintrag {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  border-bottom: 1px solid var(--karte-rand); text-decoration: none;
  color: inherit;
}
.liste-eintrag:last-child { border-bottom: 0; }
.liste-eintrag .mitte { flex: 1; min-width: 0; }
.liste-eintrag .name { font-weight: 550; }
.liste-eintrag .unter { font-size: 12.5px; color: var(--text-leise); }
.liste-eintrag .stern { font-size: 15px; color: var(--fett); flex: none; }
.marke {
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: var(--karte-rand); color: var(--text-leise);
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 20px; font-size: 13.5px;
  border: 1px solid var(--karte-rand); background: var(--karte);
  cursor: pointer; color: inherit; text-decoration: none;
}
.chip:hover { border-color: var(--kcal); color: var(--kcal); }

.fuss {
  text-align: center; font-size: 11.5px; color: var(--text-still);
  padding: 20px 14px 10px; line-height: 1.7;
}
.fuss a { color: var(--text-leise); }
