/* EnzyMate – Design-Tokens und Komponenten
   Schrift: SF Pro Rounded auf dem iPhone (ui-rounded). Plus Jakarta Sans wird genutzt,
   wenn sie lokal unter static/fonts liegt (kein Google-Fonts-Abruf → DSGVO-freundlich). */

:root {
  --bg: #F4F3F8;
  --card: #FFFFFF;
  --card-2: #F4F3F8;
  --line: #ECEAF2;
  --text: #1B1A24;
  --muted: #6B6879;
  --ink: #1B1A24;
  --on-ink: #FFFFFF;
  --green: #2E9E63;
  --green-ink: #2B7A4F;
  --peach: #9A3F12;   --peach-bg: #FDE6DA;
  --blue: #1F4E8C;    --blue-bg: #DCEAFB;
  --lav: #4B3A8F;     --lav-bg: #EAE4FC;
  --mint: #1E6B3A;    --mint-bg: #DDF3E4;
  --sand: #5C3A00;    --sand-bg: #FCE7C8;
  --demo: #6E4A00;    --demo-bg: #FFF1CC;
  --danger: #A3261C;  --danger-bg: #FCE3E0;
  --bar-ok: #7FCB9B;  --bar-bad: #C9BEF5; --bar-unknown: #E2E0EA;
  --shadow: 0 10px 30px rgba(40, 30, 80, .10);
  --r-xl: 28px; --r-lg: 24px; --r-md: 18px; --r-sm: 12px;
  --font: "Plus Jakarta Sans", ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121118; --card: #1C1B24; --card-2: #24232E; --line: #2D2B38;
    --text: #F2F1F7; --muted: #A4A1B3; --ink: #F2F1F7; --on-ink: #121118;
    --green: #2E9E63; --green-ink: #7BD6A2;
    --peach: #F6B994; --peach-bg: #3A251C;
    --blue: #A9C8F5;  --blue-bg: #1A2638;
    --lav: #C3B6F7;   --lav-bg: #272040;
    --mint: #96DDB0;  --mint-bg: #16291F;
    --sand: #F2CF8A;  --sand-bg: #33270F;
    --demo: #F2CF77;  --demo-bg: #3A2E10;
    --danger: #F3A39A; --danger-bg: #3A1A17;
    --bar-ok: #4FA673; --bar-bad: #8D7FD6; --bar-unknown: #34323F;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--green-ink); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 800; }
p { margin: 0; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 120px); }
.app--bare { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 800; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar__title { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--lav-bg); color: var(--lav);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--card); color: var(--text);
  display: grid; place-items: center; border: 0; position: relative; text-decoration: none; cursor: pointer; flex-shrink: 0; }
.icon-btn--ink { background: var(--ink); color: var(--on-ink); }
.icon-btn svg { width: 20px; height: 20px; }
.dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--green); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }

