/* KI-MI – iPhone-first. Farben aus dem Bauplan: Navy = Eiweiß, Lavendel = Fett, Lime = Kohlenhydrate. */
:root {
  --navy: #183446; --navy-ink: #0E2230; --lime: #DDE8B9; --lime-deep: #AFC46A; --lav: #A9B3CE;
  --bg: #F5F7EE; --karte: #FFFFFF; --text: #183446; --leise: #5A6B78; --linie: #E3E7D9; --feld: #F1F3EA;
  --rot: #B5452F; --gut: #4F7A3A; --tief: #183446; --mic-bg: #183446; --mic-icon: #DDE8B9;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Figtree", -apple-system, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --oben: env(safe-area-inset-top, 0px); --unten: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F2230; --karte: #16303F; --text: #E9EEDC; --leise: #A3B0BC; --linie: #24425A; --feld: #1D3A4C;
    --navy: #DDE8B9; --navy-ink: #0B1A24; --rot: #E58A73; --gut: #A9CB8A; --tief: #24506A; --mic-bg: #DDE8B9; --mic-icon: #183446; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.45; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.leise { color: var(--leise); }
.klein { font-size: .85rem; }
.k { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--leise); }

.seite { max-width: 520px; margin: 0 auto; padding: calc(var(--oben) + 18px) 16px calc(var(--unten) + 110px); display: flex; flex-direction: column; gap: 14px; }
.seite.ohne-tabs { padding-bottom: calc(var(--unten) + 24px); }
.kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kopf .logo { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; }

