/* ==========================================================================
   Gramm – Kalorien- und Nährstoff-Tracker
   Layout: Ein-Hand-App, Inhalte oben, Bedienung unten (Tab-Leiste + Scan-Knopf)
   ========================================================================== */
:root {
  /* Dunkel ist die Grundgestaltung */
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1f232b;
  --surface-3: #2a2f39;
  --line: #2b303a;
  --text: #eceef2;
  --muted: #9aa1ae;
  --faint: #6c7381;
  --accent: #ff6a3d;        /* Scanner-Laser */
  --accent-ink: #1b0b05;
  --accent-soft: rgba(255, 106, 61, .14);
  --prot: #5bb8ff;
  --carb: #ffc24a;
  --fat: #b58cff;
  --fiber: #4fd1a5;
  --good: #3fd68f;
  --warn: #ffb547;
  --bad: #ff5872;
  --good-soft: rgba(63, 214, 143, .13);
  --warn-soft: rgba(255, 181, 71, .13);
  --bad-soft: rgba(255, 88, 114, .14);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 16px;
  --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --tabbar-h: 58px;
  --gutter: 16px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f3f5; --surface: #ffffff; --surface-2: #eceef2; --surface-3: #e0e3e9; --line: #dde0e6;
    --text: #15171c; --muted: #5a616e; --faint: #8b919c;
    --accent: #e4532a; --accent-ink: #ffffff; --accent-soft: rgba(228, 83, 42, .10);
    --prot: #1a84d6; --carb: #c48500; --fat: #8155e6;
    --fiber: #119770; --good: #13a061; --warn: #c27700; --bad: #d72f4e;
    --good-soft: rgba(19, 160, 97, .10); --warn-soft: rgba(194, 119, 0, .10); --bad-soft: rgba(215, 47, 78, .09);
    --shadow: 0 10px 30px rgba(20, 24, 33, .16);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f3f5; --surface: #ffffff; --surface-2: #eceef2; --surface-3: #e0e3e9; --line: #dde0e6;
  --text: #15171c; --muted: #5a616e; --faint: #8b919c;
  --accent: #e4532a; --accent-ink: #ffffff; --accent-soft: rgba(228, 83, 42, .10);
  --prot: #1a84d6; --carb: #c48500; --fat: #8155e6;
  --fiber: #119770; --good: #13a061; --warn: #c27700; --bad: #d72f4e;
  --good-soft: rgba(19, 160, 97, .10); --warn-soft: rgba(194, 119, 0, .10); --bad-soft: rgba(215, 47, 78, .09);
  --shadow: 0 10px 30px rgba(20, 24, 33, .16);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.s { width: 18px; height: 18px; }
.i.l { width: 26px; height: 26px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Grundgerüst ---------- */
#app { min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(var(--gutter), env(safe-area-inset-right, 0px)) 8px max(var(--gutter), env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.datenav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.datenav .label { flex: 1; min-width: 0; text-align: center; background: none; border: 0; padding: 6px 4px; border-radius: 10px; }
.datenav .label strong { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.datenav .label span { display: block; font-size: 12px; color: var(--muted); }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--text); }
.iconbtn:active { background: var(--surface-2); }

main#view {
  padding: 4px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 96px) max(var(--gutter), env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
  max-width: 640px; margin: 0 auto;
}