/* Labels */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; }
.badge--demo { background: var(--demo-bg); color: var(--demo); }
.badge--ok { background: var(--mint-bg); color: var(--mint); }
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 10px; white-space: nowrap; }
.chip--fat { background: var(--peach-bg); color: var(--peach); }
.chip--lac { background: var(--blue-bg); color: var(--blue); }
.chip--lip { background: var(--lav-bg); color: var(--lav); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Karten */
.card { background: var(--card); border-radius: var(--r-lg); padding: 18px; }
.card--flat { background: var(--card-2); }
.card--outline { background: transparent; border: 1px solid var(--line); }
.card--peach { background: var(--peach-bg); } .card--blue { background: var(--blue-bg); }
.card--lav { background: var(--lav-bg); } .card--mint { background: var(--mint-bg); } .card--sand { background: var(--sand-bg); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.section-head a { font-size: 14px; font-weight: 700; text-decoration: none; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* Woche */
.week { background: var(--card); border-radius: 26px; padding: 12px 6px; display: grid;
  grid-template-columns: 28px repeat(7, minmax(0, 1fr)) 28px; align-items: center; }
.week__day { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.week__wd { font-size: 12px; font-weight: 700; color: var(--muted); }
.week__n { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--line); }
.week__day.is-logged .week__n { border: 2.5px solid var(--green); }
.week__day.is-today .week__n { border-color: var(--green); }
.week__day.is-selected .week__n { background: var(--green); color: #fff; border-color: var(--green); }
.week__day.is-future { pointer-events: none; opacity: .5; }
.week__nav { display: grid; place-items: center; color: var(--muted); text-decoration: none; height: 38px; }
.week__nav svg { width: 16px; height: 16px; }

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { border-radius: 26px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.tile--tall { grid-row: span 2; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 18px; min-height: 220px; }
.tile__icon { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.85); display: grid; place-items: center; flex-shrink: 0; }
@media (prefers-color-scheme: dark) { .tile__icon { background: rgba(255,255,255,.10); } }
.tile--tall .tile__icon { width: 58px; height: 58px; }
.tile__label { font-size: 13px; font-weight: 700; }
.tile__value { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.tile--tall .tile__value { font-size: 34px; letter-spacing: -.03em; }
.tile--peach { background: var(--peach-bg); } .tile--peach .tile__label, .tile--peach .tile__sub { color: var(--peach); }
.tile--blue { background: var(--blue-bg); } .tile--blue .tile__label { color: var(--blue); }
.tile--lav { background: var(--lav-bg); } .tile--lav .tile__label { color: var(--lav); }
.tile__sub { font-size: 12px; font-weight: 600; }
.strip { border-radius: 22px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-decoration: none; color: var(--text); font-size: 14px; font-weight: 700; }
.strip--mint { background: var(--mint-bg); } .strip--mint .strip__label { color: var(--mint); }
.strip--blue { background: var(--blue-bg); } .strip--blue .strip__label { color: var(--blue); }

/* Mahlzeitenkarten */
.meal-card { background: var(--card); border-radius: 26px; padding: 14px; display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); }
.thumb { width: 72px; height: 72px; border-radius: 22px; flex-shrink: 0; overflow: hidden; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 54px; height: 54px; }
.thumb--main { background: var(--peach-bg); } .thumb--snack { background: var(--mint-bg); } .thumb--drink { background: var(--blue-bg); }
.meal-card__title { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-card__meta { font-size: 12px; font-weight: 600; color: var(--muted); }
.meal-card__meta--lav { color: var(--lav); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 22px;
  border-radius: 26px; border: 0; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer; text-decoration: none; width: 100%; }
.btn svg { width: 20px; height: 20px; }
.btn--ink { background: var(--ink); color: var(--on-ink); min-height: 58px; border-radius: 29px; }
.btn--green { background: var(--green); color: #fff; }
.btn--outline { background: transparent; color: var(--text); border: 1.5px solid var(--ink); }
.btn--soft { background: var(--card-2); color: var(--text); }
.btn--danger { background: var(--danger-bg); color: var(--danger); }
.btn--sm { min-height: 44px; font-size: 14px; padding: 0 16px; width: auto; border-radius: 22px; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--green-ink); font-weight: 700; cursor: pointer; text-decoration: underline; }

/* Scan-Button groß */
.scan-cta { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 28px; background: var(--green); color: #fff; text-decoration: none; }
.scan-cta__icon { width: 58px; height: 58px; border-radius: 20px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex-shrink: 0; }
.scan-cta__icon svg { width: 28px; height: 28px; }
.scan-cta__title { font-size: 20px; font-weight: 800; }
.scan-cta__sub { font-size: 14px; opacity: .9; }

/* Navigation */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: min(448px, calc(100% - 32px)); height: 72px; border-radius: 36px; background: var(--card); box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; padding: 0 6px; z-index: 20; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav a.is-active { color: var(--text); font-weight: 800; }
.nav svg { width: 22px; height: 22px; }
.nav .fab { width: 66px; height: 66px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center;
  margin-top: -40px; box-shadow: 0 10px 22px rgba(46,158,99,.38); border: 5px solid var(--bg); }
.nav .fab svg { width: 28px; height: 28px; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field__label { font-size: 14px; font-weight: 700; }
.field__help { font-size: 12px; color: var(--muted); }
.field__error { font-size: 13px; color: var(--danger); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=email], input[type=file], select, textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none;
}
textarea { min-height: 80px; }
select { background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--green); flex-shrink: 0; }
/* Auswahl-Chips (Radio/Checkbox-Listen) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices > div { display: contents; }
.choices label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 14px;
  background: var(--card-2); border: 1.5px solid var(--line); font-size: 14px; font-weight: 700; cursor: pointer; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label:has(input:checked) { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.choices label:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }
.choices--col { flex-direction: column; } .choices--col label { width: 100%; }
.choices--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices--grid label { justify-content: center; text-align: center; }

/* Meldungen */
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { border-radius: 16px; padding: 12px 14px; font-size: 14px; font-weight: 600; background: var(--mint-bg); color: var(--mint); }
.msg--error { background: var(--danger-bg); color: var(--danger); }
.msg--warning, .msg--info { background: var(--sand-bg); color: var(--sand); }
.hint { display: flex; gap: 12px; align-items: flex-start; border-radius: 20px; padding: 14px 16px; background: var(--card-2); font-size: 13px; color: var(--muted); }
.hint svg { width: 22px; height: 22px; flex-shrink: 0; }
.hint--sand { background: var(--sand-bg); color: var(--sand); }

/* Scan */
.hero { margin: calc(-18px - env(safe-area-inset-top)) -18px 0; height: 340px; background: var(--mint-bg); position: relative;
  display: grid; place-items: center; overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero__bar { position: absolute; top: calc(env(safe-area-inset-top) + 14px); left: 18px; right: 18px; display: flex; justify-content: space-between; }
.sheet { background: var(--card); border-radius: 30px 30px 0 0; margin: -24px -18px 0; padding: 24px 18px 8px; position: relative; display: flex; flex-direction: column; gap: 16px; min-height: 50vh; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); padding-top: 12px; }
.facts > div { display: flex; flex-direction: column; gap: 6px; }
.facts > div + div { border-left: 1px solid var(--line); padding-left: 12px; }
.facts__label { font-size: 12px; font-weight: 700; color: var(--muted); }
.facts__value { font-size: 14px; font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.stepper .facts__value { font-size: 13px; }
.stepper button { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; color: var(--text);
  font: inherit; font-weight: 800; cursor: pointer; padding: 0; }
.stepper button:disabled { opacity: .3; }
.range { display: flex; flex-direction: column; gap: 8px; }
.range__track { height: 10px; border-radius: 5px; background: var(--card-2); position: relative; overflow: hidden; }
.range__fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.range--fat .range__fill { background: #F2C089; } .range--lac .range__fill { background: #9DB8F2; }
.comp { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.comp + .comp { border-top: 1px solid rgba(75,58,143,.15); }
.comp__icon { width: 34px; height: 34px; border-radius: 12px; background: var(--card); display: grid; place-items: center; flex-shrink: 0; }
.comp__icon svg { width: 18px; height: 18px; }

/* Segment-Umschalter */
.segmented { background: var(--card-2); border-radius: 18px; padding: 4px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.segmented a { min-height: 44px; border-radius: 14px; display: grid; place-items: center; text-decoration: none; color: var(--text); font-size: 14px; font-weight: 600; }
.segmented a.is-active { background: var(--card); font-weight: 800; box-shadow: 0 2px 8px rgba(40,30,80,.10); }

/* Diagramme */
.bars { display: grid; gap: 6px; align-items: end; height: 150px; }
.bars__col { display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; height: 100%; }
.bars__stack { width: 100%; max-width: 28px; display: flex; flex-direction: column; gap: 3px; }
.bars__stack span { display: block; border-radius: 8px; }
.bars__label { font-size: 11px; font-weight: 700; color: var(--muted); height: 16px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; font-weight: 600; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.obs { display: flex; align-items: center; gap: 12px; border-radius: 18px; padding: 12px 14px; }

/* Tagebuch */
.day-head { font-size: 14px; font-weight: 800; color: var(--muted); padding: 6px 4px 0; }
.entry { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 20px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.entry__time { font-size: 13px; font-weight: 700; color: var(--muted); width: 44px; flex-shrink: 0; }
.entry__icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.entry__icon svg { width: 20px; height: 20px; }

/* Liste */
.list { background: var(--card); border-radius: var(--r-lg); overflow: hidden; }
.list > * { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--text); min-height: 56px; }
.list > * + * { border-top: 1px solid var(--line); }
.list svg.chev { width: 16px; height: 16px; color: var(--muted); margin-left: auto; flex-shrink: 0; }

/* Leerer Zustand */
.empty { text-align: center; padding: 28px 18px; color: var(--muted); font-size: 14px; }

/* Bericht (Druck) */
.report { background: #fff; color: #111; max-width: 800px; margin: 0 auto; padding: 32px; font-size: 13px; }
.report h1 { font-size: 22px; } .report h2 { font-size: 15px; margin-top: 20px; }
.report table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.report th, .report td { border-bottom: 1px solid #ddd; padding: 6px 4px; text-align: left; vertical-align: top; }
.report th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #555; }
@media print { .no-print { display: none !important; } body { background: #fff; } .report { padding: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .btn, .meal-card, .tile, .entry, .scan-cta { transition: transform .15s ease, opacity .15s ease; }
  .btn:active, .meal-card:active, .tile:active, .entry:active, .scan-cta:active { transform: scale(.98); }
}