.karte { background: var(--karte); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.karte.dunkel { background: var(--tief); color: #EEF2E2; }
.karte.dunkel .k { color: var(--lime); }
.karte.dunkel .tipp { color: var(--lime); }
.zeile { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

/* Tageswerte */
.gross { font-family: var(--display); font-size: 2.2rem; font-weight: 800; line-height: 1; }
.makro { display: grid; grid-template-columns: 92px 1fr 78px; align-items: center; gap: 10px; font-size: .9rem; }
.makro span:last-child { text-align: right; color: var(--leise); font-variant-numeric: tabular-nums; }
.balken { height: 9px; border-radius: 5px; background: var(--feld); overflow: hidden; }
.balken i { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.balken i.ueber { box-shadow: inset 0 0 0 2px var(--rot); }
.punkt { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.e { background: #183446; } .f { background: var(--lav); } .c { background: var(--lime-deep); }
@media (prefers-color-scheme: dark) { .e { background: #F5F7EE; } }
.verteilung { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--feld); }

/* Listen */
.eintrag { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--linie); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; cursor: pointer; }
.eintrag:first-of-type { border-top: 0; }
.eintrag small { display: block; color: var(--leise); font-size: .8rem; }
.mahlzeit-kopf { display: flex; justify-content: space-between; padding-top: 6px; }
.marke { font-size: .7rem; background: var(--lav); color: #183446; border-radius: 6px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }
.leer { color: var(--leise); text-align: center; padding: 18px 8px; }

/* Datum */
.datumwahl { display: flex; align-items: center; gap: 6px; }
.rund { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--karte); color: var(--text); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.rund:disabled { opacity: .35; }

/* Knöpfe & Formulare */
.knopf { border: 0; border-radius: 14px; background: #183446; color: #fff; padding: 14px 16px; font-weight: 600; cursor: pointer; width: 100%; }
@media (prefers-color-scheme: dark) { .knopf { background: var(--lime); color: #183446; } }
.knopf.zweit { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px currentColor; }
.knopf.klein { white-space: nowrap; width: auto; padding: 8px 12px; font-size: .9rem; border-radius: 10px; }
.knopf:disabled { opacity: .5; }
.reihe { display: flex; gap: 10px; }
.reihe > * { flex: 1; }
label.feld { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--leise); }
input.eingabe, select.eingabe, textarea.eingabe { width: 100%; border: 1.5px solid var(--linie); border-radius: 12px; padding: 12px 14px; background: var(--karte); color: var(--text); font-size: 1rem; }
input.eingabe:focus, textarea.eingabe:focus, select.eingabe:focus { outline: none; border-color: var(--navy); }
.wahl { display: flex; flex-direction: column; gap: 10px; }
.option { border: 1.5px solid var(--linie); border-radius: 14px; padding: 13px 14px; background: var(--karte); display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; text-align: left; width: 100%; }
.option small { display: block; color: var(--leise); }
.option[aria-pressed="true"] { border-color: #183446; background: var(--lime); color: #183446; }
.option[aria-pressed="true"] small { color: #3c5160; }
.schritte { display: flex; gap: 5px; }
.schritte i { flex: 1; height: 4px; border-radius: 2px; background: var(--linie); }
.schritte i.an { background: var(--navy); }
.fehler { color: var(--rot); font-size: .9rem; }
.hinweis { background: var(--feld); border-radius: 12px; padding: 10px 12px; font-size: .88rem; color: var(--leise); }
:focus-visible { outline: 2px solid var(--lime-deep); outline-offset: 2px; }

/* Untere Leiste mit Mikrofon */
.leiste { position: fixed; left: 0; right: 0; bottom: 0; padding: 8px 16px calc(var(--unten) + 8px); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--linie); z-index: 10; }
.leiste nav { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; }
.leiste a { text-decoration: none; color: var(--leise); font-size: .75rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.leiste a.aktiv { color: var(--text); font-weight: 600; }
.mic { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--mic-bg); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 0 0 6px var(--bg), 0 8px 18px -6px rgba(14,34,48,.6); cursor: pointer; }
.mic svg { stroke: var(--mic-icon); }

/* Erfassen-Blatt */
.blatt { position: fixed; inset: 0; background: var(--bg); z-index: 20; overflow-y: auto; }
.blatt .seite { padding-bottom: calc(var(--unten) + 24px); }
.hoeren { display: grid; place-items: center; padding: 18px 0 6px; }
.hoeren .mic { margin: 0; width: 84px; height: 84px; box-shadow: 0 0 0 10px rgba(221,232,185,.9), 0 0 0 22px rgba(221,232,185,.4); animation: puls 1.6s ease-in-out infinite; }
@keyframes puls { 50% { box-shadow: 0 0 0 14px rgba(221,232,185,.7), 0 0 0 30px rgba(221,232,185,.25); } }
@media (prefers-reduced-motion: reduce) { .hoeren .mic { animation: none; } .balken i { transition: none; } }
.transkript { font-size: 1.15rem; font-weight: 500; min-height: 3em; }
textarea.eingabe.gross-text { font-size: 1.1rem; min-height: 120px; resize: vertical; }
.posten { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--linie); align-items: center; }
.posten:first-child, .k + .posten { border-top: 0; }
.posten > span { min-width: 0; overflow-wrap: anywhere; }
.posten small { color: var(--leise); font-size: .8rem; }
.gramm { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.gramm input { width: 72px; text-align: right; padding: 8px; border-radius: 10px; border: 1.5px solid var(--linie); background: var(--feld); font-family: var(--mono); font-size: .95rem; }
.weg { border: 0; background: none; color: var(--leise); padding: 4px 6px; cursor: pointer; font-size: .85rem; }
.laden { display: flex; align-items: center; gap: 10px; color: var(--leise); }
.laden::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--linie); border-top-color: var(--navy); animation: dreh .8s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* Dialog */
.dialog-hg { position: fixed; inset: 0; background: rgba(14,34,48,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: var(--bg); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(var(--unten) + 18px); display: flex; flex-direction: column; gap: 12px; max-height: 85dvh; overflow-y: auto; }

/* Verlauf */
.diagramm svg { width: 100%; height: auto; display: block; }
.diagramm text { fill: var(--leise); font-family: var(--mono); font-size: 9px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--unten) + 96px); transform: translateX(-50%); background: #183446; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: .9rem; max-width: calc(100% - 32px); }
.quelle { font-size: .78rem; color: var(--leise); line-height: 1.5; }
.quelle a { color: inherit; }
#tag { display: flex; flex-direction: column; gap: 14px; }