/* ---------- Tab-Leiste ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar button {
  border: 0; background: none; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 4px 0; min-height: 46px;
}
.tabbar button[aria-current="page"] { color: var(--text); }
.tabbar button[aria-current="page"] .i { color: var(--accent); }

/* ---------- Scan-Knopf ---------- */
.fab {
  position: fixed; z-index: 31; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  display: flex; align-items: stretch;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent), var(--shadow);
  overflow: hidden;
}
.fab button { border: 0; background: none; color: inherit; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.fab .scan { padding: 14px 20px 14px 18px; }
.fab .more { padding: 14px 16px; border-left: 1px solid color-mix(in srgb, var(--accent-ink) 22%, transparent); }
.fab button:active { background: color-mix(in srgb, var(--accent-ink) 12%, transparent); }

/* ---------- Karten & Grundbausteine ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.card.flat { background: transparent; padding: 0; }
.card h3, .section-title { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.section-title { margin: 8px 2px 2px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 650; font-size: 16px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.linkbtn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.chip .num { font-weight: 700; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); letter-spacing: .02em; }
.badge.off { color: #e5a400; background: rgba(229, 164, 0, .12); }
.badge.bls { color: var(--prot); background: color-mix(in srgb, var(--prot) 14%, transparent); }
.badge.own { color: var(--good); background: var(--good-soft); }
.badge.recipe { color: var(--fat); background: color-mix(in srgb, var(--fat) 14%, transparent); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); }
.notice .i { margin-top: 1px; }
.notice.warn { background: var(--warn-soft); color: var(--text); }
.notice.warn .i { color: var(--warn); }
.notice.bad { background: var(--bad-soft); }
.notice.bad .i { color: var(--bad); }
.notice.good { background: var(--good-soft); }
.notice.good .i { color: var(--good); }
.notice.accent { background: var(--accent-soft); }
.notice.accent .i { color: var(--accent); }
.notice p { margin: 0; }
.notice .actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Heute: Energie-Lineal ---------- */
.hero { padding: 18px 16px 16px; }
.hero .big { display: flex; align-items: baseline; gap: 8px; }
.hero .big .value { font-family: var(--font-num); font-size: 52px; line-height: 1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero .big .unit { font-size: 15px; color: var(--muted); font-weight: 600; }
.hero .big.over .value { color: var(--bad); }
.hero .sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.ruler { position: relative; margin-top: 16px; height: 34px; }
.ruler .track { position: absolute; left: 0; right: 0; top: 6px; height: 12px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.ruler .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 6px; transition: width .35s ease; }
.ruler .over { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--bad) 0 6px, color-mix(in srgb, var(--bad) 60%, transparent) 6px 12px); }
.ruler .ticks { position: absolute; left: 0; right: 0; top: 21px; height: 8px; }
.ruler .ticks i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--faint); opacity: .6; }
.ruler .ticks i.major { height: 8px; opacity: 1; }
.ruler .goalmark { position: absolute; top: 0; width: 2px; height: 24px; background: var(--text); border-radius: 1px; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.macro { min-width: 0; }
.macro .top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.macro .name { font-size: 13px; font-weight: 650; color: var(--muted); }
.macro .val { font-family: var(--font-num); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.macro .goal { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; position: relative; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--muted); transition: width .35s ease; }
.macro.prot .bar > span { background: var(--prot); }
.macro.carb .bar > span { background: var(--carb); }
.macro.fat .bar > span { background: var(--fat); }
.macro .rest { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.macro .rest.over { color: var(--bad); }

.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 0; border-radius: 14px; padding: 10px 12px; text-align: left; min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-family: var(--font-num); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Mahlzeiten */
.meal { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.meal-head { display: flex; align-items: center; gap: 10px; padding: 12px 8px 12px 16px; }
.meal-head .title { font-weight: 700; font-size: 16px; }
.meal-head .sum { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meal-head .add { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); }
.entry { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.entry:active { background: var(--surface-2); }
.entry .name { font-weight: 600; font-size: 15px; }
.entry .detail { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry .kcal { font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; font-size: 14px; }

/* ---------- Listen ---------- */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; background: none; border: 0; text-align: left; min-height: 52px; }
button.li:active, .li.tap:active { background: var(--surface-2); }
.li .title { font-weight: 600; }
.li .sub { font-size: 13px; color: var(--muted); }
.li .end { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.li .chev { color: var(--faint); }

/* Suchergebnisse */
.result { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 0; }
.result .open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 11px 6px 11px 16px; background: none; border: 0; text-align: left; }
.result .open:active { background: var(--surface-2); }
.result .meta { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); min-width: 0; }
.result .quick { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; flex: none; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 650; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); }
.input.num { text-align: right; }
.inputwrap { position: relative; display: flex; align-items: center; }
.inputwrap .input { padding-right: 52px; }
.inputwrap .suffix { position: absolute; right: 12px; color: var(--muted); font-size: 14px; pointer-events: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formrow { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.formrow:first-child { border-top: 0; }
.formrow.indent > span { padding-left: 14px; color: var(--muted); }
.formrow .inputwrap .input { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
details.more { background: var(--surface-2); border-radius: 12px; padding: 0 12px; }
details.more > summary { padding: 13px 0; font-weight: 650; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { border-bottom: 1px solid var(--line); }
details.more .content { padding: 6px 0 12px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Sheets (von unten) ---------- */
#sheets { position: relative; z-index: 50; }
.sheet-wrap { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); animation: fade .2s ease; }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100% - env(safe-area-inset-top, 0px) - 12px);
  background: var(--bg); border-radius: 20px 20px 0 0; display: flex; flex-direction: column;
  animation: up .26s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow);
}
.sheet.full { height: calc(100% - env(safe-area-inset-top, 0px) - 12px); }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; text-align: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .spacer { min-width: 40px; display: flex; justify-content: flex-end; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; flex: 1; }
.sheet-foot { padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); background: var(--bg); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
.sheet-wrap.closing .sheet { animation: down .2s ease forwards; }
.sheet-wrap.closing .sheet-backdrop { animation: fadeout .2s ease forwards; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }

/* Lebensmittel-Detail */
.food-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.food-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 4px; }
.amount { display: flex; align-items: center; gap: 8px; }
.amount .input { font-family: var(--font-num); font-size: 26px; font-weight: 700; text-align: center; min-height: 58px; }
.amount .step { width: 52px; height: 58px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 22px; font-weight: 600; flex: none; }
.preview { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 6px; }
.preview > div { background: var(--surface); border-radius: 12px; padding: 10px; text-align: center; min-width: 0; }
.preview .v { font-family: var(--font-num); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.preview .k { font-size: 11px; color: var(--muted); font-weight: 650; }
.preview .p .v { color: var(--prot); } .preview .c .v { color: var(--carb); } .preview .f .v { color: var(--fat); }
table.nutr { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.nutr td { padding: 7px 0; border-top: 1px solid var(--line); }
table.nutr td:last-child { text-align: right; }
table.nutr tr.sub td:first-child { padding-left: 14px; color: var(--muted); }

/* ---------- Mikros ---------- */
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 11px 16px; align-items: center; width: 100%; background: none; border: 0; text-align: left; }
.mrow:active { background: var(--surface-2); }
.mrow .name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.mrow .vals { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.mrow .pct { font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; }
.mrow .bar { grid-column: 1 / -1; margin-top: 2px; }
.mrow .bar .ul { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); }
.lvl-good .pct { color: var(--good); } .lvl-good .bar > span { background: var(--good); }
.lvl-mid .pct { color: var(--warn); } .lvl-mid .bar > span { background: var(--warn); }
.lvl-low .pct { color: var(--bad); } .lvl-low .bar > span { background: var(--bad); }
.lvl-none .pct { color: var(--faint); } .lvl-none .bar > span { background: var(--faint); }
.lvl-over .pct { color: var(--bad); } .lvl-over .bar > span { background: repeating-linear-gradient(135deg, var(--bad) 0 5px, color-mix(in srgb, var(--bad) 55%, transparent) 5px 10px); }

.meter { display: flex; align-items: center; gap: 14px; }
.meter .ring { width: 64px; height: 64px; flex: none; }
.meter .ring circle { fill: none; stroke-width: 7; }
.meter .ring .bg { stroke: var(--surface-3); }
.meter .ring .fg { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }

/* ---------- Supplemente ---------- */
.supp { display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%; border: 0; background: none; text-align: left; min-height: 64px; }
.supp:active { background: var(--surface-2); }
.check { width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--surface-3); display: grid; place-items: center; flex: none; transition: all .15s; color: transparent; }
.supp.done .check { background: var(--good); border-color: var(--good); color: #062915; }
.supp.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.supp .title { font-weight: 650; }
.supp .sub { font-size: 13px; color: var(--muted); }
.progress-big { display: flex; align-items: baseline; gap: 8px; }
.progress-big .value { font-family: var(--font-num); font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Woche ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar-ok { fill: var(--accent); }
.chart .bar-over { fill: var(--bad); }
.chart .bar-none { fill: var(--surface-3); }
.chart .goal { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .wline { fill: none; stroke: var(--prot); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .warea { fill: color-mix(in srgb, var(--prot) 16%, transparent); }
.chart .wdot { fill: var(--prot); }
.avgtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.avgtable td { padding: 8px 0; border-top: 1px solid var(--line); }
.avgtable td:nth-child(2), .avgtable td:nth-child(3) { text-align: right; }
.avgtable td:nth-child(3) { color: var(--muted); width: 32%; }

/* ---------- Scanner ---------- */
.scanner { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; flex-direction: column; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .shade { position: absolute; inset: 0; pointer-events: none; }
.scanner .frame {
  position: absolute; left: 7%; right: 7%; top: 50%; height: 30%; transform: translateY(-58%);
  border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .52); pointer-events: none;
}
.scanner .frame::before, .scanner .frame::after { content: ""; position: absolute; inset: 0; border-radius: 18px; border: 3px solid rgba(255,255,255,.9); clip-path: polygon(0 0, 22% 0, 22% 3px, 3px 3px, 3px 30%, 0 30%, 0 70%, 3px 70%, 3px calc(100% - 3px), 22% calc(100% - 3px), 22% 100%, 0 100%); }
.scanner .frame::after { transform: scaleX(-1); }
.scanner .laser { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff4b2b; box-shadow: 0 0 12px 2px rgba(255, 75, 43, .85); animation: laser 1.8s ease-in-out infinite; }
@keyframes laser { 0%, 100% { transform: translateY(-34px); opacity: .9; } 50% { transform: translateY(34px); opacity: 1; } }
.scanner .top { position: relative; display: flex; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; }
.scanner .roundbtn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.scanner .roundbtn.on { background: #fff; color: #000; }
.scanner .bottom { position: relative; margin-top: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; background: linear-gradient(transparent, rgba(0,0,0,.75) 30%); }
.scanner .hint { text-align: center; font-weight: 650; font-size: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.6); margin: 0; }
.scanner .status { text-align: center; font-size: 14px; color: rgba(255,255,255,.8); min-height: 20px; margin: 0; }
.scanner .manual { display: flex; gap: 8px; }
.scanner .manual .input { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.18); color: #fff; }
.scanner .manual .input::placeholder { color: rgba(255,255,255,.55); }
.scanner .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.18); color: #fff; }
.scanner .btn.primary { background: var(--accent); color: var(--accent-ink); }
.scanner .nocam { position: relative; margin: auto 24px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 84px); z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); pointer-events: auto; animation: toastin .2s ease; }
.toast.bad { background: var(--bad); color: #fff; }
.toast button { margin-left: auto; border: 0; background: none; color: var(--accent); font-weight: 800; padding: 4px 2px; }
.toast.bad button { color: #fff; text-decoration: underline; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.prose { font-size: 15px; line-height: 1.5; }
.prose p { margin: 0 0 10px; }
.prose ol, .prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.src { font-size: 12px; color: var(--faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 640px; border-radius: 18px 18px 0 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.sheet-body > div:empty { display: none; }
.badge.ai { color: var(--accent); background: var(--accent-soft); }

/* ---------- Assistent ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.bubble.bot { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 5px; }
.bubble.pending { align-self: stretch; max-width: none; background: var(--accent-soft); }
.bubble .by { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.ai-actions { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ai-actions.undone .ai-action { opacity: .5; text-decoration: line-through; }
.ai-action { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; width: 100%; }
.ai-action .i { color: var(--good); margin-top: 2px; }
.chatbar { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.chatbar .input { flex: 1; min-height: 46px; max-height: 140px; resize: none; line-height: 1.35; }
.chatbar .btn { flex: 0 0 auto; }
.fab .ai { padding: 14px 16px; border-left: 1px solid color-mix(in srgb, var(--accent-ink) 22%, transparent); }
.daylist .li { min-height: 56px; }
.daylist .bar { width: 80px; margin: 0; }
.hit .meta { font-size: 13px; color: var(--muted); }
.chart .wraw { fill: var(--muted); opacity: .55; }
input[type="checkbox"] { accent-color: var(--accent); }

/* Hinweis als Knopf (z. B. „3 Lebensmittel erkannt") */
button.notice { font: inherit; color: inherit; cursor: pointer; align-items: center; }
button.notice:active { filter: brightness(.95); }
/* Lange Fenster: Listen (overflow:hidden) dürfen im Flex-Layout nicht zusammengedrückt werden */
.sheet-body > * { flex-shrink: 0; }

/* ---- Wasser/Koffein/Ausgaben-Kacheln ---------------------------------- */
.stat.split { position: relative; padding: 0; display: flex; }
.stat.split .main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 10px 12px; color: inherit; font: inherit; }
.stat.split .plus { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 9px; border: 0; background: var(--surface-2); color: var(--prot); display: grid; place-items: center; }
.stat.split .plus:active { transform: scale(.94); }

/* ---- Schnellleiste ------------------------------------------------------ */
.quickbar { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 calc(-1 * var(--gutter, 16px)); padding: 2px var(--gutter, 16px) 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.quickbar::-webkit-scrollbar { display: none; }
.qtile { flex: none; width: 132px; min-height: 76px; scroll-snap-align: start; background: var(--surface); border: 0; border-radius: 14px; padding: 10px 34px 10px 12px; text-align: left; position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; color: var(--text); }
.qtile:active { background: var(--surface-2); }
.qtile .qn { font-weight: 650; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qtile .qs { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qtile .qp { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }

/* ---- Wischen ------------------------------------------------------------ */
.swipe { position: relative; overflow: hidden; }
.swipe-bg { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 18px; font-weight: 700; font-size: 14px; border-top: 1px solid var(--line); opacity: 0; }
.swipe-bg span { display: flex; align-items: center; gap: 6px; }
.swipe-bg .l { color: var(--good); visibility: hidden; }
.swipe-bg .r { color: var(--bad); visibility: hidden; }
.swipe.right .swipe-bg { opacity: 1; background: var(--good-soft); } .swipe.right .swipe-bg .l { visibility: visible; }
.swipe.left .swipe-bg { opacity: 1; background: var(--bad-soft); } .swipe.left .swipe-bg .r { visibility: visible; }
.swipe.armed.left .swipe-bg { background: color-mix(in srgb, var(--bad) 30%, transparent); }
.swipe.armed.right .swipe-bg { background: color-mix(in srgb, var(--good) 30%, transparent); }
.swipe .entry { position: relative; background: var(--surface); transition: transform .18s ease; }
.swipe.dragging .entry { transition: none; }

/* ---- Kalender ----------------------------------------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal .d { min-height: 46px; border-radius: 10px; background: var(--surface-2); border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 14px; font-weight: 650; color: var(--text); padding: 2px; min-width: 0; font-variant-numeric: tabular-nums; }
.cal .d.blank { background: transparent; }
.cal .d.empty { background: transparent; color: var(--muted); }
.cal .d.both { background: var(--good-soft); }
.cal .d.one { background: var(--warn-soft); }
.cal .d.none { background: var(--bad-soft); }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d.future { opacity: .4; }
.cal .d .t { font-size: 9.5px; font-weight: 700; color: var(--prot); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.1; }
.cal .d .t.rest { color: var(--muted); }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-legend i.both { background: var(--good); } .cal-legend i.one { background: var(--warn); } .cal-legend i.none { background: var(--bad); }
#view { will-change: auto; }

/* Kein Zoom bei Doppeltipp (iOS); Eingabefelder mind. 16px, sonst zoomt Safari beim Antippen */
html, body, button, a, label, input, textarea, select, .entry, .qtile, .stat, .chip { touch-action: manipulation; }
input, textarea, select { font-size: max(16px, 1em); }

/* Mikros: Zielspanne und Obergrenze */
.lvl-high .pct { color: var(--prot); } .lvl-high .bar > span { background: var(--prot); }
.mrow .mstatus { display: block; flex-basis: 100%; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.mrow .name { flex-wrap: wrap; }
.lvl-high .mstatus { color: var(--prot); } .lvl-over .mstatus { color: var(--bad); } .lvl-mid .mstatus { color: var(--warn); }
.mrow .ulnote { font-size: 11px; color: var(--faint); }

/* Fortschrittsfotos */
.pcompare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pcompare figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.pcompare img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: var(--surface-2); display: block; }
.pcompare figcaption { font-size: 13px; color: var(--muted); text-align: center; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pthumb { position: relative; padding: 0; border: 0; background: var(--surface-2); border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; cursor: pointer; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb span { position: absolute; left: 4px; bottom: 4px; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; }

/* Kassenzettel */
.rbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.rbar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.rhist { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 140px; align-items: end; }
.rhist > div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.rhist .b { width: 100%; max-width: 36px; background: var(--surface-2); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.rhist .on .b { background: var(--accent); }
.rhist .v { font-size: 11px; color: var(--muted); }
.rhist .l { font-size: 12px; color: var(--muted); }
.rhist .on .l { color: var(--text); font-weight: 600; }

/* Verlauf: Suche als Symbol neben den Bereichen */
.iconbtn.on { background: var(--accent-soft); color: var(--accent); }

/* Kassenzettel-Ansicht (immer helles Papier) */
.bon { background: #fbfaf6; color: #222; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.45; padding: 20px 18px 18px; position: relative; margin: 14px 2px 18px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.bon::before, .bon::after { content: ''; position: absolute; left: 0; right: 0; height: 8px; background-repeat: repeat-x; background-size: 12px 8px; }
.bon::before { top: -8px; background-image: linear-gradient(135deg, transparent 50%, #fbfaf6 50%), linear-gradient(225deg, transparent 50%, #fbfaf6 50%); background-position: 0 0, 0 0; }
.bon::after { bottom: -8px; background-image: linear-gradient(45deg, transparent 50%, #fbfaf6 50%), linear-gradient(-45deg, transparent 50%, #fbfaf6 50%); transform: rotate(180deg); }
.bon-head { text-align: center; font-weight: 800; font-size: 17px; letter-spacing: .12em; }
.bon-sub { text-align: center; color: #666; font-size: 12px; margin-top: 2px; }
.bon-sep { border-top: 1px dashed #999; margin: 10px 0; }
.bon-line { display: flex; justify-content: space-between; gap: 12px; }
.bon-line span:first-child { min-width: 0; overflow-wrap: anywhere; }
.bon-line span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bon-line.bold { font-weight: 800; font-size: 15px; }
.bon-line.small { font-size: 12px; color: #555; }
.bon-note { font-size: 11px; color: #777; margin: -1px 0 3px 10px; }
.bon-foot { text-align: center; font-size: 11px; color: #888; margin-top: 12px; }

/* Relevanz-Punkte in der Nährstoff-Info */
.reldots { display: inline-flex; gap: 4px; }
.reldot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line, rgba(127,127,127,.3)); }
.reldot.on { background: var(--accent); border-color: var(--accent); }

/* Viele Mahlzeiten: Auswahl seitlich scrollbar */
.seg.many { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
.seg.many::-webkit-scrollbar { display: none; }
.seg.many button { flex: 0 0 auto; padding-left: 12px; padding-right: 12px; }

/* Alltag: Schlaf, Hunger, Schritte */
.bodyrow { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: var(--surface); color: inherit; font: inherit; font-size: 14px; border-radius: 14px; padding: 12px 14px; margin-top: 10px; text-align: left; cursor: pointer; }
.bodyrow .i { color: var(--accent); }
.accbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.accbar span { display: block; height: 100%; }
.accbar .a, .dot.a { background: var(--good); }
.accbar .b, .dot.b { background: var(--accent); }
.accbar .c, .dot.c { background: var(--warn); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* Nutri-Score & NOVA */
.nutri, .nova { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; }
.nutri.nA { background: #038141; } .nutri.nB { background: #85bb2f; } .nutri.nC { background: #e5a600; } .nutri.nD { background: #ee8100; } .nutri.nE { background: #e63e11; }
.nova { background: var(--surface-2); color: var(--text); } .nova.v4 { background: var(--warn-soft); }

/* Peptide: Einstichstellen */
.sitegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.site { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 1px solid var(--line, rgba(127,127,127,.25)); background: var(--surface-2); color: inherit; font: inherit; font-size: 13px; border-radius: 10px; padding: 8px 10px; text-align: left; cursor: pointer; }
.site small { color: var(--muted); font-size: 11px; }
.site.on { border-color: var(--accent); background: var(--accent-soft); }
