/* Leichtpunkt – mobil zuerst, iPhone-Safe-Areas, Hell/Dunkel nach Systemeinstellung */
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d2321;
  --muted: #6b7471;
  --line: #e7e5df;
  --accent: #14897a;
  --accent-ink: #ffffff;
  --accent-soft: #dff2ee;
  --zero: #4f9d3a;
  --zero-soft: #e6f3df;
  --warn: #d4533b;
  --warn-soft: #fbe6e1;
  --ring-bg: #e9e7e1;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --card: #1b1f22;
    --text: #eef1ef;
    --muted: #9aa3a0;
    --line: #2a3033;
    --accent: #2fb7a3;
    --accent-ink: #06231f;
    --accent-soft: #173a35;
    --zero: #7cc463;
    --zero-soft: #1f3319;
    --warn: #f07a62;
    --warn-soft: #3e211b;
    --ring-bg: #2a3033;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top);
  min-height: 100vh;
}
body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }

.page { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 0 4px; }
.good { color: var(--zero); }
.warn, .warn b { color: var(--warn); }

/* ---------- Karten, Listen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 12px 0; }
.card.list { padding: 4px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--text); width: 100%; background: none; border: 0; text-align: left; min-height: 56px; }
.row + .row { border-top: 1px solid var(--line); }
button.row { cursor: pointer; }
.row:active { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; flex: none; background: var(--accent-soft); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-weight: 700; color: var(--accent); text-transform: uppercase; }
.empty { color: var(--muted); text-align: center; padding: 18px 12px; margin: 0; }
.section-title { font-size: 15px; margin: 18px 4px 4px; }
.section-title small { color: var(--muted); font-weight: 400; }
.label { font-weight: 600; margin: 4px 0 8px; font-size: 14px; }
.hint { font-size: 13px; color: var(--warn); margin: 8px 0 0; }
.notice { display: block; background: var(--accent-soft); color: var(--text); font-size: 14px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin: 6px 0 0; }
.tag.zero { background: var(--zero-soft); color: var(--zero); }

.pts { flex: none; min-width: 44px; height: 32px; padding: 0 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: inline-flex; align-items: baseline; justify-content: center; gap: 1px; line-height: 32px; }
.pts small { font-size: 11px; font-weight: 600; }
.pts.zero { background: var(--zero-soft); color: var(--zero); }

/* ---------- Knöpfe ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; text-align: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--warn); border-color: var(--warn-soft); background: transparent; }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; margin: 10px 0; }
.btn:disabled { opacity: .55; }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; color: var(--accent); padding: 8px 16px 10px; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--text); cursor: pointer; flex: none; }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.on { color: #e6a700; }
.icon-btn.on svg { fill: currentColor; }
.icon-btn-space { width: 44px; flex: none; }

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; gap: 4px; margin: 0 -8px 4px; min-height: 52px; }
.topbar h1 { flex: 1; text-align: center; font-size: 17px; }

/* ---------- Formulare ---------- */
.form label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0; }
.form input:not([type=checkbox]), .form select, .form textarea, .amount input {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px;
}
.form input:focus, .form select:focus, .form textarea:focus, .amount input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.searchbar:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.form label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 15px; }
.form label.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 label { margin: 6px 0; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.inline-form label { margin: 0; }
.inline-form .btn { grid-column: 1 / -1; }
.preview { margin: 12px 0 4px; font-size: 15px; min-height: 1.4em; }

.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; padding: 0 6px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.page > .seg { margin: 4px 0 10px; }

.tabs { display: flex; gap: 6px; margin: 12px 0 0; overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 99px; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- Anmeldung ---------- */
.auth { padding-top: 8vh; }
.auth-logo { text-align: center; margin-bottom: 16px; }
.auth-logo img { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.auth-logo h1 { font-size: 28px; margin-top: 12px; }
.auth-logo p { color: var(--muted); margin: 4px 0 0; }

/* ---------- Heute ---------- */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px; min-height: 52px; }
.daytitle { position: relative; font-weight: 700; font-size: 18px; padding: 8px 12px; }
.daytitle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.summary { display: flex; gap: 16px; align-items: center; }
.ring-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.ring { width: 132px; height: 132px; }
.ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: var(--ring-bg); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring.over .ring-fg { stroke: var(--warn); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 40px; line-height: 1; }
.ring-text span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.summary-facts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.summary-facts div { display: flex; flex-direction: column; }
.summary-facts span { font-size: 12px; }
.summary-facts b { font-size: 16px; }
.summary-facts .hint { margin: 0; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 4px 0 8px; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-radius: 12px; color: var(--muted); font-size: 12px; }
.wday.sel { background: var(--card); box-shadow: var(--shadow); color: var(--text); }
.wday.today span:first-child { color: var(--accent); font-weight: 700; }
.wbar { width: 8px; height: 30px; border-radius: 99px; background: var(--ring-bg); display: flex; align-items: flex-end; overflow: hidden; }
.wbar i { display: block; width: 100%; background: var(--accent); border-radius: 99px; }
.wday.over .wbar i { background: var(--warn); }
.wday b { font-size: 11px; min-height: 14px; color: var(--text); }

.meal { padding: 6px 0; }
.meal-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 16px; }
.meal-head h2 { font-size: 16px; }
.meal-head .muted { flex: 1; font-size: 13px; }
.meal-head .add { color: var(--accent); }
.meal .row { min-height: 52px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

/* ---------- Suchen ---------- */
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 4px 4px 4px 12px; box-shadow: var(--shadow); position: sticky; top: calc(env(safe-area-inset-top) + 4px); z-index: 5; }
.searchbar > svg { color: var(--muted); width: 20px; height: 20px; flex: none; }
.searchbar input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; font-size: 16px; outline: none; }
.scan-mini { width: 44px; height: 44px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.add-more { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Lebensmittel ---------- */
.food-head { display: flex; gap: 14px; align-items: center; margin: 4px 0 4px; }
.food-head h2 { font-size: 20px; }
.food-head p { margin: 4px 0 0; }
.food-img { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; background: #fff; flex: none; }
.amount-card { text-align: center; }
.big-points { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
.big-points b { font-size: 52px; line-height: 1; color: var(--accent); }
.big-points span { font-size: 13px; color: var(--muted); }
.big-points small { color: var(--muted); margin-top: 4px; font-size: 13px; }
.amount { display: flex; gap: 10px; align-items: center; }
.amount input { margin: 0; font-size: 22px; font-weight: 700; text-align: center; flex: 1; }
.amount .seg { flex: none; }
.unit-fixed { color: var(--muted); font-weight: 600; flex: none; }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.nutr table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nutr th { text-align: right; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 0; }
.nutr td { padding: 6px 0; border-top: 1px solid var(--line); text-align: right; }
.nutr td:first-child { text-align: left; }
.nutr tr.sub td:first-child { padding-left: 14px; color: var(--muted); }
.actions { margin: 4px 0; }

/* ---------- Rezepte ---------- */
.summary-small { display: flex; flex-direction: column; gap: 2px; }
.summary-small b { font-size: 24px; color: var(--accent); }
.row.item .grams { width: 74px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-align: right; font-size: 16px; }

.recipe-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); display: block; margin: 4px 0 0; background: var(--card); }
.import-row { display: flex; gap: 8px; }
.import-row input { flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; }
.import-row .btn { flex: none; }
.import .btn.block { margin: 8px 0 0; }
button.as-link { background: none; border: 0; padding: 0; text-align: left; color: inherit; cursor: pointer; font: inherit; }
.row-title small { font-weight: 400; }
.row.item.open .row-title { white-space: normal; font-weight: 500; }
.btn.small-btn { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.steps ol { margin: 4px 0; padding-left: 22px; }
.steps li { margin: 8px 0; line-height: 1.45; }
.steps summary { font-weight: 600; }
details.ignored { padding: 10px 0; }
details.ignored summary { padding: 0 16px; color: var(--muted); }
pre.prompt { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--bg); padding: 10px; border-radius: 10px; max-height: 280px; overflow: auto; }
.form textarea { resize: vertical; }

/* ---------- Bewegung ---------- */
.pts.plus { background: var(--zero-soft); color: var(--zero); }
.meal.activity .link { display: block; }
.summary-facts small { font-size: 11px; display: block; }
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0; }
.act-tile { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 12px; color: var(--text); font-weight: 600; font-size: 14px; min-height: 58px; line-height: 1.25; }
.act-icon { font-size: 24px; flex: none; }
.seg.stack { flex-direction: column; }
.seg.stack button { text-align: left; padding: 10px 12px; min-height: 44px; }
.seg.disabled { opacity: .45; pointer-events: none; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); cursor: pointer; }
.choice small { color: var(--muted); font-size: 13px; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- Gewicht / Profil ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.budget .stats b { color: var(--accent); font-size: 28px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 10px; fill: var(--muted); stroke: none; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 1.5; }
.chart .goal { stroke: var(--zero); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .goal-t { fill: var(--zero); }
details.card summary { font-weight: 600; cursor: pointer; padding: 2px 0; }
details.card p { font-size: 14px; color: var(--muted); }
.ios-share { font-weight: 600; }

/* ---------- Scanner ---------- */
.scan { position: fixed; inset: 0; background: #000; color: #fff; z-index: 50; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-frame i { width: min(80vw, 380px); height: min(32vw, 160px); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); border: 3px solid rgba(255, 255, 255, .9); position: relative; }
.scan-frame i::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff5a4f; box-shadow: 0 0 8px #ff5a4f; animation: scanline 1.6s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-34px); } 50% { transform: translateY(34px); } }
.scan-top { position: absolute; top: env(safe-area-inset-top); left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px; }
.scan-top span { flex: 1; text-align: center; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); font-size: 15px; }
.icon-btn.light { color: #fff; background: rgba(0, 0, 0, .35); }
.icon-btn.light.on { background: #fff; color: #000; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; padding: 12px; border-radius: 12px; border: 0; font-size: 16px; color: #000; background: #fff; }
.btn.light { color: #fff; border-color: rgba(255, 255, 255, .5); }

/* ---------- Tableiste ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: center; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 0; }
.tabbar a.active { color: var(--accent); }
.tabbar .tab-scan { flex: none; width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); justify-content: center; margin-top: -22px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.tabbar .tab-scan svg { width: 28px; height: 28px; }

/* ---------- Toast, Laden ---------- */
.toast { pointer-events: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .2); }
.toast.error { background: var(--warn); color: #fff; }
.loading { display: grid; place-items: center; min-height: 50vh; }
.loading.small { min-height: 80px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ring-bg); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
  .summary { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
